P5-6370 inquires should use markets instead of territores for calculating prices #36
This commit is contained in:
+11
-7
@@ -12,25 +12,29 @@ class Market(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(255))
|
||||
vat = db.Column(db.Float, nullable=False)
|
||||
price_adjustment = db.Column(db.Float, nullable=False)
|
||||
price_adjustments = db.Column("price_adjustment", db.Float, nullable=False)
|
||||
currency = db.Column(db.String(3), db.ForeignKey("product-currencies.iso3char"))
|
||||
_pc = db.relationship(Currencies, uselist=False)
|
||||
exchange_rate = association_proxy("_pc", "exchange_rate", creator=lambda v: Currencies(exchange_rate=v))
|
||||
|
||||
@validates("name")
|
||||
def validate_name(self, key, value):
|
||||
raise ValueError("Name can not be modified")
|
||||
exchange_rate = association_proxy("_pc", "exchange_rate")
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"price_adjustment": str(self.price_adjustment),
|
||||
"price_adjustment": str(self.price_adjustments),
|
||||
"vat": str(self.vat),
|
||||
"currency": self.currency,
|
||||
"exchange_rate": str(self.exchange_rate),
|
||||
}
|
||||
|
||||
# hack: market need a territory to make it compatible with current price calculations code
|
||||
# this will be removed in P5-6491
|
||||
@property
|
||||
def territory(self):
|
||||
if self.name == 'GLOBAL':
|
||||
return 'EU'
|
||||
return self.name
|
||||
|
||||
|
||||
class PriceAdjustments(db.Model):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user