~sergio-incaser/openerp-spain/openerp-spain

« back to all changes in this revision

Viewing changes to l10n_es_aeat_mod130/wizard/export_mod130_to_boe.py

  • Committer: Pedro M. Baeza
  • Date: 2014-01-24 10:56:45 UTC
  • Revision ID: pedro.baeza@serviciosbaeza.com-20140124105645-686gfftnvvg24wok
[ADD] l10n_es_aeat_mod130: Módulo para la declaración del modelo 130 - IRPF pago fraccionado estimación directa

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    This program is free software: you can redistribute it and/or modify
 
5
#    it under the terms of the GNU General Public License as published by
 
6
#    the Free Software Foundation, either version 3 of the License, or
 
7
#    (at your option) any later version.
 
8
#
 
9
#    This program is distributed in the hope that it will be useful,
 
10
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
#    GNU General Public License for more details.
 
13
#
 
14
#    You should have received a copy of the GNU General Public License
 
15
#    along with this program.  If not, see http://www.gnu.org/licenses/.
 
16
#
 
17
##############################################################################
 
18
from datetime import datetime
 
19
from openerp.tools.translate import _
 
20
from openerp.osv import orm
 
21
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
 
22
 
 
23
class l10n_es_aeat_mod130_export_to_boe(orm.TransientModel):
 
24
    _inherit = "l10n.es.aeat.report.export_to_boe"
 
25
    _name = 'l10n.es.aeat.mod130.export_to_boe'
 
26
 
 
27
    def _cleanString(self, string):
 
28
        return string.replace("-", "").replace(" ", "").replace("/", "")
 
29
 
 
30
    def _get_formatted_declaration_record(self, report, context=None):
 
31
        res = ''
 
32
        ## cabecera 
 
33
        res += "13001 "
 
34
        # Tipo de declaración
 
35
        # B (resultado a deducir)
 
36
        # G (cuenta corriente tributaria-ingreso)
 
37
        # I (ingreso)
 
38
        # N (negativa)
 
39
        # U (domiciliación del ingreso en CCC)
 
40
        res += self._formatString(report.tipo_declaracion, 1)
 
41
        # Código Administración - No se usan
 
42
        res += self._formatString("", 5)
 
43
        # Identificación (1)
 
44
        res += self._formatString(report.company_vat, 9) # NIF del declarante
 
45
        res += self._formatString(report.company_id.name, 4) # Comienzo primer apellido
 
46
        res += self._formatString(report.company_id.name, 30) # Apellidos
 
47
        res += self._formatString("", 15) # Nombre
 
48
        res += self._formatNumber(report.fiscalyear_id.code, 4) #Ejercicio
 
49
        res += self._formatString(report.period, 2)
 
50
        return res
 
51
 
 
52
    def _get_formatted_main_record(self, report, context=None):
 
53
        res = ''
 
54
        if report.activity_type == 'primary':
 
55
            # Datos vacíos para actividad económica
 
56
            res += self._formatString('', 91)
 
57
            # II. Activ. agrícola. estimac. directa - Volumen de ingresos [08]
 
58
            res += self._formatNumber(report.casilla_08, 11, 2)
 
59
            # II. Activ. agrícola. estimac. directa - 2% de la casilla 08 [09]
 
60
            res += self._formatNumber(report.casilla_09, 11, 2)
 
61
            # II. Activ. agrícola. estimac. directa - A deducir- Retenciones e ingr. a cuenta [10]
 
62
            res += self._formatNumber(report.casilla_10, 11, 2)
 
63
            # II. Activ. agrícola estimac. directa - Pago fraccionado previo del trimestre [11]
 
64
            res += self._formatNumber(report.casilla_11, 11, 2)
 
65
        else:
 
66
            # I. Activ. económicas estimac. Directa - Ingresos computables [01]
 
67
            res += self._formatNumber(report.casilla_01, 11, 2)
 
68
            # I. Activ. económicas estimac. Directa - Gastos fiscalmente deducibles [02]
 
69
            res += self._formatNumber(report.casilla_02, 11, 2)
 
70
            # I. Activ. económicas estimac. Directa - Rendimiento neto [03]
 
71
            res += self._formatNumber(report.casilla_03, 11, 2)
 
72
            # I. Activ. económicas estimac. Directa - 20% de la casilla 03 [04]
 
73
            res += self._formatNumber(report.casilla_04, 11, 2)
 
