@@ -13,11 +13,13 @@ def __init__(self, invoice_registered=False, contraparte_registered=True):
13
13
self .article = Article (tipo_factura = 'R1' , tipo_rectificativa = 'I' )
14
14
name_iva_21 = 'IVA 21%'
15
15
name_iva_4 = 'IVA 4%'
16
+ name_iva_5 = 'IVA 5%'
16
17
name_ibi = 'IBI 15%'
17
18
name_iva_exento = 'IVA Exento'
18
19
tax_ibi = Tax (name = name_ibi , amount = 0.15 , type = 'percent' )
19
20
tax_iva_21 = Tax (name = name_iva_21 , amount = 0.21 , type = 'percent' )
20
- tax_iva_4 = Tax (name = name_iva_21 , amount = 0.04 , type = 'percent' )
21
+ tax_iva_4 = Tax (name = name_iva_4 , amount = 0.04 , type = 'percent' )
22
+ self .tax_iva_5 = Tax (name = name_iva_5 , amount = 0.05 , type = 'percent' )
21
23
tax_iva_exento = Tax (name = name_iva_exento , amount = 0 , type = 'percent' )
22
24
self .invoice_line = [
23
25
InvoiceLine (price_subtotal = 100 , invoice_line_tax_id = [tax_iva_21 ]),
@@ -428,7 +430,244 @@ def get_out_refund_invoice(self):
428
430
)
429
431
return r_invoice , b_invoice
430
432
431
- def get_out_refund_mulitple_invoice (self ):
433
+ def get_out_refund_invoice_iva5 (self , fecha_facturas_recti = None ):
434
+ journal = Journal (
435
+ name = u'Factura de Energía Rectificativa Emitida'
436
+ )
437
+ base_bruta = 10
438
+ invoice_tax_iva_5 = InvoiceTax (
439
+ name = self .tax_iva_5 .name , base = base_bruta ,
440
+ tax_amount = base_bruta * self .tax_iva_5 .amount , tax_id = self .tax_iva_5
441
+ )
442
+ tax_line = [
443
+ invoice_tax_iva_5
444
+ ]
445
+ n_total_amount = 0
446
+ n_total_tax = 0
447
+ for tl in tax_line :
448
+ n_total_amount += tl .base + tl .tax_amount
449
+ n_total_tax += tl .tax_amount
450
+
451
+ n_date_invoice = '2023-01-01'
452
+ n_period = Period (name = '01/2023' )
453
+
454
+ if fecha_facturas_recti :
455
+ b_date_invoice = fecha_facturas_recti
456
+ y ,m ,d = fecha_facturas_recti .split ('-' )
457
+ b_period = Period (name = '{}/{}' .format (m ,y ))
458
+ else :
459
+ b_date_invoice = '2024-10-01'
460
+ b_period = Period (name = '01/2024' )
461
+ refund_tax_line = tax_line [:]
462
+ for invoice_tax in refund_tax_line :
463
+ invoice_tax .tax_amount = - 1 * abs (invoice_tax .tax_amount )
464
+
465
+ orig_invoice = Invoice (
466
+ invoice_type = 'out_invoice' ,
467
+ journal_id = journal ,
468
+ rectificative_type = 'N' ,
469
+ rectifying_id = False ,
470
+ number = 'FEmitRectificada{}' .format (self .invoice_number ),
471
+ partner_id = self .partner_invoice ,
472
+ address_contact_id = self .address_contact_id ,
473
+ company_id = self .company ,
474
+ amount_total = n_total_amount ,
475
+ amount_untaxed = base_bruta ,
476
+ amount_tax = n_total_tax ,
477
+ period_id = n_period ,
478
+ date_invoice = n_date_invoice ,
479
+ tax_line = tax_line ,
480
+ invoice_line = [], # no se usa
481
+ sii_registered = self .sii_registered ,
482
+ fiscal_position = self .fiscal_position ,
483
+ sii_description = self .sii_description ,
484
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
485
+ )
486
+
487
+ r_invoice = Invoice (
488
+ invoice_type = 'out_invoice' ,
489
+ journal_id = journal ,
490
+ rectificative_type = 'R' ,
491
+ rectifying_id = orig_invoice ,
492
+ number = 'FRectEmit{}' .format (self .invoice_number ),
493
+ partner_id = self .partner_invoice ,
494
+ address_contact_id = self .address_contact_id ,
495
+ company_id = self .company ,
496
+ amount_total = n_total_amount ,
497
+ amount_untaxed = base_bruta ,
498
+ amount_tax = n_total_tax ,
499
+ period_id = b_period ,
500
+ date_invoice = b_date_invoice ,
501
+ tax_line = tax_line ,
502
+ invoice_line = self .invoice_line ,
503
+ sii_registered = self .sii_registered ,
504
+ fiscal_position = self .fiscal_position ,
505
+ sii_description = self .sii_description ,
506
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
507
+ )
508
+ b_invoice = Invoice (
509
+ invoice_type = 'out_refund' ,
510
+ journal_id = journal ,
511
+ rectificative_type = 'B' ,
512
+ rectifying_id = orig_invoice ,
513
+ number = 'FEmitRectificada{}' .format (self .invoice_number ),
514
+ partner_id = self .partner_invoice ,
515
+ address_contact_id = self .address_contact_id ,
516
+ company_id = self .company ,
517
+ amount_total = - 1 * n_total_amount ,
518
+ amount_untaxed = - 1 * base_bruta ,
519
+ amount_tax = - 1 * n_total_tax ,
520
+ period_id = b_period ,
521
+ date_invoice = b_date_invoice ,
522
+ tax_line = refund_tax_line ,
523
+ invoice_line = [], # no se usa
524
+ sii_registered = self .sii_registered ,
525
+ fiscal_position = self .fiscal_position ,
526
+ sii_description = self .sii_description ,
527
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
528
+ )
529
+ return r_invoice , b_invoice
530
+
531
+ def get_out_refund_invoice_iva5_multi (self , fecha_facturas_recti = None ):
532
+ journal = Journal (
533
+ name = u'Factura de Energía Rectificativa Emitida'
534
+ )
535
+ base_bruta = 10
536
+ invoice_tax_iva_5 = InvoiceTax (
537
+ name = self .tax_iva_5 .name , base = base_bruta ,
538
+ tax_amount = base_bruta * self .tax_iva_5 .amount , tax_id = self .tax_iva_5
539
+ )
540
+ tax_line = [
541
+ invoice_tax_iva_5
542
+ ]
543
+ n_total_amount = 0
544
+ n_total_tax = 0
545
+ for tl in tax_line :
546
+ n_total_amount += tl .base + tl .tax_amount
547
+ n_total_tax += tl .tax_amount
548
+
549
+ n_date_invoice = '2023-01-01'
550
+ n_period = Period (name = '01/2023' )
551
+
552
+ if fecha_facturas_recti :
553
+ b_date_invoice = fecha_facturas_recti
554
+ y ,m ,d = fecha_facturas_recti .split ('-' )
555
+ b_period = Period (name = '{}/{}' .format (m ,y ))
556
+ else :
557
+ b_date_invoice = '2024-10-01'
558
+ b_period = Period (name = '01/2024' )
559
+ refund_tax_line = tax_line [:]
560
+ for invoice_tax in refund_tax_line :
561
+ invoice_tax .tax_amount = - 1 * abs (invoice_tax .tax_amount )
562
+
563
+ orig_invoice = Invoice (
564
+ invoice_type = 'out_invoice' ,
565
+ journal_id = journal ,
566
+ rectificative_type = 'N' ,
567
+ rectifying_id = False ,
568
+ number = 'FEmitRectificada{}' .format (self .invoice_number ),
569
+ partner_id = self .partner_invoice ,
570
+ address_contact_id = self .address_contact_id ,
571
+ company_id = self .company ,
572
+ amount_total = n_total_amount ,
573
+ amount_untaxed = base_bruta ,
574
+ amount_tax = n_total_tax ,
575
+ period_id = n_period ,
576
+ date_invoice = n_date_invoice ,
577
+ tax_line = tax_line ,
578
+ invoice_line = [], # no se usa
579
+ sii_registered = self .sii_registered ,
580
+ fiscal_position = self .fiscal_position ,
581
+ sii_description = self .sii_description ,
582
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
583
+ )
584
+
585
+ r_invoice = Invoice (
586
+ invoice_type = 'out_invoice' ,
587
+ journal_id = journal ,
588
+ rectificative_type = 'R' ,
589
+ rectifying_id = orig_invoice ,
590
+ number = 'FRectEmit{}' .format (self .invoice_number ),
591
+ partner_id = self .partner_invoice ,
592
+ address_contact_id = self .address_contact_id ,
593
+ company_id = self .company ,
594
+ amount_total = n_total_amount ,
595
+ amount_untaxed = base_bruta ,
596
+ amount_tax = n_total_tax ,
597
+ period_id = b_period ,
598
+ date_invoice = b_date_invoice ,
599
+ tax_line = tax_line ,
600
+ invoice_line = self .invoice_line ,
601
+ sii_registered = self .sii_registered ,
602
+ fiscal_position = self .fiscal_position ,
603
+ sii_description = self .sii_description ,
604
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
605
+ )
606
+ b_invoice = Invoice (
607
+ invoice_type = 'out_refund' ,
608
+ journal_id = journal ,
609
+ rectificative_type = 'B' ,
610
+ rectifying_id = orig_invoice ,
611
+ number = 'FEmitRectificada{}' .format (self .invoice_number ),
612
+ partner_id = self .partner_invoice ,
613
+ address_contact_id = self .address_contact_id ,
614
+ company_id = self .company ,
615
+ amount_total = - 1 * n_total_amount ,
616
+ amount_untaxed = - 1 * base_bruta ,
617
+ amount_tax = - 1 * n_total_tax ,
618
+ period_id = b_period ,
619
+ date_invoice = b_date_invoice ,
620
+ tax_line = refund_tax_line ,
621
+ invoice_line = [], # no se usa
622
+ sii_registered = self .sii_registered ,
623
+ fiscal_position = self .fiscal_position ,
624
+ sii_description = self .sii_description ,
625
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
626
+ )
627
+ r2_invoice = Invoice (
628
+ invoice_type = 'out_invoice' ,
629
+ journal_id = journal ,
630
+ rectificative_type = 'R' ,
631
+ rectifying_id = r_invoice ,
632
+ number = 'FRectEmit{}' .format (self .invoice_number ),
633
+ partner_id = self .partner_invoice ,
634
+ address_contact_id = self .address_contact_id ,
635
+ company_id = self .company ,
636
+ amount_total = n_total_amount ,
637
+ amount_untaxed = base_bruta ,
638
+ amount_tax = n_total_tax ,
639
+ period_id = b_period ,
640
+ date_invoice = b_date_invoice ,
641
+ tax_line = tax_line ,
642
+ invoice_line = self .invoice_line ,
643
+ sii_registered = self .sii_registered ,
644
+ fiscal_position = self .fiscal_position ,
645
+ sii_description = self .sii_description ,
646
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
647
+ )
648
+ b2_invoice = Invoice (
649
+ invoice_type = 'out_refund' ,
650
+ journal_id = journal ,
651
+ rectificative_type = 'B' ,
652
+ rectifying_id = r_invoice ,
653
+ number = 'FEmitRectificada{}' .format (self .invoice_number ),
654
+ partner_id = self .partner_invoice ,
655
+ address_contact_id = self .address_contact_id ,
656
+ company_id = self .company ,
657
+ amount_total = - 1 * n_total_amount ,
658
+ amount_untaxed = - 1 * base_bruta ,
659
+ amount_tax = - 1 * n_total_tax ,
660
+ period_id = b_period ,
661
+ date_invoice = b_date_invoice ,
662
+ tax_line = refund_tax_line ,
663
+ invoice_line = [], # no se usa
664
+ sii_registered = self .sii_registered ,
665
+ fiscal_position = self .fiscal_position ,
666
+ sii_description = self .sii_description ,
667
+ sii_out_clave_regimen_especial = self .sii_out_clave_regimen_especial ,
668
+ )
669
+ return r2_invoice , b2_invoice
670
+ def get_out_refund_mulitple_invoice (self , fecha_facturas_recti = None ):
432
671
journal = Journal (
433
672
name = u'Factura de Energía Rectificativa Emitida'
434
673
)
0 commit comments