Patch level :2.2 250
Files correlati :ca3.exe ca3600.msk Ricompilazione Demo : [ ] Commento :modificato filtro sulle cms/cdc/fsc che vengono prese dagli sheet; tiene conto di una commessa (e cdc e fsc) di tipo multilivello git-svn-id: svn://10.65.10.50/trunk@13565 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f151b6292f
commit
fe2d0103d7
@ -186,19 +186,19 @@ bool TPrint_movimenti_ca_recordset::valid_record(const TRelation& rel) const
|
||||
if (_codcosto.not_empty())
|
||||
{
|
||||
const TString& cos = rmov.get(RMOVANA_CODCCOSTO);
|
||||
if (cos != _codcosto)
|
||||
if (!cos.starts_with(_codcosto))
|
||||
return false;
|
||||
}
|
||||
if (_codcms.not_empty())
|
||||
{
|
||||
const TString& cms = rmov.get(RMOVANA_CODCMS);
|
||||
if (cms != _codcms)
|
||||
if (!cms.starts_with(_codcms))
|
||||
return false;
|
||||
}
|
||||
if (_codfas.not_empty())
|
||||
{
|
||||
const TString& fas = rmov.get(RMOVANA_CODFASE);
|
||||
if (fas != _codfas)
|
||||
if (!fas.starts_with(_codfas))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -436,18 +436,18 @@ void TPrint_mastrini_ca_alternative_recordset::set_filter(const TPrint_mastrini_
|
||||
|
||||
TString filtro;
|
||||
if (_codcosto.not_empty())
|
||||
filtro << "(" << RMOVANA_CODCCOSTO << "==\"" << _codcosto << "\")";
|
||||
filtro << "(" << RMOVANA_CODCCOSTO << "?=\"" << _codcosto << "*\")";
|
||||
if (_codcms.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(" << RMOVANA_CODCMS << "==\"" << _codcms << "\")";
|
||||
filtro << "(" << RMOVANA_CODCMS << "?=\"" << _codcms << "*\")";
|
||||
}
|
||||
if (_codfas.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(" << RMOVANA_CODFASE << "==\"" << _codfas << "\")";
|
||||
filtro << "(" << RMOVANA_CODFASE << "?=\"" << _codfas << "*\")";
|
||||
}
|
||||
|
||||
//scandisce il piano dei conti..
|
||||
|
450
ca/ca3600.cpp
450
ca/ca3600.cpp
@ -197,7 +197,7 @@ class TPag_per_cms_recordset : public TISAM_recordset
|
||||
|
||||
protected:
|
||||
TDate _dadata, _adata;
|
||||
long _dacodfor, _acodfor;
|
||||
long _codfor;
|
||||
TString8 _campodata;
|
||||
TString _codcosto, _codcms, _codfas;
|
||||
|
||||
@ -207,12 +207,15 @@ protected: //da libreria
|
||||
protected:
|
||||
void crea_trr(const TFilename& trr) const;
|
||||
static bool part_callback(const TRelation& rel, void* pJolly);
|
||||
// static bool mov_callback(const TRelation& rel, void* pJolly);
|
||||
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);
|
||||
|
||||
public:
|
||||
virtual void set_filter(const TPag_per_cms_mask& msk, int cms_row);
|
||||
virtual void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor);
|
||||
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);
|
||||
|
||||
TPag_per_cms_recordset(const TString& sql) : TISAM_recordset(sql) { _tmp = NULL;}
|
||||
~TPag_per_cms_recordset();
|
||||
@ -272,70 +275,312 @@ void TPag_per_cms_recordset::crea_trr(const TFilename& trr) const
|
||||
of << "DESFORN|1|50|0|Descrizione fornitore" << endl;
|
||||
of << "HIDDEN|8|1|0|Record nascosto" << endl;
|
||||
of << 1 << endl;
|
||||
of << "CONTO+NREG+DATAPAG+CODFORN" << endl;
|
||||
of << "CONTO+NREG+DATAPAG" << endl;
|
||||
}
|
||||
|
||||
//Criptico metodo per la scansione del cursore..
|
||||
typedef bool (*SCAN_FUNC)(const TRelation& rel, void* pJolly);
|
||||
|
||||
bool scan_cursor(TCursor& cur, const char* msg, SCAN_FUNC func, void* pJolly)
|
||||
long TPag_per_cms_recordset::find_movimento(const TRectype& riga_pag) const
|
||||
{
|
||||
TRecnotype items = 0; // Temporarily
|
||||
TProgind pi(items, msg, true, true);
|
||||
|
||||
int n_fatture = 0; //numero di fatture trovate
|
||||
int first_fatt = 0; //numero riga della prima fattura
|
||||
//scan della partita dall'ultima alla prima riga
|
||||
const TPartita partita(riga_pag);
|
||||
for (int p = partita.last(); p > 0; p = partita.pred(p))
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
items = cur.items();
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
if (items > 0)
|
||||
{
|
||||
cur.freeze();
|
||||
pi.setmax(items);
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
const TRiga_partite& fatt = partita.riga(p);
|
||||
if (fatt.is_fattura())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
n_fatture++;
|
||||
first_fatt = p;
|
||||
}
|
||||
}
|
||||
|
||||
if (n_fatture > 1)
|
||||
{
|
||||
const int linea_pag = riga_pag.get_int(PART_NRIGA);
|
||||
int linea_fattura = 0;
|
||||
for (int f = first_fatt; (f > 0) && (f <= partita.last()) && (linea_fattura == 0); f = partita.succ(f))
|
||||
{
|
||||
const TRiga_partite& fatt = partita.riga(f);
|
||||
if (fatt.is_fattura())
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if (!func(*cur.relation(), pJolly))
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
for (int r = 1; r <= fatt.rate(); r++)
|
||||
{
|
||||
const TRiga_scadenze& rata = fatt.rata(r);
|
||||
if (rata.exist(linea_pag))
|
||||
{
|
||||
linea_fattura = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cur.freeze(false);
|
||||
if (linea_fattura > 0) // oppure anche (linea_fattura > first_fatt)
|
||||
first_fatt = linea_fattura;
|
||||
}
|
||||
return ok;
|
||||
|
||||
long nreg = 0;
|
||||
if (first_fatt > 0)
|
||||
{
|
||||
const TRiga_partite& fatt = partita.riga(first_fatt);
|
||||
nreg = fatt.get_long(PART_NREG);
|
||||
}
|
||||
|
||||
return nreg;
|
||||
}
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::scan_movs(const TPag_per_cms_mask& msk)
|
||||
{
|
||||
if (_campodata == PART_DATAPAG) // I movimenti non hanno DATAPAG
|
||||
_campodata = PART_DATAREG;
|
||||
|
||||
TString filtro = "(REG==\"\")&&(TIPOMOV==\"\")";
|
||||
|
||||
TRectype darec(LF_MOV), arec(LF_MOV);
|
||||
if (_campodata == MOV_DATAREG)
|
||||
{
|
||||
if (_dadata.ok())
|
||||
darec.put(MOV_DATAREG, _dadata);
|
||||
if (_adata.ok())
|
||||
arec.put(MOV_DATAREG, _adata);
|
||||
}
|
||||
else
|
||||
{
|
||||
TString80 f;
|
||||
if (_dadata.ok())
|
||||
{
|
||||
f.format("&&(ANSI(%s)>=\"%s\")", (const char*)_campodata, _dadata.string(ANSI));
|
||||
filtro << f;
|
||||
}
|
||||
if (_adata.ok())
|
||||
{
|
||||
f.format("&&(ANSI(%s)<=\"%s\")", (const char*)_campodata, _adata.string(ANSI));
|
||||
filtro << f;
|
||||
}
|
||||
}
|
||||
|
||||
TRelation rel(LF_MOV);
|
||||
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);*/
|
||||
}
|
||||
|
||||
//prepara l'assoc con tutte le righe da mandare in stampa per quanto riguarda i movimenti con
|
||||
//saldaconto (siano essi con o senza iva)
|
||||
void TPag_per_cms_recordset::find_commesse(const long nreg, const TRectype& riga_pag)
|
||||
{
|
||||
/* TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
if (pn.read() == NOERR)
|
||||
{
|
||||
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 i = 0; i < pn.iva_items(); i++)
|
||||
{
|
||||
const TRectype& rmoviva = pn.iva(i);
|
||||
const TString& codcms = rmoviva.get(RMI_CODCMS);
|
||||
const TString& codfase = rmoviva.get(RMI_FASCMS);
|
||||
|
||||
const TBill conto(rmoviva);
|
||||
|
||||
if (cms_in_range(codcms, codfase) && conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
TToken_string cms_fsc = codcms;
|
||||
if (codfase.not_empty())
|
||||
cms_fsc.add(codfase);
|
||||
|
||||
const real importo = rmoviva.get_real(RMI_IMPONIBILE);
|
||||
real imposta = rmoviva.get_real(RMI_IMPOSTA);
|
||||
real* imp = (real*)commesse.objptr(cms_fsc);
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new real;
|
||||
commesse.add(cms_fsc, imp);
|
||||
}
|
||||
*imp += importo;
|
||||
totdoc_cms += importo;
|
||||
|
||||
if (imposta != ZERO)
|
||||
{
|
||||
//controllo prorata
|
||||
const TRectype& pla = cache().get("CMS", codcms);
|
||||
const bool prorata = pla.get_bool("B4");
|
||||
if (prorata)
|
||||
{
|
||||
const TDate datareg = pn.curr().get_date(MOV_DATAREG);
|
||||
const int anno = datareg.year();
|
||||
TRegistro registro(pn.curr().get(MOV_REG), anno);
|
||||
|
||||
imposta *= (CENTO - registro.prorata(anno))/CENTO;
|
||||
imposta.round(TCurrency::get_firm_dec()); //ci vanno i decimali della ditta
|
||||
}
|
||||
|
||||
*imp += imposta;
|
||||
totdoc_cms += imposta;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
else //..movimento NON iva (sempre con saldaconto)
|
||||
{
|
||||
for (int i = 0; i < pn.cg_items(); i++)
|
||||
{
|
||||
const TRectype& rmov = pn.cg(i);
|
||||
const TBill conto(rmov);
|
||||
|
||||
TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
|
||||
importo.normalize('D');
|
||||
|
||||
if (conto.tipo() > ' ')
|
||||
{
|
||||
totdoc -= importo.valore();
|
||||
totdoc_netto -= importo.valore(); //valore per il calcolo del residuo
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cerca_fiscali(conto) || cerca_sociali(conto))
|
||||
{
|
||||
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
continue;
|
||||
}
|
||||
|
||||
const TString& codcms = rmov.get(RMV_CODCMS);
|
||||
const TString& codfase = rmov.get(RMV_FASCMS);
|
||||
|
||||
if (cms_in_range(codcms,codfase) && conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
TToken_string cms_fsc = codcms;
|
||||
if (codfase.not_empty())
|
||||
cms_fsc.add(codfase);
|
||||
|
||||
real* imp = (real*)commesse.objptr(cms_fsc);
|
||||
if (imp == NULL)
|
||||
{
|
||||
imp = new real;
|
||||
commesse.add(cms_fsc, imp);
|
||||
}
|
||||
*imp += importo.valore();
|
||||
totdoc_cms += importo.valore();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
}
|
||||
}
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(commesse, h, k, imp)
|
||||
{
|
||||
const real& impcms = *(real*)imp;
|
||||
TPag_per_cms_struct* ppcs = new TPag_per_cms_struct;
|
||||
|
||||
// campi del pagamento
|
||||
ppcs->_tipo = 0; //movimenti da saldaconto
|
||||
ppcs->_codforn = riga_pag.get_long(PART_SOTTOCONTO);
|
||||
ppcs->_datapag = riga_pag.get_date(_campodata);
|
||||
ppcs->_importopagato.set_num(distributore.get()); //pagamento nella partita
|
||||
ppcs->_importopagato_prec.set_num(distributore_prec.get()); //pagamenti precedenti al
|
||||
ppcs->_descrpagamento = riga_pag.get(PART_DESCR);
|
||||
// campi della fattura
|
||||
ppcs->_nreg = nreg;
|
||||
ppcs->_numfat = movfat.get(MOV_NUMDOC);
|
||||
ppcs->_datafat = movfat.get_date(MOV_DATADOC);
|
||||
ppcs->_protiva = movfat.get_long(MOV_PROTIVA);
|
||||
ppcs->_totfat = totdoc; //questo e' quello che viene stampato in Tot.fattura
|
||||
|
||||
TToken_string cms_fsc = k;
|
||||
|
||||
ppcs->_commessa = cms_fsc.get(0);
|
||||
ppcs->_fase = cms_fsc.get(1);
|
||||
ppcs->_importocommessa.set_num(impcms); //importo da pagare scritto sulla fattura
|
||||
|
||||
_righe.add(ppcs); //aggiunge il pagamento all'array dei pagamenti
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
bool TPag_per_cms_recordset::part_callback(const TRelation& rel, void* pJolly)
|
||||
{
|
||||
/* TPag_per_cms* app = (TPag_per_cms*)pJolly;
|
||||
TPag_per_cms_recordset* recordset = (TPag_per_cms_recordset*)pJolly;
|
||||
const TRectype& riga_part_pag = rel.curr();
|
||||
|
||||
const long nreg = app->find_movimento(riga_part_pag); //prima cerco un movimento della fattura...
|
||||
if (nreg > 0) //..se ne trovo almeno uno cerco la commessa corrispondente
|
||||
app->find_commesse(nreg, riga_part_pag);*/
|
||||
const long nreg = recordset->find_movimento(riga_part_pag); //prima cerco un movimento della fattura...
|
||||
/* if (nreg > 0) //..se ne trovo almeno uno cerco la commessa corrispondente
|
||||
recordset->find_commesse(nreg, riga_part_pag);*/
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::scan_pags(const TPag_per_cms_mask& msk)
|
||||
{
|
||||
//costruzione filtro
|
||||
TRectype darec(LF_PARTITE);
|
||||
TRectype arec(LF_PARTITE);
|
||||
darec.put(PART_TIPOCF, 'F');
|
||||
darec.put(PART_GRUPPO, 0);
|
||||
darec.put(PART_CONTO, 0);
|
||||
arec = darec;
|
||||
if (_dacodfor > 0)
|
||||
darec.put(PART_SOTTOCONTO, _dacodfor);
|
||||
if (_acodfor >= _dacodfor)
|
||||
arec.put(PART_SOTTOCONTO, _acodfor);
|
||||
TRectype filtrec(LF_PARTITE);
|
||||
filtrec.put(PART_TIPOCF, 'F');
|
||||
filtrec.put(PART_GRUPPO, 0);
|
||||
filtrec.put(PART_CONTO, 0);
|
||||
if (_codfor > 0)
|
||||
filtrec.put(PART_SOTTOCONTO, _codfor);
|
||||
|
||||
TString filtro = "(TIPOMOV>=\"3\")"; //deve essere un pagamento a fornitore!!!
|
||||
|
||||
@ -353,11 +598,11 @@ void TPag_per_cms_recordset::scan_pags(const TPag_per_cms_mask& msk)
|
||||
}
|
||||
//applica il filtro alla relazione
|
||||
TRelation rel(LF_PARTITE);
|
||||
TCursor cur(&rel, filtro, 1, &darec, &arec);
|
||||
scan_cursor(cur, "Movimenti saldacontati...", part_callback, this);
|
||||
TCursor cur(&rel, filtro, 1, &filtrec, &filtrec);
|
||||
cur.scan(part_callback, this, "Movimenti con saldaconto...");
|
||||
}
|
||||
|
||||
void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, int cms_row)
|
||||
void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor)
|
||||
{
|
||||
//se esiste il file temporano con tracciato persomalizzato lo cancella e lo ricrea vuoto
|
||||
TFilename trr; //file tracciato record
|
||||
@ -383,9 +628,9 @@ void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, int cms_ro
|
||||
if (cms_row >= 0)
|
||||
{
|
||||
TSheet_field& sf = msk.sfield(F_RIGHE);
|
||||
TMask& sm = sf.sheet_mask();
|
||||
sf.update_mask(cms_row);
|
||||
TRelation rel(LF_RMOVANA);
|
||||
TMask& sm = sf.sheet_mask(); //metodo ingannatore per ottenere tutti i campi dallo sheet..
|
||||
sf.update_mask(cms_row); //..delle cms/fsc/cdc senza rifare il giro della configurazione..
|
||||
TRelation rel(LF_RMOVANA); //..anale
|
||||
sm.autosave(rel);
|
||||
_codcosto = rel.curr().get(RMOVANA_CODCCOSTO);
|
||||
_codcms = rel.curr().get(RMOVANA_CODCMS);
|
||||
@ -410,10 +655,8 @@ void TPag_per_cms_recordset::set_filter(const TPag_per_cms_mask& msk, int cms_ro
|
||||
scan_pags(msk);
|
||||
|
||||
//se c'e' un filtro sui fornitori, non si fa lo scan dei movimenti senza saldaconto
|
||||
_dacodfor = msk.get_long(F_DACODFOR);
|
||||
_acodfor = msk.get_long(F_ACODFOR);
|
||||
// if (_dacodfor == 0 && _acodfor == 0)
|
||||
// scan_movs();
|
||||
if (codfor <= 0)
|
||||
scan_movs(msk);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
@ -427,7 +670,7 @@ protected:
|
||||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||||
|
||||
public:
|
||||
void set_filter(const TPag_per_cms_mask& msk, int cms_row);
|
||||
void set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor);
|
||||
};
|
||||
|
||||
|
||||
@ -444,7 +687,7 @@ bool TPag_per_cms_rep::set_recordset(const TString& sql)
|
||||
}
|
||||
|
||||
|
||||
void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, int cms_row)
|
||||
void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, const int cms_row, const long codfor)
|
||||
{
|
||||
TAnal_report::set_recordset(NULL);
|
||||
|
||||
@ -452,7 +695,7 @@ void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, int cms_row)
|
||||
|
||||
TPag_per_cms_recordset* recset = new TPag_per_cms_recordset(query);
|
||||
|
||||
recset->set_filter(msk, cms_row);
|
||||
recset->set_filter(msk, cms_row, codfor);
|
||||
TAnal_report::set_recordset(recset);
|
||||
}
|
||||
|
||||
@ -465,6 +708,7 @@ void TPag_per_cms_rep::set_filter(const TPag_per_cms_mask& msk, int cms_row)
|
||||
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);
|
||||
const TMultilevel_code_info& get_level_one() const;
|
||||
virtual void main_loop();
|
||||
};
|
||||
@ -478,6 +722,48 @@ 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)
|
||||
{
|
||||
TSheet_field& sheet = mask.sfield(F_RIGHE);
|
||||
TString video_string; //stringa che compare nella progind
|
||||
if (sheet.empty()) //se non ci sono righe sullo sheet (selezione su tutte le cms/cdc)...
|
||||
{
|
||||
TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet
|
||||
|
||||
const TMultilevel_code_info& liv1 = get_level_one(); //stabilisce quale è il primo livello (tra CDC e CMS)..
|
||||
TISAM_recordset set(liv1.logic() == LF_CDC ? "USE CDC" : "USE COMMESSE"); //..e di conseguenza scrive la use giusta
|
||||
|
||||
TProgind pi(set.items(), video_string, true, true);
|
||||
for (int i = 0; set.move_to(i); i++) //fighissimo metodo per scandire un file in 1 riga!
|
||||
{
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
break;
|
||||
row = set.get((unsigned int)0).as_string(); //prende il valore del primo campo del file (CDC o CMS code)
|
||||
|
||||
video_string = TR("Scansione");
|
||||
video_string << " " << row; //completa la stringa da visualizzare sulla progind
|
||||
pi.set_text(video_string);
|
||||
|
||||
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)
|
||||
book.add(rep);
|
||||
}
|
||||
sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet
|
||||
}
|
||||
else //se ha almeno una riga sullo sheet delle cms/cdc...
|
||||
{
|
||||
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..
|
||||
//..temporaneo i cui dati riempiranno il report
|
||||
book.add(rep); //aggiunge il report relativo alla cdc/cms corrente al book
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TPag_per_cms::main_loop()
|
||||
{
|
||||
TPag_per_cms_mask mask;
|
||||
@ -491,44 +777,22 @@ void TPag_per_cms::main_loop()
|
||||
TPag_per_cms_rep rep;
|
||||
rep.load(path);
|
||||
|
||||
TSheet_field& sheet = mask.sfield(F_RIGHE);
|
||||
TString video_string; //stringa che compare nella progind
|
||||
if (sheet.empty()) //se non ci sono righe sullo sheet (selezione su tutte le cms/cdc)...
|
||||
const long dacodfor = mask.get_long(F_DACODFOR);
|
||||
const long acodfor = mask.get_long(F_ACODFOR);
|
||||
|
||||
if (dacodfor > 0 || acodfor > 0) //specifica il range dei clifo..
|
||||
{
|
||||
TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet
|
||||
|
||||
const TMultilevel_code_info& liv1 = get_level_one(); //stabilisce quale è il primo livello (tra CDC e CMS)..
|
||||
TISAM_recordset set(liv1.logic() == LF_CDC ? "USE CDC" : "USE COMMESSE"); //..e di conseguenza scrive la use giusta
|
||||
|
||||
TProgind pi(set.items(), video_string, true, true);
|
||||
for (int i = 0; set.move_to(i); i++) //fighissimo metodo per scandire un file in 1 riga!
|
||||
TISAM_recordset clifo("USE CLIFO\nFROM TIPOCF='F' CODCF=#DACODFOR\nTO TIPOCF='F' CODCF=#ACODFOR");
|
||||
clifo.set_var("#DACODFOR", TVariant(dacodfor));
|
||||
clifo.set_var("#ACODFOR", TVariant(acodfor));
|
||||
for (bool ok = clifo.move_first(); ok; ok = clifo.move_next())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
break;
|
||||
row = set.get((unsigned int)0).as_string(); //prende il valore del primo campo del file (CDC o CMS code)
|
||||
|
||||
video_string = TR("Scansione");
|
||||
video_string << " " << row; //completa la stringa da visualizzare sulla progind
|
||||
pi.set_text(video_string);
|
||||
|
||||
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); //fa la set filter sulla prima riga (che è quella usata)
|
||||
book.add(rep);
|
||||
}
|
||||
sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet
|
||||
}
|
||||
else //se ha almeno una riga sullo sheet delle cms/cdc...
|
||||
{
|
||||
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); //..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
|
||||
const long codforn = clifo.get("CODCF").as_int();
|
||||
stampa_per_commessa(mask, book, rep, codforn);
|
||||
}
|
||||
}
|
||||
else
|
||||
stampa_per_commessa(mask, book, rep, 0); //se non si specifica alcun clifo...
|
||||
|
||||
book.print_or_preview(); //stampa il book dei report
|
||||
}
|
||||
|
@ -9,8 +9,7 @@
|
||||
#define F_DADESFOR 204
|
||||
#define F_ACODFOR 205
|
||||
#define F_ADESFOR 206
|
||||
#define F_ORDINAMENTO 207
|
||||
#define F_REPORT 208
|
||||
#define F_REPORT 207
|
||||
|
||||
//sheet commesse e righe relative
|
||||
#define F_RIGHE 260
|
||||
|
@ -24,7 +24,7 @@ ENDPAGE
|
||||
|
||||
PAGE "Stampa pagato" -1 -1 78 20
|
||||
|
||||
SPREADSHEET F_RIGHE -1 -13
|
||||
SPREADSHEET F_RIGHE -1 -12
|
||||
BEGIN
|
||||
PROMPT 1 1 "Centro di Costo / Commessa / Fase"
|
||||
ITEM "Cdc1"
|
||||
@ -43,12 +43,12 @@ END
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 9 "@bEstrazione per data di: "
|
||||
PROMPT 1 10 "@bEstrazione per data di: "
|
||||
END
|
||||
|
||||
RADIOBUTTON F_TIPODATA 76
|
||||
BEGIN
|
||||
PROMPT 2 9 ""
|
||||
PROMPT 2 10 ""
|
||||
ITEM "0|Registrazione"
|
||||
ITEM "1|Documento"
|
||||
ITEM "2|Pagamento"
|
||||
@ -57,24 +57,24 @@ END
|
||||
|
||||
DATE F_DATAINI
|
||||
BEGIN
|
||||
PROMPT 2 11 "Dalla data "
|
||||
PROMPT 2 12 "Dalla data "
|
||||
END
|
||||
|
||||
DATE F_DATAFIN
|
||||
BEGIN
|
||||
PROMPT 25 11 "Alla data "
|
||||
PROMPT 25 12 "Alla data "
|
||||
VALIDATE DATE_CMP_FUNC >= F_DATAINI
|
||||
WARNING "La data finale deve essere successiva a quella iniziale"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 13 "@bSelezione fornitori"
|
||||
PROMPT 1 14 "@bSelezione fornitori"
|
||||
END
|
||||
|
||||
NUMBER F_DACODFOR 6
|
||||
BEGIN
|
||||
PROMPT 2 14 "Da codice "
|
||||
PROMPT 2 15 "Da codice "
|
||||
USE LF_CLIFO KEY 1
|
||||
FLAGS "U"
|
||||
INPUT TIPOCF "F"
|
||||
@ -88,7 +88,7 @@ END
|
||||
|
||||
STRING F_DADESFOR 50
|
||||
BEGIN
|
||||
PROMPT 23 14 ""
|
||||
PROMPT 23 15 ""
|
||||
USE LF_CLIFO KEY 2
|
||||
INPUT TIPOCF "F"
|
||||
INPUT RAGSOC F_DADESFOR
|
||||
@ -100,7 +100,7 @@ END
|
||||
|
||||
NUMBER F_ACODFOR 6
|
||||
BEGIN
|
||||
PROMPT 2 15 "A codice "
|
||||
PROMPT 2 16 "A codice "
|
||||
COPY USE F_DACODFOR
|
||||
FLAGS "U"
|
||||
INPUT TIPOCF "F"
|
||||
@ -115,7 +115,7 @@ END
|
||||
|
||||
STRING F_ADESFOR 50
|
||||
BEGIN
|
||||
PROMPT 23 15 ""
|
||||
PROMPT 23 16 ""
|
||||
COPY USE F_DADESFOR
|
||||
INPUT TIPOCF "F"
|
||||
INPUT RAGSOC F_ADESFOR
|
||||
@ -124,14 +124,6 @@ BEGIN
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
RADIOBUTTON F_ORDINAMENTO 1 40
|
||||
BEGIN
|
||||
PROMPT 1 17 "@bTipo ordinamento"
|
||||
ITEM " |Commessa"
|
||||
ITEM "X|Fornitore"
|
||||
FLAGS "Z"
|
||||
END
|
||||
|
||||
STRING F_REPORT 256 64
|
||||
BEGIN
|
||||
PROMPT 2 20 "Report "
|
||||
@ -197,7 +189,7 @@ ENDPAGE
|
||||
ENDMASK
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Righe degli sheet
|
||||
// Righe dello sheet con commesse fasi centridicosto
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
PAGE "Riga Analitica" -1 -1 78 19
|
||||
|
@ -709,19 +709,19 @@ void TPrint_rendiconto_ca_recordset::crea_righe_da_rmovana()
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(" << RMOVANA_CODCCOSTO << "==\"" << _codcosto << "\")";
|
||||
filtro << "(" << RMOVANA_CODCCOSTO << "?=\"" << _codcosto << "*\")";
|
||||
}
|
||||
if (_codcms.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(" << RMOVANA_CODCMS << "==\"" << _codcms << "\")";
|
||||
filtro << "(" << RMOVANA_CODCMS << "?=\"" << _codcms << "*\")";
|
||||
}
|
||||
if (_codfas.not_empty())
|
||||
{
|
||||
if (filtro.not_empty())
|
||||
filtro << "&&";
|
||||
filtro << "(" << RMOVANA_CODFASE << "==\"" << _codfas << "\")";
|
||||
filtro << "(" << RMOVANA_CODFASE << "?=\"" << _codfas << "*\")";
|
||||
}
|
||||
|
||||
TCursor cur_rmovana(&rel_rmovana, filtro, 2, &da_rmovana, &a_rmovana);
|
||||
|
Loading…
x
Reference in New Issue
Block a user