Skip to content

Commit a198b3b

Browse files
authored
Merge pull request #878 from fproldan/diamoerp-staging
Diamoerp staging
2 parents 074eb18 + 2827aa2 commit a198b3b

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

erpnext/accounts/report/accounts_receivable/accounts_receivable.html

+7
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ <h5 class="text-center">
142142
{% } %}
143143
{% if(!filters.show_future_payments) { %}
144144
<th style="width: 20%">{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}</th>
145+
{% if(report.report_name === "Accounts Receivable" && frappe.boot.single_types.includes("Persat Settings")) { %}
146+
<th style="width: 20%">Familia</th>
147+
{% } %}
145148
{% } %}
146149
<th style="width: 10%; text-align: right">{%= __("Invoiced Amount") %}</th>
147150
{% if(!filters.show_future_payments) { %}
@@ -204,6 +207,10 @@ <h5 class="text-center">
204207
</td>
205208
{% } %}
206209

210+
{% if(report.report_name === "Accounts Receivable" && frappe.boot.single_types.includes("Persat Settings")) { %}
211+
<td>{%= data[i]["familia"] %}</td>
212+
{% } %}
213+
207214
<td style="text-align: right">
208215
{%= format_currency(data[i]["invoiced"], data[i]["currency"]) %}</td>
209216

