From 09579bdaec9fa2b2c683eaf06f53b74db8f7e62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Rold=C3=A1n?= Date: Tue, 29 Aug 2023 13:31:40 -0300 Subject: [PATCH] feat: account receivable customization for serviplaga (#752) --- .../accounts_receivable/accounts_receivable.js | 17 +++++++++++++++++ .../accounts_receivable/accounts_receivable.py | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js index 570029851e83..ce641dc68742 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js @@ -1,6 +1,22 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +if (frappe.boot.single_types.includes("Persat Settings")) { + var family = { + "fieldname": "familia", + "label": __("Familia"), + "fieldtype": "Link", + "options": "Customer" + } +} else { + var family = { + "fieldname": "familia", + "label": __("Familia"), + "fieldtype": "Link", + "options": "Customer", + "hidden": 1 + } +} frappe.query_reports["Accounts Receivable"] = { "filters": [ { @@ -66,6 +82,7 @@ frappe.query_reports["Accounts Receivable"] = { } } }, + family, { "fieldname": "ageing_based_on", "label": __("Ageing Based On"), diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index e0f2e8480bd4..c32f1ac9c213 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -97,6 +97,12 @@ def get_data(self): def init_voucher_balance(self): # build all keys, since we want to exclude vouchers beyond the report date for gle in self.gl_entries: + + if frappe.get_hooks('accounts_receivable_family_column') and gle.party_type == 'Customer': + familia = frappe.get_value('Customer', gle.party, 'familia') + else: + familia = None + # get the balance object for voucher_type key = (gle.voucher_type, gle.voucher_no, gle.party) if not key in self.voucher_balance: @@ -114,7 +120,8 @@ def init_voucher_balance(self): invoiced_in_account_currency = 0.0, paid_in_account_currency = 0.0, credit_note_in_account_currency = 0.0, - outstanding_in_account_currency = 0.0 + outstanding_in_account_currency = 0.0, + familia = familia ) self.get_invoices(gle) @@ -231,7 +238,7 @@ def build_data(self): row.outstanding_in_account_currency = flt(row.invoiced_in_account_currency - row.paid_in_account_currency - \ row.credit_note_in_account_currency, self.currency_precision) row.invoice_grand_total = row.invoiced - + if frappe.get_hooks('accounts_receivable_usd_column') and row.outstanding != 0.0: if row['voucher_type'] == "Payment Entry": currency_field = "paid_to_account_currency" @@ -736,6 +743,10 @@ def add_customer_filters(self, conditions, values): conditions.append("party in (select name from tabCustomer where default_sales_partner=%s)") values.append(self.filters.get("sales_partner")) + if self.filters.get("familia"): + conditions.append("party in (select name from tabCustomer where familia=%s)") + values.append(self.filters.get("familia")) + def add_supplier_filters(self, conditions, values): if self.filters.get("supplier_group"): conditions.append("""party in (select name from tabSupplier @@ -803,6 +814,9 @@ def get_columns(self): self.add_column(label=_(self.party_type), fieldname='party', fieldtype='Link', options=self.party_type, width=180) + if frappe.get_hooks('accounts_receivable_family_column') and self.party_type == 'Customer': + self.add_column(_("Familia"), fieldname='familia', fieldtype='Link', options='Customer') + if self.party_naming_by == "Naming Series": self.add_column(_('{0} Name').format(self.party_type), fieldname = scrub(self.party_type) + '_name', fieldtype='Data')