Merge pull request #35825 from ruthra-kumar/convert_db_call_to_whitelisted_method

fix: multiple fixes in reconciliation tools
This commit is contained in:
ruthra kumar 2023-06-22 11:27:04 +05:30 committed by GitHub
commit 4e7deba2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 20 deletions

View File

@ -10,6 +10,7 @@ from frappe.model.document import Document
from frappe.query_builder.custom import ConstantColumn from frappe.query_builder.custom import ConstantColumn
from frappe.utils import cint, flt from frappe.utils import cint, flt
from erpnext import get_default_cost_center
from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount
from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import ( from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import (
get_amounts_not_reflected_in_system, get_amounts_not_reflected_in_system,
@ -140,6 +141,9 @@ def create_journal_entry_bts(
second_account second_account
) )
) )
company = frappe.get_value("Account", company_account, "company")
accounts = [] accounts = []
# Multi Currency? # Multi Currency?
accounts.append( accounts.append(
@ -149,6 +153,7 @@ def create_journal_entry_bts(
"debit_in_account_currency": bank_transaction.withdrawal, "debit_in_account_currency": bank_transaction.withdrawal,
"party_type": party_type, "party_type": party_type,
"party": party, "party": party,
"cost_center": get_default_cost_center(company),
} }
) )
@ -158,11 +163,10 @@ def create_journal_entry_bts(
"bank_account": bank_transaction.bank_account, "bank_account": bank_transaction.bank_account,
"credit_in_account_currency": bank_transaction.withdrawal, "credit_in_account_currency": bank_transaction.withdrawal,
"debit_in_account_currency": bank_transaction.deposit, "debit_in_account_currency": bank_transaction.deposit,
"cost_center": get_default_cost_center(company),
} }
) )
company = frappe.get_value("Account", company_account, "company")
journal_entry_dict = { journal_entry_dict = {
"voucher_type": entry_type, "voucher_type": entry_type,
"company": company, "company": company,

View File

@ -85,25 +85,29 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo
// check for any running reconciliation jobs // check for any running reconciliation jobs
if (this.frm.doc.receivable_payable_account) { if (this.frm.doc.receivable_payable_account) {
frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments").then((enabled) => { this.frm.call({
if(enabled) { doc: this.frm.doc,
this.frm.call({ method: 'is_auto_process_enabled',
'method': "erpnext.accounts.doctype.process_payment_reconciliation.process_payment_reconciliation.is_any_doc_running", callback: (r) => {
"args": { if (r.message) {
for_filter: { this.frm.call({
company: this.frm.doc.company, 'method': "erpnext.accounts.doctype.process_payment_reconciliation.process_payment_reconciliation.is_any_doc_running",
party_type: this.frm.doc.party_type, "args": {
party: this.frm.doc.party, for_filter: {
receivable_payable_account: this.frm.doc.receivable_payable_account company: this.frm.doc.company,
party_type: this.frm.doc.party_type,
party: this.frm.doc.party,
receivable_payable_account: this.frm.doc.receivable_payable_account
}
} }
} }).then(r => {
}).then(r => { if (r.message) {
if (r.message) { let doc_link = frappe.utils.get_form_link("Process Payment Reconciliation", r.message, true);
let doc_link = frappe.utils.get_form_link("Process Payment Reconciliation", r.message, true); let msg = __("Payment Reconciliation Job: {0} is running for this party. Can't reconcile now.", [doc_link]);
let msg = __("Payment Reconciliation Job: {0} is running for this party. Can't reconcile now.", [doc_link]); this.frm.dashboard.add_comment(msg, "yellow");
this.frm.dashboard.add_comment(msg, "yellow"); }
} });
}); }
} }
}); });
} }

View File

@ -252,6 +252,10 @@ class PaymentReconciliation(Document):
return difference_amount return difference_amount
@frappe.whitelist()
def is_auto_process_enabled(self):
return frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments")
@frappe.whitelist() @frappe.whitelist()
def calculate_difference_on_allocation_change(self, payment_entry, invoice, allocated_amount): def calculate_difference_on_allocation_change(self, payment_entry, invoice, allocated_amount):
invoice_exchange_map = self.get_invoice_exchange_map(invoice, payment_entry) invoice_exchange_map = self.get_invoice_exchange_map(invoice, payment_entry)