Merge pull request #3192 from neilLasrado/purchase-costing

Purchase costing in Projects
This commit is contained in:
Rushabh Mehta
2015-05-05 10:59:11 +05:30
5 changed files with 69 additions and 21 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(amount) as cost
from `tabPurchase Invoice Item` where project_name = %s and docstatus=1 """, self.name, as_dict=1)[0].cost or 0
@frappe.whitelist()
def get_cost_center_name(project_name):