Total Purchase Cost added to Projects
This commit is contained in:
parent
5e13799704
commit
9a56764bf2
@ -5,21 +5,6 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "supplier_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "",
|
||||
"options": "icon-user",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
@ -91,6 +76,14 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "project",
|
||||
"fieldtype": "Link",
|
||||
"label": "Project",
|
||||
"options": "Project",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
|
@ -239,6 +239,7 @@ class PurchaseInvoice(BuyingController):
|
||||
self.update_against_document_in_jv()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
self.update_project()
|
||||
|
||||
def make_gl_entries(self):
|
||||
auto_accounting_for_stock = \
|
||||
@ -373,9 +374,14 @@ class PurchaseInvoice(BuyingController):
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
self.make_gl_entries_on_cancel()
|
||||
|
||||
def on_update(self):
|
||||
pass
|
||||
self.update_project()
|
||||
|
||||
def update_project(self):
|
||||
if self.project and frappe.db.exists("Project", self.project):
|
||||
project = frappe.get_doc("Project", self.project)
|
||||
project.flags.dont_sync_tasks = True
|
||||
project.update_purchase_costing()
|
||||
project.save()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
@ -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",
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user