Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: account payable currency and value #36859

Merged
46 changes: 27 additions & 19 deletions erpnext/accounts/report/accounts_payable/accounts_payable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ frappe.query_reports["Accounts Payable"] = {
}
}
},
{
"fieldname": "supplier",
"label": __("Supplier"),
"fieldtype": "Link",
"options": "Supplier",
on_change: () => {
var supplier = frappe.query_report.get_filter_value('supplier');
if (supplier) {
frappe.db.get_value('Supplier', supplier, "tax_id", function(value) {
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
});
} else {
frappe.query_report.set_filter_value('tax_id', "");
}

frappe.query_report.refresh();
}
},
{
"fieldname": "party_account",
"label": __("Payable Account"),
Expand Down Expand Up @@ -112,11 +94,37 @@ frappe.query_reports["Accounts Payable"] = {
"fieldtype": "Link",
"options": "Payment Terms Template"
},
{
"fieldname": "party_type",
"label": __("Party Type"),
"fieldtype": "Link",
"options": "Party Type",
get_query: () => {
return {
filters: {
'account_type': 'Payable'
}
};
},
on_change: () => {
frappe.query_report.set_filter_value('party', "");
// hide supplier group and group_by_supplier filter if party type is employee
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') === "Employee")
frappe.query_report.toggle_filter_display('group_by_party', frappe.query_report.get_filter_value('party_type') === "Employee")
}

},
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "Dynamic Link",
"options": "party_type",
},
{
"fieldname": "supplier_group",
"label": __("Supplier Group"),
"fieldtype": "Link",
"options": "Supplier Group"
"options": "Supplier Group",
},
{
"fieldname": "group_by_party",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,10 @@ def update_voucher_balance(self, ple):
return

# amount in "Party Currency", if its supplied. If not, amount in company currency
for party_type in self.party_type:
if self.filters.get(scrub(party_type)):
amount = ple.amount_in_account_currency
else:
amount = ple.amount
if self.filters.get("party_type") and self.filters.get("party"):
amount = ple.amount_in_account_currency
else:
amount = ple.amount
amount_in_account_currency = ple.amount_in_account_currency

# update voucher
Expand Down Expand Up @@ -426,10 +425,9 @@ def set_party_details(self, row):
# customer / supplier name
party_details = self.get_party_details(row.party) or {}
row.update(party_details)
for party_type in self.party_type:
if self.filters.get(scrub(party_type)):
row.currency = row.account_currency
break

if self.filters.get("party_type") and self.filters.get("party"):
row.currency = row.account_currency
else:
row.currency = self.company_currency

Expand Down Expand Up @@ -765,6 +763,7 @@ def get_sales_invoices_or_customers_based_on_sales_person(self):
def prepare_conditions(self):
self.qb_selection_filter = []
self.or_filters = []

for party_type in self.party_type:
party_type_field = scrub(party_type)
self.or_filters.append(self.ple.party_type == party_type)
Expand Down Expand Up @@ -800,6 +799,12 @@ def add_common_filters(self, party_type_field):
if self.filters.get(party_type_field):
self.qb_selection_filter.append(self.ple.party == self.filters.get(party_type_field))

if self.filters.get("party_type"):
self.qb_selection_filter.append(self.filters.party_type == self.ple.party_type)

if self.filters.get("party"):
self.qb_selection_filter.append(self.filters.party == self.ple.party)

if self.filters.party_account:
self.qb_selection_filter.append(self.ple.account == self.filters.party_account)
else:
Expand Down