Commit 07d82be9 by Etienne Freiss

Merge branch '2613-fix-pos-ticket-with-meal-vouchers' into 'dev_cooperatic'

2613-fix-pos-ticket-with-meal-vouchers

See merge request !34
parents 5743b9cb 28ea6dd1
......@@ -355,21 +355,21 @@ msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et sca
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:96
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:101
#, python-format
msgid "Eligible subtotal for meal vouchers:"
msgstr "Sous-total éligible en tickets restaurant :"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:110
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:120
#, python-format
msgid "Eligible subtotal for"
msgstr "Sous-total éligible en"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:112
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:122
#, python-format
msgid "meal vouchers:"
msgstr "tickets restaurant :"
......@@ -43,42 +43,33 @@ odoo.define("pos_meal_voucher.models", function (require) {
}
}), 0), this.pos.currency.rounding);
},
/* point_of_sale/statis/src/js/models.js */
export_for_printing: function(){
var orderlines = [];
var self = this;
var paymentlines = [];
// Add fork&knife symbol on pos ticket for products with meal voucher allowed & when meal voucher is used
is_meal_voucher_used: function() {
var meal_voucher_used = false;
this.paymentlines.each(function(paymentline){
var line = paymentline.export_for_printing();
paymentlines.push(line);
this.paymentlines.each( function(paymentline) {
if (paymentline.is_meal_voucher()) {
meal_voucher_used = true;
return false;
}
});
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
return meal_voucher_used;
},
/* point_of_sale/statis/src/js/models.js */
export_for_printing: function(){
var orderlines = [];
var self = this;
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(meal_voucher_symbol) === false
) {
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 + " ", "");
}
var orderline_for_printing = orderline.export_for_printing();
orderline_for_printing.product_meal_voucher_ok = orderline.product.meal_voucher_ok;
orderlines.push(orderline_for_printing);
});
var paymentlines = [];
this.paymentlines.each(function(paymentline){
paymentlines.push(paymentline.export_for_printing());
});
var client = this.get('client');
var cashier = this.pos.cashier || this.pos.user;
var company = this.pos.company;
......@@ -147,7 +138,7 @@ odoo.define("pos_meal_voucher.models", function (require) {
name: shop.name,
},
currency: this.pos.currency,
meal_voucher_used: meal_voucher_used,
meal_voucher_used: this.is_meal_voucher_used(),
total_meal_voucher_eligible: this.get_total_meal_voucher_eligible()
};
......
......@@ -403,39 +403,15 @@ odoo.define("pos_meal_voucher.screens", function (require) {
/* point_of_sale/statis/src/js/screens.js */
screens.ReceiptScreenWidget.include({
render_receipt: function() {
var order = this.pos.get_order();
var orderlines = order.get_orderlines();
var paymentlines = order.get_paymentlines();
// Add fork&knife symbol on pos ticket for product with meal voucher allowed & when meal voucher is used
order.meal_voucher_used = false;
for (var i = 0; i < paymentlines.length; i++) {
if (paymentlines[i].is_meal_voucher()) {
order.meal_voucher_used = true;
break;
}
};
var order = this.pos.get_order();
order.meal_voucher_used = order.is_meal_voucher_used();
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
for (var i = 0; i < orderlines.length; i++) {
if (
order.meal_voucher_used === true &&
orderlines[i].product.meal_voucher_ok === true &&
orderlines[i].product.display_name.includes(meal_voucher_symbol) === false
) {
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 + " ", "");
}
}
this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
widget:this,
order: order,
receipt: order.export_for_printing(),
orderlines: orderlines,
paymentlines: paymentlines
orderlines: order.get_orderlines(),
paymentlines: order.get_paymentlines()
}));
}
});
......
......@@ -84,8 +84,13 @@
</t>
</t>
<t t-extend="PosTicket">
<t t-jquery="table.receipt-total" t-operation="before">
<t t-extend="PosTicket"> <!-- Ticket displayed on screen -->
<t t-jquery="table.receipt-orderlines tr td:first" t-operation="prepend"> <!-- Add cutlery on orderline if needed -->
<t t-if="order.meal_voucher_used === true and orderline.get_product().meal_voucher_ok === true">
<i class="fa fa-cutlery" />
</t>
</t>
<t t-jquery="table.receipt-total" t-operation="before"> <!-- meal voucher subtotal-->
<t t-if="order.meal_voucher_used === true">
<table class='receipt-eligible-meal-voucher'>
<colgroup>
......@@ -93,7 +98,7 @@
<col width='25%' />
</colgroup>
<tr>
<td>Eligible subtotal for meal vouchers:</td>
<td><i class="fa fa-cutlery"/> Eligible subtotal for meal vouchers:</td>
<td class="pos-right-align">
<t t-esc="widget.format_currency(order.get_total_meal_voucher_eligible())"/>
</td>
......@@ -103,11 +108,16 @@
</t>
</t>
</t>
<t t-extend="XmlReceipt">
<t t-extend="XmlReceipt"> <!-- Ticket sent to the printer -->
<t t-jquery="div.orderlines line:not([indent]) left" t-operation="prepend"> <!-- hack to get product name line (lines with qty have 'indent' attr) -->
<t t-if='receipt.meal_voucher_used === true and line.product_meal_voucher_ok === true'>
<i class="fa fa-cutlery" />
</t>
</t>
<t t-jquery="div.orderlines" t-operation="after">
<t t-if="receipt.meal_voucher_used === true">
<line><right>--------</right></line>
<line><left>Eligible subtotal for</left></line>
<line><left><i class="fa fa-cutlery"/> Eligible subtotal for</left></line>
<line>
<left>meal vouchers:</left>
<right><value t-att-value-decimals='pos.currency.decimals'><t t-esc='receipt.total_meal_voucher_eligible' /></value></right>
......
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