Beispiel #1
0
 def update_fact_count_custom(cls, acceptance, items):
     debug(u"Обновление фактического кол-ва по новой `прихода` id = '%s' "
           u"начато." % acceptance.id)
     from services.mailinvoice import InvoiceService
     from applications.good.service import GoodService
     invoice = acceptance.invoices[0]
     acceptance.items.delete()
     invoice.items.delete()
     for item in items:
         good_id = item[GOOD_OBJ_ATTR][GOOD_ID_ATTR]
         fact_count = item[COUNT_ATTR]
         price_post = item[PRICE_POST_ATTR]
         price_retail = item[PRICE_RETAIL_ATTR]
         price_gross = item[PRICE_GROSS_ATTR]
         good = GoodService.get_good(good_id)
         InvoiceService.handle_invoiceitem(
             invoice=invoice, good=good, fact_count=fact_count,
             price_with_NDS=price_post, full_name=None, name=None,
             number_local=None, number_global=None, count_order=None,
             count_postorder=None, count=fact_count,
             price_without_NDS=None, sum_NDS=None, sum_with_NDS=None,
             thematic=None, count_whole_pack=None, placer=None,
             rate_NDS=None, sum_without_NDS=None, price_retail=price_retail,
             price_gross=price_gross)
         ac_it = AcceptanceItems()
         ac_it.good_id = good_id
         ac_it.acceptance = acceptance
         ac_it.count = fact_count
         ac_it.fact_count = fact_count
         db.session.add(ac_it)
     debug(u"Обновление фактического кол-ва по новой `прихода` id = '%s' "
           u"завершено." % acceptance.id)
Beispiel #2
0
    def initial_acceptance_from_mail(cls, acceptance):
        debug(u"Инициализация по почте `прихода` id = '%s' начата."
              % acceptance.id)
        invoices = acceptance.invoices
        debug(u"Удаляем позиции прихода id = '%s'." % acceptance.id)
        acceptance.items.delete()

        for invoice in invoices:
            items = invoice.items.order_by(asc(InvoiceItem.id))
            debug(u"Создаем новые позиции прихода id = '%s' из накладной."
                  % acceptance.id)
            for item in items:
                ac_it = AcceptanceItems()
                ac_it.good_id = item.good_id
                ac_it.acceptance = acceptance
                ac_it.count = item.count
                db.session.add(ac_it)
        debug(u"Инициализация по почте `прихода` id = '%s' завершена."
              % acceptance.id)