Skip to content

Commit bf27206

Browse files
committed
Merge PR #4984 into 18.0
Signed-off-by primes2h
2 parents 08ce60d + 93eaf8a commit bf27206

File tree

6 files changed

+79
-9
lines changed

6 files changed

+79
-9
lines changed

l10n_it_riba_oca/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"account_due_list",
2424
"base_iban",
2525
"l10n_it_abicab",
26-
"l10n_it_edi",
26+
"l10n_it_edi_related_document",
2727
"account_payment_term_extension",
2828
],
2929
"data": [

l10n_it_riba_oca/models/riba.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,25 @@ def _compute_line_values(self):
283283
amount = fields.Float(compute="_compute_line_values")
284284
invoice_date = fields.Char(compute="_compute_line_values", size=256)
285285
invoice_number = fields.Char(compute="_compute_line_values", size=256)
286-
cig = fields.Char(string="CIG", size=256)
287-
cup = fields.Char(string="CUP", size=256)
286+
cig = fields.Char(compute="_compute_cig_cup_values", string="CIG", size=256)
287+
cup = fields.Char(compute="_compute_cig_cup_values", string="CUP", size=256)
288+
289+
def _compute_cig_cup_values(self):
290+
for line in self:
291+
line.cig = ""
292+
line.cup = ""
293+
related_documents = line.mapped(
294+
"move_line_ids.move_line_id.move_id.related_document_ids"
295+
)
296+
297+
for related_document in related_documents:
298+
if related_document.cup:
299+
line.cup = str(related_document.cup)
300+
if related_document.cig:
301+
line.cig = str(related_document.cig)
302+
# Stop if at least one value is found
303+
if line.cup or line.cig:
304+
break
288305

289306
sequence = fields.Integer("Number")
290307
move_line_ids = fields.One2many(

l10n_it_riba_oca/readme/USAGE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ impostata con la data di scadenza della RiBa, ma è possibile modificarla in due
3333
- successivamente a pagamento effettivamente avvenuto selezionando la
3434
registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data
3535
di pagamento RiBa".
36+
37+
Non è possibile emettere Riba per fatture verso Enti che richiedono più di un CIG e un CUP differenti per fattura.
38+
In questo caso particolare, emettere più fatture.
39+
Non è possibile raggruppare Riba in fase di emissione se le fatture contengono CIG e CUP differenti. Verrà creata una riga di distinta per ogni fattura.

l10n_it_riba_oca/tests/test_riba.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ def test_riba_fatturapa(self):
455455
},
456456
)
457457
],
458+
"related_document_ids": [
459+
(
460+
0,
461+
0,
462+
{
463+
"type": "order",
464+
"name": "SO1232",
465+
"cig": "7987210EG5",
466+
"cup": "H71N17000690124",
467+
},
468+
)
469+
],
458470
}
459471
)
460472
invoice._onchange_riba_partner_bank_id()
@@ -472,8 +484,12 @@ def test_riba_fatturapa(self):
472484
riba_list_id = action and action["res_id"] or False
473485
riba_list = self.slip_model.browse(riba_list_id)
474486
riba_list.confirm()
487+
self.assertEqual(riba_list.line_ids[0].cig, "7987210EG5")
488+
self.assertEqual(riba_list.line_ids[0].cup, "H71N17000690124")
475489
wizard_riba_export = self.env["riba.file.export"].create({})
476490
wizard_riba_export.with_context(active_ids=[riba_list.id]).act_getfile()
491+
riba_txt = base64.decodebytes(wizard_riba_export.riba_txt)
492+
self.assertTrue(b"CIG: 7987210EG5 CUP: H71N17000690124" in riba_txt)
477493
# Assert
478494
file_content = base64.decodebytes(wizard_riba_export.riba_txt).decode()
479495
self.assertNotIn("INV/2025/00004", file_content)
@@ -508,6 +524,18 @@ def test_riba_fatturapa_group(self):
508524
},
509525
)
510526
],
527+
"related_document_ids": [
528+
(
529+
0,
530+
0,
531+
{
532+
"type": "order",
533+
"name": "SO1232",
534+
"cig": "7987210EG5",
535+
"cup": "H71N17000690124",
536+
},
537+
)
538+
],
511539
}
512540
)
513541
invoice._onchange_riba_partner_bank_id()
@@ -533,6 +561,18 @@ def test_riba_fatturapa_group(self):
533561
},
534562
)
535563
],
564+
"related_document_ids": [
565+
(
566+
0,
567+
0,
568+
{
569+
"type": "order",
570+
"name": "SO1232",
571+
"cig": "7987210EG5",
572+
"cup": "H71N17000690125",
573+
},
574+
)
575+
],
536576
}
537577
)
538578
invoice1._onchange_riba_partner_bank_id()
@@ -556,6 +596,9 @@ def test_riba_fatturapa_group(self):
556596
self.assertTrue(len(riba_list.line_ids), 2)
557597
wizard_riba_export = self.env["riba.file.export"].create({})
558598
wizard_riba_export.with_context(active_ids=[riba_list.id]).act_getfile()
599+
riba_txt = base64.decodebytes(wizard_riba_export.riba_txt)
600+
self.assertTrue(b"CIG: 7987210EG5 CUP: H71N17000690124" in riba_txt)
601+
self.assertTrue(b"CIG: 7987210EG5 CUP: H71N17000690125" in riba_txt)
559602
# Assert
560603
file_content = base64.decodebytes(wizard_riba_export.riba_txt).decode()
561604
self.assertNotIn("INV/2025/00008", file_content)

l10n_it_riba_oca/wizard/wizard_riba_file_export.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,8 @@ def act_getfile(self):
392392
unidecode(line.partner_id.ref and line.partner_id.ref[:16] or ""),
393393
unidecode(line.invoice_number[:40]),
394394
line.invoice_date,
395-
unidecode(f"CIG: {line.cig if line.cig else ''} "),
396-
"",
397-
unidecode(f"CUP: {line.cup if line.cup else ''} "),
398-
"",
395+
unidecode(f"CIG: {line.cig} " if line.cig else ""),
396+
unidecode(f"CUP: {line.cup} " if line.cup else ""),
399397
]
400398
array_riba.append(riba)
401399

l10n_it_riba_oca/wizard/wizard_riba_issue.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ def create_rdl(
6262
self.env._("It is possible to issue C/O for posted move only!")
6363
)
6464
do_group_riba = True
65-
if len({f"{x.l10n_it_cig}{x.l10n_it_cup}" for x in move_lines.move_id}) > 1:
65+
if (
66+
len(
67+
{
68+
f"{x.cig}{x.cup}"
69+
for x in move_lines.mapped("move_id.related_document_ids")
70+
}
71+
)
72+
> 1
73+
):
6674
do_group_riba = False
6775
if do_group_riba:
6876
for move_line in move_lines:
@@ -90,7 +98,7 @@ def create_rdl(
9098
invoice=move_line.move_id.name,
9199
)
92100
)
93-
if move_line.partner_id.group_riba: # and do_group_riba:
101+
if move_line.partner_id.group_riba and do_group_riba:
94102
for key in grouped_lines:
95103
if (
96104
key[0] == move_line.partner_id.id

0 commit comments

Comments
 (0)