Skip to content

Commit

Permalink
Merge pull request #181 from gisce/63894_imp_tipo_impositivo_novigent…
Browse files Browse the repository at this point in the history
…e_ab_como_r4

Envío tipo impositivo como S y R4 para facturas abonadoras con tipos impositivos fuera de vigencia
  • Loading branch information
guilleJB authored Dec 20, 2024
2 parents cabcec0 + 7cecefd commit 0dfc420
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 6 deletions.
18 changes: 17 additions & 1 deletion sii/models/basic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def __init__(self,
origin_date_invoice=None,
origin=None,
fiscal_name=None,
fiscal_vat=None):
fiscal_vat=None,
sii_non_current_tax_rate='R4'):
self.journal_id = journal_id
self.number = number
self.type = invoice_type
Expand All @@ -136,3 +137,18 @@ def __init__(self,
self.sii_out_clave_regimen_especial = sii_out_clave_regimen_especial
self.rectificative_type = rectificative_type
self.rectifying_id = rectifying_id
self.sii_non_current_tax_rate = sii_non_current_tax_rate

def get_values_taxes_non_current_tax_rate(self):
if self.sii_non_current_tax_rate == 'R4':
return {
'TipoRectificativa': 'S',
'TipoFactura': 'R4',
'ImporteRectificacion': {
'BaseRectificada': 0,
'CuotaRectificada': 0
}
}
else:
return {}

9 changes: 7 additions & 2 deletions sii/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,15 @@ def get_factura_emitida(invoice, rect_sust_opc1=False, rect_sust_opc2=False):

if invoice.rectificative_type in ('A', 'B'):
if tipo_impositivo_no_vigente:
if invoice.date_invoice > tipo_impositivo_no_vigente:
if invoice.date_invoice > tipo_impositivo_no_vigente:
factura_expedida.update(
{'FechaOperacion': get_fecha_operacion_rec(invoice)}
{
'FechaOperacion': get_fecha_operacion_rec(invoice)
}
)
extra_info = invoice.get_values_taxes_non_current_tax_rate()
if extra_info:
factura_expedida.update(extra_info)
if rectificativa:
opcion = 0
if rect_sust_opc1:
Expand Down
124 changes: 122 additions & 2 deletions spec/serialization_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,9 @@ def group_by_tax_rate(iva_values, in_invoice):
self.out_refund.tax_line[0].tax_id.amount * 100
))

