コード例 #1
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'))
コード例 #2
0
class DistributorSchema(BaseSchema):
    class Meta:
        model = Distributor
        exclude = ('created_on', 'updated_on')

    name = ma.String()
    phone_numbers = ma.List(ma.Integer())
    emails = ma.List(ma.Email())
    retail_shop_id = ma.Integer()

    retail_shop = ma.Nested('RetailShopSchema', many=False, dump_only=True, only=('id', 'name'))
    bills = ma.Nested('DistributorBillSchema', many=True, exclude=('distributor', 'distributor_id'))
コード例 #3
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'))
コード例 #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)
コード例 #5
0
class ProductElasticSchema(BaseSchema):
    class Meta:
        model = Product
        exclude = ('created_on', 'updated_on', 'store', 'last_selling_amount',
                   'last_purchase_amount', 'stock_required', 'is_short',
                   'distributors', '_links', 'stocks', 'min_stock', 'combos',
                   'add_ons')

    name = ma.String()
    short_code = ma.String()
    description = ma.List(ma.Dict(), allow_none=True)
    sub_description = ma.String(allow_none=True)
    brand_id = ma.Integer()
    brand = ma.Nested('BrandSchema', many=False, only=('name', ))
    salts = ma.Nested('SaltElasticSchema', many=True, only=('id', 'name'))
    taxes = ma.Nested('TaxSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name', 'value'))
    is_disabled = ma.Boolean()
    store_id = ma.Integer()
    quantity_label = ma.String(dump_only=True, allow_none=True)
    default_quantity = ma.Float(precision=2, partila=True)
    packaging_form = ma.String(dump_only=True, allow_none=True)
    packaging_size = ma.String(dump_only=True, allow_none=True)
    is_loose = ma.Boolean(dump_only=True, allow_none=True)
    mrp = ma.Integer(dump_only=True)
    min_stock = ma.Float(dump_only=True)
    auto_discount = ma.Float(dump_only=True)
    available_stock = ma.Integer(dump_only=True)
    similar_products = ma.List(ma.Integer)
    product_salts = ma.Nested('ProductSaltSchema',
                              many=True,
                              only=('salt_id', 'unit', 'value'))
    barcode = ma.String(max_length=13,
                        min_length=8,
                        dump_onl=True,
                        allow_none=False)
    available_stocks = ma.Nested('StockSchema',
                                 many=True,
                                 dump_only=True,
                                 only=('purchase_amount', 'selling_amount',
                                       'units_purchased', 'batch_number',
                                       'units_sold', 'expiry_date',
                                       'purchase_date', 'id', 'default_stock'))
コード例 #6
0
ファイル: schemas.py プロジェクト: saurabh1e/pos-api
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)
    store_ids = ma.List(ma.UUID, dump_only=True)
    stores = ma.Nested('StoreSchema', many=True, dump_only=True)

    roles = ma.Nested('RoleSchema',
                      many=True,
                      dump_only=True,
                      only=('id', 'name'))
    permissions = ma.Nested('PermissionSchema',
                            many=True,
                            dump_only=True,
                            only=('id', 'name'))
コード例 #7
0
class DistributorSchema(BaseSchema):
    class Meta:
        model = Distributor
        exclude = ('created_on', 'updated_on')

    id = ma.UUID()
    name = ma.String()
    phone_numbers = ma.List(ma.Integer())
    emails = ma.List(ma.Email())
    retail_shop_id = ma.UUID()
    products = ma.Nested('ProductSchema',
                         many=True,
                         dump_only=True,
                         only=('id', 'name', 'last_selling_amount', 'barcode',
                               'last_purchase_amount', 'stock_required',
                               'quantity_label'))

    retail_shop = ma.Nested('RetailShopSchema',
                            many=False,
                            dump_only=True,
                            only=('id', 'name'))
    bills = ma.Nested('DistributorBillSchema',
                      many=True,
                      exclude=('distributor', 'distributor_id'))
コード例 #8
0
class CustomerSchema(BaseSchema):
    class Meta:
        model = Customer
        exclude = ('updated_on', )

    mobile_number = ma.Integer()
    total_orders = ma.Integer(dump_only=True)
    total_billing = ma.Float(precison=2, dump_only=True)
    amount_due = ma.Float(precison=2, dump_only=True)
    addresses = ma.Nested('AddressSchema', many=True, load=False, partial=True)
    retail_brand_id = ma.UUID(load=True)
    retail_shop_id = ma.List(ma.UUID(), load=True)
    retail_brand = ma.Nested('RetailBrandSchema',
                             many=False,
                             only=('id', 'name'))
    transactions = ma.Nested('CustomerTransactionSchema',
                             many=True,
                             only=('id', 'amount', 'created_on'))
コード例 #9
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'))