diff --git a/ha/ha2200.cpp b/ha/ha2200.cpp index 435da5bd7..2131cbbaa 100755 --- a/ha/ha2200.cpp +++ b/ha/ha2200.cpp @@ -156,7 +156,7 @@ TFatture_recordset::TFatture_recordset() 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.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("BGM.FINERECORD", AN, 2, 0, true, "\r\n"); TString80 str; str << ditta.get(ANA_INDRES) << ", " << ditta.get(ANA_CIVRES); @@ -182,7 +182,7 @@ TFatture_recordset::TFatture_recordset() add_field("NAS.TELEFAX", AN, 25, 490); add_field("NAS.TELEX", AN, 25, 515); add_field("NAS.EMAIL", AN, 70, 540); - add_field("NAS.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("NAS.FINERECORD", AN, 2, 0, true, "\r\n"); str.cut(0); str << cliente_esselunga.get(CLI_INDCF) << ", " << cliente_esselunga.get(CLI_CIVCF); @@ -199,13 +199,13 @@ TFatture_recordset::TFatture_recordset() 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); - add_field("NAI.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("NAI.FINERECORD", AN, 2, 0, true, "\r\n"); // 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); - add_field("FTX.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("FTX.FINERECORD", AN, 2, 0, true, "\r\n"); // Record PAT: condizioni di pagamento standard add_field("PAT.TIPOREC", AN, 3, 1, true, "PAT"); @@ -224,7 +224,7 @@ TFatture_recordset::TFatture_recordset() add_field("PAT.FACTOR", AN, 35, 158); add_field("PAT.CODPAG", AN, 3, 193); add_field("PAT.MEZZOPAG", AN, 3, 196); - add_field("PAT.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("PAT.FINERECORD", AN, 2, 0, true, "\r\n"); // *** Sezione di dettaglio fattura *** @@ -255,19 +255,19 @@ TFatture_recordset::TFatture_recordset() add_field("DET.DIVRIGA", AN, 3, 282); add_field("DET.IMPORTO2", NU, 16, 285); add_field("DET.DIVRIGA2", AN, 3, 301); - add_field("DET.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("DET.FINERECORD", AN, 2, 0, true, "\r\n"); // Record DES: descrizione articolo add_field("DES.TIPOREC", AN, 3, 1, true, "DES"); add_field("DES.DESCR", AN,175, 3, true); - add_field("DES.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("DES.FINERECORD", AN, 2, 0, true, "\r\n"); // 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); - add_field("RFN.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("RFN.FINERECORD", AN, 2, 0, true, "\r\n"); // Record TAX: informazioni assoggettamento iva add_field("TAX.TIPOREC", AN, 3, 1, true, "TAX"); @@ -276,7 +276,7 @@ TFatture_recordset::TFatture_recordset() add_field("TAX.CATIMP", AN, 3, 42, true); add_field("TAX.ALIQIVA", NU, 7, 45, true); add_field("TAX.IMPORTO", NU, 16, 52, true); - add_field("TAX.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("TAX.FINERECORD", AN, 2, 0, true, "\r\n"); // Record ALD: sconti di riga add_field("ALD.TIPOREC", AN, 3, 1, true, "ALD"); @@ -287,7 +287,7 @@ TFatture_recordset::TFatture_recordset() add_field("ALD.IMPORTO", NU, 16, 51); add_field("ALD.PERC", NU, 7, 67, true); add_field("ALD.FLGPRZUN", AN, 3, 74); - add_field("ALD.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("ALD.FINERECORD", AN, 2, 0, true, "\r\n"); // Record NAD: identificazione punto di consegna add_field("NAD.TIPOREC", AN, 3, 1, true, "NAD"); @@ -303,7 +303,7 @@ TFatture_recordset::TFatture_recordset() add_field("NAD.DATABOLL", NU, 8, 255, true); add_field("NAD.NUMORD", AN, 35, 263, true); add_field("NAD.DATAORD", NU, 8, 298, true); - add_field("NAD.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("NAD.FINERECORD", AN, 2, 0, true, "\r\n"); // *** Sezione di sommario fattura @@ -311,17 +311,17 @@ TFatture_recordset::TFatture_recordset() add_field("FTT.TIPOREC", AN, 3, 1, true, "FTT"); add_field("FTT.TIPONOTA", AN, 3, 4); add_field("FTT.NOTE", AN,350, 7); - add_field("FTT.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("FTT.FINERECORD", AN, 2, 0, true, "\r\n"); // 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.INDSCADD", AN, 3, 4, true, "A"); 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); - add_field("ALT.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("ALT.FINERECORD", AN, 2, 0, true, "\r\n"); // Record IVA: subtotali imposte add_field("IVA.TIPOREC", AN, 3, 1, true, "IVA"); @@ -331,7 +331,7 @@ TFatture_recordset::TFatture_recordset() add_field("IVA.ALIQIVA", NU, 7, 45); add_field("IVA.SIMPONIB", NU, 16, 52, true); add_field("IVA.SIMPORTO", NU, 16, 68); - add_field("IVA.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("IVA.FINERECORD", AN, 2, 0, true, "\r\n"); // Record TMA: totali documento add_field("TMA.TIPOREC", AN, 3, 1, true, "TMA"); @@ -349,7 +349,7 @@ TFatture_recordset::TFatture_recordset() add_field("TMA.TOTANT2", NU, 16, 167); add_field("TMA.TOTPAG2", NU, 16, 183); add_field("TMA.DIVISA2", AN, 3, 199); - add_field("TMA.FINERECORD", AN, 2, 0, true, "\r\n"); + add_field("TMA.FINERECORD", AN, 2, 0, true, "\r\n"); } /////////////////////////////////////// @@ -362,8 +362,8 @@ protected: void elabora(const TMask& mask); void check_date(const TDate& datafine, TDate& dataini); long check_cliente(const long codcf); - void add_rec_testata(TFatture_recordset& fat, const TDocumento& doc); - void add_rec_sommario(TFatture_recordset& fat, const TDocumento& doc); + void add_rec_testata(TFatture_recordset& fat, TDocumento& doc); + void add_rec_sommario(TFatture_recordset& fat, TDocumento& doc); void add_rec_dettaglio(TFatture_recordset& fat, const TDocumento& doc, const TRiga_documento& rigadoc); public: @@ -426,26 +426,68 @@ long THardy_esselunga_fat::genera_recordset(const TMask& mask, TISAM_recordset& return recset.items(); } -void THardy_esselunga_fat::add_rec_testata(TFatture_recordset& fat, const TDocumento& doc) +void THardy_esselunga_fat::add_rec_testata(TFatture_recordset& fat, TDocumento& doc) { fat.new_rec("BGM"); fat.set("BGM.NUMDOC", doc.numero()); fat.set("BGM.DATAOC", doc.data().string()); fat.new_rec("NAS"); + fat.new_rec("NAI"); + fat.new_rec("FTX"); + fat.new_rec("PAT"); + fat.set("PAT.DESCRIZ", doc.pagamento().name()); } -void THardy_esselunga_fat::add_rec_sommario(TFatture_recordset& fat, const TDocumento& doc) +void THardy_esselunga_fat::add_rec_sommario(TFatture_recordset& fat, TDocumento& doc) { - fat.new_rec("FTT"); - fat.new_rec("ALT"); - fat.new_rec("IVA"); + //fat.new_rec("FTT"); non ci sono note nel documento! + // se c'e' sconto scrivo il record corrispondente + real r; + TString80 s; + bool sconto = scontoexpr2perc(doc.get(DOC_SCONTOPERC), FALSE, s, r); + if ( sconto && r != ZERO) + { + fat.new_rec("ALT"); + fat.set("ALT.IMPORTO", r); + fat.set("ALT.PERC", s); + } + + TAssoc_array& tabella_iva = doc.tabella_iva(); + TRiepilogo_iva* ri; + for (ri = (TRiepilogo_iva*) tabella_iva.first_item(); ri != NULL; ri = (TRiepilogo_iva*) tabella_iva.succ_item()) + { + fat.new_rec("IVA"); + fat.set("IVA.DESCRIZ", ri->cod_iva().descrizione()); + fat.set("IVA.ALIQIVA", ri->cod_iva().percentuale()); + fat.set("IVA.SIMPONIB", ri->imponibile()); + fat.set("IVA.SIMPORTO", ri->imposta()); + } fat.new_rec("TMA"); + fat.set("TMA.TOTDOC1", doc.totale_doc()); + fat.set("TMA.IMPOSTA1", doc.imposta()); + fat.set("TMA.IMPONIB1", doc.imponibile()); + fat.set("TMA.TOTRIGHE1", doc.totale_netto()); + fat.set("TMA.TOTANT1", ""); } + + + + + + + + + + + + + + void THardy_esselunga_fat::add_rec_dettaglio(TFatture_recordset& fat, const TDocumento& doc, const TRiga_documento& rigadoc) { fat.new_rec("DET"); @@ -471,6 +513,7 @@ void THardy_esselunga_fat::elabora(const TMask& mask) TProgind pi(recset.items(), TR("Elaborazione documenti in corso..."), true, true); TFatture_recordset fatture; TCodArtEsselunga_cache cache_ca; + const bool definitivo = mask.get_bool(F_DEFINITIVO); for (bool ok = recset.move_first(); ok; ok = recset.move_next()) { if (!pi.addstatus(1)) @@ -486,16 +529,12 @@ void THardy_esselunga_fat::elabora(const TMask& mask) FOR_EACH_PHYSICAL_RDOC(*doc, r, rigadoc) add_rec_dettaglio(fatture, *doc, *rigadoc); add_rec_sommario(fatture, *doc); + if (definitivo) + doc->put("HA_FATTURE", "X"); } // if check_cliente... } //for (bool ok = recset.move_first()... 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) - { - - } log.print_or_preview(); }