diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 2f4be2e60..8e82bbea6 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -82,7 +82,7 @@ class Invoice < ApplicationRecord end def vat_amount - (subtotal * vat_rate / 100) + subtotal * vat_rate / 100 end def total @@ -117,9 +117,8 @@ 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(wo_vat, 'Direct top-up via bank transfer', - payable: false) + net = (transaction.sum / (1 + (vat / 100))) + registrar_user.issue_prepayment_invoice(net, 'Direct top-up via bank transfer', payable: false) end private diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 86ff5ef4d..4d3d9f926 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -101,6 +101,10 @@ class Registrar < ApplicationRecord ) SendEInvoiceJob.enqueue(invoice.id, payable: payable) + unless payable + InvoiceMailer.invoice_email(invoice: invoice, recipient: billing_email).deliver_now + end + invoice end