From df65ac13c9056b403ce5c9c5238cd5404a3a9fb8 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Thu, 7 Nov 2024 01:28:33 +0100 Subject: [PATCH] Patch level : 12.00 1368 Files correlati : cg0.exe Commento: Corretto controllo partite iva e codci fiscali duplicati --- src/cg/cg0200.cpp | 51 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/cg/cg0200.cpp b/src/cg/cg0200.cpp index 00f534f34..64a1ec1f9 100755 --- a/src/cg/cg0200.cpp +++ b/src/cg/cg0200.cpp @@ -166,13 +166,21 @@ HIDDEN bool no_dup_fis(TMask_field& f, KEY key) TCursor c(new TRelation(LF_CLIFO), "", 4, &from, &from); const TString4 alleg = m.get(F_ALLEG); - const bool multi_clifo = c.items() > 1; + const long items = c.items(); + const long this_cf = m.get_long(F_CODCF); + long dup_cf = 0L; + + for (c = 0L; dup_cf == 0L && c.pos() < items; ++c) + { + const long codcf = c.curr().get_long(CLI_CODCF); + + if (codcf != this_cf && !c.curr().get_bool(CLI_SOSPESO)) + dup_cf = codcf; + } + + const bool multi_clifo = dup_cf != 0L; const bool not_dup = (alleg != "4" && alleg != "6" & alleg != "G"); - - c = 0L; - const char * tipo = c.curr().get(CLI_TIPOCF) == "C" ? "cliente" : "fornitore"; - const long codice = c.curr().get_long(CLI_CODCF); if (only_one_paiv) { @@ -182,16 +190,16 @@ HIDDEN bool no_dup_fis(TMask_field& f, KEY key) { if (not_dup) return f.error_box(FR("Codice fiscale già utilizzato per il codice %s %ld\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), - tipo, codice); + tipo, dup_cf); } else - return f.error_box(FR("Codice fiscale già utilizzato per il codice %s %ld"), tipo, codice); + return f.error_box(FR("Codice fiscale già utilizzato per il codice %s %ld"), tipo, dup_cf); } } else if (multi_clifo && not_dup) return f.error_box(FR("Codice fiscale già utilizzato per il codice %s %ld\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), - tipo, codice); + tipo, dup_cf); } return true ; } @@ -212,13 +220,21 @@ HIDDEN bool no_dup_iva(TMask_field& f, KEY key) TCursor c(new TRelation(LF_CLIFO), "", 5, &from, &from); const TString4 alleg = m.get(F_ALLEG); - const bool multi_clifo = c.items(); + const long items = c.items(); + const long this_cf = m.get_long(F_CODCF); + long dup_cf = 0L; + + for (c = 0L; dup_cf == 0L && c.pos() < items; ++c) + { + const long codcf = c.curr().get_long(CLI_CODCF); + + if (codcf != this_cf && !c.curr().get_bool(CLI_SOSPESO)) + dup_cf = codcf; + } + + const bool multi_clifo = dup_cf != 0L; const bool not_dup = (alleg != "4" && alleg != "7" & alleg != "G"); - - c = 0L; - const char * tipo = c.curr().get(CLI_TIPOCF) == "C" ? "cliente" : "fornitore"; - const long codice = c.curr().get_long(CLI_CODCF); if (only_one_paiv) { @@ -228,16 +244,16 @@ HIDDEN bool no_dup_iva(TMask_field& f, KEY key) { if (not_dup) return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s ld\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), - tipo, codice); + tipo, dup_cf); } else - return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s %ld"), tipo, codice); + return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s %ld"), tipo, dup_cf); } } else if (multi_clifo && not_dup) return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s %ld\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), - tipo, codice); + tipo, dup_cf); } return true; } @@ -246,10 +262,12 @@ HIDDEN bool no_dup_iva(TMask_field& f, KEY key) HIDDEN bool almeno_cf_o_pi(TMask_field& f) { bool ok = true; + if (f.empty() && !app().is_transaction()) // Evita rischieste inutili durante le transazioni { const TMask& m = f.mask(); const TString& stato = m.get(F_STATOPAIV); + if (stato.blank() || stato == "IT") // Se sono un italiano ... { const bool occas = m.get_bool(F_OCCASIONALE); @@ -319,7 +337,6 @@ bool TClifo_application::tipocf_handler(TMask_field& f, KEY key) { if (key == K_TAB && f.focusdirty()) app().update_navigation_bar(); - return true; }