mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
[fix] [minor] perpetual inventory: account for each warehouse
This commit is contained in:
@@ -34,16 +34,17 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
where against_jv=%s""", jv_invoice.doc.name))
|
||||
|
||||
def test_jv_against_stock_account(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
set_perpetual_inventory()
|
||||
|
||||
jv = webnotes.bean(copy=test_records[0])
|
||||
jv.doclist[1].account = "_Test Account Stock in Hand - _TC"
|
||||
jv.doclist[1].account = "_Test Warehouse - _TC"
|
||||
jv.insert()
|
||||
|
||||
from accounts.general_ledger import StockAccountInvalidTransaction
|
||||
self.assertRaises(StockAccountInvalidTransaction, jv.submit)
|
||||
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def test_monthly_budget_crossed_ignore(self):
|
||||
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
|
||||
@@ -9,13 +9,14 @@ import webnotes.model
|
||||
import json
|
||||
from webnotes.utils import cint
|
||||
import webnotes.defaults
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
|
||||
test_dependencies = ["Item", "Cost Center"]
|
||||
test_ignore = ["Serial No"]
|
||||
|
||||
class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_without_auto_accounting_for_stock(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
set_perpetual_inventory(0)
|
||||
self.assertTrue(not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")))
|
||||
|
||||
wrapper = webnotes.bean(copy=test_records[0])
|
||||
@@ -42,7 +43,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
||||
|
||||
def test_gl_entries_with_auto_accounting_for_stock(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
set_perpetual_inventory(1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = webnotes.bean(copy=test_records[1])
|
||||
@@ -68,10 +69,10 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_values[i][1], gle.debit)
|
||||
self.assertEquals(expected_values[i][2], gle.credit)
|
||||
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def test_gl_entries_with_aia_for_non_stock_items(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
set_perpetual_inventory()
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = webnotes.bean(copy=test_records[1])
|
||||
@@ -98,8 +99,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_values[i][0], gle.account)
|
||||
self.assertEquals(expected_values[i][1], gle.debit)
|
||||
self.assertEquals(expected_values[i][2], gle.credit)
|
||||
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def test_purchase_invoice_calculation(self):
|
||||
wrapper = webnotes.bean(copy=test_records[0])
|
||||
|
||||
@@ -91,8 +91,8 @@ def validate_total_debit_credit(total_debit, total_credit):
|
||||
|
||||
def validate_account_for_auto_accounting_for_stock(gl_map):
|
||||
if gl_map[0].voucher_type=="Journal Voucher":
|
||||
aii_accounts = [d[0] for d in webnotes.conn.sql("""select account from tabWarehouse
|
||||
where ifnull(account, '')!=''""")]
|
||||
aii_accounts = [d[0] for d in webnotes.conn.sql("""select name from tabAccount
|
||||
where account_type = 'Warehouse' and ifnull(master_name, '')!=''""")]
|
||||
|
||||
for entry in gl_map:
|
||||
if entry.account in aii_accounts:
|
||||
|
||||
Reference in New Issue
Block a user