Patch level :10.0 306
Files correlati :ca3.exe Ricompilazione Demo : [ ] Commento : gestione conti non riclassificati nella esportazione rendiconto git-svn-id: svn://10.65.10.50/trunk@18889 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
798a82df2a
commit
273fe07c1d
@ -243,6 +243,71 @@ TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask()
|
||||
set_handlers();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// TRiclass
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
class TRiclass : public TCache
|
||||
{
|
||||
TString16 _prefix;
|
||||
|
||||
protected:
|
||||
TObject* key2obj(const char* key);
|
||||
|
||||
public:
|
||||
void set_prefix(const TString& p) { _prefix = p; }
|
||||
bool is_riclassificato(const TString& str_conto) const;
|
||||
TRiclass() : TCache(883) {}
|
||||
};
|
||||
|
||||
TObject* TRiclass::key2obj(const char* key)
|
||||
{
|
||||
CHECK(_prefix.full(), "Empty pconana prefix");
|
||||
const TFixed_string str_conto(key);
|
||||
|
||||
TRelation panarel(LF_PANAPDC);
|
||||
TString filter;
|
||||
filter << '(' << PANAPDC_CODCONTO << "[1," << _prefix.len() << "]==\"" << _prefix << "\")";
|
||||
|
||||
TRectype& fromto = panarel.curr();
|
||||
if (str_conto.len() >= 3)
|
||||
fromto.put(PANAPDC_GRUPPO, str_conto.left(3));
|
||||
|
||||
if (str_conto.len() >= 6)
|
||||
fromto.put(PANAPDC_CONTO, str_conto.mid(3,3));
|
||||
else
|
||||
filter << "&&(" << PANAPDC_CONTO << "=\"\")";
|
||||
|
||||
if (str_conto.len() >= 12)
|
||||
fromto.put(PANAPDC_SOTTOCONTO, str_conto.mid(6,6));
|
||||
else
|
||||
filter << "&&(" << PANAPDC_SOTTOCONTO << "=\"\")";
|
||||
|
||||
TCursor panacur(&panarel, filter, 2, &fromto, &fromto);
|
||||
|
||||
bool ok = panacur.items() > 0;
|
||||
return new real(ok ? UNO : ZERO);
|
||||
}
|
||||
|
||||
//cerca se str_conto è riclassificato
|
||||
bool TRiclass::is_riclassificato(const TString& str_conto) const
|
||||
{
|
||||
TString80 codice = str_conto;
|
||||
|
||||
const real* o = (const real*)((TRiclass*)this)->objptr(codice); //Allah!!!
|
||||
if (o->is_zero() && codice.len() == 12)
|
||||
{
|
||||
codice.cut(6);
|
||||
o = (const real*)((TRiclass*)this)->objptr(codice); //Budda!!!
|
||||
}
|
||||
if (o->is_zero() && codice.len() == 6)
|
||||
{
|
||||
codice.cut(3);
|
||||
o = (const real*)((TRiclass*)this)->objptr(codice); //Jeowah!!!
|
||||
}
|
||||
return !o->is_zero();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// RECORDSET
|
||||
@ -258,6 +323,7 @@ class TPrint_rendiconto_ca_recordset : public TISAM_recordset
|
||||
bool _implode_rows;
|
||||
TString _prefix;
|
||||
TAssoc_array _ratrisc;
|
||||
TRiclass _ricl;
|
||||
|
||||
protected:
|
||||
int _anno;
|
||||
@ -289,8 +355,8 @@ public: //da libreria
|
||||
public:
|
||||
void set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row, TLog_report& log);
|
||||
void set_cms_cdc_fase(const char* cdc, const char* cms, const char* fase);
|
||||
real get_budget(const TString& conto, char tipo) const; //per la stampa
|
||||
void get_budget(const TString& codcdc, const TString& codcms, const TString& codfase,
|
||||
real get_budget_print(const TString& conto, char tipo) const; //per la stampa
|
||||
void get_budget_export(const TString& codcdc, const TString& codcms, const TString& codfase,
|
||||
TImporto& att, TImporto& pas, TImporto& cos, TImporto& ric) const; //per l'esportazione
|
||||
|
||||
|
||||
@ -372,8 +438,8 @@ void TPrint_rendiconto_ca_recordset::set_cms_cdc_fase(const char* cdc, const cha
|
||||
_codfas = fase;
|
||||
}
|
||||
|
||||
void TPrint_rendiconto_ca_recordset::get_budget(const TString& codcdc, const TString& codcms, const TString& codfase,
|
||||
TImporto& att, TImporto& pas, TImporto& cos, TImporto& ric) const
|
||||
void TPrint_rendiconto_ca_recordset::get_budget_export(const TString& codcdc, const TString& codcms, const TString& codfase,
|
||||
TImporto& att, TImporto& pas, TImporto& cos, TImporto& ric) const
|
||||
{
|
||||
TString query;
|
||||
query << "USE SALDANA\nSELECT ";
|
||||
@ -388,7 +454,11 @@ void TPrint_rendiconto_ca_recordset::get_budget(const TString& codcdc, const TSt
|
||||
TISAM_recordset saldana(query);
|
||||
for (bool ok = saldana.move_first(); ok; ok = saldana.move_next())
|
||||
{
|
||||
const TAnal_bill zio(saldana.get("CONTO").as_string());
|
||||
const TString80 str_conto = saldana.get("CONTO").as_string();
|
||||
if (_riclassificato && !_ricl.is_riclassificato(str_conto))
|
||||
continue;
|
||||
|
||||
const TAnal_bill zio(str_conto);
|
||||
const int indbil = zio.indicatore_bilancio();
|
||||
|
||||
TImporto saldo = ca_get_imp(saldana, SALDANA_SEZIONEP, SALDANA_SALDOP);
|
||||
@ -412,7 +482,7 @@ void TPrint_rendiconto_ca_recordset::get_budget(const TString& codcdc, const TSt
|
||||
}
|
||||
|
||||
//sconvolgente metodo per la normalizzazione dei conti
|
||||
real TPrint_rendiconto_ca_recordset::get_budget(const TString& conto, char tipo) const
|
||||
real TPrint_rendiconto_ca_recordset::get_budget_print(const TString& conto, char tipo) const
|
||||
{
|
||||
//data del cazzo che però serve per costruire il conto analitico
|
||||
const TDate null_date;
|
||||
@ -507,13 +577,13 @@ const TVariant& TPrint_rendiconto_ca_recordset::get(const char* column_name) con
|
||||
{
|
||||
//stessa cosa del precedente ma per movimenti di tipo variazione preventivo
|
||||
const TString& conto = TISAM_recordset::get("CONTO").as_string();
|
||||
return get_tmp_var() = get_budget(conto, 'P');
|
||||
return get_tmp_var() = get_budget_print(conto, 'P');
|
||||
}
|
||||
if (strcmp(column_name, "#VARIAZIONE") == 0)
|
||||
{
|
||||
//prende il conto
|
||||
const TString& conto = TISAM_recordset::get("CONTO").as_string();
|
||||
return get_tmp_var() = get_budget(conto, 'V');
|
||||
return get_tmp_var() = get_budget_print(conto, 'V');
|
||||
}
|
||||
}
|
||||
return TISAM_recordset::get(column_name);
|
||||
@ -541,7 +611,7 @@ const TString& TPrint_rendiconto_ca_recordset::riclassifica(const TBill& zio, TR
|
||||
da_panapdc.put(PANAPDC_GRUPPO, zio.gruppo());
|
||||
|
||||
TString filtro;
|
||||
if (_prefix.not_empty())
|
||||
if (_prefix.full())
|
||||
filtro << "(CODCONTO[1," << _prefix.len() << "]=='" << _prefix << "')";
|
||||
|
||||
TCursor cur_panapdc(&rel_panapdc, filtro, 2, &da_panapdc, &da_panapdc);
|
||||
@ -1586,11 +1656,12 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask&
|
||||
for (short id = F_PRE1; id <= F_PRE3 && msk.id2pos(id) > 0; id++)
|
||||
{
|
||||
const TString& pr = msk.get(id);
|
||||
if (pr.not_empty())
|
||||
if (pr.full())
|
||||
_prefix << pr;
|
||||
else
|
||||
break;
|
||||
}
|
||||
_ricl.set_prefix(_prefix);
|
||||
}
|
||||
|
||||
//c'e' un range di conti da considerare?
|
||||
@ -1814,9 +1885,9 @@ void TPrint_rendiconto_ca::esporta_csv(TPrint_rendiconto_ca_recordset& rendy, co
|
||||
//calcolatore dei saldi: va fatta attraverso i saldi!!! perchè i budget sono multianno
|
||||
TImporto att, pas, ric, cos;
|
||||
if (first_level == LF_CDC)
|
||||
rendy.get_budget(curr_codice, codcms, codfas, att, pas, cos, ric);
|
||||
rendy.get_budget_export(curr_codice, codcms, codfas, att, pas, cos, ric);
|
||||
else
|
||||
rendy.get_budget(codcdc, curr_codice, codfas, att, pas, cos, ric);
|
||||
rendy.get_budget_export(codcdc, curr_codice, codfas, att, pas, cos, ric);
|
||||
|
||||
//aggiunge i valori dei saldi all'array con gli importi; li mette nella colonna [0] che è quella dei budget..
|
||||
//..e nella riga corrispondente all'indicatore bilancio
|
||||
|
Loading…
x
Reference in New Issue
Block a user