mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
[minor] renamed perpetual accounting to make_accounting_entry_for_every_stock_entry
This commit is contained in:
@@ -13,18 +13,18 @@ class DocType:
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
self.validate_perpetual_accounting()
|
||||
self.validate_auto_accounting_for_stock()
|
||||
|
||||
def validate_perpetual_accounting(self):
|
||||
if cint(self.doc.perpetual_accounting) == 1:
|
||||
def validate_auto_accounting_for_stock(self):
|
||||
if cint(self.doc.auto_accounting_for_stock) == 1:
|
||||
previous_val = cint(webnotes.conn.get_value("Accounts Settings",
|
||||
None, "perpetual_accounting"))
|
||||
if cint(self.doc.perpetual_accounting) != previous_val:
|
||||
None, "auto_accounting_for_stock"))
|
||||
if cint(self.doc.auto_accounting_for_stock) != previous_val:
|
||||
from accounts.utils import validate_stock_and_account_balance, \
|
||||
create_stock_in_hand_jv
|
||||
validate_stock_and_account_balance()
|
||||
create_stock_in_hand_jv(reverse=cint(self.doc.perpetual_accounting) < previous_val)
|
||||
create_stock_in_hand_jv(reverse=cint(self.doc.auto_accounting_for_stock) < previous_val)
|
||||
|
||||
def on_update(self):
|
||||
for key in ["perpetual_accounting"]:
|
||||
for key in ["auto_accounting_for_stock"]:
|
||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ''))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-24 15:49:57",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-01 17:35:16",
|
||||
"modified": "2013-08-28 18:55:43",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -42,9 +42,9 @@
|
||||
"default": "1",
|
||||
"description": "If enabled, the system will post accounting entries for inventory automatically.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "perpetual_accounting",
|
||||
"fieldname": "auto_accounting_for_stock",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Perpetual Accounting for Inventory"
|
||||
"label": "Make Accounting Entry For Every Stock Entry"
|
||||
},
|
||||
{
|
||||
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",
|
||||
|
||||
@@ -34,6 +34,6 @@ class DocType:
|
||||
(res[0][0], self.doc.company), raise_exception=1)
|
||||
|
||||
def validate_expense_account(self):
|
||||
if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \
|
||||
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||
and not self.doc.expense_account:
|
||||
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 12:15:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-09 16:35:03",
|
||||
"modified": "2013-08-28 19:13:42",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -163,7 +163,7 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:sys_defaults.perpetual_accounting",
|
||||
"depends_on": "eval:sys_defaults.auto_accounting_for_stock",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -212,15 +212,15 @@ class DocType(BuyingController):
|
||||
raise Exception
|
||||
|
||||
def set_against_expense_account(self):
|
||||
perpetual_accounting = cint(webnotes.defaults.get_global_default("perpetual_accounting"))
|
||||
auto_accounting_for_stock = cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
|
||||
if perpetual_accounting:
|
||||
if auto_accounting_for_stock:
|
||||
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
||||
|
||||
against_accounts = []
|
||||
stock_items = self.get_stock_items()
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if perpetual_accounting and item.item_code in stock_items:
|
||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
||||
# in case of auto inventory accounting, against expense account is always
|
||||
# Stock Received But Not Billed for a stock item
|
||||
item.expense_head = stock_not_billed_account
|
||||
@@ -234,7 +234,7 @@ class DocType(BuyingController):
|
||||
(item.item_code or item.item_name), raise_exception=1)
|
||||
|
||||
elif item.expense_head not in against_accounts:
|
||||
# if no perpetual_accounting or not a stock item
|
||||
# if no auto_accounting_for_stock or not a stock item
|
||||
against_accounts.append(item.expense_head)
|
||||
|
||||
self.doc.against_expense_account = ",".join(against_accounts)
|
||||
@@ -317,8 +317,8 @@ class DocType(BuyingController):
|
||||
self.update_prevdoc_status()
|
||||
|
||||
def make_gl_entries(self):
|
||||
perpetual_accounting = \
|
||||
cint(webnotes.defaults.get_global_default("perpetual_accounting"))
|
||||
auto_accounting_for_stock = \
|
||||
cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
|
||||
gl_entries = []
|
||||
|
||||
@@ -355,15 +355,15 @@ class DocType(BuyingController):
|
||||
valuation_tax += (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
||||
|
||||
# item gl entries
|
||||
stock_item_and_perpetual_accounting = False
|
||||
stock_item_and_auto_accounting_for_stock = False
|
||||
stock_items = self.get_stock_items()
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if perpetual_accounting and item.item_code in stock_items:
|
||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
||||
if flt(item.valuation_rate):
|
||||
# if auto inventory accounting enabled and stock item,
|
||||
# then do stock related gl entries
|
||||
# expense will be booked in sales invoice
|
||||
stock_item_and_perpetual_accounting = True
|
||||
stock_item_and_auto_accounting_for_stock = True
|
||||
|
||||
valuation_amt = (flt(item.amount, self.precision("amount", item)) +
|
||||
flt(item.item_tax_amount, self.precision("item_tax_amount", item)) +
|
||||
@@ -390,7 +390,7 @@ class DocType(BuyingController):
|
||||
})
|
||||
)
|
||||
|
||||
if stock_item_and_perpetual_accounting and valuation_tax:
|
||||
if stock_item_and_auto_accounting_for_stock and valuation_tax:
|
||||
# credit valuation tax amount in "Expenses Included In Valuation"
|
||||
# this will balance out valuation amount included in cost of goods sold
|
||||
gl_entries.append(
|
||||
|
||||
@@ -14,9 +14,9 @@ test_dependencies = ["Item", "Cost Center"]
|
||||
test_ignore = ["Serial No"]
|
||||
|
||||
class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_gl_entries_without_perpetual_accounting(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
self.assertTrue(not cint(webnotes.defaults.get_global_default("perpetual_accounting")))
|
||||
def test_gl_entries_without_auto_accounting_for_stock(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
self.assertTrue(not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")))
|
||||
|
||||
wrapper = webnotes.bean(copy=test_records[0])
|
||||
wrapper.run_method("calculate_taxes_and_totals")
|
||||
@@ -41,9 +41,9 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
for d in gl_entries:
|
||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
||||
|
||||
def test_gl_entries_with_perpetual_accounting(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1)
|
||||
def test_gl_entries_with_auto_accounting_for_stock(self):
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = webnotes.bean(copy=test_records[1])
|
||||
pi.run_method("calculate_taxes_and_totals")
|
||||
@@ -68,11 +68,11 @@ 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("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def test_gl_entries_with_aia_for_non_stock_items(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = webnotes.bean(copy=test_records[1])
|
||||
pi.doclist[1].item_code = "_Test Non Stock Item"
|
||||
@@ -99,7 +99,7 @@ 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("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def test_purchase_invoice_calculation(self):
|
||||
wrapper = webnotes.bean(copy=test_records[0])
|
||||
|
||||
@@ -358,7 +358,7 @@ cur_frm.set_query("income_account", "entries", function(doc) {
|
||||
});
|
||||
|
||||
// expense account
|
||||
if (sys_defaults.perpetual_accounting) {
|
||||
if (sys_defaults.auto_accounting_for_stock) {
|
||||
cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) {
|
||||
return {
|
||||
filters: {
|
||||
|
||||
@@ -558,7 +558,7 @@ class DocType(SellingController):
|
||||
make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2),
|
||||
update_outstanding=update_outstanding, merge_entries=False)
|
||||
|
||||
if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \
|
||||
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||
and cint(self.doc.update_stock):
|
||||
self.update_gl_entries_after()
|
||||
|
||||
@@ -603,7 +603,7 @@ class DocType(SellingController):
|
||||
)
|
||||
|
||||
# expense account gl entries
|
||||
if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \
|
||||
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||
and cint(self.doc.update_stock):
|
||||
gl_entries += self.get_gl_entries_for_stock()
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
"Batched for Billing")
|
||||
|
||||
def test_sales_invoice_gl_entry_without_aii(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
self.clear_stock_account_balance()
|
||||
si = webnotes.bean(copy=test_records[1])
|
||||
si.insert()
|
||||
@@ -332,7 +332,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
def atest_pos_gl_entry_with_aii(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
|
||||
old_default_company = webnotes.conn.get_default("company")
|
||||
webnotes.conn.set_default("company", "_Test Company")
|
||||
@@ -392,11 +392,11 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
self.assertFalse(get_stock_and_account_difference([si.doclist[1].warehouse]))
|
||||
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
webnotes.conn.set_default("company", old_default_company)
|
||||
|
||||
def atest_sales_invoice_gl_entry_with_aii_no_item_code(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
|
||||
si_copy = webnotes.copy_doclist(test_records[1])
|
||||
si_copy[1]["item_code"] = None
|
||||
@@ -420,10 +420,10 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_values[i][1], gle.debit)
|
||||
self.assertEquals(expected_values[i][2], gle.credit)
|
||||
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def atest_sales_invoice_gl_entry_with_aii_non_stock_item(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 1)
|
||||
|
||||
si_copy = webnotes.copy_doclist(test_records[1])
|
||||
si_copy[1]["item_code"] = "_Test Non Stock Item"
|
||||
@@ -447,7 +447,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_values[i][1], gle.debit)
|
||||
self.assertEquals(expected_values[i][2], gle.credit)
|
||||
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
webnotes.defaults.set_global_default("auto_accounting_for_stock", 0)
|
||||
|
||||
def _insert_purchase_receipt(self):
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||
|
||||
Reference in New Issue
Block a user