Commit 71e9f196 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Check for the list of payment as simulation can create more.

parent 64a037a5
...@@ -15,16 +15,29 @@ if sale_invoice_transaction.getSimulationState() in ["draft", "cancelled", "dele ...@@ -15,16 +15,29 @@ if sale_invoice_transaction.getSimulationState() in ["draft", "cancelled", "dele
context.cancel(comment="Invoice is cancelled, so subscription is cancelled") context.cancel(comment="Invoice is cancelled, so subscription is cancelled")
return return
payment_transaction = sale_invoice_transaction.getCausalityRelatedValue( payment_transaction_list = sale_invoice_transaction.getCausalityRelatedValueList(
portal_type="Payment Transaction") portal_type="Payment Transaction")
if payment_transaction.getSimulationState() in ["draft", "cancelled", "deleted"]: cancel_subscription_request = None
is_paid = False
for payment_transaction in payment_transaction_list:
if cancel_subscription_request != False and payment_transaction.getSimulationState() in ["draft", "cancelled", "deleted"]:
cancel_subscription_request = True
if payment_transaction.getSimulationState() == "stopped":
cancel_subscription_request = False
is_paid = True
if cancel_subscription_request:
context.cancel(comment="Payment is cancelled, so subscription is cancelled") context.cancel(comment="Payment is cancelled, so subscription is cancelled")
sale_invoice_transaction.cancel(comment="Payment is cancelled, so invoice is cancelled") sale_invoice_transaction.cancel(comment="Payment is cancelled, so invoice is cancelled")
return for payment_transaction in payment_transaction_list:
if payment_transaction.getSimulationState() == "started":
payment_transaction.cancel("Subscription is been cancelled")
# Check if payment_transaction is payed. # Check if payment_transaction is payed.
if payment_transaction.getSimulationState() != "stopped": if not is_paid:
# Nothing to do bug wait the payment # Nothing to do bug wait the payment
return return
......
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