From b3d565c91faca2b06d6814a6ea69e0191b267b7e Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Mon, 19 Jun 2023 19:54:03 +0530 Subject: [PATCH 1/4] feat: Provision to send Accounts Receivable Reports using Process Statement of Accounts Issue #35707 --- .../process_statement_of_accounts.html | 2 +- .../process_statement_of_accounts.js | 14 + .../process_statement_of_accounts.json | 67 ++- .../process_statement_of_accounts.py | 191 ++++++--- .../accounts_receivable.html | 399 ++++++++++-------- 5 files changed, 429 insertions(+), 244 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 03abc93e0b..5307ccb193 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 @@ -1,6 +1,6 @@
- {% if letter_head %} + {% if letter_head.content %}
{{ letter_head.content }}

{% endif %} diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js index 7dd5ef36f2..cec48c1d56 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js @@ -65,6 +65,20 @@ frappe.ui.form.on('Process Statement Of Accounts', { frm.set_value('to_date', frappe.datetime.get_today()); } }, + report: function(frm){ + let filters = { + 'company': frm.doc.company, + } + if(frm.doc.report == 'Accounts Receivable'){ + filters['account_type'] = 'Receivable'; + } + frm.set_query("account", function() { + return { + filters: filters + }; + }); + + }, customer_collection: function(frm){ frm.set_value('collection_name', ''); if(frm.doc.customer_collection){ diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json index e23620fd4e..70e810439c 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json @@ -6,17 +6,24 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "report", "section_break_11", "from_date", + "posting_date", "company", "account", "group_by", "cost_center", + "territory", "column_break_14", "to_date", "finance_book", "currency", "project", + "payment_terms_template", + "sales_partner", + "sales_person", + "based_on_payment_terms", "section_break_3", "customer_collection", "collection_name", @@ -67,14 +74,14 @@ "reqd": 1 }, { - "depends_on": "eval:doc.enable_auto_email == 0;", + "depends_on": "eval:(doc.enable_auto_email == 0 && doc.report == 'General Ledger');", "fieldname": "from_date", "fieldtype": "Date", "label": "From Date", "mandatory_depends_on": "eval:doc.frequency == '';" }, { - "depends_on": "eval:doc.enable_auto_email == 0;", + "depends_on": "eval:(doc.enable_auto_email == 0 && doc.report == 'General Ledger');", "fieldname": "to_date", "fieldtype": "Date", "label": "To Date", @@ -87,6 +94,7 @@ "options": "PSOA Cost Center" }, { + "depends_on": "eval: (doc.report == 'General Ledger');", "fieldname": "project", "fieldtype": "Table MultiSelect", "label": "Project", @@ -104,7 +112,7 @@ { "fieldname": "section_break_11", "fieldtype": "Section Break", - "label": "General Ledger Filters" + "label": "Report Filters" }, { "fieldname": "column_break_14", @@ -164,12 +172,14 @@ }, { "default": "Group by Voucher (Consolidated)", + "depends_on": "eval:(doc.report == 'General Ledger');", "fieldname": "group_by", "fieldtype": "Select", "label": "Group By", "options": "\nGroup by Voucher\nGroup by Voucher (Consolidated)" }, { + "depends_on": "eval: (doc.report == 'General Ledger');", "fieldname": "currency", "fieldtype": "Link", "label": "Currency", @@ -297,6 +307,7 @@ }, { "default": "0", + "depends_on": "eval: (doc.report == 'General Ledger');", "fieldname": "show_net_values_in_party_account", "fieldtype": "Check", "label": "Show Net Values in Party Account" @@ -310,10 +321,58 @@ { "fieldname": "column_break_ocfq", "fieldtype": "Column Break" + }, + { + "fieldname": "report", + "fieldtype": "Select", + "label": "Report", + "options": "General Ledger\nAccounts Receivable" + }, + { + "default": "Today", + "depends_on": "eval:(doc.report == 'Accounts Receivable');", + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Posting Date" + }, + { + "depends_on": "eval: (doc.report == 'Accounts Receivable');", + "fieldname": "payment_terms_template", + "fieldtype": "Link", + "label": "Payment Terms Template", + "options": "Payment Terms Template" + }, + { + "depends_on": "eval: (doc.report == 'Accounts Receivable');", + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "options": "Sales Partner" + }, + { + "depends_on": "eval: (doc.report == 'Accounts Receivable');", + "fieldname": "sales_person", + "fieldtype": "Link", + "label": "Sales Person", + "options": "Sales Person" + }, + { + "depends_on": "eval: (doc.report == 'Accounts Receivable');", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "Territory" + }, + { + "default": "0", + "depends_on": "eval:(doc.report == 'Accounts Receivable');", + "fieldname": "based_on_payment_terms", + "fieldtype": "Check", + "label": "Based On Payment Terms" } ], "links": [], - "modified": "2023-04-26 12:46:43.645455", + "modified": "2023-06-19 18:37:10.040570", "modified_by": "Administrator", "module": "Accounts", "name": "Process Statement Of Accounts", 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 67dbe09d0d..db186d81a2 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 @@ -15,6 +15,7 @@ from frappe.www.printview import get_print_style from erpnext import get_company_currency from erpnext.accounts.party import get_party_account_currency +from erpnext.accounts.report.accounts_receivable.accounts_receivable import execute as get_ar_soa from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import ( execute as get_ageing, ) @@ -43,29 +44,10 @@ class ProcessStatementOfAccounts(Document): def get_report_pdf(doc, consolidated=True): statement_dict = {} ageing = "" - base_template_path = "frappe/www/printview.html" - template_path = ( - "erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html" - ) for entry in doc.customers: if doc.include_ageing: - ageing_filters = frappe._dict( - { - "company": doc.company, - "report_date": doc.to_date, - "ageing_based_on": doc.ageing_based_on, - "range1": 30, - "range2": 60, - "range3": 90, - "range4": 120, - "customer": entry.customer, - } - ) - col1, ageing = get_ageing(ageing_filters) - - if ageing: - ageing[0]["ageing_based_on"] = doc.ageing_based_on + ageing = set_ageing(doc, entry) tax_id = frappe.get_doc("Customer", entry.customer).tax_id presentation_currency = ( @@ -73,60 +55,25 @@ def get_report_pdf(doc, consolidated=True): or doc.currency or get_company_currency(doc.company) ) - if doc.letter_head: - from frappe.www.printview import get_letter_head - letter_head = get_letter_head(doc, 0) + filters = get_common_filters(doc) - filters = frappe._dict( - { - "from_date": doc.from_date, - "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, - "party_type": "Customer", - "party": [entry.customer], - "party_name": [entry.customer_name] if entry.customer_name else None, - "presentation_currency": presentation_currency, - "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, - "tax_id": tax_id if tax_id else None, - "show_net_values_in_party_account": doc.show_net_values_in_party_account, - } - ) - col, res = get_soa(filters) + if doc.report == "General Ledger": + filters.update(get_gl_filters(doc, entry, tax_id, presentation_currency)) + else: + filters.update(get_ar_filters(doc, entry)) - for x in [0, -2, -1]: - res[x]["account"] = res[x]["account"].replace("'", "") + if doc.report == "General Ledger": + col, res = get_soa(filters) + for x in [0, -2, -1]: + res[x]["account"] = res[x]["account"].replace("'", "") + if len(res) == 3: + continue + else: + ar_res = get_ar_soa(filters) + col, res = ar_res[0], ar_res[1] - if len(res) == 3: - continue - - html = frappe.render_template( - template_path, - { - "filters": filters, - "data": res, - "ageing": ageing[0] if (doc.include_ageing and ageing) else None, - "letter_head": letter_head if doc.letter_head else None, - "terms_and_conditions": frappe.db.get_value( - "Terms and Conditions", doc.terms_and_conditions, "terms" - ) - if doc.terms_and_conditions - else None, - }, - ) - - html = frappe.render_template( - base_template_path, - {"body": html, "css": get_print_style(), "title": "Statement For " + entry.customer}, - ) - statement_dict[entry.customer] = html + statement_dict[entry.customer] = get_html(doc, filters, entry, col, res, ageing) if not bool(statement_dict): return False @@ -140,6 +87,110 @@ def get_report_pdf(doc, consolidated=True): return statement_dict +def set_ageing(doc, entry): + ageing_filters = frappe._dict( + { + "company": doc.company, + "report_date": doc.to_date, + "ageing_based_on": doc.ageing_based_on, + "range1": 30, + "range2": 60, + "range3": 90, + "range4": 120, + "customer": entry.customer, + } + ) + col1, ageing = get_ageing(ageing_filters) + + if ageing: + ageing[0]["ageing_based_on"] = doc.ageing_based_on + + return ageing + + +def get_common_filters(doc): + return frappe._dict( + { + "company": doc.company, + "finance_book": doc.finance_book if doc.finance_book else None, + "account": [doc.account] if doc.account else None, + "cost_center": [cc.cost_center_name for cc in doc.cost_center], + } + ) + + +def get_gl_filters(doc, entry, tax_id, presentation_currency): + return { + "from_date": doc.from_date, + "to_date": doc.to_date, + "party_type": "Customer", + "party": [entry.customer], + "party_name": [entry.customer_name] if entry.customer_name else None, + "presentation_currency": presentation_currency, + "group_by": doc.group_by, + "currency": doc.currency, + "project": [p.project_name for p in doc.project], + "show_opening_entries": 0, + "include_default_book_entries": 0, + "tax_id": tax_id if tax_id else None, + "show_net_values_in_party_account": doc.show_net_values_in_party_account, + } + + +def get_ar_filters(doc, entry): + return { + "report_date": doc.posting_date if doc.posting_date else None, + "customer_name": entry.customer, + "payment_terms_template": doc.payment_terms_template if doc.payment_terms_template else None, + "sales_partner": doc.sales_partner if doc.sales_partner else None, + "sales_person": doc.sales_person if doc.sales_person else None, + "territory": doc.territory if doc.territory else None, + "based_on_payment_terms": doc.based_on_payment_terms, + "report_name": "Accounts Receivable", + "ageing_based_on": doc.ageing_based_on, + "range1": 30, + "range2": 60, + "range3": 90, + "range4": 120, + } + + +def get_html(doc, filters, entry, col, res, ageing): + base_template_path = "frappe/www/printview.html" + template_path = ( + "erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html" + if doc.report == "General Ledger" + else "erpnext/accounts/report/accounts_receivable/accounts_receivable.html" + ) + + if doc.letter_head: + from frappe.www.printview import get_letter_head + + letter_head = get_letter_head(doc, 0) + + html = frappe.render_template( + template_path, + { + "filters": filters, + "data": res, + "report": {"report_name": doc.report, "columns": col}, + "ageing": ageing[0] if (doc.include_ageing and ageing) else None, + "letter_head": letter_head if doc.letter_head else None, + "terms_and_conditions": frappe.db.get_value( + "Terms and Conditions", doc.terms_and_conditions, "terms" + ) + if doc.terms_and_conditions + else None, + }, + ) + + html = frappe.render_template( + base_template_path, + {"body": html, "css": get_print_style(), "title": "Statement For " + entry.customer}, + ) + return html + + def get_customers_based_on_territory_or_customer_group(customer_collection, collection_name): fields_dict = { "Customer Group": "customer_group", diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index f2bf9424f7..07e1896292 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -8,51 +8,56 @@ } -

{%= __(report.report_name) %}

+

{{ _(report.report_name) }}

- {% if (filters.customer_name) { %} - {%= filters.customer_name %} - {% } else { %} - {%= filters.customer || filters.supplier %} - {% } %} + {% if (filters.customer_name) %} + {{ filters.customer_name }} + {% else %} + {{ filters.customer ~ filters.supplier }} + {% endif %}

- {% if (filters.tax_id) { %} - {%= __("Tax Id: ")%} {%= filters.tax_id %} - {% } %} + {% if (filters.tax_id) %} + {{ _("Tax Id: ") }}{{ filters.tax_id }} + {% endif %}
- {%= __(filters.ageing_based_on) %} - {%= __("Until") %} - {%= frappe.datetime.str_to_user(filters.report_date) %} + {{ _(filters.ageing_based_on) }} + {{ _("Until") }} + {{ frappe.format(filters.report_date, 'Date') }}
- {% if(filters.payment_terms) { %} - {%= __("Payment Terms") %}: {%= filters.payment_terms %} - {% } %} + {% if(filters.payment_terms) %} + {{ _("Payment Terms") }}: {{ filters.payment_terms }} + {% endif %}
- {% if(filters.credit_limit) { %} - {%= __("Credit Limit") %}: {%= format_currency(filters.credit_limit) %} - {% } %} + {% if(filters.credit_limit) %} + {{ _("Credit Limit") }}: {{ frappe.utils.fmt_money(filters.credit_limit) }} + {% endif %}
- {% if(filters.show_future_payments) { %} - {% var balance_row = data.slice(-1).pop(); - var start = report.columns.findIndex((elem) => (elem.fieldname == 'age')); - var range1 = report.columns[start].label; - var range2 = report.columns[start+1].label; - var range3 = report.columns[start+2].label; - var range4 = report.columns[start+3].label; - var range5 = report.columns[start+4].label; - var range6 = report.columns[start+5].label; - %} - {% if(balance_row) { %} + {% if(filters.show_future_payments) %} + {% set balance_row = data.slice(-1).pop() %} + {% for i in report.columns %} + {% if i.fieldname == 'age' %} + {% set elem = i %} + {% endif %} + {% endfor %} + {% set start = report.columns.findIndex(elem) %} + {% set range1 = report.columns[start].label %} + {% set range2 = report.columns[start+1].label %} + {% set range3 = report.columns[start+2].label %} + {% set range4 = report.columns[start+3].label %} + {% set range5 = report.columns[start+4].label %} + {% set range6 = report.columns[start+5].label %} + + {% if(balance_row) %} - + @@ -66,42 +71,42 @@ - - - - - - - - + + + + + + + + - + - + @@ -109,10 +114,10 @@ - + @@ -120,168 +125,224 @@ + {{ frappe.utils.fmt_money(flt(balance_row["outstanding"] - balance_row[("future_amount")]), data[data.length-1]["currency"]) }}
(Amount in {%= data[0]["currency"] || "" %})(Amount in {{ data[0]["currency"] ~ "" }})
{%= __(" ") %}{%= __(range1) %}{%= __(range2) %}{%= __(range3) %}{%= __(range4) %}{%= __(range5) %}{%= __(range6) %}{%= __("Total") %}{{ _(" ") }}{{ _(range1) }}{{ _(range2) }}{{ _(range3) }}{{ _(range4) }}{{ _(range5) }}{{ _(range6) }}{{ _("Total") }}
{%= __("Total Outstanding") %}{{ _("Total Outstanding") }} - {%= format_number(balance_row["age"], null, 2) %} + {{ format_number(balance_row["age"], null, 2) }} - {%= format_currency(balance_row["range1"], data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(balance_row["range1"], data[data.length-1]["currency"]) }} - {%= format_currency(balance_row["range2"], data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(balance_row["range2"], data[data.length-1]["currency"]) }} - {%= format_currency(balance_row["range3"], data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(balance_row["range3"], data[data.length-1]["currency"]) }} - {%= format_currency(balance_row["range4"], data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(balance_row["range4"], data[data.length-1]["currency"]) }} - {%= format_currency(balance_row["range5"], data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(balance_row["range5"], data[data.length-1]["currency"]) }} - {%= format_currency(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) }}
{%= __("Future Payments") %}{{ _("Future Payments") }} - {%= format_currency(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) %} + {{ frappe.utils.fmt_money(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) }}
- {% } %} - {% } %} + {% endif %} + {% endif %} - {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} - - + {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} + + - {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} - - - {% } else { %} - - {% } %} - {% if(!filters.show_future_payments) { %} - - {% } %} - - {% if(!filters.show_future_payments) { %} - - - {% } %} - - {% if(filters.show_future_payments) { %} - {% if(report.report_name === "Accounts Receivable") { %} - - {% } %} - - - - {% } %} - {% } else { %} - - - - - - {% } %} + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + + + {% else %} + + {% endif %} + {% if not(filters.show_future_payments) %} + + {% endif %} + + {% if not(filters.show_future_payments) %} + + + {% endif %} + + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} + + {% endif %} + + + + {% endif %} + {% else %} + + + + + + {% endif %} - {% for(var i=0, l=data.length; i - {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} - {% if(data[i]["party"]) { %} - - + {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} + {% if(data[i]["party"]) %} + + - {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} - - {% } %} + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + + {% endif %} - {% if(!filters.show_future_payments) { %} + {% if not (filters.show_future_payments) %} - {% } %} + {% endif %} + {{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }} - {% if(!filters.show_future_payments) { %} + {% if not(filters.show_future_payments) %} + {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} - {% } %} + {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} + {% endif %} + {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} - {% if(filters.show_future_payments) { %} - {% if(report.report_name === "Accounts Receivable") { %} + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} - {% } %} - - - - {% } %} - {% } else { %} + {{ data[i]["po_no"] }} + {% endif %} + + + + {% endif %} + {% else %} - {% if(!filters.show_future_payments) { %} + {% if not(filters.show_future_payments) %} - {% } %} - {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} + {% endif %} + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} - {% } %} + {% endif %} - + + {{ frappe.utils.fmt_money(data[i]["invoiced"], data[i]["currency"]) }} - {% if(!filters.show_future_payments) { %} + {% if not(filters.show_future_payments) %} - - {% } %} + {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} + + {% endif %} + {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} - {% if(filters.show_future_payments) { %} - {% if(report.report_name === "Accounts Receivable") { %} + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} - {% } %} - - - - {% } %} - {% } %} - {% } else { %} - {% if(data[i]["party"]|| " ") { %} - {% if(!data[i]["is_total_row"]) { %} + {{ data[i]["po_no"] }} + {% endif %} + + + + {% endif %} + {% endif %} + {% else %} + {% if(data[i]["party"] or " ") %} + {% if not(data[i]["is_total_row"]) %} - {% } else { %} - - {% } %} - - - - - {% } %} - {% } %} + {% else %} + + {% endif %} + + + + + {% endif %} + {% endif %} - {% } %} + {% endfor %} + + + + + + + +
{%= __("Date") %}{%= __("Age (Days)") %}{{ _("Date") }}{{ _("Age (Days)") }}{%= __("Reference") %}{%= __("Sales Person") %}{%= __("Reference") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}{%= __("Invoiced Amount") %}{%= __("Paid Amount") %}{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}{%= __("Outstanding Amount") %}{%= __("Customer LPO No.") %}{%= __("Future Payment Ref") %}{%= __("Future Payment Amount") %}{%= __("Remaining Balance") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}{%= __("Total Invoiced Amount") %}{%= __("Total Paid Amount") %}{%= report.report_name === "Accounts Receivable Summary" ? __('Credit Note Amount') : __('Debit Note Amount') %}{%= __("Total Outstanding Amount") %}{{ _("Reference") }}{{ _("Sales Person") }}{{ _("Reference") }} + {% if (filters.customer or filters.supplier or filters.customer_name) %} + {{ _("Remarks") }} + {% else %} + {{ _("Party") }} + {% endif %} + {{ _("Invoiced Amount") }}{{ _("Paid Amount") }} + {% if report.report_name == "Accounts Receivable" %} + {{ _('Credit Note') }} + {% else %} + {{ _('Debit Note') }} + {% endif %} + {{ _("Outstanding Amount") }}{{ _("Customer LPO No.") }}{{ _("Future Payment Ref") }}{{ _("Future Payment Amount") }}{{ _("Remaining Balance") }} + {% if (filters.customer or filters.supplier or filters.customer_name) %} + {{ _("Remarks")}} + {% else %} + {{ _("Party") }} + {% endif %} + {{ _("Total Invoiced Amount") }}{{ _("Total Paid Amount") }} + {% if report.report_name == "Accounts Receivable Summary" %} + {{ _('Credit Note Amount') }} + {% else %} + {{ _('Debit Note Amount') }} + {% endif %} + {{ _("Total Outstanding Amount") }}
{%= frappe.datetime.str_to_user(data[i]["posting_date"]) %}{%= data[i]["age"] %}{{ (data[i]["posting_date"]) }}{{ data[i]["age"] }} - {% if(!filters.show_future_payments) { %} - {%= data[i]["voucher_type"] %} + {% if not(filters.show_future_payments) %} + {{ data[i]["voucher_type"] }}
- {% } %} - {%= data[i]["voucher_no"] %} + {% endif %} + {{ data[i]["voucher_no"] }}
{%= data[i]["sales_person"] %}{{ data[i]["sales_person"] }} - {% if(!(filters.customer || filters.supplier)) { %} - {%= data[i]["party"] %} - {% if(data[i]["customer_name"] && data[i]["customer_name"] != data[i]["party"]) { %} -
{%= data[i]["customer_name"] %} - {% } else if(data[i]["supplier_name"] != data[i]["party"]) { %} -
{%= data[i]["supplier_name"] %} - {% } %} - {% } %} + {% if(not(filters.customer or filters.supplier or filters.customer_name)) %} + {{ data[i]["party"] }} + {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} +
{{ data[i]["customer_name"] }} + {% elif(data[i]["supplier_name"] != data[i]["party"]) %} +
{{ data[i]["supplier_name"] }} + {% endif %} + {% endif %}
{% if data[i]["remarks"] %} - {%= __("Remarks") %}: - {%= data[i]["remarks"] %} - {% } %} + {{ _("Remarks") }}: + {{ data[i]["remarks"] }} + {% endif %}
- {%= format_currency(data[i]["invoiced"], data[i]["currency"]) %} - {%= format_currency(data[i]["paid"], data[i]["currency"]) %} - {%= format_currency(data[i]["credit_note"], data[i]["currency"]) %} - {%= format_currency(data[i]["outstanding"], data[i]["currency"]) %} - {%= data[i]["po_no"] %}{%= data[i]["future_ref"] %}{%= format_currency(data[i]["future_amount"], data[i]["currency"]) %}{%= format_currency(data[i]["remaining_balance"], data[i]["currency"]) %}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }}{%= __("Total") %}{{ _("Total") }} - {%= format_currency(data[i]["invoiced"], data[i]["currency"] ) %} - {%= format_currency(data[i]["paid"], data[i]["currency"]) %}{%= format_currency(data[i]["credit_note"], data[i]["currency"]) %} {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} - {%= format_currency(data[i]["outstanding"], data[i]["currency"]) %} - {%= data[i]["po_no"] %}{%= data[i]["future_ref"] %}{%= format_currency(data[i]["future_amount"], data[i]["currency"]) %}{%= format_currency(data[i]["remaining_balance"], data[i]["currency"]) %}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }} - {% if(!(filters.customer || filters.supplier)) { %} - {%= data[i]["party"] %} - {% if(data[i]["customer_name"] && data[i]["customer_name"] != data[i]["party"]) { %} -
{%= data[i]["customer_name"] %} - {% } else if(data[i]["supplier_name"] != data[i]["party"]) { %} -
{%= data[i]["supplier_name"] %} - {% } %} - {% } %} -
{%= __("Remarks") %}: - {%= data[i]["remarks"] %} + {% if(not(filters.customer | filters.supplier)) %} + {{ data[i]["party"] }} + {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} +
{{ data[i]["customer_name"] }} + {% elif(data[i]["supplier_name"] != data[i]["party"]) %} +
{{ data[i]["supplier_name"] }} + {% endif %} + {% endif %} +
{{ _("Remarks") }}: + {{ data[i]["remarks"] }}
{%= __("Total") %}{%= format_currency(data[i]["invoiced"], data[i]["currency"]) %}{%= format_currency(data[i]["paid"], data[i]["currency"]) %}{%= format_currency(data[i]["credit_note"], data[i]["currency"]) %}{%= format_currency(data[i]["outstanding"], data[i]["currency"]) %}{{ _("Total") }}{{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }}
{{ frappe.utils.fmt_money(data|sum(attribute="invoiced"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="paid"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="credit_note"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="outstanding"), currency=data[0]["currency"]) }}
-

