コード例 #1
0
ファイル: resource.py プロジェクト: StasEvseev/adminbuy
    def post(self, id):
        try:
            inventory = WayBillReturnService.get_by_id(id)
            status = request.json['data']['status']
            WayBillReturnService.status(inventory, status)
            db.session.add(inventory)
            db.session.commit()

            return inventory
        except Exception as exc:
            message = u" Не удалось сменить статус `накладной " \
                      u"возврата` %s." % id
            error(message + unicode(exc))
            abort(400, message=message)
コード例 #2
0
ファイル: resource.py プロジェクト: StasEvseev/adminbuy
    def save_model(self, obj):
        try:
            if not obj.id:
                waybill = WayBillReturnService.create(
                    obj.pointsale_id, obj.receiver_id, obj.date, obj.date_to,
                    obj.type, obj.typeRec, obj.returninst_id)
            else:
                super(WayBillReturnCanon, self).save_model(obj)
                waybill = obj
            if obj.waybill_items:
                try:
                    items = WayBillReturnService.build_retail_items(
                        obj.waybill_items)
                except Exception as exc:
                    debug(u"Ошибка сохранения накладной %s. " + unicode(
                        exc) % obj)
                    raise WayBillReturnCanon.WayBillCanonException(unicode(exc))
                WayBillReturnService.upgrade_items(waybill, items)
        except WayBillReturnService.WayBillReturnServiceExc as exc:
            debug(u"Сохранение накладной %s не удалось." % obj)
            raise WayBillReturnCanon.WayBillCanonException(unicode(exc))

        return waybill
コード例 #3
0
ファイル: resource.py プロジェクト: StasEvseev/adminbuy
    def get(self, id):

        waybill = WayBillReturnService.get_by_id(id)

        file_name = str(uuid.uuid4()) + ".xls"
        path_to_target = os.path.join(PATH_TO_GENERATE_INVOICE, file_name)
        path = os.path.join(PATH_WEB, file_name)

        pi = PrintInvoice(
            path=os.path.join(PATH_TEMPLATE, 'print_waybillreturn.xls'),
            destination=path_to_target)
        pi.set_cells(0, 0, [('number', 2)])
        pi.set_cells(0, 3, ['a', 'date', 'c', 'c', 'c', 'receiver'])
        pi.set_cells(0, 4, ['a', 'date_to'])
        pi.set_cells(0, 5, ['a', 'type'])
        pi.set_cells(0, 7, [('name', 5), 'count_plan', 'count'])

        pi.write(0, 0, 0, [{'number': waybill.number}])
        pi.write(0, 3, 2, [{'date': waybill.date.strftime(
            '%d.%m.%Y').decode("utf-8"), 'receiver': waybill.rec}])
        pi.write(0, 4, 0, [{'date_to': waybill.date_to.strftime(
            '%d.%m.%Y').decode("utf-8")}])
        pi.write(0, 5, 0, [{'type': waybill.type}])

        if waybill.type == RETAIL:
            items = [
                {'name': it.good.full_name, 'count_plan': it.count_plan or "",
                 'count': it.count or ""} for it in waybill.items]
            pi.write(0, 7, 2, items)
        else:
            items = [
                {'name': it.good.full_name, 'count_plan': it.count_plan or "",
                 'count': it.count or ""} for it in waybill.items]
            pi.write(0, 7, 2, items)

        return {"link": path}