Skip to content

Commit

Permalink
Merge pull request #2443 from internetee/prohibition-bank-transaction…
Browse files Browse the repository at this point in the history
…-over-paid-invoice

protected public method account activity create
  • Loading branch information
vohmar authored Oct 3, 2022
2 parents 28ebc58 + 3bdd5aa commit 8528a5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions app/controllers/eis_billing/payment_status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ def update

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)

registrar = invoice.buyer
bank.create_activity(registrar, invoice)
bank.bind_invoice(params[:order_reference])

respond_to do |format|
format.json do
Expand Down
15 changes: 9 additions & 6 deletions app/models/bank_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ def validate_invoice_data(invoice)
errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match')) if invoice.total != sum
end

def parsed_ref_number
reference_no || ref_number_from_description
end

private

def create_activity(registrar, invoice)
validate_invoice_data(invoice)
return if errors.any?

activity = AccountActivity.new(account: registrar.cash_account, bank_transaction: self,
invoice: invoice, sum: invoice.subtotal,
currency: currency, description: description,
Expand All @@ -102,12 +111,6 @@ def create_activity(registrar, invoice)
end
end

def parsed_ref_number
reference_no || ref_number_from_description
end

private

def reset_pending_registrar_balance_reload(registrar)
return unless registrar.settings['balance_auto_reload']

Expand Down
3 changes: 1 addition & 2 deletions test/models/bank_transaction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def test_binds_if_this_sum_invoice_already_present

first_transaction = BankTransaction.new(sum: 10,
description: 'Order nr 1 from registrar 1234567 second number 2345678')

first_transaction.create_activity(another_invoice.buyer, another_invoice)
first_transaction.bind_invoice(another_invoice.number)

transaction = BankTransaction.new(sum: 10,
description: 'Order nr 1 from registrar 1234567 second number 2345678')
Expand Down

0 comments on commit 8528a5b

Please sign in to comment.