Patch level : 2.2
Files correlati : ca3 Ricompilazione Demo : [ ] Commento : Aggiunta in libreria la cache dei saldi analitici git-svn-id: svn://10.65.10.50/trunk@13217 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c247c55a4a
commit
187b5e6b7a
@ -9,6 +9,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
case 1: ca3200(argc, argv); break; // stampa mastrini
|
||||
case 2: ca3300(argc, argv); break; // stampa bilancio
|
||||
case 8: ca3900(argc, argv); break; // generazione movimenti perfetti ma casuali
|
||||
default: ca3100(argc, argv); break; // stampa movimenti
|
||||
}
|
||||
exit(0);
|
||||
|
1
ca/ca3.h
1
ca/ca3.h
@ -4,5 +4,6 @@
|
||||
int ca3100(int argc, char* argv[]);
|
||||
int ca3200(int argc, char* argv[]);
|
||||
int ca3300(int argc, char* argv[]);
|
||||
int ca3900(int argc, char* argv[]);
|
||||
|
||||
#endif // __CA3_H
|
||||
|
100
ca/ca3300.cpp
100
ca/ca3300.cpp
@ -15,6 +15,7 @@
|
||||
////////////////////////////////////////////////////////
|
||||
// MASCHERA
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
class TPrint_bilancio_ca_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
@ -228,73 +229,6 @@ TPrint_bilancio_ca_mask::TPrint_bilancio_ca_mask()
|
||||
create_sheet();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// TSaldi_cache
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
struct TSaldanal : public TObject
|
||||
{
|
||||
TImporto _ini, _dare, _avere, _fin;
|
||||
bool _movimentato;
|
||||
};
|
||||
|
||||
class TSaldi_cache : private TCache
|
||||
{
|
||||
TDate _dal, _al;
|
||||
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key);
|
||||
|
||||
public:
|
||||
void set_range(const TDate& dal, const TDate& al);
|
||||
const TSaldanal& saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase, word tipi);
|
||||
TSaldi_cache() : TCache(3883) { }
|
||||
};
|
||||
|
||||
TObject* TSaldi_cache::key2obj(const char* key)
|
||||
{
|
||||
TSaldanal* s = new TSaldanal;
|
||||
|
||||
TToken_string tok(key);
|
||||
TString80 conto = tok.get(); conto.trim();
|
||||
TString80 costo = tok.get(); costo.trim();
|
||||
TString80 commessa = tok.get(); commessa.trim();
|
||||
TString80 fase = tok.get(); fase.trim();
|
||||
const char tipo = tok.get_char();
|
||||
|
||||
TAnal_balance bal;
|
||||
s->_movimentato = bal.saldi(conto, costo, commessa, fase, _dal, _al, tipo,
|
||||
s->_ini, s->_dare, s->_avere);
|
||||
s->_fin = s->_ini; s->_fin += s->_dare; s->_fin += s->_avere;
|
||||
s->_fin.normalize();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
const TSaldanal& TSaldi_cache::saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase, word tipi)
|
||||
{
|
||||
TToken_string key;
|
||||
key.add(conto, 0);
|
||||
key.add(costo, 1);
|
||||
key.add(commessa, 2);
|
||||
key.add(fase, 3);
|
||||
key.add(tipi, 4);
|
||||
return *(const TSaldanal*)objptr(key);
|
||||
}
|
||||
|
||||
void TSaldi_cache::set_range(const TDate& dal, const TDate& al)
|
||||
{
|
||||
if (_dal != dal || _al != al)
|
||||
{
|
||||
_dal = dal;
|
||||
_al = al;
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
TSaldi_cache _saldi;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Recordset
|
||||
@ -326,37 +260,42 @@ const TVariant& TPiano_conti_recordset::get(const char* column_name) const
|
||||
{
|
||||
if (strncmp(column_name, "SALDO:", 6) == 0)
|
||||
{
|
||||
TString16 sub_field = column_name+6;
|
||||
const char last = sub_field.right(1)[0];
|
||||
int tipimov = 0;
|
||||
switch (last)
|
||||
{
|
||||
case 'C': tipimov = 1; sub_field.rtrim(1); break; // Consuntivo
|
||||
case 'P':
|
||||
case 'V': tipimov = 6; sub_field.rtrim(1); break; // Preventivo o variazaione preventivo
|
||||
default : tipimov = _tipimov; break;
|
||||
}
|
||||
const TString& conto = get(PCONANA_CODCONTO).as_string();
|
||||
const char* sub_field = column_name+6;
|
||||
const TSaldanal& s = ca_saldo(conto, _codcosto, _codcms, _codfas, _dal, _al, tipimov);
|
||||
|
||||
TVariant& var = get_tmp_var();
|
||||
if (strcmp(sub_field, "INI_DARE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._ini.sezione() == 'D' ? s._ini.valore() : ZERO;
|
||||
} else
|
||||
if (strcmp(sub_field, "INI_AVERE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._ini.sezione() == 'A' ? s._ini.valore() : ZERO;
|
||||
} else
|
||||
if (strcmp(sub_field, "MOV_DARE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._dare.valore();
|
||||
} else
|
||||
if (strcmp(sub_field, "MOV_AVERE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._avere.valore();
|
||||
} else
|
||||
if (strcmp(sub_field, "FIN_DARE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._fin.sezione() == 'D' ? s._fin.valore() : ZERO;
|
||||
} else
|
||||
if (strcmp(sub_field, "FIN_AVERE") == 0)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
var = s._fin.sezione() == 'A' ? s._fin.valore() : ZERO;
|
||||
}
|
||||
return var;
|
||||
@ -390,7 +329,7 @@ bool TPiano_conti_recordset::valid_record(const TRelation& rel) const
|
||||
|
||||
if (_movimentati || _nonnulli)
|
||||
{
|
||||
const TSaldanal& s = _saldi.saldo(conto, _codcosto, _codcms, _codfas, _tipimov);
|
||||
const TSaldanal& s = ca_saldo(conto, _codcosto, _codcms, _codfas, _dal, _al, _tipimov);
|
||||
if (_movimentati && !s._movimentato)
|
||||
return false;
|
||||
if (_nonnulli && s._ini.is_zero() && s._dare.is_zero() && s._avere.is_zero())
|
||||
@ -432,9 +371,14 @@ void TPiano_conti_recordset::set_filter(const TMask& m, int r)
|
||||
|
||||
_dal = m.get(F_DATADA);
|
||||
_al = m.get(F_DATAA);
|
||||
_saldi.set_range(_dal, _al);
|
||||
|
||||
_tipimov = m.get(F_TIPOSTAMPA)[0] == 'C' ? 1 : 6;
|
||||
switch (m.get(F_TIPOSTAMPA)[0])
|
||||
{
|
||||
case 'C': _tipimov = 1; break; // Consuntivo
|
||||
case 'P': _tipimov = 6; break; // Preventivo e variazioni
|
||||
default : _tipimov = 7; break; // Raffronto
|
||||
}
|
||||
|
||||
_movimentati = m.get_int(F_STAMPAV) == 1;
|
||||
_nonnulli = m.get_int(F_STAMPAV) == 2;
|
||||
|
||||
@ -548,7 +492,7 @@ void randomov()
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
TRectype& rmov = mov.new_row();
|
||||
rmov.put(RMOVANA_DATAREG, mov.get(MOVANA_DATAREG));
|
||||
rmov.put(RMOVANA_DATACOMP, mov.get(MOVANA_DATACOMP));
|
||||
rmov.put(RMOVANA_ANNOES, mov.get(MOVANA_ANNOES));
|
||||
|
||||
curconti = rand() % conti;
|
||||
|
120
ca/ca3300a.rep
Executable file
120
ca/ca3300a.rep
Executable file
@ -0,0 +1,120 @@
|
||||
|
||||
<report libraries="ca3300a" name="ca3300a" orientation="2" lpi="8">
|
||||
<description>Bilancio normale di verifica</description>
|
||||
<font face="Courier New" size="8" />
|
||||
<section type="Head">
|
||||
<font italic="1" face="Courier New" bold="1" size="10" />
|
||||
<field type="Stringa" width="50" pattern="1">
|
||||
<source>#SYSTEM.RAGSOC</source>
|
||||
</field>
|
||||
<field x="90" type="Data" width="10" pattern="1">
|
||||
<source>#SYSTEM.DATE</source>
|
||||
</field>
|
||||
<field x="164" type="Numero" align="right" width="4" pattern="1">
|
||||
<source>#REPORT.PAGE</source>
|
||||
</field>
|
||||
<field y="2" type="Testo" width="20" pattern="1" text="Centro di costo:" />
|
||||
<field x="20" y="2" type="Stringa" width="24" pattern="1">
|
||||
<source>#COSTO</source>
|
||||
</field>
|
||||
<field y="3" type="Testo" width="20" pattern="1" text="Commessa:" />
|
||||
<field x="20" y="3" type="Stringa" width="24" pattern="1">
|
||||
<source>#COMMESSA</source>
|
||||
</field>
|
||||
<field x="45" y="3" type="Stringa" width="50" pattern="1">
|
||||
<prescript description="H0.0 PRESCRIPT">MESSAGE ISAMREAD,COMMESSE,CODCMS=#COMMESSA,DESCR</prescript>
|
||||
</field>
|
||||
<field y="4" type="Testo" width="20" pattern="1" text="Fase:" />
|
||||
<field x="20" y="4" type="Stringa" width="13" pattern="1">
|
||||
<source>#FASE</source>
|
||||
</field>
|
||||
<field border="1" y="6" type="Linea" width="168" height="0" pattern="1" />
|
||||
<field x="85" y="6" type="Testo" align="center" width="27" pattern="1" text="SALDO INIZIALE" />
|
||||
<field x="113" y="6" type="Testo" align="center" width="27" pattern="1" text="MOVIMENTI DEL PERIODO" />
|
||||
<field x="141" y="6" type="Testo" align="center" width="27" pattern="1" text="SALDO FINALE" />
|
||||
<field y="6.5" type="Testo" width="10" pattern="1" text="Conto" />
|
||||
<field x="30" y="6.5" type="Testo" width="15" pattern="1" text="Descrizione" />
|
||||
<field x="78" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<field x="92" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="109" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<field x="123" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="141" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="155" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<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">
|
||||
<font face="Courier New" bold="1" size="16" />
|
||||
</field>
|
||||
</section>
|
||||
<section type="Head" level="2">
|
||||
<condition>CODCONTO:2!=""</condition>
|
||||
<groupby>CODCONTO:1</groupby>
|
||||
<prescript description="H2 PRESCRIPT">"CODCONTO:1" @
|
||||
"F2.101" !</prescript>
|
||||
</section>
|
||||
<section type="Head" level="3">
|
||||
<condition>CODCONTO:3!=""</condition>
|
||||
<groupby>CODCONTO:2</groupby>
|
||||
<prescript description="H3 PRESCRIPT">"CODCONTO:2" @
|
||||
"F3.101" !</prescript>
|
||||
</section>
|
||||
<section type="Head" level="4">
|
||||
<condition>CODCONTO:4 != ""</condition>
|
||||
<groupby>CODCONTO:3</groupby>
|
||||
<prescript description="H4 PRESCRIPT">"CODCONTO:3" @
|
||||
"F4.101" !</prescript>
|
||||
</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>
|
||||
</field>
|
||||
<field x="25" type="Stringa" width="50" id="102" pattern="1">
|
||||
<source>DESCR</source>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" />
|
||||
<section type="Foot" level="1" />
|
||||
<section type="Foot" level="2" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript description="F2.101 PRESCRIPT">CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="3" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript>CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="4" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript>CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<sql>USE PCONANA SELECT LEN(CODCONTO)=10</sql>
|
||||
</report>
|
120
ca/ca3300b.rep
Executable file
120
ca/ca3300b.rep
Executable file
@ -0,0 +1,120 @@
|
||||
|
||||
<report libraries="ca3300b" name="ca3300b" orientation="2" lpi="8">
|
||||
<description>Bilancio normale di verifica</description>
|
||||
<font face="Courier New" size="8" />
|
||||
<section type="Head">
|
||||
<font italic="1" face="Courier New" bold="1" size="10" />
|
||||
<field type="Stringa" width="50" pattern="1">
|
||||
<source>#SYSTEM.RAGSOC</source>
|
||||
</field>
|
||||
<field x="90" type="Data" width="10" pattern="1">
|
||||
<source>#SYSTEM.DATE</source>
|
||||
</field>
|
||||
<field x="164" type="Numero" align="right" width="4" pattern="1">
|
||||
<source>#REPORT.PAGE</source>
|
||||
</field>
|
||||
<field y="2" type="Testo" width="20" pattern="1" text="Centro di costo:" />
|
||||
<field x="20" y="2" type="Stringa" width="24" pattern="1">
|
||||
<source>#COSTO</source>
|
||||
</field>
|
||||
<field y="3" type="Testo" width="20" pattern="1" text="Commessa:" />
|
||||
<field x="20" y="3" type="Stringa" width="24" pattern="1">
|
||||
<source>#COMMESSA</source>
|
||||
</field>
|
||||
<field x="45" y="3" type="Stringa" width="50" pattern="1">
|
||||
<prescript description="H0.0 PRESCRIPT">MESSAGE ISAMREAD,COMMESSE,CODCMS=#COMMESSA,DESCR</prescript>
|
||||
</field>
|
||||
<field y="4" type="Testo" width="20" pattern="1" text="Fase:" />
|
||||
<field x="20" y="4" type="Stringa" width="13" pattern="1">
|
||||
<source>#FASE</source>
|
||||
</field>
|
||||
<field border="1" y="6" type="Linea" width="168" height="0" pattern="1" />
|
||||
<field x="85" y="6" type="Testo" align="center" width="27" pattern="1" text="SALDO INIZIALE" />
|
||||
<field x="113" y="6" type="Testo" align="center" width="27" pattern="1" text="MOVIMENTI DEL PERIODO" />
|
||||
<field x="141" y="6" type="Testo" align="center" width="27" pattern="1" text="SALDO FINALE" />
|
||||
<field y="6.5" type="Testo" width="10" pattern="1" text="Conto" />
|
||||
<field x="30" y="6.5" type="Testo" width="15" pattern="1" text="Descrizione" />
|
||||
<field x="78" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<field x="92" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="109" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<field x="123" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="141" y="7" type="Testo" align="right" width="13" pattern="1" text="AVERE" />
|
||||
<field x="155" y="7" type="Testo" align="right" width="13" pattern="1" text="DARE" />
|
||||
<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">
|
||||
<font face="Courier New" bold="1" size="16" />
|
||||
</field>
|
||||
</section>
|
||||
<section type="Head" level="2">
|
||||
<condition>CODCONTO:2!=""</condition>
|
||||
<groupby>CODCONTO:1</groupby>
|
||||
<prescript description="H2 PRESCRIPT">"CODCONTO:1" @
|
||||
"F2.101" !</prescript>
|
||||
</section>
|
||||
<section type="Head" level="3">
|
||||
<condition>CODCONTO:3!=""</condition>
|
||||
<groupby>CODCONTO:2</groupby>
|
||||
<prescript description="H3 PRESCRIPT">"CODCONTO:2" @
|
||||
"F3.101" !</prescript>
|
||||
</section>
|
||||
<section type="Head" level="4">
|
||||
<condition>CODCONTO:4 != ""</condition>
|
||||
<groupby>CODCONTO:3</groupby>
|
||||
<prescript description="H4 PRESCRIPT">"CODCONTO:3" @
|
||||
"F4.101" !</prescript>
|
||||
</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>
|
||||
</field>
|
||||
<field x="25" type="Stringa" width="50" id="102" pattern="1">
|
||||
<source>DESCR</source>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" />
|
||||
<section type="Foot" level="1" />
|
||||
<section type="Foot" level="2" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript description="F2.101 PRESCRIPT">CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="3" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript>CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="4" height="2">
|
||||
<condition>#101 != ""</condition>
|
||||
<field type="Testo" width="7" pattern="1" text="Totale" />
|
||||
<field x="8" type="Stringa" width="23" id="101" pattern="1">
|
||||
<prescript>CA_FORMAT_CONTO</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<sql>USE PCONANA SELECT LEN(CODCONTO)=10</sql>
|
||||
</report>
|
@ -137,6 +137,22 @@ bool TAnal_report::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
|
||||
// TAnal_balance
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TAnal_balance : public TObject
|
||||
{
|
||||
public:
|
||||
TImporto saldo_fine_anno(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
int annofin, word tipo) const;
|
||||
bool saldo_movimenti(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipo,
|
||||
TImporto& ini, TImporto& dare, TImporto& avere) const;
|
||||
bool saldi(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipo,
|
||||
TImporto& ini, TImporto& dare, TImporto& avere) const;
|
||||
};
|
||||
|
||||
TImporto TAnal_balance::saldo_fine_anno(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
int anno, word tipo) const
|
||||
@ -284,3 +300,66 @@ bool TAnal_balance::saldi(const char* conto, const char* costo,
|
||||
ini, dare, avere);
|
||||
return mov;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// TSaldi_cache
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
class TSaldi_cache : private TCache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key);
|
||||
|
||||
public:
|
||||
const TSaldanal& saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipi = 0x1);
|
||||
TSaldi_cache() : TCache(3883) { }
|
||||
};
|
||||
|
||||
TObject* TSaldi_cache::key2obj(const char* key)
|
||||
{
|
||||
TSaldanal* s = new TSaldanal;
|
||||
|
||||
TToken_string tok(key);
|
||||
TString80 conto = tok.get(); conto.trim();
|
||||
TString80 costo = tok.get(); costo.trim();
|
||||
TString80 commessa = tok.get(); commessa.trim();
|
||||
TString80 fase = tok.get(); fase.trim();
|
||||
const TDate dal = tok.get();
|
||||
const TDate al = tok.get();
|
||||
const char tipo = tok.get_char();
|
||||
|
||||
TAnal_balance bal;
|
||||
s->_movimentato = bal.saldi(conto, costo, commessa, fase, dal, al, tipo,
|
||||
s->_ini, s->_dare, s->_avere);
|
||||
s->_fin = s->_ini; s->_fin += s->_dare; s->_fin += s->_avere;
|
||||
s->_fin.normalize();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
const TSaldanal& TSaldi_cache::saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipi)
|
||||
{
|
||||
TToken_string key;
|
||||
key.add(conto, 0);
|
||||
key.add(costo, 1);
|
||||
key.add(commessa, 2);
|
||||
key.add(fase, 3);
|
||||
key.add(dal, 4);
|
||||
key.add(al, 5);
|
||||
key.add(tipi, 6);
|
||||
return *(const TSaldanal*)objptr(key);
|
||||
}
|
||||
|
||||
const TSaldanal& ca_saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipi)
|
||||
{
|
||||
static TSaldi_cache* cache = NULL;
|
||||
if (cache = NULL)
|
||||
cache = new TSaldi_cache;
|
||||
return cache->saldo(conto, costo, commessa, fase, dal, al, tipi);
|
||||
}
|
||||
|
22
ca/calib02.h
22
ca/calib02.h
@ -33,23 +33,17 @@ public: // meglio pubic?
|
||||
// TAnal_balance
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Tipi di saldo: 1 = Normale; 2 = Preventivo; 4 = Variazione preventivo
|
||||
// Tipi di saldo: 1 = Normale; 2 = Preventivo; 4 = Variazione preventivo; 7 = Tutti
|
||||
|
||||
class TAnal_balance : public TObject
|
||||
struct TSaldanal : public TObject
|
||||
{
|
||||
public:
|
||||
TImporto saldo_fine_anno(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
int annofin, word tipo) const;
|
||||
bool saldo_movimenti(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipo,
|
||||
TImporto& ini, TImporto& dare, TImporto& avere) const;
|
||||
bool saldi(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipo,
|
||||
TImporto& ini, TImporto& dare, TImporto& avere) const;
|
||||
TImporto _ini, _dare, _avere, _fin;
|
||||
bool _movimentato;
|
||||
};
|
||||
|
||||
const TSaldanal& ca_saldo(const char* conto, const char* costo,
|
||||
const char* commessa, const char* fase,
|
||||
const TDate& dal, const TDate& al, word tipi = 1);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
#define RMOVANA_NUMREG "NUMREG"
|
||||
#define RMOVANA_NUMRIG "NUMRIG"
|
||||
#define RMOVANA_SEZIONE "SEZIONE"
|
||||
#define RMOVANA_DATAREG "DATAREG"
|
||||
#define RMOVANA_DATACOMP "DATACOMP"
|
||||
#define RMOVANA_CODCCOSTO "CODCCOSTO"
|
||||
#define RMOVANA_CODCMS "CODCMS"
|
||||
#define RMOVANA_CODFASE "CODFASE"
|
||||
|
Loading…
x
Reference in New Issue
Block a user