Aggiunto oggetto TAgente
Corretta rate2rows nel caso di agente non definito git-svn-id: svn://10.65.10.50/trunk@5450 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3df5a55161
commit
cfa88b17dc
17
pr/prlib.h
17
pr/prlib.h
@ -124,4 +124,21 @@ public:
|
|||||||
~TProvvigioni_agente();
|
~TProvvigioni_agente();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TAgente : public TRectype
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int read(const char* codice);
|
||||||
|
virtual TAgente & copy(const TAgente & a) { return (TAgente &) TRectype::operator=((TRectype &)a);}
|
||||||
|
|
||||||
|
public:
|
||||||
|
TObject* dup() const { return new TAgente(*this); }
|
||||||
|
const TString& codice() const { return get("CODAGE");}
|
||||||
|
const TString& ragsoc() const { return get("RAGSOC"); }
|
||||||
|
const TString& campoprovv() const { return get("CAMPOPROVV"); }
|
||||||
|
|
||||||
|
TAgente(const char* codice = NULL);
|
||||||
|
TAgente(const TAgente & a);
|
||||||
|
TAgente(const TRectype& rec);
|
||||||
|
virtual ~TAgente() {}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
170
pr/prlib01.cpp
170
pr/prlib01.cpp
@ -90,79 +90,83 @@ int TProvvigioni_agente::rate2rows(int action)
|
|||||||
// Scorre gli elementi di _rate (TDoc_rate) uno ad uno
|
// Scorre gli elementi di _rate (TDoc_rate) uno ad uno
|
||||||
// per settare le righe provvigionali
|
// per settare le righe provvigionali
|
||||||
// Scrive tramite chiave 1: utilizzando un solo record array (CODAGE+NROW)
|
// Scrive tramite chiave 1: utilizzando un solo record array (CODAGE+NROW)
|
||||||
TRecord_array* rows = new TRecord_array(LF_PROVV,PROV_NROW);
|
|
||||||
TRectype* k = new TRectype(LF_PROVV);
|
|
||||||
k->put(PROV_CODAGE, _agente);
|
|
||||||
rows->set_key(k);
|
|
||||||
TString_array kl;
|
|
||||||
int nrow = 1; // Numero riga per agente e per documento
|
|
||||||
const int items = documenti(kl); // Prende l'elenco dei documenti
|
|
||||||
kl.sort(); // ordina per documento
|
|
||||||
int err = NOERR;
|
int err = NOERR;
|
||||||
for (int i = 0; i < items && err == NOERR; i++)
|
|
||||||
|
if (_agente.not_empty())
|
||||||
{
|
{
|
||||||
TRate_doc& rd = (TRate_doc&)_rate[kl.row(i)];
|
TRecord_array * rows = new TRecord_array(LF_PROVV,PROV_NROW);
|
||||||
const int anno = rd.anno();
|
TRectype* k = new TRectype(LF_PROVV);
|
||||||
const long ndoc = rd.ndoc();
|
k->put(PROV_CODAGE, _agente);
|
||||||
TString codnum(rd.codnum());
|
rows->set_key(k);
|
||||||
TDate datadoc(rd.datadoc());
|
TString_array kl;
|
||||||
real impdoc = rd.impdoc();
|
int nrow = 1; // Numero riga per agente e per documento
|
||||||
real impprdoc = rd.impprdoc();
|
const int items = documenti(kl); // Prende l'elenco dei documenti
|
||||||
real impnet = rd.impnet();
|
kl.sort(); // ordina per documento
|
||||||
const long codcf = rd.codcf();
|
for (int i = 0; i < items && err == NOERR; i++)
|
||||||
TString codval(rd.codval());
|
|
||||||
TDate datacam(rd.datacam());
|
|
||||||
real cambio = rd.cambio();
|
|
||||||
// Chiave del TRecord_array
|
|
||||||
const int ritems = rd.items(); // Ciclo per rate di questo documento
|
|
||||||
for (int j = 0; j < ritems; j++)
|
|
||||||
{
|
{
|
||||||
TRata& rt = rd[j];
|
TRate_doc& rd = (TRate_doc&)_rate[kl.row(i)];
|
||||||
TRectype* record = new TRectype(LF_PROVV);
|
const int anno = rd.anno();
|
||||||
record->put(PROV_CODAGE,_agente);
|
const long ndoc = rd.ndoc();
|
||||||
record->put(PROV_ANNO,anno);
|
TString codnum(rd.codnum());
|
||||||
record->put(PROV_CODNUM,codnum);
|
TDate datadoc(rd.datadoc());
|
||||||
record->put(PROV_NDOC,ndoc);
|
real impdoc = rd.impdoc();
|
||||||
record->put(PROV_NROW,nrow++);
|
real impprdoc = rd.impprdoc();
|
||||||
record->put(PROV_NRIGA,j+1);
|
real impnet = rd.impnet();
|
||||||
record->put(PROV_NRATA,rt.rata());
|
const long codcf = rd.codcf();
|
||||||
record->put(PROV_GENERATA,rt.generata());
|
TString codval(rd.codval());
|
||||||
record->put(PROV_SALDATA,rt.saldata());
|
TDate datacam(rd.datacam());
|
||||||
record->put(PROV_TIPOPAGPR,rt.tipopagpr());
|
real cambio = rd.cambio();
|
||||||
record->put(PROV_DATADOC,datadoc);
|
// Chiave del TRecord_array
|
||||||
record->put(PROV_IMPDOC,impdoc);
|
const int ritems = rd.items(); // Ciclo per rate di questo documento
|
||||||
record->put(PROV_IMPPRDOC,impprdoc);
|
for (int j = 0; j < ritems; j++)
|
||||||
record->put(PROV_IMPNETDOC,impnet);
|
{
|
||||||
record->put(PROV_CODCLI,codcf);
|
TRata& rt = rd[j];
|
||||||
record->put(PROV_CODVAL,codval);
|
TRectype* record = new TRectype(LF_PROVV);
|
||||||
record->put(PROV_DATACAMBIO,datacam);
|
record->put(PROV_CODAGE,_agente);
|
||||||
record->put(PROV_CAMBIO,cambio);
|
record->put(PROV_ANNO,anno);
|
||||||
record->put(PROV_DATASCAD,rt.datascad());
|
record->put(PROV_CODNUM,codnum);
|
||||||
record->put(PROV_IMPRATA,rt.imprata());
|
record->put(PROV_NDOC,ndoc);
|
||||||
record->put(PROV_TIPOPAG,rt.tipopag());
|
record->put(PROV_NROW,nrow++);
|
||||||
record->put(PROV_IMPPROVV,rt.impprovv());
|
record->put(PROV_NRIGA,j+1);
|
||||||
record->put(PROV_PAGATO,rt.pagato());
|
record->put(PROV_NRATA,rt.rata());
|
||||||
record->put(PROV_PROVVPAG,rt.provvpag());
|
record->put(PROV_GENERATA,rt.generata());
|
||||||
record->put(PROV_PAGMAT,rt.pagmat());
|
record->put(PROV_SALDATA,rt.saldata());
|
||||||
record->put(PROV_PROVVMAT,rt.provvmat());
|
record->put(PROV_TIPOPAGPR,rt.tipopagpr());
|
||||||
rows->add_row(record);
|
record->put(PROV_DATADOC,datadoc);
|
||||||
}
|
record->put(PROV_IMPDOC,impdoc);
|
||||||
switch (action)
|
record->put(PROV_IMPPRDOC,impprdoc);
|
||||||
{
|
record->put(PROV_IMPNETDOC,impnet);
|
||||||
case 0: // write
|
record->put(PROV_CODCLI,codcf);
|
||||||
err = rows->write();
|
record->put(PROV_CODVAL,codval);
|
||||||
break;
|
record->put(PROV_DATACAMBIO,datacam);
|
||||||
case 1: // rewrite
|
record->put(PROV_CAMBIO,cambio);
|
||||||
err = rows->rewrite();
|
record->put(PROV_DATASCAD,rt.datascad());
|
||||||
break;
|
record->put(PROV_IMPRATA,rt.imprata());
|
||||||
case 2: // remove
|
record->put(PROV_TIPOPAG,rt.tipopag());
|
||||||
err = rows->remove();
|
record->put(PROV_IMPPROVV,rt.impprovv());
|
||||||
break;
|
record->put(PROV_PAGATO,rt.pagato());
|
||||||
default: // remove
|
record->put(PROV_PROVVPAG,rt.provvpag());
|
||||||
break;
|
record->put(PROV_PAGMAT,rt.pagmat());
|
||||||
|
record->put(PROV_PROVVMAT,rt.provvmat());
|
||||||
|
rows->add_row(record);
|
||||||
|
}
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 0: // write
|
||||||
|
err = rows->write();
|
||||||
|
break;
|
||||||
|
case 1: // rewrite
|
||||||
|
err = rows->rewrite();
|
||||||
|
break;
|
||||||
|
case 2: // remove
|
||||||
|
err = rows->remove();
|
||||||
|
break;
|
||||||
|
default: // remove
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
delete rows;
|
||||||
}
|
}
|
||||||
delete rows;
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,3 +328,33 @@ TRata::TRata(TRectype& rec)
|
|||||||
set(rec);
|
set(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TAgente::read(const char * codice)
|
||||||
|
{
|
||||||
|
TLocalisamfile f(LF_AGENTI);
|
||||||
|
|
||||||
|
put("CODAGE", codice);
|
||||||
|
int err = TRectype::read(f);
|
||||||
|
if (err != NOERR)
|
||||||
|
{
|
||||||
|
zero();
|
||||||
|
put("CODAGE", codice);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAgente::TAgente(const char * codice)
|
||||||
|
: TRectype(LF_AGENTI)
|
||||||
|
{
|
||||||
|
read(codice);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAgente::TAgente(const TAgente & a)
|
||||||
|
: TRectype(LF_AGENTI)
|
||||||
|
{
|
||||||
|
copy(a);
|
||||||
|
}
|
||||||
|
TAgente::TAgente(const TRectype & rec)
|
||||||
|
: TRectype(LF_AGENTI)
|
||||||
|
{
|
||||||
|
TRectype::operator=(rec);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user