Total Purchase Cost added to Projects

This commit is contained in:
Neil Trini Lasrado
2015-04-27 17:10:10 +05:30
parent 5e13799704
commit 9a56764bf2
4 changed files with 31 additions and 19 deletions

View File

@@ -303,6 +303,15 @@
"precision": "",
"read_only": 1
},
{
"fieldname": "total_purchase_cost",
"fieldtype": "Currency",
"hidden": 0,
"label": "Total Purchase Cost (via Purchase Invoice)",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "margin",
"fieldtype": "Section Break",
@@ -347,7 +356,7 @@
"icon": "icon-puzzle-piece",
"idx": 1,
"max_attachments": 4,
"modified": "2015-04-23 05:51:53.642253",
"modified": "2015-04-27 07:37:44.239930",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",

View File

@@ -89,6 +89,10 @@ 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):
self.total_purchase_cost = frappe.db.sql("""select sum(grand_total) as cost
from `tabPurchase Invoice` where project = %s and docstatus=1 """, self.name, as_dict=1)[0].cost
@frappe.whitelist()
def get_cost_center_name(project_name):