[fix] Purchase cost against project
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 87a5551..551518e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -192,3 +192,4 @@
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
erpnext.patches.v5_7.item_template_attributes
erpnext.patches.v4_2.repost_reserved_qty #2015-08-17
+erpnext.patches.v5_4.update_purchase_cost_against_project
diff --git a/erpnext/patches/v5_4/update_purchase_cost_against_project.py b/erpnext/patches/v5_4/update_purchase_cost_against_project.py
new file mode 100644
index 0000000..7e54738
--- /dev/null
+++ b/erpnext/patches/v5_4/update_purchase_cost_against_project.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ for p in frappe.get_all("Project"):
+ project = frappe.get_doc("Project", p.name)
+ project.update_purchase_costing()
+ project.save()
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 6ebafdb..1306278 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -107,8 +107,10 @@
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):