mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 15:34:41 +02:00
Troubleshoot invoice not paid in billing system
This commit is contained in:
parent
e86dae7eea
commit
91c471049a
5 changed files with 196 additions and 172 deletions
|
@ -4,6 +4,10 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
setup do
|
||||
@registrar = registrars(:bestnames)
|
||||
@invoice = invoices(:one)
|
||||
if Feature.billing_system_integrated?
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_status')
|
||||
.to_return(status: 200, body: '', headers: {})
|
||||
end
|
||||
end
|
||||
|
||||
def test_matches_against_invoice_nubmber_and_reference_number
|
||||
|
@ -16,87 +20,86 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_binds_if_this_sum_invoice_already_present
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
another_invoice.update(reference_no: '7654321', number: '2221')
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
another_invoice.update(reference_no: '7654321', number: '2221')
|
||||
|
||||
first_transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
first_transaction.create_activity(another_invoice.buyer, another_invoice)
|
||||
first_transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
first_transaction.create_activity(another_invoice.buyer, another_invoice)
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
|
||||
def test_binds_if_this_sum_cancelled_invoice_already_present
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
another_invoice.update(reference_no: '1234567', number: '2221', cancelled_at: Time.zone.now)
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
another_invoice.update(reference_no: '1234567', number: '2221', cancelled_at: Time.zone.now)
|
||||
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
|
||||
def test_marks_the_first_one_as_paid_if_same_sum
|
||||
if Feature.billing_system_integrated?
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
another_invoice.update(reference_no: '7654321', number: '2221')
|
||||
return unless Feature.billing_system_integrated?
|
||||
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
invoice_n = Invoice.order(number: :desc).last.number
|
||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
another_invoice = @invoice.dup
|
||||
another_invoice.save(validate: false)
|
||||
another_invoice.update(reference_no: '7654321', number: '2221')
|
||||
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
another_item = @invoice.items.first.dup
|
||||
another_item.invoice = another_invoice
|
||||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
@invoice.reload
|
||||
another_invoice.reload
|
||||
assert(@invoice.paid?)
|
||||
assert_not(another_invoice.paid?)
|
||||
assert_difference 'AccountActivity.count' do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
|
||||
@invoice.reload
|
||||
another_invoice.reload
|
||||
assert(@invoice.paid?)
|
||||
assert_not(another_invoice.paid?)
|
||||
end
|
||||
|
||||
def test_matches_against_invoice_nubmber_and_reference_number_in_description
|
||||
|
@ -192,7 +195,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
|
||||
def test_parsed_ref_no_returns_nil_if_ref_not_found
|
||||
statement = BankTransaction.new
|
||||
statement.description = "all invalid 12 123 55 77777 --"
|
||||
statement.description = 'all invalid 12 123 55 77777 --'
|
||||
assert_nil statement.parsed_ref_number
|
||||
end
|
||||
|
||||
|
@ -208,6 +211,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
transaction.bind_invoice('2222')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_payable_invoice(attributes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue