Skip to content

Commit

Permalink
feat: account receivable customization for serviplaga (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
fproldan authored and github-actions[bot] committed Aug 29, 2023
1 parent 4bf75f5 commit 09579bd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
17 changes: 17 additions & 0 deletions erpnext/accounts/report/accounts_receivable/accounts_receivable.js
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -66,6 +82,7 @@ frappe.query_reports["Accounts Receivable"] = {
}
}
},
family,
{
"fieldname": "ageing_based_on",
"label": __("Ageing Based On"),
Expand Down
18 changes: 16 additions & 2 deletions erpnext/accounts/report/accounts_receivable/accounts_receivable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 09579bd

Please sign in to comment.