Merge lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-6.1

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 235
Proposed branch: lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-6.1
Diff against target: 1439 lines (+499/-583)
13 files modified
l10n_it_vat_registries/AUTHORS.txt (+1/-1)
l10n_it_vat_registries/__init__.py (+3/-3)
l10n_it_vat_registries/__openerp__.py (+4/-4)
l10n_it_vat_registries/account.py (+10/-28)
l10n_it_vat_registries/account_view.xml (+8/-9)
l10n_it_vat_registries/invoice.py (+104/-306)
l10n_it_vat_registries/reports.xml (+15/-3)
l10n_it_vat_registries/templates/registro_iva_acquisti.mako (+114/-73)
l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako (+93/-46)
l10n_it_vat_registries/templates/registro_iva_vendite.mako (+94/-51)
l10n_it_vat_registries/wizard/__init__.py (+2/-2)
l10n_it_vat_registries/wizard/print_registro_iva.py (+45/-53)
l10n_it_vat_registries/wizard/print_registro_iva.xml (+6/-4)
To merge this branch: bzr merge lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified
Reviewer Review Type Date Requested Status
Sergio Corato (community) Approve
Review via email: mp+162367@code.launchpad.net
To post a comment you must log in.
232. By Lorenzo Battistini

[imp] journal domain

233. By Lorenzo Battistini

[add] on_type_changed

234. By Lorenzo Battistini

[add] back porting http://bazaar.launchpad.net/~elbati/openobject-italia/7-l10n_it_vat_registries_simplified/revision/231?remember=231&compare_revid=229

Revision history for this message
Sergio Corato (icsergio) wrote :

Non c'è nella 6.1 il campo supplier_invoice_number, si potrebbe aggiungere direttamente in questo modulo?
In account.py basterebbe:

class account_invoice(osv.osv):
    _inherit = "account.invoice"

    _columns = {
        'supplier_invoice_number': fields.char('Supplier invoice nr', size=16),
        }

review: Needs Fixing
235. By Lorenzo Battistini

[FIX] AttributeError: "Field 'supplier_invoice_number' does not exist in object 'browse_record(account.invoice, 1)'"

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Per ora uso il campo 'reference' che di solito è usato come numero fattura fornitore.

Revision history for this message
Sergio Corato (icsergio) wrote :

