mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Improve invoice view
This commit is contained in:
parent
43e111add0
commit
6a47f38e80
14 changed files with 167 additions and 44 deletions
|
@ -7,4 +7,24 @@ class Invoice < ActiveRecord::Base
|
|||
def seller_address
|
||||
[seller_street, seller_city, seller_state, seller_zip].reject(&:blank?).compact.join(', ')
|
||||
end
|
||||
|
||||
def buyer_address
|
||||
[buyer_street, buyer_city, buyer_state, buyer_zip].reject(&:blank?).compact.join(', ')
|
||||
end
|
||||
|
||||
def items
|
||||
invoice_items
|
||||
end
|
||||
|
||||
def total_without_vat
|
||||
items.map(&:item_total_without_vat).sum
|
||||
end
|
||||
|
||||
def total_vat
|
||||
total_without_vat * vat_prc
|
||||
end
|
||||
|
||||
def total
|
||||
total_without_vat + total_vat
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
class InvoiceItem < ActiveRecord::Base
|
||||
belongs_to :invoice
|
||||
|
||||
def item_total_without_vat
|
||||
amount * price
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,9 +67,9 @@ class Registrar < ActiveRecord::Base
|
|||
invoice_items_attributes: [
|
||||
{
|
||||
description: 'prepayment',
|
||||
item_unit: 'piece',
|
||||
item_amount: 1,
|
||||
item_price: amount
|
||||
unit: 'piece',
|
||||
amount: 1,
|
||||
price: amount
|
||||
}
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue