mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 23:39:28 +00:00
[mionr] fixes and cleanups
This commit is contained in:
@@ -5,11 +5,11 @@ cur_frm.add_fetch('employee', 'employee_name', 'employee_name');
|
||||
frappe.ui.form.on("Timesheet", {
|
||||
setup: function(frm) {
|
||||
frm.get_field('time_logs').grid.editable_fields = [
|
||||
{fieldname: 'billable', columns: 2},
|
||||
{fieldname: 'billable', columns: 1},
|
||||
{fieldname: 'activity_type', columns: 2},
|
||||
{fieldname: 'from_time', columns: 2},
|
||||
{fieldname: 'hours', columns: 2},
|
||||
{fieldname: 'to_time', columns: 2},
|
||||
{fieldname: 'from_time', columns: 3},
|
||||
{fieldname: 'hours', columns: 1},
|
||||
{fieldname: 'project', columns: 3}
|
||||
];
|
||||
|
||||
frm.fields_dict.employee.get_query = function() {
|
||||
@@ -22,7 +22,8 @@ frappe.ui.form.on("Timesheet", {
|
||||
child = locals[cdt][cdn];
|
||||
return{
|
||||
filters: {
|
||||
'project': child.project
|
||||
'project': child.project,
|
||||
'status': ["!=", "Closed"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +38,7 @@ frappe.ui.form.on("Timesheet", {
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus==1) {
|
||||
if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0
|
||||
&& !frm.doc.production_order){
|
||||
if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0){
|
||||
frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") },
|
||||
"icon-file-alt");
|
||||
}
|
||||
@@ -147,13 +147,16 @@ var calculate_time_and_amount = function(frm) {
|
||||
var tl = frm.doc.time_logs || [];
|
||||
total_hr = 0;
|
||||
total_billing_amount = 0;
|
||||
total_costing_amount = 0;
|
||||
for(var i=0; i<tl.length; i++) {
|
||||
if (tl[i].hours) {
|
||||
total_hr += tl[i].hours;
|
||||
total_billing_amount += tl[i].billing_amount;
|
||||
total_costing_amount += tl[i].costing_amount;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.set_value("total_hours", total_hr);
|
||||
cur_frm.set_value("total_billing_amount", total_billing_amount);
|
||||
cur_frm.set_value("total_costing_amount", total_costing_amount);
|
||||
}
|
||||
@@ -157,7 +157,7 @@
|
||||
"no_copy": 1,
|
||||
"options": "Draft\nSubmitted\nBilled\nPayslip\nCompleted\nCancelled",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
@@ -478,7 +478,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"default": "0",
|
||||
"description": "updated via Time Logs",
|
||||
"description": "",
|
||||
"fieldname": "total_hours",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -529,7 +529,7 @@
|
||||
"collapsible": 0,
|
||||
"default": "0",
|
||||
"depends_on": "",
|
||||
"description": "updated via Time Logs",
|
||||
"description": "",
|
||||
"fieldname": "total_billing_amount",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -551,6 +551,31 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "total_costing_amount",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Total Costing Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@@ -637,7 +662,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-13 23:44:05.086570",
|
||||
"modified": "2016-07-26 00:01:56.055046",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Timesheet",
|
||||
|
||||
@@ -20,14 +20,21 @@ class OverProductionLoggedError(frappe.ValidationError): pass
|
||||
class Timesheet(Document):
|
||||
def validate(self):
|
||||
self.set_status()
|
||||
self.total_hours = 0.0
|
||||
self.total_billing_amount = 0.0
|
||||
self.validate_dates()
|
||||
self.validate_time_logs()
|
||||
self.update_cost()
|
||||
self.calculate_total_amounts()
|
||||
|
||||
def calculate_total_amounts(self):
|
||||
self.total_hours = 0.0
|
||||
self.total_billing_amount = 0.0
|
||||
self.total_costing_amount = 0.0
|
||||
|
||||
for d in self.get("time_logs"):
|
||||
self.total_hours += flt(d.hours)
|
||||
if d.billable: self.total_billing_amount += flt(d.billing_amount)
|
||||
if d.billable:
|
||||
self.total_billing_amount += flt(d.billing_amount)
|
||||
self.total_costing_amount += flt(d.costing_amount)
|
||||
|
||||
def set_status(self):
|
||||
self.status = {
|
||||
@@ -88,7 +95,7 @@ class Timesheet(Document):
|
||||
frappe.throw(_("Row {0}: Completed Qty must be greater than zero.").format(data.idx))
|
||||
|
||||
if self.production_order and flt(pending_qty) < flt(data.completed_qty):
|
||||
frappe.throw(_("Row {0}: Completed Qty cannot be more than {0} for operation {1}").format(data.idx, pending_qty, self.operation),
|
||||
frappe.throw(_("Row {0}: Completed Qty cannot be more than {1} for operation {2}").format(data.idx, pending_qty, data.operation),
|
||||
OverProductionLoggedError)
|
||||
|
||||
def update_production_order(self, time_sheet):
|
||||
@@ -220,7 +227,7 @@ class Timesheet(Document):
|
||||
|
||||
def update_cost(self):
|
||||
for data in self.time_logs:
|
||||
if data.activity_type and not data.billing_amount:
|
||||
if data.activity_type and (not data.billing_amount or not data.costing_amount):
|
||||
rate = get_activity_cost(self.employee, data.activity_type)
|
||||
hours = data.hours or 0
|
||||
if rate:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:!parent.production_order",
|
||||
"depends_on": "",
|
||||
"fieldname": "billable",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -27,7 +27,7 @@
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
@@ -163,7 +163,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:!parent.production_order",
|
||||
"depends_on": "billable",
|
||||
"fieldname": "section_break_11",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -265,7 +265,7 @@
|
||||
"collapsible": 0,
|
||||
"default": "0",
|
||||
"depends_on": "",
|
||||
"description": "To display value check Billable",
|
||||
"description": "",
|
||||
"fieldname": "billing_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -292,7 +292,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"default": "0",
|
||||
"description": "To display value check Billable",
|
||||
"description": "",
|
||||
"fieldname": "costing_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -532,7 +532,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-21 09:59:01.622745",
|
||||
"modified": "2016-07-26 00:07:58.267131",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Timesheet Detail",
|
||||
|
||||
Reference in New Issue
Block a user