{{ __("Printed On ") }}{%= frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string()) %}

+
+ {% if ageing %} +

{{ _("Ageing Report based on ") }} {{ ageing.ageing_based_on }} + {{ _("up to " ) }} {{ frappe.format(filters.report_date, 'Date')}} +

+ + + + + + + + + + + + + + + + + +
30 Days60 Days90 Days120 Days
{{ frappe.utils.fmt_money(ageing.range1, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range2, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range3, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range4, currency=data[0]["currency"]) }}
+ {% endif %} +

{{ _("Printed On ") }}{{ frappe.utils.now() }}

From 555c126eb9b2badeacfa742fa379f33038b7085b Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Fri, 23 Jun 2023 10:52:25 +0530 Subject: [PATCH 2/4] fix: add patch for setting default value of report field --- .../process_statement_of_accounts.json | 5 +- .../process_statement_of_accounts.py | 2 +- ...ement_of_accounts_accounts_receivable.html | 348 +++++++++++++++ .../accounts_receivable.html | 399 ++++++++---------- erpnext/patches.txt | 1 + .../v14_0/set_report_in_process_SOA.py | 10 + 6 files changed, 532 insertions(+), 233 deletions(-) create mode 100644 erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html create mode 100644 erpnext/patches/v14_0/set_report_in_process_SOA.py diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json index 70e810439c..8004659065 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json @@ -326,7 +326,8 @@ "fieldname": "report", "fieldtype": "Select", "label": "Report", - "options": "General Ledger\nAccounts Receivable" + "options": "General Ledger\nAccounts Receivable", + "reqd": 1 }, { "default": "Today", @@ -372,7 +373,7 @@ } ], "links": [], - "modified": "2023-06-19 18:37:10.040570", + "modified": "2023-06-23 10:13:15.051950", "modified_by": "Administrator", "module": "Accounts", "name": "Process Statement Of Accounts", 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 db186d81a2..08f4cf45d6 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 @@ -160,7 +160,7 @@ def get_html(doc, filters, entry, col, res, ageing): template_path = ( "erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html" if doc.report == "General Ledger" - else "erpnext/accounts/report/accounts_receivable/accounts_receivable.html" + else "erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html" ) if doc.letter_head: diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html new file mode 100644 index 0000000000..07e1896292 --- /dev/null +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html @@ -0,0 +1,348 @@ + + +

