Patch level : 2.2

Files correlati     : ca3
Ricompilazione Demo : [ ]
Commento            :

Aggiunto generatore di movimenti perfettamente casuali


git-svn-id: svn://10.65.10.50/trunk@13218 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-06-24 11:28:19 +00:00
parent 187b5e6b7a
commit 39302b50e0
3 changed files with 207 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<report libraries="ca3300a" name="ca3300a" orientation="2" lpi="8">
<description>Bilancio normale di verifica</description>
<description>Bilancio di raffronto di verifica</description>
<font face="Courier New" size="8" />
<section type="Head">
<font italic="1" face="Courier New" bold="1" size="10" />
@ -43,7 +43,7 @@
<field border="1" x="-1" y="8" type="Linea" width="168" height="0" pattern="1" />
</section>
<section type="Head" level="1" height="3">
<field border="1" radius="100" x="1" type="Testo" valign="center" align="center" shade_offset="25" width="166" height="2.5" text="BILANCIO DI VERIFICA">
<field border="1" radius="100" x="1" type="Testo" valign="center" align="center" shade_offset="25" width="166" height="2.5" text="BILANCIO DI RAFFRONTO DI VERIFICA">
<font face="Courier New" bold="1" size="16" />
</field>
</section>
@ -67,24 +67,6 @@
</section>
<section type="Body" />
<section type="Body" level="1">
<field x="78" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_DARE</source>
</field>
<field x="92" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_AVERE</source>
</field>
<field x="109" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_DARE</source>
</field>
<field x="123" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_AVERE</source>
</field>
<field x="141" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_DARE</source>
</field>
<field x="155" type="Valuta" align="right" width="13" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_AVERE</source>
</field>
<field type="Stringa" width="24" id="101" pattern="1">
<source>CODCONTO</source>
<prescript description="B1.101 PRESCRIPT">CA_FORMAT_CONTO</prescript>
@ -92,6 +74,60 @@
<field x="25" type="Stringa" width="50" id="102" pattern="1">
<source>DESCR</source>
</field>
<field x="78" type="Valuta" align="right" width="13" id="103" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_DAREP</source>
</field>
<field x="92" type="Valuta" align="right" width="13" id="104" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_AVEREP</source>
</field>
<field x="109" type="Valuta" align="right" width="13" id="105" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_DAREP</source>
</field>
<field x="123" type="Valuta" align="right" width="13" id="106" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_AVEREP</source>
</field>
<field x="141" type="Valuta" align="right" width="13" id="107" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_DAREP</source>
</field>
<field x="155" type="Valuta" align="right" width="13" id="108" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_AVEREP</source>
</field>
<field x="78" y="1" type="Valuta" align="right" width="13" id="203" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_DAREC</source>
</field>
<field x="92" y="1" type="Valuta" align="right" width="13" id="204" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:INI_AVEREC</source>
</field>
<field x="109" y="1" type="Valuta" align="right" width="13" id="205" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_DAREC</source>
</field>
<field x="123" y="1" type="Valuta" align="right" width="13" id="206" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:MOV_AVEREC</source>
</field>
<field x="141" y="1" type="Valuta" align="right" width="13" id="207" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_DAREC</source>
</field>
<field x="155" y="1" type="Valuta" align="right" width="13" id="208" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>SALDO:FIN_AVEREC</source>
</field>
<field x="78" y="2" type="Valuta" align="right" width="13" id="303" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#103-#203</source>
</field>
<field x="92" y="2" type="Valuta" align="right" width="13" id="304" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#104-#204</source>
</field>
<field x="109" y="2" type="Valuta" align="right" width="13" id="305" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#105-#205</source>
</field>
<field x="123" y="2" type="Valuta" align="right" width="13" id="306" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#106-#206</source>
</field>
<field x="141" y="2" type="Valuta" align="right" width="13" id="307" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#107-#207</source>
</field>
<field x="155" y="2" type="Valuta" align="right" width="13" id="308" pattern="1" hide_zero="1" text="###.###.###,@@">
<source>#108-#208</source>
</field>
</section>
<section type="Foot" />
<section type="Foot" level="1" />
@ -117,4 +153,4 @@
</field>
</section>
<sql>USE PCONANA SELECT LEN(CODCONTO)=10</sql>
</report>
</report>

149
ca/ca3900.cpp Executable file
View File

@ -0,0 +1,149 @@
#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"
////////////////////////////////////////////////////////
// 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);
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 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();
rmov.put(RMOVANA_DATACOMP, mov.get(MOVANA_DATACOMP));
rmov.put(RMOVANA_ANNOES, mov.get(MOVANA_ANNOES));
TString80 descr; descr.format("Riga casuale %d", i+1);
rmov.put(RMOVANA_DESCR, descr);
curconti = rand() % conti;
rmov.put(RMOVANA_CODCONTO, curconti.curr().get(PCONANA_CODCONTO));
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];
rmov.put(RMOVANA_ANNOES, mov.get(MOVANA_ANNOES));
rmov.put(RMOVANA_DATACOMP, mov.get(MOVANA_DATACOMP));
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;
}

View File

@ -359,7 +359,7 @@ const TSaldanal& ca_saldo(const char* conto, const char* costo,
const TDate& dal, const TDate& al, word tipi)
{
static TSaldi_cache* cache = NULL;
if (cache = NULL)
if (cache == NULL)
cache = new TSaldi_cache;
return cache->saldo(conto, costo, commessa, fase, dal, al, tipi);
}