Refactor EveryPay / Banklink processing

This commit is contained in:
Karl Erik Õunapuu 2020-01-30 21:01:15 +02:00
parent cb76a9f962
commit 32d4fc3c83
5 changed files with 55 additions and 28 deletions

View file

@ -31,19 +31,13 @@ class BankTransaction < ApplicationRecord
end
# For successful binding, reference number, invoice id and sum must match with the invoice
def autobind_invoice(invoice_no: nil)
def autobind_invoice
return if binded?
return unless registrar
return unless invoice
return unless invoice.payable?
inv = if invoice_no.nil?
invoice
else
Invoice.find_by(number: invoice_no)
end
return unless inv
return unless inv.payable?
create_activity(registrar, inv)
create_activity(registrar, invoice)
end
def bind_invoice(invoice_no)