2015-03-03 14:55:30 +05:30
|
|
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
2013-08-05 14:59:54 +05:30
|
|
|
// License: GNU General Public License v3. See license.txt
|
|
|
|
|
2023-09-27 13:01:48 +05:30
|
|
|
frappe.provide("erpnext.utils");
|
|
|
|
|
2014-02-14 15:47:51 +05:30
|
|
|
frappe.query_reports["Accounts Receivable"] = {
|
2013-04-22 13:14:52 +05:30
|
|
|
"filters": [
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "company",
|
2014-04-14 16:25:30 +05:30
|
|
|
"label": __("Company"),
|
2013-04-22 13:14:52 +05:30
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Company",
|
2019-07-01 11:54:11 +05:30
|
|
|
"reqd": 1,
|
2015-12-23 16:37:00 +05:30
|
|
|
"default": frappe.defaults.get_user_default("Company")
|
2013-04-22 13:14:52 +05:30
|
|
|
},
|
2020-03-02 19:10:29 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "report_date",
|
2020-03-02 19:10:29 +05:30
|
|
|
"label": __("Posting Date"),
|
|
|
|
"fieldtype": "Date",
|
|
|
|
"default": frappe.datetime.get_today()
|
|
|
|
},
|
2018-04-23 02:56:50 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "finance_book",
|
2018-04-23 02:56:50 +05:30
|
|
|
"label": __("Finance Book"),
|
|
|
|
"fieldtype": "Link",
|
2018-05-09 15:10:29 +05:30
|
|
|
"options": "Finance Book"
|
2018-04-23 02:56:50 +05:30
|
|
|
},
|
2019-03-18 11:53:04 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "cost_center",
|
2019-03-18 11:53:04 +05:30
|
|
|
"label": __("Cost Center"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Cost Center",
|
|
|
|
get_query: () => {
|
|
|
|
var company = frappe.query_report.get_filter_value('company');
|
|
|
|
return {
|
|
|
|
filters: {
|
|
|
|
'company': company
|
|
|
|
}
|
2020-09-18 13:26:46 +05:30
|
|
|
};
|
2019-03-18 11:53:04 +05:30
|
|
|
}
|
|
|
|
},
|
2013-04-22 13:14:52 +05:30
|
|
|
{
|
2023-09-27 13:01:48 +05:30
|
|
|
"fieldname":"party_type",
|
2023-09-18 13:50:21 +05:30
|
|
|
"label": __("Party Type"),
|
2023-09-27 13:01:48 +05:30
|
|
|
"fieldtype": "Autocomplete",
|
|
|
|
options: get_party_type_options(),
|
|
|
|
on_change: function() {
|
2023-09-18 13:50:21 +05:30
|
|
|
frappe.query_report.set_filter_value('party', "");
|
|
|
|
frappe.query_report.toggle_filter_display('customer_group', frappe.query_report.get_filter_value('party_type') !== "Customer");
|
2018-03-23 15:04:37 +05:30
|
|
|
}
|
2013-04-22 13:14:52 +05:30
|
|
|
},
|
2023-09-18 13:50:21 +05:30
|
|
|
{
|
|
|
|
"fieldname":"party",
|
|
|
|
"label": __("Party"),
|
2023-09-27 13:01:48 +05:30
|
|
|
"fieldtype": "MultiSelectList",
|
|
|
|
get_data: function(txt) {
|
|
|
|
if (!frappe.query_report.filters) return;
|
|
|
|
|
|
|
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
|
|
|
if (!party_type) return;
|
|
|
|
|
|
|
|
return frappe.db.get_link_options(party_type, txt);
|
|
|
|
},
|
2023-09-18 13:50:21 +05:30
|
|
|
},
|
2022-03-30 15:00:16 +05:30
|
|
|
{
|
|
|
|
"fieldname": "party_account",
|
|
|
|
"label": __("Receivable Account"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Account",
|
|
|
|
get_query: () => {
|
|
|
|
var company = frappe.query_report.get_filter_value('company');
|
|
|
|
return {
|
|
|
|
filters: {
|
|
|
|
'company': company,
|
|
|
|
'account_type': 'Receivable',
|
|
|
|
'is_group': 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
2020-07-10 11:25:39 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "ageing_based_on",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Ageing Based On"),
|
|
|
|
"fieldtype": "Select",
|
|
|
|
"options": 'Posting Date\nDue Date',
|
|
|
|
"default": "Due Date"
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "range1",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Ageing Range 1"),
|
|
|
|
"fieldtype": "Int",
|
|
|
|
"default": "30",
|
|
|
|
"reqd": 1
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "range2",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Ageing Range 2"),
|
|
|
|
"fieldtype": "Int",
|
|
|
|
"default": "60",
|
|
|
|
"reqd": 1
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "range3",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Ageing Range 3"),
|
|
|
|
"fieldtype": "Int",
|
|
|
|
"default": "90",
|
|
|
|
"reqd": 1
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "range4",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Ageing Range 4"),
|
|
|
|
"fieldtype": "Int",
|
|
|
|
"default": "120",
|
|
|
|
"reqd": 1
|
|
|
|
},
|
2017-04-24 17:03:50 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "customer_group",
|
2017-04-24 17:03:50 +05:30
|
|
|
"label": __("Customer Group"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Customer Group"
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "payment_terms_template",
|
2018-01-09 15:39:35 +05:30
|
|
|
"label": __("Payment Terms Template"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Payment Terms Template"
|
2017-04-24 17:03:50 +05:30
|
|
|
},
|
2018-01-24 18:16:08 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "sales_partner",
|
2018-01-24 18:16:08 +05:30
|
|
|
"label": __("Sales Partner"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Sales Partner"
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "sales_person",
|
2018-01-24 18:16:08 +05:30
|
|
|
"label": __("Sales Person"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Sales Person"
|
|
|
|
},
|
2020-07-10 11:25:39 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "territory",
|
2020-07-10 11:25:39 +05:30
|
|
|
"label": __("Territory"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Territory"
|
|
|
|
},
|
2020-02-18 16:07:34 +05:30
|
|
|
{
|
|
|
|
"fieldname": "group_by_party",
|
|
|
|
"label": __("Group By Customer"),
|
|
|
|
"fieldtype": "Check"
|
|
|
|
},
|
2019-04-01 16:24:23 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "based_on_payment_terms",
|
2019-04-01 16:24:23 +05:30
|
|
|
"label": __("Based On Payment Terms"),
|
|
|
|
"fieldtype": "Check",
|
|
|
|
},
|
2018-02-07 18:32:51 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "show_future_payments",
|
2019-09-03 16:07:46 +05:30
|
|
|
"label": __("Show Future Payments"),
|
2018-02-07 18:32:51 +05:30
|
|
|
"fieldtype": "Check",
|
2018-03-23 15:04:37 +05:30
|
|
|
},
|
2018-11-12 11:17:39 +05:30
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "show_delivery_notes",
|
2020-03-02 19:10:29 +05:30
|
|
|
"label": __("Show Linked Delivery Notes"),
|
2019-09-03 16:07:46 +05:30
|
|
|
"fieldtype": "Check",
|
|
|
|
},
|
|
|
|
{
|
2021-09-09 11:57:29 +05:30
|
|
|
"fieldname": "show_sales_person",
|
2019-09-03 16:07:46 +05:30
|
|
|
"label": __("Show Sales Person"),
|
2018-11-12 11:17:39 +05:30
|
|
|
"fieldtype": "Check",
|
|
|
|
},
|
2022-08-22 15:46:04 +05:30
|
|
|
{
|
|
|
|
"fieldname": "show_remarks",
|
|
|
|
"label": __("Show Remarks"),
|
|
|
|
"fieldtype": "Check",
|
2013-04-22 13:14:52 +05:30
|
|
|
}
|
2017-01-03 16:29:41 +05:30
|
|
|
],
|
|
|
|
|
2020-02-18 16:07:34 +05:30
|
|
|
"formatter": function(value, row, column, data, default_formatter) {
|
|
|
|
value = default_formatter(value, row, column, data);
|
|
|
|
if (data && data.bold) {
|
|
|
|
value = value.bold();
|
|
|
|
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
|
2017-01-03 16:29:41 +05:30
|
|
|
onload: function(report) {
|
|
|
|
report.page.add_inner_button(__("Accounts Receivable Summary"), function() {
|
|
|
|
var filters = report.get_values();
|
|
|
|
frappe.set_route('query-report', 'Accounts Receivable Summary', {company: filters.company});
|
|
|
|
});
|
|
|
|
}
|
2014-09-11 19:27:24 +05:30
|
|
|
}
|
2019-07-07 21:24:45 +05:30
|
|
|
|
2020-05-26 19:23:45 +05:30
|
|
|
erpnext.utils.add_dimensions('Accounts Receivable', 9);
|
2023-09-27 13:01:48 +05:30
|
|
|
|
|
|
|
|
|
|
|
function get_party_type_options() {
|
|
|
|
let options = [];
|
|
|
|
frappe.db.get_list(
|
|
|
|
"Party Type", {filters:{"account_type": "Receivable"}, fields:['name']}
|
|
|
|
).then((res) => {
|
|
|
|
res.forEach((party_type) => {
|
|
|
|
options.push(party_type.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return options;
|
|
|
|
}
|