mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
EveryPay/BankLink: Select specific Invoice to mark as paid
This commit is contained in:
parent
53fbd2f50c
commit
7033d91227
3 changed files with 15 additions and 7 deletions
|
@ -24,15 +24,20 @@ class BankTransaction < ApplicationRecord
|
||||||
@registrar ||= Invoice.find_by(reference_no: parsed_ref_number)&.buyer
|
@registrar ||= Invoice.find_by(reference_no: parsed_ref_number)&.buyer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# For successful binding, reference number, invoice id and sum must match with the invoice
|
# For successful binding, reference number, invoice id and sum must match with the invoice
|
||||||
def autobind_invoice
|
def autobind_invoice(invoice_no: nil)
|
||||||
return if binded?
|
return if binded?
|
||||||
return unless registrar
|
return unless registrar
|
||||||
return unless invoice
|
|
||||||
return unless invoice.payable?
|
|
||||||
|
|
||||||
create_activity(registrar, invoice)
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_invoice(invoice_no)
|
def bind_invoice(invoice_no)
|
||||||
|
|
|
@ -51,6 +51,7 @@ module PaymentOrders
|
||||||
def complete_transaction
|
def complete_transaction
|
||||||
return unless valid_response_from_intermediary? && settled_payment?
|
return unless valid_response_from_intermediary? && settled_payment?
|
||||||
|
|
||||||
|
self.status = 'paid'
|
||||||
transaction = BankTransaction.where(description: invoice.order).first_or_initialize(
|
transaction = BankTransaction.where(description: invoice.order).first_or_initialize(
|
||||||
description: invoice.order,
|
description: invoice.order,
|
||||||
reference_no: invoice.reference_no,
|
reference_no: invoice.reference_no,
|
||||||
|
@ -66,7 +67,7 @@ module PaymentOrders
|
||||||
transaction.paid_at = Time.parse(response['VK_T_DATETIME'])
|
transaction.paid_at = Time.parse(response['VK_T_DATETIME'])
|
||||||
|
|
||||||
transaction.save!
|
transaction.save!
|
||||||
transaction.autobind_invoice
|
transaction.autobind_invoice(invoice_no: invoice.number)
|
||||||
end
|
end
|
||||||
|
|
||||||
def settled_payment?
|
def settled_payment?
|
||||||
|
|
|
@ -36,6 +36,7 @@ module PaymentOrders
|
||||||
|
|
||||||
def complete_transaction
|
def complete_transaction
|
||||||
return unless valid_response_from_intermediary? && settled_payment?
|
return unless valid_response_from_intermediary? && settled_payment?
|
||||||
|
self.status = 'paid'
|
||||||
|
|
||||||
transaction = BankTransaction.where(description: invoice.order).first_or_initialize(
|
transaction = BankTransaction.where(description: invoice.order).first_or_initialize(
|
||||||
description: invoice.order,
|
description: invoice.order,
|
||||||
|
@ -48,7 +49,8 @@ module PaymentOrders
|
||||||
transaction.paid_at = Date.strptime(response['timestamp'], '%s')
|
transaction.paid_at = Date.strptime(response['timestamp'], '%s')
|
||||||
transaction.buyer_name = response['cc_holder_name']
|
transaction.buyer_name = response['cc_holder_name']
|
||||||
|
|
||||||
transaction.autobind_invoice
|
transaction.save!
|
||||||
|
transaction.autobind_invoice(invoice_no: invoice.number)
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_params
|
def base_params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue