Merge pull request #1992 from internetee/1991-fix-payment-processing

Fix processing of transactions not related to registrar
This commit is contained in:
Timo Võhmar 2021-05-18 15:55:47 +03:00 committed by GitHub
commit 064987a14c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -40,6 +40,8 @@ namespace :invoices do
description: incoming_transaction.payment_description }
transaction = bank_statement.bank_transactions.create!(transaction_attributes)
next if transaction.registrar.blank?
unless transaction.non_canceled?
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
transaction.autobind_invoice

View file

@ -32,6 +32,34 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
end
end
def test_not_raises_error_if_bad_reference
@payment_description = 'some weird description 252923'
beneficiary_iban = 'GB33BUKB20201555555555'
Lhv::ConnectApi.class_eval do
define_method :credit_debit_notification_messages do
transaction = OpenStruct.new(amount: @payment_amount,
currency: @payment_currency,
date: @payment_date,
payment_reference_number: @payment_reference_number,
payment_description: @payment_description)
message = OpenStruct.new(bank_account_iban: beneficiary_iban,
credit_transactions: [transaction])
[message]
end
end
assert_no_difference 'AccountActivity.count' do
assert_no_difference 'Invoice.count' do
assert_no_difference -> {@account.balance} do
assert_nothing_raised do
capture_io { run_task }
end
end
end
end
end
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
assert_not @invoice.paid?