diff --git a/app/assets/images/eis-logo-et.png b/app/assets/images/eis-logo-et.png new file mode 100644 index 000000000..1bdf0a983 Binary files /dev/null and b/app/assets/images/eis-logo-et.png differ diff --git a/app/assets/stylesheets/registrar.sass b/app/assets/stylesheets/registrar.sass index 9441d99e6..2f2de0b32 100644 --- a/app/assets/stylesheets/registrar.sass +++ b/app/assets/stylesheets/registrar.sass @@ -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% diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 612083710..693967f5b 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -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 diff --git a/app/models/invoice_item.rb b/app/models/invoice_item.rb index 180f29522..0c7e6faf8 100644 --- a/app/models/invoice_item.rb +++ b/app/models/invoice_item.rb @@ -1,3 +1,7 @@ class InvoiceItem < ActiveRecord::Base belongs_to :invoice + + def item_total_without_vat + amount * price + end end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 2728642b7..6243bf2d9 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -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 } ] ) diff --git a/app/views/registrar/invoices/partials/_buyer.haml b/app/views/registrar/invoices/partials/_buyer.haml index e69de29bb..2201e65ac 100644 --- a/app/views/registrar/invoices/partials/_buyer.haml +++ b/app/views/registrar/invoices/partials/_buyer.haml @@ -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 diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/registrar/invoices/partials/_details.haml new file mode 100644 index 000000000..608dade76 --- /dev/null +++ b/app/views/registrar/invoices/partials/_details.haml @@ -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 diff --git a/app/views/registrar/invoices/partials/_items.haml b/app/views/registrar/invoices/partials/_items.haml new file mode 100644 index 000000000..a3c5613b4 --- /dev/null +++ b/app/views/registrar/invoices/partials/_items.haml @@ -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 diff --git a/app/views/registrar/invoices/partials/_seller.haml b/app/views/registrar/invoices/partials/_seller.haml index ab1957f45..91c15b695 100644 --- a/app/views/registrar/invoices/partials/_seller.haml +++ b/app/views/registrar/invoices/partials/_seller.haml @@ -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 diff --git a/app/views/registrar/invoices/partials/_total.haml b/app/views/registrar/invoices/partials/_total.haml new file mode 100644 index 000000000..247f84b64 --- /dev/null +++ b/app/views/registrar/invoices/partials/_total.haml @@ -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 diff --git a/app/views/registrar/invoices/show.haml b/app/views/registrar/invoices/show.haml index ef87ac4be..41619084d 100644 --- a/app/views/registrar/invoices/show.haml +++ b/app/views/registrar/invoices/show.haml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index cb21caa33..5fc476487 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}%)' diff --git a/db/migrate/20150408081917_create_invoice_items.rb b/db/migrate/20150408081917_create_invoice_items.rb index e4025a8fc..c884c3dda 100644 --- a/db/migrate/20150408081917_create_invoice_items.rb +++ b/db/migrate/20150408081917_create_invoice_items.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 7db3923fe..6546ff70f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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