erpnext/accounts/report/accounts_receivable/accounts_receivable.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@ if (frappe.boot.single_types.includes("Persat Settings")) {
66
"fieldname": "familia",
77
"label": __("Familia"),
88
"fieldtype": "Link",
9-
"options": "Customer"
9+
"options": "Customer",
10+
get_query: () => {
11+
return {
12+
filters: {
13+
'es_familia': 1
14+
}
15+
};
16+
}
17+
}
18+
var group_by_family = {
19+
"fieldname": "group_by_family",
20+
"label": __("Agrupar por Familia"),
21+
"fieldtype": "Check",
22+
get_query: () => {
23+
return {
24+
filters: {
25+
'es_familia': 1
26+
}
27+
};
28+
}
1029
}
1130
} else {
1231
var family = {
@@ -16,6 +35,12 @@ if (frappe.boot.single_types.includes("Persat Settings")) {
1635
"options": "Customer",
1736
"hidden": 1
1837
}
38+
var group_by_family = {
39+
"fieldname": "group_by_family",
40+
"label": __("Agrupar por Familia"),
41+
"fieldtype": "Check",
42+
"hidden": 1
43+
}
1944
}
2045
frappe.query_reports["Accounts Receivable"] = {
2146
"filters": [
@@ -153,6 +178,7 @@ frappe.query_reports["Accounts Receivable"] = {
153178
"label": __("Group By Customer"),
154179
"fieldtype": "Check"
155180
},
181+
group_by_family,
156182
{
157183
"fieldname": "based_on_payment_terms",
158184
"label": __("Based On Payment Terms"),

erpnext/accounts/report/accounts_receivable/accounts_receivable.py

+48-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def set_defaults(self):
6969
self.previous_party=''
7070
self.total_row_map = {}
7171
self.skip_total_row = 1
72+
elif self.filters.get('group_by_family'):
73+
self.previous_family=''
74+
self.total_family_row_map = {}
75+
self.skip_total_row = 1
7276

7377
def get_data(self):
7478
self.get_gl_entries()
@@ -106,6 +110,8 @@ def init_voucher_balance(self):
106110
else:
107111
familia = None
108112

113+
if self.filters.get('group_by_family') and not familia:
114+
continue
109115
# get the balance object for voucher_type
110116
key = (gle.voucher_type, gle.voucher_no, gle.party)
111117
if not key in self.voucher_balance:
@@ -130,9 +136,13 @@ def init_voucher_balance(self):
130136

131137
if self.filters.get('group_by_party'):
132138
self.init_subtotal_row(gle.party)
139+
elif self.filters.get('group_by_family'):
140+
self.init_subtotal_family_row(familia)
133141

134142
if self.filters.get('group_by_party'):
135143
self.init_subtotal_row('Total')
144+
elif self.filters.get('group_by_family'):
145+
self.init_subtotal_family_row('Total')
136146

137147
def get_invoices(self, gle):
138148
if gle.voucher_type in ('Sales Invoice', 'Purchase Invoice'):
@@ -152,6 +162,16 @@ def init_subtotal_row(self, party):
152162

153163
for field in self.get_currency_fields():
154164
self.total_row_map[party][field] = 0.0
165+
166+
def init_subtotal_family_row(self, familia):
167+
if not self.total_family_row_map.get(familia):
168+
self.total_family_row_map.setdefault(familia, {
169+
'familia': familia,
170+
'bold': 1
171+
})
172+
173+
for field in self.get_currency_fields():
174+
self.total_family_row_map[familia][field] = 0.0
155175

156176
def get_currency_fields(self):
157177
return ['invoiced', 'paid', 'credit_note', 'outstanding', 'range1', 'range2', 'range3', 'range4', 'range5']
@@ -194,6 +214,12 @@ def update_sub_total_row(self, row, party):
194214

195215
for field in self.get_currency_fields():
196216
total_row[field] += row.get(field, 0.0)
217+
218+
def update_sub_total_family_row(self, row, familia):
219+
total_row = self.total_family_row_map.get(familia)
220+
221+
for field in self.get_currency_fields():
222+
total_row[field] += row.get(field, 0.0)
197223

198224
def append_subtotal_row(self, party):
199225
sub_total_row = self.total_row_map.get(party)
@@ -202,6 +228,14 @@ def append_subtotal_row(self, party):
202228
self.data.append(sub_total_row)
203229
self.data.append({})
204230
self.update_sub_total_row(sub_total_row, 'Total')
231+
232+
def append_subtotal_family_row(self, familia):
233+
sub_total_row = self.total_family_row_map.get(familia)
234+
235+
if sub_total_row:
236+
self.data.append(sub_total_row)
237+
self.data.append({})
238+
self.update_sub_total_family_row(sub_total_row, 'Total')
205239

206240
def get_voucher_balance(self, gle):
207241
if self.filters.get("sales_person"):
@@ -276,6 +310,8 @@ def build_data(self):
276310
conversion_rate = get_exchange_rate("USD", vourcher_data[currency_field], nowdate(), exchange_type)
277311
row.outstanding_original_currency = flt((row.outstanding / conversion_rate), self.currency_precision)
278312

313+
row['voucher_type'] = _(row['voucher_type'])
314+
279315
if frappe.get_hooks('accounts_receivable_usd_column') and row.outstanding == 0.0:
280316
row.outstanding_original_currency = 0
281317

@@ -306,6 +342,10 @@ def build_data(self):
306342
self.append_subtotal_row(self.previous_party)
307343
if self.data:
308344
self.data.append(self.total_row_map.get('Total'))
345+
elif self.filters.get('group_by_family'):
346+
self.append_subtotal_family_row(self.previous_family)
347+
if self.data:
348+
self.data.append(self.total_family_row_map.get('Total'))
309349

310350
def append_row(self, row):
311351
self.allocate_future_payments(row)
@@ -318,6 +358,11 @@ def append_row(self, row):
318358
if self.previous_party and (self.previous_party != row.party):
319359
self.append_subtotal_row(self.previous_party)
320360
self.previous_party = row.party
361+
elif self.filters.get('group_by_family'):
362+
self.update_sub_total_family_row(row, row.familia)
363+
if self.previous_family and (self.previous_family != row.familia):
364+
self.append_subtotal_family_row(self.previous_family)
365+
self.previous_family = row.familia
321366

322367
self.data.append(row)
323368

@@ -652,7 +697,7 @@ def get_gl_entries(self):
652697
doc_currency_fields = "debit_in_account_currency, credit_in_account_currency"
653698

654699
remarks = ", remarks" if self.filters.get("show_remarks") else ""
655-
700+
656701
self.gl_entries = frappe.db.sql("""
657702
select
658703
name, posting_date, account, party_type, party, voucher_type, voucher_no, cost_center,
@@ -712,6 +757,8 @@ def get_cost_center_conditions(self, conditions):
712757
def get_order_by_condition(self):
713758
if self.filters.get('group_by_party'):
714759
return "order by party, posting_date"
760+
elif self.filters.get('group_by_family'):
761+
return "order by party, posting_date"
715762
else:
716763
return "order by posting_date, party"
717764

0 commit comments

Comments
 (0)