feat: provistion to pull timesheet in sales invoice
This commit is contained in:
parent
9b178bcd10
commit
47ce85484b
@ -695,6 +695,7 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
refresh_field(['timesheets'])
|
refresh_field(['timesheets'])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
frm.refresh();
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
@ -810,6 +811,65 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
if (frm.doc.project) {
|
||||||
|
frm.add_custom_button(__('Fetch Timesheet'), function() {
|
||||||
|
let d = new frappe.ui.Dialog({
|
||||||
|
title: __('Fetch Timesheet'),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
"label" : "From",
|
||||||
|
"fieldname": "from_time",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"reqd": 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Column Break',
|
||||||
|
fieldname: 'col_break_1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label" : "To",
|
||||||
|
"fieldname": "to_time",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"reqd": 1,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
primary_action: function() {
|
||||||
|
let data = d.get_values();
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.projects.doctype.timesheet.timesheet.get_projectwise_timesheet_data",
|
||||||
|
args: {
|
||||||
|
from_time: data.from_time,
|
||||||
|
to_time: data.to_time,
|
||||||
|
project: frm.doc.project
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc) {
|
||||||
|
if(r.message.length > 0) {
|
||||||
|
frm.clear_table('timesheets')
|
||||||
|
r.message.forEach((d) => {
|
||||||
|
frm.add_child('timesheets',{
|
||||||
|
'time_sheet': d.parent,
|
||||||
|
'billing_hours': d.billing_hours,
|
||||||
|
'billing_amount': d.billing_amt,
|
||||||
|
'timesheet_detail': d.name
|
||||||
|
});
|
||||||
|
});
|
||||||
|
frm.refresh_field('timesheets')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
frappe.msgprint(__('No Timesheet Found.'))
|
||||||
|
}
|
||||||
|
d.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
primary_action_label: __('Get Timesheets')
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (frappe.boot.active_domains.includes("Healthcare")) {
|
if (frappe.boot.active_domains.includes("Healthcare")) {
|
||||||
frm.set_df_property("patient", "hidden", 0);
|
frm.set_df_property("patient", "hidden", 0);
|
||||||
frm.set_df_property("patient_name", "hidden", 0);
|
frm.set_df_property("patient_name", "hidden", 0);
|
||||||
|
|||||||
@ -204,14 +204,16 @@ class Timesheet(Document):
|
|||||||
ts_detail.billing_rate = 0.0
|
ts_detail.billing_rate = 0.0
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_projectwise_timesheet_data(project, parent=None):
|
def get_projectwise_timesheet_data(project, parent=None, from_time=None, to_time=None):
|
||||||
cond = ''
|
condition = ''
|
||||||
if parent:
|
if parent:
|
||||||
cond = "and parent = %(parent)s"
|
condition = "AND parent = %(parent)s"
|
||||||
|
if from_time and to_time:
|
||||||
|
condition += "AND from_time BETWEEN %(from_time)s AND %(to_time)s"
|
||||||
|
|
||||||
return frappe.db.sql("""select name, parent, billing_hours, billing_amount as billing_amt
|
return frappe.db.sql("""select name, parent, billing_hours, billing_amount as billing_amt
|
||||||
from `tabTimesheet Detail` where parenttype = 'Timesheet' and docstatus=1 and project = %(project)s {0} and billable = 1
|
from `tabTimesheet Detail` where parenttype = 'Timesheet' and docstatus=1 and project = %(project)s {0} and billable = 1
|
||||||
and sales_invoice is null""".format(cond), {'project': project, 'parent': parent}, as_dict=1)
|
and sales_invoice is null""".format(condition), {'project': project, 'parent': parent, 'from_time': from_time, 'to_time': to_time}, as_dict=1)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user