Skip to content

Commit 0dfc420

Browse files
authored
Merge pull request #181 from gisce/63894_imp_tipo_impositivo_novigente_ab_como_r4
Envío tipo impositivo como S y R4 para facturas abonadoras con tipos impositivos fuera de vigencia
2 parents cabcec0 + 7cecefd commit 0dfc420

File tree

4 files changed

+150
-6
lines changed

4 files changed

+150
-6
lines changed

sii/models/basic_models.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def __init__(self,
109109
origin_date_invoice=None,
110110
origin=None,
111111
fiscal_name=None,
112-
fiscal_vat=None):
112+
fiscal_vat=None,
113+
sii_non_current_tax_rate='R4'):
113114
self.journal_id = journal_id
114115
self.number = number
115116
self.type = invoice_type
@@ -136,3 +137,18 @@ def __init__(self,
136137
self.sii_out_clave_regimen_especial = sii_out_clave_regimen_especial
137138
self.rectificative_type = rectificative_type
138139
self.rectifying_id = rectifying_id
140+
self.sii_non_current_tax_rate = sii_non_current_tax_rate
141+
142+
def get_values_taxes_non_current_tax_rate(self):
143+
if self.sii_non_current_tax_rate == 'R4':
144+
return {
145+
'TipoRectificativa': 'S',
146+
'TipoFactura': 'R4',
147+
'ImporteRectificacion': {
148+
'BaseRectificada': 0,
149+
'CuotaRectificada': 0
150+
}
151+
}
152+
else:
153+
return {}
154+

sii/resource.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,15 @@ def get_factura_emitida(invoice, rect_sust_opc1=False, rect_sust_opc2=False):
445445

446446
if invoice.rectificative_type in ('A', 'B'):
447447
if tipo_impositivo_no_vigente:
448-
if invoice.date_invoice > tipo_impositivo_no_vigente:
448+
if invoice.date_invoice > tipo_impositivo_no_vigente:
449449
factura_expedida.update(
450-
{'FechaOperacion': get_fecha_operacion_rec(invoice)}
450+
{
451+
'FechaOperacion': get_fecha_operacion_rec(invoice)
452+
}
451453
)
454+
extra_info = invoice.get_values_taxes_non_current_tax_rate()
455+
if extra_info:
456+
factura_expedida.update(extra_info)
452457
if rectificativa:
453458
opcion = 0
454459
if rect_sust_opc1:

spec/serialization_spec.py

+122-2
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,9 @@ def group_by_tax_rate(iva_values, in_invoice):
990990
self.out_refund.tax_line[0].tax_id.amount * 100
991991
))
992992

