From 401223fad3da7aee80d40f265885d3deb88f32f8 Mon Sep 17 00:00:00 2001 From: cris Date: Tue, 12 Apr 2011 13:38:18 +0000 Subject: [PATCH] Patch level : Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@21936 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ha/ha2100.cpp | 62 +------- ha/ha2100a.uml | 6 +- ha/ha2200.cpp | 397 +++++++++++++++++++++++++++++++------------------ ha/ha2200a.h | 5 +- ha/ha2200a.uml | 17 +-- ha/halib.cpp | 27 ++++ ha/halib.h | 14 ++ 7 files changed, 301 insertions(+), 227 deletions(-) diff --git a/ha/ha2100.cpp b/ha/ha2100.cpp index 50af7b498..aad9f33dc 100755 --- a/ha/ha2100.cpp +++ b/ha/ha2100.cpp @@ -13,6 +13,8 @@ #include "../cg/cglib01.h" #include "../ve/velib.h" +#include "halib.h" + #include "ha2.h" #include "ha2100a.h" @@ -37,69 +39,9 @@ THardy_esselunga_mask::THardy_esselunga_mask() : TAutomask ("ha2100a") bool THardy_esselunga_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { - switch (o.dlg()) - { - case F_DATAINI: - if (e == fe_close || e == fe_modify) - { - //se la data iniziale è piena -> l'anno deve essere lo stesso nelle 2 date; - //se invece è vuota -> la data iniziale viene presa come la data iniziale dell'esercizio della data finale... - //..ma questo qui non serve e viene rinviato alla query principale del recordset - const TDate datafin = get_date(F_DATAFIN); - TEsercizi_contabili esc; - const int datafin_esc = esc.date2esc(datafin); - - TDate dataini = o.get(); - if (dataini.ok()) - { - const int dataini_esc = esc.date2esc(dataini); - if (datafin_esc != dataini_esc) - return error_box("Le date devono appartenere allo stesso esercizio!"); - } - } - break; - default: - break; - } return true; } -/////////////////////////////////////////////////////////// -// TCodArtEsselunga_cache -/////////////////////////////////////////////////////////// - -class TCodArtEsselunga_cache : public TCache -{ -protected: - virtual TObject* key2obj(const char* key); - -public: - const TString& decode(const TString& codart); - TCodArtEsselunga_cache() {} -}; - -TObject* TCodArtEsselunga_cache::key2obj(const char* key) -{ - TToken_string code(key); - TString80 codart; code.get(0, codart); - const TString& codcf = ini_get_string(CONFIG_DITTA, "ha", "Esselunga_CodEsselunga"); - TISAM_recordset codcorr("USE CODCORR\nSELECT CODCF=#CODCF\nFROM CODART=#COD\nTO CODART=#COD"); - codcorr.set_var("#COD", TVariant(codart)); - codcorr.set_var("#CODCF", TVariant(codcf)); - if (codcorr.items()>0) - { - codcorr.move_first(); - return new TString80(codcorr.get(CODCORR_CODARTALT).as_string()); - } - else - return new TString80(codart); -} - -const TString& TCodArtEsselunga_cache::decode(const TString& codart) -{ - return *(const TString*)objptr(codart); -} - ///////////////////////////////////////////////////////////// // Recordset per file privat ///////////////////////////////////////////////////////////// diff --git a/ha/ha2100a.uml b/ha/ha2100a.uml index e27a526f8..30c4129bf 100755 --- a/ha/ha2100a.uml +++ b/ha/ha2100a.uml @@ -53,9 +53,6 @@ DATE F_DATAINI BEGIN PROMPT 2 4 "Documenti dal " HELP "Data di inizio per trasferimento documenti" - CHECKTYPE REQUIRED - WARNING "Data dal non valida" - FLAGS "A" END DATE F_DATAFIN @@ -64,7 +61,8 @@ BEGIN HELP "Data di fine per trasferimento documenti" CHECKTYPE REQUIRED VALIDATE DATE_CMP_FUNC >= F_DATAINI - WARNING "Data di fine scadenza non valida" + WARNING "Data di fine non valida" + FLAGS "A" END LISTBOX F_DIPENDENZA 10 diff --git a/ha/ha2200.cpp b/ha/ha2200.cpp index 7bd423bda..67c3c401b 100755 --- a/ha/ha2200.cpp +++ b/ha/ha2200.cpp @@ -7,12 +7,18 @@ #include #include +#include +#include +#include +#include #include #include #include "../mg/codcorr.h" #include "../cg/cglib01.h" #include "../ve/velib.h" +#include "halib.h" + #include "ha2.h" #include "ha2200a.h" @@ -37,69 +43,9 @@ THardy_esselunga_fat_mask::THardy_esselunga_fat_mask() : TAutomask ("ha2200a") bool THardy_esselunga_fat_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { - switch (o.dlg()) - { - case F_DATAINI: - if (e == fe_close || e == fe_modify) - { - //se la data iniziale è piena -> l'anno deve essere lo stesso nelle 2 date; - //se invece è vuota -> la data iniziale viene presa come la data iniziale dell'esercizio della data finale... - //..ma questo qui non serve e viene rinviato alla query principale del recordset - const TDate datafin = get_date(F_DATAFIN); - TEsercizi_contabili esc; - const int datafin_esc = esc.date2esc(datafin); - - TDate dataini = o.get(); - if (dataini.ok()) - { - const int dataini_esc = esc.date2esc(dataini); - if (datafin_esc != dataini_esc) - return error_box("Le date devono appartenere allo stesso esercizio!"); - } - } - break; - default: - break; - } return true; } -/////////////////////////////////////////////////////////// -// TCodArtEsselunga_cache -/////////////////////////////////////////////////////////// - -class TCodArtEsselunga_cache : public TCache -{ -protected: - virtual TObject* key2obj(const char* key); - -public: - const TString& decode(const TString& codart); - TCodArtEsselunga_cache() {} -}; - -TObject* TCodArtEsselunga_cache::key2obj(const char* key) -{ - TToken_string code(key); - TString80 codart; code.get(0, codart); - const TString& codcf = ini_get_string(CONFIG_DITTA, "ha", "Esselunga_CodEsselunga"); - TISAM_recordset codcorr("USE CODCORR\nSELECT CODCF=#CODCF\nFROM CODART=#COD\nTO CODART=#COD"); - codcorr.set_var("#COD", TVariant(codart)); - codcorr.set_var("#CODCF", TVariant(codcf)); - if (codcorr.items()>0) - { - codcorr.move_first(); - return new TString80(codcorr.get(CODCORR_CODARTALT).as_string()); - } - else - return new TString80(codart); -} - -const TString& TCodArtEsselunga_cache::decode(const TString& codart) -{ - return *(const TString*)objptr(codart); -} - ///////////////////////////////////////////////////////////// // Recordset per file fatture ///////////////////////////////////////////////////////////// @@ -111,7 +57,7 @@ class TFatture_recordset : public TAS400_recordset void add_field(const char* name, TFE_type type, int len, int pos, bool required = false, const char* def = NULL); public: - TFatture_recordset(const TString4 dipendenza); + TFatture_recordset(); }; void TFatture_recordset::add_field(const char* name, TFE_type type, int len, int pos, @@ -138,38 +84,242 @@ void TFatture_recordset::add_field(const char* name, TFE_type type, int len, int CHECKS(ok, "Impossibile creare il campo ", (const char*)name); } -TFatture_recordset::TFatture_recordset(const TString4 dipendenza) -: TAS400_recordset("AS400(400)") +TFatture_recordset::TFatture_recordset() +: TAS400_recordset("AS400(610)") { + // dati di configurazione TConfig config(CONFIG_DITTA, "ha"); const TString80 piva_hardy = config.get("Esselunga_PIvaHardy"); const TString80 piva_esselunga = config.get("Esselunga_PIvaEsselunga"); const TString8 tipo_emissione = config.get("Esselunga_TipoEmissione"); + const long codcli_esselunga = config.get_long("Esselunga_CodEsselunga"); + const TString80 cod_hardy = config.get("Esselunga_CodHardy"); + + // record cliente Esselunga + TToken_string key; + key.add("C"); key.add(codcli_esselunga); + const TRectype& cliente_esselunga = cache().get(LF_CLIFO, key); + TString4 stato = cliente_esselunga.get(CLI_STATOCF); + TString4 comune = cliente_esselunga.get(CLI_COMCF); + key.cut(0); + key.add(stato); key.add(comune); + const TRectype& com_esselunga = cache().get(LF_COMUNI, key); + + // ditta + const TFirm& ditta = prefix().firm(); + // record anag + const char tipoa = ditta.get(NDT_TIPOA)[0]; + const long codanagr = ditta.get_long(NDT_CODANAGR); + key.cut(0); + key.add(tipoa); key.add(codanagr); + const TRectype& anag = cache().get(LF_ANAG, key); + + // record anagiu + key.cut(0); + key.add(codanagr); + const TRectype& anagiu = cache().get(LF_ANAGGIU, key); + + // record comuni per hardy + stato = anag.get(ANA_STATORES); + comune = anag.get(ANA_COMRES); + key.add(stato, 0); key.add(comune, 1); + const TRectype& comres = cache().get(LF_COMUNI, key); + + // *** Sezione di intestazione fattura *** // Record BGM: nome documento e numero fattura - add_field("BGM.TIPOREC", "AN", 3, 1, true, "BGM"); - add_field("BGM.ID-EDI-MITT-1", "AN", 35, 4, true, piva_hardy); - add_field("BGM.ID-EDI-MITT-2", "AN", 4, 39, true, tipo_emissione); - add_field("BGM.ID-EDI-MITT-3", "AN", 14, 43); - add_field("BGM.ID-EDI-DEST-1", "AN", 35, 57, true, piva_esselunga); - add_field("BGM.ID-EDI-DEST-2", "AN", 4, 92, true, tipo_emissione); - add_field("BGM.ID-EDI-DEST-3", "AN", 14, 96); - add_field("BGM.TIPODOC", "AN", 6, 110, true); - add_field("BGM.NUMDOC", "AN", 35, 116, true); - add_field("BGM.DATADOC", "NU", 8, 151, true); - add_field("BGM.ORADOC", "NU", 4, 159); - add_field("BGM.FILLER", "AN", 6, 163); + add_field("BGM.TIPOREC", AN, 3, 1, true, "BGM"); + add_field("BGM.ID-EDI-MITT-1", AN, 35, 4, true, piva_hardy); + add_field("BGM.ID-EDI-MITT-2", AN, 4, 39, true, tipo_emissione); + add_field("BGM.ID-EDI-MITT-3", AN, 14, 43); + add_field("BGM.ID-EDI-DEST-1", AN, 35, 57, true, piva_esselunga); + add_field("BGM.ID-EDI-DEST-2", AN, 4, 92, true, tipo_emissione); + add_field("BGM.ID-EDI-DEST-3", AN, 14, 96); + add_field("BGM.TIPODOC", AN, 6, 110, true); + add_field("BGM.NUMDOC", AN, 35, 116, true); + add_field("BGM.DATADOC", NU, 8, 151, true); + add_field("BGM.ORADOC", NU, 4, 159); + add_field("BGM.FILLER", AN, 6, 163); - const TString80 cod_hardy = config.get("Esselunga_CodHardy"); + + TString80 str; + str << ditta.get(ANA_INDRES) << ", " << ditta.get(ANA_CIVRES); // Record NAS: identificazione mittente - add_field("BGM.TIPOREC", "AN", 3, 1, true, "NAS"); - add_field("BGM.CODFORN", "AN", 17, 4, true, cod_hardy); - add_field("BGM.QCODFORN", "AN", 3, 21, true, "92"); - add_field("BGM.RAGSOCF", "AN", 70, 24, true, ); + add_field("NAS.TIPOREC", AN, 3, 1, true, "NAS"); + add_field("NAS.CODFORN", AN, 17, 4, true, cod_hardy); + add_field("NAS.QCODFORN", AN, 3, 21, true, "92"); + add_field("NAS.RAGSOCF", AN, 70, 24, true, ditta.ragione_sociale()); + add_field("NAS.INDIRF", AN, 70, 94, true, str); + add_field("NAS.CITTAF", AN, 35, 164, true, comres.get(COM_DENCOM)); + add_field("NAS.PROVF", AN, 9, 199, true, comres.get(COM_PROVCOM)); + add_field("NAS.CAPF", AN, 9, 208, true, anag.get(ANA_CAPRES)); + add_field("NAS.NAZIOF", AN, 3, 217, true, anag.get(ANA_STATORES)); + add_field("NAS.PIVANAZF", AN, 35, 220, true, anag.get(ANA_PAIV)); + add_field("NAS.TRIBUNALE", AN, 35, 255, true, "MILANO"); + add_field("NAS.LICIMPEXP", AN, 35, 290); + add_field("NAS.CCIAA", AN, 35, 325, true, ditta.get(NDT_NISCRAA)); + add_field("NAS.CAPSOC", AN, 35, 360, true, anagiu.get("CAPSOC")); + add_field("NAS.CODFISC", AN, 35, 395, true, anag.get(ANA_COFI)); + add_field("NAS.PIVAINT", AN, 35, 430); + add_field("NAS.TELEFONO", AN, 25, 465); + add_field("NAS.TELEFAX", AN, 25, 490); + add_field("NAS.TELEX", AN, 25, 515); + add_field("NAS.EMAIL", AN, 70, 540); + str.cut(0); + str << cliente_esselunga.get(CLI_INDCF) << ", " << cliente_esselunga.get(CLI_CIVCF); + // Record NAI: identificazione destinatario + add_field("NAI.TIPOREC", AN, 3, 1, true, "NAI"); + add_field("NAI.CODFATT", AN, 17, 4, true, piva_esselunga); // verificare con Robbi perche' nell'esempio c'e' un altro numero + add_field("NAI.QCODFATT", AN, 3, 21, true, "VA"); + add_field("NAI.RAGSOCI", AN, 70, 24, true, cliente_esselunga.get(CLI_RAGSOC)); + add_field("NAI.INDIRI", AN, 70, 94, true, str); + add_field("NAI.CITTAI", AN, 35, 164, true, com_esselunga.get(COM_DENCOM)); + add_field("NAI.PROVI", AN, 9, 199, true, com_esselunga.get(COM_PROVCOM)); + add_field("NAI.CAPI", AN, 9, 208, true, cliente_esselunga.get(CLI_CAPCF)); + add_field("NAI.NAZIOI", AN, 3, 217, true, cliente_esselunga.get(CLI_STATOCF)); + add_field("NAI.PIVANAZI", AN, 35, 220, true, cliente_esselunga.get(CLI_PAIV)); + add_field("NAI.FILLER", AN, 51, 255); + // Record FTX: divisa di pagamento + add_field("FTX.TIPOREC", AN, 3, 1, true, "FTX"); + add_field("FTX.DIVISA", AN, 3, 4, true, "EUR"); + add_field("FTX.NOTE", AN,350, 7); + + // Record PAT: condizioni di pagamento standard + add_field("PAT.TIPOREC", AN, 3, 1, true, "PAT"); + add_field("PAT.TIPOCONDC", AN, 3, 4, true, "10E"); + add_field("PAT.DATASCAD", NU, 8, 7); + add_field("PAT.RIFTERMP", AN, 3, 15, true); + add_field("PAT.RELTERMP", AN, 3, 18); + add_field("PAT.UNTEMP", AN, 3, 21); + add_field("PAT.NUNTEMP", NU, 3, 24); + add_field("PAT.IMPORTO", NU, 16, 27); + add_field("PAT.DIVISA", AN, 3, 43); + add_field("PAT.PERC", NU, 7, 46); + add_field("PAT.DESCRIZ", AN, 35, 53, true); + add_field("PAT.BANCACOD", AN, 35, 88); + add_field("PAT.BANCADESC", AN, 35, 123); + add_field("PAT.FACTOR", AN, 35, 158); + add_field("PAT.CODPAG", AN, 3, 193); + add_field("PAT.MEZZOPAG", AN, 3, 196); + + // *** Sezione di dettaglio fattura *** + + // Record DET: identificazione, quantita'e prezzi articolo + 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", NU, 6, 13); + add_field("DET.CODEANCU", AN, 35, 19, true); + add_field("DET.TIPCODCU", AN, 3, 54, true, "EN"); + add_field("DET.CODEANTU", AN, 35, 57); + add_field("DET.CODFORTU", AN, 35, 92); + add_field("DET.CODDISTU", AN, 35, 127); + add_field("DET.TIPQUANT", AN, 3, 162); + add_field("DET.QTACONS", NU, 16, 165); + add_field("DET.UDMQCONS", AN, 3, 181); + add_field("DET.QTAFATT", NU, 16, 184); + add_field("DET.UDMQFATT", AN, 3, 200); + add_field("DET.NRCUINTU", NU, 16, 203, true); + add_field("DET.UDMNRCUINTU", AN, 3, 219, true, "PCE"); + add_field("DET.PRZUNI", NU, 16, 222, true); + add_field("DET.TIPORPZ", AN, 3, 238, true, "AAA"); // prezzo netto + add_field("DET.UDMPRZUN", AN, 3, 241, true); + add_field("DET.PRZUN2", NU, 16, 244, true); + add_field("DET.TIPOPRZ2", AN, 3, 260, true, "AAB"); // prezo lordo + add_field("DET.UDMPRZUN2", AN, 3, 263, true); + add_field("DET.IMPORTO", NU, 16, 266, true); + add_field("DET.DIVRIGA", AN, 3, 282); + add_field("DET.IMPORTO2", NU, 16, 285); + add_field("DET.DIVRIGA2", AN, 3, 301); + + // Record DES: descrizione articolo + add_field("DES.TIPOREC", AN, 3, 1, true, "DES"); + add_field("DES.DESCR", AN,175, 3, true); + + // Record RFN: riferimenti fatture (obbligatorio per note di credito e debito) + add_field("RFN.TIPOREC", AN, 3, 1, true, "RFN"); + add_field("RFN.TIPORIF", AN, 3, 4, true, "IV"); + add_field("RFN.RIFACCADD", AN, 35, 7, true); + add_field("RFN.DATARIF", AN, 8, 42, true); + + // Record TAX: informazioni assoggettamento iva + add_field("TAX.TIPOREC", AN, 3, 1, true, "TAX"); + add_field("TAX.TIPOTASS", AN, 3, 4, true, "VAT"); + add_field("TAX.DESCRIZ", AN, 35, 7); + add_field("TAX.CATIMP", AN, 3, 42, true); + add_field("TAX.ALIQIVA", NU, 7, 45, true); + add_field("TAX.IMPORTO", NU, 16, 52, true); + + // Record ALD: sconti di riga + add_field("ALD.TIPOREC", AN, 3, 1, true, "ALD"); + add_field("ALD.INDSCADD", AN, 3, 4); + add_field("ALD.DESCR", AN, 35, 7); + add_field("ALD.INDSEQ", NU, 3, 42); + add_field("ALD.TIPOSCADD", AN, 6, 45); + add_field("ALD.IMPORTO", NU, 16, 51); + add_field("ALD.PERC", NU, 7, 67, true); + add_field("ALD.FLGPRZUN", AN, 3, 74); + + // Record NAD: identificazione punto di consegna + add_field("NAD.TIPOREC", AN, 3, 1, true, "NAD"); + add_field("NAD.CODCONS", AN, 17, 4); + add_field("NAD.QCODCONS", AN, 3, 21, true, "92"); + add_field("NAD.RAGSOCD", AN, 70, 24, true); + add_field("NAD.INDIRD", AN, 70, 94, true); + add_field("NAD.CITTAD", AN, 35, 164, true); + add_field("NAD.PROVD", AN, 9, 199, true); + add_field("NAD.CAPD", AN, 9, 208, true); + add_field("NAD.NAZIOD", AN, 3, 217, true); + add_field("NAD.NUMBOLLA", AN, 35, 220, true); + add_field("NAD.DATABOLL", NU, 8, 255, true); + add_field("NAD.NUMORD", AN, 35, 263, true); + add_field("NAD.DATAORD", NU, 8, 298, true); + + // *** Sezione di sommario fattura + + // Record FTT: note di sommario + add_field("FTT.TIPOREC", AN, 3, 1, true, "FTT"); + add_field("FTT.TIPONOTA", AN, 3, 4); + add_field("FTT.NOTE", AN,350, 7); + + // Record ALT: sconto di sommario + add_field("ALT.TIPOREC", AN, 3, 1, true, "ALT"); + add_field("ALT.INDSCADD", AN, 3, 4, true); + add_field("ALT.DESCR", AN, 35, 7); + add_field("ALT.INDSEQ", NU, 3, 42); + add_field("ALT.TIPOSCADD", AN, 6, 45); + add_field("ALT.IMPORTO", NU, 16, 51, true); + add_field("ALT.PERC", NU, 7, 67, true); + + // Record IVA: subtotali imposte + add_field("IVA.TIPOREC", AN, 3, 1, true, "IVA"); + add_field("IVA.TIPOTASS", AN, 3, 4, true, "VAT"); + add_field("IVA.DESCRIZ", AN, 35, 7); + add_field("IVA.CATIMP", AN, 3, 42, true); + add_field("IVA.ALIQIVA", NU, 7, 45); + add_field("IVA.SIMPONIB", NU, 16, 52, true); + add_field("IVA.SIMPORTO", NU, 16, 68); + + // Record TMA: totali documento + add_field("TMA.TIPOREC", AN, 3, 1, true, "TMA"); + add_field("TMA.TOTDOC1", NU, 16, 4, true); + add_field("TMA.IMPOSTA1", NU, 16, 20, true); + add_field("TMA.IMPONIB1", NU, 16, 36, true); + add_field("TMA.TOTRIGHE1", NU, 16, 52, true); + add_field("TMA.TOTANT1", NU, 16, 68); + add_field("TMA.TOTPAG1", NU, 16, 84); + add_field("TMA.DIVISA1", AN, 3, 100); + add_field("TMA.TOTDOC2", NU, 16, 103); + add_field("TMA.IMPOSTA2", NU, 16, 119); + add_field("TMA.IMPONIB2", NU, 16, 135); + add_field("TMA.TOTRIGHE2", NU, 16, 151); + add_field("TMA.TOTANT2", NU, 16, 167); + add_field("TMA.TOTPAG2", NU, 16, 183); + add_field("TMA.DIVISA2", AN, 3, 199); } /////////////////////////////////////// @@ -181,8 +331,7 @@ protected: long genera_recordset(const TMask& mask, TISAM_recordset& recset); void elabora(const TMask& mask); void check_date(const TDate& datafine, TDate& dataini); - long check_cliente(const long codcf, const TString4 dipendenza); - TFilename scrivi_testata(const TMask& mask); + long check_cliente(const long codcf); public: virtual void main_loop(); @@ -243,89 +392,47 @@ long THardy_esselunga_fat::genera_recordset(const TMask& mask, TISAM_recordset& recset.set_var("#DATAFIN", datafin); return recset.items(); } -TFilename THardy_esselunga_fat::scrivi_testata(const TMask& mask) -{ - const TString4 dipendenza = mask.get(F_DIPENDENZA); - TConfig config(CONFIG_DITTA, "ha"); - TFilename file_privat = config.get("Esselunga_Path"); - if (dipendenza[0] == 'D') - file_privat.add("CDMI"); - else - file_privat.add("CDFI"); - file_privat.ext("txt"); - ofstream file_output(file_privat); - TString record(260); - // tipo record/filler/tot_record/progr_record - record = "PVT*?*001001"; - // nome del file - record << file_privat.name(); - // identificativo mittente - record.overwrite(config.get("Esselunga_PIvaHardy"), 85); - record.overwrite(config.get("Esselunga_TipoEmissione"), 120); - // identificativo destinatario - record.overwrite(config.get("Esselunga_PIvaEsselunga"), 138); - record.overwrite(config.get("Esselunga_TipoEmissione"), 173); - // formato (Ascii) - record.overwrite("A", 191); - // identificativo univoco del documento - record.overwrite("0000000000000001", 243); - file_output << record << endl; - file_output.close(); - return file_privat; -} void THardy_esselunga_fat::elabora(const TMask& mask) { TLog_report log; - const TString4 dipendenza = mask.get(F_DIPENDENZA); - TFilename file_privat = scrivi_testata(mask); + TConfig config(CONFIG_DITTA, "ha"); + TFilename file_fatture = config.get("Esselunga_Path"); + file_fatture.add("FATTURE"); + file_fatture.ext("txt"); TISAM_recordset recset(""); const long items = genera_recordset(mask, recset); if (items == 0) log.log(1, "Non esistono documenti che soddisfano i parametri selezionati."); // lettura dei documenti da recordset - TProgind pi(recset.items(), TR("Elaborazione documenti in corso..."), true, true); - TPrivat_recordset privat(dipendenza); + TProgind pi(recset.items(), TR("Elaborazione documenti in corso..."), true, true); + TFatture_recordset fatture; TCodArtEsselunga_cache cache_ca; 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 appartiene alla dipendenza selezionata e se ha tutti i parametri per poter essere inviato - const long codcf_esselunga = check_cliente(codcf, dipendenza); + // verificare se il cliente ha tutti i parametri per poter essere inviato (invio e codice cliente per hardy) + const long codcf_esselunga = check_cliente(codcf); if ( codcf_esselunga > 0) { TDocumento* doc = new TDocumento(recset.cursor()->curr()); - // passo tutte le righe del documento all'AS400recordset - TString16 numdoc; - 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) { + const TString80& codart_esselunga = cache_ca.decode(rigadoc->get(RDOC_CODART)); - privat.new_rec(""); - privat.set("CDC", TVariant(codcf_esselunga)); - privat.set("CODART", codart_esselunga); - privat.set("NUMBOLLA", numdoc); - privat.set("DATABOLLA", recset.get(DOC_DATADOC)); - real qta = rigadoc->get_real(RDOC_QTA); - TString16 qtastr = qta.string(8,2,'0'); - qtastr.strip("."); - privat.set("QTACONS", qtastr); - privat.set("QTARESA", "0000000"); + fatture.new_rec(""); + //fatture.set("CDC", TVariant(codcf_esselunga)); + //fatture.set("CODART", codart_esselunga); + //fatture.set("NUMBOLLA", numdoc); } //FOR_EACH... } // if check_cliente... } //for (bool ok = recset.move_first()... - TFilename tempfile; - tempfile.temp(); - privat.save_as(tempfile, fmt_text); - fcopy(tempfile, file_privat, true); + fatture.save_as(file_fatture, fmt_text); // memorizzo su campo virtuale che il doc. e' stato inviato const bool definitivo = mask.get_bool(F_DEFINITIVO); if (definitivo) @@ -335,7 +442,7 @@ void THardy_esselunga_fat::elabora(const TMask& mask) log.print_or_preview(); } -long THardy_esselunga_fat::check_cliente(const long codcf, const TString4 dipendenza) +long THardy_esselunga_fat::check_cliente(const long codcf) { long codcf_hardy = -1; TString key; @@ -343,11 +450,7 @@ long THardy_esselunga_fat::check_cliente(const long codcf, const TString4 dipend const TRectype rec_cliente = cache().get("&CEL", key); const bool invio = rec_cliente.get_bool("B0"); if (invio) - { - const char dip_cliente = rec_cliente.get("S1")[0]; - if (dip_cliente == dipendenza[0]) - codcf_hardy = rec_cliente.get_long("I0"); - } + codcf_hardy = rec_cliente.get_long("I0"); return codcf_hardy; } @@ -368,5 +471,5 @@ int ha2200 (int argc, char* argv[]) { THardy_esselunga_fat elabapp; elabapp.run(argc, argv, APPNAME); - return 0; + return 0; } \ No newline at end of file diff --git a/ha/ha2200a.h b/ha/ha2200a.h index 027e1f63a..3d7c802b8 100755 --- a/ha/ha2200a.h +++ b/ha/ha2200a.h @@ -2,9 +2,8 @@ #define F_RAGSOC 202 #define F_DATAINI 203 #define F_DATAFIN 204 -#define F_DIPENDENZA 205 -#define F_DEFINITIVO 206 -#define F_SHEETDOC 207 +#define F_DEFINITIVO 205 +#define F_SHEETDOC 206 // campi dello sheet #define F_S_CODNUM 101 #define F_S_DESNUM 102 diff --git a/ha/ha2200a.uml b/ha/ha2200a.uml index dc9457736..1e388560b 100755 --- a/ha/ha2200a.uml +++ b/ha/ha2200a.uml @@ -53,9 +53,6 @@ DATE F_DATAINI BEGIN PROMPT 2 4 "Documenti dal " HELP "Data di inizio per trasferimento documenti" - CHECKTYPE REQUIRED - WARNING "Data dal non valida" - FLAGS "A" END DATE F_DATAFIN @@ -64,24 +61,18 @@ BEGIN HELP "Data di fine per trasferimento documenti" CHECKTYPE REQUIRED VALIDATE DATE_CMP_FUNC >= F_DATAINI - WARNING "Data di fine scadenza non valida" -END - -LISTBOX F_DIPENDENZA 10 -BEGIN - PROMPT 2 5 "Dipendenza " - ITEM "D|Milano" - ITEM "U|Firenze" + WARNING "Data di fine non valida" + FLAGS "A" END BOOLEAN F_DEFINITIVO BEGIN - PROMPT 2 6 "Trasferimento definitivo" + PROMPT 2 5 "Trasferimento definitivo" END SPREADSHEET F_SHEETDOC 78 10 BEGIN - PROMPT 1 8 "Scelta documenti" + PROMPT 1 7 "Scelta documenti" ITEM "Cod. num." ITEM "Descrizione num.@50" END diff --git a/ha/halib.cpp b/ha/halib.cpp index 738c5983d..5e054abc0 100755 --- a/ha/halib.cpp +++ b/ha/halib.cpp @@ -350,6 +350,33 @@ TEsporta_pagamenti_recordset::TEsporta_pagamenti_recordset(int rec_length) add_eol_field(); } +/////////////////////////////////////////////////////////// +// TCodArtEsselunga_cache +/////////////////////////////////////////////////////////// + +TObject* TCodArtEsselunga_cache::key2obj(const char* key) +{ + TToken_string code(key); + TString80 codart; code.get(0, codart); + const TString& codcf = ini_get_string(CONFIG_DITTA, "ha", "Esselunga_CodEsselunga"); + TISAM_recordset codcorr("USE CODCORR\nSELECT CODCF=#CODCF\nFROM CODART=#COD\nTO CODART=#COD"); + codcorr.set_var("#COD", TVariant(codart)); + codcorr.set_var("#CODCF", TVariant(codcf)); + if (codcorr.items()>0) + { + codcorr.move_first(); + return new TString80(codcorr.get(CODCORR_CODARTALT).as_string()); + } + else + return new TString80(codart); +} + +const TString& TCodArtEsselunga_cache::decode(const TString& codart) +{ + return *(const TString*)objptr(codart); +} + + ///////////////////////////////////////////////////////////// diff --git a/ha/halib.h b/ha/halib.h index 60c790f88..99272351d 100755 --- a/ha/halib.h +++ b/ha/halib.h @@ -211,6 +211,20 @@ public: TEsporta_pagamenti_recordset(int rec_length = 27); }; +/////////////////////////////////////////////////////////// +// TCodArtEsselunga_cache +/////////////////////////////////////////////////////////// + +class TCodArtEsselunga_cache : public TCache +{ +protected: + virtual TObject* key2obj(const char* key); + +public: + const TString& decode(const TString& codart); + TCodArtEsselunga_cache() {} +}; + //---------------------------------------------------------- //metodi di utility //----------------------------------------------------------