mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
parent
1107dc67b8
commit
169c67839e
5 changed files with 34 additions and 3 deletions
|
@ -35,6 +35,7 @@ class Invoice < ActiveRecord::Base
|
|||
before_create :set_invoice_number
|
||||
before_create :apply_default_vat_rate, unless: :vat_rate?
|
||||
before_create :calculate_total, unless: :total?
|
||||
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
|
||||
|
||||
attribute :vat_rate, ::Type::VATRate.new
|
||||
attr_readonly :vat_rate
|
||||
|
@ -169,6 +170,10 @@ class Invoice < ActiveRecord::Base
|
|||
self.vat_rate = buyer.effective_vat_rate
|
||||
end
|
||||
|
||||
def apply_default_buyer_vat_no
|
||||
self.buyer_vat_no = buyer.vat_no
|
||||
end
|
||||
|
||||
def calculate_total
|
||||
self.total = subtotal + vat_amount
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue