Patch level : 2.1 114

Files correlati     : cg2.exe
Ricompilazione Demo : [ ]
Commento            :

0000231
Se inserisco il flag di commessa obbligatoria sul piano dei conti a
livello di conto, questo non scatena il controllo nel momento in cui
utlizzo un qualunque sottoconto appartenente a quel conto.


git-svn-id: svn://10.65.10.50/trunk@12314 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-09-15 14:50:57 +00:00
parent 9233353811
commit 9766c35379
4 changed files with 37 additions and 22 deletions

View File

@ -792,16 +792,11 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
// La commessa è vuota: controlliamo se era obbligatoria // La commessa è vuota: controlliamo se era obbligatoria
const TString80 cms = r.get(CG_COMMESSA-FIRST_FIELD); const TString80 cms = r.get(CG_COMMESSA-FIRST_FIELD);
if (c.tipo() <= ' ' && cms.blank()) if (c.tipo() <= ' ' && cms.blank() && c.required_cdc())
{ {
TToken_string k = c.string(); TToken_string k = c.string(); k.replace('|', ' ');
const TRectype& pc = cache().get(LF_PCON, k); return f.error_box(FR("Il codice commessa è obbligatorio per il conto %s della riga %d"),
if (pc.get_bool(PCN_CMSNEEDED)) (const char*)k, i+1);
{
k.replace('|', ' ');
return f.error_box(FR("Il codice commessa è obbligatorio per il conto %s della riga %d"),
(const char*)k, i+1);
}
} }
} }
} }
@ -1927,11 +1922,10 @@ bool TPrimanota_application::iva_sottoconto_handler(TMask_field& f, KEY key)
} }
} }
TToken_string k = zio.string();
const TRectype& pc = cache().get(LF_PCON, k); if (key == K_ENTER && cdc.empty() && zio.required_cdc())
if (key == K_ENTER && cdc.empty() && pc.get_bool(PCN_CMSNEEDED))
{ {
k.replace(k.separator(), ' '); TToken_string k = zio.string(); k.replace(k.separator(), ' ');
return cdc.error_box(FR("Il conto %s richiede che sia specificato il codice CDC/Commessa"), return cdc.error_box(FR("Il conto %s richiede che sia specificato il codice CDC/Commessa"),
(const char*)k); (const char*)k);
} }

View File

@ -919,19 +919,38 @@ const char* TBill::string(int mode) const
return s; return s;
} }
bool TBill::required_cdc() const
{
TString16 key;
for (int i = 2; i >= 0; i--)
{
key.format("%d|%d|%ld", gruppo(), i > 0 ? conto() : 0, i > 1 ? sottoconto() : 0);
const TRectype& sottoc = cache().get(LF_PCON, key);
if (sottoc.get_bool(PCN_CMSNEEDED))
return true;
}
return false;
}
bool TBill::default_cdc(TString& cdc, TString& fas) const bool TBill::default_cdc(TString& cdc, TString& fas) const
{ {
bool ok = tipo() <= ' ' && sottoconto() > 0; bool ok = tipo() <= ' ' && sottoconto() > 0;
if (ok) if (ok)
{ {
TString16 key; key.format("%d|%d|%ld", gruppo(), conto(), sottoconto()); TString16 key;
const TRectype& pcon = cache().get(LF_PCON, key); for (int i = 2; i >= 0; i--)
ok = !pcon.empty();
if (ok)
{ {
cdc = pcon.get(PCN_CODCMS); key.format("%d|%d|%ld", gruppo(), i > 0 ? conto() : 0, i > 1 ? sottoconto() : 0);
fas = pcon.get(PCN_FASCMS); const TRectype& pcon = cache().get(LF_PCON, key);
if (!pcon.empty())
{
cdc = pcon.get(PCN_CODCMS);
fas = pcon.get(PCN_FASCMS);
if (cdc.not_empty() || fas.not_empty())
break;
}
} }
} }
return ok && cdc.not_empty(); return ok && (cdc.not_empty() || fas.not_empty());
} }

View File

@ -236,6 +236,7 @@ public:
const char* string(int mode = 0) const; const char* string(int mode = 0) const;
bool required_cdc() const;
bool default_cdc(TString& cdc, TString& fas) const; bool default_cdc(TString& cdc, TString& fas) const;
}; };

View File

@ -648,8 +648,9 @@ tipo_movimento TRiga_partite::tipo() const
char TRiga_partite::sezione_ritsoc() const char TRiga_partite::sezione_ritsoc() const
{ {
TString16 key; key << get(PART_CODCAUS) << "|14"; // Riga ritenute sociali TString16 key; key << get(PART_CODCAUS) << "|14"; // Riga ritenute sociali
const char sezrs = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0]; const char sez_cau = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0];
return sezrs > ' ' ? (sezrs == 'D' ? 'A' : 'D') : sezione(); const char sez_rit = sez_cau > ' ' ? (sez_cau == 'D' ? 'A' : 'D') : sezione();
return sez_rit;
} }
// Legge le rate relative ad una riga di fattura // Legge le rate relative ad una riga di fattura