[taxes and charges] [item wise tax detail] patch to store this as json
This commit is contained in:
parent
ecc28f0311
commit
f41ce11e91
23
patches/may_2013/p08_change_item_wise_tax.py
Normal file
23
patches/may_2013/p08_change_item_wise_tax.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import webnotes
|
||||||
|
import json
|
||||||
|
from webnotes.utils import flt
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for doctype in ["Purchase Taxes and Charges", "Sales Taxes and Charges"]:
|
||||||
|
for tax_name, item_wise_tax_detail in \
|
||||||
|
webnotes.conn.sql("""select name, item_wise_tax_detail from `tab%s`""" % doctype):
|
||||||
|
if not item_wise_tax_detail or not isinstance(item_wise_tax_detail, basestring):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
json.loads(item_wise_tax_detail)
|
||||||
|
except ValueError:
|
||||||
|
out = {}
|
||||||
|
for t in item_wise_tax_detail.split("\n"):
|
||||||
|
if ":" in t:
|
||||||
|
account_head, amount = t.split(":")
|
||||||
|
out[account_head.strip()] = flt(amount.strip())
|
||||||
|
|
||||||
|
if out:
|
||||||
|
webnotes.conn.sql("""update `tab%s` set item_wise_tax_detail=%s
|
||||||
|
where name=%s""" % (doctype, "%s", "%s"), (json.dumps(out), tax_name))
|
@ -255,4 +255,5 @@ patch_list = [
|
|||||||
"patches.may_2013.p05_update_cancelled_gl_entries",
|
"patches.may_2013.p05_update_cancelled_gl_entries",
|
||||||
"patches.may_2013.p06_make_notes",
|
"patches.may_2013.p06_make_notes",
|
||||||
"patches.may_2013.p07_move_update_stock_to_pos",
|
"patches.may_2013.p07_move_update_stock_to_pos",
|
||||||
|
"patches.may_2013.p08_change_item_wise_tax",
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user