diff --git a/cd/test/ba0952.txt b/cd/test/ba0952.txt new file mode 100644 index 000000000..7c32afab4 --- /dev/null +++ b/cd/test/ba0952.txt @@ -0,0 +1,4 @@ +bacnv.exe + +Aggiunta conversione sottocategorie alla conversione CONAI documenti +Velocizzata la conversione CONAI documenti diff --git a/cd/test/ba0952a.ini b/cd/test/ba0952a.ini new file mode 100644 index 000000000..572ce2f94 --- /dev/null +++ b/cd/test/ba0952a.ini @@ -0,0 +1,31 @@ +[Main] +Demo=0 + +[ba0] +File(14) = bacnv.exe|X +Patch = 0952 +Versione = 21511200 + +[ba99] +Kill(0) = wxmsw240.dll|x +Kill(1) = batbsce.txt|x +Kill(2) = bastfsc.rep|x +Kill(3) = bastfsc.msk|x +Kill(4) = bastcms.msk|x +Kill(5) = bastcms.rep|x +Kill(6) = bastuue.rep|x +Kill(7) = bastuue.msk|x + +[ba] +Data = 24-02-2020 +Descrizione = Base +Dischi = 1 +Moduli = sy +OEM = +Patch = 952 +PostProcess = bainst -0 BA +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/ba0952a1.zip b/cd/test/ba0952a1.zip new file mode 100644 index 000000000..39691f73d Binary files /dev/null and b/cd/test/ba0952a1.zip differ diff --git a/cd/test/fp0954.txt b/cd/test/fp0954.txt new file mode 100644 index 000000000..2aefcf8c1 --- /dev/null +++ b/cd/test/fp0954.txt @@ -0,0 +1,4 @@ +fp0.exe + +Modificata esportazione dati CONAI se non hai le personalizzazioni attive, in modo da poter personalizzare anche il CONAI. +Aggiunti dati precompilati per altri dati gestionali per CONAI. diff --git a/cd/test/fp0954a.ini b/cd/test/fp0954a.ini new file mode 100644 index 000000000..e09826964 --- /dev/null +++ b/cd/test/fp0954a.ini @@ -0,0 +1,19 @@ +[Main] +Demo=0 + +[fp0] +File(0) = fp0.exe|X +Patch = 954 +Versione = 21511200 + +[fp] +Data = 24-02-2020 +Descrizione = Fattura Elettronica +Dischi = 1 +Moduli = cg,ve +OEM = +Patch = 954 +PostProcess = +PreProcess = +Versione = 21511200 + diff --git a/cd/test/fp0954a1.zip b/cd/test/fp0954a1.zip new file mode 100644 index 000000000..05f519f2a Binary files /dev/null and b/cd/test/fp0954a1.zip differ diff --git a/cd/test/fp0956.txt b/cd/test/fp0956.txt new file mode 100644 index 000000000..988ea4b57 --- /dev/null +++ b/cd/test/fp0956.txt @@ -0,0 +1,3 @@ +fp0.exe + +Modifica per prevenire altri errori possibili come per alcuni clienti che hanno nei codici ISO per l'italia il flag di paese EU disabilitato. diff --git a/cd/test/fp0956a.ini b/cd/test/fp0956a.ini new file mode 100644 index 000000000..6032247e9 --- /dev/null +++ b/cd/test/fp0956a.ini @@ -0,0 +1,19 @@ +[Main] +Demo=0 + +[fp0] +File(0) = fp0.exe|X +Patch = 0956 +Versione = 21511200 + +[fp] +Data = 28-02-2020 +Descrizione = Fattura Elettronica +Dischi = 1 +Moduli = cg,ve +OEM = +Patch = 956 +PostProcess = +PreProcess = +Versione = 21511200 + diff --git a/cd/test/fp0956a1.zip b/cd/test/fp0956a1.zip new file mode 100644 index 000000000..3eaf0b023 Binary files /dev/null and b/cd/test/fp0956a1.zip differ diff --git a/cd/test/lv0952.txt b/cd/test/lv0952.txt new file mode 100644 index 000000000..87ae8339d --- /dev/null +++ b/cd/test/lv0952.txt @@ -0,0 +1,3 @@ +lv0.exe + +Corretto salvataggio dotazioni nei contratti diff --git a/cd/test/lv0952a.ini b/cd/test/lv0952a.ini new file mode 100644 index 000000000..e649dac36 --- /dev/null +++ b/cd/test/lv0952a.ini @@ -0,0 +1,22 @@ +[Main] +Demo=0 + +[lv0] +Edit_168 = lv0 -3 +File(0) = lv0.exe|X +Patch = 0952 +Versione = 21511200 + +[lv] +Data = 24-02-2020 +Descrizione = Gestione lavanderie +Dischi = 1 +Moduli = ve,mg +OEM = 2 +Patch = 952 +PostProcess = bainst -0 LV +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/lv0952a1.zip b/cd/test/lv0952a1.zip new file mode 100644 index 000000000..bfc9c0c40 Binary files /dev/null and b/cd/test/lv0952a1.zip differ diff --git a/cd/test/ve0952.txt b/cd/test/ve0952.txt new file mode 100644 index 000000000..5beb93be2 --- /dev/null +++ b/cd/test/ve0952.txt @@ -0,0 +1,4 @@ +ve0.exe + +Aggiunta conversione sottocategorie alla conversione CONAI documenti +Velocizzata la conversione CONAI documenti diff --git a/cd/test/ve0952a.ini b/cd/test/ve0952a.ini new file mode 100644 index 000000000..240484040 --- /dev/null +++ b/cd/test/ve0952a.ini @@ -0,0 +1,129 @@ +[Main] +Demo=0 + +[ve0] +File(20) = ve0.exe|X +Patch = 0952 +Versione = 21511200 + +[ve99] +Kill(0) = batbcld.msk|x +Kill(1) = bastspp.rep|x +Kill(2) = bastgcg.msk|x +Kill(3) = bastbnp.rep|x +Kill(4) = ve7600a.msk|x +Kill(5) = batbtip.msk|x +Kill(6) = batbbnp.msk|x +Kill(7) = basttip.msk|x +Kill(8) = bastprs.msk|x +Kill(9) = efstbnp.msk|x +Kill(10) = batbfrd.msk|x +Kill(11) = efstbnp.rep|x +Kill(12) = ve7200a.frm|x +Kill(13) = bastrfa.msk|x +Kill(14) = bastrfc.rep|x +Kill(15) = bastabe.rep|x +Kill(16) = batbcau.msk|x +Kill(17) = ve7.exe|x +Kill(18) = bastfrm.rep|x +Kill(19) = bastcaa.rep|x +Kill(20) = bastfrd.rep|x +Kill(21) = batbctr.msk|x +Kill(22) = batbspp.msk|x +Kill(23) = bastspp.msk|x +Kill(24) = basteld.rep|x +Kill(25) = batbfid.msk|x +Kill(26) = batbfca.msk|x +Kill(27) = batbfrm.msk|x +Kill(28) = batbabe.msk|x +Kill(29) = basttri.rep|x +Kill(30) = bastasf.msk|x +Kill(31) = ve7100a.msk|x +Kill(32) = batbtag.msk|x +Kill(33) = bastprs.rep|x +Kill(34) = batbrfc.msk|x +Kill(35) = bastimb.msk|x +Kill(36) = bastfrr.msk|x +Kill(37) = bastums.msk|x +Kill(38) = batbgca.msk|x +Kill(39) = bastabe.msk|x +Kill(40) = basttag.msk|x +Kill(41) = batbnum.msk|x +Kill(42) = bastctr.msk|x +Kill(43) = batbmre.msk|x +Kill(44) = eftbbnp.msk|x +Kill(45) = batbtri.msk|x +Kill(46) = batbubi.msk|x +Kill(47) = bastcau.rep|x +Kill(48) = bastfrd.msk|x +Kill(49) = basttag.rep|x +Kill(50) = batbums.msk|x +Kill(51) = basteld.msk|x +Kill(52) = baststd.msk|x +Kill(53) = bastfrm.msk|x +Kill(54) = batbgsa.msk|x +Kill(55) = basttri.msk|x +Kill(56) = bastcra.msk|x +Kill(57) = batbprv.msk|x +Kill(58) = bastasf.rep|x +Kill(59) = batbrfa.msk|x +Kill(60) = ve7700a.msk|x +Kill(61) = bastnum.msk|x +Kill(62) = ve7400a.msk|x +Kill(63) = bastums.rep|x +Kill(64) = bastnum.rep|x +Kill(65) = ve7200a.msk|x +Kill(66) = baststd.rep|x +Kill(67) = bastbnp.msk|x +Kill(68) = basttip.rep|x +Kill(69) = batbgmc.msk|x +Kill(70) = batbfsa.msk|x +Kill(71) = bastfca.msk|x +Kill(72) = batbgcg.msk|x +Kill(73) = ve7400conf.ini|x +Kill(74) = bastgca.msk|x +Kill(75) = ve7300a.msk|x +Kill(76) = ve7400a.ini|x +Kill(77) = batbstd.msk|x +Kill(78) = batbcaa.msk|x +Kill(79) = batbfrr.msk|x +Kill(80) = batbasf.msk|x +Kill(81) = bastgca.rep|x +Kill(82) = ve7701a.ini|x +Kill(83) = bastrfc.msk|x +Kill(84) = batbspt.msk|x +Kill(85) = bastrfa.rep|x +Kill(86) = bastcaa.msk|x +Kill(87) = bastfca.rep|x +Kill(88) = batbprs.msk|x +Kill(89) = bastimb.rep|x +Kill(90) = ve7500a.msk|x +Kill(91) = bastgcg.rep|x +Kill(92) = ve7300a.frm|x +Kill(93) = bastubi.rep|x +Kill(94) = bastubi.msk|x +Kill(95) = bastgmc.rep|x +Kill(96) = bastcra.rep|x +Kill(97) = batbpro.msk|x +Kill(98) = batbacr.msk|x +Kill(99) = batbimb.msk|x +Kill(100) = bastgmc.msk|x +Kill(101) = bastfrr.rep|x +Kill(102) = batbeld.msk|x +Kill(103) = bastcau.msk|x +Kill(104) = batbcra.msk|x +Kill(105) = bastctr.rep|x + +[ve] +Data = 24-02-2020 +Descrizione = Vendite +Dischi = 1 +Moduli = ba,cg9,pr9,mg9,sv9,in9,ef9 +OEM = +Patch = 952 +PostProcess = bainst -0 VE +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/ve0952a1.zip b/cd/test/ve0952a1.zip new file mode 100644 index 000000000..4e11867d4 Binary files /dev/null and b/cd/test/ve0952a1.zip differ diff --git a/cd/test/ve0954.txt b/cd/test/ve0954.txt new file mode 100644 index 000000000..d63545604 --- /dev/null +++ b/cd/test/ve0954.txt @@ -0,0 +1,3 @@ +ve0.exe + +Ricompilato programma diff --git a/cd/test/ve0954a.ini b/cd/test/ve0954a.ini new file mode 100644 index 000000000..1f096e48d --- /dev/null +++ b/cd/test/ve0954a.ini @@ -0,0 +1,129 @@ +[Main] +Demo=0 + +[ve0] +File(20) = ve0.exe|X +Patch = 0954 +Versione = 21511200 + +[ve99] +Kill(0) = batbimb.msk|x +Kill(1) = batbacr.msk|x +Kill(2) = bastimb.rep|x +Kill(3) = bastgmc.rep|x +Kill(4) = batbprs.msk|x +Kill(5) = bastubi.msk|x +Kill(6) = batbpro.msk|x +Kill(7) = bastcra.rep|x +Kill(8) = bastrfa.rep|x +Kill(9) = bastgcg.rep|x +Kill(10) = batbspt.msk|x +Kill(11) = ve7500a.msk|x +Kill(12) = bastfca.rep|x +Kill(13) = bastubi.rep|x +Kill(14) = bastcaa.msk|x +Kill(15) = ve7300a.frm|x +Kill(16) = bastgca.rep|x +Kill(17) = batbasf.msk|x +Kill(18) = bastrfc.msk|x +Kill(19) = ve7701a.ini|x +Kill(20) = bastcaa.rep|x +Kill(21) = batbfid.msk|x +Kill(22) = ve7100a.msk|x +Kill(23) = bastfrm.rep|x +Kill(24) = basteld.rep|x +Kill(25) = bastasf.msk|x +Kill(26) = batbfrm.msk|x +Kill(27) = bastprs.rep|x +Kill(28) = batbfca.msk|x +Kill(29) = batbtag.msk|x +Kill(30) = bastabe.rep|x +Kill(31) = batbctr.msk|x +Kill(32) = bastrfc.rep|x +Kill(33) = bastfrd.rep|x +Kill(34) = ve7.exe|x +Kill(35) = bastspp.msk|x +Kill(36) = batbcau.msk|x +Kill(37) = batbspp.msk|x +Kill(38) = efstbnp.rep|x +Kill(39) = batbfrd.msk|x +Kill(40) = bastrfa.msk|x +Kill(41) = ve7200a.frm|x +Kill(42) = batbrfa.msk|x +Kill(43) = ve7200a.msk|x +Kill(44) = bastfca.msk|x +Kill(45) = bastasf.rep|x +Kill(46) = bastnum.rep|x +Kill(47) = batbfsa.msk|x +Kill(48) = bastbnp.msk|x +Kill(49) = ve7400conf.ini|x +Kill(50) = baststd.rep|x +Kill(51) = batbgcg.msk|x +Kill(52) = basttag.rep|x +Kill(53) = basttri.msk|x +Kill(54) = bastnum.msk|x +Kill(55) = bastfrd.msk|x +Kill(56) = batbgsa.msk|x +Kill(57) = ve7700a.msk|x +Kill(58) = batbprv.msk|x +Kill(59) = bastums.rep|x +Kill(60) = bastcra.msk|x +Kill(61) = ve7400a.msk|x +Kill(62) = bastabe.msk|x +Kill(63) = batbtri.msk|x +Kill(64) = basteld.msk|x +Kill(65) = batbgca.msk|x +Kill(66) = eftbbnp.msk|x +Kill(67) = batbums.msk|x +Kill(68) = bastcau.rep|x +Kill(69) = bastfrm.msk|x +Kill(70) = batbubi.msk|x +Kill(71) = baststd.msk|x +Kill(72) = basttri.rep|x +Kill(73) = bastimb.msk|x +Kill(74) = batbnum.msk|x +Kill(75) = batbabe.msk|x +Kill(76) = batbrfc.msk|x +Kill(77) = basttag.msk|x +Kill(78) = bastums.msk|x +Kill(79) = batbmre.msk|x +Kill(80) = bastfrr.msk|x +Kill(81) = bastctr.msk|x +Kill(82) = batbfrr.msk|x +Kill(83) = batbcaa.msk|x +Kill(84) = batbgmc.msk|x +Kill(85) = ve7300a.msk|x +Kill(86) = basttip.rep|x +Kill(87) = bastgca.msk|x +Kill(88) = batbstd.msk|x +Kill(89) = ve7400a.ini|x +Kill(90) = bastctr.rep|x +Kill(91) = batbcra.msk|x +Kill(92) = bastfrr.rep|x +Kill(93) = bastgmc.msk|x +Kill(94) = bastcau.msk|x +Kill(95) = batbeld.msk|x +Kill(96) = efstbnp.msk|x +Kill(97) = bastprs.msk|x +Kill(98) = bastspp.rep|x +Kill(99) = batbcld.msk|x +Kill(100) = batbtip.msk|x +Kill(101) = ve7600a.msk|x +Kill(102) = bastbnp.rep|x +Kill(103) = bastgcg.msk|x +Kill(104) = basttip.msk|x +Kill(105) = batbbnp.msk|x + +[ve] +Data = 27-02-2020 +Descrizione = Vendite +Dischi = 1 +Moduli = ba,cg9,pr9,mg9,sv9,in9,ef9 +OEM = +Patch = 954 +PostProcess = bainst -0 VE +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/ve0954a1.zip b/cd/test/ve0954a1.zip new file mode 100644 index 000000000..3ac12d25b Binary files /dev/null and b/cd/test/ve0954a1.zip differ diff --git a/src/fp/fp0500.cpp b/src/fp/fp0500.cpp index b35e1af5e..1264ab5e3 100644 --- a/src/fp/fp0500.cpp +++ b/src/fp/fp0500.cpp @@ -97,22 +97,46 @@ public: void TFpcust::init_insert_mode(TMask& m) { - // Presetto delle righe di default + // Presetto delle righe di default - // Causale - TToken_string& row_causale = m.sfield(F_CAUSALI).row(-1); - row_causale.add("READ(%TIP, S0)"); + // Causale + TToken_string& row_causale = m.sfield(F_CAUSALI).row(-1); + row_causale.add("READ(%TIP, S0)"); - // Articoli - TToken_string& row_articolo_interno = m.sfield(F_ARTICOLI).row(-1); - row_articolo_interno.add("Codice articolo interno"); - row_articolo_interno.add("READ(34, CODARTMAG)"); - row_articolo_interno.add("READ(34, CODARTMAG) != \"\" && READ(34, CODART) != \"\""); + // Articoli + TToken_string& row_articolo_interno = m.sfield(F_ARTICOLI).row(-1); + row_articolo_interno.add("Codice articolo interno"); + row_articolo_interno.add("READ(34, CODARTMAG)"); + row_articolo_interno.add("READ(34, CODARTMAG) != \"\" && READ(34, CODART) != \"\""); - TToken_string& row_articolo = m.sfield(F_ARTICOLI).row(-1); - row_articolo.add("Codice articolo cliente"); - row_articolo.add("READ(34, CODART)"); - row_articolo.add("READ(34, CODARTMAG) != READ(34, CODART) && READ(34, CODART) != \"\""); + TToken_string& row_articolo = m.sfield(F_ARTICOLI).row(-1); + row_articolo.add("Codice articolo cliente"); + row_articolo.add("READ(34, CODART)"); + row_articolo.add("READ(34, CODARTMAG) != READ(34, CODART) && READ(34, CODART) != \"\""); + + // Altri dati gestionali + // CONAI + TRelation rel(LF_TABMOD); + TRectype rec(LF_TABMOD); + rec.put("MOD", "VE"); + rec.put("COD", "SCC"); + + TCursor conais(&rel, "", 1, &rec, &rec); + for (conais = 0; conais.pos() < conais.items(); ++conais) + { + TRectype& row = conais.curr(); + TToken_string& row_conai = m.sfield(F_ADG).row(-1); + const TString& csc = row.get("CODTAB"); + TString cat(conai_material(conai_str2class(csc))); + cat.upper(); + row_conai.add("CONAI"); // TIPODATO + row_conai.add(TString("\"Contributo CONAI ") << cat << " (KG)\""); // RTESTO + row_conai.add("READ(RDOC,PCON(1))"); // RNUMERO + row_conai.add(""); // RDATA + row_conai.add(""); // TIPORIGA + row_conai.add(TString("READ(RDOC,CCON(1)) == \"") << csc << "\""); // COND + row_conai.add(""); // SPLIT + } } int TFpcust::read(TMask& m) diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index 4d3de93fd..a88369337 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -1381,20 +1381,20 @@ bool TDoc_fp::export_info_articolo(TFPRiga_documento* rdoc, TPaf_record& paf1900 // Controllo se ha il CONAI in tal caso aggiungo i dati for (int i = 0; i < FR_CMAX; i++) { - if (rdoc->get(conai_peso_name(i)).full()) + if (rdoc->get(conai_peso_name(i)).full() && !_has_cust) { - reset(paf2100f); - paf2100f.set("PK_KEYNLINEA", static_cast(riga_doc)); - paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++); - - TString scat = rdoc->get(conai_sottocat_name(i)); - TString msg_conai; - - msg_conai << "Contributo CONAI " << conai_material(conai_str2class(scat)) << " (KG)"; - paf2100f.set("PK_TIPODATO", "CONAI"); - paf2100f.set("PK_RIFDATO", msg_conai); - paf2100f.set("PK_RIFNUMERO", rdoc->get_real(conai_peso_name(i)).string()); - ok &= insert(paf2100f); + reset(paf2100f); + paf2100f.set("PK_KEYNLINEA", static_cast(riga_doc)); + paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++); + + TString scat = rdoc->get(conai_sottocat_name(i)); + TString msg_conai; + + msg_conai << "Contributo CONAI " << conai_material(conai_str2class(scat)) << " (KG)"; + paf2100f.set("PK_TIPODATO", "CONAI"); + paf2100f.set("PK_RIFDATO", msg_conai); + paf2100f.set("PK_RIFNUMERO", rdoc->get_real(conai_peso_name(i)).string()); + ok &= insert(paf2100f); } } return ok; @@ -1554,7 +1554,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc) &fisc = cliente.codice_fiscale(); if (!stato.full()) stato = "IT"; - if(tab_codiso.get_bool("B0")) // Cliente EU + if(tab_codiso.get_bool("B0") || stato == "IT") // Cliente EU { if (piva.full()) { diff --git a/src/include/checks.cpp b/src/include/checks.cpp index 22a627137..05c944e0f 100755 --- a/src/include/checks.cpp +++ b/src/include/checks.cpp @@ -254,7 +254,7 @@ int yesnocancel_box( // // @flag K_YES | Se viene premuto il tasto SI // @flag K_NO | Se viene premuto il tasto NO - // @flag K_ESC | Se viene premuto il tosto ESC + // @flag K_ESC | Se viene premuto il tasto ESC // // @xref { diff --git a/src/ps/ps6215100.cpp b/src/ps/ps6215100.cpp index 32bc7ee90..02f8116f6 100644 --- a/src/ps/ps6215100.cpp +++ b/src/ps/ps6215100.cpp @@ -14,10 +14,104 @@ #include "sqlset.h" #include #include "ps6215partite.h" +#include +#include "scadenze.h" +#include "clifo.h" #define CLIFO_RECLEN 730 +struct part +{ + char _tipocf; + int _anno; + TString _numpart; + part(const char tipocf, const int anno, const TString numpart) : _tipocf(tipocf), _anno(anno), _numpart(numpart) { } +}; +//namespace Elem { +// +//struct mov_t +//{ +// // Keys +// int n_reg; +// TDate data_reg; +// // Attributes +// int tipo_mov; +// real importo; +//}; +// +//struct part_t +//{ +// // Keys +// int year; +// TString num; +// // Attributes +// mov_t capo_part; +// vector movs; +//}; +// +//} +// +//class TPartite_aperte +//{ +// +// /* Uso la chiave della partita stessa */ +// std::map, Elem::part_t> _parts; +// +//public: +// TPartite_aperte(); +//}; +// +// +///* Vogliono esportare solo le partite aperte al 31.12.2019. Quindi devo controllare +// * che le partite che risultano chiuse non abbiano delle registrazioni superiori al 31.12.2019 +// * altrimenti non devo tener conto di quel pagamento, e controllare poi se veramente chiusa. +// * Ma se semplicemente controllassi i movimenti senza prenderli copiarmeli?? +// */ +//TPartite_aperte::TPartite_aperte() +//{ +// TLocalisamfile part(LF_PARTITE); +// part.read(); +// for(bool ok = part.first(); ok; ok = part.next()) +// { +// if (part.get(PART_NUMPART) == "9999") // Salto la riga di saldo +// continue; +// +// Elem::part_t p; +// p.num = part.get(PART_NUMPART); +// p.year = part.get_int(PART_ANNO); +// +// std::pair key = { p.num, p.year }; +// auto it = _parts.find(key); +// // Se non esiste gia' la partita vuol dire che non ho ancora iniziato a caricarla +// if(it == _parts.end()) +// { +// _parts.insert({ key, p }); +// +// if ((it = _parts.find(key)) == _parts.end()) +// fatal_box("ERROR IN %s, %s", __FILE__, __LINE__); +// +// Elem::part_t& pa = it->second; +// // Leggo il capo partita (se c'e') +// const int tipo = part.get_int(PART_TIPOMOV); +// if (tipo == 1 || tipo == 2) // Fattura o NC +// { +// const Elem::mov_t m = { part.get_int(PART_NREG), part.get_int(PART_DATAREG), tipo, part.get_real(PART_IMPORTO) }; +// pa.capo_part = m; +// } +// } +// else +// { +// Elem::part_t& pa = it->second; +// const int tipo = part.get_int(PART_TIPOMOV); +// const Elem::mov_t m = { part.get_int(PART_NREG), part.get_int(PART_DATAREG), tipo, part.get_real(PART_IMPORTO) }; +// +// pa.movs.insert(pa.movs.end(), m); +// } +// } +// +// +//} class TFixed_record { @@ -228,19 +322,25 @@ void TComariExport_mask::load_all() class TComariExport_app : public TSkeleton_application { TString _fld_dest; + std::vector> _exported; + std::vector _chiuse; - bool export_all() const; + bool export_all(); static void add_to_record(char* record, TString& str, int len, int& index); static void export_clifo(ofstream& fout); - static void export_parti(ofstream& fout); - bool export_table(short id) const; + static void create_rec(int items, TLocalisamfile& part_rec, const char** fields, std::shared_ptr& rec); + void write_chiuse(ofstream& fout, int items, const int* dim_fields, const char** fields); + void add_chiusa(const TISAM_recordset& part_rec); + void export_parti(ofstream& fout); + void export_scadenze(ofstream& fout); + bool export_table(short id); public: bool create() override; void main_loop() override; TComariExport_app() = default; }; -bool TComariExport_app::export_all() const +bool TComariExport_app::export_all() { return export_table(F_CLIFOR) && @@ -414,65 +514,323 @@ void TComariExport_app::export_clifo(ofstream& fout) } } +void TComariExport_app::create_rec(int items, TLocalisamfile& part_rec, const char** fields, std::shared_ptr& rec) +{ + for (int _Idx = 0; _Idx < items; ++_Idx) + { + if (_Idx >= I_DATAREG && _Idx <= I_DATAPAG) + { + TDate date(part_rec.get(part_rec.get_date(fields[_Idx]))); + rec->set_str(_Idx, TString(date.date2ansi())); + } + else if (_Idx >= I_IMPORTO && _Idx <= I_RITSOC || _Idx == I_ABBUONI || _Idx == I_DIFFCAM) + rec->set_str(_Idx, part_rec.get_real(fields[_Idx]).string()); + else + rec->set_str(_Idx, part_rec.get(fields[_Idx])); + } +} + +void TComariExport_app::write_chiuse(ofstream& fout, int items, const int* dim_fields, const char** fields) +{ + std::shared_ptr rec = std::make_shared(items, dim_fields, fields); + for(auto& it : _chiuse) + { + TLocalisamfile part(LF_PARTITE); + part.setkey(1); + part.put(PART_TIPOCF, it._tipocf); + part.put(PART_ANNO, it._anno); + part.put(PART_NUMPART, it._numpart); + part.read(); + for(bool ok = true; ok; ok = part.next() == NOERR) + { + if(part.get_date(PART_DATAREG) > TDate(31, 12, 2019) || + part.get_int(PART_NRIGA) == 9999) // Per sicurezza :'( + break; + create_rec(items, part, fields, rec); + + fout << rec->get_line() << endl; + _exported.insert(_exported.end(), rec); + } + } +} + +void TComariExport_app::add_chiusa(const TISAM_recordset& part_rec) +{ + const int anno = part_rec.get(part_rec.find_column(PART_ANNO)).as_int(); + const TString npart = part_rec.get(part_rec.find_column(PART_NUMPART)).as_string(); + const char tipocf = part_rec.get(part_rec.find_column(PART_TIPOCF)).as_string()[0]; + _chiuse.insert(_chiuse.end(), part(tipocf, anno, npart)); +} + void TComariExport_app::export_parti(ofstream& fout) { const char* fields[] = { - PART_ANNO, PART_NUMPART, PART_NRIGA, PART_TIPOCF, PART_SOTTOCONTO, PART_TIPOMOV, PART_TIPOPAG, PART_NREG, PART_NUMRIG, PART_DATAREG, PART_DATADOC, + PART_ANNO, PART_NUMPART, PART_NRIGA, PART_TIPOCF, PART_SOTTOCONTO, + PART_TIPOMOV, PART_TIPOPAG, PART_NREG, PART_NUMRIG, PART_DATAREG, PART_DATADOC, PART_DATAPAG, PART_NUMDOC, PART_REG, PART_PROTIVA, PART_CODCAUS, PART_SEZ, PART_IMPORTO, PART_IMPOSTA, PART_SPESE, PART_IMPTOTDOC, PART_RITENUTE, - PART_RITSOC, PART_SEZABB, PART_ABBUONI, PART_SEZDIFCAM, PART_DIFFCAM, PART_GRUPPOCL, PART_CONTOCL + PART_RITSOC, PART_SEZABB, PART_ABBUONI, PART_SEZDIFCAM, PART_DIFFCAM, PART_GRUPPOCL, PART_CONTOCL, + CLI_COFI, CLI_STATOPAIV, CLI_PAIV }; const int dim_fields[] = { - D_ANNO, D_NUMPART, D_NRIGA, D_TIPOC, D_SOTTOCONTO, D_TIPOMOV, D_TIPOPAG, D_NREG, D_NUMRIG, D_DATAREG, D_DATADOC, + D_ANNO, D_NUMPART, D_NRIGA, D_TIPOC, D_SOTTOCONTO, + D_TIPOMOV, D_TIPOPAG, D_NREG, D_NUMRIG, D_DATAREG, D_DATADOC, D_DATAPAG, D_NUMDOC, D_REG, D_PROTIVA, D_CODCAUS, D_SEZ, D_IMPORTO, D_IMPOSTA, D_SPESE, D_IMPTOTDOC, D_RITENUTE, - D_RITSOC, D_SEZABB, D_ABBUONI, D_SEZDIFCAM, D_DIFFCAM, D_GRUPPOCL, D_CONTOCL + D_RITSOC, D_SEZABB, D_ABBUONI, D_SEZDIFCAM, D_DIFFCAM, D_GRUPPOCL, D_CONTOCL, + D_COFI, D_STATOPAIV, D_PAIV }; TString4 last_game = ini_get_string(CONFIG_DITTA, "ps6215", "last_year_open_game", "2019"); - const string year = (const char*)last_game; + const string year((const char*)last_game); const int y = stol(year); if (y < 2000 || y > 2029) last_game = "2019"; ini_set_string(CONFIG_DITTA, "ps6215", "last_game", last_game); const int items = (int)(sizeof dim_fields / sizeof *dim_fields); - TString sql; sql << "SELECT "; - for (int i = 0; i < items - 1; ++i) - sql << fields[i] << ", "; - sql << fields[items - 1] << '\n'; - sql << " FROM part WHERE CHIUSA<>'X' AND ANNO <=" << last_game << ";"; - TSQL_recordset openpart(sql); + //TString sql; sql << "SELECT "; + //for (int i = 0; i < items - 1 + 1; ++i) // +1 perche' c'e' anche la colonna CHIUSA in fields + // sql << fields[i] << ", "; + //sql << fields[items - 1 +1] << '\n'; + //sql << "FROM part WHERE ANNO <=" << last_game << ";"; + //TSQL_recordset openpart(sql); + TISAM_recordset part_rec(R"(USE PART SELECT (ANNO<=2019)&&((CHIUSA!="X")||((CHIUSA=="X")&&(DATAREG>"31-12-2019")))&&(NRIGA!=9999))"); + + const int part_items = part_rec.items(); - if (!openpart.items()) + if (!part_items) message_box("Non ci sono partite aperte al %s da esportare.", (const char*)last_game); - else if(openpart.move_first()) + else if (part_rec.move_first()) { - TProgress_monitor bar(openpart.items(), "Esportazione Partite Aperte"); - for(bool ok = true; ok; ok = openpart.move_next()) + TProgress_monitor bar(part_items, "Esportazione Partite Aperte"); + std::vector> saved; + for (bool ok = true; ok; ok = part_rec.move_next()) { if (!bar.add_status()) break; - TFixed_record rec(items, dim_fields, fields); - for (int i = 0; i < items; ++i) + auto rec = std::make_shared(items, dim_fields, fields); + for (int idx = 0; idx < items; ++idx) { - if (openpart.column_info(i)._type == _datefld) + if (idx >= I_DATAREG && idx <= I_DATAPAG) { - TString ansi; ansi << TDate(openpart.get(i).as_date()).date2ansi(); - if(ansi != "0") // Butto le date "vuote" - rec.set_str(i, ansi); + TDate date(part_rec.get(part_rec.find_column(fields[idx])).as_date()); + rec->set_str(idx, TString(date.date2ansi())); } - else if(i >= I_IMPORTO && i <= I_RITSOC || i == I_ABBUONI || i == I_DIFFCAM) // reali (non so perche' ma becca come reali anche gli interi...) - rec.set_str(i, TString(openpart.get(i).as_real().string(18, 3, ' '))); + else if (idx >= I_IMPORTO && idx <= I_RITSOC || idx == I_ABBUONI || idx == I_DIFFCAM) + rec->set_str(idx, part_rec.get(part_rec.find_column(fields[idx])).as_real().string()); + else if(idx <= I_CONTOCL) + rec->set_str(idx, part_rec.get(part_rec.find_column(fields[idx])).as_string()); else - rec.set_str(i, openpart.get(i).as_string()); + { + TLocalisamfile clifo(LF_CLIFO); + TString c = part_rec.get(part_rec.find_column(PART_TIPOCF)).as_string(); + TString s = part_rec.get(part_rec.find_column(PART_SOTTOCONTO)).as_string(); + clifo.put(CLI_TIPOCF, part_rec.get(part_rec.find_column(PART_TIPOCF)).as_string()); + clifo.put(CLI_CODCF, part_rec.get(part_rec.find_column(PART_SOTTOCONTO)).as_string()); + clifo.read(); + + rec->set_str(idx, clifo.get(CLI_COFI)); + rec->set_str(idx, clifo.get(CLI_STATOPAIV)); + rec->set_str(idx, clifo.get(CLI_PAIV)); + break; // Setto ed esco tanto sono gli ultimi + } } - fout << rec.get_line() << endl; + + if(!part_rec.get(part_rec.find_column(PART_CHIUSA)).as_bool()) + { + fout << rec->get_line() << endl; // Caso normale in cui e' aperta + _exported.insert(_exported.end(), rec); + } + else + add_chiusa(part_rec); + + //if (part_rec.get(PART_CHIUSA).as_bool()) // se partita chiusa controllo che la riga non superi il limite + //{ + // if (part_rec.get(PART_DATAREG).as_date() > TDate(31, 12, 2019)) + // { + // // La partita in realta' e' aperta + // // Non salvo questa ma scrivo tutte le altre; + // for (auto it = saved.begin(); it != saved.end(); ++it) + // fout << (*it)->get_line() << endl; + // _exported.insert(_exported.end(), saved.begin(), saved.end()); + // saved.clear(); // Svuoto il vettore temporaneo. + // // Mi sposto avanti finche' non trovo la riga di saldo. + // part_rec.move_next(); + // if (!bar.add_status()) + // break; + // while (part_rec.get(PART_NRIGA).as_int() != 9999) + // { + // part_rec.move_next(); + // if (!bar.add_status()) + // break; + // } + // continue; + // } + // if (part_rec.get(PART_NRIGA).as_int() == 9999) // Balzo, purtoppo puo' capitare di finire in questo caso... + // saved.clear(); // Svuoto il vettore temporaneo. + // else + // { + // // Quando e' chiusa e non supera il limite invece me le salvo momentaneamente + // saved.insert(saved.end(), rec); // Verranno scritte solo se in realta' e' aperta + // continue; + // } + //} + //if (part_rec.get(PART_NRIGA).as_int() == 9999) // Balzo + // continue; + + //if (part_rec.get(PART_DATAREG).as_date() <= TDate(31, 12, 2019)) + //{ + // fout << rec->get_line() << endl; // Caso normale in cui e' aperta + // _exported.insert(_exported.end(), rec); + //} } + write_chiuse(fout, items, dim_fields, fields); } else warning_box(TR("Impossibile leggere file partite aperte.")); + + //if (!openpart.items()) + // message_box("Non ci sono partite aperte al %s da esportare.", (const char*)last_game); + //else if(openpart.move_first()) + //{ + // TProgress_monitor bar(openpart.items(), "Esportazione Partite Aperte"); + // std::vector> saved; + // for (bool ok = true; ok; ok = openpart.move_next()) + // { + // if (!bar.add_status()) + // break; + // /*if (openpart.get(openpart.find_column(PART_CHIUSA)).as_bool() && + // openpart.get(openpart.find_column(PART_DATAREG)).as_date() > TDate(31, 12, 2019)) + // bool simo = true;*/ + // /* Esporto solo le righe che non sono registrazioni con datareg superiore al limite + // * e che non sono righe di saldo + // */ + // // Uso uno shared ptr altrimenti non potrei salvare nulla nel vector perche' a ogni ciclo il record verrebbe distrutto con tutti i suoi puntatori + // // in questo modo se ne occupa lo smart pointer di distruggerlo quando non ci sono piu' riferimenti. + // std::shared_ptr rec = std::make_shared(items, dim_fields, fields); + + // for (int i = 0; i < items; ++i) + // { + // if (openpart.column_info(i)._type == _datefld) + // { + // TString ansi; ansi << TDate(openpart.get(i).as_date()).date2ansi(); + // if (ansi != "0") // Butto le date "vuote" + // rec->set_str(i, ansi); + // } + // else if (i >= I_IMPORTO && i <= I_RITSOC || i == I_ABBUONI || i == I_DIFFCAM) // reali (non so perche' ma becca come reali anche gli interi...) + // rec->set_str(i, TString(openpart.get(i).as_real().string(18, 3, ' '))); + // else + // rec->set_str(i, openpart.get(i).as_string()); + // } + // if (openpart.get(openpart.find_column(PART_CHIUSA)).as_bool()) // se partita chiusa controllo che la riga non superi il limite + // { + // if (openpart.get(openpart.find_column(PART_DATAREG)).as_date() > TDate(31, 12, 2019)) + // { + // // La partita in realta' e' aperta + // // Non salvo questa ma scrivo tutte le altre; + // for(auto it = saved.begin(); it != saved.end(); ++it) + // fout << (*it)->get_line() << endl; + // _exported.insert(_exported.end(), saved.begin(), saved.end()); + // saved.clear(); // Svuoto il vettore temporaneo. + // // Mi sposto avanti finche' non trovo la riga di saldo. + // ok = openpart.move_next(); + // if (!bar.add_status()) + // break; + // while (ok && openpart.get(openpart.find_column(PART_NRIGA)).as_int() != 9999) + // { + // ok = openpart.move_next(); + // if (!bar.add_status()) + // break; + // } + // continue; + // } + // if (openpart.get(openpart.find_column(PART_NRIGA)).as_int() == 9999) // Balzo, purtoppo puo' capitare di finire in questo caso... + // saved.clear(); // Svuoto il vettore temporaneo. + // else + // { + // // Quando e' chiusa e non supera il limite invece me le salvo momentaneamente + // saved.insert(saved.end(), rec); // Verranno scritte solo se in realta' e' aperta + // continue; + // } + // } + // if (openpart.get(openpart.find_column(PART_NRIGA)).as_int() == 9999) // Balzo + // continue; + + // if (openpart.get(openpart.find_column(PART_DATAREG)).as_date() <= TDate(31, 12, 2019)) + // { + // fout << rec->get_line() << endl; // Caso normale in cui e' aperta + // _exported.insert(_exported.end(), rec); + // } + // } + //} + //else + // warning_box(TR("Impossibile leggere file partite aperte.")); } -bool TComariExport_app::export_table(const short id) const +void TComariExport_app::export_scadenze(ofstream& fout) +{ + const char* fields[] = { + SCAD_ANNO, SCAD_NUMPART, SCAD_NRIGA, SCAD_NRATA, SCAD_CODPAG, SCAD_TIPOPAG, SCAD_IMPORTO, SCAD_DATASCAD, SCAD_TIPOCF, + SCAD_SOTTOCONTO, SCAD_GGRIT, SCAD_PAGATA, SCAD_IMPORTOPAG, SCAD_IMPORTOANT, SCAD_CODABIPR, SCAD_CODCABPR, SCAD_CODABI, SCAD_CODCAB + }; + const int dim_fields[] = { + DS_ANNO, DS_NUMPART, DS_NRIGA, DS_NRATA, DS_CODPAG, DS_TIPOPAG, DS_IMPORTO, DS_DATASCAD, DS_TIPOCF, + DS_SOTTOCONTO, DS_GGRIT, DS_PAGATA, DS_IMPORTOPAG, DS_IMPORTOANT, DS_CODABIPR, DS_CODCABPR, DS_CODABI, DS_CODCAB + }; + // Esporto le scadenze per i documenti che ho esportato dalle partite + if(!_exported.empty()) + { + const int items = (int)(sizeof dim_fields / sizeof *dim_fields); + TProgress_monitor bar(_exported.size(), "Esportazione Scadenze"); + TString sql_fields; + for (int i = 0; i < items - 1; ++i) + sql_fields << fields[i] << ", "; + sql_fields << fields[items - 1] << '\n'; + for (auto it = _exported.begin(); it != _exported.end(); ++it) + { + if (!bar.add_status()) + break; + TFixed_record& part = *(*it); + const TFixed_string& tipocf = part[3]; + const TFixed_string& anno = part[0]; + TString numpart = (const char*)part[1]; + numpart.trim(); + const TFixed_string& nriga = part[2]; + TString sql; sql << "SELECT " << sql_fields << + "FROM scad WHERE TIPOC = '" << tipocf << "' AND ANNO = " << anno << " AND NRIGA = " << nriga << ";"; + TSQL_recordset scad(sql); + bool found = false; + for(bool ok = scad.move_first(); ok; ok = scad.move_next()) + { + if (scad.get(1).as_string() == numpart) + { + found = true; + TFixed_record rec(items, dim_fields, fields); + for (int i = 0; i < items; ++i) + { + if (scad.column_info(i)._type == _datefld) + { + TString ansi; ansi << TDate(scad.get(i).as_date()).date2ansi(); + if (ansi != "0") // Butto le date "vuote" + rec.set_str(i, ansi); + } + else if (i == IS_IMPORTO || i == IS_IMPORTOPAG || i == IS_IMPORTOANT) // reali (non so perche' ma becca come reali anche gli interi...) + rec.set_str(i, TString(scad.get(i).as_real().string(18, 3, ' '))); + else + rec.set_str(i, scad.get(i).as_string()); + } + fout << rec.get_line() << std::endl; + } + else + { + if (found) + break; + } + } + } + } +} + +bool TComariExport_app::export_table(const short id) { bool ok = false; ofstream fout; @@ -501,7 +859,16 @@ bool TComariExport_app::export_table(const short id) const export_parti(fout); fout.close(); } - name = "Clienti Fornitori"; + name_file = "scadenze.txt"; + path = _fld_dest; + path << "\\" << name_file; + fout.open(path, ios_base::out); + if ((ok = fout.is_open())) + { + export_scadenze(fout); + fout.close(); + } + name = "Partite aperte"; break; case F_PIANOCONTI: // Not implemented name_file = "pianoconti.txt"; @@ -516,7 +883,7 @@ bool TComariExport_app::export_table(const short id) const name = "Mastri"; break; } - TString msg; msg << "Esportazione " << name << (ok ? " " : " non ") << "completata.\nFile: " << (ok ? path : name_file); + TString msg; msg << "Esportazione " << name << (ok ? " " : " non ") << "completata."; if (ok) message_box(msg); else diff --git a/src/ps/ps6215partite.h b/src/ps/ps6215partite.h index f61bdb50f..96bd5d123 100644 --- a/src/ps/ps6215partite.h +++ b/src/ps/ps6215partite.h @@ -30,6 +30,9 @@ #define D_DIFFCAM 18 // 18 con 3 decimali, segno, e virgola #define D_GRUPPOCL 3 #define D_CONTOCL 3 +#define D_COFI 28 +#define D_STATOPAIV 2 +#define D_PAIV 12 #define I_ANNO 0 #define I_NUMPART 1 @@ -59,4 +62,45 @@ #define I_SEZDIFCAM 25 #define I_DIFFCAM 26 #define I_GRUPPOCL 27 -#define I_CONTOCL 28 \ No newline at end of file +#define I_CONTOCL 28 +#define I_COFI 29 +#define I_STATOPAIV 30 +#define I_PAIV 31 + +#define DS_ANNO 4 +#define DS_NUMPART 7 +#define DS_NRIGA 4 +#define DS_NRATA 4 +#define DS_CODPAG 4 +#define DS_TIPOPAG 1 +#define DS_IMPORTO 18 +#define DS_DATASCAD 8 +#define DS_TIPOCF 1 +#define DS_SOTTOCONTO 6 +#define DS_GGRIT 4 +#define DS_PAGATA 1 +#define DS_IMPORTOPAG 18 +#define DS_IMPORTOANT 18 +#define DS_CODABIPR 5 +#define DS_CODCABPR 5 +#define DS_CODABI 5 +#define DS_CODCAB 5 + +#define IS_ANNO 0 +#define IS_NUMPART 1 +#define IS_NRIGA 2 +#define IS_NRATA 3 +#define IS_CODPAG 4 +#define IS_TIPOPAG 5 +#define IS_IMPORTO 6 +#define IS_DATASCAD 7 +#define IS_TIPOCF 8 +#define IS_SOTTOCONTO 9 +#define IS_GGRIT 10 +#define IS_PAGATA 11 +#define IS_IMPORTOPAG 12 +#define IS_IMPORTOANT 13 +#define IS_CODABIPR 14 +#define IS_CODCABPR 15 +#define IS_CODABI 16 +#define IS_CODCAB 17