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; const bool only_one_paiv = ini_get_bool(CONFIG_DITTA, "cg", "OnlyOnePaIV");
TRectype from(LF_CLIFO);
TLocalisamfile& clifo = app().get_relation()->lfile(LF_CLIFO); from.put(CLI_TIPOCF, m.get(F_TIPOCF));
if (!f.empty() && !clifo.empty()) from.put(CLI_COFI, m.get(F_COFI));
{
clifo.zero() ;
const char t1 = msk.get(F_TIPOCF)[0] ;
clifo.put(CLI_TIPOCF, t1); TCursor c(new TRelation(LF_CLIFO), "", 4, &from, &from);
clifo.put(CLI_COFI, f.get()); const TString4 alleg = m.get(F_ALLEG);
clifo.setkey(4) ; const bool multi_clifo = c.items() > 1;
clifo.read() ; const bool not_dup = (alleg != "4" && alleg != "6" & alleg != "G");
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)) c = 0L;
{
f.message_box(FR("Codice fiscale già utilizzato per il codice %c/%ld"), const char * tipo = c.curr().get(CLI_TIPOCF) == "C" ? "cliente" : "fornitore";
t, s); const long codice = c.curr().get_long(CLI_CODCF);
}
} if (only_one_paiv)
{
return ok ; if (multi_clifo)
{
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
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));
TLocalisamfile clifo(LF_CLIFO) ; from.put(CLI_STATOPAIV, m.get(F_STATOPAIV));
clifo.put(CLI_TIPOCF, msk.get(F_TIPOCF)) ; from.put(CLI_PAIV, m.get(F_PAIV));
clifo.put(CLI_STATOPAIV, msk.get(F_STATOPAIV)) ;
clifo.put(CLI_PAIV, f.get()) ; TCursor c(new TRelation(LF_CLIFO), "", 5, &from, &from);
clifo.setkey(5) ;
const int err = clifo.read() ; const TString4 alleg = m.get(F_ALLEG);
if (err == NOERR) const bool multi_clifo = c.items();
{ const bool not_dup = (alleg != "4" && alleg != "7" & alleg != "G");
const long s = clifo.get_long(CLI_CODCF);
const long s1 = msk.get_long(F_CODCF); c = 0L;
if (s1 != s)
ok = f.error_box(FR("Partita IVA gia' utilizzata per il codice %ld" const char * tipo = c.curr().get(CLI_TIPOCF) == "C" ? "cliente" : "fornitore";
"\nsenza avere indicato il valore 4, 7 o G nell'inserimento in allegato"), s); const long codice = c.curr().get_long(CLI_CODCF);
}
} if (only_one_paiv)
{
return ok; if (multi_clifo)
{
if (supervisor())
{
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);
}
else
return f.error_box(FR("Partita IVA gia' utilizzata per il codice %s %ld"), tipo, codice);
}
}
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);
}
return true;
} }
// Controlla la presenza di Codice Fiscale e/o Partita IVA // Controlla la presenza di Codice Fiscale e/o Partita IVA
@ -231,7 +259,7 @@ HIDDEN bool almeno_cf_o_pi(TMask_field& f)
const TEdit_field& cofi = m.efield(F_COFI); const TEdit_field& cofi = m.efield(F_COFI);
if (cofi.empty()) // Dal 2007 serve il codice fiscale if (cofi.empty()) // Dal 2007 serve il codice fiscale
ok = cofi.yesno_box(TR("Codice fiscale assente per residente in Italia : lo accetto ugualmente ?")); ok = cofi.yesno_box(TR("Codice fiscale assente per residente in Italia : lo accetto ugualmente ?"));
// Se NON sono privato (alleg!=6), serve partita IVA // Se NON sono privato (alleg != 6), serve partita IVA
if (ok) if (ok)
{ {
const TEdit_field& paiv = m.efield(F_PAIV); const TEdit_field& paiv = m.efield(F_PAIV);
@ -245,56 +273,32 @@ 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 (!m.query_mode())
if (key == K_ENTER && !f.dirty() && !m.query_mode()) {
ok = ((TEdit_field&)f).validate(key); if (f.running_check(key))
{
if (ok && f.to_check(key)) const TString& s1 = f.get();
{
if (key == K_TAB) if (s1.full())
{ m.set(F_TIPOPERS, isdigit(s1[0]) ? "G" : "F");
const TString& s1 = f.get(); }
if (s1.full()) else
m.set(F_TIPOPERS, isdigit(s1[0]) ? "G" : "F"); if (f.final_check(key))
} return f.validate(key) && no_dup_fis(f, key) && almeno_cf_o_pi(f);
const int alleg = m.get_int(F_ALLEG); }
if (!m.query_mode() && key == K_ENTER && alleg != 4) return true;
{
ok = no_dup_fis(f, key);
if (ok)
ok = almeno_cf_o_pi(f);
}
}
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,30 +544,39 @@ 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);
else if(f.get() == "F") m.enable(F_COD_RFSO_G);
{ m.set(F_COD_RFSO_F, "");
f.mask().show(F_COD_RFSO_F); m.hide(F_COD_RFSO_F);
f.mask().enable(F_COD_RFSO_F); m.disable(F_COD_RFSO_F);
f.mask().set(F_COD_RFSO_G, ""); }
f.mask().hide(F_COD_RFSO_G); else
f.mask().disable(F_COD_RFSO_G); {
} if (val == "F")
else {
{ m.show(F_COD_RFSO_F);
f.mask().set(F_COD_RFSO_F, ""); m.enable(F_COD_RFSO_F);
f.mask().set(F_COD_RFSO_G, ""); m.set(F_COD_RFSO_G, "");
f.mask().hide(F_COD_RFSO_F); m.hide(F_COD_RFSO_G);
f.mask().hide(F_COD_RFSO_G); m.disable(F_COD_RFSO_G);
f.mask().disable(F_COD_RFSO_F); }
f.mask().disable(F_COD_RFSO_G); else
{
f.mask().set(F_COD_RFSO_F, "");
f.mask().set(F_COD_RFSO_G, "");
f.mask().hide(F_COD_RFSO_F);
f.mask().hide(F_COD_RFSO_G);
f.mask().disable(F_COD_RFSO_F);
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"));