Patch level :2.2 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento :prosegue la stampa del pagato; adesso da' un tignoso problema mettendo un breakpoint nella find_commesse_cg git-svn-id: svn://10.65.10.50/trunk@13838 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
bf12e004e5
commit
624fa873f0
719
ca/ca3600.cpp
719
ca/ca3600.cpp
@ -161,7 +161,7 @@ void TPag_per_cms_mask::config_loader(TSheet_field& sf, const char* paragrafo)
|
||||
|
||||
TString_array conti;
|
||||
|
||||
int n = configfile.list_variables(conti, false, paragrafo, true);
|
||||
configfile.list_variables(conti, false, paragrafo, true);
|
||||
FOR_EACH_ARRAY_ROW(conti, i, row)
|
||||
{
|
||||
sf.row(-1) = configfile.get(*row); //carica la riga del .ini senza il contatore
|
||||
@ -199,7 +199,7 @@ class TPag_per_cms_recordset : public TISAM_recordset
|
||||
protected:
|
||||
TDate _dadata, _adata;
|
||||
long _codfor;
|
||||
TString8 _campodata;
|
||||
TString16 _campodata;
|
||||
TString _codcosto, _codcms, _codfas;
|
||||
TAssoc_array _costi,_pagamenti,_fiscali,_sociali; //array che contengono i conti letti dal .ini
|
||||
|
||||
@ -213,9 +213,9 @@ protected:
|
||||
static bool mov_callback(const TRelation& rel, void* pJolly);
|
||||
long find_movimento(const TRectype& riga_pag) const;
|
||||
void find_commesse(const long nreg, const TRectype& riga_pag);
|
||||
void find_commesse_cg(const long nreg);
|
||||
void find_commesse_cg(const TRectype& mov);
|
||||
bool check_cms_cdc_fsc(const TRectype& rec_analriga);
|
||||
TString create_isam_query(const long nreg);
|
||||
const TString& query_movama_by_numregcg(const long nreg);
|
||||
void lettura_conti(TAssoc_array& assoc, const char tipoconto);
|
||||
int cerca_riga_fattura_origine(const TPartita& match, const TRectype& riga_pag);
|
||||
real totale_documento(const TRectype& mov) const;
|
||||
@ -228,10 +228,10 @@ protected:
|
||||
bool cerca_sociali(const TBill& bill) const;
|
||||
|
||||
public:
|
||||
virtual void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor);
|
||||
virtual void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor, const TString& campodata);
|
||||
virtual void set_custom_filter(TCursor& cur) const;
|
||||
void scan_pags(const TPag_per_cms_mask& msk);
|
||||
void scan_movs(const TPag_per_cms_mask& msk);
|
||||
void scan_pags();
|
||||
void scan_movs();
|
||||
|
||||
TPag_per_cms_recordset(const TString& sql) : TISAM_recordset(sql) { _tmp = NULL;}
|
||||
~TPag_per_cms_recordset();
|
||||
@ -255,14 +255,18 @@ void TPag_per_cms_recordset::set_custom_filter(TCursor& cur) const
|
||||
|
||||
//filtro sulla data(non avendo anche codnum non ho la chiave completa per mettere la data nella setregion)
|
||||
TString filtro;
|
||||
TString80 f;
|
||||
if (_dadata.ok())
|
||||
filtro << "(ANSI(DATA)>=" << _dadata << ")";
|
||||
|
||||
{
|
||||
f.format("(ANSI(%s)>=\"%s\")", (const char*)_campodata, _dadata.string(ANSI));
|
||||
filtro << f;
|
||||
}
|
||||
if (_adata.ok())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(ANSI(DATA)<=" << _adata << ")";
|
||||
f.format("(ANSI(%s)<=\"%s\")", (const char*)_campodata, _adata.string(ANSI));
|
||||
filtro << f;
|
||||
}
|
||||
|
||||
cur.setregion(darec, arec);
|
||||
@ -301,12 +305,14 @@ const TVariant& TPag_per_cms_recordset::get(const char* column_name) const
|
||||
|
||||
void TPag_per_cms_recordset::crea_trr(const TFilename& trr) const
|
||||
{
|
||||
TString chiave;
|
||||
ofstream of(trr);
|
||||
of << 1000 << endl;
|
||||
of << 15 << endl;
|
||||
of << 16 << endl;
|
||||
of << "CODFORN|3|6|0|Codice fornitore" << endl;
|
||||
of << "DESFORN|1|50|0|Descrizione fornitore" << endl;
|
||||
of << "NREG|3|7|0|Numero registrazione" << endl;
|
||||
of << "DATAREG|5|8|0|Data registrazione" << endl;
|
||||
of << "DATAPAG|5|8|0|Data pagamento" << endl;
|
||||
of << "DESCRPAG|1|50|0|Descrizione pagamento" << endl;
|
||||
of << "NDOC|1|6|0|Numero documento" << endl;
|
||||
@ -320,7 +326,10 @@ void TPag_per_cms_recordset::crea_trr(const TFilename& trr) const
|
||||
of << "FSC|1|10|0|Fase" << endl;
|
||||
of << "HIDDEN|8|1|0|Record nascosto" << endl;
|
||||
of << 1 << endl;
|
||||
of << "CODFORN+FSC+NREG+DATAPAG" << endl;
|
||||
//l'ordinamento dipende dal tipo di data selezionato sulla maschera
|
||||
chiave << "CODFORN+FSC+NREG+";
|
||||
chiave << _campodata;
|
||||
of << chiave << endl;
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::lettura_conti(TAssoc_array& assoc, const char tipoconto)
|
||||
@ -507,64 +516,98 @@ long TPag_per_cms_recordset::find_movimento(const TRectype& riga_pag) const
|
||||
|
||||
//prepara gli oggetti (_righecosti,_righepagamenti) contenenti le righe dei pagamenti..
|
||||
//..senza saldaconto
|
||||
void TPag_per_cms_recordset::find_commesse_cg(const long nreg)
|
||||
void TPag_per_cms_recordset::find_commesse_cg(const TRectype& mov)
|
||||
{
|
||||
const long numregcg = mov.get_long(MOV_NUMREG);
|
||||
// if (numregcg == 1039)
|
||||
// warning_box("movimento rompico...");
|
||||
//cerca un record di MOVANA che abbia numregcg = nreg;usa il nuovo metodo fighissimo..
|
||||
//..con la isam query implementato nella create_isam_query()
|
||||
TISAM_recordset movana(create_isam_query(nreg));
|
||||
//..con la isam query implementato nella query_movama_by_numregcg()
|
||||
TISAM_recordset movana(query_movama_by_numregcg(numregcg));
|
||||
const TRecnotype items = movana.items();
|
||||
|
||||
for (TRecnotype i = 0; movana.move_to(i); i++)
|
||||
if (items > 0)
|
||||
{
|
||||
const long numregcg = movana.get(MOVANA_NUMREGCG).as_int();
|
||||
//se trova il record cercato in MOVANA...
|
||||
if (numregcg == nreg)
|
||||
if (items > 1)
|
||||
error_box(TR("Esiste piu' di un movimento analitico collegato al movimento contabile %ld"),numregcg);
|
||||
|
||||
movana.move_last(); //si posiziona sul record corretto
|
||||
//prepara il record tmpcurr sul file temporaneo _tmp su cui registrare i dati da stampare
|
||||
TRectype& tmpcurr = _tmp->curr();
|
||||
tmpcurr.zero();
|
||||
|
||||
//crea il movana legato al mov
|
||||
const TAnal_mov anal_mov(mov);
|
||||
const TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
for (int j = 1; j <= anal_rows.rows(); j++) //scansiona righe analitiche..
|
||||
{
|
||||
//prepara il record tmpcurr sul file temporaneo _tmp su cui registrare i dati da stampare
|
||||
TRectype& tmpcurr = _tmp->curr();
|
||||
tmpcurr.zero();
|
||||
|
||||
//trova le RMOVANA del MOVANA corrente che hanno il conto = a quello della i-esima rigaiva
|
||||
TAnal_mov anal_mov(nreg);
|
||||
TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
if (anal_rows.rows() > 0) //se il movana ha righe...
|
||||
const TRectype& anal_row = anal_rows[j];
|
||||
if (check_cms_cdc_fsc(anal_row))
|
||||
{
|
||||
for (int j = 1; j <= anal_rows.rows(); j++) //scansiona righe analitiche..
|
||||
//prende il conto sulla riga analitica e lo confronta con quelli della configurazione
|
||||
const TString& conto_riga_analitica = anal_row.get(RMOVANA_CODCONTO);
|
||||
const int gruppo_anal = atoi(conto_riga_analitica.left(3));
|
||||
const int conto_anal = atoi(conto_riga_analitica.mid(3,3));
|
||||
const long sottoconto_anal = atol(conto_riga_analitica.mid(6,6));
|
||||
|
||||
const TBill conto(gruppo_anal, conto_anal, sottoconto_anal);
|
||||
if (cerca_costo(conto) || cerca_pagamento(conto))
|
||||
{
|
||||
const char sezione = anal_row.get_char(RMOVANA_SEZIONE);
|
||||
const real valore = anal_row.get_real(RMOVANA_IMPORTO);
|
||||
const TImporto imp(sezione, valore);
|
||||
|
||||
if (check_cms_cdc_fsc(anal_rows[j]))
|
||||
{
|
||||
//prende il conto sulla riga analitica e lo confronta con quello della riga iva
|
||||
const int gruppo_anal = atoi(anal_rows[j].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[j].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[j].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
//deve aggiungere ora al file temporaneo il record
|
||||
// campi del pagamento che vanno spediti nel file temporaneo
|
||||
//codice fornitore e descrizione
|
||||
const TString8 codforn = mov.get(MOV_CODCF);
|
||||
tmpcurr.put("CODFORN", codforn);
|
||||
TString16 keyclifo;
|
||||
keyclifo.format("%s|%d", "F", codforn);
|
||||
const TRectype& rec_clifo = cache().get(LF_CLIFO, keyclifo);
|
||||
TString80 desforn = rec_clifo.get(CLI_RAGSOC);
|
||||
tmpcurr.put("DESFORN", desforn);
|
||||
|
||||
const TBill conto(gruppo_anal, conto_anal, sottoconto_anal);
|
||||
if (cerca_costo(conto) || cerca_pagamento(conto))
|
||||
{
|
||||
const char sezione = anal_rows[j].get_char(RMOVANA_SEZIONE);
|
||||
const real valore = anal_rows[j].get_real(RMOVANA_IMPORTO);
|
||||
const TImporto imp(sezione, valore);
|
||||
}
|
||||
}
|
||||
} //for(j<anal_rows...
|
||||
} //if(anal_rows>0...
|
||||
} //if(numregcg==nreg...
|
||||
} //for(TRecnotype...
|
||||
//nreg,data pagamento,descrizione pagamento
|
||||
tmpcurr.put("NREG", numregcg);
|
||||
tmpcurr.put("DATAREG", mov.get_date(MOV_DATAREG));
|
||||
|
||||
//documento origine
|
||||
tmpcurr.put("NDOC", mov.get_long(MOV_NUMDOC));
|
||||
tmpcurr.put("DATADOC", mov.get_date(MOV_DATADOC));
|
||||
tmpcurr.put("PROT", mov.get_long(MOV_PROTIVA));
|
||||
tmpcurr.put("TOTDOC", mov.get_real(MOV_TOTDOC));
|
||||
//tmpcurr.put("TOTPAG", distributore.get()); //pagamento nella partita
|
||||
// tmpcurr.put("TOTRES", ); //pagamenti precedenti al
|
||||
|
||||
//campi relativi a cdc,commessa,fase
|
||||
tmpcurr.put("CMS",anal_row.get(RMOVANA_CODCMS));
|
||||
tmpcurr.put("CDC",anal_row.get(RMOVANA_CODCCOSTO));
|
||||
tmpcurr.put("FSC",anal_row.get(RMOVANA_CODFASE));
|
||||
// tmpcurr.put("IMPCMS",impcms);
|
||||
|
||||
//e finalmente aggiunge il record al file temporaneo
|
||||
_tmp->write();
|
||||
|
||||
}
|
||||
}
|
||||
} //for(j<anal_rows...
|
||||
|
||||
} //if(items>0...
|
||||
}
|
||||
|
||||
bool TPag_per_cms_recordset::mov_callback(const TRelation& rel, void* pJolly)
|
||||
{
|
||||
TPag_per_cms_recordset* recordset = (TPag_per_cms_recordset*)pJolly;
|
||||
const long nreg = rel.curr().get_long(MOV_NUMREG);
|
||||
recordset->find_commesse_cg(nreg);
|
||||
recordset->find_commesse_cg(rel.curr());
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::scan_movs(const TPag_per_cms_mask& msk)
|
||||
void TPag_per_cms_recordset::scan_movs()
|
||||
{
|
||||
if (_campodata == PART_DATAPAG) // I movimenti non hanno DATAPAG
|
||||
_campodata = PART_DATAREG;
|
||||
_campodata = MOV_DATAREG;
|
||||
|
||||
TString filtro = "(REG==\"\")&&(TIPOMOV==\"\")";
|
||||
|
||||
@ -595,10 +638,6 @@ void TPag_per_cms_recordset::scan_movs(const TPag_per_cms_mask& msk)
|
||||
TCursor cur(&rel, filtro, 2, &darec, &arec);
|
||||
cur.scan(mov_callback, this, "Movimenti senza saldaconto...");
|
||||
|
||||
/* crea_righe_stampa(_righecosti, 1);
|
||||
crea_righe_stampa(_righepagamenti, 2);
|
||||
crea_righe_stampa(_righefiscali, 3);
|
||||
crea_righe_stampa(_righesociali, 4);*/
|
||||
}
|
||||
|
||||
bool TPag_per_cms_recordset::check_cms_cdc_fsc(const TRectype& rec_analriga)
|
||||
@ -613,15 +652,12 @@ bool TPag_per_cms_recordset::check_cms_cdc_fsc(const TRectype& rec_analriga)
|
||||
return true;
|
||||
}
|
||||
|
||||
TString TPag_per_cms_recordset::create_isam_query(const long nreg)
|
||||
const TString& TPag_per_cms_recordset::query_movama_by_numregcg(const long nreg)
|
||||
{
|
||||
TString query, strnreg;
|
||||
strnreg.format("%07ld", nreg);
|
||||
|
||||
TString& query = get_tmp_string();
|
||||
query << "USE MOVANA KEY 3\n";
|
||||
query << "WHERE NUMREGCG=";
|
||||
query << strnreg;
|
||||
query << "\n";
|
||||
query << "FROM NUMREGCG=" << nreg << "\n";
|
||||
query << "TO NUMREGCG=" << nreg;
|
||||
return query;
|
||||
}
|
||||
|
||||
@ -630,291 +666,294 @@ TString TPag_per_cms_recordset::create_isam_query(const long nreg)
|
||||
void TPag_per_cms_recordset::find_commesse(const long nreg, const TRectype& riga_pag)
|
||||
{
|
||||
//cerca un record di MOVANA che abbia numregcg = nreg;usa il nuovo metodo fighissimo..
|
||||
//..con la isam query implementato nella create_isam_query()
|
||||
TISAM_recordset movana(create_isam_query(nreg));
|
||||
//..con la isam query implementato nella query_movama_by_numregcg()
|
||||
TISAM_recordset movana(query_movama_by_numregcg(nreg));
|
||||
const TRecnotype items = movana.items();
|
||||
|
||||
for (TRecnotype i = 0; movana.move_to(i); i++)
|
||||
if (items > 0)
|
||||
{
|
||||
const long numregcg = movana.get(MOVANA_NUMREGCG).as_int();
|
||||
//se trova il record cercato in MOVANA...
|
||||
if (numregcg == nreg)
|
||||
if (items > 1)
|
||||
error_box(TR("Esiste piu' di un movimento analitico collegato al movimento contabile %ld"),nreg);
|
||||
|
||||
movana.move_last(); //si posiziona sul record corretto
|
||||
//prepara il record tmpcurr sul file temporaneo _tmp su cui registrare i dati da stampare
|
||||
TRectype& tmpcurr = _tmp->curr();
|
||||
tmpcurr.zero();
|
||||
|
||||
//crea un movimento p.n. con il numero reg che viene passato al metodo (nreg relativo..
|
||||
//..ad un movimento della fattura originaria)
|
||||
TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
if (pn.read() == NOERR)
|
||||
{
|
||||
//prepara il record tmpcurr sul file temporaneo _tmp su cui registrare i dati da stampare
|
||||
TRectype& tmpcurr = _tmp->curr();
|
||||
tmpcurr.zero();
|
||||
const TRectype& movfat = pn.curr();
|
||||
|
||||
//crea un movimento p.n. con il numero reg che viene passato al metodo (nreg relativo..
|
||||
//..ad un movimento della fattura originaria)
|
||||
TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
if (pn.read() == NOERR)
|
||||
real totdoc_cms;
|
||||
real totdoc, totdoc_netto;
|
||||
TAssoc_array commesse;
|
||||
|
||||
//Movimenti CON SALDACONTO
|
||||
//se movimento IVA..
|
||||
if (pn.iva_items() > 0)
|
||||
{
|
||||
const TRectype& movfat = pn.curr();
|
||||
|
||||
real totdoc_cms;
|
||||
real totdoc, totdoc_netto;
|
||||
TAssoc_array commesse;
|
||||
|
||||
//Movimenti CON SALDACONTO
|
||||
//se movimento IVA..
|
||||
if (pn.iva_items() > 0)
|
||||
for (int j = 0; j < pn.iva_items(); j++)
|
||||
{
|
||||
for (int j = 0; j < pn.iva_items(); j++)
|
||||
const TRectype& rmoviva = pn.iva(j);
|
||||
const TBill zio(rmoviva);
|
||||
//il tutto si fa solo se l'indicatore di bilancio del conto nella riga iva e' != 5
|
||||
if (zio.indicatore_bilancio() != 5)
|
||||
{
|
||||
const TRectype& rmoviva = pn.iva(j);
|
||||
const TBill zio(rmoviva);
|
||||
//il tutto si fa solo se l'indicatore di bilancio del conto nella riga iva e' != 5
|
||||
if (zio.indicatore_bilancio() != 5)
|
||||
//e vediamo 'sto conto della riga iva..
|
||||
const int gruppo_iva = zio.gruppo();
|
||||
const int conto_iva = zio.conto();
|
||||
const long sottoconto_iva = zio.sottoconto();
|
||||
|
||||
//crea il movana legato al moviva
|
||||
const TAnal_mov anal_mov(rmoviva);
|
||||
//trova le RMOVANA del MOVANA corrente che hanno il conto = a quello della i-esima rigaiva
|
||||
TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
if (anal_rows.rows() > 0) //se il movana ha righe...
|
||||
{
|
||||
//e vediamo 'sto conto della riga iva..
|
||||
const int gruppo_iva = zio.gruppo();
|
||||
const int conto_iva = zio.conto();
|
||||
const long sottoconto_iva = zio.sottoconto();
|
||||
real imponibile_iva = rmoviva.get_real(RMI_IMPONIBILE);
|
||||
real imposta_iva = rmoviva.get_real(RMI_IMPOSTA);
|
||||
const real lordo_iva = imponibile_iva + imposta_iva;
|
||||
//distributore per il lordo iva (che sara' distribuito successivamente in base..
|
||||
//..agli importi delle righe analitiche corretti per le % iva
|
||||
TGeneric_distrib agip (lordo_iva, TCurrency::get_firm_dec());
|
||||
|
||||
//trova le RMOVANA del MOVANA corrente che hanno il conto = a quello della i-esima rigaiva
|
||||
TAnal_mov anal_mov(rmoviva);
|
||||
TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
if (anal_rows.rows() > 0) //se il movana ha righe...
|
||||
for (int k = 1; k <= anal_rows.rows(); k++) //scansiona righe analitiche..
|
||||
{
|
||||
real imponibile_iva = rmoviva.get_real(RMI_IMPONIBILE);
|
||||
real imposta_iva = rmoviva.get_real(RMI_IMPOSTA);
|
||||
const real lordo_iva = imponibile_iva + imposta_iva;
|
||||
//distributore per il lordo iva (che sara' distribuito successivamente in base..
|
||||
//..agli importi delle righe analitiche corretti per le % iva
|
||||
TGeneric_distrib agip (lordo_iva, TCurrency::get_firm_dec());
|
||||
|
||||
for (int k = 1; k <= anal_rows.rows(); k++) //scansiona righe analitiche..
|
||||
real perc_ded_iva = UNO; //%iva deducibile (di default 100, a meno del prorata)
|
||||
if (imposta_iva != ZERO)
|
||||
{
|
||||
real perc_ded_iva = UNO; //%iva deducibile (di default 100, a meno del prorata)
|
||||
if (imposta_iva != ZERO)
|
||||
//controllo prorata
|
||||
const TString80 commessa_riga_anal = anal_rows[k].get(RMOVANA_CODCMS);
|
||||
const TRectype& pla = cache().get(LF_COMMESSE, commessa_riga_anal);
|
||||
const bool prorata = pla.get_bool("PRORATA");
|
||||
if (prorata)
|
||||
{
|
||||
//controllo prorata
|
||||
const TString80 commessa_riga_anal = anal_rows[k].get(RMOVANA_CODCMS);
|
||||
const TRectype& pla = cache().get(LF_COMMESSE, commessa_riga_anal);
|
||||
const bool prorata = pla.get_bool("PRORATA");
|
||||
if (prorata)
|
||||
const TDate datareg = pn.curr().get_date(MOV_DATAREG);
|
||||
const int anno = datareg.year();
|
||||
TRegistro registro(pn.curr().get(MOV_REG), anno);
|
||||
//%deducibilità iva rivista con il prorata
|
||||
perc_ded_iva = (CENTO - registro.prorata(anno))/CENTO;
|
||||
imposta_iva.round(TCurrency::get_firm_dec()); //ci vanno i decimali della ditta
|
||||
}
|
||||
} //if imposta_iva...
|
||||
|
||||
//prende il conto sulla riga analitica e lo confronta con quello della riga iva
|
||||
const int gruppo_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[k].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
|
||||
//il codconto anale e iva coincidono?..
|
||||
if (gruppo_iva == gruppo_anal && conto_iva == conto_anal && sottoconto_iva == sottoconto_anal)
|
||||
{
|
||||
//..in tal caso aggiunge l'importo della riga analitica al distributore, dopo..
|
||||
//..averlo corretto in base alle % precedentemente calcolate
|
||||
real importo_anal = anal_rows[k].get_real(RMOVANA_IMPORTO);
|
||||
const real perc_iva = imposta_iva / imponibile_iva;
|
||||
const real perc_corretta_iva = perc_iva * (UNO - perc_ded_iva);
|
||||
importo_anal = importo_anal * (UNO - perc_corretta_iva);
|
||||
|
||||
agip.add(importo_anal);
|
||||
} //if(gruppo_iva==...
|
||||
} //for (anal_rows...
|
||||
|
||||
for (int l = 1; l <= anal_rows.rows(); l++) //..allora le scansiona..
|
||||
{
|
||||
//prende il conto sulla riga analitica e lo confronta con quello della riga iva
|
||||
const int gruppo_anal = atoi(anal_rows[l].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[l].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[l].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
|
||||
//il codconto anale e iva coincidono?
|
||||
if (gruppo_iva == gruppo_anal && conto_iva == conto_anal && sottoconto_iva == sottoconto_anal)
|
||||
{
|
||||
//impoerto
|
||||
real importo = agip.get();
|
||||
//commessa,cdc,fase della riga analitica devono essere coincidenti con quelle dello sheet
|
||||
if (check_cms_cdc_fsc(anal_rows[l]))
|
||||
{
|
||||
//costruzione dell'assoc_array 'commesse' con cms/cdc/fsc ed importi
|
||||
TToken_string cms_cdc_fsc;
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODCMS));
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODCCOSTO));
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODFASE));
|
||||
|
||||
real* imp = (real*)commesse.objptr(cms_cdc_fsc);
|
||||
//aggiunge un elemento all'assoc_array...
|
||||
if (imp == NULL)
|
||||
{
|
||||
const TDate datareg = pn.curr().get_date(MOV_DATAREG);
|
||||
const int anno = datareg.year();
|
||||
TRegistro registro(pn.curr().get(MOV_REG), anno);
|
||||
//%deducibilità iva rivista con il prorata
|
||||
perc_ded_iva = (CENTO - registro.prorata(anno))/CENTO;
|
||||
imposta_iva.round(TCurrency::get_firm_dec()); //ci vanno i decimali della ditta
|
||||
imp = new real;
|
||||
commesse.add(cms_cdc_fsc, imp);
|
||||
}
|
||||
} //if imposta_iva...
|
||||
*imp += importo;
|
||||
totdoc_cms += importo;
|
||||
|
||||
//prende il conto sulla riga analitica e lo confronta con quello della riga iva
|
||||
const int gruppo_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[k].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
} //if check_cms_cdc_fsc...
|
||||
|
||||
//il codconto anale e iva coincidono?..
|
||||
if (gruppo_iva == gruppo_anal && conto_iva == conto_anal && sottoconto_iva == sottoconto_anal)
|
||||
{
|
||||
//..in tal caso aggiunge l'importo della riga analitica al distributore, dopo..
|
||||
//..averlo corretto in base alle % precedentemente calcolate
|
||||
real importo_anal = anal_rows[k].get_real(RMOVANA_IMPORTO);
|
||||
const real perc_iva = imposta_iva / imponibile_iva;
|
||||
const real perc_corretta_iva = perc_iva * (UNO - perc_ded_iva);
|
||||
importo_anal = importo_anal * (UNO - perc_corretta_iva);
|
||||
} //if(gruppo_iva==...
|
||||
|
||||
agip.add(importo_anal);
|
||||
} //if(gruppo_iva==...
|
||||
} //for (anal_rows...
|
||||
} //for (anal_rows...
|
||||
|
||||
for (int l = 1; l <= anal_rows.rows(); l++) //..allora le scansiona..
|
||||
{
|
||||
//prende il conto sulla riga analitica e lo confronta con quello della riga iva
|
||||
const int gruppo_anal = atoi(anal_rows[l].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[l].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[l].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
} //if anal_rows() > 0...
|
||||
} //if indicatore_bilancio!=5...
|
||||
|
||||
//il codconto anale e iva coincidono?
|
||||
if (gruppo_iva == gruppo_anal && conto_iva == conto_anal && sottoconto_iva == sottoconto_anal)
|
||||
{
|
||||
//impoerto
|
||||
real importo = agip.get();
|
||||
//commessa,cdc,fase della riga analitica devono essere coincidenti con quelle dello sheet
|
||||
if (check_cms_cdc_fsc(anal_rows[l]))
|
||||
{
|
||||
//costruzione dell'assoc_array 'commesse' con cms/cdc/fsc ed importi
|
||||
TToken_string cms_cdc_fsc;
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODCMS));
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODCCOSTO));
|
||||
cms_cdc_fsc.add(anal_rows[l].get(RMOVANA_CODFASE));
|
||||
} //for (pn.iva_items(...
|
||||
|
||||
real* imp = (real*)commesse.objptr(cms_cdc_fsc);
|
||||
//aggiunge un elemento all'assoc_array...
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new real;
|
||||
commesse.add(cms_cdc_fsc, imp);
|
||||
}
|
||||
*imp += importo;
|
||||
totdoc_cms += importo;
|
||||
|
||||
} //if check_cms_cdc_fsc...
|
||||
|
||||
} //if(gruppo_iva==...
|
||||
|
||||
} //for (anal_rows...
|
||||
|
||||
} //if anal_rows() > 0...
|
||||
} //if indicatore_bilancio!=5...
|
||||
|
||||
} //for (pn.iva_items(...
|
||||
|
||||
totdoc = totale_documento(pn.curr()); //tot doc con ritenute fiscali + ritenute sociali (da stampare)
|
||||
totdoc_netto = pn.curr().get_real(MOV_TOTDOC); //questo si usa solo per il calcolo del residuo
|
||||
} //if(pn.iva_items(...
|
||||
else //..movimento NON iva (sempre con saldaconto)
|
||||
totdoc = totale_documento(pn.curr()); //tot doc con ritenute fiscali + ritenute sociali (da stampare)
|
||||
totdoc_netto = pn.curr().get_real(MOV_TOTDOC); //questo si usa solo per il calcolo del residuo
|
||||
} //if(pn.iva_items(...
|
||||
else //..movimento NON iva (sempre con saldaconto)
|
||||
{
|
||||
for (int j = 0; j < pn.cg_items(); j++)
|
||||
{
|
||||
for (int j = 0; j < pn.cg_items(); j++)
|
||||
const TRectype& rmov = pn.cg(j);
|
||||
const TBill zio_cg(rmov);
|
||||
|
||||
TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
|
||||
importo.normalize('D');
|
||||
|
||||
if (zio_cg.tipo() > ' ')
|
||||
{
|
||||
const TRectype& rmov = pn.cg(j);
|
||||
const TBill zio_cg(rmov);
|
||||
|
||||
TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
|
||||
importo.normalize('D');
|
||||
|
||||
if (zio_cg.tipo() > ' ')
|
||||
{
|
||||
totdoc -= importo.valore();
|
||||
totdoc_netto -= importo.valore(); //valore per il calcolo del residuo
|
||||
}
|
||||
else
|
||||
if (cerca_fiscali(zio_cg) || cerca_sociali(zio_cg))
|
||||
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
} //for j < pn.cg_items...
|
||||
|
||||
TAnal_mov anal_mov(nreg);
|
||||
TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
if (anal_rows.rows() > 0) //se il movana ha righe...
|
||||
{
|
||||
|
||||
for (int k = 1; k <= anal_rows.rows(); k++) //..allora le scansiona..
|
||||
{
|
||||
//prende gr/co/sott sulla riga analitica...
|
||||
const int gruppo_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[k].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
//..e crea il conto contabile corrispondente
|
||||
TBill conto_cg(gruppo_anal, conto_anal, sottoconto_anal);
|
||||
|
||||
//l'indicatore di bilancio del conto contabile appena creato e' valido?
|
||||
if (conto_cg.indicatore_bilancio() != 5)
|
||||
{
|
||||
const real importo_anal = anal_rows[k].get_real(RMOVANA_IMPORTO);
|
||||
|
||||
//costruzione dell'assoc_array 'commesse' con cms/cdc/fsc ed importi
|
||||
TToken_string cms_cdc_fsc;
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODCMS));
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODCCOSTO));
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODFASE));
|
||||
|
||||
real* imp = (real*)commesse.objptr(cms_cdc_fsc);
|
||||
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new real;
|
||||
commesse.add(cms_cdc_fsc, imp);
|
||||
}
|
||||
|
||||
TImporto importo(anal_rows[k].get_char(RMOVANA_SEZIONE), anal_rows[k].get_real(RMOVANA_IMPORTO));
|
||||
importo.normalize('D');
|
||||
|
||||
*imp += importo.valore();
|
||||
totdoc_cms += importo.valore();
|
||||
} //if(conto_cg.indicatore...
|
||||
} //for(k<anal_rows...
|
||||
} //if(anal_rows>0...
|
||||
} //else (pn.iva_items(...
|
||||
|
||||
//parte comune a movimenti IVA e non (vengono anche qui considerate le ritenute fiscali
|
||||
//e sociali perche' possono essere state inserite direttamente nella partita e non nel movimento
|
||||
//(quindi non si puo' in questo caso applicare la totale_documento()
|
||||
//Le ritenute fiscali vanno sempre sommate..
|
||||
real totpagato = riga_pag.get_real(PART_IMPORTO) + riga_pag.get_real(PART_RITENUTE);
|
||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||
const real ritsoc = riga_pag.get_real(PART_RITSOC);
|
||||
if (!ritsoc.is_zero())
|
||||
{
|
||||
const TRectype& mov = pn.curr();
|
||||
TCausale caus(mov.get(MOV_CODCAUS));
|
||||
const bool swapt = test_swap(caus, false); // Totale invertito ?
|
||||
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ?
|
||||
if (swapt ^ swaps) // Somma ritenute sociali con segno
|
||||
totpagato -= ritsoc;
|
||||
else
|
||||
totpagato += ritsoc;
|
||||
}
|
||||
|
||||
const real percentuale = totpagato / totdoc_netto;
|
||||
|
||||
//calcolo del residuo (solo movimenti saldacontati)
|
||||
//mi servono,dalla riga partita che viene passata,i valori dei campi per la chiave del
|
||||
//file delle scadenze
|
||||
const TPartita match(riga_pag);
|
||||
//ci serve la riga di fattura che origina la nostra riga pagamento
|
||||
const int riga_fatt = cerca_riga_fattura_origine(match, riga_pag);
|
||||
//quanto era stato pagato del documento prima della attuale riga_pag
|
||||
const real totpagato_prec = calcola_pagato_prec(match, riga_fatt, riga_pag);
|
||||
const real perc_prec = totpagato_prec / totdoc_netto;
|
||||
|
||||
TGeneric_distrib distributore(totdoc_cms * percentuale, TCurrency::get_firm_dec());
|
||||
TGeneric_distrib distributore_prec(totdoc_cms * perc_prec, TCurrency::get_firm_dec());
|
||||
{
|
||||
FOR_EACH_ASSOC_OBJECT(commesse, h, k, imp)
|
||||
{
|
||||
const real& impcms = *(real*)imp;
|
||||
distributore.add(impcms);
|
||||
distributore_prec.add(impcms); //distributore di importo pagato sulle commesse
|
||||
totdoc -= importo.valore();
|
||||
totdoc_netto -= importo.valore(); //valore per il calcolo del residuo
|
||||
}
|
||||
}
|
||||
else
|
||||
if (cerca_fiscali(zio_cg) || cerca_sociali(zio_cg))
|
||||
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
} //for j < pn.cg_items...
|
||||
|
||||
TAnal_mov anal_mov(nreg);
|
||||
TRecord_array& anal_rows = anal_mov.body();
|
||||
|
||||
if (anal_rows.rows() > 0) //se il movana ha righe...
|
||||
{
|
||||
|
||||
for (int k = 1; k <= anal_rows.rows(); k++) //..allora le scansiona..
|
||||
{
|
||||
//prende gr/co/sott sulla riga analitica...
|
||||
const int gruppo_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).left(3));
|
||||
const int conto_anal = atoi(anal_rows[k].get(RMOVANA_CODCONTO).mid(3,3));
|
||||
const long sottoconto_anal = atol(anal_rows[k].get(RMOVANA_CODCONTO).mid(6,6));
|
||||
//..e crea il conto contabile corrispondente
|
||||
TBill conto_cg(gruppo_anal, conto_anal, sottoconto_anal);
|
||||
|
||||
//l'indicatore di bilancio del conto contabile appena creato e' valido?
|
||||
if (conto_cg.indicatore_bilancio() != 5)
|
||||
{
|
||||
const real importo_anal = anal_rows[k].get_real(RMOVANA_IMPORTO);
|
||||
|
||||
//costruzione dell'assoc_array 'commesse' con cms/cdc/fsc ed importi
|
||||
TToken_string cms_cdc_fsc;
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODCMS));
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODCCOSTO));
|
||||
cms_cdc_fsc.add(anal_rows[k].get(RMOVANA_CODFASE));
|
||||
|
||||
real* imp = (real*)commesse.objptr(cms_cdc_fsc);
|
||||
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new real;
|
||||
commesse.add(cms_cdc_fsc, imp);
|
||||
}
|
||||
|
||||
TImporto importo(anal_rows[k].get_char(RMOVANA_SEZIONE), anal_rows[k].get_real(RMOVANA_IMPORTO));
|
||||
importo.normalize('D');
|
||||
|
||||
*imp += importo.valore();
|
||||
totdoc_cms += importo.valore();
|
||||
} //if(conto_cg.indicatore...
|
||||
} //for(k<anal_rows...
|
||||
} //if(anal_rows>0...
|
||||
} //else (pn.iva_items(...
|
||||
|
||||
//parte comune a movimenti IVA e non (vengono anche qui considerate le ritenute fiscali
|
||||
//e sociali perche' possono essere state inserite direttamente nella partita e non nel movimento
|
||||
//(quindi non si puo' in questo caso applicare la totale_documento()
|
||||
//Le ritenute fiscali vanno sempre sommate..
|
||||
real totpagato = riga_pag.get_real(PART_IMPORTO) + riga_pag.get_real(PART_RITENUTE);
|
||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||
const real ritsoc = riga_pag.get_real(PART_RITSOC);
|
||||
if (!ritsoc.is_zero())
|
||||
{
|
||||
const TRectype& mov = pn.curr();
|
||||
TCausale caus(mov.get(MOV_CODCAUS));
|
||||
const bool swapt = test_swap(caus, false); // Totale invertito ?
|
||||
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ?
|
||||
if (swapt ^ swaps) // Somma ritenute sociali con segno
|
||||
totpagato -= ritsoc;
|
||||
else
|
||||
totpagato += ritsoc;
|
||||
}
|
||||
|
||||
const real percentuale = totpagato / totdoc_netto;
|
||||
|
||||
//calcolo del residuo (solo movimenti saldacontati)
|
||||
//mi servono,dalla riga partita che viene passata,i valori dei campi per la chiave del
|
||||
//file delle scadenze
|
||||
const TPartita match(riga_pag);
|
||||
//ci serve la riga di fattura che origina la nostra riga pagamento
|
||||
const int riga_fatt = cerca_riga_fattura_origine(match, riga_pag);
|
||||
//quanto era stato pagato del documento prima della attuale riga_pag
|
||||
const real totpagato_prec = calcola_pagato_prec(match, riga_fatt, riga_pag);
|
||||
const real perc_prec = totpagato_prec / totdoc_netto;
|
||||
|
||||
TGeneric_distrib distributore(totdoc_cms * percentuale, TCurrency::get_firm_dec());
|
||||
TGeneric_distrib distributore_prec(totdoc_cms * perc_prec, TCurrency::get_firm_dec());
|
||||
{
|
||||
FOR_EACH_ASSOC_OBJECT(commesse, h, k, imp)
|
||||
{
|
||||
const real& impcms = *(real*)imp;
|
||||
distributore.add(impcms);
|
||||
distributore_prec.add(impcms); //distributore di importo pagato sulle commesse
|
||||
}
|
||||
}
|
||||
|
||||
// campi del pagamento che vanno spediti nel file temporaneo
|
||||
//codice fornitore e descrizione
|
||||
const long codforn = riga_pag.get_long(PART_SOTTOCONTO);
|
||||
tmpcurr.put("CODFORN", codforn);
|
||||
TString16 keyclifo;
|
||||
keyclifo.format("%s|%d", "F", codforn);
|
||||
const TRectype& rec_clifo = cache().get(LF_CLIFO, keyclifo);
|
||||
TString80 desforn = rec_clifo.get(CLI_RAGSOC);
|
||||
tmpcurr.put("DESFORN", desforn);
|
||||
FOR_EACH_ASSOC_OBJECT(commesse, h, k, imp)
|
||||
{
|
||||
const real& impcms = *(real*)imp;
|
||||
|
||||
//nreg,data pagamento,descrizione pagamento
|
||||
tmpcurr.put("NREG", nreg);
|
||||
tmpcurr.put("DATAPAG", riga_pag.get_date(_campodata));
|
||||
tmpcurr.put("DESCRPAG", riga_pag.get(PART_DESCR));
|
||||
// campi del pagamento che vanno spediti nel file temporaneo
|
||||
//codice fornitore e descrizione
|
||||
const long codforn = riga_pag.get_long(PART_SOTTOCONTO);
|
||||
tmpcurr.put("CODFORN", codforn);
|
||||
TString16 keyclifo;
|
||||
keyclifo.format("%s|%d", "F", codforn);
|
||||
const TRectype& rec_clifo = cache().get(LF_CLIFO, keyclifo);
|
||||
TString80 desforn = rec_clifo.get(CLI_RAGSOC);
|
||||
tmpcurr.put("DESFORN", desforn);
|
||||
|
||||
//documento origine
|
||||
tmpcurr.put("NDOC", movfat.get_long(MOV_NUMDOC));
|
||||
tmpcurr.put("DATADOC", movfat.get_date(MOV_DATADOC));
|
||||
tmpcurr.put("PROT", movfat.get_long(MOV_PROTIVA));
|
||||
tmpcurr.put("TOTDOC", totdoc);
|
||||
tmpcurr.put("TOTPAG", distributore.get()); //pagamento nella partita
|
||||
// tmpcurr.put("TOTRES", ); //pagamenti precedenti al
|
||||
//nreg,data pagamento,descrizione pagamento
|
||||
tmpcurr.put("NREG", nreg);
|
||||
tmpcurr.put("DATAPAG", riga_pag.get_date(PART_DATAPAG));
|
||||
tmpcurr.put("DATAREG", riga_pag.get_date(PART_DATAREG));
|
||||
tmpcurr.put("DESCRPAG", riga_pag.get(PART_DESCR));
|
||||
|
||||
//campi relativi a cdc,commessa,fase
|
||||
TToken_string cdc_cms_fsc = k;
|
||||
tmpcurr.put("CMS",cdc_cms_fsc.get(0));
|
||||
tmpcurr.put("CDC",cdc_cms_fsc.get(1));
|
||||
tmpcurr.put("FSC",cdc_cms_fsc.get(2));
|
||||
// tmpcurr.put("IMPCMS",impcms);
|
||||
//documento origine
|
||||
tmpcurr.put("NDOC", movfat.get_long(MOV_NUMDOC));
|
||||
tmpcurr.put("DATADOC", movfat.get_date(MOV_DATADOC));
|
||||
tmpcurr.put("PROT", movfat.get_long(MOV_PROTIVA));
|
||||
tmpcurr.put("TOTDOC", totdoc);
|
||||
tmpcurr.put("TOTPAG", distributore.get()); //pagamento nella partita
|
||||
//totres = importo da pagare (sulla fattura) - pagamenti precedenti al
|
||||
tmpcurr.put("TOTRES", impcms - distributore_prec.get());
|
||||
|
||||
//e finalmente aggiunge il record al file temporaneo
|
||||
_tmp->write();
|
||||
} //FOR_EACH_...
|
||||
//campi relativi a cdc,commessa,fase
|
||||
TToken_string cdc_cms_fsc = k;
|
||||
tmpcurr.put("CMS",cdc_cms_fsc.get(0));
|
||||
tmpcurr.put("CDC",cdc_cms_fsc.get(1));
|
||||
tmpcurr.put("FSC",cdc_cms_fsc.get(2));
|
||||
|
||||
} //pn.read()...
|
||||
} //if (numregcg==nreg)...
|
||||
} //for TRecnotype...
|
||||
//e finalmente aggiunge il record al file temporaneo
|
||||
_tmp->write();
|
||||
} //FOR_EACH_...
|
||||
|
||||
} //pn.read()...
|
||||
|
||||
} //if (items>0...
|
||||
}
|
||||
|
||||
bool TPag_per_cms_recordset::part_callback(const TRelation& rel, void* pJolly)
|
||||
@ -928,7 +967,7 @@ bool TPag_per_cms_recordset::part_callback(const TRelation& rel, void* pJolly)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::scan_pags(const TPag_per_cms_mask& msk)
|
||||
void TPag_per_cms_recordset::scan_pags()
|
||||
{
|
||||
//costruzione filtro
|
||||
TRectype filtrec(LF_PARTITE);
|
||||
@ -958,7 +997,7 @@ void TPag_per_cms_recordset::scan_pags(const TPag_per_cms_mask& msk)
|
||||
cur.scan(part_callback, this, "Movimenti con saldaconto...");
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor)
|
||||
void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor, const TString& campodata)
|
||||
{
|
||||
//se esiste il file temporano con tracciato persomalizzato lo cancella e lo ricrea vuoto
|
||||
TFilename trr; //file tracciato record
|
||||
@ -969,6 +1008,12 @@ void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int
|
||||
trr.ext("trr");
|
||||
dbf.ext("dbf");
|
||||
|
||||
//scelta tipo data di estrazione (registrazione, documento, pagamento)
|
||||
//deve stare qui per poter generare la chiave del file temporaneo in base al tipo di data di estrazione
|
||||
_campodata = campodata;
|
||||
//stessa cosa per il simpatico codice fornitore
|
||||
_codfor = codfor;
|
||||
|
||||
//crea il file .trr in base ai parametri del metodo
|
||||
crea_trr(trr);
|
||||
//svuota la memoria dal vecchio file temporaneo
|
||||
@ -993,15 +1038,6 @@ void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int
|
||||
_codfas = rel.curr().get(RMOVANA_CODFASE);
|
||||
}
|
||||
|
||||
//scelta tipo data di estrazione (registrazione, documento, pagamento)
|
||||
_campodata = PART_DATAREG;
|
||||
switch(msk.get_int(F_TIPODATA))
|
||||
{
|
||||
case 1:_campodata = PART_DATADOC;break;
|
||||
case 2:_campodata = PART_DATAPAG;break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
//lettura eventuali date limite (il controllo sul loro valore sara' nei metodi di costruzione
|
||||
//dei filtri
|
||||
_dadata = msk.get_date(F_DATAINI);
|
||||
@ -1015,11 +1051,11 @@ void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int
|
||||
lettura_conti(_sociali, 'S');
|
||||
|
||||
//scansione movimenti con saldaconto
|
||||
scan_pags(msk);
|
||||
scan_pags();
|
||||
|
||||
//se c'e' un filtro sui fornitori, non si fa lo scan dei movimenti senza saldaconto
|
||||
if (codfor <= 0)
|
||||
scan_movs(msk);
|
||||
scan_movs();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
@ -1033,7 +1069,7 @@ protected:
|
||||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||||
|
||||
public:
|
||||
void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor);
|
||||
void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor, const TString& campodata);
|
||||
};
|
||||
|
||||
|
||||
@ -1050,7 +1086,7 @@ bool TPag_per_cms_rep::set_recordset(const TString& sql)
|
||||
}
|
||||
|
||||
|
||||
void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor)
|
||||
void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor, const TString& campodata)
|
||||
{
|
||||
TAnal_report::set_recordset(NULL);
|
||||
|
||||
@ -1058,7 +1094,7 @@ void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, const int cms_ro
|
||||
|
||||
TPag_per_cms_recordset* recset = new TPag_per_cms_recordset(query);
|
||||
|
||||
recset->set_filter(msk, cms_row, codfor);
|
||||
recset->set_filter(msk, cms_row, codfor, campodata);
|
||||
TAnal_report::set_recordset(recset);
|
||||
}
|
||||
|
||||
@ -1071,7 +1107,7 @@ void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, const int cms_ro
|
||||
class TPag_per_cms : public TSkeleton_application
|
||||
{
|
||||
public:
|
||||
void stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_book& book, TPag_per_cms_rep& rep, const long codfor);
|
||||
void stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_book& book, TPag_per_cms_rep& rep, const long codfor, const TString& campodata);
|
||||
const TMultilevel_code_info& get_level_one() const;
|
||||
virtual void main_loop();
|
||||
};
|
||||
@ -1085,7 +1121,7 @@ const TMultilevel_code_info& TPag_per_cms::get_level_one() const
|
||||
return ca_multilevel_code_info(logic);
|
||||
}
|
||||
|
||||
void TPag_per_cms::stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_book& book, TPag_per_cms_rep& rep, const long codfor)
|
||||
void TPag_per_cms::stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_book& book, TPag_per_cms_rep& rep, const long codfor, const TString& campodata)
|
||||
{
|
||||
TSheet_field& sheet = mask.sfield(F_RIGHE);
|
||||
TString video_string; //stringa che compare nella progind
|
||||
@ -1111,7 +1147,7 @@ void TPag_per_cms::stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_bo
|
||||
for (int l = liv1.levels()-2; l >= 0; l--) //se la struttura è a più livelli costruisce la tokenstring
|
||||
row.insert("|", liv1.total_len(l));
|
||||
|
||||
rep.set_filter(mask, 0, codfor); //fa la set filter sulla prima riga (che è quella usata)
|
||||
rep.set_filter(mask, 0, codfor, campodata); //fa la set filter sulla prima riga (che è quella usata)
|
||||
book.add(rep);
|
||||
}
|
||||
sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet
|
||||
@ -1120,7 +1156,7 @@ void TPag_per_cms::stampa_per_commessa(const TPag_per_cms_mask& mask, TReport_bo
|
||||
{
|
||||
FOR_EACH_SHEET_ROW(sheet, r, row) //per ogni cdc/cms che appare nello sheet di pag.1 della msk..
|
||||
{
|
||||
rep.set_filter(mask, r, codfor); //..chiama il metodone globale che crea e compila il file..
|
||||
rep.set_filter(mask, r, codfor, campodata); //..chiama il metodone globale che crea e compila il file..
|
||||
//..temporaneo i cui dati riempiranno il report
|
||||
book.add(rep); //aggiunge il report relativo alla cdc/cms corrente al book
|
||||
}
|
||||
@ -1149,6 +1185,17 @@ void TPag_per_cms::main_loop()
|
||||
TPag_per_cms_rep rep;
|
||||
rep.load(path);
|
||||
|
||||
//scelta tipo data di estrazione (registrazione, documento, pagamento)
|
||||
//viene presa qui perche' serve subito alla set_filter del report prima che venga..
|
||||
//..utilizzata nel recordset
|
||||
TString16 campodata = PART_DATAREG;
|
||||
switch(mask.get_int(F_TIPODATA))
|
||||
{
|
||||
case 1:campodata = PART_DATADOC;break;
|
||||
case 2:campodata = PART_DATAPAG;break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
const long dacodfor = mask.get_long(F_DACODFOR);
|
||||
const long acodfor = mask.get_long(F_ACODFOR);
|
||||
|
||||
@ -1163,11 +1210,11 @@ void TPag_per_cms::main_loop()
|
||||
for (bool ok = clifo.move_first(); ok; ok = clifo.move_next())
|
||||
{
|
||||
const long codforn = clifo.get("CODCF").as_int();
|
||||
stampa_per_commessa(mask, book, rep, codforn);
|
||||
stampa_per_commessa(mask, book, rep, codforn, campodata);
|
||||
}
|
||||
}
|
||||
else
|
||||
stampa_per_commessa(mask, book, rep, 0); //se non si specifica alcun clifo...
|
||||
stampa_per_commessa(mask, book, rep, 0, campodata); //se non si specifica alcun clifo...
|
||||
|
||||
book.print_or_preview(); //stampa il book dei report
|
||||
}
|
||||
|
@ -14,17 +14,18 @@
|
||||
<field x="155" type="Numero" align="right" width="3" pattern="1">
|
||||
<source>#REPORT.PAGE</source>
|
||||
</field>
|
||||
<field border="2" x="1" y="2" type="Linea" width="159" height="0" pattern="1" />
|
||||
<field border="2" x="1" y="2" type="Linea" width="160" height="0" pattern="1" />
|
||||
<field x="1" y="3.5" type="Testo" align="right" width="7" pattern="1" text="N. Reg." />
|
||||
<field x="10" y="3.5" type="Testo" align="center" width="11" pattern="1" text="Data pag." />
|
||||
<field x="23" y="3.5" type="Testo" width="25" pattern="1" text="Descrizione pagamento" />
|
||||
<field x="69" y="3.5" type="Testo" align="center" width="7" pattern="1" text="N. doc." />
|
||||
<field x="84" y="3.5" type="Testo" align="center" width="10" pattern="1" text="Data doc." />
|
||||
<field x="97.5" y="3.5" type="Testo" width="5" pattern="1" text="Prot." />
|
||||
<field x="104" y="3.5" type="Testo" align="right" width="18" pattern="1" text="Totale documento" />
|
||||
<field x="123" y="3.5" type="Testo" align="right" width="18" pattern="1" text="Totale pagamento" />
|
||||
<field x="142" y="3.5" type="Testo" align="right" width="18" pattern="1" text="Totale residuo" />
|
||||
<field border="1" x="1" y="4.5" type="Linea" width="159" height="0" pattern="1" />
|
||||
<field x="10" y="3.5" type="Testo" align="center" width="11" pattern="1" text="Data reg." />
|
||||
<field x="21" y="3.5" type="Testo" align="center" width="11" pattern="1" text="Data pag." />
|
||||
<field x="33" y="3.5" type="Testo" width="25" pattern="1" text="Descrizione pagamento" />
|
||||
<field x="79" y="3.5" type="Testo" align="center" width="7" pattern="1" text="N. doc." />
|
||||
<field x="94" y="3.5" type="Testo" align="center" width="10" pattern="1" text="Data doc." />
|
||||
<field x="107.5" y="3.5" type="Testo" width="5" pattern="1" text="Prot." />
|
||||
<field x="114" y="3.5" type="Testo" align="right" width="15" pattern="1" text="Tot. documento" />
|
||||
<field x="130" y="3.5" type="Testo" align="right" width="15" pattern="1" text="Tot. pagamento" />
|
||||
<field x="146" y="3.5" type="Testo" align="right" width="15" pattern="1" text="Tot. residuo" />
|
||||
<field border="1" x="1" y="4.5" type="Linea" width="160" height="0" pattern="1" />
|
||||
</section>
|
||||
<section type="Head" level="1" height="9">
|
||||
<prescript description="H1 PRESCRIPT">MESSAGE RESET,F1.101
|
||||
@ -144,32 +145,35 @@ MESSAGE RESET,F3.103</prescript>
|
||||
<section type="Body" />
|
||||
<section type="Body" level="1">
|
||||
<condition>HIDDEN!='X'</condition>
|
||||
<field x="10" type="Data" width="10" pattern="1">
|
||||
<field x="9" type="Data" width="10" pattern="1">
|
||||
<source>DATAREG</source>
|
||||
</field>
|
||||
<field x="21" type="Data" width="10" pattern="1">
|
||||
<source>DATAPAG</source>
|
||||
</field>
|
||||
<field x="22" type="Stringa" width="50" pattern="1">
|
||||
<field x="33" type="Stringa" width="50" pattern="1">
|
||||
<source>DESCRPAG</source>
|
||||
</field>
|
||||
<field x="74" type="Stringa" width="7" pattern="1">
|
||||
<field x="84" type="Stringa" width="7" pattern="1">
|
||||
<source>NDOC</source>
|
||||
</field>
|
||||
<field x="84" type="Data" width="10" pattern="1">
|
||||
<field x="94" type="Data" width="10" pattern="1">
|
||||
<source>DATADOC</source>
|
||||
</field>
|
||||
<field x="97" type="Numero" align="right" width="5" pattern="1">
|
||||
<field x="107" type="Numero" align="right" width="5" pattern="1">
|
||||
<source>PROT</source>
|
||||
</field>
|
||||
<field x="104" type="Valuta" align="right" width="18" pattern="1" text="###.###.###,@@">
|
||||
<field x="114" type="Valuta" align="right" width="15" pattern="1" text="###.###.###,@@">
|
||||
<source>TOTDOC</source>
|
||||
<postscript description="B1.0 POSTSCRIPT">MESSAGE ADD,F2.101
|
||||
MESSAGE ADD,F3.101</postscript>
|
||||
</field>
|
||||
<field x="123" type="Valuta" align="right" width="18" pattern="1" text="###.###.###,@@">
|
||||
<field x="130" type="Valuta" align="right" width="15" pattern="1" text="###.###.###,@@">
|
||||
<source>TOTPAG</source>
|
||||
<postscript description="B1.0 POSTSCRIPT">MESSAGE ADD,F2.102
|
||||
MESSAGE ADD,F3.102</postscript>
|
||||
</field>
|
||||
<field x="142" type="Valuta" align="right" width="18" pattern="1" text="###.###.###,@@">
|
||||
<field x="146" type="Valuta" align="right" width="15" pattern="1" text="###.###.###,@@">
|
||||
<source>TOTRES</source>
|
||||
<postscript description="B1.0 POSTSCRIPT">MESSAGE ADD,F2.103
|
||||
MESSAGE ADD,F3.103</postscript>
|
||||
@ -200,51 +204,50 @@ MESSAGE ADD,F3.103</postscript>
|
||||
</section>
|
||||
<section type="Foot" />
|
||||
<section type="Foot" level="1">
|
||||
<field border="2" x="1" y="0.5" type="Linea" width="159" height="0" pattern="1" />
|
||||
<field border="2" x="1" y="0.5" type="Linea" width="160" height="0" pattern="1" />
|
||||
<field x="73" y="1" type="Testo" width="30" pattern="1" text="TOTALE PER COMMESSA:">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="104" y="1" type="Valuta" align="right" width="18" id="101" pattern="1" text="###.###.###,@@">
|
||||
<field x="114" y="1" type="Valuta" align="right" width="15" id="101" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="123" y="1" type="Valuta" align="right" width="18" id="102" pattern="1" text="###.###.###,@@">
|
||||
<field x="130" y="1" type="Valuta" align="right" width="15" id="102" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="142" y="1" type="Valuta" align="right" width="18" id="103" pattern="1" text="###.###.###,@@">
|
||||
<field x="146" y="1" type="Valuta" align="right" width="15" id="103" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="2" height="2.5">
|
||||
<field border="1" x="1" y="0.5" type="Linea" width="159" height="0" pattern="1" />
|
||||
<field border="1" x="1" y="0.5" type="Linea" width="160" height="0" pattern="1" />
|
||||
<field x="80" y="1" type="Testo" width="25" pattern="1" text="Totale per fornitore:">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="104" y="1" type="Valuta" align="right" width="18" id="101" pattern="1" text="###.###.###,@@">
|
||||
<field x="114" y="1" type="Valuta" align="right" width="15" id="101" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
<postscript description="F2.101 POSTSCRIPT">MESSAGE ADD,F1.101</postscript>
|
||||
</field>
|
||||
<field x="123" y="1" type="Valuta" align="right" width="18" id="102" pattern="1" text="###.###.###,@@">
|
||||
<field x="130" y="1" type="Valuta" align="right" width="15" id="102" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
<postscript description="F2.102 POSTSCRIPT">MESSAGE ADD,F1.102</postscript>
|
||||
</field>
|
||||
<field x="142" y="1" type="Valuta" align="right" width="18" id="103" pattern="1" text="###.###.###,@@">
|
||||
<field x="146" y="1" type="Valuta" align="right" width="15" id="103" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
<postscript description="F2.103 POSTSCRIPT">MESSAGE ADD,F1.103</postscript>
|
||||
</field>
|
||||
</section>
|
||||
<section type="Foot" level="3">
|
||||
<prescript description="F3 PRESCRIPT">0 #B1.100 !</prescript>
|
||||
<field border="1" x="1" y="0.5" type="Linea" width="159" height="0" pattern="1" />
|
||||
<field x="80" y="1" type="Testo" width="20" pattern="1" text="Totale per fase:">
|
||||
<field x="80" y="0.5" type="Testo" width="20" pattern="1" text="Totale per fase:">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="104" y="1" type="Valuta" align="right" width="18" id="101" pattern="1" text="###.###.###,@@">
|
||||
<field x="114" y="0.5" type="Valuta" align="right" width="15" id="101" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="123" y="1" type="Valuta" align="right" width="18" id="102" pattern="1" text="###.###.###,@@">
|
||||
<field x="130" y="0.5" type="Valuta" align="right" width="15" id="102" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
<field x="142" y="1" type="Valuta" align="right" width="18" id="103" pattern="1" text="###.###.###,@@">
|
||||
<field x="146" y="0.5" type="Valuta" align="right" width="15" id="103" pattern="1" text="###.###.###,@@">
|
||||
<font face="Courier New" bold="1" size="8" />
|
||||
</field>
|
||||
</section>
|
||||
|
@ -940,7 +940,7 @@ const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate&
|
||||
// TAnal_report_mask
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
bool TAnal_report_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
bool TAnal_report_mask::on_field_event(TOperable_field& , TField_event , long )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -950,11 +950,11 @@ int TAnal_report_mask::create_sheet_fields(short sheet_id, int lf, int& y, short
|
||||
TSheet_field& sf = sfield(sheet_id);
|
||||
TMask& sm = sf.sheet_mask();
|
||||
|
||||
const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, dlg+50);
|
||||
const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, short(dlg+50));
|
||||
|
||||
for (int i = 0; i < h; i++)
|
||||
{
|
||||
TEdit_field& fld = sm.efield(dlg+i);
|
||||
TEdit_field& fld = sm.efield(short(dlg+i));
|
||||
int logic = lf;
|
||||
if (logic == LF_FASI)
|
||||
{
|
||||
@ -981,12 +981,12 @@ int TAnal_report_mask::create_sheet_fields(short sheet_id, int lf, int& y, short
|
||||
fld.check_type(CHECK_SEARCH); //search e non normal perchè nelle..
|
||||
//..stampe non si vuole la fase legata alla commessa/cdc
|
||||
|
||||
TEdit_field& dfld = sm.efield(dlg+50+i);
|
||||
TEdit_field& dfld = sm.efield(short(dlg+50+i));
|
||||
dfld.set_field(EMPTY_STRING); // Toglie campi che fan saltare gli output!
|
||||
}
|
||||
|
||||
y += h+1;
|
||||
dlg += h;
|
||||
dlg = short(dlg+h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user