Patch level : 12.00 1360

Files correlati     : ve0.exe ve2400.msk

Commento:
Agiunto il flag  OnlyOnePaIV nel paragrafo cg ddi ditta.ini per bloccare l'inserimento dei clienti/fornitori per gli utenti che non sono supervisori.
This commit is contained in:
Alessandro Bonazzi 2024-10-07 19:56:04 +02:00
parent c7232a0d5b
commit 1cc5cb6358

View File

@ -154,64 +154,92 @@ bool TClifo_application::get_next_key(TToken_string& key)
HIDDEN bool no_dup_fis(TMask_field& f, KEY key) HIDDEN bool no_dup_fis(TMask_field& f, KEY key)
{ {
bool ok = true; TMask& m = f.mask();
TMask& msk = f.mask() ; if (f.full())
if (msk.query_mode() || !f.to_check(key))
return ok;
TLocalisamfile& clifo = app().get_relation()->lfile(LF_CLIFO);
if (!f.empty() && !clifo.empty())
{ {
clifo.zero() ; const bool only_one_paiv = ini_get_bool(CONFIG_DITTA, "cg", "OnlyOnePaIV");
const char t1 = msk.get(F_TIPOCF)[0] ; TRectype from(LF_CLIFO);
clifo.put(CLI_TIPOCF, t1); from.put(CLI_TIPOCF, m.get(F_TIPOCF));
clifo.put(CLI_COFI, f.get()); from.put(CLI_COFI, m.get(F_COFI));
clifo.setkey(4) ;
clifo.read() ;
clifo.setkey(1) ;
const char t = clifo.get_char(CLI_TIPOCF);
const long s = clifo.get_long(CLI_CODCF);
const long s1 = msk.get_long(F_CODCF);
if (clifo.good() && (t1 != t || s1 != s)) TCursor c(new TRelation(LF_CLIFO), "", 4, &from, &from);
const TString4 alleg = m.get(F_ALLEG);
const bool multi_clifo = c.items() > 1;
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)
{ {
f.message_box(FR("Codice fiscale già utilizzato per il codice %c/%ld"), if (multi_clifo)
t, s); {
if (supervisor())
{
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);
}
else
return f.error_box(FR("Codice fiscale già utilizzato per il codice %s %ld"), tipo, codice);
} }
} }
else
return ok ; 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);
}
return true ;
} }
HIDDEN bool no_dup_iva(TMask_field& f, KEY key) HIDDEN bool no_dup_iva(TMask_field& f, KEY key)
{ {
bool ok = true; TMask& m = f.mask() ;
TMask& msk = f.mask() ; if (f.full())
if (msk.query_mode() || !f.to_check(key)) {
return ok; const bool only_one_paiv = ini_get_bool(CONFIG_DITTA, "cg", "OnlyOnePaIV");
TRectype from(LF_CLIFO);
if (!f.empty()) from.put(CLI_TIPOCF, m.get(F_TIPOCF));
from.put(CLI_STATOPAIV, m.get(F_STATOPAIV));
from.put(CLI_PAIV, m.get(F_PAIV));
TCursor c(new TRelation(LF_CLIFO), "", 5, &from, &from);
const TString4 alleg = m.get(F_ALLEG);
const bool multi_clifo = c.items();
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)
{ {
TLocalisamfile clifo(LF_CLIFO) ; if (multi_clifo)
clifo.put(CLI_TIPOCF, msk.get(F_TIPOCF)) ;
clifo.put(CLI_STATOPAIV, msk.get(F_STATOPAIV)) ;
clifo.put(CLI_PAIV, f.get()) ;
clifo.setkey(5) ;
const int err = clifo.read() ;
if (err == NOERR)
{ {
const long s = clifo.get_long(CLI_CODCF); if (supervisor())
const long s1 = msk.get_long(F_CODCF); {
if (s1 != s) if (not_dup)
ok = f.error_box(FR("Partita IVA gia' utilizzata per il codice %ld" 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"),
"\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), s); tipo, codice);
}
else
return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s %ld"), tipo, codice);
} }
} }
else
return ok; 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);
}
return true;
} }
// Controlla la presenza di Codice Fiscale e/o Partita IVA // Controlla la presenza di Codice Fiscale e/o Partita IVA
@ -246,55 +274,31 @@ HIDDEN bool almeno_cf_o_pi(TMask_field& f)
HIDDEN bool cofi_handler(TMask_field& f, KEY key) HIDDEN bool cofi_handler(TMask_field& f, KEY key)
{ {
bool ok = true;
TMask& m = f.mask(); TMask& m = f.mask();
if (key == K_ENTER && !f.dirty() && !m.query_mode())
ok = ((TEdit_field&)f).validate(key);
if (ok && f.to_check(key)) if (!m.query_mode())
{ {
if (key == K_TAB) if (f.running_check(key))
{ {
const TString& s1 = f.get(); const TString& s1 = f.get();
if (s1.full()) if (s1.full())
m.set(F_TIPOPERS, isdigit(s1[0]) ? "G" : "F"); m.set(F_TIPOPERS, isdigit(s1[0]) ? "G" : "F");
} }
const int alleg = m.get_int(F_ALLEG); else
if (!m.query_mode() && key == K_ENTER && alleg != 4) if (f.final_check(key))
{ return f.validate(key) && no_dup_fis(f, key) && almeno_cf_o_pi(f);
ok = no_dup_fis(f, key);
if (ok)
ok = almeno_cf_o_pi(f);
} }
} return true;
return ok;
} }
HIDDEN bool paiv_handler(TMask_field& f, KEY key) HIDDEN bool paiv_handler(TMask_field& f, KEY key)
{ {
bool ok = true;
const TMask& m = f.mask(); const TMask& m = f.mask();
if (key == K_ENTER && !m.query_mode()) if (!m.query_mode() && f.final_check(key))
{ return f.validate(key) && no_dup_iva(f, key) && almeno_cf_o_pi(f);
if (!f.dirty()) return true;
ok = ((TEdit_field&)f).validate(key);
if (ok)
{
const TString4 alleg = m.get(F_ALLEG);
if (alleg != "4" && alleg != "7" && alleg != "G")
{
ok = no_dup_iva(f, key);
if (ok)
ok = almeno_cf_o_pi(f);
}
}
}
return ok;
} }
bool TClifo_application::tipocf_handler(TMask_field& f, KEY key) bool TClifo_application::tipocf_handler(TMask_field& f, KEY key)
@ -540,21 +544,28 @@ bool TClifo_application::comi_handler(TMask_field& f, KEY k)
bool TClifo_application::rfso_handler(TMask_field& f, KEY key) bool TClifo_application::rfso_handler(TMask_field& f, KEY key)
{ {
if(f.get() == "G") if (f.to_check(key))
{ {
f.mask().show(F_COD_RFSO_G); TMask & m = f.mask();
f.mask().enable(F_COD_RFSO_G); const TString & val = f.get();
f.mask().set(F_COD_RFSO_F, "");
f.mask().hide(F_COD_RFSO_F); if (val == "G")
f.mask().disable(F_COD_RFSO_F); {
m.show(F_COD_RFSO_G);
m.enable(F_COD_RFSO_G);
m.set(F_COD_RFSO_F, "");
m.hide(F_COD_RFSO_F);
m.disable(F_COD_RFSO_F);
} }
else if(f.get() == "F") else
{ {
f.mask().show(F_COD_RFSO_F); if (val == "F")
f.mask().enable(F_COD_RFSO_F); {
f.mask().set(F_COD_RFSO_G, ""); m.show(F_COD_RFSO_F);
f.mask().hide(F_COD_RFSO_G); m.enable(F_COD_RFSO_F);
f.mask().disable(F_COD_RFSO_G); m.set(F_COD_RFSO_G, "");
m.hide(F_COD_RFSO_G);
m.disable(F_COD_RFSO_G);
} }
else else
{ {
@ -565,6 +576,8 @@ bool TClifo_application::rfso_handler(TMask_field& f, KEY key)
f.mask().disable(F_COD_RFSO_F); f.mask().disable(F_COD_RFSO_F);
f.mask().disable(F_COD_RFSO_G); f.mask().disable(F_COD_RFSO_G);
} }
}
}
return true; return true;
} }
@ -608,12 +621,6 @@ HIDDEN bool alleg_handler(TMask_field& f, KEY key)
TMask& m = f.mask(); TMask& m = f.mask();
if (tipoall == 4)
{
TToken_string key; key.format("%c|%ld", m.get(F_TIPOCF)[0], m.get_long(F_CODALLEG));
const TRectype& coll = cache().get(LF_CLIFO, key);
}
if (key == K_ENTER) if (key == K_ENTER)
{ {
if (m.get_bool(F_OCCASIONALE)) if (m.get_bool(F_OCCASIONALE))
@ -656,16 +663,16 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key)
if (cod == m.get(F_CODCF)) if (cod == m.get(F_CODCF))
return error_box(TR("Il codice per allegato coincide con il codice anagrafico")); return error_box(TR("Il codice per allegato coincide con il codice anagrafico"));
const char tipo = m.get(F_TIPOCF)[0]; TToken_string key = m.get(F_TIPOCF);
key.add(cod);
TString8 key; key.format("%c|%s", tipo, (const char*)cod);
const TRectype& clifo = cache().get(LF_CLIFO, key); const TRectype& clifo = cache().get(LF_CLIFO, key);
if (clifo.empty())
return false;
if (clifo.empty())
return error_box(TR("Il codice per allegato assente"));
if (clifo.get(CLI_CODALLEG).full()) if (clifo.get(CLI_CODALLEG).full())
return error_box(TR("Codice non utilizzabile: contiene a sua volta un codice per allegato")); return error_box(TR("Codice non utilizzabile: contiene a sua volta un codice per allegato"));
if (clifo.get(CLI_PAIV).blank() && clifo.get(CLI_COFI).blank()) if (clifo.get(CLI_PAIV).blank() && clifo.get(CLI_COFI).blank())
return error_box(TR("Codice non utilizzabile: partita IVA e codice fiscale non specificati")); return error_box(TR("Codice non utilizzabile: partita IVA e codice fiscale non specificati"));