[minor] project cost
This commit is contained in:
parent
4765d75b83
commit
e270c7261d
@ -25,13 +25,13 @@ class Project(Document):
|
||||
"description": task.description,
|
||||
"task_id": task.name
|
||||
})
|
||||
|
||||
|
||||
def __setup__(self):
|
||||
self.onload()
|
||||
|
||||
|
||||
def get_tasks(self):
|
||||
return frappe.get_all("Task", "*", {"project": self.name}, order_by="exp_start_date asc")
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.sync_tasks()
|
||||
@ -74,7 +74,7 @@ class Project(Document):
|
||||
for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}):
|
||||
frappe.delete_doc("Task", t.name)
|
||||
task_added_or_deleted = True
|
||||
|
||||
|
||||
if task_added_or_deleted:
|
||||
self.update_project()
|
||||
|
||||
@ -87,12 +87,12 @@ class Project(Document):
|
||||
if total:
|
||||
completed = frappe.db.sql("""select count(*) from tabTask where
|
||||
project=%s and status in ('Closed', 'Cancelled')""", self.name)[0][0]
|
||||
|
||||
|
||||
self.percent_complete = flt(completed) / total * 100
|
||||
|
||||
def update_costing(self):
|
||||
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount,
|
||||
sum(total_billing_amount) as billing_amount, sum(total_expense_claim) as expense_claim,
|
||||
total_cost = frappe.db.sql("""select sum(ifnull(total_costing_amount, 0)) as costing_amount,
|
||||
sum(ifnull(total_billing_amount, 0)) as billing_amount, sum(ifnull(total_expense_claim, 0)) as expense_claim,
|
||||
min(act_start_date) as start_date, max(act_end_date) as end_date, sum(actual_time) as time
|
||||
from `tabTask` where project = %s""", self.name, as_dict=1)[0]
|
||||
|
||||
@ -105,12 +105,12 @@ class Project(Document):
|
||||
self.gross_margin = flt(total_cost.billing_amount) - flt(total_cost.costing_amount)
|
||||
if self.total_billing_amount:
|
||||
self.per_gross_margin = (self.gross_margin / flt(self.total_billing_amount)) *100
|
||||
|
||||
|
||||
def update_purchase_costing(self):
|
||||
total_purchase_cost = frappe.db.sql("""select sum(base_net_amount)
|
||||
from `tabPurchase Invoice Item` where project_name = %s and docstatus=1 """, self.name)
|
||||
|
||||
self.total_purchase_cost = total_purchase_cost[0][0] if total_purchase_cost else 0
|
||||
total_purchase_cost = frappe.db.sql("""select sum(ifnull(base_net_amount, 0))
|
||||
from `tabPurchase Invoice Item` where project_name = %s and docstatus=1""", self.name)
|
||||
|
||||
self.total_purchase_cost = total_purchase_cost and total_purchase_cost[0][0] or 0
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_cost_center_name(project_name):
|
||||
|
Loading…
x
Reference in New Issue
Block a user