File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
account_reconcile_oca/static/src Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ export class AccountReconcileDataWidget extends Component {
24
24
}
25
25
getReconcileLines ( ) {
26
26
var data = this . props . record . data [ this . props . name ] . data ;
27
+ const totals = {
28
+ debit : 0 ,
29
+ credit : 0 ,
30
+ balance : 0 ,
31
+ } ;
27
32
for ( var line in data ) {
28
33
data [ line ] . amount_format = fieldUtils . format . monetary (
29
34
data [ line ] . amount ,
@@ -64,8 +69,22 @@ export class AccountReconcileDataWidget extends Component {
64
69
data [ line ] . date_format = fieldUtils . format . date (
65
70
fieldUtils . parse . date ( data [ line ] . date , undefined , { isUTC : true } )
66
71
) ;
72
+ totals . debit += data [ line ] . debit || 0 ;
73
+ totals . credit += data [ line ] . credit || 0 ;
67
74
}
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} ;
69
88
}
70
89
onTrashLine ( ev , line ) {
71
90
ev . stopPropagation ( ) ;
Original file line number Diff line number Diff line change 106
106
<th class =" text-end" >Credit</th >
107
107
<th t-if =" ! props.record.data.is_reconciled" />
108
108
</thead >
109
+ <t t-set =" rec" t-value =" getReconcileLines()" />
109
110
<tbody >
110
111
<t
111
- t-foreach =" getReconcileLines() "
112
+ t-foreach =" rec.lines "
112
113
t-as =" reconcile_line"
113
114
t-key =" reconcile_line_index"
114
115
>
183
184
</td >
184
185
</tr >
185
186
</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 >
186
193
</tbody >
187
194
</table >
188
195
</t >
You can’t perform that action at this time.
0 commit comments