diff options
| author | Antoine Prieels <anp@odoo.com> | 2020-08-19 13:49:02 +0000 |
|---|---|---|
| committer | Antoine Prieels <anp@odoo.com> | 2020-08-21 12:41:10 +0000 |
| commit | 379e4f0a72bc95798068735c0c7a8662d3a48b3b (patch) | |
| tree | 62af60fad32801bdcf2b3a96cd6a5b80669eb232 /addons/pos_restaurant/static/src/js/Screens | |
| parent | 25d63db3f850b989b9d37e016ef1ba492452058b (diff) | |
[ADD] pos_restaurant_adyen: Tipping on the receipt
The amount is authorized when the customer scans its card, then the
customer writes the tip on the receipt and the total amount is captured
when the waiter manually inputs the tip, either right after or at the
end of the day.
closes odoo/odoo#56148
Taskid: 2321771
Related: odoo/upgrade#1661
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/pos_restaurant/static/src/js/Screens')
| -rw-r--r-- | addons/pos_restaurant/static/src/js/Screens/TipScreen.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/addons/pos_restaurant/static/src/js/Screens/TipScreen.js b/addons/pos_restaurant/static/src/js/Screens/TipScreen.js index e17ad6f1470..84091103542 100644 --- a/addons/pos_restaurant/static/src/js/Screens/TipScreen.js +++ b/addons/pos_restaurant/static/src/js/Screens/TipScreen.js @@ -12,6 +12,11 @@ odoo.define('pos_restaurant.TipScreen', function (require) { this.state = useContext(this.currentOrder.uiState.TipScreen); this._totalAmount = this.currentOrder.get_total_with_tax(); } + mounted () { + if (this.env.pos.proxy.printer) { + this.printTipReceipt(); + } + } get overallAmountStr() { const tipAmount = parse.float(this.state.inputTipAmount || '0'); const original = this.env.pos.format_currency(this.totalAmount); @@ -92,6 +97,28 @@ odoo.define('pos_restaurant.TipScreen', function (require) { return { name: 'ProductScreen' }; } } + async printTipReceipt() { + const receipts = [ + this.currentOrder.selected_paymentline.ticket, + this.currentOrder.selected_paymentline.cashier_receipt + ]; + + for (let i = 0; i < receipts.length; i++) { + const data = receipts[i]; + var receipt = this.env.qweb.renderToString('TipReceipt', { + receipt: this.currentOrder.getOrderReceiptEnv().receipt, + data: data, + total: this.env.pos.format_currency(this.totalAmount), + }); + const printResult = await this.env.pos.proxy.printer.print_receipt(receipt); + if (!printResult.successful) { + await this.showPopup('ErrorPopup', { + title: printResult.message.title, + body: printResult.message.body, + }); + } + } + } } TipScreen.template = 'pos_restaurant.TipScreen'; |
