frappe.provide("erpnext.accounts.bank_reconciliation");
erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager {
constructor(opts) {
Object.assign(this, opts);
this.dialog_manager = new erpnext.accounts.bank_reconciliation.DialogManager(
this.company,
this.bank_account,
this.bank_statement_from_date,
this.bank_statement_to_date,
this.filtered_by_reference_date,
this.from_reference_date,
this.to_reference_date
);
this.make_dt();
}
make_dt() {
var me = this;
frappe.call({
method:
"erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_bank_transactions",
args: {
bank_account: this.bank_account,
from_date:this.bank_statement_from_date,
to_date:this.bank_statement_to_date
},
callback: function (response) {
me.format_data(response.message);
me.get_dt_columns();
me.get_datatable();
me.set_listeners();
},
});
}
get_dt_columns() {
this.columns = [
{
name: __("Date"),
editable: false,
width: 100,
},
{
name: __("Party Type"),
editable: false,
width: 95,
},
{
name: __("Party"),
editable: false,
width: 100,
},
{
name: __("Description"),
editable: false,
width: 350,
},
{
name: __("Deposit"),
editable: false,
width: 100,
format: (value) =>
"" +
format_currency(value, this.currency) +
"",
},
{
name: __("Withdrawal"),
editable: false,
width: 100,
format: (value) =>
"" +
format_currency(value, this.currency) +
"",
},
{
name: __("Unallocated Amount"),
editable: false,
width: 100,
format: (value) =>
"" +
format_currency(value, this.currency) +
"",
},
{
name: __("Reference Number"),
editable: false,
width: 140,
},
{
name: __("Actions"),
editable: false,
sortable: false,
focusable: false,
dropdown: false,
width: 100,
},
];
}
format_data(transactions) {
this.transactions = [];
if (transactions[0]) {
this.currency = transactions[0]["currency"];
}
this.transaction_dt_map = {};
let length;
transactions.forEach((row) => {
length = this.transactions.push(this.format_row(row));
this.transaction_dt_map[row["name"]] = length - 1;
});
}
format_row(row) {
return [
row["date"],
row["party_type"],
row["party"],
row["description"],
row["deposit"],
row["withdrawal"],
row["unallocated_amount"],
row["reference_number"],
`