5b97f21b73
Files correlati : ca3 Ricompilazione Demo : [ ] Commento : Aggiunta classe TAnal_bill per gestire congiuntamente CONTO.COSTO,COMMESSA,FASE Prima versione di alcuni report per bilancio di verifica git-svn-id: svn://10.65.10.50/trunk@13224 c028cbd2-c16b-5b4b-a496-9718f37d4682
160 lines
4.2 KiB
C++
Executable File
160 lines
4.2 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <urldefid.h>
|
|
|
|
#include "movana.h"
|
|
#include "pconana.h"
|
|
#include "rmovana.h"
|
|
|
|
#include "ca3.h"
|
|
#include "calib01.h"
|
|
#include "../cg/cglib01.h"
|
|
|
|
////////////////////////////////////////////////////////
|
|
// APPLICAZIONE
|
|
////////////////////////////////////////////////////////
|
|
class TRandom_ca : public TSkeleton_application
|
|
{
|
|
protected:
|
|
void kill_bill();
|
|
|
|
public:
|
|
virtual void main_loop();
|
|
};
|
|
|
|
void TRandom_ca::kill_bill()
|
|
{
|
|
const int lnum[3] = { LF_MOVANA, LF_RMOVANA, LF_SALDANA };
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
TSystemisamfile f(lnum[i]);
|
|
f.zap();
|
|
}
|
|
}
|
|
|
|
void TRandom_ca::main_loop()
|
|
{
|
|
TMask mask("Movimenti casuali ma perfetti", 1, 60, 6);
|
|
|
|
TReal_field& add_number (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", int ndec = 0);
|
|
mask.add_number(101, 0, "Numero di movimenti ", 1, 1, 4, "U");
|
|
mask.add_static (DLG_NULL, 0, "@bAttenzione: verranno distrutti movimenti e saldi", 1, 3);
|
|
mask.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
mask.add_button(DLG_QUIT, 0, "", -22, -1, 10, 2);
|
|
mask.set(101, 100);
|
|
if (mask.run() == K_QUIT)
|
|
return;
|
|
|
|
kill_bill();
|
|
|
|
const TMultilevel_code_info& info = ca_multilevel_code_info(LF_PCONANA);
|
|
TString filter;
|
|
int len = 0;
|
|
for (int l = info.levels()-1; l >= 0; l--)
|
|
len += info.len(l);
|
|
filter << "LEN(CODCONTO)==" << len;
|
|
|
|
TRelation relconti(LF_PCONANA);
|
|
TCursor curconti(&relconti, filter);
|
|
const TRecnotype conti = curconti.items();
|
|
curconti.freeze();
|
|
|
|
TRelation relcommesse(LF_COMMESSE);
|
|
TCursor curcommesse(&relcommesse);
|
|
const TRecnotype commesse = curcommesse.items();
|
|
curcommesse.freeze();
|
|
|
|
TRelation relcaus(LF_CAUSALI);
|
|
TCursor curcaus(&relcaus, "MOVIND=\"X\"");
|
|
const TRecnotype causali = curcaus.items();
|
|
curcaus.freeze();
|
|
|
|
TEsercizi_contabili esc;
|
|
|
|
const int quanti = (mask.get_int(101)+1)/2;
|
|
TProgind pi(quanti, "Generazione in corso", FALSE, TRUE);
|
|
for (int m = 0; m < quanti; m++)
|
|
{
|
|
pi.addstatus(1);
|
|
TAnal_mov mov;
|
|
|
|
TDate data(TODAY); data -= rand()%365;
|
|
mov.put(MOVANA_DATAREG, data);
|
|
mov.put(MOVANA_DATACOMP, data-1L);
|
|
mov.put(MOVANA_DATADOC, data-2L);
|
|
mov.put(MOVANA_ANNOES, esc.date2esc(data));
|
|
mov.put(MOVANA_DESCR, "Movimento random preventivo");
|
|
mov.put(MOVANA_TIPOMOV, "P");
|
|
if (causali > 0)
|
|
{
|
|
curcaus = rand() % causali;
|
|
mov.put(MOVANA_CODCAUS, curcaus.curr().get("CODCAUS"));
|
|
}
|
|
|
|
const int rows = rand()%10+1;
|
|
TImporto tot;
|
|
int i;
|
|
for (i = 0; i < rows; i++)
|
|
{
|
|
TRectype& rmov = mov.new_row();
|
|
TString80 descr; descr.format("Riga casuale %d", i+1);
|
|
rmov.put(RMOVANA_DESCR, descr);
|
|
|
|
if (conti > 0)
|
|
{
|
|
curconti = rand() % conti;
|
|
rmov.put(RMOVANA_CODCONTO, curconti.curr().get(PCONANA_CODCONTO));
|
|
}
|
|
if (commesse > 0)
|
|
{
|
|
curcommesse = rand() % commesse;
|
|
rmov.put(RMOVANA_CODCMS, curcommesse.curr().get("CODCMS"));
|
|
}
|
|
const TImporto imp(i & 0x1 ? 'A' : 'D', real(10*(rand()%1000+1)));
|
|
rmov.put(RMOVANA_SEZIONE, imp.sezione());
|
|
rmov.put(RMOVANA_IMPORTO, imp.valore());
|
|
tot += imp;
|
|
}
|
|
|
|
tot.normalize();
|
|
mov.put(MOVANA_SEZIONE, tot.sezione());
|
|
mov.put(MOVANA_TOTDOC, tot.valore());
|
|
|
|
TLocalisamfile fmov(LF_MOVANA);
|
|
mov.write(fmov);
|
|
|
|
// Consuntivo
|
|
mov.put(MOVANA_NUMREG, mov.get_long(MOVANA_NUMREG)+1);
|
|
data += rand()%30+30;
|
|
mov.put(MOVANA_DATAREG, data);
|
|
mov.put(MOVANA_DATACOMP, data-1L);
|
|
mov.put(MOVANA_DATADOC, data-2L);
|
|
mov.put(MOVANA_ANNOES, esc.date2esc(data));
|
|
mov.put(MOVANA_DESCR, "Movimento random consuntivo");
|
|
mov.put(MOVANA_TIPOMOV, "");
|
|
|
|
tot.set('D', ZERO);
|
|
for (i = 1; i <= rows; i++)
|
|
{
|
|
TRectype& rmov = mov.body()[i];
|
|
real imp = rmov.get(RMOVANA_IMPORTO);
|
|
imp += real((rand()%100)-50);
|
|
rmov.put(RMOVANA_IMPORTO, imp);
|
|
tot += TImporto(rmov.get_char(RMOVANA_SEZIONE), imp);
|
|
}
|
|
tot.normalize();
|
|
mov.put(MOVANA_SEZIONE, tot.sezione());
|
|
mov.put(MOVANA_TOTDOC, tot.valore());
|
|
|
|
mov.write(fmov);
|
|
}
|
|
}
|
|
|
|
int ca3900(int argc, char* argv[])
|
|
{
|
|
TRandom_ca a;
|
|
a.run(argc, argv, TR("Movimenti casuali ma perfetti"));
|
|
return 0;
|
|
}
|