Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento :riportata esportazione rendiconto git-svn-id: svn://10.65.10.50/trunk@18716 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
589a23f49a
commit
3bb02501a9
162
ca/ca3700.cpp
162
ca/ca3700.cpp
@ -16,6 +16,7 @@
|
|||||||
#include "pconana.h"
|
#include "pconana.h"
|
||||||
#include "movana.h"
|
#include "movana.h"
|
||||||
#include "rmovana.h"
|
#include "rmovana.h"
|
||||||
|
#include "saldana.h"
|
||||||
|
|
||||||
#include "ca3.h"
|
#include "ca3.h"
|
||||||
#include "ca3700.h"
|
#include "ca3700.h"
|
||||||
@ -147,8 +148,8 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event
|
|||||||
_print_mode = 'A';
|
_print_mode = 'A';
|
||||||
stop_run(K_ENTER);
|
stop_run(K_ENTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DLG_EXPORT:
|
case DLG_EXPORT:
|
||||||
if (e == fe_button)
|
if (e == fe_button)
|
||||||
{
|
{
|
||||||
@ -296,7 +297,9 @@ public: //da libreria
|
|||||||
public:
|
public:
|
||||||
void set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row, TLog_report& log);
|
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);
|
void set_cms_cdc_fase(const char* cdc, const char* cms, const char* fase);
|
||||||
real get_budget(const TString& conto, char tipo) const;
|
real get_budget(const TString& conto, char tipo) const; //per la stampa
|
||||||
|
void get_budget(const TString& codcdc, const TString& codcms, const TString& codfase,
|
||||||
|
TImporto& att, TImporto& pas, TImporto& cos, TImporto& ric) const; //per l'esportazione
|
||||||
|
|
||||||
|
|
||||||
TPrint_rendiconto_ca_recordset(const TString& sql);
|
TPrint_rendiconto_ca_recordset(const TString& sql);
|
||||||
@ -377,6 +380,45 @@ void TPrint_rendiconto_ca_recordset::set_cms_cdc_fase(const char* cdc, const cha
|
|||||||
_codfas = fase;
|
_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
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "USE SALDANA\nSELECT ";
|
||||||
|
if (codcdc.full())
|
||||||
|
query << "(COSTO='" << codcdc << "')&&";
|
||||||
|
if (codcms.full())
|
||||||
|
query << "(COMMESSA='" << codcms << "')&&";
|
||||||
|
if (codfase.full())
|
||||||
|
query << "(FASE='" << codfase << "')&&";
|
||||||
|
query.rtrim(2);
|
||||||
|
|
||||||
|
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 int indbil = zio.indicatore_bilancio();
|
||||||
|
|
||||||
|
TImporto saldo = ca_get_imp(saldana, SALDANA_SEZIONEP, SALDANA_SALDOP);
|
||||||
|
saldo += ca_get_imp(saldana, SALDANA_SEZIONEV, SALDANA_SALDOV);
|
||||||
|
|
||||||
|
switch(indbil)
|
||||||
|
{
|
||||||
|
case 1: att += saldo; break;
|
||||||
|
case 2: pas += saldo; break;
|
||||||
|
case 3: cos += saldo; break;
|
||||||
|
case 4: ric += saldo; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
att.normalize('D');
|
||||||
|
cos.normalize('D');
|
||||||
|
|
||||||
|
pas.normalize('A');
|
||||||
|
ric.normalize('A');
|
||||||
|
}
|
||||||
|
|
||||||
//sconvolgente metodo per la normalizzazione dei conti
|
//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(const TString& conto, char tipo) const
|
||||||
{
|
{
|
||||||
@ -1471,8 +1513,8 @@ void TPrint_rendiconto_ca_recordset::crea_trr(const TFilename& trr) const
|
|||||||
of << "HIDDEN|8|1|0|Record nascosto" << endl;
|
of << "HIDDEN|8|1|0|Record nascosto" << endl;
|
||||||
of << 3 << endl;
|
of << 3 << endl;
|
||||||
of << "ORDCONT+CONTO+DATA+CODNUM+NUMRD+NUMREG+NRIGA" << endl;
|
of << "ORDCONT+CONTO+DATA+CODNUM+NUMRD+NUMREG+NRIGA" << endl;
|
||||||
of << "CODCMS+CONTO+DATA|X" << endl;
|
of << "CODCMS+ORDCONT+CONTO+DATA+CODNUM+NUMRD+NUMREG+NRIGA|X" << endl;
|
||||||
of << "CODCOSTO+CONTO+DATA|X" << endl;
|
of << "CODCOSTO+ORDCONT+CONTO+DATA+CODNUM+NUMRD+NUMREG+NRIGA|X" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row, TLog_report& log)
|
void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row, TLog_report& log)
|
||||||
@ -1650,8 +1692,8 @@ void TPrint_rendiconto_ca::esporta_csv_row(ostream& file_to_date, const int firs
|
|||||||
{
|
{
|
||||||
case 1: col = 16; break; //attività
|
case 1: col = 16; break; //attività
|
||||||
case 2: col = 23; break; //passività
|
case 2: col = 23; break; //passività
|
||||||
case 3: col = 2; break; //costi (o ricavi se selezionato il flag di inversione sulla maschera)
|
case 3: col = 2; break; //costi
|
||||||
case 4: col = 9; break; //ricavi (o costi se selezionato il flag di inversione sulla maschera)
|
case 4: col = 9; break; //ricavi
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1704,13 +1746,28 @@ void TPrint_rendiconto_ca::esporta_csv(TPrint_rendiconto_ca_recordset& rendy, co
|
|||||||
path.add("rendiconto.xls");
|
path.add("rendiconto.xls");
|
||||||
ofstream file_to_date(path, ios::app);
|
ofstream file_to_date(path, ios::app);
|
||||||
|
|
||||||
|
const bool invert_cosric = _msk->get_bool(F_REV_COSRIC);
|
||||||
|
|
||||||
//array bidimensionale con gli importi per indbil e colonna
|
//array bidimensionale con gli importi per indbil e colonna
|
||||||
real importi[5][4];
|
real importi[5][4];
|
||||||
//array bidimensionale con gli importi totali finali
|
//array bidimensionale con gli importi totali finali
|
||||||
real importi_totali[5][4];
|
real importi_totali[5][4];
|
||||||
TString80 last_codice, curr_codice, last_conto, curr_conto;
|
TString80 last_codice, curr_codice;
|
||||||
|
|
||||||
//recordset sul file .dbf, da scandire tutto uno per volta
|
TSheet_field& sf = _msk->sfield(F_RIGHE);
|
||||||
|
TString80 codcms, codcdc, codfas;
|
||||||
|
if (first_level == LF_CDC)
|
||||||
|
{
|
||||||
|
ca_extract_sheet_field(sf, r, LF_COMMESSE, codcms);
|
||||||
|
ca_extract_sheet_field(sf, r, LF_FASI, codfas);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ca_extract_sheet_field(sf, r, LF_CDC, codcdc);
|
||||||
|
ca_extract_sheet_field(sf, r, LF_FASI, codfas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//recordset sul file rendy.dbf, da scandire tutto un record per volta
|
||||||
rendy.requery();
|
rendy.requery();
|
||||||
for (bool ok = rendy.move_first(); ok; ok = rendy.move_next())
|
for (bool ok = rendy.move_first(); ok; ok = rendy.move_next())
|
||||||
{
|
{
|
||||||
@ -1719,58 +1776,45 @@ void TPrint_rendiconto_ca::esporta_csv(TPrint_rendiconto_ca_recordset& rendy, co
|
|||||||
//operazioni da fare al cambio commessa/cdc (codice primo livello)
|
//operazioni da fare al cambio commessa/cdc (codice primo livello)
|
||||||
if (curr_codice != last_codice)
|
if (curr_codice != last_codice)
|
||||||
{
|
{
|
||||||
|
//SCRIVE UNA RIGA SUL FILE DA ESPORTARE
|
||||||
|
//lo schema è questo: budget\impegnato\maturato\fatturato\da impegnare\da maturare\da fatturare
|
||||||
//controlla se last_codice sia pieno per non aggiungere una inutile riga di zeri all'inizio
|
//controlla se last_codice sia pieno per non aggiungere una inutile riga di zeri all'inizio
|
||||||
if (last_codice.full())
|
if (last_codice.full())
|
||||||
esporta_csv_row(file_to_date, first_level, last_codice, importi, importi_totali);
|
esporta_csv_row(file_to_date, first_level, last_codice, importi, importi_totali);
|
||||||
|
|
||||||
memset(importi, 0, sizeof(importi)); //Allah! Azzeratore dell'array con i totali per commessa (o cdc)
|
memset(importi, 0, sizeof(importi)); //Allah! Azzeratore dell'array con i totali per commessa (o cdc)
|
||||||
last_codice = curr_codice; //memorizza il cambio codice
|
last_codice = curr_codice; //memorizza il cambio codice (cms/cdc)
|
||||||
last_conto = ""; //azzera l'ultimo conto
|
|
||||||
}
|
|
||||||
|
|
||||||
curr_conto = rendy.get("CONTO").as_string();
|
//calcolatore dei saldi: va fatta attraverso i saldi!!! perchè i budget sono multianno
|
||||||
|
TImporto att, pas, ric, cos;
|
||||||
//gestione dei budget: va fatta attraverso i saldi!!! come nella stampa, onde evitare pericolose dimenticanze..
|
|
||||||
//..di movimenti budget in anni diversi da quello considerato
|
|
||||||
const bool hidden = rendy.get("HIDDEN").as_bool();
|
|
||||||
const int indbil = rendy.get("ORDCONT").as_int();
|
|
||||||
|
|
||||||
if (hidden && curr_conto.full() && (curr_conto != last_conto))
|
|
||||||
{
|
|
||||||
//preparazione dei parametri per il calcolo dei saldi
|
|
||||||
TSheet_field& sf = _msk->sfield(F_RIGHE);
|
|
||||||
TString80 codcms, codcdc, codfas;
|
|
||||||
if (first_level == LF_CDC)
|
if (first_level == LF_CDC)
|
||||||
{
|
rendy.get_budget(curr_codice, codcms, codfas, att, pas, cos, ric);
|
||||||
codcdc = curr_codice;
|
|
||||||
ca_extract_sheet_field(sf, r, LF_COMMESSE, codcms);
|
|
||||||
ca_extract_sheet_field(sf, r, LF_FASI, codfas);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
rendy.get_budget(codcdc, curr_codice, codfas, att, pas, cos, ric);
|
||||||
codcms = curr_codice;
|
|
||||||
ca_extract_sheet_field(sf, r, LF_CDC, codcdc);
|
|
||||||
ca_extract_sheet_field(sf, r, LF_FASI, codfas);
|
|
||||||
}
|
|
||||||
//calcola i saldana usando la get_budget come in stampa
|
|
||||||
rendy.set_cms_cdc_fase(codcdc, codcms, codfas);
|
|
||||||
real budget = rendy.get_budget(curr_conto, 'P');
|
|
||||||
budget += rendy.get_budget(curr_conto, 'V');
|
|
||||||
importi[indbil][0] += budget;
|
|
||||||
|
|
||||||
last_conto = curr_conto;
|
//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
|
||||||
|
importi[1][0] = pas.valore();
|
||||||
|
importi[2][0] = att.valore();
|
||||||
|
importi[3][0] = cos.valore();
|
||||||
|
importi[4][0] = ric.valore();
|
||||||
}
|
}
|
||||||
|
|
||||||
//lo schema è questo: budget\impegnato\maturato\fatturato\da impegnare\da maturare\da fatturare
|
//aggiorna tutti gli altri valori dell'array degli importi che non siano budget (cosa che fa solo a cambio codice)..
|
||||||
//aggiorna budget
|
//..come si vede sopra
|
||||||
|
const bool hidden = rendy.get("HIDDEN").as_bool();
|
||||||
//aggiorna tutti gli altri campi
|
|
||||||
if (!hidden)
|
if (!hidden)
|
||||||
{
|
{
|
||||||
const real impegnato = rendy.get("IMPEGNATO").as_real();
|
const real impegnato = rendy.get("IMPEGNATO").as_real();
|
||||||
const real fatturato = rendy.get("FATTURATO").as_real();
|
const real fatturato = rendy.get("FATTURATO").as_real();
|
||||||
const real maturato = rendy.get("MATURATO").as_real();
|
const real maturato = rendy.get("MATURATO").as_real();
|
||||||
|
|
||||||
|
//occhio all'inversione ricavi/costi, che causa il ribaltamento del significato di ordcont
|
||||||
|
int indbil = rendy.get("ORDCONT").as_int();
|
||||||
|
if (invert_cosric && (indbil == 3 || indbil == 4))
|
||||||
|
indbil = 7 - indbil;
|
||||||
|
|
||||||
|
//aggiornamento degli importi non budget di commessa/cdc
|
||||||
importi[indbil][1] += impegnato;
|
importi[indbil][1] += impegnato;
|
||||||
importi[indbil][2] += maturato;
|
importi[indbil][2] += maturato;
|
||||||
importi[indbil][3] += fatturato;
|
importi[indbil][3] += fatturato;
|
||||||
@ -1781,9 +1825,10 @@ void TPrint_rendiconto_ca::esporta_csv(TPrint_rendiconto_ca_recordset& rendy, co
|
|||||||
//gestione speciale dell'ultima riga
|
//gestione speciale dell'ultima riga
|
||||||
if (last_codice.full())
|
if (last_codice.full())
|
||||||
{
|
{
|
||||||
|
//SCRIVE L'ULTIMA RIGA RELATIVA A CMS/CDC SUL FILE DA ESPORTARE
|
||||||
esporta_csv_row(file_to_date, first_level, last_codice, importi, importi_totali);
|
esporta_csv_row(file_to_date, first_level, last_codice, importi, importi_totali);
|
||||||
|
|
||||||
//aggiunge la riga con i totali
|
//AGGIUNGE L'EVENTUALE RIGA DEI TOTALI
|
||||||
TToken_string str_tot = _msk->sfield(F_RIGHE).row(r);
|
TToken_string str_tot = _msk->sfield(F_RIGHE).row(r);
|
||||||
//la riga con i totali ci va solo se non è stato specificato il primo livello (es. commessa o cdc)
|
//la riga con i totali ci va solo se non è stato specificato il primo livello (es. commessa o cdc)
|
||||||
const TFixed_string first_field = str_tot.get(0);
|
const TFixed_string first_field = str_tot.get(0);
|
||||||
@ -1799,7 +1844,7 @@ void TPrint_rendiconto_ca::esporta_csv(TPrint_rendiconto_ca_recordset& rendy, co
|
|||||||
//doppia riga vuota di stacco
|
//doppia riga vuota di stacco
|
||||||
file_to_date << endl << endl;
|
file_to_date << endl << endl;
|
||||||
}
|
}
|
||||||
}
|
} //if(last_codice.full())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1853,29 +1898,15 @@ void TPrint_rendiconto_ca::main_loop()
|
|||||||
recset_key = 3; //chiave del recordset per centro di costo
|
recset_key = 3; //chiave del recordset per centro di costo
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool reverse_cos_ric = mask.get_bool(F_REV_COSRIC); //occhio al flag di rovesciamento
|
//const bool reverse_cos_ric = mask.get_bool(F_REV_COSRIC); //occhio al flag di rovesciamento
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: intestazione_1.add("Costi"); break;
|
||||||
{
|
case 1: intestazione_1.add("Ricavi"); break;
|
||||||
if (reverse_cos_ric)
|
case 2: intestazione_1.add("Attività"); break;
|
||||||
intestazione_1.add("Ricavi");
|
|
||||||
else
|
|
||||||
intestazione_1.add("Costi");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
if (reverse_cos_ric)
|
|
||||||
intestazione_1.add("Costi");
|
|
||||||
else
|
|
||||||
intestazione_1.add("Ricavi");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: intestazione_1.add("Attività"); break;
|
|
||||||
case 3: intestazione_1.add("Passività"); break;
|
case 3: intestazione_1.add("Passività"); break;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < 6; j++)
|
for (int j = 0; j < 6; j++)
|
||||||
@ -1978,7 +2009,6 @@ void TPrint_rendiconto_ca::main_loop()
|
|||||||
else
|
else
|
||||||
book.print();
|
book.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
} //while(true)...
|
} //while(true)...
|
||||||
|
|
||||||
delete _msk;
|
delete _msk;
|
||||||
|
@ -725,7 +725,7 @@ public:
|
|||||||
TSaldi_cache();
|
TSaldi_cache();
|
||||||
};
|
};
|
||||||
|
|
||||||
static TImporto get_imp(const TRecordset& rs, const char* sez, const char* imp)
|
TImporto ca_get_imp(const TRecordset& rs, const char* sez, const char* imp)
|
||||||
{
|
{
|
||||||
const char sezione = rs.get(sez).as_string()[0];
|
const char sezione = rs.get(sez).as_string()[0];
|
||||||
const real importo = rs.get(imp).as_real();
|
const real importo = rs.get(imp).as_real();
|
||||||
@ -784,15 +784,15 @@ bool TSaldi_cache::int_saldo_annuale(const TAnal_bill& b, int da_anno, int ad_an
|
|||||||
TImporto imp;
|
TImporto imp;
|
||||||
if (tipo & _saldanal_consuntivo)
|
if (tipo & _saldanal_consuntivo)
|
||||||
{
|
{
|
||||||
imp += get_imp(saldini, SALDANA_SEZIONE, SALDANA_SALDO);
|
imp += ca_get_imp(saldini, SALDANA_SEZIONE, SALDANA_SALDO);
|
||||||
}
|
}
|
||||||
if (tipo & _saldanal_preventivo)
|
if (tipo & _saldanal_preventivo)
|
||||||
{
|
{
|
||||||
imp += get_imp(saldini, SALDANA_SEZIONEP, SALDANA_SALDOP);
|
imp += ca_get_imp(saldini, SALDANA_SEZIONEP, SALDANA_SALDOP);
|
||||||
}
|
}
|
||||||
if (tipo & _saldanal_variazione)
|
if (tipo & _saldanal_variazione)
|
||||||
{
|
{
|
||||||
imp += get_imp(saldini, SALDANA_SEZIONEV, SALDANA_SALDOV);
|
imp += ca_get_imp(saldini, SALDANA_SEZIONEV, SALDANA_SALDOV);
|
||||||
}
|
}
|
||||||
if (!imp.is_zero())
|
if (!imp.is_zero())
|
||||||
{
|
{
|
||||||
|
@ -77,8 +77,14 @@ public:
|
|||||||
TSaldanal(const TSaldanal& sa) { copy(sa); }
|
TSaldanal(const TSaldanal& sa) { copy(sa); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
|
// Metodi sciolti ma decisivi
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi = _saldanal_consuntivo);
|
const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi = _saldanal_consuntivo);
|
||||||
|
|
||||||
|
TImporto ca_get_imp(const TRecordset& rs, const char* sez, const char* imp);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// TPconana_recordset
|
// TPconana_recordset
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user