[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) <sgv@odoo.com>
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
@@ -108,11 +108,23 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 d-flex flex-column justify-content-between" t-if="hasLines">
|
||||
<h4 class="d-flex flex-row mt-1">
|
||||
<span class="d-flex flex-row mt-1 text-muted">
|
||||
<span class="flex-grow-1">
|
||||
Total
|
||||
</span>
|
||||
<LunchCurrency currency="currency" amount="state.infos.total"/>
|
||||
</span>
|
||||
<span class="d-flex flex-row mt-1 text-muted">
|
||||
<span class="flex-grow-1">
|
||||
Already Paid
|
||||
</span>
|
||||
<LunchCurrency currency="currency" amount="state.infos.paid_subtotal"/>
|
||||
</span>
|
||||
<h4 class="d-flex flex-row mt-1">
|
||||
<span class="flex-grow-1">
|
||||
To Pay
|
||||
</span>
|
||||
<LunchCurrency currency="currency" amount="state.infos.unpaid_subtotal"/>
|
||||
</h4>
|
||||
<button class="btn btn-primary" t-if="canOrder" t-on-click="orderNow">Order Now</button>
|
||||
</div>
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user