def handle_orderitem(cls, full_name, name, number_local, number_global, date, remission, NDS, price_prev, price_post, order): from applications.good.service import GoodService from applications.commodity.service import CommodityService item = OrderItem() item.full_name = full_name, item.name = name item.number_local = number_local item.number_global = number_global item.date = date item.remission = remission item.NDS = float(NDS.replace("%", "").strip()) item.price_prev = price_prev if price_prev else 0.0 item.price_post = price_post if price_post else 0.0 item.order = order res, comm = CommodityService.get_or_create_commodity( name=name) if res is False: if not number_local and not number_global: comm.numeric = False db.session.add(comm) db.session.flush() res, good = GoodService.get_or_create_commodity_numbers( comm.id, number_local, number_global) good.commodity = comm good.full_name = full_name item.good = good db.session.add(good) db.session.add(item)
def handle_returnitem(cls, full_name, name, number_local, number_global, date, date_to, price_without_NDS, price_with_NDS, remission, count_delivery, count_rem, return_inst): from applications.commodity.service import CommodityService from applications.good.service import GoodService item = ReturnItem() item.full_name = full_name item.name = name item.number_local = number_local item.number_global = number_global item.date = date item.date_to = date_to item.price_without_NDS = price_without_NDS item.price_with_NDS = price_with_NDS item.remission = remission item.count_delivery = count_delivery item.count_rem = count_rem item.return_item = return_inst res, comm = CommodityService.get_or_create_commodity( name=name) if res is False: if not number_local and not number_global: comm.numeric = False db.session.add(comm) db.session.flush() try: res, good = GoodService.get_or_create_commodity_numbers( comm.id, number_local, number_global) except GoodArgumentExc as exc: error(u"При обработке позиций возврата возникла " u"ошибка. " + unicode(exc)) raise good.commodity = comm good.full_name = full_name item.good = good db.session.add(good) db.session.add(item)
def handle_invoiceitem( cls, full_name, name, number_local, number_global, invoice, count_order, count_postorder, count, price_without_NDS, price_with_NDS, sum_without_NDS, sum_NDS, rate_NDS, sum_with_NDS, thematic, count_whole_pack, placer, good=None, fact_count=None, price_retail=None, price_gross=None): """ Обработка позиции накладной. Сохраняем в БД позицию. Создаем товар в системе. """ from applications.commodity.service import CommodityService invitem = InvoiceItem() invitem.full_name = full_name invitem.count_order = count_order invitem.count_postorder = count_postorder invitem.count = count invitem.price_without_NDS = price_without_NDS invitem.price_with_NDS = price_with_NDS invitem.sum_without_NDS = sum_without_NDS invitem.sum_with_NDS = sum_with_NDS invitem.sum_NDS = sum_NDS invitem.rate_NDS = rate_NDS invitem.count_whole_pack = count_whole_pack invitem.placer = placer invitem.invoice = invoice invitem.price_gross = price_gross invitem.price_retail = price_retail if good: invitem.good = good invitem.name = good.commodity.name invitem.number_local = good.number_local invitem.number_global = good.number_global invitem.thematic=good.commodity.thematic if fact_count: invitem.fact_count = fact_count else: invitem.name=name invitem.number_local=number_local invitem.number_global=number_global invitem.thematic=thematic res, comm = CommodityService.get_or_create_commodity( name=name, thematic=thematic) if res is False: if not number_local and not number_global: comm.numeric = False db.session.add(comm) db.session.flush() try: res, good = GoodService.get_or_create_commodity_numbers( comm.id, number_local, number_global) except GoodArgumentExc as exc: error(u"При обработке позиций накладной возникла ошибка. " + unicode(exc)) raise good.commodity = comm good.full_name = full_name invitem.good = good db.session.add(good) db.session.add(invitem)