Skip to content

Commit

Permalink
Merge pull request #1026 from 8848digital/custom_bank_reconciliation_…
Browse files Browse the repository at this point in the history
…tool

feat: modify bank reco erpnext
  • Loading branch information
tinadn authored Jan 14, 2025
2 parents 5eed582 + fd8d6c6 commit e482e07
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ frappe.ui.form.on("Bank Reconciliation Tool ERPNext", {
});
// frm.trigger("render_chart");
frm.trigger("get_account_opening_balance");
frm.doc.difference_amount = (frm.doc.closing_balance_as_per_bank_statement - frm.doc.closing_balance_as_per_erp)
frm.refresh_fields();
frm.add_custom_button(__("Get Unreconciled Entries"), function () {
frm.set_value(
"difference_amount",
(frm.doc.closing_balance_as_per_bank_statement - frm.doc.closing_balance_as_per_erp)
);
frappe.call({
method: "erpnext.accounts.doctype.bank_reconciliation_tool_erpnext.bank_reconciliation_tool_erpnext.get_bank_transaction",
args: {
Expand Down Expand Up @@ -175,8 +181,14 @@ frappe.ui.form.on("Bank Reconciliation Tool ERPNext", {
bnk_tr.deposit = 0;
}
} else if (i.doctype === "Journal Entry") {
bnk_tr.deposit = i.paid_amount;
bnk_tr.withdraw = i.paid_amount; // Confirm logic here.
if (i.bank == 'Credit'){
bnk_tr.deposit = 0;
bnk_tr.withdraw = i.paid_amount; // Confirm logic here.
}
else if (i.bank == 'Debit'){
bnk_tr.deposit = i.paid_amount;
bnk_tr.withdraw = 0; // Confirm logic here.
}
}

// Add the reference ID to the Set to track it
Expand All @@ -200,7 +212,7 @@ frappe.ui.form.on("Bank Reconciliation Tool ERPNext", {
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_account_balance",
args: {
bank_account: frm.doc.bank_account,
till_date: frappe.datetime.add_days(frm.doc.bank_statement_from_date, -1),
till_date: frappe.datetime.add_days(frm.doc.bank_statement_from_date, -1)
},
callback: (response) => {
frm.set_value("opening_balance", response.message);
Expand Down Expand Up @@ -300,7 +312,6 @@ frappe.ui.form.on("Bank Reconciliation Tool ERPNext", {
},
callback: () => {
frm.refresh();
frm.msgprint("Bank Transaction is Reconciled");
},
});
},
Expand All @@ -316,6 +327,8 @@ frappe.ui.form.on("Bank Reconciliation Tool ERPNext", {
payment_document: i.reference_to,
},
callback: function (r) {
frm.clear_table("matching_table");
frm.refresh();
// console.log('GHJJHJHJHJBBJ')
if (!r.exc) {
if (r.message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# For license information, please see license.txt

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import flt

Expand Down Expand Up @@ -142,21 +143,33 @@ def get_erp_transaction(bank_account, company, from_statement_date=None, to_stat
transaction_list = frappe.db.get_all(
"Bank Transaction", {"bank_account": bank_account, "status": "Unreconciled"}, pluck="name"
)
result = []
for i in transaction_list:
transaction = frappe.get_doc("Bank Transaction", i)
# print("++++++++++++++++++++++++++++++++")
# print(transaction_list)
# # print(transaction_list)
# print(get_linked_payments(transaction.name, document_types=["payment_entry","journal_entry"], from_date=from_statement_date, to_date=to_statement_date, filter_by_reference_date=None, from_reference_date=from_statement_date, to_reference_date=to_statement_date))
# print("++++++++++++++++++++++++++++++++")
return get_linked_payments(
transaction.name,
document_types=["payment_entry", "journal_entry"],
from_date=from_statement_date,
to_date=to_statement_date,
filter_by_reference_date=None,
from_reference_date=from_statement_date,
to_reference_date=to_statement_date,
)

for i in get_linked_payments(transaction.name, document_types=["payment_entry","journal_entry"], from_date=from_statement_date, to_date=to_statement_date, filter_by_reference_date=None, from_reference_date=from_statement_date, to_reference_date=to_statement_date):
if i['doctype'] == "Journal Entry":
list = frappe.db.get_all("Journal Entry Account",
{
'account': "IDFC Bank - PP Ltd",
'parent': i.name
},
['credit_in_account_currency', 'debit_in_account_currency', 'parent']
)
for j in list:
if j['credit_in_account_currency'] > 0:
i['bank'] = 'Credit'
elif j['debit_in_account_currency'] > 0:
i['bank'] = 'Debit'
result.append(i)
else:
result.append(i)

return result
# if from_statement_date and to_statement_date:
# pe_list = frappe.db.get_all("Payment Entry",filters={'posting_date': ['between' ,[from_statement_date, to_statement_date]], 'bank_account':bank_account, 'company': company}, fields = ['posting_date', 'paid_amount', 'reference_no', 'payment_type'])
# je_list = frappe.db.get_all("Journal Entry Account", filters={'bank_account': bank_account}, fields = ["parent", "account", "creation", "debit", "credit"])
Expand All @@ -178,6 +191,7 @@ def reconcile_bnk_transaction(bank_transaction_id, amount, name, payment_documen
)
try:
bnk_trn.save()
frappe.msgprint(_("Successfully Reconciled"))
except Exception as e:
frappe.msgprint("Please Reconcile again to ")

Expand Down

0 comments on commit e482e07

Please sign in to comment.