Patch level : 12.0 514
Files correlati : li Commento : Aggiunta funzione popolaPlafond() per fatturazione bolle git-svn-id: svn://10.65.10.50/branches/R_10_00@24299 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
261d36a40d
commit
50a1a35af3
@ -339,7 +339,7 @@ bool TVisLI_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
// Creo una maschera che richiede la data
|
||||
TMask app("Creazione storico LI", 1, 50, 10);
|
||||
app.add_button_tool(DLG_OK, "Esegui", TOOL_OK);
|
||||
app.add_button_tool(DLG_OK, "~Conferma", TOOL_OK);
|
||||
app.add_button_tool(DLG_CANCEL, "Annulla", TOOL_CANCEL);
|
||||
app.add_date(101, 0, "Data iniziale ", 1,1);
|
||||
app.field(101).check_type(CHECK_REQUIRED);
|
||||
|
@ -15,6 +15,8 @@ const TToken_string& TLi_manager::getUse(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();
|
||||
|
||||
real plaUtil = ZERO;
|
||||
|
||||
@ -36,7 +38,7 @@ const TToken_string& TLi_manager::getUse(TDocumento& d, const bool write)
|
||||
{
|
||||
ret.cut(0) << consPlaf(plaUtil, write);
|
||||
if(ret.starts_with("ERRORE"))
|
||||
ret << " al documento " << d.numerazione() << " n." << d.numero() << "\nTotale plafond da consumare: " << plaUtil.string() << "\nTotale rimasto: " << getPlafond().string();
|
||||
ret << " al documento " << d.numerazione() << " n." << d.numero() << "\nTotale plafond da utilizzare: " << plaUtil.string() << "\nTotale rimasto: " << getPlafond().string();
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,10 +625,6 @@ bool TLi_manager::testPlafond(TLista_documenti& dout, TLog_report& lerr)
|
||||
clearModifiche();
|
||||
err = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dout[i].put("PLAFOND", use);
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
@ -762,7 +760,7 @@ bool generaLiStorico(TDate dataIni)
|
||||
|
||||
// Date
|
||||
TDate startCurr = rletint.get_date("DAL"), endCurr;
|
||||
endCurr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? rletintn.get_date("DAL")-- : NULLDATE;
|
||||
endCurr = rletint.get_int("CODCLI") == rletintn.get_int("CODCLI") ? --rletintn.get_date("DAL") : NULLDATE;
|
||||
// Dati lettera
|
||||
real impLI = rletint.get_real("IMPORTO");
|
||||
bool soluzione = rletint.get_int("TIPOOP") == SOLUZIONE_UNICA;
|
||||
@ -817,4 +815,64 @@ bool generaLiStorico(TDate dataIni)
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool popolaPlafond(TLista_documenti & din, const TDate& data_elab)
|
||||
{
|
||||
std::map<int, TLi_manager*> plafs;
|
||||
TProgress_monitor mDoc(din.items(), "Generazione plafond nelle fatture");
|
||||
bool ok = true;
|
||||
for(int i = 0; i < din.items() && ok; i++)
|
||||
{
|
||||
if (!mDoc.add_status())
|
||||
return false;
|
||||
|
||||
// Per ogni fattura richiamo il plafond dell'intestatario e faccio le mie elaborazioni
|
||||
if (plafs.find(din[i].codcf()) == plafs.end())
|
||||
{
|
||||
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;
|
||||
|
||||
// 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())
|
||||
{
|
||||
if (thisPla.checkIva(totali->cod_iva().codice()))
|
||||
utilizzato += cache().get("%TIP", din[i].tipo().codice()).get_bool("B7") ? -totali->imp_orig() : totali->imp_orig();
|
||||
}
|
||||
|
||||
// Passo a un altro doc se non usa plafond
|
||||
if (utilizzato.is_zero()) continue;
|
||||
|
||||
TToken_string used;
|
||||
if (din[i].tipo().nota_credito())
|
||||
{
|
||||
used = thisPla.incrPlaf(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);
|
||||
}
|
||||
|
||||
// Rincontrollo che l'utilizzo del pladond sia tutto ok, meglio una volta in più che una in meno!
|
||||
if (used.starts_with("ERRORE"))
|
||||
{
|
||||
error_box("Errore! Superato l'utilizzo del plafond per il documento %s %d, del cli/fo %c%d, come è possibile?", din[i].tipo().codice(), din[i].numero(), din[i].tipocf(), din[i].codcf());
|
||||
ok = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
din[i].put("PLAFOND", used);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = plafs.begin(); it != plafs.end(); ++it)
|
||||
delete it->second;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ public:
|
||||
|
||||
static void createTipiStati(TToken_string& tipi, TToken_string& stati);
|
||||
bool generaLiStorico(TDate dataIni);
|
||||
bool popolaPlafond(TLista_documenti& din, const TDate& data_elab);
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user