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