Bernd Wurst commited on 2024-05-18 08:43:48
Zeige 1 geänderte Dateien mit 36 Einfügungen und 2 Löschungen.
... | ... |
@@ -108,6 +108,41 @@ def InvoiceToXML(invoice): |
108 | 108 |
if invoice.contract_number: |
109 | 109 |
doc.trade.agreement.contract.issuer_assigned_id = invoice.contract_number |
110 | 110 |
|
111 |
+ # Wenn alle Leistungsdaten aller Posten exakt ein fixes Datum sind, sollte statt dem Datumbereich der |
|
112 |
+ # einzelnen Posten doc.trade.delivery.event.occurence verwendet werden. Dazu müssen vorab alle Posten |
|
113 |
+ # aller Tabellen geprüft werden |
|
114 |
+ only_one_date = True |
|
115 |
+ deliverydate = None |
|
116 |
+ try: |
|
117 |
+ for part in invoice.parts: |
|
118 |
+ if not isinstance(part, InvoiceTable): |
|
119 |
+ continue |
|
120 |
+ for el in part.entries: |
|
121 |
+ end = None |
|
122 |
+ start = None |
|
123 |
+ if 'period_end' in el and el['period_end']: |
|
124 |
+ end = el['period_end'] |
|
125 |
+ if 'period_start' in el and el['period_start']: |
|
126 |
+ start = el['period_start'] |
|
127 |
+ if start and end and start != end: |
|
128 |
+ print(f"{start} != {end}") |
|
129 |
+ deliverydate = None |
|
130 |
+ only_one_date = False |
|
131 |
+ raise Exception('loop abort') |
|
132 |
+ if start and not deliverydate: |
|
133 |
+ deliverydate = el['period_start'] |
|
134 |
+ continue |
|
135 |
+ if start != deliverydate: |
|
136 |
+ print(f"{start} != {deliverydate}") |
|
137 |
+ deliverydate = None |
|
138 |
+ only_one_date = False |
|
139 |
+ raise Exception('loop abort') |
|
140 |
+ except Exception as e: |
|
141 |
+ print('exception: ' + str(e)) |
|
142 |
+ pass |
|
143 |
+ if only_one_date and deliverydate: |
|
144 |
+ doc.trade.delivery.event.occurrence = deliverydate |
|
145 |
+ |
|
111 | 146 |
# Line Items |
112 | 147 |
summe_netto = 0.0 |
113 | 148 |
summe_brutto = 0.0 |
... | ... |
@@ -136,12 +171,11 @@ def InvoiceToXML(invoice): |
136 | 171 |
if 'desc' in el and el['desc'] != '': |
137 | 172 |
li.product.description = el['desc'] |
138 | 173 |
|
174 |
+ if not only_one_date: |
|
139 | 175 |
if 'period_start' in el and el['period_start']: |
140 | 176 |
li.settlement.period.start = el['period_start'] |
141 | 177 |
if 'period_end' in el and el['period_end']: |
142 | 178 |
li.settlement.period.end = el['period_end'] |
143 |
- else: |
|
144 |
- li.settlement.period.end = el['period_start'] |
|
145 | 179 |
|
146 | 180 |
unit = 'C62' |
147 | 181 |
if el['unit']: |
148 | 182 |