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