Commit 56e5974c by Damien Moulard

display subtotal eligible for meal vouchers on receipt

parent 695c942f
...@@ -353,3 +353,16 @@ msgstr "Chèque restaurant" ...@@ -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" 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." 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 :"
...@@ -60,6 +60,8 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -60,6 +60,8 @@ odoo.define("pos_meal_voucher.models", function (require) {
meal_voucher_used = true; meal_voucher_used = true;
} }
}); });
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
this.orderlines.each(function(orderline){ this.orderlines.each(function(orderline){
var orderline_for_printing = orderline.export_for_printing() var orderline_for_printing = orderline.export_for_printing()
...@@ -67,11 +69,11 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -67,11 +69,11 @@ odoo.define("pos_meal_voucher.models", function (require) {
if ( if (
meal_voucher_used === true && meal_voucher_used === true &&
orderline.product.meal_voucher_ok === 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; 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(String.fromCharCode(0xD83C, 0xDF74)) === true) { } 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(String.fromCharCode(0xD83C, 0xDF74) + " ", ""); orderline_for_printing.product_name = orderline_for_printing.product_name.replace(meal_voucher_symbol + " ", "");
} }
orderlines.push(orderline_for_printing); orderlines.push(orderline_for_printing);
...@@ -100,7 +102,7 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -100,7 +102,7 @@ odoo.define("pos_meal_voucher.models", function (require) {
return qweb.render('subreceipt',{'pos':self.pos,'widget':self.pos.chrome,'order':self, 'receipt': receipt}) ; return qweb.render('subreceipt',{'pos':self.pos,'widget':self.pos.chrome,'order':self, 'receipt': receipt}) ;
} }
} }
var receipt = { var receipt = {
orderlines: orderlines, orderlines: orderlines,
paymentlines: paymentlines, paymentlines: paymentlines,
...@@ -145,6 +147,8 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -145,6 +147,8 @@ odoo.define("pos_meal_voucher.models", function (require) {
name: shop.name, name: shop.name,
}, },
currency: this.pos.currency, 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)){ if (is_xml(this.pos.config.receipt_header)){
......
...@@ -408,23 +408,25 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -408,23 +408,25 @@ odoo.define("pos_meal_voucher.screens", function (require) {
var paymentlines = order.get_paymentlines(); var paymentlines = order.get_paymentlines();
// Add fork&knife symbol on pos ticket for product with meal voucher allowed & when meal voucher is used // 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++) { for (var i = 0; i < paymentlines.length; i++) {
if (paymentlines[i].is_meal_voucher()) { if (paymentlines[i].is_meal_voucher()) {
meal_voucher_used = true; order.meal_voucher_used = true;
break; break;
} }
}; };
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
for (var i = 0; i < orderlines.length; i++) { for (var i = 0; i < orderlines.length; i++) {
if ( if (
meal_voucher_used === true && order.meal_voucher_used === true &&
orderlines[i].product.meal_voucher_ok === 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; orderlines[i].product.display_name = meal_voucher_symbol + " " + orderlines[i].product.display_name;
} else if (meal_voucher_used === false && orderlines[i].product.display_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === true) { } 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(String.fromCharCode(0xD83C, 0xDF74) + " ", ""); orderlines[i].product.display_name = orderlines[i].product.display_name.replace(meal_voucher_symbol + " ", "");
} }
} }
......
...@@ -84,4 +84,30 @@ ...@@ -84,4 +84,30 @@
</t> </t>
</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> </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