[fix] Vehicle expense report not working
This commit is contained in:
parent
768a888bf2
commit
1ff1368280
@ -22,18 +22,6 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
query_report.trigger_refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.defaults.get_user_default("year_start_date"),
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.defaults.get_user_default("year_end_date"),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -3,15 +3,16 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import erpnext
|
||||
from frappe import _
|
||||
from frappe.utils import flt,cstr
|
||||
from erpnext.accounts.report.financial_statements import get_period_list
|
||||
|
||||
def execute(filters=None):
|
||||
period_list = get_period_list(2016, 2016,"Monthly")
|
||||
for period in period_list:
|
||||
pass
|
||||
columns, data = [], []
|
||||
if filters.get('fiscal_year'):
|
||||
company = erpnext.get_default_company()
|
||||
period_list = get_period_list(filters.get('fiscal_year'), filters.get('fiscal_year'),"Monthly", company)
|
||||
columns=get_columns()
|
||||
data=get_log_data(filters)
|
||||
chart=get_chart_data(data,period_list)
|
||||
@ -27,17 +28,16 @@ def get_columns():
|
||||
return columns
|
||||
|
||||
def get_log_data(filters):
|
||||
conditions=""
|
||||
if filters.from_date:
|
||||
conditions += " and date >= %(from_date)s"
|
||||
if filters.to_date:
|
||||
conditions += " and date <= %(to_date)s"
|
||||
data = frappe.db.sql("""select vhcl.license_plate as "License",vhcl.make as "Make",vhcl.model as "Model",
|
||||
vhcl.location as "Location",log.name as "Log",log.odometer as "Odometer",log.date as "Date",
|
||||
log.fuel_qty as "Fuel Qty",log.price as "Fuel Price"
|
||||
from `tabVehicle` vhcl,`tabVehicle Log` log
|
||||
where vhcl.license_plate = log.license_plate and log.docstatus = 1 %s
|
||||
order by date""" % (conditions,),filters, as_dict=1)
|
||||
fy = frappe.db.get_value('Fiscal Year', filters.get('fiscal_year'), ['year_start_date', 'year_end_date'], as_dict=True)
|
||||
data = frappe.db.sql("""select
|
||||
vhcl.license_plate as "License", vhcl.make as "Make", vhcl.model as "Model",
|
||||
vhcl.location as "Location", log.name as "Log", log.odometer as "Odometer",
|
||||
log.date as "Date", log.fuel_qty as "Fuel Qty", log.price as "Fuel Price"
|
||||
from
|
||||
`tabVehicle` vhcl,`tabVehicle Log` log
|
||||
where
|
||||
vhcl.license_plate = log.license_plate and log.docstatus = 1 and date between %s and %s
|
||||
order by date""" ,(fy.year_start_date, fy.year_end_date), as_dict=1)
|
||||
dl=list(data)
|
||||
for row in dl:
|
||||
row["Service Expense"]= get_service_expense(row["Log"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user