class LocalPurchaseOrderSchema(ma.ModelSchema): entity = ma.Nested(EntitySchema, only=('name', 'address', 'email', 'phone')) vendor = ma.Nested(VendorSchema, only=('name', 'address', 'email', 'phone')) vendor_id = ma.String(required=True) entity_id = ma.String(required=True) class Meta: model = LocalPurchaseOrder sqla_session = db.session additional = ("creator", "items", "credit")
class LpoItemSchema(ma.ModelSchema): item = ma.Nested(ItemSchema, only=('name','uuid')) order = ma.Nested(LocalPurchaseOrderSchema, only=('id','uuid', 'vendor_id')) not_empty = validate.Length(min=1, max=50, error="Field cant be empty.") order_id = ma.String(required=True) item_id = ma.String(required=True, validate=[not_empty]) quantity = ma.Integer(required=True) unit_price = ma.Integer(required=True) class Meta: model = LpoItem sqla_session = db.session additional = ("creator", "amount")
class VehicleSchema(ma.ModelSchema): vehicle_model = ma.Nested(VehicleModelSchema) customer = ma.Nested(CustomerSchema, only=('name', 'address', 'email', 'phone')) registration_no = ma.String(required=True) chassis_no = ma.String(required=True) model_id = ma.String(required=True) model_no = ma.String(required=True) engine_no = ma.String(required=True) customer_id = ma.String(required=True) class Meta: model = Vehicle sqla_session = db.session additional = ("creator", )
class EntitySchema(ma.ModelSchema): account = ma.Nested(AccountSchema) class Meta: model = Entity sqla_session = db.session additional = ("creator",)
class JobItemSchema(ma.ModelSchema): item = ma.Nested(ItemSchema, only=('id', 'name', 'price')) job = ma.Nested(JobSchema, only=('id', 'employee_id', 'request_id', 'is_complete')) not_empty = validate.Length(min=1, max=50, error='Field cant be empty.') job_id = ma.String(required=True) item_id = ma.String(required=True, validate=[not_empty]) quantity = ma.Integer(required=True) unit_cost = ma.Integer(required=True) entity_id = ma.String(required=True) class Meta: model = JobItem sqla_session = db.session additional = ('creator', 'cost')
class ServiceRequestSchema(ma.ModelSchema): vehicle = ma.Nested(VehicleSchema) service = ma.Nested(ServiceSchema) customer = ma.Nested(CustomerSchema, only=('name', 'address', 'email', 'phone')) entity = ma.Nested(EntitySchema, only=('name', 'address', 'email', 'phone')) not_empty = validate.Length(min=1, max=50, error="Field cant be empty.") pay_types = validate.OneOf(["cash", "momo"]) customer_id = ma.String(required=True, validate=[not_empty]) service_id = ma.String(required=True, validate=[not_empty]) vehicle_id = ma.String(required=True, validate=[not_empty]) entity_id = ma.String(required=True, validate=[not_empty]) class Meta: model = ServiceRequest sqla_session = db.session
class JobSchema(ma.ModelSchema): request = ma.Nested(ServiceRequestSchema) employee = ma.Nested(EmployeeSchema, only=('name', 'address', 'email', 'phone')) entity = ma.Nested(EntitySchema, only=('name', 'address', 'email', 'phone')) employee_id = ma.String(required=True) request_id = ma.String(required=True) entity_id = ma.String() is_complete = ma.Boolean() class Meta: model = Job sqla_session = db.session additional = ("creator", "time")
class ItemSchema(ma.ModelSchema): entity = ma.Nested(EntitySchema, only=("name", "address", "email", "phone")) category = ma.Nested(ItemCategorySchema) vendor = ma.Nested(VendorSchema) name = ma.String(required=True) code = ma.String(required=True) model_id = ma.String(required=True) category_id = ma.String(required=True) price = ma.Integer(required=True) make_id = ma.Integer(required=True) item_type = ma.String(required=True) entity_id = ma.String(required=True) class Meta: model = Item sqla_session = db.session additional = ("creator", "quantity")
class ItemLogSchema(ma.ModelSchema): item = ma.Nested(ItemSchema, only=('name', 'uuid')) entity = ma.Nested(EntitySchema, only=('name', 'address', 'email', 'phone')) item_id = ma.String(required=True) debit = ma.String(required=True) credit = ma.String(required=True) reference = ma.String(required=True) category = ma.String(required=True) quantity = ma.Integer(required=True) amount = ma.Integer(required=True) unit_cost = ma.Integer(required=True) entity_id = ma.String(required=True) class Meta: model = ItemLog sqla_session = db.session additional = ("debit_account", "credit_account", "creator")
class VehicleModelSchema(ma.ModelSchema): type = ma.Nested(VehicleTypeSchema) type_id = ma.String(required=True) description = ma.String(required=True) name = ma.String(required=True) class Meta: model = VehicleModel sqla_session = db.session additional = ("creator", )
class CommissionAccountSchema(ma.ModelSchema): account = ma.Nested(AccountSchema) entity_id = ma.String(required=True) code = ma.String(required=True) name = ma.String(required=True) class Meta: model = CommissionAccount sqla_session = db.session additional = ('creator', )
class WorkItemSchema(ma.ModelSchema): request = ma.Nested(ServiceRequestSchema) not_empty = validate.Length(min=1, max=50, error='Field cant be empty.') request_id = ma.String(required=True) item = ma.String(required=True, validate=[not_empty]) quantity = ma.Integer(required=True) unit_cost = ma.Integer(required=True) entity_id = ma.String(required=True) class Meta: model = WorkItem sqla_session = db.session additional = ('creator', 'cost')
class EntrySchema(ma.ModelSchema): creator = ma.Nested(UserSchema) debit = ma.Integer() credit = ma.Integer() reference = ma.String(required=True) debit = ma.String(required=True) credit = ma.String(required=True) amount = ma.Integer(required=True) description = ma.String(required=True) tran_type = ma.String(required=True) pay_type = ma.String(required=True) entity_id = ma.String(required=True) class Meta: model = Entry sqla_session = db.session additional = ("debit_account", "credit_account", "entity")
class CustomerSchema(ma.ModelSchema): account = ma.Nested(AccountSchema) type_id = ma.String(required=True) entity_id = ma.String(required=True) name = ma.String(required=True) email = ma.Email() address = ma.String(required=True) phone = ma.String( validate=[ validate.Regexp( r"^(256|0)[3,4,7][0,1,5,7,8,9][0-9]{7}$", error="Invalid phone number supplied", ) ], required=True, ) class Meta: model = Customer sqla_session = db.session additional = ("entity", )
class VendorSchema(ma.ModelSchema): account = ma.Nested(AccountSchema) class Meta: model = Vendor sqla_session = db.session