mirror of
https://gitlab.com/datalifeit/trytond-aeat_sii
synced 2023-12-13 20:30:37 +01:00
Add new model to store SII tax lines
This commit is contained in:
parent
00dd880e26
commit
55b27992cc
|
@ -21,6 +21,7 @@ def register():
|
|||
load_pkcs12.LoadPKCS12Start,
|
||||
aeat.SIIReport,
|
||||
aeat.SIIReportLine,
|
||||
aeat.SIIReportLineTax,
|
||||
aeat_mapping.IssuedTrytonInvoiceMapper,
|
||||
aeat_mapping.RecievedTrytonInvoiceMapper,
|
||||
module='aeat_sii', type_='model')
|
||||
|
|
52
aeat.py
52
aeat.py
|
@ -5,6 +5,7 @@
|
|||
__all__ = [
|
||||
'SIIReport',
|
||||
'SIIReportLine',
|
||||
'SIIReportLineTax',
|
||||
]
|
||||
|
||||
import unicodedata
|
||||
|
@ -24,6 +25,10 @@ _logger = getLogger(__name__)
|
|||
_ZERO = Decimal('0.0')
|
||||
|
||||
|
||||
def _decimal(x):
|
||||
return Decimal(x) if x is not None else None
|
||||
|
||||
|
||||
COMMUNICATION_TYPE = [ # L0
|
||||
('A0', 'New Invoices'),
|
||||
('A1', 'Modify Invoices'),
|
||||
|
@ -543,6 +548,17 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
reg.DatosFacturaEmitida.
|
||||
ClaveRegimenEspecialOTrascendencia),
|
||||
total_amount=reg.DatosFacturaEmitida.ImporteTotal,
|
||||
taxes=tuple(
|
||||
SIIReportLineTax(
|
||||
base=_decimal(detail.BaseImponible),
|
||||
rate=_decimal(detail.TipoImpositivo),
|
||||
amount=_decimal(detail.CuotaRepercutida),
|
||||
surcharge_rate=_decimal(detail.TipoRecargoEquivalencia),
|
||||
surcharge_amount=_decimal(detail.CuotaRecargoEquivalencia),
|
||||
)
|
||||
for detail in reg.DatosFacturaEmitida.TipoDesglose.
|
||||
DesgloseFactura.Sujeta.NoExenta.DesgloseIVA.DetalleIVA
|
||||
),
|
||||
counterpart_name=(
|
||||
reg.DatosFacturaEmitida.Contraparte.NombreRazon),
|
||||
counterpart_id=(
|
||||
|
@ -617,6 +633,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
SIIReportLine = pool.get('aeat.sii.report.lines')
|
||||
SIIReportLineTax = pool.get('aeat.sii.report.line.tax')
|
||||
headers = mapping.get_headers(
|
||||
name=self.company.party.name,
|
||||
vat=self.company.party.vat_number,
|
||||
|
@ -662,6 +679,19 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
reg.DatosFacturaRecibida.
|
||||
ClaveRegimenEspecialOTrascendencia),
|
||||
total_amount=reg.DatosFacturaRecibida.ImporteTotal,
|
||||
taxes=tuple(
|
||||
SIIReportLineTax(
|
||||
base=_decimal(detail.BaseImponible),
|
||||
rate=_decimal(detail.TipoImpositivo),
|
||||
amount=_decimal(detail.CuotaSoportada),
|
||||
surcharge_rate=_decimal(detail.TipoRecargoEquivalencia),
|
||||
surcharge_amount=_decimal(detail.CuotaRecargoEquivalencia),
|
||||
reagyp_rate=_decimal(detail.PorcentCompensacionREAGYP),
|
||||
reagyp_amount=_decimal(detail.ImporteCompensacionREAGYP),
|
||||
)
|
||||
for detail in reg.DatosFacturaRecibida.
|
||||
DesgloseFactura.DesgloseIVA.DetalleIVA
|
||||
),
|
||||
counterpart_name=(
|
||||
reg.DatosFacturaRecibida.Contraparte.NombreRazon),
|
||||
counterpart_id=(
|
||||
|
@ -703,7 +733,8 @@ class SIIReportLine(ModelSQL, ModelView):
|
|||
total_amount = fields.Numeric('Total Amount', readonly=True)
|
||||
counterpart_name = fields.Char('Counterpart Name', readonly=True)
|
||||
counterpart_id = fields.Char('Counterpart ID', readonly=True)
|
||||
# TODO: tax lines
|
||||
taxes = fields.One2Many(
|
||||
'aeat.sii.report.line.tax', 'line', 'Tax Lines', readonly=True)
|
||||
presenter = fields.Char('Presenter', readonly=True)
|
||||
presentation_date = fields.Char('Presentation Date', readonly=True)
|
||||
csv = fields.Char('CSV', readonly=True)
|
||||
|
@ -730,6 +761,7 @@ class SIIReportLine(ModelSQL, ModelView):
|
|||
default['invoice_kind'] = None
|
||||
default['special_key'] = None
|
||||
default['total_amount'] = None
|
||||
default['taxes'] = None
|
||||
default['counterpart_name'] = None
|
||||
default['counterpart_id'] = None
|
||||
default['presenter'] = None
|
||||
|
@ -737,3 +769,21 @@ class SIIReportLine(ModelSQL, ModelView):
|
|||
default['csv'] = None
|
||||
default['balance_state'] = None
|
||||
return super(SIIReportLine, cls).copy(records, default=default)
|
||||
|
||||
|
||||
class SIIReportLineTax(ModelSQL, ModelView):
|
||||
'''
|
||||
SII Report Line Tax
|
||||
'''
|
||||
__name__ = 'aeat.sii.report.line.tax'
|
||||
|
||||
line = fields.Many2One(
|
||||
'aeat.sii.report.lines', 'Report Line', ondelete='CASCADE')
|
||||
|
||||
base = fields.Numeric('Base', readonly=True)
|
||||
rate = fields.Numeric('Rate', readonly=True)
|
||||
amount = fields.Numeric('Amount', readonly=True)
|
||||
surcharge_rate = fields.Numeric('Surcharge Rate', readonly=True)
|
||||
surcharge_amount = fields.Numeric('Surcharge Amount', readonly=True)
|
||||
reagyp_rate = fields.Numeric('REAGYP Rate', readonly=True)
|
||||
reagyp_amount = fields.Numeric('REAGYP Amount', readonly=True)
|
||||
|
|
7
aeat.xml
7
aeat.xml
|
@ -104,6 +104,13 @@
|
|||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="aeat_sii_report_line_tax_tree_view">
|
||||
<field name="model">aeat.sii.report.line.tax</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">sii_report_line_tax_list</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.rule.group" id="rule_group_sii_report">
|
||||
<field name="model" search="[('model', '=', 'aeat.sii.report')]"/>
|
||||
<field name="global_p" eval="True"/>
|
||||
|
|
13
view/sii_report_line_tax_list.xml
Normal file
13
view/sii_report_line_tax_list.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tree string="SII Report Line Tax">
|
||||
<field name="line"/>
|
||||
<field name="base"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
<field name="surcharge_rate"/>
|
||||
<field name="surcharge_amount"/>
|
||||
<field name="reagyp_rate"/>
|
||||
<field name="reagyp_amount"/>
|
||||
</tree>
|
|
@ -24,6 +24,7 @@
|
|||
<field name="special_key"/>
|
||||
<label name="total_amount"/>
|
||||
<field name="total_amount"/>
|
||||
<field name="taxes" colspan="4"/>
|
||||
<label name="counterpart_name"/>
|
||||
<field name="counterpart_name"/>
|
||||
<label name="counterpart_id"/>
|
||||
|
|
Loading…
Reference in a new issue