From 2d49557540242d7dd515046f91bb16f0afdc8283 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 15 Nov 2011 11:18:51 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : ha0.exe ha0200a.msk ha2.exe ha2200a.msk Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@22490 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ha/ha0200a.h | 1 + ha/ha0200a.uml | 13 ++++++- ha/ha0500.cpp | 19 ---------- ha/ha2100.cpp | 13 +++---- ha/ha2200.cpp | 97 ++++++++++++++++++++++++++++++++++++-------------- ha/ha2200a.h | 1 + ha/ha2200a.uml | 39 +++++--------------- 7 files changed, 101 insertions(+), 82 deletions(-) diff --git a/ha/ha0200a.h b/ha/ha0200a.h index 892a14633..100678d4a 100755 --- a/ha/ha0200a.h +++ b/ha/ha0200a.h @@ -68,6 +68,7 @@ #define F_E_COD_ESSELUNGA 305 #define F_E_TIPOEMISSIONE 306 #define F_E_DATACONF 307 +#define F_E_PRIVATPATH 308 //============================== //pagina 4 diff --git a/ha/ha0200a.uml b/ha/ha0200a.uml index 4a2f3c8bf..70dc40220 100755 --- a/ha/ha0200a.uml +++ b/ha/ha0200a.uml @@ -560,7 +560,7 @@ PAGE "Configurazione Esselunga" 0 2 0 0 STRING F_E_PATH 255 39 BEGIN - PROMPT 2 2 "Percorso files da spedire " + PROMPT 2 2 "Percorso file FATTURE da spedire " DSELECT FLAGS "M" CHECKTYPE REQUIRED @@ -568,6 +568,17 @@ BEGIN FIELD Esselunga_Path END +STRING F_E_PRIVATPATH 255 39 +BEGIN + PROMPT 2 3 "Percorso file PRIVAT da spedire " + DSELECT + FLAGS "M" + CHECKTYPE REQUIRED + WARNING "Selezionare una cartella valida!" + FIELD Esselunga_PrivatPath +END + + STRING F_E_PIVA_HARDY 12 BEGIN PROMPT 2 4 "Partita IVA Hardy " diff --git a/ha/ha0500.cpp b/ha/ha0500.cpp index 6737bae47..476e7ec4b 100755 --- a/ha/ha0500.cpp +++ b/ha/ha0500.cpp @@ -225,25 +225,6 @@ long THardy_elab_docs::genera_recordset(const TMask& mask, TISAM_recordset& recs TConfig config(CONFIG_DITTA, "ha"); const TString4 tipo_doc_to_elab = config.get("TipoFatt"); - /* - //e adesso cerca le numerazioni che contengono il tipo preso dalla configurazione - TString_array num_doc; - const int numerazioni_valide = find_numerazioni(tipo_doc_to_elab, num_doc); - if (numerazioni_valide > 0) - { - query << "&&("; - - for (int i = 0; i < numerazioni_valide; i++) - { - if (i > 0) - query << "||"; - - query << "(CODNUM='" << num_doc[i] << "')"; - } - - query << ")"; - } - */ // Inutile testare tutte le numerazioni, basta il tipo documento query << "&&(" << DOC_TIPODOC << "=='" << tipo_doc_to_elab << "')"; diff --git a/ha/ha2100.cpp b/ha/ha2100.cpp index d9656f641..49b346421 100755 --- a/ha/ha2100.cpp +++ b/ha/ha2100.cpp @@ -140,9 +140,10 @@ long THardy_esselunga::genera_recordset(const TMask& mask, TISAM_recordset& recs TFilename THardy_esselunga::scrivi_testata(const TMask& mask) { - const TString4 dipendenza = mask.get(F_DIPENDENZA); TConfig config(CONFIG_DITTA, "ha"); - TFilename file_privat = config.get("Esselunga_Path"); + TFilename file_privat = config.get("Esselunga_PrivatPath"); + + const TString& dipendenza = mask.get(F_DIPENDENZA); if (dipendenza[0] == 'D') file_privat.add("CDMI"); else @@ -192,15 +193,15 @@ void THardy_esselunga::elabora(const TMask& mask) const long codcf_esselunga = check_cliente(codcf, dipendenza); if ( codcf_esselunga > 0) { - TDocumento* doc = new TDocumento(recset.cursor()->curr()); + TDocumento doc(recset.cursor()->curr()); // passo tutte le righe del documento all'AS400recordset TString16 numdoc; - const TString& num = doc->numerazione(); - numdoc.format("%012d",doc->numero()); + const TString& num = doc.numerazione(); + numdoc.format("%012d",doc.numero()); numdoc << cache().get("%NUM", num, "S7"); numdoc.strip("/"); numdoc = numdoc.right(12); - FOR_EACH_PHYSICAL_RDOC(*doc, r, rigadoc) + FOR_EACH_PHYSICAL_RDOC(doc, r, rigadoc) { const TString& codart = rigadoc->get(RDOC_CODART); const TString& codart_esselunga = cache_ca.decode(codart); diff --git a/ha/ha2200.cpp b/ha/ha2200.cpp index a04247950..92c6b6d92 100755 --- a/ha/ha2200.cpp +++ b/ha/ha2200.cpp @@ -22,8 +22,6 @@ #include "ha2.h" #include "ha2200a.h" -const char* const APPNAME = TR("Esselunga: generazione file Fatture"); - /////////////////////////////////////////////////////////// // TAutomask /////////////////////////////////////////////////////////// @@ -280,7 +278,7 @@ TFatture_recordset::TFatture_recordset() add_field("DET.TIPOREC", AN, 3, 1, true, "DET"); add_field("DET.NUMRIGA", NU, 6, 4, true); add_field("DET.IDSOTTOR", AN, 3, 10); - add_field("DET.NUMSRIGA", AN, 6, 13); // AN perche'e' un campo che non c'e' mai e non deve essere zerofilled + add_field("DET.NUMSRIGA", AN, 6, 13); // AN perche' e' un campo che non c'e' mai e non deve essere zerofilled add_field("DET.CODEANCU", AN, 35, 19, true); add_field("DET.TIPCODCU", AN, 3, 54, true, "EN"); add_field("DET.CODEANTU", AN, 35, 57); @@ -406,11 +404,16 @@ TFatture_recordset::TFatture_recordset() /////////////////////////////////////// class THardy_esselunga_fat : public TSkeleton_application { + TCodArtEsselunga_cache _cache_ca; + protected: long genera_recordset(const TMask& mask, TISAM_recordset& recset); void elabora(const TMask& mask); void check_date(const TDate& datafine, TDate& dataini); TString4 check_cliente(const long codcf); + + void segnala_documento(const TDocumento& doc, TLog_report& log, const char* msg) const; + bool esistono_righe_esselunga(const TDocumento& doc) const; void add_rec_testata(TFatture_recordset& fat, TDocumento& doc); void add_rec_sommario(TFatture_recordset& fat, TDocumento& doc); void add_recs_dettaglio(TFatture_recordset& fat, TDocumento& doc); @@ -497,11 +500,12 @@ void THardy_esselunga_fat::add_rec_testata(TFatture_recordset& fat, TDocumento& fat.new_rec("FTX"); fat.new_rec("PAT"); - fat.set("PAT.DESCRIZ", doc.pagamento().name()); - fat.set("PAT.DATASCAD", TVariant(doc.pagamento().data_rata(0))); + const TPagamento& pag = doc.pagamento(); + fat.set("PAT.DESCRIZ", pag.name()); + fat.set("PAT.DATASCAD", TVariant(pag.data_rata(0))); fat.set("PAT.IMPORTO", TVariant(doc.totale_doc())); - TString8 tp = doc.pagamento().tipo_prima_rata(); - real imp = doc.pagamento().importo_rata(0); + TString8 tp = pag.tipo_prima_rata(); + real imp = pag.importo_rata(0); } void THardy_esselunga_fat::add_rec_sommario(TFatture_recordset& fat, TDocumento& doc) @@ -549,13 +553,24 @@ void THardy_esselunga_fat::add_rec_sommario(TFatture_recordset& fat, TDocumento& fat.set("TMA.TOTANT1", ""); } +bool THardy_esselunga_fat::esistono_righe_esselunga(const TDocumento& doc) const +{ + FOR_EACH_PHYSICAL_RDOC((TDocumento&)doc, r, rigadoc) + { + const TString& codart = rigadoc->get(RDOC_CODART); + const TString& codart_esselunga = ((TCodArtEsselunga_cache&)_cache_ca).decode(codart); + if (codart_esselunga.full()) + return true; + } + return false; +} + void THardy_esselunga_fat::add_recs_dettaglio(TFatture_recordset& fat, TDocumento& doc) { - TCodArtEsselunga_cache cache_ca; FOR_EACH_PHYSICAL_RDOC(doc, r, rigadoc) { const TString16 codart = rigadoc->get(RDOC_CODART); - const TString& codart_esselunga = cache_ca.decode(codart); + const TString& codart_esselunga = _cache_ca.decode(codart); if (codart_esselunga.blank()) continue; const TRectype& rec_anamag = cache().get(LF_ANAMAG, codart); @@ -576,7 +591,6 @@ void THardy_esselunga_fat::add_recs_dettaglio(TFatture_recordset& fat, TDocument fat.set("DES.DESCR", rigadoc->get(RDOC_DESCR)); //fat.new_rec("RFN"); // solo per note di debito e di credito (chiedere a Robbi) - fat.new_rec("TAX"); fat.set("TAX.ALIQIVA", rigadoc->iva().percentuale()); @@ -638,6 +652,25 @@ void THardy_esselunga_fat::add_recs_dettaglio(TFatture_recordset& fat, TDocument } } +void THardy_esselunga_fat::segnala_documento(const TDocumento& doc, TLog_report& log, const char* msg) const +{ + TString s; + s << TR("Doc. ") << doc.get(DOC_CODNUM) << ' ' + << doc.get(DOC_ANNO) << '/' << doc.get(DOC_NDOC) << " : "; + + if (msg && *msg) + { + s << msg; + log.log(1, s); + } + else + { + s << TR("Elaborato con successo"); + log.log(0, s); + } + +} + void THardy_esselunga_fat::elabora(const TMask& mask) { TLog_report log; @@ -648,41 +681,53 @@ void THardy_esselunga_fat::elabora(const TMask& mask) TISAM_recordset recset(""); const long items = genera_recordset(mask, recset); if (items == 0) - log.log(1, "Non esistono documenti che soddisfano i parametri selezionati."); + log.log(1, "Non esistono documenti che soddisfino i parametri selezionati."); // lettura dei documenti da recordset - TProgind pi(recset.items(), TR("Elaborazione documenti in corso..."), true, true); + TProgind pi(recset.items(), TR("Elaborazione documenti in corso...")); TFatture_recordset fatture; TCodArtEsselunga_cache cache_ca; const bool definitivo = mask.get_bool(F_DEFINITIVO); + const bool forzatura = mask.get_bool(F_FORZATURA); for (bool ok = recset.move_first(); ok; ok = recset.move_next()) { if (!pi.addstatus(1)) break; const long codcf = recset.get(DOC_CODCF).as_int(); - // verificare se il cliente ha tutti i parametri per poter essere inviato (invio e codice cliente per hardy) + // verificare se il cliente ha tutti i parametri per poter essere inviato (invio e codice cliente per Hardy) const TString4 codcf_esselunga = check_cliente(codcf); - if (codcf_esselunga.not_empty()) + if (codcf_esselunga.full()) { - TDocumento* doc = new TDocumento(recset.cursor()->curr()); - add_rec_testata(fatture, *doc); - add_recs_dettaglio(fatture, *doc); - add_rec_sommario(fatture, *doc); - if (definitivo) - doc->put("HA_FATTURE", "X"); + TDocumento doc(recset.cursor()->curr()); + if (doc.get_bool("HA_FATTURE") && !forzatura) + continue; + + if (esistono_righe_esselunga(doc)) + { + add_rec_testata(fatture, doc); + add_recs_dettaglio(fatture, doc); + add_rec_sommario(fatture, doc); + if (definitivo) + { + doc.put("HA_FATTURE", "X"); + doc.rewrite(); + } + segnala_documento(doc, log, NULL); + } + else + segnala_documento(doc, log, "Non contiene righe valide per Esselunga"); } // if check_cliente... } //for (bool ok = recset.move_first()... fatture.save_as(file_fatture, fmt_text); - log.print_or_preview(); + log.preview(); } TString4 THardy_esselunga_fat::check_cliente(const long codcf) { - TString4 codcf_hardy = ""; - TString key; - key.format("%ld", codcf); - const TRectype rec_cliente = cache().get("&CEL", key); + TString4 codcf_hardy; + TString8 key; key << codcf; + const TRectype& rec_cliente = cache().get("&CEL", key); const bool invio = rec_cliente.get_bool("B0"); const char dipendenza = rec_cliente.get("S1")[0]; if (invio) @@ -709,6 +754,6 @@ bool THardy_esselunga_fat::create() int ha2200 (int argc, char* argv[]) { THardy_esselunga_fat elabapp; - elabapp.run(argc, argv, APPNAME); + elabapp.run(argc, argv, TR("Esselunga: generazione file Fatture")); return 0; } \ No newline at end of file diff --git a/ha/ha2200a.h b/ha/ha2200a.h index 3d7c802b8..c62920303 100755 --- a/ha/ha2200a.h +++ b/ha/ha2200a.h @@ -4,6 +4,7 @@ #define F_DATAFIN 204 #define F_DEFINITIVO 205 #define F_SHEETDOC 206 +#define F_FORZATURA 207 // campi dello sheet #define F_S_CODNUM 101 #define F_S_DESNUM 102 diff --git a/ha/ha2200a.uml b/ha/ha2200a.uml index 3a03f3d44..9339da95c 100755 --- a/ha/ha2200a.uml +++ b/ha/ha2200a.uml @@ -16,41 +16,15 @@ ENDPAGE PAGE "Esselunga: generazione file Fatture" -1 -1 78 18 -GROUPBOX DLG_NULL 78 3 -BEGIN - PROMPT 1 0 "@bDitta" -END - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 2 1 "Codice " - FLAGS "GDF" - USE LF_NDITTE - INPUT CODDITTA F_CODDITTA - OUTPUT F_RAGSOC RAGSOC - CHECKTYPE REQUIRED -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 17 1 "Rag.Soc. " - FLAGS "D" -END - -GROUPBOX DLG_NULL 78 4 -BEGIN - PROMPT 1 3 "@bParametri" -END - DATE F_DATAINI BEGIN - PROMPT 2 4 "Documenti dal " + PROMPT 1 0 "Data iniziale " HELP "Data di inizio per trasferimento documenti" END DATE F_DATAFIN BEGIN - PROMPT 30 4 "al " + PROMPT 1 1 "Data finale " HELP "Data di fine per trasferimento documenti" CHECKTYPE REQUIRED VALIDATE DATE_CMP_FUNC >= F_DATAINI @@ -60,12 +34,17 @@ END BOOLEAN F_DEFINITIVO BEGIN - PROMPT 2 6 "Trasferimento definitivo" + PROMPT 35 0 "Trasferimento definitivo" +END + +BOOLEAN F_FORZATURA +BEGIN + PROMPT 35 1 "Includere documenti già trasferiti" END SPREADSHEET F_SHEETDOC 78 BEGIN - PROMPT 1 7 "Scelta documenti" + PROMPT 1 2 "Scelta documenti" ITEM "Cod. num." ITEM "Descrizione num.@50" END