2017-02-15 13:29:34 +00:00
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <relapp.h>
|
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
#include <filetext.h>
|
2017-07-21 17:12:40 +00:00
|
|
|
|
#include "..\ve\velib.h"
|
2017-02-15 13:29:34 +00:00
|
|
|
|
#include <real.h>
|
|
|
|
|
#include "lilib01.h"
|
|
|
|
|
|
|
|
|
|
#include "li0.h"
|
|
|
|
|
#include "li0200a.h"
|
|
|
|
|
|
|
|
|
|
#define CONFIG_DICINT "DICINT.ini"
|
|
|
|
|
|
|
|
|
|
class TResDI_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
TSheet_field& sheet; // Sheet
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) { return true; };
|
|
|
|
|
TResDI_mask() : TAutomask("li0200a"), sheet(sfield(DOCUMENTI_STATO)) { load_config(); };
|
|
|
|
|
void load_config();
|
2017-02-20 10:06:13 +00:00
|
|
|
|
void elabTipiDoc(TToken_string& tipi, TToken_string& stati, TToken_string& tipif, TToken_string& statif);
|
2017-02-15 13:29:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TResDI_mask::load_config()
|
|
|
|
|
{
|
2017-02-17 10:43:09 +00:00
|
|
|
|
//Anno
|
2017-02-20 10:06:13 +00:00
|
|
|
|
set(F_A_DATA, TDate(TODAY));
|
2017-02-17 10:43:09 +00:00
|
|
|
|
|
2017-02-20 10:06:13 +00:00
|
|
|
|
set(F_TABIVA_CODTAB, ini_get_string(CONFIG_DITTA, "li", "CODIVA"));
|
2017-02-15 13:29:34 +00:00
|
|
|
|
TToken_string tipidoc(ini_get_string(CONFIG_DITTA, "li", "TIPIDOC"));
|
|
|
|
|
|
|
|
|
|
TString_array& strarr = sheet.rows_array();
|
|
|
|
|
sheet.hide();
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < tipidoc.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TString td = tipidoc.get(i);
|
|
|
|
|
TToken_string stati(ini_get_string(CONFIG_DITTA, "li", td));
|
|
|
|
|
for(int j = 0; j < stati.items(); j++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string row, s(stati.get(j), ',');
|
|
|
|
|
row.add(td);
|
|
|
|
|
row.add(s.get(0));
|
|
|
|
|
row.add(s.get(1));
|
|
|
|
|
strarr.add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
sheet.show();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-20 10:06:13 +00:00
|
|
|
|
void TResDI_mask::elabTipiDoc(TToken_string& tipi, TToken_string& stati, TToken_string& tipif, TToken_string& statif)
|
2017-02-15 13:29:34 +00:00
|
|
|
|
{
|
2017-02-20 10:06:13 +00:00
|
|
|
|
bool fattura;
|
|
|
|
|
TString tipo;
|
2017-02-15 13:29:34 +00:00
|
|
|
|
for(int i = 0; i < sheet.items(); i++)
|
|
|
|
|
{
|
2017-02-20 10:06:13 +00:00
|
|
|
|
TToken_string row = sheet.row(i); // Es. "F01|1|5"
|
2017-02-15 13:29:34 +00:00
|
|
|
|
int statoin = row.get_int(1), statoout = row.get_int(2);
|
2017-02-20 10:06:13 +00:00
|
|
|
|
tipo = row.get(0);
|
|
|
|
|
|
|
|
|
|
if(cache().get("%TIP", tipo).get_int("I1") == 2) // Se il tipo <20> una fattura
|
|
|
|
|
fattura = true;
|
|
|
|
|
else
|
|
|
|
|
fattura = false;
|
|
|
|
|
|
2017-02-15 13:29:34 +00:00
|
|
|
|
for(; statoin <= statoout; statoin++)
|
|
|
|
|
{
|
2017-02-20 10:06:13 +00:00
|
|
|
|
// Aggiornamento: Ci sono 4 token string ora, due per le fatture e due per il resto.
|
2017-02-15 13:29:34 +00:00
|
|
|
|
// Immetto nelle due TToken_string i valori per gestire la classe TLista_documenti
|
|
|
|
|
// Per ogni posizione metto il documento e stato interessato, es. F01: da 1 a 3 -> tipi {F01|F01|F01} stati {1|2|3}
|
2017-02-20 10:06:13 +00:00
|
|
|
|
if (fattura)
|
|
|
|
|
{
|
|
|
|
|
tipif.add(tipo);
|
|
|
|
|
statif.add(statoin);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tipi.add(tipo);
|
|
|
|
|
stati.add(statoin);
|
|
|
|
|
}
|
2017-02-15 13:29:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TResDI_app : public TSkeleton_application
|
2017-12-12 14:07:36 +00:00
|
|
|
|
{
|
2017-02-15 13:29:34 +00:00
|
|
|
|
void elab(TResDI_mask& m);
|
|
|
|
|
public:
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TResDI_app::elab(TResDI_mask& m)
|
|
|
|
|
{
|
2017-02-17 10:43:09 +00:00
|
|
|
|
int clifoda = m.get_long(F_CODICE_CLIFO_DA);
|
|
|
|
|
int clifoa = m.get_long(F_CODICE_CLIFO_A);
|
2017-02-20 10:06:13 +00:00
|
|
|
|
TDate aData(m.get_date(F_A_DATA));
|
2017-02-15 13:29:34 +00:00
|
|
|
|
|
|
|
|
|
// Creo le TToken_string necessarie per filtrare i documenti
|
2017-02-20 10:06:13 +00:00
|
|
|
|
TToken_string tipi, stati, tipif, statif;
|
|
|
|
|
m.elabTipiDoc(tipi, stati, tipif, statif);
|
2017-02-15 13:29:34 +00:00
|
|
|
|
|
|
|
|
|
TRelation r_clifo(LF_CLIFO);
|
|
|
|
|
TRectype fil_from(r_clifo.curr()), fil_to(r_clifo.curr());
|
|
|
|
|
fil_from.put("TIPOCF", "C");
|
|
|
|
|
fil_to.put("TIPOCF", "C");
|
|
|
|
|
|
|
|
|
|
if(clifoda > 0)
|
|
|
|
|
fil_from.put("CODCF", clifoda);
|
|
|
|
|
|
|
|
|
|
if(clifoa > 0)
|
|
|
|
|
fil_to.put("CODCF", clifoa);
|
|
|
|
|
|
|
|
|
|
TCursor c_clifo(&r_clifo, "", 1, &fil_from, &fil_to);
|
|
|
|
|
|
|
|
|
|
TLog_report log(TR("Resoconto plafond"));
|
|
|
|
|
for(c_clifo = 0; c_clifo.pos() < c_clifo.items(); ++c_clifo)
|
|
|
|
|
{
|
|
|
|
|
TRectype row_clifo(c_clifo.curr());
|
|
|
|
|
|
2017-12-12 14:07:36 +00:00
|
|
|
|
TLi_manager currentCli(row_clifo.get_char("TIPOCF"), row_clifo.get_long("CODCF"), aData); // Inizializzo l'oggetto per la gestione del plafond
|
2017-02-15 13:29:34 +00:00
|
|
|
|
if(currentCli.hasValidPlafond())
|
|
|
|
|
{
|
|
|
|
|
real plafond = currentCli.getPlafond();
|
2017-02-20 10:06:13 +00:00
|
|
|
|
real resPlafond = plafond - currentCli.elabUtil(tipi, stati, aData) - currentCli.elabUtil(tipif, statif);
|
2017-02-15 13:29:34 +00:00
|
|
|
|
|
|
|
|
|
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() << "<EFBFBD>\n";
|
|
|
|
|
log.log(0, msg);
|
2017-02-17 10:43:09 +00:00
|
|
|
|
msg = TString("Plafond disponibile: ") << static_cast<TCurrency>((resPlafond > ZERO ? resPlafond : ZERO )).string() << "<EFBFBD>";
|
2017-02-16 14:39:57 +00:00
|
|
|
|
log.log(0, msg);
|
|
|
|
|
msg = TString("Tipo dichiarazione: ") << (currentCli.isSoluzione() ? "Singola\n" : "A concorrenza\n");
|
2017-02-15 13:29:34 +00:00
|
|
|
|
log.log(0, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.print_or_preview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TResDI_app::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TResDI_mask m;
|
|
|
|
|
while (m.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
elab(m);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int li0200(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TResDI_app a;
|
|
|
|
|
a.run(argc, argv, TR("Stato lettere di intento"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|