993-
with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia'):
993+
with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia como tipo R4'):
994994
with before.all:
995-
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5()
995+
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5(sii_non_current_tax_rate='R4')
996996
self.out_refund_obj = SII(self.out_refund).generate_object()
997997
self.out_b_inovice_obj = SII(self.out_b_inovice).generate_object()
998998
self.fact_rect_emit = (
@@ -1008,6 +1008,100 @@ def group_by_tax_rate(iva_values, in_invoice):
10081008
expect(
10091009
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
10101010
).to(equal('01-01-2023'))
1011+
with it('la TipoRectificativa debe ser S'):
1012+
expect(
1013+
self.fact_refund_emit['FacturaExpedida']['TipoRectificativa']
1014+
).to(equal('S'))
1015+
with it('la TipoFactura tiene que ser R4'):
1016+
expect(
1017+
self.fact_refund_emit['FacturaExpedida'][
1018+
'TipoFactura']
1019+
).to(equal('R4'))
1020+
with context('en los datos de rectificación'):
1021+
with it('el TipoRectificativa debe ser por sustitución (S)'):
1022+
expect(
1023+
self.fact_rect_emit['FacturaExpedida']['TipoRectificativa']
1024+
).to(equal('S'))
1025+
1026+
with it('la FechaOperacion debe ser por factura original'):
1027+
expect(
1028+
self.fact_rect_emit['FacturaExpedida']['FechaOperacion']
1029+
).to(equal('01-01-2023'))
1030+
1031+
with before.all:
1032+
self.importe_rectificacion = (
1033+
self.fact_rect_emit['FacturaExpedida']
1034+
['ImporteRectificacion']
1035+
)
1036+
1037+
with it('la BaseRectificada debe ser 0'):
1038+
expect(
1039+
self.importe_rectificacion['BaseRectificada']
1040+
).to(equal(0))
1041+
1042+
with it('la CuotaRectificada debe ser 0'):
1043+
expect(
1044+
self.importe_rectificacion['CuotaRectificada']
1045+
).to(equal(0))
1046+
1047+
with context('en los detalles del IVA'):
1048+
with before.all:
1049+
detalle_iva = (
1050+
self.fact_rect_emit['FacturaExpedida']['TipoDesglose']
1051+
['DesgloseFactura']['Sujeta']['NoExenta']['DesgloseIVA']
1052+
['DetalleIVA']
1053+
)
1054+
self.grouped_detalle_iva = group_by_tax_rate(
1055+
detalle_iva, in_invoice=False
1056+
)
1057+
1058+
with it('la BaseImponible debe ser la original'):
1059+
expect(
1060+
self.grouped_detalle_iva[5.0]['BaseImponible']
1061+
).to(equal(
1062+
self.out_refund.tax_line[0].base
1063+
))
1064+
with it('la CuotaRepercutida debe ser la original'):
1065+
expect(
1066+
self.grouped_detalle_iva[5.0]['CuotaRepercutida']
1067+
).to(equal(
1068+
-1 * abs(self.out_refund.tax_line[0].tax_amount)
1069+
))
1070+
with it('el TipoImpositivo debe ser la original'):
1071+
expect(
1072+
self.grouped_detalle_iva[5.0]['TipoImpositivo']
1073+
).to(equal(
1074+
self.out_refund.tax_line[0].tax_id.amount * 100
1075+
))
1076+
1077+
with description('en los datos de una factura rectificativa emitida con IVA 5% fecha postrior vigencia como tipo F1'):
1078+
with before.all:
1079+
self.out_refund, self.out_b_inovice = self.data_gen.get_out_refund_invoice_iva5(sii_non_current_tax_rate='F1')
1080+
self.out_refund_obj = SII(self.out_refund).generate_object()
1081+
self.out_b_inovice_obj = SII(self.out_b_inovice).generate_object()
1082+
self.fact_rect_emit = (
1083+
self.out_refund_obj['SuministroLRFacturasEmitidas']
1084+
['RegistroLRFacturasEmitidas']
1085+
)
1086+
self.fact_refund_emit = (
1087+
self.out_b_inovice_obj['SuministroLRFacturasEmitidas']
1088+
['RegistroLRFacturasEmitidas']
1089+
)
1090+
with context('en los datos de abonadora'):
1091+
with it('la FechaOperacion debe ser por factura original'):
1092+
expect(
1093+
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
1094+
).to(equal('01-01-2023'))
1095+
with it('la TipoRectificativa NO debe existir'):
1096+
expect(
1097+
self.fact_refund_emit['FacturaExpedida'].get(
1098+
'TipoRectificativa', False)
1099+
).to(equal(False))
1100+
with it('la TipoFactura tiene que ser F1'):
1101+
expect(
1102+
self.fact_refund_emit['FacturaExpedida'][
1103+
'TipoFactura']
1104+
).to(equal('F1'))
10111105
with context('en los datos de rectificación'):
10121106
with it('el TipoRectificativa debe ser por sustitución (S)'):
10131107
expect(
@@ -1084,6 +1178,14 @@ def group_by_tax_rate(iva_values, in_invoice):
10841178
self.fact_refund_emit['FacturaExpedida'].get(
10851179
'FechaOperacion', False)
10861180
).to(equal(False))
1181+
with it('la TipoRectificativa NO debe ser informado'):
1182+
expect(
1183+
self.fact_refund_emit['FacturaExpedida'].get('TipoRectificativa',False)
1184+
).to(equal(False))
1185+
with it('la TipoFactura tiene que ser F1'):
1186+
expect(
1187+
self.fact_refund_emit['FacturaExpedida'].get('TipoFactura', False)
1188+
).to(equal('F1'))
10871189
with context('en los datos de rectificación'):
10881190
with it('el TipoRectificativa debe ser por sustitución (S)'):
10891191
expect(
@@ -1094,6 +1196,15 @@ def group_by_tax_rate(iva_values, in_invoice):
10941196
expect(
10951197
self.fact_rect_emit['FacturaExpedida'].get('FechaOperacion', False)
10961198
).to(equal(False))
1199+
with it('la TipoRectificativa debe ser S'):
1200+
expect(
1201+
self.fact_rect_emit['FacturaExpedida'].get('TipoRectificativa',False)
1202+
).to(equal('S'))
1203+
with it('la TipoFactura tiene que ser R4'):
1204+
expect(
1205+
self.fact_rect_emit['FacturaExpedida'][
1206+
'TipoFactura']
1207+
).to(equal('R4'))
10971208

10981209
with before.all:
10991210
self.importe_rectificacion = (
@@ -1159,6 +1270,15 @@ def group_by_tax_rate(iva_values, in_invoice):
11591270
expect(
11601271
self.fact_refund_emit['FacturaExpedida']['FechaOperacion']
11611272
).to(equal('01-01-2023'))
1273+
with it('la TipoRectificativa debe ser S'):
1274+
expect(
1275+
self.fact_refund_emit['FacturaExpedida']['TipoRectificativa']
1276+
).to(equal('S'))
1277+
with it('la TipoFactura tiene que ser R4'):
1278+
expect(
1279+
self.fact_refund_emit['FacturaExpedida'][
1280+
'TipoFactura']
1281+
).to(equal('R4'))
11621282
with context('en los datos de rectificación'):
11631283
with it('la FechaOperacion debe ser por factura original'):
11641284
expect(

spec/testing_data.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def get_out_refund_invoice(self):
430430
)
431431
return r_invoice, b_invoice
432432

433-
def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
433+
def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None, sii_non_current_tax_rate='R4'):
434434
journal = Journal(
435435
name=u'Factura de Energía Rectificativa Emitida'
436436
)
@@ -482,6 +482,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
482482
fiscal_position=self.fiscal_position,
483483
sii_description=self.sii_description,
484484
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
485+
sii_non_current_tax_rate=sii_non_current_tax_rate
485486
)
486487

487488
r_invoice = Invoice(
@@ -504,6 +505,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
504505
fiscal_position=self.fiscal_position,
505506
sii_description=self.sii_description,
506507
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
508+
sii_non_current_tax_rate = sii_non_current_tax_rate
507509
)
508510
b_invoice = Invoice(
509511
invoice_type='out_refund',
@@ -525,6 +527,7 @@ def get_out_refund_invoice_iva5(self, fecha_facturas_recti=None):
525527
fiscal_position=self.fiscal_position,
526528
sii_description=self.sii_description,
527529
sii_out_clave_regimen_especial=self.sii_out_clave_regimen_especial,
530+
sii_non_current_tax_rate=sii_non_current_tax_rate
528531
)
529532
return r_invoice, b_invoice
530533

0 commit comments

Comments
 (0)