Commit f14d5aa9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Invalidate Regularisation Request with the same rule of

Person_checkToCreateRegularisationRequest
parent 95bed802
...@@ -5,8 +5,24 @@ if REQUEST is not None: ...@@ -5,8 +5,24 @@ if REQUEST is not None:
state = context.getSimulationState() state = context.getSimulationState()
person = context.getSourceProjectValue(portal_type="Person") person = context.getSourceProjectValue(portal_type="Person")
if (state != 'suspended') or \ if (state != 'suspended') or \
(person is None) or \ (person is None):
(int(person.Entity_statOutstandingAmount()) > 0):
return return
else:
outstanding_amount = person.Entity_statSlapOSOutstandingAmount()
# Amount to be ignored, as it comes from the first invoice generated
# after the subscription. We do not take it into account as no service
# was provided yet.
unpaid_payment_amount = 0
for payment in person.Person_getSubscriptionRequestFirstUnpaidPaymentList():
unpaid_payment_amount += payment.PaymentTransaction_getTotalPayablePrice()
# It can't be smaller, we are considernig all open invoices are from unpaid_payment_amount
if round(float(outstanding_amount), 2) == round(-float(unpaid_payment_amount), 2):
context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statOutstandingAmount()) context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statOutstandingAmount())
if (int(outstanding_amount) > 0):
return
context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statOutstandingAmount())
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