|
@@ -130,7 +130,18 @@ class Sum(ioex.calcex.Figure):
|
|
|
)
|
|
|
|
|
|
|
|
|
-class Invoice(_Object, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
+class _ItemCollection():
|
|
|
+
|
|
|
+ def __init__(self, items=None):
|
|
|
+ if items is not None:
|
|
|
+ assert isinstance(items, list)
|
|
|
+ assert all([isinstance(i, Item) for i in items])
|
|
|
+ self.items = items
|
|
|
+ else:
|
|
|
+ self.items = []
|
|
|
+
|
|
|
+
|
|
|
+class Invoice(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
|
|
|
yaml_tag = u'!invoice'
|
|
|
|
|
@@ -157,15 +168,10 @@ class Invoice(_Object, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
self.discounts = discounts
|
|
|
else:
|
|
|
self.discounts = []
|
|
|
- if items:
|
|
|
- assert isinstance(items, list)
|
|
|
- assert all([isinstance(i, Item) for i in items])
|
|
|
- self.items = items
|
|
|
- else:
|
|
|
- self.items = []
|
|
|
+ _ItemCollection.__init__(self, items)
|
|
|
|
|
|
|
|
|
-class Order(_Object, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
+class Order(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
|
|
|
yaml_tag = u'!order'
|
|
|
|
|
@@ -187,18 +193,13 @@ class Order(_Object, _YamlInitConstructor, _YamlVarsRepresenter):
|
|
|
if customer_id is not None:
|
|
|
assert type(customer_id) is str
|
|
|
self.customer_id = customer_id
|
|
|
- if items is None:
|
|
|
- self.items = []
|
|
|
- else:
|
|
|
- assert type(items) is list
|
|
|
- assert all([isinstance(i, Item) for i in items])
|
|
|
- self.items = items
|
|
|
if discounts is None:
|
|
|
self.discounts = []
|
|
|
else:
|
|
|
assert type(discounts) is list
|
|
|
assert all([isinstance(d, Discount) for d in discounts])
|
|
|
self.discounts = discounts
|
|
|
+ _ItemCollection.__init__(self, items)
|
|
|
|
|
|
|
|
|
class Distance(ioex.calcex.Figure):
|