Merge lp:~openobject-italia-core-devs/openobject-italia/l10n_it_invoice_tax_compute into lp:~openobject-italia-core-devs/openobject-italia/italian-addons
- l10n_it_invoice_tax_compute
- Merge into italian-addons
Status: | Merged |
---|---|
Merge reported by: | Lorenzo Battistini |
Merged at revision: | not available |
Proposed branch: | lp:~openobject-italia-core-devs/openobject-italia/l10n_it_invoice_tax_compute |
Merge into: | lp:~openobject-italia-core-devs/openobject-italia/italian-addons |
Diff against target: |
535 lines (+493/-0) 8 files modified
account_invoice_tax_by_column/AUTHORS.txt (+4/-0) account_invoice_tax_by_column/__init__.py (+24/-0) account_invoice_tax_by_column/__openerp__.py (+58/-0) account_invoice_tax_by_column/account.py (+55/-0) account_invoice_tax_by_column/i18n/account_invoice_tax_by_column.pot (+72/-0) account_invoice_tax_by_column/i18n/it.po (+94/-0) account_invoice_tax_by_column/invoice.py (+79/-0) account_invoice_tax_by_column/tests/tests.txt (+107/-0) |
To merge this branch: | bzr merge lp:~openobject-italia-core-devs/openobject-italia/l10n_it_invoice_tax_compute |
Related bugs: | |
Related blueprints: |
Calcolo Verticale IVA
(High)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lorenzo Battistini | Approve | ||
Review via email:
|
This proposal has been superseded by a proposal from 2011-08-23.
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lorenzo Battistini (elbati) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lorenzo Battistini (elbati) wrote : | # |
Sembrano esserci problemi con le tasse parzialmente deducibili.
Ho provato a creare una fattura fornitore con una riga da 123,57 e IVA 20% deducibile al 50%.
Cliccando su 'Compute Taxes' ottengo
ERROR:web-
Traceback (most recent call last):
File "/home/
return f(self, dbname, *args, **kwargs)
File "/home/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/
for taxe in ait_obj.compute(cr, uid, id, context=
File "/home/
amount = tax_obj.
KeyError: 'tax'
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lorenzo Battistini (elbati) wrote : | # |
Per me ora il modulo 'account_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lorenzo Battistini (elbati) wrote : | # |
Si potrebbe perfezionare il modulo cercando di usare 'super' ove possibile invece di riscrivere completamente i metodi di calcolo delle tasse
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Lorenzo Battistini (elbati) wrote : | # |
Ecco: http://
Qualcuno vuole fare dei test?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Corato (icsergio) wrote : | # |
Il 20/08/2011 12:10, Lorenzo Battistini - Agile BG - Domsense ha scritto:
> Review: Approve
> Ecco: http://
> Qualcuno vuole fare dei test?
L'ho provato sulla 6.0.3, per me è tutto regolare.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Davide Corio (enlightx-deactivatedaccount) wrote : | # |
Allora, lato tecnico (codice, funzionamento wizard, stampe...) mi pare tutto ok, quindi il merge è ok per me.
Possiamo quindi iniziare a lavorare alle raffinatezze e all'usabilità. soprattutto per quanto riguarda wizard e stampe.
Cmq bravo Lorenzo
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Davide Corio (enlightx-deactivatedaccount) wrote : | # |
Ooooops, ho fatto casino :-)
per qualche link confuso stavo testando il branch sui registri iva.
su questo branch invece ho trovato un errore di calcolo con aliquote parzialmente deducibili
Preview Diff
1 | === added directory 'account_invoice_tax_by_column' | |||
2 | === added file 'account_invoice_tax_by_column/AUTHORS.txt' | |||
3 | --- account_invoice_tax_by_column/AUTHORS.txt 1970-01-01 00:00:00 +0000 | |||
4 | +++ account_invoice_tax_by_column/AUTHORS.txt 2011-08-20 10:12:24 +0000 | |||
5 | @@ -0,0 +1,4 @@ | |||
6 | 1 | Matteo Grolla <magrolla@yahoo.it> | ||
7 | 2 | Marco Marchiori <marcomarkiori@gmail.com> | ||
8 | 3 | Massimo Biancalani <massimo.biancalani@gmail.com> | ||
9 | 4 | Lorenzo Battistini <lorenzo.battistini@domsense.com> | ||
10 | 0 | 5 | ||
11 | === added file 'account_invoice_tax_by_column/__init__.py' | |||
12 | --- account_invoice_tax_by_column/__init__.py 1970-01-01 00:00:00 +0000 | |||
13 | +++ account_invoice_tax_by_column/__init__.py 2011-08-20 10:12:24 +0000 | |||
14 | @@ -0,0 +1,24 @@ | |||
15 | 1 | # -*- encoding: utf-8 -*- | ||
16 | 2 | ############################################################################## | ||
17 | 3 | # | ||
18 | 4 | # OpenERP, Open Source Management Solution | ||
19 | 5 | # Copyright (C) 2011 | ||
20 | 6 | # Associazione OpenERP Italia (<http://www.openerp-italia.org>) | ||
21 | 7 | # | ||
22 | 8 | # This program is free software: you can redistribute it and/or modify | ||
23 | 9 | # it under the terms of the GNU Affero General Public License as | ||
24 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
25 | 11 | # License, or (at your option) any later version. | ||
26 | 12 | # | ||
27 | 13 | # This program is distributed in the hope that it will be useful, | ||
28 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
29 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
30 | 16 | # GNU Affero General Public License for more details. | ||
31 | 17 | # | ||
32 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
33 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
34 | 20 | # | ||
35 | 21 | ############################################################################## | ||
36 | 22 | |||
37 | 23 | import invoice | ||
38 | 24 | import account | ||
39 | 0 | 25 | ||
40 | === added file 'account_invoice_tax_by_column/__openerp__.py' | |||
41 | --- account_invoice_tax_by_column/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
42 | +++ account_invoice_tax_by_column/__openerp__.py 2011-08-20 10:12:24 +0000 | |||
43 | @@ -0,0 +1,58 @@ | |||
44 | 1 | # -*- encoding: utf-8 -*- | ||
45 | 2 | ############################################################################## | ||
46 | 3 | # | ||
47 | 4 | # OpenERP, Open Source Management Solution | ||
48 | 5 | # Copyright (C) 2011 | ||
49 | 6 | # Associazione OpenERP Italia (<http://www.openerp-italia.org>) | ||
50 | 7 | # | ||
51 | 8 | # This program is free software: you can redistribute it and/or modify | ||
52 | 9 | # it under the terms of the GNU Affero General Public License as | ||
53 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
54 | 11 | # License, or (at your option) any later version. | ||
55 | 12 | # | ||
56 | 13 | # This program is distributed in the hope that it will be useful, | ||
57 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
59 | 16 | # GNU Affero General Public License for more details. | ||
60 | 17 | # | ||
61 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
62 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
63 | 20 | # | ||
64 | 21 | ############################################################################## | ||
65 | 22 | { | ||
66 | 23 | 'name': 'Account Invoice Tax - Computation By Column', | ||
67 | 24 | 'version': '0.1', | ||
68 | 25 | 'category': 'Generic Modules/Accounting', | ||
69 | 26 | 'description': """ | ||
70 | 27 | -Invoice taxes: | ||
71 | 28 | legend: | ||
72 | 29 | TA(l) TaxAmount for line l | ||
73 | 30 | TBA(l) TaxBaseAmount for line l | ||
74 | 31 | TA(t) TaxAmount for tax t | ||
75 | 32 | TBA(t) TaxBaseAmount for tax t | ||
76 | 33 | |||
77 | 34 | default behaviour: | ||
78 | 35 | openerp by default calculates taxes line by line as a function of line tax base amount | ||
79 | 36 | and then groups these amounts by tax. | ||
80 | 37 | TA(l) = f(TBA(l) | ||
81 | 38 | TA(t) = sum( round( TA(l) ) ) /sum on lines l to which tax t is applied | ||
82 | 39 | this module behaviour: | ||
83 | 40 | In Italy the correct way to compute taxes is to first compute the tax base amount TBA(t) | ||
84 | 41 | and the compute TA as a function of TBA(t) | ||
85 | 42 | TBA(t) = sum( TBA(t) ) /sum on lines l to which tax t is applied | ||
86 | 43 | TA(t) = f( TBA(t) ) | ||
87 | 44 | the result difference is small but important | ||
88 | 45 | |||
89 | 46 | """, | ||
90 | 47 | 'author': 'OpenERP Italian Community', | ||
91 | 48 | 'website': 'http://www.openerp-italia.org', | ||
92 | 49 | 'license': 'AGPL-3', | ||
93 | 50 | "depends" : ['account', 'account_voucher'], | ||
94 | 51 | "init_xml" : [], | ||
95 | 52 | "update_xml" : [], | ||
96 | 53 | "demo_xml" : [], | ||
97 | 54 | "active": False, | ||
98 | 55 | "installable": True | ||
99 | 56 | } | ||
100 | 57 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
101 | 58 | |||
102 | 0 | 59 | ||
103 | === added file 'account_invoice_tax_by_column/account.py' | |||
104 | --- account_invoice_tax_by_column/account.py 1970-01-01 00:00:00 +0000 | |||
105 | +++ account_invoice_tax_by_column/account.py 2011-08-20 10:12:24 +0000 | |||
106 | @@ -0,0 +1,55 @@ | |||
107 | 1 | # -*- encoding: utf-8 -*- | ||
108 | 2 | ############################################################################## | ||
109 | 3 | # | ||
110 | 4 | # OpenERP, Open Source Management Solution | ||
111 | 5 | # Copyright (C) 2010-2010 Camptocamp Austria (<http://www.camptocamp.at>) | ||
112 | 6 | # Copyright (C) 2011 | ||
113 | 7 | # Associazione OpenERP Italia (<http://www.openerp-italia.org>) | ||
114 | 8 | # | ||
115 | 9 | # This program is free software: you can redistribute it and/or modify | ||
116 | 10 | # it under the terms of the GNU Affero General Public License as | ||
117 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
118 | 12 | # License, or (at your option) any later version. | ||
119 | 13 | # | ||
120 | 14 | # This program is distributed in the hope that it will be useful, | ||
121 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
122 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
123 | 17 | # GNU Affero General Public License for more details. | ||
124 | 18 | # | ||
125 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
126 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
127 | 21 | # | ||
128 | 22 | ############################################################################## | ||
129 | 23 | |||
130 | 24 | from osv import fields, osv | ||
131 | 25 | import decimal_precision as dp | ||
132 | 26 | from decimal import * | ||
133 | 27 | |||
134 | 28 | class account_tax(osv.osv): | ||
135 | 29 | |||
136 | 30 | _inherit = 'account.tax' | ||
137 | 31 | |||
138 | 32 | _columns = { | ||
139 | 33 | 'line_precision' : fields.boolean('Rounding Precision', help="Calculates floating point tax per line to simulate vertical calculation"), | ||
140 | 34 | } | ||
141 | 35 | |||
142 | 36 | _defaults = { | ||
143 | 37 | 'line_precision': True | ||
144 | 38 | } | ||
145 | 39 | |||
146 | 40 | def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): | ||
147 | 41 | res = super(account_tax, self)._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner) | ||
148 | 42 | tax_pool=self.pool.get('account.tax') | ||
149 | 43 | total = 0.0 | ||
150 | 44 | for r in res: | ||
151 | 45 | tax = tax_pool.browse(cr, uid, r['id']) | ||
152 | 46 | if tax.line_precision: | ||
153 | 47 | if r.get('balance',False): | ||
154 | 48 | r['amount'] = r.get('balance', 0.0) * quantity - total | ||
155 | 49 | else: | ||
156 | 50 | r['amount'] = r.get('amount', 0.0) * quantity | ||
157 | 51 | total += r['amount'] | ||
158 | 52 | return res | ||
159 | 53 | |||
160 | 54 | |||
161 | 55 | account_tax() | ||
162 | 0 | 56 | ||
163 | === added directory 'account_invoice_tax_by_column/i18n' | |||
164 | === added file 'account_invoice_tax_by_column/i18n/account_invoice_tax_by_column.pot' | |||
165 | --- account_invoice_tax_by_column/i18n/account_invoice_tax_by_column.pot 1970-01-01 00:00:00 +0000 | |||
166 | +++ account_invoice_tax_by_column/i18n/account_invoice_tax_by_column.pot 2011-08-20 10:12:24 +0000 | |||
167 | @@ -0,0 +1,72 @@ | |||
168 | 1 | # Translation of OpenERP Server. | ||
169 | 2 | # This file contains the translation of the following modules: | ||
170 | 3 | # * account_invoice_tax_by_column | ||
171 | 4 | # | ||
172 | 5 | msgid "" | ||
173 | 6 | msgstr "" | ||
174 | 7 | "Project-Id-Version: OpenERP Server 6.0.2\n" | ||
175 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
176 | 9 | "POT-Creation-Date: 2011-07-23 14:32+0000\n" | ||
177 | 10 | "PO-Revision-Date: 2011-07-23 14:32+0000\n" | ||
178 | 11 | "Last-Translator: <>\n" | ||
179 | 12 | "Language-Team: \n" | ||
180 | 13 | "MIME-Version: 1.0\n" | ||
181 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
182 | 15 | "Content-Transfer-Encoding: \n" | ||
183 | 16 | "Plural-Forms: \n" | ||
184 | 17 | |||
185 | 18 | #. module: account_invoice_tax_by_column | ||
186 | 19 | #: model:ir.model,name:account_invoice_tax_by_column.model_account_invoice_tax | ||
187 | 20 | msgid "Invoice Tax" | ||
188 | 21 | msgstr "" | ||
189 | 22 | |||
190 | 23 | #. module: account_invoice_tax_by_column | ||
191 | 24 | #: model:ir.module.module,description:account_invoice_tax_by_column.module_meta_information | ||
192 | 25 | msgid " \n" | ||
193 | 26 | " -Invoice taxes: \n" | ||
194 | 27 | " legend:\n" | ||
195 | 28 | " TA(l) TaxAmount for line l\n" | ||
196 | 29 | " TBA(l) TaxBaseAmount for line l\n" | ||
197 | 30 | " TA(t) TaxAmount for tax t\n" | ||
198 | 31 | " TBA(t) TaxBaseAmount for tax t\n" | ||
199 | 32 | " \n" | ||
200 | 33 | " default behaviour: \n" | ||
201 | 34 | " openerp by default calculates taxes line by line as a function of line tax base amount \n" | ||
202 | 35 | " and then groups these amounts by tax.\n" | ||
203 | 36 | " TA(l) = f(TBA(l)\n" | ||
204 | 37 | " TA(t) = sum( round( TA(l) ) ) /sum on lines l to which tax t is applied\n" | ||
205 | 38 | " this module behaviour: \n" | ||
206 | 39 | " In Italy the correct way to compute taxes is to first compute the tax base amount TBA(t) \n" | ||
207 | 40 | " and the compute TA as a function of TBA(t)\n" | ||
208 | 41 | " TBA(t) = sum( TBA(t) ) /sum on lines l to which tax t is applied\n" | ||
209 | 42 | " TA(t) = f( TBA(t) )\n" | ||
210 | 43 | " the result difference is small but important\n" | ||
211 | 44 | "\n" | ||
212 | 45 | " " | ||
213 | 46 | msgstr "" | ||
214 | 47 | |||
215 | 48 | #. module: account_invoice_tax_by_column | ||
216 | 49 | #: help:account.tax,line_precision:0 | ||
217 | 50 | msgid "Calculates floating point tax per line to simulate vertical calculation" | ||
218 | 51 | msgstr "" | ||
219 | 52 | |||
220 | 53 | #. module: account_invoice_tax_by_column | ||
221 | 54 | #: field:account.tax,line_precision:0 | ||
222 | 55 | msgid "Rounding Precision" | ||
223 | 56 | msgstr "" | ||
224 | 57 | |||
225 | 58 | #. module: account_invoice_tax_by_column | ||
226 | 59 | #: model:ir.module.module,shortdesc:account_invoice_tax_by_column.module_meta_information | ||
227 | 60 | msgid "Account Invoice Tax - Computation By Column" | ||
228 | 61 | msgstr "" | ||
229 | 62 | |||
230 | 63 | #. module: account_invoice_tax_by_column | ||
231 | 64 | #: model:ir.model,name:account_invoice_tax_by_column.model_account_tax | ||
232 | 65 | msgid "account.tax" | ||
233 | 66 | msgstr "" | ||
234 | 67 | |||
235 | 68 | #. module: account_invoice_tax_by_column | ||
236 | 69 | #: sql_constraint:account.tax:0 | ||
237 | 70 | msgid "The tax name must be unique!" | ||
238 | 71 | msgstr "" | ||
239 | 72 | |||
240 | 0 | 73 | ||
241 | === added file 'account_invoice_tax_by_column/i18n/it.po' | |||
242 | --- account_invoice_tax_by_column/i18n/it.po 1970-01-01 00:00:00 +0000 | |||
243 | +++ account_invoice_tax_by_column/i18n/it.po 2011-08-20 10:12:24 +0000 | |||
244 | @@ -0,0 +1,94 @@ | |||
245 | 1 | # Translation of OpenERP Server. | ||
246 | 2 | # This file contains the translation of the following modules: | ||
247 | 3 | # * account_invoice_tax_by_column | ||
248 | 4 | # | ||
249 | 5 | msgid "" | ||
250 | 6 | msgstr "" | ||
251 | 7 | "Project-Id-Version: OpenERP Server 6.0.2\n" | ||
252 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
253 | 9 | "POT-Creation-Date: 2011-07-23 14:32+0000\n" | ||
254 | 10 | "PO-Revision-Date: 2011-07-23 16:35+0100\n" | ||
255 | 11 | "Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n" | ||
256 | 12 | "Language-Team: \n" | ||
257 | 13 | "MIME-Version: 1.0\n" | ||
258 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
259 | 15 | "Content-Transfer-Encoding: 8bit\n" | ||
260 | 16 | "Plural-Forms: \n" | ||
261 | 17 | |||
262 | 18 | #. module: account_invoice_tax_by_column | ||
263 | 19 | #: model:ir.model,name:account_invoice_tax_by_column.model_account_invoice_tax | ||
264 | 20 | msgid "Invoice Tax" | ||
265 | 21 | msgstr "Imposta della fattura" | ||
266 | 22 | |||
267 | 23 | #. module: account_invoice_tax_by_column | ||
268 | 24 | #: model:ir.module.module,description:account_invoice_tax_by_column.module_meta_information | ||
269 | 25 | msgid "" | ||
270 | 26 | " \n" | ||
271 | 27 | " -Invoice taxes: \n" | ||
272 | 28 | " legend:\n" | ||
273 | 29 | " TA(l) TaxAmount for line l\n" | ||
274 | 30 | " TBA(l) TaxBaseAmount for line l\n" | ||
275 | 31 | " TA(t) TaxAmount for tax t\n" | ||
276 | 32 | " TBA(t) TaxBaseAmount for tax t\n" | ||
277 | 33 | " \n" | ||
278 | 34 | " default behaviour: \n" | ||
279 | 35 | " openerp by default calculates taxes line by line as a function of line tax base amount \n" | ||
280 | 36 | " and then groups these amounts by tax.\n" | ||
281 | 37 | " TA(l) = f(TBA(l)\n" | ||
282 | 38 | " TA(t) = sum( round( TA(l) ) ) /sum on lines l to which tax t is applied\n" | ||
283 | 39 | " this module behaviour: \n" | ||
284 | 40 | " In Italy the correct way to compute taxes is to first compute the tax base amount TBA(t) \n" | ||
285 | 41 | " and the compute TA as a function of TBA(t)\n" | ||
286 | 42 | " TBA(t) = sum( TBA(t) ) /sum on lines l to which tax t is applied\n" | ||
287 | 43 | " TA(t) = f( TBA(t) )\n" | ||
288 | 44 | " the result difference is small but important\n" | ||
289 | 45 | "\n" | ||
290 | 46 | " " | ||
291 | 47 | msgstr "" | ||
292 | 48 | " \n" | ||
293 | 49 | " -Invoice taxes: \n" | ||
294 | 50 | " legend:\n" | ||
295 | 51 | " TA(l) TaxAmount for line l\n" | ||
296 | 52 | " TBA(l) TaxBaseAmount for line l\n" | ||
297 | 53 | " TA(t) TaxAmount for tax t\n" | ||
298 | 54 | " TBA(t) TaxBaseAmount for tax t\n" | ||
299 | 55 | " \n" | ||
300 | 56 | " default behaviour: \n" | ||
301 | 57 | " openerp by default calculates taxes line by line as a function of line tax base amount \n" | ||
302 | 58 | " and then groups these amounts by tax.\n" | ||
303 | 59 | " TA(l) = f(TBA(l)\n" | ||
304 | 60 | " TA(t) = sum( round( TA(l) ) ) /sum on lines l to which tax t is applied\n" | ||
305 | 61 | " this module behaviour: \n" | ||
306 | 62 | " In Italy the correct way to compute taxes is to first compute the tax base amount TBA(t) \n" | ||
307 | 63 | " and the compute TA as a function of TBA(t)\n" | ||
308 | 64 | " TBA(t) = sum( TBA(t) ) /sum on lines l to which tax t is applied\n" | ||
309 | 65 | " TA(t) = f( TBA(t) )\n" | ||
310 | 66 | " the result difference is small but important\n" | ||
311 | 67 | "\n" | ||
312 | 68 | " " | ||
313 | 69 | |||
314 | 70 | #. module: account_invoice_tax_by_column | ||
315 | 71 | #: help:account.tax,line_precision:0 | ||
316 | 72 | msgid "Calculates floating point tax per line to simulate vertical calculation" | ||
317 | 73 | msgstr "Calculates floating point tax per line to simulate vertical calculation" | ||
318 | 74 | |||
319 | 75 | #. module: account_invoice_tax_by_column | ||
320 | 76 | #: field:account.tax,line_precision:0 | ||
321 | 77 | msgid "Rounding Precision" | ||
322 | 78 | msgstr "Precisione arrotondamento" | ||
323 | 79 | |||
324 | 80 | #. module: account_invoice_tax_by_column | ||
325 | 81 | #: model:ir.module.module,shortdesc:account_invoice_tax_by_column.module_meta_information | ||
326 | 82 | msgid "Account Invoice Tax - Computation By Column" | ||
327 | 83 | msgstr "Imposte fattura - Calcolo per colonna" | ||
328 | 84 | |||
329 | 85 | #. module: account_invoice_tax_by_column | ||
330 | 86 | #: model:ir.model,name:account_invoice_tax_by_column.model_account_tax | ||
331 | 87 | msgid "account.tax" | ||
332 | 88 | msgstr "account.tax" | ||
333 | 89 | |||
334 | 90 | #. module: account_invoice_tax_by_column | ||
335 | 91 | #: sql_constraint:account.tax:0 | ||
336 | 92 | msgid "The tax name must be unique!" | ||
337 | 93 | msgstr "Il nome della tasse deve essere unico" | ||
338 | 94 | |||
339 | 0 | 95 | ||
340 | === added file 'account_invoice_tax_by_column/invoice.py' | |||
341 | --- account_invoice_tax_by_column/invoice.py 1970-01-01 00:00:00 +0000 | |||
342 | +++ account_invoice_tax_by_column/invoice.py 2011-08-20 10:12:24 +0000 | |||
343 | @@ -0,0 +1,79 @@ | |||
344 | 1 | # -*- encoding: utf-8 -*- | ||
345 | 2 | ############################################################################## | ||
346 | 3 | # | ||
347 | 4 | # OpenERP, Open Source Management Solution | ||
348 | 5 | # Copyright (C) 2011 | ||
349 | 6 | # Associazione OpenERP Italia (<http://www.openerp-italia.org>) | ||
350 | 7 | # | ||
351 | 8 | # This program is free software: you can redistribute it and/or modify | ||
352 | 9 | # it under the terms of the GNU Affero General Public License as | ||
353 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
354 | 11 | # License, or (at your option) any later version. | ||
355 | 12 | # | ||
356 | 13 | # This program is distributed in the hope that it will be useful, | ||
357 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
358 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
359 | 16 | # GNU Affero General Public License for more details. | ||
360 | 17 | # | ||
361 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
362 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
363 | 20 | # | ||
364 | 21 | ############################################################################## | ||
365 | 22 | import time | ||
366 | 23 | from osv import fields, osv | ||
367 | 24 | |||
368 | 25 | |||
369 | 26 | class account_invoice_tax(osv.osv): | ||
370 | 27 | _inherit = "account.invoice.tax" | ||
371 | 28 | |||
372 | 29 | def compute(self, cr, uid, invoice_id, context=None): | ||
373 | 30 | tax_grouped = super(account_invoice_tax, self).compute(cr, uid, invoice_id, context) | ||
374 | 31 | total_base = 0 | ||
375 | 32 | total_tax = {} | ||
376 | 33 | total_amount_of_taxes_horizontal = 0 | ||
377 | 34 | number_deductible_account = 0 | ||
378 | 35 | cur_obj = self.pool.get('res.currency') | ||
379 | 36 | inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) | ||
380 | 37 | cur = inv.currency_id | ||
381 | 38 | for line in inv.invoice_line: | ||
382 | 39 | # workout of total amount of taxes | ||
383 | 40 | for tax in line.invoice_line_tax_id: | ||
384 | 41 | key = tax['amount'] | ||
385 | 42 | if not key in total_tax: | ||
386 | 43 | # Total_tax | ||
387 | 44 | total_tax[key] = [0] | ||
388 | 45 | total_tax[key][0] += (line.price_unit* (1-(line.discount or 0.0)/100.0)) * tax['amount'] | ||
389 | 46 | |||
390 | 47 | index = 0 | ||
391 | 48 | for t in tax_grouped.values(): | ||
392 | 49 | if inv.type in ('in_invoice') and t['base_code_id'] == False: | ||
393 | 50 | number_deductible_account += 1 | ||
394 | 51 | total_amount_of_taxes_horizontal += t['tax_amount'] | ||
395 | 52 | |||
396 | 53 | total_amount_of_taxes_vertical = 0 | ||
397 | 54 | # round the total amount of taxes | ||
398 | 55 | for t in total_tax.values(): | ||
399 | 56 | t[0] = cur_obj.round(cr, uid, cur, t[0]) | ||
400 | 57 | total_amount_of_taxes_vertical += t[0] | ||
401 | 58 | total_amount_of_taxes_vertical = cur_obj.round(cr, uid, cur, total_amount_of_taxes_vertical) | ||
402 | 59 | total_amount_of_taxes_horizontal = cur_obj.round(cr, uid, cur, total_amount_of_taxes_horizontal) | ||
403 | 60 | if number_deductible_account != 0: | ||
404 | 61 | quotient = (total_amount_of_taxes_vertical - total_amount_of_taxes_horizontal) / number_deductible_account | ||
405 | 62 | quotient = cur_obj.round(cr, uid, cur, quotient) | ||
406 | 63 | remainder = (total_amount_of_taxes_vertical - total_amount_of_taxes_horizontal) - number_deductible_account * quotient | ||
407 | 64 | remainder = cur_obj.round(cr, uid, cur, remainder) | ||
408 | 65 | # change at least a deductible tax amount to to make coincide total amount of taxes | ||
409 | 66 | counter = 0 | ||
410 | 67 | if inv.type in ('in_invoice') and total_amount_of_taxes_vertical != total_amount_of_taxes_horizontal: | ||
411 | 68 | for t in tax_grouped.values(): | ||
412 | 69 | if t['base_code_id'] == False: | ||
413 | 70 | counter += 1 | ||
414 | 71 | t['tax_amount'] = t['tax_amount'] + quotient | ||
415 | 72 | t['amount'] = t['amount'] + quotient | ||
416 | 73 | if counter == number_deductible_account: | ||
417 | 74 | t['tax_amount'] = t['tax_amount'] + remainder | ||
418 | 75 | t['amount'] = t['amount'] + remainder | ||
419 | 76 | return tax_grouped | ||
420 | 77 | |||
421 | 78 | account_invoice_tax() | ||
422 | 79 | |||
423 | 0 | 80 | ||
424 | === added directory 'account_invoice_tax_by_column/tests' | |||
425 | === added file 'account_invoice_tax_by_column/tests/tests.txt' | |||
426 | --- account_invoice_tax_by_column/tests/tests.txt 1970-01-01 00:00:00 +0000 | |||
427 | +++ account_invoice_tax_by_column/tests/tests.txt 2011-08-20 10:12:24 +0000 | |||
428 | @@ -0,0 +1,107 @@ | |||
429 | 1 | Manual tests on tax calculation (should write automated tests) | ||
430 | 2 | |||
431 | 3 | 1) arrotondamento IVA ordinaria 20% | ||
432 | 4 | fattura VENDJ/2011/016 | ||
433 | 5 | IVA20 12,29 2,46 | ||
434 | 6 | IVA20 12,29 2,46 | ||
435 | 7 | IVA20 12,29 2,46 | ||
436 | 8 | IVA10 | ||
437 | 9 | |||
438 | 10 | IVA10 | ||
439 | 11 | |||
440 | 12 | IVA10 | ||
441 | 13 | |||
442 | 14 | IVA10 | ||
443 | 15 | |||
444 | 16 | IVA10 | ||
445 | 17 | |||
446 | 18 | IVA10 | ||
447 | 19 | |||
448 | 20 | IVA10 | ||
449 | 21 | |||
450 | 22 | IVA10 | ||
451 | 23 | |||
452 | 24 | IVA10 | ||
453 | 25 | |||
454 | 26 | somma 36,87 7,38 | ||
455 | 27 | |||
456 | 28 | |||
457 | 29 | |||
458 | 30 | IVA10 0 0 | ||
459 | 31 | IVA20 36,87 7,37 | ||
460 | 32 | |||
461 | 33 | |||
462 | 34 | |||
463 | 35 | |||
464 | 36 | 36,87 7,37 | ||
465 | 37 | L'IVA corretta è 7,37, e cioè il 20% del totale imponibile al 20% | ||
466 | 38 | |||
467 | 39 | 2) arrotondamento IVA ordinaria e agevolata 4% | ||
468 | 40 | fattura VENDJ/2011/018 | ||
469 | 41 | IVA4 12,33 0,49 | ||
470 | 42 | IVA20 12,29 2,46 | ||
471 | 43 | IVA20 12,29 2,46 | ||
472 | 44 | IVA20 12,29 2,46 | ||
473 | 45 | IVA4 12,33 0,49 | ||
474 | 46 | IVA4 12,33 0,49 | ||
475 | 47 | IVA20 12,29 2,46 | ||
476 | 48 | IVA20 12,29 2,46 | ||
477 | 49 | IVA20 12,29 2,46 | ||
478 | 50 | IVA20 | ||
479 | 51 | |||
480 | 52 | IVA20 | ||
481 | 53 | |||
482 | 54 | IVA20 | ||
483 | 55 | |||
484 | 56 | |||
485 | 57 | |||
486 | 58 | |||
487 | 59 | somma 110,73 16,23 | ||
488 | 60 | |||
489 | 61 | |||
490 | 62 | |||
491 | 63 | IVA4 36,99 1,48 | ||
492 | 64 | IVA20 73,74 14,75 | ||
493 | 65 | |||
494 | 66 | |||
495 | 67 | |||
496 | 68 | TOTALE IVA 110,73 16,23 | ||
497 | 69 | |||
498 | 70 | l'IVA viene correttamente ripartita fra IVA 4 ed IVA 20 | ||
499 | 71 | |||
500 | 72 | arrotondamento IVA ordinaria 20% ed agevolata 10% | ||
501 | 73 | |||
502 | 74 | fattura VENDJ/2011/019 | ||
503 | 75 | IVA20 12,29 2,46 | ||
504 | 76 | IVA20 12,29 2,46 | ||
505 | 77 | IVA20 12,29 2,46 | ||
506 | 78 | IVA10 10,56 1,06 | ||
507 | 79 | IVA10 10,56 1,06 | ||
508 | 80 | IVA10 10,56 1,06 | ||
509 | 81 | IVA10 | ||
510 | 82 | |||
511 | 83 | IVA10 | ||
512 | 84 | |||
513 | 85 | IVA10 | ||
514 | 86 | |||
515 | 87 | IVA10 | ||
516 | 88 | |||
517 | 89 | IVA10 | ||
518 | 90 | |||
519 | 91 | IVA10 | ||
520 | 92 | |||
521 | 93 | |||
522 | 94 | |||
523 | 95 | |||
524 | 96 | somma 68,55 10,56 | ||
525 | 97 | |||
526 | 98 | |||
527 | 99 | |||
528 | 100 | IVA10 31,68 3,17 | ||
529 | 101 | IVA20 36,87 7,37 | ||
530 | 102 | |||
531 | 103 | |||
532 | 104 | |||
533 | 105 | TOTALE IVA 68,55 10,54 | ||
534 | 106 | |||
535 | 107 | L'IVA viene correttamente calcolata ed indicata secondo le aliquote |
Non appena qualcuno conferma che il modulo 'l10n_it_ invoice_ tax' effettua correttamente il calcolo delle tasse sulle righe della fattura, possiamo approvare il merge sul repository ufficiale