fix: Project link not set in accounts other than profit and loss accounts (#22049)

* fix: project link not set in accounts other than profilt and loss accounts

* fix: cannot find get_allow_cost_center_in_entry_of_bs_account

* fix: remove enable_allow_cost_center_in_entry_of_bs_account

* chore: add tests and remove test based on allow_cost_center_for_bs_accounts

* fix: travis

* fix: Test Cases

* fix: Patch to remove Property Setter

* fix: Test Cases

* fix: Remove v13 patch

* fix: Procurement Tracker test case

* fix: Proccurement tracker report test

* fix: Codacy

* fix: Remove duplicate project field

Co-authored-by: Saqib Ansari <nextchamp.saqib@gmail.com>
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
Deepesh Garg
2020-08-12 21:06:25 +05:30
committed by GitHub
parent 9bd041c14c
commit a979fcc25b
28 changed files with 498 additions and 405 deletions

View File

@@ -88,7 +88,7 @@ class TestDeliveryNote(unittest.TestCase):
# check stock in hand balance
bal = get_balance_on(stock_in_hand_account)
self.assertEqual(bal, prev_bal - stock_value_difference)
self.assertEqual(flt(bal, 2), flt(prev_bal - stock_value_difference, 2))
# back dated incoming entry
make_stock_entry(posting_date=add_days(nowdate(), -2), target="Stores - TCP1",
@@ -548,11 +548,8 @@ class TestDeliveryNote(unittest.TestCase):
dt = make_delivery_trip(dn.name)
self.assertEqual(dn.name, dt.delivery_stops[0].delivery_note)
def test_delivery_note_for_enable_allow_cost_center_in_entry_of_bs_account(self):
def test_delivery_note_with_cost_center(self):
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
accounts_settings.allow_cost_center_in_entry_of_bs_account = 1
accounts_settings.save()
cost_center = "_Test Cost Center for BS Account - TCP1"
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory")
@@ -578,13 +575,8 @@ class TestDeliveryNote(unittest.TestCase):
}
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
accounts_settings.save()
def test_delivery_note_for_disable_allow_cost_center_in_entry_of_bs_account(self):
accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
accounts_settings.save()
def test_delivery_note_cost_center_with_balance_sheet_account(self):
cost_center = "Main - TCP1"
company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company')
@@ -594,7 +586,11 @@ class TestDeliveryNote(unittest.TestCase):
make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100)
stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory')
dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1")
dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1",
do_not_submit=1)
dn.get('items')[0].cost_center = None
dn.submit()
gl_entries = get_gl_entries("Delivery Note", dn.name)
@@ -604,7 +600,7 @@ class TestDeliveryNote(unittest.TestCase):
"cost_center": cost_center
},
stock_in_hand_account: {
"cost_center": None
"cost_center": cost_center
}
}
for i, gle in enumerate(gl_entries):

View File

@@ -1,5 +1,4 @@
{
"actions": [],
"autoname": "hash",
"creation": "2013-04-22 13:15:44",
"doctype": "DocType",
@@ -82,6 +81,7 @@
"accounting_dimensions_section",
"cost_center",
"dimension_col_break",
"project",
"reason_for_return_section_break",
"reason_for_return",
"section_break_72",
@@ -703,6 +703,12 @@
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
},
{
"fieldname": "project",
"fieldtype": "Link",
"label": "Project",
"options": "Project"
},
{
"depends_on": "eval:parent.is_return==1",
"fieldname": "reason_for_return",

View File

@@ -1,5 +1,4 @@
{
"actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-05-21 16:16:39",

View File

@@ -51,7 +51,7 @@ class TestPurchaseReceipt(unittest.TestCase):
self.assertEqual(current_bin_stock_value, existing_bin_stock_value + 250)
self.assertFalse(get_gl_entries("Purchase Receipt", pr.name))
def test_batched_serial_no_purchase(self):
item = frappe.db.exists("Item", {'item_name': 'Batched Serialized Item'})
if not item:
@@ -68,7 +68,7 @@ class TestPurchaseReceipt(unittest.TestCase):
pr = make_purchase_receipt(item_code=item.name, qty=5, rate=500)
self.assertTrue(frappe.db.get_value('Batch', {'item': item.name, 'reference_name': pr.name}))
pr.load_from_db()
batch_no = pr.items[0].batch_no
pr.cancel()
@@ -374,7 +374,7 @@ class TestPurchaseReceipt(unittest.TestCase):
location = frappe.db.get_value('Asset', assets[0].name, 'location')
self.assertEquals(location, "Test Location")
def test_purchase_return_with_submitted_asset(self):
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_return
@@ -396,17 +396,14 @@ class TestPurchaseReceipt(unittest.TestCase):
pr_return = make_purchase_return(pr.name)
self.assertRaises(frappe.exceptions.ValidationError, pr_return.submit)
asset.load_from_db()
asset.cancel()
pr_return.submit()
def test_purchase_receipt_for_enable_allow_cost_center_in_entry_of_bs_account(self):
def test_purchase_receipt_cost_center(self):
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
accounts_settings.allow_cost_center_in_entry_of_bs_account = 1
accounts_settings.save()
cost_center = "_Test Cost Center for BS Account - TCP1"
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory")
@@ -434,14 +431,7 @@ class TestPurchaseReceipt(unittest.TestCase):
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
accounts_settings.save()
def test_purchase_receipt_for_disable_allow_cost_center_in_entry_of_bs_account(self):
accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
accounts_settings.save()
def test_purchase_receipt_cost_center_with_balance_sheet_account(self):
if not frappe.db.exists('Location', 'Test Location'):
frappe.get_doc({
'doctype': 'Location',
@@ -453,13 +443,14 @@ class TestPurchaseReceipt(unittest.TestCase):
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
self.assertTrue(gl_entries)
cost_center = pr.get('items')[0].cost_center
expected_values = {
"Stock Received But Not Billed - TCP1": {
"cost_center": None
"cost_center": cost_center
},
stock_in_hand_account: {
"cost_center": None
"cost_center": cost_center
}
}
for i, gle in enumerate(gl_entries):