mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Test valid invoice sums when created by bank transaction
This commit is contained in:
parent
1a56fcf179
commit
3decec8b02
4 changed files with 25 additions and 5 deletions
|
@ -117,10 +117,10 @@ class Invoice < ApplicationRecord
|
|||
return unless registrar_user
|
||||
|
||||
vat = VatRateCalculator.new(registrar: registrar_user).calculate
|
||||
wo_vat = transaction.sum / (1 + (vat / 100))
|
||||
registrar_user.issue_prepayment_invoice(amount: wo_vat,
|
||||
description: 'Direct top-up via bank transfer',
|
||||
payable: false)
|
||||
wo_vat = (transaction.sum / (1 + (vat / 100)))
|
||||
|
||||
registrar_user.issue_prepayment_invoice(wo_vat, 'Direct top-up via bank transfer',
|
||||
payable: false, total: transaction.sum)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -54,7 +54,7 @@ class Registrar < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def issue_prepayment_invoice(amount, description = nil, payable: true)
|
||||
def issue_prepayment_invoice(amount, description = nil, payable: true, total: nil)
|
||||
vat_rate = ::Invoice::VatRateCalculator.new(registrar: self).calculate
|
||||
|
||||
invoice = invoices.create!(
|
||||
|
@ -90,6 +90,7 @@ class Registrar < ApplicationRecord
|
|||
buyer_email: email,
|
||||
reference_no: reference_no,
|
||||
vat_rate: vat_rate,
|
||||
total: total,
|
||||
items_attributes: [
|
||||
{
|
||||
description: 'prepayment',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue