Patch level : 1.7 AGA no patch
Files correlati : si0.exe si0400a.ini Ricompilazione Demo : [ ] Commento : Corretto tracciato e risultati del file di Invio ad AS/400 git-svn-id: svn://10.65.10.50/trunk@10076 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5b58dca9b7
commit
887a4d8e1b
110
si/si0400.cpp
110
si/si0400.cpp
@ -35,26 +35,15 @@ class TScaricoAS400: public TSkeleton_application
|
|||||||
virtual bool destroy();
|
virtual bool destroy();
|
||||||
// Coontrolla se lo stato ed il tipo del documento sono validi e rispettano la selezione
|
// Coontrolla se lo stato ed il tipo del documento sono validi e rispettano la selezione
|
||||||
bool doc_tipo_stato_ok(const TDocumento* doc);
|
bool doc_tipo_stato_ok(const TDocumento* doc);
|
||||||
// Handler del codice elaborazione differita
|
|
||||||
static bool handle_cod_eld(TMask_field& f, KEY k);
|
|
||||||
// Handler dell'intervallo di date
|
// Handler dell'intervallo di date
|
||||||
static bool handle_data_range(TMask_field& f, KEY k);
|
static bool handle_data_range(TMask_field& f, KEY k);
|
||||||
// Handler del pulsante di selezione codici numerazione
|
|
||||||
static bool handle_select(TMask_field& f, KEY k);
|
|
||||||
// Aggiunge il documento corrente alla lista dei documenti raggruppabili
|
|
||||||
void add_to_group_list(TDocumento* doc);
|
|
||||||
// Costruisce la stringa chiave per raggruppamento
|
|
||||||
void build_group_key(TString& key, TDocumento* doc);
|
|
||||||
// Costruisce la stringa chiave per documento
|
|
||||||
void build_doc_key(TToken_string& key, TDocumento* doc);
|
|
||||||
void put_seq(TConfig & c);
|
|
||||||
void transfer();
|
void transfer();
|
||||||
// costruisce l'array delle elaborazioni scelte
|
// costruisce l'array delle elaborazioni scelte
|
||||||
void build_elaborazioni();
|
void build_elaborazioni();
|
||||||
// costruisce l'array dei tipi doc e relativi stati per una elaborazione
|
// costruisce l'array dei tipi doc e relativi stati per una elaborazione
|
||||||
void build_tipidoc(const TContabilizzazione& cont);
|
void build_tipidoc(const TContabilizzazione& cont);
|
||||||
void scrivi_righe(TAssoc_array& arr_imponibile, TAssoc_array& arr_imposta);
|
void scrivi_righe(TAssoc_array& arr_imponibile, TAssoc_array& arr_imposta);
|
||||||
void record(THash_object& lavoro, TString& codartmag, TString& valimponibile, TString& valimposta);
|
void record(THash_object& lavoro, TString& codartmag, real& valimponibile, real& valimposta);
|
||||||
virtual const char * extra_modules() const { return "BA"; }
|
virtual const char * extra_modules() const { return "BA"; }
|
||||||
public:
|
public:
|
||||||
TString16& provenienza() {return _provenienza;};
|
TString16& provenienza() {return _provenienza;};
|
||||||
@ -74,7 +63,8 @@ class TScarico_file: public TFile_text
|
|||||||
protected:
|
protected:
|
||||||
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void forza_validate(TRecord_text& rec, TTracciato_record& tr );
|
||||||
TScarico_file(const TString& file_name, const TString& config_name);
|
TScarico_file(const TString& file_name, const TString& config_name);
|
||||||
virtual ~TScarico_file() { }
|
virtual ~TScarico_file() { }
|
||||||
};
|
};
|
||||||
@ -88,6 +78,13 @@ void TScarico_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, T
|
|||||||
valore = app().provenienza();
|
valore = app().provenienza();
|
||||||
else if (code == "_DATADOC")
|
else if (code == "_DATADOC")
|
||||||
valore = app().datadocprec().string(brief,'\0');
|
valore = app().datadocprec().string(brief,'\0');
|
||||||
|
else if (code == "_CURRENCY")
|
||||||
|
{
|
||||||
|
valore = str;
|
||||||
|
int len = atoi(s.get());
|
||||||
|
if (len > 0)
|
||||||
|
valore.lpad(len);
|
||||||
|
}
|
||||||
else NFCHECK("Macro non definita: %s", (const char *)code);
|
else NFCHECK("Macro non definita: %s", (const char *)code);
|
||||||
str = valore;
|
str = valore;
|
||||||
}
|
}
|
||||||
@ -97,6 +94,29 @@ TScarico_file::TScarico_file(const TString& file_name, const TString& config_nam
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TScarico_file::forza_validate(TRecord_text& rec, TTracciato_record& tr )
|
||||||
|
{
|
||||||
|
TString campo;
|
||||||
|
TCursor cur(tr.relation());
|
||||||
|
TRelation& rel = *cur.relation();
|
||||||
|
TArray& a_tc = tr.tracciati_campo();
|
||||||
|
int items = a_tc.items();
|
||||||
|
for (int i = 0; i < items; i++)
|
||||||
|
{
|
||||||
|
TTracciato_campo& tc = tr.get(i);
|
||||||
|
const TString& message = tc.message();
|
||||||
|
if (!message.empty())
|
||||||
|
{
|
||||||
|
campo = rec.get(i);
|
||||||
|
TToken_string msg (message, ',');
|
||||||
|
if (!msg.blank())
|
||||||
|
{
|
||||||
|
validate(cur, rec, msg, campo);
|
||||||
|
rec.add(campo, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// costruisce l'assoc array delle elaborazioni scelte
|
// costruisce l'assoc array delle elaborazioni scelte
|
||||||
void TScaricoAS400::build_elaborazioni()
|
void TScaricoAS400::build_elaborazioni()
|
||||||
@ -173,7 +193,7 @@ bool TScaricoAS400::doc_tipo_stato_ok(const TDocumento* doc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//emetto un record
|
//emetto un record
|
||||||
void TScaricoAS400::record(THash_object& lavoro, TString& codartmag, TString& valimponibile, TString& valimposta)
|
void TScaricoAS400::record(THash_object& lavoro, TString& codartmag, real& valimponibile, real& valimposta)
|
||||||
{
|
{
|
||||||
TTracciato_record& oggetto = (TTracciato_record&)lavoro.obj();
|
TTracciato_record& oggetto = (TTracciato_record&)lavoro.obj();
|
||||||
const TString& tipo = oggetto.type();
|
const TString& tipo = oggetto.type();
|
||||||
@ -181,8 +201,15 @@ void TScaricoAS400::record(THash_object& lavoro, TString& codartmag, TString& va
|
|||||||
//carico il record da emettere
|
//carico il record da emettere
|
||||||
_trasfile->autoload(rec, LF_RIGHEDOC);
|
_trasfile->autoload(rec, LF_RIGHEDOC);
|
||||||
_trasfile->add_field(rec, "CODARTMAG", (const char*) codartmag);
|
_trasfile->add_field(rec, "CODARTMAG", (const char*) codartmag);
|
||||||
_trasfile->add_field(rec, "IMPONIBILE", (const char*) valimponibile);
|
TCurrency c(valimponibile);
|
||||||
_trasfile->add_field(rec, "IMPOSTA", (const char*) valimposta);
|
TString80 str = c.string();
|
||||||
|
str.strip(",");
|
||||||
|
_trasfile->add_field(rec, "IMPONIBILE", (const char*) str);
|
||||||
|
c = TCurrency(valimposta);
|
||||||
|
str = c.string();
|
||||||
|
str.strip(",");
|
||||||
|
_trasfile->add_field(rec, "IMPOSTA", (const char*) str);
|
||||||
|
_trasfile->forza_validate(rec,oggetto);
|
||||||
_trasfile->write(rec);//emetto i dati su file
|
_trasfile->write(rec);//emetto i dati su file
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +259,6 @@ void TScaricoAS400::main_loop()
|
|||||||
_trasfile->open(_msk->get(F_FILEMOV),'w');
|
_trasfile->open(_msk->get(F_FILEMOV),'w');
|
||||||
build_elaborazioni();
|
build_elaborazioni();
|
||||||
transfer();
|
transfer();
|
||||||
put_seq(c);
|
|
||||||
delete _trasfile;
|
delete _trasfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,19 +270,13 @@ void TScaricoAS400::scrivi_righe(TAssoc_array& arr_imponibile, TAssoc_array& arr
|
|||||||
for (int i=0;i<arrimp.items();i++)
|
for (int i=0;i<arrimp.items();i++)
|
||||||
{
|
{
|
||||||
TString80 codartmag = arrimp.row(i).get(0);
|
TString80 codartmag = arrimp.row(i).get(0);
|
||||||
real& r = (real&) arr_imponibile[codartmag];
|
real& valimponibile = (real&) arr_imponibile[codartmag];
|
||||||
TCurrency c(r);
|
real& valimposta = (real&) arr_imposta[codartmag];
|
||||||
TString80 valimponibile = c.string();
|
|
||||||
valimponibile.strip(",");
|
|
||||||
r = (real&) arr_imposta[codartmag];
|
|
||||||
c = TCurrency(r);
|
|
||||||
TString80 valimposta = c.string();
|
|
||||||
valimposta.strip(",");
|
|
||||||
THash_object* lavoro = _tracciati.get_hashobj();
|
THash_object* lavoro = _tracciati.get_hashobj();
|
||||||
//scandisco tutti i record di un effetto
|
//scandisco tutti i record di un effetto
|
||||||
for (int i = 0; lavoro != NULL; i++)
|
for (int i = 0; lavoro != NULL; i++)
|
||||||
{
|
{
|
||||||
record(*lavoro, codartmag, valimponibile, valimposta);//emetto il record
|
record(*lavoro, codartmag, valimponibile, valimposta); //emetto il record
|
||||||
lavoro = _tracciati.get_hashobj();
|
lavoro = _tracciati.get_hashobj();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +342,7 @@ void TScaricoAS400::transfer()
|
|||||||
doc_cur = j;
|
doc_cur = j;
|
||||||
TDocumento* doc = new TDocumento;
|
TDocumento* doc = new TDocumento;
|
||||||
if (doc->read(doc_cur.curr()) == NOERR && // legge il documento
|
if (doc->read(doc_cur.curr()) == NOERR && // legge il documento
|
||||||
codnum == doc->get(DOC_CODNUM) && // patch del cazzo
|
codnum == doc->get(DOC_CODNUM) && // patch del cazzo (non l'ho scritto io!!!!)
|
||||||
doc_tipo_stato_ok(doc)) // controlla che il tipo documento e lo stato siano coerenti con la ELD selezionata
|
doc_tipo_stato_ok(doc)) // controlla che il tipo documento e lo stato siano coerenti con la ELD selezionata
|
||||||
{
|
{
|
||||||
TDate datadoc = doc->data();
|
TDate datadoc = doc->data();
|
||||||
@ -332,9 +352,7 @@ void TScaricoAS400::transfer()
|
|||||||
{
|
{
|
||||||
if (_datadocprec.ok())
|
if (_datadocprec.ok())
|
||||||
// devo scrivere i record su file di testo
|
// devo scrivere i record su file di testo
|
||||||
{
|
|
||||||
scrivi_righe(arr_imponibile, arr_imposta);
|
scrivi_righe(arr_imponibile, arr_imposta);
|
||||||
}
|
|
||||||
// devo azzerare l'assoc array con tipodoc e codartmag
|
// devo azzerare l'assoc array con tipodoc e codartmag
|
||||||
arr_imposta.destroy();
|
arr_imposta.destroy();
|
||||||
arr_imponibile.destroy();
|
arr_imponibile.destroy();
|
||||||
@ -357,11 +375,11 @@ void TScaricoAS400::transfer()
|
|||||||
if (!arr_imponibile.is_key(key))
|
if (!arr_imponibile.is_key(key))
|
||||||
arr_imponibile.add(key, new real);
|
arr_imponibile.add(key, new real);
|
||||||
real& rl1 = (real&) arr_imponibile[key];
|
real& rl1 = (real&) arr_imponibile[key];
|
||||||
rl1 += rr.imponibile(TRUE);
|
rl1 += rr.imponibile();
|
||||||
if (!arr_imposta.is_key(key))
|
if (!arr_imposta.is_key(key))
|
||||||
arr_imposta.add(key, new real);
|
arr_imposta.add(key, new real);
|
||||||
real& rl2 = (real&) arr_imposta[key];
|
real& rl2 = (real&) arr_imposta[key];
|
||||||
rl2 += rr.imposta(TRUE);
|
rl2 += rr.imposta();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cont.change_doc_status(*doc);
|
cont.change_doc_status(*doc);
|
||||||
@ -372,26 +390,7 @@ void TScaricoAS400::transfer()
|
|||||||
}
|
}
|
||||||
if (_datadocprec.ok())
|
if (_datadocprec.ok())
|
||||||
// devo scrivere i record su file di testo
|
// devo scrivere i record su file di testo
|
||||||
{
|
|
||||||
scrivi_righe(arr_imponibile, arr_imposta);
|
scrivi_righe(arr_imponibile, arr_imposta);
|
||||||
/*
|
|
||||||
TString_array arrimp;
|
|
||||||
arr_imponibile.get_keys(arrimp, TRUE);
|
|
||||||
for (i=0;i<arrimp.items();i++)
|
|
||||||
{
|
|
||||||
TString80 codartmag = arrimp.row(i).get(0);
|
|
||||||
real& r = (real&) arr_imponibile[codartmag];
|
|
||||||
TString80 valimponibile = r.string();
|
|
||||||
THash_object* lavoro = tracciati.get_hashobj();
|
|
||||||
//scandisco tutti i record di un effetto
|
|
||||||
for (int i = 0; lavoro != NULL; i++)
|
|
||||||
{
|
|
||||||
record(*lavoro, codartmag, valimponibile, valimposta);//emetto il record
|
|
||||||
lavoro = tracciati.get_hashobj();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
if (p.iscancelled()) break;
|
if (p.iscancelled()) break;
|
||||||
#endif
|
#endif
|
||||||
@ -400,17 +399,6 @@ void TScaricoAS400::transfer()
|
|||||||
xvt_statbar_set("");
|
xvt_statbar_set("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TScaricoAS400::put_seq(TConfig & c)
|
|
||||||
{
|
|
||||||
TScanner seq(c.get("FileSeqE"));
|
|
||||||
//const int expected_seq = c.get_int("Seq1") + 1;
|
|
||||||
const int seqnum = seq.integer();
|
|
||||||
|
|
||||||
//if (expected_seq != seqnum)
|
|
||||||
// error_box("Il numero di sequenza trovato %d\nnon coincide con quello atteso %d", seqnum, expected_seq);
|
|
||||||
c.set("Seq1", seqnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int si0400(int argc, char* argv[])
|
int si0400(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
TScaricoAS400 a;
|
TScaricoAS400 a;
|
||||||
|
@ -18,18 +18,19 @@ NAME(1) = Data documento
|
|||||||
POSITION(1) = 4
|
POSITION(1) = 4
|
||||||
|
|
||||||
|
|
||||||
LENGTH(2) = 20
|
LENGTH(2) = 13
|
||||||
NAME(2) = CODARTMAG
|
NAME(2) = CODARTMAG
|
||||||
POSITION(2) = 10
|
POSITION(2) = 10
|
||||||
|
|
||||||
LENGTH(3) = 15
|
LENGTH(3) = 15
|
||||||
NAME(3) = IMPONIBILE
|
NAME(3) = IMPONIBILE
|
||||||
POSITION(3) = 30
|
POSITION(3) = 23
|
||||||
ALLIGN = R
|
ALLIGN(3) = R
|
||||||
|
MESSAGE(3) = _CURRENCY,15
|
||||||
|
|
||||||
LENGTH(4) = 15
|
LENGTH(4) = 15
|
||||||
NAME(4) = IMPOSTA
|
NAME(4) = IMPOSTA
|
||||||
POSITION(4) = 45
|
POSITION(4) = 38
|
||||||
ALLIGN = R
|
ALLIGN(4) = R
|
||||||
|
MESSAGE(4) = _CURRENCY,15
|
||||||
USE=34
|
USE=34
|
||||||
|
Loading…
x
Reference in New Issue
Block a user