Patch level : 12.0 900

Files correlati     : ve0.exe ve6.exe
Commento            :

Contollata la sottocategoria e il codice spesa conai in fatturazione bolle
This commit is contained in:
Alessandro Bonazzi 2019-11-16 11:25:51 +01:00
parent 3cde95efb6
commit 466c4bad25
5 changed files with 150 additions and 30 deletions

@ -403,7 +403,7 @@ bool TFatturazione_bolle_app::test_dicint(const TMask& m)
TString msg(80);
TLog_report lerr(TR("Errori controllo plafond"));
TLog_report lerr(TR("Errori controllo plafond e CONAI"));
lerr.log(0,"\n");
bool err = false;
for (int c = 0; c < tot_cli; c++)
@ -412,13 +412,13 @@ bool TFatturazione_bolle_app::test_dicint(const TMask& m)
TLi_manager currentCli(tipocf, codcli, ad); // Inizializzo l'oggetto per la gestione del plafond
if(currentCli.has_valid_plafond())
if (currentCli.has_valid_plafond())
{
TLista_documenti din; // Legge tutti i documenti di input
din.read('D', tipocf, codcli, anno, tipidoc, statidoc, dd, ad, codnum, dn, an);
if (din.items() > 0)
{
err |= currentCli.test_plafond(din, lerr);
err |= currentCli.test_plafond(din, lerr);
}
}
}
@ -431,6 +431,103 @@ bool TFatturazione_bolle_app::test_dicint(const TMask& m)
}
return true;
}
// Effettuo un test per i clienti che hanno un plafond attivo, se trovo delle bolle che fuoriescono chiedo se continuare
bool TFatturazione_bolle_app::test_CONAI(const TMask& m)
{
const TDate data_elab = m.get_date(F_DATA_ELAB);
const int anno = data_elab.year();
const long dc = m.get_long(F_CODICE_CLIFO_DA);
const long ac = m.get_long(F_CODICE_CLIFO_A);
const int da = m.get_int(F_CODICE_AGENTE_DA);
const int aa = m.get_int(F_CODICE_AGENTE_A);
const TString16 dz(m.get(F_CODICE_ZONA_DA));
const TString16 az(m.get(F_CODICE_ZONA_A));
const TDate dd = m.get_date(F_DATA_DOCUMENTO_DA);
TString st_da = m.get(F_DATA_DOCUMENTO_A); // qui verificare
const TDate ad = st_da.not_empty() ? (TDate)(const char*)st_da : data_elab;
const TString& codnum = m.get(F_CODICE_NUMERAZIONE);
const long dn = m.get_long(F_NUMERO_DOCUMENTO_DA);
const long an = m.get_long(F_NUMERO_DOCUMENTO_A);
TElaborazione& eld = *elab(m.get(F_CODICE_ELAB));
TToken_string tipidoc(24), statidoc(10);
eld.tipi_stati_iniziali(tipidoc, statidoc);
TTipo_documento t(eld.tipo_iniziale(0));
char tipocf(t.tipocf());
TLista_cf clienti(tipocf);
const int tot_cli = clienti.leggi_doc(eld, dd, ad, dc, ac, da, aa, dz, az);
TString msg(80);
TLog_report lerr(TR("Errori controllo CONAI"));
lerr.log(0, "\n");
bool err = false;
for (int c = 0; c < tot_cli; c++)
{
const long codcli = clienti[c]; // Codice cliente in esame
TConai conai;
{
TLista_documenti din; // Legge tutti i documenti di input
din.read('D', tipocf, codcli, anno, tipidoc, statidoc, dd, ad, codnum, dn, an);
const int nbolle = din.items();
for (int b = 0; b < nbolle; b++)
{
TDocumento & bolla = din[b];
const int nrows = bolla.physical_rows();
for (int r = 1; r <= nrows; r++)
{
TRiga_documento & row = bolla[r];
msg.format("Cliente %ld Bolla %ld Riga %d - ",
bolla.get_long(DOC_CODCF),
bolla.get_long(DOC_NDOC),
row.get_int(RDOC_NRIGA));
for (int i = 1; i <= FR_CMAX; i++)
{
const TString8 sottocat = row.get(conai_sottocat_name(i));
if (sottocat.full())
{
if (!conai.exist_sottocat(sottocat))
{
err = true;
TString msgerr(msg);
msgerr << format("Sottocategoria CONAI %s assente", (const char *)sottocat);
lerr.log(2, msgerr);
continue;
}
TSpesa_prest sp = conai.get_spesa(sottocat);
if (!sp.valid())
{
err = true;
TString msgerr(msg);
msgerr << sp.err_msg();
lerr.log(2, msgerr);
}
}
}
}
}
}
}
delete &eld;
if (err)
{
lerr.print_or_preview();
return false;
}
return true;
}
bool TFatturazione_bolle_app::clifo_da_fatt(const TMask& m) const
{
@ -456,7 +553,9 @@ void TFatturazione_bolle_app::main_loop()
{
continue;
}
const TString& select_from = m.get(F_SELEZIONE);
if (!test_CONAI(m))
continue;
const TString& select_from = m.get(F_SELEZIONE);
if (select_from != _default_selection)
ini_set_string(CONFIG_DITTA, "ve", "FATBOLSEL", _default_selection = select_from);

@ -30,7 +30,8 @@ public:
void process_by_ragsoc(const TMask& m);
void process_by_doc(const TMask& m);
void process_by_fatt(const TMask& m);
bool test_dicint(const TMask& m); // Effettua un test per la dichiarazione d'intenti
bool test_dicint(const TMask& m); // Effettua un test per la dichiarazione d'intenti
bool test_CONAI(const TMask& m); // Effettua un test per le sottocategorie CONAI
};
#endif

