diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js
index 9370f0453e..0a025f68d5 100644
--- a/erpnext/accounts/report/accounts_payable/accounts_payable.js
+++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js
@@ -10,36 +10,6 @@ frappe.query_reports["Accounts Payable"] = {
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
- {
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
- },
- {
- "fieldname":"supplier",
- "label": __("Supplier"),
- "fieldtype": "Link",
- "options": "Supplier",
- on_change: () => {
- var supplier = frappe.query_report.get_filter_value('supplier');
- frappe.db.get_value('Supplier', supplier, "tax_id", function(value) {
- frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
- });
- }
- },
- {
- "fieldname":"supplier_group",
- "label": __("Supplier Group"),
- "fieldtype": "Link",
- "options": "Supplier Group"
- },
- {
- "fieldname":"report_date",
- "label": __("As on Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
- },
{
"fieldname":"ageing_based_on",
"label": __("Ageing Based On"),
@@ -48,7 +18,10 @@ frappe.query_reports["Accounts Payable"] = {
"default": "Posting Date"
},
{
- "fieldtype": "Break",
+ "fieldname":"report_date",
+ "label": __("As on Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today()
},
{
"fieldname":"range1",
@@ -71,6 +44,34 @@ frappe.query_reports["Accounts Payable"] = {
"default": "90",
"reqd": 1
},
+ {
+ "fieldname":"finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book"
+ },
+ {
+ "fieldname":"supplier",
+ "label": __("Supplier"),
+ "fieldtype": "Link",
+ "options": "Supplier",
+ on_change: () => {
+ var supplier = frappe.query_report.get_filter_value('supplier');
+ if (supplier) {
+ frappe.db.get_value('Supplier', supplier, "tax_id", function(value) {
+ frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
+ });
+ } else {
+ frappe.query_report.set_filter_value('tax_id', "");
+ }
+ }
+ },
+ {
+ "fieldname":"supplier_group",
+ "label": __("Supplier Group"),
+ "fieldtype": "Link",
+ "options": "Supplier Group"
+ },
{
"fieldname":"tax_id",
"label": __("Tax Id"),
diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
index 77b099fd07..7823cac89c 100644
--- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
+++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
@@ -10,24 +10,6 @@ frappe.query_reports["Accounts Payable Summary"] = {
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
- {
- "fieldname":"supplier",
- "label": __("Supplier"),
- "fieldtype": "Link",
- "options": "Supplier"
- },
- {
- "fieldname":"supplier_group",
- "label": __("Supplier Group"),
- "fieldtype": "Link",
- "options": "Supplier Group"
- },
- {
- "fieldname":"report_date",
- "label": __("Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
- },
{
"fieldname":"ageing_based_on",
"label": __("Ageing Based On"),
@@ -36,7 +18,10 @@ frappe.query_reports["Accounts Payable Summary"] = {
"default": "Posting Date"
},
{
- "fieldtype": "Break",
+ "fieldname":"report_date",
+ "label": __("Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today()
},
{
"fieldname":"range1",
@@ -58,6 +43,24 @@ frappe.query_reports["Accounts Payable Summary"] = {
"fieldtype": "Int",
"default": "90",
"reqd": 1
+ },
+ {
+ "fieldname":"finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book"
+ },
+ {
+ "fieldname":"supplier",
+ "label": __("Supplier"),
+ "fieldtype": "Link",
+ "options": "Supplier"
+ },
+ {
+ "fieldname":"supplier_group",
+ "label": __("Supplier Group"),
+ "fieldtype": "Link",
+ "options": "Supplier Group"
}
],
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
index 4930207abd..fd462a628e 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
@@ -1,24 +1,14 @@
-{% if(filters.show_pdc_in_print) { %}
-
-{% } %}
-
-
{%= __(report.report_name) %}
+{%= __(report.report_name) %}
{% if (filters.customer_name) { %}
{%= filters.customer_name %}
@@ -36,7 +26,20 @@
{%= __("Until") %}
{%= frappe.datetime.str_to_user(filters.report_date) %}
-
+
+
+
+ {% if(filters.payment_terms) { %}
+ {%= __("Payment Terms") %}: {%= filters.payment_terms %}
+ {% } %}
+
+
+ {% if(filters.credit_limit) { %}
+ {%= __("Credit Limit") %}: {%= format_currency(filters.credit_limit) %}
+ {% } %}
+
+
+
{% if(filters.show_pdc_in_print) { %}
{% var balance_row = data.slice(-1).pop();
var range1 = report.columns[11].label;
@@ -104,17 +107,21 @@
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
- {%= __("Date") %} |
- {%= __("Reference") %} |
+ {%= __("Date") %} |
+ {%= __("Age (Days)") %} |
+ {%= __("Reference") %} |
+ {% if(report.report_name === "Accounts Receivable") { %}
+ {%= __("Sales Person") %} |
+ {% } %}
{% if(!filters.show_pdc_in_print) { %}
{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} |
{% } %}
- {%= __("Invoiced Amount") %} |
+ {%= __("Invoiced Amount") %} |
{% if(!filters.show_pdc_in_print) { %}
- {%= __("Paid Amount") %} |
- {%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %} |
+ {%= __("Paid Amount") %} |
+ {%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %} |
{% } %}
- {%= __("Outstanding Amount") %} |
+ {%= __("Outstanding Amount") %} |
{% if(filters.show_pdc_in_print) { %}
{% if(report.report_name === "Accounts Receivable") { %}
{%= __("Customer LPO No.") %} |
@@ -139,6 +146,7 @@
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
{% if(data[i][__("Customer")] || data[i][__("Supplier")]) { %}
{%= frappe.datetime.str_to_user(data[i]["posting_date"]) %} |
+ {%= data[i][__("Age (Days)")] %} |
{% if(!filters.show_pdc_in_print) { %}
{%= data[i]["voucher_type"] %}
@@ -146,6 +154,11 @@
{% } %}
{%= data[i]["voucher_no"] %}
|
+
+ {% if(report.report_name === "Accounts Receivable") { %}
+ {%= data[i]["sales_person"] %} |
+ {% } %}
+
{% if(!filters.show_pdc_in_print) { %}
{% if(!(filters.customer || filters.supplier)) { %}
@@ -156,10 +169,15 @@
{%= data[i][__("Supplier Name")] %}
{% } %}
{% } %}
- {%= __("Remarks") %}:
- {%= data[i][__("Remarks")] %}
+
+ {% if data[i][__("Remarks")] %}
+ {%= __("Remarks") %}:
+ {%= data[i][__("Remarks")] %}
+ {% } %}
+
|
{% } %}
+
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"]) %} |
@@ -187,7 +205,11 @@
{% if(!filters.show_pdc_in_print) { %}
|
{% } %}
- {%= __("Total") %} |
+ {% if(report.report_name === "Accounts Receivable") { %}
+ |
+ {% } %}
+ |
+ {%= __("Total") %} |
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"] ) %} |
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
index fda496057f..b1bdce95c8 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
@@ -10,6 +10,40 @@ frappe.query_reports["Accounts Receivable"] = {
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
+ {
+ "fieldname":"ageing_based_on",
+ "label": __("Ageing Based On"),
+ "fieldtype": "Select",
+ "options": 'Posting Date\nDue Date',
+ "default": "Posting Date"
+ },
+ {
+ "fieldname":"report_date",
+ "label": __("As on Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today()
+ },
+ {
+ "fieldname":"range1",
+ "label": __("Ageing Range 1"),
+ "fieldtype": "Int",
+ "default": "30",
+ "reqd": 1
+ },
+ {
+ "fieldname":"range2",
+ "label": __("Ageing Range 2"),
+ "fieldtype": "Int",
+ "default": "60",
+ "reqd": 1
+ },
+ {
+ "fieldname":"range3",
+ "label": __("Ageing Range 3"),
+ "fieldtype": "Int",
+ "default": "90",
+ "reqd": 1
+ },
{
"fieldname":"finance_book",
"label": __("Finance Book"),
@@ -23,10 +57,19 @@ frappe.query_reports["Accounts Receivable"] = {
"options": "Customer",
on_change: () => {
var customer = frappe.query_report.get_filter_value('customer');
- frappe.db.get_value('Customer', customer, ["tax_id", "customer_name"], function(value) {
- frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
- frappe.query_report.set_filter_value('customer_name', value["customer_name"]);
- });
+ if (customer) {
+ frappe.db.get_value('Customer', customer, ["tax_id", "customer_name", "credit_limit", "payment_terms"], function(value) {
+ frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
+ frappe.query_report.set_filter_value('customer_name', value["customer_name"]);
+ frappe.query_report.set_filter_value('credit_limit', value["credit_limit"]);
+ frappe.query_report.set_filter_value('payment_terms', value["payment_terms"]);
+ });
+ } else {
+ frappe.query_report.set_filter_value('tax_id', "");
+ frappe.query_report.set_filter_value('customer_name', "");
+ frappe.query_report.set_filter_value('credit_limit', "");
+ frappe.query_report.set_filter_value('payment_terms', "");
+ }
}
},
{
@@ -59,43 +102,6 @@ frappe.query_reports["Accounts Receivable"] = {
"fieldtype": "Link",
"options": "Sales Person"
},
- {
- "fieldtype": "Break",
- },
- {
- "fieldname":"report_date",
- "label": __("As on Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
- },
- {
- "fieldname":"ageing_based_on",
- "label": __("Ageing Based On"),
- "fieldtype": "Select",
- "options": 'Posting Date\nDue Date',
- "default": "Posting Date"
- },
- {
- "fieldname":"range1",
- "label": __("Ageing Range 1"),
- "fieldtype": "Int",
- "default": "30",
- "reqd": 1
- },
- {
- "fieldname":"range2",
- "label": __("Ageing Range 2"),
- "fieldtype": "Int",
- "default": "60",
- "reqd": 1
- },
- {
- "fieldname":"range3",
- "label": __("Ageing Range 3"),
- "fieldtype": "Int",
- "default": "90",
- "reqd": 1
- },
{
"fieldname":"show_pdc_in_print",
"label": __("Show PDC in Print"),
@@ -112,6 +118,18 @@ frappe.query_reports["Accounts Receivable"] = {
"label": __("Customer Name"),
"fieldtype": "Data",
"hidden": 1
+ },
+ {
+ "fieldname":"payment_terms",
+ "label": __("Payment Tems"),
+ "fieldtype": "Data",
+ "hidden": 1
+ },
+ {
+ "fieldname":"credit_limit",
+ "label": __("Credit Limit"),
+ "fieldtype": "Currency",
+ "hidden": 1
}
],
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 572f81dc35..8e05a087af 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -125,17 +125,22 @@ class ReceivablePayableReport(object):
}]
if args.get('party_type') == 'Customer':
- columns.append({
- "label": _("Customer LPO"),
- "fieldtype": "Data",
- "fieldname": "po_no",
- "width": 100,
- })
- columns += [_("Delivery Note") + ":Data:100"]
- if args.get("party_type") == "Customer":
columns += [
+ {
+ "label": _("Customer LPO"),
+ "fieldtype": "Data",
+ "fieldname": "po_no",
+ "width": 100,
+ },
+ _("Delivery Note") + ":Data:100",
_("Territory") + ":Link/Territory:80",
- _("Customer Group") + ":Link/Customer Group:120"
+ _("Customer Group") + ":Link/Customer Group:120",
+ {
+ "label": _("Sales Person"),
+ "fieldtype": "Data",
+ "fieldname": "sales_person",
+ "width": 120,
+ }
]
if args.get("party_type") == "Supplier":
columns += [_("Supplier Group") + ":Link/Supplier Group:80"]
@@ -238,7 +243,8 @@ class ReceivablePayableReport(object):
# customer territory / supplier group
if args.get("party_type") == "Customer":
- row += [self.get_territory(gle.party), self.get_customer_group(gle.party)]
+ row += [self.get_territory(gle.party), self.get_customer_group(gle.party),
+ voucher_details.get(gle.voucher_no, {}).get("sales_person")]
if args.get("party_type") == "Supplier":
row += [self.get_supplier_group(gle.party)]
@@ -395,9 +401,14 @@ class ReceivablePayableReport(object):
values.append(self.filters.get("sales_partner"))
if self.filters.get("sales_person"):
- conditions.append("""party in (select parent
- from `tabSales Team` where sales_person=%s and parenttype = 'Customer')""")
- values.append(self.filters.get("sales_person"))
+ lft, rgt = frappe.db.get_value("Sales Person",
+ self.filters.get("sales_person"), ["lft", "rgt"])
+
+ conditions.append("""exists(select name from `tabSales Team` steam where
+ steam.sales_person in (select name from `tabSales Person` where lft >= {0} and rgt <= {1})
+ and ((steam.parent = voucher_no and steam.parenttype = voucher_type)
+ or (steam.parent = against_voucher and steam.parenttype = against_voucher_type)
+ or (steam.parent = party and steam.parenttype = 'Customer')))""".format(lft, rgt))
if party_type_field=="supplier":
if self.filters.get("supplier_group"):
@@ -550,8 +561,12 @@ def get_voucher_details(party_type, voucher_nos, dn_details):
voucher_details = frappe._dict()
if party_type == "Customer":
- for si in frappe.db.sql("""select name, due_date, po_no
- from `tabSales Invoice` where docstatus=1 and name in (%s)
+ for si in frappe.db.sql("""
+ select inv.name, inv.due_date, inv.po_no, GROUP_CONCAT(steam.sales_person SEPARATOR ', ') as sales_person
+ from `tabSales Invoice` inv
+ left join `tabSales Team` steam on steam.parent = inv.name and steam.parenttype = 'Sales Invoice'
+ where inv.docstatus=1 and inv.name in (%s)
+ group by inv.name
""" %(','.join(['%s'] *len(voucher_nos))), (tuple(voucher_nos)), as_dict=1):
si['delivery_note'] = dn_details.get(si.name)
voucher_details.setdefault(si.name, si)
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
index 96e5d18093..a6f1457954 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
@@ -11,25 +11,11 @@ frappe.query_reports["Accounts Receivable Summary"] = {
"default": frappe.defaults.get_user_default("Company")
},
{
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer"
- },
- {
- "fieldname":"customer_group",
- "label": __("Customer Group"),
- "fieldtype": "Link",
- "options": "Customer Group"
- },
- {
- "fieldname":"payment_terms_template",
- "label": __("Payment Terms Template"),
- "fieldtype": "Link",
- "options": "Payment Terms Template"
- },
- {
- "fieldtype": "Break",
+ "fieldname":"ageing_based_on",
+ "label": __("Ageing Based On"),
+ "fieldtype": "Select",
+ "options": 'Posting Date\nDue Date',
+ "default": "Posting Date"
},
{
"fieldname":"report_date",
@@ -37,13 +23,6 @@ frappe.query_reports["Accounts Receivable Summary"] = {
"fieldtype": "Date",
"default": frappe.datetime.get_today()
},
- {
- "fieldname":"ageing_based_on",
- "label": __("Ageing Based On"),
- "fieldtype": "Select",
- "options": 'Posting Date\nDue Date',
- "default": "Posting Date"
- },
{
"fieldname":"range1",
"label": __("Ageing Range 1"),
@@ -64,6 +43,48 @@ frappe.query_reports["Accounts Receivable Summary"] = {
"fieldtype": "Int",
"default": "90",
"reqd": 1
+ },
+ {
+ "fieldname":"finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book"
+ },
+ {
+ "fieldname":"customer",
+ "label": __("Customer"),
+ "fieldtype": "Link",
+ "options": "Customer"
+ },
+ {
+ "fieldname":"customer_group",
+ "label": __("Customer Group"),
+ "fieldtype": "Link",
+ "options": "Customer Group"
+ },
+ {
+ "fieldname":"payment_terms_template",
+ "label": __("Payment Terms Template"),
+ "fieldtype": "Link",
+ "options": "Payment Terms Template"
+ },
+ {
+ "fieldname":"territory",
+ "label": __("Territory"),
+ "fieldtype": "Link",
+ "options": "Territory"
+ },
+ {
+ "fieldname":"sales_partner",
+ "label": __("Sales Partner"),
+ "fieldtype": "Link",
+ "options": "Sales Partner"
+ },
+ {
+ "fieldname":"sales_person",
+ "label": __("Sales Person"),
+ "fieldtype": "Link",
+ "options": "Sales Person"
}
],
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 7bf99728f7..190031abb8 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -97,6 +97,12 @@ class AccountsReceivableSummary(ReceivablePayableReport):
"fieldtype": "Link",
"options": "Customer Group",
"width": 80
+ },
+ {
+ "label": _("Sales Person"),
+ "fieldtype": "Data",
+ "fieldname": "sales_person",
+ "width": 120,
}]
if args.get("party_type") == "Supplier":
@@ -135,7 +141,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
]
if args.get("party_type") == "Customer":
- row += [self.get_territory(party), self.get_customer_group(party)]
+ row += [self.get_territory(party), self.get_customer_group(party), ", ".join(set(party_dict.sales_person))]
if args.get("party_type") == "Supplier":
row += [self.get_supplier_group(party)]
@@ -156,15 +162,19 @@ class AccountsReceivableSummary(ReceivablePayableReport):
"range1": 0,
"range2": 0,
"range3": 0,
- "range4": 0
+ "range4": 0,
+ "sales_person": []
})
)
for k in list(party_total[d.party]):
- if k != "currency":
+ if k not in ["currency", "sales_person"]:
party_total[d.party][k] += flt(d.get(k, 0))
party_total[d.party].currency = d.currency
+ if d.sales_person:
+ party_total[d.party].sales_person.append(d.sales_person)
+
return party_total
def get_voucherwise_data(self, party_naming_by, args):
@@ -181,12 +191,13 @@ class AccountsReceivableSummary(ReceivablePayableReport):
cols += ["bill_no", "bill_date"]
cols += ["invoiced_amt", "paid_amt", "credit_amt",
- "outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency"]
+ "outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency", "pdc/lc_date", "pdc/lc_ref",
+ "pdc/lc_amount", "remaining_balance"]
if args.get("party_type") == "Supplier":
cols += ["supplier_group", "remarks"]
if args.get("party_type") == "Customer":
- cols += ["territory", "customer_group", "remarks"]
+ cols += ["po_no", "do_no", "territory", "customer_group", "sales_person", "remarks"]
return self.make_data_dict(cols, voucherwise_data)