{{ _(report.report_name) }}

+

+ {% if (filters.customer_name) %} + {{ filters.customer_name }} + {% else %} + {{ filters.customer ~ filters.supplier }} + {% endif %} +

+
+ {% if (filters.tax_id) %} + {{ _("Tax Id: ") }}{{ filters.tax_id }} + {% endif %} +
+
+ {{ _(filters.ageing_based_on) }} + {{ _("Until") }} + {{ frappe.format(filters.report_date, 'Date') }} +
+ +
+
+ {% if(filters.payment_terms) %} + {{ _("Payment Terms") }}: {{ filters.payment_terms }} + {% endif %} +
+
+ {% if(filters.credit_limit) %} + {{ _("Credit Limit") }}: {{ frappe.utils.fmt_money(filters.credit_limit) }} + {% endif %} +
+
+ + {% if(filters.show_future_payments) %} + {% set balance_row = data.slice(-1).pop() %} + {% for i in report.columns %} + {% if i.fieldname == 'age' %} + {% set elem = i %} + {% endif %} + {% endfor %} + {% set start = report.columns.findIndex(elem) %} + {% set range1 = report.columns[start].label %} + {% set range2 = report.columns[start+1].label %} + {% set range3 = report.columns[start+2].label %} + {% set range4 = report.columns[start+3].label %} + {% set range5 = report.columns[start+4].label %} + {% set range6 = report.columns[start+5].label %} + + {% if(balance_row) %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
(Amount in {{ data[0]["currency"] ~ "" }})
{{ _(" ") }}{{ _(range1) }}{{ _(range2) }}{{ _(range3) }}{{ _(range4) }}{{ _(range5) }}{{ _(range6) }}{{ _("Total") }}
{{ _("Total Outstanding") }} + {{ format_number(balance_row["age"], null, 2) }} + + {{ frappe.utils.fmt_money(balance_row["range1"], data[data.length-1]["currency"]) }} + + {{ frappe.utils.fmt_money(balance_row["range2"], data[data.length-1]["currency"]) }} + + {{ frappe.utils.fmt_money(balance_row["range3"], data[data.length-1]["currency"]) }} + + {{ frappe.utils.fmt_money(balance_row["range4"], data[data.length-1]["currency"]) }} + + {{ frappe.utils.fmt_money(balance_row["range5"], data[data.length-1]["currency"]) }} + + {{ frappe.utils.fmt_money(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) }} +
{{ _("Future Payments") }} + {{ frappe.utils.fmt_money(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) }} +
+ {% endif %} + {% endif %} + + + + {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} + + + + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + + + {% else %} + + {% endif %} + {% if not(filters.show_future_payments) %} + + {% endif %} + + {% if not(filters.show_future_payments) %} + + + {% endif %} + + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} + + {% endif %} + + + + {% endif %} + {% else %} + + + + + + {% endif %} + + + + {% for i in range(data|length) %} + + {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} + {% if(data[i]["party"]) %} + + + + + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + + {% endif %} + + {% if not (filters.show_future_payments) %} + + {% endif %} + + + + {% if not(filters.show_future_payments) %} + + + {% endif %} + + + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} + + {% endif %} + + + + {% endif %} + {% else %} + + {% if not(filters.show_future_payments) %} + + {% endif %} + {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + + {% endif %} + + + + + {% if not(filters.show_future_payments) %} + + + {% endif %} + + + {% if(filters.show_future_payments) %} + {% if(report.report_name == "Accounts Receivable") %} + + {% endif %} + + + + {% endif %} + {% endif %} + {% else %} + {% if(data[i]["party"] or " ") %} + {% if not(data[i]["is_total_row"]) %} + + {% else %} + + {% endif %} + + + + + {% endif %} + {% endif %} + + {% endfor %} + + + + + + + + + +
{{ _("Date") }}{{ _("Age (Days)") }}{{ _("Reference") }}{{ _("Sales Person") }}{{ _("Reference") }} + {% if (filters.customer or filters.supplier or filters.customer_name) %} + {{ _("Remarks") }} + {% else %} + {{ _("Party") }} + {% endif %} + {{ _("Invoiced Amount") }}{{ _("Paid Amount") }} + {% if report.report_name == "Accounts Receivable" %} + {{ _('Credit Note') }} + {% else %} + {{ _('Debit Note') }} + {% endif %} + {{ _("Outstanding Amount") }}{{ _("Customer LPO No.") }}{{ _("Future Payment Ref") }}{{ _("Future Payment Amount") }}{{ _("Remaining Balance") }} + {% if (filters.customer or filters.supplier or filters.customer_name) %} + {{ _("Remarks")}} + {% else %} + {{ _("Party") }} + {% endif %} + {{ _("Total Invoiced Amount") }}{{ _("Total Paid Amount") }} + {% if report.report_name == "Accounts Receivable Summary" %} + {{ _('Credit Note Amount') }} + {% else %} + {{ _('Debit Note Amount') }} + {% endif %} + {{ _("Total Outstanding Amount") }}
{{ (data[i]["posting_date"]) }}{{ data[i]["age"] }} + {% if not(filters.show_future_payments) %} + {{ data[i]["voucher_type"] }} +
+ {% endif %} + {{ data[i]["voucher_no"] }} +
{{ data[i]["sales_person"] }} + {% if(not(filters.customer or filters.supplier or filters.customer_name)) %} + {{ data[i]["party"] }} + {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} +
{{ data[i]["customer_name"] }} + {% elif(data[i]["supplier_name"] != data[i]["party"]) %} +
{{ data[i]["supplier_name"] }} + {% endif %} + {% endif %} +
+ {% if data[i]["remarks"] %} + {{ _("Remarks") }}: + {{ data[i]["remarks"] }} + {% endif %} +
+
+ {{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }} + {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} + {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} + {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} + {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }}{{ _("Total") }} + {{ frappe.utils.fmt_money(data[i]["invoiced"], data[i]["currency"]) }} + {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} + {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} + {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }} + {% if(not(filters.customer | filters.supplier)) %} + {{ data[i]["party"] }} + {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} +
{{ data[i]["customer_name"] }} + {% elif(data[i]["supplier_name"] != data[i]["party"]) %} +
{{ data[i]["supplier_name"] }} + {% endif %} + {% endif %} +
{{ _("Remarks") }}: + {{ data[i]["remarks"] }} +
{{ _("Total") }}{{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }}
{{ frappe.utils.fmt_money(data|sum(attribute="invoiced"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="paid"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="credit_note"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="outstanding"), currency=data[0]["currency"]) }}
+
+ {% if ageing %} +

{{ _("Ageing Report based on ") }} {{ ageing.ageing_based_on }} + {{ _("up to " ) }} {{ frappe.format(filters.report_date, 'Date')}} +

+ + + + + + + + + + + + + + + + + +
30 Days60 Days90 Days120 Days
{{ frappe.utils.fmt_money(ageing.range1, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range2, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range3, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range4, currency=data[0]["currency"]) }}
+ {% endif %} +

{{ _("Printed On ") }}{{ frappe.utils.now() }}

diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index 07e1896292..ed3b991559 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -8,56 +8,51 @@ } -

{{ _(report.report_name) }}

+

{%= __(report.report_name) %}

- {% if (filters.customer_name) %} - {{ filters.customer_name }} - {% else %} - {{ filters.customer ~ filters.supplier }} - {% endif %} + {% if (filters.customer_name) { %} + {%= filters.customer_name %} + {% } else { %} + {%= filters.customer || filters.supplier %} + {% } %}

- {% if (filters.tax_id) %} - {{ _("Tax Id: ") }}{{ filters.tax_id }} - {% endif %} + {% if (filters.tax_id) { %} + {%= __("Tax Id: ")%} {%= filters.tax_id %} + {% } %}
- {{ _(filters.ageing_based_on) }} - {{ _("Until") }} - {{ frappe.format(filters.report_date, 'Date') }} + {%= __(filters.ageing_based_on) %} + {%= __("Until") %} + {%= frappe.datetime.str_to_user(filters.report_date) %}
- {% if(filters.payment_terms) %} - {{ _("Payment Terms") }}: {{ filters.payment_terms }} - {% endif %} + {% if(filters.payment_terms) { %} + {%= __("Payment Terms") %}: {%= filters.payment_terms %} + {% } %}
- {% if(filters.credit_limit) %} - {{ _("Credit Limit") }}: {{ frappe.utils.fmt_money(filters.credit_limit) }} - {% endif %} + {% if(filters.credit_limit) { %} + {%= __("Credit Limit") %}: {%= format_currency(filters.credit_limit) %} + {% } %}
- {% if(filters.show_future_payments) %} - {% set balance_row = data.slice(-1).pop() %} - {% for i in report.columns %} - {% if i.fieldname == 'age' %} - {% set elem = i %} - {% endif %} - {% endfor %} - {% set start = report.columns.findIndex(elem) %} - {% set range1 = report.columns[start].label %} - {% set range2 = report.columns[start+1].label %} - {% set range3 = report.columns[start+2].label %} - {% set range4 = report.columns[start+3].label %} - {% set range5 = report.columns[start+4].label %} - {% set range6 = report.columns[start+5].label %} - - {% if(balance_row) %} + {% if(filters.show_future_payments) { %} + {% var balance_row = data.slice(-1).pop(); + var start = report.columns.findIndex((elem) => (elem.fieldname == 'age')); + var range1 = report.columns[start].label; + var range2 = report.columns[start+1].label; + var range3 = report.columns[start+2].label; + var range4 = report.columns[start+3].label; + var range5 = report.columns[start+4].label; + var range6 = report.columns[start+5].label; + %} + {% if(balance_row) { %} - + @@ -71,42 +66,42 @@ - - - - - - - - + + + + + + + + - + - + @@ -114,10 +109,10 @@ - + @@ -125,224 +120,168 @@ + {%= format_currency(flt(balance_row["outstanding"] - balance_row[("future_amount")]), data[data.length-1]["currency"]) %}
(Amount in {{ data[0]["currency"] ~ "" }})(Amount in {%= data[0]["currency"] || "" %})
{{ _(" ") }}{{ _(range1) }}{{ _(range2) }}{{ _(range3) }}{{ _(range4) }}{{ _(range5) }}{{ _(range6) }}{{ _("Total") }}{%= __(" ") %}{%= __(range1) %}{%= __(range2) %}{%= __(range3) %}{%= __(range4) %}{%= __(range5) %}{%= __(range6) %}{%= __("Total") %}
{{ _("Total Outstanding") }}{%= __("Total Outstanding") %} - {{ format_number(balance_row["age"], null, 2) }} + {%= format_number(balance_row["age"], null, 2) %} - {{ frappe.utils.fmt_money(balance_row["range1"], data[data.length-1]["currency"]) }} + {%= format_currency(balance_row["range1"], data[data.length-1]["currency"]) %} - {{ frappe.utils.fmt_money(balance_row["range2"], data[data.length-1]["currency"]) }} + {%= format_currency(balance_row["range2"], data[data.length-1]["currency"]) %} - {{ frappe.utils.fmt_money(balance_row["range3"], data[data.length-1]["currency"]) }} + {%= format_currency(balance_row["range3"], data[data.length-1]["currency"]) %} - {{ frappe.utils.fmt_money(balance_row["range4"], data[data.length-1]["currency"]) }} + {%= format_currency(balance_row["range4"], data[data.length-1]["currency"]) %} - {{ frappe.utils.fmt_money(balance_row["range5"], data[data.length-1]["currency"]) }} + {%= format_currency(balance_row["range5"], data[data.length-1]["currency"]) %} - {{ frappe.utils.fmt_money(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) }} + {%= format_currency(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) %}
{{ _("Future Payments") }}{%= __("Future Payments") %} - {{ frappe.utils.fmt_money(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) }} + {%= format_currency(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) %}
- {% endif %} - {% endif %} + {% } %} + {% } %} - {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} - - + {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} + + - {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} - - - {% else %} - - {% endif %} - {% if not(filters.show_future_payments) %} - - {% endif %} - - {% if not(filters.show_future_payments) %} - - - {% endif %} - - {% if(filters.show_future_payments) %} - {% if(report.report_name == "Accounts Receivable") %} - - {% endif %} - - - - {% endif %} - {% else %} - - - - - - {% endif %} + {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} + + + {% } else { %} + + {% } %} + {% if(!filters.show_future_payments) { %} + + {% } %} + + {% if(!filters.show_future_payments) { %} + + + {% } %} + + {% if(filters.show_future_payments) { %} + {% if(report.report_name === "Accounts Receivable") { %} + + {% } %} + + + + {% } %} + {% } else { %} + + + + + + {% } %} - {% for i in range(data|length) %} + {% for(var i=0, l=data.length; i - {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} - {% if(data[i]["party"]) %} - - + {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} + {% if(data[i]["party"]) { %} + + - {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} - - {% endif %} + {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} + + {% } %} - {% if not (filters.show_future_payments) %} + {% if(!filters.show_future_payments) { %} - {% endif %} + {% } %} + {%= format_currency(data[i]["invoiced"], data[i]["currency"]) %} - {% if not(filters.show_future_payments) %} + {% if(!filters.show_future_payments) { %} + {%= format_currency(data[i]["paid"], data[i]["currency"]) %} - {% endif %} + {%= format_currency(data[i]["credit_note"], data[i]["currency"]) %} + {% } %} + {%= format_currency(data[i]["outstanding"], data[i]["currency"]) %} - {% if(filters.show_future_payments) %} - {% if(report.report_name == "Accounts Receivable") %} + {% if(filters.show_future_payments) { %} + {% if(report.report_name === "Accounts Receivable") { %} - {% endif %} - - - - {% endif %} - {% else %} + {%= data[i]["po_no"] %} + {% } %} + + + + {% } %} + {% } else { %} - {% if not(filters.show_future_payments) %} + {% if(!filters.show_future_payments) { %} - {% endif %} - {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} + {% } %} + {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %} - {% endif %} + {% } %} - + + {%= format_currency(data[i]["invoiced"], data[i]["currency"] ) %} - {% if not(filters.show_future_payments) %} + {% if(!filters.show_future_payments) { %} - - {% endif %} + {%= format_currency(data[i]["paid"], data[i]["currency"]) %} + + {% } %} + {%= format_currency(data[i]["outstanding"], data[i]["currency"]) %} - {% if(filters.show_future_payments) %} - {% if(report.report_name == "Accounts Receivable") %} + {% if(filters.show_future_payments) { %} + {% if(report.report_name === "Accounts Receivable") { %} - {% endif %} - - - - {% endif %} - {% endif %} - {% else %} - {% if(data[i]["party"] or " ") %} - {% if not(data[i]["is_total_row"]) %} + {%= data[i]["po_no"] %} + {% } %} + + + + {% } %} + {% } %} + {% } else { %} + {% if(data[i]["party"]|| " ") { %} + {% if(!data[i]["is_total_row"]) { %} - {% else %} - - {% endif %} - - - - - {% endif %} - {% endif %} + {% } else { %} + + {% } %} + + + + + {% } %} + {% } %} - {% endfor %} - - - - - - - - + {% } %}
{{ _("Date") }}{{ _("Age (Days)") }}{%= __("Date") %}{%= __("Age (Days)") %}{{ _("Reference") }}{{ _("Sales Person") }}{{ _("Reference") }} - {% if (filters.customer or filters.supplier or filters.customer_name) %} - {{ _("Remarks") }} - {% else %} - {{ _("Party") }} - {% endif %} - {{ _("Invoiced Amount") }}{{ _("Paid Amount") }} - {% if report.report_name == "Accounts Receivable" %} - {{ _('Credit Note') }} - {% else %} - {{ _('Debit Note') }} - {% endif %} - {{ _("Outstanding Amount") }}{{ _("Customer LPO No.") }}{{ _("Future Payment Ref") }}{{ _("Future Payment Amount") }}{{ _("Remaining Balance") }} - {% if (filters.customer or filters.supplier or filters.customer_name) %} - {{ _("Remarks")}} - {% else %} - {{ _("Party") }} - {% endif %} - {{ _("Total Invoiced Amount") }}{{ _("Total Paid Amount") }} - {% if report.report_name == "Accounts Receivable Summary" %} - {{ _('Credit Note Amount') }} - {% else %} - {{ _('Debit Note Amount') }} - {% endif %} - {{ _("Total Outstanding Amount") }}{%= __("Reference") %}{%= __("Sales Person") %}{%= __("Reference") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}{%= __("Invoiced Amount") %}{%= __("Paid Amount") %}{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}{%= __("Outstanding Amount") %}{%= __("Customer LPO No.") %}{%= __("Future Payment Ref") %}{%= __("Future Payment Amount") %}{%= __("Remaining Balance") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}{%= __("Total Invoiced Amount") %}{%= __("Total Paid Amount") %}{%= report.report_name === "Accounts Receivable Summary" ? __('Credit Note Amount') : __('Debit Note Amount') %}{%= __("Total Outstanding Amount") %}
{{ (data[i]["posting_date"]) }}{{ data[i]["age"] }}{%= frappe.datetime.str_to_user(data[i]["posting_date"]) %}{%= data[i]["age"] %} - {% if not(filters.show_future_payments) %} - {{ data[i]["voucher_type"] }} + {% if(!filters.show_future_payments) { %} + {%= data[i]["voucher_type"] %}
- {% endif %} - {{ data[i]["voucher_no"] }} + {% } %} + {%= data[i]["voucher_no"] %}
{{ data[i]["sales_person"] }}{%= data[i]["sales_person"] %} - {% if(not(filters.customer or filters.supplier or filters.customer_name)) %} - {{ data[i]["party"] }} - {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} -
{{ data[i]["customer_name"] }} - {% elif(data[i]["supplier_name"] != data[i]["party"]) %} -
{{ data[i]["supplier_name"] }} - {% endif %} - {% endif %} + {% if(!(filters.customer || filters.supplier)) { %} + {%= data[i]["party"] %} + {% if(data[i]["customer_name"] && data[i]["customer_name"] != data[i]["party"]) { %} +
{%= data[i]["customer_name"] %} + {% } else if(data[i]["supplier_name"] != data[i]["party"]) { %} +
{%= data[i]["supplier_name"] %} + {% } %} + {% } %}
{% if data[i]["remarks"] %} - {{ _("Remarks") }}: - {{ data[i]["remarks"] }} - {% endif %} + {%= __("Remarks") %}: + {%= data[i]["remarks"] %} + {% } %}
- {{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }} - {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} - {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} - {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} - {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }}{%= data[i]["future_ref"] %}{%= format_currency(data[i]["future_amount"], data[i]["currency"]) %}{%= format_currency(data[i]["remaining_balance"], data[i]["currency"]) %}{{ _("Total") }}{%= __("Total") %} - {{ frappe.utils.fmt_money(data[i]["invoiced"], data[i]["currency"]) }} - {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} {%= format_currency(data[i]["credit_note"], data[i]["currency"]) %} - {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} - {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }}{{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }}{%= data[i]["future_ref"] %}{%= format_currency(data[i]["future_amount"], data[i]["currency"]) %}{%= format_currency(data[i]["remaining_balance"], data[i]["currency"]) %} - {% if(not(filters.customer | filters.supplier)) %} - {{ data[i]["party"] }} - {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %} -
{{ data[i]["customer_name"] }} - {% elif(data[i]["supplier_name"] != data[i]["party"]) %} -
{{ data[i]["supplier_name"] }} - {% endif %} - {% endif %} -
{{ _("Remarks") }}: - {{ data[i]["remarks"] }} + {% if(!(filters.customer || filters.supplier)) { %} + {%= data[i]["party"] %} + {% if(data[i]["customer_name"] && data[i]["customer_name"] != data[i]["party"]) { %} +
{%= data[i]["customer_name"] %} + {% } else if(data[i]["supplier_name"] != data[i]["party"]) { %} +
{%= data[i]["supplier_name"] %} + {% } %} + {% } %} +
{%= __("Remarks") %}: + {%= data[i]["remarks"] %}
{{ _("Total") }}{{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }}{{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }}{%= __("Total") %}{%= format_currency(data[i]["invoiced"], data[i]["currency"]) %}{%= format_currency(data[i]["paid"], data[i]["currency"]) %}{%= format_currency(data[i]["credit_note"], data[i]["currency"]) %}{%= format_currency(data[i]["outstanding"], data[i]["currency"]) %}
{{ frappe.utils.fmt_money(data|sum(attribute="invoiced"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="paid"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="credit_note"), currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(data|sum(attribute="outstanding"), currency=data[0]["currency"]) }}
-
- {% if ageing %} -

{{ _("Ageing Report based on ") }} {{ ageing.ageing_based_on }} - {{ _("up to " ) }} {{ frappe.format(filters.report_date, 'Date')}} -

- - - - - - - - - - - - - - - - - -
30 Days60 Days90 Days120 Days
{{ frappe.utils.fmt_money(ageing.range1, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range2, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range3, currency=data[0]["currency"]) }}{{ frappe.utils.fmt_money(ageing.range4, currency=data[0]["currency"]) }}
- {% endif %} -

{{ _("Printed On ") }}{{ frappe.utils.now() }}

+

{{ __("Printed On ") }}{%= frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string()) %}

\ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 18bd10f45f..8c0fa6bbcd 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -339,3 +339,4 @@ execute:frappe.delete_doc('DocType', 'Cash Flow Mapper', ignore_missing=True) execute:frappe.delete_doc('DocType', 'Cash Flow Mapping Template', ignore_missing=True) execute:frappe.delete_doc('DocType', 'Cash Flow Mapping Accounts', ignore_missing=True) erpnext.patches.v14_0.cleanup_workspaces +erpnext.patches.v14_0.set_report_in_process_SOA diff --git a/erpnext/patches/v14_0/set_report_in_process_SOA.py b/erpnext/patches/v14_0/set_report_in_process_SOA.py new file mode 100644 index 0000000000..1cb7e415d8 --- /dev/null +++ b/erpnext/patches/v14_0/set_report_in_process_SOA.py @@ -0,0 +1,10 @@ +# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors +# License: MIT. See LICENSE + +import frappe + + +def execute(): + process_soa = frappe.qb.DocType("Process Statement of Accounts") + q = frappe.qb.update(process_soa).set(process_soa.report, "General Ledger") + q.run() From cde82bc0cc978c3f4fec183825b709460062f8a8 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Fri, 23 Jun 2023 12:12:32 +0530 Subject: [PATCH 3/4] fix: modify patch --- erpnext/patches/v14_0/set_report_in_process_SOA.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/patches/v14_0/set_report_in_process_SOA.py b/erpnext/patches/v14_0/set_report_in_process_SOA.py index 1cb7e415d8..0f65b36404 100644 --- a/erpnext/patches/v14_0/set_report_in_process_SOA.py +++ b/erpnext/patches/v14_0/set_report_in_process_SOA.py @@ -5,6 +5,7 @@ import frappe def execute(): + frappe.reload_doc("accounts", "doctype", "Process Statement of Accounts", force=True) process_soa = frappe.qb.DocType("Process Statement of Accounts") q = frappe.qb.update(process_soa).set(process_soa.report, "General Ledger") q.run() From 4de7a4c5718acbc144729f143cdfc0f61a3693f7 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 24 Jun 2023 16:31:19 +0530 Subject: [PATCH 4/4] chore: update typo in patch --- erpnext/patches/v14_0/set_report_in_process_SOA.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/patches/v14_0/set_report_in_process_SOA.py b/erpnext/patches/v14_0/set_report_in_process_SOA.py index 0f65b36404..9eb5e3ab9b 100644 --- a/erpnext/patches/v14_0/set_report_in_process_SOA.py +++ b/erpnext/patches/v14_0/set_report_in_process_SOA.py @@ -5,7 +5,6 @@ import frappe def execute(): - frappe.reload_doc("accounts", "doctype", "Process Statement of Accounts", force=True) - process_soa = frappe.qb.DocType("Process Statement of Accounts") + process_soa = frappe.qb.DocType("Process Statement Of Accounts") q = frappe.qb.update(process_soa).set(process_soa.report, "General Ledger") q.run()