Browse Source

[FIX] release capital request matched with credit note

when a release capital request is matched with a credit note it's marked
as paid but it should not process it has a normal paid release capital
request. No share should be given to the cooperator and no operation
should be written in the cooperator register
pull/1/head
houssine 6 years ago
parent
commit
09fd84b650
  1. 17
      easy_my_coop/models/account_invoice.py

17
easy_my_coop/models/account_invoice.py

@ -67,13 +67,24 @@ class account_invoice(models.Model):
def confirm_paid(self): def confirm_paid(self):
for invoice in self: for invoice in self:
super(account_invoice, invoice).confirm_paid() super(account_invoice, invoice).confirm_paid()
if invoice.partner_id.cooperator and invoice.release_capital_request and invoice.type == 'out_invoice':
effective_date = datetime.now().strftime("%d/%m/%Y")
# we check if there is an open refund for this invoice. in this case we
# don't run the process_subscription function as the invoice has been
# reconciled with a refund and not a payment.
refund = self.search([('type','=','out_refund'),('origin','=',invoice.number)]).filtered(lambda record: record.state == 'open')
if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund:
#take the effective date from the payment. by default the confirmation date is the payment date #take the effective date from the payment. by default the confirmation date is the payment date
if invoice.payment_move_line_ids :
effective_date = datetime.now().strftime("%d/%m/%Y")
if invoice.payment_move_line_ids:
move_line = invoice.payment_move_line_ids[0] move_line = invoice.payment_move_line_ids[0]
effective_date = move_line.date effective_date = move_line.date
invoice.subscription_request.state = 'paid' invoice.subscription_request.state = 'paid'
invoice.post_process_confirm_paid(effective_date) invoice.post_process_confirm_paid(effective_date)
# if there is a open refund we mark the subscription as cancelled
elif invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and refund:
invoice.subscription_request.state = 'cancelled'
return True return True
Loading…
Cancel
Save