Patch level : 12.0 no-patch
Files correlati : li, ve Commento : Tolte quelle porcherie che avevo scritto sul conai, passato da camelCase a underscore_case
This commit is contained in:
parent
02998fe78a
commit
74cf43f735
@ -345,7 +345,7 @@ bool TVisLI_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|||||||
app.field(101).check_type(CHECK_REQUIRED);
|
app.field(101).check_type(CHECK_REQUIRED);
|
||||||
// Lancio la maschera
|
// Lancio la maschera
|
||||||
if(app.run() == K_ENTER)
|
if(app.run() == K_ENTER)
|
||||||
generaLiStorico(app.get_date(101));
|
genera_li_storico(app.get_date(101));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DLG_USER:
|
case DLG_USER:
|
||||||
|
@ -123,17 +123,17 @@ void TResDI_app::elab(TResDI_mask& m)
|
|||||||
TRectype row_clifo(c_clifo.curr());
|
TRectype row_clifo(c_clifo.curr());
|
||||||
|
|
||||||
TLi_manager currentCli(row_clifo.get_char("TIPOCF"), row_clifo.get_long("CODCF"), aData); // Inizializzo l'oggetto per la gestione del plafond
|
TLi_manager currentCli(row_clifo.get_char("TIPOCF"), row_clifo.get_long("CODCF"), aData); // Inizializzo l'oggetto per la gestione del plafond
|
||||||
if(currentCli.hasValidPlafond())
|
if(currentCli.has_valid_plafond())
|
||||||
{
|
{
|
||||||
real plafond = currentCli.getPlafond();
|
real plafond = currentCli.get_plafond();
|
||||||
real resPlafond = plafond - currentCli.elabUtil(tipi, stati, aData) - currentCli.elabUtil(tipif, statif);
|
real resPlafond = plafond - currentCli.elab_util(tipi, stati, aData) - currentCli.elab_util(tipif, statif);
|
||||||
|
|
||||||
TString msg;
|
TString msg;
|
||||||
msg << "\nDichiarazione di intento cliente N." << row_clifo.get_long("CODCF") << "\nRagione sociale: " << row_clifo.get("RAGSOC") << "\nPlafond totale: " << static_cast<TCurrency>(plafond).string() << "€\n";
|
msg << "\nDichiarazione di intento cliente N." << row_clifo.get_long("CODCF") << "\nRagione sociale: " << row_clifo.get("RAGSOC") << "\nPlafond totale: " << static_cast<TCurrency>(plafond).string() << "€\n";
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
msg = TString("Plafond disponibile: ") << static_cast<TCurrency>((resPlafond > ZERO ? resPlafond : ZERO )).string() << "€";
|
msg = TString("Plafond disponibile: ") << static_cast<TCurrency>((resPlafond > ZERO ? resPlafond : ZERO )).string() << "€";
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
msg = TString("Tipo dichiarazione: ") << (currentCli.isSoluzione() ? "Singola\n" : "A concorrenza\n");
|
msg = TString("Tipo dichiarazione: ") << (currentCli.is_soluzione() ? "Singola\n" : "A concorrenza\n");
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,103 +13,102 @@ const TString make_key(const int anno, const int numplaf)
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLi_manager::elabTipiStati()
|
void TLi_manager::elab_tipi_stati()
|
||||||
{
|
{
|
||||||
createTipiStati(tipi, stati);
|
create_tipi_stati(_tipi, _stati);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TToken_string& TLi_manager::getUse(TDocumento& d, const bool write)
|
const TToken_string& TLi_manager::get_use(TDocumento& d, const bool write)
|
||||||
{
|
{
|
||||||
static TToken_string& ret = get_tmp_string();
|
static TToken_string& ret = get_tmp_string();
|
||||||
TAssoc_array tabIva = d.tabella_iva(true);
|
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||||
TString4 numDoc = d.numerazione();
|
TString4 num_doc = d.numerazione();
|
||||||
int nDoc = d.numero();
|
|
||||||
|
|
||||||
real plaUtil = ZERO;
|
real pla_util = ZERO;
|
||||||
|
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tab_iva.get(); totali != NULL; totali = (TRiepilogo_iva *) tab_iva.get())
|
||||||
{
|
{
|
||||||
if(checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
if(check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||||
{
|
{
|
||||||
plaUtil += totali->imp_orig();
|
pla_util += totali->imp_orig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plaUtil > ZERO)
|
if(pla_util > ZERO)
|
||||||
{
|
{
|
||||||
if(d.is_nota_credito())
|
if(d.is_nota_credito())
|
||||||
{
|
{
|
||||||
ret.cut(0) << incrPlaf(d, plaUtil, write);
|
ret.cut(0) << incr_plaf(d, pla_util, write);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret.cut(0) << consPlaf(plaUtil, write);
|
ret.cut(0) << cons_plaf(pla_util, write);
|
||||||
if(ret.starts_with("ERRORE"))
|
if(ret.starts_with("ERRORE"))
|
||||||
ret << " al documento " << d.numerazione() << " n." << d.numero() << "\nTotale plafond da utilizzare: " << plaUtil.string() << "\nTotale rimasto: " << getPlafond().string();
|
ret << " al documento " << d.numerazione() << " n." << d.numero() << "\nTotale plafond da utilizzare: " << pla_util.string() << "\nTotale rimasto: " << get_plafond().string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TToken_string& TLi_manager::consPlaf(real& plafUsed, const bool write)
|
const TToken_string& TLi_manager::cons_plaf(real& plaf_used, const bool write)
|
||||||
{
|
{
|
||||||
static TToken_string used("", ','); used.cut(0);
|
static TToken_string used("", ','); used.cut(0);
|
||||||
if(!validPlafond || plafUsed > getPlafond())
|
if(!_valid_plafond || plaf_used > get_plafond())
|
||||||
{
|
{
|
||||||
used << "ERRORE NEL CALCOLO DEL PLAFOND";
|
used << "ERRORE NEL CALCOLO DEL PLAFOND";
|
||||||
return used;
|
return used;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool close = false;
|
bool close = false;
|
||||||
TToken_string thisPlaf("", ',');
|
TToken_string this_plaf("", ',');
|
||||||
while(plafUsed > ZERO)
|
while(plaf_used > ZERO)
|
||||||
{
|
{
|
||||||
// Calcolo quanto plafond ho usato
|
// Calcolo quanto plafond ho usato
|
||||||
TString thisNumprot = plafondi.begin()->first;
|
TString this_numprot = _plafondi.begin()->first;
|
||||||
real thisAmount = plafondi.begin()->second;
|
real this_amount = _plafondi.begin()->second;
|
||||||
|
|
||||||
real thisUtilizzato;
|
real this_utilizzato;
|
||||||
|
|
||||||
if(plafUsed >= thisAmount)
|
if(plaf_used >= this_amount)
|
||||||
{
|
{
|
||||||
close = true;
|
close = true;
|
||||||
thisUtilizzato = thisAmount;
|
this_utilizzato = this_amount;
|
||||||
|
|
||||||
// Rimuovo il plafond dalla lista,
|
// Rimuovo il plafond dalla lista,
|
||||||
plafondi.erase(thisNumprot);
|
_plafondi.erase(this_numprot);
|
||||||
|
|
||||||
if(write)
|
if(write)
|
||||||
{
|
{
|
||||||
// lo chiudo
|
// lo chiudo
|
||||||
changeStato(thisNumprot, true);
|
change_stato(this_numprot, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// e diminuisco tutto
|
// e diminuisco tutto
|
||||||
plafond -= thisAmount;
|
_plafond -= this_amount;
|
||||||
plafUsed -= thisAmount;
|
plaf_used -= this_amount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
close = false;
|
close = false;
|
||||||
thisUtilizzato = plafUsed;
|
this_utilizzato = plaf_used;
|
||||||
|
|
||||||
// e diminuisco tutto
|
// e diminuisco tutto
|
||||||
plafond -= plafUsed;
|
_plafond -= plaf_used;
|
||||||
plafondi[thisNumprot] -= plafUsed;
|
_plafondi[this_numprot] -= plaf_used;
|
||||||
plafUsed = ZERO;
|
plaf_used = ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Segno di aver usato il plafond
|
// Segno di aver usato il plafond
|
||||||
static TToken_string u; u.cut(0);
|
static TToken_string u; u.cut(0);
|
||||||
u.add(thisNumprot, _planno);
|
u.add(this_numprot, _planno);
|
||||||
u.add(thisUtilizzato.string(), _plimporto);
|
u.add(this_utilizzato.string(), _plimporto);
|
||||||
u.add(close? "X" : "", _plchiusura);
|
u.add(close? "X" : "", _plchiusura);
|
||||||
used.add(u);
|
used.add(u);
|
||||||
}
|
}
|
||||||
// Controllo di avere ancora plafond rimanente
|
// Controllo di avere ancora plafond rimanente
|
||||||
if(plafond <= ZERO)
|
if(_plafond <= ZERO)
|
||||||
validPlafond = false;
|
_valid_plafond = false;
|
||||||
|
|
||||||
// Tolgo la virgola finale
|
// Tolgo la virgola finale
|
||||||
used.cut(used.len()-1);
|
used.cut(used.len()-1);
|
||||||
@ -118,92 +117,92 @@ const TToken_string& TLi_manager::consPlaf(real& plafUsed, const bool write)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Aggiungo al plafond quello che trovo */
|
/* Aggiungo al plafond quello che trovo */
|
||||||
const TToken_string& TLi_manager::incrPlaf(TDocumento& d, real impNC, const bool write)
|
const TToken_string& TLi_manager::incr_plaf(TDocumento& d, real imp_nc, const bool write)
|
||||||
{
|
{
|
||||||
static TToken_string used("", ','); used.cut(0);
|
static TToken_string used("", ','); used.cut(0);
|
||||||
// Controllo se questa nota credito si riferisce a un singolo documento, in quel caso aggiorno faccio un aggiornamento sulle lettere di intento
|
// Controllo se questa nota credito si riferisce a un singolo documento, in quel caso aggiorno faccio un aggiornamento sulle lettere di intento
|
||||||
// Se si rifà a più documenti o non è specificato salta, meglio stare bassi
|
// Se si rifà a più documenti o non è specificato salta, meglio stare bassi
|
||||||
if(d.get("NUMDOCRIF").blank() || d.get("CODNUMRIF").blank() || d.get("ANNORIF").blank() || iniDicInt.year() != d.get_int("ANNORIF"))
|
if(d.get("NUMDOCRIF").blank() || d.get("CODNUMRIF").blank() || d.get("ANNORIF").blank() || _ini_dic_int.year() != d.get_int("ANNORIF"))
|
||||||
{
|
{
|
||||||
return used;
|
return used;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumento ds('D', d.get_int("ANNORIF"), d.get("CODNUMRIF"), d.get_int("NUMDOCRIF"));
|
TDocumento ds('D', d.get_int("ANNORIF"), d.get("CODNUMRIF"), d.get_int("NUMDOCRIF"));
|
||||||
TToken_string lePlafs(ds.get("PLAFOND"), ','); // [ANNO|NUMPROT|UTILIZZATO],...
|
TToken_string le_plafs(ds.get("PLAFOND"), ','); // [ANNO|NUMPROT|UTILIZZATO],...
|
||||||
|
|
||||||
// Se il documento di riferimento non ha nulla inserito nel plafond esco, non mi interessa
|
// Se il documento di riferimento non ha nulla inserito nel plafond esco, non mi interessa
|
||||||
if(lePlafs.items() == 0)
|
if(le_plafs.items() == 0)
|
||||||
return used;
|
return used;
|
||||||
|
|
||||||
// Controllo se non ho già ricevuto la quantità da stornare di plafond nella nota credito
|
// Controllo se non ho già ricevuto la quantità da stornare di plafond nella nota credito
|
||||||
if(impNC == ZERO)
|
if(imp_nc == ZERO)
|
||||||
{
|
{
|
||||||
// In caso negativo la calcolo
|
// In caso negativo la calcolo
|
||||||
TAssoc_array tabIva = d.tabella_iva(true);
|
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tab_iva.get(); totali != NULL; totali = (TRiepilogo_iva *) tab_iva.get())
|
||||||
{
|
{
|
||||||
if(checkIva(totali->cod_iva().codice()))
|
if(check_iva(totali->cod_iva().codice()))
|
||||||
{
|
{
|
||||||
impNC += totali->imp_orig();
|
imp_nc += totali->imp_orig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controllo se ho del plafond da stornare
|
// Controllo se ho del plafond da stornare
|
||||||
if(impNC <= ZERO)
|
if(imp_nc <= ZERO)
|
||||||
return used;
|
return used;
|
||||||
|
|
||||||
bool open = false;
|
bool open = false;
|
||||||
TToken_string thisPlaf("", '|');
|
TToken_string this_plaf("", '|');
|
||||||
for(int i = lePlafs.items() - 1; i >= 0 && impNC > ZERO; i--)
|
for(int i = le_plafs.items() - 1; i >= 0 && imp_nc > ZERO; i--)
|
||||||
{
|
{
|
||||||
lePlafs.get(i, thisPlaf);
|
le_plafs.get(i, this_plaf);
|
||||||
|
|
||||||
// Importo utilizzato del plafond
|
// Importo utilizzato del plafond
|
||||||
real importoPlaf = thisPlaf.get(_plimporto);
|
real importo_plaf = this_plaf.get(_plimporto);
|
||||||
// Importo già riaccreditato da altre NC
|
// Importo già riaccreditato da altre NC
|
||||||
real importoNC = thisPlaf.get(_plNC);
|
real importo_nc = this_plaf.get(_plNC);
|
||||||
// Importo possibile di plafond da stornare
|
// Importo possibile di plafond da stornare
|
||||||
real rimanente = importoPlaf - importoNC;
|
real rimanente = importo_plaf - importo_nc;
|
||||||
|
|
||||||
if(rimanente == ZERO)
|
if(rimanente == ZERO)
|
||||||
// This isn't the plafond you're looking for
|
// This isn't the plafond you're looking for
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(rimanente < impNC)
|
if(rimanente < imp_nc)
|
||||||
{
|
{
|
||||||
impNC -= rimanente;
|
imp_nc -= rimanente;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rimanente = impNC;
|
rimanente = imp_nc;
|
||||||
impNC = ZERO;
|
imp_nc = ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Salvo la quantità utilizzata nelle TToken_string
|
// Salvo la quantità utilizzata nelle TToken_string
|
||||||
thisPlaf.add(rimanente, _plNC);
|
this_plaf.add(rimanente, _plNC);
|
||||||
lePlafs.add(thisPlaf, i);
|
le_plafs.add(this_plaf, i);
|
||||||
|
|
||||||
// Aggiungo a plafond
|
// Aggiungo a plafond
|
||||||
const TString key = make_key(thisPlaf.get_int(_planno), thisPlaf.get_int(_plnumprot));
|
const TString key = make_key(this_plaf.get_int(_planno), this_plaf.get_int(_plnumprot));
|
||||||
|
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
open = false;
|
open = false;
|
||||||
// Incremento!
|
// Incremento!
|
||||||
plafondi[key] += rimanente;
|
_plafondi[key] += rimanente;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Va aggiunto ex novo!
|
// Va aggiunto ex novo!
|
||||||
// Calcolo l'importo delle righe che rientrano nel plafond
|
// Calcolo l'importo delle righe che rientrano nel plafond
|
||||||
open = true;
|
open = true;
|
||||||
plafondi.insert(std::pair<TString,real>(key, rimanente));
|
_plafondi.insert(std::pair<TString,real>(key, rimanente));
|
||||||
|
|
||||||
// Se devo scrivere abilito il plafond
|
// Se devo scrivere abilito il plafond
|
||||||
if(write)
|
if(write)
|
||||||
{
|
{
|
||||||
changeStato(key, false);
|
change_stato(key, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Segno di aver usato il plafond
|
// Segno di aver usato il plafond
|
||||||
@ -215,19 +214,19 @@ const TToken_string& TLi_manager::incrPlaf(TDocumento& d, real impNC, const bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rigiro used, nelle note credito sono invertiti i plafond
|
// Rigiro used, nelle note credito sono invertiti i plafond
|
||||||
static TToken_string usedApp("", ','); usedApp.cut(0);
|
static TToken_string used_app("", ','); used_app.cut(0);
|
||||||
for(int i = used.items(); i > 0; i--)
|
for(int i = used.items(); i > 0; i--)
|
||||||
usedApp.add(used.get(used.items()-i), i-1);
|
used_app.add(used.get(used.items()-i), i-1);
|
||||||
|
|
||||||
// Sovrascrivo il documento
|
// Sovrascrivo il documento
|
||||||
ds.put("PLAFOND", lePlafs);
|
ds.put("PLAFOND", le_plafs);
|
||||||
ds.rewrite();
|
ds.rewrite();
|
||||||
|
|
||||||
// Tolgo la virgola finale
|
// Tolgo la virgola finale
|
||||||
used.cut(used.len()-1);
|
used.cut(used.len()-1);
|
||||||
|
|
||||||
// Succedono cose in memoria, devo rimediare così
|
// Succedono cose in memoria, devo rimediare così
|
||||||
return usedApp;
|
return used_app;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void TLi_manager::stornaDoc(const TDocumento& d, const bool write)
|
void TLi_manager::stornaDoc(const TDocumento& d, const bool write)
|
||||||
@ -291,7 +290,7 @@ void TLi_manager::stornaDocs(const TDocumento& d, const bool write)
|
|||||||
TLista_documenti din; // Legge tutti i documenti di input
|
TLista_documenti din; // Legge tutti i documenti di input
|
||||||
|
|
||||||
// Trovo tutti i documenti che mi interessano
|
// Trovo tutti i documenti che mi interessano
|
||||||
din.read('D', tipocf, codcli, iniDicInt.year(), tipi, stati, d.data(), finDicInt);
|
din.read('D', _tipocf, _codcli, iniDicInt.year(), tipi, stati, d.data(), finDicInt);
|
||||||
|
|
||||||
for(int i = 0; i < din.items(); i++)
|
for(int i = 0; i < din.items(); i++)
|
||||||
{
|
{
|
||||||
@ -302,49 +301,49 @@ void TLi_manager::stornaDocs(const TDocumento& d, const bool write)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const TToken_string& TLi_manager::stornaDoc(const TDocumento& d, real impDC, const bool write)
|
const TToken_string& TLi_manager::storna_doc(const TDocumento& d, real imp_dc, const bool write)
|
||||||
{
|
{
|
||||||
static TToken_string used("", ','); used.cut(0);
|
static TToken_string used("", ','); used.cut(0);
|
||||||
// True se devo stornare tutto il Doc
|
// True se devo stornare tutto il Doc
|
||||||
bool totale = impDC.is_zero();
|
const bool totale = imp_dc.is_zero();
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
// Devo ricaricare le righe sui plafond che ho
|
// Devo ricaricare le righe sui plafond che ho
|
||||||
TToken_string plafs(d.get("PLAFOND"), ',');
|
TToken_string plafs(d.get("PLAFOND"), ',');
|
||||||
for(int i = 0; i < plafs.items() && impDC > ZERO; i++)
|
for(int i = 0; i < plafs.items() && imp_dc > ZERO; i++)
|
||||||
{
|
{
|
||||||
TToken_string thisPlafond = plafs.get(i);
|
TToken_string this_plafond = plafs.get(i);
|
||||||
const TString key = make_key(thisPlafond.get_int(_planno), thisPlafond.get_int(_plnumprot));
|
const TString key = make_key(this_plafond.get_int(_planno), this_plafond.get_int(_plnumprot));
|
||||||
real thisImporto = thisPlafond.get(_plimporto);
|
real this_importo = this_plafond.get(_plimporto);
|
||||||
if(totale)
|
if(totale)
|
||||||
{
|
{
|
||||||
if(thisImporto >= impDC)
|
if(this_importo >= imp_dc)
|
||||||
{
|
{
|
||||||
thisImporto = impDC;
|
this_importo = imp_dc;
|
||||||
// Controllo se vado a stornare solo una parte o tutto, nel primo caso cambio la Token, nel secondo elimino normalmente
|
// Controllo se vado a stornare solo una parte o tutto, nel primo caso cambio la Token, nel secondo elimino normalmente
|
||||||
if(thisImporto > impDC)
|
if(this_importo > imp_dc)
|
||||||
{
|
{
|
||||||
thisPlafond.add(impDC, _plimporto);
|
this_plafond.add(imp_dc, _plimporto);
|
||||||
plafs.add(thisPlafond, i);
|
plafs.add(this_plafond, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
plafs.destroy(i);
|
plafs.destroy(i);
|
||||||
impDC = ZERO;
|
imp_dc = ZERO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
impDC -= thisImporto;
|
imp_dc -= this_importo;
|
||||||
plafs.destroy(i);
|
plafs.destroy(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TString asd = thisImporto.string();
|
TString asd = this_importo.string();
|
||||||
if(d.is_nota_credito())
|
if(d.is_nota_credito())
|
||||||
{
|
{
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
if(thisImporto < plafondi[key])
|
if(this_importo < _plafondi[key])
|
||||||
{
|
{
|
||||||
// Sottraggo
|
// Sottraggo
|
||||||
plafondi[key] -= thisImporto;
|
_plafondi[key] -= this_importo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -364,19 +363,19 @@ const TToken_string& TLi_manager::stornaDoc(const TDocumento& d, real impDC, con
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
//Sommo
|
//Sommo
|
||||||
plafondi[key] += thisImporto;
|
_plafondi[key] += this_importo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Aggiungo ai plafond
|
// Aggiungo ai plafond
|
||||||
plafondi.insert(std::pair<TString, real>(key, thisImporto));
|
_plafondi.insert(std::pair<TString, real>(key, this_importo));
|
||||||
// Se devo scrivere abilito il plafond
|
// Se devo scrivere abilito il plafond
|
||||||
if(write)
|
if(write)
|
||||||
{
|
{
|
||||||
changeStato(key, false);
|
change_stato(key, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,7 +393,7 @@ bool TLi_manager::recalcAfter(const TDocumento& d, TLog_report& lerr)
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
int first = -1;
|
int first = -1;
|
||||||
// Trovo tutti i documenti che mi interessano
|
// Trovo tutti i documenti che mi interessano
|
||||||
din.read('D', tipocf, codcli, iniDicInt.year(), tipi, stati, d.data(), finDicInt);
|
din.read('D', _tipocf, _codcli, iniDicInt.year(), tipi, stati, d.data(), finDicInt);
|
||||||
|
|
||||||
for(int i = 0; i < din.items() && ok; i++)
|
for(int i = 0; i < din.items() && ok; i++)
|
||||||
{
|
{
|
||||||
@ -422,18 +421,18 @@ bool TLi_manager::recalcAfter(const TDocumento& d, TLog_report& lerr)
|
|||||||
*/
|
*/
|
||||||
/* Faccio un analisi di tutti i plafond aperti e li sommo salvandomeli in plafonds */
|
/* Faccio un analisi di tutti i plafond aperti e li sommo salvandomeli in plafonds */
|
||||||
|
|
||||||
void TLi_manager::elabPlafond()
|
void TLi_manager::elab_plafond()
|
||||||
{
|
{
|
||||||
validPlafond = false;
|
_valid_plafond = false;
|
||||||
|
|
||||||
// Controllo preventivo per evitare di fare calcoli su anni precedenti al plafond
|
// Controllo preventivo per evitare di fare calcoli su anni precedenti al plafond
|
||||||
if(iniDicInt.year() < 2017)
|
if(_ini_dic_int.year() < 2017)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TRelation letint(LF_LETINT);
|
TRelation letint(LF_LETINT);
|
||||||
TRectype filtro(letint.curr());
|
TRectype filtro(letint.curr());
|
||||||
filtro.add("CODCLI", codcli);
|
filtro.add("CODCLI", _codcli);
|
||||||
filtro.add("ANNO", iniDicInt.year());
|
filtro.add("ANNO", _ini_dic_int.year());
|
||||||
|
|
||||||
// Creo un cursore ordinato e prelevo la prima riga non chiusa
|
// Creo un cursore ordinato e prelevo la prima riga non chiusa
|
||||||
TCursor c_dicint(&letint, "", 2, &filtro, &filtro);
|
TCursor c_dicint(&letint, "", 2, &filtro, &filtro);
|
||||||
@ -441,11 +440,11 @@ void TLi_manager::elabPlafond()
|
|||||||
if(c_dicint.items() > 0)
|
if(c_dicint.items() > 0)
|
||||||
{
|
{
|
||||||
// Cerco finchè non arrivo alla fine o non trovo una soluzione
|
// Cerco finchè non arrivo alla fine o non trovo una soluzione
|
||||||
for(c_dicint = 0; c_dicint.pos() < c_dicint.items() && !soluzione; ++c_dicint)
|
for(c_dicint = 0; c_dicint.pos() < c_dicint.items() && !_soluzione; ++c_dicint)
|
||||||
{
|
{
|
||||||
TRectype row = c_dicint.curr();
|
TRectype row = c_dicint.curr();
|
||||||
// Esco se raggiungo una data successiva al nostro documento
|
// Esco se raggiungo una data successiva al nostro documento
|
||||||
if(row.get_date("DAL") > finDicInt)
|
if(row.get_date("DAL") > _fin_dic_int)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(!row.get_bool("CHIUSA"))
|
if(!row.get_bool("CHIUSA"))
|
||||||
@ -455,113 +454,113 @@ void TLi_manager::elabPlafond()
|
|||||||
if(row.get_int("TIPOOP") == SOLUZIONE_UNICA)
|
if(row.get_int("TIPOOP") == SOLUZIONE_UNICA)
|
||||||
{
|
{
|
||||||
// Faccio un controllo in più per bloccare un utente con plafond di diverso tipo
|
// Faccio un controllo in più per bloccare un utente con plafond di diverso tipo
|
||||||
if(validPlafond)
|
if(_valid_plafond)
|
||||||
{
|
{
|
||||||
// ERRORE! Esiste già un plafond e ho trovato una soluzione unica!
|
// ERRORE! Esiste già un plafond e ho trovato una soluzione unica!
|
||||||
validPlafond = false;
|
_valid_plafond = false;
|
||||||
plafondi.clear();
|
_plafondi.clear();
|
||||||
plafond = -UNO;
|
_plafond = -UNO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
soluzione = true;
|
_soluzione = true;
|
||||||
}
|
}
|
||||||
if(!validPlafond)
|
if(!_valid_plafond)
|
||||||
iniDicInt = row.get_date("DAL");
|
_ini_dic_int = row.get_date("DAL");
|
||||||
|
|
||||||
// Aggiungo il plafond trovato all'elenco dei plafond
|
// Aggiungo il plafond trovato all'elenco dei plafond
|
||||||
const TString key = make_key(row.get_int("ANNO"), row.get_int("NUMPROT"));
|
const TString key = make_key(row.get_int("ANNO"), row.get_int("NUMPROT"));
|
||||||
plafondi.insert(std::pair<TString,real>(key, row.get_real("IMPORTO")));
|
_plafondi.insert(std::pair<TString,real>(key, row.get_real("IMPORTO")));
|
||||||
|
|
||||||
// Aggiungo il valore del plafond al totale
|
// Aggiungo il valore del plafond al totale
|
||||||
plafond += row.get_real("IMPORTO");
|
_plafond += row.get_real("IMPORTO");
|
||||||
validPlafond = true;
|
_valid_plafond = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!validPlafond)
|
if(!_valid_plafond)
|
||||||
plafond = -UNO;
|
_plafond = -UNO;
|
||||||
}
|
}
|
||||||
|
|
||||||
const real TLi_manager::getPlaRes()
|
const real TLi_manager::get_pla_res()
|
||||||
{
|
{
|
||||||
return elabPlaRes();
|
return elab_pla_res();
|
||||||
}
|
}
|
||||||
|
|
||||||
const real TLi_manager::getPlaRes(TToken_string tipi, TToken_string stati)
|
const real TLi_manager::get_pla_res(TToken_string tipi, TToken_string stati)
|
||||||
{
|
{
|
||||||
return elabPlaRes(tipi, stati);
|
return elab_pla_res(tipi, stati);
|
||||||
}
|
}
|
||||||
|
|
||||||
const real TLi_manager::elabPlaRes(TToken_string t, TToken_string s, TDate ad)
|
const real TLi_manager::elab_pla_res(TToken_string t, TToken_string s, TDate ad)
|
||||||
{
|
{
|
||||||
if(elabPR)
|
if(_elab_pr)
|
||||||
return plafond;
|
return _plafond;
|
||||||
else
|
else
|
||||||
elabPR = true;
|
_elab_pr = true;
|
||||||
|
|
||||||
if(t.full() && s.full())
|
if(t.full() && s.full())
|
||||||
{
|
{
|
||||||
tipi = t;
|
_tipi = t;
|
||||||
stati = s;
|
_stati = s;
|
||||||
}
|
}
|
||||||
if(!ad.ok())
|
if(!ad.ok())
|
||||||
ad = finDicInt;
|
ad = _fin_dic_int;
|
||||||
plafond = -UNO;
|
_plafond = -UNO;
|
||||||
if(!validPlafond)
|
if(!_valid_plafond)
|
||||||
return plafond;
|
return _plafond;
|
||||||
|
|
||||||
TLista_documenti din; // Legge tutti i documenti di input
|
TLista_documenti din; // Legge tutti i documenti di input
|
||||||
|
|
||||||
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al plafond
|
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al _plafond
|
||||||
din.read('D', tipocf, codcli, iniDicInt.year(), tipi, stati, iniDicInt, ad);
|
din.read('D', _tipocf, _codcli, _ini_dic_int.year(), _tipi, _stati, _ini_dic_int, ad);
|
||||||
|
|
||||||
for(int i = 0; i < din.items(); i++)
|
for(int i = 0; i < din.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string plaf(din[i].get("PLAFOND"), ',');
|
TToken_string plaf(din[i].get("PLAFOND"), ',');
|
||||||
for(int j = 0; j < plaf.items(); j++)
|
for(int j = 0; j < plaf.items(); j++)
|
||||||
{
|
{
|
||||||
TToken_string thePla(plaf.get(j));
|
TToken_string the_pla(plaf.get(j));
|
||||||
const TString key = make_key(thePla.get_int(_planno), thePla.get_int(_plnumprot));
|
const TString key = make_key(the_pla.get_int(_planno), the_pla.get_int(_plnumprot));
|
||||||
static TString chiusura; chiusura.cut(0) << thePla.get(_plchiusura); // La get ritorna un const char*
|
static TString chiusura; chiusura.cut(0) << the_pla.get(_plchiusura); // La get ritorna un const char*
|
||||||
if(din[i].tipo().nota_credito())
|
if(din[i].tipo().nota_credito())
|
||||||
{
|
{
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
if(DEBUG_ENABLED && chiusura == "X" && yesno_box("Attenzione! La lettera con codice %s riferito alla nota credito %s, %d l'ho trovata ma dovevo aprirla adesso!\n Che faccio, azzero?", key, din[i].numerazione(), din[i].numero()))
|
if(DEBUG_ENABLED && chiusura == "X" && yesno_box("Attenzione! La lettera con codice %s riferito alla nota credito %s, %d l'ho trovata ma dovevo aprirla adesso!\n Che faccio, azzero?", key, din[i].numerazione(), din[i].numero()))
|
||||||
{
|
{
|
||||||
plafondi[key] = ZERO;
|
_plafondi[key] = ZERO;
|
||||||
}
|
}
|
||||||
plafondi[key] += static_cast<real>(thePla.get(_plimporto));
|
_plafondi[key] += static_cast<real>(the_pla.get(_plimporto));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Va aggiunto ex novo!
|
// Va aggiunto ex novo!
|
||||||
if(DEBUG_ENABLED && chiusura != "X" && yesno_box("Attenzione! La lettera con codice %s riferito alla nota credito %s, %d non l'ho trovata ma doveva già essere aperta!\n Che faccio, annullo?", key, din[i].numerazione(), din[i].numero()))
|
if(DEBUG_ENABLED && chiusura != "X" && yesno_box("Attenzione! La lettera con codice %s riferito alla nota credito %s, %d non l'ho trovata ma doveva già essere aperta!\n Che faccio, annullo?", key, din[i].numerazione(), din[i].numero()))
|
||||||
{
|
{
|
||||||
validPlafond = false;
|
_valid_plafond = false;
|
||||||
return plafond;
|
return _plafond;
|
||||||
}
|
}
|
||||||
// Calcolo l'importo delle righe che rientrano nel plafond
|
// Calcolo l'importo delle righe che rientrano nel plafond
|
||||||
plafondi.insert(std::pair<TString,real>(key, static_cast<real>(thePla.get(_plimporto))));
|
_plafondi.insert(std::pair<TString,real>(key, static_cast<real>(the_pla.get(_plimporto))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
if(chiusura == "X")
|
if(chiusura == "X")
|
||||||
{
|
{
|
||||||
if(DEBUG_ENABLED && plafondi[key] != static_cast<real>(thePla.get(_plimporto)) &&
|
if(DEBUG_ENABLED && _plafondi[key] != static_cast<real>(the_pla.get(_plimporto)) &&
|
||||||
!yesno_box(TR("Questa lettera di intento è incongruente,\nTotale attivo: %s\nTotale da disattivare: %s\nContinuare?"), plafondi[key].string(), thePla.get(_plimporto)))
|
!yesno_box(TR("Questa lettera di intento è incongruente,\nTotale attivo: %s\nTotale da disattivare: %s\nContinuare?"), _plafondi[key].string(), the_pla.get(_plimporto)))
|
||||||
{
|
{
|
||||||
validPlafond = false;
|
_valid_plafond = false;
|
||||||
return plafond;
|
return _plafond;
|
||||||
}
|
}
|
||||||
plafondi.erase(key);
|
_plafondi.erase(key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plafondi[key] -= static_cast<real>(thePla.get(_plimporto));
|
_plafondi[key] -= static_cast<real>(the_pla.get(_plimporto));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,18 +568,18 @@ const real TLi_manager::elabPlaRes(TToken_string t, TToken_string s, TDate ad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcolo il totale da mappa scansionata
|
// Calcolo il totale da mappa scansionata
|
||||||
plafond = ZERO;
|
_plafond = ZERO;
|
||||||
for(auto it = plafondi.begin(); it != plafondi.end(); ++it)
|
for(auto it = _plafondi.begin(); it != _plafondi.end(); ++it)
|
||||||
plafond += it->second;
|
_plafond += it->second;
|
||||||
|
|
||||||
return plafond;
|
return _plafond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const real TLi_manager::elabUtil(TToken_string tipi, TToken_string stati, TDate ad)
|
const real TLi_manager::elab_util(TToken_string tipi, TToken_string stati, TDate ad)
|
||||||
{
|
{
|
||||||
if(!validPlafond)
|
if(!_valid_plafond)
|
||||||
return -UNO;
|
return -UNO;
|
||||||
if(tipi.items() == 0)
|
if(tipi.items() == 0)
|
||||||
return ZERO;
|
return ZERO;
|
||||||
@ -590,21 +589,21 @@ const real TLi_manager::elabUtil(TToken_string tipi, TToken_string stati, TDate
|
|||||||
TLista_documenti din; // Legge tutti i documenti di input
|
TLista_documenti din; // Legge tutti i documenti di input
|
||||||
|
|
||||||
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al plafond
|
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al plafond
|
||||||
din.read('D', tipocf, codcli, iniDicInt.year(), tipi, stati, iniDicInt, ad);
|
din.read('D', _tipocf, _codcli, _ini_dic_int.year(), tipi, stati, _ini_dic_int, ad);
|
||||||
|
|
||||||
for(int i = 0; i < din.items(); i++)
|
for(int i = 0; i < din.items(); i++)
|
||||||
{
|
{
|
||||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tab_iva.get(); totali != NULL; totali = (TRiepilogo_iva *) tab_iva.get())
|
||||||
{
|
{
|
||||||
if(checkIva(totali->cod_iva().codice()))
|
if(check_iva(totali->cod_iva().codice()))
|
||||||
{
|
{
|
||||||
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nel caso il plafond trovato fosse una soluzione unica e ho già trovato dei documenti vuol dire che il plafond non è più valido
|
// Nel caso il plafond trovato fosse una soluzione unica e ho già trovato dei documenti vuol dire che il plafond non è più valido
|
||||||
if(soluzione)
|
if(_soluzione)
|
||||||
{
|
{
|
||||||
utilizzato = -UNO;
|
utilizzato = -UNO;
|
||||||
break;
|
break;
|
||||||
@ -614,21 +613,21 @@ const real TLi_manager::elabUtil(TToken_string tipi, TToken_string stati, TDate
|
|||||||
return utilizzato;
|
return utilizzato;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TLi_manager::testPlafond(TLista_documenti& dout, TLog_report& lerr)
|
bool TLi_manager::test_plafond(TLista_documenti& dout, TLog_report& lerr)
|
||||||
{
|
{
|
||||||
bool err = false;
|
bool err = false;
|
||||||
static TToken_string& use = get_tmp_string();
|
static TToken_string& use = get_tmp_string();
|
||||||
// Faccio un ragionamento identico a getPlaRes, ma in input ho la lista di documenti appena elaborati
|
// Faccio un ragionamento identico a getPlaRes, ma in input ho la lista di documenti appena elaborati
|
||||||
for(int i = 0; i < dout.items() && !err; i++)
|
for(int i = 0; i < dout.items() && !err; i++)
|
||||||
{
|
{
|
||||||
use.cut(0) << getUse(dout[i], true);
|
use.cut(0) << get_use(dout[i], true);
|
||||||
if(use.starts_with("ERRORE"))
|
if(use.starts_with("ERRORE"))
|
||||||
{
|
{
|
||||||
TString msgerr;
|
TString msgerr;
|
||||||
msgerr << "Superata dichiarazione di intento cliente N." << dout[i].codcf() << "\n" << use;
|
msgerr << "Superata dichiarazione di intento cliente N." << dout[i].codcf() << "\n" << use;
|
||||||
lerr.log(2, msgerr);
|
lerr.log(2, msgerr);
|
||||||
revertModifiche();
|
revert_modifiche();
|
||||||
clearModifiche();
|
clear_modifiche();
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,31 +636,31 @@ bool TLi_manager::testPlafond(TLista_documenti& dout, TLog_report& lerr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Per scelte implementative non ha una accuratezza del 100% */
|
/* Per scelte implementative non ha una accuratezza del 100% */
|
||||||
bool TLi_manager::checkUtilizzo(TDocumento& d, real impNC)
|
bool TLi_manager::check_utilizzo(TDocumento& d, real imp_nc)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
TToken_string lePlafs(d.get("PLAFOND"), ',');
|
TToken_string le_plafs(d.get("PLAFOND"), ',');
|
||||||
|
|
||||||
// Se me lo passa la funzione evito di calcolarlo
|
// Se me lo passa la funzione evito di calcolarlo
|
||||||
if(impNC.is_zero())
|
if(imp_nc.is_zero())
|
||||||
{
|
{
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) d.tabella_iva(true).get(); totali != NULL; totali = (TRiepilogo_iva *) d.tabella_iva(true).get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) d.tabella_iva(true).get(); totali != NULL; totali = (TRiepilogo_iva *) d.tabella_iva(true).get())
|
||||||
if(checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
if(check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||||
impNC += totali->imp_orig();
|
imp_nc += totali->imp_orig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Per sapere se non ho usato il plafond di questa NC controllo innanzitutto se c'è ne abbastanza
|
/* Per sapere se non ho usato il plafond di questa NC controllo innanzitutto se c'è ne abbastanza
|
||||||
* rimasto per coprire la NC, non è il controllo della vita ma toglie già un po' di calcoli */
|
* rimasto per coprire la NC, non è il controllo della vita ma toglie già un po' di calcoli */
|
||||||
ok = getPlaRes() > impNC;
|
ok = get_pla_res() > imp_nc;
|
||||||
|
|
||||||
// Sucessivamente vado in dettaglio a verificare se sono sempre maggiori (getPlaRes() mi carica anche la variabile "plafondi" per gli altri calcoli)
|
// Sucessivamente vado in dettaglio a verificare se sono sempre maggiori (getPlaRes() mi carica anche la variabile "plafondi" per gli altri calcoli)
|
||||||
for(int i = 0; i < lePlafs.items() && ok; i++)
|
for(int i = 0; i < le_plafs.items() && ok; i++)
|
||||||
{
|
{
|
||||||
TToken_string thisPlaf(lePlafs.get(i));
|
TToken_string this_plaf(le_plafs.get(i));
|
||||||
const TString key = make_key(thisPlaf.get_int(_planno), thisPlaf.get_int(_plnumprot));
|
const TString key = make_key(this_plaf.get_int(_planno), this_plaf.get_int(_plnumprot));
|
||||||
if(plafondi.find(key) != plafondi.end())
|
if(_plafondi.find(key) != _plafondi.end())
|
||||||
{
|
{
|
||||||
ok = plafondi[key] > static_cast<real>(lePlafs.get(_plimporto));
|
ok = _plafondi[key] > static_cast<real>(le_plafs.get(_plimporto));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ok = false;
|
ok = false;
|
||||||
@ -670,56 +669,56 @@ bool TLi_manager::checkUtilizzo(TDocumento& d, real impNC)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLi_manager::changeStato(const TString& key, const bool stato)
|
void TLi_manager::change_stato(const TString& key, const bool stato)
|
||||||
{
|
{
|
||||||
TRectype Jean_Baptiste_Le_Rond_dAlembert = cache().get(LF_LETINT, key); // Che nome di classe!
|
TRectype Jean_Baptiste_Le_Rond_dAlembert = cache().get(LF_LETINT, key); // Che nome di classe!
|
||||||
Jean_Baptiste_Le_Rond_dAlembert.put("CHIUSA", stato);
|
Jean_Baptiste_Le_Rond_dAlembert.put("CHIUSA", stato);
|
||||||
Jean_Baptiste_Le_Rond_dAlembert.rewrite(TLocalisamfile(LF_LETINT));
|
Jean_Baptiste_Le_Rond_dAlembert.rewrite(TLocalisamfile(LF_LETINT));
|
||||||
|
|
||||||
TString skey; skey << key << "|" << stato ? "" : "X"; // Ottimizzazione portami via...
|
TString skey; skey << key << "|" << stato ? "" : "X"; // Ottimizzazione portami via...
|
||||||
modifiche.insert(std::pair<int, TString>(modifiche.size()+1, skey));
|
_modifiche.insert(std::pair<int, TString>(_modifiche.size()+1, skey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLi_manager::revertModifiche()
|
void TLi_manager::revert_modifiche()
|
||||||
{
|
{
|
||||||
if(!hasModifiche())
|
if(!has_modifiche())
|
||||||
return;
|
return;
|
||||||
TLocalisamfile baguette(LF_LETINT);
|
TLocalisamfile baguette(LF_LETINT);
|
||||||
|
|
||||||
for(auto it = modifiche.begin(); it != modifiche.end(); ++it)
|
for(auto it = _modifiche.begin(); it != _modifiche.end(); ++it)
|
||||||
{
|
{
|
||||||
TToken_string key = it->second;
|
TToken_string key = it->second;
|
||||||
TRectype Jean_Baptiste_Le_Rond_dAlembert = cache().get(LF_LETINT, key.get(0)); // Che nome di classe!
|
TRectype Jean_Baptiste_Le_Rond_dAlembert = cache().get(LF_LETINT, key.get(0)); // Che nome di classe!
|
||||||
Jean_Baptiste_Le_Rond_dAlembert.put("CHIUSA", key.get(1));
|
Jean_Baptiste_Le_Rond_dAlembert.put("CHIUSA", key.get(1));
|
||||||
Jean_Baptiste_Le_Rond_dAlembert.rewrite(baguette);
|
Jean_Baptiste_Le_Rond_dAlembert.rewrite(baguette);
|
||||||
}
|
}
|
||||||
clearModifiche();
|
clear_modifiche();
|
||||||
}
|
}
|
||||||
|
|
||||||
TLi_manager::TLi_manager(const char t, const long c, TDate iniDic, TDate finDic)
|
TLi_manager::TLi_manager(const char t, const long c, TDate iniDic, TDate finDic)
|
||||||
: tipocf (t), codcli(c), iniDicInt(iniDic), finDicInt(finDic),
|
: _tipocf (t), _codcli(c), _ini_dic_int(iniDic), _fin_dic_int(finDic),
|
||||||
codivaDef(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
_codiva_def(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||||
codivaAlt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
_codiva_alt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||||
plafond(ZERO), validPlafond(false), soluzione(false), elabPR(false)
|
_plafond(ZERO), _valid_plafond(false), _soluzione(false), _elab_pr(false)
|
||||||
{
|
{
|
||||||
elabTipiStati();
|
elab_tipi_stati();
|
||||||
elabPlafond();
|
elab_plafond();
|
||||||
}
|
}
|
||||||
|
|
||||||
TLi_manager::TLi_manager(const char t, const long c, TDate finDic)
|
TLi_manager::TLi_manager(const char t, const long c, TDate finDic)
|
||||||
: tipocf (t), codcli(c), finDicInt(finDic),
|
: _tipocf (t), _codcli(c), _fin_dic_int(finDic),
|
||||||
codivaDef(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
_codiva_def(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||||
codivaAlt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
_codiva_alt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||||
plafond(ZERO), validPlafond(false), soluzione(false), elabPR(false)
|
_plafond(ZERO), _valid_plafond(false), _soluzione(false), _elab_pr(false)
|
||||||
{
|
{
|
||||||
iniDicInt.set_day(01);
|
_ini_dic_int.set_day(01);
|
||||||
iniDicInt.set_month(01);
|
_ini_dic_int.set_month(01);
|
||||||
iniDicInt.set_year(finDic.year());
|
_ini_dic_int.set_year(finDic.year());
|
||||||
elabTipiStati();
|
elab_tipi_stati();
|
||||||
elabPlafond();
|
elab_plafond();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createTipiStati(TToken_string& tipi, TToken_string& stati)
|
static void create_tipi_stati(TToken_string& tipi, TToken_string& stati)
|
||||||
{
|
{
|
||||||
static const TToken_string tipidoc(ini_get_string(CONFIG_DITTA, "li", "TIPIDOC"));
|
static const TToken_string tipidoc(ini_get_string(CONFIG_DITTA, "li", "TIPIDOC"));
|
||||||
if(tipi.blank() && stati.blank())
|
if(tipi.blank() && stati.blank())
|
||||||
@ -738,17 +737,17 @@ static void createTipiStati(TToken_string& tipi, TToken_string& stati)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generaLiStorico(TDate dataIni)
|
bool genera_li_storico(const TDate& data_ini)
|
||||||
{
|
{
|
||||||
// Apro la tabella dei plafonds con chiave 2 (CODCLI+ANNO+NUMPROT) e per ogni cliente calcolo i plafond dal 2017
|
// Apro la tabella dei plafonds con chiave 2 (CODCLI+ANNO+NUMPROT) e per ogni cliente calcolo i plafond dal 2017
|
||||||
TRelation rletint(LF_LETINT);
|
TRelation rletint(LF_LETINT);
|
||||||
TString filter = "DAL>="; filter << dataIni.date2ansi();
|
TString filter = "DAL>="; filter << data_ini.date2ansi();
|
||||||
TCursor cletint(&rletint, filter, 2);
|
TCursor cletint(&rletint, filter, 2);
|
||||||
static TToken_string tipi, stati;
|
static TToken_string tipi, stati;
|
||||||
createTipiStati(tipi, stati);
|
create_tipi_stati(tipi, stati);
|
||||||
|
|
||||||
static TString codIVAP = ini_get_string(CONFIG_DITTA, "li", "CODIVA");
|
static TString cod_ivap = ini_get_string(CONFIG_DITTA, "li", "CODIVA");
|
||||||
static TString codIVAS = ini_get_string(CONFIG_DITTA, "li", "CODIVALT");
|
static TString cod_ivas = ini_get_string(CONFIG_DITTA, "li", "CODIVALT");
|
||||||
|
|
||||||
TProgress_monitor status(cletint.items(), "Aggiornamento plafond");
|
TProgress_monitor status(cletint.items(), "Aggiornamento plafond");
|
||||||
|
|
||||||
@ -765,15 +764,15 @@ bool generaLiStorico(TDate dataIni)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
TDate startCurr = rletint.get_date("DAL"), endCurr;
|
TDate start_curr = rletint.get_date("DAL"), end_curr;
|
||||||
endCurr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? --rletintn.get_date("DAL") : NULLDATE;
|
end_curr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? --rletintn.get_date("DAL") : NULLDATE;
|
||||||
// Dati lettera
|
// Dati lettera
|
||||||
real impLI = rletint.get_real("IMPORTO");
|
real imp_li = rletint.get_real("IMPORTO");
|
||||||
bool soluzione = rletint.get_int("TIPOOP") == SOLUZIONE_UNICA;
|
bool soluzione = rletint.get_int("TIPOOP") == SOLUZIONE_UNICA;
|
||||||
|
|
||||||
// Adesso che so le date apro tutti i documenti
|
// Adesso che so le date apro tutti i documenti
|
||||||
TLista_documenti din;
|
TLista_documenti din;
|
||||||
din.read('D', 'C', rletint.get_long("CODCLI"), startCurr.year(), tipi, stati, startCurr, endCurr);
|
din.read('D', 'C', rletint.get_long("CODCLI"), start_curr.year(), tipi, stati, start_curr, end_curr);
|
||||||
for(int i = 0; i < din.items(); i++)
|
for(int i = 0; i < din.items(); i++)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
@ -781,10 +780,10 @@ bool generaLiStorico(TDate dataIni)
|
|||||||
bool tolla = true;
|
bool tolla = true;
|
||||||
#endif
|
#endif
|
||||||
real utilizzato = ZERO;
|
real utilizzato = ZERO;
|
||||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tab_iva.get(); totali != NULL; totali = (TRiepilogo_iva *) tab_iva.get())
|
||||||
{
|
{
|
||||||
if(totali->cod_iva().codice() == codIVAP || totali->cod_iva().codice() == codIVAS)
|
if(totali->cod_iva().codice() == cod_ivap || totali->cod_iva().codice() == cod_ivas)
|
||||||
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +799,7 @@ bool generaLiStorico(TDate dataIni)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Controllo di non superare il plafond
|
// Controllo di non superare il plafond
|
||||||
if(impLI >= utilizzato)
|
if(imp_li >= utilizzato)
|
||||||
{
|
{
|
||||||
// Creo la chiave da scrivere e metto tutto dentro
|
// Creo la chiave da scrivere e metto tutto dentro
|
||||||
const TString key = make_key(rletint.get_int("ANNO"), rletint.get_int("NUMPROT"));
|
const TString key = make_key(rletint.get_int("ANNO"), rletint.get_int("NUMPROT"));
|
||||||
@ -823,14 +822,14 @@ bool generaLiStorico(TDate dataIni)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool popolaPlafond(TLista_documenti & din, const TDate& data_elab)
|
bool popola_plafond(TLista_documenti & din, const TDate& data_elab)
|
||||||
{
|
{
|
||||||
std::map<int, TLi_manager*> plafs;
|
std::map<int, TLi_manager*> plafs;
|
||||||
TProgress_monitor mDoc(din.items(), "Generazione plafond nelle fatture");
|
TProgress_monitor m_doc(din.items(), "Generazione plafond nelle fatture");
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for(int i = 0; i < din.items() && ok; i++)
|
for(int i = 0; i < din.items() && ok; i++)
|
||||||
{
|
{
|
||||||
if (!mDoc.add_status())
|
if (!m_doc.add_status())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Per ogni fattura richiamo il plafond dell'intestatario e faccio le mie elaborazioni
|
// Per ogni fattura richiamo il plafond dell'intestatario e faccio le mie elaborazioni
|
||||||
@ -839,15 +838,15 @@ bool popolaPlafond(TLista_documenti & din, const TDate& data_elab)
|
|||||||
TLi_manager* app = new TLi_manager(din[i].tipocf(), din[i].codcf(), data_elab);
|
TLi_manager* app = new TLi_manager(din[i].tipocf(), din[i].codcf(), data_elab);
|
||||||
plafs.insert(std::pair<int, TLi_manager*>(din[i].codcf(), app));
|
plafs.insert(std::pair<int, TLi_manager*>(din[i].codcf(), app));
|
||||||
}
|
}
|
||||||
TLi_manager& thisPla = *plafs[din[i].codcf()]; // Forget about optimization!
|
TLi_manager& this_pla = *plafs[din[i].codcf()]; // Forget about optimization!
|
||||||
if (!thisPla.hasValidPlafond()) continue;
|
if (!this_pla.has_valid_plafond()) continue;
|
||||||
|
|
||||||
// Calcolo quanto plafond sta utilizzando
|
// Calcolo quanto plafond sta utilizzando
|
||||||
real utilizzato = ZERO;
|
real utilizzato = ZERO;
|
||||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *)tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *)tabIva.get())
|
for (TRiepilogo_iva * totali = (TRiepilogo_iva *)tab_iva.get(); totali != NULL; totali = (TRiepilogo_iva *)tab_iva.get())
|
||||||
{
|
{
|
||||||
if (thisPla.checkIva(totali->cod_iva().codice()))
|
if (this_pla.check_iva(totali->cod_iva().codice()))
|
||||||
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,12 +856,12 @@ bool popolaPlafond(TLista_documenti & din, const TDate& data_elab)
|
|||||||
TToken_string used;
|
TToken_string used;
|
||||||
if (din[i].tipo().nota_credito())
|
if (din[i].tipo().nota_credito())
|
||||||
{
|
{
|
||||||
used = thisPla.incrPlaf(din[i], utilizzato, true);
|
used = this_pla.incr_plaf(din[i], utilizzato, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Il controllo è andato bene, adesso mi segno i plafond che ho utilizzato nel memo del documento
|
// Il controllo è andato bene, adesso mi segno i plafond che ho utilizzato nel memo del documento
|
||||||
used = thisPla.consPlaf(utilizzato, true);
|
used = this_pla.cons_plaf(utilizzato, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rincontrollo che l'utilizzo del pladond sia tutto ok, meglio una volta in più che una in meno!
|
// Rincontrollo che l'utilizzo del pladond sia tutto ok, meglio una volta in più che una in meno!
|
||||||
|
@ -24,43 +24,43 @@ enum plafStruct { _planno, _plnumprot, _plimporto, _plchiusura, _plNC };
|
|||||||
|
|
||||||
class TLi_manager : TObject
|
class TLi_manager : TObject
|
||||||
{
|
{
|
||||||
TToken_string tipi;
|
TToken_string _tipi;
|
||||||
TToken_string stati;
|
TToken_string _stati;
|
||||||
bool validPlafond;
|
bool _valid_plafond;
|
||||||
bool soluzione;
|
bool _soluzione;
|
||||||
bool elabPR;
|
bool _elab_pr;
|
||||||
const char tipocf;
|
const char _tipocf;
|
||||||
const long codcli;
|
const long _codcli;
|
||||||
|
|
||||||
TDate iniDicInt;
|
TDate _ini_dic_int;
|
||||||
TDate finDicInt;
|
TDate _fin_dic_int;
|
||||||
real plafond;
|
real _plafond;
|
||||||
|
|
||||||
const TString codivaDef;
|
const TString _codiva_def;
|
||||||
const TString codivaAlt;
|
const TString _codiva_alt;
|
||||||
// Elenco di plafond con eventuale
|
// Elenco di plafond con eventuale
|
||||||
// Chiave ANNO|NUMERO(6)
|
// Chiave ANNO|NUMERO(6)
|
||||||
std::map<TString, real> plafondi;
|
std::map<TString, real> _plafondi;
|
||||||
std::map<int, TString> modifiche; // Progressivo, TToken_string(chiave,stato);
|
std::map<int, TString> _modifiche; // Progressivo, TToken_string(chiave,stato);
|
||||||
void elabTipiStati(); // Preparo due token string con tipi[0] -> stati[0], ...
|
void elab_tipi_stati(); // Preparo due token string con tipi[0] -> stati[0], ...
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Getters
|
// Getters
|
||||||
// Ritorno il plafond
|
// Ritorno il plafond
|
||||||
const real getPlafond() { return plafond; }
|
const real get_plafond() { return _plafond; }
|
||||||
// Ritorno se il plafond è valido
|
// Ritorno se il plafond è valido
|
||||||
bool hasValidPlafond() { return validPlafond; }
|
bool has_valid_plafond() const { return _valid_plafond; }
|
||||||
// Ritorna se è una dichiarazione di tipo soluzione
|
// Ritorna se è una dichiarazione di tipo soluzione
|
||||||
bool isSoluzione() { return soluzione; }
|
bool is_soluzione() const { return _soluzione; }
|
||||||
|
|
||||||
// Funzione che unisce consPlaf e incrPlaf
|
// Funzione che unisce consPlaf e incrPlaf
|
||||||
const TToken_string& getUse(TDocumento& d, const bool write = false);
|
const TToken_string& get_use(TDocumento& d, const bool write = false);
|
||||||
// "Consuma" il plafond
|
// "Consuma" il plafond
|
||||||
const TToken_string& consPlaf(real& plafUsed, const bool write = false);
|
const TToken_string& cons_plaf(real& plaf_used, const bool write = false);
|
||||||
// Da una nota credito passata incremento il plafond
|
// Da una nota credito passata incremento il plafond
|
||||||
const TToken_string& incrPlaf(TDocumento& d, real impNC = ZERO, const bool write = false);
|
const TToken_string& incr_plaf(TDocumento& d, real imp_nc = ZERO, const bool write = false);
|
||||||
// Storna un documento che riceve
|
// Storna un documento che riceve
|
||||||
const TToken_string& stornaDoc(const TDocumento& d, real impDC = ZERO, const bool write = false);
|
const TToken_string& storna_doc(const TDocumento& d, real imp_dc = ZERO, const bool write = false);
|
||||||
// Storna i documenti dopo a quello che riceve
|
// Storna i documenti dopo a quello che riceve
|
||||||
//void stornaDocs(const TDocumento& d, const bool write = false);
|
//void stornaDocs(const TDocumento& d, const bool write = false);
|
||||||
// Ricalcola i documenti dopo quello che riceve
|
// Ricalcola i documenti dopo quello che riceve
|
||||||
@ -69,41 +69,41 @@ public:
|
|||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
// Vado a estrapolare il plafond
|
// Vado a estrapolare il plafond
|
||||||
void elabPlafond();
|
void elab_plafond();
|
||||||
// Testo se con i documenti passati supero il plafond
|
// Testo se con i documenti passati supero il plafond
|
||||||
bool testPlafond(TLista_documenti& dout, TLog_report& lerr);
|
bool test_plafond(TLista_documenti& dout, TLog_report& lerr);
|
||||||
// Controllo se il codice iva è uguale a quello impostato per il calcolo del plafond
|
// Controllo se il codice iva è uguale a quello impostato per il calcolo del plafond
|
||||||
bool checkIva(TString cod) { return cod == codivaDef || cod == codivaAlt; }
|
bool check_iva(const TString& cod) const { return cod == _codiva_def || cod == _codiva_alt; }
|
||||||
|
|
||||||
// Controllo se il plafond che la NC passata rilascia non è già stato utilizzato
|
// Controllo se il plafond che la NC passata rilascia non è già stato utilizzato
|
||||||
bool checkUtilizzo(TDocumento& d, real impNC = ZERO);
|
bool check_utilizzo(TDocumento& d, real imp_nc = ZERO);
|
||||||
|
|
||||||
// Calcolo il rimanente del plafond
|
// Calcolo il rimanente del plafond
|
||||||
const real getPlaRes();
|
const real get_pla_res();
|
||||||
// Calcolo il rimanente del plafond su tipi e stati documento passati
|
// Calcolo il rimanente del plafond su tipi e stati documento passati
|
||||||
const real getPlaRes(TToken_string tipi, TToken_string stati);
|
const real get_pla_res(TToken_string tipi, TToken_string stati);
|
||||||
// Funzione che effettivamente effettua il calcolodalla data della dichiarazione alla data passata
|
// Funzione che effettivamente effettua il calcolodalla data della dichiarazione alla data passata
|
||||||
const real elabPlaRes(TToken_string t = "", TToken_string s = "", TDate ad = 0L);
|
const real elab_pla_res(TToken_string t = "", TToken_string s = "", TDate ad = 0L);
|
||||||
// Ritorna la quantità di plafond utilizzato dalla data della dichiarazione alla data passata
|
// Ritorna la quantità di plafond utilizzato dalla data della dichiarazione alla data passata
|
||||||
const real elabUtil(TToken_string tipi, TToken_string stati, TDate ad = 0L);
|
const real elab_util(TToken_string tipi, TToken_string stati, TDate ad = 0L);
|
||||||
// Modifica una lettera e salva la modifica in "modifiche"
|
// Modifica una lettera e salva la modifica in "modifiche"
|
||||||
void changeStato(const TString& key, const bool stato);
|
void change_stato(const TString& key, const bool stato);
|
||||||
// Controlla se ci sono delle modifiche da salvare nei plafonds
|
// Controlla se ci sono delle modifiche da salvare nei plafonds
|
||||||
bool hasModifiche() { return !modifiche.empty(); }
|
bool has_modifiche() const { return !_modifiche.empty(); }
|
||||||
// Annullo le modifiche
|
// Annullo le modifiche
|
||||||
void revertModifiche();
|
void revert_modifiche();
|
||||||
// Vuoto le modifiche
|
// Vuoto le modifiche
|
||||||
void clearModifiche() { modifiche.clear(); }
|
void clear_modifiche() { _modifiche.clear(); }
|
||||||
|
|
||||||
// Costructors/Destructors
|
// Costructors/Destructors
|
||||||
TLi_manager(const char t, const long c, TDate iniDic, TDate finDic);
|
TLi_manager(const char t, const long c, TDate ini_dic, TDate fin_dic);
|
||||||
TLi_manager(const char t, const long c, TDate finDic); // Sets iniDicInt as 01/01/finDic.year()
|
TLi_manager(const char t, const long c, TDate fin_dic); // Sets iniDicInt as 01/01/finDic.year()
|
||||||
virtual ~TLi_manager() {}
|
virtual ~TLi_manager() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void createTipiStati(TToken_string& tipi, TToken_string& stati);
|
static void create_tipi_stati(TToken_string& tipi, TToken_string& stati);
|
||||||
bool generaLiStorico(TDate dataIni);
|
bool genera_li_storico(const TDate& data_ini);
|
||||||
bool popolaPlafond(TLista_documenti& din, const TDate& data_elab);
|
bool popola_plafond(TLista_documenti& din, const TDate& data_elab);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -528,7 +528,7 @@ int TMotore_application::write( const TMask& m ) // C 90
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aggiunte per il controllo plafond
|
// Aggiunte per il controllo plafond
|
||||||
if(has_module(LIAUT, CHK_DONGLE) && d.tipo().is_fattura() && ini_get_bool(CONFIG_DITTA, "ve", "USELETTERE") && checkPlafondWrite(d) == -1)
|
if(has_module(LIAUT, CHK_DONGLE) && d.tipo().is_fattura() && ini_get_bool(CONFIG_DITTA, "ve", "USELETTERE") && check_plafond_write(d) == -1)
|
||||||
{
|
{
|
||||||
return _isnowarning;
|
return _isnowarning;
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ int TMotore_application::rewrite( const TMask& m ) // C 90
|
|||||||
d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
|
d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
|
||||||
|
|
||||||
// Aggiunte per il controllo plafond
|
// Aggiunte per il controllo plafond
|
||||||
if(has_module(LIAUT, CHK_DONGLE) && d.tipo().is_fattura() && ini_get_bool(CONFIG_DITTA, "ve", "USELETTERE") && checkPlafondRewrite(d) == -1)
|
if(has_module(LIAUT, CHK_DONGLE) && d.tipo().is_fattura() && ini_get_bool(CONFIG_DITTA, "ve", "USELETTERE") && check_plafond_rewrite(d) == -1)
|
||||||
{
|
{
|
||||||
return _isnowarning;
|
return _isnowarning;
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ int TMotore_application::rewrite( const TMask& m ) // C 90
|
|||||||
bool TMotore_application::remove() // C 90
|
bool TMotore_application::remove() // C 90
|
||||||
{
|
{
|
||||||
TDocumento& d = (TDocumento &) _rel->curr();
|
TDocumento& d = (TDocumento &) _rel->curr();
|
||||||
bool ok = checkPlafondDelete(d);
|
bool ok = check_plafond_delete(d);
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
d.put(DOC_NOTE, "DELETING");
|
d.put(DOC_NOTE, "DELETING");
|
||||||
@ -710,7 +710,7 @@ bool TMotore_application::user_create( )
|
|||||||
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR,
|
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR,
|
||||||
LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, LF_MOV, LF_STOMAG,
|
LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, LF_MOV, LF_STOMAG,
|
||||||
LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0);
|
LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0);
|
||||||
|
|
||||||
TISAM_recordset num("USE %NUM");
|
TISAM_recordset num("USE %NUM");
|
||||||
for (bool ok = num.move_first(); ok; ok = num.move_next())
|
for (bool ok = num.move_first(); ok; ok = num.move_next())
|
||||||
cached_numerazione(num.get("CODTAB").as_string());
|
cached_numerazione(num.get("CODTAB").as_string());
|
||||||
@ -1313,48 +1313,47 @@ void TMotore_application::preview()
|
|||||||
save_and_print(true, screenvis);
|
save_and_print(true, screenvis);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TMotore_application::checkPlafondWrite(TDocumento& d)
|
int TMotore_application::check_plafond_write(TDocumento& d)
|
||||||
{
|
{
|
||||||
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
||||||
|
if(!plafond.has_valid_plafond()) // Se il cliente non mi interessa
|
||||||
if(!plafond.hasValidPlafond()) // Se il cliente non mi interessa
|
|
||||||
return NOERR;
|
return NOERR;
|
||||||
|
|
||||||
TAssoc_array tabIva = d.tabella_iva(true);
|
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||||
|
|
||||||
real plaUtil = ZERO;
|
real pla_util = ZERO;
|
||||||
|
|
||||||
for (TRiepilogo_iva * totali = static_cast<TRiepilogo_iva *>(tabIva.get()); totali != NULL; totali = static_cast<TRiepilogo_iva *>(tabIva.get()))
|
for (TRiepilogo_iva * totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()); totali != nullptr; totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()))
|
||||||
{
|
{
|
||||||
if(plafond.checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
if(plafond.check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||||
{
|
{
|
||||||
plaUtil += totali->imp_orig();
|
pla_util += totali->imp_orig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plaUtil <= ZERO)
|
if(pla_util <= ZERO)
|
||||||
{
|
{
|
||||||
return NOERR;
|
return NOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
real plaRes = plafond.getPlaRes();
|
real pla_res = plafond.get_pla_res();
|
||||||
|
|
||||||
TToken_string used;
|
TToken_string used;
|
||||||
if(d.tipo().nota_credito())
|
if(d.tipo().nota_credito())
|
||||||
{
|
{
|
||||||
used = plafond.incrPlaf(d, plaUtil, true);
|
used = plafond.incr_plaf(d, pla_util, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Il controllo è andato bene, adesso mi segno i plafond che ho utilizzato nel memo del documento
|
// Il controllo è andato bene, adesso mi segno i plafond che ho utilizzato nel memo del documento
|
||||||
used = plafond.consPlaf(plaUtil, true);
|
used = plafond.cons_plaf(pla_util, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(used.starts_with("ERRORE"))
|
if(used.starts_with("ERRORE"))
|
||||||
{
|
{
|
||||||
plafond.revertModifiche();
|
plafond.revert_modifiche();
|
||||||
TString msg("Attenzione il plafond è stato superato di ");
|
TString msg("Attenzione il plafond è stato superato di ");
|
||||||
msg << TCurrency(-(plaRes - plaUtil)).string() << "€";
|
msg << TCurrency(-(pla_res - pla_util)).string() << "€";
|
||||||
warning_box(msg);
|
warning_box(msg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1365,39 +1364,39 @@ int TMotore_application::checkPlafondWrite(TDocumento& d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TMotore_application::checkPlafondRewrite(TDocumento& d)
|
int TMotore_application::check_plafond_rewrite(TDocumento& d)
|
||||||
{
|
{
|
||||||
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
||||||
if(!plafond.hasValidPlafond()) // Se il cliente non mi interessa
|
if(!plafond.has_valid_plafond()) // Se il cliente non mi interessa
|
||||||
return NOERR;
|
return NOERR;
|
||||||
|
|
||||||
TAssoc_array tabIva = d.tabella_iva(true);
|
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||||
TDocumento oldDoc;
|
TDocumento old_doc;
|
||||||
|
|
||||||
real plaUtil = ZERO;
|
real pla_util = ZERO;
|
||||||
|
|
||||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
for (TRiepilogo_iva * totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()); totali != nullptr; totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()))
|
||||||
if(plafond.checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
if(plafond.check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||||
plaUtil += totali->imp_orig();
|
pla_util += totali->imp_orig();
|
||||||
|
|
||||||
if(plaUtil <= ZERO)
|
if(pla_util <= ZERO)
|
||||||
return NOERR;
|
return NOERR;
|
||||||
|
|
||||||
// Prima di tutto controllo che non stia salvando la stessa roba che ho già, confronto il totale dei plafond con il totale da calcolare
|
// Prima di tutto controllo che non stia salvando la stessa roba che ho già, confronto il totale dei plafond con il totale da calcolare
|
||||||
TToken_string lePlafs(d.get("PLAFOND"), ',');
|
TToken_string le_plafs(d.get("PLAFOND"), ',');
|
||||||
real totPlaf = ZERO;
|
real tot_plaf = ZERO;
|
||||||
for(int i = 0; i < lePlafs.items(); i++)
|
for(int i = 0; i < le_plafs.items(); i++)
|
||||||
{
|
{
|
||||||
// É + ottimizzato rispetto a farlo in una linea sola?
|
// É + ottimizzato rispetto a farlo in una linea sola?
|
||||||
//static TToken_string thisPlaf; thisPlaf.cut(0) << lePlafs.get(i);
|
//static TToken_string thisPlaf; thisPlaf.cut(0) << lePlafs.get(i);
|
||||||
totPlaf += (real)((TToken_string)lePlafs.get(i)).get(_plimporto);
|
tot_plaf += static_cast<real>(static_cast<TToken_string>(le_plafs.get(i)).get(_plimporto));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcolo le differenze tra il plafond attuale da verificare e quello precedente
|
// Calcolo le differenze tra il plafond attuale da verificare e quello precedente
|
||||||
if(totPlaf == plaUtil)
|
if(tot_plaf == pla_util)
|
||||||
return NOERR;
|
return NOERR;
|
||||||
|
|
||||||
real plaRes = plafond.getPlaRes();
|
real pla_res = plafond.get_pla_res();
|
||||||
TToken_string used;
|
TToken_string used;
|
||||||
/* Devo gestire queste modifiche dividendo in 4 parti:
|
/* Devo gestire queste modifiche dividendo in 4 parti:
|
||||||
* 1) > vecchio Doc : faccio la differenza nuovo - vecchio e provo a generare un used nuovo
|
* 1) > vecchio Doc : faccio la differenza nuovo - vecchio e provo a generare un used nuovo
|
||||||
@ -1405,34 +1404,34 @@ int TMotore_application::checkPlafondRewrite(TDocumento& d)
|
|||||||
* 3) < vecchio Doc : storno parte del plafond già utilizzato
|
* 3) < vecchio Doc : storno parte del plafond già utilizzato
|
||||||
* 4) < vecchio NC : verifico che il plafond stornato con questa NC non sia stato utilizzato, in caso negativo tutto OK, positivo blocco.
|
* 4) < vecchio NC : verifico che il plafond stornato con questa NC non sia stato utilizzato, in caso negativo tutto OK, positivo blocco.
|
||||||
*/
|
*/
|
||||||
if(totPlaf < plaUtil)
|
if(tot_plaf < pla_util)
|
||||||
{
|
{
|
||||||
if(d.tipo().nota_credito()) // 2
|
if(d.tipo().nota_credito()) // 2
|
||||||
{
|
{
|
||||||
plaUtil -= totPlaf;
|
pla_util -= tot_plaf;
|
||||||
used = plafond.incrPlaf(d, plaUtil, true);
|
used = plafond.incr_plaf(d, pla_util, true);
|
||||||
}
|
}
|
||||||
else // 1
|
else // 1
|
||||||
{
|
{
|
||||||
plaUtil -= totPlaf;
|
pla_util -= tot_plaf;
|
||||||
used = plafond.consPlaf(plaUtil, true);
|
used = plafond.cons_plaf(pla_util, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(d.tipo().nota_credito()) // 4
|
if(d.tipo().nota_credito()) // 4
|
||||||
{
|
{
|
||||||
if(plafond.checkUtilizzo(d, plaUtil))
|
if(plafond.check_utilizzo(d, pla_util))
|
||||||
{
|
{
|
||||||
TString msg = "Attenzione! Si sta cercando di modificare una Nota di Credito che influisce le seguenti lettere di intento: \n";
|
TString msg = "Attenzione! Si sta cercando di modificare una Nota di Credito che influisce le seguenti lettere di intento: \n";
|
||||||
for(int i = 0; i < lePlafs.items(); i++)
|
for(int i = 0; i < le_plafs.items(); i++)
|
||||||
{
|
{
|
||||||
msg << i+1 << " - N." << lePlafs.get(_plnumprot) << "\n";
|
msg << i+1 << " - N." << le_plafs.get(_plnumprot) << "\n";
|
||||||
}
|
}
|
||||||
msg << "Vuoi continuare?";
|
msg << "Vuoi continuare?";
|
||||||
if(yesno_box(msg))
|
if(yesno_box(msg))
|
||||||
{
|
{
|
||||||
used = plafond.stornaDoc(d, totPlaf - plaUtil, true);
|
used = plafond.storna_doc(d, tot_plaf - pla_util, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
@ -1442,13 +1441,13 @@ int TMotore_application::checkPlafondRewrite(TDocumento& d)
|
|||||||
}
|
}
|
||||||
else // 3
|
else // 3
|
||||||
{
|
{
|
||||||
used = plafond.stornaDoc(d, totPlaf - plaUtil, true);
|
used = plafond.storna_doc(d, tot_plaf - pla_util, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(used.starts_with("ERRORE"))
|
if(used.starts_with("ERRORE"))
|
||||||
{
|
{
|
||||||
plafond.revertModifiche();
|
plafond.revert_modifiche();
|
||||||
warning_box(used);
|
warning_box(used);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1459,30 +1458,30 @@ int TMotore_application::checkPlafondRewrite(TDocumento& d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TMotore_application::checkPlafondDelete(TDocumento& d)
|
bool TMotore_application::check_plafond_delete(TDocumento& d)
|
||||||
{
|
{
|
||||||
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
TLi_manager plafond(d.tipocf(), d.codcf(), d.data());
|
||||||
if(d.get("PLAFOND").blank() || !plafond.hasValidPlafond()) // Se la fattura non ha nulla scritto in plafond non mi interessa
|
if(d.get("PLAFOND").blank() || !plafond.has_valid_plafond()) // Se la fattura non ha nulla scritto in plafond non mi interessa
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
TAssoc_array tabIva = d.tabella_iva(true);
|
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||||
TDocumento oldDoc;
|
TDocumento old_doc;
|
||||||
|
|
||||||
// Prima di tutto controllo che non stia salvando la stessa roba che ho già, confronto il totale dei plafond con il totale da calcolare
|
// Prima di tutto controllo che non stia salvando la stessa roba che ho già, confronto il totale dei plafond con il totale da calcolare
|
||||||
TToken_string lePlafs(d.get("PLAFOND"), ',');
|
TToken_string le_plafs(d.get("PLAFOND"), ',');
|
||||||
real totPlaf = ZERO;
|
real totPlaf = ZERO;
|
||||||
for(int i = 0; i < lePlafs.items(); i++)
|
for(int i = 0; i < le_plafs.items(); i++)
|
||||||
{
|
{
|
||||||
// É + ottimizzato rispetto a farlo in una linea sola?
|
// É + ottimizzato rispetto a farlo in una linea sola?
|
||||||
//static TToken_string thisPlaf; thisPlaf.cut(0) << lePlafs.get(i);
|
//static TToken_string thisPlaf; thisPlaf.cut(0) << lePlafs.get(i);
|
||||||
totPlaf += (real)((TToken_string)lePlafs.get(i)).get(_plimporto);
|
totPlaf += static_cast<real>(static_cast<TToken_string>(le_plafs.get(i)).get(_plimporto));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcolo le differenze tra il plafond attuale da verificare e quello precedente
|
// Calcolo le differenze tra il plafond attuale da verificare e quello precedente
|
||||||
if(totPlaf == ZERO)
|
if(totPlaf == ZERO)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
real plaRes = plafond.getPlaRes();
|
real pla_res = plafond.get_pla_res();
|
||||||
TToken_string used;
|
TToken_string used;
|
||||||
/* Devo gestire queste modifiche dividendo in 4 parti:
|
/* Devo gestire queste modifiche dividendo in 4 parti:
|
||||||
* 1) < vecchio Doc : storno parte del plafond già utilizzato
|
* 1) < vecchio Doc : storno parte del plafond già utilizzato
|
||||||
@ -1490,18 +1489,18 @@ bool TMotore_application::checkPlafondDelete(TDocumento& d)
|
|||||||
*/
|
*/
|
||||||
if(d.tipo().nota_credito()) // 2
|
if(d.tipo().nota_credito()) // 2
|
||||||
{
|
{
|
||||||
if(plafond.checkUtilizzo(d, totPlaf))
|
if(plafond.check_utilizzo(d, totPlaf))
|
||||||
{
|
{
|
||||||
TString msg = "Attenzione! Si sta cercando di modificare una Nota di Credito che influisce le seguenti lettere di intento: \n";
|
TString msg = "Attenzione! Si sta cercando di modificare una Nota di Credito che influisce le seguenti lettere di intento: \n";
|
||||||
for(int i = 0; i < lePlafs.items(); i++)
|
for(int i = 0; i < le_plafs.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string thisPlaf(lePlafs.get(i));
|
TToken_string this_plaf(le_plafs.get(i));
|
||||||
msg << i+1 << " - N." << thisPlaf.get(_plnumprot) << "\n";
|
msg << i+1 << " - N." << this_plaf.get(_plnumprot) << "\n";
|
||||||
}
|
}
|
||||||
msg << "Vuoi continuare?";
|
msg << "Vuoi continuare?";
|
||||||
if(yesno_box(msg))
|
if(yesno_box(msg))
|
||||||
{
|
{
|
||||||
used = plafond.stornaDoc(d, totPlaf, true);
|
used = plafond.storna_doc(d, totPlaf, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@ -1511,23 +1510,23 @@ bool TMotore_application::checkPlafondDelete(TDocumento& d)
|
|||||||
}
|
}
|
||||||
else // 1
|
else // 1
|
||||||
{
|
{
|
||||||
real plafSto = ZERO;
|
real plaf_sto = ZERO;
|
||||||
for(int i = 0; i < lePlafs.items(); i++)
|
for(int i = 0; i < le_plafs.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string thisPlaf(lePlafs.get(i));
|
TToken_string this_plaf(le_plafs.get(i));
|
||||||
plafSto += static_cast<real>(thisPlaf.get(_plNC));
|
plaf_sto += static_cast<real>(this_plaf.get(_plNC));
|
||||||
}
|
}
|
||||||
if(plafSto > ZERO)
|
if(plaf_sto > ZERO)
|
||||||
{
|
{
|
||||||
if(!yesno_box(TR("Attenzione! Si sta cercando di eliminare un documento per cui sono presenti una o più note di variazione per un totale di %s€\nContinuare?"), TCurrency(plafSto).string()))
|
if(!yesno_box(TR("Attenzione! Si sta cercando di eliminare un documento per cui sono presenti una o più note di variazione per un totale di %s€\nContinuare?"), TCurrency(plaf_sto).string()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
used = plafond.stornaDoc(d, totPlaf, true);
|
used = plafond.storna_doc(d, totPlaf, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(used.starts_with("ERRORE"))
|
if(used.starts_with("ERRORE"))
|
||||||
{
|
{
|
||||||
plafond.revertModifiche();
|
plafond.revert_modifiche();
|
||||||
warning_box(used);
|
warning_box(used);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,9 @@ public:
|
|||||||
virtual const char* get_next_key( );
|
virtual const char* get_next_key( );
|
||||||
|
|
||||||
// Test Plafond
|
// Test Plafond
|
||||||
int checkPlafondWrite(TDocumento& d);
|
int check_plafond_write(TDocumento& d);
|
||||||
int checkPlafondRewrite(TDocumento& d);
|
int check_plafond_rewrite(TDocumento& d);
|
||||||
bool checkPlafondDelete(TDocumento& d);
|
bool check_plafond_delete(TDocumento& d);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline TMotore_application& app() { return (TMotore_application &) main_app(); }
|
inline TMotore_application& app() { return (TMotore_application &) main_app(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user