From eb5814e0984e994536b3bee5196d04e47a456886 Mon Sep 17 00:00:00 2001 From: luca83 Date: Wed, 19 Aug 2009 09:47:20 +0000 Subject: [PATCH] Patch level : 10.0 patch 416 Files correlati : lv2 Ricompilazione Demo : [ ] Commento : Evitate le write di documenti che devono ancora essere popolati dalle righe; in questo modo si evitano errori in fase di riscritura degli stessi documenti git-svn-id: svn://10.65.10.50/trunk@19209 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- lv/lv2400.cpp | 57 +++++++++++++++++++++++++++++++++++++++------------ lv/lv2600.cpp | 56 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 87 insertions(+), 26 deletions(-) diff --git a/lv/lv2400.cpp b/lv/lv2400.cpp index 90649c87a..9409fbccf 100755 --- a/lv/lv2400.cpp +++ b/lv/lv2400.cpp @@ -45,11 +45,12 @@ class TGenera_documenti_app : public TSkeleton_application TAssoc_array _quantita_ritirata; TConfig* _configlv; char _buono; + long _ndoc; private: //Metodi per la generazione dei documenti - bool crea_documento(const TISAM_recordset& plan); - void crea_riga(const TString& codart, const char modpas, const int tplis, const bool tmp, const bool prinbo,TDocumento& doc); + bool crea_documento(const TISAM_recordset& plan, TLog_report& rep); + void crea_riga(const TString& codart, const char modpas, const int tplis, const bool tmp, const bool prinbo,TDocumento& doc, TLog_report& rep); //Metodi per il recupero di codnum, tpdoc, stato bool numerazione_ddt(TString& codnum, TString& tpdoc, TString& statoi, TString& statof) const; bool numerazione_drit(const int cod, TString& codnum, TString& tpdoc, TString& statoi, TString& statof) const; @@ -84,6 +85,8 @@ bool TGenera_documenti_app::create() { open_files(LF_DOC, 34, 0); _msk = new TGenera_documenti_mask("lv2400a"); + _ndoc = 0; + _configlv = new TConfig(CONFIG_DITTA,"lv"); _buono = *TApplication::argv(2); return TSkeleton_application::create(); @@ -111,7 +114,7 @@ bool TGenera_documenti_app::destroy() /////////////////////////////////////////////////////// //CREA_DOCUMENTO: metodo che crea un nuovo documento di trasporto dai dati salvati -bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan) +bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan, TLog_report& rep) { //recupero i dati di interesse dalla maschera const TDate datagen(TODAY); @@ -153,13 +156,22 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan) //se non trovo quale documento generare, evito il resto dell'elaborazione if (!numerazione_ddt(codnum, tpdoc, statoi, statof)) - return NOERR; - + return NOERR; + + if(_ndoc == 0) + { + TString query2; + query2 << "USE DOC\n" + << "FROM PROVV=\"D\" ANNO=" << anno << "CODNUM=\"" << codnum << "\"\n" + << "TO PROVV=\"D\" ANNO=" << anno << "CODNUM=\"" << codnum << "\""; + TISAM_recordset sporco(query2); + sporco.move_last(); + _ndoc = sporco.get(DOC_NDOC).as_int(); + } //creo il documento corretto riempiendo i campi che già conosco - TDocumento doc('D',anno,codnum,0); - doc.put(DOC_TIPODOC, tpdoc); - //doc.write(); + TDocumento doc('D', anno, codnum, ++_ndoc); + doc.put(DOC_TIPODOC, tpdoc); //calcola tutte le quantità riportate sui documenti di ritiro, sui documenti di anticipo e sulle bolle di consegna //...eventualmente modificate a mano @@ -197,7 +209,7 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan) FOR_EACH_ASSOC_OBJECT(_quantita,h,codart,obj) { - crea_riga(codart, modpas, tplis, false, prinbo, doc); + crea_riga(codart, modpas, tplis, false, prinbo, doc, rep); /*const TDate dadata = rcont.get(LVRCONDV_INDTTMP).as_date(); const TDate adata = rcont.get(LVRCONDV_FIDTTMP).as_date(); @@ -206,7 +218,7 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan) } if (doc.rows() > 0) - err = doc.write(); + err = doc.rewrite(); else doc.remove(); @@ -224,7 +236,7 @@ bool TGenera_documenti_app::crea_documento(const TISAM_recordset& plan) } //CREA_RIGA: questa funzione crea una riga merce per una bolla di consegna -void TGenera_documenti_app::crea_riga(const TString& codart, const char modpas, const int tplis, const bool tmp, const bool prinbo, TDocumento& doc) +void TGenera_documenti_app::crea_riga(const TString& codart, const char modpas, const int tplis, const bool tmp, const bool prinbo, TDocumento& doc, TLog_report& rep) { const int perarr = _configlv->get_int("Perarr"); @@ -388,6 +400,17 @@ void TGenera_documenti_app::crea_riga(const TString& codart, const char modpas, rdoc.put(RDOC_CODMAG, magazzino); rdoc.put(RDOC_CODMAGC, magazzinoc); + + //se il record di riga contratto è vuoto aggiorno il log + if (rcont.empty()) + { + TString str; + str << "L'articolo " << codart << " inserito nel documento " << doc.get(DOC_CODNUM) << "-" << doc.get(DOC_TIPODOC) + << " numero " << doc.get(DOC_NDOC) << " in quantità " << quantita_arr + << "non è prsente sul contratto del cliente " << codcli; + rep.log(1, str); + } + } ////////////////////////////////////////////////////////////// @@ -766,6 +789,9 @@ bool TGenera_documenti_app::transfer() TString4 statof; // bool err; + TLog_report rep("Articoli non in contratto"); + rep.kill_duplicates(); + numerazione_drit(0, codnum, tpdoc, statoi, statof); //instanzio un recordset che contiene tutti i documenti di interesse @@ -829,11 +855,16 @@ bool TGenera_documenti_app::transfer() { _quantita.destroy(); _quantita_ritirata.destroy(); - crea_documento(plan); + crea_documento(plan, rep); } } - message_box(TR("Generazione terminata")); + TReport_book buc; + buc.add(rep); + if (buc.pages() > 0) + buc.preview(); + else + message_box(TR("Generazione terminata")); return true; } void TGenera_documenti_app::main_loop() diff --git a/lv/lv2600.cpp b/lv/lv2600.cpp index 0511d4b03..92a4db4d9 100755 --- a/lv/lv2600.cpp +++ b/lv/lv2600.cpp @@ -68,6 +68,7 @@ TAcquisizione_msk::TAcquisizione_msk():TAutomask("lv2600a") class TAcquisizione_cache : public TCache { TString4 _codnum, _tipodoc, _stato; + long _ndoc; protected: virtual void discarding(const THash_object* obj); @@ -92,9 +93,20 @@ TObject* TAcquisizione_cache::key2obj(const char* key) const TDate datadoc = chiave.get(); const TDate datagen(TODAY); TDate adata = datagen; - adata.set_month(datagen.month() + 1); + adata.addmonth(); const long codcf = chiave.get_long(); + if(_ndoc == 0) + { + TString query2; + query2 << "USE DOC\n" + << "FROM PROVV=\"D\" ANNO=" << datadoc.year() << "CODNUM=\"" << _codnum << "\"\n" + << "TO PROVV=\"D\" ANNO=" << datadoc.year() << "CODNUM=\"" << _codnum << "\""; + TISAM_recordset sporco(query2); + sporco.move_last(); + _ndoc = sporco.get(DOC_NDOC).as_int(); + } + TString query = "USE DOC KEY 2\n"; query << "SELECT (TIPODOC=\"" << _tipodoc << "\" && STATO=" << _stato <<")\n"; query << "FROM TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << datadoc.year() << " DATADOC=" << datadoc << " CODNUM=" << _codnum << "\n"; @@ -117,7 +129,7 @@ TObject* TAcquisizione_cache::key2obj(const char* key) consegne.move_first(); const TDate dataprco = consegne.get(LVRCONSPLAN_DTCONS).as_date(); - doc = new TDocumento('D',datadoc.year(),_codnum,0); + doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc); doc->put(DOC_TIPODOC, _tipodoc); doc->put(DOC_STATO, _stato); doc->put(DOC_DATADOC, datadoc); @@ -126,8 +138,7 @@ TObject* TAcquisizione_cache::key2obj(const char* key) doc->put(DOC_CODCONT, codcont); doc->put("DATACON", datadoc); //data conteggio doc->put("DATAGEN", datagen); //data generazione del documento - doc->put("DATAPRCO", dataprco); //data prevista consegna - //doc->write(); // Scrivo subito per prenotare il numero documento + doc->put("DATAPRCO", dataprco); //data prevista consegna } return doc; } @@ -143,10 +154,11 @@ TDocumento& TAcquisizione_cache::doc(const TDate& gg, const long cc) //metodo costruttore di una cache di 17 elementi TAcquisizione_cache::TAcquisizione_cache() : TCache(17) { - TConfig cfg(CONFIG_DITTA, "lv"); - _codnum = cfg.get("NUM_RIT", NULL, 0); - _tipodoc = cfg.get("TIPODOC_RIT", NULL, 0); - _stato = cfg.get("STATO_RIT", NULL, 0); + _codnum = ini_get_string(CONFIG_DITTA, "lv", "NUM_RIT(0)"); + _tipodoc = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_RIT(0)"); + _stato = ini_get_string(CONFIG_DITTA, "lv", "STATO_RIT(0)"); + + _ndoc = 0; } //////////////////////////////////////////// @@ -164,7 +176,7 @@ protected: virtual bool create(); virtual bool destroy(); - void elabora_file(const TString& file, bool new_file); + void elabora_file(const TString& file, bool new_file, TLog_report &rep); public: @@ -192,7 +204,7 @@ bool TAcquisizione_lavanderie_app::destroy() } //ELABORA_FILE: metodo che effettivamente fa l'elaborazione del file, creando i documenti -void TAcquisizione_lavanderie_app::elabora_file(const TString& file, bool new_file) +void TAcquisizione_lavanderie_app::elabora_file(const TString& file, bool new_file, TLog_report &rep) { TAcquisizione_cache ca; @@ -277,6 +289,16 @@ void TAcquisizione_lavanderie_app::elabora_file(const TString& file, bool new_fi default: return; } } + else + { + if (!doc.get_date("DATAPRCO").ok()) + { + TString msg; + msg << TR("Il documento ") << doc.get(DOC_NDOC) << TR(" del ") << doc.get(DOC_DATADOC) + << TR(" del cliente ") << codcf << TR(" non ha data di prevista consegna."); + rep.log(1,msg); + } + } //se voglio sovrascrivere i file, e non l'ho mai cancellato, allora svuotalo effettivamente const TString8 numdoc = doc.get(DOC_NDOC); @@ -354,6 +376,9 @@ bool TAcquisizione_lavanderie_app::transfer() const TString& path = _msk->get(F_PATH); TSheet_field& sheet = _msk->sfield(F_SHEET_NAME); TFilename file; + + TLog_report logrep("Aquisizione da contapezzi"); + logrep.kill_duplicates(true); //per ogni riga dello sheet, leggo il suo contenuto, se contiene dei caratteri jolly //preparo la lista dei file che soddisfano la maschera in quella directory e li elaboro @@ -376,14 +401,19 @@ bool TAcquisizione_lavanderie_app::transfer() list_files(file, lista_file); FOR_EACH_ARRAY_ROW(lista_file, r2, row2) - elabora_file(*row2, true); + elabora_file(*row2, true, logrep); } else - elabora_file(file, true); + elabora_file(file, true, logrep); } } - message_box(TR("Generazione terminata")); + TReport_book buc; + buc.add(logrep); + if (buc.pages() > 0) + buc.preview(); + else + message_box(TR("Generazione terminata")); return true; }