feat: added date filter based on billing date and based date (#18936)
This commit is contained in:
parent
ede7050afe
commit
ac0c1edd23
@ -39,7 +39,6 @@ def validate_filters(filters):
|
|||||||
frappe.throw(_("'Based On' and 'Group By' can not be same"))
|
frappe.throw(_("'Based On' and 'Group By' can not be same"))
|
||||||
|
|
||||||
def get_data(filters, conditions):
|
def get_data(filters, conditions):
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
inc, cond= '',''
|
inc, cond= '',''
|
||||||
query_details = conditions["based_on_select"] + conditions["period_wise_select"]
|
query_details = conditions["based_on_select"] + conditions["period_wise_select"]
|
||||||
@ -47,10 +46,11 @@ def get_data(filters, conditions):
|
|||||||
posting_date = 't1.transaction_date'
|
posting_date = 't1.transaction_date'
|
||||||
if conditions.get('trans') in ['Sales Invoice', 'Purchase Invoice', 'Purchase Receipt', 'Delivery Note']:
|
if conditions.get('trans') in ['Sales Invoice', 'Purchase Invoice', 'Purchase Receipt', 'Delivery Note']:
|
||||||
posting_date = 't1.posting_date'
|
posting_date = 't1.posting_date'
|
||||||
|
if filters.period_based_on:
|
||||||
|
posting_date = 't1.'+filters.period_based_on
|
||||||
|
|
||||||
if conditions["based_on_select"] in ["t1.project,", "t2.project,"]:
|
if conditions["based_on_select"] in ["t1.project,", "t2.project,"]:
|
||||||
cond = ' and '+ conditions["based_on_select"][:-1] +' IS Not NULL'
|
cond = ' and '+ conditions["based_on_select"][:-1] +' IS Not NULL'
|
||||||
|
|
||||||
if conditions.get('trans') in ['Sales Order', 'Purchase Order']:
|
if conditions.get('trans') in ['Sales Order', 'Purchase Order']:
|
||||||
cond += " and t1.status != 'Closed'"
|
cond += " and t1.status != 'Closed'"
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
erpnext.get_purchase_trends_filters = function() {
|
erpnext.get_purchase_trends_filters = function() {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
"fieldname":"company",
|
||||||
|
"label": __("Company"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"reqd": 1,
|
||||||
|
"default": frappe.defaults.get_user_default("Company")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"period",
|
"fieldname":"period",
|
||||||
"label": __("Period"),
|
"label": __("Period"),
|
||||||
@ -15,6 +23,23 @@ erpnext.get_purchase_trends_filters = function() {
|
|||||||
],
|
],
|
||||||
"default": "Monthly"
|
"default": "Monthly"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"fiscal_year",
|
||||||
|
"label": __("Fiscal Year"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options":'Fiscal Year',
|
||||||
|
"default": frappe.sys_defaults.fiscal_year
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"period_based_on",
|
||||||
|
"label": __("Period based On"),
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "posting_date", "label": __("Posting Date") },
|
||||||
|
{ "value": "bill_date", "label": __("Billing Date") },
|
||||||
|
],
|
||||||
|
"default": "posting_date"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"based_on",
|
"fieldname":"based_on",
|
||||||
"label": __("Based On"),
|
"label": __("Based On"),
|
||||||
@ -39,19 +64,5 @@ erpnext.get_purchase_trends_filters = function() {
|
|||||||
],
|
],
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname":"fiscal_year",
|
|
||||||
"label": __("Fiscal Year"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options":'Fiscal Year',
|
|
||||||
"default": frappe.sys_defaults.fiscal_year
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname":"company",
|
|
||||||
"label": __("Company"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"default": frappe.defaults.get_user_default("Company")
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user