with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia'):
with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia como tipo R4'):
with before.all:
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5()
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5(sii_non_current_tax_rate='R4')
self.out_refund_obj = SII(self.out_refund).generate_object()
self.out_b_inovice_obj = SII(self.out_b_inovice).generate_object()
self.fact_rect_emit = (
Expand All @@ -1008,6 +1008,100 @@ def group_by_tax_rate(iva_values, in_invoice):
expect(
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
).to(equal('01-01-2023'))
with it('la TipoRectificativa debe ser S'):
expect(
self.fact_refund_emit['FacturaExpedida']['TipoRectificativa']
).to(equal('S'))
with it('la TipoFactura tiene que ser R4'):
expect(
self.fact_refund_emit['FacturaExpedida'][
'TipoFactura']
).to(equal('R4'))
with context('en los datos de rectificación'):
with it('el TipoRectificativa debe ser por sustitución (S)'):
expect(
self.fact_rect_emit['FacturaExpedida']['TipoRectificativa']
).to(equal('S'))

with it('la FechaOperacion debe ser por factura original'):
expect(
self.fact_rect_emit['FacturaExpedida']['FechaOperacion']
).to(equal('01-01-2023'))

with before.all:
self.importe_rectificacion = (
self.fact_rect_emit['FacturaExpedida']
['ImporteRectificacion']
)

with it('la BaseRectificada debe ser 0'):
expect(
self.importe_rectificacion['BaseRectificada']
).to(equal(0))

with it('la CuotaRectificada debe ser 0'):
expect(
self.importe_rectificacion['CuotaRectificada']
).to(equal(0))

with context('en los detalles del IVA'):
with before.all:
detalle_iva = (
self.fact_rect_emit['FacturaExpedida']['TipoDesglose']
['DesgloseFactura']['Sujeta']['NoExenta']['DesgloseIVA']
['DetalleIVA']
)
self.grouped_detalle_iva = group_by_tax_rate(
detalle_iva, in_invoice=False
)

with it('la BaseImponible debe ser la original'):
expect(
self.grouped_detalle_iva[5.0]['BaseImponible']
).to(equal(
self.out_refund.tax_line[0].base
))
with it('la CuotaRepercutida debe ser la original'):
expect(
self.grouped_detalle_iva[5.0]['CuotaRepercutida']
).to(equal(
-1 * abs(self.out_refund.tax_line[0].tax_amount)
))
with it('el TipoImpositivo debe ser la original'):
expect(
self.grouped_detalle_iva[5.0]['TipoImpositivo']
).to(equal(
self.out_refund.tax_line[0].tax_id.amount * 100
))

with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia como tipo F1'):
with before.all:
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5(sii_non_current_tax_rate='F1')
self.out_refund_obj = SII(self.out_refund).generate_object()
self.out_b_inovice_obj = SII(self.out_b_inovice).generate_object()
self.fact_rect_emit = (
self.out_refund_obj['SuministroLRFacturasEmitidas']
['RegistroLRFacturasEmitidas']
)
self.fact_refund_emit = (
self.out_b_inovice_obj['SuministroLRFacturasEmitidas']
['RegistroLRFacturasEmitidas']
)
with context('en los datos de abonadora'):
with it('la FechaOperacion debe ser por factura original'):
expect(
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
).to(equal('01-01-2023'))
with it('la TipoRectificativa NO debe existir'):
expect(
self.fact_refund_emit['FacturaExpedida'].get(
'TipoRectificativa', False)
).to(equal(False))
with it('la TipoFactura tiene que ser F1'):
expect(
self.fact_refund_emit['FacturaExpedida'][
'TipoFactura']
).to(equal('F1'))
with context('en los datos de rectificación'):
with it('el TipoRectificativa debe ser por sustitución (S)'):
expect(
Expand Down Expand Up @@ -1084,6 +1178,14 @@ def group_by_tax_rate(iva_values, in_invoice):
self.fact_refund_emit['FacturaExpedida'].get(
'FechaOperacion', False)
).to(equal(False))
with it('la TipoRectificativa NO debe ser informado'):
expect(
self.fact_refund_emit['FacturaExpedida'].get('TipoRectificativa',False)
).to(equal(False))
with it('la TipoFactura tiene que ser F1'):
expect(
self.fact_refund_emit['FacturaExpedida'].get('TipoFactura', False)
).to(equal('F1'))
with context('en los datos de rectificación'):
with it('el TipoRectificativa debe ser por sustitución (S)'):
expect(
Expand All @@ -1094,6 +1196,15 @@ def group_by_tax_rate(iva_values, in_invoice):
expect(
self.fact_rect_emit['FacturaExpedida'].get('FechaOperacion', False)
).to(equal(False))
with it('la TipoRectificativa debe ser S'):
expect(
self.fact_rect_emit['FacturaExpedida'].get('TipoRectificativa',False)
).to(equal('S'))
with it('la TipoFactura tiene que ser R4'):
expect(
self.fact_rect_emit['FacturaExpedida'][
'TipoFactura']
).to(equal('R4'))

with before.all:
self.importe_rectificacion = (
Expand Down Expand Up @@ -1159,6 +1270,15 @@ def group_by_tax_rate(iva_values, in_invoice):
expect(
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
).to(equal('01-01-2023'))
with it('la TipoRectificativa debe ser S'):
expect(
self.fact_refund_emit['FacturaExpedida']['TipoRectificativa']
).to(equal('S'))
with it('la TipoFactura tiene que ser R4'):
expect(
self.fact_refund_emit['FacturaExpedida'][
'TipoFactura']
).to(equal('R4'))
with context('en los datos de rectificación'):
with it('la FechaOperacion debe ser por factura original'):
expect(
Expand Down
5 changes: 4 additions & 1 deletion spec/testing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def get_out_refund_invoice(self):
)
return r_invoice, b_invoice

def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None, sii_non_current_tax_rate='R4'):
journal = Journal(
name=u'Factura de Energía Rectificativa Emitida'
)
Expand Down Expand Up @@ -482,6 +482,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
fiscal_position=self.fiscal_position,
sii_description=self.sii_description,
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
sii_non_current_tax_rate=sii_non_current_tax_rate
)

r_invoice = Invoice(
Expand All @@ -504,6 +505,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
fiscal_position=self.fiscal_position,
sii_description=self.sii_description,
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
sii_non_current_tax_rate = sii_non_current_tax_rate
)
b_invoice = Invoice(
invoice_type='out_refund',
Expand All @@ -525,6 +527,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
fiscal_position=self.fiscal_position,
sii_description=self.sii_description,
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
sii_non_current_tax_rate=sii_non_current_tax_rate
)
return r_invoice, b_invoice

Expand Down

0 comments on commit 0dfc420

Please sign in to comment.