Merge remote-tracking branch 'origin/R_10_00' into R_10_00
This commit is contained in:
commit
7b68ee33a7
3
cd/test/cg0860.txt
Normal file
3
cd/test/cg0860.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cg2.exe
|
||||
|
||||
Corretta importazione scadenze con f1
|
95
cd/test/cg0860a.ini
Normal file
95
cd/test/cg0860a.ini
Normal file
@ -0,0 +1,95 @@
|
||||
[Main]
|
||||
Demo=0
|
||||
|
||||
[cg2]
|
||||
Edit_23 = cg2 -0
|
||||
File(145) = cg2.exe|X
|
||||
Patch = 0860
|
||||
Versione = 21511200
|
||||
|
||||
[cg99]
|
||||
Kill(0) = batbdel.msk|x
|
||||
Kill(1) = bastdpn.msk|x
|
||||
Kill(2) = cgtbcon.msk|x
|
||||
Kill(3) = bastcfi.msk|x
|
||||
Kill(4) = bastpor.msk|x
|
||||
Kill(5) = batbesc.msk|x
|
||||
Kill(6) = batbvet.msk|x
|
||||
Kill(7) = bastleg.rep|x
|
||||
Kill(8) = batbntb.msk|x
|
||||
Kill(9) = bastleg.msk|x
|
||||
Kill(10) = batbzon.msk|x
|
||||
Kill(11) = batbinl.msk|x
|
||||
Kill(12) = bastvet.rep|x
|
||||
Kill(13) = batbind.msk|x
|
||||
Kill(14) = batbnot.msk|x
|
||||
Kill(15) = bastnot.rep|x
|
||||
Kill(16) = batbleg.msk|x
|
||||
Kill(17) = batbver.msk|x
|
||||
Kill(18) = bastarb.msk|x
|
||||
Kill(19) = bastreg.rep|x
|
||||
Kill(20) = bastcco.msk|x
|
||||
Kill(21) = bastreg.msk|x
|
||||
Kill(22) = bastcam.rep|x
|
||||
Kill(23) = batbcve.msk|x
|
||||
Kill(24) = batbtit.msk|x
|
||||
Kill(25) = bastesc.rep|x
|
||||
Kill(26) = batbdpn.msk|x
|
||||
Kill(27) = bastivd.msk|x
|
||||
Kill(28) = batbtra.msk|x
|
||||
Kill(29) = bastndo.msk|x
|
||||
Kill(30) = bastcfi.rep|x
|
||||
Kill(31) = bastzon.rep|x
|
||||
Kill(32) = cg2fppro.msk|x
|
||||
Kill(33) = bastcve.rep|x
|
||||
Kill(34) = bastcve.msk|x
|
||||
Kill(35) = bastndo.rep|x
|
||||
Kill(36) = bastcam.msk|x
|
||||
Kill(37) = batbcam.msk|x
|
||||
Kill(38) = batbcco.msk|x
|
||||
Kill(39) = bastver.rep|x
|
||||
Kill(40) = bastivd.rep|x
|
||||
Kill(41) = batbmsp.msk|x
|
||||
Kill(42) = bastnot.msk|x
|
||||
Kill(43) = bastscc.msk|x
|
||||
Kill(44) = bastpor.rep|x
|
||||
Kill(45) = batbreg.msk|x
|
||||
Kill(46) = batbndo.msk|x
|
||||
Kill(47) = batbcfi.msk|x
|
||||
Kill(48) = bastesc.msk|x
|
||||
Kill(49) = bastarb.rep|x
|
||||
Kill(50) = bastver.msk|x
|
||||
Kill(51) = bastntb.msk|x
|
||||
Kill(52) = bastmsp.rep|x
|
||||
Kill(53) = batbarb.msk|x
|
||||
Kill(54) = batbscc.msk|x
|
||||
Kill(55) = bastntb.rep|x
|
||||
Kill(56) = batbivd.msk|x
|
||||
Kill(57) = batbins.msk|x
|
||||
Kill(58) = bastcco.rep|x
|
||||
Kill(59) = bastpdb.msk|x
|
||||
Kill(60) = bastscc.rep|x
|
||||
Kill(61) = bastzon.msk|x
|
||||
Kill(62) = batblia.msk|x
|
||||
Kill(63) = batbpdb.msk|x
|
||||
Kill(64) = bastdpn.rep|x
|
||||
Kill(65) = bastvet.msk|x
|
||||
Kill(66) = bastmsp.msk|x
|
||||
Kill(67) = batblbu.msk|x
|
||||
Kill(68) = bastpdb.rep|x
|
||||
Kill(69) = batblia.msk|x
|
||||
Kill(70) = batbpor.msk|x
|
||||
|
||||
[cg]
|
||||
Data = 23-07-2019
|
||||
Descrizione = Contabilita' Generale
|
||||
Dischi = 1
|
||||
Moduli = ba
|
||||
OEM =
|
||||
Patch = 860
|
||||
PostProcess = bainst -0 CG
|
||||
PreProcess =
|
||||
Prezzo(1) =
|
||||
Prezzo(2) =
|
||||
Versione = 21511200
|
||||
|
BIN
cd/test/cg0860a1.zip
Normal file
BIN
cd/test/cg0860a1.zip
Normal file
Binary file not shown.
5
cd/test/lv0860.txt
Normal file
5
cd/test/lv0860.txt
Normal file
@ -0,0 +1,5 @@
|
||||
lv0300a.msk
|
||||
lv2.exe
|
||||
|
||||
Aggiunto dettaglio consegne alla fatturazione
|
||||
Nella configurazione prima pagina c'è il flag dettaglio consegne
|
23
cd/test/lv0860a.ini
Normal file
23
cd/test/lv0860a.ini
Normal file
@ -0,0 +1,23 @@
|
||||
[Main]
|
||||
Demo=0
|
||||
|
||||
[lv1]
|
||||
Edit_168 = lv0 -3
|
||||
File(6) = lv0300a.msk|X
|
||||
File(46) = lv2.exe|X
|
||||
Patch = 860
|
||||
Versione = 21511200
|
||||
|
||||
[lv]
|
||||
Data = 22-07-2019
|
||||
Descrizione = Gestione lavanderie
|
||||
Dischi = 1
|
||||
Moduli = ve,mg
|
||||
OEM = 2
|
||||
Patch = 860
|
||||
PostProcess = bainst -0 LV
|
||||
PreProcess =
|
||||
Prezzo(1) =
|
||||
Prezzo(2) =
|
||||
Versione = 21511200
|
||||
|
BIN
cd/test/lv0860a1.zip
Normal file
BIN
cd/test/lv0860a1.zip
Normal file
Binary file not shown.
4
cd/test/lv0862.txt
Normal file
4
cd/test/lv0862.txt
Normal file
@ -0,0 +1,4 @@
|
||||
lv0300a.msk
|
||||
lv2.exe
|
||||
Aggiunto dettaglio consegne alla fatturazione
|
||||
Nella configurazione prima pagina c'è il flag dettaglio consegne
|
23
cd/test/lv0862a.ini
Normal file
23
cd/test/lv0862a.ini
Normal file
@ -0,0 +1,23 @@
|
||||
[Main]
|
||||
Demo=0
|
||||
|
||||
[lv1]
|
||||
Edit_168 = lv0 -3
|
||||
File(6) = lv0300a.msk|X
|
||||
File(46) = lv2.exe|X
|
||||
Patch = 0862
|
||||
Versione = 21511200
|
||||
|
||||
[lv]
|
||||
Data = 22-07-2019
|
||||
Descrizione = Gestione lavanderie
|
||||
Dischi = 1
|
||||
Moduli = ve,mg
|
||||
OEM = 2
|
||||
Patch = 862
|
||||
PostProcess = bainst -0 LV
|
||||
PreProcess =
|
||||
Prezzo(1) =
|
||||
Prezzo(2) =
|
||||
Versione = 21511200
|
||||
|
BIN
cd/test/lv0862a1.zip
Normal file
BIN
cd/test/lv0862a1.zip
Normal file
Binary file not shown.
@ -513,7 +513,7 @@ bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
doc.put(DOC_CODNUM, row.get(2));
|
||||
doc.put(DOC_TIPODOC, row.get(3));
|
||||
doc.put(DOC_NDOC, row.get(5));
|
||||
if (doc.edit())
|
||||
if (doc.edit(LF_DOC, "", "ve0")) // Perchè prima andava senza dovergli mettere nulla?
|
||||
fill();
|
||||
}
|
||||
break;
|
||||
|
@ -197,6 +197,7 @@
|
||||
#define LF_FPCCAUS 177
|
||||
#define LF_FPCART 178
|
||||
#define LF_FPCADG 179
|
||||
#define LF_CONART 180
|
||||
|
||||
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
|
||||
|
||||
|
@ -78,5 +78,5 @@
|
||||
#define RDOC_VALC "VALC"
|
||||
#define RDOC_VALV "VALV"
|
||||
#define RDOC_PPROV "PPROV"
|
||||
|
||||
#define RDOC_TIPOCON "TIPOCON" // Con questo campo capisco a quale sottocategoria conai si riferisce la riga autogenerata
|
||||
#endif
|
||||
|
@ -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);
|
||||
// Lancio la maschera
|
||||
if(app.run() == K_ENTER)
|
||||
generaLiStorico(app.get_date(101));
|
||||
genera_li_storico(app.get_date(101));
|
||||
break;
|
||||
}
|
||||
case DLG_USER:
|
||||
|
@ -123,17 +123,17 @@ void TResDI_app::elab(TResDI_mask& m)
|
||||
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
|
||||
if(currentCli.hasValidPlafond())
|
||||
if(currentCli.has_valid_plafond())
|
||||
{
|
||||
real plafond = currentCli.getPlafond();
|
||||
real resPlafond = plafond - currentCli.elabUtil(tipi, stati, aData) - currentCli.elabUtil(tipif, statif);
|
||||
real plafond = currentCli.get_plafond();
|
||||
real resPlafond = plafond - currentCli.elab_util(tipi, stati, aData) - currentCli.elab_util(tipif, statif);
|
||||
|
||||
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";
|
||||
log.log(0, msg);
|
||||
msg = TString("Plafond disponibile: ") << static_cast<TCurrency>((resPlafond > ZERO ? resPlafond : ZERO )).string() << "€";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -13,103 +13,102 @@ const TString make_key(const int anno, const int numplaf)
|
||||
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();
|
||||
TAssoc_array tabIva = d.tabella_iva(true);
|
||||
TString4 numDoc = d.numerazione();
|
||||
int nDoc = d.numero();
|
||||
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||
TString4 num_doc = d.numerazione();
|
||||
|
||||
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())
|
||||
{
|
||||
ret.cut(0) << incrPlaf(d, plaUtil, write);
|
||||
ret.cut(0) << incr_plaf(d, pla_util, write);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.cut(0) << consPlaf(plaUtil, write);
|
||||
ret.cut(0) << cons_plaf(pla_util, write);
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
if(!validPlafond || plafUsed > getPlafond())
|
||||
if(!_valid_plafond || plaf_used > get_plafond())
|
||||
{
|
||||
used << "ERRORE NEL CALCOLO DEL PLAFOND";
|
||||
return used;
|
||||
}
|
||||
|
||||
bool close = false;
|
||||
TToken_string thisPlaf("", ',');
|
||||
while(plafUsed > ZERO)
|
||||
TToken_string this_plaf("", ',');
|
||||
while(plaf_used > ZERO)
|
||||
{
|
||||
// Calcolo quanto plafond ho usato
|
||||
TString thisNumprot = plafondi.begin()->first;
|
||||
real thisAmount = plafondi.begin()->second;
|
||||
TString this_numprot = _plafondi.begin()->first;
|
||||
real this_amount = _plafondi.begin()->second;
|
||||
|
||||
real thisUtilizzato;
|
||||
real this_utilizzato;
|
||||
|
||||
if(plafUsed >= thisAmount)
|
||||
if(plaf_used >= this_amount)
|
||||
{
|
||||
close = true;
|
||||
thisUtilizzato = thisAmount;
|
||||
this_utilizzato = this_amount;
|
||||
|
||||
// Rimuovo il plafond dalla lista,
|
||||
plafondi.erase(thisNumprot);
|
||||
_plafondi.erase(this_numprot);
|
||||
|
||||
if(write)
|
||||
{
|
||||
// lo chiudo
|
||||
changeStato(thisNumprot, true);
|
||||
change_stato(this_numprot, true);
|
||||
}
|
||||
|
||||
// e diminuisco tutto
|
||||
plafond -= thisAmount;
|
||||
plafUsed -= thisAmount;
|
||||
_plafond -= this_amount;
|
||||
plaf_used -= this_amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
close = false;
|
||||
thisUtilizzato = plafUsed;
|
||||
this_utilizzato = plaf_used;
|
||||
|
||||
// e diminuisco tutto
|
||||
plafond -= plafUsed;
|
||||
plafondi[thisNumprot] -= plafUsed;
|
||||
plafUsed = ZERO;
|
||||
_plafond -= plaf_used;
|
||||
_plafondi[this_numprot] -= plaf_used;
|
||||
plaf_used = ZERO;
|
||||
}
|
||||
|
||||
// Segno di aver usato il plafond
|
||||
static TToken_string u; u.cut(0);
|
||||
u.add(thisNumprot, _planno);
|
||||
u.add(thisUtilizzato.string(), _plimporto);
|
||||
u.add(this_numprot, _planno);
|
||||
u.add(this_utilizzato.string(), _plimporto);
|
||||
u.add(close? "X" : "", _plchiusura);
|
||||
used.add(u);
|
||||
}
|
||||
// Controllo di avere ancora plafond rimanente
|
||||
if(plafond <= ZERO)
|
||||
validPlafond = false;
|
||||
if(_plafond <= ZERO)
|
||||
_valid_plafond = false;
|
||||
|
||||
// Tolgo la virgola finale
|
||||
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 */
|
||||
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);
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
if(lePlafs.items() == 0)
|
||||
if(le_plafs.items() == 0)
|
||||
return used;
|
||||
|
||||
// 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
|
||||
TAssoc_array tabIva = d.tabella_iva(true);
|
||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
||||
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||
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
|
||||
if(impNC <= ZERO)
|
||||
if(imp_nc <= ZERO)
|
||||
return used;
|
||||
|
||||
bool open = false;
|
||||
TToken_string thisPlaf("", '|');
|
||||
for(int i = lePlafs.items() - 1; i >= 0 && impNC > ZERO; i--)
|
||||
TToken_string this_plaf("", '|');
|
||||
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
|
||||
real importoPlaf = thisPlaf.get(_plimporto);
|
||||
real importo_plaf = this_plaf.get(_plimporto);
|
||||
// Importo già riaccreditato da altre NC
|
||||
real importoNC = thisPlaf.get(_plNC);
|
||||
real importo_nc = this_plaf.get(_plNC);
|
||||
// Importo possibile di plafond da stornare
|
||||
real rimanente = importoPlaf - importoNC;
|
||||
real rimanente = importo_plaf - importo_nc;
|
||||
|
||||
if(rimanente == ZERO)
|
||||
// This isn't the plafond you're looking for
|
||||
continue;
|
||||
|
||||
if(rimanente < impNC)
|
||||
if(rimanente < imp_nc)
|
||||
{
|
||||
impNC -= rimanente;
|
||||
imp_nc -= rimanente;
|
||||
}
|
||||
else
|
||||
{
|
||||
rimanente = impNC;
|
||||
impNC = ZERO;
|
||||
rimanente = imp_nc;
|
||||
imp_nc = ZERO;
|
||||
}
|
||||
|
||||
// Salvo la quantità utilizzata nelle TToken_string
|
||||
thisPlaf.add(rimanente, _plNC);
|
||||
lePlafs.add(thisPlaf, i);
|
||||
this_plaf.add(rimanente, _plNC);
|
||||
le_plafs.add(this_plaf, i);
|
||||
|
||||
// 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;
|
||||
// Incremento!
|
||||
plafondi[key] += rimanente;
|
||||
_plafondi[key] += rimanente;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Va aggiunto ex novo!
|
||||
// Calcolo l'importo delle righe che rientrano nel plafond
|
||||
open = true;
|
||||
plafondi.insert(std::pair<TString,real>(key, rimanente));
|
||||
_plafondi.insert(std::pair<TString,real>(key, rimanente));
|
||||
|
||||
// Se devo scrivere abilito il plafond
|
||||
if(write)
|
||||
{
|
||||
changeStato(key, false);
|
||||
change_stato(key, false);
|
||||
}
|
||||
}
|
||||
// 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
|
||||
static TToken_string usedApp("", ','); usedApp.cut(0);
|
||||
static TToken_string used_app("", ','); used_app.cut(0);
|
||||
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
|
||||
ds.put("PLAFOND", lePlafs);
|
||||
ds.put("PLAFOND", le_plafs);
|
||||
ds.rewrite();
|
||||
|
||||
// Tolgo la virgola finale
|
||||
used.cut(used.len()-1);
|
||||
|
||||
// Succedono cose in memoria, devo rimediare così
|
||||
return usedApp;
|
||||
return used_app;
|
||||
}
|
||||
/*
|
||||
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
|
||||
|
||||
// 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++)
|
||||
{
|
||||
@ -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);
|
||||
// True se devo stornare tutto il Doc
|
||||
bool totale = impDC.is_zero();
|
||||
const bool totale = imp_dc.is_zero();
|
||||
bool ok = true;
|
||||
// Devo ricaricare le righe sui plafond che ho
|
||||
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);
|
||||
const TString key = make_key(thisPlafond.get_int(_planno), thisPlafond.get_int(_plnumprot));
|
||||
real thisImporto = thisPlafond.get(_plimporto);
|
||||
TToken_string this_plafond = plafs.get(i);
|
||||
const TString key = make_key(this_plafond.get_int(_planno), this_plafond.get_int(_plnumprot));
|
||||
real this_importo = this_plafond.get(_plimporto);
|
||||
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
|
||||
if(thisImporto > impDC)
|
||||
if(this_importo > imp_dc)
|
||||
{
|
||||
thisPlafond.add(impDC, _plimporto);
|
||||
plafs.add(thisPlafond, i);
|
||||
this_plafond.add(imp_dc, _plimporto);
|
||||
plafs.add(this_plafond, i);
|
||||
}
|
||||
else
|
||||
plafs.destroy(i);
|
||||
impDC = ZERO;
|
||||
imp_dc = ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
impDC -= thisImporto;
|
||||
imp_dc -= this_importo;
|
||||
plafs.destroy(i);
|
||||
}
|
||||
}
|
||||
TString asd = thisImporto.string();
|
||||
TString asd = this_importo.string();
|
||||
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
|
||||
plafondi[key] -= thisImporto;
|
||||
_plafondi[key] -= this_importo;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -364,19 +363,19 @@ const TToken_string& TLi_manager::stornaDoc(const TDocumento& d, real impDC, con
|
||||
}
|
||||
else
|
||||
{
|
||||
if(plafondi.find(key) != plafondi.end())
|
||||
if(_plafondi.find(key) != _plafondi.end())
|
||||
{
|
||||
//Sommo
|
||||
plafondi[key] += thisImporto;
|
||||
_plafondi[key] += this_importo;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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
|
||||
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;
|
||||
int first = -1;
|
||||
// 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++)
|
||||
{
|
||||
@ -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 */
|
||||
|
||||
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
|
||||
if(iniDicInt.year() < 2017)
|
||||
if(_ini_dic_int.year() < 2017)
|
||||
return;
|
||||
|
||||
TRelation letint(LF_LETINT);
|
||||
TRectype filtro(letint.curr());
|
||||
filtro.add("CODCLI", codcli);
|
||||
filtro.add("ANNO", iniDicInt.year());
|
||||
filtro.add("CODCLI", _codcli);
|
||||
filtro.add("ANNO", _ini_dic_int.year());
|
||||
|
||||
// Creo un cursore ordinato e prelevo la prima riga non chiusa
|
||||
TCursor c_dicint(&letint, "", 2, &filtro, &filtro);
|
||||
@ -441,11 +440,11 @@ void TLi_manager::elabPlafond()
|
||||
if(c_dicint.items() > 0)
|
||||
{
|
||||
// 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();
|
||||
// Esco se raggiungo una data successiva al nostro documento
|
||||
if(row.get_date("DAL") > finDicInt)
|
||||
if(row.get_date("DAL") > _fin_dic_int)
|
||||
break;
|
||||
|
||||
if(!row.get_bool("CHIUSA"))
|
||||
@ -455,113 +454,113 @@ void TLi_manager::elabPlafond()
|
||||
if(row.get_int("TIPOOP") == SOLUZIONE_UNICA)
|
||||
{
|
||||
// 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!
|
||||
validPlafond = false;
|
||||
plafondi.clear();
|
||||
plafond = -UNO;
|
||||
_valid_plafond = false;
|
||||
_plafondi.clear();
|
||||
_plafond = -UNO;
|
||||
return;
|
||||
}
|
||||
soluzione = true;
|
||||
_soluzione = true;
|
||||
}
|
||||
if(!validPlafond)
|
||||
iniDicInt = row.get_date("DAL");
|
||||
if(!_valid_plafond)
|
||||
_ini_dic_int = row.get_date("DAL");
|
||||
|
||||
// Aggiungo il plafond trovato all'elenco dei plafond
|
||||
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
|
||||
plafond += row.get_real("IMPORTO");
|
||||
validPlafond = true;
|
||||
_plafond += row.get_real("IMPORTO");
|
||||
_valid_plafond = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!validPlafond)
|
||||
plafond = -UNO;
|
||||
if(!_valid_plafond)
|
||||
_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)
|
||||
return plafond;
|
||||
if(_elab_pr)
|
||||
return _plafond;
|
||||
else
|
||||
elabPR = true;
|
||||
_elab_pr = true;
|
||||
|
||||
if(t.full() && s.full())
|
||||
{
|
||||
tipi = t;
|
||||
stati = s;
|
||||
_tipi = t;
|
||||
_stati = s;
|
||||
}
|
||||
if(!ad.ok())
|
||||
ad = finDicInt;
|
||||
plafond = -UNO;
|
||||
if(!validPlafond)
|
||||
return plafond;
|
||||
ad = _fin_dic_int;
|
||||
_plafond = -UNO;
|
||||
if(!_valid_plafond)
|
||||
return _plafond;
|
||||
|
||||
TLista_documenti din; // Legge tutti i documenti di input
|
||||
|
||||
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al plafond
|
||||
din.read('D', tipocf, codcli, iniDicInt.year(), tipi, stati, iniDicInt, ad);
|
||||
// Trovo tutti i documenti che mi interessano e sottraggo l'imponibile al _plafond
|
||||
din.read('D', _tipocf, _codcli, _ini_dic_int.year(), _tipi, _stati, _ini_dic_int, ad);
|
||||
|
||||
for(int i = 0; i < din.items(); i++)
|
||||
{
|
||||
TToken_string plaf(din[i].get("PLAFOND"), ',');
|
||||
for(int j = 0; j < plaf.items(); j++)
|
||||
{
|
||||
TToken_string thePla(plaf.get(j));
|
||||
const TString key = make_key(thePla.get_int(_planno), thePla.get_int(_plnumprot));
|
||||
static TString chiusura; chiusura.cut(0) << thePla.get(_plchiusura); // La get ritorna un const char*
|
||||
TToken_string the_pla(plaf.get(j));
|
||||
const TString key = make_key(the_pla.get_int(_planno), the_pla.get_int(_plnumprot));
|
||||
static TString chiusura; chiusura.cut(0) << the_pla.get(_plchiusura); // La get ritorna un const char*
|
||||
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()))
|
||||
{
|
||||
plafondi[key] = ZERO;
|
||||
_plafondi[key] = ZERO;
|
||||
}
|
||||
plafondi[key] += static_cast<real>(thePla.get(_plimporto));
|
||||
_plafondi[key] += static_cast<real>(the_pla.get(_plimporto));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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()))
|
||||
{
|
||||
validPlafond = false;
|
||||
return plafond;
|
||||
_valid_plafond = false;
|
||||
return _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
|
||||
{
|
||||
if(plafondi.find(key) != plafondi.end())
|
||||
if(_plafondi.find(key) != _plafondi.end())
|
||||
{
|
||||
if(chiusura == "X")
|
||||
{
|
||||
if(DEBUG_ENABLED && plafondi[key] != static_cast<real>(thePla.get(_plimporto)) &&
|
||||
!yesno_box(TR("Questa lettera di intento è incongruente,\nTotale attivo: %s\nTotale da disattivare: %s\nContinuare?"), plafondi[key].string(), 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(), the_pla.get(_plimporto)))
|
||||
{
|
||||
validPlafond = false;
|
||||
return plafond;
|
||||
_valid_plafond = false;
|
||||
return _plafond;
|
||||
}
|
||||
plafondi.erase(key);
|
||||
_plafondi.erase(key);
|
||||
}
|
||||
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
|
||||
plafond = ZERO;
|
||||
for(auto it = plafondi.begin(); it != plafondi.end(); ++it)
|
||||
plafond += it->second;
|
||||
_plafond = ZERO;
|
||||
for(auto it = _plafondi.begin(); it != _plafondi.end(); ++it)
|
||||
_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;
|
||||
if(tipi.items() == 0)
|
||||
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
|
||||
|
||||
// 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++)
|
||||
{
|
||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
||||
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
break;
|
||||
@ -614,21 +613,21 @@ const real TLi_manager::elabUtil(TToken_string tipi, TToken_string stati, TDate
|
||||
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;
|
||||
static TToken_string& use = get_tmp_string();
|
||||
// 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++)
|
||||
{
|
||||
use.cut(0) << getUse(dout[i], true);
|
||||
use.cut(0) << get_use(dout[i], true);
|
||||
if(use.starts_with("ERRORE"))
|
||||
{
|
||||
TString msgerr;
|
||||
msgerr << "Superata dichiarazione di intento cliente N." << dout[i].codcf() << "\n" << use;
|
||||
lerr.log(2, msgerr);
|
||||
revertModifiche();
|
||||
clearModifiche();
|
||||
revert_modifiche();
|
||||
clear_modifiche();
|
||||
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% */
|
||||
bool TLi_manager::checkUtilizzo(TDocumento& d, real impNC)
|
||||
bool TLi_manager::check_utilizzo(TDocumento& d, real imp_nc)
|
||||
{
|
||||
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
|
||||
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())
|
||||
if(checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||
impNC += totali->imp_orig();
|
||||
if(check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||
imp_nc += totali->imp_orig();
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
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)
|
||||
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));
|
||||
const TString key = make_key(thisPlaf.get_int(_planno), thisPlaf.get_int(_plnumprot));
|
||||
if(plafondi.find(key) != plafondi.end())
|
||||
TToken_string this_plaf(le_plafs.get(i));
|
||||
const TString key = make_key(this_plaf.get_int(_planno), this_plaf.get_int(_plnumprot));
|
||||
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
|
||||
ok = false;
|
||||
@ -670,56 +669,56 @@ bool TLi_manager::checkUtilizzo(TDocumento& d, real impNC)
|
||||
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!
|
||||
Jean_Baptiste_Le_Rond_dAlembert.put("CHIUSA", stato);
|
||||
Jean_Baptiste_Le_Rond_dAlembert.rewrite(TLocalisamfile(LF_LETINT));
|
||||
|
||||
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;
|
||||
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;
|
||||
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.rewrite(baguette);
|
||||
}
|
||||
clearModifiche();
|
||||
clear_modifiche();
|
||||
}
|
||||
|
||||
TLi_manager::TLi_manager(const char t, const long c, TDate iniDic, TDate finDic)
|
||||
: tipocf (t), codcli(c), iniDicInt(iniDic), finDicInt(finDic),
|
||||
codivaDef(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||
codivaAlt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||
plafond(ZERO), validPlafond(false), soluzione(false), elabPR(false)
|
||||
: _tipocf (t), _codcli(c), _ini_dic_int(iniDic), _fin_dic_int(finDic),
|
||||
_codiva_def(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||
_codiva_alt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||
_plafond(ZERO), _valid_plafond(false), _soluzione(false), _elab_pr(false)
|
||||
{
|
||||
elabTipiStati();
|
||||
elabPlafond();
|
||||
elab_tipi_stati();
|
||||
elab_plafond();
|
||||
}
|
||||
|
||||
TLi_manager::TLi_manager(const char t, const long c, TDate finDic)
|
||||
: tipocf (t), codcli(c), finDicInt(finDic),
|
||||
codivaDef(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||
codivaAlt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||
plafond(ZERO), validPlafond(false), soluzione(false), elabPR(false)
|
||||
: _tipocf (t), _codcli(c), _fin_dic_int(finDic),
|
||||
_codiva_def(ini_get_string(CONFIG_DITTA, "li", "CODIVA")),
|
||||
_codiva_alt(ini_get_string(CONFIG_DITTA, "li", "CODIVALT")),
|
||||
_plafond(ZERO), _valid_plafond(false), _soluzione(false), _elab_pr(false)
|
||||
{
|
||||
iniDicInt.set_day(01);
|
||||
iniDicInt.set_month(01);
|
||||
iniDicInt.set_year(finDic.year());
|
||||
elabTipiStati();
|
||||
elabPlafond();
|
||||
_ini_dic_int.set_day(01);
|
||||
_ini_dic_int.set_month(01);
|
||||
_ini_dic_int.set_year(finDic.year());
|
||||
elab_tipi_stati();
|
||||
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"));
|
||||
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
|
||||
TRelation rletint(LF_LETINT);
|
||||
TString filter = "DAL>="; filter << dataIni.date2ansi();
|
||||
TString filter = "DAL>="; filter << data_ini.date2ansi();
|
||||
TCursor cletint(&rletint, filter, 2);
|
||||
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 codIVAS = ini_get_string(CONFIG_DITTA, "li", "CODIVALT");
|
||||
static TString cod_ivap = ini_get_string(CONFIG_DITTA, "li", "CODIVA");
|
||||
static TString cod_ivas = ini_get_string(CONFIG_DITTA, "li", "CODIVALT");
|
||||
|
||||
TProgress_monitor status(cletint.items(), "Aggiornamento plafond");
|
||||
|
||||
@ -765,15 +764,15 @@ bool generaLiStorico(TDate dataIni)
|
||||
continue;
|
||||
|
||||
// Date
|
||||
TDate startCurr = rletint.get_date("DAL"), endCurr;
|
||||
endCurr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? --rletintn.get_date("DAL") : NULLDATE;
|
||||
TDate start_curr = rletint.get_date("DAL"), end_curr;
|
||||
end_curr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? --rletintn.get_date("DAL") : NULLDATE;
|
||||
// Dati lettera
|
||||
real impLI = rletint.get_real("IMPORTO");
|
||||
real imp_li = rletint.get_real("IMPORTO");
|
||||
bool soluzione = rletint.get_int("TIPOOP") == SOLUZIONE_UNICA;
|
||||
|
||||
// Adesso che so le date apro tutti i documenti
|
||||
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++)
|
||||
{
|
||||
#ifdef DBG
|
||||
@ -781,10 +780,10 @@ bool generaLiStorico(TDate dataIni)
|
||||
bool tolla = true;
|
||||
#endif
|
||||
real utilizzato = ZERO;
|
||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get())
|
||||
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||
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();
|
||||
}
|
||||
|
||||
@ -800,7 +799,7 @@ bool generaLiStorico(TDate dataIni)
|
||||
}
|
||||
|
||||
// Controllo di non superare il plafond
|
||||
if(impLI >= utilizzato)
|
||||
if(imp_li >= utilizzato)
|
||||
{
|
||||
// Creo la chiave da scrivere e metto tutto dentro
|
||||
const TString key = make_key(rletint.get_int("ANNO"), rletint.get_int("NUMPROT"));
|
||||
@ -823,14 +822,14 @@ bool generaLiStorico(TDate dataIni)
|
||||
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;
|
||||
TProgress_monitor mDoc(din.items(), "Generazione plafond nelle fatture");
|
||||
TProgress_monitor m_doc(din.items(), "Generazione plafond nelle fatture");
|
||||
bool ok = true;
|
||||
for(int i = 0; i < din.items() && ok; i++)
|
||||
{
|
||||
if (!mDoc.add_status())
|
||||
if (!m_doc.add_status())
|
||||
return false;
|
||||
|
||||
// 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);
|
||||
plafs.insert(std::pair<int, TLi_manager*>(din[i].codcf(), app));
|
||||
}
|
||||
TLi_manager& thisPla = *plafs[din[i].codcf()]; // Forget about optimization!
|
||||
if (!thisPla.hasValidPlafond()) continue;
|
||||
TLi_manager& this_pla = *plafs[din[i].codcf()]; // Forget about optimization!
|
||||
if (!this_pla.has_valid_plafond()) continue;
|
||||
|
||||
// Calcolo quanto plafond sta utilizzando
|
||||
real utilizzato = ZERO;
|
||||
TAssoc_array tabIva = din[i].tabella_iva(true);
|
||||
for (TRiepilogo_iva * totali = (TRiepilogo_iva *)tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *)tabIva.get())
|
||||
TAssoc_array tab_iva = din[i].tabella_iva(true);
|
||||
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();
|
||||
}
|
||||
|
||||
@ -857,12 +856,12 @@ bool popolaPlafond(TLista_documenti & din, const TDate& data_elab)
|
||||
TToken_string used;
|
||||
if (din[i].tipo().nota_credito())
|
||||
{
|
||||
used = thisPla.incrPlaf(din[i], utilizzato, true);
|
||||
used = this_pla.incr_plaf(din[i], utilizzato, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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!
|
||||
|
@ -24,43 +24,43 @@ enum plafStruct { _planno, _plnumprot, _plimporto, _plchiusura, _plNC };
|
||||
|
||||
class TLi_manager : TObject
|
||||
{
|
||||
TToken_string tipi;
|
||||
TToken_string stati;
|
||||
bool validPlafond;
|
||||
bool soluzione;
|
||||
bool elabPR;
|
||||
const char tipocf;
|
||||
const long codcli;
|
||||
TToken_string _tipi;
|
||||
TToken_string _stati;
|
||||
bool _valid_plafond;
|
||||
bool _soluzione;
|
||||
bool _elab_pr;
|
||||
const char _tipocf;
|
||||
const long _codcli;
|
||||
|
||||
TDate iniDicInt;
|
||||
TDate finDicInt;
|
||||
real plafond;
|
||||
TDate _ini_dic_int;
|
||||
TDate _fin_dic_int;
|
||||
real _plafond;
|
||||
|
||||
const TString codivaDef;
|
||||
const TString codivaAlt;
|
||||
const TString _codiva_def;
|
||||
const TString _codiva_alt;
|
||||
// Elenco di plafond con eventuale
|
||||
// Chiave ANNO|NUMERO(6)
|
||||
std::map<TString, real> plafondi;
|
||||
std::map<int, TString> modifiche; // Progressivo, TToken_string(chiave,stato);
|
||||
void elabTipiStati(); // Preparo due token string con tipi[0] -> stati[0], ...
|
||||
std::map<TString, real> _plafondi;
|
||||
std::map<int, TString> _modifiche; // Progressivo, TToken_string(chiave,stato);
|
||||
void elab_tipi_stati(); // Preparo due token string con tipi[0] -> stati[0], ...
|
||||
|
||||
public:
|
||||
// Getters
|
||||
// Ritorno il plafond
|
||||
const real getPlafond() { return plafond; }
|
||||
const real get_plafond() { return _plafond; }
|
||||
// Ritorno se il plafond è valido
|
||||
bool hasValidPlafond() { return validPlafond; }
|
||||
bool has_valid_plafond() const { return _valid_plafond; }
|
||||
// Ritorna se è una dichiarazione di tipo soluzione
|
||||
bool isSoluzione() { return soluzione; }
|
||||
bool is_soluzione() const { return _soluzione; }
|
||||
|
||||
// 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
|
||||
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
|
||||
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
|
||||
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
|
||||
//void stornaDocs(const TDocumento& d, const bool write = false);
|
||||
// Ricalcola i documenti dopo quello che riceve
|
||||
@ -69,41 +69,41 @@ public:
|
||||
|
||||
// Functions
|
||||
// Vado a estrapolare il plafond
|
||||
void elabPlafond();
|
||||
void elab_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
|
||||
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
|
||||
bool checkUtilizzo(TDocumento& d, real impNC = ZERO);
|
||||
bool check_utilizzo(TDocumento& d, real imp_nc = ZERO);
|
||||
|
||||
// Calcolo il rimanente del plafond
|
||||
const real getPlaRes();
|
||||
const real get_pla_res();
|
||||
// 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
|
||||
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
|
||||
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"
|
||||
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
|
||||
bool hasModifiche() { return !modifiche.empty(); }
|
||||
bool has_modifiche() const { return !_modifiche.empty(); }
|
||||
// Annullo le modifiche
|
||||
void revertModifiche();
|
||||
void revert_modifiche();
|
||||
// Vuoto le modifiche
|
||||
void clearModifiche() { modifiche.clear(); }
|
||||
void clear_modifiche() { _modifiche.clear(); }
|
||||
|
||||
// Costructors/Destructors
|
||||
TLi_manager(const char t, const long c, TDate iniDic, TDate finDic);
|
||||
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 ini_dic, TDate fin_dic);
|
||||
TLi_manager(const char t, const long c, TDate fin_dic); // Sets iniDicInt as 01/01/finDic.year()
|
||||
virtual ~TLi_manager() {}
|
||||
};
|
||||
|
||||
static void createTipiStati(TToken_string& tipi, TToken_string& stati);
|
||||
bool generaLiStorico(TDate dataIni);
|
||||
bool popolaPlafond(TLista_documenti& din, const TDate& data_elab);
|
||||
static void create_tipi_stati(TToken_string& tipi, TToken_string& stati);
|
||||
bool genera_li_storico(const TDate& data_ini);
|
||||
bool popola_plafond(TLista_documenti& din, const TDate& data_elab);
|
||||
|
||||
|
||||
#endif
|
@ -101,6 +101,8 @@
|
||||
|
||||
#define F_DOTSTO 278
|
||||
|
||||
#define F_DETTCONS 279
|
||||
|
||||
#define F_BACKUP 300
|
||||
|
||||
#define S_CODNUM_RIT 101
|
||||
|
@ -166,7 +166,7 @@ BEGIN
|
||||
FLAGS "UP"
|
||||
END
|
||||
|
||||
STRING F_DESTIPODOC_FAT 50
|
||||
STRING F_DESTIPODOC_FAT 50 30
|
||||
BEGIN
|
||||
PROMPT 24 5 ""
|
||||
HELP "Descrizione tipo documento"
|
||||
@ -177,6 +177,14 @@ BEGIN
|
||||
COPY OUTPUT F_TIPODOC_FAT
|
||||
END
|
||||
|
||||
BOOLEAN F_DETTCONS
|
||||
BEGIN
|
||||
PROMPT 60 5 "Dettaglio consegne"
|
||||
FIELD DettCons
|
||||
MESSAGE TRUE CLEAR,F_RIFTEST
|
||||
MESSAGE FALSE ENABLE,F_RIFTEST
|
||||
END
|
||||
|
||||
BOOLEAN F_RIFTEST
|
||||
BEGIN
|
||||
PROMPT 2 6 "Scrivi riferimenti in testata documento"
|
||||
|
@ -124,8 +124,8 @@ protected:
|
||||
virtual bool doc_raggruppabili(const TDocumento& doc_in, const TDocumento& doc_out, TToken_string& campi) const ;
|
||||
virtual bool doc_raggruppabile(const TDocumento & doc) const { return true; }
|
||||
virtual void campi_raggruppamento_righe(TToken_string& campi_riga) const;
|
||||
virtual bool gestione_riferimenti() const { return true; }
|
||||
virtual bool riferimenti_in_testa() const { return true; }
|
||||
// virtual bool gestione_riferimenti() const { return true; }
|
||||
// virtual bool riferimenti_in_testa() const { return true; }
|
||||
virtual TRiga_documento& find_or_create_row(TDocumento& doc_out, const TRiga_documento & rin,const char lavtype);
|
||||
virtual bool get_num_tip_out(const TDocumento& doc_out, TString& codnum, TString& tipodoc) const;
|
||||
|
||||
@ -511,24 +511,26 @@ int TFatturazione_lavanderie::write_fatt_ragg(const bool solotot)
|
||||
void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_documenti& doc_in)
|
||||
{
|
||||
const bool use_indsp = ini_get_bool(CONFIG_DITTA, "mg", "MOV_INDSPED");
|
||||
const bool riftest = ini_get_bool(CONFIG_DITTA, "lv", "RifTest");
|
||||
const bool zero_note = ini_get_bool(CONFIG_DITTA, "lv", "ZeroNote");
|
||||
|
||||
const bool dett_cons = ini_get_bool(CONFIG_DITTA, "lv", "DettCons");
|
||||
const bool riftest = !dett_cons && ini_get_bool(CONFIG_DITTA, "lv", "RifTest");
|
||||
|
||||
//scorro tutti i documenti di output generati precedentemente
|
||||
for (int id = 0; id < doc_out.items(); id++)
|
||||
{
|
||||
//instanzio il documento e recupero le variabili di interesse per recuperare
|
||||
//il contratto del cliente in questione
|
||||
TDocumento& doc = doc_out[id];
|
||||
const long clifo = doc.get_long(DOC_CODCF);
|
||||
TRecord_array original_rows = doc.body();
|
||||
const long clifo = doc.get_long(DOC_CODCF);
|
||||
|
||||
const int indsped = doc.get_int(DOC_CODINDSP);
|
||||
TLaundry_contract contr(clifo,indsped,_data_elab);
|
||||
//flag per il calcolo sul valore convenzionale e sul fisso per dotazione iniziale
|
||||
bool valconvcli = false;
|
||||
bool fixdotin = false;
|
||||
bool elcons = contr.get_bool(LVCONDV_ELCONS);
|
||||
bool rifbol = contr.get_bool(LVCONDV_RIFBOL);
|
||||
// bool fixdotin = false;
|
||||
bool elcons = contr.get_bool(LVCONDV_ELCONS);
|
||||
bool rifbol = !dett_cons && contr.get_bool(LVCONDV_RIFBOL);
|
||||
|
||||
const bool splitpay = doc.anno() > 2015 && doc.clifor().get_bool(CLI_SPLITPAY);
|
||||
real consvconv;
|
||||
@ -556,6 +558,8 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
|
||||
if (doc.physical_rows() > 0 && doc[1].is_descrizione())
|
||||
{
|
||||
const TString desc = doc[1].get(RDOC_DESCR);
|
||||
|
||||
if (elcons)
|
||||
{
|
||||
TRiga_documento& rout = doc[1];
|
||||
@ -564,7 +568,7 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
rout.put(RDOC_DESCEST, "");
|
||||
}
|
||||
else
|
||||
if (!rifbol)
|
||||
if (!rifbol || dett_cons)
|
||||
doc.destroy_row(1, true);
|
||||
}
|
||||
|
||||
@ -739,7 +743,9 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
else // se il tipo canone è impostato a nessuno o % sul valore convenzionale per cliente vado in ambedue i casi ad eseguire il ciclo che analizza i tipi forfait
|
||||
{
|
||||
//per ogni documento, scorro tutte le sue righe
|
||||
for (int i = 1; i <= doc.physical_rows() ; i++)
|
||||
const int rigamerce = doc.physical_rows() > 0 && doc[1].is_descrizione() ? 2 : 1;
|
||||
|
||||
for (int i = rigamerce; i <= doc.physical_rows() ; i++)
|
||||
{
|
||||
TRiga_documento& rout = doc[i];
|
||||
|
||||
@ -1340,12 +1346,28 @@ void TFatturazione_lavanderie::post_process(TLista_documenti& doc_out, TLista_do
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int h = doc.physical_rows(); h > 0; h--)
|
||||
const int rigamerce = doc.physical_rows() > 0 && doc[1].is_descrizione() ? 2 : 1;
|
||||
|
||||
for(int h = doc.physical_rows(); h >= rigamerce; h--)
|
||||
{
|
||||
TRiga_documento& rdoc = doc[h];
|
||||
if (rdoc.get(RDOC_DESCR).empty() || ((rdoc.imponibile().is_zero() && rdoc.get_real(RDOC_QTA).is_zero())))
|
||||
doc.destroy_row(h, true);
|
||||
}
|
||||
if (dett_cons)
|
||||
{
|
||||
for (int i = 1; i <= original_rows.rows(); i++)
|
||||
{
|
||||
if (((TRiga_documento &) original_rows[i]).is_descrizione())
|
||||
{
|
||||
TRiga_documento & r = doc.new_row(original_rows[i].get(RDOC_TIPORIGA));
|
||||
|
||||
doc.copy_data(r, original_rows[i]);
|
||||
r.zero(RDOC_PREZZO);
|
||||
r.zero(RDOC_CODIVA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int id = doc_out.items() - 1; id >= 0 ; id--)
|
||||
{
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "../mg/rmovmag.h"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
|
||||
// campi comuni alla maschere di magazzino
|
||||
typedef enum
|
||||
{
|
||||
@ -85,6 +87,8 @@ const char* const zero_fields[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
class TArticolo_conai;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCodice_articolo
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -169,6 +173,8 @@ public:
|
||||
TRecord_array& deslin() const { return body(LF_DESLIN); }
|
||||
TRecord_array& codcorr() const { return body(LF_CODCORR); }
|
||||
|
||||
TArticolo_conai& conai() const;
|
||||
|
||||
TArticolo(const char* codice = NULL);
|
||||
TArticolo(const TRectype& rec);
|
||||
virtual ~TArticolo() {}
|
||||
@ -330,6 +336,25 @@ void refresh_article(const char* codart);
|
||||
TArticolo& cached_article(const char* codart);
|
||||
TArticolo_giacenza& cached_article_balances(const char* codart);
|
||||
|
||||
class TArticolo_conai : TObject
|
||||
{
|
||||
private:
|
||||
const TString _codart;
|
||||
// Categoria -> Sottocategoria + peso
|
||||
std::map<TString, std::map<TString, real>> _catsotpes;
|
||||
public:
|
||||
const std::map<TString, std::map<TString, real>>& get_map() { return _catsotpes; }
|
||||
const std::map<TString, real>* get_scat(const TString& cat);
|
||||
real get_peso(const TString& cat, const TString& scat);
|
||||
real get_peso(const TString& fcat) { return get_peso(fcat.left(2), fcat.right(2)); }
|
||||
|
||||
TArticolo_conai(const TString& codart);
|
||||
};
|
||||
|
||||
#define FOR_EACH_CONAI_CAT(_art_con, _cat) const auto& _map_conai = ac.get_map(); \
|
||||
for(const auto& _cat : _map_conai)
|
||||
#define FOR_EACH_CONAI_SOTTOCAT(_art_con, _cat, _sottocat) FOR_EACH_CONAI_CAT(_art_con, _cat) for(const auto& _sottocat : (_cat).second)
|
||||
|
||||
// *******************************
|
||||
// LIBRERIA DI utility del magazzino
|
||||
// *******************************
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "clifogiac.h"
|
||||
#include "movmag.h"
|
||||
#include "rmovmag.h"
|
||||
#include "conart.h"
|
||||
|
||||
// libreria per i movimenti
|
||||
class TTimed_skipbox: public TTimed_breakbox
|
||||
@ -465,6 +466,15 @@ real TArticolo::convert_to_um(const real& v, const TString& to_um, const TString
|
||||
return r;
|
||||
}
|
||||
|
||||
TArticolo_conai& TArticolo::conai() const
|
||||
{
|
||||
static TArticolo_conai* articolo_conai = nullptr;
|
||||
if (articolo_conai == nullptr)
|
||||
articolo_conai = new TArticolo_conai(_codice);
|
||||
|
||||
return *articolo_conai;
|
||||
}
|
||||
|
||||
TArticolo::TArticolo(const char* codice) : TMultiple_rectype(LF_ANAMAG)
|
||||
{
|
||||
add_file(LF_UMART,"NRIGA");
|
||||
@ -1840,6 +1850,95 @@ TArticolo_giacenza& cached_article_balances(const char* codart)
|
||||
return __cache_articoli_giacenza.art(codart);
|
||||
}
|
||||
|
||||
const char* conai2anamagfld(const TString& conai_cat)
|
||||
{
|
||||
if (conai_cat == "AL")
|
||||
return "CONALL";
|
||||
else if (conai_cat == "AC")
|
||||
return "CONACC";
|
||||
else if (conai_cat == "CA")
|
||||
return "CONCAR";
|
||||
else if (conai_cat == "PL")
|
||||
return "CONPLA";
|
||||
else if (conai_cat == "LE")
|
||||
return "CONLEG";
|
||||
else if (conai_cat == "VE")
|
||||
return "CONVET";
|
||||
else
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
// Conai nell'articolo
|
||||
TArticolo_conai::TArticolo_conai(const TString& codart)
|
||||
: _codart(codart)
|
||||
{
|
||||
/* Devo caricarmi tutti i codici conai presenti nell'articolo
|
||||
* Cerco inizialmente la presenza dell'articolo in tabmod,
|
||||
* se non lo trovo sarà salvato nel vecchio metodo
|
||||
*/
|
||||
{
|
||||
TLocalisamfile conart(LF_CONART);
|
||||
conart.put(CONART_CODART, _codart);
|
||||
int err = conart.read(_isgteq);
|
||||
while (err == NOERR && _codart == conart.get(CONART_CODART))
|
||||
{
|
||||
const TString& categoria = conart.get(CONART_CATEGORIA);
|
||||
const TString& sottocat = conart.get(CONART_SOTTOCAT);
|
||||
const real& peso = conart.get_real(CONART_PESO);
|
||||
_catsotpes[categoria][sottocat] = peso;
|
||||
err = conart.next();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Vado a cercare sempre nelle vecchie tabelle dell'articolo, Perchè giovane padawan?
|
||||
* La risposta è semplice, tutti i programmi che non verranno aggiornati da queste modifiche (es. Importazione Pack/SKNT)
|
||||
* scrivono li e quindi va tenuta la compatibilità
|
||||
*/
|
||||
{
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
TRectype ranamag(LF_ANAMAG);
|
||||
ranamag.put(ANAMAG_CODART, _codart);
|
||||
if (ranamag.read(anamag) == NOERR) // Non dovrebbe mai fallire
|
||||
{
|
||||
const TString& conaisc = ranamag.get(ANAMAG_CONAISC);
|
||||
int startcon = -1;
|
||||
// Mi serve sapere dove iniziano i campi del conai
|
||||
const RecFieldDes* fs = ranamag.rec_des().Fd;
|
||||
for (int i = 0; i < ranamag.rec_des().NFields && startcon == -1; i++)
|
||||
startcon = strcmp(fs[i].Name, ANAMAG_CONACC) == 0 ? i : -1;
|
||||
|
||||
if (startcon > -1)
|
||||
{
|
||||
for (int i = 0; i < conaisc.len() / 4; i++)
|
||||
{
|
||||
const TString& con = conaisc.mid(i * 4, 4);
|
||||
const TString& categoria = con.left(2);
|
||||
const TString& sottocat = con.right(2);
|
||||
if (con.blank()) continue;
|
||||
|
||||
_catsotpes[categoria][sottocat] = ranamag.get_real(fs[startcon + i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<TString, real>* TArticolo_conai::get_scat(const TString& cat)
|
||||
{
|
||||
if (_catsotpes.find(cat) != _catsotpes.end())
|
||||
return &_catsotpes[cat];
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
real TArticolo_conai::get_peso(const TString& cat, const TString& scat)
|
||||
{
|
||||
real peso = -UNO;
|
||||
if (_catsotpes.find(cat) != _catsotpes.end() && _catsotpes[cat].find(scat) != _catsotpes[cat].end())
|
||||
peso = _catsotpes[cat][scat];
|
||||
return peso;
|
||||
}
|
||||
|
||||
// causali
|
||||
|
||||
int TCausale_magazzino::sgn(TTipo_saldomag tiposaldo) const
|
||||
|
@ -528,7 +528,7 @@ int TMotore_application::write( const TMask& m ) // C 90
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -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
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -583,7 +583,7 @@ int TMotore_application::rewrite( const TMask& m ) // C 90
|
||||
bool TMotore_application::remove() // C 90
|
||||
{
|
||||
TDocumento& d = (TDocumento &) _rel->curr();
|
||||
bool ok = checkPlafondDelete(d);
|
||||
bool ok = check_plafond_delete(d);
|
||||
if(ok)
|
||||
{
|
||||
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,
|
||||
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);
|
||||
|
||||
|
||||
TISAM_recordset num("USE %NUM");
|
||||
for (bool ok = num.move_first(); ok; ok = num.move_next())
|
||||
cached_numerazione(num.get("CODTAB").as_string());
|
||||
@ -1313,48 +1313,47 @@ void TMotore_application::preview()
|
||||
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());
|
||||
|
||||
if(!plafond.hasValidPlafond()) // Se il cliente non mi interessa
|
||||
if(!plafond.has_valid_plafond()) // Se il cliente non mi interessa
|
||||
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;
|
||||
}
|
||||
|
||||
real plaRes = plafond.getPlaRes();
|
||||
real pla_res = plafond.get_pla_res();
|
||||
|
||||
TToken_string used;
|
||||
if(d.tipo().nota_credito())
|
||||
{
|
||||
used = plafond.incrPlaf(d, plaUtil, true);
|
||||
used = plafond.incr_plaf(d, pla_util, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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"))
|
||||
{
|
||||
plafond.revertModifiche();
|
||||
plafond.revert_modifiche();
|
||||
TString msg("Attenzione il plafond è stato superato di ");
|
||||
msg << TCurrency(-(plaRes - plaUtil)).string() << "€";
|
||||
msg << TCurrency(-(pla_res - pla_util)).string() << "€";
|
||||
warning_box(msg);
|
||||
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());
|
||||
if(!plafond.hasValidPlafond()) // Se il cliente non mi interessa
|
||||
if(!plafond.has_valid_plafond()) // Se il cliente non mi interessa
|
||||
return NOERR;
|
||||
|
||||
TAssoc_array tabIva = d.tabella_iva(true);
|
||||
TDocumento oldDoc;
|
||||
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||
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())
|
||||
if(plafond.checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||
plaUtil += totali->imp_orig();
|
||||
for (TRiepilogo_iva * totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()); totali != nullptr; totali = dynamic_cast<TRiepilogo_iva *>(tab_iva.get()))
|
||||
if(plafond.check_iva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa
|
||||
pla_util += totali->imp_orig();
|
||||
|
||||
if(plaUtil <= ZERO)
|
||||
if(pla_util <= ZERO)
|
||||
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
|
||||
TToken_string lePlafs(d.get("PLAFOND"), ',');
|
||||
real totPlaf = ZERO;
|
||||
for(int i = 0; i < lePlafs.items(); i++)
|
||||
TToken_string le_plafs(d.get("PLAFOND"), ',');
|
||||
real tot_plaf = ZERO;
|
||||
for(int i = 0; i < le_plafs.items(); i++)
|
||||
{
|
||||
// É + ottimizzato rispetto a farlo in una linea sola?
|
||||
//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
|
||||
if(totPlaf == plaUtil)
|
||||
if(tot_plaf == pla_util)
|
||||
return NOERR;
|
||||
|
||||
real plaRes = plafond.getPlaRes();
|
||||
real pla_res = plafond.get_pla_res();
|
||||
TToken_string used;
|
||||
/* Devo gestire queste modifiche dividendo in 4 parti:
|
||||
* 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
|
||||
* 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
|
||||
{
|
||||
plaUtil -= totPlaf;
|
||||
used = plafond.incrPlaf(d, plaUtil, true);
|
||||
pla_util -= tot_plaf;
|
||||
used = plafond.incr_plaf(d, pla_util, true);
|
||||
}
|
||||
else // 1
|
||||
{
|
||||
plaUtil -= totPlaf;
|
||||
used = plafond.consPlaf(plaUtil, true);
|
||||
pla_util -= tot_plaf;
|
||||
used = plafond.cons_plaf(pla_util, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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";
|
||||
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?";
|
||||
if(yesno_box(msg))
|
||||
{
|
||||
used = plafond.stornaDoc(d, totPlaf - plaUtil, true);
|
||||
used = plafond.storna_doc(d, tot_plaf - pla_util, true);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
@ -1442,13 +1441,13 @@ int TMotore_application::checkPlafondRewrite(TDocumento& d)
|
||||
}
|
||||
else // 3
|
||||
{
|
||||
used = plafond.stornaDoc(d, totPlaf - plaUtil, true);
|
||||
used = plafond.storna_doc(d, tot_plaf - pla_util, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(used.starts_with("ERRORE"))
|
||||
{
|
||||
plafond.revertModifiche();
|
||||
plafond.revert_modifiche();
|
||||
warning_box(used);
|
||||
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());
|
||||
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;
|
||||
|
||||
TAssoc_array tabIva = d.tabella_iva(true);
|
||||
TDocumento oldDoc;
|
||||
TAssoc_array tab_iva = d.tabella_iva(true);
|
||||
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
|
||||
TToken_string lePlafs(d.get("PLAFOND"), ',');
|
||||
TToken_string le_plafs(d.get("PLAFOND"), ',');
|
||||
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?
|
||||
//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
|
||||
if(totPlaf == ZERO)
|
||||
return true;
|
||||
|
||||
real plaRes = plafond.getPlaRes();
|
||||
real pla_res = plafond.get_pla_res();
|
||||
TToken_string used;
|
||||
/* Devo gestire queste modifiche dividendo in 4 parti:
|
||||
* 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(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";
|
||||
for(int i = 0; i < lePlafs.items(); i++)
|
||||
for(int i = 0; i < le_plafs.items(); i++)
|
||||
{
|
||||
TToken_string thisPlaf(lePlafs.get(i));
|
||||
msg << i+1 << " - N." << thisPlaf.get(_plnumprot) << "\n";
|
||||
TToken_string this_plaf(le_plafs.get(i));
|
||||
msg << i+1 << " - N." << this_plaf.get(_plnumprot) << "\n";
|
||||
}
|
||||
msg << "Vuoi continuare?";
|
||||
if(yesno_box(msg))
|
||||
{
|
||||
used = plafond.stornaDoc(d, totPlaf, true);
|
||||
used = plafond.storna_doc(d, totPlaf, true);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -1511,23 +1510,23 @@ bool TMotore_application::checkPlafondDelete(TDocumento& d)
|
||||
}
|
||||
else // 1
|
||||
{
|
||||
real plafSto = ZERO;
|
||||
for(int i = 0; i < lePlafs.items(); i++)
|
||||
real plaf_sto = ZERO;
|
||||
for(int i = 0; i < le_plafs.items(); i++)
|
||||
{
|
||||
TToken_string thisPlaf(lePlafs.get(i));
|
||||
plafSto += static_cast<real>(thisPlaf.get(_plNC));
|
||||
TToken_string this_plaf(le_plafs.get(i));
|
||||
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;
|
||||
}
|
||||
used = plafond.stornaDoc(d, totPlaf, true);
|
||||
used = plafond.storna_doc(d, totPlaf, true);
|
||||
}
|
||||
|
||||
if(used.starts_with("ERRORE"))
|
||||
{
|
||||
plafond.revertModifiche();
|
||||
plafond.revert_modifiche();
|
||||
warning_box(used);
|
||||
return false;
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ public:
|
||||
virtual const char* get_next_key( );
|
||||
|
||||
// Test Plafond
|
||||
int checkPlafondWrite(TDocumento& d);
|
||||
int checkPlafondRewrite(TDocumento& d);
|
||||
bool checkPlafondDelete(TDocumento& d);
|
||||
int check_plafond_write(TDocumento& d);
|
||||
int check_plafond_rewrite(TDocumento& d);
|
||||
bool check_plafond_delete(TDocumento& d);
|
||||
};
|
||||
|
||||
inline TMotore_application& app() { return (TMotore_application &) main_app(); }
|
||||
|
@ -248,7 +248,7 @@ END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 13 1 "@bCodice Spesa"
|
||||
PROMPT 13 1 "@bCodice Spesa Default"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
@ -469,6 +469,8 @@ END
|
||||
ZOOM F_DESCONAIASS 110 50
|
||||
BEGIN
|
||||
PROMPT 2 16 ""
|
||||
FIELD DESCCONAIASS
|
||||
GROUP 7
|
||||
END
|
||||
|
||||
BOOLEAN F_ESPONIESENTI
|
||||
|
@ -9,8 +9,9 @@
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <tabutil.h>
|
||||
#include "conart.h"
|
||||
|
||||
const char * get_token(TSheet_field & s, int r, int dlg)
|
||||
const char * get_token(TSheet_field & s, int r, int dlg)
|
||||
{
|
||||
TString & tmp = get_tmp_string(50);
|
||||
TToken_string & row = s.row(r);
|
||||
@ -141,7 +142,9 @@ protected:
|
||||
virtual void on_firm_change();
|
||||
bool search_on_file(const char * key, int file, int nkey, const char * field);
|
||||
virtual bool protected_record(TRectype&);
|
||||
|
||||
|
||||
void fill_conai(const TString& codart, TSheet_field& fld_con) const;
|
||||
int write_conai(const TMask& m) const;
|
||||
virtual int read(TMask& m);
|
||||
void load_um(TMask& m);
|
||||
virtual bool remove();
|
||||
@ -1987,8 +1990,74 @@ bool TAnagrafica_magazzino::protected_record(TRectype& rec)
|
||||
return TRUE;
|
||||
else
|
||||
return search_on_file(art, LF_RMOVMAG, 2, "CODART");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TAnagrafica_magazzino::fill_conai(const TString& codart, TSheet_field& fld_con) const
|
||||
{
|
||||
// Distruggo e nascondo lo sheet
|
||||
fld_con.destroy();
|
||||
fld_con.hide();
|
||||
|
||||
TArticolo_conai ac(codart);
|
||||
FOR_EACH_CONAI_SOTTOCAT(ac, cat, sottocat)
|
||||
{
|
||||
TToken_string& row = fld_con.row(-1);
|
||||
row.add(cat.first);
|
||||
row.add(sottocat.first);
|
||||
row.add(sottocat.second);
|
||||
}
|
||||
|
||||
// Lo rimostro
|
||||
fld_con.show();
|
||||
}
|
||||
|
||||
int TAnagrafica_magazzino::write_conai(const TMask& m) const
|
||||
{
|
||||
int ok = NOERR;
|
||||
// Prima di tutto svuoto i campi del conai sull'articolo
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
anamag.put(ANAMAG_CODART, m.get(F_CODART));
|
||||
if(anamag.read() == NOERR)
|
||||
{
|
||||
anamag.put(ANAMAG_CONAISC, "");
|
||||
anamag.put(ANAMAG_CONACC, "");
|
||||
anamag.put(ANAMAG_CONALL, "");
|
||||
anamag.put(ANAMAG_CONCAR, "");
|
||||
anamag.put(ANAMAG_CONLEG, "");
|
||||
anamag.put(ANAMAG_CONPLA, "");
|
||||
anamag.put(ANAMAG_CONVET, "");
|
||||
ok |= anamag.rewrite();
|
||||
}
|
||||
|
||||
// Adesso svuoto i record presenti in CONART
|
||||
TLocalisamfile conart(LF_CONART);
|
||||
TRelation rel_conart(LF_CONART);
|
||||
TRectype filter_conart(LF_CONART);
|
||||
filter_conart.put(ANAMAG_CODART, m.get(F_CODART));
|
||||
|
||||
TCursor cur_conart(&rel_conart, "", 1, &filter_conart, &filter_conart);
|
||||
while(cur_conart.items() > 0)
|
||||
{
|
||||
ok |= conart.remove(cur_conart.curr());
|
||||
}
|
||||
|
||||
// Infine salvo i nuovi dati in conart
|
||||
|
||||
TSheet_field& sheet_conai = m.sfield(F_SHEETCON);
|
||||
FOR_EACH_SHEET_ROW(sheet_conai, num_riga, row)
|
||||
{
|
||||
conart.zero();
|
||||
conart.put(CONART_CODART, m.get(F_CODART));
|
||||
conart.put(CONART_NRIGA, num_riga +1);
|
||||
conart.put(CONART_CATEGORIA, row->get(cid2index(FS_CAT_CONAI)));
|
||||
conart.put(CONART_SOTTOCAT, row->get(cid2index(FS_SCAT_CONAI)));
|
||||
conart.put(CONART_PESO, row->get(cid2index(FS_PES_CONAI)));
|
||||
ok |= conart.write();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TAnagrafica_magazzino::user_create()
|
||||
{
|
||||
open_files(LF_TAB, LF_TABCOM, LF_ANAMAG, LF_MAG, LF_STOMAG,
|
||||
@ -2042,6 +2111,10 @@ int TAnagrafica_magazzino::read(TMask& m)
|
||||
|
||||
fld_giac.sort(cmp_rows);
|
||||
((TMask_anamag&) m).giacs() = fld_giac.rows_array();
|
||||
|
||||
// Lettura sheet CONAI
|
||||
TSheet_field &fld_con = m.sfield(F_SHEETCON);
|
||||
fill_conai(m.get(F_CODART), fld_con);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -2073,7 +2146,7 @@ bool TAnagrafica_magazzino::remove()
|
||||
TSheet_field& f = m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
||||
TLocalisamfile distinte(LF_DIST);
|
||||
distinte.put("CODDIST", m.get(F_CODART));
|
||||
int err = distinte.read();// esiste la distinta ?
|
||||
const int err = distinte.read();// esiste la distinta ?
|
||||
switch(err)
|
||||
{
|
||||
case _iskeynotfound :
|
||||
@ -2096,6 +2169,8 @@ int TAnagrafica_magazzino::write(const TMask& m)
|
||||
{
|
||||
TSheet_field& f = m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
||||
err = f.record()->write(FALSE);
|
||||
// Salvo il conai
|
||||
err |= write_conai(m);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -2176,12 +2251,15 @@ int TAnagrafica_magazzino::rewrite(const TMask& m)
|
||||
fld_giac.autoload(*get_relation());
|
||||
fld_giac.sort(cmp_rows);
|
||||
}
|
||||
|
||||
int err =TRelation_application::rewrite(m);
|
||||
|
||||
if (err == NOERR)
|
||||
{
|
||||
TSheet_field& f= m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
||||
err|=f.record()->write(TRUE);
|
||||
TSheet_field& f = m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
||||
err |= f.record()->write(TRUE);
|
||||
// Salvo il conai
|
||||
err |= write_conai(m);
|
||||
}
|
||||
((TMask_anamag &)m).ricalcola_giacenze();
|
||||
return err;
|
||||
|
@ -112,10 +112,11 @@
|
||||
#define F_DESCRALT 200
|
||||
|
||||
#define F_SHEETUM 201
|
||||
#define F_SHEETDESLIN 202
|
||||
#define F_SHEETCOD 203
|
||||
#define F_SHEETGIAC 204
|
||||
#define F_SHEETSTOMAG 205
|
||||
#define F_SHEETCON 202
|
||||
#define F_SHEETDESLIN 203
|
||||
#define F_SHEETCOD 204
|
||||
#define F_SHEETGIAC 205
|
||||
#define F_SHEETSTOMAG 206
|
||||
#define F_STOULTCOS1 210
|
||||
#define F_STOULTCOS2 211
|
||||
#define F_STOCOSTOSTD 212
|
||||
@ -240,6 +241,11 @@
|
||||
#define FS_PREZZO 103
|
||||
#define FS_PREZZO_LORDO 104
|
||||
|
||||
// definizioni per l'archivio del calcolo del CONAI
|
||||
#define FS_CAT_CONAI 101
|
||||
#define FS_SCAT_CONAI 102
|
||||
#define FS_PES_CONAI 103
|
||||
|
||||
// definizioni per l'archivio descrizioni in lingua estera
|
||||
#define FS_CODLIN 101
|
||||
#define FS_DESCR 102
|
||||
@ -255,7 +261,7 @@
|
||||
#define FS_TIPOCF 108
|
||||
#define FS_CODCF 109
|
||||
#define FS_RAGCF 110
|
||||
#define FS_DESCRC 111
|
||||
#define FS_DESCRC 111
|
||||
|
||||
// definizioni per l'archivio giacenze
|
||||
#include "ve2400d.h"
|
||||
|
@ -605,126 +605,13 @@ BEGIN
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
SPREADSHEET F_SHEETCON 78 8
|
||||
BEGIN
|
||||
PROMPT 1 14 "Sottocategorie"
|
||||
PROMPT 0 13 ""
|
||||
ITEM "Categoria@20"
|
||||
ITEM "Sottocategoria@20"
|
||||
ITEM "Peso@20"
|
||||
END
|
||||
|
||||
STRING F_SCAACC 4
|
||||
BEGIN
|
||||
PROMPT 1 15 "Acciaio "
|
||||
FIELD CONAISC[1,4]
|
||||
USE &SCC SELECT CODTAB[1,2]=="AC"
|
||||
INPUT CODTAB F_SCAACC
|
||||
DISPLAY "Categoria" CODTAB[1,2]
|
||||
DISPLAY "Sottocategoria" CODTAB[3,4]
|
||||
DISPLAY "Descrizione@50" S0
|
||||
MESSAGE EMPTY CLEAR,F_CONACC
|
||||
MESSAGE ENABLE,F_CONACC
|
||||
OUTPUT F_SCAACC CODTAB
|
||||
END
|
||||
|
||||
STRING F_SCAALL 4
|
||||
BEGIN
|
||||
PROMPT 27 15 "Alluminio "
|
||||
FIELD CONAISC[5,8]
|
||||
USE &SCC SELECT CODTAB[1,2]=="AL"
|
||||
INPUT CODTAB F_SCAALL
|
||||
COPY DISPLAY F_SCAACC
|
||||
OUTPUT F_SCAALL CODTAB
|
||||
MESSAGE EMPTY CLEAR,F_CONALL
|
||||
MESSAGE ENABLE,F_CONALL
|
||||
END
|
||||
|
||||
STRING F_SCACAR 4
|
||||
BEGIN
|
||||
PROMPT 54 15 "Carta "
|
||||
FIELD CONAISC[9,12]
|
||||
USE &SCC SELECT CODTAB[1,2]=="CA"
|
||||
INPUT CODTAB F_SCACAR
|
||||
COPY DISPLAY F_SCAACC
|
||||
OUTPUT F_SCACAR CODTAB
|
||||
MESSAGE EMPTY CLEAR,F_CONCAR
|
||||
MESSAGE ENABLE,F_CONCAR
|
||||
END
|
||||
|
||||
STRING F_SCAPLA 4
|
||||
BEGIN
|
||||
PROMPT 1 16 "Plastica "
|
||||
FIELD CONAISC[13,16]
|
||||
USE &SCC SELECT CODTAB[1,2]=="PL"
|
||||
INPUT CODTAB F_SCAPLA
|
||||
COPY DISPLAY F_SCAACC
|
||||
OUTPUT F_SCAPLA CODTAB
|
||||
MESSAGE EMPTY CLEAR,F_CONPLA
|
||||
MESSAGE ENABLE,F_CONPLA
|
||||
END
|
||||
|
||||
STRING F_SCALEG 4
|
||||
BEGIN
|
||||
PROMPT 27 16 "Legno "
|
||||
FIELD CONAISC[17,20]
|
||||
USE &SCC SELECT CODTAB[1,2]=="LE"
|
||||
INPUT CODTAB F_SCALEG
|
||||
COPY DISPLAY F_SCAACC
|
||||
OUTPUT F_SCALEG CODTAB
|
||||
MESSAGE EMPTY CLEAR,F_CONLEG
|
||||
MESSAGE ENABLE,F_CONLEG
|
||||
END
|
||||
|
||||
STRING F_SCAVET 4
|
||||
BEGIN
|
||||
PROMPT 54 16 "Vetro "
|
||||
FIELD CONAISC[21,24]
|
||||
USE &SCC SELECT CODTAB[1,2]=="VE"
|
||||
INPUT CODTAB F_SCAVET
|
||||
COPY DISPLAY F_SCAACC
|
||||
OUTPUT F_SCAVET CODTAB
|
||||
MESSAGE EMPTY CLEAR,F_CONVET
|
||||
MESSAGE ENABLE,F_CONVET
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 1 17 "Pesi (Kg)"
|
||||
END
|
||||
|
||||
NUMBER F_CONACC 15 5
|
||||
BEGIN
|
||||
PROMPT 1 18 "Acciaio "
|
||||
FIELD CONACC
|
||||
END
|
||||
|
||||
NUMBER F_CONALL 15 5
|
||||
BEGIN
|
||||
PROMPT 27 18 "Alluminio "
|
||||
FIELD CONALL
|
||||
END
|
||||
|
||||
NUMBER F_CONCAR 15 5
|
||||
BEGIN
|
||||
PROMPT 54 18 "Carta "
|
||||
FIELD CONCAR
|
||||
END
|
||||
|
||||
NUMBER F_CONPLA 15 5
|
||||
BEGIN
|
||||
PROMPT 1 19 "Plastica "
|
||||
FIELD CONPLA
|
||||
END
|
||||
|
||||
NUMBER F_CONLEG 15 5
|
||||
BEGIN
|
||||
PROMPT 27 19 "Legno "
|
||||
FIELD CONLEG
|
||||
END
|
||||
|
||||
NUMBER F_CONVET 15 5
|
||||
BEGIN
|
||||
PROMPT 54 19 "Vetro "
|
||||
FIELD CONVET
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
|
||||
@ -1675,5 +1562,6 @@ ENDMASK
|
||||
#include "ve2400c.uml"
|
||||
#include "ve2400b.uml"
|
||||
#include "ve2400a.uml"
|
||||
#include "ve2400f.uml"
|
||||
#include "ve2400d.uml"
|
||||
#include "ve2400e.uml"
|
||||
|
@ -23,8 +23,8 @@ PAGE "Storico giacenze" -1 -1 80 23
|
||||
|
||||
STRING F_STOTIPORIGA 1
|
||||
BEGIN
|
||||
FLAGS "D"
|
||||
PROMPT 2 100 "Tipo riga"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
|
||||
|
55
src/ve/ve2400f.uml
Normal file
55
src/ve/ve2400f.uml
Normal file
@ -0,0 +1,55 @@
|
||||
// SHEET 3 (CONAI) DI VE2400
|
||||
|
||||
PAGE "Pagina CONAI" 5 5 75 15
|
||||
|
||||
LIST FS_CAT_CONAI 12
|
||||
BEGIN
|
||||
PROMPT 3 2 "Codice categoria "
|
||||
ITEM "|"
|
||||
ITEM "AC|Acciaio"
|
||||
ITEM "AL|Alluminio"
|
||||
ITEM "CA|Carta"
|
||||
ITEM "LE|Legno"
|
||||
ITEM "PL|Plastica"
|
||||
ITEM "VE|Vetro"
|
||||
END
|
||||
|
||||
STRING FS_SCAT_CONAI 2
|
||||
BEGIN
|
||||
PROMPT 2 4 "Sottocategoria "
|
||||
USE &SCC
|
||||
INPUT CODTAB[1,2] FS_CAT_CONAI
|
||||
INPUT CODTAB[3,4] FS_SCAT_CONAI
|
||||
DISPLAY "Categoria" CODTAB[1,2]
|
||||
DISPLAY "Sottocategoria" CODTAB[3,4]
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT FS_CAT_CONAI CODTAB[1,2]
|
||||
OUTPUT FS_SCAT_CONAI CODTAB[3,4]
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
NUMBER FS_PES_CONAI 15 5
|
||||
BEGIN
|
||||
PROMPT 2 6 "Peso in Kg "
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 "Elimina"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
@ -38,7 +38,7 @@ bool TFatturazione_bolle_app::process(TProgress_monitor& iw, TElaborazione & eld
|
||||
do_events(); // Attende visualizzazione
|
||||
|
||||
// Una volta che di documenti sono elaborati ci scrivo sopra il valore del plafond
|
||||
if (!popolaPlafond(dout, data_elab))
|
||||
if (!popola_plafond(dout, data_elab))
|
||||
{
|
||||
return error_box("Errore durante la generazione del plafond, le fatture non son state create");
|
||||
}
|
||||
@ -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.hasValidPlafond())
|
||||
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.testPlafond(din, lerr);
|
||||
err |= currentCli.test_plafond(din, lerr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ class TSelect_color_mask;
|
||||
#include <rdoc.h>
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
|
||||
#define RIGA_MERCE 'M'
|
||||
#define RIGA_SPESEDOC 'S'
|
||||
#define RIGA_PRESTAZIONI 'P'
|
||||
@ -536,7 +538,8 @@ enum TCONAI_class { CONAI_NONE=-1, CONAI_FIRST=0,
|
||||
CONAI_LAST=5, CONAI_CLASSES=6
|
||||
};
|
||||
|
||||
TCONAI_class conai_str2class(const char* class_or_subclass);
|
||||
TCONAI_class conai_str2class(const char* class_or_subclass);
|
||||
const char* conai_class2str(TCONAI_class cc);
|
||||
const char* conai_material(TCONAI_class cc);
|
||||
bool conai_configured_class(TCONAI_class cc);
|
||||
const char* conai_peso_name(TCONAI_class cc, int logic_num = LF_RIGHEDOC);
|
||||
@ -547,13 +550,35 @@ const char* conai_esenzione_name(TCONAI_class cc, int logicnum = LF_RIGHEDOC);
|
||||
#define FOR_EACH_CONAI_CLASS(cc) for (TCONAI_class cc = CONAI_FIRST; cc < CONAI_CLASSES; cc=TCONAI_class(cc+1))
|
||||
#define FOR_EACH_CONFIGURED_CONAI_CLASS(cc) FOR_EACH_CONAI_CLASS(cc) if (conai_configured_class(cc))
|
||||
|
||||
class TConai : public TObject
|
||||
{
|
||||
private:
|
||||
/* It's a trap!
|
||||
* Design mappa 1:
|
||||
* Codice CONAI, mappa2
|
||||
* Design mappa 1:
|
||||
* Sottocategoria CONAI, classe spesa
|
||||
*/
|
||||
std::map<TString, std::map<TString, TSpesa_prest>> _conais;
|
||||
std::map<TString, TCONAI_class> _tipo_spesa;
|
||||
public:
|
||||
|
||||
const TSpesa_prest& get_spesa(const TString& cat, const TString& sottocat) { return _conais[cat][sottocat]; }
|
||||
const TSpesa_prest& get_spesa(const TString& full_sottocat) { return get_spesa(full_sottocat.left(2), full_sottocat.right(2)); }
|
||||
const std::map<TString, TSpesa_prest> get_categoria(const TString& cat) { return _conais[cat]; }
|
||||
const bool find(const TString& cod_spesa) { return _conais.find(cod_spesa.left(2)) != _conais.end() && _conais[cod_spesa.left(2)].find(cod_spesa.right(2)) != _conais[cod_spesa.left(2)].end(); }
|
||||
const TString_array get_lista_cod_spesa();
|
||||
|
||||
TConai();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRiga_documento
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TRiga_documento : public TAuto_variable_rectype // velib02
|
||||
{
|
||||
TDocumento* _doc;
|
||||
TDocumento* _doc;
|
||||
static long _firm;
|
||||
static TAssoc_array _tipi;
|
||||
static TAssoc_array _spese;
|
||||
@ -667,7 +692,7 @@ public:
|
||||
virtual real quantita_mag() const;
|
||||
virtual real qtaevasa_mag() const;
|
||||
virtual real qtaresidua_mag() const;
|
||||
real calc_conai_qta(TCONAI_class type) const;
|
||||
real calc_conai_qta(TCONAI_class type, const int num_field) const;
|
||||
|
||||
real valore(bool totale, bool lordo = false, int ndec = AUTO_DECIMALS) const;
|
||||
const TString& codice_costo() const;
|
||||
@ -750,7 +775,7 @@ class TDocumento : public TMultiple_rectype // velib03
|
||||
TString8 _old_agente; // Agente originale
|
||||
TString8 _old_agente1; // Secondo Agente originale
|
||||
|
||||
TRiga_documento * _sconto; // Riga per lo sconto di testata
|
||||
TRiga_documento * _sconto; // Riga per lo sconto di testata
|
||||
TRiga_documento * _esenzione; // Riga per l' esenzione iva
|
||||
TRiga_documento * _valfisc; // Riga di valenza fiscale per fatture 2019+
|
||||
|
||||
@ -764,6 +789,9 @@ class TDocumento : public TMultiple_rectype // velib03
|
||||
static short _has_provv;
|
||||
static TCodgiac_livelli *_livelli;
|
||||
|
||||
TConai _conai;
|
||||
std::map<TString, real> _conaiqta; // Per ogni sottocategoria CONAI mi calcola la qta
|
||||
|
||||
protected:
|
||||
virtual TRectype * new_body_record(int logicnum = 0)
|
||||
{ return new TRiga_documento(this); }
|
||||
@ -918,8 +946,10 @@ public:
|
||||
TPagamento& pagamento();
|
||||
|
||||
void update_spese_aut(TString_array & spese, bool preserve_old = false, TSheet_field * sh = NULL, bool force = false);
|
||||
real calc_conai_qta(TCONAI_class type);
|
||||
void update_conai_qta();
|
||||
//real calc_conai_qta(TCONAI_class type);
|
||||
void update_conai();
|
||||
void old_update_conai();
|
||||
|
||||
bool is_generic() const { return tipo_valido() && tipo().is_generic(); }
|
||||
bool is_fattura() const { return tipo_valido() && tipo().is_fattura(); }
|
||||
@ -1105,6 +1135,7 @@ public:
|
||||
static bool num_handler( TMask_field& f, KEY key );
|
||||
static bool tipo_handler( TMask_field& f, KEY key );
|
||||
static bool numdocrif_search_handler( TMask_field& f, KEY key );
|
||||
static bool ragsoc_search_handler( TMask_field& f, KEY key );
|
||||
static bool rif_search_handler( TMask_field& f, KEY key );
|
||||
static bool datadocrif_handler(TMask_field& f, KEY key);
|
||||
static bool sheet_handler(TMask_field& f, KEY key);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "velib.h"
|
||||
#include "sconti.h"
|
||||
#include "vepriv.h"
|
||||
#include "../ca/commesse.h"
|
||||
@ -5,6 +6,7 @@
|
||||
#include <config.h>
|
||||
#include <recset.h>
|
||||
#include <utility.h>
|
||||
#include <memory>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Tipo riga di un documento
|
||||
@ -886,6 +888,12 @@ TCONAI_class conai_str2class(const char* code)
|
||||
return ct;
|
||||
}
|
||||
|
||||
const char * conai_class2str(TCONAI_class cc)
|
||||
{
|
||||
static const char* conai_str[CONAI_CLASSES] = { "AC", "AL", "CA", "PL", "LE", "VE" };
|
||||
return conai_str[cc];
|
||||
}
|
||||
|
||||
const char* conai_material(TCONAI_class cc)
|
||||
{
|
||||
CHECK_CONAI(cc);
|
||||
@ -924,6 +932,27 @@ bool conai_configured_class(TCONAI_class cc)
|
||||
return cc>=CONAI_FIRST && cc<=CONAI_LAST && __con_conf[cc];
|
||||
}
|
||||
|
||||
TString conai_configured_spesa(TCONAI_class cc)
|
||||
{
|
||||
CHECK_CONAI(cc);
|
||||
|
||||
static TToken_string* __con_conf = NULL;
|
||||
if (__con_conf == NULL)
|
||||
{
|
||||
__con_conf = new TToken_string[CONAI_CLASSES];
|
||||
static const char* const __conai_suffixes[CONAI_CLASSES] = { "ACC", "ALL", "CAR", "PLA", "LEG", "VET" };
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
TString8 name_conf, name_cods, cod_spesa;
|
||||
FOR_EACH_CONAI_CLASS(i)
|
||||
{
|
||||
name_cods.cut(0) << "COD" << __conai_suffixes[i];
|
||||
__con_conf->add(c.get(name_cods), i);
|
||||
}
|
||||
}
|
||||
|
||||
return __con_conf->get(cc);
|
||||
}
|
||||
|
||||
// Campi virtuali per peso CONAI su RDOC e ANAMAG in Kg
|
||||
const char* conai_peso_name(TCONAI_class type, int logicnum)
|
||||
{
|
||||
@ -937,8 +966,11 @@ const char* conai_peso_name(TCONAI_class type, int logicnum)
|
||||
|
||||
switch (logicnum)
|
||||
{
|
||||
case LF_ANAMAG : return __conai_peso_anmg[type];
|
||||
case LF_RIGHEDOC: return __conai_peso_rdoc[type];
|
||||
case LF_ANAMAG :
|
||||
error_box("La gestione conai è stata modificata! Impossibile determinare il campo");
|
||||
return __conai_peso_anmg[type];
|
||||
case LF_RIGHEDOC:
|
||||
return __conai_peso_rdoc[type];
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
@ -957,7 +989,9 @@ const char* conai_sottocat_name(TCONAI_class type, int logicnum)
|
||||
ANAMAG_CONAISC"[13,16]", ANAMAG_CONAISC"[17,20]", ANAMAG_CONAISC"[21,24]" };
|
||||
switch (logicnum)
|
||||
{
|
||||
case LF_ANAMAG : return __conai_scat_anmg[type];
|
||||
case LF_ANAMAG :
|
||||
error_box("La gestione conai è stata modificata! Impossibile determinare il campo");
|
||||
return __conai_scat_anmg[type];
|
||||
case LF_RIGHEDOC: return __conai_scat_rdoc[type];
|
||||
default : break;
|
||||
}
|
||||
@ -982,16 +1016,63 @@ const char* conai_esenzione_name(TCONAI_class cc, int logicnum)
|
||||
return "";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TConai
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const TString_array TConai::get_lista_cod_spesa()
|
||||
{
|
||||
TString_array ret;
|
||||
for (auto i = _conais.begin(); i != _conais.end(); ++i)
|
||||
{
|
||||
/*for (auto j = i->second.begin(); j != i->second().end(); ++j)
|
||||
{
|
||||
if (ret.find(j->second.codice()) == -1)
|
||||
ret.add(j->second.codice());
|
||||
}
|
||||
*/
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TConai::TConai()
|
||||
{
|
||||
TRelation rel(LF_TABMOD);
|
||||
TRectype rec(LF_TABMOD);
|
||||
rec.put("MOD", "VE");
|
||||
rec.put("COD", "SCC");
|
||||
|
||||
TCursor conais(&rel, "", 1, &rec, &rec);
|
||||
for (conais = 0; conais.pos() < conais.items(); ++conais)
|
||||
{
|
||||
TRectype row = conais.curr();
|
||||
const TString& con_class = row.get("CODTAB").left(2);
|
||||
const TString& con_sub = row.get("CODTAB").mid(2);
|
||||
const TString& cod_spesa = row.get("S1").blank() ? conai_configured_spesa(conai_str2class(con_class)) : row.get("S1");
|
||||
if (conai_configured_class(conai_str2class(con_class)))
|
||||
{
|
||||
// Aggiungo
|
||||
_conais[con_class][con_sub] = TSpesa_prest(cod_spesa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRiga_documento
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Calcola il peso in Kg di una componente (carta, palstica, ecc.) dell'imballo della riga corrente
|
||||
real TRiga_documento::calc_conai_qta(TCONAI_class type) const
|
||||
|
||||
real TRiga_documento::calc_conai_qta(TCONAI_class type, const int num_field) const
|
||||
{
|
||||
real kg;
|
||||
if (is_merce() || is_omaggio())
|
||||
{
|
||||
const char* weight_name = conai_peso_name(type, LF_RIGHEDOC);
|
||||
if (weight_name && *weight_name) // Se la categoria conai e' gestita
|
||||
TString weight_name = conai_peso_name(type, LF_RIGHEDOC);
|
||||
if (weight_name.full()) // Se la categoria conai e' gestita
|
||||
{
|
||||
const real peso = get_real(weight_name); // Peso unitario imballo
|
||||
weight_name << "(%d)";
|
||||
const real peso = get_real(weight_name.format(weight_name, num_field)); // Peso unitario imballo
|
||||
real qta = quantita(); // Quantita' merce
|
||||
if (peso > ZERO && !qta.is_zero()) // Verifica se ha un peso valido
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "sconti.h"
|
||||
#include "vepriv.h"
|
||||
#include "veuml.h"
|
||||
#include <set>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTipo_documento_cache
|
||||
@ -1056,11 +1057,11 @@ void TDocumento::set_riga_esenzione()
|
||||
if(multi_plaf)
|
||||
{
|
||||
d << " come dalle vostre dichiarazioni:\n";
|
||||
TToken_string lePlafs(get("PLAFOND"), ',');
|
||||
for(int i = 0; i < lePlafs.items(); i++)
|
||||
TToken_string le_plafs(get("PLAFOND"), ',');
|
||||
for(int i = 0; i < le_plafs.items(); i++)
|
||||
{
|
||||
static TToken_string thisPlaf; thisPlaf.cut(0) << lePlafs.get(i);
|
||||
static TString key; key.cut(0) << thisPlaf.get(0) << "|" << thisPlaf.get(1);
|
||||
static TToken_string this_plaf; this_plaf.cut(0) << le_plafs.get(i);
|
||||
static TString key; key.cut(0) << this_plaf.get(0) << "|" << this_plaf.get(1);
|
||||
TRectype plaf = cache().get(LF_LETINT, key);
|
||||
d << "N. " << plaf.get(LETINT_VSPROT) << " del " << plaf.get(LETINT_VSDATA)
|
||||
<< " da noi annotata al n. " << plaf.get(LETINT_NUMPROT) << " il " << plaf.get(LETINT_DATAREG) << "\n";
|
||||
@ -2998,45 +2999,83 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old,
|
||||
put(DOC_SPESEUPD, true);
|
||||
}
|
||||
|
||||
// Calcola il peso in Kg degli imballaggi di una data categoria CONAI
|
||||
real TDocumento::calc_conai_qta(TCONAI_class cc)
|
||||
{
|
||||
real qta;
|
||||
if (conai_configured_class(cc))
|
||||
{
|
||||
FOR_EACH_PHYSICAL_RDOC(*this, i, r) if (r->is_merce() || r->is_omaggio())
|
||||
{
|
||||
const real rowqty = r->calc_conai_qta(cc);
|
||||
qta += rowqty;
|
||||
}
|
||||
qta.round(5); // Arrotondamento al centigrammo
|
||||
}
|
||||
return qta;
|
||||
}
|
||||
void TDocumento::update_conai_qta()
|
||||
{
|
||||
_conaiqta.clear();
|
||||
|
||||
FOR_EACH_PHYSICAL_RDOC(*this, i, r) if (r->is_merce() || r->is_omaggio())
|
||||
{
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
{
|
||||
TString catconai = conai_sottocat_name(cc, LF_RIGHEDOC); catconai << "(%d)";
|
||||
int row_conai = 1;
|
||||
bool ok = true;
|
||||
while(ok)
|
||||
{
|
||||
static TString current_cat; current_cat.cut(0);
|
||||
current_cat.format(catconai, row_conai);
|
||||
|
||||
if (r->get(current_cat).full())
|
||||
{
|
||||
const real rowqty = r->calc_conai_qta(cc, row_conai);
|
||||
if (rowqty.is_zero()) continue;
|
||||
_conaiqta[r->get(current_cat)] += rowqty;
|
||||
row_conai++;
|
||||
}
|
||||
else
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* get_cf_esenz(const TString& tipo_conai)
|
||||
{
|
||||
if (tipo_conai == "AC")
|
||||
return "ESACC";
|
||||
if (tipo_conai == "AL")
|
||||
return "ESALL";
|
||||
if (tipo_conai == "CA")
|
||||
return "ESCAR";
|
||||
if (tipo_conai == "PL")
|
||||
return "ESPLA";
|
||||
if (tipo_conai == "LE")
|
||||
return "ESLEG";
|
||||
if (tipo_conai == "VE")
|
||||
return "ESVET";
|
||||
|
||||
// Non dovrebbe mai succedere!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool has_new_conai(const TDocumento& doc)
|
||||
{
|
||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||
{
|
||||
if (rdoc->get(RDOC_TIPOCON).full())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* La gestione CONAI adesso è diversa, non ci sarà più un codice spesa per categoria CONAI
|
||||
* ma si potrà specificarne uno per sottocategoria che vincerà su quello di categoria.
|
||||
*/
|
||||
void TDocumento::update_conai()
|
||||
{
|
||||
if (main_app().has_module(DCAUT, CHK_DONGLE) && tipo().add_conai() && tipo().stati_iniziali_modifica().find(stato()) >= 0)
|
||||
{
|
||||
set<TString> conai_aggiornati;
|
||||
const TRectype& cfven = clifor().vendite();
|
||||
const bool cli_add_conai = cfven.get_bool("ADDCONAI");
|
||||
const char * const __conai_cf_names[] = {"ESACC", "ESALL", "ESCAR", "ESPLA", "ESLEG", "ESVET"};
|
||||
|
||||
const TDate datadoc = get(DOC_DATADOC);
|
||||
const TDate dataes = cfven.get(CFV_DATAECONAI);
|
||||
bool esponi_esenti = false;
|
||||
|
||||
TString_array conai_sp(CONAI_CLASSES); // Codici spesa conai
|
||||
{
|
||||
const char* const conai_cod[CONAI_CLASSES] = { "CODACC", "CODALL", "CODCAR", "CODPLA", "CODLEG", "CODVET" };
|
||||
TConfig c(CONFIG_DITTA, "ve");
|
||||
for (int i = 0; i < CONAI_CLASSES; i++)
|
||||
conai_sp.add(c.get(conai_cod[i]));
|
||||
|
||||
esponi_esenti = c.get_bool("ESPONIESENTI");
|
||||
}
|
||||
bool esponi_esenti = ini_get_bool(CONFIG_DITTA, "ve", "ESPONIESENTI");
|
||||
|
||||
// Come prima cosa mi calcolo le qta conai
|
||||
update_conai_qta();
|
||||
|
||||
bool updated[CONAI_CLASSES] = {false,false,false,false,false,false};
|
||||
for (int i = physical_rows(); i > 0; i--)
|
||||
{
|
||||
TRiga_documento& r = row(i);
|
||||
@ -3045,15 +3084,21 @@ void TDocumento::update_conai()
|
||||
// Elimina righe generate
|
||||
if (tipo_conai)
|
||||
{
|
||||
// Controllo se il documento ha il metodo nuovo, in caso negativo skippo tutto
|
||||
// Cancella le righe generate e poi ti ricalcolo tutto
|
||||
if(!has_new_conai(*this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const TString& cod = r.get(RDOC_CODART);
|
||||
const TCONAI_class pos = (TCONAI_class)conai_sp.find(cod);
|
||||
|
||||
if (pos >= CONAI_FIRST && pos <= CONAI_LAST)
|
||||
const TString& sottocat = r.get(RDOC_TIPOCON);
|
||||
if (_conai.find(sottocat))
|
||||
{
|
||||
if (cli_add_conai)
|
||||
{
|
||||
real perc_esenz = cfven.get_real(__conai_cf_names[pos]);
|
||||
real qta = calc_conai_qta(pos);
|
||||
real perc_esenz = cfven.get_real(get_cf_esenz(sottocat.left(2)));
|
||||
real qta = _conaiqta[sottocat];
|
||||
if (dataes.ok() && datadoc > dataes)
|
||||
perc_esenz = ZERO;
|
||||
const bool cli_esente = esponi_esenti && (perc_esenz >= CENTO);
|
||||
@ -3069,8 +3114,8 @@ void TDocumento::update_conai()
|
||||
destroy_row(i, true);
|
||||
}
|
||||
else
|
||||
destroy_row(i, true);
|
||||
updated[pos] = true;
|
||||
destroy_row(i, true);
|
||||
conai_aggiornati.insert(sottocat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3079,54 +3124,61 @@ void TDocumento::update_conai()
|
||||
if (cli_add_conai)
|
||||
{
|
||||
const TString4 cod_iva_cli = codesiva();
|
||||
TSpesa_prest sp;
|
||||
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(ct) if (!updated[ct])
|
||||
|
||||
std::map<TString, TRiga_documento> righe_spesa;
|
||||
|
||||
for(auto cp = _conaiqta.begin(); cp != _conaiqta.end(); ++cp)
|
||||
{
|
||||
const real perc_esenz = cfven.get_real(__conai_cf_names[ct]);
|
||||
const bool cli_esente = (esponi_esenti) && (perc_esenz >= CENTO);
|
||||
const real qta_lorda = calc_conai_qta(ct);
|
||||
real qta = qta_lorda;
|
||||
if (!cli_esente && !qta_lorda.is_zero() && !perc_esenz.is_zero())
|
||||
{
|
||||
qta = qta_lorda * (CENTO - perc_esenz) / CENTO;
|
||||
qta.round(5);
|
||||
}
|
||||
const TString cod_sottocat = cp->first;
|
||||
|
||||
// Se l'ho già fatto skippo
|
||||
if (conai_aggiornati.find(cod_sottocat) != conai_aggiornati.end())
|
||||
continue;
|
||||
|
||||
TSpesa_prest sp = _conai.get_spesa(cod_sottocat);
|
||||
|
||||
if (qta > ZERO)
|
||||
{
|
||||
const TString& s = conai_sp.row(ct);
|
||||
|
||||
if (sp.read(s) != NOERR)
|
||||
message_box(FR("Il codice spesa CONAI %s specificato nei parametri ditta è assente: '%s'"),
|
||||
conai_material(ct), (const char*)s);
|
||||
else
|
||||
{
|
||||
const TString4 tipo = sp.tipo_riga();
|
||||
TRiga_documento& riga = new_row(tipo);
|
||||
|
||||
riga.put(RDOC_CODART, s);
|
||||
riga.generata();
|
||||
riga.put(RDOC_GENTIPO, 'C');
|
||||
riga.put(RDOC_DESCR, sp.descrizione());
|
||||
riga.put(RDOC_QTA, qta);
|
||||
|
||||
const real cambio = get_real(DOC_CAMBIO);
|
||||
const TString4 valuta = get(DOC_CODVAL);
|
||||
real prezzo = cli_esente ? ZERO : sp.prezzo();
|
||||
|
||||
sppr_calc(sp, valuta, cambio, prezzo);
|
||||
if (this->tipo().calcolo_lordo())
|
||||
prezzo = riga.iva().lordo(prezzo, ALL_DECIMALS);
|
||||
riga.put(RDOC_PREZZO, prezzo);
|
||||
riga.put(RDOC_UMQTA, sp.um());
|
||||
if (cod_iva_cli.empty())
|
||||
riga.put(RDOC_CODIVA, sp.cod_iva());
|
||||
else
|
||||
riga.put(RDOC_CODIVA, cod_iva_cli);
|
||||
}
|
||||
// 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);
|
||||
const real qta_lorda = _conaiqta[cod_sottocat];
|
||||
real qta = qta_lorda;
|
||||
if (!cli_esente && !qta_lorda.is_zero() && !perc_esenz.is_zero())
|
||||
{
|
||||
qta = qta_lorda * (CENTO - perc_esenz) / CENTO;
|
||||
qta.round(5);
|
||||
}
|
||||
}
|
||||
|
||||
if (qta > ZERO)
|
||||
{
|
||||
const TString4 tipo = sp.tipo_riga();
|
||||
TRiga_documento& riga = new_row(tipo);
|
||||
|
||||
riga.put(RDOC_CODART, sp.codice());
|
||||
riga.generata();
|
||||
riga.put(RDOC_GENTIPO, 'C');
|
||||
static TString descrizione;
|
||||
descrizione.cut(0) << sp.descrizione() << " (" << cod_sottocat << ")";
|
||||
riga.put(RDOC_DESCR, descrizione);
|
||||
riga.put(RDOC_QTA, qta);
|
||||
|
||||
// Mi salvo anche la sottocategoria in questione
|
||||
riga.put(RDOC_TIPOCON, cod_sottocat);
|
||||
|
||||
const real cambio = get_real(DOC_CAMBIO);
|
||||
const TString4 valuta = get(DOC_CODVAL);
|
||||
real prezzo = cli_esente ? ZERO : sp.prezzo();
|
||||
|
||||
sppr_calc(sp, valuta, cambio, prezzo);
|
||||
if (this->tipo().calcolo_lordo())
|
||||
prezzo = riga.iva().lordo(prezzo, ALL_DECIMALS);
|
||||
riga.put(RDOC_PREZZO, prezzo);
|
||||
riga.put(RDOC_UMQTA, sp.um());
|
||||
if (cod_iva_cli.empty())
|
||||
riga.put(RDOC_CODIVA, sp.cod_iva());
|
||||
else
|
||||
riga.put(RDOC_CODIVA, cod_iva_cli);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#define SCC_CATEGORIA 101
|
||||
#define SCC_CODICE 102
|
||||
#define SCC_DESCR 103
|
||||
#define SCC_CODSPESA 103
|
||||
#define SCC_DESCR 104
|
||||
|
@ -39,10 +39,25 @@ BEGIN
|
||||
DISPLAY "Categoria" CODTAB[1,2]
|
||||
DISPLAY "Codice@8" CODTAB[3,4]
|
||||
DISPLAY "Descrizione@50" S0
|
||||
DISPLAY "Spesa@8" S1
|
||||
OUTPUT SCC_CODICE CODTAB[3,4]
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING SCC_CODSPESA 8
|
||||
BEGIN
|
||||
PROMPT 20 3 "Codice spesa "
|
||||
FIELD S1
|
||||
USE SPP
|
||||
FLAGS "U"
|
||||
INPUT CODTAB SCC_CODSPESA
|
||||
DISPLAY "Codice Spesa " CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT SCC_CODSPESA CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
HELP "Codice spesa collegato alla sottocategoria"
|
||||
END
|
||||
|
||||
STRING SCC_DESCR 50
|
||||
BEGIN
|
||||
PROMPT 2 5 "Descrizione "
|
||||
|
Loading…
x
Reference in New Issue
Block a user