mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Change Invoice::Item price scale to 3 places
This commit is contained in:
parent
3decec8b02
commit
d62e55e6a1
5 changed files with 18 additions and 16 deletions
|
@ -82,7 +82,7 @@ class Invoice < ApplicationRecord
|
|||
end
|
||||
|
||||
def vat_amount
|
||||
subtotal * vat_rate / 100
|
||||
(subtotal * vat_rate / 100)
|
||||
end
|
||||
|
||||
def total
|
||||
|
@ -118,9 +118,8 @@ class Invoice < ApplicationRecord
|
|||
|
||||
vat = VatRateCalculator.new(registrar: registrar_user).calculate
|
||||
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)
|
||||
payable: false)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -130,6 +129,6 @@ class Invoice < ApplicationRecord
|
|||
end
|
||||
|
||||
def calculate_total
|
||||
self.total = subtotal + vat_amount
|
||||
self.total = (subtotal + vat_amount).round(3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class InvoiceItem < ApplicationRecord
|
|||
delegate :vat_rate, to: :invoice
|
||||
|
||||
def item_sum_without_vat
|
||||
(price * quantity).round(2)
|
||||
(price * quantity).round(3)
|
||||
end
|
||||
alias_method :subtotal, :item_sum_without_vat
|
||||
|
||||
|
@ -14,6 +14,6 @@ class InvoiceItem < ApplicationRecord
|
|||
end
|
||||
|
||||
def total
|
||||
subtotal + vat_amount
|
||||
(subtotal + vat_amount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ class Registrar < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def issue_prepayment_invoice(amount, description = nil, payable: true, total: nil)
|
||||
def issue_prepayment_invoice(amount, description = nil, payable: true)
|
||||
vat_rate = ::Invoice::VatRateCalculator.new(registrar: self).calculate
|
||||
|
||||
invoice = invoices.create!(
|
||||
|
@ -90,7 +90,6 @@ 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