mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
in Time Log - Server side validations added to recalculate cost on save
This commit is contained in:
@@ -46,7 +46,10 @@ class ExpenseClaim(Document):
|
|||||||
def update_task(self):
|
def update_task(self):
|
||||||
expense_amount = frappe.db.sql("""select sum(total_sanctioned_amount) from `tabExpense Claim`
|
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))
|
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):
|
def validate_task(self):
|
||||||
if self.project and not self.task:
|
if self.project and not self.task:
|
||||||
|
|||||||
@@ -246,8 +246,9 @@
|
|||||||
],
|
],
|
||||||
"icon": "icon-check",
|
"icon": "icon-check",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
|
"istable": 0,
|
||||||
"max_attachments": 5,
|
"max_attachments": 5,
|
||||||
"modified": "2015-03-30 05:50:04.409614",
|
"modified": "2015-03-31 03:31:13.055284",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Task",
|
"name": "Task",
|
||||||
|
|||||||
@@ -51,11 +51,7 @@ var calculate_cost = function(doc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.ui.form.on("Time Log", "hours", function(frm) {
|
var get_activity_cost = function(frm) {
|
||||||
calculate_cost(frm.doc);
|
|
||||||
});
|
|
||||||
|
|
||||||
frappe.ui.form.on("Time Log", "activity_type", function(frm) {
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.projects.doctype.time_log.time_log.get_activity_cost",
|
method: "erpnext.projects.doctype.time_log.time_log.get_activity_cost",
|
||||||
args: {
|
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) {
|
cur_frm.cscript.billable = function(doc) {
|
||||||
if (doc.billable==1) {
|
if (doc.billable==1) {
|
||||||
|
|||||||
@@ -216,6 +216,9 @@ class TimeLog(Document):
|
|||||||
self.quantity = None
|
self.quantity = None
|
||||||
|
|
||||||
def validate_cost(self):
|
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
|
self.internal_cost = self.internal_rate * self.hours
|
||||||
if self.billable:
|
if self.billable:
|
||||||
self.billing_amount = self.billing_rate * self.hours
|
self.billing_amount = self.billing_rate * self.hours
|
||||||
|
|||||||
Reference in New Issue
Block a user