85 lines
2.2 KiB
C++
85 lines
2.2 KiB
C++
|
#include "../cg/cglib01.h"
|
||
|
|
||
|
#include "../ca/calib01.h"
|
||
|
#include "../ca/movana.h"
|
||
|
#include "../ca/rmovana.h"
|
||
|
|
||
|
//--------------------------------------------------------------------
|
||
|
// APPLICAZIONE
|
||
|
//--------------------------------------------------------------------
|
||
|
|
||
|
class TPulisci_app : public TSkeleton_application
|
||
|
{
|
||
|
|
||
|
protected:
|
||
|
virtual const char * extra_modules() const {return "cm";} //deve funzionare anche per le commesse
|
||
|
virtual void main_loop();
|
||
|
static bool elabora_movimento(const TRelation& rel, void* pJolly);
|
||
|
|
||
|
public:
|
||
|
TPulisci_app() {}
|
||
|
virtual ~TPulisci_app() {}
|
||
|
};
|
||
|
|
||
|
bool TPulisci_app::elabora_movimento(const TRelation& rel, void* pJolly)
|
||
|
{
|
||
|
TAnal_mov & mov = (TAnal_mov &) rel.curr();
|
||
|
bool updated = false;
|
||
|
TImporto totdoc(mov.get_char(MOVANA_SEZIONE), mov.get_real(MOVANA_TOTDOC));
|
||
|
|
||
|
for (int i = mov.rows(); i >= 1; i--)
|
||
|
{
|
||
|
const TRectype & row = mov.body()[i];
|
||
|
const TString code = row.get(RMOVANA_CODCONTO);
|
||
|
const int gr = atoi(code.left(3));
|
||
|
const int co = atoi(code.mid(3, 3));
|
||
|
const long sc = atol(code.right(6));
|
||
|
const TBill zio(gr, co, sc);
|
||
|
|
||
|
if (!zio.is_analitico())
|
||
|
{
|
||
|
TImporto importo(row.get_char(RMOVANA_SEZIONE), row.get_real(RMOVANA_IMPORTO));
|
||
|
|
||
|
updated = true;
|
||
|
totdoc -= importo;
|
||
|
mov.body().destroy_row(i, true);
|
||
|
}
|
||
|
}
|
||
|
if (updated)
|
||
|
{
|
||
|
totdoc.normalize();
|
||
|
mov.put(MOVANA_SEZIONE, totdoc.sezione());
|
||
|
mov.put(MOVANA_TOTDOC, totdoc.valore());
|
||
|
if (mov.rows() > 0)
|
||
|
mov.rewrite(rel.lfile());
|
||
|
else
|
||
|
mov.remove(rel.lfile());
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void TPulisci_app::main_loop()
|
||
|
{
|
||
|
if (ca_config().get_bool("UsePdcc") &&
|
||
|
yesno_box("Si desidera eliminare i conti non analitici") &&
|
||
|
yesno_box("Si desidera veramente eliminare i conti non analitici"))
|
||
|
{
|
||
|
TRelation rel_movana(LF_MOVANA);
|
||
|
TCursor cur_movana(&rel_movana, "", 1);
|
||
|
const long items = cur_movana.items();
|
||
|
|
||
|
if (items > 0)
|
||
|
{
|
||
|
rel_movana.lfile().set_curr(new TAnal_mov); //il record principale della rel e' un TMov_anal!!
|
||
|
cur_movana.scan(elabora_movimento, this, "Eliminazione conti non analitici...");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int ps0713700(int argc, char* argv[])
|
||
|
{
|
||
|
TPulisci_app app;
|
||
|
app.run(argc, argv, "Eliminazione conti non analitici...");
|
||
|
return 0;
|
||
|
}
|