[accounts] [perpetual] accounts settings for perpetual accounting for inventory

This commit is contained in:
Nabin Hait 2013-08-02 11:24:51 +05:30
parent 0fa631944c
commit b865db910b
2 changed files with 16 additions and 14 deletions

View File

@ -2,23 +2,24 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
from webnotes.utils import cint, cstr
from webnotes import msgprint, _
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.make_adjustment_jv_for_auto_inventory()
def make_adjustment_jv_for_auto_inventory(self):
previous_auto_inventory_accounting = cint(webnotes.conn.get_value("Accounts Settings",
None, "auto_inventory_accounting"))
if cint(self.doc.auto_inventory_accounting) != previous_auto_inventory_accounting:
from accounts.utils import create_stock_in_hand_jv
create_stock_in_hand_jv(reverse = \
cint(self.doc.auto_inventory_accounting) < previous_auto_inventory_accounting)
self.validate_perpetual_accounting()
def validate_perpetual_accounting(self):
if cint(self.doc.perpetual_accounting) == 1:
previous_val = cint(webnotes.conn.get_value("Accounts Settings",
None, "perpetual_accounting"))
if cint(self.doc.perpetual_accounting) != previous_val:
from accounts.utils import validate_stock_and_account_balance
validate_stock_and_account_balance()
def on_update(self):
for key in ["auto_inventory_accounting"]:
for key in ["perpetual_accounting"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ''))

View File

@ -2,7 +2,7 @@
{
"creation": "2013-06-24 15:49:57",
"docstatus": 0,
"modified": "2013-07-05 14:23:40",
"modified": "2013-08-01 17:35:16",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -39,11 +39,12 @@
"name": "Accounts Settings"
},
{
"default": "1",
"description": "If enabled, the system will post accounting entries for inventory automatically.",
"doctype": "DocField",
"fieldname": "auto_inventory_accounting",
"fieldname": "perpetual_accounting",
"fieldtype": "Check",
"label": "Enable Auto Inventory Accounting"
"label": "Enable Perpetual Accounting for Inventory"
},
{
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",