From 61e142c92bd3f5333603ef124440818bd3764e6a Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 7 Sep 2012 14:54:55 +0000 Subject: [PATCH] Aggiunto porgramma di controllo pagamenti doppi git-svn-id: svn://10.65.10.50/branches/R_10_00@22724 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sc/sc1.cpp | 1 + sc/sc1.h | 1 + sc/sc1500.cpp | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++ sc/scmenu.men | 1 + 4 files changed, 149 insertions(+) create mode 100644 sc/sc1500.cpp diff --git a/sc/sc1.cpp b/sc/sc1.cpp index 333bef7e1..545444b6e 100755 --- a/sc/sc1.cpp +++ b/sc/sc1.cpp @@ -10,6 +10,7 @@ int main(int argc,char** argv) case 1: sc1200(argc,argv); break; // Apertura scadenze da saldi case 2: sc1300(argc,argv); break; // Allineamento partite case 3: sc1400(argc,argv); break; // Abbuoni automatici + case 4: sc1500(argc,argv); break; // Controllo pagamenti doppi default: sc1100(argc,argv); break; // Archiviazione partite pareggiate } return 0; diff --git a/sc/sc1.h b/sc/sc1.h index 7a0a28906..f5958405d 100755 --- a/sc/sc1.h +++ b/sc/sc1.h @@ -2,4 +2,5 @@ int sc1100(int argc, char** argv); int sc1200(int argc, char** argv); int sc1300(int argc, char** argv); int sc1400(int argc, char** argv); +int sc1500(int argc, char** argv); diff --git a/sc/sc1500.cpp b/sc/sc1500.cpp new file mode 100644 index 000000000..8788edfb5 --- /dev/null +++ b/sc/sc1500.cpp @@ -0,0 +1,146 @@ +#include +#include +#include + +#include "../cg/cgsaldac.h" + +class TCheckDoublePagsca : public TSkeleton_application +{ +protected: + void add_rec(const TISAM_recordset& inp, TCSV_recordset& outp); + +public: + virtual void main_loop(); +}; + +void TCheckDoublePagsca::add_rec(const TISAM_recordset& p, TCSV_recordset& o) +{ + o.new_rec(); + o.set(0, p.get(PART_TIPOCF)); + o.set(1, p.get(PART_SOTTOCONTO)); + o.set(2, p.get(PART_ANNO)); + o.set(3, p.get(PART_NUMPART)); + o.set(4, p.get(PART_NRIGA)); + o.set(5, p.get(PART_IMPORTO)); + o.set(6, p.get(PART_NREG)); + o.set(7, p.get(PART_DESCR)); +} + +void TCheckDoublePagsca::main_loop() +{ + TCSV_recordset o(""); + o.create_column(PART_TIPOCF, _alfafld); + o.create_column(PART_SOTTOCONTO, _longfld); + o.create_column(PART_ANNO, _intfld); + o.create_column(PART_NUMPART, _alfafld); + o.create_column(PART_NRIGA, _intfld); + o.create_column(PART_IMPORTO, _realfld); + o.create_column("NUM_REG", _longfld); + o.create_column("Descrizione riga pagamento", _alfafld); + + TISAM_recordset p("USE PART SELECT TIPOMOV=3\nTO TIPOC=C"); + const TRecnotype tot = p.items(); + + if (tot > 1) + { + TProgind pi(tot, title()); + + long sott1 = 0; + int anno1 = 0; + TString16 part1; + long nreg1 = 0; + int nrig1 = 0; + real impt1; + for (bool ok = p.move_first(); ok; ok = p.move_next()) + { + if (!pi.addstatus(1)) + break; + const long sott2 = p.get(PART_SOTTOCONTO).as_int(); + const int anno2 = p.get(PART_ANNO).as_int(); + const TString16 part2 = p.get(PART_NUMPART).as_string(); + const long nreg2 = p.get(PART_NREG).as_int(); + const int nrig2 = p.get(PART_NUMRIG).as_int(); + const real impt2 = p.get(PART_IMPORTO).as_real(); + if (sott1 == sott2 && anno1 == anno2 && part1 == part2 && nreg1 == nreg2 && nrig1 == nrig2 && impt1 == impt2) + { + p.move_prev(); + add_rec(p, o); + p.move_next(); + add_rec(p, o); + } + sott1 = sott2; + anno1 = anno2; + part1 = part2; + nreg1 = nreg2; + nrig1 = nrig2; + impt1 = impt2; + } + } + + const TRecnotype d = o.items(); + if (d > 0) + { + TRecordset_sheet s(o); + if (s.run() == K_ENTER && noyes_box(FR("Confermare l'eliminazione di %ld righe doppie"), d/2)) + { + TProgind pi(tot, TR("Eliminazione pagamenti doppi")); + TRecnotype e = 0; + for (bool ok = o.move_first(); ok; ok = o.move_next()) + { + if (!pi.addstatus(1)) + break; + const char tipocf = o.get(0L).as_string()[0]; + const long codcf = o.get(1).as_int(); + const int anno = o.get(2).as_int(); + const TString8 num= o.get(3).as_string(); + const int nriga1 = o.get(4).as_int(); + + o.move_next(); + const int nriga2 = o.get(4).as_int(); + CHECKD(nriga1 < nriga2, "Numero riga partita incoerente ", nriga2); + + const TBill clifo(0, 0, codcf, tipocf); + TPartita p(clifo, anno, num); + + TRecord_array& u = p.unassigned(); + const int flag = (u.exist(nriga1) ? 1 : 0) + (u.exist(nriga2) ? 2 : 0); + if (flag != 0) + { + const int nrigp = (flag == 1) ? nriga1 : nriga2; + p.elimina_pagamento(9999, 9999, nrigp); + } + else + { + const int nrigp = nriga2; + for (int f = p.prima_fattura(); f > 0 && f < nriga2; f = p.succ(f)) + { + const TRiga_partite& rf = p.riga(f); // Fattura + for (int r = rf.rate(); r > 0; r--) + { + if (p.esiste(f, r, nrigp)) + p.elimina_pagamento(f, r, nrigp); + } + } + } + if (p.rewrite()) + e++; + else + { + error_box(TR("Errore durante l'aggiornamento delle partite")); + break; + } + } + message_box(FR("Sono state eliminate %ld righe"), e); + } + } + else + message_box(TR("Non sono stati rilevati pagamenti doppi")); +} + +int sc1500(int argc, char** argv) +{ + TCheckDoublePagsca a; + a.run(argc, argv, TR("Controllo pagamenti doppi")); + return 0; +} + diff --git a/sc/scmenu.men b/sc/scmenu.men index 69214cbe6..243bc7d1c 100755 --- a/sc/scmenu.men +++ b/sc/scmenu.men @@ -22,4 +22,5 @@ Item_01 = "Stampa controllo saldi", "sc2 -4", "" Item_02 = "Creazione saldaconto da saldi", "sc1 -1", "" Item_03 = "Allineamento Partite", "sc1 -2", "F" Item_04 = "Abbuoni automatici", "sc1 -3", "F" +Item_05 = "Controllo pagamenti doppi", "sc1 -4", "F"