mirror of
https://github.com/internetee/registry.git
synced 2025-08-14 21:43:50 +02:00
Merge pull request #2443 from internetee/prohibition-bank-transaction-over-paid-invoice
protected public method account activity create
This commit is contained in:
commit
8528a5bab1
3 changed files with 11 additions and 11 deletions
|
@ -10,9 +10,7 @@ module EisBilling
|
||||||
|
|
||||||
bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time])
|
bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time])
|
||||||
create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status)
|
create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status)
|
||||||
|
bank.bind_invoice(params[:order_reference])
|
||||||
registrar = invoice.buyer
|
|
||||||
bank.create_activity(registrar, invoice)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
|
|
|
@ -88,7 +88,16 @@ class BankTransaction < ApplicationRecord
|
||||||
errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match')) if invoice.total != sum
|
errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match')) if invoice.total != sum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parsed_ref_number
|
||||||
|
reference_no || ref_number_from_description
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def create_activity(registrar, invoice)
|
def create_activity(registrar, invoice)
|
||||||
|
validate_invoice_data(invoice)
|
||||||
|
return if errors.any?
|
||||||
|
|
||||||
activity = AccountActivity.new(account: registrar.cash_account, bank_transaction: self,
|
activity = AccountActivity.new(account: registrar.cash_account, bank_transaction: self,
|
||||||
invoice: invoice, sum: invoice.subtotal,
|
invoice: invoice, sum: invoice.subtotal,
|
||||||
currency: currency, description: description,
|
currency: currency, description: description,
|
||||||
|
@ -102,12 +111,6 @@ class BankTransaction < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parsed_ref_number
|
|
||||||
reference_no || ref_number_from_description
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def reset_pending_registrar_balance_reload(registrar)
|
def reset_pending_registrar_balance_reload(registrar)
|
||||||
return unless registrar.settings['balance_auto_reload']
|
return unless registrar.settings['balance_auto_reload']
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
first_transaction = BankTransaction.new(sum: 10,
|
first_transaction = BankTransaction.new(sum: 10,
|
||||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||||
|
first_transaction.bind_invoice(another_invoice.number)
|
||||||
first_transaction.create_activity(another_invoice.buyer, another_invoice)
|
|
||||||
|
|
||||||
transaction = BankTransaction.new(sum: 10,
|
transaction = BankTransaction.new(sum: 10,
|
||||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue