fixes in Purchase Invoice
This commit is contained in:
parent
01720404db
commit
42a554e5cb
@ -76,14 +76,6 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "project",
|
||||
"fieldtype": "Link",
|
||||
"label": "Project",
|
||||
"options": "Project",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
@ -946,7 +938,7 @@
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-04-27 20:32:12.436976",
|
||||
"modified": "2015-04-30 03:05:13.790265",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice",
|
||||
|
@ -377,11 +377,14 @@ class PurchaseInvoice(BuyingController):
|
||||
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()
|
||||
project_list = []
|
||||
for d in self.items:
|
||||
if d.project_name and d.project_name not in project_list:
|
||||
project = frappe.get_doc("Project", d.project_name)
|
||||
project.flags.dont_sync_tasks = True
|
||||
project.update_purchase_costing()
|
||||
project.save()
|
||||
project_list.append(d.project_name)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
@ -238,13 +238,13 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
purchase_invoice = frappe.new_doc('Purchase Invoice')
|
||||
purchase_invoice.update({
|
||||
"credit_to": "_Test Payable - _TC",
|
||||
"project": "_Test Project",
|
||||
"supplier": "_Test Supplier",
|
||||
"company": "_Test Company",
|
||||
"items": [
|
||||
{
|
||||
"rate": 500,
|
||||
"qty": 1,
|
||||
"project_name": "_Test Project",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
@ -252,6 +252,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
{
|
||||
"rate": 1500,
|
||||
"qty": 1,
|
||||
"project_name": "_Test Project",
|
||||
"item_code": "_Test Item Home Desktop 200",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC"
|
||||
|
@ -91,8 +91,8 @@ 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(grand_total) as cost
|
||||
from `tabPurchase Invoice` where project = %s and docstatus=1 """, self.name, as_dict=1)[0].cost or 0
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user