def get_items_acceptance(cls, acc_id, remain=True): from applications.point_sale.service import PointSaleService from applications.acceptance.service import AcceptanceService from applications.waybill.service import WayBillService acceptance = AcceptanceService.get_by_id(acc_id) pointsale = acceptance.pointsale def get_count_remain(remain, item, pointsale_id): if remain: return PointSaleService.item_to_pointsale_good( pointsale.id, item.good_id).count \ if PointSaleService.item_to_pointsale_good( pointsale.id, item.good_id) else "" else: return item.count if acceptance.invoice: return [{ "id": item.id, "full_name": item.full_name, "good_id": item.good_id, "price_without_NDS": item.price_without_NDS, "price_with_NDS": item.price_with_NDS, "price_retail": GoodService.get_price( item.good_id).price_retail if GoodService.get_price( item.good_id) else "", "price_gross": GoodService.get_price( item.good_id).price_gross if GoodService.get_price( item.good_id) else "", "count": get_count_remain(remain, item, pointsale.id), "fact_count": item.fact_count } for item in cls.get_items(invoice_id=acceptance.invoice_id)] elif acceptance.waybill_crud: return [{ "id": item.id, "full_name": item.good.full_name, "good_id": item.good_id, "price_retail": GoodService.get_price( item.good_id).price_retail if GoodService.get_price( item.good_id) else "", "price_gross": GoodService.get_price( item.good_id).price_gross if GoodService.get_price( item.good_id) else "", "count": get_count_remain(remain, item, pointsale.id), } for item in WayBillService.get_items(acceptance.waybill_id)]
def get_item_to_acceptance(cls, invoice_id, acceptance_id): from applications.point_sale.service import PointSaleService from applications.acceptance.service import AcceptanceService acceptance = AcceptanceService.get_by_id(acceptance_id) pointsale = acceptance.pointsale return [{ "id": item.id, "full_name": item.full_name, "good_id": item.good_id, "price_retail": GoodService.get_price( item.good_id).price_retail if GoodService.get_price( item.good_id) else "", "price_gross": GoodService.get_price( item.good_id).price_gross if GoodService.get_price( item.good_id) else "", "count": PointSaleService.item_to_pointsale_good( pointsale.id, item.good_id).count if PointSaleService.item_to_pointsale_good( pointsale.id, item.good_id) else "", } for item in cls.get_items(invoice_id=invoice_id)]