Commit 39f428a6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Fixup! Skip if Cloud Contract has no Lines

parent 6c968390
...@@ -29,15 +29,21 @@ currency_uid_list = [ ...@@ -29,15 +29,21 @@ currency_uid_list = [
portal.currency_module.CNY.getUid(), portal.currency_module.CNY.getUid(),
] ]
contract_line_list = contract.objectValues(
portal_type="Cloud Contract Line")
if not len(contract_line_list):
return context.Entity_statOutstandingAmount(
at_date=at_date)
for currency_uid in currency_uid_list: for currency_uid in currency_uid_list:
for line in contract.objectValues( for line in contract_line_list:
portal_type="Cloud Contract Line"):
if line.getPriceCurrencyUid() == currency_uid: if line.getPriceCurrencyUid() == currency_uid:
maximum_invoice_credit = line.getMaximumInvoiceCredit() maximum_invoice_credit = line.getMaximumInvoiceCredit()
amount_per_currency = context.Entity_statOutstandingAmount( amount_per_currency = context.Entity_statOutstandingAmount(
at_date=at_date, resource_uid=currency_uid) at_date=at_date, resource_uid=currency_uid)
if amount_per_currency > maximum_invoice_credit: if amount_per_currency > maximum_invoice_credit:
return amount_per_currency # We exceed maximum amount because return amount_per_currency - maximum_invoice_credit
# We exceed maximum amount because
# user already requested too much # user already requested too much
if maximum_invoice_delay: if maximum_invoice_delay:
......
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