Improve invoice view

This commit is contained in:
Martin Lensment 2015-04-09 17:55:27 +03:00
parent 43e111add0
commit 6a47f38e80
14 changed files with 167 additions and 44 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -13,16 +13,28 @@ html
min-height: 100%
body
padding-bottom: 60px
padding-bottom: 130px
body > .container
height: 100%
background: #fff
padding: 60px 30px 30px 30px
h1, h2, h3, h4
margin-bottom: 0px !important
hr
margin-top: 10px !important
margin-bottom: 10px !important
.no-border
border: 0 !important
.footer
position: absolute
bottom: 0
width: 100%
height: 60px
background-color: black
height: 130px
background: image_url('bg.jpg')
color: white !important
background-size: 100%

View file

@ -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

View file

@ -1,3 +1,7 @@
class InvoiceItem < ActiveRecord::Base
belongs_to :invoice
def item_total_without_vat
amount * price
end
end

View file

@ -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
}
]
)

View file

@ -0,0 +1,20 @@
%h4= t('buyer')
%hr
%dl.dl-horizontal
%dt= t('name')
%dd= @invoice.buyer_name
%dt= t('reg_no')
%dd= @invoice.buyer_reg_no
%dt= t('address')
%dd= @invoice.buyer_address
%dt= t('phone')
%dd= @invoice.buyer_phone
%dt= t('url')
%dd= @invoice.buyer_url
%dt= t('email')
%dd= @invoice.buyer_email

View file

@ -0,0 +1,17 @@
%h4= t('details')
%hr
%dl.dl-horizontal
/ %dt= t('document_name')
/ %dd= t(@invoice.document_name)
%dt= t('issue_date')
%dd= l(@invoice.created_at)
%dt= t('due_date')
%dd= l(@invoice.due_date)
%dt= t('payment_term')
%dd= t(@invoice.payment_term)
%dt= t('description')
%dd= @invoice.description

View file

@ -0,0 +1,32 @@
%h4= t('items')
%hr
.table-responsive
%table.table.table-hover.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t('description')
%th{class: 'col-xs-2'}= t('unit')
%th{class: 'col-xs-2'}= t('amount')
%th{class: 'col-xs-2'}= t('price')
%th{class: 'col-xs-2'}= t('total')
%tbody
- @invoice.items.each do |x|
%tr
%td= t(x.description)
%td= x.unit
%td= x.amount
%td= x.price
%td= x.item_total_without_vat
%tfoot
%tr
%th{colspan: 3}
%th= t('total_without_vat')
%td= @invoice.total_without_vat
%tr
%th.no-border{colspan: 3}
%th= t('vat', vat_prc: (@invoice.vat_prc * 100).round)
%td= @invoice.total_vat
%tr
%th.no-border{colspan: 3}
%th= t('total')
%td= @invoice.total

View file

@ -1,37 +1,35 @@
.panel.panel-default
.panel-heading
%h3.panel-title= t('general')
.panel-body
%dl.dl-horizontal
%dt= t('name')
%dd= @invoice.seller_name
%h4= t('seller')
%hr
%dl.dl-horizontal
%dt= t('name')
%dd= @invoice.seller_name
%dt= t('reg_no')
%dd= @invoice.seller_reg_no
%dt= t('reg_no')
%dd= @invoice.seller_reg_no
%dt= t('iban')
%dd= @invoice.seller_iban
%dt= t('iban')
%dd= @invoice.seller_iban
%dt= t('bank')
%dd= @invoice.seller_bank
%dt= t('bank')
%dd= @invoice.seller_bank
%dt= t('swift')
%dd= @invoice.seller_swift
%dt= t('swift')
%dd= @invoice.seller_swift
%dt= t('vat_no')
%dd= @invoice.seller_vat_no
%dt= t('vat_no')
%dd= @invoice.seller_vat_no
%dt= t('address')
%dd= @invoice.seller_address
%dt= t('address')
%dd= @invoice.seller_address
%dt= t('phone')
%dd= @invoice.seller_phone
%dt= t('phone')
%dd= @invoice.seller_phone
%dt= t('url')
%dd= @invoice.seller_url
%dt= t('url')
%dd= @invoice.seller_url
%dt= t('email')
%dd= @invoice.seller_email
%dt= t('email')
%dd= @invoice.seller_email
%dt= t('issuer')
%dd= @invoice.seller_contact_name
%dt= t('issuer')
%dd= @invoice.seller_contact_name

View file

@ -0,0 +1,17 @@
%h4= t('total')
%hr
%dl.dl-horizontal
/ %dt= t('document_name')
/ %dd= t(@invoice.document_name)
%dt= t('issue_date')
%dd= l(@invoice.created_at)
%dt= t('due_date')
%dd= l(@invoice.due_date)
%dt= t('payment_term')
%dd= t(@invoice.payment_term)
%dt= t('description')
%dd= @invoice.description

View file

@ -2,11 +2,11 @@
%hr
.row
.col-md-6= render 'registrar/invoices/partials/seller'
.col-md-6= render 'registrar/invoices/partials/buyer'
/ .row
/ .col-md-12= render 'admin/domains/partials/tech_contacts'
/ .row
/ .col-md-12= render 'admin/domains/partials/admin_contacts'
.col-md-6= render 'registrar/invoices/partials/details'
.row
.col-md-12= render 'registrar/invoices/partials/buyer'
.row
.col-md-12= render 'registrar/invoices/partials/items'
/ .row
/ .col-md-12= render 'admin/domains/partials/statuses'
/ .row

View file

@ -647,3 +647,6 @@ en:
amount: 'Amount'
please_pay_the_following_invoice: 'Please pay the following invoice'
invoice_no: 'Invoice no. %{no}'
seller: 'Seller'
prepayment: 'Prepayment'
vat: 'VAT (%{vat_prc}%)'

View file

@ -4,9 +4,9 @@ class CreateInvoiceItems < ActiveRecord::Migration
t.integer :invoice_id
# t.string :product_code
t.string :description, null: false
t.string :item_unit
t.integer :item_amount
t.decimal :item_price
t.string :unit
t.integer :amount
t.decimal :price
t.timestamps
end

View file

@ -209,9 +209,9 @@ ActiveRecord::Schema.define(version: 20150413140933) do
create_table "invoice_items", force: :cascade do |t|
t.integer "invoice_id"
t.string "description", null: false
t.string "item_unit"
t.integer "item_amount"
t.decimal "item_price"
t.string "unit"
t.integer "amount"
t.decimal "price"
t.datetime "created_at"
t.datetime "updated_at"
end