internetee-registry/app/views/invoice/pdf.haml
Artur Beljajev 27ea790b28 Refactor invoice PDF generation, download and delivery
- Remove `Que::Mailer` (#895)
- Extract controllers
- Extract translations
- Convert HAML to ERB
- Add mailer preview
- Improve UI
- Remove unused routes
- Add tests
2019-04-11 13:04:42 +03:00

285 lines
6.4 KiB
Text

%html{lang: I18n.locale.to_s}
%head
%meta{charset: "utf-8"}
:css
.container {
margin: auto;
font-size: 12px;
}
.col-md-12 {
}
.col-md-6 {
width: 49%;
display: inline-block;
}
.col-xs-4 {
width: 33%;
}
.col-xs-2 {
width: 16%;
}
.col-md-3 {
width: 24%;
display: inline-block;
}
.left {
float: left;
}
.left {
padding-right: 5px;
}
.right {
float: right;
}
.text-right {
text-align: right;
}
dt {
float: left;
width: 100px;
clear: left;
text-align: right;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
line-height: 1.42857;
}
dd {
margin-left: 120px;
line-height: 1.42857;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
th {
text-align: left;
border: 0px;
border-top: 1px solid #DDD;
padding: 6px;
}
thead th {
border-bottom: 2px solid #DDD;
border-top: 0px;
}
td {
border-top: 1px solid #DDD;
}
td {
padding: 6px;
}
.no-border {
border: 0px;
}
hr {
height: 1px;
border: 0;
color: #DDD;
background-color: #DDD;
}
.clear {
clear: both;
}
.pull-down {
margin-top: 50px;
}
#header {
position: relative;
min-height: 100px;
}
img {
width: 106px;
height: 102px;
}
#header-content {
position: absolute;
bottom: 0;
}
#footer {
position: absolute;
bottom: 0px;
width: 99%;
}
h1 {
margin-bottom: 5px;
}
%body
.container
#header.row
.col-sm-6.left
#header-content
%h1
= @invoice
.col-sm-6.right
%img{src: "#{Rails.root}/public/eis-logo-black-et.png"}
.clear
%hr
.row
.col-md-6.left
%h4
Details
%hr
%dl.dl-horizontal
%dt= t(:issue_date)
%dd= l @invoice.issue_date
- if @invoice.cancelled?
%dt= Invoice.human_attribute_name :cancelled_at
%dd= l @invoice.cancelled_at
%dt= t(:due_date)
- if @invoice.cancelled?
%dd= t(:cancelled)
- else
%dd= l @invoice.due_date
%dt= Invoice.human_attribute_name :receipt_date
- if @invoice.paid?
%dd= l @invoice.receipt_date
- elsif @invoice.cancelled?
%dd= t(:cancelled)
- else
%dd{class: 'text-danger'}= t(:unpaid)
%dt= t(:issuer)
%dd= @invoice.seller_contact_name
%dt= t(:payment_term)
%dd Prepayment
%dt= t(:invoice_number)
%dd= @invoice.number
- if @invoice.description.present?
%dt= t(:description)
%dd=@invoice.description
%dt= Invoice.human_attribute_name :reference_no
%dd= @invoice.reference_no
.col-md-6.right
%h4= t(:client)
%hr
%dl.dl-horizontal
%dt= t(:name)
%dd= @invoice.buyer_name
%dt= t(:reg_no)
%dd= @invoice.buyer_reg_no
- if @invoice.buyer_address.present?
%dt= t(:address)
%dd= @invoice.buyer_address
- if @invoice.buyer_country.present?
%dt= t(:country)
%dd= @invoice.buyer_country
- if @invoice.buyer_phone.present?
%dt= t(:phone)
%dd= @invoice.buyer_phone
- if @invoice.buyer_phone.present?
%dt= t(:url)
%dd= @invoice.buyer_url
- if @invoice.buyer_email.present?
%dt= t(:email)
%dd= @invoice.buyer_email
.clear
.row.pull-down
.col-md-12
.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-1'}= InvoiceItem.human_attribute_name :quantity
%th{class: 'col-xs-3'}= t(:price)
%th{class: 'col-xs-2'}= t(:total)
%tbody
- @invoice.each do |invoice_item|
%tr
%td= invoice_item.description
%td= invoice_item.unit
%td= invoice_item.quantity
%td= currency(invoice_item.price)
%td= "#{currency(invoice_item.item_sum_without_vat)} #{@invoice.currency}"
%tfoot
%tr
%th{colspan: 3}
%th= Invoice.human_attribute_name :subtotal
%td= number_to_currency @invoice.subtotal
%tr
%th.no-border{colspan: 3}
%th= "VAT #{number_to_percentage(@invoice.vat_rate, precision: 1)}"
%td= number_to_currency @invoice.vat_amount
%tr
%th.no-border{colspan: 3}
%th= t(:total)
%td= number_to_currency @invoice.total
#footer
%hr
.row
.col-md-3.left
= @invoice.seller_name
%br
= @invoice.seller_address
%br
= @invoice.seller_country
%br
= "#{t('reg_no')} #{@invoice.seller_reg_no}"
%br
= "#{Registrar.human_attribute_name :vat_no} #{@invoice.seller_vat_no}"
.col-md-3.left
= @invoice.seller_phone
%br
= @invoice.seller_email
%br
= @invoice.seller_url
.col-md-3.text-right.left
= t(:bank)
%br
= t(:iban)
%br
= t(:swift)
.col-md-3.left
= @invoice.seller_bank
%br
= @invoice.seller_iban
%br
= @invoice.seller_swift