Patch level :4.0 506
Files correlati :ca3.exe ca3700.msk ca3700a.rep Ricompilazione Demo : [ ] Commento :aggiunto ordinamento conti per indicatore di bilancio; richiesta di Eva Braun del CRPA git-svn-id: svn://10.65.10.50/trunk@14371 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4af434baab
commit
10db434c95
209
ca/ca3700.cpp
209
ca/ca3700.cpp
@ -234,6 +234,7 @@ class TPrint_rendiconto_ca_recordset : public TISAM_recordset
|
||||
{
|
||||
TExternisamfile* _tmp;
|
||||
bool _riclassificato;
|
||||
bool _reverse_cos_ric;
|
||||
TString _prefix;
|
||||
|
||||
protected:
|
||||
@ -256,6 +257,7 @@ protected:
|
||||
void crea_trr(const TFilename& trr) const;
|
||||
void scrive_riga(const TRectype& rmovana, const TRectype& movana, const TDocumento* doc);
|
||||
void scrive_riga_speciale(const TDocumento* doc, const TString_array& special_docs);
|
||||
int sort_indbil(int indbil) const;
|
||||
TString riclassifica(const int gruppo, const int conto, const long sottoconto, TRectype& tmpcurr);
|
||||
real get_budget(const TString& conto, char tipo) const;
|
||||
|
||||
@ -284,10 +286,15 @@ void TPrint_rendiconto_ca_recordset::set_custom_filter(TCursor& cur) const
|
||||
arec.zero();
|
||||
|
||||
if (_daconto.not_empty())
|
||||
{
|
||||
darec.put("ORDCONT", 1);
|
||||
darec.put("CONTO", _daconto);
|
||||
}
|
||||
if (_aconto.not_empty())
|
||||
{
|
||||
arec.put("ORDCONT", 5);
|
||||
arec.put("CONTO", _aconto);
|
||||
|
||||
}
|
||||
//filtro sulla data(non avendo anche codnum non ho la chiave completa per mettere la data nella setregion)
|
||||
TString filtro;
|
||||
if (_dadata.ok())
|
||||
@ -300,6 +307,20 @@ void TPrint_rendiconto_ca_recordset::set_custom_filter(TCursor& cur) const
|
||||
filtro << "(ANSI(DATA)<=" << _adata << ")";
|
||||
}
|
||||
|
||||
if (_daconto.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(CONTO>='" << _daconto << "')";
|
||||
}
|
||||
|
||||
if (_aconto.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(CONTO<='" << _aconto << "~')";
|
||||
}
|
||||
|
||||
cur.setregion(darec, arec);
|
||||
cur.setfilter(filtro);
|
||||
|
||||
@ -414,6 +435,17 @@ const TVariant& TPrint_rendiconto_ca_recordset::get(const char* column_name) con
|
||||
return TISAM_recordset::get(column_name);
|
||||
}
|
||||
|
||||
int TPrint_rendiconto_ca_recordset::sort_indbil(int indbil) const
|
||||
{
|
||||
if (_reverse_cos_ric) //sono del CRPA/CSA
|
||||
{
|
||||
if (indbil == 3 || indbil == 4)
|
||||
indbil = 7 - indbil;
|
||||
}
|
||||
return indbil;
|
||||
}
|
||||
|
||||
|
||||
TString TPrint_rendiconto_ca_recordset::riclassifica(const int gruppo, const int conto,
|
||||
const long sottoconto, TRectype& tmpcurr)
|
||||
{
|
||||
@ -472,6 +504,24 @@ TString TPrint_rendiconto_ca_recordset::riclassifica(const int gruppo, const int
|
||||
return conto_riclassificato;
|
||||
}
|
||||
|
||||
static int bill2indbil(const TString& codconto, bool is_anal)
|
||||
{
|
||||
int indbil = 0;
|
||||
if (is_anal)
|
||||
{
|
||||
const TAnal_bill bill(codconto);
|
||||
indbil = bill.indicatore_bilancio();
|
||||
}
|
||||
else
|
||||
{
|
||||
const int gruppo = atoi(codconto.left(3));
|
||||
const int conto = atoi(codconto.mid(3,3));
|
||||
const long sottoconto = atol(codconto.mid(6,6));
|
||||
const TBill bill(gruppo, conto, sottoconto);
|
||||
indbil = bill.indicatore_bilancio();
|
||||
}
|
||||
return indbil;
|
||||
}
|
||||
|
||||
//compila i campi del file temporaneo che sara' poi stampato
|
||||
void TPrint_rendiconto_ca_recordset::scrive_riga(const TRectype& rmovana, const TRectype& movana, const TDocumento* doc)
|
||||
@ -482,29 +532,53 @@ void TPrint_rendiconto_ca_recordset::scrive_riga(const TRectype& rmovana, const
|
||||
TString8 codnum_desc; //codnum da usare sia per compilare il campo "CODNUM"
|
||||
codnum_desc.cut(0);
|
||||
|
||||
TString codconto = rmovana.get(RMOVANA_CODCONTO);
|
||||
TString codcontocg;
|
||||
int indbil = 0;
|
||||
|
||||
// il conto puo' essere analitico o contabile...
|
||||
//se è compilato l'archivio di collegamento PANAPDC
|
||||
//si deve usare come conto il campo codconto del panapdc!!!...
|
||||
if (_riclassificato)
|
||||
//si deve usare come conto il campo codconto del panapdc!!!...
|
||||
//Solo se si ha un conto contabile e' possibile riclassificare in analitico!!!
|
||||
if (_riclassificato) //traduzione:sei il CRPA/CSA
|
||||
{
|
||||
//prende il gr/co/so dalla riga rmovana in esame
|
||||
const int gruppo = atoi(rmovana.get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto = atoi(rmovana.get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto = atol(rmovana.get(RMOVANA_CODCONTO).mid(6,6));
|
||||
const int gruppo = atoi(codconto.left(3));
|
||||
const int conto = atoi(codconto.mid(3,3));
|
||||
const long sottoconto = atol(codconto.mid(6,6));
|
||||
|
||||
//stringa che conterrà il conto riclassificato (se sara' trovato)
|
||||
TString conto_riclassificato = riclassifica(gruppo, conto, sottoconto, tmpcurr);
|
||||
//stringa che conterrà il conto riclassificato (se sara' trovato)
|
||||
const TString conto_riclassificato = riclassifica(gruppo, conto, sottoconto, tmpcurr);
|
||||
//se il conto viene ritornato vuoto significa che non ricade nell'intervallo dei conti..
|
||||
//..riclassificati selezionato dall'utente
|
||||
if (conto_riclassificato == EMPTY_STRING)
|
||||
//..riclassificati selezionato dall'utente..
|
||||
if (conto_riclassificato.empty())
|
||||
return;
|
||||
//..senno' lo scrive come conto riclassificato
|
||||
codcontocg = codconto;
|
||||
codconto = conto_riclassificato;
|
||||
indbil = bill2indbil(codcontocg, false);
|
||||
|
||||
} //if(_riclassificato)
|
||||
else //...sennò si usa il normale piano dei conti analitico (cioè tutti tranne che il CRPA)
|
||||
tmpcurr.put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto
|
||||
else //...sennò si usano..
|
||||
{
|
||||
if (_piano == "A") //..il normale piano dei conti analitico..
|
||||
indbil = bill2indbil(codconto, true);
|
||||
else //..o il normale piano dei conti contabile
|
||||
{
|
||||
codcontocg = codconto;
|
||||
indbil = bill2indbil(codcontocg, false);
|
||||
}
|
||||
}
|
||||
|
||||
//mette i conti nel file (se piano dei conti puramente contabile i valori coincidono)
|
||||
tmpcurr.put("CONTO", codconto); //conto
|
||||
tmpcurr.put("CONTOCG", codcontocg); //conto_cg
|
||||
|
||||
//fa il sort l'indicatore di bilancio del conto e lo utilizza per ordinare i record nel file..
|
||||
//..di appoggio;se sei del CRPA/CSA vuoi i costi dopo i ricavi!
|
||||
const int ordcont = sort_indbil(indbil);
|
||||
tmpcurr.put("ORDCONT", ordcont);
|
||||
|
||||
//in ogni caso riempio il campo conto_cg
|
||||
tmpcurr.put("CONTOCG", rmovana.get(RMOVANA_CODCONTO)); //conto_cg
|
||||
|
||||
//tipo movimento CONSUNTIVO (o TEMPORANEO)
|
||||
const char tipomov = movana.get_char(MOVANA_TIPOMOV);
|
||||
@ -701,6 +775,8 @@ F=IMF*/
|
||||
//..quali le fatture da emettere e ricevere, la cui lista e' nel ca_config
|
||||
void TPrint_rendiconto_ca_recordset::scrive_riga_speciale(const TDocumento* doc, const TString_array& special_docs)
|
||||
{
|
||||
//prende il tipocf che gli serve un po' ovunque in seguito..
|
||||
const char tipocf = doc->get_char(DOC_TIPOCF);
|
||||
const int rows = doc->physical_rows();
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
@ -714,8 +790,7 @@ void TPrint_rendiconto_ca_recordset::scrive_riga_speciale(const TDocumento* doc,
|
||||
TString8 codnum_desc;
|
||||
codnum_desc.cut(0);
|
||||
|
||||
//prende il tipocf che gli serve un po' ovunque in seguito..
|
||||
const char tipocf = doc->get_char(DOC_TIPOCF);
|
||||
TString codconto, codcontocg;
|
||||
|
||||
//se usa il piano dei conti contabile -> _piano = C..
|
||||
if (_piano == "C")
|
||||
@ -724,43 +799,49 @@ void TPrint_rendiconto_ca_recordset::scrive_riga_speciale(const TDocumento* doc,
|
||||
TContabilizzazione_analitica contab;
|
||||
TBill conto;
|
||||
if (contab.search_costo_ricavo(rigadoc, conto))
|
||||
{
|
||||
const int gr = conto.gruppo();
|
||||
const int co = conto.conto();
|
||||
const long so = conto.sottoconto();
|
||||
|
||||
if (_riclassificato)
|
||||
{
|
||||
//stringa che conterrà il conto riclassificato (se sara' trovato)
|
||||
TString conto_riclassificato = riclassifica(gr, co, so, tmpcurr);
|
||||
if (conto_riclassificato == EMPTY_STRING)
|
||||
return;
|
||||
|
||||
} //if(_riclassificato)
|
||||
else //...sennò si usa il conto
|
||||
tmpcurr.put("CONTO", conto.string(0x8));
|
||||
}
|
||||
codconto = codcontocg = conto.string(0x8);
|
||||
}
|
||||
else //se ivece usa il piano dei conti analitico -> _piano = A...
|
||||
{
|
||||
TString80 conto_anal;
|
||||
if (rigadoc.is_articolo())
|
||||
if (_riclassificato)
|
||||
{
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, rigadoc.get(RDOC_CODARTMAG));
|
||||
conto_anal = anamag.get(tipocf == 'F' ? ANAMAG_CONTOINDA : ANAMAG_CONTOINDV);
|
||||
}
|
||||
TContabilizzazione_analitica contab;
|
||||
TBill conto;
|
||||
if (contab.search_costo_ricavo(rigadoc, conto))
|
||||
{
|
||||
//stringa che conterrà il conto riclassificato (se sara' trovato)
|
||||
codconto = riclassifica(conto.gruppo(), conto.conto(), conto.sottoconto(), tmpcurr);
|
||||
codcontocg = conto.string(0x8);
|
||||
}
|
||||
} //if(_riclassificato)
|
||||
else
|
||||
{
|
||||
if (rigadoc.is_spese() || rigadoc.is_prestazione() ||
|
||||
rigadoc.is_risorsa() || rigadoc.is_attrezzatura())
|
||||
if (rigadoc.is_articolo())
|
||||
{
|
||||
const char tipo = rigadoc.tipo().tipo();
|
||||
const TSpesa_prest spp(rigadoc.get(RDOC_CODART), tipo);
|
||||
conto_anal = tipocf == 'F' ? spp.conto_analitico_acquisti() : spp.conto_analitico_vendite();
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, rigadoc.get(RDOC_CODARTMAG));
|
||||
codconto = anamag.get(tipocf == 'F' ? ANAMAG_CONTOINDA : ANAMAG_CONTOINDV);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rigadoc.is_spese() || rigadoc.is_prestazione() ||
|
||||
rigadoc.is_risorsa() || rigadoc.is_attrezzatura())
|
||||
{
|
||||
const char tipo = rigadoc.tipo().tipo();
|
||||
const TSpesa_prest spp(rigadoc.get(RDOC_CODART), tipo);
|
||||
codconto = tipocf == 'F' ? spp.conto_analitico_acquisti() : spp.conto_analitico_vendite();
|
||||
}
|
||||
}
|
||||
}
|
||||
tmpcurr.put("CONTO", conto_anal);
|
||||
}
|
||||
//non trova il conto -> esce
|
||||
if (codconto.empty())
|
||||
return;
|
||||
|
||||
const int indbil = codcontocg.full() ? bill2indbil(codcontocg, false)
|
||||
: bill2indbil(codconto, true) ;
|
||||
tmpcurr.put("CONTO", codconto);
|
||||
tmpcurr.put("CONTOCG", codcontocg);
|
||||
tmpcurr.put("ORDCONT", sort_indbil(indbil));
|
||||
|
||||
//comincia a riempire i record
|
||||
//prima i campi che prende direttamente dal doc speciale
|
||||
@ -1055,10 +1136,10 @@ void TPrint_rendiconto_ca_recordset::crea_righe_da_rdoc(const TPrint_rendiconto_
|
||||
old_key = curr_key;
|
||||
|
||||
TDocumento doc(curr_doc);
|
||||
TAnal_mov mov;
|
||||
|
||||
//documento NON contabilizzato
|
||||
if (numregca == 0)
|
||||
{
|
||||
{
|
||||
TAnal_mov mov;
|
||||
cont_anal.elabora(doc, 0, NULL, false, mov);
|
||||
|
||||
//estrae il tipo ed il codice clifo dal documento per metterlo nel movana che ha generato
|
||||
@ -1081,10 +1162,11 @@ void TPrint_rendiconto_ca_recordset::crea_righe_da_rdoc(const TPrint_rendiconto_
|
||||
continue;
|
||||
if (_codfas.not_empty() && rmov.get(RMOVANA_CODFASE) != _codfas)
|
||||
continue;
|
||||
scrive_riga(rmov, mov, &doc); //documenti "normali"
|
||||
|
||||
scrive_riga(rmov, mov, &doc); //documenti "normali"
|
||||
} //for int j...
|
||||
}
|
||||
//righe di documento configurate come da emettere/ricevere
|
||||
//righe di documento configurate come da emettere/ricevere (documenti speciali)
|
||||
if (is_special_doc)
|
||||
scrive_riga_speciale(&doc, num_fdr);
|
||||
} //if (numregca==0...
|
||||
@ -1112,7 +1194,8 @@ void TPrint_rendiconto_ca_recordset::crea_trr(const TFilename& trr) const
|
||||
{
|
||||
ofstream of(trr);
|
||||
of << 1000 << endl;
|
||||
of << 18 << endl;
|
||||
of << 19 << endl;
|
||||
of << "ORDCONT|1|1|0|Ordinatore in base a indicatore di bilancio" << endl;
|
||||
of << "CONTO|1|20|0|Conto analitico" << endl;
|
||||
of << "DATA|5|8|0|Data movimento o documento" << endl;
|
||||
of << "CODNUM|1|4|0|Numerazione documento" << endl;
|
||||
@ -1132,7 +1215,7 @@ void TPrint_rendiconto_ca_recordset::crea_trr(const TFilename& trr) const
|
||||
of << "CONTOCG|1|12|0|Conto contabile" << endl;
|
||||
of << "HIDDEN|8|1|0|Record nascosto" << endl;
|
||||
of << 1 << endl;
|
||||
of << "CONTO+DATA+CODNUM+NUMRD+NRIGA" << endl;
|
||||
of << "ORDCONT+CONTO+DATA+CODNUM+NUMRD+NRIGA" << endl;
|
||||
}
|
||||
|
||||
void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row)
|
||||
@ -1175,7 +1258,7 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask&
|
||||
const short dlg_al = tc == 'C' ? F_PDC1_FIN : F_PAN1_FIN;
|
||||
|
||||
//si utilizza la riclassificazione dei conti?
|
||||
|
||||
//Ovvero: sei il CRPA o un qualsiasi altro utente del mondo?
|
||||
_piano = msk.get(F_PIANO);
|
||||
if (_piano == "A")
|
||||
{
|
||||
@ -1186,15 +1269,6 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask&
|
||||
else
|
||||
_riclassificato = false;
|
||||
|
||||
for (int i = 0; i < 4 && msk.id2pos(dlg_da+i) > 0; i++)
|
||||
{
|
||||
_daconto << msk.get(dlg_da+i);
|
||||
_aconto << msk.get(dlg_al+i);
|
||||
}
|
||||
|
||||
_dadata = msk.get_date(F_DATAINI);
|
||||
_adata = msk.get_date(F_DATAFIN);
|
||||
|
||||
if (_riclassificato)
|
||||
{
|
||||
//esiste un prefisso a più livelli?
|
||||
@ -1207,6 +1281,21 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask&
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//c'e' un range di conti da considerare?
|
||||
for (int i = 0; i < 4 && msk.id2pos(dlg_da+i) > 0; i++)
|
||||
{
|
||||
_daconto << msk.get(dlg_da+i);
|
||||
_aconto << msk.get(dlg_al+i);
|
||||
}
|
||||
//vuoi l'ordinamento normale o sei la Roberta del CRPA?
|
||||
_reverse_cos_ric = msk.get_bool(F_REV_COSRIC);
|
||||
|
||||
//c'e' un fottuto range di date?
|
||||
_dadata = msk.get_date(F_DATAINI);
|
||||
_adata = msk.get_date(F_DATAFIN);
|
||||
|
||||
|
||||
//metodi per riempire il file da cui generare il report
|
||||
//dati estratti dalle righe movimenti di contabilita' analitica
|
||||
crea_righe_da_rmovana();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define F_REPORT 255
|
||||
#define F_DATAINI 256
|
||||
#define F_DATAFIN 257
|
||||
#define F_REV_COSRIC 258
|
||||
|
||||
//campi generati dai piani dei conti
|
||||
#define F_PIANO 319
|
||||
|
@ -64,9 +64,14 @@ BEGIN
|
||||
ADD NONE
|
||||
END
|
||||
|
||||
BOOLEAN F_REV_COSRIC
|
||||
BEGIN
|
||||
PROMPT 1 3 "Stampa Ricavi prima dei Costi"
|
||||
END
|
||||
|
||||
SPREADSHEET F_RIGHE -1 -4
|
||||
BEGIN
|
||||
PROMPT 0 4 "Centro di Costo / Commessa / Fase"
|
||||
PROMPT 0 5 "Centro di Costo / Commessa / Fase"
|
||||
ITEM "Cdc1"
|
||||
ITEM "Cdc2"
|
||||
ITEM "Cdc3"
|
||||
|
@ -138,7 +138,7 @@ MESSAGE RESET,F1.102</prescript>
|
||||
</field>
|
||||
</section>
|
||||
<section repeat="1" type="Head" level="2" height="2">
|
||||
<groupby>CONTO</groupby>
|
||||
<groupby>ORDCONT+CONTO</groupby>
|
||||
<font italic="1" face="Courier New" size="8" />
|
||||
<prescript description="H2 PRESCRIPT">MESSAGE RESET,F2.101
|
||||
MESSAGE RESET,F2.102
|
||||
|
Loading…
x
Reference in New Issue
Block a user