fixes in test cases and added fiscal year field to stock reco

This commit is contained in:
Anand Doshi
2013-03-26 14:49:25 +05:30
parent 988bca04f2
commit 40dc9e83a5
10 changed files with 96 additions and 31 deletions

View File

@@ -3,8 +3,8 @@ import webnotes
def execute():
dn_list = webnotes.conn.sql("""select name from `tabDelivery Note` where docstatus < 2""")
for dn in dn_list:
webnotes.bean("Delivery Note", dn[0]).set_buying_amount()
webnotes.bean("Delivery Note", dn[0]).run_method("set_buying_amount")
si_list = webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus < 2""")
for si in si_list:
webnotes.bean("Sales Invoice", si[0]).set_buying_amount()
webnotes.bean("Sales Invoice", si[0]).run_method("set_buying_amount")

View File

@@ -1,7 +1,7 @@
import webnotes
def execute():
for purchase_invoice in webnotes.conn.sql("""select distinct parent
for purchase_invoice in webnotes.conn.sql_list("""select distinct parent
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(valuation_rate, 0)=0"""):
pi = webnotes.get_obj("Purchase Invoice", purchase_invoice)
pi.calculate_taxes_and_totals()

View File

@@ -1,24 +1,59 @@
import webnotes
def execute():
add_group_accounts()
add_ledger_accounts()
def _check(parent_account, company):
def _get_root(is_pl_account, debit_or_credit):
res = webnotes.conn.sql("""select name from `tabAccount`
where company=%s and is_pl_account = %s and debit_or_credit = %s
and ifnull(parent_account, "") ="" """, (company, is_pl_account, debit_or_credit))
return res and res[0][0] or None
if not webnotes.conn.exists("Account", parent_account):
if parent_account.startswith("Current Assets"):
parent_account = _get_root("No", "Debit")
elif parent_account.startswith("Direct Expenses"):
parent_account = _get_root("Yes", "Debit")
elif parent_account.startswith("Current Liabilities"):
parent_account = _get_root("No", "Credit")
return parent_account
def add_group_accounts():
accounts_to_add = [
["Stock Assets", "Current Assets", "Group", ""],
["Stock Expenses", "Direct Expenses", "Group", "Expense Account"],
["Stock Liabilities", "Current Liabilities", "Group", ""],
]
add_accounts(accounts_to_add, _check)
def add_ledger_accounts():
accounts_to_add = [
["Stock In Hand", "Stock Assets", "Ledger", ""],
["Stock Debit But Not Billed", "Stock Assets", "Ledger", ""],
["Stock Expenses", "Direct Expenses", "Group", "Expense Account"],
["Cost of Goods Sold", "Stock Expenses", "Ledger", "Expense Account"],
["Stock Adjustment", "Stock Expenses", "Ledger", "Expense Account"],
["Expenses Included In Valuation", "Stock Expenses", "Ledger", "Expense Account"],
["Stock Liabilities", "Current Liabilities", "Group", ""],
["Stock Received But Not Billed", "Stock Liabilities", "Ledger", ""],
]
add_accounts(accounts_to_add)
for company, abbr in webnotes.conn.sql_list("""select name, abbr from `tabCompany`"""):
def add_accounts(accounts_to_add, check_fn=None):
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
for account_name, parent_account_name, group_or_ledger, account_type in accounts_to_add:
if not webnotes.conn.exists("Account", "%s - %s" % (account_name, abbr)):
parent_account = "%s - %s" % (parent_account_name, abbr)
if check_fn:
parent_account = check_fn(parent_account, company)
account = webnotes.bean({
"doctype": "Account",
"account_name": account_name,
"parent_account": "%s - %s" % (parent_account_name, abbr),
"parent_account": parent_account,
"group_or_ledger": group_or_ledger,
"account_type": account_type,
"company": company