From 1aa60d0476a161f24e0396a7e6f2987afe22a467 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 4 Oct 1994 17:25:53 +0000 Subject: [PATCH] Modifiche a causali bilanci libro giornale git-svn-id: svn://10.65.10.50/trunk@314 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0500.cpp | 354 +++---- cg/cg0500a.uml | 5 +- cg/cg0500b.uml | 69 +- cg/cg1500.cpp | 1703 ++++++++++++++++++---------------- cg/cg1500a.uml | 2 +- cg/cg1600.cpp | 2385 ++++++++++++++++++++++++++++++------------------ cg/cg3400.cpp | 516 +++++++---- cg/cg3500.cpp | 73 +- cg/cg3500.h | 54 +- cg/cg3500a.uml | 152 +-- cg/cglib.h | 48 +- cg/cglib01.cpp | 227 ++--- 12 files changed, 3209 insertions(+), 2379 deletions(-) diff --git a/cg/cg0500.cpp b/cg/cg0500.cpp index 834b566ed..9585a7241 100755 --- a/cg/cg0500.cpp +++ b/cg/cg0500.cpp @@ -153,11 +153,12 @@ void TRighe_rcaus::set_descr(int i, const char * dfi, char tipocf) if (r == NULL) { - r = new Riga_rcaus (tc,dfi,tipocf); + // r = new Riga_rcaus (tc,dfi,tipocf); + r = new Riga_rcaus (tc,dfi); add(r,i); } r->add(dfi, 0); - r->add(tipocf, 1); + // r->add(tipocf, 1); } bool filtra_reg(const TRelation * r); @@ -249,7 +250,7 @@ bool CG0500_application::leggi_riga(int r, KEY k) if (k == K_ENTER) { TToken_string &riga = app()->ss().row(r); - const int g = riga.get_int(3); + const int g = riga.get_int(2); if (g == 0) // riga azzerata { riga.add("", 1); // pulisco tipo C/F @@ -263,27 +264,34 @@ bool CG0500_application::leggi_riga(int r, KEY k) bool filtra_reg(const TRelation * r) { - TFixed_string codtab(r->lfile().get("CODTAB")); - const int anno = atoi(codtab.cut(4)); - if (anno == anno_iva()) - { - const int tiporeg = r->lfile().get_int("I0"); - const bool corrisp = r->lfile().get_bool("B0"); + const TString codtab(r->lfile().get("CODTAB")); + int tiporeg = r->lfile().get_int("I0"); + bool corrisp = r->lfile().get_bool("B0"); - switch (app()->_filtro) - { - case 1: - return (tiporeg == 1); - case 2: - return (tiporeg == 1 && corrisp); - case 3: - return (tiporeg == 2); - case 4: // tiporeg 1 senza corrisp OPPURE 2 (NC ST ND AF) - return ( (tiporeg == 1 && !corrisp) || tiporeg == 2 ); - default: - return FALSE; - } - } + const int anno = atoi(codtab.left(4)); + + switch (app()->_filtro) + { + case 1: + if (anno == anno_iva() && tiporeg == 1) + return TRUE; + break; + case 2: + if (anno == anno_iva() && tiporeg == 1 && corrisp) + return TRUE; + break; + case 3: + if (anno == anno_iva() && tiporeg == 2) + return TRUE; + break; + case 4: // tiporeg 1 senza corrisp OPPURE 2 (NC ST ND AF) + if (anno == anno_iva()) + if ( (tiporeg == 1 && !corrisp) || tiporeg == 2 ) + return TRUE; + break; + default: + return FALSE; + } return FALSE; } @@ -358,31 +366,6 @@ bool CG0500_application::tipodoc_hndl (TMask_field& f, KEY k) field_reg.browse()->cursor()->set_filterfunction(filtra_reg); } } - /************************************************************** - // Cambio il filtro sui registri: con tipo=1 - if (val == "FV" || val == "FF" || val == "FS") { - app()->_filtro = 1; - field_reg.browse()->cursor()->set_filterfunction(filtra_reg); - } else - // con tipo=1 e corrisp="X" - if (val == "CN" || val == "RN" || val == "CR" || - val == "SC" || val == "RF" || val == "SN") { - app()->_filtro = 2; - field_reg.browse()->cursor()->set_filterfunction(filtra_reg); - } else - // Possono essere 1 o 2 - if (val == "NC" || val == "ST" || val == "ND" || - val == "AF") { - app()->_filtro = 4; - field_reg.browse()->cursor()->set_filterfunction(filtra_reg); - } else - // con tipo=2 - if (val == "FA" || val == "BD") { - app()->_filtro = 3; - field_reg.browse()->cursor()->set_filterfunction(filtra_reg); - } - **************************************************************/ - } else // TIPODOC vuoto || IN || PG || AN { @@ -398,25 +381,25 @@ bool CG0500_application::tipodoc_hndl (TMask_field& f, KEY k) } // Ma davvero esiste il registro ? - const TString16 codreg=f.mask().get(F_COD_REG); + TString16 codreg=f.mask().get(F_COD_REG); if (codreg.not_empty()) { - const TRegistro registro(codreg, anno_iva()); - if (!registro.ok()) - return f.error_box("Non esiste il registro %s per l'anno %d", - (const char*)codreg, anno_iva()); + TRegistro registro(codreg, anno_iva()); + if (!registro.read(codreg, anno_iva())) + return f.warning_box("Non esiste il registro %s per l'anno %d", + (const char *)codreg, anno_iva()); } app()->MostraCampi(f); - app()->fill_sheet(f.mask()); + if (f.focusdirty()) + app()->fill_sheet(f.mask()); } return TRUE; } bool CG0500_application::tipomov_hndl (TMask_field& f, KEY k) { - if (k == K_SPACE) - { + if (k == K_SPACE) { app()->MostraCampi(f); if (f.focusdirty()) app()->fill_sheet(f.mask()); } @@ -427,15 +410,14 @@ bool CG0500_application::tipomov_hndl (TMask_field& f, KEY k) // essere puramente contabile (= codreg vuoto e tpm = Nessuno bool CG0500_application::codcausim_hndl (TMask_field& f, KEY k) { - if (f.to_check(k)) - { - const TString16 causim(f.get()); + if (f.to_check(k)) { + TString16 causim(f.get()); TLocalisamfile& caus = app()->_rel->lfile(LF_CAUSALI); caus.zero(); caus.put(CAU_CODCAUS, causim); if (caus.read() == NOERR) { - const int tpm = caus.get_int(CAU_TIPOMOV); + const int tpm = caus.get_int(CAU_TIPOMOV); TString16 codreg = caus.get(CAU_REG); if (codreg.not_empty() || tpm != 0) return f.warning_box("La causale per l'incasso immediato specificata (%s) deve essere puramente contabile", @@ -449,8 +431,8 @@ bool CG0500_application::codcausim_hndl (TMask_field& f, KEY k) bool CG0500_application::MostraCampi(TMask_field& f) { TMask& m = f.mask(); - const int tpm = m.get_int(F_TIPO_MOV); - const TString16 codreg = m.get(F_COD_REG); + const int tpm = m.get_int(F_TIPO_MOV); + TString16 codreg = m.get(F_COD_REG); if (codreg.empty()) { m.hide(F_AUTO_FAT); @@ -458,15 +440,14 @@ bool CG0500_application::MostraCampi(TMask_field& f) m.hide(F_FAT_RITARDO); m.hide(F_OP_INTRACOM); m.hide(F_VALINTRA); - if (salda_conto()) - m.hide(F_COD_CAUS_IM); - switch (tpm) - { + if (salda_conto()) m.hide(F_COD_CAUS_IM); + + switch (tpm) { case 0: m.show(F_OP_FINE_ANNO); m.show(F_COLL_CESP); m.show(F_M_770); - m.hide(F_MOV_VALU); + if (salda_conto()) m.hide(F_MOV_VALU); m.hide(F_MOV_SEZ); break; case 3: @@ -482,8 +463,7 @@ bool CG0500_application::MostraCampi(TMask_field& f) break; } } - else - { // codreg non vuoto + else { // codreg non vuoto m.hide(F_OP_FINE_ANNO); m.hide(F_MOV_SEZ); if (gestione_valuta()) m.show(F_MOV_VALU); @@ -500,11 +480,9 @@ bool CG0500_application::MostraCampi(TMask_field& f) bool CG0500_application::cod_reg_hndl (TMask_field& f, KEY k) { - if (k == K_TAB) - { + if (k == K_TAB) { app()->MostraCampi(f); - if (f.focusdirty()) - app()->fill_sheet(f.mask()); + if (f.focusdirty()) app()->fill_sheet(f.mask()); return TRUE; } @@ -526,53 +504,13 @@ bool CG0500_application::cod_reg_hndl (TMask_field& f, KEY k) i = (TipoIVA)tabtpd.get_int("I0"); // IVA acquisti, vendite, generica const TipoIVA ri = grog.iva(); if (i == iva_generica) i = ri; - if (i != ri) - { + if (i != ri) { return f.warning_box("Tipo documento incompatibile con tipo registro"); i = iva_errata; } } } } - /* - if (tpd.not_empty() && tpd != "AN" && tpd != "PG" && tpd != "IN") - { - if (codreg.empty()) - return f.warning_box("Manca il codice del registro"); - } - else - { - // con tipo=1 - if (tpd == "FV" || tpd == "FS" || tpd == "FS") - { - if (tipo != 1) ok = FALSE; - } else - - // con tipo=1 e corrisp="X" - if (tpd == "CN" || tpd == "RN" || tpd == "CR" || - tpd == "SC" || tpd == "RF" || tpd == "SN") - { - if (tipo != 1 || !corrisp) ok = FALSE; - } else - // Possono essere 1 o 2 - if (tpd == "NC" || tpd == "ST" || tpd == "ND" || - tpd == "AF") - { - if (tipo != 1 && tipo != 2) ok = FALSE; - } else - - // con tipo=2 - if (tpd == "FA" || tpd == "BD") - { - if (tipo != 2) ok = FALSE; - } - } - - if (!ok) - return f.warning_box("Il registro (tipo %d) non e' compatibile con il tipo di documento (%s)", - tipo, (const char*)tpd); - } - */ return TRUE; } @@ -580,9 +518,9 @@ bool CG0500_application::cod_reg_hndl (TMask_field& f, KEY k) //////////////////////////////////////////////////////////////////////////// // Handler della maschera dello spreadsheet //////////////////////////////////////////////////////////////////////////// -// Se specifico il conto deve essere non vuoto il gruppo bool CG0500_application::conto_hndl (TMask_field& f, KEY k) { + // Se specifico il conto deve essere non vuoto il gruppo if (f.to_check(k)) { int io = f.dlg(); @@ -593,7 +531,7 @@ bool CG0500_application::conto_hndl (TMask_field& f, KEY k) if (g == 0) return f.warning_box("Non accetto un conto senza gruppo"); } - // Controllo: << solo la riga 1 o 7 possono essere C/F >> + // Controllo: << se e' fattura solo la riga 1 o 7 possono essere C/F >> if (k == K_ENTER) { char scarta = '\0'; @@ -601,52 +539,50 @@ bool CG0500_application::conto_hndl (TMask_field& f, KEY k) char cf = f.mask().get(SS_TIPOCF)[0]; TMask_field& cfld = f.mask().field(SS_TIPOCF); const int tpr = app()->main_mask()->get_int(F_TIPO_REG); - + bool puramente_contabile = FALSE; + switch (tpr) { - case 1: - scarta = 'F'; - break; - case 2: - scarta = 'C'; - break; - case 0: - scarta = 'Z'; // Accetto tutto - switch (app()->_tipo_des) - { - case incasso_pagamento: - ultima = 11; - break; - case incasso_pagamento_gesval: - ultima = 12; - break; - default: - break; - } - } - if (app()->_riga > ultima) // se sono nelle righe libere accetto tutto - return TRUE; - else - if (app()->_riga == 0 || app()->_riga == 6) - { - if (cf == scarta) - return cfld.warning_box( - "Impossibile inserire un %s con registro di tipo %s nella riga %d", - cf == 'C' ? "cliente" : "fornitore", - tpr == 1 ? "vendite" : "acquisti", app()->_riga+1); - } + case 1: scarta = 'F'; break; + case 2: scarta = 'C'; break; + case 0: + scarta = 'Z'; // Accetto tutto + puramente_contabile = TRUE; + switch (app()->_tipo_des) + { + case incasso_pagamento: ultima = 11; break; + case incasso_pagamento_gesval: ultima = 12; break; + default: break; + } + } + + if (!puramente_contabile) + { + if (app()->_riga > ultima) // se sono nelle righe libere accetto TUTTO.. + return TRUE; else - if (cf != '\0') - return cfld.warning_box( - "Impossibile inserire un %s con registro di tipo %s nella riga %d", - cf == 'C' ? "cliente" : "fornitore", - tpr == 1 ? "vendite" : "acquisti", app()->_riga+1); + if (app()->_riga == 0 || app()->_riga == 6) + { + if (cf == scarta) + return cfld.warning_box( + "Impossibile inserire un %s con registro di tipo %s nella riga %d", + cf == 'C' ? "cliente" : "fornitore", + tpr == 1 ? "vendite" : "acquisti", app()->_riga+1); + } + else + if (cf == 'C' || cf == 'F') + return cfld.warning_box( + "Impossibile inserire un %s con registro di tipo %s nella riga %d", + cf == 'C' ? "cliente" : "fornitore", + tpr == 1 ? "vendite" : "acquisti", app()->_riga+1); + } } return TRUE; } -// Se specifico il sottoconto devono essere non vuoti gruppo e conto -bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k) +// 1. Se specifico il sottoconto devono essere non vuoti gruppo e conto +// 2. g-c-s devono esistere +bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k) { if (f.to_check(k)) { @@ -658,6 +594,10 @@ bool CG0500_application::sottoconto_hndl (TMask_field& f, KEY k) if (s > 0) if (g == 0 || c == 0) return f.warning_box("Non accetto un sottoconto con gruppo o conto vuoti"); + + TConto tc(g,c,s); + if (!tc.read()) + return f.warning_box("Conto inesistente"); } return TRUE; } @@ -706,15 +646,15 @@ void TRighe_rcaus::CausaleAcquisti() int i=0; app()->_tipo_des = acquisto; // set_descr( i++, "C Fornitori", 'F'); - set_descr( i++, "C Fornitori", ' '); - set_descr(i++, "C Di costo", ' '); - set_descr(i++, "C Iva acquisti", ' '); - set_descr(i++, "C Iva non detraibile", ' '); - set_descr(i++, "C Imp. esenti", ' '); - set_descr(i++, "C Imp. non imponibili", ' '); - set_descr(i++, "C Imp. non soggetti", ' '); - set_descr(i++, "C Ritenute fiscali", ' '); - set_descr(i++, "C Ritenute soc.", ' '); + set_descr( i++, "C Fornitori"); + set_descr(i++, "C Di costo"); + set_descr(i++, "C Iva acquisti"); + set_descr(i++, "C Iva non detraibile"); + set_descr(i++, "C Imp. esenti"); + set_descr(i++, "C Imp. non imponibili"); + set_descr(i++, "C Imp. non soggetti"); + set_descr(i++, "C Ritenute fiscali"); + set_descr(i++, "C Ritenute soc."); CaricaRigheLibere(); } @@ -764,8 +704,7 @@ void CG0500_application::compilaarray(const TString& tpd, int tpm, int tpr, int { if (salda_conto()) { - switch (tpm) - { + switch (tpm) { case 3: case 5: case 6: @@ -774,8 +713,7 @@ void CG0500_application::compilaarray(const TString& tpd, int tpm, int tpr, int case 0: if (m770 == 6) _righe_rcaus.CausaleRitenutaOccas(); - else - { + else { _forcedCopy = TRUE; _righe_rcaus.ClearDescr(); _righe_rcaus.CaricaRigheLibere(); @@ -788,8 +726,7 @@ void CG0500_application::compilaarray(const TString& tpd, int tpm, int tpr, int break; } } - else - { // NO saldaconto + else { // NO saldaconto _forcedCopy = TRUE; _righe_rcaus.ClearDescr(); _righe_rcaus.CaricaRigheLibere(); @@ -833,9 +770,13 @@ void CG0500_application::add_riga(int numrig, { TSheet_field& cs = ss(); TToken_string & riga = cs.row(numrig); - riga.add(cf, 1); riga.add(tc.gruppo(), 2); - riga.add(tc.conto(), 3); riga.add(tc.sottoconto(),4); - riga.add(sz, 5); riga.add(d, 6); riga.add(da,7); + riga.add(cf, 1); + riga.add(tc.gruppo(), 2); + riga.add(tc.conto(), 3); + riga.add(tc.sottoconto(),4); + riga.add(sz, 5); + riga.add(d, 6); + riga.add(da,7); riga.add(riva ? "X" : "", 8); riga.add(civa, 9); } @@ -850,12 +791,16 @@ void CG0500_application::read_rcaus(TMask& m) TLocalisamfile& rcaus = _rel->lfile(LF_RCAUSALI); _rel->update(); // chiamo position_rels() - + const TString cod(_rel->lfile().get(RCA_CODCAUS)); + _righe_gia_presenti.reset(); // _righe_rcaus.destroy(); + + rcaus.zero(); + rcaus.put(RCA_CODCAUS, cod); + int e = rcaus.read(_isgteq); - bool ok = _rel->is_first_match(LF_RCAUSALI); - while (ok) + while (e == NOERR && rcaus.get(RCA_CODCAUS) == cod) { numrig = rcaus.get_int(RCA_NRIGA); CHECK(numrig > 0, "Causale con numero riga nullo"); @@ -865,7 +810,6 @@ void CG0500_application::read_rcaus(TMask& m) sz = rcaus.get_char(RCA_SEZIONE); d = rcaus.get(RCA_DESC); da = rcaus.get(RCA_CODDESC); - // cf = rcaus.get(RCA_TIPOCF)[0]; cf = rcaus.get_char(RCA_TIPOCF); riva = rcaus.get_bool(RCA_RIGAIVA); civa = rcaus.get(RCA_CODIVA); @@ -873,8 +817,8 @@ void CG0500_application::read_rcaus(TMask& m) add_riga(numrig-1, cf, sz, d, da, riva, civa, tc); - _righe_gia_presenti.set(numrig); - ok = _rel->next_match(LF_RCAUSALI); + _righe_gia_presenti.set(numrig); + e = rcaus.next(); } } @@ -915,22 +859,18 @@ bool CG0500_application::descr2array(TMask& m, bool fromHandler) int tpm, m770, tpr; // if (m.mode() == MODE_MOD && !fromHandler) - if (fromHandler) - { + if (fromHandler) { codreg = m.field(F_COD_REG).get(); tpd = m.field(F_TIPO_DOC).get(); tpm = m.get_int(F_TIPO_MOV); m770 = m.get_int(F_M_770); - } - else if (m.mode() == MODE_MOD) - { + } else if (m.mode() == MODE_MOD) { codreg = caus.get("REG"); tpd = caus.get("TIPODOC"); tpm = caus.get_int("TIPOMOV"); m770 = caus.get_int("M770"); } - else - { // sono in inserimento e prima di entrare negli handler + else { // sono in inserimento e prima di entrare negli handler codreg = m.field(F_COD_REG).get(); tpd = m.field(F_TIPO_DOC).get(); tpm = m.get_int(F_TIPO_MOV); @@ -939,13 +879,12 @@ bool CG0500_application::descr2array(TMask& m, bool fromHandler) if (fromHandler) tpr = m.get_int(F_TIPO_REG); - else - { + else { TString16 chiave; chiave << anno_iva() << codreg; TTable reg("REG"); reg.put("CODTAB", chiave); reg.read(); - tpr = reg.get_int("I0"); + tpr = reg.get_int("I0"); } // carico le descrizioni fisse nell'array Righe_rcaus @@ -957,7 +896,7 @@ bool CG0500_application::descr2array(TMask& m, bool fromHandler) void CG0500_application::togli_dal_file(const TString& cau) { long i; - TLocalisamfile &rcaus = _rel->lfile(LF_RCAUSALI); + TLocalisamfile& rcaus = _rel->lfile(LF_RCAUSALI); long last = _righe_gia_presenti.last_one(); long start = _righe_gia_presenti.first_one(); @@ -988,10 +927,10 @@ int CG0500_application::rewrite(const TMask& m) int CG0500_application::re_write(const TMask& m,bool rewrite) { const TString16 cau(m.get(F_COD_CAUS)); - TString80 desc; - TString16 coddesc; - TLocalisamfile &caus = _rel->lfile(LF_CAUSALI); - TLocalisamfile &rcaus = _rel->lfile(LF_RCAUSALI); + TString80 desc; + TString16 coddesc; + TLocalisamfile& caus = _rel->lfile(LF_CAUSALI); + TLocalisamfile& rcaus = _rel->lfile(LF_RCAUSALI); m.autosave(_rel); @@ -1004,14 +943,13 @@ int CG0500_application::re_write(const TMask& m,bool rewrite) TToken_string &riga = cs.row(i); if (riga.empty_items()) continue; - desc = riga.get(0); - const char tipo_cf = riga.get_char(); - const int g = riga.get_int(); - const int c = riga.get_int(); - long s = riga.get_long(); - char sezione = riga.get_char(); - desc = riga.get(); - coddesc = riga.get(); + const char tipo_cf = riga.get_char(1); + const int g = riga.get_int(2); + const int c = riga.get_int(3); + long s = riga.get_long(4); + char sezione = riga.get_char(5); + desc = riga.get(6); + coddesc = riga.get(7); if (g > 0 || c > 0 || s > 0L) { @@ -1035,7 +973,7 @@ int CG0500_application::re_write(const TMask& m,bool rewrite) } else rcaus.write(); - } + } } if (rewrite) @@ -1050,10 +988,12 @@ int CG0500_application::re_write(const TMask& m,bool rewrite) bool CG0500_application::remove() { + _rel->restore_status(); // senno' non riesco a leggere il cod. caus. + _rel->update(); // chiamo position_rels() + const TString cod(_rel->lfile().get(RCA_CODCAUS)); const bool ok = TRelation_application::remove(); if (ok) { - const TString cod(_rel->lfile().get(RCA_CODCAUS)); TLocalisamfile& rcaus = _rel->lfile(LF_RCAUSALI); rcaus.zero(); rcaus.put(RCA_CODCAUS, cod); @@ -1101,15 +1041,13 @@ bool CG0500_application::user_create() _msk = new TMask("cg0500a"); - if (!salda_conto()) - { + if (!salda_conto()) { _msk->hide (F_MOV_SEZ); _msk->hide (F_TIPO_MOV_1); _msk->hide (F_TIPO_MOV_2); _msk->show (F_COD_CAUS_IM); } - else - { + else { _msk->show (F_MOV_SEZ); _msk->hide (F_COD_CAUS_IM); } diff --git a/cg/cg0500a.uml b/cg/cg0500a.uml index 2f04a2b0d..74ef576c3 100755 --- a/cg/cg0500a.uml +++ b/cg/cg0500a.uml @@ -81,9 +81,10 @@ BEGIN OUTPUT F_COD_REG CODTAB[5,7] OUTPUT F_TIPO_REG I0 OUTPUT F_CORRISP B0 - HELP "Codice registro" + HELP "Inserire il codice registro" + WARNING "Non trovo il registro" CHECKTYPE NORMAL - FLAGS "DU" + FLAGS "DUZ" END // Questo rimane sempre nascosto diff --git a/cg/cg0500b.uml b/cg/cg0500b.uml index 04cc3d9df..ee1f2f525 100755 --- a/cg/cg0500b.uml +++ b/cg/cg0500b.uml @@ -11,15 +11,9 @@ END LISTBOX 102 1 11 BEGIN PROMPT 33 1 "C/F " - ITEM " |Conto" - MESSAGE SHOW,105|HIDE,205|HIDE,305 - MESSAGE SHOW,107|HIDE,207|HIDE,307 - ITEM "C|Cliente" - MESSAGE SHOW,205|HIDE,105|HIDE,305 - MESSAGE SHOW,207|HIDE,107|HIDE,307 - ITEM "F|Fornitore" - MESSAGE SHOW,305|HIDE,105|HIDE,205 - MESSAGE SHOW,307|HIDE,107|HIDE,207 + ITEM " |Conto" MESSAGE SHOW,105|HIDE,205|HIDE,305|SHOW,107|HIDE,207|HIDE,307 + ITEM "C|Cliente" MESSAGE SHOW,205|HIDE,105|HIDE,305|SHOW,207|HIDE,107|HIDE,307 + ITEM "F|Fornitore" MESSAGE SHOW,305|HIDE,105|HIDE,205|SHOW,307|HIDE,107|HIDE,207 FLAGS "DG" GROUP 1 // FLAGS "U" @@ -60,7 +54,10 @@ BEGIN OUTPUT 102 TMCF OUTPUT 104 CONTO OUTPUT 103 GRUPPO - OUTPUT 107 DESCR + OUTPUT 107 DESCR + OUTPUT 207 DESCR + OUTPUT 307 DESCR + MESSAGE DIRTY,105|DIRTY,205|DIRTY,305 WARNING "Conto inesistente o mancante" ADD RUN CG0 -0 GROUP 1 @@ -85,6 +82,8 @@ BEGIN OUTPUT 107 DESCR ADD RUN CG0 -0 CHECKTYPE NORMAL + HELP "Inserire il sottoconto" + WARNING "Sottoconto inesistente" GROUP 1 END @@ -103,8 +102,19 @@ BEGIN DISPLAY "Ragione sociale@50" RAGSOC DISPLAY "Tipo C/F" TIPOCF OUTPUT 205 CODCF +<<<<<<< cg0500b.uml + OUTPUT 105 CODCF OUTPUT 207 RAGSOC + OUTPUT 107 RAGSOC + OUTPUT 307 RAGSOC +======= + OUTPUT 207 RAGSOC +>>>>>>> 1.11 CHECKTYPE NORMAL +<<<<<<< cg0500b.uml + FLAGS "H" +======= +>>>>>>> 1.11 ADD RUN CG0 -1 GROUP 1 END @@ -123,8 +133,20 @@ BEGIN DISPLAY "Ragione sociale@50" RAGSOC DISPLAY "Tipo C/F" TIPOCF OUTPUT 305 CODCF +<<<<<<< cg0500b.uml + OUTPUT 205 CODCF + OUTPUT 105 CODCF + OUTPUT 107 RAGSOC + OUTPUT 207 RAGSOC OUTPUT 307 RAGSOC +======= + OUTPUT 307 RAGSOC +>>>>>>> 1.11 CHECKTYPE NORMAL +<<<<<<< cg0500b.uml + FLAGS "H" +======= +>>>>>>> 1.11 ADD RUN CG0 -1 GROUP 1 END @@ -154,6 +176,11 @@ BEGIN OUTPUT 104 CONTO OUTPUT 103 GRUPPO OUTPUT 107 DESCR +<<<<<<< cg0500b.uml + OUTPUT 207 DESCR + OUTPUT 307 DESCR +======= +>>>>>>> 1.11 ADD RUN CG0 -0 GROUP 1 END @@ -171,8 +198,15 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Sottoconto" CODCF + OUTPUT 105 CODCF OUTPUT 205 CODCF + OUTPUT 305 CODCF + OUTPUT 107 RAGSOC OUTPUT 207 RAGSOC +<<<<<<< cg0500b.uml + OUTPUT 307 RAGSOC +======= +>>>>>>> 1.11 GROUP 1 FLAGS "H" END @@ -191,7 +225,14 @@ BEGIN DISPLAY "Conto" CONTO DISPLAY "Sottoconto" CODCF OUTPUT 305 CODCF + OUTPUT 205 CODCF + OUTPUT 105 CODCF OUTPUT 307 RAGSOC +<<<<<<< cg0500b.uml + OUTPUT 207 RAGSOC + OUTPUT 107 RAGSOC +======= +>>>>>>> 1.11 GROUP 1 FLAGS "H" END @@ -232,18 +273,18 @@ END BUTTON DLG_OK 9 2 BEGIN - PROMPT -13 -1 "" + PROMPT -13 -1 "" END BUTTON DLG_CANCEL 9 2 BEGIN - PROMPT -23 -1 "" + PROMPT -23 -1 "" END BUTTON DLG_NULL 9 2 BEGIN - PROMPT -33 -1 "Azzera" - MESSAGE RESET,1@ + PROMPT -33 -1 "Azzera" + MESSAGE RESET,1@ END ENDPAGE diff --git a/cg/cg1500.cpp b/cg/cg1500.cpp index 7438891a9..15b0f7b26 100755 --- a/cg/cg1500.cpp +++ b/cg/cg1500.cpp @@ -56,6 +56,7 @@ class CG1500_application : public TPrintapp real movdare; real movavere; real saldofinale; + TDate udata; }; cli_for* _cf; @@ -65,21 +66,22 @@ class CG1500_application : public TPrintapp TRelation* _rel; TCursor * _cur; TProgind * _prog; - TClifo_list* _listacf, * _lista; + TSaldi_list* _listacf, * _lista; TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag; TIsamtempfile * _tmp_saldi_att, * _tmp_saldi_pass, * _tmp_saldi_conti_uno; TIsamtempfile * _tmp_saldi_costi, * _tmp_saldi_ricavi,* _tmp_saldi_conti_due; TTable* _esc; - TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis,_tipoc_succ; + TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis; TString _descr_dare, _descr_avere, _gc_corr_dare, _gc_corr_avere, _descr; - TString _gc_prec_dare, _gc_prec_avere, _situazione, _descr_succ, _tipo_conto; + TString _gc_prec_dare, _gc_prec_avere, _situazione, _descr_succ; + char _tipo_conto, _tipoc_succ; int _annoes, _bilancio, _tipo_stampa, _tipo_stampa1,_stampa_width,_gp,_cp,_i; int _eof1, _eof2, _gruppo_dare, _gruppo_avere, _conto_dare, _conto_avere; int _add_file_da, _add_file_a, _indbil_dare, _indbil_avere, _indbil; int _eof3, _eof4, _eof5, _eof6, _verifica, _stampac, _stampav, _ordinamento; - int _gruppo, _conto, _gruppo_succ, _conto_succ; + int _gruppo, _conto, _gruppo_succ, _conto_succ, _annoapp; long _sottoconto_dare, _sottoconto_avere, _sottoconto, _sottoconto_succ; real _saldo_dare, _saldo_avere, _gruppo_a, _gruppo_da, _conto_a; @@ -91,19 +93,21 @@ class CG1500_application : public TPrintapp real _mov_avere_succ, _saldofinale_succ; real _saldo_dare_tot, _saldo_avere_tot, _mov_dare_tot, _mov_avere_tot; real _saldo_finale_tot, _saldo_ini_gruppo_dare, _saldo_ini_gruppo_avere; - - TDate _datalim, _data, _datada, _dataa, _dataini, _ultima_data; + real _gruppo_da_ordine, _gruppo_a_ordine; + real _prg_saldoini_dare, _prg_saldoini_avere; + + TDate _datalim, _data, _datada, _dataa, _dataini, _ultima_data, _u_max; bool _cambiato_conto_1, _cambiato_conto_2, _add_file_avere; bool _add_file_dare, _prima_volta, _seconda_volta, _totali, _codici, _saldo; bool _add_dare, _add_avere, _controlla, _salto_pagina, _flag, _stampato; bool _sottoc_dare, _sottoc_avere, _salto_pagina1, _livello_conto; bool _stampa_mov_prov; TString _causale_ap, _causale_chi; - + TArray _clienti, _fornitori; + public: TDate _inizioEs, _fineEs; - bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; } void user_create() ; void user_destroy(); @@ -113,21 +117,22 @@ public: virtual void preprocess_header(); virtual bool preprocess_page(int,int); virtual print_action postprocess_page(int,int); - virtual print_action postprocess_print(int,int); + //virtual print_action postprocess_print(int,int); + virtual void postclose_print(); virtual void set_page(int,int); - + real compensazione(bool compensa, int indbil_conto, real& saldo); const char* causale_chiusura() { return _causale_chi;} const char* causale_apertura() { return _causale_ap;} bool bil_sez_contr(); bool bil_verifica(); - bool situazione_clifo(); - bool ricerca_sottoc_clifo(int,int,char,bool,int,real&); + bool ricerca_sottoc_clifo(int,int,bool,int,real&); bool ricerca_cf(int,int,char,real&,real&,real&,real&,real&,real&,real&); bool calcola(int,int,long); + void leggi_pcon(); // Inizializza i TArray C/F void crea_sort_clifo(); void init_sort(); void leggi_sort(); - void riempi_record(const char*,int,int,long,const char*,const real&, + void riempi_record(char,int,int,long,const char*,const real&, const real&,const real&,const real&,const real&); void get_dati_ditta(); void scrivi_record_conto(const real&,const real&,const real&, @@ -135,7 +140,7 @@ public: void scrivi_record_gruppo(const real&,const real&,const real&, const real&, const real&); int stampa_record_conto(int,int,const char*,const real&,const real&, - const real&,const real&,const real&,const TString&); + const real&,const real&,const real&,const char); int stampa_intestazione_ditta(); int cerca_indbil(int,int); void scrivig_file_temp(); @@ -148,9 +153,9 @@ public: void stampa_prima_colonna(int,int,long,const char*,const real&); void stampa_seconda_colonna(int,int,long,const char*,const real&); void stampa_totali(); - void controlla_conto_uno(int,int); - //void controlla_conto_due(); - const char* DescrizioneConto(int,int,long,const char*); + void stampa_totali_uno(); + void controlla_conto(int,int); + const char* DescrizioneConto(int,int,long,char); //chiama quella di TConto TDate UltimaData(int,int,long,int); CG1500_application() {} @@ -193,7 +198,7 @@ TDate FineEsercizio(int anno) bool IsEsercizio (const TDate& datalim, int anno_eser) { TTable TabEs ("ESC"); - TString codtab; + TString16 codtab; TDate inizio,fine; TabEs.zero(); @@ -222,7 +227,7 @@ HIDDEN int date2esc(const TDate& d, int* prevesc) const TDate fa(esc.get("D1")); // Data fine esercizio const anno = esc.get_int("CODTAB"); app()->_inizioEs = ia; - app()->_fineEs = fa; + app()->_fineEs = fa; if (d >= ia && d <= fa) return anno; if (prevesc) *prevesc = anno; @@ -248,7 +253,7 @@ bool mask_anno(TMask_field& f, KEY k) return FALSE; } } - if (k == K_SPACE || k == K_TAB) + if ( k == K_TAB || f.focusdirty()) { int tipo_stampa; int anno = f.mask().get_int(F_ANNO); @@ -363,18 +368,20 @@ bool mask_datalim (TMask_field& f, KEY k) else f.mask().field(F_DATALIM).set(FineEsercizio(anno)); } - else + else //anno == 0 { if (!datalim.ok()) { f.error_box ("La data limite e' obbligatoria"); return FALSE; } - if (date2esc(datalim) == 0) + long anno = date2esc(datalim); + if (anno == 0) { f.error_box ("La data limite deve appartenere ad un esercizio attivo della ditta"); return FALSE; - } + } + f.mask().set(F_ANNO,anno); } } return TRUE; @@ -406,13 +413,14 @@ bool mask_date(TMask_field& f, KEY k) f.mask().field(F_DATADA).set(InizioEsercizio(anno)); else if (id == F_DATAA) f.mask().field(F_DATAA).set(FineEsercizio(anno)); - } + } + app()->_annoapp = anno; } else { if ( !data.ok() ) { - f.error_box("Indicare una data appartenente ad un esercizio attivato della ditta"); + f.error_box("Indicare una data appartenente ad un esercizio attivo della ditta"); return FALSE; } else @@ -429,9 +437,10 @@ bool mask_date(TMask_field& f, KEY k) if (id == F_DATAA) { TDate from (f.mask().get(id - 1)); - if ( date2esc(from) != date2esc(data) ) + app()->_annoapp = date2esc(from); + if ( app()->_annoapp != date2esc(data) ) { - f.error_box("Le date devono appartenere ad uno stesso esercizio attivato della ditta"); + f.error_box("Le date devono appartenere ad uno stesso esercizio attivo della ditta"); return FALSE; } if (from > data) @@ -439,6 +448,7 @@ bool mask_date(TMask_field& f, KEY k) f.error_box("La data limite inferiore non puo' essere maggiore della data limite superiore"); return FALSE; } + //f.mask().set(F_ANNO, anno); } } } @@ -506,45 +516,87 @@ void CG1500_application::scrivig_file_temp() if (_add_dare) { nome_campo = SLD_PDARE; - valore = _gruppo_da; - if (_indbil == 1 || _indbil==2) tmp = _tmp_saldi_att; // da stampare a sx - else - if (_indbil==3 || _indbil==4) tmp = _tmp_saldi_costi; //da stampare a sx - else - if (_indbil==5) tmp = _tmp_saldi_conti_uno; - else return; + valore = _gruppo_da; + switch (_indbil) + { + case 1: + case 2: + tmp = _tmp_saldi_att; + break; + case 3: + case 4: + tmp = _tmp_saldi_costi; + break; + case 5: + tmp = _tmp_saldi_conti_uno; + valore = _gruppo_da_ordine; + break; + default: + break; + } + tmp->zero(); tmp->put(SLD_GRUPPO,_gp); - tmp->put(SLD_CONTO,0); - tmp->put(SLD_SOTTOCONTO,0L); - tmp->put(nome_campo, valore); - tmp->write(); + if (tmp->read() == NOERR) + { + tmp->put(SLD_CONTO,0); + tmp->put(SLD_SOTTOCONTO,0L); + tmp->put(nome_campo, valore); + tmp->rewrite(); + } + else + { + tmp->put(SLD_CONTO,0); + tmp->put(SLD_SOTTOCONTO,0L); + tmp->put(nome_campo, valore); + tmp->write(); + } + + //if (_indbil == 5) + // _gruppo_da_ordine = ZERO; } if (_add_avere) { nome_campo = SLD_PAVERE; - valore = _gruppo_a; - if (_indbil==2 || _indbil==1) tmp = _tmp_saldi_pass; //da stampare a dx - else - if (_indbil==4 || _indbil==3) tmp = _tmp_saldi_ricavi;//da stampare a dx - else - if (_indbil==5) tmp = _tmp_saldi_conti_due; - else return; + valore = _gruppo_a; + switch (_indbil) + { + case 1: + case 2: + tmp = _tmp_saldi_pass; + break; + case 3: + case 4: + tmp = _tmp_saldi_ricavi; + break; + case 5: + tmp = _tmp_saldi_conti_due; + valore = _gruppo_a_ordine; + break; + default: + break; + } + tmp->zero(); tmp->put(SLD_GRUPPO,_gp); - tmp->put(SLD_CONTO,0); - tmp->put(SLD_SOTTOCONTO,0L); - tmp->put(nome_campo, valore); - tmp->write(); + if (tmp->read() == NOERR) + { + tmp->put(SLD_CONTO,0); + tmp->put(SLD_SOTTOCONTO,0L); + tmp->put(nome_campo, valore); + tmp->rewrite(); + } + else + { + tmp->put(SLD_CONTO,0); + tmp->put(SLD_SOTTOCONTO,0L); + tmp->put(nome_campo, valore); + tmp->write(); + } + + //if (_indbil == 5) + // _gruppo_a_ordine = ZERO; } - /* - tmp->zero(); - tmp->put(SLD_GRUPPO,_gp); - tmp->put(SLD_CONTO,0); - tmp->put(SLD_SOTTOCONTO,0L); - tmp->put(nome_campo, valore); - tmp->write(); - */ _add_dare = _add_avere = FALSE; } @@ -648,6 +700,64 @@ void CG1500_application::scrivis_file_temp(int g, int c, long s, real saldo) tmp->write(); } +real CG1500_application::compensazione(bool compensa, int indbil_conto, real& sld) +{ + real saldo = sld; + + if (!compensa) + { + switch (indbil_conto) + { + case 1: + if (saldo > ZERO) + _indbil = indbil_conto; + else + { + _indbil = 2; + saldo = -saldo; + } + break; + + case 3: + if (saldo > ZERO) + _indbil = indbil_conto; + else + { + _indbil = 4; + saldo = -saldo; + } + break; + + case 2: + if (saldo < ZERO) + { + _indbil = indbil_conto; + saldo = -saldo; + } + else + _indbil = 1; + break; + + case 4: + if (saldo < ZERO) + { + _indbil = indbil_conto; + saldo = -saldo; + } + else + _indbil = 3; + break; + case 5: + default: break; + } + } + else //e' richiesta la compensazione + if ( indbil_conto==2 || indbil_conto==4) + saldo = -saldo; + + return saldo; +} + bool CG1500_application::bil_sez_contr() { Saldo sld; @@ -658,7 +768,8 @@ bool CG1500_application::bil_sez_contr() real saldo; bool compensa=FALSE, dettaglio=FALSE, cambiato=FALSE; bool esiste_conto=FALSE, esiste_sc = FALSE; - + bool da_considerare = FALSE; + _tmp_saldi_att->open("cg01"); _prog->addstatus(1); _tmp_saldi_pass->open("cg02"); @@ -674,17 +785,18 @@ bool CG1500_application::bil_sez_contr() _gp=-1; _cp=-1; - _gruppo_a = ZERO; - _gruppo_da = ZERO; + _gruppo_a = ZERO; + _gruppo_da = ZERO; + _gruppo_da_ordine = ZERO; + _gruppo_a_ordine = ZERO; + _prg_saldoini_dare = ZERO; + _prg_saldoini_avere = ZERO; _conto_a = ZERO; _conto_da = ZERO; _add_dare = FALSE; _add_avere = FALSE; sld.set_annoes(_annoes); - //datai = Controllo_data_limite(_datalim, _annoes, _annoes-1); - //fine_es = FineEsercizio(_annoes); - //fine_es_prec = FineEsercizio(_annoes-1); for (_pcn->first(); !_pcn->eof(); _pcn->next()) { @@ -700,6 +812,7 @@ bool CG1500_application::bil_sez_contr() esiste_sc ) { scrivic_file_temp(); + scrivig_file_temp(); _cp = c; esiste_conto = TRUE; _conto_da = ZERO; @@ -713,6 +826,8 @@ bool CG1500_application::bil_sez_contr() _gp = g; _gruppo_da = ZERO; _gruppo_a = ZERO; + _gruppo_da_ordine = ZERO; + _gruppo_a_ordine = ZERO; } if (cambiato) @@ -730,8 +845,8 @@ bool CG1500_application::bil_sez_contr() tipo_conto = _pcn->get(PCN_TMCF)[0]; if ( (tipo_conto == 'C') || (tipo_conto == 'F') ) { - saldo = 0; - esiste_sc = ricerca_sottoc_clifo(g, c, tipo_conto, compensa, + saldo = ZERO; + esiste_sc = ricerca_sottoc_clifo(g, c, compensa, indbil_conto, saldo); if (esiste_sc) { @@ -763,99 +878,99 @@ bool CG1500_application::bil_sez_contr() } if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite - { - if (!sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov)) continue; - else saldo = sld.saldo(); - } - else if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso - { - if (!sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto)) continue; - else saldo = sld.saldo(); - } - - if (_saldo) //se richiesto di non stampare i conti con saldo a zero - if (saldo == 0) - continue; - - esiste_sc = TRUE; - _indbil = indbil_conto; + //if (!sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov)) + //continue; + //else saldo = sld.saldo(); + da_considerare = sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + else + if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso + //if (!sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto)) + // continue; + //else + // saldo = sld.saldo(); + da_considerare = sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto); - //i due flag seguenti servono solo per i conti d'ordine - _sottoc_dare = FALSE; - _sottoc_avere = FALSE; - - //error_box ("saldo = %s", saldo.string()); - - if (!compensa) + if (da_considerare) { - if ( (indbil_conto==1)||(indbil_conto==3) ) - if (saldo > ZERO) //saldo in dare - _indbil = indbil_conto; - else //saldo in avere - { - if (indbil_conto == 1) - _indbil = 2; - else _indbil = 3; - saldo = -saldo; - } - if ( (indbil_conto==2)||(indbil_conto==4) ) - if (saldo < ZERO) - { - _indbil = indbil_conto; - saldo = -saldo; + saldo = sld.saldo(); + if (_saldo) //se richiesto di NON stampare i conti con saldo a zero + // if (saldo == ZERO && !sld.significativo()) + if (saldo == ZERO) + { + TRecnotype recnum = _pcn->recno(); + _pcn->next(); + if (_pcn->eof()) + { + scrivic_file_temp(); + scrivig_file_temp(); + } + _pcn->readat(recnum); + continue; } - else - if (indbil_conto == 2) - _indbil = 1; - else _indbil = 4; - } - else //e' richiesta la compensazione - { - if ( (indbil_conto==1)||(indbil_conto==3) ) - _indbil = indbil_conto; - if ( (indbil_conto==2)||(indbil_conto==4) ) + + esiste_sc = TRUE; + _indbil = indbil_conto; + + //i due flag seguenti servono solo per i conti d'ordine + _sottoc_dare = FALSE; + _sottoc_avere = FALSE; + + //error_box ("saldo = %s", saldo.string()); + + if (saldo != ZERO) + saldo = compensazione(compensa, indbil_conto, saldo); + + if (_indbil == 1 || _indbil == 2) { - _indbil = indbil_conto; - saldo = -saldo; - } - } - - if ( (_indbil==1) || (_indbil==3) ) - { - _gruppo_da += saldo; - _conto_da += saldo; - _add_file_dare = TRUE; - } - - if ( (_indbil==2) || (_indbil==4) ) - { - _gruppo_a += saldo; - _conto_a += saldo; - _add_file_avere = TRUE; - } - - if (_indbil==5) - if ( (saldo >= ZERO)||(compensa) ) + real app = sld.saldoini(); + if (app > ZERO) + _prg_saldoini_dare += app; + else if (app < ZERO) + { + app = -app; + _prg_saldoini_avere += app; + } + } + + if ( _indbil==1 || _indbil==3 ) { _gruppo_da += saldo; _conto_da += saldo; _add_file_dare = TRUE; - _sottoc_dare = TRUE; - } - else + } + + if ( _indbil==2 || _indbil==4 ) { - saldo = -saldo; _gruppo_a += saldo; _conto_a += saldo; _add_file_avere = TRUE; - _sottoc_avere = TRUE; } - - if ( (dettaglio) && ( (tipo_conto != 'C') && (tipo_conto != 'F') ) ) - scrivis_file_temp(g, c, s, saldo); - - _gp = g; - _cp = c; + + if (_indbil==5) + { + if ( saldo >= ZERO || compensa ) + { + _gruppo_da_ordine += saldo; + _conto_da += saldo; + _add_file_dare = TRUE; + _sottoc_dare = TRUE; + } + else + { + saldo = -saldo; + _gruppo_a_ordine += saldo; + _conto_a += saldo; + _add_file_avere = TRUE; + _sottoc_avere = TRUE; + } + scrivig_file_temp(); + } + if ( (dettaglio) && ( (tipo_conto != 'C') && (tipo_conto != 'F') ) ) + scrivis_file_temp(g, c, s, saldo); + + _gp = g; + _cp = c; + } TRecnotype recnum = _pcn->recno(); _pcn->next(); @@ -870,19 +985,19 @@ bool CG1500_application::bil_sez_contr() return TRUE; } -bool CG1500_application::ricerca_sottoc_clifo(int g,int c,char tipocf,bool compensa, int indbil_conto,real& saldo) +bool CG1500_application::ricerca_sottoc_clifo(int g,int c, bool compensa, int indbil_conto,real& saldo) { Saldo sld; sld.set_annoes(_annoes); - _listacf = new TClifo_list(g, c, tipocf); + _listacf = new TSaldi_list(g, c, _annoes); long s; TRecnotype items = _listacf->items(); bool esiste_sc = FALSE; for (int i = 0; i < items; i++) { - const TRectype& r = _listacf->clifo(i); - s = r.get_long(CLI_CODCF); + const TRectype& r = _listacf->saldi(i); + s = r.get_long(SLD_SOTTOCONTO); if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite { @@ -908,40 +1023,21 @@ bool CG1500_application::ricerca_sottoc_clifo(int g,int c,char tipocf,bool compe //error_box ("saldo = %s", saldo.string()); - if (!compensa) + if (saldo != ZERO) + saldo = compensazione(compensa, indbil_conto, saldo); + + if (_indbil == 1 || _indbil == 2) { - if ( (indbil_conto==1)||(indbil_conto==3) ) - if (saldo > ZERO) //saldo in dare - _indbil = indbil_conto; - else //saldo in avere - { - if (indbil_conto == 1) - _indbil = 2; - else _indbil = 3; - saldo = -saldo; - } - if ( (indbil_conto==2)||(indbil_conto==4) ) - if (saldo < ZERO) - { - _indbil = indbil_conto; - saldo = -saldo; - } - else - if (indbil_conto == 2) - _indbil = 1; - else _indbil = 4; - } - else //e' richiesta la compensazione - { - if ( (indbil_conto==1)||(indbil_conto==3) ) - _indbil = indbil_conto; - if ( (indbil_conto==2)||(indbil_conto==4) ) + real app = sld.saldoini(); + if (app > ZERO) + _prg_saldoini_dare += app; + else if (app < ZERO) { - _indbil = indbil_conto; - saldo = -saldo; - } - } - + app = -app; + _prg_saldoini_avere += app; + } + } + if ( (_indbil==1) || (_indbil==3) ) { _gruppo_da += saldo; @@ -957,21 +1053,24 @@ bool CG1500_application::ricerca_sottoc_clifo(int g,int c,char tipocf,bool compe } if (_indbil==5) + { if ( (saldo >= ZERO) || (compensa) ) // il sottoconto ha saldo in dare { - _gruppo_da += saldo; - _conto_da += saldo; - _add_file_dare = TRUE; - _sottoc_dare = TRUE; + _gruppo_da_ordine += saldo; + _conto_da += saldo; + _add_file_dare = TRUE; + _sottoc_dare = TRUE; } else //il sottoconto ha saldo in avere { saldo = -saldo; - _gruppo_a += saldo; + _gruppo_a_ordine += saldo; _conto_a += saldo; _add_file_avere = TRUE; _sottoc_avere = TRUE; - } + } + scrivig_file_temp(); + } } delete _listacf; return esiste_sc; @@ -986,7 +1085,7 @@ bool CG1500_application::bil_verifica() real saldo_finale, saldo_conto, saldo_gruppo, saldo_iniziale; real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere; real mov_gruppo_dare, mov_gruppo_avere, prg_gruppo_dare, prg_gruppo_avere; - bool esiste_conto = FALSE, esiste_sc = FALSE; + bool esiste_conto = FALSE, esiste_sc = FALSE, movimentato = FALSE; _tmp_saldi_att->open("cg01"); @@ -1006,7 +1105,8 @@ bool CG1500_application::bil_verifica() mov_gruppo_dare = ZERO; mov_gruppo_avere = ZERO; prg_gruppo_dare = ZERO; - prg_gruppo_avere = ZERO; + prg_gruppo_avere = ZERO; + _u_max = 0l; for (_pcn->first(); !_pcn->eof(); _pcn->next()) { @@ -1132,86 +1232,99 @@ bool CG1500_application::bil_verifica() _indbil = indbil_conto; if (_tipo_stampa1 == 1) //bil. di verifica per data limite { - if ( !calcola(g,c,s) )//il conto non e' movimentato - if (_stampav == 1) - continue; - - saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere; - - if (_datada == _dataini) - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - else if (_datada > _dataini) - saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare- - _mov_periodo_avere; - if (saldo_finale == ZERO) - if (_stampav == 2) - continue; + //if ( !calcola(g,c,s) )//il conto non e' movimentato + // if (_stampav == 1) + // continue; + movimentato = calcola(g,c,s); + if (movimentato || _stampav != 1) + { + saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere; + + if (_datada == _dataini) + saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; + else if (_datada > _dataini) + saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare- + _mov_periodo_avere; + //if (saldo_finale == ZERO) + // if (_stampav == 2) + // continue; + } //se saldo_finale < 0 verra' stampato con una A, se no con una D } else { - if (!sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto)) - if (_stampav == 1) - continue; + //if (!sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto)) + // if (_stampav == 1) + // continue; + movimentato = sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto); - saldo_iniziale = sld.saldoini(); + if (movimentato || _stampav != 1) + { + saldo_iniziale = sld.saldoini(); - _mov_periodo_dare = sld.prgdare(); - _mov_periodo_avere = sld.prgavere(); - _prg_prec_dare = ZERO; - _prg_prec_avere = ZERO; - - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - - if (saldo_finale == ZERO) - if (_stampav == 2) - continue; + _mov_periodo_dare = sld.prgdare(); + _mov_periodo_avere = sld.prgavere(); + _prg_prec_dare = ZERO; + _prg_prec_avere = ZERO; + + saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; + + //if (saldo_finale == ZERO) + // if (_stampav == 2) + // continue; + } } - esiste_sc = TRUE; - - if (saldo_iniziale < ZERO) - _saldo_ini_conto_avere += saldo_iniziale; - else - _saldo_ini_conto_dare += saldo_iniziale; - mov_conto_dare += _mov_periodo_dare; - mov_conto_avere += _mov_periodo_avere; - prg_conto_dare += _prg_prec_dare; - prg_conto_avere += _prg_prec_avere; - saldo_conto += saldo_finale; // somma algebrica!!! - - //scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro - if (_verifica != 2) - { - _tmp_saldi_att->zero(); - _tmp_saldi_att->put(SLD_GRUPPO,g); - _tmp_saldi_att->put(SLD_CONTO,c); - _tmp_saldi_att->put(SLD_SOTTOCONTO,s); - _tmp_saldi_att->put(SLD_FLAGSALINI,tipo_conto); - if ( (_datada == _dataini) || (_tipo_stampa1 != 1) ) + if (movimentato || _stampav != 1) + if (!(saldo_finale == ZERO && _stampav == 2)) { - if (saldo_iniziale > ZERO) //va stampato in Dare - _tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale); - else if (saldo_iniziale < ZERO) + esiste_sc = TRUE; + esiste_conto = TRUE; + + if (saldo_iniziale < ZERO) + _saldo_ini_conto_avere += saldo_iniziale; + else + _saldo_ini_conto_dare += saldo_iniziale; + mov_conto_dare += _mov_periodo_dare; + mov_conto_avere += _mov_periodo_avere; + prg_conto_dare += _prg_prec_dare; + prg_conto_avere += _prg_prec_avere; + saldo_conto += saldo_finale; // somma algebrica!!! + + //scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro + if (_verifica != 2) { - saldo_iniziale = -saldo_iniziale; - _tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale); + _tmp_saldi_att->zero(); + _tmp_saldi_att->put(SLD_GRUPPO,g); + _tmp_saldi_att->put(SLD_CONTO,c); + _tmp_saldi_att->put(SLD_SOTTOCONTO,s); + _tmp_saldi_att->put(SLD_FLAGSALINI,tipo_conto); + if ( (_datada == _dataini) || (_tipo_stampa1 != 1) ) + { + if (saldo_iniziale > ZERO) //va stampato in Dare + _tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale); + else if (saldo_iniziale < ZERO) + { + saldo_iniziale = -saldo_iniziale; + _tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale); + } + } + else if (_datada > _dataini) + { + _tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare); + _tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere); + } + _tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare); + _tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere); + _tmp_saldi_att->put(SLD_SALDO,saldo_finale); + _tmp_saldi_att->put(SLD_DATAULMOV,_u_max); + _tmp_saldi_att->write(); } - } - else if (_datada > _dataini) - { - _tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare); - _tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere); - } - _tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare); - _tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere); - _tmp_saldi_att->put(SLD_SALDO,saldo_finale); - _tmp_saldi_att->write(); - } - _gp = g; - _cp = c; + _gp = g; + _cp = c; + } TRecnotype recnum = _pcn->recno(); _pcn->next(); @@ -1236,7 +1349,7 @@ bool CG1500_application::bil_verifica() if ( (_verifica == 1)||( (_verifica == 2)&& (!((_stampav == 2)&&(saldo_conto == 0))) ) ) scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare, - mov_conto_avere,saldo_conto); + mov_conto_avere,saldo_conto); } _pcn->readat(recnum); } @@ -1245,7 +1358,7 @@ bool CG1500_application::bil_verifica() bool CG1500_application::calcola(int g, int c, long s) { - TString sezione, provvis; + char sezione, provvis; real importo; int annoe; long num_reg; @@ -1260,7 +1373,8 @@ bool CG1500_application::calcola(int g, int c, long s) _prg_prec_avere = ZERO; _saldo_ini_dare = ZERO; _saldo_ini_avere = ZERO; - + _u_max = 0l; + rmov.setkey(2); rmov.zero(); rmov.put(RMV_GRUPPO,g); @@ -1285,7 +1399,7 @@ bool CG1500_application::calcola(int g, int c, long s) mov.read(); if (mov.bad()) mov.zero(); - provvis = mov.get(MOV_PROVVIS); + provvis = mov.get_char(MOV_PROVVIS); datacomp = mov.get_date(MOV_DATACOMP); if ( (!_stampa_mov_prov)&&(provvis == ' ') ) //se non richiesto @@ -1293,21 +1407,19 @@ bool CG1500_application::calcola(int g, int c, long s) TString codcaus(mov.get(MOV_CODCAUS)); - if (codcaus == causale_chiusura()) - continue; + if (codcaus.not_empty()) + if (codcaus == causale_chiusura()) + continue; //la causale e' uguale a quella di chiusura // break; - sezione = rmov.get(RMV_SEZIONE); + sezione = rmov.get_char(RMV_SEZIONE); importo = rmov.get_real(RMV_IMPORTO); if (_annoes == 0) data_reg = data; else data_reg = datacomp; - if (data_reg < _datada || data_reg > _dataa) - continue; - if (importo == 0) continue; @@ -1317,9 +1429,10 @@ bool CG1500_application::calcola(int g, int c, long s) (codcaus != causale_apertura())) { conto_mov = TRUE; - if (sezione == "D") + if (sezione == 'D') _mov_periodo_dare += importo; else _mov_periodo_avere += importo; + _u_max = fnc_max(_u_max, data); } //il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup. @@ -1327,18 +1440,20 @@ bool CG1500_application::calcola(int g, int c, long s) { if (codcaus == causale_apertura()) { - if (sezione == "D") + if (sezione == 'D') _saldo_ini_dare += importo; else _saldo_ini_avere += importo; + _u_max = fnc_max(_u_max, data); conto_mov = TRUE; } } else if (_datada > _dataini) //calcolo i progressivi precedenti - if ( (data >= _dataini) && (data <= _datada) ) + if ( (data_reg >= _dataini) && (data_reg <= _datada) ) { - if (sezione == "D") + if (sezione == 'D') _prg_prec_dare += importo; - else _prg_prec_avere += importo; + else _prg_prec_avere += importo; + _u_max = fnc_max(_u_max, data); conto_mov = TRUE; } } @@ -1350,14 +1465,20 @@ bool CG1500_application::ricerca_cf(int g,int c,char tipocf,real& saldo_finale,r { Saldo sld; bool esiste_sc = FALSE; - _lista = new TClifo_list(g, c, tipocf); long s; + int anno; + + if (_tipo_stampa1 == 1) + anno = _annoapp; + else anno = _annoes; + + _lista = new TSaldi_list(g, c, anno); TRecnotype items = _lista->items(); for (int i = 0; i < items; i++) { - const TRectype& r = _lista->clifo(i); - s = r.get_long(CLI_CODCF); + const TRectype& r = _lista->saldi(i); + s = r.get_long(SLD_SOTTOCONTO); saldo_finale = ZERO; //saldo finale relativo a ciascun sottoconto @@ -1437,7 +1558,8 @@ bool CG1500_application::ricerca_cf(int g,int c,char tipocf,real& saldo_finale,r } _tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare); _tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere); - _tmp_saldi_att->put(SLD_SALDO,saldo_finale); + _tmp_saldi_att->put(SLD_SALDO,saldo_finale); + _tmp_saldi_att->put(SLD_DATAULMOV, _u_max); _tmp_saldi_att->write(); } } @@ -1507,33 +1629,48 @@ void CG1500_application::init_sort() { _cf = new cli_for; _sort = new TSort(sizeof(cli_for)); - - _sort->addsortkey ((char*)&(_cf->tipocf)-(char*)&(_cf->tipocf),1); - _sort->addsortkey ((char*)&(_cf->gruppo)-(char*)&(_cf->tipocf),3); - _sort->addsortkey ((char*)&(_cf->conto)-(char*)&(_cf->tipocf),3); - _sort->addsortkey ((char*)&(_cf->ragsoc)-(char*)&(_cf->tipocf),50); + + if (_ordinamento == 1) + { + _sort->addsortkey ((char*)&(_cf->tipocf)-(char*)&(_cf->tipocf),1); + _sort->addsortkey ((char*)&(_cf->gruppo)-(char*)&(_cf->tipocf),3); + _sort->addsortkey ((char*)&(_cf->conto)-(char*)&(_cf->tipocf),3); + _sort->addsortkey ((char*)&(_cf->codcf)-(char*)&(_cf->tipocf),6); + } + else if (_ordinamento == 2) + { + _sort->addsortkey ((char*)&(_cf->tipocf)-(char*)&(_cf->tipocf),1); + _sort->addsortkey ((char*)&(_cf->gruppo)-(char*)&(_cf->tipocf),3); + _sort->addsortkey ((char*)&(_cf->conto)-(char*)&(_cf->tipocf),3); + _sort->addsortkey ((char*)&(_cf->ragsoc)-(char*)&(_cf->tipocf),50); + } + _sort->init(); } -void CG1500_application::riempi_record(const char* t,int g,int c,long s, +void CG1500_application::riempi_record(char t,int g,int c,long s, const char* rs,const real& sd,const real& sa, const real& md,const real& ma,const real& sf) { - _cf->tipocf = t[0]; + _cf->tipocf = t; sprintf(_cf->gruppo, "%03d", g); sprintf(_cf->conto, "%03d", c); sprintf(_cf->codcf, "%06ld", s); - sprintf(_cf->ragsoc, "%s", rs); - if (s == 0L) + sprintf(_cf->ragsoc, "%s", rs); + if ( s == 999999L ) { if ( (_datada == _dataini)||(_tipo_stampa1 != 1) ) { real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere; - if (app > ZERO) //va stampato in Dare + if (app > ZERO) //va stampato in Dare + { + _cf->saldoavere = ZERO; _cf->saldodare = app; + } else if (app < ZERO) { app = -app; + _cf->saldodare = ZERO; _cf->saldoavere = app; } } @@ -1551,25 +1688,28 @@ void CG1500_application::riempi_record(const char* t,int g,int c,long s, _cf->movdare = md; _cf->movavere = ma; _cf->saldofinale = sf; + _cf->udata = _u_max; _sort->sort((const char*)_cf); } void CG1500_application::crea_sort_clifo() { Saldo sld; + TLocalisamfile saldi(LF_SALDI, FALSE); int g=0, c=0; long codcf=0l; - TString tipocf, tipocfp, ragsoc; + TString80 ragsoc; + char tipocf,tipocfp; real saldo_finale, saldo_conto, saldo_iniziale, saldodare, saldoavere, movdare, movavere; real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere; - bool esiste_sc=FALSE; - + bool esiste_sc = FALSE, movimentato = FALSE; + TArray gccf; TRecnotype items = _cur->items(); _gp=-1; _cp=-1; - tipocfp = ""; + tipocfp = ' '; _saldo_ini_conto_dare = ZERO; _saldo_ini_conto_avere = ZERO; @@ -1578,9 +1718,7 @@ void CG1500_application::crea_sort_clifo() mov_conto_avere = ZERO; prg_conto_dare = ZERO; prg_conto_avere = ZERO; - - // fine_es = FineEsercizio(_annoes); - // fine_es_prec = FineEsercizio(_annoes-1); + _u_max = 0l; init_sort(); @@ -1589,267 +1727,142 @@ void CG1500_application::crea_sort_clifo() for (int i = 0; i < items; i++,++(*_cur)) { _prog->addstatus(1); - g = _cur->curr().get_int (CLI_GRUPPO); - c = _cur->curr().get_int (CLI_CONTO); codcf = _cur->curr().get_long(CLI_CODCF); - tipocf = _cur->curr().get(CLI_TIPOCF); + tipocf = _cur->curr().get(CLI_TIPOCF)[0]; ragsoc = _cur->curr().get(CLI_RAGSOC); - if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) && - esiste_sc ) - { - //scrivo il record del conto; - riempi_record(tipocfp,_gp,_cp,0l,"zzzz",prg_conto_dare, - prg_conto_avere,mov_conto_dare,mov_conto_avere,saldo_conto); - tipocfp = tipocf; - _cp = c; - esiste_sc = FALSE; - _saldo_ini_conto_dare = ZERO; - _saldo_ini_conto_avere = ZERO; - saldo_conto = ZERO; - mov_conto_dare = ZERO; - mov_conto_avere = ZERO; - prg_conto_dare = ZERO; - prg_conto_avere = ZERO; - } - - saldo_finale = ZERO; - saldodare = ZERO; - saldoavere = ZERO; - movdare = ZERO; - movavere = ZERO; - - if (_tipo_stampa1 == 1) //bilancio per data limite - { - if ( !calcola(g,c,codcf) )//il conto non e' mov. - if (_stampac == 1) - continue; - - saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere; - - if (_datada == _dataini) - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - else if (_datada > _dataini) - saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare - -_mov_periodo_avere; - if (saldo_finale == ZERO) - if (_stampac == 2) - continue; - - //se saldo_finale < 0 verra' stampato con una A, se no con una D - } + if (tipocf == 'C') + gccf = _clienti; else + if (tipocf == 'F') + gccf = _fornitori; + + for (int i=0; i < gccf.items(); i++) { - _indbil = cerca_indbil(g,c); - if (!sld.ultima_immissione_bilancio(_annoes,g,c,codcf,_indbil)) - if (_stampac == 1) - continue; + int g = ((TToken_string&)gccf[i]).get_int(0); + int c = ((TToken_string&)gccf[i]).get_int(1); - saldo_iniziale = sld.saldoini(); + saldi.zero(); + saldi.put(SLD_ANNOES, _annoes); + saldi.put(SLD_GRUPPO, g); + saldi.put(SLD_CONTO, c); + saldi.put(SLD_SOTTOCONTO, codcf); - _mov_periodo_dare = sld.prgdare(); - _mov_periodo_avere = sld.prgavere(); - _prg_prec_dare = ZERO; - _prg_prec_avere = ZERO; + if (saldi.read() != NOERR) continue; - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - - if (saldo_finale == ZERO) - if (_stampac == 2) - continue; - } - - esiste_sc = TRUE; - - if (saldo_iniziale < ZERO) - _saldo_ini_conto_avere += saldo_iniziale; - else - _saldo_ini_conto_dare += saldo_iniziale; - mov_conto_dare += _mov_periodo_dare; - mov_conto_avere += _mov_periodo_avere; - prg_conto_dare += _prg_prec_dare; - prg_conto_avere += _prg_prec_avere; - saldo_conto += saldo_finale; // somma algebrica!!! - - if ( (_datada == _dataini)||(_tipo_stampa1 != 1) ) - { - if (saldo_iniziale > ZERO) //va stampato in Dare - saldodare = saldo_iniziale; - else if (saldo_iniziale < ZERO) + if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) && + esiste_sc ) { - saldo_iniziale = -saldo_iniziale; - saldoavere = saldo_iniziale; + //scrivo il record del conto; + riempi_record(tipocfp,_gp,_cp,999999L,"zzzz",prg_conto_dare, + prg_conto_avere,mov_conto_dare,mov_conto_avere,saldo_conto); + tipocfp = tipocf; + _cp = c; + esiste_sc = FALSE; + _saldo_ini_conto_dare = ZERO; + _saldo_ini_conto_avere = ZERO; + saldo_conto = ZERO; + mov_conto_dare = ZERO; + mov_conto_avere = ZERO; + prg_conto_dare = ZERO; + prg_conto_avere = ZERO; } - } - else if (_datada > _dataini) - { - saldodare = _prg_prec_dare; - saldoavere = _prg_prec_avere; - } - movdare = _mov_periodo_dare; - movavere = _mov_periodo_avere; - - riempi_record(tipocf,g,c,codcf,ragsoc,saldodare,saldoavere,movdare, - movavere,saldo_finale); - tipocfp = tipocf; - _gp = g; - _cp = c; + + saldo_finale = ZERO; + saldodare = ZERO; + saldoavere = ZERO; + movdare = ZERO; + movavere = ZERO; + + if (_tipo_stampa1 == 1) //bilancio per data limite + { + //if ( !calcola(g,c,codcf) )//il conto non e' mov. + // if (_stampac == 1) + // continue; + movimentato = calcola(g,c,codcf); + if (movimentato || _stampac != 1) + { + saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere; + + if (_datada == _dataini) + saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; + else if (_datada > _dataini) + saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare + -_mov_periodo_avere; + } + //if (saldo_finale == ZERO) + // if (_stampac == 2) + // continue; + + //se saldo_finale < 0 verra' stampato con una A, se no con una D + } + else //bilancio di verifica + { + _indbil = cerca_indbil(g,c); + //if (!sld.ultima_immissione_bilancio(_annoes,g,c,codcf,_indbil)) + // if (_stampac == 1) + // continue; + movimentato = sld.ultima_immissione_bilancio(_annoes,g,c,codcf,_indbil); + if (movimentato || _stampac != 1) + { + saldo_iniziale = sld.saldoini(); - TRecnotype pos = _cur->pos(); - bool finito = (pos == items - 1); + _mov_periodo_dare = sld.prgdare(); + _mov_periodo_avere = sld.prgavere(); + _prg_prec_dare = ZERO; + _prg_prec_avere = ZERO; + + saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; + } + //if (saldo_finale == ZERO) + // if (_stampac == 2) + // continue; + } + if (movimentato || _stampac != 1) + if (!(saldo_finale == ZERO && _stampac == 2)) + { + esiste_sc = TRUE; - if (finito) - riempi_record(tipocfp,_gp,_cp,0L,"zzzz",prg_conto_dare,prg_conto_avere, - mov_conto_dare,mov_conto_avere,saldo_conto); + if (saldo_iniziale < ZERO) + _saldo_ini_conto_avere += saldo_iniziale; + else + _saldo_ini_conto_dare += saldo_iniziale; + mov_conto_dare += _mov_periodo_dare; + mov_conto_avere += _mov_periodo_avere; + prg_conto_dare += _prg_prec_dare; + prg_conto_avere += _prg_prec_avere; + saldo_conto += saldo_finale; // somma algebrica!!! + + if ( (_datada == _dataini)||(_tipo_stampa1 != 1) ) + { + if (saldo_iniziale > ZERO) //va stampato in Dare + saldodare = saldo_iniziale; + else if (saldo_iniziale < ZERO) + { + saldo_iniziale = -saldo_iniziale; + saldoavere = saldo_iniziale; + } + } + else if (_datada > _dataini) + { + saldodare = _prg_prec_dare; + saldoavere = _prg_prec_avere; + } + + movdare = _mov_periodo_dare; + movavere = _mov_periodo_avere; + + riempi_record(tipocf,g,c,codcf,ragsoc,saldodare,saldoavere,movdare, + movavere,saldo_finale); + tipocfp = tipocf; + _gp = g; + _cp = c; + } + } } -} - -bool CG1500_application::situazione_clifo() -{ - Saldo sld; - int g=0, c=0; - long codcf=0l; - TString tipocf; - real saldo_finale, saldo_conto, saldo_iniziale; - real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere; - bool esiste_sc=FALSE; - - TRecnotype items = _cur->items(); - - _tmp_saldi_att->open("cg01"); - - _gp=-1; - _cp=-1; - - _saldo_ini_conto_dare = ZERO; - _saldo_ini_conto_avere = ZERO; - saldo_conto = ZERO; - mov_conto_dare = ZERO; - mov_conto_avere = ZERO; - prg_conto_dare = ZERO; - prg_conto_avere = ZERO; - - // fine_es = FineEsercizio(_annoes); - // fine_es_prec = FineEsercizio(_annoes-1); - - *_cur = 0l; - - for (int i = 0; i < items; i++,++(*_cur)) - { - _prog->addstatus(1); - g = _cur->curr().get_int (CLI_GRUPPO); - c = _cur->curr().get_int (CLI_CONTO); - codcf = _cur->curr().get_long(CLI_CODCF); - tipocf = _cur->curr().get(CLI_TIPOCF); - - if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) && - esiste_sc ) - { - //scrivo il record del conto; - scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare, - mov_conto_avere,saldo_conto); - _cp = c; - esiste_sc = FALSE; - _saldo_ini_conto_dare = ZERO; - _saldo_ini_conto_avere = ZERO; - saldo_conto = ZERO; - mov_conto_dare = ZERO; - mov_conto_avere = ZERO; - prg_conto_dare = ZERO; - prg_conto_avere = ZERO; - } - - saldo_finale = ZERO; //saldo finale relativo a ciascun sottoconto - - if (_tipo_stampa1 == 1) //bilancio per data limite - { - if ( !calcola(g,c,codcf) )//il conto non e' movimentato - if (_stampac == 1) - continue; - - saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere; - - if (_datada == _dataini) - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - else if (_datada > _dataini) - saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare- - _mov_periodo_avere; - if (saldo_finale == ZERO) - if (_stampac == 2) - continue; - - //se saldo_finale < 0 verra' stampato con una A, se no con una D - - } - else - { - _indbil = cerca_indbil(g,c); - if (!sld.ultima_immissione_bilancio(_annoes,g,c,codcf,_indbil)) - if (_stampac == 1) - continue; - - saldo_iniziale = sld.saldoini(); - - _mov_periodo_dare = sld.prgdare(); - _mov_periodo_avere = sld.prgavere(); - _prg_prec_dare = ZERO; - _prg_prec_avere = ZERO; - - saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere; - - if (saldo_finale == ZERO) - if (_stampac == 2) - continue; - } - - esiste_sc = TRUE; - - if (saldo_iniziale < ZERO) - _saldo_ini_conto_avere += saldo_iniziale; - else - _saldo_ini_conto_dare += saldo_iniziale; - mov_conto_dare += _mov_periodo_dare; - mov_conto_avere += _mov_periodo_avere; - prg_conto_dare += _prg_prec_dare; - prg_conto_avere += _prg_prec_avere; - saldo_conto += saldo_finale; // somma algebrica!!! - - _tmp_saldi_att->zero(); - _tmp_saldi_att->put(SLD_GRUPPO,g); - _tmp_saldi_att->put(SLD_CONTO,c); - _tmp_saldi_att->put(SLD_SOTTOCONTO,codcf); - _tmp_saldi_att->put(SLD_FLAGSALINI,tipocf); - if ( (_datada == _dataini)||(_tipo_stampa1 != 1) ) - { - if (saldo_iniziale > ZERO) //va stampato in Dare - _tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale); - else if (saldo_iniziale < ZERO) - { - saldo_iniziale = -saldo_iniziale; - _tmp_saldi_att ->put(SLD_PAVERESCA,saldo_iniziale); - } - } - else if (_datada > _dataini) - { - _tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare); - _tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere); - } - _tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare); - _tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere); - _tmp_saldi_att->put(SLD_SALDO,saldo_finale); - _tmp_saldi_att->write(); - - _gp = g; - _cp = c; - - TRecnotype pos = _cur->pos(); - bool finito = (pos == items - 1); - - if (finito) - scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare, - mov_conto_avere,saldo_conto); - } - return TRUE; + if (esiste_sc) + riempi_record(tipocfp,_gp,_cp,999999L,"zzzz",prg_conto_dare,prg_conto_avere, + mov_conto_dare,mov_conto_avere,saldo_conto); } int CG1500_application::cerca_indbil(int g, int c) @@ -1874,7 +1887,7 @@ void CG1500_application::leggi_files_dare(TIsamtempfile* file) _sottoconto_dare = file->get_long(SLD_SOTTOCONTO); _saldo_dare = file->get_real(SLD_PDARE); - _descr_dare = DescrizioneConto(_gruppo_dare,_conto_dare,_sottoconto_dare,""); + _descr_dare = DescrizioneConto(_gruppo_dare,_conto_dare,_sottoconto_dare,' '); _gc_corr_dare = format("%3d%3d", _gruppo_dare, _conto_dare); @@ -1895,7 +1908,7 @@ void CG1500_application::leggi_files_avere(TIsamtempfile* file) _saldo_avere = file->get_real(SLD_PAVERE); _descr_avere = DescrizioneConto(_gruppo_avere,_conto_avere,_sottoconto_avere, - ""); + ' '); _gc_corr_avere = format("%3d%3d", _gruppo_avere, _conto_avere); if (_gc_corr_avere != _gc_prec_avere) @@ -1930,8 +1943,8 @@ bool CG1500_application::preprocess_print(int file, int counter) } else { - if ( (_verifica == 3) && (_ordinamento == 1) ) - _tmp_saldi_att->setkey(2); + //if ( (_verifica == 3) && (_ordinamento == 1) ) + // _tmp_saldi_att->setkey(2); set_print_zero(FALSE); _cambiato_conto_1 = FALSE; _livello_conto = TRUE; @@ -1951,7 +1964,7 @@ void CG1500_application::leggi_file_tmp() _gruppo = _tmp_saldi_att->get_int(SLD_GRUPPO); _conto = _tmp_saldi_att->get_int(SLD_CONTO); _sottoconto = _tmp_saldi_att->get_long(SLD_SOTTOCONTO); - _tipo_conto = _tmp_saldi_att->get(SLD_FLAGSALINI); + _tipo_conto = _tmp_saldi_att->get_char(SLD_FLAGSALINI); _descr = DescrizioneConto(_gruppo,_conto,_sottoconto,_tipo_conto); _saldoini_dare = _tmp_saldi_att->get_real(SLD_PDARESCA); _saldoini_avere = _tmp_saldi_att->get_real(SLD_PAVERESCA); @@ -1965,10 +1978,12 @@ void CG1500_application::leggi_file_tmp() _gruppo_succ = _tmp_saldi_att->get_int(SLD_GRUPPO); _conto_succ = _tmp_saldi_att->get_int(SLD_CONTO); _sottoconto_succ = _tmp_saldi_att->get_long(SLD_SOTTOCONTO); - _tipoc_succ = _tmp_saldi_att->get(SLD_FLAGSALINI); - if ( (_verifica != 2) && (_sottoconto_succ != 0) ) - _ultima_data = UltimaData(_gruppo_succ,_conto_succ, - _sottoconto_succ,_annoes); + _tipoc_succ = _tmp_saldi_att->get_char(SLD_FLAGSALINI); + if ( (_verifica != 2) && (_sottoconto_succ != 0) ) + if (_tipo_stampa1 == 2) + _ultima_data = UltimaData(_gruppo_succ,_conto_succ, + _sottoconto_succ,_annoes); + else _ultima_data = _tmp_saldi_att->get_date(SLD_DATAULMOV); _descr_succ = DescrizioneConto(_gruppo_succ,_conto_succ, _sottoconto_succ,_tipoc_succ); _saldoini_dare_succ = _tmp_saldi_att->get_real(SLD_PDARESCA); @@ -2012,8 +2027,7 @@ bool CG1500_application::preprocess_page(int file, int counter) { if (_prima_volta) { - stampa_totali(); - + stampa_totali_uno(); _eof3 = _tmp_saldi_costi->first(); _eof4 = _tmp_saldi_ricavi->first(); } @@ -2022,7 +2036,7 @@ bool CG1500_application::preprocess_page(int file, int counter) _controlla = TRUE; if (_salto_pagina) - { + { if ( (!_eof3) && (_cambiato_conto_1) ) _eof3 = _tmp_saldi_costi->next(); @@ -2041,9 +2055,9 @@ bool CG1500_application::preprocess_page(int file, int counter) { if (_seconda_volta) { - stampa_totali(); - _eof5 = _tmp_saldi_conti_uno->first(); - _eof6 = _tmp_saldi_conti_due->first(); + stampa_totali(); + _eof5 = _tmp_saldi_conti_uno->first(); + _eof6 = _tmp_saldi_conti_due->first(); } else { @@ -2055,15 +2069,15 @@ bool CG1500_application::preprocess_page(int file, int counter) _eof5 = _tmp_saldi_conti_uno->next(); if ( (!_eof6) && (_cambiato_conto_2) ) - _eof6 = _tmp_saldi_conti_due->next(); + _eof6 = _tmp_saldi_conti_due->next(); } } - + if ( (!_eof5) && (_cambiato_conto_1) ) leggi_files_dare(_tmp_saldi_conti_uno); if ( (!_eof6) && (_cambiato_conto_2) ) - leggi_files_avere(_tmp_saldi_conti_due); + leggi_files_avere(_tmp_saldi_conti_due); } } } @@ -2082,7 +2096,7 @@ bool CG1500_application::preprocess_page(int file, int counter) } else //stampa bilancio di verifica { - if ( (_verifica == 3) && (_ordinamento == 2) ) + if (_verifica == 3) leggi_sort(); else { @@ -2098,7 +2112,7 @@ bool CG1500_application::preprocess_page(int file, int counter) return FALSE; else leggi_file_tmp(); } - } + } } return TRUE; } @@ -2110,12 +2124,16 @@ void CG1500_application::leggi_sort() if ( (_buff = _sort->retrieve()) != NULL) { cf = (struct cli_for*)_buff; + _tipo_conto = cf->tipocf; _gruppo = atoi(cf->gruppo); _conto = atoi(cf->conto); _sottoconto = atol(cf->codcf); _descr = cf->ragsoc; - if (_descr != "zzzz") - _ultima_data = UltimaData(_gruppo,_conto,_sottoconto,_annoes); + if ( (_ordinamento == 2 && _descr != "zzzz") || + (_ordinamento == 1 && _sottoconto != 999999L) ) + if (_tipo_stampa1 == 2) + _ultima_data = UltimaData(_gruppo,_conto,_sottoconto,_annoes); + else _ultima_data = cf->udata; _saldo_dare = cf->saldodare; _saldo_avere = cf->saldoavere; _mov_dare = cf->movdare; @@ -2124,22 +2142,21 @@ void CG1500_application::leggi_sort() } } -void CG1500_application::controlla_conto_uno(int file1,int file2) +void CG1500_application::controlla_conto(int file1,int file2) { char dep = '*'; if (!file1) if (_cambiato_conto_1) { - //set_row(_i,"%s @66g|", (const char*)dep); - set_row(_i,"@66g%c", dep); + if (!(_totali && _conto_dare==0 && _sottoconto_dare == 0l)) + set_row(_i,"@66g%c", dep); _cambiato_conto_1 = FALSE; } else { stampa_prima_colonna(_gruppo_dare, _conto_dare, _sottoconto_dare, _descr_dare,_saldo_dare); - _cambiato_conto_1 = TRUE; if ( (_conto_dare == 0) && (_sottoconto_dare == 0) ) _tot_dare += _saldo_dare; @@ -2148,61 +2165,26 @@ void CG1500_application::controlla_conto_uno(int file1,int file2) if (!file2) if (_cambiato_conto_2) { - //set_row(_i,"%s @66g|", (const char*)dep); - set_row(_i,"@66g%c", dep); - _cambiato_conto_2 = FALSE; + //if (!(_totali && _conto_avere==0 && _sottoconto_avere == 0l)) + if (_totali && _conto_avere==0 && _sottoconto_avere==0l) + _cambiato_conto_2 = FALSE; + else + { + set_row(_i,"@66g%c", dep); + _cambiato_conto_2 = FALSE; + } } else { stampa_seconda_colonna(_gruppo_avere, _conto_avere, _sottoconto_avere, _descr_avere, _saldo_avere); - _cambiato_conto_2 = TRUE; if ( (_conto_avere == 0) && (_sottoconto_avere == 0) ) _tot_avere += _saldo_avere; } } -/* - void CG1500_application::controlla_conto_due() - { - TString dep = ""; - - if (!_eof3) - if (_cambiato_conto_2) - { - set_row(_i,"%s @66g|", (const char*)dep); - _cambiato_conto_2 = FALSE; - } - else - { - stampa_prima_colonna(_gruppo_avere, _conto_avere, _sottoconto_avere, - _descr_avere, _saldo_avere); - - _cambiato_conto_2 = TRUE; - if ( (_conto_avere == 0) && (_sottoconto_avere == 0) ) - _tot_avere += _saldo_avere; - } - - if (!_eof4) - if (_cambiato_conto_1) - { - set_row(_i,"%s @66g|", (const char*)dep); - _cambiato_conto_1 = FALSE; - } - else - { - stampa_seconda_colonna(_gruppo_dare, _conto_dare, _sottoconto_dare, - _descr_dare, _saldo_dare); - - _cambiato_conto_1 = TRUE; - if ( (_conto_dare == 0) && (_sottoconto_dare == 0) ) - _tot_dare += _saldo_dare; - } - } - */ - -print_action CG1500_application::postprocess_print(int file, int counter) +void CG1500_application::postclose_print() { if (_bilancio == 1) { @@ -2215,12 +2197,12 @@ print_action CG1500_application::postprocess_print(int file, int counter) } else { - if (! ((_verifica == 3) && (_ordinamento == 2))) - _tmp_saldi_att->close(); - if ( (_verifica == 3) && (_ordinamento == 2) ) + if (_verifica == 3) delete _sort; + else + _tmp_saldi_att->close(); } - return NEXT_PAGE; + //return NEXT_PAGE; } void CG1500_application::set_page(int file, int counter) @@ -2238,7 +2220,7 @@ void CG1500_application::set_page(int file, int counter) set_row(_i++, (const char*)dep); } - controlla_conto_uno(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no + controlla_conto(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no if ( _eof1 && _eof2 && (!_prima_volta) && _controlla ) if (!_salto_pagina) @@ -2253,73 +2235,71 @@ void CG1500_application::set_page(int file, int counter) if (_eof1 && _eof2 && _controlla) { - //controlla_conto_due(); - controlla_conto_uno(_eof3,_eof4); + controlla_conto(_eof3,_eof4); if ( _eof3 && _eof4 && (!_seconda_volta) && _flag ) if (!_salto_pagina1) - { - printer().formfeed(); - set_row(_i++,"@59gCONTI D'ORDINE"); - set_row(_i++,"@59g--------------"); - set_row(_i++, (const char*)dep); - _salto_pagina1 = TRUE; - if (_eof5 && _eof6) + { + if (!_tmp_saldi_conti_uno->empty() || !_tmp_saldi_conti_due->empty()) { - _stampato = TRUE; - stampa_totali(); + printer().formfeed(); + set_row(_i++,"@59gCONTI D'ORDINE"); + set_row(_i++,"@59g--------------"); + set_row(_i++, (const char*)dep); + if (_eof5 && _eof6) + { + _stampato = TRUE; + stampa_totali(); + } } + _salto_pagina1 = TRUE; } if (_eof3 && _eof4 && _flag) { - controlla_conto_uno(_eof5,_eof6); - if (_eof5 && _eof6) - if (!_stampato) stampa_totali(); + if (!_tmp_saldi_conti_uno->empty() || !_tmp_saldi_conti_due->empty()) + { + controlla_conto(_eof5,_eof6); + if (_eof5 && _eof6) + if (!_stampato) stampa_totali(); + } } } } else //stampa bilancio di verifica { TString udata = _ultima_data.string(2,'/'); - TString app; + char app; int r = 1; - if ( (_verifica == 3) && (_ordinamento == 2) ) + if (_verifica == 3) { if (_buff != NULL) { if (_saldofinale > 0) - app = "D"; + app = 'D'; else if (_saldofinale < 0) { _saldofinale = -_saldofinale; - app = "A"; + app = 'A'; } - - if (_descr == "zzzz") //devo stampare il conto + if ( (_ordinamento == 2 && _descr == "zzzz") || + (_ordinamento == 1 && _sottoconto == 999999L) ) //devo stampare il conto { - _descr = DescrizioneConto(_gruppo,_conto,_sottoconto,""); + _descr = DescrizioneConto(_gruppo,_conto,0L,' '); stampa_record_conto(_gruppo,_conto,_descr,_saldo_dare,_saldo_avere, _mov_dare,_mov_avere,_saldofinale,app); } else if (_stampa_width == 132) { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s", - // _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare,&_saldo_avere, - // &_mov_dare,&_mov_avere,&_saldofinale,(const char*)app); set_row(r,"@1g%6ld",(const char*)_sottoconto); set_row(r," %s",(const char*)udata); - set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r",(const char*)_descr,&_saldo_dare, - &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale); - set_row(r,"%s",(const char*)app); + set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c",(const char*)_descr,&_saldo_dare, + &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale,app); } - else if (app == "D") + else if (app == 'D') { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|", - // _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare, - // &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale); set_row(r,"@1g%6ld",(const char*)_sottoconto); set_row(r," %s",(const char*)udata); set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g!",(const char*)_descr, @@ -2327,26 +2307,23 @@ void CG1500_application::set_page(int file, int counter) } else { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|", - // _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare, - // &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale); set_row(r,"@1g%6ld",(const char*)_sottoconto); set_row(r," %s",(const char*)udata); set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g!", (const char*)_descr,&_saldo_dare,&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale); - } + } } - } - else + } + else //_verifica != 3 { if (!_eof1) { if (_saldofinale_succ > 0) - app = "D"; + app = 'D'; else if (_saldofinale_succ < 0) { _saldofinale_succ = -_saldofinale_succ; - app = "A"; + app = 'A'; } if (_livello_conto) //sto stampando un conto/gruppo @@ -2360,20 +2337,13 @@ void CG1500_application::set_page(int file, int counter) { if (_stampa_width == 132) { - // set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s", - // _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, - // &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ,(const char*)app); set_row(r,"%3d",_conto_succ); - set_row(r," @8g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r", + set_row(r," @8g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c", (const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, - &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); - set_row(r,"%s",(const char*)app); + &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ,app); } - else if (app == "D") + else if (app == 'D') { - // set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|", - // _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, - // &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); set_row(r,"%3d",_conto_succ); set_row(r," @8g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g!", (const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, @@ -2381,9 +2351,6 @@ void CG1500_application::set_page(int file, int counter) } else { - // set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|", - // _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, - // &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); set_row(r,"%3d",_conto_succ); set_row(r," @8g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g!", (const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, @@ -2394,23 +2361,14 @@ void CG1500_application::set_page(int file, int counter) { if (_stampa_width == 132) { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s", - // _sottoconto_succ,(const char*)udata,(const char*)_descr_succ,&_saldoini_dare_succ, - // &_saldoini_avere_succ,&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ, - // (const char*)app); set_row(r,"@1g%6ld",(const char*)_sottoconto_succ); set_row(r," %s",(const char*)udata); - set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r", + set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c", (const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ, - &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); - set_row(r,"%s",(const char*)app); + &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ,app); } - else if (app == "D") + else if (app == 'D') { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|", - // _sottoconto_succ,(const char*)udata,(const char*)_descr_succ, - // &_saldoini_dare_succ,&_saldoini_avere_succ, - // &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); set_row(r,"@1g%6ld",(const char*)_sottoconto_succ); set_row(r," %s",(const char*)udata); set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g!", @@ -2419,10 +2377,6 @@ void CG1500_application::set_page(int file, int counter) } else { - // set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|", - // _sottoconto_succ,(const char*)udata,(const char*)_descr_succ, - // &_saldoini_dare_succ,&_saldoini_avere_succ, - // &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ); set_row(r,"@1g%6ld",(const char*)_sottoconto_succ); set_row(r," %s",(const char*)udata); set_row(r,"@18g%s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g!", @@ -2435,10 +2389,10 @@ void CG1500_application::set_page(int file, int counter) else { if (_saldofinale > 0) - app = "D"; + app = 'D'; else if (_saldofinale < 0) { - app = "A"; + app = 'A'; _saldofinale = -_saldofinale; } r = stampa_record_conto(_gruppo,_conto,_descr,_saldoini_dare, @@ -2452,14 +2406,18 @@ void CG1500_application::set_page(int file, int counter) int CG1500_application::stampa_record_conto(int g,int c,const char* d, const real& r1,const real& r2,const real& r3,const real& r4,const real& r5, - const TString& app) + const char app) { TString dep = ""; int r = 1; - set_row(r,"@49g!@82g!@115g!",(const char*)dep); //stampo una riga vuota if (_stampa_width == 148) + { + set_row(r,"@49g!@82g!@115g!",(const char*)dep); //stampo una riga vuota set_row(r,"@148g!",(const char*)dep); + } + else + set_row(r,"@49g!@82g!@114g!",(const char*)dep); //stampo una riga vuota r++; if (_verifica == 2) { @@ -2468,11 +2426,10 @@ int CG1500_application::stampa_record_conto(int g,int c,const char* d, // set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",g,d,&r1,&r2,&r3,&r4,&r5,(const char*)app); set_row(r,"%3d-",g); set_row(r,"@8g%s",d); - set_row(r,"@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r",&r1,&r2,&r3,&r4,&r5); - set_row(r++,"%s",(const char*)app); + set_row(r++,"@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c",&r1,&r2,&r3,&r4,&r5,app); } else - if (app == "D") + if (app == 'D') { // set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,d,&r1,&r2,&r3,&r4,&r5); set_row(r,"%3d-",g); @@ -2495,10 +2452,9 @@ int CG1500_application::stampa_record_conto(int g,int c,const char* d, set_row(r,"%3d-",g); set_row(r,"%3d ********",c); set_row(r,"@18g%s",d); - set_row(r,"@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r",&r1,&r2,&r3,&r4,&r5); - set_row(r++,"%s",(const char*)app); + set_row(r++,"@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c",&r1,&r2,&r3,&r4,&r5,app); } - else if (app == "D") + else if (app == 'D') { // set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,c,d,&r1,&r2,&r3,&r4,&r5); set_row(r,"%3d-",g); @@ -2515,16 +2471,24 @@ int CG1500_application::stampa_record_conto(int g,int c,const char* d, set_row(r++,"@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g!",&r1,&r2,&r3,&r4,&r5); } } - set_row(r,"@49g!@82g!@115g!",(const char*)dep); if (_stampa_width == 148) + { + set_row(r,"@49g!@82g!@115g!",(const char*)dep); set_row(r,"@148g!",(const char*)dep); + } + else + set_row(r,"@49g!@82g!@114g!",(const char*)dep); r++; - set_row(r,"@49g!@82g!@115g!",(const char*)dep); - if (_stampa_width == 148) - set_row(r,"@148g!",(const char*)dep); + if (_stampa_width == 148) + { + set_row(r,"@49g!@82g!@115g!",(const char*)dep); + set_row(r,"@148g!",(const char*)dep); + } + else + set_row(r,"@49g!@82g!@114g!",(const char*)dep); r++; - if (app == "D") + if (app == 'D') _saldo_finale_tot += r5; else _saldo_finale_tot -= r5; @@ -2538,14 +2502,15 @@ int CG1500_application::stampa_record_conto(int g,int c,const char* d, void CG1500_application::stampa_riga_totali(int r) { - TString app, dep = ""; - + TString dep = ""; + char app = ' '; + if (_saldo_finale_tot > 0) - app = "D"; + app = 'D'; else if (_saldo_finale_tot < 0) { _saldo_finale_tot = -_saldo_finale_tot; - app = "A"; + app = 'A'; } if (_datada == _dataini) //colonna saldo iniziale @@ -2562,16 +2527,20 @@ void CG1500_application::stampa_riga_totali(int r) _saldo_dare_tot = ZERO; } } - set_row(r,"@49g!@82g!@115g!",(const char*)dep); if (_stampa_width == 148) + { + set_row(r,"@49g!@82g!@115g!",(const char*)dep); set_row(r,"@148g!",(const char*)dep); + } + else + set_row(r,"@49g!@82g!@114g!",(const char*)dep); r++; if (_verifica == 2) { if (_stampa_width == 132) - set_row(r,"***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r%s",&_saldo_dare_tot,&_saldo_avere_tot,&_mov_dare_tot, - &_mov_avere_tot,&_saldo_finale_tot,(const char*)app); - else if (app == "D") + set_row(r,"***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c",&_saldo_dare_tot,&_saldo_avere_tot,&_mov_dare_tot, + &_mov_avere_tot,&_saldo_finale_tot,app); + else if (app == 'D') set_row(r,"***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g!",&_saldo_dare_tot,&_saldo_avere_tot, &_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot); else @@ -2581,14 +2550,13 @@ void CG1500_application::stampa_riga_totali(int r) else { if (_stampa_width == 132) - set_row(r,"****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r%s",&_saldo_dare_tot,&_saldo_avere_tot, - &_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot, - (const char*)app); - else if (app == "D") + set_row(r,"****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c",&_saldo_dare_tot,&_saldo_avere_tot, + &_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot,app); + else if (app == 'D') set_row(r,"****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g!",&_saldo_dare_tot, &_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot, &_saldo_finale_tot); - else + else set_row(r,"****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g!",&_saldo_dare_tot, &_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot, &_saldo_finale_tot); @@ -2637,42 +2605,112 @@ void CG1500_application::stampa_totali() _tot_avere = ZERO; } +//per Attivita'/Passivita' stampo anche lo sbilancio es. precedente +void CG1500_application::stampa_totali_uno() +{ + TString dep = ""; + real pareggio; + real sbilancio = _tot_dare - _prg_saldoini_dare - (_tot_avere - _prg_saldoini_avere); + real sbilprec = _prg_saldoini_avere - _prg_saldoini_dare; + if (sbilancio > ZERO) //ho un utile => va stampato tra le passivita' + { + sbilprec = -sbilprec; + pareggio = _tot_avere + sbilancio + sbilprec; + } +else if (sbilancio < ZERO) //ho una perdita => va stampato tra le attivita' cambiato di segno +{ + sbilancio = -sbilancio; + pareggio = _tot_dare + sbilancio + sbilprec; +} +if (_prima_volta) //ho finito di stampare le attivita'/passivita' + _prima_volta = FALSE; +else +_seconda_volta = FALSE; +_gc_prec_dare = _gc_corr_avere = ""; +_cambiato_conto_1 = TRUE; +_cambiato_conto_2 = TRUE; + +set_row(_i++, (const char*)dep); +set_row(_i++, (const char*)dep); +set_row(_i++, (const char*)dep); +set_row(_i++, (const char*)dep); +set_row(_i++, "@35gTOTALE@45g%r@103gTOTALE@113g%r", + &_tot_dare, &_tot_avere); + if (sbilancio > ZERO) +{ + if (sbilprec != ZERO) + set_row(_i++, "@79gSBILANCIO ESERCIZIO PRECEDENTE@113g%r", + &sbilprec); + set_row(_i++, "@81gSBILANCIO ESERCIZIO IN CORSO@113g%r", + &sbilancio); + set_row(_i++, "@92gTOTALE A PAREGGIO@113g%r",&pareggio); +} +else if (sbilancio < ZERO) +{ + if (sbilprec != ZERO) + set_row(_i++, "@11gSBILANCIO ESERCIZIO PRECEDENTE@45g%r", + &sbilprec); + set_row(_i++, "@13gSBILANCIO ESERCIZIO IN CORSO@45g%r", + &sbilancio); + set_row(_i++, "@24gTOTALE A PAREGGIO@45g%r", &pareggio); +} +else //sbilancio es. in corso == 0 +{ + sbilprec = -sbilprec; + if (sbilprec > ZERO) //va stampato sotto le passivita' + { + pareggio = _tot_avere + sbilprec; + set_row(_i++, "@79gSBILANCIO ESERCIZIO PRECEDENTE@113g%r", + &sbilprec); + set_row(_i++, "@92gTOTALE A PAREGGIO@113g%r", &pareggio); + } +else if (sbilprec < ZERO) +{ + sbilprec = -sbilprec; + pareggio = _tot_dare + sbilprec; + set_row(_i++, "@79gSBILANCIO ESERCIZIO PRECEDENTE@113g%r", + &sbilprec); + set_row(_i++, "@92gTOTALE A PAREGGIO@113g%r",&pareggio); +} +} +_tot_dare = ZERO; +_tot_avere = ZERO; +} + void CG1500_application::stampa_prima_colonna(int g, int c, long s, const char* desc, const real& saldo) { char dep = '*'; - if (_codici) //sono stampate solo le descrizioni dei conti + if (_codici) //sono stampate solo le descrizioni dei conti { - set_row(_i, "%s @66g%c", desc, dep); - - if ( (!_totali) || ((c != 0) || (s != 0)) ) - set_row(_i, "@45g%r", &saldo); - } - else if ( _totali && (c == 0) && (s == 0l) ) - { - set_row(_i, "%3d ", g); - set_row(_i, "@18g%s @66g%c", desc, dep); - } - else if ( (c == 0) && (s == 0l) ) - { - set_row(_i, "%3d ", g); - set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); - } - else if (s == 0l) - { - // set_row(_i, "%3d %3d ", g, c); - set_row(_i, "%3d ", g); - set_row(_i, "%3d ", c); - set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); + if (!_totali) + set_row(_i, "%s @45g%r @66g%c", desc, &saldo, dep); + else if ( !(c == 0 && s == 0) ) + set_row(_i, "%s @45g%r @66g%c", desc, &saldo, dep); } else { - // set_row(_i, "%3d %3d %6ld ", g, c, s); - set_row(_i, "%3d ", g); - set_row(_i, "%3d ", c); - set_row(_i, "%6ld ",(const char*) s); - set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); + if (_totali && c == 0 && s == 0l) + return; + else if ( c == 0 && s == 0l ) + { + set_row(_i, "%3d ", g); + set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); + } + else if (s == 0l) + { + set_row(_i, "%3d ", g); + set_row(_i, "%3d ", c); + set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); + } + else + { + set_row(_i, "%3d ", g); + set_row(_i, "%3d ", c); + set_row(_i, "%6ld ",(const char*) s); + set_row(_i, "@18g%s @45g%r @66g%c", desc, &saldo, dep); + } } } @@ -2683,36 +2721,37 @@ void CG1500_application::stampa_seconda_colonna(int g, int c, long s, if (_codici) //sono stampate solo le descrizioni dei conti { - set_row(_i, "@66g%c", dep); - set_row(_i, "@69g%s", desc); - - if ( (!_totali) || ((c != 0) || (s != 0)) ) + if (!_totali) + { + set_row(_i, "@66g%c", dep); + set_row(_i, "@69g%s", desc); set_row(_i, "@113g%r", &saldo); - } - else if ( (_totali) && (c == 0) && (s == 0l) ) - { - set_row(_i, "@66g%c@69g%3d ", dep, g); - set_row(_i, "@86g%s", desc); - } - else if ( (c == 0) && (s == 0l) ) - { - set_row(_i, "@66g%c@69g%3d ", dep, g); - set_row(_i, "@86g%s @113g%r", desc, &saldo); - } - else if (s == 0l) - { - // set_row(_i, "@66g|@69g%3d %3d ", g, c); - set_row(_i, "@66g%c@69g%3d ", dep, g); - set_row(_i, "%3d", c); - set_row(_i, "@86g%s @113g%r", desc, &saldo); - } + } + else if ( !(c == 0 && s == 0) ) + set_row(_i, "@66g%c @69g%s @113g%r", dep, desc, &saldo); + } else { - // set_row(_i, "@66g|@69g%3d %3d %6ld ", g, c, s); - set_row(_i, "@66g%c@69g%3d ", dep, g); - set_row(_i, "%3d ", c); - set_row(_i, "%6ld ",(const char*) s); - set_row(_i, "@86g%s @113g%r", desc, &saldo); + if (_totali && c == 0 && s == 0l) + return; + else if ( c == 0 && s == 0l ) + { + set_row(_i, "@66g%c@69g%3d ", dep, g); + set_row(_i, "@86g%s @113g%r", desc, &saldo); + } + else if (s == 0l) + { + set_row(_i, "@66g%c@69g%3d ", dep, g); + set_row(_i, "%3d", c); + set_row(_i, "@86g%s @113g%r", desc, &saldo); + } + else + { + set_row(_i, "@66g%c@69g%3d ", dep, g); + set_row(_i, "%3d ", c); + set_row(_i, "%6ld ",(const char*) s); + set_row(_i, "@86g%s @113g%r", desc, &saldo); + } } } @@ -2720,12 +2759,12 @@ print_action CG1500_application::postprocess_page(int file, int counter) { if (_bilancio == 1) { - if ( _eof1 && _eof2 && _eof3 && _eof4 && _eof5 && _salto_pagina1 ) + if ( _eof1 && _eof2 && _eof3 && _eof4 && _eof5 && _eof6 && _salto_pagina1 ) return NEXT_PAGE; } else //bilancio di verifica { - if ( (_verifica == 3) && (_ordinamento == 2) ) + if (_verifica == 3) { if (_buff == NULL) return NEXT_PAGE; @@ -2738,8 +2777,8 @@ print_action CG1500_application::postprocess_page(int file, int counter) TDate CG1500_application::UltimaData(int g, int c, long s, int anno) { - TLocalisamfile saldi(LF_SALDI, FALSE); //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp TDate uldata; + TLocalisamfile saldi(LF_SALDI, FALSE); //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp saldi.zero(); if (_annoes != 0) @@ -2753,15 +2792,18 @@ TDate CG1500_application::UltimaData(int g, int c, long s, int anno) if (saldi.bad()) saldi.zero(); uldata = saldi.get(SLD_DATAULMOV); - + return uldata; } -// Please don't use this function any more: use TConto class instead -// It'll be removed within some days const char* CG1500_application::DescrizioneConto(int g, int c, long s, - const char* tipocf) + char tipocf) { + /* + TConto tc (g,c,s,tipocf); + TMP = tc.descrizione(); + return TMP; + */ TLocalisamfile pconti(LF_PCON,FALSE); TLocalisamfile clifo (LF_CLIFO); @@ -2787,7 +2829,7 @@ const char* CG1500_application::DescrizioneConto(int g, int c, long s, TMP = ""; } return TMP; -} +} void CG1500_application::user_create() { @@ -2832,6 +2874,36 @@ void CG1500_application::user_destroy() delete _tmp_saldi_conti_due; } +void CG1500_application::leggi_pcon() +{ + TLocalisamfile pconti(LF_PCON); + TToken_string gc(10); + + for (pconti.first(); !pconti.eof(); pconti.next()) + { + gc.restart(); + int gruppo = pconti.get_int(PCN_GRUPPO); + int conto = pconti.get_int(PCN_CONTO); + long sottoconto = pconti.get_long(PCN_SOTTOCONTO); + if ( (sottoconto == 0l) && (conto != 0) ) //si tratta di un conto + { + char tipocf = pconti.get_char(PCN_TMCF); + if (tipocf == 'C') + { + gc.add(gruppo,0); + gc.add(conto,1); + _clienti.add(gc); + } + else if (tipocf == 'F') + { + gc.add(gruppo,0); + gc.add(conto,1); + _fornitori.add(gc); + } + } + } +} + bool CG1500_application::set_print(int) { TMask m ("cg1500a"); @@ -2869,8 +2941,8 @@ if (tasto == K_ENTER) { if (_annoes != 0) _dataini = InizioEsercizio(_annoes); - else _dataini = _inizioEs; - _datalim = m.get(F_DATALIM); + else _dataini = _inizioEs; + _datalim = m.get(F_DATALIM); _stampa_mov_prov = (bool)(m.get(F_STAMPAMPROV) == "X"); } bil_sez_contr(); @@ -2905,7 +2977,7 @@ if (tasto == K_ENTER) _stampac = atoi(m.get(F_STAMPAC)); _ordinamento = atoi(m.get(F_ORDINAMENTO)); - _cur->setkey(3); + // _cur->setkey(3); if (_situazione.not_empty()) _cur->setfilter(format("TIPOCF = \"%s\"",(const char*)_situazione)); @@ -2914,14 +2986,12 @@ if (tasto == K_ENTER) _prog = new TProgind(_cur->items(),"Elaborazione in corso... prego attendere",FALSE); - if (_ordinamento == 2) - { - crea_sort_clifo(); - _sort->endsort(); - delete _cf; - } - else - situazione_clifo(); + _clienti.destroy(); + _fornitori.destroy(); + leggi_pcon(); + crea_sort_clifo(); + _sort->endsort(); + delete _cf; } } delete _prog; @@ -3001,7 +3071,7 @@ int CG1500_application::stampa_intestazione_ditta() get_dati_ditta(); codice_ditta << get_firm(); - set_header (r, "Ditta %s %s Via %s %s %s %s", (const char*)codice_ditta, + set_header (r, "Ditta %s %s %s %s %s %s", (const char*)codice_ditta, (const char*)_ragsoc, (const char*)_viafis, (const char*)_cap, (const char*)_comunefis, (const char*)_provfis); @@ -3057,8 +3127,8 @@ void CG1500_application::preprocess_header() else // bilancio di verifica { TString riga (_stampa_width); - TString datada = _datada.string(); - TString dataa = _dataa.string(); + TString16 datada = _datada.string(); + TString16 dataa = _dataa.string(); if (_verifica == 1) set_header(r, "STAMPA BILANCIO DI VERIFICA"); else if (_verifica == 2) @@ -3108,44 +3178,46 @@ void CG1500_application::preprocess_header() if ( ((_datada == _dataini)&&(_tipo_stampa1 == 1))||(_tipo_stampa1 != 1) ) { if ( (_verifica == 1)||(_verifica == 3) ) - set_header(r,"@7g!@16g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO@115g!"); + set_header(r,"@7g!@16g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO"); else - set_header(r,"@7g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO@115g!"); + set_header(r,"@7g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO"); } else if (_tipo_stampa1 == 1) if ( (_verifica == 1)||(_verifica == 3) ) - set_header(r,"@7g!@16g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO@115g!"); + set_header(r,"@7g!@16g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO"); else - set_header(r,"@7g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO@115g!"); + set_header(r,"@7g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO"); if (_stampa_width == 148) - set_header(r,"@130gSALDO@148g!"); + set_header(r,"@115g!@130gSALDO@148g!"); + else + set_header(r,"@114g!"); r++; if ( (_verifica == 1)||(_verifica == 3) ) { if (_stampa_width == 132) { - set_header(r++,"@2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@115g!@123gSALDO",(const char*)riga, (const char*)riga); - set_header(r++,"@2gconto! data ! denominazione@49g!@58gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!"); + set_header(r++,"@2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO",(const char*)riga, (const char*)riga); + set_header(r++,"@2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g!"); } else { set_header(r++,"@2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g!",(const char*)riga, (const char*)riga, (const char*)riga); - set_header(r++,"@2gconto! data ! denominazione@49g!@58gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g!"); + set_header(r++,"@2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g!"); } } else { if (_stampa_width == 132) { - set_header(r++,"@2gcod. !@49g!@50g%.32s@82g!@83g%.32s@115g!@123gSALDO",(const char*)riga, (const char*)riga); - set_header(r++,"@1gmastro!descrizione@49g!@58gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!"); + set_header(r++,"@2gcod. !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO",(const char*)riga, (const char*)riga); + set_header(r++,"@1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g!"); } else { set_header(r++,"@2gcod. !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g!",(const char*)riga, (const char*)riga, (const char*)riga); - set_header(r++,"@1gmastro!descrizione@49g!@58gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g!"); + set_header(r++,"@1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g!"); } } set_header(r, (const char*)riga); @@ -3164,3 +3236,38 @@ int cg1500 (int argc, char* argv[]) return 0; } +/* + if (!compensa) + { + if ( (indbil_conto==1)||(indbil_conto==3) ) + if (saldo > ZERO) //saldo in dare + _indbil = indbil_conto; + else //saldo in avere + { + if (indbil_conto == 1) + _indbil = 2; + else _indbil = 4; + saldo = -saldo; + } + if ( (indbil_conto==2)||(indbil_conto==4) ) + if (saldo < ZERO) + { + _indbil = indbil_conto; + saldo = -saldo; + } + else + if (indbil_conto == 2) + _indbil = 1; + else _indbil = 3; + } + else //e' richiesta la compensazione + { + if ( (indbil_conto==1)||(indbil_conto==3) ) + _indbil = indbil_conto; + if ( (indbil_conto==2)||(indbil_conto==4) ) + { + _indbil = indbil_conto; + saldo = -saldo; + } + } + */ diff --git a/cg/cg1500a.uml b/cg/cg1500a.uml index 7a5b26914..924f840d0 100755 --- a/cg/cg1500a.uml +++ b/cg/cg1500a.uml @@ -203,7 +203,7 @@ BEGIN END */ -LIST F_ORDINAMENTO 12 +LIST F_ORDINAMENTO 11 BEGIN PROMPT 2 11 "Tipo ordinamento " ITEM "1|Per codice" diff --git a/cg/cg1600.cpp b/cg/cg1600.cpp index c4a831928..ab458ce95 100755 --- a/cg/cg1600.cpp +++ b/cg/cg1600.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "cglib.h" #include "cg1.h" @@ -136,12 +137,13 @@ public: const char * sezione () { return _str->get(3); } const char * lettera () { return _str->get(4); } const char * num_rom () { return _str->get(5); } - int numero () { return atoi(_str->get(6)); } - real saldo_conto (); - void incrementa_saldo(real& nuovo_saldo); + int numero () { return atoi(_str->get(6)); } + real saldo_conto (); + real saldo_conto_raf(); + void incrementa_saldo(real& nuovo_saldo,real& nuovo_saldo_raf); _riga_sez_opp(int g, int c, long s, const char * sezione, const char * lettera, - const char * num_rom, int num, real& saldo); + const char * num_rom, int num, real& saldo, real& saldo_raf); ~_riga_sez_opp(); }; @@ -151,16 +153,25 @@ real _riga_sez_opp::saldo_conto () return r; } -void _riga_sez_opp::incrementa_saldo(real& sld) +real _riga_sez_opp::saldo_conto_raf () +{ + real r(_str->get(8)); + return r; +} + +void _riga_sez_opp::incrementa_saldo(real& sld,real& sld_raf) { - real sld_prec = saldo_conto(); - sld_prec += sld; - _str->add(sld_prec.string(), 7); + real sld_prec = saldo_conto(); + real sld_prec_raf = saldo_conto_raf(); + sld_prec += sld; + sld_prec_raf += sld_raf; + _str->add(sld_prec.string(), 7); + _str->add(sld_prec_raf.string(), 8); } _riga_sez_opp::_riga_sez_opp(int g, int c, long s, const char * sezione, const char * lettera, - const char * num_rom, int num, real& saldo) + const char * num_rom, int num, real& saldo, real& saldo_raf) { _str = new TToken_string(30); _str->add(format("%d",g)); @@ -170,7 +181,8 @@ _riga_sez_opp::_riga_sez_opp(int g, int c, long s, _str->add(lettera); _str->add(num_rom); _str->add(format("%d",num)); - _str->add(saldo.string()); + _str->add(saldo.string()); + _str->add(saldo_raf.string()); } _riga_sez_opp::~_riga_sez_opp() @@ -188,30 +200,31 @@ public: const char * sezione () { return riga()->sezione(); } const char * lettera () { return riga()->lettera(); } const char * num_rom () { return riga()->num_rom(); } - int numero () { return riga()->numero(); } + int numero () { return riga()->numero(); } real saldo_conto () { return riga()->saldo_conto(); } + real saldo_conto_raf () { return riga()->saldo_conto_raf(); } void add (int g, int c, long s, const char * sezione, const char * lettera, - const char * num_rom, int num, real saldo); + const char * num_rom, int num, real saldo, real saldo_raf); }; void Righe_sez_opp::add(int g, int c, long s, const char * sezione, const char * lettera, - const char * num_rom, int num, real saldo) + const char * num_rom, int num, real saldo, real saldo_raf) { _riga_sez_opp * riga; TString key = format("%s%s%s%d",sezione,lettera,num_rom,num); if (!is_key((const char *) key)) { - riga = new _riga_sez_opp (g, c, s, sezione, lettera, num_rom, num, saldo); + riga = new _riga_sez_opp (g, c, s, sezione, lettera, num_rom, num, saldo, saldo_raf); TAssoc_array::add(key,riga); } else { riga = (_riga_sez_opp*) objptr ((const char*) key); - riga->incrementa_saldo(saldo); + riga->incrementa_saldo(saldo,saldo_raf); // add(key,riga,TRUE); } } @@ -260,20 +273,20 @@ class CG1600_application : public TPrintapp TSort* _sort; Anni_es _anni_es; Righe_sez_opp _sezopps; - TClifo_list* _listacf; + TSaldi_list* _listasld; TProgind* _prog; TDate _data_fine_ese,_data_fine_ese_prec,_data_fine_raf,_data_fine_raf_prec; TDate _datastampa,_datalimite,_databilrafr,_datai,_datairaf; - TDate _dataini,_datafine,_data_ini_ese; - int _annoese,_annoeserafr; + TDate _dataini,_datafine,_data_ini_ese,_data_ini_raf; + int _annoese,_annoeserafr,_anno_esercizio; bool _competenza,_intera_struttura,_stampamov,_stampacod,_stampa_modulo; - bool _stampa_mov_prov; - TString _classe_stampata, _classe_da_stampare,_numr_tot,_num_tot,_numr,_num; + bool _stampa_mov_prov,_diffprod_fatto,_risimp_fatto; + TString _classe_stampata, _classe_da_stampare,_numr_tot,_num_tot,_numr; char _sez_da_stamp,_let_da_stamp,_sez_stamp,_let_stamp,_sez_tot,_let_tot,_let,_sez_saldo,_sez,_tot_sez_saldo; TString _numr_da_stamp,_num_da_stamp,_numr_stamp,_num_stamp,_descr_sez; int _tipo_bilancio, _tipo_stampa; - int _cont_let,_cont_numr,_cont_num,_cont_gcs; + int _cont_let,_cont_numr,_cont_num,_cont_gcs,_num; Saldo _sld; real _sale,_salerafr,_totale_ordine,_totale_economico; real _totale_ordine_raf,_totale_economico_raf; @@ -292,6 +305,9 @@ class CG1600_application : public TPrintapp real _tot_num_mov_a,_tot_numr_mov_a,_tot_let_mov_a,_tot_gen_mov_a; real _tot_num_saldo_d,_tot_numr_saldo_d,_tot_let_saldo_d,_tot_gen_saldo_d; real _tot_num_saldo_a,_tot_numr_saldo_a,_tot_let_saldo_a,_tot_gen_saldo_a; + real _totale_parziale,_totale_parziale_raf; + real _tot_parz_sld,_tot_parz_sld_d,_tot_parz_sld_a,_tot_parz_prg_d; + real _tot_parz_prg_a,_tot_parz_mov_d,_tot_parz_mov_a; int _i; bool _reset_righe_stampa,_totale_attivita_gia_stampato,_totale_passivita_gia_stampato,_statopatr_no_stamp; TString _causale_ap, _causale_chi; @@ -318,21 +334,18 @@ public: void intesta_scalare(); void intesta_verifica(); void intesta_verifica_fissa(); - TDate data_inferiore(); - TDate data_inferiore_raf(); void init_sort(); void crea_sort_tabella(); void crea_sort_piano_conti_scalare(); void crea_sort_piano_conti_verifica(); void scrivi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char); - void scrivi_record_fittizio(const TString&,const TString&,const TString&,int); void riempi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char); const char* descrizione_sezione(char); const char* descrizione_lettera(char, char); const char* descrizione_numeroromano(char, char, int); const char* descrizione_numero(char, char, int, int); const char* descrizione_sottoconto(int, int, long); - const char* descr_sottoc_clifo(char,int,int,long); + const char* descr_sottoc_clifo(char,long); void setta_righe(const char*); void setta_righe_verifica(); void stampa_totali(); @@ -340,7 +353,8 @@ public: void stampa_totali_verifica(); bool calcola_saldo(real&, real&,int,int,long,int); bool calcola(int,int,long,const TDate&,const TDate&); - bool ricerca_sottoc_clifo(int,int,char,TString&,TString&,TString&,int,int); + real sottoc_clifo_scalare (int,int,int,int); + void sottoc_clifo_verifica(int,int,int,char,TString&,TString&,TString&,int,int,bool); const char* causale_apertura() { return _causale_ap;} const char* causale_chiusura() { return _causale_chi;} void stampa_saldo_132(const real&); @@ -410,7 +424,7 @@ void CG1600_application::set_bil_key(bil_ivd* b, char sezione, char lettera, void CG1600_application::set_bil_val(bil_ivd* b, const real& saldo, const real& saldorafr, const real& sld_prg_dare, - const real& sld_prg_avere, + const real& sld_prg_avere, const real& mov_dare, const real& mov_avere) { @@ -430,8 +444,8 @@ HIDDEN int date2esc(const TDate& d, int* prevesc) { const TDate ia(esc.get("D0")); // Data inizio esercizio const TDate fa(esc.get("D1")); // Data fine esercizio - a()->_inizioEs = ia; - a()->_fineEs = fa; + a()->_inizioEs = ia; + a()->_fineEs = fa; const anno = esc.get_int("CODTAB"); if (d >= ia && d <= fa) return anno; @@ -448,54 +462,59 @@ bool data_limite (TMask_field& f, KEY key) int tipobil,tipostampa; TDate datalim; TDate in="", fin=""; - // CG1600_application * a = (CG1600_application*) MainApp(); + // CG1600_application * a = (CG1600_application*) MainApp(); tipobil = atoi(m.get(F_TIPOBIL)); tipostampa = atoi(m.get(F_TIPOSTAMPA)); long annoese = m.get_long(F_ANNOESE); - a()->_anni_es.aggiungi_anno(annoese, in, fin); - a()->_data_fine_ese = fin; - a()->_data_ini_ese = in; + if ((tipobil == 1) && (tipostampa == 1)) { - datalim = m.get(F_DATALIM); + datalim = m.get(F_DATALIM); if (annoese != 0) - { + { + a()->_anni_es.aggiungi_anno(annoese, in, fin); + a()->_data_fine_ese = fin; + a()->_data_ini_ese = in; + + a()->_anno_esercizio = annoese; + if (datalim == botime) - a()->_datalimite = a()->_data_fine_ese; + a()->_datalimite = a()->_data_fine_ese; else if ((datalim < in)||(datalim > fin)) { f.error_box("La data limite non appartiene all' esercizio indicato"); return FALSE; - } - else - a()->_datalimite = datalim; + } + else + a()->_datalimite = datalim; } else - if (annoese == 0) - { - if (datalim == botime) - { - f.error_box("La data limite deve essere indicata obbligatoriamente"); + if (annoese == 0) + { + if (datalim == botime) + { + f.error_box("La data limite deve essere indicata obbligatoriamente"); + return FALSE; + } + + int anno = date2esc(datalim); + + if (anno == 0) + { + f.error_box("La data limite indicata non appartiene ad alcun esercizio attivo della ditta"); return FALSE; } - int anno = date2esc(datalim); + a()->_data_ini_ese = a()->_inizioEs; + a()->_data_fine_ese = a()->_fineEs; - if (anno == 0) - { - f.error_box("La data limite indicata non appartiene ad alcun esercizio attivo della ditta"); - return FALSE; - } - - a()->_data_ini_ese = a()->_inizioEs; - a()->_data_fine_ese = a()->_fineEs; - - a()->_datalimite = datalim; - } + a()->_datalimite = datalim; + a()->_anno_esercizio = anno; + } } } TString data1 = a()->_datalimite.string(); @@ -519,56 +538,75 @@ bool data_bil_raff (TMask_field& f, KEY key) int annoese = m.get_int(F_ANNOESE); int annoraf = m.get_int(F_ANNORAFFR); - if ((tipobil == 1) && (tipostampa == 1)) + if (tipobil == 1) //&& (tipostampa == 1)) { dataraf = m.get(F_DATABILRAF); datalim = m.get(F_DATALIM); - - date2esc(datalim); - in = a()->_inizioEs; - - int anno = date2esc(dataraf); - in_raf = a()->_inizioEs; - fin_raf = a()->_fineEs; - + if (annoraf == 0) - { - if (dataraf == botime) + { + int anno; + + if (datalim != botime) { - f.error_box("La data bilancio da raffrontare deve essere indicata obbligatoriamente"); - return FALSE; + date2esc(datalim); + in = a()->_inizioEs; } else + in = a()->_data_ini_ese; + + if (dataraf != botime) { - if (dataraf > in) - { - f.error_box("La data bilancio da raffrontare non puo' essere maggiore o uguale alla data inizio esercizio in corso"); - return FALSE; - } - - if (anno == 0) - { - f.error_box("La data bilancio da raffrontare indicata non appartiene ad alcun esercizio attivo della ditta"); - return FALSE; - } - - a()->_databilrafr = dataraf; + anno = date2esc(dataraf); + in_raf = a()->_inizioEs; + fin_raf = a()->_fineEs; } + else + anno == 1; +/**** + if (dataraf == botime) + { + f.error_box("La data bilancio da raffrontare deve essere indicata obbligatoriamente"); + return FALSE; + } + else + { +********/ + if (dataraf > in) + { + f.error_box("La data bilancio da raffrontare non puo' essere maggiore o uguale alla data inizio esercizio in corso"); + return FALSE; + } + + if (anno == 0) + { + f.error_box("La data bilancio da raffrontare indicata non appartiene ad alcun esercizio attivo della ditta"); + return FALSE; + } + + a()->_databilrafr = dataraf; + a()->_data_ini_raf = in_raf; + a()->_data_fine_raf = fin_raf; + //} } else - if (annoraf != 0) - { - if (dataraf == botime) - a()->_databilrafr = fin_raf; + if (annoraf != 0) + { + a()->_anni_es.aggiungi_anno(annoraf, in_raf, fin_raf); + a()->_data_fine_raf = fin_raf; + a()->_data_ini_raf = in_raf; + + if (dataraf == botime) + a()->_databilrafr = fin_raf; - else - if (dataraf < in_raf || dataraf > fin_raf) - { - f.error_box("La data bilancio da raffrontare deve appartenere all' esercizio da raffrontare"); + else + if (dataraf < in_raf || dataraf > fin_raf) + { + f.error_box("La data bilancio da raffrontare deve appartenere all' esercizio da raffrontare"); return FALSE; - } - else + } + else a()->_databilrafr = dataraf; } } @@ -577,6 +615,8 @@ bool data_bil_raff (TMask_field& f, KEY key) TString data2 = in_raf.string(); TString data3 = fin_raf.string(); TString data4 = a()->_databilrafr.string(); + TString data5 = a()->_data_ini_raf.string(); + TString data6 = a()->_data_fine_raf.string(); return TRUE; } @@ -594,28 +634,28 @@ bool anno_ese_raff (TMask_field& f, KEY key) { if (annoese != 0) { - if (annoraf > annoese) - { - f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno esercizio in corso"); + if (annoraf > annoese) + { + f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno esercizio in corso"); return FALSE; } } else - if (annoese == 0) - { - datalim = f.mask().get(F_DATALIM); + if (annoese == 0) + { + datalim = f.mask().get(F_DATALIM); - if (datalim != botime) - { - anno = date2esc(datalim); + if (datalim != botime) + { + anno = date2esc(datalim); - if (annoraf >= anno) - { - f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno di esercizio di appartenenza della data limite"); - return FALSE; - } - } - } + if (annoraf >= anno) + { + f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno di esercizio di appartenenza della data limite"); + return FALSE; + } + } + } } } return TRUE; @@ -641,19 +681,19 @@ bool tipo_bilancio (TMask_field& f, KEY key) { if (anno != 0) { - f.mask().show (96); - f.mask().show (97); - f.mask().hide (98); + f.mask().show (96); + f.mask().show (97); + f.mask().hide (98); f.mask().hide (99); } else - if (anno == 0) - { - f.mask().show(98); - f.mask().show(99); - f.mask().hide(96); - f.mask().hide(97); - } + if (anno == 0) + { + f.mask().show(98); + f.mask().show(99); + f.mask().hide(96); + f.mask().hide(97); + } } } return TRUE; @@ -663,7 +703,7 @@ bool anno_esercizio (TMask_field& f, KEY key) { int tipo_bil, anno; - if (key == K_TAB) + if (key == K_TAB || f.focusdirty()) { tipo_bil = f.mask().get_int(F_TIPOBIL); anno = f.mask().get_int(F_ANNOESE); @@ -679,19 +719,19 @@ bool anno_esercizio (TMask_field& f, KEY key) { if (anno != 0) { - f.mask().show (96); - f.mask().show (97); - f.mask().hide (98); + f.mask().show (96); + f.mask().show (97); + f.mask().hide (98); f.mask().hide (99); } else - if (anno == 0) - { - f.mask().show(98); - f.mask().show(99); - f.mask().hide(96); - f.mask().hide(97); - } + if (anno == 0) + { + f.mask().show(98); + f.mask().show(99); + f.mask().hide(96); + f.mask().hide(97); + } } } return TRUE; @@ -710,7 +750,7 @@ bool tipo_stampa(TMask_field& f,KEY k) if (tipo_stampa == 2) if (anno == 0) { - error_box("Nella stampa all' ultima immissione l' anno esercizio e' obbligatorio"); + error_box("Nella stampa all' ultima immissione l' anno esercizio e' obbligatorio"); return FALSE; } @@ -735,28 +775,38 @@ bool data_inizio(TMask_field& f, KEY k) a()->_anni_es.aggiungi_anno(anno, in, fin); a()->_data_ini_ese = in; a()->_data_fine_ese = fin; + a()->_anno_esercizio = anno; if (data == botime) - a()->_dataini = in; + a()->_dataini = in; else - if (data < in || data > fin) - { - f.error_box("La data non appartiene all' esercizio indicato"); + if (data < in || data > fin) + { + f.error_box("La data non appartiene all' esercizio indicato"); return FALSE; - } - else + } + else a()->_dataini = data; } else if (anno == 0) { - if (data == botime) - { - f.error_box("La data deve essere obbligatoriamente indicata"); + if (data == botime) + { + f.error_box("La data deve essere obbligatoriamente indicata"); + return FALSE; + } + + int anno = date2esc(data); + + if (anno == 0) + { + f.error_box("La data limite indicata non appartiene ad alcun esercizio attivo della ditta"); return FALSE; } - else - a()->_dataini = data; + + a()->_anno_esercizio = anno; + a()->_dataini = data; } } TString datastr = a()->_dataini.string(); @@ -785,36 +835,36 @@ bool data_fine(TMask_field& f, KEY k) a()->_data_fine_ese = fin; if (data == botime) - a()->_datafine = fin; + a()->_datafine = fin; else - if (data < in || data > fin) - { - f.error_box("La data non appartiene all' esercizio indicato"); - return FALSE; - } - else + if (data < in || data > fin) + { + f.error_box("La data non appartiene all' esercizio indicato"); + return FALSE; + } + else a()->_datafine = data; } else if (annoes == 0) { - if (data == botime) - { - f.error_box("La data deve essere obbligatoriamente indicata"); + if (data == botime) + { + f.error_box("La data deve essere obbligatoriamente indicata"); return FALSE; - } + } - date2esc(data_ini); - TString data3 = a()->_inizioEs.string(); - TString data4 = a()->_fineEs.string(); + date2esc(data_ini); + TString data3 = a()->_inizioEs.string(); + TString data4 = a()->_fineEs.string(); - if (data < a()->_inizioEs || data > a()->_fineEs) - { - f.error_box("La data non appartiene all' esercizio indicato"); - return FALSE; + if (data < a()->_inizioEs || data > a()->_fineEs) + { + f.error_box("La data non appartiene all' esercizio indicato"); + return FALSE; } else - a()->_datafine = data; + a()->_datafine = data; } if (data < data_ini) @@ -847,15 +897,6 @@ void CG1600_application::scrivi_record(const TString& sez, _sort->sort ((const char*) _bil); } -void CG1600_application::scrivi_record_fittizio(const TString& sez, - const TString& let,const TString& numerorom,int numero) - -{ - set_bil_key(_bil, sez[0], let[0], numerorom, numero, TRUE, 0); - set_bil_val(_bil); - _sort->sort ((const char*) _bil); -} - void CG1600_application::riempi_record(const TString& sez, const TString& let, const TString& numerorom,int numero, int g,int c,long s,const real& saldo,const real& saldorafr, @@ -880,8 +921,6 @@ void CG1600_application::crea_sort_tabella() int preclen; bool FINITO=FALSE; - init_sort(); - tabivd.first(); codtab_prec = tabivd.get("CODTAB"); @@ -908,7 +947,7 @@ void CG1600_application::crea_sort_tabella() tabivd.readat(recno_prec); const char sez = *((const char*) sezione); const char let = *((const char*) lettera); - TString16 nrom((const char*)numerorom); + TString16 nrom((const char*)numerorom); const int nu = (int) numero; set_bil_key(_bil, sez, let,(const char*)nrom, nu, FALSE,-1); @@ -929,18 +968,18 @@ void CG1600_application::crea_sort_piano_conti_scalare() TString sez,let,numerorom; TString sez_conto,let_conto,numr_conto,sez_opp,let_opp,numr_opp; int num_conto, indbil; - char sezione,lettera,tmcf; - int numero,g,c,num_opp; - long s; - bool sez_opposta = FALSE; - bool no_sez_opposta = FALSE; - bool classe_conto = FALSE; - bool conto_dettagliato = FALSE; - bool stsottbil; - int gruppo_prec,conto_prec; - real saldo,saldo_raf,saldo_conto,saldo_conto_raf; - real saldo_conto_opp,saldo_conto_raf_opp; - + char sezione,lettera,tmcf; + int numero,g,c,num_opp; + long s; + bool sez_opposta = FALSE; + bool no_sez_opposta = FALSE; + bool classe_conto = FALSE; + bool conto_dettagliato = FALSE; + bool stsottbil; + int gruppo_prec,conto_prec; + real saldo,saldo_raf,saldo_conto,saldo_conto_raf; + real saldo_conto_opp,saldo_conto_raf_opp; + TString saldostr,saldo_rafstr; c = 0; num_conto = 0; tmcf = ' '; @@ -951,15 +990,15 @@ void CG1600_application::crea_sort_piano_conti_scalare() saldo_conto_opp = ZERO; saldo_conto_raf_opp = ZERO; - gruppo_prec = -1; - conto_prec = -1; + gruppo_prec = -1; + conto_prec = -1; for (pconti.first(); !pconti.eof(); pconti.next()) { _prog->addstatus(1); - g = pconti.get_int (PCN_GRUPPO); - c = pconti.get_int (PCN_CONTO); - s = pconti.get_long(PCN_SOTTOCONTO); + g = pconti.get_int (PCN_GRUPPO); + c = pconti.get_int (PCN_CONTO); + s = pconti.get_long(PCN_SOTTOCONTO); sez = pconti.get(PCN_SEZIVD); let = pconti.get(PCN_LETTIVD); sezione = sez[0]; @@ -967,41 +1006,50 @@ void CG1600_application::crea_sort_piano_conti_scalare() numerorom = pconti.get(PCN_NUMRIVD); numero = pconti.get_int (PCN_NUMIVD); - saldo = ZERO; + saldo = ZERO; saldo_raf = ZERO; - if (conto_dettagliato) + //Anche se il conto non e' da dettagliare ma contiene la classe e' da + //mandare ugualmente in stampa con il totale di tutti i suoi sottoconti letti + + if (classe_conto) { - if (classe_conto) + if (c != conto_prec && conto_prec != -1) { - if (c != conto_prec && conto_prec != -1) + if (no_sez_opposta) + { + TString saldo_contostr,saldo_conto_rafstr; + + saldo_contostr = saldo_conto.string(); + saldo_conto_rafstr = saldo_conto_raf.string(); + riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + saldo_conto = ZERO; + saldo_conto_raf = ZERO; + classe_conto = FALSE; + no_sez_opposta = FALSE; + } + if (sez_opposta) { - if (no_sez_opposta) - { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); - saldo_conto = ZERO; - saldo_conto_raf = ZERO; - classe_conto = FALSE; - no_sez_opposta = FALSE; + int items = _sezopps.items(); + _sezopps.restart(); + for (int i=0; isezione(); + TString let_opp = lriga->lettera(); + TString numr_opp = lriga->num_rom(); + if (numr_opp == " ") //Sembrerebbe che il metodo sezione() quando il numero romano non esiste, ritorni + numr_opp.ltrim(); //una TString contenente uno spazio e non un NULL, sconvolgendo l' ordinamento. + //Per evitare tutto cio' aggiungo il metodo ltrim(), che toglie gli spazi. + //Pero', essendo il numero romano un campo Zerofill, uso ltrim() solo se non c'e'. + int num_opp = lriga->numero(); + real saldo_conto = lriga->saldo_conto(); + real saldo_conto_raf = lriga->saldo_conto_raf(); + riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); } - if (sez_opposta) - { - int items = _sezopps.items(); - _sezopps.restart(); - for (int i=0; isezione(); - TString let_opp = lriga->lettera(); - TString numr_opp = lriga->num_rom(); - int num_opp = lriga->numero(); - real saldo_conto_opp = lriga->saldo_conto(); - riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto_opp,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); - } - sez_opposta = FALSE; + sez_opposta = FALSE; - _sezopps.destroy(); - } + _sezopps.destroy(); } } } @@ -1023,148 +1071,294 @@ void CG1600_application::crea_sort_piano_conti_scalare() if ((g != 0) && (c != 0) && (s == 0)) { stsottbil = pconti.get_bool(PCN_STSOTTBIL); - tmcf = pconti.get(PCN_TMCF)[0]; - long record = pconti.recno(); - pconti.next(); - pconti.next(); - int g_app = pconti.get_int(PCN_GRUPPO); - int c_app = pconti.get_int(PCN_CONTO); - long s_app = pconti.get_long(PCN_SOTTOCONTO); - pconti.readat(record); - + tmcf = pconti.get (PCN_TMCF)[0]; + indbil = pconti.get_int (PCN_INDBIL); + //Se sono nello stesso gruppo, ma ho un conto diverso da quello precedentemente - //analizzato, allore devo controllare se va dettagliato - //(STSOTTBIL) e in caso affermativo se ha almeno due sottoconti. + //analizzato, e se questi contiene la classe IV dir. CEE, + //allore devo controllare se va dettagliato (STSOTTBIL) - if (((stsottbil)||(tmcf=='C')||(tmcf=='F'))&&((g_app!=0)&&(c_app!=0)&&(s_app!=0))) + if (sez != "") { - conto_dettagliato = TRUE; + if (!stsottbil || tmcf == 'C' || tmcf == 'F') + conto_dettagliato = FALSE; + else + conto_dettagliato = TRUE; - indbil = pconti.get_int(PCN_INDBIL); - - if ((let != "")||(numerorom != "")||(numero != 0)) - { - // if (sez == "") - // sez_conto = "9"; - // else - sez_conto = sez; + sez_conto = sez; - if (let != "") - let_conto = let; - else - if ((sez == "1")||(sez == "2")) - let_conto = "Z"; - else - let_conto = let; - - numr_conto = numerorom; - num_conto = numero; - classe_conto = TRUE; - } + if (let != "") + let_conto = let; else - classe_conto = FALSE; + if ((sez == "1")||(sez == "2")) + let_conto = "Z"; + else + let_conto = let; + + numr_conto = numerorom; + num_conto = numero; + classe_conto = TRUE; + + if (tmcf == 'C' || tmcf == 'F') + saldo_conto = sottoc_clifo_scalare(g, c,_anno_esercizio,indbil); } else - conto_dettagliato = FALSE; + { + classe_conto = FALSE; // Metto conto dettagliato = TRUE perche' potrebbero esserci dei sottoconti + conto_dettagliato = TRUE; // di questo conto che hanno la classe e quindi vanno stampati. + } } // Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort. - if (conto_dettagliato) - { - if ((g != 0) && (c != 0) && (s != 0)) + if ((g != 0) && (c != 0) && (s != 0)) + { + bool rec_es_corr = FALSE; + bool rec_es_prec = FALSE; + + if (!calcola_saldo(saldo,saldo_raf,g,c,s,indbil)) + continue; + + // classe_conto indica se il conto precedentemente letto conteneva + // la classe. In caso affermativo anche questo sottoconto appena + // letto avra' la stessa classe del conto. + + saldostr = saldo.string(); + saldo_rafstr = saldo_raf.string(); + bool stessa_sezione = (saldo * saldo_raf) > ZERO; + + if (classe_conto) { - - // int indbil = pconti.get_int(PCN_INDBIL); - if (!calcola_saldo(saldo,saldo_raf,g,c,s,indbil)) - continue; - - // classe_conto indica se il conto precedentemente letto conteneva la classe, - // ma quest' ultima non era presente a livello di gruppo. In caso affermativo - // anche questo sottoconto appena letto avra' la stessa classe del conto. - - if (classe_conto) - { - sez_opp = pconti.get(PCN_SEZIVDOPP); - if ((sez_opp != "")&&(((sez_conto=="1")&&(saldo < ZERO))||((sez_conto=="2")&&(saldo > ZERO)))) - { - let_opp = pconti.get(PCN_LETTIVDOPP); - numr_opp = pconti.get(PCN_NUMRIVDOPP); - num_opp = pconti.get_int(PCN_NUMIVDOPP); - sez_opposta = TRUE; + sez_opp = pconti.get(PCN_SEZIVDOPP); + if (sez_opp != "") + { + let_opp = pconti.get(PCN_LETTIVDOPP); + numr_opp = pconti.get(PCN_NUMRIVDOPP); + num_opp = pconti.get_int(PCN_NUMIVDOPP); + + if (sez_conto == "1" && saldo < ZERO)// || (sez_conto == "2" && saldo > ZERO) ) + { saldo = -saldo; - - _sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,saldo); - - riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + rec_es_corr = TRUE; } - else + if (sez_conto == "1" && saldo_raf < ZERO) //|| (sez_conto == "2" && saldo_raf > ZERO) ) { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); - saldo_conto += saldo; - saldo_conto_raf += saldo_raf; - no_sez_opposta = TRUE; + saldo_raf = -saldo_raf; + rec_es_prec = TRUE; } + if (sez_conto == "2" && saldo > ZERO) + { + rec_es_corr = TRUE; + } + if (sez_conto == "2" && saldo_raf > ZERO) + { + rec_es_prec = TRUE; + } + + if (rec_es_corr && rec_es_prec) + { + if (conto_dettagliato) + { + _sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,saldo,saldo_raf); + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + sez_opposta = TRUE; + } + else + sez_opposta = FALSE; + } + else + if (rec_es_corr) + { + if (conto_dettagliato) + { + _sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,saldo,ZERO); + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); + if (saldo_raf != ZERO) + { + if (sez_conto == "2") + if (saldo_raf < ZERO) + saldo_raf = -saldo_raf; + + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + //saldo_conto += saldo; + saldo_conto_raf += saldo_raf; + no_sez_opposta = TRUE; + } + sez_opposta = TRUE; + } + else + sez_opposta = FALSE; + } + else + if (rec_es_prec) + { + if (conto_dettagliato) + { + _sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,ZERO,saldo_raf); + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + if (saldo != ZERO) + { + if (sez_conto == "2") + if (saldo < ZERO) + saldo = -saldo; + + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); + saldo_conto += saldo; + //saldo_conto_raf += saldo_raf; + no_sez_opposta = TRUE; + } + sez_opposta = TRUE; + } + else + sez_opposta = FALSE; + } + else + { + if (sez_conto == "2") + { + if (saldo < ZERO) + saldo = -saldo; + if (saldo_raf < ZERO) + saldo_raf = -saldo_raf; + } + if (conto_dettagliato) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + + saldo_conto += saldo; + saldo_conto_raf += saldo_raf; + no_sez_opposta = TRUE; + } } else - { - sez_opp = pconti.get(PCN_SEZIVDOPP); - if ((sez_opp != "")&&(((sez=="1")&&(saldo < ZERO))||((sez=="2")&&(saldo > ZERO)))) + { + if (sez_conto == "2") { - let_opp = pconti.get(PCN_LETTIVDOPP); - numr_opp = pconti.get(PCN_NUMRIVDOPP); - num_opp = pconti.get_int(PCN_NUMIVDOPP); - riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); - } - else - { - if ((let != "")||(numerorom != "")||(numero != 0)) - { - // if (sez == "") - // sez = "9"; - - scrivi_record(sez,let,numerorom,numero,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); - } + saldo = -saldo; + saldo_raf = -saldo_raf; } + if (conto_dettagliato) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + + saldo_conto += saldo; + saldo_conto_raf += saldo_raf; + no_sez_opposta = TRUE; } } + else + { + sez_opp = pconti.get(PCN_SEZIVDOPP); + if (sez_opp != "") + { + let_opp = pconti.get(PCN_LETTIVDOPP); + numr_opp = pconti.get(PCN_NUMRIVDOPP); + num_opp = pconti.get_int(PCN_NUMIVDOPP); + + if (sez == "1" && saldo < ZERO) //|| (sez == "2" && saldo > ZERO) ) + { + saldo = -saldo; + rec_es_corr = TRUE; + } + if (sez == "1" && saldo_raf < ZERO) //|| (sez == "2" && saldo_raf > ZERO) ) + { + saldo_raf = -saldo_raf; + rec_es_prec = TRUE; + } + if (sez == "2" && saldo > ZERO) + { + rec_es_corr = TRUE; + } + if (sez == "2" && saldo_raf > ZERO) + { + rec_es_prec = TRUE; + } + + if (rec_es_corr && rec_es_prec) + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + else + if (rec_es_corr) + { + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); + if (saldo_raf != ZERO) + { + if (sez == "2") + if (saldo_raf < ZERO) + saldo_raf = -saldo_raf; + riempi_record(sez,let,numerorom,numero,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + } + } + else + if (rec_es_prec) + { + riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + if (saldo != ZERO) + { + if (sez == "2") + if (saldo < ZERO) + saldo = -saldo; + riempi_record(sez,let,numerorom,numero,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); + } + } + else + if (sez != "") + { + if (sez == "2") + { + if (saldo < ZERO) + saldo = -saldo; + if (saldo_raf < ZERO) + saldo_raf = -saldo_raf; + } + riempi_record(sez,let,numerorom,numero,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + } + } + else + if (sez != "") + { + if (sez == "2") + { + saldo = -saldo; + saldo_raf = -saldo_raf; + } + riempi_record(sez,let,numerorom,numero,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + } + } } } conto_prec = 0; - if (conto_dettagliato) + if (classe_conto) { - if (classe_conto) + if (c != conto_prec && conto_prec != -1) { - if (c != conto_prec && conto_prec != -1) + if (no_sez_opposta) { - if (no_sez_opposta) - { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); - saldo_conto = ZERO; - saldo_conto_raf = ZERO; - classe_conto = FALSE; - no_sez_opposta = FALSE; + riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); + saldo_conto = ZERO; + saldo_conto_raf = ZERO; + classe_conto = FALSE; + no_sez_opposta = FALSE; + } + if (sez_opposta) + { + int items = _sezopps.items(); + _sezopps.restart(); + for (int i=0; isezione(); + TString let_opp = lriga->lettera(); + TString numr_opp = lriga->num_rom(); + if (numr_opp == " ") + numr_opp.ltrim(); + int num_opp = lriga->numero(); + real saldo_conto = lriga->saldo_conto(); + real saldo_conto_raf = lriga->saldo_conto_raf(); + riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf); } - if (sez_opposta) - { - int items = _sezopps.items(); - _sezopps.restart(); - for (int i=0; isezione(); - TString let_opp = lriga->lettera(); - TString numr_opp = lriga->num_rom(); - int num_opp = lriga->numero(); - real saldo_conto_opp = lriga->saldo_conto(); - riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto_opp,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf); - } - sez_opposta = FALSE; + sez_opposta = FALSE; - _sezopps.destroy(); - } + _sezopps.destroy(); } } } @@ -1181,7 +1375,6 @@ void CG1600_application::crea_sort_piano_conti_verifica() long s; bool classe_conto = FALSE; bool conto_dettagliato = FALSE; - bool stamp_almeno_un_sottoc = FALSE; bool stsottbil; int gruppo_prec,conto_prec, indbil; real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere; @@ -1195,19 +1388,19 @@ void CG1600_application::crea_sort_piano_conti_verifica() mov_dare_conto = ZERO; mov_avere_conto = ZERO; - indbil = 0; - gruppo_prec = -1; - conto_prec = -1; - c = 0; - num_conto = 0; - tmcf = ' '; + indbil = 0; + gruppo_prec = -1; + conto_prec = -1; + c = 0; + num_conto = 0; + tmcf = ' '; for (pconti.first(); !pconti.eof(); pconti.next()) { _prog->addstatus(1); - g = pconti.get_int (PCN_GRUPPO); - c = pconti.get_int (PCN_CONTO); - s = pconti.get_long(PCN_SOTTOCONTO); + g = pconti.get_int (PCN_GRUPPO); + c = pconti.get_int (PCN_CONTO); + s = pconti.get_long(PCN_SOTTOCONTO); sez = pconti.get(PCN_SEZIVD); let = pconti.get(PCN_LETTIVD); sezione = sez[0]; @@ -1223,24 +1416,17 @@ void CG1600_application::crea_sort_piano_conti_verifica() mov_avere = ZERO; app = ZERO; - if (conto_dettagliato) + if (classe_conto) { - if (stamp_almeno_un_sottoc) + if (c != conto_prec && conto_prec != -1) { - if (classe_conto) - { - if (c != conto_prec && conto_prec != -1) - { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf); - saldo_conto = ZERO; - sld_prg_dare_conto = ZERO; - sld_prg_avere_conto = ZERO; - mov_dare_conto = ZERO; - mov_avere_conto = ZERO; - classe_conto = FALSE; - stamp_almeno_un_sottoc = FALSE; - } - } + riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf); + saldo_conto = ZERO; + sld_prg_dare_conto = ZERO; + sld_prg_avere_conto = ZERO; + mov_dare_conto = ZERO; + mov_avere_conto = ZERO; + classe_conto = FALSE; } } @@ -1264,210 +1450,55 @@ void CG1600_application::crea_sort_piano_conti_verifica() tmcf = pconti.get(PCN_TMCF)[0]; indbil = pconti.get_int(PCN_INDBIL); - if ((tmcf == 'C') || (tmcf == 'F')) - if (stsottbil) - { - if (!ricerca_sottoc_clifo(g, c, tmcf,sez,let,numerorom,numero,indbil)) - continue; - } - else - continue; - - long record = pconti.recno(); - pconti.next(); - pconti.next(); - int g_app = pconti.get_int(PCN_GRUPPO); - int c_app = pconti.get_int(PCN_CONTO); - int s_app = pconti.get_int(PCN_SOTTOCONTO); - pconti.readat(record); - //Se sono nello stesso gruppo, ma ho un conto diverso da quello precedentemente - //analizzato , allora devo controllare se va dettagliato - //(STSOTTBIL) e in caso affermativo se ha almeno due sottoconti. + //analizzato , se contiene la classe IV dir. CEE + //allora devo controllare se va dettagliato (STSOTTBIL) - if ((stsottbil)&&(g_app!=0)&&(c_app!=0)&&(s_app!=0)) - { - conto_dettagliato = TRUE; - - if ((let != "")||(numerorom != "")||(numero != 0)) - { - // if (sez == "") - // sez_conto = "9"; - // else - sez_conto = sez; - - if (let != "") - let_conto = let; - else - if ((sez == "1")||(sez == "2")) - let_conto = "Z"; - else - let_conto = let; - - numr_conto = numerorom; - num_conto = numero; - classe_conto = TRUE; - } - else - classe_conto = FALSE; - } - else - conto_dettagliato = FALSE; - } - - // Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort. - - if (conto_dettagliato) - { - if ((g != 0) && (c != 0) && (s != 0)) - { - // int indbil = pconti.get_int(PCN_INDBIL); - - // classe_conto indica se il conto precedentemente letto conteneva la classe, - // ma quest' ultima non era presente a livello di gruppo. In caso affermativo - // anche questo sottoconto appena letto avra' la stessa classe del conto. - - if (_tipo_stampa == 1) - { - if(!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec)) - continue; - - if (_dataini == _data_ini_ese) - { - sld_prg_dare = _saldo_ini_dare; - sld_prg_avere = _saldo_ini_avere; - mov_dare = _mov_periodo_dare; - mov_avere = _mov_periodo_avere; - saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; - } - else if (_dataini > _data_ini_ese) - { - sld_prg_dare = _prg_prec_dare; - sld_prg_avere = _prg_prec_avere; - mov_dare = _mov_periodo_dare; - mov_avere = _mov_periodo_avere; - saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; - } + if (sez != "") + { + if ((tmcf == 'C') || (tmcf == 'F')) + { + sottoc_clifo_verifica(g, c,_anno_esercizio, tmcf,sez,let,numerorom,numero,indbil,stsottbil); + continue; } else - if (_tipo_stampa == 2) - { - if (!_sld.ultima_immissione_bilancio(_annoese,g,c,s,indbil)) - continue; - app = _sld.saldoini(); - if (app < ZERO) - { - app = -app; - sld_prg_dare = ZERO; - sld_prg_avere = app; - } - else - { - sld_prg_dare = app; - sld_prg_avere = ZERO; - } - mov_dare = _sld.prgdare(); - mov_avere = _sld.prgavere(); - saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; - } - if (classe_conto) - { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf); - saldo_conto += saldo; - sld_prg_dare_conto += sld_prg_dare; - sld_prg_avere_conto += sld_prg_avere; - mov_dare_conto += mov_dare; - mov_avere_conto += mov_avere; - stamp_almeno_un_sottoc = TRUE; - } + if (!stsottbil) + conto_dettagliato = FALSE; + else + conto_dettagliato = TRUE; + + sez_conto = sez; + + if (let != "") + let_conto = let; else - { - if ((let != "")||(numerorom != "")||(numero != 0)) - { - // if (sez == "") - // sez = "9"; - - scrivi_record(sez,let,numerorom,numero,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf); - stamp_almeno_un_sottoc = TRUE; - } - } + if ((sez == "1")||(sez == "2")) + let_conto = "Z"; + else + let_conto = let; + + numr_conto = numerorom; + num_conto = numero; + classe_conto = TRUE; } - } - } - - conto_prec = 0; - - if (conto_dettagliato) - { - if (stamp_almeno_un_sottoc) - { - if (classe_conto) - { - if (c != conto_prec && conto_prec != -1) - { - riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf); - saldo_conto = ZERO; - sld_prg_dare_conto = ZERO; - sld_prg_avere_conto = ZERO; - mov_dare_conto = ZERO; - mov_avere_conto = ZERO; - classe_conto = FALSE; - stamp_almeno_un_sottoc = FALSE; - } - } - } - } -} - - -bool CG1600_application::ricerca_sottoc_clifo(int g,int c,char tipocf,TString& sez,TString& let,TString& numerorom,int numero,int indbil) -{ - long s; - _listacf = new TClifo_list (g,c,tipocf); - real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere; - real saldo_conto,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto; - real app; - TString sez_conto,let_conto,numr_conto; - int num_conto; - - saldo_conto = ZERO; - sld_prg_dare_conto = ZERO; - sld_prg_avere_conto = ZERO; - mov_dare_conto = ZERO; - mov_avere_conto = ZERO; - - int items = _listacf->items(); - if (items >= 2) - { - sez_conto = sez; - - if (let != "") - let_conto = let; - else - if ((sez == "1")||(sez == "2")) - let_conto = "Z"; else - let_conto = let; - - numr_conto = numerorom; - num_conto = numero; - - for (int i=0 ; i < _listacf->items(); i++) + { + classe_conto = FALSE; // Metto conto dettagliato = TRUE perche' potrebbero esserci dei sottoconti + conto_dettagliato = TRUE; // di questo conto che hanno la classe e quindi vanno stampati. + } + } + // Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort. + + if ((g != 0) && (c != 0) && (s != 0)) { - const TRectype& r=_listacf->clifo(i); - s = r.get_long(CLI_CODCF); - - saldo = ZERO; - sld_prg_dare = ZERO; - sld_prg_avere = ZERO; - mov_dare = ZERO; - mov_avere = ZERO; - app = ZERO; - + // classe_conto indica se il conto precedentemente letto conteneva la classe, + // ma quest' ultima non era presente a livello di gruppo. In caso affermativo + // anche questo sottoconto appena letto avra' la stessa classe del conto. + if (_tipo_stampa == 1) { - if (!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec)) - continue; + if(!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec)) + continue; if (_dataini == _data_ini_ese) { @@ -1491,10 +1522,10 @@ bool CG1600_application::ricerca_sottoc_clifo(int g,int c,char tipocf,TString& s { if (!_sld.ultima_immissione_bilancio(_annoese,g,c,s,indbil)) continue; - app = _sld.saldoini(); + app = _sld.saldoini(); if (app < ZERO) { - app = -app; + app = -app; sld_prg_dare = ZERO; sld_prg_avere = app; } @@ -1505,28 +1536,175 @@ bool CG1600_application::ricerca_sottoc_clifo(int g,int c,char tipocf,TString& s } mov_dare = _sld.prgdare(); mov_avere = _sld.prgavere(); - saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; + saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; } - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tipocf); - saldo_conto += saldo; - sld_prg_dare_conto += sld_prg_dare; - sld_prg_avere_conto += sld_prg_avere; - mov_dare_conto += mov_dare; - mov_avere_conto += mov_avere; - } - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tipocf); - saldo_conto = ZERO; - sld_prg_dare_conto = ZERO; - sld_prg_avere_conto = ZERO; - mov_dare_conto = ZERO; - mov_avere_conto = ZERO; + if (classe_conto) + { + if (conto_dettagliato) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf); - delete _listacf; - return TRUE; + saldo_conto += saldo; + sld_prg_dare_conto += sld_prg_dare; + sld_prg_avere_conto += sld_prg_avere; + mov_dare_conto += mov_dare; + mov_avere_conto += mov_avere; + } + else + { + if (sez != "") + scrivi_record(sez,let,numerorom,numero,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf); + } + } } + + conto_prec = 0; + + if (classe_conto) + { + if (c != conto_prec && conto_prec != -1) + { + riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf); + saldo_conto = ZERO; + sld_prg_dare_conto = ZERO; + sld_prg_avere_conto = ZERO; + mov_dare_conto = ZERO; + mov_avere_conto = ZERO; + classe_conto = FALSE; + } + } +} + + +void CG1600_application::sottoc_clifo_verifica(int g,int c,int anno,char tipocf,TString& sez,TString& let,TString& numerorom,int numero,int indbil,bool stsottbil) +{ + long s; + _listasld = new TSaldi_list (g,c,anno); + real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere; + real saldo_conto,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto; + real app; + TString sez_conto,let_conto,numr_conto; + int num_conto; + + saldo_conto = ZERO; + sld_prg_dare_conto = ZERO; + sld_prg_avere_conto = ZERO; + mov_dare_conto = ZERO; + mov_avere_conto = ZERO; + + int items = _listasld->items(); + + sez_conto = sez; + + if (let != "") + let_conto = let; else - return FALSE; + if ((sez == "1")||(sez == "2")) + let_conto = "Z"; + else + let_conto = let; + + numr_conto = numerorom; + num_conto = numero; + + for (int i=0 ; i < items; i++) + { + const TRectype& r=_listasld->saldi(i); + s = r.get_long(SLD_SOTTOCONTO); + + saldo = ZERO; + sld_prg_dare = ZERO; + sld_prg_avere = ZERO; + mov_dare = ZERO; + mov_avere = ZERO; + app = ZERO; + + if (_tipo_stampa == 1) + { + if (!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec)) + continue; + + if (_dataini == _data_ini_ese) + { + sld_prg_dare = _saldo_ini_dare; + sld_prg_avere = _saldo_ini_avere; + mov_dare = _mov_periodo_dare; + mov_avere = _mov_periodo_avere; + saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; + } + else if (_dataini > _data_ini_ese) + { + sld_prg_dare = _prg_prec_dare; + sld_prg_avere = _prg_prec_avere; + mov_dare = _mov_periodo_dare; + mov_avere = _mov_periodo_avere; + saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; + } + } + else + if (_tipo_stampa == 2) + { + if (!_sld.ultima_immissione_bilancio(_annoese,g,c,s,indbil)) + continue; + app = _sld.saldoini(); + if (app < ZERO) + { + app = -app; + sld_prg_dare = ZERO; + sld_prg_avere = app; + } + else + { + sld_prg_dare = app; + sld_prg_avere = ZERO; + } + mov_dare = _sld.prgdare(); + mov_avere = _sld.prgavere(); + saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; + } + + if (stsottbil) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tipocf); + saldo_conto += saldo; + sld_prg_dare_conto += sld_prg_dare; + sld_prg_avere_conto += sld_prg_avere; + mov_dare_conto += mov_dare; + mov_avere_conto += mov_avere; + } + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tipocf); + saldo_conto = ZERO; + sld_prg_dare_conto = ZERO; + sld_prg_avere_conto = ZERO; + mov_dare_conto = ZERO; + mov_avere_conto = ZERO; + + delete _listasld; +} + +real CG1600_application::sottoc_clifo_scalare(int g,int c,int anno,int indbil) +{ + long s; + _listasld = new TSaldi_list (g,c,anno); + real saldo,saldo_conto,saldo_raf; + + saldo_conto = ZERO; + + int items = _listasld->items(); + + for (int i=0 ; i < items; i++) + { + const TRectype& r=_listasld->saldi(i); + s = r.get_long(SLD_SOTTOCONTO); + + saldo = ZERO; + + if (!calcola_saldo(saldo,saldo_raf,g,c,s,indbil)) + continue; + + saldo_conto += saldo; + } + delete _listasld; + return saldo_conto; } //La funzione calcola_saldo calcola il saldo dell'esercizio in corso e di @@ -1535,9 +1713,10 @@ bool CG1600_application::ricerca_sottoc_clifo(int g,int c,char tipocf,TString& s bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c,long s,int indbil) { - bool no_movimentato = TRUE; + bool no_movimentato = TRUE; bool no_movimentato_raf = TRUE; - + TString saldostr,saldo_rafstr; + _sld.set_annoes(_annoese); if (_tipo_bilancio == 1) @@ -1558,8 +1737,9 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, } saldo = _sld.saldo(); - - if (_annoeserafr != 0) + saldostr = saldo.string(); + + if (_annoeserafr != 0 || _databilrafr != botime) { _sld.set_annoes(_annoeserafr); @@ -1574,11 +1754,12 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, { if (!_sld.ultima_immissione_bilancio(_annoeserafr,g,c,s,indbil)) no_movimentato_raf = TRUE; - else + else no_movimentato_raf = FALSE; } saldo_raf = _sld.saldo(); + saldo_rafstr = saldo_raf.string(); } } @@ -1643,8 +1824,9 @@ bool CG1600_application::calcola(int g, int c, long s, //li scarto const TString codcaus(mov.get(MOV_CODCAUS)); - if (codcaus == causale_chiusura()) //la causale e' uguale a quella di chiusura - break; + if (codcaus.not_empty()) + if (codcaus == causale_chiusura()) //la causale e' uguale a quella di chiusura + continue; if (_annoese == 0) data = datareg; @@ -1691,8 +1873,6 @@ bool CG1600_application::set_print(int) { KEY tasto; - // if (_sort) delete _sort; - // if (_bil) delete _bil; { TConfig conf(CONFIG_DITTA); @@ -1739,13 +1919,17 @@ if (tasto == K_ENTER) _cont_gcs = 0; _reset_righe_stampa = TRUE; - set_real_picture("###.###.###.###"); - set_print_zero(); - // _sld.set_bil(_tipo_bilancio); + set_real_picture("###.###.###.###"); + if (_stampamov) + set_print_zero(FALSE); + else + set_print_zero(TRUE); _totale_attivita_gia_stampato = FALSE; _totale_passivita_gia_stampato = FALSE; - _statopatr_no_stamp = TRUE; + _statopatr_no_stamp = TRUE; + _diffprod_fatto = TRUE; + _risimp_fatto = TRUE; _sez_stamp = ' '; _let_stamp = ' '; @@ -1756,10 +1940,18 @@ if (tasto == K_ENTER) _numr_tot = ""; _num_tot = ""; - _datai = data_inferiore(); - _datairaf = data_inferiore_raf(); + _datai = _data_ini_ese; + _datairaf = _data_ini_raf; + TString data1 = _data_ini_ese.string(); + TString data2 = _data_ini_raf.string(); - crea_sort_tabella(); +// Se si tratta di stampa intera struttura allora passo al sort anche tutte +// le classi presenti sulla tabella IV dir. CEE, altrimenti passo solamente +// le classi associate ai conti/sottoconti del Piano dei conti. + + init_sort(); + if (_intera_struttura) + crea_sort_tabella(); if (_tipo_bilancio == 1) crea_sort_piano_conti_scalare(); else if (_tipo_bilancio == 2) @@ -1778,8 +1970,13 @@ return FALSE; void CG1600_application::stampa_totali() { bool gia_stampato_conto_ord = FALSE; - - _num = _num_tot; + TString16 diff_prod; + TString16 ris_imp; + + diff_prod.format("%c%c",'9','B'); + ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + + _num = atoi(_num_tot); _numr = _numr_tot; _let = _let_tot; @@ -1792,17 +1989,39 @@ void CG1600_application::stampa_totali() } if (_num_da_stamp!=_num_tot) - { + { if (_let_stamp != 'Z') { if (_sez_stamp != '5') - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { - //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i++,"@86g%r", &_totale_numero); + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } } } + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + + if (classe > ris_imp && _risimp_fatto) + { + if (_num_tot == "21" || _num_tot == "22") + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i++,"@86g%r", &_totale_parziale); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%r", &_totale_economico); + _risimp_fatto = FALSE; + } + } + } + _cont_gcs = 0; _totale_numero = 0; } @@ -1812,19 +2031,25 @@ void CG1600_application::stampa_totali() { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { - //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i++,"@86g%r", &_totale_numero); + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); - TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i++,"@86g%r", &_totale_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + } } } } @@ -1834,42 +2059,110 @@ void CG1600_application::stampa_totali() _totale_numr = 0; } if (_let_da_stamp!=_let_tot) - { + { + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp); + + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + } + } + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let_stamp == 'D') + set_row (_i,"@4gTotale delle rettifiche"); + else + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + else + if (_sez_stamp != '9') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i++,"@86g%r", &_totale_lettera); + else + if (_sez_stamp != '9') + set_row (_i++,"@86g%r", &_totale_lettera); + } + } + + if (classe > diff_prod && _diffprod_fatto) + { + if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r", &_totale_economico); + _diffprod_fatto = FALSE; + } + } + } + else + { if (_let_stamp != 'Z') { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { - //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i++,"@86g%r", &_totale_numero); + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); - TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i++,"@86g%r", &_totale_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + } } - if (_cont_numr >= 2) + if (_cont_numr != 0)//(_cont_numr >= 2) { - //Fai il totale della lettera e stampalo - set_row (_i,"@3gTotale@10g%c@12g)", _let); - set_row (_i++,"@86g%r", &_totale_lettera); + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%r", &_totale_lettera); + } } - } + } } if ((_sez_stamp == '1')&&(_let_da_stamp == 'Z')) { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVITA'"); + set_row (_i,"@0gTOTALE ATTIVO"); set_row (_i++,"@86g%r", &_totale_sezione); _totale_attivita = _totale_sezione; - _totale_sezione = 0; + _totale_sezione = ZERO; _totale_attivita_gia_stampato = TRUE; } @@ -1877,10 +2170,10 @@ void CG1600_application::stampa_totali() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVITA'"); + set_row (_i,"@0gTOTALE PASSIVO"); set_row (_i++,"@86g%r", &_totale_sezione); _totale_passivita = _totale_sezione; - _totale_sezione = 0; + _totale_sezione = ZERO; _totale_passivita_gia_stampato = TRUE; } @@ -1890,7 +2183,7 @@ void CG1600_application::stampa_totali() set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); set_row (_i++,"@86g%r", &_totale_ordine_attivo); - _totale_ordine_attivo = 0; +// _totale_ordine_attivo = ZERO; gia_stampato_conto_ord = TRUE; } @@ -1900,10 +2193,16 @@ void CG1600_application::stampa_totali() set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i++,"@86g%r", &_totale_ordine_passivo); - _totale_ordine_passivo = 0; + _i++; + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%r", &totale); + _totale_ordine_attivo = ZERO; + _totale_ordine_passivo = ZERO; gia_stampato_conto_ord = TRUE; } - + } _cont_gcs = 0; _cont_num = 0; _cont_numr = 0; @@ -1917,25 +2216,43 @@ void CG1600_application::stampa_totali() { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i++,"@86g%r", &_totale_numero); + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i++,"@86g%r", &_totale_numr); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + } } - if (_cont_numr >= 2) + if (_cont_numr != 0)//(_cont_numr >= 2) { //Fai il totale della lettera e stampalo - set_row (_i,"@3gTotale@10g%c@12g)", _let); - set_row (_i++,"@86g%r", &_totale_lettera); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%r", &_totale_lettera); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%r", &_totale_lettera); + } + } } } } @@ -1945,10 +2262,10 @@ void CG1600_application::stampa_totali() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVITA'"); + set_row (_i,"@0gTOTALE ATTIVO"); set_row (_i++,"@86g%r", &_totale_sezione); _totale_attivita = _totale_sezione; - _totale_sezione = 0; + _totale_sezione = ZERO; } if (!_totale_passivita_gia_stampato) @@ -1956,10 +2273,10 @@ void CG1600_application::stampa_totali() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVITA'"); + set_row (_i,"@0gTOTALE PASSIVO"); set_row (_i++,"@86g%r", &_totale_sezione); _totale_passivita = _totale_sezione; - _totale_sezione = 0; + _totale_sezione = ZERO; } if (!gia_stampato_conto_ord) @@ -1970,7 +2287,7 @@ void CG1600_application::stampa_totali() set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); set_row (_i++,"@86g%r", &_totale_ordine_attivo); - _totale_ordine_attivo = 0; + // _totale_ordine_attivo = ZERO; } if ((_sez_stamp == '2')&&(_let_stamp == 'Z')) @@ -1978,8 +2295,14 @@ void CG1600_application::stampa_totali() char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); - set_row (_i++,"@86g%r", &_totale_ordine_passivo); - _totale_ordine_passivo = 0; + set_row (_i++,"@86g%r", &_totale_ordine_passivo); + _i++; + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%r", &totale); + _totale_ordine_passivo = ZERO; + _totale_ordine_attivo = ZERO; } } @@ -1988,10 +2311,10 @@ void CG1600_application::stampa_totali() char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVITA' - PASSIVITA')"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); _totale_patrimoniale = _totale_attivita - _totale_passivita; set_row (_i++,"@86g%r", &_totale_patrimoniale); - _totale_patrimoniale = 0; + _totale_patrimoniale = ZERO; } if (_sez_stamp == '5') { @@ -1999,15 +2322,15 @@ void CG1600_application::stampa_totali() set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE"); set_row (_i++,"@86g%r", &_totale_ordine); - _totale_ordine = 0; + _totale_ordine = ZERO; } if (_sez_stamp == '9') { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTO ECONOMICO"); + set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); set_row (_i++,"@86g%r", &_totale_economico); - _totale_economico = 0; + _totale_economico = ZERO; } _cont_gcs = 0; _cont_num = 0; @@ -2022,8 +2345,12 @@ void CG1600_application::stampa_totali() void CG1600_application::stampa_totali_con_raffronto() { bool gia_stampato_conto_ord = FALSE; + TString16 diff_prod; + TString16 ris_imp; - _num = _num_tot; + diff_prod.format("%c%c",'9','B'); + ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + _num = atoi(_num_tot); _numr = _numr_tot; _let = _let_tot; @@ -2037,16 +2364,40 @@ void CG1600_application::stampa_totali_con_raffronto() if (_num_da_stamp!=_num_tot) { + if (_let_stamp != 'Z') { if (_sez_stamp != '5') - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i,"@86g%r", &_totale_numero); - set_row (_i++,"@112g%r", &_totale_num_raf); + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,"@86g%r", &_totale_numero); + set_row (_i++,"@112g%r", &_totale_num_raf); + } } + } + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + + if (classe > ris_imp && _risimp_fatto) + { + if (_num_tot == "21" || _num_tot == "22") + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i,"@86g%r", &_totale_parziale); + set_row (_i++,"@112g%r", &_totale_parziale_raf); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i,"@86g%r", &_totale_economico); + set_row (_i++,"@112g%r", &_totale_economico_raf); + _risimp_fatto = FALSE; + } + } } _cont_gcs = 0; _totale_numero = 0; @@ -2058,21 +2409,27 @@ void CG1600_application::stampa_totali_con_raffronto() { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i,"@86g%r", &_totale_numero); - set_row (_i++,"@112g%r", &_totale_num_raf); + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,"@86g%r", &_totale_numero); + set_row (_i++,"@112g%r", &_totale_num_raf); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i,"@86g%r", &_totale_numr); - set_row (_i++,"@112g%r", &_totale_numr_raf); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i,"@86g%r", &_totale_numr); + set_row (_i++,"@112g%r", &_totale_numr_raf); + } } } } @@ -2085,32 +2442,106 @@ void CG1600_application::stampa_totali_con_raffronto() } if (_let_da_stamp!=_let_tot) { + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp); + + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%r", &_totale_numero); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + } + } + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let_stamp == 'D') + set_row (_i,"@4gTotale delle rettifiche"); + else + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + else + if (_sez_stamp != '9') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@86g%r", &_totale_lettera); + set_row (_i++,"@112g%r", &_totale_let_raf); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@86g%r", &_totale_lettera); + set_row (_i++,"@112g%r", &_totale_let_raf); + } + } + } + if (classe > diff_prod && _diffprod_fatto) + { + if (_let_tot == 'A' || _let_tot == 'B') + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r@112g%r", &_totale_economico,&_totale_economico_raf); + _diffprod_fatto = FALSE; + } + } + + } + else + { if (_let_stamp != 'Z') { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i,"@86g%r", &_totale_numero); - set_row (_i++,"@112g%r", &_totale_num_raf); + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,"@86g%r", &_totale_numero); + set_row (_i++,"@112g%r", &_totale_num_raf); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i,"@86g%r", &_totale_numr); - set_row (_i++,"@112g%r", &_totale_numr_raf); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i,"@86g%r", &_totale_numr); + set_row (_i++,"@112g%r", &_totale_numr_raf); + } } - if (_cont_numr >= 2) + if (_cont_numr != 0)//(_cont_numr >= 2) { //Fai il totale della lettera e stampalo - set_row (_i,"@3gTotale@10g%c@12g)", _let); - set_row (_i,"@86g%r", &_totale_lettera); - set_row (_i++,"@112g%r", &_totale_let_raf); + if (_let != ' ') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,"@86g%r", &_totale_lettera); + set_row (_i++,"@112g%r", &_totale_let_raf); + } } } } @@ -2119,13 +2550,13 @@ void CG1600_application::stampa_totali_con_raffronto() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVITA'"); + set_row (_i,"@0gTOTALE ATTIVO"); set_row (_i,"@86g%r", &_totale_sezione); set_row (_i++,"@112g%r", &_totale_sez_raf); _totale_attivita = _totale_sezione; _totale_attiv_raf = _totale_sez_raf; - _totale_sezione = 0; - _totale_sez_raf = 0; + _totale_sezione = ZERO; + _totale_sez_raf = ZERO; _totale_attivita_gia_stampato = TRUE; } @@ -2133,13 +2564,13 @@ void CG1600_application::stampa_totali_con_raffronto() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVITA'"); + set_row (_i,"@0gTOTALE PASSIVO"); set_row (_i,"@86g%r", &_totale_sezione); set_row (_i++,"@112g%r", &_totale_sez_raf); _totale_passivita = _totale_sezione; _totale_passiv_raf = _totale_sez_raf; - _totale_sezione = 0; - _totale_sez_raf = 0; + _totale_sezione = ZERO; + _totale_sez_raf = ZERO; _totale_passivita_gia_stampato = TRUE; } @@ -2150,8 +2581,8 @@ void CG1600_application::stampa_totali_con_raffronto() set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); set_row (_i,"@86g%r", &_totale_ordine_attivo); set_row (_i++,"@112g%r", &_totale_ordine_attivo_raf); - _totale_ordine_attivo = 0; - _totale_ordine_attivo_raf = 0; + //_totale_ordine_attivo = ZERO; + //_totale_ordine_attivo_raf = ZERO; gia_stampato_conto_ord = TRUE; } @@ -2162,11 +2593,20 @@ void CG1600_application::stampa_totali_con_raffronto() set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i,"@86g%r", &_totale_ordine_passivo); set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf); - _totale_ordine_passivo = 0; - _totale_ordine_passivo_raf = 0; - gia_stampato_conto_ord = TRUE; + _i++; + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i,"@86g%r", &totale); + set_row (_i++,"@112g%r", &tot_raf); + _totale_ordine_attivo = ZERO; + _totale_ordine_attivo_raf = ZERO; + _totale_ordine_passivo = ZERO; + _totale_ordine_passivo_raf = ZERO; + gia_stampato_conto_ord = TRUE; + } } - _cont_gcs = 0; _cont_num = 0; _cont_numr = 0; @@ -2183,28 +2623,47 @@ void CG1600_application::stampa_totali_con_raffronto() { if (_sez_stamp != '5') { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo - set_row (_i,"@18gTotale@25g%s@27g)",(const char*) _num); - set_row (_i,"@86g%r", &_totale_numero); - set_row (_i++,"@112g%r", &_totale_num_raf); + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,"@86g%r", &_totale_numero); + set_row (_i++,"@112g%r", &_totale_num_raf); + } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); - TString numrom = itor(numeror); - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); - set_row (_i++,"@86g%r", &_totale_numr); - set_row (_i++,"@112g%r", &_totale_numr_raf); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%r", &_totale_numr); + set_row (_i++,"@112g%r", &_totale_numr_raf); + } } - if (_cont_numr >= 2) + if (_cont_numr != 0)//(_cont_numr >= 2) { //Fai il totale della lettera e stampalo - set_row (_i,"@3gTotale@10g%c@12g)", _let); - set_row (_i++,"@86g%r", &_totale_lettera); - set_row (_i++,"@112g%r", &_totale_let_raf); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%r", &_totale_lettera); + set_row (_i++,"@112g%r", &_totale_let_raf); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%r", &_totale_lettera); + set_row (_i++,"@112g%r", &_totale_let_raf); + } + } } } } @@ -2214,13 +2673,13 @@ void CG1600_application::stampa_totali_con_raffronto() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVITA'"); + set_row (_i,"@0gTOTALE ATTIVO"); set_row (_i,"@86g%r", &_totale_sezione); set_row (_i++,"@112g%r", &_totale_sez_raf); _totale_attivita = _totale_sezione; _totale_attiv_raf = _totale_sez_raf; - _totale_sezione = 0; - _totale_sez_raf = 0; + _totale_sezione = ZERO; + _totale_sez_raf = ZERO; _totale_attivita_gia_stampato = TRUE; } @@ -2229,13 +2688,13 @@ void CG1600_application::stampa_totali_con_raffronto() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVITA'"); + set_row (_i,"@0gTOTALE PASSIVO"); set_row (_i,"@86g%r", &_totale_sezione); set_row (_i++,"@112g%r", &_totale_sez_raf); _totale_passivita = _totale_sezione; _totale_passiv_raf = _totale_sez_raf; - _totale_sezione = 0; - _totale_sez_raf = 0; + _totale_sezione = ZERO; + _totale_sez_raf = ZERO; _totale_passivita_gia_stampato = TRUE; } @@ -2246,8 +2705,10 @@ void CG1600_application::stampa_totali_con_raffronto() char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); - set_row (_i++,"@86g%r", &_totale_ordine_attivo); - _totale_ordine_attivo = 0; + set_row (_i,"@86g%r", &_totale_ordine_attivo); + set_row (_i++,"@112g%r", &_totale_ordine_attivo_raf); + //_totale_ordine_attivo = ZERO; + //_totale_ordine_attivo_raf = ZERO; } if ((_sez_stamp == '2')&&(_let_stamp == 'Z')) @@ -2255,8 +2716,19 @@ void CG1600_application::stampa_totali_con_raffronto() char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); - set_row (_i++,"@86g%r", &_totale_ordine_passivo); - _totale_ordine_passivo = 0; + set_row (_i,"@86g%r", &_totale_ordine_passivo); + set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf); + _i++; + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i,"@86g%r", &totale); + set_row (_i++,"@112g%r", &tot_raf); + _totale_ordine_attivo = ZERO; + _totale_ordine_attivo_raf = ZERO; + _totale_ordine_passivo = ZERO; + _totale_ordine_passivo_raf = ZERO; } } @@ -2265,7 +2737,7 @@ void CG1600_application::stampa_totali_con_raffronto() char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVITA' - PASSIVITA')"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); _totale_patrimoniale = _totale_attivita - _totale_passivita; _totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; set_row (_i,"@86g%r", &_totale_patrimoniale); @@ -2287,7 +2759,7 @@ void CG1600_application::stampa_totali_con_raffronto() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTO ECONOMICO"); + set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); set_row (_i,"@86g%r", &_totale_economico); set_row (_i++,"@112g%r", &_totale_economico_raf); _totale_economico = 0; @@ -2307,8 +2779,12 @@ void CG1600_application::stampa_totali_con_raffronto() } void CG1600_application::stampa_totali_verifica() -{ - _num = _num_tot; +{ + TString16 ris_imp; + + ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + + _num = atoi(_num_tot); _numr = _numr_tot; _let = _let_tot; _sez = _sez_tot; @@ -2323,19 +2799,25 @@ void CG1600_application::stampa_totali_verifica() if (_num_da_stamp!=_num_tot) { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z')) - { - set_row (_i,"@8gTotale@15g%s@17g)",(const char*) _num); + { + if (_num != 0) + set_row (_i,"@8gTotale@15g%2d@17g)",_num); } else - set_row (_i,"@8gTotale"); - set_row (_i,"@49g%r", &_tot_num_prg_d); - set_row (_i,"@65g%r", &_tot_num_prg_a); - set_row (_i,"@82g%r", &_tot_num_mov_d); - set_row (_i,"@98g%r", &_tot_num_mov_a); + if (_num != 0) + set_row (_i,"@8gTotale"); + + if (_num != 0) + { + set_row (_i,"@49g%r", &_tot_num_prg_d); + set_row (_i,"@65g%r", &_tot_num_prg_a); + set_row (_i,"@82g%r", &_tot_num_mov_d); + set_row (_i,"@98g%r", &_tot_num_mov_a); + } if (!_stampa_modulo) { @@ -2345,14 +2827,54 @@ void CG1600_application::stampa_totali_verifica() _tot_sez_saldo = 'A'; } else - _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_num_saldo); + _tot_sez_saldo = 'D'; + + if (_num != 0) + stampa_saldo_132(_tot_num_saldo); } else - { - stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); + { + if (_num != 0) + stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); // _tot_num_saldo_d = 0; // _tot_num_saldo_a = 0; + } + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + + if (classe > ris_imp && _risimp_fatto) + { + if (_num_tot == "21" || _num_tot == "22") + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i,"@49g%r", &_tot_parz_prg_d); + set_row (_i,"@65g%r", &_tot_parz_prg_a); + set_row (_i,"@82g%r", &_tot_parz_mov_d); + set_row (_i,"@98g%r", &_tot_parz_mov_a); + _risimp_fatto = FALSE; + if (!_stampa_modulo) + { + if (_tot_parz_sld < ZERO) + { + _tot_parz_sld = -_tot_parz_sld; + _tot_sez_saldo = 'A'; + } + else + _tot_sez_saldo = 'D'; + + if (_num != 0) + stampa_saldo_132(_tot_parz_sld); + } + else + { + if (_num != 0) + stampa_saldo_198(_tot_parz_sld_d,_tot_parz_sld_a); + } + } + } } } _cont_gcs = 0; @@ -2364,19 +2886,25 @@ void CG1600_application::stampa_totali_verifica() } if (_numr_da_stamp!=_numr_tot) { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z')) - { - set_row (_i,"@8gTotale@15g%s@17g)",(const char*) _num); + { + if (_num != 0) + set_row (_i,"@8gTotale@15g%2d@17g)", _num); + } + else + if (_num != 0) + set_row (_i,"@8gTotale"); + + if (_num != 0) + { + set_row (_i,"@49g%r", &_tot_num_prg_d); + set_row (_i,"@65g%r", &_tot_num_prg_a); + set_row (_i,"@82g%r", &_tot_num_mov_d); + set_row (_i,"@98g%r", &_tot_num_mov_a); } - else - set_row (_i,"@8gTotale"); - set_row (_i,"@49g%r", &_tot_num_prg_d); - set_row (_i,"@65g%r", &_tot_num_prg_a); - set_row (_i,"@82g%r", &_tot_num_mov_d); - set_row (_i,"@98g%r", &_tot_num_mov_a); if (!_stampa_modulo) { @@ -2386,26 +2914,32 @@ void CG1600_application::stampa_totali_verifica() _tot_sez_saldo = 'A'; } else - _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_num_saldo); + _tot_sez_saldo = 'D'; + + if (_num != 0) + stampa_saldo_132(_tot_num_saldo); } else - { - stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); + { + if (_num != 0) + stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); //_tot_num_saldo_d = 0; //_tot_num_saldo_a = 0; } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); - TString numrom = itor(numeror); - set_row (_i,"@8gTotale@15g%s", (const char*) numrom); - set_row (_i,"@49g%r", &_tot_numr_prg_d); - set_row (_i,"@65g%r", &_tot_numr_prg_a); - set_row (_i,"@82g%r", &_tot_numr_mov_d); - set_row (_i,"@98g%r", &_tot_numr_mov_a); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@8gTotale@15g%s", (const char*) numrom); + set_row (_i,"@49g%r", &_tot_numr_prg_d); + set_row (_i,"@65g%r", &_tot_numr_prg_a); + set_row (_i,"@82g%r", &_tot_numr_mov_d); + set_row (_i,"@98g%r", &_tot_numr_mov_a); + } if (!_stampa_modulo) { @@ -2415,12 +2949,15 @@ void CG1600_application::stampa_totali_verifica() _tot_sez_saldo = 'A'; } else - _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_numr_saldo); + _tot_sez_saldo = 'D'; + + if (numrom != "") + stampa_saldo_132(_tot_numr_saldo); } else - { - stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a); + { + if (numrom != "") + stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a); // _tot_numr_saldo_d = 0; // _tot_numr_saldo_a = 0; } @@ -2440,19 +2977,25 @@ void CG1600_application::stampa_totali_verifica() } if ((_let_da_stamp!=_let_tot) || (_sez_da_stamp != _sez_tot)) { - if (_cont_gcs >= 2) + if (_cont_gcs != 0)//(_cont_gcs >= 2) { //Fai il totale del numero arabo e stampalo if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z')) - { - set_row (_i,"@8gTotale@15g%s@17g)",(const char*) _num); + { + if (_num != 0) + set_row (_i,"@8gTotale@15g%2d@17g)",_num); } else - set_row (_i,"@8gTotale"); - set_row (_i,"@49g%r", &_tot_num_prg_d); - set_row (_i,"@65g%r", &_tot_num_prg_a); - set_row (_i,"@82g%r", &_tot_num_mov_d); - set_row (_i,"@98g%r", &_tot_num_mov_a); + if (_num != 0) + set_row (_i,"@8gTotale"); + + if (_num != 0) + { + set_row (_i,"@49g%r", &_tot_num_prg_d); + set_row (_i,"@65g%r", &_tot_num_prg_a); + set_row (_i,"@82g%r", &_tot_num_mov_d); + set_row (_i,"@98g%r", &_tot_num_mov_a); + } if (!_stampa_modulo) { @@ -2462,26 +3005,32 @@ void CG1600_application::stampa_totali_verifica() _tot_sez_saldo = 'A'; } else - _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_num_saldo); + _tot_sez_saldo = 'D'; + + if (_num != 0) + stampa_saldo_132(_tot_num_saldo); } else - { - stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); + { + if (_num != 0) + stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a); // _tot_num_saldo_d = 0; // _tot_num_saldo_a = 0; } } - if (_cont_num >= 2) + if (_cont_num != 0)//(_cont_num >= 2) { //Fai il totale del numero romano e stampalo int numeror = atoi(_numr); TString numrom = itor(numeror); - set_row (_i,"@8gTotale@15g%s", (const char*) numrom); - set_row (_i,"@49g%r", &_tot_numr_prg_d); - set_row (_i,"@65g%r", &_tot_numr_prg_a); - set_row (_i,"@82g%r", &_tot_numr_mov_d); - set_row (_i,"@98g%r", &_tot_numr_mov_a); + if (numrom != "") + { + set_row (_i,"@8gTotale@15g%s", (const char*) numrom); + set_row (_i,"@49g%r", &_tot_numr_prg_d); + set_row (_i,"@65g%r", &_tot_numr_prg_a); + set_row (_i,"@82g%r", &_tot_numr_mov_d); + set_row (_i,"@98g%r", &_tot_numr_mov_a); + } if (!_stampa_modulo) { @@ -2492,23 +3041,41 @@ void CG1600_application::stampa_totali_verifica() } else _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_numr_saldo); + + if (numrom != "") + stampa_saldo_132(_tot_numr_saldo); } else - { - stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a); + { + if (numrom != "") + stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a); // _tot_numr_saldo_d = 0; // _tot_numr_saldo_a = 0; } } - if (_cont_numr >= 2) + if (_cont_numr != 0)//(_cont_numr >= 2) { - //Fai il totale della lettera e stampalo - set_row (_i,"@8gTotale@15g%c@16g)", _let); - set_row (_i,"@49g%r", &_tot_let_prg_d); - set_row (_i,"@65g%r", &_tot_let_prg_a); - set_row (_i,"@82g%r", &_tot_let_mov_d); - set_row (_i,"@98g%r", &_tot_let_mov_a); + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@8gTotale@15g%c@16g)", _let); + set_row (_i,"@49g%r", &_tot_let_prg_d); + set_row (_i,"@65g%r", &_tot_let_prg_a); + set_row (_i,"@82g%r", &_tot_let_mov_d); + set_row (_i,"@98g%r", &_tot_let_mov_a); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@8gTotale@15g%c@16g)", _let); + set_row (_i,"@49g%r", &_tot_let_prg_d); + set_row (_i,"@65g%r", &_tot_let_prg_a); + set_row (_i,"@82g%r", &_tot_let_mov_d); + set_row (_i,"@98g%r", &_tot_let_mov_a); + } + } if (!_stampa_modulo) { @@ -2519,11 +3086,21 @@ void CG1600_application::stampa_totali_verifica() } else _tot_sez_saldo = 'D'; - stampa_saldo_132(_tot_let_saldo); + + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + stampa_saldo_132(_tot_let_saldo); + else + if (_sez_stamp != '9') + stampa_saldo_132(_tot_let_saldo); } else - { - stampa_saldo_198(_tot_let_saldo_d,_tot_let_saldo_a); + { + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + stampa_saldo_198(_tot_let_saldo_d,_tot_let_saldo_a); + else + stampa_saldo_198(_tot_let_saldo_d,_tot_let_saldo_a); // _tot_let_saldo_d = 0; // _tot_let_saldo_a = 0; } @@ -2587,6 +3164,13 @@ print_action CG1600_application::postprocess_page(int file, int counter) setta_righe("CONTI D' ORDINE"); _reset_righe_stampa = FALSE; } + } + else + { + reset_print(); + _i = 1; + setta_righe("CONTI D' ORDINE"); + _reset_righe_stampa = FALSE; } } if (_sez_da_stamp == '9') @@ -2600,7 +3184,14 @@ print_action CG1600_application::postprocess_page(int file, int counter) setta_righe("CONTO ECONOMICO"); _reset_righe_stampa = FALSE; } - } + } + else + { + reset_print(); + _i = 1; + setta_righe("CONTO ECONOMICO"); + _reset_righe_stampa = FALSE; + } } } @@ -2642,7 +3233,8 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) int g,c; long s; bool fai = TRUE; - + TString saldostr,saldo_rafstr; + if (!counter) { reset_print(); @@ -2699,7 +3291,7 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) if (_buff == NULL) { - if (_annoeserafr == 0) + if (_annoeserafr == 0 && _databilrafr == botime) stampa_totali(); else stampa_totali_con_raffronto(); @@ -2735,7 +3327,7 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) if (counter) { if (fai) - if (_annoeserafr == 0) + if (_annoeserafr == 0 && _databilrafr == botime) stampa_totali(); else stampa_totali_con_raffronto(); @@ -2749,12 +3341,12 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) return FALSE; _sale = bil->saldo; - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) _salerafr = bil->saldorafr; if (_stampamov) { - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) { if ((_sale.is_zero()) && (_salerafr.is_zero())) return FALSE; @@ -2779,12 +3371,12 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) } _sale = bil->saldo; - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) _salerafr = bil->saldorafr; if (_stampamov) { - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) { if ((_sale.is_zero()) && (_salerafr.is_zero())) return FALSE; @@ -2797,14 +3389,17 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) } } + saldostr = _sale.string(); + saldo_rafstr = _salerafr.string(); + if ((g != 0) && (c != 0) && (s != 0)) { - if (_sez_da_stamp == '5') - if (_sale < ZERO) - _sale = -_sale; + // if (_sez_da_stamp == '5') + // if (_sale < ZERO) + // _sale = -_sale; if (_sez_da_stamp == '9') - if (_sale> ZERO) + // if (_sale> ZERO) _sale = -_sale; _totale_numero += _sale; @@ -2827,16 +3422,20 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) if (_sez_da_stamp == '5') _totale_ordine += _sale; - if (_sez_da_stamp == '9') - _totale_economico += _sale; - - if (_annoeserafr != 0) + if (_sez_da_stamp == '9') { - if (_sez_da_stamp == '5') - if (_salerafr < ZERO) - _salerafr = -_salerafr; + _totale_economico += _sale; + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + _totale_parziale += _sale; + } + + if (_annoeserafr != 0 || _databilrafr != botime) + { + //if (_sez_da_stamp == '5') + // if (_salerafr < ZERO) + // _salerafr = -_salerafr; if (_sez_da_stamp == '9') - if (_salerafr> ZERO) + //if (_salerafr> ZERO) _salerafr = -_salerafr; _totale_num_raf += _salerafr; @@ -2858,8 +3457,13 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) if (_sez_da_stamp == '5') _totale_ordine_raf += _salerafr; - if (_sez_da_stamp == '9') - _totale_economico_raf += _salerafr; + + if (_sez_da_stamp == '9') + { + _totale_economico_raf += _salerafr; + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + _totale_parziale_raf += _salerafr; + } } } return TRUE; @@ -3048,12 +3652,15 @@ bool CG1600_application::preprocess_stampa_verifica(int counter) _tot_numr_saldo += _sale; _tot_let_saldo += _sale; _tot_gen_saldo += _sale; + if (_sez_da_stamp == '9') + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + _tot_parz_sld += _sale; - if (_sld_prg_avere < ZERO) - _sld_prg_avere = -_sld_prg_avere; + //if (_sld_prg_avere < ZERO) + // _sld_prg_avere = -_sld_prg_avere; - if (_mov_avere < ZERO) - _mov_avere = -_mov_avere; + //if (_mov_avere < ZERO) + // _mov_avere = -_mov_avere; if (_sale < ZERO) { @@ -3065,6 +3672,9 @@ bool CG1600_application::preprocess_stampa_verifica(int counter) _tot_numr_saldo_a += _sale; _tot_let_saldo_a += _sale; _tot_gen_saldo_a += _sale; + if (_sez_da_stamp == '9') + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + _tot_parz_sld_a += _sale; } } else @@ -3076,6 +3686,10 @@ bool CG1600_application::preprocess_stampa_verifica(int counter) _tot_numr_saldo_d += _sale; _tot_let_saldo_d += _sale; _tot_gen_saldo_d += _sale; + if (_sez_da_stamp == '9') + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + _tot_parz_sld_d += _sale; + } } @@ -3095,6 +3709,14 @@ bool CG1600_application::preprocess_stampa_verifica(int counter) _tot_numr_mov_a += _mov_avere; _tot_let_mov_a += _mov_avere; _tot_gen_mov_a += _mov_avere; + if (_sez_da_stamp == '9') + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + { + _tot_parz_prg_d += _sld_prg_dare; + _tot_parz_prg_a += _sld_prg_avere; + _tot_parz_mov_d += _mov_dare; + _tot_parz_mov_a += _mov_avere; + } } return TRUE; } @@ -3137,7 +3759,7 @@ void CG1600_application::setta_righe(const char * titolo) int numeror, numero, gruppo, conto; char sezione,lettera; long sottoc; - TString numrom,numr,num; + TString numrom,numr; TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe; bool stampa_classe = TRUE; @@ -3148,7 +3770,7 @@ void CG1600_application::setta_righe(const char * titolo) numeror = atoi(bil->numr); numrom = itor(numeror); numero = atoi(bil->num); - num = bil->num; +// num = bil->num; gruppo = atoi(bil->gruppo); conto = atoi(bil->conto); sottoc = atoi(bil->sottoc); @@ -3178,13 +3800,13 @@ void CG1600_application::setta_righe(const char * titolo) } else if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z')) - { - char app = ' '; - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gATTIVITA'"); - set_row (_i++,"@0g%c", app); - } - + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gATTIVO"); + set_row (_i++,"@0g%c", app); + } + if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) { char app = ' '; @@ -3198,10 +3820,10 @@ void CG1600_application::setta_righe(const char * titolo) { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gPASSIVITA'"); + set_row (_i++,"@0gPASSIVO"); set_row(_i++,"@0g%c", app); } - + if (stampa_classe) { if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9')) @@ -3221,7 +3843,7 @@ void CG1600_application::setta_righe(const char * titolo) set_row(_i,"@3g%8s", (const char*) numrom); set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); } - if (num != "") + if (numero != 0) { set_row(_i,"@13g%s", bil->num); set_row(_i++,"@15g)@18g%s", (const char*) descr_num); @@ -3254,13 +3876,17 @@ void CG1600_application::setta_righe(const char * titolo) { set_row(_i,"@0g%c", bil->let); set_row(_i++,"@1g)@3g%s", (const char*) descr_let); - _cont_let += 1; + //_cont_let += 1; + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 0; + if (numrom != "") { set_row(_i,"@3g%8s", (const char*) numrom); set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); } - if (num != "") + if (numero != 0) { set_row(_i,"@13g%s", bil->num); set_row(_i++,"@15g)@18g%s", (const char*) descr_num); @@ -3275,8 +3901,12 @@ void CG1600_application::setta_righe(const char * titolo) { set_row(_i,"@3g%8s", (const char*) numrom); set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); - _cont_numr += 1; - if (num != "") + //_cont_numr += 1; + //_cont_numr = 1; + _cont_num = 1; + _cont_gcs = 0; + + if (numero != 0) { set_row(_i,"@13g%s", bil->num); set_row(_i++,"@15g)@18g%s", (const char*) descr_num); @@ -3290,7 +3920,8 @@ void CG1600_application::setta_righe(const char * titolo) { set_row(_i,"@13g%s", bil->num); set_row(_i++,"@15g)@18g%s", (const char*) descr_num); - _cont_num += 1; + //_cont_num += 1; + _cont_gcs = 0; } } if (bil->gruppo[0] != 'A') @@ -3303,25 +3934,25 @@ void CG1600_application::setta_righe(const char * titolo) set_row (_i,"@26g%s", bil->sottoc); set_row (_i,"@33g%s", (const char*) descr_sottoc); set_row (_i,"@86g%r", &_sale); - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) set_row (_i,"@112g%r", &_salerafr); _i++; } else { - if ((sezione != ' ')&&(lettera == ' ')&&(numrom == "")&&(num == "")) + if ((sezione != ' ')&&(lettera == ' ')&&(numrom == "")&&(numero == 0)) descr_classe = _descr_sez; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom == "")&&(num == "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom == "")&&(numero == 0)) descr_classe = descr_let; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(num == "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(numero == 0)) descr_classe = descr_numr; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(num != "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(numero != 0)) descr_classe = descr_num; if (descr_classe != descr_sottoc) { set_row (_i,"@33g%s", (const char*) descr_sottoc); set_row (_i,"@86g%r", &_sale); - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) set_row (_i,"@112g%r", &_salerafr); _i++; } @@ -3335,7 +3966,7 @@ void CG1600_application::setta_righe_verifica() int numeror, numero, gruppo, conto; char sezione,lettera,tmcf; long sottoc; - TString numrom,numr,num; + TString numrom,numr; TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe; sezione = bil->sez; @@ -3344,7 +3975,7 @@ void CG1600_application::setta_righe_verifica() numeror = atoi(bil->numr); numrom = itor(numeror); numero = atoi(bil->num); - num = bil->num; +// num = bil->num; gruppo = atoi(bil->gruppo); conto = atoi(bil->conto); sottoc = atoi(bil->sottoc); @@ -3354,7 +3985,7 @@ void CG1600_application::setta_righe_verifica() descr_numr = descrizione_numeroromano(sezione,lettera,numeror); descr_num = descrizione_numero(sezione,lettera,numeror,numero); if ((tmcf == 'C') || (tmcf == 'F')) - descr_sottoc = descr_sottoc_clifo(tmcf,gruppo,conto,sottoc); + descr_sottoc = descr_sottoc_clifo(tmcf,sottoc); else descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc); @@ -3387,7 +4018,7 @@ void CG1600_application::setta_righe_verifica() set_row(_i,"@8g)@10g%s", (const char*) descr_numr); set_row (_i++,"@48g!@81g!@114g!"); } - if (num != " 0") + if (numero != 0) { set_row(_i,"@0g%s", bil->num); set_row(_i,"@2g)@4g%s", (const char*) descr_num); @@ -3409,14 +4040,18 @@ void CG1600_application::setta_righe_verifica() set_row(_i,"@0g%c", bil->let); set_row(_i,"@1g)@3g%s", (const char*) descr_let); set_row (_i++,"@48g!@81g!@114g!"); - _cont_let += 1; + //_cont_let += 1; + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 0; + if (numrom != "") { set_row(_i,"@0g%8s", (const char*) numrom); set_row(_i,"@8g)@10g%s", (const char*) descr_numr); set_row (_i++,"@48g!@81g!@114g!"); } - if (num != " 0") + if (numero != 0) { set_row(_i,"@0g%s", bil->num); set_row(_i,"@2g)@4g%s", (const char*) descr_num); @@ -3438,8 +4073,12 @@ void CG1600_application::setta_righe_verifica() set_row(_i,"@0g%8s", (const char*) numrom); set_row(_i,"@8g)@10g%s", (const char*) descr_numr); set_row (_i++,"@48g!@81g!@114g!"); - _cont_numr += 1; - if (num != " 0") + //_cont_numr += 1; + //_cont_numr = 1; + _cont_num = 1; + _cont_gcs = 0; + + if (numero != 0) { set_row(_i,"@0g%s", bil->num); set_row(_i,"@2g)@4g%s", (const char*) descr_num); @@ -3462,6 +4101,7 @@ void CG1600_application::setta_righe_verifica() set_row(_i,"@2g)@4g%s", (const char*) descr_num); set_row (_i++,"@48g!@81g!@114g!"); _cont_num += 1; + _cont_gcs = 0; } } } @@ -3501,13 +4141,13 @@ void CG1600_application::setta_righe_verifica() } else { - if ((sezione != ' ')&&(lettera == ' ')&&(numrom == "")&&(num == "")) + if ((sezione != ' ')&&(lettera == ' ')&&(numrom == "")&&(numero == 0)) descr_classe = _descr_sez; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom == "")&&(num == "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom == "")&&(numero == 0)) descr_classe = descr_let; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(num == "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(numero == 0)) descr_classe = descr_numr; - if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(num != "")) + if ((sezione != ' ')&&(lettera != ' ')&&(numrom != "")&&(numero != 0)) descr_classe = descr_num; if (descr_classe != descr_sottoc) { @@ -3541,49 +4181,6 @@ void CG1600_application::setta_righe_verifica() } } -TDate CG1600_application::data_inferiore() -{ - TDate data; - TDate data_ini_ese_prec,data_fine_ese_prec,data_ini_ese,data_fine_ese; - long annoese,annoeseprec; - - annoese = _msk->get_long(F_ANNOESE); - annoeseprec = annoese - 1; - - _anni_es.aggiungi_anno(annoese, data_ini_ese, data_fine_ese); - _anni_es.aggiungi_anno(annoeseprec, data_ini_ese_prec, data_fine_ese_prec); - - if ((_datalimite>=data_ini_ese_prec)&&(_datalimite<=data_fine_ese_prec)) - data = data_ini_ese_prec; - if ((_datalimite>=data_ini_ese)&&(_datalimite<=data_fine_ese)) - data = data_ini_ese; - _data_ini_ese = data_ini_ese; - return (data); -} - -TDate CG1600_application::data_inferiore_raf() -{ - TDate data; - TDate data_ini_raf_prec,data_fine_raf_prec,data_ini_raf,data_fine_raf; - long annoese,annoeseprec; - - annoese = _msk->get_long(F_ANNORAFFR); - annoeseprec = annoese - 1; - - _anni_es.aggiungi_anno(annoese, data_ini_raf, data_fine_raf); - _anni_es.aggiungi_anno(annoeseprec, data_ini_raf_prec, data_fine_raf_prec); - - _data_fine_raf = data_fine_raf; - _data_fine_raf_prec = data_fine_raf_prec; - - if ((_databilrafr>=data_ini_raf_prec)&&(_databilrafr<=data_fine_raf_prec)) - data = data_ini_raf_prec; - if ((_databilrafr>=data_ini_raf)&&(_databilrafr<=data_fine_raf)) - data = data_ini_raf; - - return (data); -} - const char* CG1600_application::descrizione_sezione(char sezione) { TTable tabivd(TAB_IVD); @@ -3623,8 +4220,12 @@ const char* CG1600_application::descrizione_numeroromano(char sezione, char lett TTable tabivd(TAB_IVD); TString dep, dep2; - tabivd.zero(); - dep = format("%1c%1c%04d", sezione, lettera, numr); + tabivd.zero(); + if (numr != 0) + dep = format("%1c%1c%04d", sezione, lettera, numr); + else + dep = format("%c%c ", sezione, lettera); + tabivd.put("CODTAB", dep); tabivd.read(); dep2 = tabivd.get("CODTAB"); @@ -3638,15 +4239,20 @@ const char* CG1600_application::descrizione_numeroromano(char sezione, char lett const char* CG1600_application::descrizione_numero(char sezione, char lettera, int numr, int numero) { TTable tabivd(TAB_IVD); - TString dep; + TString dep,dep2; - tabivd.zero(); - dep = format("%1c%1c%04d%02d",sezione, lettera, numr, numero); + tabivd.zero(); + if (numr != 0) + dep = format("%1c%1c%4d%02d",sezione, lettera, numr, numero); + else + dep = format("%c%c %02d",sezione,lettera,numero); tabivd.put("CODTAB", dep); - tabivd.read(); - if (tabivd.bad()) - tabivd.zero(); - tmp = tabivd.get("S0"); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; return (__tmp); } @@ -3667,15 +4273,12 @@ const char* CG1600_application::descrizione_sottoconto(int gruppo, int conto, lo return (__tmp); } -const char* CG1600_application::descr_sottoc_clifo(char tipocf,int g,int c,long s) +const char* CG1600_application::descr_sottoc_clifo(char tipocf,long s) { TLocalisamfile clifo (LF_CLIFO); clifo.zero(); clifo.put(CLI_TIPOCF,tipocf); - clifo.put(CLI_GRUPPO , g); - if (c != 0) - clifo.put(CLI_CONTO , c ); if (s != 0) clifo.put(CLI_CODCF, s); clifo.read(); @@ -3770,7 +4373,7 @@ void CG1600_application::crea_intestazione() set_header (2,"@131gData@136g%s",(const char*) datastampastr); else set_header (2,"@105gData@110g%s",(const char*) datastampastr); - + if (_tipo_bilancio == 1) { intesta_scalare(); @@ -3831,10 +4434,8 @@ void CG1600_application::intesta_scalare() TString sep(132); set_header (3,"@0gSTAMPA BILANCIO CONFORME ALLA IV DIRETTIVA"); - if (_competenza) - set_header (3,"@48g(con controllo competenza)"); set_header (3,"@89gEsercizio@99g%d", _annoese); - if (_annoeserafr != 0) + if (_annoeserafr != 0 || _databilrafr != botime) { set_header (3,"@115gEsercizio@125g%d", _annoeserafr); databilrafrstr = _databilrafr.string(); @@ -3857,8 +4458,6 @@ void CG1600_application::intesta_verifica() TString sep(132),sep1(147); set_header (3,"@0gBILANCIO DI VERIFICA IV DIRETTIVA"); - if (_competenza) - set_header (3,"@87g(con controllo competenza)"); if (_tipo_stampa == 1) { TString datainistr = _dataini.string(); @@ -3867,7 +4466,7 @@ void CG1600_application::intesta_verifica() set_header (3,"@65galla data@75g%s", (const char*) datafinestr); } else if (_tipo_stampa == 2) - set_header (3,"@42gall' ultima immissione esercizio in corso"); + set_header (3,"@42gall' ultima immissione"); if (_stampa_modulo) { diff --git a/cg/cg3400.cpp b/cg/cg3400.cpp index 08d351a3b..7571e275a 100755 --- a/cg/cg3400.cpp +++ b/cg/cg3400.cpp @@ -28,10 +28,10 @@ #include "cg3400a.h" #include "cg3400b.h" -#define REAL_PICTURE "###.###.###.###" - -HIDDEN const int RIGHE_MODULO = 66; -HIDDEN const int RIGHE_FOOTER = 10; +HIDDEN const char* REAL_PICTURE = "###.###.###.###"; +HIDDEN const char* REAL_TOT_PIC = "##.###.###.###.###.###"; +HIDDEN const int RIGHE_MODULO = 66; +HIDDEN const int RIGHE_FOOTER = 10; HIDDEN TString256 tmp; @@ -42,7 +42,8 @@ HIDDEN enum descr { causale, conto, operazione }; class CG3400_application : public TPrintapp { static bool mask_a_cod_reg (TMask_field& f, KEY k); - static bool mask_a_data (TMask_field& f, KEY k); + static bool data_a_hndl (TMask_field& f, KEY k); + static bool data_da_hndl (TMask_field& f, KEY k); static bool mask_b_ripristina(TMask_field& f, KEY k); public: @@ -55,9 +56,11 @@ public: TString80 _reg_descr; TDate _data_da, _data_a, _last_data; real _tot_dare, _tot_avere; // valori di partenza - real _tot_dare_progr, _tot_avere_progr; // progressivi + real _tot_dare_progr, _tot_avere_progr; // progressivi anno in corso + real _tot_dare_progr_ap, _tot_avere_progr_ap; // progr. anno prec. real _tot_dare_gg , _tot_avere_gg ; // giornalieri - real _tot_dare_ac , _tot_avere_ac ; // anno precedente + real _tot_dare_ap , _tot_avere_ap ; // giornalieri anno precedente + real _tot_dare_generale, _tot_avere_generale; // tot. generali long _nprog_da, _nprog_mov; int _num_rig, _stampa_width, _stampa_len; @@ -106,9 +109,11 @@ public: void setta_righe_valuta(); void setta_righe_descr(TParagraph_string*, enum descr); void calcola_iva(); + void init_print(); virtual bool cancel_hook(); virtual bool set_print(int); + void init_totals(); int stampa_intestazione_ditta(); int set_header_132(); int set_header_198(); @@ -123,7 +128,7 @@ public: const char* get_descr_caus (const char * codcaus); TRectype& look_com (const char * cod); - CG3400_application() : _tot_dare_progr(ZERO),_tot_avere_progr (ZERO) {}; + CG3400_application() {}; virtual ~CG3400_application() {}; }; @@ -237,6 +242,7 @@ void CG3400_application::get_dati_ditta () void CG3400_application::user_create() { + _ae = 0; _tabreg = new TTable ("REG"); _tabval = new TTable ("%VAL"); _tabes = new TTable ("ESC"); @@ -252,7 +258,7 @@ void CG3400_application::user_create() _descr_operazione = new TParagraph_string ("",28); _descr_causale = new TParagraph_string ("",20); -// disable_print_menu(); + // disable_print_menu(); _rel = new TRelation (LF_MOV); _rel->add (LF_RMOV, "NUMREG=NUMREG"); @@ -331,31 +337,34 @@ void CG3400_application::scrivi_numgio(long nprog) // void CG3400_application::set_totali_giorno(const TDate& data, const int righeiva) { - int r = 1 + righeiva; - TString dep(_stampa_width); - - dep = "Operazioni del "; dep << data.string(); + int r = 1 + righeiva; + TString dep(_stampa_width); + TString16 frm; if (_stampa_width == 132) - set_row (r++, "@b@10g%s Dare: %r Avere: %r", (const char *)dep, &_tot_dare_gg, &_tot_avere_gg ); - else - set_row (r++, "@b@10g%s Dare: %r Avere: %r", (const char *)dep, &_tot_dare_gg, &_tot_avere_gg ); - - if ( _tot_avere_ac != ZERO || _tot_dare_ac != ZERO ) + frm = "@b@10g"; + + if (_tot_avere_gg != ZERO || _tot_dare_gg != ZERO) { - dep = "Operazioni del "; dep << data.string() << " " << "Anno precedente"; + dep = frm; + dep << "Operazioni del "; dep << data.string(); - if (_stampa_width == 132) - set_row (r++, "@b@10g%s Dare: %r Avere: %r", (const char *)dep, &_tot_dare_ac, &_tot_avere_ac ); - else - set_row (r++, "@b@10g%s Dare: %r Avere: %r", (const char *)dep, &_tot_dare_ac, &_tot_avere_ac ); + set_row (r++, "%s Dare: %r Avere: %r", (const char *)dep, + &_tot_dare_gg, &_tot_avere_gg ); + _tot_dare_gg = _tot_avere_gg = ZERO; + } - _tot_avere_ac = _tot_dare_ac = ZERO; + if ( _tot_avere_ap != ZERO || _tot_dare_ap != ZERO ) + { + dep = frm; + dep << "Operazioni del "; dep << data.string() << " " << "Anno precedente"; - set_row (r, ""); + set_row (r++, "%s Dare: %r Avere: %r", (const char *)dep, &_tot_dare_ap, + &_tot_avere_ap ); + _tot_avere_ap = _tot_dare_ap = ZERO; } - else - set_row (r, ""); // Lascio una riga vuota dopo il totale + + set_row (r, ""); // Lascio una riga vuota dopo il totale } // -------------------------------------------------------------------------- @@ -371,23 +380,24 @@ void CG3400_application::set_page_132 (int file, int counter) case LF_MOV: if (_libro_giornale_iva_unico) { - if (_stampa_definitiva) - set_row(r,"Registrazione n. #-3ld del @d documento n. @3n del @d @s Anno di competenza %04d", - &_nprog_mov, - FLD(LF_MOV, MOV_DATAREG), - FLD(LF_MOV, MOV_NUMDOC), - FLD(LF_MOV, MOV_DATADOC), - FLD(LF_MOV, MOV_DESCR), - _ae); + if (_stampa_definitiva) + { + set_row(r,"Operazione n. #-3ld", &_nprog_mov); + set_row(r," del @d", FLD(LF_MOV, MOV_DATAREG) ); + set_row(r," documento n. @3pn", FLD(LF_MOV, MOV_NUMDOC, "###") ); + set_row(r," del @d @s", FLD(LF_MOV, MOV_DATADOC), + FLD(LF_MOV, MOV_DESCR)); + set_row(r," Anno di competenza @4pn", FLD(LF_MOV, MOV_ANNOES, "@@@@") ); + } else - set_row(r,"Registrazione n. @3,lpn del @d documento n. @7s del @d @s Anno di competenza %04d", - FLD(LF_MOV, MOV_NUMREG, "#######"), - FLD(LF_MOV, MOV_DATAREG), - FLD(LF_MOV, MOV_NUMDOC), - FLD(LF_MOV, MOV_DATADOC), - FLD(LF_MOV, MOV_DESCR), - _ae); - + { + set_row(r,"Operazione n. @3,lpn", FLD(LF_MOV, MOV_NUMREG, "###")); + set_row(r," del @d", FLD(LF_MOV, MOV_DATAREG) ); + set_row(r," documento n. @3pn", FLD(LF_MOV, MOV_NUMDOC, "###") ); + set_row(r," del @d @s", FLD(LF_MOV, MOV_DATADOC), + FLD(LF_MOV, MOV_DESCR)); + set_row(r," Anno di competenza @4pn", FLD(LF_MOV, MOV_ANNOES, "@@@@") ); + } } else if (!_gia_settata_riga_mov) @@ -404,12 +414,10 @@ void CG3400_application::set_page_132 (int file, int counter) if (!_stampa_definitiva) set_row (r, "%3d", _num_rig); - set_row (r, "@5g@3s@56g@pn@pn@pn", - FLD(LF_MOV, MOV_CODCAUS), - FLD(LF_RMOV, RMV_GRUPPO, "@@."), - FLD(LF_RMOV, RMV_CONTO , "@@."), - FLD(LF_RMOV, RMV_SOTTOCONTO, "@@@@@@") - ); + // set_row (r, "@5g@3s", FLD(LF_MOV, MOV_CODCAUS)); + set_row (r, "@56g@pn", FLD(LF_RMOV, RMV_GRUPPO, "@@.")); + set_row (r, "@pn", FLD(LF_RMOV, RMV_CONTO , "@@.")); + set_row (r, "@pn", FLD(LF_RMOV, RMV_SOTTOCONTO, "@@@@@@")); } else // no libro_giornale_iva_unico { @@ -425,8 +433,7 @@ void CG3400_application::set_page_132 (int file, int counter) ); } break; - case LF_RMOVIVA: - break; + default: break; } @@ -516,24 +523,72 @@ void CG3400_application::postclose_print() void CG3400_application::preprocess_footer() { - TString16 dare = _tot_dare_progr.string("###.###.###.###"); - TString16 avere = _tot_avere_progr.string("###.###.###.###"); - int r=2; + TString progr_dare_ap(22), progr_avere_ap(22); + TString256 riga, frm; + bool ap = FALSE; + int r=2; + if (_tot_avere_progr_ap != ZERO || _tot_dare_progr_ap != ZERO) + { + progr_dare_ap = _tot_dare_progr_ap.string(REAL_TOT_PIC); + progr_avere_ap = _tot_avere_progr_ap.string(REAL_TOT_PIC); + ap = TRUE; + } + if (_stampa_width == 132) - set_footer (r, "@b@u@65gTotale progressivi generali@r @bDare: %s Avere: %s", - (const char *) dare, - (const char *) avere); + frm = "@b@45g"; else - set_footer (r, "@b@100gTotale progressivi generali Totale dare %s Totale avere %s", - (const char *) dare, - (const char *) avere); + frm = "@b@100g"; + + if (_cur->pos() >= _cur->items()-1) // se sono sull'ultimo + { + const TFixed_string progr_dare ( _tot_dare_progr.string(REAL_TOT_PIC)); + const TFixed_string progr_avere ( _tot_avere_progr.string(REAL_TOT_PIC)); + + riga = frm; + riga << format("Totale progressivi Dare: %s Avere: %s", + (const char *) progr_dare, (const char *) progr_avere); + + set_footer (r++, (const char*) riga); + + if (ap) + { + // riga = frm; + riga.format("%sTotale progressivi anno precedente Dare: %s Avere: %s", + (const char*) frm, + (const char *) progr_dare_ap, (const char *) progr_avere_ap); + set_footer (r++, (const char*) riga); + } + + _tot_dare_generale = _tot_dare_progr + _tot_dare_progr_ap; + _tot_avere_generale = _tot_avere_progr + _tot_avere_progr_ap; + const TFixed_string dts(_tot_dare_generale.string(REAL_TOT_PIC)); + const TFixed_string ats(_tot_avere_generale.string(REAL_TOT_PIC)); + + riga = frm; + riga << format ("Totale progressivi generali Dare: %s Avere: %s", (const char *) dts, (const char *) ats); + set_footer (r++, (const char*) riga); + } +else // Non ancora totale generale +{ + real dt = _tot_dare_progr + _tot_dare_progr_ap; + real at = _tot_avere_progr + _tot_avere_progr_ap; + const TFixed_string dts(dt.string(REAL_TOT_PIC)); + const TFixed_string ats(at.string(REAL_TOT_PIC)); + riga = frm; + riga << format ("A riportare Dare: %s Avere: %s@r", (const char *) dts, + (const char *) ats); + set_footer (r++, (const char*) riga); +} } int CG3400_application::stampa_intestazione_ditta() { int r=1; +#if XVT_OS == XVT_OS_SCOUNIX + TString riga(_stampa_width); +#endif get_dati_ditta(); @@ -557,6 +612,9 @@ int CG3400_application::stampa_intestazione_ditta() return r; } +//////////////////////////////////////////////////////////////////// +// HEADER 198 +//////////////////////////////////////////////////////////////////// int CG3400_application::set_header_198() { int r=1; @@ -566,9 +624,9 @@ int CG3400_application::set_header_198() if (_stampa_intesta) r = stampa_intestazione_ditta(); - set_header(r, "@iCodice libro: %s %s @40gdalla data: %s alla data: %s", + set_header(r, "@bCodice libro:@r %s %s @bdalla data:@r %s @balla data:@r %s @bEsercizio:@r %04d", (const char *) _reg_cod, (const char *) _reg_descr, - (const char *) data_da, (const char *) data_a); + (const char *) data_da, (const char *) data_a, _ae); r++; riga.fill('-'); @@ -629,13 +687,13 @@ int CG3400_application::set_header_132() set_header(r, riga); #endif - set_header(r++, "@bCodice libro:@r %s %s @50g@bdalla data:@r %s @balla data:@r %s", + set_header(r++, "@bCodice libro:@r %s %s @50g@bdalla data:@r %s @balla data:@r %s @bEsercizio:@r %04d", (const char *) _reg_cod, (const char *) _reg_descr, - (const char *) data_da, (const char *) data_a); + (const char *) data_da, (const char *) data_a, _ae); -//////////////////////////////////////////////////////////////////// -// LIBRO GIORNALE IVA UNICO -//////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // LIBRO GIORNALE IVA UNICO + //////////////////////////////////////////////////////////////////// if (_libro_giornale_iva_unico) { set_header(r, "Ri"); @@ -653,9 +711,9 @@ int CG3400_application::set_header_132() r++; } else -//////////////////////////////////////////////////////////////////// -// NO LIBRO GIORNALE IVA UNICO -//////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // NO LIBRO GIORNALE IVA UNICO + //////////////////////////////////////////////////////////////////// { set_header(r, "Numero@12gDocumento@28gCodice@115gImporti@127g A S"); r++; @@ -678,23 +736,31 @@ int CG3400_application::set_header_132() void CG3400_application::preprocess_header() { - int pag = printer().getcurrentpage(); - TString dare = _tot_dare_progr.string(REAL_PICTURE); - TString avere = _tot_avere_progr.string(REAL_PICTURE); - int r = _last_header + 1; + int r = _last_header + 1; + int pag = printer().getcurrentpage(); + TString16 frm; + real riporto_dare, riporto_avere; if (pag > 0) // Stampa riporti { - dare.right_just(); - avere.right_just(); + riporto_dare = _tot_dare_progr + _tot_dare_progr_ap; + riporto_avere = _tot_avere_progr + _tot_avere_progr_ap; + + TString dare(riporto_dare.string(REAL_TOT_PIC)); + TString avere(riporto_avere.string(REAL_TOT_PIC)); + if (_stampa_width == 132) - _riporto.format ("@b@86gRiporto: %15s %15s", - (const char *) dare, - (const char *) avere ); + frm = "@b@78g"; else - _riporto.format ("@b@100gRiporto %s @140g %s", (const char *) dare, - (const char *) avere ); + frm = "@b@100g"; + + _riporto = frm; + + _riporto << format ("Riporto: %15s %15s", (const char *) dare, + (const char *) avere ); + set_header (r++, "%s", (const char *) _riporto); + set_header (r, ""); } } @@ -724,14 +790,8 @@ bool CG3400_application::preprocess_print(int file, int counter) case LF_MOV: _gia_settata_riga_mov = FALSE; // Stampa o no la riga di mov (solo se - // NO stampa giornale_iva_unico - _num_rig = 1; - _tot_dare_ac = ZERO; - _tot_avere_ac = ZERO; - _tot_dare_gg = ZERO; - _tot_avere_gg = ZERO; - _tot_dare_progr = _tot_dare; - _tot_avere_progr = _tot_avere; + // NO stampa giornale_iva_unico + _num_rig = 1; _iva_array.destroy(); if (_cur->items() == 0) @@ -796,17 +856,12 @@ print_action CG3400_application::postprocess_page(int file, int counter) --(*_cur); _cur->restore_status(); -// if (_data_corr != _data_succ || _cur->lastrec()) + // if (_data_corr != _data_succ || _cur->lastrec()) if (_data_corr != _data_succ || _cur->pos() == _cur->items()) { nuovo_mese = (_mese_succ != _mese_corr); - set_totali_giorno(_data_corr, righe_iva_settate); - - _tot_dare_gg = _tot_avere_gg = ZERO; - _gia_settata_riga_mov = FALSE; - return REPEAT_PAGE; } else @@ -814,7 +869,7 @@ print_action CG3400_application::postprocess_page(int file, int counter) if (righe_iva_settate > 0) return REPEAT_PAGE; - + break; case LF_RMOVIVA: @@ -839,19 +894,22 @@ bool CG3400_application::preprocess_page(int file, int counter) int g, c; long s; bool gia_stampato=FALSE; + static bool settata_causale=FALSE; TString80 rmv_descr; char sezione; real importo; TString16 frm; TConto tc; - + if (counter) return TRUE; switch (file) { - + case LF_MOV: _num_rig=1; + settata_causale = FALSE; + _iva_array.destroy(); if (!_cur->is_first_match(LF_RMOV)) return FALSE; @@ -911,25 +969,37 @@ bool CG3400_application::preprocess_page(int file, int counter) _descr_conto->set_width(198); } - *_descr_causale = get_descr_caus(_caus); *_descr_operazione = (const char *)rmv_descr; *_descr_conto = tc.descrizione(); - - setta_righe_descr (_descr_causale, causale); + + // Il codice e descrizione della causale vanno solo sulla prima riga + if (!settata_causale) + { + set_row (1, "@5g%3s", (const char*) _caus ); + *_descr_causale = get_descr_caus(_caus); + setta_righe_descr (_descr_causale, causale); + settata_causale = TRUE; + } + setta_righe_descr (_descr_operazione, operazione); setta_righe_descr (_descr_conto, conto); if (cf > ' ') if (_libro_cronologico) setta_righe_indirizzo(cf, s); - + if (sezione == 'D') { - _tot_dare_progr += importo; // prog. generali if (_annoEsMov != _ae) - _tot_dare_ac += importo; // prog. anno precedente + { + _tot_dare_ap += importo; // prog. anno precedente + _tot_dare_progr_ap += importo; + } else + { _tot_dare_gg += importo; // prog. giornalieri + _tot_dare_progr += importo; // prog. generali + } if (_stampa_width == 132) frm = "@95g%r"; @@ -937,13 +1007,17 @@ bool CG3400_application::preprocess_page(int file, int counter) frm = "@142g%r"; } else - { - _tot_avere_progr += importo; - + { if (_annoEsMov != _ae) - _tot_avere_ac += importo; + { + _tot_avere_ap += importo; + _tot_avere_progr_ap += importo; + } else + { _tot_avere_gg += importo; + _tot_avere_progr += importo; + } if (_stampa_width == 132) frm = "@112g%r"; @@ -1040,14 +1114,14 @@ int CG3400_application::setta_righe_iva() { case 0 : set_row(r, "@73gDetraibile"); break; - case 1 : set_row(r, "@73gIndetraibile su op.es."); + case 1 : set_row(r, "@73gIndetraibile su op.es."); break; - case 3 : set_row(r, "@73gPassaggi interni"); + case 3 : set_row(r, "@73gPassaggi interni"); break; - case 9 : set_row(r, "@73gIndetraibile art.19"); + case 9 : set_row(r, "@73gIndetraibile art.19"); break; - default: break; - } + default: break; + } } _iva_array.destroy(); set_row (j+1, ""); // lascio una riga vuota dopo tutto cio' @@ -1094,40 +1168,40 @@ void CG3400_application::setta_righe_indirizzo(char tipocf, long codcf) capcf = occ.get (OCC_CAP); comcf = occ.get (OCC_COM); } - else - { - _clifo->zero(); - _clifo->put(CLI_CODCF, codcf); - _clifo->put(CLI_TIPOCF, tipocf); +else +{ + _clifo->zero(); + _clifo->put(CLI_CODCF, codcf); + _clifo->put(CLI_TIPOCF, tipocf); - if (_clifo->read() == NOERR) - { - viacf = _clifo->get(CLI_INDCF); - civcf = _clifo->get(CLI_CIVCF); - comcf = _clifo->get(CLI_COMCF); - capcf = _clifo->get(CLI_CAPCF); - statocf = _clifo->get(CLI_STATOCF); - } - } - - TRectype dep = look_com (comcf); - comune = dep.get(COM_DENCOM); - prov = dep.get(COM_PROVCOM); - - if (_libro_giornale_iva_unico) + if (_clifo->read() == NOERR) { - set_row (2, "@69g%s %s", (const char *)viacf, (const char *)civcf); - set_row (3, "@69g%s %s %s", (const char *)capcf, (const char *)comune, - (const char *)prov); - } - else // no libro iva unico. Cambia la colonna di inizio - { - set_row (2, "@26g%s %s", (const char *)viacf, (const char *)civcf); - set_row (3, "@26g%s %s %s", (const char *)capcf, (const char *)comune, - (const char *)prov); + viacf = _clifo->get(CLI_INDCF); + civcf = _clifo->get(CLI_CIVCF); + comcf = _clifo->get(CLI_COMCF); + capcf = _clifo->get(CLI_CAPCF); + statocf = _clifo->get(CLI_STATOCF); } } +TRectype dep = look_com (comcf); +comune = dep.get(COM_DENCOM); +prov = dep.get(COM_PROVCOM); + +if (_libro_giornale_iva_unico) +{ + set_row (2, "@69g%s %s", (const char *)viacf, (const char *)civcf); + set_row (3, "@69g%s %s %s", (const char *)capcf, (const char *)comune, + (const char *)prov); +} +else // no libro iva unico. Cambia la colonna di inizio +{ + set_row (2, "@26g%s %s", (const char *)viacf, (const char *)civcf); + set_row (3, "@26g%s %s %s", (const char *)capcf, (const char *)comune, + (const char *)prov); +} +} + // // Lettura/aggiornamento tabella registri // @@ -1146,8 +1220,8 @@ void CG3400_application::aggiorna_tabreg(int partito_da, int stampate) _tabreg->put ("I1", _pagine_stampate + stampate); _tabreg->put ("I7", partito_da); // partito_da = -1 se stampa OK _tabreg->put ("I6", _nprog_mov); - _tabreg->put ("R1", _tot_dare_progr); - _tabreg->put ("R2", _tot_avere_progr); + _tabreg->put ("R1", _tot_dare_generale); + _tabreg->put ("R2", _tot_avere_generale); _tabreg->put ("D3", _data_a); _tabreg->rewrite(); } @@ -1205,15 +1279,19 @@ HIDDEN int date2esc(const TDate& d, int* prevesc) // //----------------------------------------------------------------------- -bool CG3400_application::mask_a_data (TMask_field& f, KEY k) +bool CG3400_application::data_a_hndl (TMask_field& f, KEY k) { - if (k == K_TAB && f.focusdirty() || k == K_ENTER) + if (f.to_check(k)) { - TMask& m = f.mask(); - const TDate data_a(f.get()); + TMask& m = f.mask(); + const TDate data_a(f.get()); const TString16 codreg(m.get(CODREG)); - const int ae = date2esc(data_a); // Anno esercizio - const bool definitiva = m.get_bool(STAMPA_DEF); + const int ae = date2esc(data_a); // Anno esercizio + const bool definitiva = m.get_bool(STAMPA_DEF); + TString16 dep(data_a.string()); + + if (dep.empty()) + return TRUE; app()->_ae = ae; @@ -1221,15 +1299,15 @@ bool CG3400_application::mask_a_data (TMask_field& f, KEY k) return f.error_box("La data specificata non appartiene a nessun esercizio"); TRegistro reg(codreg, ae); - + if (!reg.ok()) return f.warning_box("Non trovo il libro giornale %s per l'esercizio %d", (const char *) codreg, ae); - + if (reg.tipo() != 5) return f.warning_box("Il registro %s per l'anno %d non e' di tipo libro giornale", (const char *) codreg, ae); - + const TDate data_da(m.get(DATA_DA)); TString16 dtda(data_da.string()); @@ -1237,15 +1315,35 @@ bool CG3400_application::mask_a_data (TMask_field& f, KEY k) { if (dtda.not_empty()) // senno' ci metto inizioEs if (data_da < app()->_inizioEs || data_a > app()->_fineEs); - return f.warning_box("Le date specificate non appartengono allo stesso esercizio"); + return f.warning_box("Le date specificate non appartengono allo stesso esercizio"); } - else -// se la stampa e' di prova DALLA_DATA e' obbligatoria - if (dtda.empty()) - return f.warning_box("Manca la data di partenza"); - else - if (data_da > data_a) - return f.warning_box("La data di inizio non puo' essere maggiore della data finale"); +else + // se la stampa e' di prova DALLA_DATA e' obbligatoria + if (dtda.empty()) + return f.warning_box("Manca la data di partenza"); + else + if (data_da > data_a) + return f.warning_box("La data di inizio non puo' essere maggiore della data finale"); + } + return TRUE; +} + +bool CG3400_application::data_da_hndl(TMask_field& f, KEY k) +{ + if (f.to_check(k)) + { + TMask& m = f.mask(); + const TDate data_da (f.get()); + const TString16 data_a(m.get(DATA_A)); + const int ae_data_da = date2esc(data_da); + const TString16 dep(data_da.string()); + + if (dep.empty() || data_a.empty()) + return TRUE; + + if (app()->_ae != 0) + if (app()->_ae != ae_data_da) + return f.error_box("Le due date non appartengono allo stesso esercizio"); } return TRUE; } @@ -1301,16 +1399,64 @@ bool CG3400_application::mask_b_ripristina (TMask_field& f, KEY k) return TRUE; } +void CG3400_application::init_print() +{ + if (_stampa_len != 0) + printer().formlen(_stampa_len); + else + printer().formlen(RIGHE_MODULO); + + printer().footerlen(RIGHE_FOOTER); + + reset_print(); + reset_header(); + reset_footer(); + set_background(); + + set_real_picture (REAL_PICTURE); + set_print_zero(TRUE); + + if (_stampa_width == 1) + _stampa_width = 132; + else + _stampa_width = 198; + + force_setpage(TRUE); + + printer().set_from_page (_pagina_da); + + if (_stampa_ok != -1) // la stampa precedente era andata male + set_page_number (_stampa_ok); + + if (_stampa_width == 132) + _last_header = set_header_132(); + else + _last_header = set_header_198(); + +} + +void CG3400_application::init_totals() +{ + _tot_dare_ap = ZERO; + _tot_avere_ap = ZERO; + _tot_dare_progr_ap = ZERO; + _tot_avere_progr_ap = ZERO; + _tot_dare_gg = ZERO; + _tot_avere_gg = ZERO; + _tot_dare_generale = ZERO; + _tot_avere_generale = ZERO; + _tot_dare_progr = _tot_dare; + _tot_avere_progr = _tot_avere; +} + bool CG3400_application::set_print(int) { TMask ma ("cg3400a"); KEY tasto; ma.set_handler (CODREG, mask_a_cod_reg); - ma.set_handler (DATA_A, mask_a_data); - - // m.set_handler (REG_ANNO, mask_set_pagina_da); - // m.set_handler (REG_DESC, mask_set_pagina_da); + ma.set_handler (DATA_A, data_a_hndl); + ma.set_handler (DATA_DA, data_da_hndl); tasto = ma.run(); @@ -1327,8 +1473,8 @@ bool CG3400_application::set_print(int) _stampa_width = ma.get_int(STAMPA_WIDTH); _stampa_len = ma.get_int(STAMPA_LEN); -// Se stampa definita DALLA_DATA e' l'ultima data di stampa del -// registro, se indicata, oppure la data di inizio esercizio + // Se stampa definita DALLA_DATA e' l'ultima data di stampa del + // registro, se indicata, oppure la data di inizio esercizio if (_stampa_definitiva) if (_last_data.ok()) _data_da = _last_data; @@ -1337,18 +1483,9 @@ bool CG3400_application::set_print(int) leggi_tabreg(_reg_cod, _ae); - if (_stampa_len != 0) - printer().formlen(_stampa_len); - else - printer().formlen(RIGHE_MODULO); - - printer().footerlen(RIGHE_FOOTER); - - if (_stampa_width == 1) - _stampa_width = 132; - else - _stampa_width = 198; - + init_print(); + init_totals(); + TRectype da (_cur->file(LF_MOV).curr()); TRectype a (_cur->file(LF_MOV).curr()); @@ -1358,27 +1495,6 @@ bool CG3400_application::set_print(int) _cur->setregion(da, a); - force_setpage(TRUE); - - set_background(); - - reset_print(); - reset_header(); - reset_footer(); - - set_real_picture (REAL_PICTURE); - set_print_zero(TRUE); - - printer().set_from_page (_pagina_da); - - if (_stampa_ok != -1) // la stampa precedente era andata male - set_page_number (_stampa_ok); - - if (_stampa_width == 132) - _last_header = set_header_132(); - else - _last_header = set_header_198(); - if (_stampa_definitiva) { TMask mb("cg3400b"); diff --git a/cg/cg3500.cpp b/cg/cg3500.cpp index ff2ca74d2..86393e02e 100755 --- a/cg/cg3500.cpp +++ b/cg/cg3500.cpp @@ -25,7 +25,7 @@ typedef enum {stampagruppo, stampaconto, stampasottoconto, fine} tipo; class CG3500_application : public TPrintapp { TProgind * _prog; - TClifo_list* _lista; + TSaldi_list* _lista; TLocalisamfile* _com, * _pcn, * _clifo, * _saldi, * _nditte,* _anag; TIsamtempfile * _tmp_saldi; tipo _tp; @@ -88,11 +88,11 @@ bool CG3500_application::riepilogo() g = _pcn->get_int (PCN_GRUPPO); c = _pcn->get_int (PCN_CONTO); s = _pcn->get_long(PCN_SOTTOCONTO); - tipo_conto = _pcn->get(PCN_TMCF)[0]; + tipo_conto = _pcn->get_char(PCN_TMCF); TConto conto (g,c,s,tipo_conto); - //il conto e' cambiato anche se e' rimasto invariato il conto ma e' cambiato il gruppo + //il "conto" e' cambiato anche se e' rimasto invariato il conto ma e' cambiato il gruppo if ( (((cp != -1) && (conto.conto() != cp)) || ((gp != -1) && (conto.gruppo() != gp))) && esiste_sc ) { @@ -230,10 +230,11 @@ bool CG3500_application::riepilogo() if (_richiesta == 1) sld.prg_attuali(_annoese,conto,indbil,prg_dare,prg_avere); else sld.prg_mov_eliminati(_annoese,conto,indbil,prg_dare,prg_avere); + saldo = prg_dare - prg_avere; prg_conto_dare += prg_dare; - prg_conto_avere += prg_avere; + prg_conto_avere += prg_avere; if (_scelta == 1) //riepilogo conti { @@ -320,15 +321,15 @@ bool CG3500_application::ricerca_cf(TConto& conto,int indbil,real& prg_conto_dar long s; real prg_dare, prg_avere, saldo; - _lista = new TClifo_list (g,c,tipo); + _lista = new TSaldi_list (g,c,_annoese); TRecnotype items = _lista->items(); prg_conto_dare = 0.00; prg_conto_avere = 0.00; for (int i = 0; i < items; i++) { _prog->addstatus(1); - const TRectype& r = _lista->clifo(i); - s = r.get_long(CLI_CODCF); + const TRectype& r = _lista->saldi(i); + s = r.get_long(SLD_SOTTOCONTO); esiste_sc = TRUE; prg_dare = 0.00; prg_avere = 0.00; @@ -420,7 +421,9 @@ tipo CG3500_application::leggi_conti(int counter) { _ultima_data = UltimaData(_gcorr,_ccorr,_scorr,_annoese); _tmp_saldi->readat(pos); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; TConto conto (_gcorr,_ccorr,_scorr,_tipo); _descr = conto.descrizione(); _prg_dare = _tmp_saldi->get_real(SLD_PDARE); @@ -442,7 +445,9 @@ tipo CG3500_application::leggi_conti(int counter) _ultima_data = UltimaData(_gcorr,_ccorr,_scorr,_annoese); _tmp_saldi->readat(pos); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; TConto conto (_gcorr,_ccorr,_scorr,_tipo); _descr = conto.descrizione(); _prg_dare = _tmp_saldi->get_real(SLD_PDARE); @@ -481,7 +486,9 @@ tipo CG3500_application::leggi_gruppi(int counter) { _tmp_saldi->readat(pos); _ultima_data = _tmp_saldi->get_date(SLD_DATAULMOV); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; TConto conto (_gcorr,_ccorr,0l,_tipo); _descrconto = conto.descrizione(); _prg_dare_conto = _tmp_saldi->get_real(SLD_PDARE); @@ -499,7 +506,9 @@ tipo CG3500_application::leggi_gruppi(int counter) _tmp_saldi->readat(pos); _ultima_data = _tmp_saldi->get_date(SLD_DATAULMOV); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; TConto conto (_gcorr,_ccorr,0l,_tipo); _descrconto = conto.descrizione(); _prg_dare_conto = _tmp_saldi->get_real(SLD_PDARE); @@ -523,7 +532,9 @@ bool CG3500_application::CercaConto(int g, int c) { _gconto = _tmp_saldi->get_int(SLD_GRUPPO); _cconto = _tmp_saldi->get_int(SLD_CONTO); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; if (_scelta == 2) _ultima_data = _tmp_saldi->get_date(SLD_DATAULMOV); TConto conto (_gconto,_cconto,0l,_tipo); @@ -548,7 +559,9 @@ bool CG3500_application::CercaGruppo(int g) if (_tmp_saldi->read() == NOERR) { _ggruppo = _tmp_saldi->get_int(SLD_GRUPPO); - _tipo = _tmp_saldi->get(SLD_FLAGSALINI)[0]; + _tipo = _tmp_saldi->get_char(SLD_FLAGSALINI); + if (_tipo != 'C' && _tipo != 'F') + _tipo = ' '; TConto conto (_ggruppo,0,0l,_tipo); _descrgruppo = conto.descrizione(); _prg_dare_gruppo = _tmp_saldi->get_real(SLD_PDARE); @@ -611,8 +624,8 @@ void CG3500_application::setta_riga_sottoconto() { TString udata = _ultima_data.string(); - set_row(1,"%06ld", (const char*) _scorr); - set_row(1," %.32s", (const char*) _descr); + set_row(1,"%06ld", _scorr); + set_row(1,"@i %.32s@r",(const char*) _descr); set_row(1,"@42g%s",(const char*) udata); set_row(1,"@57g%r@77g%r@97g%r@117g%r",&_prg_dare,&_prg_avere,&_saldo_dare,&_saldo_avere); } @@ -629,13 +642,13 @@ void CG3500_application::setta_riga_conto() if (_scelta == 1) { set_row(r++,"%s",(const char*)riga); - set_row(r,"**** Totali conto %03d.%03d",(const char*)_gconto,(const char*)_cconto); - set_row(r," %.27s",(const char*)_descrconto); + set_row(r,"@b**** Totali conto %03d.%03d",_gconto,_cconto); + set_row(r,"@i %.27s@r",(const char*)_descrconto); } if (_scelta == 2) { - set_row(r,"%03d", (const char*)_ccorr); - set_row(r," %.32s",(const char*)_descrconto); + set_row(r,"%03d", _ccorr); + set_row(r,"@i %.32s@r",(const char*)_descrconto); set_row(r,"@42g%s",(const char*)udata); } set_row(r++,"@57g%r@77g%r@97g%r@117g%r",&_prg_dare_conto,&_prg_avere_conto,&_saldo_dare_conto,&_saldo_avere_conto); @@ -655,8 +668,8 @@ void CG3500_application::setta_riga_gruppo() if (_scelta == 2) if (_tp == fine) r = 3; else r = 2; - set_row(r,"**** TOTALI GRUPPO %03d-",(const char*)_ggruppo); - set_row(r," %.30s",(const char*)_descrgruppo); + set_row(r,"@b**** TOTALI GRUPPO %03d-",_ggruppo); + set_row(r,"@i %.30s@r",(const char*)_descrgruppo); set_row(r++,"@57g%r@77g%r@97g%r@117g%r",&_prg_dare_gruppo,&_prg_avere_gruppo,&_saldo_dare_gruppo,&_saldo_avere_gruppo); set_row(r++,"%s",(const char*)riga); riga = ""; @@ -670,7 +683,7 @@ void CG3500_application::setta_riga_totale() _saldo_tot = _prg_dare_tot - _prg_avere_tot; if (_scelta == 1) r = 8; else r = 6; - set_row(r,"**** TOTALE GENERALE @57g%r@77g%r",&_prg_dare_tot,&_prg_avere_tot); + set_row(r,"@b**** TOTALE GENERALE @57g%r@77g%r",&_prg_dare_tot,&_prg_avere_tot); if (_saldo_tot > 0.00) set_row(r,"@97g%r",&_saldo_tot); else @@ -682,7 +695,7 @@ void CG3500_application::setta_riga_totale() TDate CG3500_application::UltimaData(int g, int c, long s, int anno) { - TLocalisamfile saldi(LF_SALDI, FALSE); //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp + TLocalisamfile saldi(LF_SALDI, FALSE); //il parametro a false permette di usare un record corrente del file saldi differente a quello del file temporaneo TDate uldata; saldi.zero(); @@ -703,13 +716,13 @@ TDate CG3500_application::UltimaData(int g, int c, long s, int anno) void CG3500_application::user_create() { - _clifo = new TLocalisamfile(LF_CLIFO); - _com = new TLocalisamfile(LF_COMUNI); - _pcn = new TLocalisamfile(LF_PCON); - _saldi = new TLocalisamfile(LF_SALDI); - _nditte = new TLocalisamfile(LF_NDITTE); - _anag = new TLocalisamfile(LF_ANAG); - _tmp_saldi = new TIsamtempfile (LF_SALDI); + _clifo = new TLocalisamfile(LF_CLIFO); + _com = new TLocalisamfile(LF_COMUNI); + _pcn = new TLocalisamfile(LF_PCON); + _saldi = new TLocalisamfile(LF_SALDI); + _nditte = new TLocalisamfile(LF_NDITTE); + _anag = new TLocalisamfile(LF_ANAG); + _tmp_saldi = new TIsamtempfile (LF_SALDI); } void CG3500_application::user_destroy() diff --git a/cg/cg3500.h b/cg/cg3500.h index 363a2cab0..84659ab27 100755 --- a/cg/cg3500.h +++ b/cg/cg3500.h @@ -1,27 +1,27 @@ -#ifndef __CG3500_H -#define __CG3500_H - -#define F_CODDITTA 101 -#define F_DATASTAMPA 102 -#define F_RAGSOC 103 -#define F_ANNO 104 -#define F_STAMPA 105 -#define F_RICHIESTA 106 - -#endif // __CG3500_H - - - - - - - - - - - - - - - - +#ifndef __CG3500_H +#define __CG3500_H + +#define F_CODDITTA 101 +#define F_DATASTAMPA 102 +#define F_RAGSOC 103 +#define F_ANNO 104 +#define F_STAMPA 105 +#define F_RICHIESTA 106 + +#endif // __CG3500_H + + + + + + + + + + + + + + + + diff --git a/cg/cg3500a.uml b/cg/cg3500a.uml index 1437fb60f..35d7f30f6 100755 --- a/cg/cg3500a.uml +++ b/cg/cg3500a.uml @@ -1,77 +1,77 @@ -#include "cg3500.h" - -PAGE "" -1 -1 71 16 - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 2 1 "Ditta " - FLAGS "FRD" - USE LF_NDITTE KEY 1 - CHECKTYPE REQUIRED - INPUT CODDITTA F_CODDITTA - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale @50" RAGSOC - OUTPUT F_CODDITTA CODDITTA - OUTPUT F_RAGSOC RAGSOC -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 2 2 "Ragione sociale " - FLAGS "D" -END - -DATE F_DATASTAMPA -BEGIN - PROMPT 43 1 "Data di stampa " - FLAGS "A" -END - -NUMBER F_ANNO 4 -BEGIN - PROMPT 2 3 "Anno esercizio " +#include "cg3500.h" + +PAGE "" -1 -1 71 16 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 2 2 "Ragione sociale " + FLAGS "D" +END + +DATE F_DATASTAMPA +BEGIN + PROMPT 43 1 "Data di stampa " FLAGS "A" - USE ESC - INPUT CODTAB F_ANNO - DISPLAY "Anno" CODTAB - DISPLAY "Data inizio esercizio" D0 - DISPLAY "Data fine esercizio" D1 - OUTPUT F_ANNO CODTAB - CHECKTYPE REQUIRED - WARNING "L'anno di esercizio deve essere presente nella tabella degli esercizi" -END - -RADIOBUTTON F_STAMPA 26 -BEGIN - PROMPT 2 5 "Scelta stampa " - ITEM "1|Stampa riepilogo conti" - ITEM "2|Stampa riepilogo gruppi" -END - -RADIOBUTTON F_RICHIESTA 40 -BEGIN - PROMPT 2 9 "Richiesta stampa " - ITEM "1|Stampa progressivi attuali" - ITEM "2|Stampa progressivi movimenti eliminati" -END - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_CANCEL 9 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -ENDMASK - - - - - - - +END + +NUMBER F_ANNO 4 +BEGIN + PROMPT 2 3 "Anno esercizio " + FLAGS "RZ" + USE ESC + INPUT CODTAB F_ANNO + DISPLAY "Anno" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio" D1 + OUTPUT F_ANNO CODTAB + CHECKTYPE REQUIRED + WARNING "L'anno di esercizio deve essere presente nella tabella degli esercizi" +END + +RADIOBUTTON F_STAMPA 26 +BEGIN + PROMPT 2 5 "Scelta stampa " + ITEM "1|Stampa riepilogo conti" + ITEM "2|Stampa riepilogo gruppi" +END + +RADIOBUTTON F_RICHIESTA 40 +BEGIN + PROMPT 2 9 "Richiesta stampa " + ITEM "1|Stampa progressivi attuali" + ITEM "2|Stampa progressivi movimenti eliminati" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK + + + + + + + diff --git a/cg/cglib.h b/cg/cglib.h index cc1d43d0e..64da53163 100755 --- a/cg/cglib.h +++ b/cg/cglib.h @@ -4,46 +4,49 @@ #ifndef __ISAM_H #include #endif - -#ifndef __ASSOC_H -#include +#ifndef __REAL_H +#include +#endif +#ifndef __DATE_H +#include #endif +#include #include "conto.h" TLocalisamfile * get_descr_cf(TLocalisamfile * pconti, TLocalisamfile * clifo , int g, int c, long s); - class TClifo_list : public TArray + class TSaldi_list : public TArray { public: - TClifo_list(int g, int c, char tipocf); - TRectype& clifo(int i)const { return(TRectype&)this->operator[](i); } + TSaldi_list(int g, int c, int anno); + TRectype& saldi(int i)const { return(TRectype&)this->operator[](i); } }; -//typedef enum {scalare = 1, verifica} bilancio; class Saldo { real _saldo, _saldo_iniziale, _prg_dare, _prg_avere; int _indbil; - TRectype* _rec; - //bilancio _bilancio; + TRectype* _rec; int _annoes; TDate _inizioEs, _fineEs; TString16 _codcaus; TDate _datareg; TDate _datacomp; TString _provv; - + bool _significativo; + bool _movimentato; protected: void InFinEs(int); -public: +public: + bool movimentato() const { return _movimentato==TRUE; } + bool significativo() const { return _significativo==TRUE; } + const int EsePre (const int annocorr); int annoes () const { return _annoes; } - //bilancio bil () const { return _bilancio; } void set_annoes (int anno) { _annoes = anno; } - //void set_bil (bilancio bil) { _bilancio = bil; } void leggi_mov(long); bool causale_mov(long, const TDate&, const TDate&, TString&); const char* causale_chiusura_es(); @@ -53,7 +56,7 @@ public: bool calcola_ultima_immissione(int, int, int, int, long, int); bool ultima_immissione_bilancio(int anno,int g,int c,long s,int indbil); bool data_limite_bilancio(int,int,int,long,const TDate&,const TDate&,int,bool); - real calcola_saldo_iniziale(int, int, int, long, int); + real calcola_saldo_iniziale(int, int, long, int); bool calcola_clifo(int, int, int, int, int); TRectype& ricerca_progr_prec(int, int, int, long); real saldofin_esprec(int,int,int,long); @@ -61,8 +64,6 @@ public: real saldoini() {return _saldo_iniziale;} real prgdare() {return _prg_dare;} real prgavere() {return _prg_avere;} - bool calcola(int,int,int,int,long,const TDate&,const TDate&,int,bool, - const TDate&,const TDate&,const TDate&,bool); bool prg_attuali(int,TConto&,int,real&,real&); bool prg_mov_eliminati(int,TConto&,int,real&,real&); Saldo(); @@ -84,7 +85,8 @@ public: class TSaldo_agg : public TObject { TTab_conti _tab_conti; - bool _movap; // se e' mov. d'apertura (aggiorno SALDO e FLAGSALINI in saldi) + bool _movap; // se e' mov. d'apertura (aggiorno SALDO e FLAGSALINI in + // saldi) bool _provv; int _anno_es; // anno esercizio TDate _data_ulmov; // data ultimo movimento @@ -101,19 +103,19 @@ public: char sezione, bool somma=TRUE); void set_anno_es(int anno) { _anno_es = anno; } - int anno_es() const { return _anno_es; } + int anno_es() { return _anno_es; } void set_movap (bool movap) { _movap = movap; } - bool movap() const { return _movap; } + bool movap() { return _movap; } void set_movprovv (bool p) { _provv = p; } - bool movprovv() const { return _provv; } + bool movprovv() { return _provv; } - void set_data_ulmov (const TDate& data) { _data_ulmov = data; } - const TDate& data_ulmov() const { return _data_ulmov; } + void set_data_ulmov (TDate& data) { _data_ulmov = data; } + TDate& data_ulmov() { return _data_ulmov; } void set_num_ulmov (long num) { _num_ulmov = num; } - long num_ulmov() const { return _num_ulmov; } + long num_ulmov() { return _num_ulmov; } void reset(); // pulisce l'array dei conti TSaldo_agg(); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 2e7974171..ec5cbde2a 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -20,15 +21,15 @@ const MAXSTR = 128; static char __tmp [MAXSTR]; static TFixed_string tmp (__tmp, MAXSTR); -TClifo_list::TClifo_list(int g, int c, char tipocf) +TSaldi_list::TSaldi_list(int g, int c, int anno) { - TLocalisamfile cf(LF_CLIFO); + TLocalisamfile cf(LF_SALDI); destroy(); - cf.setkey(3); + cf.setkey(1); cf.zero(); - cf.put(CLI_TIPOCF,tipocf); - cf.put(CLI_GRUPPO,g); - cf.put(CLI_CONTO,c); + cf.put(SLD_ANNOES,anno); + cf.put(SLD_GRUPPO,g); + cf.put(SLD_CONTO,c); TRectype rec(cf.curr()); cf.read(_isgteq); for ( ;!cf.eof();cf.next()) @@ -53,27 +54,56 @@ Saldo::Saldo() Saldo::~Saldo() { } + +// +// Cerca l'esercizio precedente di EseCorr +// Se EseCorr e' gia' il primo ritorna 0 +// senno' ritorna, astutamente, EseCorr - 1 +// +const int Saldo::EsePre(const int EseCorr) +{ + TTable ese("ESC"); + TString16 first; + TString codtab; + + ese.first(); + first = ese.get("CODTAB"); + + codtab << EseCorr; + codtab.format("%04d"); + + if (codtab == first) + return 0; + + return EseCorr - 1; +} real Saldo::saldofin_esprec(int annoes, int g, int c, long s) { real saldo,pdare,pavere,pdaresca,paveresca; char flag; - TRectype app = ricerca_progr_prec(annoes-1, g, c, s); + const int annoesprec = EsePre(annoes); + + if (annoesprec == 0) return ZERO; // non ci sono esercizi prima del primo + + TRectype app = ricerca_progr_prec(annoesprec, g, c, s); flag = app.get(SLD_FLAGSALINI)[0]; saldo = app.get_real(SLD_SALDO); pdare = app.get_real(SLD_PDARE); pavere = app.get_real(SLD_PAVERE); - pdaresca = app.get_real(SLD_PDARESCA); - paveresca = app.get_real(SLD_PAVERESCA); - + pdaresca = app.get_real(SLD_PDARE); + paveresca = app.get_real(SLD_PAVERE); + + _significativo = (saldo != ZERO || pdare != ZERO || pavere != ZERO); + if (flag == 'D') - return saldo+pdaresca-paveresca+pdare-pavere; + return pdare-pavere+saldo; else - return pdaresca-saldo-paveresca+pdare-pavere; + return pdare-pavere-saldo; } -real Saldo::calcola_saldo_iniziale(int annoes,int g,int c,long s,int indbil) +real Saldo::calcola_saldo_iniziale(int g,int c,long s,int indbil) { real saldoini, pdaresca, paveresca; char flag; @@ -85,46 +115,38 @@ real Saldo::calcola_saldo_iniziale(int annoes,int g,int c,long s,int indbil) saldi.put(SLD_CONTO,c); if (s != 0) saldi.put(SLD_SOTTOCONTO,s); - saldi.put(SLD_ANNOES,annoes); + saldi.put(SLD_ANNOES,_annoes); saldi.read(); if (saldi.bad()) saldi.zero(); - flag = saldi.get(SLD_FLAGSALINI)[0]; + flag = saldi.get_char(SLD_FLAGSALINI); saldoini = saldi.get_real(SLD_SALDO); pdaresca = saldi.get_real(SLD_PDARESCA); paveresca = saldi.get_real(SLD_PAVERESCA); + + if (saldoini != ZERO) + if (flag == 'A') saldoini = -saldoini; - if (saldoini == ZERO) //e il conto e' patrimoniale o d'ordine + if (saldoini == ZERO) if ( indbil == 1 || indbil == 2 || indbil == 5 ) - saldoini = saldofin_esprec(annoes, g, c, s); + { + saldoini = saldofin_esprec(_annoes, g, c, s); + flag = 'D'; // Il segno DEVE essere quello del saldo precedente + } + + _saldo_iniziale = saldoini; + +#ifdef DBG + TString sldi(saldoini.string()); +#endif if (flag == 'D') - return saldoini+pdaresca-paveresca; - else //if (flag == 'A') - return pdaresca-saldoini-paveresca; -} - -/* -bool Saldo::calcola(int annoes, int annoesprec,int g, int c, long s, - const TDate& data_inf, const TDate& data_sup, - int indbil, bool controllo_competenza, const TDate& inizio_es, - const TDate& fine_es, const TDate& fine_es_prec,bool stp_prov) -{ - if (data_sup.ok()) - { - if (!calcola_data_limite(annoes, g, c, s, data_inf, data_sup, indbil, - controllo_competenza, inizio_es, fine_es, fine_es_prec,stp_prov)) - return FALSE; - } + return pdaresca-paveresca+saldoini; else - if (!calcola_ultima_immissione(annoes,annoesprec, g, c, s, indbil)) - return FALSE; - - return TRUE; + return pdaresca-paveresca-saldoini; } -*/ const char* Saldo::causale_chiusura_es() { @@ -202,17 +224,17 @@ bool Saldo::calcola_data_limite(int annoes, int g, int c, long s, const TDate& d if (gcs_corr != gcs_prec) { gcs_prec = gcs_corr; - dep += calcola_saldo_iniziale(annoe,gruppo,conto,sottoconto,indbil); + //dep += calcola_saldo_iniziale(annoe,gruppo,conto,sottoconto,indbil); } //controllo sulle date if (annoe != annoes) if (annoe != annoes-1) - continue; + continue; if (controllo_competenza) if ( (annoe == annoes -1) && (data_sup != fine_es) ) - continue; + continue; else if ( (data_rmv <= fine_es) && (data_rmv <= fine_es_prec) || (data_rmv > fine_es) ) @@ -237,24 +259,6 @@ bool Saldo::calcola_data_limite(int annoes, int g, int c, long s, const TDate& d return esito; } -/* -void Saldo::InFinEs(int ae) -{ - TTable TabEs ("ESC"); - TString16 codtab; - - TabEs.zero(); - - codtab.format ("%04d", ae); - TabEs.put ("CODTAB", codtab); - TabEs.read(); - if (TabEs.good()) - { - _inizioEs = TabEs.get_date ("D0"); - _fineEs = TabEs.get_date ("D1"); - } -} -*/ bool Saldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf, const TDate& data_sup, int indbil, bool stp_prov) { @@ -264,9 +268,10 @@ bool Saldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate long sottoconto, num_reg; TDate data_mov; char sezione; - bool esito = FALSE; + bool buono = FALSE; + _saldo_iniziale = ZERO; TLocalisamfile rmov(LF_RMOV, FALSE); - + rmov.setkey(2); rmov.zero(); rmov.put(RMV_GRUPPO,g); @@ -275,6 +280,7 @@ bool Saldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate TRectype rec(rmov.curr()); rmov.read(_isgteq); + for ( ; !rmov.eof(); rmov.next()) { if (rmov.curr() != rec) break; @@ -301,8 +307,9 @@ bool Saldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate // se la causale del movimento e' uguale a quella di chiusura, // il movimento non va considerato - - if (_codcaus == causale_chiusura_es()) continue; + + if (_codcaus.not_empty()) + if (_codcaus == causale_chiusura_es()) continue; if (!stp_prov && _provv.trim().not_empty()) //se non e' richiesta stampa continue; //mov. provvisori li scarto @@ -312,23 +319,30 @@ bool Saldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate if (gcs_corr != gcs_prec) { gcs_prec = gcs_corr; - dep += calcola_saldo_iniziale(_annoes,gruppo,conto,sottoconto,indbil); + dep += calcola_saldo_iniziale(gruppo,conto,sottoconto,indbil); } - - sezione = rmov.get_char(RMV_SEZIONE); - importo = rmov.get_real(RMV_IMPORTO); +#ifdef DBG + TString dep1(dep.string()); +#endif + sezione = rmov.get_char(RMV_SEZIONE); + importo = rmov.get_real(RMV_IMPORTO); if (importo == ZERO) continue; - esito = TRUE; + buono = TRUE; - if (sezione == 'D') dep += importo; - else dep -= importo; + if (sezione == 'D') + dep += importo; + else + dep -= importo; } +#ifdef DBG + TString dep2(dep.string()); +#endif _saldo = dep; - return esito; + return buono; } bool Saldo::calcola_ultima_immissione(int annoes, int annoesprec, int g, int c, @@ -344,7 +358,7 @@ long s, int indbil) _saldo_iniziale = ZERO; _prg_dare = ZERO; _prg_avere = ZERO; - _saldo = ZERO; + _saldo = ZERO; saldi.zero(); @@ -368,32 +382,26 @@ long s, int indbil) if (annoesprec == 0) //all'ultima immissione es.in corso { -// if (indbil == 3 || indbil == 4) -// return esito; - if (indbil == 1 || indbil == 2 || indbil == 5) if (_saldo_iniziale == ZERO) - _saldo_iniziale += saldofin_esprec(annoes,gruppo,conto,sottoconto); - + _saldo_iniziale += saldofin_esprec(annoes,gruppo,conto,sottoconto); + // i tre valori precedenti vengono utilizzati per la stampa bilancio // di verifica _saldo = _saldo_iniziale + _prg_dare - _prg_avere; } else //all'ultima immissione es.precedente { - TRecnotype numrec = saldi.recno(); - TRectype app = ricerca_progr_prec(annoe-1, gruppo, conto, sottoconto); - annoe = app.get_int (SLD_ANNOES); - _prg_dare = app.get_real(SLD_PDARE); - _prg_avere = app.get_real(SLD_PAVERE); -#ifdef DBG - TString16 pd, pa; - pa = _prg_avere.string(); - pd = _prg_dare.string(); - warning_box ("pdare=%s pavere=%s", (const char*)pd, (const char *)pa); -#endif - saldi.readat(numrec); - _saldo = _prg_dare - _prg_avere; + const int annoesprec = EsePre(annoes); + + if (annoesprec != 0) + { + TRectype app = ricerca_progr_prec(annoe-1, gruppo, conto, sottoconto); + annoe = app.get_int (SLD_ANNOES); + _prg_dare = app.get_real(SLD_PDARE); + _prg_avere = app.get_real(SLD_PAVERE); + } + _saldo = _prg_dare - _prg_avere; } } return esito; @@ -411,7 +419,7 @@ bool Saldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil) _saldo_iniziale = ZERO; _prg_dare = ZERO; _prg_avere = ZERO; - _saldo = ZERO; + _saldo = ZERO; saldi.zero(); @@ -430,15 +438,18 @@ bool Saldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil) _prg_dare = saldi.get_real(SLD_PDARE); _prg_avere = saldi.get_real(SLD_PAVERE); sezione = saldi.get_char(SLD_FLAGSALINI); - + + if (_prg_dare == 0 && _prg_avere == 0) + return esito; + if (sezione == 'A') _saldo_iniziale = -_saldo_iniziale; // if (indbil == 3 || indbil == 4) -// return esito; +// return esito; if (indbil == 1 || indbil == 2 || indbil == 5) if (_saldo_iniziale == ZERO) - _saldo_iniziale += saldofin_esprec(annoes,gruppo,conto,sottoconto); + _saldo_iniziale += saldofin_esprec(annoes,gruppo,conto,sottoconto); // i tre valori precedenti vengono utilizzati per la stampa bilancio // di verifica @@ -452,11 +463,12 @@ TRectype& Saldo::ricerca_progr_prec (int annoesprec, int g, int c, long s) { TLocalisamfile saldi(LF_SALDI, FALSE); // TRectype rec(LF_SALDI); - + const int oldkey = saldi.getkey(); + saldi.setkey(1); saldi.zero(); - if (annoesprec != 0) saldi.put(SLD_ANNOES,annoesprec); + saldi.put(SLD_ANNOES,annoesprec); if (g != 0) saldi.put(SLD_GRUPPO,g); if (c != 0) saldi.put(SLD_CONTO,c); if (s != 0) saldi.put(SLD_SOTTOCONTO,s); @@ -464,7 +476,8 @@ TRectype& Saldo::ricerca_progr_prec (int annoesprec, int g, int c, long s) if (saldi.read() != NOERR) saldi.zero(); *_rec = saldi.curr(); - + saldi.setkey(oldkey); + return *_rec; } @@ -494,11 +507,11 @@ bool Saldo::prg_attuali(int annoes,TConto& conto,int indbil,real& prgdare,real& if ( (indbil == 1) || (indbil == 2) || (indbil == 5) ) if (saldoini == 0) { - saldoini = saldofin_esprec(annoes,conto.gruppo(),conto.conto(),conto.sottoconto()); - if (saldoini > 0.00) - flagsalini = 'D'; + saldoini = saldofin_esprec(annoes,conto.gruppo(),conto.conto(),conto.sottoconto()); + if (saldoini > 0.00) + flagsalini = 'D'; else flagsalini = 'A'; - } + } pdare = saldi.get_real(SLD_PDARE); pavere = saldi.get_real(SLD_PAVERE); pdaresca = saldi.get_real(SLD_PDARESCA); @@ -539,11 +552,11 @@ bool Saldo::prg_mov_eliminati(int annoes,TConto& conto,int indbil,real& prgdare, if ( (indbil == 1) || (indbil == 2) || (indbil == 5) ) if (saldoini == ZERO) { - saldoini = saldofin_esprec(annoes,conto.gruppo(),conto.conto(),conto.sottoconto()); - if (saldoini > ZERO) - flagsalini = 'D'; + saldoini = saldofin_esprec(annoes,conto.gruppo(),conto.conto(),conto.sottoconto()); + if (saldoini > ZERO) + flagsalini = 'D'; else flagsalini = 'A'; - } + } pdaresca = saldi.get_real(SLD_PDARESCA); paveresca = saldi.get_real(SLD_PAVERESCA); if (flagsalini == 'D') @@ -561,7 +574,7 @@ bool Saldo::prg_mov_eliminati(int annoes,TConto& conto,int indbil,real& prgdare, } TLocalisamfile * get_descr_cf (TLocalisamfile * pconti, - TLocalisamfile * clifo, int g, int c, long s) + TLocalisamfile * clifo, int g, int c, long s) { pconti->zero(); pconti->put (PCN_GRUPPO, g);