mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
aii fixes
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
import webnotes
|
||||
from webnotes.utils import now_datetime
|
||||
|
||||
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]).run_method("set_buying_amount")
|
||||
webnotes.conn.auto_commit_on_many_writes = True
|
||||
for company in webnotes.conn.sql("select name from `tabCompany`"):
|
||||
print company[0]
|
||||
stock_ledger_entries = webnotes.conn.sql("""select item_code, voucher_type, voucher_no,
|
||||
voucher_detail_no, posting_date, posting_time, stock_value,
|
||||
warehouse, actual_qty as qty from `tabStock Ledger Entry`
|
||||
where ifnull(`is_cancelled`, "No") = "No" and company = %s
|
||||
order by item_code desc, warehouse desc,
|
||||
posting_date desc, posting_time desc, name desc""", company[0], as_dict=True)
|
||||
|
||||
si_list = webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus < 2""")
|
||||
for si in si_list:
|
||||
webnotes.bean("Sales Invoice", si[0]).run_method("set_buying_amount")
|
||||
dn_list = webnotes.conn.sql("""select name from `tabDelivery Note`
|
||||
where docstatus < 2 and company = %s""", company[0])
|
||||
print "Total Delivery Note: ", len(dn_list)
|
||||
|
||||
for dn in dn_list:
|
||||
dn = webnotes.get_obj("Delivery Note", dn[0], with_children = 1)
|
||||
dn.set_buying_amount(stock_ledger_entries)
|
||||
|
||||
si_list = webnotes.conn.sql("""select name from `tabSales Invoice`
|
||||
where docstatus < 2 and company = %s""", company[0])
|
||||
print "Total Sales Invoice: ", len(si_list)
|
||||
for si in si_list:
|
||||
si = webnotes.get_obj("Sales Invoice", si[0], with_children = 1)
|
||||
si.set_buying_amount(stock_ledger_entries)
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = False
|
||||
@@ -2,12 +2,12 @@ import webnotes
|
||||
|
||||
def execute():
|
||||
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()
|
||||
pi.update_raw_material_cost()
|
||||
pi.update_valuation_rate("entries")
|
||||
for item in pi.doclist.get({"parentfield": "entries"}):
|
||||
webnotes.conn.set_value("Purchase Invoice Item", item.name, "valuation_rate",
|
||||
item.valuation_rate)
|
||||
|
||||
from `tabPurchase Invoice Item` pi_item where docstatus = 1 and ifnull(valuation_rate, 0)=0
|
||||
and exists(select name from `tabPurchase Invoice` where name = pi_item.parent)"""):
|
||||
pi = webnotes.get_obj("Purchase Invoice", purchase_invoice)
|
||||
pi.calculate_taxes_and_totals()
|
||||
pi.update_raw_material_cost()
|
||||
pi.update_valuation_rate("entries")
|
||||
for item in pi.doclist.get({"parentfield": "entries"}):
|
||||
webnotes.conn.set_value("Purchase Invoice Item", item.name, "valuation_rate",
|
||||
item.valuation_rate)
|
||||
@@ -2,6 +2,7 @@ import webnotes
|
||||
def execute():
|
||||
add_group_accounts()
|
||||
add_ledger_accounts()
|
||||
add_aii_cost_center()
|
||||
|
||||
def _check(parent_account, company):
|
||||
def _get_root(is_pl_account, debit_or_credit):
|
||||
@@ -34,7 +35,6 @@ def add_group_accounts():
|
||||
def add_ledger_accounts():
|
||||
accounts_to_add = [
|
||||
["Stock In Hand", "Stock Assets", "Ledger", ""],
|
||||
["Stock Debit But Not Billed", "Stock Assets", "Ledger", ""],
|
||||
["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"],
|
||||
@@ -58,4 +58,21 @@ def add_accounts(accounts_to_add, check_fn=None):
|
||||
"account_type": account_type,
|
||||
"company": company
|
||||
})
|
||||
account.insert()
|
||||
account.insert()
|
||||
|
||||
def add_aii_cost_center():
|
||||
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
|
||||
if not webnotes.conn.exists("Cost Center", "Auto Inventory Accounting - %s" % abbr):
|
||||
parent_cost_center = webnotes.conn.get_value("Cost Center",
|
||||
{"parent_cost_center['']": '', "company_name": company}, 'name')
|
||||
|
||||
cc = webnotes.bean({
|
||||
"doctype": "Cost Center",
|
||||
"cost_center_name": "Auto Inventory Accounting",
|
||||
"parent_cost_center": parent_cost_center,
|
||||
"group_or_ledger": "Ledger",
|
||||
"company_name": company
|
||||
})
|
||||
cc.insert()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user