fix: Issues in Bank Reconciliation tool
(cherry picked from commit ff183ee895fb0dd1ca595eb76e2286695063315a)
This commit is contained in:
parent
b8c212aaef
commit
d807d78313
@ -218,6 +218,8 @@ def reconcile_vouchers(bank_transaction_name, vouchers):
|
|||||||
# updated clear date of all the vouchers based on the bank transaction
|
# updated clear date of all the vouchers based on the bank transaction
|
||||||
vouchers = json.loads(vouchers)
|
vouchers = json.loads(vouchers)
|
||||||
transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
|
transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
|
||||||
|
company_account = frappe.db.get_value('Bank Account', transaction.bank_account, 'account')
|
||||||
|
|
||||||
if transaction.unallocated_amount == 0:
|
if transaction.unallocated_amount == 0:
|
||||||
frappe.throw(_("This bank transaction is already fully reconciled"))
|
frappe.throw(_("This bank transaction is already fully reconciled"))
|
||||||
total_amount = 0
|
total_amount = 0
|
||||||
@ -226,7 +228,7 @@ def reconcile_vouchers(bank_transaction_name, vouchers):
|
|||||||
total_amount += get_paid_amount(frappe._dict({
|
total_amount += get_paid_amount(frappe._dict({
|
||||||
'payment_document': voucher['payment_doctype'],
|
'payment_document': voucher['payment_doctype'],
|
||||||
'payment_entry': voucher['payment_name'],
|
'payment_entry': voucher['payment_name'],
|
||||||
}), transaction.currency)
|
}), transaction.currency, company_account)
|
||||||
|
|
||||||
if total_amount > transaction.unallocated_amount:
|
if total_amount > transaction.unallocated_amount:
|
||||||
frappe.throw(_("The Sum Total of Amounts of All Selected Vouchers Should be Less than the Unallocated Amount of the Bank Transaction"))
|
frappe.throw(_("The Sum Total of Amounts of All Selected Vouchers Should be Less than the Unallocated Amount of the Bank Transaction"))
|
||||||
@ -261,7 +263,7 @@ def get_linked_payments(bank_transaction_name, document_types = None):
|
|||||||
return matching
|
return matching
|
||||||
|
|
||||||
def check_matching(bank_account, company, transaction, document_types):
|
def check_matching(bank_account, company, transaction, document_types):
|
||||||
# combine all types of vocuhers
|
# combine all types of vouchers
|
||||||
subquery = get_queries(bank_account, company, transaction, document_types)
|
subquery = get_queries(bank_account, company, transaction, document_types)
|
||||||
filters = {
|
filters = {
|
||||||
"amount": transaction.unallocated_amount,
|
"amount": transaction.unallocated_amount,
|
||||||
@ -343,13 +345,11 @@ def get_pe_matching_query(amount_condition, account_from_to, transaction):
|
|||||||
def get_je_matching_query(amount_condition, transaction):
|
def get_je_matching_query(amount_condition, transaction):
|
||||||
# get matching journal entry query
|
# get matching journal entry query
|
||||||
|
|
||||||
|
# We have mapping at the bank level
|
||||||
|
# So one bank could have both types of bank accounts like asset and liability
|
||||||
|
# So cr_or_dr should be judged only on basis of withdrawal and deposit and not account type
|
||||||
company_account = frappe.get_value("Bank Account", transaction.bank_account, "account")
|
company_account = frappe.get_value("Bank Account", transaction.bank_account, "account")
|
||||||
root_type = frappe.get_value("Account", company_account, "root_type")
|
cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
|
||||||
|
|
||||||
if root_type == "Liability":
|
|
||||||
cr_or_dr = "debit" if transaction.withdrawal > 0 else "credit"
|
|
||||||
else:
|
|
||||||
cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
|
|
||||||
|
|
||||||
return f"""
|
return f"""
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ def get_total_allocated_amount(payment_entry):
|
|||||||
AND
|
AND
|
||||||
bt.docstatus = 1""", (payment_entry.payment_document, payment_entry.payment_entry), as_dict=True)
|
bt.docstatus = 1""", (payment_entry.payment_document, payment_entry.payment_entry), as_dict=True)
|
||||||
|
|
||||||
def get_paid_amount(payment_entry, currency):
|
def get_paid_amount(payment_entry, currency, bank_account):
|
||||||
if payment_entry.payment_document in ["Payment Entry", "Sales Invoice", "Purchase Invoice"]:
|
if payment_entry.payment_document in ["Payment Entry", "Sales Invoice", "Purchase Invoice"]:
|
||||||
|
|
||||||
paid_amount_field = "paid_amount"
|
paid_amount_field = "paid_amount"
|
||||||
@ -115,7 +115,7 @@ def get_paid_amount(payment_entry, currency):
|
|||||||
payment_entry.payment_entry, paid_amount_field)
|
payment_entry.payment_entry, paid_amount_field)
|
||||||
|
|
||||||
elif payment_entry.payment_document == "Journal Entry":
|
elif payment_entry.payment_document == "Journal Entry":
|
||||||
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "total_credit")
|
return frappe.db.get_value('Journal Entry Account', {'parent': payment_entry.payment_entry, 'account': bank_account}, "sum(credit_in_account_currency)", debug=1)
|
||||||
|
|
||||||
elif payment_entry.payment_document == "Expense Claim":
|
elif payment_entry.payment_document == "Expense Claim":
|
||||||
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "total_amount_reimbursed")
|
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "total_amount_reimbursed")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user