Skip to content

Instantly share code, notes, and snippets.

@MaxMorais
Last active December 7, 2018 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaxMorais/0ff73424af307763bcf74c92578862a8 to your computer and use it in GitHub Desktop.
Save MaxMorais/0ff73424af307763bcf74c92578862a8 to your computer and use it in GitHub Desktop.
Boleta UY
.print-format-gutter, .print-format, .page-break {
margin: 0px !important;
padding: 0px !important;
}
.hidden-pdf {
display: none;
}
.dados-boleta {
text-align: right !important;
}
.rut-comprador {
text-align: right !important;
}
@media print {
.print-format-gutter, .print-format, .page-break {
margin: 0px !important;
padding: 0px !important;
}
.row .section-break {
margin: 0px !important;
padding: 0px !important;
}
.table {
.margin-bottom: 0px !important;
.margin-top: 0px !important;
}
.items .table thead, .items .table tbody{
font-size: 9px !important;
}
}
{% set unit = "mm" %}
{% set page_height = 204 %}
{% set page_width = 121 %}
<div id="margin-top" class="hidden-pdf">0mm</div>
<div id="margin-bottom" class="hidden-pdf">0mm</div>
<div id="margin-left" class="hidden-pdf">0mm</div>
<div id="margin-right" class="hidden-pdf">0mm</div>
<div id="page-width" class="hidden-pdf">121mm</div>
<div id="page-height" class="hidden-pdf">204mm</div>
<div id="header-html">Hello</div>
<div id="footer-html">World</div>
{% for page in [0, 1, 2] %}
{% set increment = page * (page_height + 5) %}
<!-- flexible element top positions start here --!>
{% set dados = 15 + increment %}
{% set rut = 36 + increment %}
{% set consumidor = rut %}
{% set first = 50 + increment %}
{% set items = first + 1 %}
{% set oracion = 149 + increment %}
{% set totals = 152 + increment %}
{% set via = 174 + increment %}
{% set total = via %}
<!-- top positions end --!>
<div class="page-break" id="page-{{ page + 1 }}" style="min-width: {{ page_width - 1 }}{{ unit }} !important; max-width: {{ page_width }}{{ unit }};min-height: {{ page_height - 1 }}{{ unit }} !important; max-height: {{ page_height }}{{ unit }};">
{% set serie = doc.naming_series.replace("-", "") %}
{% set serie_no = doc.name.replace(serie+"-", "") %}
{% if doc.is_return %}
{% set comprobante = "Devolución de Contado" %}
{% elif doc.is_pos or doc.due_date == doc.posting_date %}
{% set comprobante = "B. Contado" %}
{% else %}
{% set comprobante = "B. Crédito" %}
{% endif %}
<div class="dados-boleta" style="position: fixed !important; left: 67mm !important; top: {{ dados }}{{ unit }} !important; width: 50mm !important; height: 15mm !important; font-size: 10px !important;">
{{ doc.get_formatted("posting_date") }} - {{ comprobante }} - <span class="text-small">{{ doc.name }}</span>
</div>
<div class="rut-comprador" style="position: fixed !important; left: 55mm !important; top: {{ rut }}{{ unit }} !important;width: 50mm !important;height: 10mm !important;font-size: 24px;">
{{ frappe.db.get_value("Customer", doc.customer, "tax_id") or "" }}
</div>
{% if (doc.is_pos) %}
<div class="consumidor-final" style="position: fixed !important;left: 109mm !important;top: {{ consumidor }}{{ unit }} !important;width: 10mm !important;height: 10mm !important;font-size: 20px;">X</div>
{% endif %}
<div class="via" style="position: fixed !important;left: 10mm !important;top: {{ via }}{{ unit }} !important;width: 30mm !important;height: 10mm !important;">
{% if page == 0 %}
Via Cliente
{% elif page == 1 %}
Via Contabilidad
{% else %}
Via Archivo
{% endif %}
</div>
<div class="total" style="position: fixed !important;left: 88mm !important;top: {{ total }}{{ unit }} !important; font-size: 16px !important;width: 30mm !important;height: 10mm !important;">
{{ doc.get_formatted("grand_total") }}
</div>
<div class="row section-break first" style="position: fixed !important; top: {{ first }}{{ unit }} !important;left: 4mm !important;width: 100%; text-size: 12px !important;">
<div class="col-xs-12">
<b>Razón Social:</b> {{ frappe.db.get_value("Customer", doc.customer, "razon_social") }}
{% if doc.customer_address %}
<br/><b>Domicilio:</b> {{ frappe.db.get_value("Address", doc.customer_address, "address_line1") }}
{% endif %}
</div>
</div>
<div class="row section-break items" style="position: fixed !important; top: {{ items }}{{ unit }} !important; left: 4mm !important; width: 100% !important;">
<div class="col-xs-12">
<br>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th rowspan="2" width="50%" class="text-center" style="vertical-align: bottom !important;">Detalle</th>
<th rowspan="2" colspan="2" width="20%" class="text-center" style="vertical-align: bottom !important;">Cantidad</th>
<th colspan="2" width="30%" class="text-center">Precio</th>
</tr>
<tr>
<th width="15%" class="text-center">Unitario</th>
<th width="15%" class="text-center">Total</th>
</tr>
</thead>
<tbody>
{% for row in doc.items %}
<tr>
<td>{{ row.item_name }}</td>
<td class="text-center">{{ row.get_formatted("qty") }} / <span>{{ row.stock_uom }}</span></td>
<td class="text-center">X</td>
<td class="text-center">{{ row.get_formatted("rate") }}</td>
<td class="text-center">{{ row.get_formatted("amount") }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="row section-break oracion" style="position: fixed !important; top: {{ oracion }}{{ unit }} !important; left: 4mm !important; width: 100 !important; font-size: 9px !important; border: 1px solid black !important; width: 100% !important; min-height: 5mm !important;">
Observaciónes: {{ doc.terms or "" }}
</div>
<div class="row section-break totals" style="position: fixed !important; top: {{ totals }}{{ unit }} !important;left: 4mm !important;width: 100% !important; text-size: 12px !important;">
<div class="col-xs-12">
<table class="table" width="100%">
<tbody>
<tr>
<td><b>{{ _(doc.meta.get_label("total")) }}</b></td>
{% if doc.apply_discount_on == "Net Total" and doc.discount_amount %}
<td><b>{{ _("Discount Amount") }}</b></td>
{% endif %}
{% for tax in doc.taxes %}
{% if not tax.included_in_print_rate %}
<td><b>{{ tax.get_formatted("description") }}</b></td>
{% endif %}
{% endfor %}
{% if doc.apply_discount_on == "Grand Total" and doc.discount_amount %}
<td><b>{{ _("Discount Amount") }}</b></td>
{% endif %}
<td><b>{{ _(doc.meta.get_label("grand_total")) }}</b></td>
</tr>
<tr>
<td>{{ doc.get_formatted("total") }} </td>
{% if doc.apply_discount_on == "Net Total" and doc.discount_amount %}
<td> - {{ doc.get_formatted("discount_amount") }}</td>
{% endif %}
{% for tax in doc.taxes %}
{% if not tax.included_in_print_rate %}
<td>{{ tax.get_formatted("tax_amount") }}</td>
{% endif %}
{% endfor %}
{% if doc.apply_discount_on == "Grand Total" and doc.discount_amount %}
<td> - {{ doc.get_formatted("discount_amount") }}</td>
{% endif %}
<td><b>{{ doc.get_formatted("grand_total") }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row section-break">
<div class="col-xs-12 text-center">&nbsp;</div>
</div>
</div>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment