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 invoice = context
specialise = context.getPortalObject().portal_preferences.getPreferredAggregatedSaleTradeCondition() specialise = context.getPortalObject().portal_preferences.getPreferredAggregatedSaleTradeCondition()
if invoice.getSpecialise() != specialise: 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: if len(invoice.getCausalityRelatedList(portal_type=['Cloud Contract', 'Subscription Request'])) > 0:
# Nothing to compare # Nothing to compare
return True return True
delivery_list = invoice.getCausalityValueList(portal_type='Sale Packing List') delivery_list = invoice.getCausalityValueList(portal_type='Sale Packing List')
amount = len(delivery_list) amount = len(delivery_list)
if amount != 1: if amount < 1:
raise TypeError('Wrong amount %s of related packing lists' % amount) return False
delivery = delivery_list[0]
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