Skip to content

Commit

Permalink
fix: default_advance_account field in Process Payment Reconciliation
Browse files Browse the repository at this point in the history
(cherry picked from commit 143209f)

# Conflicts:
#	erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.json
#	erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.py
  • Loading branch information
ljain112 authored and mergify[bot] committed Sep 6, 2024
1 parent f4032b6 commit 3691a50
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ frappe.ui.form.on("Process Payment Reconciliation", {
},
};
});

frm.set_query("default_advance_account", function (doc) {
return {
filters: {
company: doc.company,
is_group: 0,
account_type: doc.party_type == "Customer" ? "Receivable" : "Payable",
root_type: doc.party_type == "Customer" ? "Liability" : "Asset",
},
};
});
frm.set_query("cost_center", function (doc) {
return {
filters: {
Expand Down Expand Up @@ -102,13 +113,15 @@ frappe.ui.form.on("Process Payment Reconciliation", {
company(frm) {
frm.set_value("party", "");
frm.set_value("receivable_payable_account", "");
frm.set_value("default_advance_account", "");
},
party_type(frm) {
frm.set_value("party", "");
},

party(frm) {
frm.set_value("receivable_payable_account", "");
frm.set_value("default_advance_account", "");
if (!frm.doc.receivable_payable_account && frm.doc.party_type && frm.doc.party) {
return frappe.call({
method: "erpnext.accounts.party.get_party_account",
Expand All @@ -119,7 +132,12 @@ frappe.ui.form.on("Process Payment Reconciliation", {
},
callback: (r) => {
if (!r.exc && r.message) {
frm.set_value("receivable_payable_account", r.message);
if (typeof r.message === "string") {
frm.set_value("receivable_payable_account", r.message);
} else if (Array.isArray(r.message)) {
frm.set_value("receivable_payable_account", r.message[0]);
frm.set_value("default_advance_account", r.message[1]);
}
}
frm.refresh();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"column_break_io6c",
"party",
"receivable_payable_account",
"default_advance_account",
"filter_section",
"from_invoice_date",
"to_invoice_date",
Expand Down Expand Up @@ -141,12 +142,27 @@
{
"fieldname": "section_break_a8yx",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:doc.party",
"description": "Only 'Payment Entries' made against this advance account are supported.",
"documentation_url": "https://docs.erpnext.com/docs/user/manual/en/advance-in-separate-party-account",
"fieldname": "default_advance_account",
"fieldtype": "Link",
"label": "Default Advance Account",
"mandatory_depends_on": "doc.party_type",
"options": "Account",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
<<<<<<< HEAD
"modified": "2023-08-11 10:56:51.699137",
=======
"modified": "2024-08-27 14:48:56.715320",
>>>>>>> 143209f91a (fix: `default_advance_account` field in Process Payment Reconciliation)
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Payment Reconciliation",
Expand Down Expand Up @@ -180,4 +196,4 @@
"sort_order": "DESC",
"states": [],
"title_field": "company"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@


class ProcessPaymentReconciliation(Document):
<<<<<<< HEAD
=======
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from frappe.types import DF

amended_from: DF.Link | None
bank_cash_account: DF.Link | None
company: DF.Link
cost_center: DF.Link | None
default_advance_account: DF.Link
error_log: DF.LongText | None
from_invoice_date: DF.Date | None
from_payment_date: DF.Date | None
party: DF.DynamicLink
party_type: DF.Link
receivable_payable_account: DF.Link
status: DF.Literal[
"", "Queued", "Running", "Paused", "Completed", "Partially Reconciled", "Failed", "Cancelled"
]
to_invoice_date: DF.Date | None
to_payment_date: DF.Date | None
# end: auto-generated types

>>>>>>> 143209f91a (fix: `default_advance_account` field in Process Payment Reconciliation)
def validate(self):
self.validate_receivable_payable_account()
self.validate_bank_cash_account()
Expand Down Expand Up @@ -76,6 +105,7 @@ def get_pr_instance(doc: str):
"party_type",
"party",
"receivable_payable_account",
"default_advance_account",
"from_invoice_date",
"to_invoice_date",
"from_payment_date",
Expand Down

0 comments on commit 3691a50

Please sign in to comment.