Merge lp:~qdp/openobject-addons/5.0-l10nbe-intervat5.1.0-compliancy into lp:openobject-addons/5.0
- 5.0-l10nbe-intervat5.1.0-compliancy
- Merge into 5.0
Proposed by
qdp (OpenERP)
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~qdp/openobject-addons/5.0-l10nbe-intervat5.1.0-compliancy |
Merge into: | lp:openobject-addons/5.0 |
Diff against target: |
434 lines (+110/-147) 5 files modified
account/account_bank_statement.py (+26/-21) l10n_be/account_pcmn_belgium.xml (+29/-7) l10n_be/company.py (+4/-2) l10n_be/wizard/account_vat_declaration.py (+14/-12) l10n_be/wizard/wizard_vat_intra.py (+37/-105) |
To merge this branch: | bzr merge lp:~qdp/openobject-addons/5.0-l10nbe-intervat5.1.0-compliancy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account/account_bank_statement.py' | |||
2 | --- account/account_bank_statement.py 2010-02-04 11:47:04 +0000 | |||
3 | +++ account/account_bank_statement.py 2010-04-06 17:52:20 +0000 | |||
4 | @@ -529,35 +529,40 @@ | |||
5 | 529 | 529 | ||
6 | 530 | def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, | 530 | def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, |
7 | 531 | context={}): | 531 | context={}): |
8 | 532 | res = {'value': {}} | ||
9 | 532 | if not partner_id: | 533 | if not partner_id: |
21 | 533 | return {} | 534 | return res |
22 | 534 | res_currency_obj = self.pool.get('res.currency') | 535 | line = self.browse(cursor, user, line_id) |
23 | 535 | res_users_obj = self.pool.get('res.users') | 536 | |
24 | 536 | 537 | if not line or (line and not line[0].account_id): | |
25 | 537 | company_currency_id = res_users_obj.browse(cursor, user, user, | 538 | part = self.pool.get('res.partner').browse(cursor, user, partner_id, |
15 | 538 | context=context).company_id.currency_id.id | ||
16 | 539 | |||
17 | 540 | if not currency_id: | ||
18 | 541 | currency_id = company_currency_id | ||
19 | 542 | |||
20 | 543 | part = self.pool.get('res.partner').browse(cursor, user, partner_id, | ||
26 | 544 | context=context) | 539 | context=context) |
33 | 545 | if type == 'supplier': | 540 | if type == 'supplier': |
34 | 546 | account_id = part.property_account_payable.id | 541 | account_id = part.property_account_payable.id |
35 | 547 | else: | 542 | else: |
36 | 548 | account_id = part.property_account_receivable.id | 543 | account_id = part.property_account_receivable.id |
37 | 549 | 544 | res['value']['account_id'] = account_id | |
38 | 550 | cursor.execute('SELECT sum(debit-credit) \ | 545 | |
39 | 546 | if not line or (line and not line[0].amount): | ||
40 | 547 | res_users_obj = self.pool.get('res.users') | ||
41 | 548 | res_currency_obj = self.pool.get('res.currency') | ||
42 | 549 | company_currency_id = res_users_obj.browse(cursor, user, user, | ||
43 | 550 | context=context).company_id.currency_id.id | ||
44 | 551 | if not currency_id: | ||
45 | 552 | currency_id = company_currency_id | ||
46 | 553 | |||
47 | 554 | cursor.execute('SELECT sum(debit-credit) \ | ||
48 | 551 | FROM account_move_line \ | 555 | FROM account_move_line \ |
49 | 552 | WHERE (reconcile_id is null) \ | 556 | WHERE (reconcile_id is null) \ |
50 | 553 | AND partner_id = %s \ | 557 | AND partner_id = %s \ |
51 | 554 | AND account_id=%s', (partner_id, account_id)) | 558 | AND account_id=%s', (partner_id, account_id)) |
54 | 555 | res = cursor.fetchone() | 559 | pgres = cursor.fetchone() |
55 | 556 | balance = res and res[0] or 0.0 | 560 | balance = pgres and pgres[0] or 0.0 |
56 | 557 | 561 | ||
58 | 558 | balance = res_currency_obj.compute(cursor, user, company_currency_id, | 562 | balance = res_currency_obj.compute(cursor, user, company_currency_id, |
59 | 559 | currency_id, balance, context=context) | 563 | currency_id, balance, context=context) |
61 | 560 | return {'value': {'amount': balance, 'account_id': account_id}} | 564 | res['value']['amount'] = balance |
62 | 565 | return res | ||
63 | 561 | 566 | ||
64 | 562 | def _reconcile_amount(self, cursor, user, ids, name, args, context=None): | 567 | def _reconcile_amount(self, cursor, user, ids, name, args, context=None): |
65 | 563 | if not ids: | 568 | if not ids: |
66 | 564 | 569 | ||
67 | === modified file 'l10n_be/account_pcmn_belgium.xml' | |||
68 | --- l10n_be/account_pcmn_belgium.xml 2010-03-08 13:26:39 +0000 | |||
69 | +++ l10n_be/account_pcmn_belgium.xml 2010-04-06 17:52:20 +0000 | |||
70 | @@ -6466,9 +6466,20 @@ | |||
71 | 6466 | </record> | 6466 | </record> |
72 | 6467 | <record id="vat_code_a44" model="account.tax.code.template"> | 6467 | <record id="vat_code_a44" model="account.tax.code.template"> |
73 | 6468 | <field name="code">44</field> | 6468 | <field name="code">44</field> |
74 | 6469 | <field name="name">Services intra-communautaires et ABC</field> | ||
75 | 6470 | <field name="parent_id" ref="vat_code_out"/> | ||
76 | 6471 | </record> | ||
77 | 6472 | <record id="vat_code_a44a" model="account.tax.code.template"> | ||
78 | 6473 | <field name="code">44a</field> | ||
79 | 6469 | <field name="name">Services intra-communautaires</field> | 6474 | <field name="name">Services intra-communautaires</field> |
82 | 6470 | <field name="parent_id" ref="vat_code_out"/> | 6475 | <field name="parent_id" ref="vat_code_a44"/> |
83 | 6471 | </record> | 6476 | </record> |
84 | 6477 | <record id="vat_code_a44b" model="account.tax.code.template"> | ||
85 | 6478 | <field name="code">44b</field> | ||
86 | 6479 | <field name="name">ABC intra-communautaires</field> | ||
87 | 6480 | <field name="parent_id" ref="vat_code_a44"/> | ||
88 | 6481 | </record> | ||
89 | 6482 | |||
90 | 6472 | <record id="vat_code_a45" model="account.tax.code.template"> | 6483 | <record id="vat_code_a45" model="account.tax.code.template"> |
91 | 6473 | <field name="code">45</field> | 6484 | <field name="code">45</field> |
92 | 6474 | <field name="name">Operations avec TVA due par le cocontractant</field> | 6485 | <field name="name">Operations avec TVA due par le cocontractant</field> |
93 | @@ -7053,14 +7064,25 @@ | |||
94 | 7053 | </record> | 7064 | </record> |
95 | 7054 | <record id="vat_IO_S" model="account.tax.template"> | 7065 | <record id="vat_IO_S" model="account.tax.template"> |
96 | 7055 | <field name="chart_template_id" ref="l10nbe_chart_template"/> | 7066 | <field name="chart_template_id" ref="l10nbe_chart_template"/> |
98 | 7056 | <field name="name">TVA 0% Intracommunautaire (Services et ABC)</field> | 7067 | <field name="name">TVA 0% Services Intracommunautaires</field> |
99 | 7057 | <field name="description">V-INTRA-S 0</field> | 7068 | <field name="description">V-INTRA-S 0</field> |
100 | 7058 | <field eval="0.00" name="amount"/> | 7069 | <field eval="0.00" name="amount"/> |
101 | 7059 | <field name="type">percent</field> | 7070 | <field name="type">percent</field> |
106 | 7060 | <field name="base_code_id" ref="vat_code_a44"/> | 7071 | <field name="base_code_id" ref="vat_code_a44a"/> |
107 | 7061 | <field name="ref_base_code_id" ref="vat_code_a48"/> | 7072 | <field name="ref_base_code_id" ref="vat_code_a48"/> |
108 | 7062 | <field name="type_tax_use">sale</field> | 7073 | <field name="type_tax_use">sale</field> |
109 | 7063 | </record> | 7074 | </record> |
110 | 7075 | <record id="vat_IO_S" model="account.tax.template"> | ||
111 | 7076 | <field name="chart_template_id" ref="l10nbe_chart_template"/> | ||
112 | 7077 | <field name="name">TVA 0% ABC Intracommunautaire</field> | ||
113 | 7078 | <field name="description">V-INTRA-ABC 0</field> | ||
114 | 7079 | <field eval="0.00" name="amount"/> | ||
115 | 7080 | <field name="type">percent</field> | ||
116 | 7081 | <field name="base_code_id" ref="vat_code_a44b"/> | ||
117 | 7082 | <field name="ref_base_code_id" ref="vat_code_a48"/> | ||
118 | 7083 | <field name="type_tax_use">sale</field> | ||
119 | 7084 | </record> | ||
120 | 7085 | |||
121 | 7064 | 7086 | ||
122 | 7065 | <!-- Purchases VAT --> | 7087 | <!-- Purchases VAT --> |
123 | 7066 | <record id="vat_IO_buy_21b" model="account.tax.template"> | 7088 | <record id="vat_IO_buy_21b" model="account.tax.template"> |
124 | 7067 | 7089 | ||
125 | === modified file 'l10n_be/company.py' | |||
126 | --- l10n_be/company.py 2009-02-05 05:43:13 +0000 | |||
127 | +++ l10n_be/company.py 2010-04-06 17:52:20 +0000 | |||
128 | @@ -28,7 +28,7 @@ | |||
129 | 28 | 28 | ||
130 | 29 | 29 | ||
131 | 30 | def _get_default_ad(self, addresses): | 30 | def _get_default_ad(self, addresses): |
133 | 31 | city = post_code = address = "" | 31 | city = post_code = address = country_code = "" |
134 | 32 | for ads in addresses: | 32 | for ads in addresses: |
135 | 33 | if ads.type == 'default': | 33 | if ads.type == 'default': |
136 | 34 | city = ads.city or "" | 34 | city = ads.city or "" |
137 | @@ -37,7 +37,9 @@ | |||
138 | 37 | address = ads.street or "" | 37 | address = ads.street or "" |
139 | 38 | if ads.street2: | 38 | if ads.street2: |
140 | 39 | address += " " + ads.street2 | 39 | address += " " + ads.street2 |
142 | 40 | return city, post_code, address | 40 | if ads.country_id: |
143 | 41 | country_code = ads.country_id and ads.country_id.code or "" | ||
144 | 42 | return city, post_code, address, country_code | ||
145 | 41 | res_company() | 43 | res_company() |
146 | 42 | 44 | ||
147 | 43 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 45 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
148 | 44 | 46 | ||
149 | === modified file 'l10n_be/wizard/account_vat_declaration.py' | |||
150 | --- l10n_be/wizard/account_vat_declaration.py 2009-04-09 10:02:19 +0000 | |||
151 | +++ l10n_be/wizard/account_vat_declaration.py 2010-04-06 17:52:20 +0000 | |||
152 | @@ -30,10 +30,16 @@ | |||
153 | 30 | form_fyear = """<?xml version="1.0"?> | 30 | form_fyear = """<?xml version="1.0"?> |
154 | 31 | <form string="Select Period"> | 31 | <form string="Select Period"> |
155 | 32 | <field name="period" /> | 32 | <field name="period" /> |
156 | 33 | <field name="ask_resitution"/> | ||
157 | 34 | <field name="ask_payment"/> | ||
158 | 35 | <field name="client_nihil"/> | ||
159 | 33 | </form>""" | 36 | </form>""" |
160 | 34 | 37 | ||
161 | 35 | fields_fyear = { | 38 | fields_fyear = { |
162 | 36 | 'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,}, | 39 | 'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,}, |
163 | 40 | 'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',}, | ||
164 | 41 | 'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',}, | ||
165 | 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'}, | ||
166 | 37 | } | 43 | } |
167 | 38 | 44 | ||
168 | 39 | form = """<?xml version="1.0"?> | 45 | form = """<?xml version="1.0"?> |
169 | @@ -54,7 +60,7 @@ | |||
170 | 54 | class wizard_vat_declaration(wizard.interface): | 60 | class wizard_vat_declaration(wizard.interface): |
171 | 55 | 61 | ||
172 | 56 | def _create_xml(self, cr, uid, data, context): | 62 | def _create_xml(self, cr, uid, data, context): |
174 | 57 | list_of_tags=['00','01','02','03','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','91'] | 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'] |
175 | 58 | pool_obj = pooler.get_pool(cr.dbname) | 64 | pool_obj = pooler.get_pool(cr.dbname) |
176 | 59 | #obj_company = pool_obj.get('res.company').browse(cr,uid,1) | 65 | #obj_company = pool_obj.get('res.company').browse(cr,uid,1) |
177 | 60 | obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id | 66 | obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id |
178 | @@ -68,27 +74,22 @@ | |||
179 | 68 | ctx['period_id'] = data['form']['period'] #added context here | 74 | ctx['period_id'] = data['form']['period'] #added context here |
180 | 69 | tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_ids,['code','sum_period'],context=ctx) | 75 | tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_ids,['code','sum_period'],context=ctx) |
181 | 70 | 76 | ||
185 | 71 | address=post_code=city='' | 77 | address = post_code = city = country_code = '' |
183 | 72 | if not obj_company.partner_id.address: | ||
184 | 73 | address=post_code=city='' | ||
186 | 74 | 78 | ||
188 | 75 | city, post_code, address = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address) | 79 | city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address) |
189 | 76 | 80 | ||
190 | 77 | obj_fyear = pool_obj.get('account.fiscalyear') | 81 | obj_fyear = pool_obj.get('account.fiscalyear') |
191 | 78 | year_id = obj_fyear.find(cr, uid) | 82 | year_id = obj_fyear.find(cr, uid) |
192 | 79 | 83 | ||
193 | 80 | account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period']) | 84 | account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period']) |
194 | 81 | current_year = account_period.fiscalyear_id.name | ||
195 | 82 | period_code = account_period.code | 85 | period_code = account_period.code |
196 | 83 | 86 | ||
200 | 84 | send_ref = user_cmpny | 87 | send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4]) |
198 | 85 | if period_code: | ||
199 | 86 | send_ref = send_ref + period_code | ||
201 | 87 | 88 | ||
202 | 88 | data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">' | 89 | data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">' |
203 | 89 | data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+str(obj_company.name)+'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>' | 90 | data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+str(obj_company.name)+'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>' |
206 | 90 | data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>' | 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>' |
207 | 91 | data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t' | 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' |
208 | 92 | 93 | ||
209 | 93 | starting_month = account_period.date_start[5:7] | 94 | starting_month = account_period.date_start[5:7] |
210 | 94 | ending_month = account_period.date_stop[5:7] | 95 | ending_month = account_period.date_stop[5:7] |
211 | @@ -100,6 +101,7 @@ | |||
212 | 100 | else: | 101 | else: |
213 | 101 | data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t' | 102 | data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t' |
214 | 102 | data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>' | 103 | data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>' |
215 | 104 | data_of_file += '\n\t\t<ClientListingNihil>'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'</ClientListingNihil>' | ||
216 | 103 | data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>' | 105 | data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>' |
217 | 104 | 106 | ||
218 | 105 | for item in tax_info: | 107 | for item in tax_info: |
219 | @@ -107,7 +109,7 @@ | |||
220 | 107 | if item['code'] == '71-72': | 109 | if item['code'] == '71-72': |
221 | 108 | item['code']='71' | 110 | item['code']='71' |
222 | 109 | if item['code'] in list_of_tags: | 111 | if item['code'] in list_of_tags: |
224 | 110 | data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>' | 112 | 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'])) +'>' |
225 | 111 | 113 | ||
226 | 112 | data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>' | 114 | data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>' |
227 | 113 | data['form']['msg']='Save the File with '".xml"' extension.' | 115 | data['form']['msg']='Save the File with '".xml"' extension.' |
228 | 114 | 116 | ||
229 | === modified file 'l10n_be/wizard/wizard_vat_intra.py' | |||
230 | --- l10n_be/wizard/wizard_vat_intra.py 2009-03-24 11:01:43 +0000 | |||
231 | +++ l10n_be/wizard/wizard_vat_intra.py 2010-04-06 17:52:20 +0000 | |||
232 | @@ -30,6 +30,7 @@ | |||
233 | 30 | import datetime | 30 | import datetime |
234 | 31 | import pooler | 31 | import pooler |
235 | 32 | import base64 | 32 | import base64 |
236 | 33 | from tools.translate import _ | ||
237 | 33 | 34 | ||
238 | 34 | form_intra = """<?xml version="1.0"?> | 35 | form_intra = """<?xml version="1.0"?> |
239 | 35 | <form string="Partner VAT Intra"> | 36 | <form string="Partner VAT Intra"> |
240 | @@ -37,13 +38,12 @@ | |||
241 | 37 | <page string="General Information"> | 38 | <page string="General Information"> |
242 | 38 | <label string="This wizard will create an XML file for Vat Intra" colspan="4"/> | 39 | <label string="This wizard will create an XML file for Vat Intra" colspan="4"/> |
243 | 39 | <newline/> | 40 | <newline/> |
245 | 40 | <field name="fyear" /> | 41 | <field name="period_code"/> |
246 | 42 | <newline/> | ||
247 | 43 | <field name="period_ids"/> | ||
248 | 41 | <newline/> | 44 | <newline/> |
249 | 42 | <field name="mand_id" help="This identifies the representative of the sending company. This is a string of 14 characters"/> | 45 | <field name="mand_id" help="This identifies the representative of the sending company. This is a string of 14 characters"/> |
250 | 43 | <newline/> | 46 | <newline/> |
251 | 44 | <field name="trimester" help="it will be the first digit of period" /> | ||
252 | 45 | <newline/> | ||
253 | 46 | <field name="test_xml" help="Set the XML output as test file"/> | ||
254 | 47 | </page> | 47 | </page> |
255 | 48 | <page string="European Countries"> | 48 | <page string="European Countries"> |
256 | 49 | <field name="country_ids" colspan="4" nolabel="1" /> | 49 | <field name="country_ids" colspan="4" nolabel="1" /> |
257 | @@ -51,14 +51,18 @@ | |||
258 | 51 | </notebook> | 51 | </notebook> |
259 | 52 | </form>""" | 52 | </form>""" |
260 | 53 | fields_intra = { | 53 | fields_intra = { |
267 | 54 | 'trimester': {'string': 'Trimester Number', 'type': 'selection', 'selection':[ | 54 | 'period_code': {'string':'Period Code','type':'char','size':'6','required': True, 'help': '''This is where you have to set the period code for the intracom declaration using the format: ppyyyy |
268 | 55 | ('1','Jan/Feb/Mar'), | 55 | |
269 | 56 | ('2','Apr/May/Jun'), | 56 | PP can stand for a month: from '01' to '12'. |
270 | 57 | ('3','Jul/Aug/Sep'), | 57 | PP can stand for a trimester: '31','32','33','34' |
271 | 58 | ('4','Oct/Nov/Dec')], 'required': True}, | 58 | The first figure means that it is a trimester, |
272 | 59 | 'test_xml': {'string':'Test XML file', 'type':'boolean'}, | 59 | The second figure identify the trimester. |
273 | 60 | PP can stand for a complete fiscal year: '00'. | ||
274 | 61 | YYYY stands for the year (4 positions). | ||
275 | 62 | ''' | ||
276 | 63 | }, | ||
277 | 64 | 'period_ids': {'string': 'Period(s)', 'type': 'many2many', 'relation': 'account.period', 'required': True, 'help': 'Select here the period(s) you want to include in your intracom declaration'}, | ||
278 | 60 | 'mand_id':{'string':'MandataireId','type':'char','size':'14','required': True}, | 65 | 'mand_id':{'string':'MandataireId','type':'char','size':'14','required': True}, |
279 | 61 | 'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True}, | ||
280 | 62 | 'country_ids': { | 66 | 'country_ids': { |
281 | 63 | 'string': 'European Countries', | 67 | 'string': 'European Countries', |
282 | 64 | 'type': 'many2many', | 68 | 'type': 'many2many', |
283 | @@ -89,19 +93,16 @@ | |||
284 | 89 | def _create_xml(self, cr, uid, data, context): | 93 | def _create_xml(self, cr, uid, data, context): |
285 | 90 | pool = pooler.get_pool(cr.dbname) | 94 | pool = pooler.get_pool(cr.dbname) |
286 | 91 | data_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id | 95 | data_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id |
287 | 92 | data_fiscal = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear']) | ||
288 | 93 | company_vat = data_cmpny.partner_id.vat | 96 | company_vat = data_cmpny.partner_id.vat |
289 | 94 | |||
290 | 95 | if not company_vat: | 97 | if not company_vat: |
291 | 96 | raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!') | 98 | raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!') |
292 | 97 | 99 | ||
293 | 98 | seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref') | 100 | seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref') |
294 | 99 | seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum') | 101 | seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum') |
300 | 100 | cref = company_vat + seq_controlref | 102 | cref = company_vat[2:] + seq_controlref[-4:] |
301 | 101 | dnum = cref + seq_declarantnum | 103 | dnum = cref + seq_declarantnum[-5:] |
302 | 102 | if len(data_fiscal.date_start.split('-')[0]) < 4: | 104 | if len(data['form']['period_code']) != 6: |
303 | 103 | raise wizard.except_wizard('Data Insufficient','Trimester year should be length of 4 digits!') | 105 | raise wizard.except_wizard(_('Wrong Period Code'), _('The period code you entered is not valid.')) |
299 | 104 | period_trimester = data['form']['trimester'] + data_fiscal.date_start.split('-')[0] | ||
304 | 105 | 106 | ||
305 | 106 | street = zip_city = country = '' | 107 | street = zip_city = country = '' |
306 | 107 | addr = pool.get('res.partner').address_get(cr, uid, [data_cmpny.partner_id.id], ['invoice']) | 108 | addr = pool.get('res.partner').address_get(cr, uid, [data_cmpny.partner_id.id], ['invoice']) |
307 | @@ -121,103 +122,34 @@ | |||
308 | 121 | sender_date = time.strftime('%Y-%m-%d') | 122 | sender_date = time.strftime('%Y-%m-%d') |
309 | 122 | data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"' | 123 | data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"' |
310 | 123 | data_file +=' ControlRef="' + cref + '" MandataireId="' + data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"' | 124 | data_file +=' ControlRef="' + cref + '" MandataireId="' + data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"' |
314 | 124 | if data['form']['test_xml']: | 125 | data_file += ' VersionTech="1.3">' |
312 | 125 | data_file += ' Test="1"' | ||
313 | 126 | data_file += ' VersionTech="1.2">' | ||
315 | 127 | data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>' | 126 | data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>' |
316 | 128 | data_file +='\n\t\t\t<Country>' + str(country) +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>' | 127 | data_file +='\n\t\t\t<Country>' + str(country) +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>' |
317 | 129 | 128 | ||
320 | 130 | data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>' | 129 | data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat[2:])+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>' |
321 | 131 | data_period = '\n\t\t<Period>'+ str(period_trimester) +'</Period>' #trimester | 130 | data_period = '\n\t\t<Period>'+ data['form']['period_code'] +'</Period>' #trimester |
322 | 132 | 131 | ||
323 | 133 | error_message = [] | 132 | error_message = [] |
324 | 134 | seq = 0 | 133 | seq = 0 |
325 | 135 | amount_sum = 0 | 134 | amount_sum = 0 |
403 | 136 | p_id_list = pool.get('res.partner').search(cr,uid,[('vat','!=',False)]) | 135 | |
404 | 137 | if not p_id_list: | 136 | list_partner = [] |
328 | 138 | raise wizard.except_wizard('Data Insufficient!','No partner has a VAT Number asociated with him.') | ||
329 | 139 | |||
330 | 140 | nb_period = len(data_fiscal.period_ids) | ||
331 | 141 | fiscal_periods = data_fiscal.period_ids | ||
332 | 142 | |||
333 | 143 | if data['form']['trimester'] == '1': | ||
334 | 144 | if nb_period == 12: | ||
335 | 145 | start_date = fiscal_periods[0].date_start | ||
336 | 146 | end_date = fiscal_periods[2].date_stop | ||
337 | 147 | elif nb_period == 4: | ||
338 | 148 | start_date = fiscal_periods[0].date_start | ||
339 | 149 | end_date = fiscal_periods[0].date_stop | ||
340 | 150 | elif data['form']['trimester'] == '2': | ||
341 | 151 | if nb_period == 12: | ||
342 | 152 | start_date = fiscal_periods[3].date_start | ||
343 | 153 | end_date = fiscal_periods[5].date_stop | ||
344 | 154 | elif nb_period == 4: | ||
345 | 155 | start_date = fiscal_periods[1].date_start | ||
346 | 156 | end_date = fiscal_periods[1].date_stop | ||
347 | 157 | elif data['form']['trimester'] == '3': | ||
348 | 158 | if nb_period == 12: | ||
349 | 159 | start_date = fiscal_periods[6].date_start | ||
350 | 160 | end_date = fiscal_periods[8].date_stop | ||
351 | 161 | elif nb_period == 4: | ||
352 | 162 | start_date = fiscal_periods[2].date_start | ||
353 | 163 | end_date = fiscal_periods[2].date_stop | ||
354 | 164 | elif data['form']['trimester'] == '4': | ||
355 | 165 | if nb_period == 12: | ||
356 | 166 | start_date = fiscal_periods[9].date_start | ||
357 | 167 | end_date = fiscal_periods[11].date_stop | ||
358 | 168 | elif nb_period == 4: | ||
359 | 169 | start_date = fiscal_periods[3].date_start | ||
360 | 170 | end_date = fiscal_periods[3].date_stop | ||
361 | 171 | |||
362 | 172 | period = "to_date('" + str(start_date) + "','yyyy-mm-dd') and to_date('" + str(end_date) +"','yyyy-mm-dd')" | ||
363 | 173 | record = {} | ||
364 | 174 | |||
365 | 175 | for p_id in p_id_list: | ||
366 | 176 | list_partner = [] | ||
367 | 177 | partner = pool.get('res.partner').browse(cr, uid, p_id) | ||
368 | 178 | go_ahead = False | ||
369 | 179 | country_code = '' | ||
370 | 180 | for ads in partner.address: | ||
371 | 181 | if ads.type == 'default' and (ads.country_id and ads.country_id.id in data['form']['country_ids'][0][2]): | ||
372 | 182 | go_ahead = True | ||
373 | 183 | country_code = ads.country_id.code | ||
374 | 184 | break | ||
375 | 185 | if not go_ahead: | ||
376 | 186 | continue | ||
377 | 187 | |||
378 | 188 | cr.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,)) | ||
379 | 189 | res = cr.dictfetchall() | ||
380 | 190 | list_partner.append(res[0]['amount']) | ||
381 | 191 | list_partner.append('T') #partner.ref ...should be check | ||
382 | 192 | list_partner.append(partner.vat) | ||
383 | 193 | list_partner.append(country_code) | ||
384 | 194 | #...deprecated... | ||
385 | 195 | # addr = pool.get('res.partner').address_get(cr, uid, [partner.id], ['invoice']) | ||
386 | 196 | # if addr.get('invoice',False): | ||
387 | 197 | # ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0] | ||
388 | 198 | # | ||
389 | 199 | # if ads.country_id: | ||
390 | 200 | # code_country = ads.country_id.code | ||
391 | 201 | # list_partner.append(code_country) | ||
392 | 202 | # else: | ||
393 | 203 | # error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no country associated with its Invoice address!') | ||
394 | 204 | # if len(list_partner)<4: | ||
395 | 205 | # list_partner.append('') | ||
396 | 206 | # error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no Invoice address!') | ||
397 | 207 | # list_partner.append(code_country or 'not avail') | ||
398 | 208 | record[p_id] = list_partner | ||
399 | 209 | |||
400 | 210 | if len(error_message): | ||
401 | 211 | data['form']['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message) | ||
402 | 212 | return data['form'] | ||
405 | 213 | data_clientinfo = '' | 137 | data_clientinfo = '' |
408 | 214 | 138 | cr.execute('''SELECT l.partner_id AS partner_id, p.vat AS vat, t.code AS intra_code, SUM(l.tax_amount) AS amount | |
409 | 215 | for r in record: | 139 | FROM account_move_line l |
410 | 140 | LEFT JOIN account_tax_code t ON (l.tax_code_id = t.id) | ||
411 | 141 | LEFT JOIN res_partner p ON (l.partner_id = p.id) | ||
412 | 142 | WHERE t.code IN ('44a','44b','88') | ||
413 | 143 | AND l.period_id IN %s | ||
414 | 144 | GROUP BY l.partner_id, p.vat, t.code''', (tuple(data['form']['period_ids'][0][2]), )) | ||
415 | 145 | for row in cr.dictfetchall(): | ||
416 | 216 | seq += 1 | 146 | seq += 1 |
418 | 217 | amt = record[r][0] or 0 | 147 | amt = row['amount'] or 0 |
419 | 218 | amt = int(amt * 100) | 148 | amt = int(amt * 100) |
420 | 219 | amount_sum += amt | 149 | amount_sum += amt |
422 | 220 | data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+record[r][2] +'</VATNum>\n\t\t\t\t<Country>'+record[r][3] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Period>'+str(period_trimester) +'</Period>\n\t\t\t<Code>'+str(record[r][1]) +'</Code>\n\t\t</ClientList>' | 150 | intra_code = row['intra_code'] == '88' and 'L' or (row['intra_code'] == '44b' and 'T' or (row['intra_code'] == '44a' and 'S' or '')) |
423 | 151 | data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+row['vat'][2:] +'</VATNum>\n\t\t\t\t<Country>'+row['vat'][:2] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Code>'+str(intra_code) +'</Code>\n\t\t</ClientList>' | ||
424 | 152 | |||
425 | 221 | amount_sum = int(amount_sum) | 153 | amount_sum = int(amount_sum) |
426 | 222 | data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >' | 154 | data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >' |
427 | 223 | data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>' | 155 | data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>' |
428 | @@ -235,4 +167,4 @@ | |||
429 | 235 | 'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]}, | 167 | 'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]}, |
430 | 236 | } | 168 | } |
431 | 237 | } | 169 | } |
432 | 238 | parter_vat_intra('vat.intra.xml') | ||
433 | 239 | \ No newline at end of file | 170 | \ No newline at end of file |
434 | 171 | parter_vat_intra('vat.intra.xml') |