Beispiel #1
0
    def upgrade_items(cls, waybill, items, path_target=None, path=None):
        from applications.price.service import PriceService
        from applications.good.service import GoodService

        waybill.items.delete()
        db.session.add(waybill)

        for it in items:
            good = GoodService.get_good(it.good_id)
            if waybill.type == RETAIL:
                if not good.price_id or not PriceService.get_price(
                        good.price_id).price_retail:
                    raise WayBillServiceException(
                        u"Товар без розничной цены. %s" % good.full_name)

            else:
                if not good.price_id or not PriceService.get_price(
                        good.price_id).price_gross:
                    raise WayBillServiceException(
                        u"Товар без оптовой цены. %s" % good.full_name)

            if it.count and not WayBillService.check_count(
                    invoice_id=waybill.invoice_id, waybill_id=waybill.id,
                    good_id=it.good_id,
                    count=int(it.count)):
                raise WayBillServiceException(
                    u"Недостаточно товара %s" % good.full_name)

            retail_item = WayBillItems(
                good_id=good.id, waybill=waybill, count=it.count if it.count
                else None)
            db.session.add(retail_item)
Beispiel #2
0
    def upgrade_items(cls, waybillreturn, items):
        from applications.price.service import PriceService
        from applications.good.service import GoodService

        waybillreturn.items.delete()
        db.session.add(waybillreturn)

        for it in items:
            good = GoodService.get_good(it.good_id)
            if waybillreturn.type == RETAIL:
                if not good.price_id or not PriceService.get_price(
                        good.price_id).price_retail:
                    raise WayBillReturnService.WayBillReturnServiceExc(
                        u"Товар без розничной цены. %s" % good.full_name)

            else:
                if not good.price_id or not PriceService.get_price(
                        good.price_id).price_gross:
                    raise WayBillReturnService.WayBillReturnServiceExc(
                        u"Товар без оптовой цены. %s" % good.full_name)

            it.waybill = waybillreturn
            db.session.add(it)
Beispiel #3
0
 def get_price(cls, good_id):
     from applications.price.service import PriceService
     good = cls.get_good(good_id)
     if good.price_id:
         return PriceService.get_price(good.price_id)