@ -124,6 +124,9 @@ class TDocumento_variable_field : public TVariable_field
class TSpesa_prest : public TRectype // velib01
{
TString16 _codice;
char _tipo;
protected:
const TString & cod() const { return get("COD"); }
@ -132,7 +135,8 @@ public:
public:
int read(const char* codice);
bool valid() const { return !empty(); }
const char * err_msg() const;
const TString& codice() const { return get("CODTAB"); }
char tipo() const { return get_char("S6"); }
bool is_qtavalore() const { return tipo() == 'V'; }

@ -158,8 +158,34 @@ int numerazioni_fatture(TString_array& num_fatture, TString_array& tip_fatture)
// TSpesa_prest
/////////////////////////////////////////////////////////////
const char * TSpesa_prest::err_msg() const
{
if (!valid())
{
switch (_tipo)
{
case RIGA_SPESEDOC:
return format("Spesa %s assente", (const char *) _codice);
break;
case RIGA_PRESTAZIONI:
return format("Prestazione %s assente", (const char *) _codice);
break;
case RIGA_RISORSE:
return format("Risorsa %s assente", (const char *) _codice);
break;
case RIGA_ATTREZZATURE:
return format("Attrezzatura %s assente", (const char *) _codice);
break;
default:
error_box("Spesa %s assente", (const char *) _codice);
break;
}
}
return "";
}
TSpesa_prest::TSpesa_prest(const char* codice, char tipo)
: TRectype(LF_TAB)
: TRectype(LF_TAB), _codice(codice), _tipo(tipo)
{
switch (tipo)
{
@ -179,35 +205,22 @@ TSpesa_prest::TSpesa_prest(const char* codice, char tipo)
settab("SPP");
break;
}
if (codice && *codice)
{
const int err = read(codice);
if (codice && *codice)
{
const int err = read(codice);
_codice = codice;
/*#ifdef DBG
if (err != NOERR)
switch (tipo)
{
case RIGA_SPESEDOC :
error_box("Spesa %s assente", codice);
break;
case RIGA_PRESTAZIONI :
error_box("Prestazione %s assente", codice);
break;
case RIGA_RISORSE :
error_box("Risorsa %s assente", codice);
break;
case RIGA_ATTREZZATURE :
error_box("Attrezzatura %s assente", codice);
break;
default :
error_box("Spesa %s assente", codice);
break;
}
}
error_box(err_msg());
#endif */
}
}
TSpesa_prest::TSpesa_prest(const TRectype& rec)
: TRectype(rec)
{
_codice = codice();
_tipo = genere();
}
char TSpesa_prest::genere() const

@ -3135,6 +3135,9 @@ void TDocumento::update_conai()
{
TSpesa_prest sp = conai.get_spesa(cod_sottocat);
if (!sp.valid())
error_box(sp.err_msg());
// Aggiungo la spesa
const real perc_esenz = cfven.get_real(get_cf_esenz(cod_sottocat.left(2)));
const bool cli_esente = (esponi_esenti) && (perc_esenz >= CENTO);