Browse Source

_ItemCollection: added attr 'debitor_address'

Fabian Peter Hammerle 6 years ago
parent
commit
5c4f783a62
2 changed files with 19 additions and 5 deletions
  1. 12 5
      finoex/__init__.py
  2. 7 0
      tests/test_yaml.py

+ 12 - 5
finoex/__init__.py

@@ -133,7 +133,14 @@ class Sum(ioex.calcex.Figure):
 
 class _ItemCollection():
 
-    def __init__(self, items=None):
+    def __init__(
+            self,
+            debitor_address=None,
+            items=None
+            ):
+        if debitor_address is not None:
+            assert isinstance(debitor_address, str)
+            self.debitor_address = debitor_address
         if items is not None:
             assert isinstance(items, list)
             assert all([isinstance(i, Item) for i in items])
@@ -157,7 +164,7 @@ class Invoice(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresent
                  invoice_id,
                  discounts=None,
                  invoice_url=None,
-                 items=None
+                 **kwargs
                  ):
         assert isinstance(creditor, str)
         self.creditor = creditor
@@ -177,7 +184,7 @@ class Invoice(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresent
         if invoice_url:
             assert isinstance(invoice_url, str)
             self.invoice_url = invoice_url
-        _ItemCollection.__init__(self, items)
+        _ItemCollection.__init__(self, **kwargs)
 
 
 class Order(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresenter):
@@ -187,8 +194,8 @@ class Order(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresenter
     def __init__(self, platform, order_id, order_date,
                  customer_id=None,
                  discounts=None,
-                 items=None,
                  platform_view_url=None,
+                 **kwargs
                  ):
         assert type(platform) is str
         self.platform = platform
@@ -212,7 +219,7 @@ class Order(_Object, _ItemCollection, _YamlInitConstructor, _YamlVarsRepresenter
         if platform_view_url:
             assert isinstance(platform_view_url, str)
             self.platform_view_url = platform_view_url
-        _ItemCollection.__init__(self, items)
+        _ItemCollection.__init__(self, **kwargs)
 
 
 class Distance(ioex.calcex.Figure):

+ 7 - 0
tests/test_yaml.py

@@ -226,6 +226,7 @@ def get_discount_c():
 def get_order_a(items = True, discounts = True):
     order = finoex.Order(
             customer_id = u'customer',
+            debitor_address='@home',
             order_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
             order_id = u'id',
             platform = u'platformπ',
@@ -263,6 +264,7 @@ def get_invoice(items = True, discounts = True):
     inv = finoex.Invoice(
             creditor = u'platformπ',
             debitor_id = u'customer',
+            debitor_address='@home',
             invoice_date = datetime.datetime(2016, 5, 8, 0, 18, 17),
             invoice_id = u'id',
             invoice_url = 'http://example.com/invoice.pdf',
@@ -391,6 +393,7 @@ reward: product
 """],
     [get_order_a(), u"""!order
 customer_id: customer
+debitor_address: '@home'
 discounts:
 - !discount
   amount: !sum '1.23 EUR'
@@ -412,6 +415,7 @@ platform_view_url: http://i.dont.know
 """],
     [get_order_a(discounts = False), u"""!order
 customer_id: customer
+debitor_address: '@home'
 items:
 - !item
   name: item a
@@ -496,6 +500,7 @@ price_brutto: !sum '1.23 EUR'
 """],
     [get_invoice(), u"""!invoice
 creditor: platformπ
+debitor_address: '@home'
 debitor_id: customer
 discounts:
 - !discount
@@ -659,6 +664,7 @@ tracking_number: LX123456789CN
 """],
     [get_order_a(), u"""!order
 customer_id: customer
+debitor_address: '@home'
 discounts:
 - !discount
   amount: !sum '1.23 EUR'
@@ -711,6 +717,7 @@ route_map: null
 """],
     [get_invoice(), u"""!invoice
 creditor: platformπ
+debitor_address: '@home'
 debitor_id: customer
 invoice_date: 2016-05-08T00:18:17
 invoice_id: id