Files correlati : sv0.exe sv1.exe sv2.exe sv0400a.msk sv1100a.frm sv1100b.frm Ricompilazione Demo : [ ] Commento : GF20028 La selezione per omaggi non può essere effettuata ATTENZIONE: Ci risulta che il bottone omaggi sia sempre selezionabile. Inoltre abilitando gli omaggi nei parametri statistiche, questi vengono stampati correttamente. Necessita segnalazione piu' chiara. GF20029 La stampa schede di vendita arrotonda glie importi all'intero. git-svn-id: svn://10.65.10.50/trunk@11194 c028cbd2-c16b-5b4b-a496-9718f37d4682
165 lines
3.8 KiB
C++
Executable File
165 lines
3.8 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
|
|
#include "sv2.h"
|
|
#include "svlib01.h"
|
|
#include "sv2100a.h"
|
|
|
|
#include "svriep.h"
|
|
|
|
class TRicalcolo_stats : public TSkeleton_application
|
|
{
|
|
TStats_agg _agg;
|
|
|
|
protected:
|
|
virtual void main_loop();
|
|
virtual bool create();
|
|
virtual void on_config_change();
|
|
|
|
public:
|
|
static bool datein_handler(TMask_field& f, KEY k);
|
|
bool kill_stats(const TDate& dfr, const TDate& dto);
|
|
void calc_stats(const TDate& dfr, const TDate& dto);
|
|
};
|
|
|
|
bool TRicalcolo_stats::create()
|
|
{
|
|
open_files(LF_TABCOM, 0); // File comuni
|
|
open_files(LF_TAB, LF_CLIFO, LF_OCCAS, 0); // File ditta
|
|
open_files(LF_CFVEN, LF_DOC, LF_RIGHEDOC, 0); // File vendite
|
|
open_files(LF_SVRIEP, 0); // File statistiche
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TRicalcolo_stats::on_config_change()
|
|
{
|
|
_agg.init();
|
|
}
|
|
|
|
bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto)
|
|
{
|
|
TRelation rel(LF_SVRIEP);
|
|
|
|
TRectype recfrom(LF_SVRIEP), recto(LF_SVRIEP);
|
|
|
|
if (dfr.ok())
|
|
{
|
|
recfrom.put(SVR_ANNO, dfr.year());
|
|
recfrom.put(SVR_PERIODO, _agg.date2period(dfr));
|
|
}
|
|
if (dto.ok())
|
|
{
|
|
recto.put(SVR_ANNO, dto.year());
|
|
recto.put(SVR_PERIODO, _agg.date2period(dto));
|
|
}
|
|
|
|
TCursor cur(&rel, "", 1, &recfrom, &recto);
|
|
const long items = cur.items();
|
|
TProgind pi(items, "Azzeramento statistiche", FALSE, TRUE);
|
|
cur.freeze();
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
{
|
|
pi.addstatus(1);
|
|
const int err = rel.remove();
|
|
if (err != NOERR)
|
|
{
|
|
error_box(FR("Errore %d durante l'azzeramento archivi"), err);
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
|
|
{
|
|
TRectype recfrom(LF_DOC), recto(LF_DOC);
|
|
if (dfr.ok())
|
|
{
|
|
recfrom.put(DOC_DATADOC, dfr);
|
|
recfrom.put(DOC_PROVV, "D");
|
|
}
|
|
if (dto.ok())
|
|
{
|
|
recto.put(DOC_DATADOC, dto);
|
|
recto.put(DOC_PROVV, "D");
|
|
}
|
|
|
|
TRelation rel(LF_DOC);
|
|
TCursor cur(&rel, "PROVV='D'", 3, &recfrom, &recto);
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
TProgind pi(items, "Ricalcolo statistiche", FALSE, TRUE);
|
|
|
|
TDocumento* curr = new TDocumento;
|
|
cur.file().set_curr(curr);
|
|
const TDocumento& doc = *curr;
|
|
|
|
long records = 0;
|
|
_agg.reset();
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
{
|
|
pi.addstatus(1);
|
|
|
|
const TTipo_documento& tipodoc = doc.tipo();
|
|
if (!tipodoc.statistiche())
|
|
continue;
|
|
|
|
const bool nota_cr = tipodoc.nota_credito();
|
|
for (int r = doc.physical_rows(); r > 0; r--)
|
|
{
|
|
const TRiga_documento& rdoc = doc[r];
|
|
if (nota_cr)
|
|
_agg.sub(rdoc);
|
|
else
|
|
_agg.add(rdoc);
|
|
}
|
|
|
|
records++;
|
|
if (records % 1000 == 0)
|
|
_agg.update();
|
|
}
|
|
_agg.update();
|
|
if (_agg.empty())
|
|
warning_box(TR("L'archivio riepilogativo delle statistiche ora ricalcolato risulta vuoto"));
|
|
}
|
|
|
|
bool TRicalcolo_stats::datein_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (f.to_check(k))
|
|
{
|
|
TConfig prassid(CONFIG_DITTA, "Euro");
|
|
TDate adozione = prassid.get("DataAdozione");
|
|
TDate inizio(f.get());
|
|
if (adozione.ok() && inizio < adozione)
|
|
return f.error_box("Impossibile effettuare la ricostruzione statistiche \n a una data inferiore alla data adozione Euro") ;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TRicalcolo_stats::main_loop()
|
|
{
|
|
TMask m("sv2100a");
|
|
m.set_handler(F_FROMDATE, datein_handler);
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
const TDate dfr(m.get(F_FROMDATE));
|
|
const TDate dto(m.get(F_TODATE));
|
|
if (kill_stats(dfr, dto))
|
|
calc_stats(dfr, dto);
|
|
}
|
|
}
|
|
|
|
int sv2100(int argc, char* argv[])
|
|
{
|
|
TRicalcolo_stats app;
|
|
app.run(argc, argv, "Ricalcolo statistiche");
|
|
return 0;
|
|
}
|