Esempio n. 1
0
class RetailShopSchema(BaseSchema):
    class Meta:
        model = RetailShop
        exclude = ('created_on', 'updated_on', 'products', 'orders', 'users',
                   'brands', 'distributors', 'tags', 'taxes')

    _links = ma.Hyperlinks({
        'products':
        ma.URLFor('pos.product_view', __retail_shop_id__exact='<id>'),
        'brands':
        ma.URLFor('pos.brand_view', __retail_shop_id__exact='<id>'),
        'distributors':
        ma.URLFor('pos.distributor_view', __retail_shop_id__exact='<id>'),
        'tags':
        ma.URLFor('pos.tag_view', __retail_shop_id__exact='<id>'),
        'taxes':
        ma.URLFor('pos.tax_view', __retail_shop_id__exact='<id>')
    })
    retail_brand_id = ma.UUID()
    retail_brand = ma.Nested('RetailBrandSchema', many=False)
    total_sales = ma.Dict()
    address = ma.Nested('AddressSchema', many=False)
    localities = ma.Nested('LocalitySchema', many=True)
    registration_details = ma.Nested('RegistrationDetailSchema', many=True)
    printer_config = ma.Nested('PrinterConfigSchema', load=True, many=False)
Esempio n. 2
0
class ProductSchema(BaseSchema):
    class Meta:
        model = Product
        exclude = ('created_on', 'updated_on')

    name = ma.String()
    description = ma.Dict()
    sub_description = ma.String()
    distributor_id = ma.Integer()
    brand_id = ma.Integer()
    retail_shop_id = ma.Integer()
    distributor = ma.Nested('DistributorSchema', many=False, 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'))
    mrp = ma.Integer(dump_only=True)
    available_stock = ma.Integer(dump_only=True)
    similar_products = ma.List(ma.Integer)
    tags = ma.Nested('TagSchema', many=True, only=('id', 'name'))
    salts = ma.Nested('SaltSchema', many=True, only=('id', 'name'))
    _links = ma.Hyperlinks(
        {
            'distributor': ma.URLFor('pos.distributor_view', slug='<distributor_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, only=('id', 'name', 'value'))
    available_stocks = ma.Nested('StockSchema', many=True, only=('purchase_amount', 'selling_amount', 'units_purchased',
                                                                 'units_sold', 'expiry_date', 'purchase_date', 'id'))
Esempio n. 3
0
class UserSchema(BaseSchema):
    class Meta:
        model = User
        exclude = ('updated_on', 'password')

    id = ma.UUID(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    name = ma.String(load=True)
    brand_ids = ma.List(ma.UUID, dump_only=True)
    retail_shop_ids = ma.List(ma.UUID, dump_only=True)
    retail_shops = ma.Nested('RetailShopSchema', many=True, dump_only=True)

    _links = ma.Hyperlinks({
        'shops':
        ma.URLFor('pos.retail_shop_view', __id__in='<retail_shop_ids>')
    })
    roles = ma.Nested('RoleSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name'))
    permissions = ma.Nested('PermissionSchema',
                            many=True,
                            dump_only=True,
                            only=('id', 'name'))
Esempio n. 4
0
class UserSchema(BaseSchema):

    class Meta:
        model = User
        exclude = ('created_on', 'updated_on', 'password', 'current_login_at', 'current_login_ip',
                   'last_login_at', 'last_login_ip', 'login_count', 'confirmed_at')

    id = ma.Integer(dump_only=True)
    email = ma.Email(unique=True, primary_key=True, required=True)
    username = ma.String(required=True)
    name = ma.String(dump_only=True)
    brand_ids = ma.List(ma.Integer)
    retail_shop_ids = ma.List(ma.Integer)
    retail_shops = ma.Nested('RetailShopSchema', many=True)

    _links = ma.Hyperlinks({'shops': ma.URLFor('pos.retail_shop_view', __id__in='<retail_shop_ids>')})
    roles = ma.Nested('RoleSchema', many=True, dump_only=True)
Esempio n. 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'))