Commit 89de62bc by Etienne Freiss

Merge branch '2482-receipt-meal-voucher-subtotal' into 'dev_cooperatic'

display subtotal eligible for meal vouchers on receipt

See merge request !33
parents 695c942f 56e5974c
......@@ -353,3 +353,16 @@ msgstr "Chèque restaurant"
msgid "To add a meal voucher ticket close this window and scan the ticket. If the ticket can't be read please enter the code"
msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et scanner le chèque. Si le chèque est illisible veuillez rentrer le code à la main."
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:92
#, python-format
msgid "Eligible amount for meal vouchers:"
msgstr "Montant éligible en tickets restaurant :"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:107
#, python-format
msgid "Eligible amount for meal vouchers:"
msgstr "Montant éligible en tickets restaurant :"
......@@ -61,17 +61,19 @@ odoo.define("pos_meal_voucher.models", function (require) {
}
});
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
this.orderlines.each(function(orderline){
var orderline_for_printing = orderline.export_for_printing()
if (
meal_voucher_used === true &&
orderline.product.meal_voucher_ok === true &&
orderline_for_printing.product_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === false
orderline_for_printing.product_name.includes(meal_voucher_symbol) === false
) {
orderline_for_printing.product_name = String.fromCharCode(0xD83C, 0xDF74) + " " + orderline_for_printing.product_name;
} else if (meal_voucher_used === false && orderline_for_printing.product_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === true) {
orderline_for_printing.product_name = orderline_for_printing.product_name.replace(String.fromCharCode(0xD83C, 0xDF74) + " ", "");
orderline_for_printing.product_name = meal_voucher_symbol + " " + orderline_for_printing.product_name;
} else if (meal_voucher_used === false && orderline_for_printing.product_name.includes(meal_voucher_symbol) === true) {
orderline_for_printing.product_name = orderline_for_printing.product_name.replace(meal_voucher_symbol + " ", "");
}
orderlines.push(orderline_for_printing);
......@@ -145,6 +147,8 @@ odoo.define("pos_meal_voucher.models", function (require) {
name: shop.name,
},
currency: this.pos.currency,
meal_voucher_used: meal_voucher_used,
total_meal_voucher_eligible: this.get_total_meal_voucher_eligible()
};
if (is_xml(this.pos.config.receipt_header)){
......
......@@ -408,23 +408,25 @@ odoo.define("pos_meal_voucher.screens", function (require) {
var paymentlines = order.get_paymentlines();
// Add fork&knife symbol on pos ticket for product with meal voucher allowed & when meal voucher is used
var meal_voucher_used = false;
order.meal_voucher_used = false;
for (var i = 0; i < paymentlines.length; i++) {
if (paymentlines[i].is_meal_voucher()) {
meal_voucher_used = true;
order.meal_voucher_used = true;
break;
}
};
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
for (var i = 0; i < orderlines.length; i++) {
if (
meal_voucher_used === true &&
order.meal_voucher_used === true &&
orderlines[i].product.meal_voucher_ok === true &&
orderlines[i].product.display_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === false
orderlines[i].product.display_name.includes(meal_voucher_symbol) === false
) {
orderlines[i].product.display_name = String.fromCharCode(0xD83C, 0xDF74) + " " + orderlines[i].product.display_name;
} else if (meal_voucher_used === false && orderlines[i].product.display_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === true) {
orderlines[i].product.display_name = orderlines[i].product.display_name.replace(String.fromCharCode(0xD83C, 0xDF74) + " ", "");
orderlines[i].product.display_name = meal_voucher_symbol + " " + orderlines[i].product.display_name;
} else if (order.meal_voucher_used === false && orderlines[i].product.display_name.includes(meal_voucher_symbol) === true) {
orderlines[i].product.display_name = orderlines[i].product.display_name.replace(meal_voucher_symbol + " ", "");
}
}
......
......@@ -84,4 +84,30 @@
</t>
</t>
<t t-extend="PosTicket">
<t t-jquery="table.receipt-total" t-operation="before">
<t t-if="order.meal_voucher_used === true">
<table class='receipt-eligible-meal-voucher'>
<tr>
<td>Eligible amount for meal vouchers:</td>
<td class="pos-right-align">
<t t-esc="widget.format_currency(order.get_total_meal_voucher_eligible())"/>
</td>
</tr>
</table>
<br/>
</t>
</t>
</t>
<t t-extend="XmlReceipt">
<t t-jquery="div.orderlines" t-operation="after">
<t t-if="receipt.meal_voucher_used === true">
<line><right>--------</right></line>
<line>
<left>Eligible amount for meal vouchers:</left>
<right><value t-att-value-decimals='pos.currency.decimals'><t t-esc='receipt.total_meal_voucher_eligible' /></value></right>
</line>
</t>
</t>
</t>
</templates>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment