From bb746fcbe4b8caaf7178e0443e2ed67e556e2839 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 19 Apr 2021 12:19:31 +0530 Subject: [PATCH 1/3] fix: Updated filters for process statement of accounts --- .../process_statement_of_accounts.html | 10 +++++----- .../process_statement_of_accounts.py | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html index 94ae79a0c6..b623898829 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html @@ -19,7 +19,7 @@ - {% for row in data %} + {% for row in data %} {% if(row.posting_date) %} {{ frappe.format(row.posting_date, 'Date') }} @@ -78,10 +78,10 @@ - {{ aging.range1 }} - {{ aging.range2 }} - {{ aging.range3 }} - {{ aging.range4 }} + {{ frappe.utils.fmt_money(aging.range1, currency=filters.presentation_currency) }} + {{ frappe.utils.fmt_money(aging.range2, currency=filters.presentation_currency) }} + {{ frappe.utils.fmt_money(aging.range3, currency=filters.presentation_currency) }} + {{ frappe.utils.fmt_money(aging.range4, currency=filters.presentation_currency) }} diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index 43fbb0600a..3cbf59448a 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -7,8 +7,9 @@ import frappe from frappe.model.document import Document from erpnext.accounts.report.general_ledger.general_ledger import execute as get_soa from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import execute as get_ageing -from frappe.core.doctype.communication.email import make +from erpnext import get_company_currency +from frappe.core.doctype.communication.email import make from frappe.utils.print_format import report_to_pdf from frappe.utils.pdf import get_pdf from frappe.utils import today, add_days, add_months, getdate, format_date @@ -64,16 +65,16 @@ def get_report_pdf(doc, consolidated=True): 'to_date': doc.to_date, 'company': doc.company, 'finance_book': doc.finance_book if doc.finance_book else None, - "account": doc.account if doc.account else None, + 'account': doc.account if doc.account else None, 'party_type': 'Customer', 'party': [entry.customer], + 'presentation_currency': doc.currency or get_company_currency(doc.company), 'group_by': doc.group_by, 'currency': doc.currency, 'cost_center': [cc.cost_center_name for cc in doc.cost_center], 'project': [p.project_name for p in doc.project], 'show_opening_entries': 0, 'include_default_book_entries': 0, - 'show_cancelled_entries': 1, 'tax_id': tax_id if tax_id else None }) col, res = get_soa(filters) From 135b852cf01e891e64c56289349cfcd54d124b26 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 19 Apr 2021 17:27:26 +0530 Subject: [PATCH 2/3] fix: Use party account currency --- .../process_statement_of_accounts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index 3cbf59448a..33c32ebce2 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -8,6 +8,7 @@ from frappe.model.document import Document from erpnext.accounts.report.general_ledger.general_ledger import execute as get_soa from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import execute as get_ageing from erpnext import get_company_currency +from erpnext.accounts.party import get_party_account_currency from frappe.core.doctype.communication.email import make from frappe.utils.print_format import report_to_pdf @@ -68,7 +69,8 @@ def get_report_pdf(doc, consolidated=True): 'account': doc.account if doc.account else None, 'party_type': 'Customer', 'party': [entry.customer], - 'presentation_currency': doc.currency or get_company_currency(doc.company), + 'presentation_currency': get_party_account_currency('Customer', entry.customer, doc.company) \ + or doc.currency or get_company_currency(doc.company), 'group_by': doc.group_by, 'currency': doc.currency, 'cost_center': [cc.cost_center_name for cc in doc.cost_center], From 968ec110f304e8c8f1710ddccef972c35d1cef73 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 26 Apr 2021 14:51:00 +0530 Subject: [PATCH 3/3] fix: Linting and translation issues --- .../process_statement_of_accounts.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index 33c32ebce2..b6149e89f5 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -4,13 +4,13 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from erpnext.accounts.report.general_ledger.general_ledger import execute as get_soa from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import execute as get_ageing from erpnext import get_company_currency from erpnext.accounts.party import get_party_account_currency -from frappe.core.doctype.communication.email import make from frappe.utils.print_format import report_to_pdf from frappe.utils.pdf import get_pdf from frappe.utils import today, add_days, add_months, getdate, format_date @@ -31,7 +31,7 @@ class ProcessStatementOfAccounts(Document): validate_template(self.body) if not self.customers: - frappe.throw(frappe._('Customers not selected.')) + frappe.throw(_('Customers not selected.')) if self.enable_auto_email: self.to_date = self.start_date @@ -60,6 +60,8 @@ def get_report_pdf(doc, consolidated=True): aging[0]['ageing_based_on'] = doc.ageing_based_on tax_id = frappe.get_doc('Customer', entry.customer).tax_id + presentation_currency = get_party_account_currency('Customer', entry.customer, doc.company) \ + or doc.currency or get_company_currency(doc.company) filters= frappe._dict({ 'from_date': doc.from_date, @@ -69,8 +71,7 @@ def get_report_pdf(doc, consolidated=True): 'account': doc.account if doc.account else None, 'party_type': 'Customer', 'party': [entry.customer], - 'presentation_currency': get_party_account_currency('Customer', entry.customer, doc.company) \ - or doc.currency or get_company_currency(doc.company), + 'presentation_currency': presentation_currency, 'group_by': doc.group_by, 'currency': doc.currency, 'cost_center': [cc.cost_center_name for cc in doc.cost_center], @@ -170,7 +171,7 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory): if customer_collection == 'Sales Person': customers = get_customers_based_on_sales_person(collection_name) if not bool(customers): - frappe.throw('No Customers found with selected options.') + frappe.throw(_('No Customers found with selected options.')) else: if customer_collection == 'Sales Partner': customers = frappe.get_list('Customer', fields=['name', 'email_id'], \ @@ -202,14 +203,14 @@ def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=Tr if len(billing_email) == 0 or (billing_email[0][0] is None): if billing_and_primary: - frappe.throw('No billing email found for customer: '+ customer_name) + frappe.throw(_("No billing email found for customer: {0}").format(customer_name)) else: return '' if billing_and_primary: primary_email = frappe.get_value('Customer', customer_name, 'email_id') if primary_email is None and int(primary_mandatory): - frappe.throw('No primary email found for customer: '+ customer_name) + frappe.throw(_("No primary email found for customer: {0}").format(customer_name)) return [primary_email or '', billing_email[0][0]] else: return billing_email[0][0] or ''