[fix] Purchase cost against project

This commit is contained in:
Nabin Hait
2015-08-18 12:39:50 +05:30
parent ffca81dbc1
commit fa5fcf5405
3 changed files with 16 additions and 2 deletions

View File

@@ -107,8 +107,10 @@ class Project(Document):
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
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
@frappe.whitelist()
def get_cost_center_name(project_name):