blob: 70ccf6d86b5498df4524d25e12980545b7243b64 [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# License: GNU General Public License v3. See license.txt
3
Nabin Haite2639192012-12-05 10:18:49 +05304def execute():
5 import webnotes
6 from webnotes.model import delete_doc
7 from webnotes.model.code import get_obj
8 from webnotes.model.doc import addchild
9
10 # delete doctypes and tables
11 for dt in ["TDS Payment", "TDS Return Acknowledgement", "Form 16A",
12 "TDS Rate Chart", "TDS Category", "TDS Control", "TDS Detail",
13 "TDS Payment Detail", "TDS Rate Detail", "TDS Category Account",
14 "Form 16A Ack Detail", "Form 16A Tax Detail"]:
15 delete_doc("DocType", dt)
16
17 webnotes.conn.commit()
18 webnotes.conn.sql("drop table if exists `tab%s`" % dt)
19 webnotes.conn.begin()
20
Nabin Haite2639192012-12-05 10:18:49 +053021 # Add tds entry in tax table for purchase invoice
22 pi_list = webnotes.conn.sql("""select name from `tabPurchase Invoice`
23 where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0""")
24 for pi in pi_list:
25 piobj = get_obj("Purchase Invoice", pi[0], with_children=1)
26 ch = addchild(piobj.doc, 'taxes_and_charges', 'Purchase Taxes and Charges')
27 ch.charge_type = "Actual"
28 ch.account_head = piobj.doc.tax_code
29 ch.description = piobj.doc.tax_code
30 ch.rate = -1*piobj.doc.ded_amount
31 ch.tax_amount = -1*piobj.doc.ded_amount
32 ch.category = "Total"
33 ch.save(1)
34
35 # Add tds entry in entries table for journal voucher
36 jv_list = webnotes.conn.sql("""select name from `tabJournal Voucher`
37 where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0""")
38 for jv in jv_list:
39 jvobj = get_obj("Journal Voucher", jv[0], with_children=1)
40 ch = addchild(jvobj.doc, 'entries', 'Journal Voucher Detail')
41 ch.account = jvobj.doc.tax_code
42 ch.credit = jvobj.doc.ded_amount
43 ch.save(1)