Commit 25b64857 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Fixup constraint

  Usage of raise it don't lead to inconsistency
  Since we can merge aggregated Packing Lists, now we consider the sum() rather the invidual comparation.
parent 6f975a16
invoice = context
specialise = context.getPortalObject().portal_preferences.getPreferredAggregatedSaleTradeCondition()
if invoice.getSpecialise() != specialise:
raise TypeError('Only invoice specialised by %s shall be checked' % specialise)
return False
if len(invoice.getCausalityRelatedList(portal_type=['Cloud Contract', 'Subscription Request'])) > 0:
# Nothing to compare
return True
delivery_list = invoice.getCausalityValueList(portal_type='Sale Packing List')
amount = len(delivery_list)
if amount != 1:
raise TypeError('Wrong amount %s of related packing lists' % amount)
delivery = delivery_list[0]
if amount < 1:
return False
amount = sum([delivery.getTotalPrice(use='use/trade/sale') for delivery in delivery_list])
return delivery.getTotalPrice(use='use/trade/sale') == context.getTotalPrice(use='use/trade/sale')
return amount == context.getTotalPrice(use='use/trade/sale')
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