74
            # I. Activ. económicas estimac. Directa - A deducir - De los trimestres anteriores [05]
 
75
            res += self._formatNumber(report.casilla_05, 11, 2)
 
76
            # I. Activ. económicas estimac. Directa - A deducir - Retenciones e ingr. a cuenta [06]
 
77
            res += self._formatNumber(report.casilla_06, 11, 2)
 
78
            # I. Activ. económicas estimac. Directa - Pago fraccionado previo del trimestre [07]
 
79
            res += self._formatNumber(report.casilla_07, 11, 2)
 
80
            # Datos vacíos para actividad agrícola
 
81
            res += self._formatString('', 52)
 
82
        # III. Total liquidación - Suma de pagos fraccionados previos del trimestre [12]
 
83
        res += self._formatNumber(report.casilla_12, 11, 2)
 
84
        # III. Total liquidación -Minoración por aplicación de la deducción. Artículo 80 bis [13]
 
85
        res += self._formatNumber(report.casilla_13, 11, 2)
 
86
        # III. Total liquidación - Diferencia (12) - (13) [14]
 
87
        res += self._formatNumber(report.casilla_14, 11, 2)
 
88
        # III. Total liquidación - A deducir - Resultados negativos de trimestres anteriores [15]
 
89
        res += self._formatNumber(report.casilla_15, 11, 2)
 
90
        # III. Total liquidación - Pago de préstamos para la adquisición de vivienda habitual [16]
 
91
        res += self._formatNumber(report.casilla_16, 11, 2)
 
92
        # III. Total liquidación - Total (14) - (15) [17]
 
93
        res += self._formatNumber(report.casilla_17, 11, 2)
 
94
        # III. Total liquidación - A deducir - Resultado de las anteriores declaraciones [18]
 
95
        res += self._formatNumber(report.casilla_18, 11, 2)
 
96
        # III. Total liquidación - Resultado de la declaración [19]
 
97
        res += self._formatNumber(report.result, 11, 2)
 
98
        return res
 
99
 
 
100
    def _get_formatted_other_records(self, report, context=None):
 
101
        res = ''
 
102
        # Ingreso (4) Importe del ingreso
 
103
        res += self._formatNumber(report.result if report.result > 0 else 0,
 
104
                                  11, 2)
 
105
        # Ingreso (4) Forma de pago - "0" No consta, "1" Efectivo,
 
106
        # "2" Adeudo en cuenta, "3" Domiciliación
 
107
        res += self._formatString("0", 1)
 
108
        ## Ingreso (4) CCC - Entidad - Sucursal - DC - Nº de cuenta - SIN USO
 
109
        res += self._formatString("",  20)
 
110
        # A deducir (5) Declaración con resultado a deducir en los siguientes
 
111
        # pagos fraccionados
 
112
        res += self._formatBoolean(report.result < 0 and report.period != '4T',
 
113
                                   yes='X', no=' ')
 
114
        # Complementaria (7) Cod. electrónico declaración anterior 
 
115
        res += self._formatString(report.previous_electronic_code if
 
116
                                  report.complementary else "" , 16)
 
117
        # Complementaria (7) Nº justificante declaración anterior 
 
118
        res += self._formatString(report.previous_declaration if
 
119
                                  report.complementary else "" , 13)
 
120
        # Persona de contacto
 
121
        res += self._formatString(report.company_id.name, 100)
 
122
        # Teléfono
 
123
        res += self._formatString(self._cleanString(report.company_id.phone), 9)
 
124
        # Observaciones
 
125
        res += self._formatString(report.comments, 350)
 
126
        # Localidad
 
127
        res += self._formatString(report.company_id.partner_id.city, 16)
 
128
        date = datetime.strptime(report.calculation_date,
 
129
                                 DEFAULT_SERVER_DATETIME_FORMAT)
 
130
        ## fecha: Dia
 
131
        res += self._formatString(date.strftime("%d"), 2)
 
132
        ## fecha: Mes
 
133
        res += self._formatString(_(date.strftime("%B")), 10)
 
134
        ## fecha: Año
 
135
        res += self._formatString(date.strftime("%Y"), 4)
 
136
        res += "\r\n".encode("ascii")
 
137
        return res
 
138
 
 
139
    def _do_global_checks(self, report, contents, context=None):
 
140
        assert len(contents) == 880, \
 
141
                _("The 130 report must be 880 characters long and are %s"
 
142
                  ) %len(contents)
 
143
        return True
 
 
b'\\ No newline at end of file'