diff --git a/si/si0400.cpp b/si/si0400.cpp index 9cd2301cd..c9d4750c7 100755 --- a/si/si0400.cpp +++ b/si/si0400.cpp @@ -35,26 +35,15 @@ class TScaricoAS400: public TSkeleton_application virtual bool destroy(); // Coontrolla se lo stato ed il tipo del documento sono validi e rispettano la selezione 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 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(); // costruisce l'array delle elaborazioni scelte void build_elaborazioni(); // costruisce l'array dei tipi doc e relativi stati per una elaborazione void build_tipidoc(const TContabilizzazione& cont); 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"; } public: TString16& provenienza() {return _provenienza;}; @@ -74,7 +63,8 @@ class TScarico_file: public TFile_text protected: 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); virtual ~TScarico_file() { } }; @@ -88,6 +78,13 @@ void TScarico_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, T valore = app().provenienza(); else if (code == "_DATADOC") 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); 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 void TScaricoAS400::build_elaborazioni() @@ -173,7 +193,7 @@ bool TScaricoAS400::doc_tipo_stato_ok(const TDocumento* doc) } //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(); const TString& tipo = oggetto.type(); @@ -181,8 +201,15 @@ void TScaricoAS400::record(THash_object& lavoro, TString& codartmag, TString& va //carico il record da emettere _trasfile->autoload(rec, LF_RIGHEDOC); _trasfile->add_field(rec, "CODARTMAG", (const char*) codartmag); - _trasfile->add_field(rec, "IMPONIBILE", (const char*) valimponibile); - _trasfile->add_field(rec, "IMPOSTA", (const char*) valimposta); + TCurrency c(valimponibile); + 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 } @@ -232,7 +259,6 @@ void TScaricoAS400::main_loop() _trasfile->open(_msk->get(F_FILEMOV),'w'); build_elaborazioni(); transfer(); - put_seq(c); delete _trasfile; } } @@ -244,19 +270,13 @@ void TScaricoAS400::scrivi_righe(TAssoc_array& arr_imponibile, TAssoc_array& arr for (int i=0;iread(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 { TDate datadoc = doc->data(); @@ -332,9 +352,7 @@ void TScaricoAS400::transfer() { if (_datadocprec.ok()) // devo scrivere i record su file di testo - { scrivi_righe(arr_imponibile, arr_imposta); - } // devo azzerare l'assoc array con tipodoc e codartmag arr_imposta.destroy(); arr_imponibile.destroy(); @@ -357,11 +375,11 @@ void TScaricoAS400::transfer() if (!arr_imponibile.is_key(key)) arr_imponibile.add(key, new real); real& rl1 = (real&) arr_imponibile[key]; - rl1 += rr.imponibile(TRUE); + rl1 += rr.imponibile(); if (!arr_imposta.is_key(key)) arr_imposta.add(key, new real); real& rl2 = (real&) arr_imposta[key]; - rl2 += rr.imposta(TRUE); + rl2 += rr.imposta(); } } cont.change_doc_status(*doc); @@ -372,26 +390,7 @@ void TScaricoAS400::transfer() } if (_datadocprec.ok()) // devo scrivere i record su file di testo - { scrivi_righe(arr_imponibile, arr_imposta); - /* - TString_array arrimp; - arr_imponibile.get_keys(arrimp, TRUE); - for (i=0;i