in Time Log - Server side validations added to recalculate cost on save
This commit is contained in:
parent
50234cb0fe
commit
a11770f06f
@ -46,7 +46,10 @@ class ExpenseClaim(Document):
|
||||
def update_task(self):
|
||||
expense_amount = frappe.db.sql("""select sum(total_sanctioned_amount) from `tabExpense Claim`
|
||||
where project = %s and task = %s and approval_status = "Approved" and docstatus=1""",(self.project, self.task))
|
||||
frappe.db.set_value("Project", self.project, "total_expense_claim", expense_amount)
|
||||
|
||||
task = frappe.get_doc("Task", self.task)
|
||||
task.total_expense_claim = expense_amount
|
||||
task.save()
|
||||
|
||||
def validate_task(self):
|
||||
if self.project and not self.task:
|
||||
|
@ -246,8 +246,9 @@
|
||||
],
|
||||
"icon": "icon-check",
|
||||
"idx": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 5,
|
||||
"modified": "2015-03-30 05:50:04.409614",
|
||||
"modified": "2015-03-31 03:31:13.055284",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Task",
|
||||
|
@ -51,11 +51,7 @@ var calculate_cost = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
frappe.ui.form.on("Time Log", "hours", function(frm) {
|
||||
calculate_cost(frm.doc);
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Time Log", "activity_type", function(frm) {
|
||||
var get_activity_cost = function(frm) {
|
||||
return frappe.call({
|
||||
method: "erpnext.projects.doctype.time_log.time_log.get_activity_cost",
|
||||
args: {
|
||||
@ -70,9 +66,19 @@ frappe.ui.form.on("Time Log", "activity_type", function(frm) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
frappe.ui.form.on("Time Log", "hours", function(frm) {
|
||||
calculate_cost(frm.doc);
|
||||
});
|
||||
|
||||
cur_frm.cscript.employee = cur_frm.cscript.activity_type;
|
||||
frappe.ui.form.on("Time Log", "activity_type", function(frm) {
|
||||
get_activity_cost(frm);
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Time Log", "employee", function(frm) {
|
||||
get_activity_cost(frm);
|
||||
});
|
||||
|
||||
cur_frm.cscript.billable = function(doc) {
|
||||
if (doc.billable==1) {
|
||||
|
@ -216,6 +216,9 @@ class TimeLog(Document):
|
||||
self.quantity = None
|
||||
|
||||
def validate_cost(self):
|
||||
rate = get_activity_cost(self.employee, self.activity_type)
|
||||
self.internal_rate = rate.get('internal_rate')
|
||||
self.billing_rate = rate.get('billing_rate')
|
||||
self.internal_cost = self.internal_rate * self.hours
|
||||
if self.billable:
|
||||
self.billing_amount = self.billing_rate * self.hours
|
||||
|
Loading…
x
Reference in New Issue
Block a user