Пример #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)
Пример #2
0
    def handle(self, provider, mail):
        from services.mailinvoice import InvoiceService
        from db import db
        invmodel = InvoiceService.create_invoice(
            number=self.number, date=self.date, provider=provider,
            sum_without_NDS=self.sum_without_NDS, sum_with_NDS=self.sum_with_NDS,
            sum_NDS=self.sum_NDS, weight=self.weight, responsible=self.responsible)
        products = self.get_products()

        mail.invoice = invmodel

        db.session.add(mail)

        for product in products:
            InvoiceService.handle_invoiceitem(
                full_name=product.full_name, name=product.name, number_local=product.number_local,
                number_global=product.number_global,
                count_order=product.count_order, count_postorder=product.count_postorder,
                count=product.count, price_without_NDS=product.price_without_NDS,
                price_with_NDS=product.price_with_NDS, sum_without_NDS=product.sum_without_NDS,
                sum_NDS=product.sum_NDS, rate_NDS=product.rate_NDS, sum_with_NDS=product.sum_with_NDS,
                thematic=product.thematic, count_whole_pack=product.count_whole_pack,
                placer=product.placer, invoice=invmodel)