47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
from orm import fields, model
|
|
|
|
|
|
class SaleCouponModel(model.Model):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.instance_id = fields.ThisModelValue(db_column='OrdCpnNbr')
|
|
self.code = fields.ThisModelValue(db_column='CouponCode')
|
|
self.discounts = fields.ThisModelDecimalValue(
|
|
db_column='OrdCpnCouponDiscountAmt * -1', db_alias='discounts', decimal_places=4
|
|
)
|
|
self.description = fields.One2OneValue(
|
|
db_column='CouponDescText',
|
|
db_table='pos.dbo.Coupons2',
|
|
join=(
|
|
('Location_Code', 'Location_Code'),
|
|
('CouponCode', 'CouponCode'),
|
|
)
|
|
)
|
|
|
|
class Conf:
|
|
db_table = 'pos.dbo.OrderCoupons'
|
|
filters = ('Location_Code', 'Order_Date', 'Order_Number')
|
|
|
|
|
|
class ItemCouponModel(model.Model):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.instance_id = fields.ThisModelValue(db_column='OrdCpnNbr')
|
|
self.code = fields.One2OneValue(
|
|
db_column='CouponCode',
|
|
db_table='pos.dbo.OrderCoupons',
|
|
join=(
|
|
('Location_Code', 'Location_Code'),
|
|
('Order_Date', 'Order_Date'),
|
|
('Order_Number', 'Order_Number'),
|
|
('OrdCpnNbr', 'OrdCpnNbr')
|
|
)
|
|
)
|
|
self.amount = fields.ThisModelDecimalValue(
|
|
db_column='OrdLineCpnCouponDiscountAmt * -1', db_alias='amount', decimal_places=4
|
|
)
|
|
|
|
class Conf:
|
|
db_table = 'pos.dbo.OrderLineCoupons'
|
|
filters = ('Location_Code', 'Order_Date', 'Order_Number', 'Line_Number')
|