Merge lp:~openerp-dev/openobject-addons/5.0-opw-381491-ado into lp:openobject-addons/5.0

Proposed by Amit Dodiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/5.0-opw-381491-ado
Merge into: lp:openobject-addons/5.0
Diff against target: 228 lines (+116/-36)
2 files modified
l10n_be/company.py (+5/-2)
l10n_be/wizard/account_vat_declaration.py (+111/-34)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/5.0-opw-381491-ado
Reviewer Review Type Date Requested Status
nel Pending
Naresh(OpenERP) Pending
Review via email: mp+91030@code.launchpad.net

Description of the change

Hello,

Improve the Vat_List.xml file creation from wizard as per the new VAT format.

Thanks,
Amit

To post a comment you must log in.
2931. By Xavier ALT

[MERGE] backport v6.0: allow printing vat subject clients list by calendar date

2932. By Amit Dodiya (OpenERP)

[FIX] l10n_be Partner VAT Declaration xml file improvement

Unmerged revisions

2932. By Amit Dodiya (OpenERP)

[FIX] l10n_be Partner VAT Declaration xml file improvement

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_be/company.py'
--- l10n_be/company.py 2010-04-06 09:41:18 +0000
+++ l10n_be/company.py 2012-03-01 11:40:31 +0000
@@ -28,7 +28,7 @@
2828
2929
30 def _get_default_ad(self, addresses):30 def _get_default_ad(self, addresses):
31 city = post_code = address = country_code = ""31 name = email = phone = city = post_code = address = country_code = ""
32 for ads in addresses:32 for ads in addresses:
33 if ads.type == 'default':33 if ads.type == 'default':
34 city = ads.city or ""34 city = ads.city or ""
@@ -39,7 +39,10 @@
39 address += " " + ads.street239 address += " " + ads.street2
40 if ads.country_id:40 if ads.country_id:
41 country_code = ads.country_id and ads.country_id.code or ""41 country_code = ads.country_id and ads.country_id.code or ""
42 return city, post_code, address, country_code42 name = ads.name or ""
43 email = ads.email or ""
44 phone = ads.phone or ""
45 return name, email, phone, city, post_code, address, country_code
43res_company()46res_company()
4447
45# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:48# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4649
=== modified file 'l10n_be/wizard/account_vat_declaration.py'
--- l10n_be/wizard/account_vat_declaration.py 2010-08-23 13:47:14 +0000
+++ l10n_be/wizard/account_vat_declaration.py 2012-03-01 11:40:31 +0000
@@ -28,39 +28,52 @@
28from tools.translate import _28from tools.translate import _
2929
30form_fyear = """<?xml version="1.0"?>30form_fyear = """<?xml version="1.0"?>
31<form string="Select Period">31 <form string="Periodical VAT Declaration">
32 <field name="period" />32 <group>
33 <field name="ask_resitution"/>33 <group colspan="4">
34 <field name="ask_payment"/>34 <separator string="Declare Periodical VAT" colspan="4"/><newline/>
35 <field name="client_nihil"/>35 <field name="period"/>
36</form>"""36 <field name="tax_code_id" string="Company" groups="base.group_multi_company"/>
37 <newline/>
38 <field name="ask_resitution"/>
39 <field name="ask_payment"/>
40 <field name="client_nihil" string="Is Last Declaration"/><label/>
41 </group>
42 <group colspan="4">
43 <separator string="Comments" colspan="4"/>
44 <field colspan="4" name="comments" nolabel="1"/>
45 </group>
46 </group>
47 </form>"""
3748
38fields_fyear = {49fields_fyear = {
39 'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,},50 'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,},
40 'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',},51 'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',},
41 'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',},52 'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',},
42 'client_nihil': {'type': 'boolean', 'string': 'Last Declaration of Entreprise', 'help': 'Thick this case only if it concerns only the last statement on the civil or cessation of activity'},53 'client_nihil': {'type': 'boolean', 'string': 'Last Declaration of Entreprise', 'help': 'Thick this case only if it concerns only the last statement on the civil or cessation of activity'},
54 'tax_code_id': {'string': 'Company', 'type': 'many2one', 'relation': 'account.tax.code', 'required': True, 'help': 'Tick this case only if it concerns only the last statement on the civil or cessation of activity: no clients to be included in the client listing.'},
55 'comments': {'string': 'Comments', 'type': 'text', 'size' : 64},
43}56}
4457
45form = """<?xml version="1.0"?>58form = """<?xml version="1.0"?>
46<form string="Notification">59<form string="Notification">
47 <separator string="XML Flie has been Created." colspan="4"/>60 <separator string="XML Flie has been Created." colspan="4"/>
48 <field name="msg" colspan="4" nolabel="1"/>61 <field name="msg" colspan="4" nolabel="1"/>
62 <field name="name"/><newline/>
49 <field name="file_save" />63 <field name="file_save" />
50</form>"""64</form>"""
5165
52fields = {66fields = {
53 'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},67 'name': {'string': 'File Name', 'type': 'char', 'size': 32, 'default': 'vat_declaration.xml'},
54 'file_save':{'string': 'Save File',68 'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True, 'default': 'Save the File with '".xml"' extension.'},
55 'type': 'binary',69 'file_save':{'string': 'Save File', 'type': 'binary', 'readonly': True,},
56 'readonly': True,},
57}70}
5871
5972
60class wizard_vat_declaration(wizard.interface):73class wizard_vat_declaration(wizard.interface):
6174
62 def _create_xml(self, cr, uid, data, context):75 def _create_xml(self, cr, uid, data, context):
63 list_of_tags=['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91']76 list_of_tags = ['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','72','81','82','83','84','85','86','87','88','91']
64 pool_obj = pooler.get_pool(cr.dbname)77 pool_obj = pooler.get_pool(cr.dbname)
65 #obj_company = pool_obj.get('res.company').browse(cr,uid,1)78 #obj_company = pool_obj.get('res.company').browse(cr,uid,1)
66 obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id79 obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id
@@ -73,48 +86,112 @@
73 ctx = context.copy()86 ctx = context.copy()
74 ctx['period_id'] = data['form']['period'] #added context here87 ctx['period_id'] = data['form']['period'] #added context here
75 tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_ids,['code','sum_period'],context=ctx)88 tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_ids,['code','sum_period'],context=ctx)
7689
77 address = post_code = city = country_code = ''90 issued_by = vat_no[:2]
7891 comments = data['form']['comments'] or ''
79 city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)92
93 name = email = phone = address = post_code = city = country_code = ''
94 name, email, phone, city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
8095
81 obj_fyear = pool_obj.get('account.fiscalyear')96 obj_fyear = pool_obj.get('account.fiscalyear')
82 year_id = obj_fyear.find(cr, uid)97 year_id = obj_fyear.find(cr, uid)
83 98
84 account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period'])99 account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period'])
85 period_code = account_period.code100 period_code = account_period.code
86
87 send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
88
89 data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-16.xml">'
90 data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+ obj_company.name +'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>'
91 data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<COUNTRY>'+country_code+'</COUNTRY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
92 data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no[2:])+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
93
94 starting_month = account_period.date_start[5:7]101 starting_month = account_period.date_start[5:7]
95 ending_month = account_period.date_stop[5:7]102 ending_month = account_period.date_stop[5:7]
103 quarter = str(((int(starting_month) - 1) / 3) + 1)
104
105 send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
106
107 if not email:
108 raise wizard.except_wizard(_('Data Insufficient!'),_('No email address associated with the partner.'))
109 if not phone:
110 raise wizard.except_wizard(_('Data Insufficient!'),_('No phone associated with the partner.'))
111
112 file_data = {
113 'issued_by': issued_by,
114 'vat_no': vat_no,
115 'only_vat': vat_no[2:],
116 'cmpny_name': obj_company.name,
117 'address': address,
118 'post_code': post_code,
119 'city': city,
120 'country_code': country_code,
121 'email': email,
122 'phone': phone,
123 'send_ref': send_ref,
124 'quarter': quarter,
125 'month': starting_month,
126 'year': str(account_period.date_stop[:4]),
127 'client_nihil': (data['form']['client_nihil'] and 'YES' or 'NO'),
128 'ask_restitution': (data['form']['ask_resitution'] and 'YES' or 'NO'),
129 'ask_payment': (data['form']['ask_payment'] and 'YES' or 'NO'),
130 'comments': comments,
131 }
132
133 data_of_file="""<?xml version="1.0"?>
134 <ns2:VATConsignment xmlns="http://www.minfin.fgov.be/InputCommon" xmlns:ns2="http://www.minfin.fgov.be/VATConsignment" VATDeclarationsNbr="1">
135 <ns2:Representative>
136 <RepresentativeID identificationType="NVAT" issuedBy="%(issued_by)s">%(only_vat)s</RepresentativeID>
137 <Name>%(cmpny_name)s</Name>
138 <Street>%(address)s</Street>
139 <PostCode>%(post_code)s</PostCode>
140 <City>%(city)s</City>
141 <CountryCode>%(country_code)s</CountryCode>
142 <EmailAddress>%(email)s</EmailAddress>
143 <Phone>%(phone)s</Phone>
144 </ns2:Representative>
145 <ns2:VATDeclaration SequenceNumber="1" DeclarantReference="%(send_ref)s">
146 <ns2:Declarant>
147 <VATNumber xmlns="http://www.minfin.fgov.be/InputCommon">%(only_vat)s</VATNumber>
148 <Name>%(cmpny_name)s</Name>
149 <Street>%(address)s</Street>
150 <PostCode>%(post_code)s</PostCode>
151 <City>%(city)s</City>
152 <CountryCode>%(country_code)s</CountryCode>
153 <EmailAddress>%(email)s</EmailAddress>
154 <Phone>%(phone)s</Phone>
155 </ns2:Declarant>
156 <ns2:Period>
157 """ % (file_data)
158
96 if starting_month != ending_month:159 if starting_month != ending_month:
97 #starting month and ending month of selected period are not the same 160 #starting month and ending month of selected period are not the same
98 #it means that the accounting isn't based on periods of 1 month but on quarters161 #it means that the accounting isn't based on periods of 1 month but on quarters
99 quarter = str(((int(starting_month) - 1) / 3) + 1)162 data_of_file += '\t\t<ns2:Quarter>%(quarter)s</ns2:Quarter>\n\t\t' % (file_data)
100 data_of_file += '<QUARTER>'+quarter+'</QUARTER>\n\t\t\t'
101 else:163 else:
102 data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t'164 data_of_file += '\t\t<ns2:Month>%(month)s</ns2:Month>\n\t\t' % (file_data)
103 data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'165 data_of_file += '\t<ns2:Year>%(year)s</ns2:Year>' % (file_data)
104 data_of_file += '\n\t\t<ClientListingNihil>'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'</ClientListingNihil>'166 data_of_file += '\n\t\t</ns2:Period>\n'
105 data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'167 data_of_file += '\t\t<ns2:Data>\t'
106168
169 cases_list = []
107 for item in tax_info:170 for item in tax_info:
108 if item['code'] == '91' and ending_month != 12:171 if item['code'] == '91' and ending_month != 12:
109 #the tax code 91 can only be send for the declaration of December172 #the tax code 91 can only be send for the declaration of December
110 continue173 continue
111 if item['code']:174 if item['code'] and item['sum_period']:
112 if item['code'] == '71-72':175 if item['code'] == 'VI':
113 item['code']='71'176 if item['sum_period'] >= 0:
177 item['code'] = '71'
178 else:
179 item['code'] = '72'
114 if item['code'] in list_of_tags:180 if item['code'] in list_of_tags:
115 data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>'181 cases_list.append(item)
182 cases_list.sort()
183 for item in cases_list:
184 grid_amount_data = {
185 'code': str(int(item['code'])),
186 'amount': str(abs(int(round(item['sum_period']*100)))),
187 }
188 data_of_file += '\n\t\t\t<Amount GridNumber="%(code)s">%(amount)s</Amount''>' % (grid_amount_data)
116189
117 data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'190 data_of_file += '\n\t\t</ns2:Data>'
191 data_of_file += '\n\t\t<ns2:ClientListingNihil>%(client_nihil)s</ns2:ClientListingNihil>' % (file_data)
192 data_of_file += '\n\t\t<ns2:Ask Restitution="%(ask_restitution)s" Payment="%(ask_payment)s"/>' % (file_data)
193 data_of_file += '\n\t\t<ns2:Comment>%(comments)s</ns2:Comment>' % (file_data)
194 data_of_file += '\n\t</ns2:VATDeclaration> \n</ns2:VATConsignment>'
118 data['form']['msg']='Save the File with '".xml"' extension.'195 data['form']['msg']='Save the File with '".xml"' extension.'
119 data['form']['file_save'] = base64.encodestring(data_of_file.encode('utf8'))196 data['form']['file_save'] = base64.encodestring(data_of_file.encode('utf8'))
120 return data['form']197 return data['form']