Commit 20b659d0 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: invoice builder: dates are now set on delivery. Do not...

slapos_accounting: invoice builder: dates are now set on delivery. Do not modify causality if it exists
parent 95f86682
...@@ -14,39 +14,17 @@ if invoice.getResource() != price_currency: ...@@ -14,39 +14,17 @@ if invoice.getResource() != price_currency:
if invoice.getPaymentMode("") == "": if invoice.getPaymentMode("") == "":
invoice.setPaymentModeValue(invoice.getPortalObject().portal_categories.payment_mode.payzen) invoice.setPaymentModeValue(invoice.getPortalObject().portal_categories.payment_mode.payzen)
causality_list = [] if invoice.getCausality(None) is None:
min_start_date = None causality_list = []
max_stop_date = None for line in invoice.objectValues():
for line in invoice.objectValues(): related_delivery = line.getDeliveryRelatedValue()
related_delivery = line.getDeliveryRelatedValue() if related_delivery is not None:
if related_delivery is not None: root_applied_rule = related_delivery.getRootAppliedRule()
root_applied_rule = related_delivery.getRootAppliedRule() if root_applied_rule is not None:
if root_applied_rule is not None: causality = root_applied_rule.getCausality()
causality = root_applied_rule.getCausality() if causality is not None and causality not in causality_list:
if causality is not None and causality not in causality_list: causality_list.append(causality)
causality_list.append(causality) invoice.setCausalityList(causality_list)
if min_start_date is None:
min_start_date = line.getStartDate()
elif line.getStartDate() < min_start_date:
min_start_date = line.getStartDate()
if max_stop_date is None:
max_stop_date = line.getStopDate()
elif line.getStopDate() > max_stop_date:
max_stop_date = line.getStopDate()
if context.getStartDate() is None:
if min_start_date is None:
min_start_date = DateTime().earliestTime()
context.setStartDate(min_start_date)
if max_stop_date is None:
if min_start_date is not None:
max_stop_date = min_start_date
else:
max_stop_date = DateTime().earliestTime()
context.setStopDate(max_stop_date)
comment = translateString('Initialised by Delivery Builder.') comment = translateString('Initialised by Delivery Builder.')
...@@ -59,6 +37,5 @@ if invoice.portal_workflow.isTransitionPossible(invoice, 'plan'): ...@@ -59,6 +37,5 @@ if invoice.portal_workflow.isTransitionPossible(invoice, 'plan'):
if invoice.portal_workflow.isTransitionPossible(invoice, 'confirm'): if invoice.portal_workflow.isTransitionPossible(invoice, 'confirm'):
invoice.confirm(comment=comment) invoice.confirm(comment=comment)
invoice.setCausalityList(causality_list)
invoice.startBuilding(comment=comment) invoice.startBuilding(comment=comment)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment