Test Cases Added
This commit is contained in:
parent
9a56764bf2
commit
349461e9e6
@ -364,6 +364,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if gl_entries:
|
if gl_entries:
|
||||||
|
for d in gl_entries:
|
||||||
|
print d.account, d.debit, d.credit
|
||||||
from erpnext.accounts.general_ledger import make_gl_entries
|
from erpnext.accounts.general_ledger import make_gl_entries
|
||||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.model
|
import frappe.model
|
||||||
import json
|
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory, \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory, \
|
||||||
@ -235,4 +234,34 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
||||||
test_recurring_document(self, test_records)
|
test_recurring_document(self, test_records)
|
||||||
|
|
||||||
|
def test_total_purchase_cost_for_project(self):
|
||||||
|
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,
|
||||||
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
"expense_account": "_Test Account Cost for Goods Sold - _TC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rate": 1500,
|
||||||
|
"qty": 1,
|
||||||
|
"item_code": "_Test Item Home Desktop 200",
|
||||||
|
"expense_account": "_Test Account Cost for Goods Sold - _TC"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
purchase_invoice.save()
|
||||||
|
purchase_invoice.submit()
|
||||||
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"), 2000)
|
||||||
|
|
||||||
|
purchase_invoice.cancel()
|
||||||
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"), 0)
|
||||||
|
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Purchase Invoice')
|
test_records = frappe.get_test_records('Purchase Invoice')
|
||||||
|
|||||||
@ -92,7 +92,7 @@ class Project(Document):
|
|||||||
|
|
||||||
def update_purchase_costing(self):
|
def update_purchase_costing(self):
|
||||||
self.total_purchase_cost = frappe.db.sql("""select sum(grand_total) as cost
|
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
|
from `tabPurchase Invoice` where project = %s and docstatus=1 """, self.name, as_dict=1)[0].cost or 0
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_cost_center_name(project_name):
|
def get_cost_center_name(project_name):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user