ah, ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_it_vat_registries/AUTHORS.txt'
--- l10n_it_vat_registries/AUTHORS.txt 2011-07-23 14:39:45 +0000
+++ l10n_it_vat_registries/AUTHORS.txt 2013-05-23 04:44:28 +0000
@@ -1,2 +1,2 @@
1Lorenzo Battistini <lorenzo.battistini@domsense.com>1Lorenzo Battistini <lorenzo.battistini@agilebg.com>
2Ingrid Barcaro2Ingrid Barcaro
33
=== modified file 'l10n_it_vat_registries/__init__.py'
--- l10n_it_vat_registries/__init__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/__init__.py 2013-05-23 04:44:28 +0000
@@ -1,7 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3# 3#
4# Copyright (C) 2011 Associazione OpenERP Italia4# Copyright (C) 2011-2013 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>). 5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
@@ -12,7 +12,7 @@
12# This program is distributed in the hope that it will be useful,12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.15# GNU Affero General Public License for more details.
16#16#
17# You should have received a copy of the GNU Affero General Public License17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -20,5 +20,5 @@
20##############################################################################20##############################################################################
2121
22import wizard22import wizard
23import invoice
23import account24import account
24import invoice
2525
=== modified file 'l10n_it_vat_registries/__openerp__.py'
--- l10n_it_vat_registries/__openerp__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/__openerp__.py 2013-05-23 04:44:28 +0000
@@ -1,7 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3# 3#
4# Copyright (C) 2011-2012 Associazione OpenERP Italia4# Copyright (C) 2011-2013 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>). 5# (<http://www.openerp-italia.org>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)7# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
@@ -14,7 +14,7 @@
14# This program is distributed in the hope that it will be useful,14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.17# GNU Affero General Public License for more details.
18#18#
19# You should have received a copy of the GNU Affero General Public License19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.20# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -28,13 +28,13 @@
28 'author': 'OpenERP Italian Community',28 'author': 'OpenERP Italian Community',
29 'website': 'http://www.openerp-italia.org',29 'website': 'http://www.openerp-italia.org',
30 'license': 'AGPL-3',30 'license': 'AGPL-3',
31 "depends" : ['report_webkit', 'l10n_it_account', 'l10n_it_partially_deductible_vat'],31 "depends" : ['report_webkit', 'l10n_it_base', 'l10n_it_fiscalcode', 'l10n_it_partially_deductible_vat'],
32 "init_xml" : [32 "init_xml" : [
33 ],33 ],
34 "update_xml" : [34 "update_xml" : [
35 'reports.xml',35 'reports.xml',
36 'wizard/print_registro_iva.xml',
36 'account_view.xml',37 'account_view.xml',
37 'wizard/print_registro_iva.xml',
38 ],38 ],
39 "demo_xml" : [],39 "demo_xml" : [],
40 "active": False,40 "active": False,
4141
=== modified file 'l10n_it_vat_registries/account.py'
--- l10n_it_vat_registries/account.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/account.py 2013-05-23 04:44:28 +0000
@@ -1,10 +1,8 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Copyright (C) 2011-2012 Associazione OpenERP Italia4# Copyright (C) 2013 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>).5# (<http://www.openerp-italia.org>).
6# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
7# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
8#6#
9# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as published8# it under the terms of the GNU Affero General Public License as published
@@ -21,28 +19,12 @@
21#19#
22##############################################################################20##############################################################################
2321
24from osv import fields, osv22from openerp.osv import fields, osv
25from tools.translate import _23from openerp.tools.translate import _
2624
2725class account_tax_code(osv.osv):
28class account_tax(osv.osv):26 _inherit = "account.tax.code"
2927
30 _inherit = 'account.tax'
31 _columns = {28 _columns = {
32 'exclude_from_registries': fields.boolean(29 'is_base': fields.boolean('Is base', help="This tax code is used for base amounts (field used by VAT registries)"),
33 'Exclude from VAT registries'),
34 'base_tax_ids': fields.one2many(
35 'account.tax', 'base_code_id', 'Base Taxes'), # serve ancora?
36 }30 }
37 _sql_constraints = [
38 ('name_uniq', 'UNIQUE(name)', 'The tax name must be unique!'),
39 ]
40
41 def get_account_tax(self, inv_tax):
42 if inv_tax.tax_code_id:
43 return self.get_account_tax_by_tax_code(inv_tax.tax_code_id)
44 if inv_tax.base_code_id:
45 return self.get_account_tax_by_base_code(inv_tax.base_code_id)
46 raise osv.except_osv(_('Error'),
47 _('No tax codes for invoice tax %s') % str(inv_tax.name))
48
4931
=== modified file 'l10n_it_vat_registries/account_view.xml'
--- l10n_it_vat_registries/account_view.xml 2011-08-19 13:08:24 +0000
+++ l10n_it_vat_registries/account_view.xml 2013-05-23 04:44:28 +0000
@@ -1,17 +1,16 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0"?>
2<openerp>2<openerp>
3 <data>3 <data>
44 <record id="view_tax_code_form" model="ir.ui.view">
5 <record id="view_tax_form" model="ir.ui.view">5 <field name="name">account.tax.code.form</field>
6 <field name="name">account.tax.form</field>6 <field name="model">account.tax.code</field>
7 <field name="model">account.tax</field>7 <field name="inherit_id" ref="account.view_tax_code_form"></field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="account.view_tax_form"></field>
10 <field name="arch" type="xml">8 <field name="arch" type="xml">
11 <field name="active" position="after">9 <field name="sign" position="after">
12 <field name="exclude_from_registries"/>10 <field name="is_base"/>
13 </field>11 </field>
14 </field>12 </field>
15 </record>13 </record>
16 </data>14 </data>
17</openerp>15</openerp>
16
1817
=== modified file 'l10n_it_vat_registries/invoice.py'
--- l10n_it_vat_registries/invoice.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/invoice.py 2013-05-23 04:44:28 +0000
@@ -1,8 +1,8 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Copyright (C) 2011 Associazione OpenERP Italia4# Copyright (C) 2011-2013 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>).5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published8# it under the terms of the GNU Affero General Public License as published
@@ -22,325 +22,123 @@
22import time22import time
23from report import report_sxw23from report import report_sxw
24from tools.translate import _24from tools.translate import _
25from decimal import *25import logging
26import netsvc26from datetime import datetime
27
28_logger = logging.getLogger(__name__)
2729
28class Parser(report_sxw.rml_parse):30class Parser(report_sxw.rml_parse):
2931
30 logger = netsvc.Logger()32 def _tax_amounts_by_code(self, move):
3133 res={}
32 def _get_partner_type(self, move_line):34 for move_line in move.line_id:
33 partner_type = ''35 if move_line.tax_code_id and move_line.tax_amount:
34 for line in move_line.move_id.line_id:36 if not res.get(move_line.tax_code_id.id):
35 if line.account_id.type == 'payable' or line.account_id.type == 'receivable':37 res[move_line.tax_code_id.id] = 0.0
36 if not partner_type:38 self.localcontext['used_tax_codes'][move_line.tax_code_id.id] = True
37 partner_type = line.account_id.type39 res[move_line.tax_code_id.id] += (move_line.tax_amount
38 elif partner_type != line.account_id.type:40 * self.localcontext['data']['tax_sign'])
39 raise Exception(41 return res
40 _('The move %s has different partner account type') % move_line.move_id.name)
41 return partner_type
42
43 def _move_total(self, move_line):
44 partner_type = self._get_partner_type(move_line)
45 total = 0.0
46 for line in move_line.move_id.line_id:
47 if line.account_id.type == partner_type:
48 total += (line.debit or line.credit)
49 return total
50
51 # Metto al tax code il segno dell'importo dell'imposta.
52 # Il tax code ha l'importo in valuta base, ma ha segno negativo per l'IVA a credito (da stampare positiva)
53 # e per le note di credito (da stampare negative)
54 def _get_amount_with_sign(self, tax_code_amount, amount):
55 return abs(tax_code_amount) * cmp(amount, 0)
56
57 def _is_refund(self, move_line):
58 if self._get_partner_type(move_line) == 'receivable' and move_line.debit > move_line.credit:
59 return True
60 if self._get_partner_type(move_line) == 'payable' and move_line.debit < move_line.credit:
61 return True
62
63 def _get_line_amount_with_sign(self, move_line):
64 if self._get_partner_type(move_line) == 'receivable':
65 return self._get_amount_with_sign(move_line.tax_amount, move_line.credit - move_line.debit)
66 if self._get_partner_type(move_line) == 'payable':
67 return self._get_amount_with_sign(move_line.tax_amount, move_line.debit - move_line.credit)
68
69 # in valuta base
70 def _get_invoice_amount_total(self, invoice):
71 total = 0.0
72 for inv_tax in invoice.tax_line:
73 total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base) \
74 + self._get_amount_with_sign(inv_tax.tax_amount, inv_tax.amount)
75 return total
76
77 # in valuta base
78 def _get_invoice_amount_untaxed(self, invoice):
79 total = 0.0
80 for inv_tax in invoice.tax_line:
81 total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base)
82 return total
8342
84 def _get_tax_lines(self, move):43 def _get_tax_lines(self, move):
85 res=[]44 res=[]
86 tax_obj = self.pool.get('account.tax')45 tax_code_obj=self.pool.get('account.tax.code')
87 cur_pool = self.pool.get('res.currency')
88 inv_pool = self.pool.get('account.invoice')
89 # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA46 # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA
90 index=047 index=0
91 totale_iva = 0.048 invoice = False
92 totale_iva_inded = 0.049 for move_line in move.line_id:
93 invoice_amount_total = 0.050 if move_line.invoice:
94 invoice_amount_untaxed = 0.051 if invoice and invoice.id != move_line.invoice.id:
95 related_invoices = []52 raise Exception(_("Move %s contains different invoices") % move.name)
9653 invoice = move_line.invoice
97 ''' riusciamo a essere sempre indipendenti dalle fatture?54 amounts_by_code = self._tax_amounts_by_code(move)
98 # se c'è l'oggetto fattura, utilizzo il calcolo su fattura55 for tax_code_id in amounts_by_code:
99 for move_line in move.line_id:56 tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
100 if move_line.invoice and move_line.invoice.id not in related_invoices:57 tax_item = {
101 related_invoices.append(move_line.invoice.id)58 'tax_code_name': tax_code.name,
102 '''59 'amount': amounts_by_code[tax_code_id],
10360 'index': index,
104 if related_invoices:61 'invoice_date': (invoice and invoice.date_invoice
105 for invoice_id in related_invoices:62 or move.date or ''),
106 return self._get_tax_lines_by_invoice(inv_pool.browse(self.cr, self.uid, invoice_id))63 'reference': (invoice and invoice.reference or '')
10764 }
108 for move_line in move.line_id:65 res.append(tax_item)
109 tax_item = {}66 index += 1
110 if move_line.tax_code_id and move_line.tax_code_id.tax_ids:67 return res
111 # Nel wizard ho già controllato che le eventuali diverse68
112 # imposte abbiamo la stessa aliquota.69 def build_parent_tax_codes(self, tax_code):
113 # Le diverse imposte devono comunque usare gli stessi tax code70 res={}
114 main_tax = tax_obj.get_main_tax(move_line.tax_code_id.tax_ids[0])71 if tax_code.parent_id and tax_code.parent_id.parent_id:
115 if main_tax.exclude_from_registries:72 res[tax_code.parent_id.id]=True
116 self.logger.notifyChannel("l10n_it_vat_registries", netsvc.LOG_INFO,73 res.update(self.build_parent_tax_codes(tax_code.parent_id))
117 _('The tax %s is excluded from registries') % main_tax.name)74 return res
118 continue75
119 # sommo gli imponibili relativi all'imposta corrente76 def _compute_totals(self, tax_code_ids):
120 base_amount = 0.0
121 for line in move_line.move_id.line_id:
122 if line.tax_code_id.id == main_tax.base_code_id.id:
123 base_amount += self._get_line_amount_with_sign(line)
124 # calcolo % indetraibile
125 actual_tax_amount = base_amount * main_tax.amount
126 actual_tax_amount = cur_pool.round(
127 self.cr, self.uid, move.company_id.currency_id,
128 actual_tax_amount)
129 non_deductible = 0.0
130 if abs(actual_tax_amount) != abs(move_line.tax_amount):
131 non_deductible = 100
132 if move_line.tax_amount:
133 non_deductible = 100 - abs((
134 move_line.tax_amount * 100.0) / actual_tax_amount)
135 non_deductible = cur_pool.round(
136 self.cr, self.uid, move.company_id.currency_id,
137 non_deductible)
138 # calcolo il totale dell'operazione
139 invoice_amount_total = self._move_total(move_line)
140 if self._is_refund(move_line):
141 invoice_amount_total = - invoice_amount_total
142 str_non_deductible = str(non_deductible).split('.')[0]
143 tax_item = {
144 'tax_percentage': main_tax.amount and str(
145 main_tax.amount * 100).split('.')[0] or
146 move_line.tax_code_id.name,
147 'tax_code_name': move_line.tax_code_id.name,
148 'base': base_amount,
149 'amount': actual_tax_amount,
150 'non_deductible': str_non_deductible != '0' and
151 str_non_deductible or '',
152 'index': index,
153 'amount_total': invoice_amount_total,
154 }
155 res.append(tax_item)
156 iva = cur_pool.round(
157 self.cr, self.uid, move.company_id.currency_id,
158 (actual_tax_amount * (100 - non_deductible) * 0.01))
159 iva_inded = cur_pool.round(
160 self.cr, self.uid, move.company_id.currency_id,
161 (actual_tax_amount * non_deductible * 0.01))
162 tax_difference= (iva + iva_inded) - actual_tax_amount
163 # se risulta un'eccedenza, la tolgo dalla parte detraibile
164 if tax_difference > 0:
165 iva = iva - tax_difference
166 # se risulta una mancanza, la aggiungo alla parte indetraibile
167 elif tax_difference < 0:
168 iva_inded = iva_inded + tax_difference
169 totale_iva += iva
170 invoice_amount_untaxed += base_amount
171 totale_iva_inded += iva_inded
172 index += 1
173
174 if tax_item:
175 if tax_item['tax_code_name'] not in self.localcontext[
176 'tax_codes']:
177 self.localcontext['tax_codes'][tax_item[
178 'tax_code_name']] = {
179 'base': tax_item['base'],
180 'amount': tax_item['amount'],
181 }
182 else:
183 self.localcontext['tax_codes'][tax_item[
184 'tax_code_name']]['base'] += tax_item['base']
185 self.localcontext['tax_codes'][tax_item[
186 'tax_code_name']]['amount'] += tax_item['amount']
187
188 self.localcontext['totali'][
189 'totale_operazioni'] += invoice_amount_total
190 self.localcontext['totali'][
191 'totale_imponibili'] += invoice_amount_untaxed
192 self.localcontext['totali']['totale_iva'] += totale_iva
193 self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
194
195 return res
196
197 def _get_tax_lines_by_invoice(self, invoice):
198 res=[]77 res=[]
199 tax_obj = self.pool.get('account.tax')78 res_dict={}
200 # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA79 tax_code_obj = self.pool.get('account.tax.code')
201 index = 080 for period_id in self.localcontext['data']['period_ids']:
202 totale_iva = 0.081 for tax_code in tax_code_obj.browse(self.cr, self.uid,
203 totale_iva_inded = 0.082 tax_code_ids, context={
204 invoice_amount_total = 0.083 'period_id': period_id,
205 invoice_amount_untaxed = 0.084 }):
206 for inv_tax in invoice.tax_line:85 if not res_dict.get(tax_code.id):
207 tax_item = {}86 res_dict[tax_code.id] = 0.0
208 if inv_tax.base_code_id and inv_tax.tax_code_id:87 res_dict[tax_code.id] += (tax_code.sum_period
209 account_tax = tax_obj.get_account_tax(inv_tax)88 * self.localcontext['data']['tax_sign'])
210 if account_tax.exclude_from_registries:89 for tax_code_id in res_dict:
211 self.logger.notifyChannel("l10n_it_vat_registries",90 tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
212 netsvc.LOG_INFO, _(91 if res_dict[tax_code_id]:
213 'The tax %s is excluded from registries')92 res.append((tax_code.name,res_dict[tax_code_id],tax_code.is_base))
214 % account_tax.name)
215 continue
216 account_tax_amount = account_tax.amount
217 invoice_amount_total = self._get_invoice_amount_total(invoice)
218 invoice_amount_untaxed = self._get_invoice_amount_untaxed(
219 invoice)
220 amount = self._get_amount_with_sign(inv_tax.tax_amount,
221 inv_tax.amount)
222 base = self._get_amount_with_sign(inv_tax.base_amount,
223 inv_tax.base)
224 # calcolo le note di credito con segno invertito
225 if invoice.type in ('in_refund', 'out_refund'):
226 amount = -amount
227 base = -base
228 invoice_amount_untaxed = -invoice_amount_untaxed
229 invoice_amount_total = -invoice_amount_total
230 tax_item = {
231 'tax_percentage': account_tax_amount and str(
232 account_tax_amount * 100).split('.')[0] or
233 inv_tax.tax_code_id.name,
234 'base': base,
235 'amount': amount, # in valuta base
236 'non_deductible': 0.0,
237 'index': index,
238 'amount_total': invoice_amount_total,
239 }
240 res.append(tax_item)
241 totale_iva += amount
242 index += 1
243 # Se non c'è il tax code imponibile, cerco la tassa relativa alla parte non deducibile
244 elif inv_tax.tax_code_id:
245 tax = tax_obj.get_main_tax(tax_obj.get_account_tax(inv_tax))
246 if tax.exclude_from_registries:
247 self.logger.notifyChannel("l10n_it_vat_registries",
248 netsvc.LOG_INFO,
249 _('The tax %s is excluded from registries') % tax.name)
250 continue
251 for inv_tax_2 in invoice.tax_line:
252 if inv_tax_2.base_code_id and not inv_tax_2.tax_code_id:
253 base_tax = tax_obj.get_main_tax(
254 tax_obj.get_account_tax(inv_tax_2))
255 # Se hanno la stessa tassa
256 if base_tax.id == tax.id:
257 # Uso il valore assoluto perchè riferendosi
258 # alla stessa imposta non ci possono essere
259 # segni differenti
260 non_deductible = (abs(inv_tax_2.base_amount) /
261 (abs(inv_tax.base_amount) + abs(
262 inv_tax_2.base_amount)) * 100)
263 invoice_amount_total = \
264 self._get_invoice_amount_total(invoice)
265 invoice_amount_untaxed = \
266 self._get_invoice_amount_untaxed(invoice)
267 amount = self._get_amount_with_sign(
268 inv_tax.tax_amount, inv_tax.amount)
269 base = self._get_amount_with_sign(
270 inv_tax.base_amount, inv_tax.base)
271 amount2 = self._get_amount_with_sign(
272 inv_tax_2.tax_amount, inv_tax_2.amount)
273 base2 = self._get_amount_with_sign(
274 inv_tax_2.base_amount, inv_tax_2.base)
275 # calcolo le note di credito con segno invertito
276 if invoice.type in ('in_refund', 'out_refund'):
277 amount = -amount
278 base = -base
279 amount2 = -amount2
280 base2 = -base2
281 invoice_amount_untaxed = \
282 -invoice_amount_untaxed
283 invoice_amount_total = -invoice_amount_total
284 tax_item = {
285 'tax_percentage': base_tax.amount and str(
286 base_tax.amount * 100).split('.')[0] or
287 inv_tax.tax_code_id.name,
288 'base': base + base2,
289 'amount': amount + amount2,
290 'non_deductible': non_deductible and str(
291 non_deductible).split('.')[0] or '',
292 'index': index,
293 'amount_total': invoice_amount_total,
294 }
295 res.append(tax_item)
296 totale_iva += amount
297 totale_iva_inded += amount2
298 index += 1
299 break
300 elif not inv_tax.tax_code_id and not inv_tax.base_code_id:
301 self.logger.notifyChannel("l10n_it_vat_registries",
302 netsvc.LOG_INFO,
303 _('The tax %s has no tax codes') % inv_tax.name)
304 continue
305 if tax_item:
306 if tax_item['tax_percentage'] not in self.localcontext[
307 'tax_codes']:
308 self.localcontext['tax_codes'][tax_item[
309 'tax_percentage']] = {
310 'base': tax_item['base'],
311 'amount': tax_item['amount'],
312 }
313 else:
314 self.localcontext['tax_codes'][tax_item[
315 'tax_percentage']]['base'] += tax_item['base']
316 self.localcontext['tax_codes'][tax_item[
317 'tax_percentage']]['amount'] += tax_item['amount']
318
319 self.localcontext['totali'][
320 'totale_operazioni'] += invoice_amount_total
321 self.localcontext['totali'][
322 'totale_imponibili'] += invoice_amount_untaxed
323# da analizzare self.totale_variazioni += invoice.amount_total
324 self.localcontext['totali']['totale_iva'] += totale_iva
325 self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
326
327 return res93 return res
94
95 def _get_tax_codes(self):
96 return self._compute_totals(self.localcontext['used_tax_codes'].keys())
97
98 def _get_tax_codes_totals(self):
99 parent_codes = {}
100 tax_code_obj = self.pool.get('account.tax.code')
101 for tax_code in tax_code_obj.browse(self.cr, self.uid,
102 self.localcontext['used_tax_codes'].keys()):
103 parent_codes.update(self.build_parent_tax_codes(tax_code))
104 return self._compute_totals(parent_codes.keys())
105
106 def _get_start_date(self):
107 period_obj = self.pool.get('account.period')
108 start_date = False
109 for period in period_obj.browse(self.cr,self.uid,
110 self.localcontext['data']['period_ids']):
111 period_start = datetime.strptime(period.date_start, '%Y-%m-%d')
112 if not start_date or start_date > period_start:
113 start_date = period_start
114 return start_date.strftime('%Y-%m-%d')
115
116 def _get_end_date(self):
117 period_obj = self.pool.get('account.period')
118 end_date = False
119 for period in period_obj.browse(self.cr,self.uid,
120 self.localcontext['data']['period_ids']):
121 period_end = datetime.strptime(period.date_stop, '%Y-%m-%d')
122 if not end_date or end_date < period_end:
123 end_date = period_end
124 return end_date.strftime('%Y-%m-%d')
328125
329 def __init__(self, cr, uid, name, context):126 def __init__(self, cr, uid, name, context):
330 super(Parser, self).__init__(cr, uid, name, context)127 super(Parser, self).__init__(cr, uid, name, context)
331 self.localcontext.update({128 self.localcontext.update({
332 'time': time,
333 'tax_lines': self._get_tax_lines,129 'tax_lines': self._get_tax_lines,
334 'totali': {130 'tax_codes': self._get_tax_codes,
335 'totale_operazioni': 0.0,131 'tax_codes_totals': self._get_tax_codes_totals,
336 'totale_imponibili': 0.0,132 'used_tax_codes': {},
337 'totale_variazioni': 0.0,133 'start_date': self._get_start_date,
338 'totale_iva': 0.0,134 'end_date': self._get_end_date,
339 'totale_iva_inded': 0.0,
340 },
341 'tax_codes': {},
342 })135 })
343136
137 def set_context(self, objects, data, ids, report_type=None):
138 self.localcontext.update({
139 'fiscal_page_base': data.get('fiscal_page_base'),
140 })
141 return super(Parser, self).set_context(objects, data, ids, report_type=report_type)
344142
345report_sxw.report_sxw('report.registro_iva_vendite',143report_sxw.report_sxw('report.registro_iva_vendite',
346 'registro_iva_vendite',144 'registro_iva_vendite',
347145
=== modified file 'l10n_it_vat_registries/reports.xml'
--- l10n_it_vat_registries/reports.xml 2012-08-16 08:50:00 +0000
+++ l10n_it_vat_registries/reports.xml 2013-05-23 04:44:28 +0000
@@ -57,7 +57,11 @@
57 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];57 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
58 for(var i in x) {58 for(var i in x) {
59 var y = document.getElementsByClassName(x[i]);59 var y = document.getElementsByClassName(x[i]);
60 for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];60 for(var j=0; j<y.length; ++j) {
61 if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
62 else{y[j].textContent = vars[x[i]];}
63 }
64
61 }65 }
62 }66 }
63 </script>67 </script>
@@ -135,7 +139,11 @@
135 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];139 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
136 for(var i in x) {140 for(var i in x) {
137 var y = document.getElementsByClassName(x[i]);141 var y = document.getElementsByClassName(x[i]);
138 for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];142 for(var j=0; j<y.length; ++j) {
143 if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
144 else{y[j].textContent = vars[x[i]];}
145 }
146
139 }147 }
140 }148 }
141 </script>149 </script>
@@ -213,7 +221,11 @@
213 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];221 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
214 for(var i in x) {222 for(var i in x) {
215 var y = document.getElementsByClassName(x[i]);223 var y = document.getElementsByClassName(x[i]);
216 for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];224 for(var j=0; j<y.length; ++j) {
225 if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
226 else{y[j].textContent = vars[x[i]];}
227 }
228
217 }229 }
218 }230 }
219 </script>231 </script>
220232
=== modified file 'l10n_it_vat_registries/templates/registro_iva_acquisti.mako'
--- l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2013-05-23 04:44:28 +0000
@@ -19,20 +19,19 @@
19<body>19<body>
20 <h2>Fatture Ricevute</h2>20 <h2>Fatture Ricevute</h2>
21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
22 <table style="width:100%;" cellspacing="0">22 <table style="width:100%; font-size: small;" cellspacing="0">
23 <thead>23 <thead>
24 <tr>24 <tr>
25 <th class="left_without_line">Data registrazione</th>25 <th class="left_without_line">Data registrazione</th>
26 <th class="left_without_line">Numero</th>26 <th class="left_without_line">Numero</th>
27 <th class="left_without_line">Ragione sociale</th>27 <th class="left_without_line">Ragione sociale</th>
28 <th class="left_without_line">Numero registrazione</th>
28 <th class="left_without_line">Numero fattura</th>29 <th class="left_without_line">Numero fattura</th>
29 <th class="left_without_line">Data fattura</th>30 <th class="left_without_line">Data fattura</th>
30 <th class="left_without_line">Causale</th>31 <th class="left_without_line">Sezionale</th>
31 <th class="right_without_line">Totale fattura</th>32 <th class="right_without_line">Totale fattura</th>
32 <th class="right_without_line">Imponibile</th>
33 <th class="right_without_line">% IVA</th>
34 <th class="right_without_line">Imposta</th>33 <th class="right_without_line">Imposta</th>
35 <th class="right_without_line">% inded.</th>34 <th class="right_without_line">Importo</th>
36 <th></th>35 <th></th>
37 </tr>36 </tr>
38 </thead>37 </thead>
@@ -63,7 +62,7 @@
63 </td><td class="left_without_line">62 </td><td class="left_without_line">
64 %endif63 %endif
65 %if line['index']==0:64 %if line['index']==0:
66 ${object.partner_id.name or ''| entity}65 ${object.partner_id.name or ''| entity}
67 %endif66 %endif
68 %if line['index']==0:67 %if line['index']==0:
69 </td><td class="left_with_line">68 </td><td class="left_with_line">
@@ -79,19 +78,23 @@
79 </td><td class="left_without_line">78 </td><td class="left_without_line">
80 %endif79 %endif
81 %if line['index']==0:80 %if line['index']==0:
82 ${ formatLang(object.date,date=True) or '' | entity}81 ${ line['reference'] or '' | entity}
83 %endif82 %endif
84 %if line['index']==0:83 %if line['index']==0:
85 </td><td class="left_with_line">84 </td><td class="left_with_line">
86 %else:85 %else:
87 </td><td class="left_without_line">86 </td><td class="left_without_line">
88 %endif87 %endif
89 %if line['index']==0:88 %if line['index']==0:
90 %if line['amount_total'] >= 0:89 ${ formatLang(line['invoice_date'],date=True) or '' | entity}
91 Fattura90 %endif
92 %else:91 %if line['index']==0:
93 Nota di credito92 </td><td class="left_with_line">
94 %endif93 %else:
94 </td><td class="left_without_line">
95 %endif
96 %if line['index']==0:
97 ${object.journal_id.name or ''| entity}
95 %endif98 %endif
96 %if line['index']==0:99 %if line['index']==0:
97 </td><td class="right_with_line">100 </td><td class="right_with_line">
@@ -99,34 +102,19 @@
99 </td><td class="right_without_line">102 </td><td class="right_without_line">
100 %endif103 %endif
101 %if line['index']==0:104 %if line['index']==0:
102 ${ formatLang(line['amount_total']) | entity}105 ${ formatLang(object.amount) | entity}
103 %endif106 %endif
104 </td>107 </td>
105 %if line['index']==0:108 %if line['index']==0:
106 <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>109 <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
107 %else:110 %else:
108 <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>111 <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
109 %endif112 %endif
110 %if line['index']==0:113 %if line['index']==0:
111 <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>114 <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
112 %else:115 %else:
113 <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>116 <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
114 %endif117 %endif
115 %if line['index']==0:
116 <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
117 %else:
118 <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
119 %endif
120 %if line['index']==0:
121 <td class="right_with_line">
122 %else:
123 <td class="right_without_line">
124 %endif
125 %if line['non_deductible']:
126 ${ line['non_deductible'] | entity} %
127 %endif
128 </td>
129 <td></td>
130 </tr>118 </tr>
131 %endfor119 %endfor
132 %endfor120 %endfor
@@ -134,34 +122,87 @@
134 </table>122 </table>
135 <div style="page-break-inside: avoid;">123 <div style="page-break-inside: avoid;">
136 <br/>124 <br/>
125 <% tax_code_list = tax_codes() %>
126 <% tax_code_totals_list = tax_codes_totals() %>
137 <table style="width:100%; " border="1">127 <table style="width:100%; " border="1">
138 <tr style="border-style:ridge;border-width:5px">128 <tr style="border-style:ridge;border-width:5px">
139 <td colspan="4" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>129 <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
140 </tr>130 </tr>
141 <tr>131 <tr>
142 <td rowspan="2" style="vertical-align:text-top;padding:10">132 <td colspan="2" style="vertical-align:text-top;padding:10">
143 <table style="width:100%;">133 <h3>Dettaglio</h3>
144 <tr>134 <table style="width:100%;">
145 <th style="text-align:left">Descrizione</th>135 <tr>
146 <th style="text-align:right">Imponibile</th>136 <th style="text-align:left">Descrizione</th>
147 <th style="text-align:right">Imposta</th>137 <th style="text-align:right">Importo</th>
148 </tr>138 </tr>
149 %for tax_code in tax_codes :139 %for tax_code_tuple in tax_code_list :
150 <tr>140 % if not tax_code_tuple[2]:
151 <td>${tax_code|entity}141 <tr>
152 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}142 <td>${tax_code_tuple[0]|entity}
153 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}143 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
154 </td>144 </td>
155 </tr>145 </tr>
156 %endfor146 %endif
157 </table>147 %endfor
158 </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>148 </table>
159 <td colspan="2" style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>149 </td>
160 </tr>150 <td style="vertical-align:text-top;padding:10">
161 <tr>151 <h3>Totali</h3>
162 <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>152 <table style="width:100%;">
163 <td style="padding:10">Totale IVA Detraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>153 <tr>
164 <td style="padding:10">Totale IVA Indetraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva_inded'])|entity}</strong></p><br/></td>154 <th style="text-align:left">Descrizione</th>
155 <th style="text-align:right">Importo</th>
156 </tr>
157 %for tax_code_tuple in tax_code_totals_list :
158 % if not tax_code_tuple[2]:
159 <tr>
160 <td>${tax_code_tuple[0]|entity}
161 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
162 </td>
163 </tr>
164 %endif
165 %endfor
166 </table>
167 </td>
168 </tr>
169 <tr>
170 <td colspan="2" style="vertical-align:text-top;padding:10">
171 <h3>Dettaglio imponibili</h3>
172 <table style="width:100%;">
173 <tr>
174 <th style="text-align:left">Descrizione</th>
175 <th style="text-align:right">Importo</th>
176 </tr>
177 %for tax_code_tuple in tax_code_list :
178 % if tax_code_tuple[2]:
179 <tr>
180 <td>${tax_code_tuple[0]|entity}
181 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
182 </td>
183 </tr>
184 %endif
185 %endfor
186 </table>
187 </td>
188 <td style="vertical-align:text-top;padding:10">
189 <h3>Totali imponibili</h3>
190 <table style="width:100%;">
191 <tr>
192 <th style="text-align:left">Descrizione</th>
193 <th style="text-align:right">Importo</th>
194 </tr>
195 %for tax_code_tuple in tax_code_totals_list :
196 % if tax_code_tuple[2]:
197 <tr>
198 <td>${tax_code_tuple[0]|entity}
199 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
200 </td>
201 </tr>
202 %endif
203 %endfor
204 </table>
205 </td>
165 </tr>206 </tr>
166 </table>207 </table>
167 </div>208 </div>
168209
=== modified file 'l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako'
--- l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2013-05-23 04:44:28 +0000
@@ -19,16 +19,15 @@
19<body>19<body>
20 <h2>Corrispettivi</h2>20 <h2>Corrispettivi</h2>
21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
22 <table style="width:100%;" cellspacing="0">22 <table style="width:100%; font-size: small;" cellspacing="0">
23 <thead>23 <thead>
24 <tr>24 <tr>
25 <th class="left_without_line">Numero</th>25 <th class="left_without_line">Numero</th>
26 <th class="left_without_line">Data registrazione</th>26 <th class="left_without_line">Data registrazione</th>
27 <th class="left_without_line">Causale</th>27 <th class="left_without_line">Sezionale</th>
28 <th class="right_without_line">Importo totale</th>28 <th class="right_without_line">Importo totale</th>
29 <th class="right_without_line">Imponibile</th>
30 <th class="right_without_line">% IVA</th>
31 <th class="right_without_line">Imposta</th>29 <th class="right_without_line">Imposta</th>
30 <th class="right_without_line">Importo</th>
32 <th></th>31 <th></th>
33 </tr>32 </tr>
34 </thead>33 </thead>
@@ -59,7 +58,7 @@
59 </td><td class="left_without_line">58 </td><td class="left_without_line">
60 %endif59 %endif
61 %if line['index']==0:60 %if line['index']==0:
62 Corrispettivi61 ${object.journal_id.name or ''| entity}
63 %endif62 %endif
64 %if line['index']==0:63 %if line['index']==0:
65 </td><td class="right_with_line">64 </td><td class="right_with_line">
@@ -67,25 +66,19 @@
67 </td><td class="right_without_line">66 </td><td class="right_without_line">
68 %endif67 %endif
69 %if line['index']==0:68 %if line['index']==0:
70 ${ formatLang(line['amount_total']) | entity}69 ${ formatLang(object.amount) | entity}
71 %endif70 %endif
72 </td>71 </td>
73 %if line['index']==0:72 %if line['index']==0:
74 <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>73 <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
75 %else:74 %else:
76 <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>75 <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
77 %endif76 %endif
78 %if line['index']==0:77 %if line['index']==0:
79 <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>78 <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
80 %else:79 %else:
81 <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>80 <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
82 %endif81 %endif
83 %if line['index']==0:
84 <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
85 %else:
86 <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
87 %endif
88 <td></td>
89 </tr>82 </tr>
90 %endfor83 %endfor
91 %endfor84 %endfor
@@ -93,33 +86,87 @@
93 </table>86 </table>
94 <div style="page-break-inside: avoid;">87 <div style="page-break-inside: avoid;">
95 <br/>88 <br/>
89 <% tax_code_list = tax_codes() %>
90 <% tax_code_totals_list = tax_codes_totals() %>
96 <table style="width:100%; " border="1">91 <table style="width:100%; " border="1">
97 <tr style="border-style:ridge;border-width:5px">92 <tr style="border-style:ridge;border-width:5px">
98 <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>93 <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
99 </tr>94 </tr>
100 <tr>95 <tr>
101 <td rowspan="2" style="vertical-align:text-top;padding:10">96 <td colspan="2" style="vertical-align:text-top;padding:10">
102 <table style="width:100%;">97 <h3>Dettaglio</h3>
103 <tr>98 <table style="width:100%;">
104 <th style="text-align:left">Descrizione</th>99 <tr>
105 <th style="text-align:right">Imponibile</th>100 <th style="text-align:left">Descrizione</th>
106 <th style="text-align:right">Imposta</th>101 <th style="text-align:right">Importo</th>
107 </tr>102 </tr>
108 %for tax_code in tax_codes :103 %for tax_code_tuple in tax_code_list :
109 <tr>104 % if not tax_code_tuple[2]:
110 <td>${tax_code|entity}105 <tr>
111 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}106 <td>${tax_code_tuple[0]|entity}
112 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}107 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
113 </td>108 </td>
114 </tr>109 </tr>
115 %endfor110 %endif
116 </table>111 %endfor
117 </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>112 </table>
118 <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>113 </td>
119 </tr>114 <td style="vertical-align:text-top;padding:10">
120 <tr>115 <h3>Totali</h3>
121 <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>116 <table style="width:100%;">
122 <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>117 <tr>
118 <th style="text-align:left">Descrizione</th>
119 <th style="text-align:right">Importo</th>
120 </tr>
121 %for tax_code_tuple in tax_code_totals_list :
122 % if not tax_code_tuple[2]:
123 <tr>
124 <td>${tax_code_tuple[0]|entity}
125 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
126 </td>
127 </tr>
128 %endif
129 %endfor
130 </table>
131 </td>
132 </tr>
133 <tr>
134 <td colspan="2" style="vertical-align:text-top;padding:10">
135 <h3>Dettaglio imponibili</h3>
136 <table style="width:100%;">
137 <tr>
138 <th style="text-align:left">Descrizione</th>
139 <th style="text-align:right">Importo</th>
140 </tr>
141 %for tax_code_tuple in tax_code_list :
142 % if tax_code_tuple[2]:
143 <tr>
144 <td>${tax_code_tuple[0]|entity}
145 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
146 </td>
147 </tr>
148 %endif
149 %endfor
150 </table>
151 </td>
152 <td style="vertical-align:text-top;padding:10">
153 <h3>Totali imponibili</h3>
154 <table style="width:100%;">
155 <tr>
156 <th style="text-align:left">Descrizione</th>
157 <th style="text-align:right">Importo</th>
158 </tr>
159 %for tax_code_tuple in tax_code_totals_list :
160 % if tax_code_tuple[2]:
161 <tr>
162 <td>${tax_code_tuple[0]|entity}
163 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
164 </td>
165 </tr>
166 %endif
167 %endfor
168 </table>
169 </td>
123 </tr>170 </tr>
124 </table>171 </table>
125 </div>172 </div>
126173
=== modified file 'l10n_it_vat_registries/templates/registro_iva_vendite.mako'
--- l10n_it_vat_registries/templates/registro_iva_vendite.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_vendite.mako 2013-05-23 04:44:28 +0000
@@ -19,7 +19,7 @@
19<body>19<body>
20 <h2>Fatture Emesse</h2>20 <h2>Fatture Emesse</h2>
21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>21 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
22 <table style="width:100%;" cellspacing="0">22 <table style="width:100%; font-size: small;" cellspacing="0">
23 <thead>23 <thead>
24 <tr>24 <tr>
25 <th class="left_without_line">Data registrazione</th>25 <th class="left_without_line">Data registrazione</th>
@@ -27,11 +27,10 @@
27 <th class="left_without_line">Ragione sociale</th>27 <th class="left_without_line">Ragione sociale</th>
28 <th class="left_without_line">Numero fattura</th>28 <th class="left_without_line">Numero fattura</th>
29 <th class="left_without_line">Data fattura</th>29 <th class="left_without_line">Data fattura</th>
30 <th class="left_without_line">Causale</th>30 <th class="left_without_line">Sezionale</th>
31 <th class="right_without_line">Totale fattura</th>31 <th class="right_without_line">Totale fattura</th>
32 <th class="right_without_line">Imponibile</th>
33 <th class="right_without_line">% IVA</th>
34 <th class="right_without_line">Imposta</th>32 <th class="right_without_line">Imposta</th>
33 <th class="right_without_line">Importo</th>
35 <th></th>34 <th></th>
36 </tr>35 </tr>
37 </thead>36 </thead>
@@ -78,7 +77,7 @@
78 </td><td class="left_without_line">77 </td><td class="left_without_line">
79 %endif78 %endif
80 %if line['index']==0:79 %if line['index']==0:
81 ${ formatLang(object.date,date=True) or '' | entity}80 ${ formatLang(line['invoice_date'],date=True) or '' | entity}
82 %endif81 %endif
83 %if line['index']==0:82 %if line['index']==0:
84 </td><td class="left_with_line">83 </td><td class="left_with_line">
@@ -86,11 +85,7 @@
86 </td><td class="left_without_line">85 </td><td class="left_without_line">
87 %endif86 %endif
88 %if line['index']==0:87 %if line['index']==0:
89 %if line['amount_total'] >= 0:88 ${object.journal_id.name or ''| entity}
90 Fattura
91 %else:
92 Nota di credito
93 %endif
94 %endif89 %endif
95 %if line['index']==0:90 %if line['index']==0:
96 </td><td class="right_with_line">91 </td><td class="right_with_line">
@@ -98,25 +93,19 @@
98 </td><td class="right_without_line">93 </td><td class="right_without_line">
99 %endif94 %endif
100 %if line['index']==0:95 %if line['index']==0:
101 ${ formatLang(line['amount_total']) | entity}96 ${ formatLang(object.amount) | entity}
102 %endif97 %endif
103 </td>98 </td>
104 %if line['index']==0:99 %if line['index']==0:
105 <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>100 <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
106 %else:101 %else:
107 <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>102 <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
108 %endif103 %endif
109 %if line['index']==0:104 %if line['index']==0:
110 <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>105 <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
111 %else:106 %else:
112 <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>107 <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
113 %endif108 %endif
114 %if line['index']==0:
115 <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
116 %else:
117 <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
118 %endif
119 <td></td>
120 </tr>109 </tr>
121 %endfor110 %endfor
122 %endfor111 %endfor
@@ -124,33 +113,87 @@
124 </table>113 </table>
125 <div style="page-break-inside: avoid;">114 <div style="page-break-inside: avoid;">
126 <br/>115 <br/>
116 <% tax_code_list = tax_codes() %>
117 <% tax_code_totals_list = tax_codes_totals() %>
127 <table style="width:100%; " border="1">118 <table style="width:100%; " border="1">
128 <tr style="border-style:ridge;border-width:5px">119 <tr style="border-style:ridge;border-width:5px">
129 <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>120 <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
130 </tr>121 </tr>
131 <tr>122 <tr>
132 <td rowspan="2" style="vertical-align:text-top;padding:10">123 <td colspan="2" style="vertical-align:text-top;padding:10">
133 <table style="width:100%;">124 <h3>Dettaglio</h3>
134 <tr>125 <table style="width:100%;">
135 <th style="text-align:left">Descrizione</th>126 <tr>
136 <th style="text-align:right">Imponibile</th>127 <th style="text-align:left">Descrizione</th>
137 <th style="text-align:right">Imposta</th>128 <th style="text-align:right">Importo</th>
138 </tr>129 </tr>
139 %for tax_code in tax_codes :130 %for tax_code_tuple in tax_code_list :
140 <tr>131 % if not tax_code_tuple[2]:
141 <td>${tax_code|entity}132 <tr>
142 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}133 <td>${tax_code_tuple[0]|entity}
143 </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}134 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
144 </td>135 </td>
145 </tr>136 </tr>
146 %endfor137 %endif
147 </table>138 %endfor
148 </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>139 </table>
149 <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>140 </td>
150 </tr>141 <td style="vertical-align:text-top;padding:10">
151 <tr>142 <h3>Totali</h3>
152 <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>143 <table style="width:100%;">
153 <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>144 <tr>
145 <th style="text-align:left">Descrizione</th>
146 <th style="text-align:right">Importo</th>
147 </tr>
148 %for tax_code_tuple in tax_code_totals_list :
149 % if not tax_code_tuple[2]:
150 <tr>
151 <td>${tax_code_tuple[0]|entity}
152 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
153 </td>
154 </tr>
155 %endif
156 %endfor
157 </table>
158 </td>
159 </tr>
160 <tr>
161 <td colspan="2" style="vertical-align:text-top;padding:10">
162 <h3>Dettaglio imponibili</h3>
163 <table style="width:100%;">
164 <tr>
165 <th style="text-align:left">Descrizione</th>
166 <th style="text-align:right">Importo</th>
167 </tr>
168 %for tax_code_tuple in tax_code_list :
169 % if tax_code_tuple[2]:
170 <tr>
171 <td>${tax_code_tuple[0]|entity}
172 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
173 </td>
174 </tr>
175 %endif
176 %endfor
177 </table>
178 </td>
179 <td style="vertical-align:text-top;padding:10">
180 <h3>Totali imponibili</h3>
181 <table style="width:100%;">
182 <tr>
183 <th style="text-align:left">Descrizione</th>
184 <th style="text-align:right">Importo</th>
185 </tr>
186 %for tax_code_tuple in tax_code_totals_list :
187 % if tax_code_tuple[2]:
188 <tr>
189 <td>${tax_code_tuple[0]|entity}
190 </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
191 </td>
192 </tr>
193 %endif
194 %endfor
195 </table>
196 </td>
154 </tr>197 </tr>
155 </table>198 </table>
156 </div>199 </div>
157200
=== modified file 'l10n_it_vat_registries/wizard/__init__.py'
--- l10n_it_vat_registries/wizard/__init__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/wizard/__init__.py 2013-05-23 04:44:28 +0000
@@ -1,7 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3# 3#
4# Copyright (C) 2011 Associazione OpenERP Italia4# Copyright (C) 2011-2013 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>). 5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
@@ -12,7 +12,7 @@
12# This program is distributed in the hope that it will be useful,12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.15# GNU Affero General Public License for more details.
16#16#
17# You should have received a copy of the GNU Affero General Public License17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.py'
--- l10n_it_vat_registries/wizard/print_registro_iva.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.py 2013-05-23 04:44:28 +0000
@@ -25,79 +25,64 @@
2525
26class wizard_registro_iva(osv.osv_memory):26class wizard_registro_iva(osv.osv_memory):
2727
28 def _get_period(self, cr, uid, context=None):
29 ctx = dict(context or {}, account_period_prefer_normal=True)
30 period_ids = self.pool.get('account.period').find(cr, uid, context=ctx)
31 return period_ids
32
28 _name = "wizard.registro.iva"33 _name = "wizard.registro.iva"
29 _columns = {34 _columns = {
30 'date_from': fields.date('From date', required=True),35 'period_ids': fields.many2many('account.period', 'registro_iva_periods_rel', 'period_id', 'registro_id', 'Periods', help='Select periods you want retrieve documents from', required=True),
31 'date_to': fields.date('To date', required=True),
32 'type': fields.selection([36 'type': fields.selection([
33 ('customer', 'Customer Invoices'),37 ('customer', 'Customer Invoices'),
34 ('supplier', 'Supplier Invoices'),38 ('supplier', 'Supplier Invoices'),
35 ('corrispettivi', 'Corrispettivi'),39 ('corrispettivi', 'Corrispettivi'),
36 ], 'Layout', required=True),40 ], 'Layout', required=True),
37 'journal_ids': fields.many2many('account.journal', 'registro_iva_journals_rel', 'journal_id', 'registro_id', 'Journals', help='Select journals you want retrieve documents from', required=True),41 'journal_ids': fields.many2many('account.journal', 'registro_iva_journals_rel', 'journal_id', 'registro_id', 'Journals', help='Select journals you want retrieve documents from', required=True),
42 'tax_sign': fields.float('Tax amount sign',
43 help="Use -1 you have negative tax amounts and you want to print them prositive"),
38 'message': fields.char('Message', size=64, readonly=True),44 'message': fields.char('Message', size=64, readonly=True),
45 'fiscal_page_base': fields.integer('Last printed page', required=True),
39 }46 }
40 _defaults = {47 _defaults = {
41 'type': 'customer',48 'type': 'customer',
42 'date_from': lambda * a: time.strftime('%Y-%m-%d'),49 'period_ids': _get_period,
43 'date_to': lambda * a: time.strftime('%Y-%m-%d'),50 'tax_sign': 1.0,
44 #'journal_ids': lambda s, cr, uid, c: s.pool.get('account.journal').search(cr, uid, []),51 'fiscal_page_base': 0,
45 }52 }
46
47 def counterparts_number(self, move_line):
48 counter = 0
49 if not move_line.credit:
50 for line in move_line.move_id.line_id:
51 if line.credit:
52 counter += 1
53 elif not move_line.debit:
54 for line in move_line.move_id.line_id:
55 if line.debit:
56 counter += 1
57 return counter
5853
59 def print_registro(self, cr, uid, ids, context=None):54 def print_registro(self, cr, uid, ids, context=None):
60 move_ids = []
61 wizard = self.read(cr, uid, ids)[0]
62 move_line_obj = self.pool.get('account.move.line')
63 tax_pool = self.pool.get('account.tax')
64 search_list = []
65 search_list = [
66 ('journal_id', 'in', wizard['journal_ids']),
67 ('move_id.date', '<=', wizard['date_to']),
68 ('move_id.date', '>=', wizard['date_from']),
69 ('move_id.state', '=', 'posted'),
70 ('tax_code_id', '!=', False),
71 ]
72 move_line_ids = move_line_obj.search(cr, uid, search_list, order='date')
73 if context is None:55 if context is None:
74 context = {}56 context = {}
75 for move_line in move_line_obj.browse(cr, uid, move_line_ids):57 wizard = self.browse(cr, uid, ids)[0]
76 # verifico che sia coinvolto un conto imposta legato ad un'imposta tramite conto standard o conto refund58 move_obj = self.pool.get('account.move')
77 if move_line.tax_code_id.tax_ids or move_line.tax_code_id.ref_tax_ids:59 obj_model_data = self.pool.get('ir.model.data')
78 if move_line.tax_code_id.tax_ids:60 move_ids = move_obj.search(cr, uid, [
79 if not tax_pool._have_same_rate(move_line.tax_code_id.tax_ids):61 ('journal_id', 'in', [j.id for j in wizard.journal_ids]),
80 raise osv.except_osv(_('Error'), _('Taxes %s have different rates')62 ('period_id', 'in', [p.id for p in wizard.period_ids]),
81 % str(move_line.tax_code_id.tax_ids))63 ('state', '=', 'posted'),
82 if move_line.tax_code_id.ref_tax_ids:64 ], order='date')
83 if not tax_pool._have_same_rate(move_line.tax_code_id.ref_tax_ids):
84 raise osv.except_osv(_('Error'), _('Taxes %s have different rates')
85 % str(move_line.tax_code_id.ref_tax_ids))
86 # controllo che ogni tax code abbia una e una sola imposta
87 ''' non posso farlo per via dell IVA inclusa nel prezzo
88 if len(move_line.tax_code_id.tax_ids) != 1:
89 raise osv.except_osv(_('Error'), _('Wrong tax configuration for tax code %s')
90 % move_line.tax_code_id.name)
91 '''
92 if move_line.move_id.id not in move_ids:
93 move_ids.append(move_line.move_id.id)
94 if not move_ids:65 if not move_ids:
95 self.write(cr, uid, ids, {'message': _('No documents found in the current selection')})66 self.write(cr, uid, ids, {'message': _('No documents found in the current selection')})
96 return True67 model_data_ids = obj_model_data.search(cr, uid, [('model','=','ir.ui.view'), ('name','=','wizard_registro_iva')])
68 resource_id = obj_model_data.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
69 return {
70 'name': _('No documents'),
71 'res_id': ids[0],
72 'view_type': 'form',
73 'view_mode': 'form',
74 'res_model': 'wizard.registro.iva',
75 'views': [(resource_id,'form')],
76 'context': context,
77 'type': 'ir.actions.act_window',
78 'target': 'new',
79 }
97 datas = {'ids': move_ids}80 datas = {'ids': move_ids}
98 datas['model'] = 'account.move'81 datas['model'] = 'account.move'
99 datas['form'] = wizard82 datas['fiscal_page_base'] = wizard.fiscal_page_base
100 datas['move_ids'] = move_ids83 datas['period_ids'] = [p.id for p in wizard.period_ids]
84 datas['layout'] = wizard['type']
85 datas['tax_sign'] = wizard['tax_sign']
101 res= {86 res= {
102 'type': 'ir.actions.report.xml',87 'type': 'ir.actions.report.xml',
103 'datas': datas,88 'datas': datas,
@@ -110,4 +95,11 @@
110 res['report_name'] = 'registro_iva_corrispettivi'95 res['report_name'] = 'registro_iva_corrispettivi'
111 return res96 return res
11297
113wizard_registro_iva()98 def on_type_changed(self, cr, uid, ids, j_type, context=None):
99 res={}
100 if j_type:
101 if j_type == 'supplier':
102 res['value'] = {'tax_sign': -1}
103 else:
104 res['value'] = {'tax_sign': 1}
105 return res
114106
=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.xml'
--- l10n_it_vat_registries/wizard/print_registro_iva.xml 2011-08-06 10:23:30 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.xml 2013-05-23 04:44:28 +0000
@@ -8,11 +8,13 @@
8 <field name="type">form</field>8 <field name="type">form</field>
9 <field name="arch" type="xml">9 <field name="arch" type="xml">
10 <form string="Tax Journal">10 <form string="Tax Journal">
11 <field name="date_from"/>11 <field name="type" on_change="on_type_changed(type)"/>
12 <field name="date_to"/>12 <field name="tax_sign"/>
13 <field name="type" colspan="4"/>13 <field name="fiscal_page_base"/>
14 <separator string="Periods" colspan="4"/>
15 <field name="period_ids" colspan="4" nolabel="1" height="250"/>
14 <separator string="Journals" colspan="4"/>16 <separator string="Journals" colspan="4"/>
15 <field name="journal_ids" colspan="4" nolabel="1" height="250"/>17 <field name="journal_ids" colspan="4" nolabel="1" height="250" domain="[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]"/>
16 <button icon="gtk-cancel" special="cancel" string="Cancel"/>18 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
17 <button icon="gtk-ok" name="print_registro" string="Print" type="object"/>19 <button icon="gtk-ok" name="print_registro" string="Print" type="object"/>
18 <newline/>20 <newline/>

Subscribers

People subscribed via source and target branches