Beispiel #1
0
class TaxSchema(BaseSchema):
    class Meta:
        model = Tax
        exclude = ('created_on', 'updated_on')

    name = ma.String(load=True)
    value = ma.Float(precision=2, load=True)
    store_id = ma.Integer(load=True)
    store = ma.Nested('StoreSchema',
                      many=False,
                      dump_only=True,
                      only=('id', 'name'))
Beispiel #2
0
class ItemTaxSchema(BaseSchema):
    class Meta:
        model = ItemTax
        exclude = ('created_on', 'updated_on')

    tax_value = ma.Float(precision=2)
    id = ma.Integer(dump_only=True)
    item_id = ma.Integer(load=True)
    tax_id = ma.Integer(load=True)

    tax = ma.Nested('TaxSchema',
                    many=False,
                    only=('id', 'name'),
                    dump_only=True)
    item = ma.Nested('ItemSchema', many=False, dump_only=True)
Beispiel #3
0
class ItemSchema(BaseSchema):
    class Meta:
        model = Item
        exclude = ('created_on', 'updated_on')

    id = ma.Integer(dump_only=True)
    product_id = ma.Integer(load=False, dump_only=True)
    unit_price = ma.Float(precision=2)
    quantity = ma.Float(precision=2)
    order_id = ma.Integer()
    stock_id = ma.Integer()
    discount = ma.Float()
    discounted_total_price = ma.Float(dump_only=True)
    discounted_unit_price = ma.Float(dump_only=True)
    total_price = ma.Float(dump_only=True)
    discount_amount = ma.Float(dump_only=True)

    taxes = ma.Nested('ItemTaxSchema', many=True, exclude=('item', ))
Beispiel #4
0
class ItemSchema(BaseSchema):
    class Meta:
        model = Item
        exclude = ('created_on', 'updated_on')

    product_id = ma.UUID(load=True, required=True)
    unit_price = ma.Float(precision=2)
    quantity = ma.Float(precision=2)
    order_id = ma.UUID()
    stock_id = ma.UUID()
    discount = ma.Float()
    discounted_total_price = ma.Float(dump_only=True)
    discounted_unit_price = ma.Float(dump_only=True)
    total_price = ma.Float(dump_only=True)
    discount_amount = ma.Float(dump_only=True)
    children = ma.Nested('self',
                         many=True,
                         default=None,
                         load=True,
                         exclude=('parent', ))
    product = ma.Nested('ProductSchema', many=False, only=('id', 'name'))
    combo = ma.Nested('ComboSchema', many=False, only=('id', 'name'))
    taxes = ma.Nested('ItemTaxSchema', many=True, exclude=('item', ))
    add_ons = ma.Nested('AddOnSchema', many=True, exclude=('item', ))
Beispiel #5
0
class ProductSchema(BaseSchema):
    class Meta:
        model = Product
        exclude = ('created_on', 'updated_on')

    name = ma.String()
    description = ma.List(ma.Dict(), allow_none=True)
    sub_description = ma.String(allow_none=True)
    brand_id = ma.UUID()
    retail_shop_id = ma.UUID()
    default_quantity = ma.Float(precision=2, partila=True)
    quantity_label = ma.String(load=True, allow_none=True)
    is_loose = ma.Boolean(load=True, allow_none=True)
    mrp = ma.Integer(dump_only=True)
    available_stock = ma.Integer(dump_only=True)
    barcode = ma.String(max_length=13,
                        min_length=8,
                        load=True,
                        allow_none=False)
    similar_products = ma.List(ma.Integer, dump_only=True)

    last_selling_amount = ma.Float(precision=2, dump_only=True)
    last_purchase_amount = ma.Float(precision=2, dump_only=True)
    stock_required = ma.Integer(dump_only=True)
    is_short = ma.Boolean(dump_only=True)
    distributors = ma.Nested('DistributorSchema',
                             many=True,
                             dump_only=True,
                             only=('id', 'name'))
    brand = ma.Nested('BrandSchema',
                      many=False,
                      dump_only=True,
                      only=('id', 'name'))
    retail_shop = ma.Nested('RetailShopSchema',
                            many=False,
                            dump_only=True,
                            only=('id', 'name'))
    tags = ma.Nested('TagSchema',
                     many=True,
                     only=('id', 'name'),
                     dump_only=True)
    salts = ma.Nested('SaltSchema',
                      many=True,
                      only=('id', 'name'),
                      dump_only=True)

    _links = ma.Hyperlinks({
        'distributor':
        ma.URLFor('pos.distributor_view', __product_id__exact='<id>'),
        'retail_shop':
        ma.URLFor('pos.retail_shop_view', slug='<retail_shop_id>'),
        'brand':
        ma.URLFor('pos.brand_view', slug='<brand_id>'),
        'stocks':
        ma.URLFor('pos.stock_view', __product_id__exact='<id>')
    })

    stocks = ma.Nested('StockSchema',
                       many=True,
                       only=('purchase_amount', 'selling_amount',
                             'units_purchased', 'units_sold', 'expiry_date',
                             'purchase_date', 'id'))
    taxes = ma.Nested('TaxSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name', 'value'))
    available_stocks = ma.Nested('StockSchema',
                                 many=True,
                                 dump_only=True,
                                 only=('purchase_amount', 'selling_amount',
                                       'units_purchased', 'units_sold',
                                       'expiry_date', 'purchase_date', 'id',
                                       'default_stock'))