class TransferHeaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = TransferHeader ordered = True load_instance = True transrow = ma.Nested(TransferRowSchema, many=True)
class ReceiveHeaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = ReceiveHeader ordered = True include_fk = True recrow = ma.Nested(ReceiveRowSchema, many=True)
class ItemRequestSchema(ma.SQLAlchemyAutoSchema): class Meta: model = ItemRequest ordered = True include_fk = True request_rows = ma.Nested(ItemRequestRowSchema, many=True)
class FinalCountSchema(ma.SQLAlchemyAutoSchema): class Meta: model = FinalInvCount ordered = True include_fk = True row = ma.Nested(FinalCountRowSchema, many=True)
class PaymentHeaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = PayTransHeader ordered = True include_fk = True payrows = ma.Nested(PaymentRowSchema, many=True)
class PullOutHeaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = PullOutHeader ordered = True include_fk = True row = ma.Nested(PullOutHeaderRowSchema, many=True)
class SalesHeaderSchema(ma.SQLAlchemyAutoSchema): class Meta: model = SalesHeader ordered = True include_fk = True load_instance = True salesrow = ma.Nested(SalesRowSchema, many=True) created_user = ma.Nested(UserSchema, only=("username", )) cashsales = ma.Number() arsales = ma.Number() agentsales = ma.Number() user = ma.String() def dump(self, *args, **kwargs): special = kwargs.pop('special', None) _partial = super(SalesHeaderSchema, self).dump(*args, **kwargs) if special is not None and all(f in _partial for f in special): for field in special: _partial['_{}'.format(field)] = _partial.pop(field) return _partial