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.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,
},
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: 80,
},
];
}
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"],
`