|
@@ -112,8 +112,10 @@ class Sum(ScalarFigure):
|
|
def set_unit(self, currency):
|
|
def set_unit(self, currency):
|
|
if currency == u'€':
|
|
if currency == u'€':
|
|
currency = u'EUR'
|
|
currency = u'EUR'
|
|
|
|
+ if currency == u'US$':
|
|
|
|
+ currency = u'USD'
|
|
assert type(currency) is unicode
|
|
assert type(currency) is unicode
|
|
- assert currency in [u'EUR']
|
|
|
|
|
|
+ assert currency in [u'EUR', u'USD']
|
|
super(Sum, self).set_unit(currency)
|
|
super(Sum, self).set_unit(currency)
|
|
|
|
|
|
""" use property() instead of decorator to enable overriding """
|
|
""" use property() instead of decorator to enable overriding """
|
|
@@ -175,6 +177,8 @@ class Order(_YamlUnicodeConstruct):
|
|
):
|
|
):
|
|
assert type(platform) is unicode
|
|
assert type(platform) is unicode
|
|
self.platform = platform
|
|
self.platform = platform
|
|
|
|
+ if type(order_id) in [int]:
|
|
|
|
+ order_id = unicode(order_id)
|
|
assert type(order_id) is unicode
|
|
assert type(order_id) is unicode
|
|
self.order_id = order_id
|
|
self.order_id = order_id
|
|
if type(order_date) is datetime.datetime:
|
|
if type(order_date) is datetime.datetime:
|
|
@@ -279,8 +283,10 @@ class Article(Item):
|
|
|
|
|
|
def __init__(
|
|
def __init__(
|
|
self,
|
|
self,
|
|
- authors = [],
|
|
|
|
|
|
+ authors = None,
|
|
delivery_date = None,
|
|
delivery_date = None,
|
|
|
|
+ option = None,
|
|
|
|
+ product_id = None,
|
|
quantity = None,
|
|
quantity = None,
|
|
reseller = None,
|
|
reseller = None,
|
|
shipper = None,
|
|
shipper = None,
|
|
@@ -290,14 +296,26 @@ class Article(Item):
|
|
super(Article, self).__init__(**kwargs)
|
|
super(Article, self).__init__(**kwargs)
|
|
assert type(quantity) is int
|
|
assert type(quantity) is int
|
|
self.quantity = quantity
|
|
self.quantity = quantity
|
|
- assert type(authors) is list
|
|
|
|
- self.authors = authors
|
|
|
|
- assert state is None or type(state) is unicode
|
|
|
|
- self.state = state
|
|
|
|
- assert reseller is None or type(reseller) is unicode
|
|
|
|
- self.reseller = reseller
|
|
|
|
- assert shipper is None or type(shipper) is unicode
|
|
|
|
- self.shipper = shipper
|
|
|
|
|
|
+ if authors is not None:
|
|
|
|
+ assert type(authors) is list
|
|
|
|
+ self.authors = authors
|
|
|
|
+ if state is not None:
|
|
|
|
+ assert type(state) is unicode
|
|
|
|
+ self.state = state
|
|
|
|
+ if reseller is not None:
|
|
|
|
+ assert type(reseller) is unicode
|
|
|
|
+ self.reseller = reseller
|
|
|
|
+ if shipper is not None:
|
|
|
|
+ assert type(shipper) is unicode
|
|
|
|
+ self.shipper = shipper
|
|
|
|
+ if product_id is not None:
|
|
|
|
+ if type(product_id) in [int]:
|
|
|
|
+ product_id = unicode(product_id)
|
|
|
|
+ assert type(product_id) is unicode
|
|
|
|
+ self.product_id = product_id
|
|
|
|
+ if option is not None:
|
|
|
|
+ assert type(option) is unicode
|
|
|
|
+ self.option = option
|
|
assert delivery_date is None or type(delivery_date) is datetime.date
|
|
assert delivery_date is None or type(delivery_date) is datetime.date
|
|
self.delivery_date = delivery_date
|
|
self.delivery_date = delivery_date
|
|
|
|
|
|
@@ -306,11 +324,11 @@ class Article(Item):
|
|
attr.update({
|
|
attr.update({
|
|
'delivery_date': self.delivery_date,
|
|
'delivery_date': self.delivery_date,
|
|
'quantity': self.quantity,
|
|
'quantity': self.quantity,
|
|
- 'reseller': self.reseller,
|
|
|
|
- 'shipper': self.shipper,
|
|
|
|
- 'state': self.state,
|
|
|
|
|
|
+ 'reseller': self.reseller if hasattr(self, 'reseller') else None,
|
|
|
|
+ 'shipper': self.shipper if hasattr(self, 'shipper') else None,
|
|
|
|
+ 'state': self.state if hasattr(self, 'state') else None,
|
|
})
|
|
})
|
|
- if len(self.authors) > 0:
|
|
|
|
|
|
+ if hasattr(self, 'authors') and len(self.authors) > 0:
|
|
attr['authors'] = self.authors
|
|
attr['authors'] = self.authors
|
|
return attr
|
|
return attr
|
|
|
|
|