From 669d7e1bcdef745a382a9ba8b8136d3f7fc4263d Mon Sep 17 00:00:00 2001 From: Florian Damhaut Date: Thu, 22 Jun 2023 14:33:51 +0000 Subject: [PATCH] [IMP] lunch: split total The total should be split between already paid and to pay closes odoo/odoo#126079 Task-id: 3349791 Signed-off-by: Sofie Gvaladze (sgv) --- addons/lunch/controllers/main.py | 7 ++++++- .../static/src/components/lunch_dashboard.xml | 14 +++++++++++++- addons/lunch/static/tests/lunch_kanban_tests.js | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/addons/lunch/controllers/main.py b/addons/lunch/controllers/main.py index 592fbf89ea5..840359bc20b 100644 --- a/addons/lunch/controllers/main.py +++ b/addons/lunch/controllers/main.py @@ -30,8 +30,13 @@ class LunchController(http.Controller): 'raw_state': line.state, 'state': translated_states[line.state], 'note': line.note} for line in lines.sorted('date')] + total = float_round(sum(line['price'] for line in lines), 2) + paid_subtotal = float_round(sum(line['price'] for line in lines if line['raw_state'] != 'new'), 2) + unpaid_subtotal = total - paid_subtotal infos.update({ - 'total': float_repr(float_round(sum(line['price'] for line in lines), 2), 2), + 'total': float_repr(total, 2), + 'paid_subtotal': float_repr(paid_subtotal, 2), + 'unpaid_subtotal': float_repr(unpaid_subtotal, 2), 'raw_state': self._get_state(lines), 'lines': lines, }) diff --git a/addons/lunch/static/src/components/lunch_dashboard.xml b/addons/lunch/static/src/components/lunch_dashboard.xml index 07f3f571b3e..8a335984c34 100644 --- a/addons/lunch/static/src/components/lunch_dashboard.xml +++ b/addons/lunch/static/src/components/lunch_dashboard.xml @@ -108,11 +108,23 @@
-

+ Total + + + + Already Paid + + + +

+ + To Pay + +

diff --git a/addons/lunch/static/tests/lunch_kanban_tests.js b/addons/lunch/static/tests/lunch_kanban_tests.js index c64d4649c5a..d4ab67e3ea7 100644 --- a/addons/lunch/static/tests/lunch_kanban_tests.js +++ b/addons/lunch/static/tests/lunch_kanban_tests.js @@ -279,6 +279,8 @@ QUnit.module('LunchKanban', (hooks) => { ], raw_state: "new", total: "4.95", + paid_subtotal: "0", + unpaid_subtotal: "4.95", }; await makeLunchView({ mockRPC: (route, args) => { @@ -328,6 +330,8 @@ QUnit.module('LunchKanban', (hooks) => { ], raw_state: "new", total: "4.95", + paid_subtotal: "0", + unpaid_subtotal: "4.95", }; await makeLunchView({ mockRPC: (route, args) => { @@ -348,6 +352,7 @@ QUnit.module('LunchKanban', (hooks) => { } ], total: 4.95 * 2, + unpaid_subtotal: 4.95 * 2, }; return Promise.resolve(true); @@ -377,6 +382,8 @@ QUnit.module('LunchKanban', (hooks) => { ], raw_state: "new", total: "4.95", + paid_subtotal: "0", + unpaid_subtotal: "4.95", }; await makeLunchView({ mockRPC: (route, args) => {