Skip to content

Commit a767b7e

Browse files
committed
[IMP] account_reconcile_oca: show open balance
1 parent c031db9 commit a767b7e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

account_reconcile_oca/static/src/js/widgets/reconcile_data_widget.esm.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export class AccountReconcileDataWidget extends Component {
2424
}
2525
getReconcileLines() {
2626
var data = this.props.record.data[this.props.name].data;
27+
const totals = {
28+
debit: 0,
29+
credit: 0,
30+
balance: 0,
31+
};
2732
for (var line in data) {
2833
data[line].amount_format = fieldUtils.format.monetary(
2934
data[line].amount,
@@ -64,8 +69,22 @@ export class AccountReconcileDataWidget extends Component {
6469
data[line].date_format = fieldUtils.format.date(
6570
fieldUtils.parse.date(data[line].date, undefined, {isUTC: true})
6671
);
72+
totals.debit += data[line].debit || 0;
73+
totals.credit += data[line].credit || 0;
6774
}
68-
return data;
75+
const firstLine = Object.values(data)[0] || {};
76+
totals.balance = totals.debit - totals.credit;
77+
if (totals.balance < 0) {
78+
const openCredit = Math.abs(totals.balance);
79+
totals.open_debit_format = fieldUtils.format.monetary(openCredit, {
80+
currency: session.get_currency(firstLine.currency_id),
81+
});
82+
} else if (totals.balance > 0) {
83+
totals.open_credit_format = fieldUtils.format.monetary(totals.balance, {
84+
currency: session.get_currency(firstLine.currency_id),
85+
});
86+
}
87+
return {lines: data, totals};
6988
}
7089
onTrashLine(ev, line) {
7190
ev.stopPropagation();

account_reconcile_oca/static/src/xml/reconcile.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@
106106
<th class="text-end">Credit</th>
107107
<th t-if="! props.record.data.is_reconciled" />
108108
</thead>
109+
<t t-set="rec" t-value="getReconcileLines()" />
109110
<tbody>
110111
<t
111-
t-foreach="getReconcileLines()"
112+
t-foreach="rec.lines"
112113
t-as="reconcile_line"
113114
t-key="reconcile_line_index"
114115
>
@@ -183,6 +184,12 @@
183184
</td>
184185
</tr>
185186
</t>
187+
<tr class="text-muted" t-if="rec.totals.balance">
188+
<td colspan="5"> Open Balance</td>
189+
<td class="text-end" t-esc="rec.totals.open_debit_format" />
190+
<td class="text-end" t-esc="rec.totals.open_credit_format" />
191+
<td />
192+
</tr>
186193
</tbody>
187194
</table>
188195
</t>

0 commit comments

Comments
 (0)