From d17fef3cf229de8820893fc522fa0b4b33d2b8e2 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 7 Mar 2007 10:11:15 +0000 Subject: [PATCH] Patch level : 4.0 649 Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 848 git-svn-id: svn://10.65.10.50/trunk@14996 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0500.cpp | 117 ++-- cg/cg0500.h | 29 +- cg/cg0500a.uml | 23 +- cg/cg1305.cpp | 53 +- cg/cg2100.cpp | 181 ++++-- cg/cg2100c.uml | 8 +- cg/cg2101.cpp | 16 + cg/cg2102.cpp | 8 +- cg/cg2102.h | 6 +- cg/cg2103.cpp | 3 + cg/cg2103.h | 1 + cg/cg3200a.uml | 6 +- cg/cg3401.h | 2 +- cg/cg3600.cpp | 237 ++++++- cg/cg3600b.uml | 12 +- cg/cg5300.cpp | 3 +- cg/cg7.cpp | 22 - cg/cg7.h | 22 - cg/cg7100.cpp | 626 ------------------ cg/cg7100a.h | 18 - cg/cg7100a.ini | 10 - cg/cg7100a.uml | 121 ---- cg/cg7200.cpp | 1630 ----------------------------------------------- cg/cg7200a.h | 23 - cg/cg7200a.uml | 234 ------- cg/cglib01.cpp | 54 +- cg/cglib01.h | 2 +- cg/cglib02.cpp | 37 +- cg/cglib02.h | 14 +- cg/cgp4.cpp | 19 - cg/cgp4.h | 7 - cg/cgp4100.cpp | 445 ------------- cg/cgp4100a.h | 40 -- cg/cgp4100a.ini | 14 - cg/cgp4100a.uml | 188 ------ cg/cgp4100b.h | 7 - cg/cgp4100b.uml | 87 --- cg/cgp4100c.h | 5 - cg/cgp4100c.uml | 52 -- cg/f26.dir | 3 +- cg/f26.trr | 3 +- cg/omasa.ini | 141 ---- cg/zucchett.ini | 1 - 43 files changed, 576 insertions(+), 3954 deletions(-) delete mode 100755 cg/cg7.cpp delete mode 100755 cg/cg7.h delete mode 100755 cg/cg7100.cpp delete mode 100755 cg/cg7100a.h delete mode 100755 cg/cg7100a.ini delete mode 100755 cg/cg7100a.uml delete mode 100755 cg/cg7200.cpp delete mode 100755 cg/cg7200a.h delete mode 100755 cg/cg7200a.uml delete mode 100755 cg/cgp4.cpp delete mode 100755 cg/cgp4.h delete mode 100755 cg/cgp4100.cpp delete mode 100755 cg/cgp4100a.h delete mode 100755 cg/cgp4100a.ini delete mode 100755 cg/cgp4100a.uml delete mode 100755 cg/cgp4100b.h delete mode 100755 cg/cgp4100b.uml delete mode 100755 cg/cgp4100c.h delete mode 100755 cg/cgp4100c.uml delete mode 100755 cg/omasa.ini diff --git a/cg/cg0500.cpp b/cg/cg0500.cpp index 0bb9ffd17..394fe5971 100755 --- a/cg/cg0500.cpp +++ b/cg/cg0500.cpp @@ -71,7 +71,7 @@ protected: virtual TRelation* get_relation() const { return _rel; } virtual TMask* get_mask(int mode) { return _msk; } - virtual bool changing_mask(int mode) {return FALSE; } + virtual bool changing_mask(int mode) {return false; } virtual bool remove(); void init_mask(TMask&); @@ -277,7 +277,7 @@ bool TCaus_app::m770_hndl (TMask_field& f, KEY k) { if (k == K_TAB && f.focusdirty()) app().fill_sheet(f.mask()); - return TRUE; + return true; } void TCaus_app::set_reg_filter(int f) @@ -294,31 +294,30 @@ void TCaus_app::set_reg_filter(int f) int TCaus_app::calc_filter(const TString& tpd) { - const TRectype & tpd_rec = cache().get("%TPD", tpd); - int filtro = 0; - - if (!tpd_rec.empty()) + + if (tpd.full()) { - const TipoIVA i = (TipoIVA)tpd_rec.get_int("I0"); // IVA acquisti, vendite, generica - const bool corrisp = tpd_rec.get_bool("B0"); - - if (i == iva_vendite) // vendite + const TRectype& tpd_rec = cache().get("%TPD", tpd); + if (!tpd_rec.empty()) { - if (corrisp) // vendite con corrispettivi - filtro = 2; - else // vendite senza corrispettivi - filtro = 1; - } else - if ( i == iva_acquisti ) // acquisti - filtro = 3; - else - if ( i == 9 ) // sia acquisti che vendite + const TipoIVA i = (TipoIVA)tpd_rec.get_int("I0"); // IVA acquisti, vendite, generica + if (i == iva_vendite) // vendite + { + const bool corrisp = tpd_rec.get_bool("B0"); // vendite con corrispettivi? + filtro = corrisp ? 2 : 1; + } + else + { + if (i == iva_acquisti) // acquisti + filtro = 3; else + if (i == iva_generica) // sia acquisti sia vendite filtro = 4; + } + } } set_reg_filter(filtro); - return filtro; } @@ -357,18 +356,18 @@ bool TCaus_app::tipodoc_hndl (TMask_field& f, KEY k) // Ma davvero esiste il registro ? const TString& codreg = field_reg.get(); - if (codreg.not_empty()) + if (codreg.full()) { TRegistro registro(codreg, app().anno_iva()); if (registro.name().empty()) return f.error_box(FR("Non esiste il registro %s per l'anno %d"), - (const char *)codreg, app().anno_iva()); + (const char*)codreg, app().anno_iva()); } app().mostra_campi(); app().fill_sheet(m); } - return TRUE; + return true; } bool TCaus_app::tipomov_hndl (TMask_field& f, KEY k) @@ -379,7 +378,7 @@ bool TCaus_app::tipomov_hndl (TMask_field& f, KEY k) if (f.focusdirty()) app().fill_sheet(f.mask()); } - return TRUE; + return true; } bool TCaus_app::mostra_campi() @@ -395,7 +394,8 @@ bool TCaus_app::mostra_campi() m.hide(F_OP_INTRACOM); m.hide(F_VALINTRA); - m.hide(F_COD_CAUS_IM); + m.hide(F_COD_CAUS_IM); + m.hide(F_CODCAUREG); const int tpm = m.get_int(F_TIPO_MOV); switch (tpm) @@ -426,6 +426,7 @@ bool TCaus_app::mostra_campi() m.enable(F_MOV_VALU, valuta()); m.show(F_COD_CAUS_IM); m.enable(F_COD_CAUS_IM, !saldaconto()); + m.show(F_CODCAUREG); m.show(F_AUTO_FAT); m.show(F_ALLEGAT); @@ -434,7 +435,7 @@ bool TCaus_app::mostra_campi() m.show(F_OP_INTRACOM); m.show(F_VALINTRA); } - return TRUE; + return true; } bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k) @@ -442,8 +443,9 @@ bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k) if (k == K_TAB) { app().mostra_campi(); - if (f.focusdirty()) app().fill_sheet(f.mask()); - return TRUE; + if (f.focusdirty()) + app().fill_sheet(f.mask()); + return true; } // controllo di consistenza tra codice (tipo) registro e tipo documento @@ -468,7 +470,7 @@ bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k) } } } - return TRUE; + return true; } @@ -478,16 +480,16 @@ bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k) bool TCaus_app::ss_notify(TSheet_field& s, int r, KEY k) { - static bool selecting = FALSE; + static bool selecting = false; switch(k) { case K_TAB: if (!selecting && s.row(r).get_char(1) <= ' ') // riga azzerata { - selecting = TRUE; - s.select(r, 1, FALSE); // Vado alla prima colonna delle righe vuote - selecting = FALSE; + selecting = true; + s.select(r, 1, false); // Vado alla prima colonna delle righe vuote + selecting = false; } break; case K_ENTER: @@ -497,7 +499,7 @@ bool TCaus_app::ss_notify(TSheet_field& s, int r, KEY k) default: break; } - return TRUE; + return true; } @@ -516,7 +518,7 @@ bool TCaus_app::sezione_hndl(TMask_field& f, KEY k) // f.reset(); } - return TRUE; + return true; } bool TCaus_app::conto_hndl (TMask_field& f, KEY k) @@ -558,7 +560,7 @@ bool TCaus_app::conto_hndl (TMask_field& f, KEY k) TMask_field& cfld = f.mask().field(SS_TIPOCF); const char cf = toupper(cfld.get()[0]); - bool ok = TRUE; + bool ok = true; if (riga == 0 || riga == 8) { ok = cf != scarta; @@ -590,7 +592,7 @@ bool TCaus_app::conto_hndl (TMask_field& f, KEY k) } } - return TRUE; + return true; } // 1. Se specifico il sottoconto devono essere non vuoti gruppo e conto @@ -603,7 +605,7 @@ bool TCaus_app::sottoconto_hndl(TMask_field& f, KEY k) const bool ok = m.get(SS_GRUPPO).not_empty() && m.get(SS_CONTO).not_empty(); if (!ok) return f.error_box(TR("Conto incompleto")); } - return TRUE; + return true; } @@ -611,14 +613,14 @@ void TCaus_app::compila_array(const TString& tpd, int tpm, int tpr, int m770) { if (tpd.empty() || tpd == "IN" || tpd == "AN" || tpd == "PG") { - bool canc = TRUE; + bool canc = true; switch (tpm) { case 0: if (m770 == 6) { causale_ritenute(); - canc = FALSE; + canc = false; } break; case 3: @@ -627,7 +629,7 @@ void TCaus_app::compila_array(const TString& tpd, int tpm, int tpr, int m770) if (saldaconto()) { causale_inc_pag(); - canc = FALSE; + canc = false; }; break; default: @@ -688,20 +690,22 @@ void TCaus_app::add_riga(int numrig, char sz, const TBill& tc, const TString& d, void TCaus_app::load_rcaus(TMask& m) { + const TString4 cod(_rel->curr().get(RCA_CODCAUS)); + TString d, da(50); + ss().destroy(); const int last = _rcaus_rec->last_row(); for (int i = 1; i <= last; i++) { - const TRectype & r = _rcaus_rec->row(i, TRUE); + const TRectype & r = _rcaus_rec->row(i, true); const char sz = r.get_char(RCA_SEZIONE); const char cf = r.get_char(RCA_TIPOCF); const int g = r.get_int(RCA_GRUPPO); const int c = r.get_int(RCA_CONTO); const long s = r.get_long(RCA_SOTTOCONTO); - const TString8 d = r.get(RCA_CODDESC); - const TString& da = cache().get("%DPN", d, "S0"); - + d = r.get(RCA_CODDESC); + da = cache().get("%DPN", d, "S0"); const TBill tc(g,c,s,cf); add_riga(i-1, sz, tc, d, da); } @@ -710,37 +714,36 @@ void TCaus_app::load_rcaus(TMask& m) bool TCaus_app::fill_sheet(TMask& m) { - const TString8 codreg = m.get(F_COD_REG); - const TString8 tpd = m.get(F_TIPO_DOC); + const TString4 codreg = m.get(F_COD_REG); + const TString4 tpd = m.get(F_TIPO_DOC); const int tpm = m.get_int(F_TIPO_MOV); const int m770 = m.get_int(F_M_770); int tpr = m.get_int(F_TIPO_REG); if (!m.is_running()) { - TString16 chiave; chiave << anno_iva() << codreg; - const TRectype & reg = cache().get("REG", chiave); - + TString8 chiave; chiave << anno_iva() << codreg; + const TRectype& reg = cache().get("REG", chiave); tpr = reg.get_int("I0"); } // carico le descrizioni fisse nell'array Righe_rcaus compila_array(tpd,tpm,tpr,m770); - return TRUE; + return true; } int TCaus_app::write(const TMask& m) { int err = TRelation_application::write(m); if (err == NOERR) - err = re_write(m, FALSE); + err = re_write(m, false); return err; } int TCaus_app::rewrite(const TMask& m) { - int err = re_write(m, TRUE); + int err = re_write(m, true); int err1 = TRelation_application::rewrite(m); return err == NOERR ? err1 : err; } @@ -758,7 +761,7 @@ int TCaus_app::re_write(const TMask& m, bool re) const char sezione = riga.get_char(1); if (g > 0 || sezione > ' ') { - TRectype & r = _rcaus_rec->row(i+1, TRUE); + TRectype & r = _rcaus_rec->row(i+1, true); const char sezione = riga.get_char(1); const char tipo_cf = riga.get_char(); const int c = riga.get_int(4); @@ -893,7 +896,7 @@ bool TCaus_app::user_create() _rel = new TRelation (LF_CAUSALI); _rcaus_rec = new TRecord_array(LF_RCAUSALI, RCA_NRIGA); _msk = new TMask("cg0500a"); - _sheet = &(TSheet_field&)_msk->field(F_SHEET_GCS); + _sheet = &_msk->sfield(F_SHEET_GCS); _msk->set_handler(F_TIPO_DOC, tipodoc_hndl); _msk->set_handler(F_COD_REG, cod_reg_hndl); @@ -907,7 +910,7 @@ bool TCaus_app::user_create() cs.sheet_mask().set_handler(SS_SOTTOCONTO+100, sottoconto_hndl); cs.sheet_mask().set_handler(SS_SOTTOCONTO+200, sottoconto_hndl); - return TRUE; + return true; } bool TCaus_app::user_destroy() @@ -916,7 +919,7 @@ bool TCaus_app::user_destroy() delete _rcaus_rec; delete _rel; - return TRUE; + return true; } int cg0500(int argc, char* argv[]) diff --git a/cg/cg0500.h b/cg/cg0500.h index c7d8e83dd..0a4c9110f 100755 --- a/cg/cg0500.h +++ b/cg/cg0500.h @@ -19,21 +19,22 @@ #define F_COLL_CESP 116 #define F_M_770 117 #define F_COLL_PRIMANOTA 118 -#define F_SHEET_GCS 201 -#define F_TIPO_REG 120 -#define F_ANNOES 121 -#define F_TIPO_MOV 122 +#define F_SHEET_GCS 201 +#define F_TIPO_REG 120 +#define F_ANNOES 121 +#define F_TIPO_MOV 122 #define F_OP_FINE_ANNO 123 -#define F_VALINTRA 124 -#define F_CORRISP 125 -#define F_COD_CAUS2 126 -#define F_DESCR2 127 -#define F_DES_DOC 128 -#define F_DES_REG 129 -#define F_MOVIND 130 -#define F_SOLAIVA 131 -#define F_PROVV 132 - +#define F_VALINTRA 124 +#define F_CORRISP 125 +#define F_COD_CAUS2 126 +#define F_DESCR2 127 +#define F_DES_DOC 128 +#define F_DES_REG 129 +#define F_MOVIND 130 +#define F_SOLAIVA 131 +#define F_PROVV 132 +#define F_CODCAUREG 133 + #define SS_SEZIONE 102 #define SS_TIPOCF 103 #define SS_GRUPPO 104 diff --git a/cg/cg0500a.uml b/cg/cg0500a.uml index 9edb2f876..f87990551 100755 --- a/cg/cg0500a.uml +++ b/cg/cg0500a.uml @@ -89,16 +89,16 @@ END STRING F_COD_REG 3 BEGIN - PROMPT 2 4 "Cod. registro " + PROMPT 2 4 "Registro " FIELD REG USE REG INPUT CODTAB[1,4] F_ANNOES INPUT CODTAB[5,7] F_COD_REG DISPLAY "Anno" CODTAB[1,4] - DISPLAY "Codice registro " CODTAB[5,7] + DISPLAY "Registro" CODTAB[5,7] DISPLAY "Tipo" I0 DISPLAY "Corrispettivi" B0 - DISPLAY "Descrizione @50" S0 + DISPLAY "Descrizione@50" S0 OUTPUT F_COD_REG CODTAB[5,7] OUTPUT F_TIPO_REG I0 OUTPUT F_CORRISP B0 @@ -303,8 +303,6 @@ BEGIN ITEM "C|Cespiti" END - - LIST F_OP_FINE_ANNO 1 11 BEGIN PROMPT 2 14 "Operazioni di fine anno " @@ -356,6 +354,21 @@ BEGIN FIELD MOVIND END +STRING F_CODCAUREG 3 +BEGIN + PROMPT 2 18 "Codice causale regolarizzazione IVA " + FLAGS "UZ" + FIELD CODCAUREG + USE LF_CAUSALI SELECT SOLOIVA="X" + INPUT CODCAUS F_CODCAUREG + DISPLAY "Codice" CODCAUS + DISPLAY "Descrizione@50" DESCR + DISPLAY "Registro" REG + DISPLAY "Documento" TIPODOC + OUTPUT F_CODCAUREG CODCAUS + CHECKTYPE NORMAL +END + ENDPAGE ENDMASK diff --git a/cg/cg1305.cpp b/cg/cg1305.cpp index 02e53a9b3..b9614a210 100755 --- a/cg/cg1305.cpp +++ b/cg/cg1305.cpp @@ -51,31 +51,50 @@ void TAgg_codes::calcola_codes() for (mov.first(); !mov.eof() && err == NOERR; mov.next()) { + bool mod = false; p.addstatus(1); data=mov.get_date(MOV_DATACOMP); - const int codes = mov.get_int(MOV_ANNOES); + int codes = mov.get_int(MOV_ANNOES); const int newcodes = esercizi.date2esc(data); if (codes != newcodes) { mov.put(MOV_ANNOES,newcodes); err = mov.rewrite(); - const long numreg = mov.get_long(MOV_NUMREG); - riga.put(RMV_NUMREG,numreg); - rigaiva.put(RMI_NUMREG,numreg); - righe.read(riga); - righeiva.read(rigaiva); - righe.renum_key(RMV_ANNOES,newcodes); - s_codes.format("%04d",newcodes); - righeiva.renum_key(RMI_ANNOES,s_codes); - if (err == NOERR) - { - err = righe.rewrite(); - if (err == NOERR) - err = righeiva.rewrite(); - if (err == NOERR) - modified_recs++; - } + mod = err == NOERR; + } + const long numreg = mov.get_long(MOV_NUMREG); + + riga.put(RMV_NUMREG,numreg); + righe.read(riga); + bool update_es = false; + for(int i = righe.first_row() ; !update_es && i <= righe.last_row(); i = righe.succ_row(i)) + { + codes = righe[i].get_int(RMV_ANNOES); + update_es = (codes != newcodes); + } + if (update_es) + { + righe.renum_key(RMV_ANNOES,newcodes); + err = righe.rewrite(); + mod = err == NOERR; + } + rigaiva.put(RMI_NUMREG,numreg); + righeiva.read(rigaiva); + update_es = false; + for(int j = righeiva.first_row() ; !update_es && j <= righeiva.last_row(); j = righeiva.succ_row(j)) + { + codes = righeiva[j].get_int(RMI_ANNOES); + update_es = (codes != newcodes); + } + if (update_es) + { + s_codes.format("%04d",newcodes); + righeiva.renum_key(RMI_ANNOES,s_codes); + err = righeiva.rewrite(); + mod = err == NOERR; } + if (mod) + modified_recs++; } if (err != NOERR) warning_box(FR("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura"),err); diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index b61cf4d93..ac33900e3 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -1,33 +1,31 @@ -#include +#include "cg2102.h" +#include "cg21sld.h" +#include "cgpagame.h" +#include "../in/inlib01.h" + #include #include #include -#include #include #include -#include "cgpagame.h" -#include - -#include "cg2100.h" -#include "cg2102.h" -#include "cg21sld.h" -#include "../in/inlib01.h" - -// Nomi dei campi +// Campi su file #include +#include #include -#include "../ca/movana.h" + +// Campi su maschera +#include "cg2100.h" /////////////////////////////////////////////////////////// // Dati incasso immediato /////////////////////////////////////////////////////////// -class TDati_incasso : public TObject +class TDati_mov_auto : public TObject { public: - int _step; - TString4 _causale; + int _tipo, _step; + TString4 _causale, _codiva; TBill _clifo; TDate _datadoc; TString8 _numdoc; @@ -42,7 +40,7 @@ public: TPrimanota_application::TPrimanota_application() : _rel(NULL), _mode(0), _iva(nessuna_iva), _causale(NULL), _giornale(NULL), - _lastreg(0), _last_dreg(TODAY), _last_dcom(TODAY), _incasso(NULL), _swap_mask(false) + _lastreg(0), _last_dreg(TODAY), _last_dcom(TODAY), _automatico(NULL), _swap_mask(false) { memset(_msk, 0, sizeof(_msk)); } @@ -184,7 +182,7 @@ bool TPrimanota_application::user_create() open_files(LF_MOV, LF_RMOV, LF_RMOVIVA, LF_SALDI, 0); open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, LF_AGENTI, 0); - _incasso = new TDati_incasso; + _automatico = new TDati_mov_auto; _rel = new TMovimentoPN; _rel->add(LF_PARTITE, "NREG=NUMREG", 2); // Collega la partita aperta dalla fattura @@ -210,7 +208,7 @@ bool TPrimanota_application::user_create() bool TPrimanota_application::save_and_new() const { - return _savenew || _incasso->_step == 1; + return _savenew || _automatico->_step == 1; } bool TPrimanota_application::user_destroy() @@ -224,7 +222,7 @@ bool TPrimanota_application::user_destroy() delete _causale; delete _rel; - delete _incasso; + delete _automatico; return true; } @@ -588,7 +586,7 @@ void TPrimanota_application::init_query_mode(TMask& m) m.set(F_DATAREG, _last_dreg); } - _incasso->_step = 0; // Azzera flag di incasso immediato + _automatico->_step = 0; // Azzera flag di incasso immediato TFilename tmp; if (get_mask_swap_file(tmp)) @@ -636,17 +634,17 @@ bool TPrimanota_application::get_next_key(TToken_string& tmp) if (m.insert_mode()) { tmp.add(F_CODCAUS); // Ricopia causale - switch (_incasso->_step) + switch (_automatico->_step) { case 1: - tmp.add(_incasso->_causale); - _msk[0]->set(F_CODCAUS, _incasso->_causale); // Joke get_mask + tmp.add(_automatico->_causale); + _msk[0]->set(F_CODCAUS, _automatico->_causale); // Joke get_mask _iva = nessuna_iva; // Impedisce incremento del numero documento break; case 2: - tmp.add(_incasso->_causale_fattura); - _msk[0]->set(F_CODCAUS, _incasso->_causale_fattura); // Joke get_mask - _iva = _incasso->_iva_fattura; // Provoca incremento del numero documento + tmp.add(_automatico->_causale_fattura); + _msk[0]->set(F_CODCAUS, _automatico->_causale_fattura); // Joke get_mask + _iva = _automatico->_iva_fattura; // Provoca incremento del numero documento break; default: tmp.add(m.get(F_CODCAUS)); // Ultima causale usata @@ -708,8 +706,8 @@ void TPrimanota_application::init_insert_mode(TMask& m) _saldi.reset(); // Inizializza saldi - if (_incasso->_step == 1) - genera_incasso(NULL); + if (_automatico->_step == 1) + genera_automatico(_automatico->_tipo, NULL); else m.reset(F_DATACOMP); // Azzera quasi sempre la data di competenza // La preservo solo per l'incasso immediato @@ -1168,6 +1166,9 @@ int TPrimanota_application::write(const TMask& m) if (iva() != nessuna_iva) { + int tipauto = 0; // Tipo movimento automatico + TString4 causauto; // Possibile causale per incasso immediato + causale().reg().reread(); // Aggiorna protocollo IVA if (is_saldaconto()) { @@ -1185,15 +1186,21 @@ int TPrimanota_application::write(const TMask& m) } else { - // Genera incasso immediato se e' una fattura e non c'e' gestione saldaconto - if (!m.get_bool(F_SOLAIVA) && !gestione_saldaconto()) + if (!m.get_bool(F_SOLAIVA) && !gestione_saldaconto()) { - const TString4 causimm(causale().causale_inc_imm()); - if (causimm.not_empty()) - - genera_incasso(causimm); + causauto = causale().causale_inc_imm(); + tipauto = causauto.full() ? 1 : 0; } } + if (iva() == iva_acquisti && tipauto <= 0) + { + // Genera regolarizzazione IVA acquisti + causauto = causale().causale_reg_iva(); + tipauto = causauto.full() ? 2 : 0; + } + + if (tipauto > 0 && causauto.full()) + genera_automatico(tipauto, causauto); } else { @@ -1300,46 +1307,80 @@ bool TPrimanota_application::remove() // Gestione incasso immediato /////////////////////////////////////////////////////////// -void TPrimanota_application::genera_incasso(const char* causimm) +void TPrimanota_application::genera_automatico(int tipo, const char* causimm) { + const TCausale& caus = causale(); TMask& m = curr_mask(); - if (causimm) + if (causimm && *causimm) // Step 0 { - _incasso->_causale = causimm; - _incasso->_causale_fattura = m.get(F_CODCAUS); - _incasso->_iva_fattura = causale().iva(); - _incasso->_datadoc = m.get(F_DATADOC); - _incasso->_numdoc = m.get(F_NUMDOC); - _incasso->_clifo.get(_rel->cg(0)); - _incasso->_totale = m.get_real(F_TOTALE); - _incasso->_step = 1; - } - else - { - const TCausale& caus = causale(); - m.set(F_DATADOC, _incasso->_datadoc); - m.set(F_NUMDOC, _incasso->_numdoc); - TBill contro; caus.bill(2, contro); + if (tipo > 0) + { + // Parte comune a tutti i movimenti automatici + _automatico->_tipo = tipo; + _automatico->_causale = causimm; + _automatico->_causale_fattura = m.get(F_CODCAUS); + _automatico->_iva_fattura = caus.iva(); + _automatico->_datadoc = m.get(F_DATADOC); + _automatico->_numdoc = m.get(F_NUMDOC); + _automatico->_clifo.get(_rel->cg(0)); + _automatico->_totale = m.get_real(F_TOTALE); - cgs().reset(); - TToken_string& row1 = cgs().row(0); - TImporto imp(caus.sezione_clifo(), _incasso->_totale); - imp.add_to(row1, 0); - row1.add(_incasso->_clifo.string(0x3)); - row1.add(" "); - row1.add(" "); - row1.add(contro.string(0x3)); + // Solo regolarizzazioni IVA + if (_automatico->_tipo == 2) + { + _automatico->_totale += m.get_real(F_RITFIS); + _automatico->_codiva = m.get(F_CODIVA); + if (_automatico->_codiva.blank() && _rel->iva_items() > 0) + _automatico->_codiva = _rel->iva(0).get(RMI_CODIVA); + } + + _automatico->_step = 1; + } + } + else // Step 1 + { + m.set(F_DATADOC, _automatico->_datadoc); + m.set(F_NUMDOC, _automatico->_numdoc); + + switch (_automatico->_tipo) + { + case 1: + { // Incasso Immediato + TBill contro; caus.bill(2, contro); + cgs().reset(); + TToken_string& row1 = cgs().row(0); + TImporto imp(caus.sezione_clifo(), _automatico->_totale); + imp.add_to(row1, 0); + row1.add(_automatico->_clifo.string(0x3)); + row1.add(" "); + row1.add(" "); + row1.add(contro.string(0x3)); - TToken_string& row2 = cgs().row(1); - imp.swap_section(); - imp.add_to(row2, 0); - row2.add(contro.string(0x3)); - row2.add(" "); - row2.add(caus.desc_agg(2)); - row2.add(_incasso->_clifo.string(0x3)); - _incasso->_step = 2; - fill_sheet(m); + TToken_string& row2 = cgs().row(1); + imp.swap_section(); + imp.add_to(row2, 0); + row2.add(contro.string(0x3)); + row2.add(" "); + row2.add(caus.desc_agg(2)); + row2.add(_automatico->_clifo.string(0x3)); + fill_sheet(m); + } + break; + case 2: // Regolarizzazione IVA + { + // Reperisce l'eventuale cliente associato al fornitore e lo propone + TString16 forn; forn.format("F|%ld", _automatico->_clifo.codclifo()); + const TString& clnt = cache().get(LF_CFVEN, forn, CFV_CODCFASS); + m.set(F_CLIENTE, clnt); + m.set(F_TOTALE, _automatico->_totale); // Imposta il totale documento e ... + m.set(F_CODIVA, _automatico->_codiva, true); // ... scatena creazione prima riga IVA + } + break; + default: + break; + } + _automatico->_step = 2; } } @@ -1555,7 +1596,7 @@ HIDDEN void ini2bill(TConfig& ini, TBill& bil, bool contro) HIDDEN bool set_not_empty(TMask& msk, int id, TConfig& ini, const char* var) { const TString& val = ini.get(var); - bool ok = val.not_empty(); + bool ok = val.full(); if (ok) msk.set(id, val); return ok; @@ -1564,7 +1605,7 @@ HIDDEN bool set_not_empty(TMask& msk, int id, TConfig& ini, const char* var) HIDDEN bool add_not_empty(TToken_string& str, int pos, TConfig& ini, const char* var) { const TString& val = ini.get(var); - bool ok = val.not_empty(); + bool ok = val.full(); if (ok) str.add(val, pos); return ok; diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index 1ee00f6d9..5572567e1 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -367,13 +367,13 @@ BEGIN CHECKTYPE NORMAL END -STRING F_RICALTCLIENTE 21 18 +STRING F_RICALTCLIENTE 30 18 BEGIN PROMPT 54 11 "Alt. " USE LF_CLIFO KEY 6 INPUT TIPOCF "C" INPUT RICALT F_RICALTCLIENTE - DISPLAY "Codice alternativo@21" RICALT + DISPLAY "Codice alternativo@30" RICALT DISPLAY "Ragione Sociale@50" RAGSOC DISPLAY "Codice" CODCF DISPLAY "Sospeso" SOSPESO @@ -385,13 +385,13 @@ BEGIN GROUP 1 END -STRING F_RICALTFORNITORE 21 18 +STRING F_RICALTFORNITORE 30 18 BEGIN PROMPT 54 11 "Alt. " USE LF_CLIFO KEY 6 INPUT TIPOCF "F" INPUT RICALT F_RICALTFORNITORE - DISPLAY "Codice alternativo@21" RICALT + DISPLAY "Codice alternativo@30" RICALT DISPLAY "Ragione Sociale@50" RAGSOC DISPLAY "Codice" CODCF DISPLAY "Sospeso" SOSPESO diff --git a/cg/cg2101.cpp b/cg/cg2101.cpp index b0fcc9b99..bc4e5927c 100755 --- a/cg/cg2101.cpp +++ b/cg/cg2101.cpp @@ -224,6 +224,22 @@ int TMovimentoPN::registra(bool re, bool force) } } r.put(RMI_TIPOATT, tipoatt); + + const TString & indetr = r.get(RMI_TIPODET); + + if (indetr.full()) + { + const TRectype & det = cache().get("%DET", indetr); + + if (!det.empty() && !det.get_bool("FPC")) + { + TTable tab("%DET"); + + tab.curr() = det; + tab.curr().put("FPC", "X"); + tab.rewrite(); + } + } } _iva.renum_key(MOV_NUMREG, numreg); diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 1b5039b17..690a48612 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -875,6 +875,10 @@ int TPrimanota_application::crea_somma_spese(TImporto& imp) void TPrimanota_application::update_saldo_riga(int r) { TMask& m = curr_mask(); + + if (m.id2pos(F_SHEETCG) < 0) + return; + TSheet_field& sheet = m.sfield(F_SHEETCG); TToken_string row = sheet.row(r); TBill bill; bill.get(row, 2, 0x1); @@ -1735,13 +1739,13 @@ bool TPrimanota_application::iva_sottoconto_handler(TMask_field& f, KEY key) { const TEdit_field& e = (const TEdit_field&)f; const TRectype& piano = e.browse()->cursor()->curr(); - int spric = piano.get_int("TIPOSPRIC"); + int spric = piano.get_int(PCN_TIPOSPRIC); if (app().iva() == iva_vendite) { - const TCausale& caus = app().causale(); if (spric == 2 || spric == 3) { + const TCausale& caus = app().causale(); const TString& td = caus.tipo_doc(); if (td == "FV" || td == "NC" || td == "ND") spric = 4; diff --git a/cg/cg2102.h b/cg/cg2102.h index 1a8238b3a..09cf32dfa 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -25,7 +25,7 @@ #include "cg2103.h" #endif -class TDati_incasso; +class TDati_mov_auto; class TPrimanota_application : public TRelation_application { @@ -65,7 +65,7 @@ class TPrimanota_application : public TRelation_application TDate _last_dreg; // Ultima data registrazione inserita TDate _last_dcom; // Ultima data competenza inserita - TDati_incasso* _incasso; // Dati per gestire incasso immediato + TDati_mov_auto* _automatico;// Dati per gestire incasso immediato TBill _conto_ricavo; // Conto di ricavo del clifo @@ -185,7 +185,7 @@ protected: // TRelation_application protected: void check_saldi(); - void genera_incasso(const char* causimm); + void genera_automatico(int tipo, const char* causimm); // 0=nessuno, 1=incasso, 2=regolarizzazione void gioca_cambi(int force = 0x00); TMask* load_mask(int n); diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 67ff41df8..bdfb13da1 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -135,6 +135,9 @@ bool TCausale::soloiva() const const TString& TCausale::causale_inc_imm() const { return _rec.get(CAU_CODCAUSIM); } +const TString& TCausale::causale_reg_iva() const +{ return _rec.get(CAU_CODCAUREG); } + const TString& TCausale::tipo_doc() const { return _rec.get(CAU_TIPODOC); } diff --git a/cg/cg2103.h b/cg/cg2103.h index 2609e0f20..534a932b1 100755 --- a/cg/cg2103.h +++ b/cg/cg2103.h @@ -40,6 +40,7 @@ public: bool soloiva() const; char provvisorio() const { return _provvisorio; } const TString& causale_inc_imm() const; + const TString& causale_reg_iva() const; const TString& tipo_doc() const; TRegistro& reg() const { return (TRegistro&)_reg; } diff --git a/cg/cg3200a.uml b/cg/cg3200a.uml index b9144b036..a8487b52a 100755 --- a/cg/cg3200a.uml +++ b/cg/cg3200a.uml @@ -392,12 +392,12 @@ BEGIN GROUP 8 END -RADIOBUTTON F_NUMCARAT 1 30 +RADIOBUTTON F_NUMCARAT 1 31 BEGIN PROMPT 1 11 "" - ITEM "1|Stampa Nomale (132 crt.)" + ITEM "1|Stampa Normale (132 crt.)" MESSAGE HIDE,F_SALDO_DES - ITEM "2|Stampa Estesa (198 crt.)" + ITEM "2|Stampa Estesa (198 crt.)" MESSAGE SHOW,F_SALDO_DES END diff --git a/cg/cg3401.h b/cg/cg3401.h index 9ee11c5bb..eb0b2f131 100755 --- a/cg/cg3401.h +++ b/cg/cg3401.h @@ -31,7 +31,7 @@ struct TRigaiva : public TObject TString _codiva; int _tipodet; - TRigaiva (const real& imponibile, const real& imposta, const char* codiva, int tipodet, const real& imponibilep, const real& impostap): + TRigaiva (const char* codiva, const real& imponibile, const real& imposta, int tipodet, const real& imponibilep, const real& impostap): _imponibile(imponibile),_imposta(imposta),_codiva(codiva),_tipodet(tipodet),_imponibilep(imponibilep),_impostap(impostap) {} }; diff --git a/cg/cg3600.cpp b/cg/cg3600.cpp index 699d770b9..934386534 100755 --- a/cg/cg3600.cpp +++ b/cg/cg3600.cpp @@ -1,20 +1,21 @@ #include +#include "cg3.h" +#include "cglib01.h" +#include "cglib02.h" +#include "cg3600.h" + #include #include #include #include #include -#include #include +#include #include #include #include -#include "cg3.h" -#include "cglib02.h" -#include "cg3600.h" - #include #include #include @@ -533,17 +534,25 @@ bool TMastrino::expand(long rec) bool TMastrino::collapse(long rec) { bool ok = true; // Posso eliminare? - if (row(rec).tipo() != riga_mastrino) // Se non sono su una riga mastrino ... - rec = pred(rec, riga_mastrino); // ... mi sposto sulla precedente riga mastrino - else - ok = !expandable(rec); // Controlla che sia possibile - - if (ok) // Posso effetivamente procedere - { - rec++; // Elimino ogni riga contropartita successiva - while (rec < items() && row(rec).tipo() != riga_mastrino) - _riga.remove(rec); + + if (rec < 0) + { + for (long i = last(); i >= 0; i = pred(i)) + collapse(i); } + else + { + if (row(rec).tipo() != riga_mastrino) // Se non sono su una riga mastrino ... + rec = pred(rec, riga_mastrino); // ... mi sposto sulla precedente riga mastrino + ok = !expandable(rec); // Controlla che sia possibile + if (ok) // Posso effetivamente procedere + { + rec++; // Elimino ogni riga contropartita successiva + while (rec < items() && row(rec).tipo() != riga_mastrino) + _riga.remove(rec); + } + } + return ok; } @@ -573,6 +582,8 @@ public: TString& operator = (const char* str) { return set(str); } TString& operator = (const TString& str) { return set(str); } + XI_EVENT* event() { return _xiev; } + TGrid_cell(XI_EVENT* xiev); virtual ~TGrid_cell() { } }; @@ -585,9 +596,9 @@ protected: // TMask_field virtual bool parse_item(TScanner& scanner); virtual word class_id() const; +public: TGrid_control& grid() const { return (TGrid_control&)*_ctl; } -public: virtual bool handler(XI_EVENT* xiev); virtual long items() const; virtual void cell_request(long rec, short id, TGrid_cell& cell); @@ -651,7 +662,6 @@ protected: void set_columns_order(TToken_string* order); - XI_OBJ* find_column(short cid) const; XI_OBJ* find_column(const char* head) const; public: @@ -660,6 +670,7 @@ public: int visible_rows() const; + XI_OBJ* find_column(short cid) const; byte& column_type(int c) { CHECKD(c >= 0 && c < MAX_COL, "Bad column ", c); return _type[c]; } void update(long n = -1); @@ -1579,10 +1590,8 @@ public: TRow_mask* TColor_mask::_sheet_mask = NULL; -TRow_mask::TRow_mask() - : TMask("cg2100k", 1) -{ -} +TRow_mask::TRow_mask() : TMask("cg2100k", 1) +{ } void TRow_mask::update() { @@ -1751,13 +1760,13 @@ class TMastrini_grid : public TGrid_field protected: // TGrid_field virtual bool on_record(long rec); - virtual void cell_request(long rec, short id, TGrid_cell& cell); virtual void on_grid_button(); virtual bool on_resize_column(short id, int new_size); void update_mask() const; public: + virtual void cell_request(long rec, short id, TGrid_cell& cell); virtual void on_dbl_cell(long rec, short id); virtual void on_record_button(long rec); virtual long items() const { return _mastrino.items(); } @@ -1809,7 +1818,20 @@ HIDDEN void set_imp(TMask_field& f, const TImporto& imp) } void TMastrini_grid::cell_request(long rec, short id, TGrid_cell& cell) -{ +{ + if (rec < 0) // testate + { + XI_OBJ* col = grid().find_column(short(1000+id%1000)); + if (col != NULL) + { + TString head; + xi_get_text(col, head.get_buffer(), head.size()); + cell = head; + + } + return; + } + const TRiga_mastrino& riga = _mastrino[rec]; switch (id) @@ -2101,7 +2123,7 @@ void TMastrini_grid::update_mask() const void TMastrini_grid::load_colors() { TConfig conf(CONFIG_USER, "cg3600b"); - _mas_back = conf.get_color("ColorMB", NULL, -1, FOCUS_BACK_COLOR); + _mas_back = conf.get_color("ColorMB", NULL, -1, REQUIRED_BACK_COLOR); _mas_fore = conf.get_color("ColorMF", NULL, -1, FOCUS_COLOR); _con_back = conf.get_color("ColorCB", NULL, -1, NORMAL_BACK_COLOR); _con_fore = conf.get_color("ColorCF", NULL, -1, NORMAL_COLOR); @@ -2126,6 +2148,150 @@ void TMastrini_grid::set_colors() } } +/////////////////////////////////////////////////////////// +// TMastrino_set +/////////////////////////////////////////////////////////// + +class TMastrino_set : public TRecordset +{ + TMastrini_grid& _grid; + long _curr; + TArray _info; + +protected: + void add_field(TFieldtypes t, short id, int width, const char* name = NULL); + long cell_request(long rec, short column, TString& str) const; + +public: + virtual TRecnotype items() const { return _grid.items(); } + virtual unsigned int columns() const { return _info.items(); } + virtual const TRecordset_column_info& column_info(unsigned int column) const; + virtual bool move_to(TRecnotype n); + virtual TRecnotype current_row() const { return _curr; } + virtual void requery() {} + virtual const TVariant& get(unsigned int column) const; + + TMastrino_set(TMastrini_grid& g); +}; + +const TRecordset_column_info& TMastrino_set::column_info(unsigned int column) const +{ + return (const TRecordset_column_info&)_info[column]; +} + +bool TMastrino_set::move_to(TRecnotype n) +{ + const bool ok = n >= 0 && n < items(); + _curr = n; + return ok; +} + +long TMastrino_set::cell_request(long rec, short column, TString& str) const +{ + XI_EVENT xiev; memset(&xiev, 0, sizeof(xiev)); + xiev.type = XIE_CELL_REQUEST; + xiev.v.cell_request.s = str.get_buffer(); + xiev.v.cell_request.len = str.size(); + TGrid_cell cell(&xiev); + _grid.cell_request(rec, column, cell); + return xiev.v.cell_request.attrib; +} + + +const TVariant& TMastrino_set::get(unsigned int column) const +{ + CHECK(_curr>=0 && _curr=0 && column< columns(), "Cella errata"); + + const TRecordset_column_info& info = column_info(column); + + TString80 str; + cell_request(_curr, abs(info._pos), str); + if (str.full()) + { + TVariant& tmp = get_tmp_var(); + switch (info._type) + { + case _realfld: + tmp = real(real::ita2eng(str)); + break; + case _longfld: + tmp = atol(str); + break; + case _datefld: + { + const int cr = str.find(' '); + if (cr >= 0) + { + if (info._pos > 0) + str.cut(cr); + else + str.ltrim(cr); + str.trim(); + } + tmp = TDate(str); + } + break; + default: + if (info._width == 1) + tmp = str.right(1); + else + tmp = str; + break; + } + return tmp; + } + return NULL_VARIANT; +} + +void TMastrino_set::add_field(TFieldtypes tipo, short id, int width, const char* name) +{ + TRecordset_column_info* i = new TRecordset_column_info; + + TString& n = i->_name; + + if (name && *name) + n = name; + else + { + cell_request(-1, abs(id), n); + const int cr = n.find('\n'); + if (cr > 0) + { + if (id > 0) + n.cut(cr); + else + n.ltrim(cr+1); + n.trim(); + } + } + + i->_type = tipo; + i->_pos = id; + i->_width = width; + + _info.add(i); +} + +TMastrino_set::TMastrino_set(TMastrini_grid& g) + : _grid(g), _curr(-1) +{ + _grid.mastrino().collapse(-1);// Nascondo tutte le righe di contropartita + + add_field(_datefld, 101, 10); // Data reg + add_field(_datefld,-101, 10); // Data comp + add_field(_alfafld, 102, 1); // Movimento di competenza? + add_field(_alfafld, 103, 25); // Causale + add_field(_alfafld, 104, 45); // Descrizione + add_field(_realfld, 105, 13); // Dare + add_field(_realfld, 106, 13); // Avere + add_field(_alfafld, 107, 7); // Num doc + add_field(_longfld,-107, 7); // Num prot + add_field(_realfld, 108, 13); // Saldo + add_field(_alfafld,-108, 1, "Sezione"); // Sezione + add_field(_realfld, 109, 13); // Saldo giornaliero + add_field(_alfafld,-109, 1, "Sezione"); // Sezione giornaliera +} + /////////////////////////////////////////////////////////// // TGrid_mask /////////////////////////////////////////////////////////// @@ -2141,6 +2307,7 @@ protected: // TMask static bool link_handler(TMask_field& f, KEY k); static bool new_handler(TMask_field& f, KEY k); + static bool edit_handler(TMask_field& f, KEY k); public: TMastrini_grid& grid() { CHECK(_grid, "What's grid?"); return *_grid; } @@ -2153,8 +2320,9 @@ TGrid_mask::TGrid_mask() : _grid(NULL) { read_mask("cg3600b", 0, 0); - set_handler(DLG_LINK, link_handler); + set_handler(DLG_LINK, link_handler); set_handler(DLG_NEWREC, new_handler); + set_handler(DLG_EDIT, edit_handler); } TMask_field* TGrid_mask::parse_field(TScanner& sc) @@ -2196,6 +2364,23 @@ bool TGrid_mask::new_handler(TMask_field& f, KEY k) return true; } +bool TGrid_mask::edit_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TGrid_mask& gm = (TGrid_mask&)f.mask(); + TMastrini_grid& grid = gm.grid(); + TMastrino_set ms(grid); + + TFilename n; n.tempdir(); n.add("mastrino.slk"); + ms.save_as(n); + xvt_sys_goto_url(n, "open"); + xvt_fsys_removefile(n); + } + return true; +} + + bool TGrid_mask::on_key(KEY k) { long rec = grid().selected(); @@ -2418,7 +2603,7 @@ void TQuery_mask::do_query(TGrid_mask& gm) gm.run(); } - + /////////////////////////////////////////////////////////// // TMastrini_video /////////////////////////////////////////////////////////// diff --git a/cg/cg3600b.uml b/cg/cg3600b.uml index 6f07c6bcf..9e6c09c5e 100755 --- a/cg/cg3600b.uml +++ b/cg/cg3600b.uml @@ -4,20 +4,26 @@ TOOLBAR "" 0 -2 0 2 BUTTON DLG_LINK 10 2 BEGIN - PROMPT -13 -11 "Colle~ga" + PROMPT -14 -11 "Colle~ga" PICTURE BMP_LINK END BUTTON DLG_NEWREC 10 2 BEGIN - PROMPT -23 -11 "~Nuovo" + PROMPT -24 -11 "~Nuovo" PICTURE BMP_NEWREC PICTURE BMP_NEWRECDN END +BUTTON DLG_EDIT 10 2 +BEGIN + PROMPT -34 -11 "~Edit" + PICTURE BMP_EDIT +END + BUTTON DLG_CANCEL 10 2 BEGIN - PROMPT -33 -11 "" + PROMPT -44 -11 "" END ENDPAGE diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index 2c1a60190..f6a89527e 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -311,7 +311,8 @@ bool TParaliq_app::user_create() _msk->set_handler(F_CODDITTA,ditta_handler); _msk->set_handler(F_UTCR_IVA,utcred_handler); _msk->sfield(F_SHEET_PLA).set_notify(sheet_action); - return TRUE; + + return true; } bool TParaliq_app::user_destroy() diff --git a/cg/cg7.cpp b/cg/cg7.cpp deleted file mode 100755 index fc8e038b2..000000000 --- a/cg/cg7.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include - -#include "cg7.h" - -int main(int argc, char** argv) -{ - const int op = argc < 2 ? 0 : argv[1][1]-'0'; - switch (op) - { - case 1: cg7100(argc,argv); break; // Invio ad altra procedura (zucchetti) - case 2: cg7200(argc,argv); break; // Invio ad altra procedura (proforma) - case 3: cg7300(argc,argv); break; // Invio ad altra procedura (Sispac/Cosmo) - default: cg7100(argc,argv); break; - } - exit(0); - return 0; -} - - - - - diff --git a/cg/cg7.h b/cg/cg7.h deleted file mode 100755 index d7cc07ae2..000000000 --- a/cg/cg7.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __CG7_H -#define __CG7_H - -int cg7100(int argc, char** argv); -int cg7200(int argc, char** argv); -int cg7300(int argc, char** argv); - -#endif // __CG7_H - - - - - - - - - - - - - - diff --git a/cg/cg7100.cpp b/cg/cg7100.cpp deleted file mode 100755 index dbfed60e0..000000000 --- a/cg/cg7100.cpp +++ /dev/null @@ -1,626 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cg7.h" -#include "cg7100a.h" - -#include -#include -#include -#include - -#define ALIAS_REG 100 - -class TInvio_file: public TFile_text -{ -protected: - virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str); - -public: - TInvio_file(const TString& file_name); - virtual ~TInvio_file() { } -}; - -TInvio_file::TInvio_file(const TString& file_name) - : TFile_text(file_name, "zucchett.ini") -{ -} - -class TInvio_mask : public TAutomask -{ -protected: - bool on_field_event(TOperable_field& o, TField_event e, long jolly); -public: - - TInvio_mask(); - - virtual ~TInvio_mask(){}; -}; - -TInvio_mask::TInvio_mask() :TAutomask ("cg7100a") -{ -} - -bool TInvio_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - switch (o.dlg()) - { - case F_CODDITTA: - if (e==fe_init && o.empty()) - { - set(F_CODDITTA, main_app().get_firm()); - ((TEdit_field&) o).check(); - disable(F_CODDITTA); - } - break; - default: - break; - } - return TRUE; -} - -class TInvio : public TSkeleton_application -{ - TCursor* _cur; - TInvio_mask* _msk; - TInvio_file* _trasfile; - long _nrecords, _nrecsfattvend, _nrecsfattacqu, _nrecsmocontab; - int _nfiles; - long _nrecsdettaglio; - TString16 _descrdettaglio; - TDate _dataini, _datafin; - bool _totale, _finemov; - -protected: - virtual bool create(void); - virtual bool destroy(void); - virtual void main_loop() ; - void invio_zucchetti(); - long i_zucchetti_causali(const bool invio = TRUE); - long i_zucchetti_clifor(const bool invio = TRUE); - long i_zucchetti_conti(const bool invio = TRUE); - long i_zucchetti_movcont(const bool invio = TRUE); - long i_zucchetti_moviva(const char acqven, const bool invio = TRUE); - void i_zucchetti_testa_dettaglio(const TString16& descr, const long nrecs); - void i_zucchetti_coda_dettaglio(const TString16& descr, const long nrecs); - void i_zucchetti_testa(); - void i_zucchetti_coda(); -public: - int get_nfiles() {return _nfiles;}; - long get_nrecords() {return _nrecords;}; - long get_nrecsdettaglio() {return _nrecsdettaglio;}; - TString16& get_descrdettaglio() {return _descrdettaglio;}; - const bool totale() {return _totale;}; - const bool finemov() {return _finemov;}; - TInvio() {} ; - virtual ~TInvio() {} ; -}; - -// restituisce un riferimento all' applicazione -inline TInvio& app() { return (TInvio&) main_app();} - -// gestione dei messaggi estesi nei campi -void TInvio_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str) -{ - const TString code(s.get(0)); - TString valore; - if (code == "_FISSO") - { - // gestione dei campi fissi per i record delle riba - // sintassi: _FISSO,! - // dove: è la stringa fissa da emettere - TString in(s.get()); - CHECK(in[0]=='!',"Macro _FISSO senza carattere '!'"); - in.ltrim(1); - in.trim(); - valore = in; - } - else if (code == "_ANNO") - { - TDate data(str); - int anno = data.year(); - valore.format("%ld", anno); - } - else if (code == "_MESE") - { - TDate data(str); - int mese = data.month(); - valore.format("%ld", mese); - } - else if (code == "_SEZIONE") - { - valore = str; - const char sezione = s.get()[0]; - const char sezriga = cur.curr(LF_RMOV).get_char(RMV_SEZIONE); - if (sezione != sezriga) - valore = ""; - } - else if (code == "_CAUSALE") - { - TFilename configname = "cg7100a.ini"; - TConfig configfile(configname); - TToken_string causali = configfile.get("STANDARD", "CAUSALI"); - const char sezione = cur.curr(LF_RMOV).get_char(RMV_SEZIONE); - if (sezione == 'D') - valore = causali.get(0); - else - valore = causali.get(1); - } - else if (code == "_NUMFILES") - { - const int nfiles = app().get_nfiles(); - valore.format("%ld", nfiles); - } - else if (code == "_NUMRECORDS") - { - const long nrecords = app().get_nrecords(); - valore.format("%ld", nrecords); - } - else if (code == "_NUMRECORDSDETTAGLIO") - { - const long nrecords = app().get_nrecsdettaglio(); - valore.format("%ld", nrecords); - } - else if (code == "_TIPOFILE") - { - valore = app().get_descrdettaglio(); - } - else if (code == "_OPZIONI") - { - TString in(s.get()); - TFilename configname = "cg7100a.ini"; - TConfig configfile(configname); - valore = configfile.get(in, "OPZIONI"); - } - else if (code == "_OGGI") - { - TDate data(TODAY); - valore = data.string(full, '-', full, full, amg_date); - valore.strip("-"); - } - else if (code == "_CODIFICA") - { - const char tipocf = str[0]; - if (tipocf == 'C') - valore = "P"; - else - valore = "R"; - } - else if (code == "_NUMDOC") - { - if (cur.file("REG").get("I0") == 1) - valore = cur.curr().get(MOV_NUMDOC); - else - valore = cur.curr().get(MOV_PROTIVA); - } - else if (code == "_SEGNO") - { - TString archivio(s.get()); - TString campo(s.get()); - const real importo = cur.curr(archivio).get_real(campo); - valore = "+"; - if (importo < 0) - valore = "-"; - } - else if (code == "_IMPORTO") - { - real importo(str); - valore = importo.string(0,2); - valore.strip("-"); - valore.strip("+"); - valore.strip("."); - } - else if (code == "_TIPODOC") - { - const char tipodoc = str[0]; - valore = (tipodoc == 'F') ? "1" : "2"; - } - else if (code == "_DIVERSI") - { - valore = (app().finemov() ? "X" : " "); - } - else if (code == "_TOTALE") - { - real importo(ZERO); - if (app().totale()) - { - importo = cur.curr(LF_MOV).get_real(MOV_TOTDOC); - importo+=cur.curr(LF_MOV).get_real(MOV_RITFIS); - } - valore = importo.string(11,2); - valore.strip("-"); - valore.strip("+"); - valore.strip("."); - } - else if (code == "_SEGNOTOTALE") - { - real importo(ZERO); - if (app().totale()) - { - importo = cur.curr(LF_MOV).get_real(MOV_TOTDOC); - importo+=cur.curr(LF_MOV).get_real(MOV_RITFIS); - } - valore = importo.string(11,2); - valore.trim(); - valore = valore.sub(0,1); - if (valore[0] != '-' && valore[0] != '+') - valore = "+"; - } - else if (code == "_GIUFIS") - { - const char tipopers = cur.curr(LF_CLIFO).get_char(CLI_TIPOPERS); - valore = (tipopers == 'F') ? " " : "S"; - } - else if (code == "_BLACKLIST") - { - const bool sospeso = cur.curr(LF_CLIFO).get_bool(CLI_SOSPESO); - valore = (sospeso == true) ? "S" : " "; - } - else NFCHECK("Macro non definita: %s", (const char *)code); - str = valore; -} - -void TInvio::i_zucchetti_testa() -{ - // cursore fittizio - TRelation rel(LF_CAUSALI); - TCursor cur(&rel); - _nrecords = 0; - _nfiles = 0; - if (_msk->get_bool(F_CAUSALI)) - { - _nrecords += i_zucchetti_causali(FALSE)+2; - _nfiles++; - } - if (_msk->get_bool(F_CLIFOR)) - { - _nrecords += i_zucchetti_clifor(FALSE)+2; - _nfiles++; - } - if (_msk->get_bool(F_CONTI)) - { - _nrecords += i_zucchetti_conti(FALSE)+2; - _nfiles++; - } - if (_msk->get_bool(F_MOVCONT)) - { - _nrecsmocontab = i_zucchetti_movcont(FALSE); - if (_nrecsmocontab > 0) - { - _nrecords += _nrecsmocontab+2; - _nfiles++; - } - } - if (_msk->get_bool(F_MOVIVA)) - { - _nrecsfattvend = i_zucchetti_moviva('V', FALSE); - if (_nrecsfattvend > 0) - { - _nrecords += _nrecsfattvend+2; - _nfiles++; - } - _nrecsfattacqu = i_zucchetti_moviva('A', FALSE); - if (_nrecsfattacqu > 0) - { - _nrecords += _nrecsfattacqu+2; - _nfiles++; - } - } - TRecord_text rec; - rec.set_type("I"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); -} - -void TInvio::i_zucchetti_testa_dettaglio(const TString16& descr, const long nrecs) -{ - // cursore fittizio - TRelation rel(LF_CAUSALI); - TCursor cur(&rel); - _nrecsdettaglio = nrecs; - _descrdettaglio = descr; - TRecord_text rec; - rec.set_type("F"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); -} - -void TInvio::i_zucchetti_coda_dettaglio(const TString16& descr, const long nrecs) -{ - // cursore fittizio - TRelation rel(LF_CAUSALI); - TCursor cur(&rel); - _nrecsdettaglio = nrecs; - _descrdettaglio = descr; - TRecord_text rec; - rec.set_type("E"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); -} - -void TInvio::i_zucchetti_coda() -{ - TRelation rel(LF_CAUSALI); - TCursor cur(&rel); - TRecord_text rec; - rec.set_type("C"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); -} - -long TInvio::i_zucchetti_causali(const bool invio) -{ - TRelation rel(LF_CAUSALI); - TCursor cur(&rel); - const long cur_items = cur.items(); - if (cur_items != 0 && invio) - { - i_zucchetti_testa_dettaglio("CAUSMOVM", cur_items); - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - TRecord_text rec; - rec.set_type("21"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); - } - i_zucchetti_coda_dettaglio("CAUSMOVM", cur_items); - } - return cur_items; -} - -long TInvio::i_zucchetti_conti(const bool invio) -{ - TRelation rel(LF_PCON); - TCursor cur(&rel); - const long cur_items = cur.items(); - if (cur_items != 0 && invio) - { - i_zucchetti_testa_dettaglio("DESCONTI", cur_items); - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - TRecord_text rec; - rec.set_type("20"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); - } - i_zucchetti_coda_dettaglio("DESCONTI", cur_items); - } - return cur_items; -} - -long TInvio::i_zucchetti_movcont(const bool invio) -{ - TRectype da(LF_MOV); - TRectype a(LF_MOV); - da.put(MOV_DATAREG, _dataini); - a.put(MOV_DATAREG, _datafin); - TRelation rel(LF_MOV); - rel.add(LF_RMOV, "NUMREG==NUMREG", 1); - TCursor cur(&rel, "23->PROTIVA == \"\"", 2, &da, &a); - - const long cur_items = cur.items(); - long totrec = 0; - if (cur_items != 0) - { - if (invio) - i_zucchetti_testa_dettaglio("MOCONTAB", _nrecsmocontab); - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - const long numreg = cur.curr().get_long(MOV_NUMREG); - bool continua = TRUE; - while (continua) - { - const long numregrig = cur.curr(LF_RMOV).get_long(RMV_NUMREG); - if (numreg == numregrig) - { - if (invio) - { - TRectype& cur_rec_righe = cur.curr(LF_RMOV); - TRecord_text recrighe; - recrighe.set_type("50"); - cur.save_status(); - _finemov = !(cur.next_match(LF_RMOV, "NUMREG")); - cur.restore_status(); - _trasfile->autoload(recrighe, cur); - _trasfile->write(recrighe); - } - totrec++; - } - continua = cur.next_match(LF_RMOV, "NUMREG"); - } - } - if (invio) - i_zucchetti_coda_dettaglio("MOCONTAB", _nrecsmocontab); - } - return totrec; -} - -long TInvio::i_zucchetti_moviva(const char acqven, const bool invio) -{ - TRectype da(LF_MOV); - TRectype a(LF_MOV); - da.put(MOV_DATAREG, _dataini); - a.put(MOV_DATAREG, _datafin); - TRelation rel(LF_MOV); - rel.add(LF_RMOVIVA, "NUMREG==NUMREG", 1); - rel.add("REG", "CODTAB[1,4]==ANNOIVA|CODTAB[5,7]==REG", 1); - TString filtro = "(23->PROTIVA != \"\") && "; - if (acqven == 'V') - filtro << "(REG->I0 == 1)"; - else - filtro << "(REG->I0 == 2)"; - TCursor cur(&rel, "", 2, &da, &a); - cur.setfilter(filtro, TRUE); - const long cur_items = cur.items(); - long totrec = 0; - if (cur_items != 0) - { - if (invio) - i_zucchetti_testa_dettaglio(acqven == 'V' ? "FATTVEND" : "FATTACQU", acqven == 'V' ? _nrecsfattvend : _nrecsfattacqu); - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - if (invio) - { - TRecord_text rec; - rec.set_type("30"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); - } - totrec++; - const long numreg = cur.curr().get_long(MOV_NUMREG); - bool continua = TRUE; - while (continua) - { - const long numregrig = cur.curr(LF_RMOVIVA).get_long(RMI_NUMREG); - if (numreg == numregrig) - { - if (invio) - { - TRectype& cur_rec_righe = cur.curr(LF_RMOVIVA); - TRecord_text recrighe; - recrighe.set_type("31"); - cur.save_status(); - _totale = !(cur.next_match(LF_RMOVIVA, "NUMREG")); - cur.restore_status(); - _trasfile->autoload(recrighe, cur); - _trasfile->write(recrighe); - } - totrec++; - } - continua = cur.next_match(LF_RMOVIVA, "NUMREG"); - } - } - if (invio) - i_zucchetti_coda_dettaglio(acqven == 'V' ? "FATTVEND" : "FATTACQU", acqven == 'V' ? _nrecsfattvend : _nrecsfattacqu); - } - return totrec; -} - -long TInvio::i_zucchetti_clifor(const bool invio) -{ - TRelation rel(LF_CLIFO); - TCursor cur(&rel); - const long cur_items = cur.items(); - if (cur_items != 0 && invio) - { - i_zucchetti_testa_dettaglio("CLIEFORN", cur_items*2); - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - TRecord_text rec; - - rec.set_type("10"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); - - rec.set_type("11"); - _trasfile->autoload(rec, cur); - _trasfile->write(rec); - } - i_zucchetti_coda_dettaglio("CLIEFORN", cur_items*2); - } - return cur_items+cur_items; -} - -//metodone globale che chiama, come un menu, i vari sottometodi in base alle scelte sulla maschera -void TInvio::invio_zucchetti() -{ - //prende i parametri dal file di configurazione dell'applicazione - TFilename configname = "cg7100a.ini"; - TConfig configfile(configname); - //prepara il file su cui scrivere, ovvero il _trasfile - TFilename filename = _msk->get(F_DESTINAZIONE); - filename.add(configfile.get("NOMEFILE", "OPZIONI")); - if (fexist(filename)) - remove(filename); - - _trasfile = new TInvio_file(filename); - _trasfile->open(filename,'w'); - - i_zucchetti_testa(); - - if (_msk->get_bool(F_CAUSALI)) - i_zucchetti_causali(); - if (_msk->get_bool(F_CLIFOR)) - i_zucchetti_clifor(); - if (_msk->get_bool(F_CONTI)) - i_zucchetti_conti(); - if (_msk->get_bool(F_MOVCONT)) - i_zucchetti_movcont(); - if (_msk->get_bool(F_MOVIVA)) - { - i_zucchetti_moviva('V'); - i_zucchetti_moviva('A'); - } - i_zucchetti_coda(); - _trasfile->close(); - delete _trasfile; - _trasfile = NULL; -} - -bool TInvio::create() -{ - _msk = new TInvio_mask(); - _trasfile = NULL; - return TSkeleton_application::create(); -} - -bool TInvio::destroy() -{ - if (_trasfile) - delete _trasfile; - delete _msk; - - return TSkeleton_application::destroy(); -} - -void TInvio::main_loop() -{ - TFilename configname = "cg7100a.ini"; - configname.custom_path(); - TConfig configfile(configname); - _msk->set(F_NUMEROINVIO, configfile.get_int("NUMEROINVIO","OPZIONI")+1); - _msk->set(F_DATAINI, configfile.get("DATA","OPZIONI")); - _msk->set(F_DESTINAZIONE, configfile.get("PERCORSO","OPZIONI")); - - while (_msk->run() != K_QUIT) - { - _totale = false; - _finemov = false; - configfile.set("NUMEROINVIO", _msk->get(F_NUMEROINVIO),"OPZIONI"); - configfile.set("DATA", _msk->get_date(F_DATAFIN),"OPZIONI"); - configfile.set("PERCORSO", _msk->get(F_DESTINAZIONE),"OPZIONI"); - configfile.set_paragraph("CAUSALI"); - _dataini = _msk->get_date(F_DATAINI); - _datafin = _msk->get_date(F_DATAFIN); - const char tipoinvio = _msk->get(F_TIPOINVIO)[0]; - if (tipoinvio == 'Z') - invio_zucchetti(); - } -} - -int cg7100(int argc, char **argv) -{ - TInvio a; - a.run(argc, argv, "Invio dati contabilità Zucchetti"); - return 0; -} - diff --git a/cg/cg7100a.h b/cg/cg7100a.h deleted file mode 100755 index b6f4fd037..000000000 --- a/cg/cg7100a.h +++ /dev/null @@ -1,18 +0,0 @@ -// invio dati ad altra procedura - -#define F_CODDITTA 101 -#define F_RAGSOC 102 -#define F_CAUSALI 110 -#define F_CONTI 111 -#define F_CLIFOR 112 -#define F_MOVCONT 113 -#define F_MOVIVA 114 -#define F_CORRISP 115 -#define F_SALDACONTO 116 -#define F_TIPOINVIO 120 -#define F_DESTINAZIONE 121 -#define F_NUMEROINVIO 122 -#define F_DATAINI 123 -#define F_DATAFIN 124 -#define F_RIPRISTINA 125 -#define F_DATARIPRISTINO 126 diff --git a/cg/cg7100a.ini b/cg/cg7100a.ini deleted file mode 100755 index 45b912f7c..000000000 --- a/cg/cg7100a.ini +++ /dev/null @@ -1,10 +0,0 @@ -[OPZIONI] -CODICEDITTA = -DATA = -NOMEFILE = -NUMEROINVIO = -PERCORSO = - -[CAUSALI] -STANDARD= - diff --git a/cg/cg7100a.uml b/cg/cg7100a.uml deleted file mode 100755 index eab868a21..000000000 --- a/cg/cg7100a.uml +++ /dev/null @@ -1,121 +0,0 @@ -#include "cg7100a.h" - -PAGE "Invio dati contabilita'" -1 -1 78 20 - -GROUPBOX DLG_NULL 76 3 -BEGIN - PROMPT 2 1 "@bDitta corrente" -END - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 3 2 "Codice " - FLAGS "FD" - USE LF_NDITTE - INPUT CODDITTA F_CODDITTA - OUTPUT F_RAGSOC RAGSOC - CHECKTYPE REQUIRED -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 23 2 "" - FLAGS "D" -END - -GROUPBOX DLG_NULL 76 6 -BEGIN - PROMPT 2 4 "Dati da inviare" -END - -BOOLEAN F_CAUSALI -BEGIN - PROMPT 3 5 "Causali" - FLAGS "D" -END - -BOOLEAN F_CONTI -BEGIN - PROMPT 3 6 "Conti" -END - -BOOLEAN F_CLIFOR -BEGIN - PROMPT 3 7 "Clienti/Fornitori" -END - -BOOLEAN F_MOVCONT -BEGIN - PROMPT 3 8 "Movimenti contabili" - MESSAGE TRUE,ENABLE F_DATAFIN -END - -BOOLEAN F_MOVIVA -BEGIN - PROMPT 40 5 "Movimenti IVA" - MESSAGE TRUE,ENABLE F_DATAFIN -END - -BOOLEAN F_CORRISP -BEGIN - PROMPT 40 6 "Corrispettivi" - MESSAGE TRUE,ENABLE F_DATAFIN -END - -BOOLEAN F_SALDACONTO -BEGIN - PROMPT 40 7 "Saldaconto" - FLAGS "D" -END - -LISTBOX F_TIPOINVIO 20 -BEGIN - PROMPT 2 10 "Invio a " - ITEM "Z|Zucchetti" -END - -STRING F_DESTINAZIONE 20 -BEGIN - PROMPT 2 11 "Destinazione " -END - -NUMBER F_NUMEROINVIO 2 -BEGIN - PROMPT 2 12 "Numero invio " -END - -DATE F_DATAINI -BEGIN - PROMPT 20 12 "Data iniz. " -END - -DATE F_DATAFIN -BEGIN - PROMPT 44 12 "Data fin. " -END - -BUTTON F_RIPRISTINA 20 -BEGIN - PROMPT 2 14 "Annulla invio" - MESSAGE SHOW,F_DATARIPRISTINO|ENABLE,F_DATARIPRISTINO -END - -DATE F_DATARIPRISTINO -BEGIN - PROMPT 25 14 "Annulla invio fino al " - FLAGS "HD" -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/cg7200.cpp b/cg/cg7200.cpp deleted file mode 100755 index d9e499732..000000000 --- a/cg/cg7200.cpp +++ /dev/null @@ -1,1630 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "cg7.h" -#include "cg7200a.h" -#include "cg2101.h" -#include "cg2103.h" -#include "cgsaldac.h" - -#include -#include - -#include "../ca/calib01.h" -#include "../ca/movana.h" -#include "../ca/rmovana.h" -#include "../ve/velib.h" - -#include -#include - - -class TInvioP_file: public TFile_text -{ -protected: - virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str); - -public: - TInvioP_file(const TString& file_name); - virtual ~TInvioP_file() { } -}; - -TInvioP_file::TInvioP_file(const TString& file_name) - : TFile_text(file_name, "proforma.ini") -{ -} - -////////////////////////////////////////////////////// -// MASCHERA -////////////////////////////////////////////////////// - -class TInvioP_mask : public TAutomask -{ -protected: - bool on_field_event(TOperable_field& o, TField_event e, long jolly); - void config_loader(TSheet_field& sf, const char* paragrafo); - void config_setter(TSheet_field& sf, const char* paragrafo); - -public: - TInvioP_mask(); - virtual ~TInvioP_mask(){}; -}; - -TInvioP_mask::TInvioP_mask() :TAutomask ("cg7200a") -{ - config_loader(sfield(F_PDCC), "Pdcc"); -} - -bool TInvioP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - switch (o.dlg()) - { - case F_CODDITTA: - if (e==fe_init && o.empty()) - { - set(F_CODDITTA, main_app().get_firm()); - ((TEdit_field&) o).check(); - disable(F_CODDITTA); - } - break; - case DLG_SAVEREC: - if (e == fe_button) - { - config_setter(sfield(F_PDCC), "Pdcc"); - } - break; - default: - break; - } - return true; -} - -void TInvioP_mask::config_loader(TSheet_field& sf, const char* paragrafo) -{ - //carica file configurazione conti; attenzione!!!il file di configurazione in questione e' il - //medesimo del programma per la stampa del pagato in contabilita' analitica, visto che i due - //programmi necessitano degli stessi conti - TFilename configname = "ca3600a.ini"; - configname.custom_path(); - TConfig configfile(configname, paragrafo); - - TString_array conti; - - int first_enabled_row = -1; - int n = configfile.list_variables(conti, false, paragrafo, true); - FOR_EACH_ARRAY_ROW(conti, i, row) - { - sf.row(-1) = configfile.get(*row); //carica la riga del .ini senza il contatore - sf.check_row(i); - TString pippo = sf.row(i); - pippo = pippo.left(1); //disabilita le righe di tipo C e P che riguardano la sola stampa.. -/* if (pippo == "C" || pippo == "P") //..del pagato - sf.disable_row(i); - else - { - if (first_enabled_row < 0) //se la riga non e' C o P deve incrementare il contatore della.. - first_enabled_row = i; //..prima riga disabilitata - }*/ - } - if (first_enabled_row >= 0) //se il contatore della prima riga disabilitata e' stato.. - sf.select(first_enabled_row); //..incrementato, sposta il focus alla prima riga abile -} - -void TInvioP_mask::config_setter(TSheet_field& sf, const char* paragrafo) -{ - TFilename configname = "ca3600a.ini"; - configname.custom_path(); - TConfig configfile(configname, paragrafo); - - configfile.remove_all(); //svuota il paragrafo sul .ini prima di ricompilarlo (se non si facesse - //non si riuscirebbero ad ammazzare le righe sul .ini - FOR_EACH_SHEET_ROW (sf, i, row) - { - TToken_string conto(""); - conto.add(row->get(0)); - conto.add(row->get(1)); - conto.add(row->get(2)); - conto.add(row->get(3)); - - configfile.set("conto", conto, NULL, true, i); - } -} - -////////////////////////////////////////////// -// STRUCT (saldo di 1 conto) -////////////////////////////////////////////// -struct TInvioP_saldo : public TObject -{ - TString16 _zio; - TImporto _importo; - - TInvioP_saldo(const TRectype& r); - TInvioP_saldo(const TString& zio, const TImporto& importo); -}; - -TInvioP_saldo::TInvioP_saldo(const TRectype& r) -{ - const TBill zio(r); - _zio = zio.string(0x8); - - const char sezione = r.get_char(RMV_SEZIONE); - const real imp = r.get_real(RMV_IMPORTO); - _importo.set(sezione, imp); - _importo.normalize(); -} - -TInvioP_saldo::TInvioP_saldo(const TString& zio, const TImporto& importo) - : _zio(zio), _importo(importo) -{} - - -////////////////////////////////////////////// -// SALDI MOVIMENTO CONTABILE -////////////////////////////////////////////// -class TInvioP_saldi_cg : public TArray -{ -public: - //prende l'oggetto i-esimo (in questo caso un TInvioP_saldo) e ritorna il conto di tale oggetto - const TString& conto(int i) { return ((TInvioP_saldo*)objptr(i))->_zio; } - //stessa roba ma per l'importo - TImporto& importo(int i) { return ((TInvioP_saldo*)objptr(i))->_importo; } - bool sottrai_importo(const TString& conto, const TImporto& importo); - void somma(const TRectype& rmov); - void sottrai(const TRectype& rmovana); -}; - -void TInvioP_saldi_cg::somma(const TRectype& rmov) -{ - TInvioP_saldo* s = new TInvioP_saldo(rmov); - add(s); -} - -bool TInvioP_saldi_cg::sottrai_importo(const TString& zio, const TImporto& imp) -{ - int k; - //caso fortunato - //scandisce gli elementi dell'array;se ne trova uno (k-esimo) con conto ed importo coincidenti.. - //..con quelli passati al metodo, azzera l'importo di tale elemento dell'array - for (k = 0; k < items(); k++) - { - if (conto(k) == zio && importo(k) == imp) - { - importo(k).set('D', ZERO); - return true; - } - } - - //caso sfortunato - //in questo caso gli importi dell'elemento k-esimo dell'array e passato al metodo NON coincidono - TImporto residuo = imp; - int ultima_riga_buona = -1; - - for (k = 0; k < items() && !residuo.is_zero(); k++) - { - if (conto(k) == zio) - { - TImporto& val = importo(k); - residuo.normalize(val.sezione()); - if (residuo >= val) - { - residuo -= val; - val.set('D', ZERO); - } - else - { - val -= residuo; - residuo.set('D', ZERO); - } - ultima_riga_buona = k; - } - } - //alla fine del ciclo sull'array resta un residuo non nullo.. - if (!residuo.is_zero()) - { - residuo.normalize(); - residuo.swap_section(); - if (ultima_riga_buona >= 0) - importo(ultima_riga_buona) += residuo; -// else -// add(new TInvioP_saldo(zio, residuo)); - } - return true; -} - -void TInvioP_saldi_cg::sottrai(const TRectype& rmovana) -{ - //adesso tocca alle righe contabili senza commessa - const int gruppo = atoi(rmovana.get(RMOVANA_CODCONTO).left(3)); - const int conto = atoi(rmovana.get(RMOVANA_CODCONTO).mid(3,3)); - const long sottoconto = atol(rmovana.get(RMOVANA_CODCONTO).mid(6,6)); - - const TBill zio(gruppo, conto, sottoconto); - - const TImporto importo(rmovana.get_char(RMOVANA_SEZIONE), rmovana.get_real(RMOVANA_IMPORTO)); - sottrai_importo(zio.string(0x8), importo); -} - -////////////////////////////////////////////// -// APPLICAZIONE -////////////////////////////////////////////// - -class TInvioP : public TSkeleton_application -{ - TCursor* _cur; - TInvioP_mask* _msk; - TDate _dataini, _datafin; - long _nregcosto, _nregpag; - real _importo; - char _accsal; - TConfig* _configfile; - TAssoc_array _fiscali,_sociali, _costi, _pagamenti; //array che contengono i conti - -protected: - virtual bool create(void); - virtual bool destroy(void); - virtual void main_loop() ; - void invio_proforma(); - bool i_proforma_movimenti(); - bool i_proforma_righe(TCursor& cur, TInvioP_file* trasfile); - bool i_proforma_pagamenti(); - bool i_proforma_clifor(char tipocf = 'C'); - bool i_proforma_conti(); - - real totale_documento(TMovimentoPN& pn, const bool includi_ritenute = true) const; - void lettura_conti(TAssoc_array& assoc, const char tipoconto); - bool cerca_conto(const TBill& bill, const TAssoc_array& assoc, const char tipoconto) const; - bool cerca_fiscali(const TBill& bill) const; - bool cerca_sociali(const TBill& bill) const; - int cerca_pagamento(const TBill& bill) const; - int cerca_costo(const TBill& bill) const; - bool test_swap(TCausale& caus, bool ritsoc) const; - real calcola_pagamento(TRectype& curpag_rec, real& iva_indetraibile); - bool sottrai_iva(TMovimentoPN& pn, const TRectype& rigaiva); - void stringa_grcosot(TRecord_text& recrighe, const TString& zio); - long calcola_fattura_originale(long nreg) const; - bool calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec, - real& imponibile, real& totdoc, real& totpagato, real& iva_indetraibile) const; - void calcola_imposte(const real& importo, const real& imposta, - const TString& codind, real& iva_det, real& iva_ind) const; - -public: - const real get_importo() {return _importo;} - const long get_nregcosto() const {return _nregcosto;} - const long get_nregpag() const {return _nregpag;} - const char get_accsal() const {return _accsal;} - const TString& get_vocespesa(const TString& zio) const; - TInvioP_file* apri_file(const char* nome); - void chiudi_file(TInvioP_file* trasfile); - - TInvioP() {}; - virtual ~TInvioP() {}; -}; - -// restituisce un riferimento all' applicazione -inline TInvioP& app() { return (TInvioP&) main_app();} - -// gestione dei messaggi estesi nei campi -void TInvioP_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str) -{ - const TString code(s.get(0)); - TString valore; - if (code == "_FISSO") - { - // gestione dei campi fissi per i record delle riba - // sintassi: _FISSO,! - // dove: è la stringa fissa da emettere - TString in(s.get()); - CHECK(in[0]=='!',"Macro _FISSO senza carattere '!'"); - in.ltrim(1); - in.trim(); - valore = in; - } - else if (code == "_TELEFONO") - { - valore = str; - valore.trim(); - str = cur.curr().get("PTEL"); - valore << str; - valore.trim(); - } - else if (code == "_RAGSOC") - { - valore = str; - valore = valore.strip_double_spaces(); - } - else if (code == "_FLAG") - { - if (app().get_accsal() == 'S') - valore = "S"; - else - valore = "A"; - - } - else if (code == "_NREGCOSTO") - { - valore.format("%ld", app().get_nregcosto()); - } - else if (code == "_NREGPAG") - { - valore.format("%ld", app().get_nregpag()); - } - else if (code == "_IMPORTO") - { - valore = app().get_importo().string(); - } - - else NFCHECK("Macro non definita: %s", (const char *)code); - str = valore; -} - -TInvioP_file* TInvioP::apri_file(const char* nome) -{ - TFilename filename = _msk->get(F_DESTINAZIONE); - filename.add(nome); - filename.ext("txt"); - if (filename.exist()) - remove(filename); - - TInvioP_file* trasfile = new TInvioP_file(filename); - trasfile->open(filename,'w'); - trasfile->force_record_separator(); - return trasfile; -} - -void TInvioP::chiudi_file(TInvioP_file* trasfile) -{ - trasfile->close(); - delete trasfile; -} - -const TString& TInvioP::get_vocespesa(const TString& zio) const -{ - TConfig configfile("cg7200a.ini", "OPZIONI"); - const TString16 confstringa = configfile.get("CONFSTRINGA"); - const int len = confstringa.len(); - - TLocalisamfile panapdc(LF_PANAPDC); - panapdc.zero(); - panapdc.setkey(2); - panapdc.put("GRUPPO", atoi(zio.mid(0,3))); - panapdc.put("CONTO", atoi(zio.mid(3,3))); - panapdc.put("SOTTOCONTO", atol(zio.mid(6,6))); - const TRectype r(panapdc.curr()); - - for (panapdc.read(); !panapdc.eof(); panapdc.next()) - { - if (panapdc.curr() != r) - break; - const TString& codconto = panapdc.get("CODCONTO"); - if (codconto.starts_with(confstringa)) - return codconto.mid(len); - } - return EMPTY_STRING; -} - -bool TInvioP::i_proforma_conti() -{ - TInvioP_file* trasfile = apri_file("pianocon"); - - TRelation rel(LF_PCON); - TCursor cur(&rel); - const long cur_items = cur.items(); - if (cur_items != 0) - { - TProgind pi(cur_items, "Trasferimento conti...", true, true); - - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - pi.addstatus(1); - if (pi.iscancelled()) - break; - - TRecord_text rec; - rec.set_type("P"); - trasfile->autoload(rec, cur); - trasfile->write(rec); - } - } - chiudi_file(trasfile); - return true; -} - -bool TInvioP::i_proforma_movimenti() -{ - TInvioP_file* trasfile = apri_file("registra"); //file testate - TInvioP_file* trasfilerighe = apri_file("righe"); //file righe movimenti - - //trasferimento testate movimenti (cerca direttamente sui movimenti analitici in chiave 2.. - //..,cioè per DATACOMP e con NUMREGCG!=0 - TRectype da(LF_MOV); - TRectype a(LF_MOV); - da.put(MOV_DATAREG, _dataini); - a.put(MOV_DATAREG, _datafin); - TRelation rel(LF_MOV); - rel.add(LF_CAUSALI, "CODCAUS==CODCAUS"); - - TCursor cur(&rel, "", 2, &da, &a); //chiave per data - - const long cur_items = cur.items(); - if (cur_items != 0) - { - //prepara i record di tipo testata da scrivere - TRecord_text rec; - rec.set_type("T"); - - TProgind pi(cur_items, "Trasferimento movimenti...", true, true); - - cur.freeze(); - const TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - pi.addstatus(1); - if (pi.iscancelled()) - break; - - //carica e scrive il record di testata in base alle informazioni contenute nel proforma.ini - trasfile->autoload(rec, cur); - trasfile->write(rec); - //trasferisce le righe del movimento analitico corrente solo - i_proforma_righe(cur, trasfilerighe); - } - } - chiudi_file(trasfilerighe); - chiudi_file(trasfile); - return true; -} - -bool TInvioP::i_proforma_righe(TCursor& cur, TInvioP_file* trasfilerighe) -{ - //---- righe movimenti ---- - TInvioP_saldi_cg conti_importi; - - //Creo un movimento PN (con numreg = a quello del mov)che servira' un po' dovunque - TMovimentoPN pn; - pn.curr() = cur.curr(); - if (pn.read() == NOERR) - { - for (int j = 0; j < pn.cg_items(); j++) - conti_importi.somma(pn.cg(j)); - } - - TRecord_text recrighe; //istanzia il tipo record corretto da scrivere sul trasfilerighe - recrighe.set_type("R"); - - TAnal_mov analmov(cur.curr()); //..istanzia il movimento analitico con numregcg=numreg del mov - const long analrighe_items = analmov.body().rows(); - - if (analrighe_items > 0) //se il movana ha righe.. - { - TRelation rel_rmovana(LF_RMOVANA); //crea una relazione sulle righe anali cui aggiunge mov e movana - rel_rmovana.add(LF_MOVANA, "NUMREG==NUMREG"); - rel_rmovana.add(LF_MOV, "NUMREG==NUMREGCG", 1, LF_MOVANA); - TCursor cur_rmovana(&rel_rmovana); //crea il cursore sulle righe analitiche che serve per poter usare la autoload - cur_rmovana.curr(LF_MOVANA) = analmov; - cur_rmovana.curr(LF_MOV) = cur.curr(); - - for (int i = 1; i <= analrighe_items; i++) - { - //..e scandisce le righe - const TRectype& riga = analmov.body().row(i); - //inganna il cursore passandogli la riga analitica in esame (bastardo!) - cur_rmovana.curr() = riga; - //carica le righe analitiche - trasfilerighe->autoload(recrighe, cur_rmovana); - //toglie le righe contabili corrispondenti che sono appena state aggiunte con la autoload (sarebbero.. - //..duplicate se non lo facesse!!!) - conti_importi.sottrai(riga); - - //procedura orrenda per eliminare gli zeri dai gr/co/sot e passarli come stringhe! - const TString16 zio = cur_rmovana.curr().get(RMOVANA_CODCONTO); - stringa_grcosot(recrighe, zio); - - //procedura per scrivere la fase che deve essere spezzata in due per sottoprogetto ed edizione - const TString& codfase = riga.get(RMOVANA_CODFASE); - if (codfase.full()) - { - recrighe.add(codfase.left(4), 14); - recrighe.add(codfase.mid(4,4), 15); - } - - //procedura per ricavare la voce di spesa - const TString& vocespesa = get_vocespesa(zio); - recrighe.add(vocespesa, 16); - - //scrive sul file di trasferimento (alla faccia della semplicita'!) - trasfilerighe->write(recrighe); - } - } - //prende le righe contabili che non sono state eliminate dalle analitiche nelle sottrai(riga).. - //..in modo da passare anche quelle (in caso contrario sarebbero andati perduti gli importi di.. - //..tali righe che non avevano commessa!) - const long conti_importi_items = conti_importi.items(); - TString workstring; //stringa di lavoro che serve nel ciclo sotto - for (int k = 0; k < conti_importi_items; k++) - { - if (!conti_importi.importo(k).is_zero()) - { - //aggiunge i valori ai campi uno ad uno perchè non ha un cursore per fare l'autoload - recrighe.destroy(); - recrighe.add(pn.curr().get(MOV_NUMREG), 0); //numreg - workstring = "N"; - recrighe.add(workstring, 1); //rigaiva - TImporto& imp = conti_importi.importo(k); - workstring.cut(0) << imp.sezione(); - recrighe.add(workstring, 2); //sezione - //procedura orrenda per eliminare gli zeri dai gr/co/sot e passarli come stringhe! - const TString& zio = conti_importi.conto(k); - stringa_grcosot(recrighe, zio); - - const TString tipocf = pn.curr().get(MOV_TIPO); - recrighe.add(tipocf, 6); //tipocf - - //procedura per stringare il codice clifo - if (tipocf > ' ') - { - const long codcf = pn.curr().get_long(MOV_CODCF); - TString cf; - cf.format("%ld", codcf); - recrighe.add(cf, 7); //codcf - } - else - { - recrighe.add("", 7); //codcf - } - - recrighe.add(pn.curr().get(RMV_DESCR), 8); //descrizione - recrighe.add(imp.valore().string(), 9); //importo - - //procedura per ricavare la voce di spesa - const TString& vocespesa = get_vocespesa(zio); - recrighe.add(vocespesa, 16); - - //e finalmente scrive le righe avanzate... - trasfilerighe->write(recrighe); - } - } - - //---- righe iva ---- - //adesso tocca alle righe iva...e sara' un casino indicibile! - - //assoc array contenente tutti i diversi conti che incontrera' nello scanning delle righe iva - TAssoc_array conti; - //causale del movimento: serve per conoscere il tipo di detraibilita' dell'iva (piu' sotto) - const TCausale caus(pn.curr().get(MOV_CODCAUS)); - const int anno = pn.curr().get_date(MOV_DATAREG).year(); - real imp_detr, iva_detr, imp_indetr, iva_indetr; - - //scanning delle righe iva alla ricerca dei conti che compaiono - for (int l = 0; l < pn.iva_items(); l++) - { - //prende il conto e lo mette nell'assoc_array dei conti (notare che, essendo un assoc_array,.. - //..non vengono inseriti doppioni! mitico!!) - TBill conto; - conto.get(pn.iva(l)); - const char* codconto = conto.string(0x8); - - //ad ogni conto lega un assoc_array (codivae) che conterra' tutti i codici iva legati a quel.. - //..conto nelle righe iva con i relativi importi - TAssoc_array* codivae = (TAssoc_array*) conti.objptr(codconto); - if (codivae == NULL) //se non esiste l'assoc_array legato al conto lo crea - { - codivae = new TAssoc_array; - //aggiunge all'assoc_array conti il suo elemento assoc_array codivae..ha un assoc_array.. - //..di assoc_array! - conti.add(codconto, codivae); - } - - const TString4 codiva = pn.iva(l).get(RMI_CODIVA); //prende il codice iva dalla riga iva - //aggiungere qui eventuale codice intero di indetraibilita' - - //ad ogni codiva presente in codivae lega un importo che risultera' la somma di tutti gli.. - //..importi con lo stesso conto e codice iva - real* tot_imp = (real*) codivae->objptr(codiva); - if (tot_imp == NULL) //se non esiste l'importo legato al codice iva lo crea - { - tot_imp = new real; - //aggiunge all'assoc_array codivae il suo elemento real tot_imp - codivae->add(codiva, tot_imp); - } - - //accresce l'importo tot_imp relativo alla coppia codiva+codconto corrente - const real imponibile = pn.iva(l).get_real(RMI_IMPONIBILE); - const real imposta = pn.iva(l).get_real(RMI_IMPOSTA); - const TString4 codind = pn.iva(l).get(RMI_TIPODET); - pn.analizza_riga_IVA(imponibile, imposta, caus, anno, codiva, codind, imp_detr, - iva_detr, imp_indetr, iva_indetr); - *tot_imp += imp_detr + imp_indetr + iva_indetr; - //aggiungere qui eventuale imposta - } - - TRecord_text recrigheiva; //istanzia il tipo record corretto da scrivere sul trasfilerighe - recrigheiva.set_type("I"); - int nrighe = 0; - - TRelation rel_rmoviva(LF_RMOVIVA); - rel_rmoviva.add(LF_MOV, "NUMREG==NUMREG"); - TCursor cur_rmoviva(&rel_rmoviva); - cur_rmoviva.curr(LF_MOV) = cur.curr(); - - const long analrigheiva_items = analmov.body().rows(); - - for (int n = 1; n <= analrigheiva_items; n++) - { - //scanning delle righe analitiche per estrarne i conti e controllare se compaiono nell'assoc_array.. - //..dei conti riempito con i conti trovati nelle righe iva - const TRectype& riga = analmov.body().row(n); - const TString& codconto = riga.get(RMOVANA_CODCONTO); - TAssoc_array* codivae = (TAssoc_array*) conti.objptr(codconto); //assoc_array codivae del codconto - - //se ha almeno un codice iva associato a questo conto nell'assoc_array dei conti.. - if (codivae != NULL) - { - //..prende l'importo della riga analitica.. - real importo_riga = riga.get_real(RMOVANA_IMPORTO); - //..lo ridistribuisce secondo le percentuali iva - TGeneric_distrib distributore(importo_riga, TCurrency::get_firm_dec()); - - FOR_EACH_ASSOC_OBJECT((*codivae), h, k, imp) - { - const real& imp_iva = *(real*)imp; - distributore.add(imp_iva); - } - - //crea una riga iva dal cursore, con numreg = numreg della testata del mov originale - TRectype& rigaiva = cur_rmoviva.curr(LF_RMOVIVA); - rigaiva.put(RMI_NUMREG, pn.curr().get(MOV_NUMREG)); - - //scan dell'assoc_array ridistribuito e inserimento dei valori nella riga iva appena creata - FOR_EACH_ASSOC_OBJECT((*codivae), hi, ki, impi) - { - rigaiva.put(RMI_NUMRIG, ++nrighe); - rigaiva.put(RMI_GRUPPO, codconto.mid(0,3)); - rigaiva.put(RMI_CONTO, codconto.mid(3,3)); - rigaiva.put(RMI_SOTTOCONTO, codconto.mid(6,6)); - const TBill zio(rigaiva); - rigaiva.put(RMI_TIPOC, zio.tipo()); - rigaiva.put(RMI_IMPONIBILE, distributore.get()); - rigaiva.put(RMI_CODIVA, ki); - - //deve sottrarre gli importi trovati dalle righe iva originali - sottrai_iva(pn, rigaiva); - - //scrittura delle righe di tipo I; notare che il cur passato alla autoload altri non e'.. - //..che la rigaiva appena completata - trasfilerighe->autoload(recrigheiva, cur_rmoviva); - - //procedura ignorante per stringare il codice clifo - if (zio.tipo() > ' ') - { - const long sottoconto = zio.sottoconto(); - TString cf; - cf.format("%ld", sottoconto); - recrigheiva.add(cf, 7); - } - - recrigheiva.add(riga.get(RMOVANA_DESCR).left(40), 8); //descrizione riga iva = riga anale corrente - recrigheiva.add(riga.get(RMOVANA_CODCMS), 13); //commessa presa dalla riga analitica corrente - - //procedura per scrivere la fase che deve essere spezzata in due per sottoprogetto ed edizione - const TString& codfase = riga.get(RMOVANA_CODFASE); - if (codfase.full()) - { - recrighe.add(codfase.left(4), 14); - recrighe.add(codfase.mid(4,4), 15); - } - - //procedura per ricavare la voce di spesa - TString uncle = zio.string(0x8); - const TString& vocespesa = get_vocespesa(uncle); - recrighe.add(vocespesa, 16); - - trasfilerighe->write(recrigheiva); - } - } //if(codivae!=.. - } //for(analmov.rows.. - - const long righeiva_items = pn.iva_items(); - if (righeiva_items > 0) - { - //deve trasferire le righe iva rimaste dopo la sottrazione degli importi dovuti alle righe analitiche - for (int m = 0; m < righeiva_items; m++) - { - const TRectype& riga = pn.iva(m); - if (!riga.get_real(RMI_IMPOSTA).is_zero()) - { - const TBill uncle(riga); - cur_rmoviva.curr() = riga; - trasfilerighe->autoload(recrigheiva, cur_rmoviva); - recrigheiva.add(uncle.tipo(), 6); //tipocf - recrigheiva.add(uncle.descrizione().left(40), 8); //descrizione della riga iva = descrizione conto - //procedura per ricavare la voce di spesa - TString zio = uncle.string(0x8); - const TString& vocespesa = get_vocespesa(zio); - recrighe.add(vocespesa, 14); - trasfilerighe->write(recrigheiva); - } - } - } - return true; -} - -bool TInvioP::sottrai_iva(TMovimentoPN& pn, const TRectype& rigaiva) -{ - const TBill zio(rigaiva); - const real imposta = rigaiva.get_real(RMI_IMPOSTA); - - int k; - //caso fortunato - //scandisce gli elementi dell'array;se ne trova uno (k-esimo) con conto ed importo coincidenti.. - //..con quelli passati al metodo, azzera l'importo di tale elemento dell'array - for (k = 0; k < pn.iva_items(); k++) - { - TRectype& iva_k = pn.iva(k); - const TBill conto_k(iva_k); - const real imposta_k = iva_k.get_real(RMI_IMPOSTA); - if (conto_k == zio && imposta_k == imposta) - { - iva_k.zero(RMI_IMPOSTA); - return true; - } - } - - //caso sfortunato - //in questo caso gli importi dell'elemento k-esimo dell'array e passato al metodo NON coincidono - real residuo = imposta; - int ultima_riga_buona = -1; - - for (k = 0; k < pn.iva_items() && !residuo.is_zero(); k++) - { - TRectype& iva_k = pn.iva(k); - const TBill conto_k(iva_k); - - if (conto_k == zio) - { - const real imposta_k = iva_k.get_real(RMI_IMPOSTA); - if (residuo >= imposta_k) - { - residuo -= imposta_k; - iva_k.zero(RMI_IMPOSTA); - } - else - { - iva_k.put(RMI_IMPOSTA, imposta_k - residuo); - residuo = ZERO; - } - ultima_riga_buona = k; - } - } - //alla fine del ciclo sull'array resta un residuo non nullo.. - if (!residuo.is_zero()) - { - if (ultima_riga_buona >= 0) - { - TRectype& iva_k = pn.iva(k); - iva_k.put(RMI_IMPOSTA, -residuo); - } - } - return true; -} - -void TInvioP::stringa_grcosot(TRecord_text& recrighe, const TString& zio) -{ - TString8 grcosot; - long gcs = 0; - - gcs = atoi(zio.left(3)); - grcosot.format("%d", gcs); - recrighe.add(grcosot, 3); //gruppo - - gcs = atoi(zio.mid(3,3)); - grcosot.format("%d", gcs); - recrighe.add(grcosot, 4); //conto - - gcs = atoi(zio.mid(6,6)); - grcosot.format("%d", gcs); - recrighe.add(grcosot, 5); //sottoconto -} - -// Calcola il totale del documento tenendo conto del segno della prima riga e di quella delle -// ritenute sociali sulla causale -real TInvioP::totale_documento(TMovimentoPN& pn, const bool includi_ritenute) const -{ - //testata del movimento di prima nota - const TRectype& mov = pn.curr(); - - real tot = mov.get_real(MOV_TOTDOC); // Legge totale - //i conti sulle ritenute li deve fare solo se il movimento e' iva!! - if (pn.iva_items() > 0) - { - if (includi_ritenute) - { - const real ritfis = mov.get_real(MOV_RITFIS); - tot += ritfis; // Somma ritenute fiscali - - const real ritsoc = mov.get_real(MOV_RITSOC); - - if (!ritsoc.is_zero()) - { - TCausale caus(mov.get(MOV_CODCAUS)); - const bool swapt = test_swap(caus, false); // Totale invertito ? - const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ? - if (swapt ^ swaps) // Somma ritenute sociali con segno - tot -= ritsoc; - else - tot += ritsoc; - } - } - } - else //movimenti non iva; calcolo delle ritenute - { - TCausale caus(mov.get(MOV_CODCAUS)); - const char sez = caus.sezione_clifo(); - bool tot_is_zero = tot.is_zero(); - TImporto totdoc(sez, tot); - for (int i = 0; i < pn.cg_items(); i++) - { - const TRectype& rmov = pn.cg(i); - const TBill conto(rmov); - const TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO)); - - if (tot_is_zero && rmov.get_char(RMV_TIPOC) > ' ') - totdoc += importo; - else - { - if (includi_ritenute && (cerca_fiscali(conto) || cerca_sociali(conto))) - totdoc += importo; //valore da stampare nella colonna Tot.fattura con ritenute - } - } - tot = totdoc.valore(); - } - return tot; -} - -// Controlla sulla causale se il segno del totale documento (ritsoc=FALSE) -// o quello delle ritenute sociali (ritsoc=TRUE) e' invertito rispetto al normale -bool TInvioP::test_swap(TCausale& caus, bool ritsoc) const -{ - const char sez = ritsoc ? caus.sezione_ritsoc() : caus.sezione_clifo(); - const bool s = (caus.iva() == iva_vendite) ^ (sez == 'D'); - return s; -} - -bool TInvioP::cerca_conto(const TBill& bill, const TAssoc_array& assoc, const char tipoconto) const -{ - TToken_string key(15); - key.add(tipoconto); //il primo char della tokenstring e' il tipoconto (Fiscale o Sociale) - - key.add(bill.gruppo()); - if (assoc.is_key(key)) - return true; - - key.add(bill.conto()); - if (assoc.is_key(key)) - return true; - - key.add(bill.sottoconto()); - if (assoc.is_key(key)) - return true; - - return false; -} - -int TInvioP::cerca_costo(const TBill& bill) const -{ - if (cerca_conto(bill, _costi, 'C')) - return 1; - else - return 0; -} - -int TInvioP::cerca_pagamento(const TBill& bill) const -{ - if (cerca_conto(bill, _pagamenti, 'P')) - return 2; - else - return 0; -} - -bool TInvioP::cerca_fiscali(const TBill& bill) const -{ - if (bill.tipo() > ' ') //non si vogliono i conti tipo Cliente Fornitore - return false; - - return cerca_conto(bill, _fiscali, 'F'); -} - -bool TInvioP::cerca_sociali(const TBill& bill) const -{ - if (bill.tipo() > ' ') //non si vogliono i conti tipo Cliente Fornitore - return false; - - return cerca_conto(bill, _sociali, 'S'); -} - -void TInvioP::lettura_conti(TAssoc_array& assoc, const char tipoconto) -{ - TConfig conti("ca3600a.ini","Pdcc"); //paragrafo da scandire nell'ini - TAssoc_array& vars = conti.list_variables(); - - FOR_EACH_ASSOC_STRING(vars, h, k, val) //riempie l'assoc con i soli valori del paragrafo dell'ini - { - if (*val == tipoconto) //mette nell'assocarray solo i conti corrispondenti al tipoconto passato - assoc.add(val); - } -} - -void TInvioP::calcola_imposte(const real& importo, const real& imposta, - const TString& codind, real& iva_det, real& iva_ind) const -{ - iva_det = imposta; - iva_ind = ZERO; - - //esiste un codice di indetraibilita'? - if (codind.full()) - { - real perc = ZERO; - const TRectype& rec = cache().get("%DET", codind); - if (rec.empty()) - { - if (strchr("139", codind[0]) != NULL) // Clausola di salvaguardia - perc = CENTO; - } - else - { - if (rec.get_int("I0") > 0) - perc = rec.get_real("R0"); - } - //valori delle varie ive - iva_ind = imposta * perc / CENTO; - iva_ind.round(2); - iva_det = imposta - iva_ind; - } -} - -bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec, real& imponibile, real& totdoc, real& totpagato, real& iva_indetraibile) const -{ - totpagato = pag_rec.get_real(PAGSCA_IMPORTO); - - TMovimentoPN pn; - pn.curr().put(MOV_NUMREG, nreg); - bool ok = nreg > 0 && pn.read() == NOERR; - if (ok) - { - //percentuale di pagamento sul totale documento senza ritenute - const real totdoc_no_rit = totale_documento(pn, false); - const real perc_ritenute = totpagato / totdoc_no_rit; - //Movimenti CON SALDACONTO - //se movimento IVA.. - if (pn.iva_items() > 0) - { - real imposta; - const TRectype& movfat = pn.curr(); - - real ritfis = movfat.get_real(MOV_RITFIS); //ritenute sulla fattura: verranno pagate percentualmente - if (perc_ritenute < UNO) - { - ritfis *= perc_ritenute; - ritfis.round(2); - } - totpagato += pag_rec.get_real(PAGSCA_RITENUTE); //ritenute eventuali sul pagamento - totpagato += ritfis; - - //Le ritenute sociali invece vanno testate con la test_swap.. - real ritsoc = movfat.get_real(MOV_RITSOC); - if (perc_ritenute < UNO) - { - ritsoc *= perc_ritenute; - ritsoc.round(2); - } - ritsoc += pag_rec.get_real(PAGSCA_RITSOC); - - if (!ritsoc.is_zero()) - { - const TRectype& mov = pn.curr(); - TCausale caus(mov.get(MOV_CODCAUS)); - const bool swapt = test_swap(caus, false); // Totale invertito ? - const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ? - if (swapt ^ swaps) // Somma ritenute sociali con segno - totpagato -= ritsoc; - else - totpagato += ritsoc; - } - for (int i = 0; i < pn.iva_items(); i++) - { - const TRectype& rmoviva = pn.iva(i); - const TBill conto(rmoviva); - - if (conto.indicatore_bilancio() != 5) - { - const real importo = rmoviva.get_real(RMI_IMPONIBILE); - const real iva = rmoviva.get_real(RMI_IMPOSTA); - //trattamento delle ive indetraibili! - const TString& codind = rmoviva.get(RMI_TIPODET); - - imponibile += importo; - - real iva_det, iva_ind; - //calcola i valori dell'iva detraibile e delle ive indetraibili in diverse percentuali - calcola_imposte(importo, iva, codind, iva_det, iva_ind); - //se esiste un'iva indetraibile.. - if (iva_ind != ZERO) - { - iva_indetraibile += iva_ind; - imponibile += iva_ind; - } - //l'iva detraibile va sempre bene sommata alle imposte - imposta += iva_det; - } - } - totdoc = totale_documento(pn); //tot doc con ritenute fiscali + ritenute sociali - - } //if pn.iva_items().. - else //NON iva - { - totdoc = totale_documento(pn); //tot doc con ritenute fiscali + ritenute sociali - imponibile = totdoc; //nel caso di non iva - - TCausale caus(pn.curr().get(MOV_CODCAUS)); - TImporto totpag(caus.sezione_clifo(), totpagato); - for (int i = 0; i < pn.cg_items(); i++) - { - const TRectype& rmov = pn.cg(i); - const TBill conto(rmov); - if (cerca_fiscali(conto) || cerca_sociali(conto)) - { - real imp = rmov.get_real(RMV_IMPORTO); - if (perc_ritenute < UNO) - { - imp *= perc_ritenute; - imp.round(2); - } - const TImporto importo(rmov.get_char(RMV_SEZIONE), imp); - totpag += importo; //valore da stampare nella colonna Tot.fattura con ritenute - } - } - totpagato = totpag.valore(); - } - } //if (pn.read() == NOERR - return ok; -} - -real TInvioP::calcola_pagamento(TRectype& curpag_rec, real& iva_indetraibile) -{ - //deve costruirsi la riga di partita che riguarda il documento di origine - //per prima cosa crea tale riga a partire dal pagamento, che ha una chiave lunghissima... - TToken_string key_part; - key_part.add(curpag_rec.get(PAGSCA_TIPOC)); - key_part.add(curpag_rec.get(PAGSCA_GRUPPO)); - key_part.add(curpag_rec.get(PAGSCA_CONTO)); - key_part.add(curpag_rec.get(PAGSCA_SOTTOCONTO)); - key_part.add(curpag_rec.get(PAGSCA_ANNO)); - key_part.add(curpag_rec.get(PAGSCA_NUMPART)); - key_part.add(curpag_rec.get(PAGSCA_NRIGA)); - //..ecco il record delle partite.. - const TRectype& rec_partite = cache().get(LF_PARTITE, key_part); - //..da cui prende nreg - const long nreg = rec_partite.get_long(PART_NREG); - //se nreg esiste... - - //dichiariamo una serie di simpatici real utilizzati in seguito - real totdoc,imponibile,totpagato; - - if (calcola_imponibile_totdoc(nreg, curpag_rec, imponibile, totdoc, totpagato, iva_indetraibile)) - { - const real percentuale = totpagato /totdoc; - //cerca se esiste una fattura da ricevere anteriore alla fattura da pagare - const long fdr = calcola_fattura_originale(nreg); - //se la trova deve tenerne conto in quanto la presente fattura (nreg) potrebbe pagare solo.. - //..una parte della fdr originale - if (fdr != nreg) - { - real imponibile_fdr, totdoc_fdr, totpagato_fdr, iva_indetraibile_fdr; - //riutilizza la calcola_imponibile_totdoc per l'fdr;si fa notare che in questo caso gli.. - //..ultimi due parametri del metodo sono del tutto inutili - if (calcola_imponibile_totdoc(fdr, curpag_rec, imponibile_fdr, totdoc_fdr, totpagato_fdr, iva_indetraibile_fdr)) - { - const real rapporto_pagati = totdoc / totdoc_fdr; - const real rapporto_imponibili = imponibile_fdr / imponibile; - //la fattura con totdoc paga una parte di una precedente fdr con totdoc maggiore! - //in questo caso totpagato e' quello della fattura e deve uscire senza ricalcolare.. - //..percentuali e cazzi vari (funziona ststisticamente!) - if (rapporto_pagati >= 0.7) - imponibile = imponibile_fdr; - - if (rapporto_imponibili < 0.7 || rapporto_imponibili > 0.85) - iva_indetraibile = ZERO; - } - } //if(fdr!=nreg.. - else //se non esiste una fdr eventuali ive indetraibili non sussistono - iva_indetraibile = ZERO; - - //calcolo finale del pagato - totpagato = imponibile * percentuale; - totpagato.round(2); - - } //if(calcola_imponibile_totdoc(nreg,... - - return totpagato; -} - -long TInvioP::calcola_fattura_originale(long nreg) const -{ - //prende il movimento del pagamento - const TRectype& mov = cache().get(LF_MOV, nreg); - - TToken_string key; - key.add(mov.get(MOV_DCODNUM)); - key.add(mov.get(MOV_DANNO)); - key.add(mov.get(MOV_DPROVV)); - key.add(mov.get(MOV_DNDOC)); - //crea il documento da cui deriva tale movimento (per il CSA e' in genere una fattura) - - TRecord_array doc(key, LF_RIGHEDOC); - for (int i = 1; i <= doc.rows(); i++) - { - const TRectype& rdoc = doc.row(i); - const TString& dacodnum = rdoc.get(RDOC_DACODNUM); - if (dacodnum.full()) - { - const TRectype& num_rec = cache().get("%NUM", dacodnum); - if (num_rec.get_bool("B3")) - { - key = rdoc.get(RDOC_DAPROVV); - key.add(rdoc.get(RDOC_DAANNO)); - key.add(dacodnum); - key.add(rdoc.get(RDOC_DANDOC)); - //cerca da quale documento deriva la fattura (la prima riga che trova e' ok) - const TRectype& original_doc = cache().get(LF_DOC, key); - //se trova il documento origine (per il CSA e' in genere una FDR) -> prende il suo nreg.. - //..come nreg da ritornare (attenzione che se il doc originale non e' stato contabilizzato.. - //..nreg diventa 0!) - if (!original_doc.empty()) - { - nreg = original_doc.get_long(DOC_NUMREG); - } - } - break; - } - } - return nreg; -} - -// oggetto che serve per memorizzare importo e flag acc/sal dei pagamenti.. -//..(usato nel trasferimento pagamenti) -struct TPay_info : public TObject -{ - real _somma; - char _as; -}; - -bool TInvioP::i_proforma_pagamenti() -{ - TInvioP_file* trasfilepag = apri_file("pagament"); - - TRectype da(LF_MOV); - TRectype a(LF_MOV); - da.put(MOV_DATAREG, _dataini); - a.put(MOV_DATAREG, _datafin); - TRelation rel(LF_MOV); - rel.add(LF_CAUSALI, "CODCAUS==CODCAUS"); - TCursor cur(&rel, "", 2, &da, &a); - const long cur_items = cur.items(); - - if (cur_items != 0) - { - //se ha almeno un movimento carica lo sheet dei conti che gli servira' in seguito nel calcolo.. - //..delle ritenute - lettura_conti(_fiscali, 'F'); - lettura_conti(_sociali, 'S'); - lettura_conti(_costi, 'C'); - lettura_conti(_pagamenti, 'P'); - - TProgind pi(cur_items, "Trasferimento pagamenti...", true, true); - - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - if (!pi.addstatus(1)) - break; - - //pagamenti saldacontati! vedi l'else per quelli non saldacontati - const tipo_movimento tipomov = (tipo_movimento)cur_rec.get_int(MOV_TIPOMOV); - if (tipomov == tm_pagamento || tipomov == tm_nota_credito || tipomov == tm_pagamento_insoluto) - { - //attraverso le partite,noto il MOV_NUMREG,riesce a collegarsi al pagamento in LF_PAGSCA - TRelation relpart(LF_PARTITE); - TRectype da(LF_PARTITE); - da.put(PART_NREG, cur_rec.get(MOV_NUMREG)); - TCursor curpart(&relpart, "", 2, &da, &da); - const long curpart_items = curpart.items(); - //se trova la partita relativa al numreg... - if (curpart_items != 0) - { - curpart.freeze(); - TRectype& curpart_rec = curpart.curr(); - TRelation relpag(LF_PAGSCA); - TRectype da(LF_PAGSCA); - //..collega i pagamenti filtrando con i parametri estratti dalle partite - for (curpart = 0; curpart.pos() < curpart_items; ++(curpart)) - { - da.put(PAGSCA_TIPOC, curpart_rec.get(PART_TIPOCF)); - da.put(PAGSCA_GRUPPO, curpart_rec.get(PART_GRUPPO)); - da.put(PAGSCA_CONTO, curpart_rec.get(PART_CONTO)); - da.put(PAGSCA_SOTTOCONTO, curpart_rec.get(PART_SOTTOCONTO)); - da.put(PAGSCA_ANNO, curpart_rec.get(PART_ANNO)); - da.put(PAGSCA_NUMPART, curpart_rec.get(PART_NUMPART)); - const int nrigapart = curpart_rec.get_int(PART_NRIGA); - TString80 filtro; - filtro.format("NRIGP == %d", nrigapart); - TCursor curpag(&relpag, filtro, 1, &da, &da); - const long curpag_items = curpag.items(); - - real iva_indet = ZERO; //valore dell'eventuale iva indetraibile - - //se trova i pagamenti,che sono alla fin fine cio' che cerca... - if (curpag_items != 0) - { - TAssoc_array pagame; - pagame.destroy(); - curpag.freeze(); - TRectype& curpag_rec = curpag.curr(); - for (curpag = 0; curpag.pos() < curpag_items; ++(curpag)) - { - TString80 indice = curpag_rec.get(PAGSCA_ANNO); - indice << '|' << curpag_rec.get(PAGSCA_NUMPART); - indice << '|' << curpag_rec.get(PAGSCA_NRIGA); - - TPay_info* pi = (TPay_info*)pagame.objptr(indice); - if (pi == NULL) - { - pi = new TPay_info; - pi->_as = 'A'; - pagame.add(indice, pi); - } - - //ricava l'importo del pagamento e lo aggiunge al memorizzatore - const real importo_pagato = calcola_pagamento(curpag_rec, iva_indet); - pi->_somma += importo_pagato; - if (curpag_rec.get_char(PAGSCA_ACCSAL) == 'S') - pi->_as = 'S'; - } - - // scrive i record risultanti - for (TPay_info* pi = (TPay_info*)pagame.first_item(); pi != NULL; pi = (TPay_info*)pagame.succ_item()) - { - TToken_string keypart; - keypart.add(curpart_rec.get(PART_TIPOCF)); - keypart.add(curpart_rec.get(PART_GRUPPO)); - keypart.add(curpart_rec.get(PART_CONTO)); - keypart.add(curpart_rec.get(PART_SOTTOCONTO)); - keypart.add(pagame.get_hashobj()->key()); - const TRectype& fattura = cache().get(LF_PARTITE, keypart); - _nregpag = cur_rec.get_long(MOV_NUMREG); //registrazione del movimento di pagamento - - //deve cercare la prima registrazione da cui deriva il pagamento.. - const long nregfatt = fattura.get_long(PART_NREG); - _nregcosto = calcola_fattura_originale(nregfatt); - _importo = pi->_somma; - //acconto/saldo in modo standard - _accsal = pi->_as; - //Casino plutonico dell'acconto-saldo in ottica CSA - //Se il doc in esame discende da una FDR (fattura da ricevere) e' necessario.. - //..cercare tutte le righe dei documenti che pagano tale FDR e sommare gli importi di tali.. - //..rdocs con quello corrente; solo se tale somma risulatsse >= del totale delle righe.. - //..della FDR originale il flag _accsal deve essere messo a saldo 'S' - if (_nregcosto != nregfatt) - { - //deve risalire al documento FDR del movimento _nregcosto - const TRectype& mov_fdr = cache().get(LF_MOV, _nregcosto); - - const TString8 fdr_codnum = mov_fdr.get(MOV_DCODNUM); - const int fdr_anno = mov_fdr.get_int(MOV_DANNO); - const char fdr_provv = mov_fdr.get_char(MOV_DPROVV); - const long fdr_ndoc = mov_fdr.get_long(MOV_DNDOC); - - //adesso che ha la chiave del documento padre FDR, deve crearsi la query.. - //..su RDOC alla ricerca di tutte le righe doc che discendono dall'FDR.. - //..In pratica cerca le "sorelle" dell'attuale fattura nregfatt - TString query; - query << "USE RDOC KEY 4"; - query << "\nFROM DACODNUM=" << fdr_codnum << " DAANNO=" << fdr_anno << " DAPROVV=" << fdr_provv << " DANDOC=" << fdr_ndoc; - query << "\nTO DACODNUM=" << fdr_codnum << " DAANNO=" << fdr_anno << " DAPROVV=" << fdr_provv << " DANDOC=" << fdr_ndoc; - - TISAM_recordset recset(query); - const int righe_delle_sorelle = recset.items(); - TAssoc_array sorelle; - TToken_string key; - //cerco la mia data di fattura; - const TDate datadoc_fattura = cache().get(LF_MOV, nregfatt, MOV_DATAREG); - //dalle righe risale ai documenti di tali righe (che posssono essere meno) - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) - { - key = recset.get(RDOC_PROVV).as_string(); - key.add(recset.get(RDOC_ANNO).as_string()); - key.add(recset.get(RDOC_CODNUM).as_string()); - key.add(recset.get(RDOC_NDOC).as_string()); - - const TDate datadoc = cache().get(LF_DOC, key, DOC_DATADOC); - //se non sono l'ultima fattura (sorella piu' giovane) allora e'.. - //..sicuramente Acconto! Quindi esce dai cicli for e if - if (datadoc > datadoc_fattura) - { - sorelle.destroy(); - _accsal = 'A'; - break; - } - //accresce l'array delle sorelle - sorelle.add(key, key); - } - //tutto il casino s'ha da fare solo in caso ci sia piu' di una fattura.. - //.."sorella" di quella in esame - if (sorelle.items() > 1) - { - real importo_totale_sorelle; - //giro su tutti i documenti delle sorelle - FOR_EACH_ASSOC_OBJECT(sorelle, obj, chiave, itm) - { - TToken_string& ts = *(TToken_string*)itm; - TDocumento sorella(ts.get_char(0), ts.get_int(1), ts.get(2), ts.get_long(3)); - //per ogni documento deve cercare le righe discendenti dall'FDR - for (int r = 1; r <= sorella.rows(); r++) - { - const TRiga_documento nipotina = sorella[r]; - //servono solo le righe discendenti dall'FDR madre! - if (nipotina.get(RDOC_DACODNUM) == fdr_codnum && nipotina.get_int(RDOC_DAANNO) == fdr_anno && - nipotina.get_char(RDOC_DAPROVV) == fdr_provv && nipotina.get_long(RDOC_DANDOC) == fdr_ndoc) - { - const real importo_da_aggiungere = nipotina.importo(true, false); //importo scontato netto - importo_totale_sorelle += importo_da_aggiungere; - } - } - } //FOR_EACH_ASSOC.. - - //Se arriva fin qui la fattura in esame e' la sorella piu' giovane; adesso.. - //..deve controllare se gli importi di tutte le sorelle sommati saldano.. - //..o meno l'importo dell'originale mamma FDR... - - //intanto ha bisogno del totale documento FDR originale a partire dal movimento FDR... - real totale_fdr = ZERO; - TMovimentoPN movimento_fdr; - movimento_fdr.curr().put(MOV_NUMREG, _nregcosto); - if (movimento_fdr.read() == NOERR) - totale_fdr = totale_documento(movimento_fdr, false); //non include ritenute - - real rimanenza = totale_fdr - importo_totale_sorelle; - //arrotonda - rimanenza.round(); - - //Se l'importo e' inferiore la FDR non e' ancora stata saldata (nasceranno.. - //..una o piu' sorelle per saldare mamma FDR in futuro) - if (rimanenza > ZERO) - _accsal = 'A'; - //Se l'importo e' >= -> la mamma e' saldata e non sono previste ulteriori.. - //..sorelle (per la felicita' del papa'!) - else - _accsal = 'S'; - - } //if(sorelle.items()>1.. - - } //if(_nregcosto!=nregfatt.. - - - //..e finalmente scrive 'sta minchia di riga - TRecord_text recpag; - recpag.set_type("G"); - trasfilepag->autoload(recpag, curpag); - trasfilepag->write(recpag); - - //se ha una riga di iva indetraibile dovuta al cambio regime fiscale 2005->2006.. - //..deve aggiungere una ulteriore riga!! - if (iva_indet > ZERO) - { - _nregcosto = nregfatt; - _importo = iva_indet; - _accsal = 'S'; - recpag.set_type("G"); - trasfilepag->autoload(recpag, curpag); - trasfilepag->write(recpag); - } - } //for( - - }//if curpag_items.. - }//for curpart =.. - }//if curpart_items.. - - }//if tipomov ==.. - if (tipomov == tm_nessuno) //tocca ai pagamenti NON saldacontati (procedura analoga a quella della stampa del pagato) - { - const long numregcg = cur_rec.get_long(MOV_NUMREG); - - //cerca un record di MOVANA che abbia numregcg = nreg;usa il nuovo metodo fighissimo.. - //..con la isam query - TString& query = get_tmp_string(); - query << "USE MOVANA KEY 3\n"; - query << "FROM NUMREGCG=" << numregcg << "\n"; - query << "TO NUMREGCG=" << numregcg; - - TISAM_recordset movana(query); - const TRecnotype items = movana.items(); - - if (items > 0) - { - if (items > 1) - error_box(TR("Esiste piu' di un movimento analitico collegato al movimento contabile %ld"),numregcg); - - movana.move_last(); //si posiziona sul record corretto - - //crea il movana legato al mov - const TAnal_mov anal_mov(cur_rec); - const TRecord_array& anal_rows = anal_mov.body(); - - for (int j = 1; j <= anal_rows.rows(); j++) //scansiona righe analitiche.. - { - const TRectype& anal_row = anal_rows[j]; - - //prende il conto sulla riga analitica e lo confronta con quelli della configurazione - const TString& conto_riga_analitica = anal_row.get(RMOVANA_CODCONTO); - const int gruppo_anal = atoi(conto_riga_analitica.left(3)); - const int conto_anal = atoi(conto_riga_analitica.mid(3,3)); - const long sottoconto_anal = atol(conto_riga_analitica.mid(6,6)); - - const TBill conto(gruppo_anal, conto_anal, sottoconto_anal); - int tipo = cerca_costo(conto) || cerca_pagamento(conto); - if (tipo > 0) - { - const char sezione = anal_row.get_char(RMOVANA_SEZIONE); - const real valore = anal_row.get_real(RMOVANA_IMPORTO); - TImporto imp(sezione, valore); - - switch (tipo) - { - case 1:imp.normalize('D');break; - case 2:imp.normalize('A');break; - default:break; - } - _nregpag = numregcg; - _nregcosto = numregcg; - _importo = imp.valore(); - //deve stabilire adesso se acconto o saldo controllando gli importi - _accsal = 'S'; - - //e finalmente aggiunge il record al file di esportazione - TRecord_text recpag; - recpag.set_type("G"); - trasfilepag->autoload(recpag, *movana.cursor()); - trasfilepag->write(recpag); - } //if (tipo > 0.. - - } //for(j0... - - } //else if tipomov ==.. - - }//for cur =.. - }//if cur_items.. - - chiudi_file(trasfilepag); - return true; -} - -bool TInvioP::i_proforma_clifor(char tipocf) -{ - TInvioP_file* trasfile = NULL; - - TString progind_string = "Trasferimento "; - - if (tipocf == 'C') - { - trasfile = apri_file("clienti"); - progind_string << "clienti"; - } - else - { - trasfile = apri_file("fornit"); - progind_string << "fornitori"; - } - - TString80 filtro = ""; - filtro.format("TIPOCF == \"%c\"", tipocf); - TRelation rel(LF_CLIFO); - rel.add(LF_COMUNI, "STATO==STATOCF|COM==COMCF", 1); - TCursor cur(&rel, filtro); - const long cur_items = cur.items(); - - if (cur_items != 0) - { - progind_string << "..."; - TProgind pi(cur_items, progind_string, true, true); - - cur.freeze(); - TRectype& cur_rec = cur.curr(); - for (cur = 0; cur.pos() < cur_items; ++(cur)) - { - pi.addstatus(1); - if (pi.iscancelled()) - break; - - TRecord_text rec; - rec.set_type("C"); - trasfile->autoload(rec, cur); - trasfile->write(rec); - } - } - chiudi_file(trasfile); - return true; -} - -//"metodo dei metodi":in base ai parametri della maschera esegue la procedura indicata -void TInvioP::invio_proforma() -{ - if (_msk->get_bool(F_MOVIMENTI)) - i_proforma_movimenti(); - if (_msk->get_bool(F_PAGAMENTI)) - i_proforma_pagamenti(); - if (_msk->get_bool(F_CLIENTI)) - i_proforma_clifor(); - if (_msk->get_bool(F_FORNITORI)) - i_proforma_clifor('F'); - if (_msk->get_bool(F_CONTI)) - i_proforma_conti(); -} - -bool TInvioP::create() -{ - _msk = new TInvioP_mask(); - _configfile = new TConfig("proforma.ini"); - return TSkeleton_application::create(); -} - -bool TInvioP::destroy() -{ - if (_configfile != NULL) - delete _configfile; - delete _msk; - - return TSkeleton_application::destroy(); -} - -void TInvioP::main_loop() -{ - //il programma si puo' usare SOLO se in contabilita' analitica si usa il piano dei conti contabile - TConfig& cfg = ca_config(); - const bool use_pdcc = cfg.get_bool("UsePdcc"); - if (!use_pdcc) - { - error_box(TR("Programma funzionante SOLO se in contabilita' analitica si usa il piano dei conti contabile")); - return; - } - - TFilename configname = "cg7200a.ini"; //file configurazione della maschera - configname.custom_path(); - TConfig configfile(configname); - _msk->set(F_DATAINI, configfile.get("DATA","OPZIONI")); - _msk->set(F_DESTINAZIONE, configfile.get("PERCORSO","OPZIONI")); - - while (_msk->run()!=K_QUIT) - { - configfile.set("DATA", _msk->get_date(F_DATAFIN),"OPZIONI"); - configfile.set("PERCORSO", _msk->get(F_DESTINAZIONE),"OPZIONI"); - _dataini = _msk->get_date(F_DATAINI); - _datafin = _msk->get_date(F_DATAFIN); - const char tipoinvio = _msk->get(F_TIPOINVIO)[0]; - if (tipoinvio == 'P') - invio_proforma(); //dopo aver preso i parametri dalla maschera chiama il "metodo dei metodi" - } -} - -int cg7200(int argc, char **argv) -{ - TInvioP a; - a.run(argc, argv, "Invio dati contabilità a Proforma"); - - return 0; -} diff --git a/cg/cg7200a.h b/cg/cg7200a.h deleted file mode 100755 index 4f35bf6a5..000000000 --- a/cg/cg7200a.h +++ /dev/null @@ -1,23 +0,0 @@ -// invio dati ad altra procedura (Proforma) - -#define F_CODDITTA 301 -#define F_RAGSOC 302 -#define F_MOVIMENTI 303 -#define F_CLIENTI 304 -#define F_FORNITORI 305 -#define F_CONTI 306 -#define F_PAGAMENTI 307 -#define F_TIPOINVIO 308 -#define F_DESTINAZIONE 309 -#define F_DATAINI 310 -#define F_DATAFIN 311 -#define F_RIPRISTINA 312 -#define F_DATARIPRISTINO 313 - -#define F_PDCC 315 - -#define S_TIPO 101 -#define S_GRUPPO 102 -#define S_CONTO 103 -#define S_SOTTOCONTO 104 -#define S_DESCRIZIONE 105 diff --git a/cg/cg7200a.uml b/cg/cg7200a.uml deleted file mode 100755 index 331dba48a..000000000 --- a/cg/cg7200a.uml +++ /dev/null @@ -1,234 +0,0 @@ -#include "cg7200a.h" - -TOOLBAR "" 0 -2 0 2 - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -11 "" -END - -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -11 "" -END - -ENDPAGE - -PAGE "Invio dati contabilita'" -1 -1 78 20 - -GROUPBOX DLG_NULL 76 3 -BEGIN - PROMPT 2 1 "@bDitta corrente" -END - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 3 2 "Codice " - FLAGS "FD" - USE LF_NDITTE - INPUT CODDITTA F_CODDITTA - OUTPUT F_RAGSOC RAGSOC - CHECKTYPE REQUIRED -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 23 2 "" - FLAGS "D" -END - -GROUPBOX DLG_NULL 76 6 -BEGIN - PROMPT 2 4 "Dati da inviare" -END - -BOOLEAN F_MOVIMENTI -BEGIN - PROMPT 3 5 "Movimenti contabili" - MESSAGE FALSE CLEAR,F_PAGAMENTI|DISABLE,F_DATAFIN - MESSAGE TRUE ENABLE,F_PAGAMENTI|ENABLE,F_DATAFIN -END - -BOOLEAN F_CLIENTI -BEGIN - PROMPT 3 6 "Clienti" -END - -BOOLEAN F_FORNITORI -BEGIN - PROMPT 3 7 "Fornitori" -END - -BOOLEAN F_CONTI -BEGIN - PROMPT 3 8 "Piano dei conti" -END - -BOOLEAN F_PAGAMENTI -BEGIN - PROMPT 40 5 "Pagamenti" -END - -LISTBOX F_TIPOINVIO 20 -BEGIN - PROMPT 2 10 "Invio a " - ITEM "P|Proforma" -END - -STRING F_DESTINAZIONE 20 -BEGIN - PROMPT 2 11 "Destinazione " -END - -DATE F_DATAINI -BEGIN - PROMPT 2 12 "Data iniziale " -END - -DATE F_DATAFIN -BEGIN - PROMPT 40 12 "Data finale " -END - -BUTTON F_RIPRISTINA 20 2 -BEGIN - PROMPT 2 14 "Annulla invio" - MESSAGE SHOW,F_DATARIPRISTINO|ENABLE,F_DATARIPRISTINO -END - -DATE F_DATARIPRISTINO -BEGIN - PROMPT 25 14 "Annulla invio fino al " - FLAGS "HD" -END - -ENDPAGE - -PAGE "Conti" -1 -1 78 20 - -TEXT -1 -BEGIN - PROMPT 1 1 "@bPiano dei conti contabile" -END - -SPREADSHEET F_PDCC 78 -6 -BEGIN - PROMPT 1 2 "Pdcc" - ITEM "Tipo" - ITEM "Gruppo" - ITEM "Conto" - ITEM "Sottoconto" - ITEM "Descrizione@50" -END - -TEXT -1 -BEGIN - PROMPT 1 17 "Inserire conti di tipo F per ritenute Fiscali" -END - -TEXT -1 -BEGIN - PROMPT 1 18 "S per ritenute Sociali, C per Costi, P per Pagamenti" -END - -BUTTON DLG_SAVEREC 12 2 -BEGIN - PROMPT -11 19 "" - PICTURE BMP_SAVEREC - PICTURE BMP_SAVERECDN -END - -ENDPAGE - -ENDMASK - -//-------------------------------------------------------------------- -// Riga dello sheet dei conti -//-------------------------------------------------------------------- - -PAGE "Riga Piano dei conti contabile" -1 -1 78 8 - -LIST S_TIPO 1 18 -BEGIN - PROMPT 1 1 "Tipo " - ITEM "C|Costi" - ITEM "P|Pagamenti" - ITEM "F|Ritenute fiscali" - ITEM "S|Ritenute sociali" -END - -NUMBER S_GRUPPO 3 -BEGIN - PROMPT 1 2 "Gruppo " - USE LF_PCON KEY 1 SELECT CONTO="" - INPUT GRUPPO S_GRUPPO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Descrizione@50" DESCR - OUTPUT S_GRUPPO GRUPPO - CHECKTYPE REQUIRED -END - -NUMBER S_CONTO 3 -BEGIN - PROMPT 1 3 "Conto " - USE LF_PCON KEY 1 SELECT ((CONTO!="")&&(SOTTOCONTO="")) - COPY INPUT S_GRUPPO - INPUT CONTO S_CONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT S_GRUPPO GRUPPO - OUTPUT S_CONTO CONTO - CHECKTYPE NORMAL - VALIDATE REQIF_FUNC 1 S_SOTTOCONTO -END - -NUMBER S_SOTTOCONTO 6 -BEGIN - PROMPT 1 4 "Sottoconto " - USE LF_PCON KEY 1 SELECT SOTTOCONTO!="" - COPY INPUT S_CONTO - INPUT SOTTOCONTO S_SOTTOCONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT S_SOTTOCONTO SOTTOCONTO - OUTPUT S_CONTO CONTO - OUTPUT S_GRUPPO GRUPPO - OUTPUT S_DESCRIZIONE DESCR - CHECKTYPE NORMAL -END - -STRING S_DESCRIZIONE 50 -BEGIN - PROMPT 1 5 "Descrizione " - KEY 2 - USE LF_PCON KEY 2 - INPUT DESCR S_DESCRIZIONE - DISPLAY "Descrizione@50" DESCR - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - COPY OUTPUT S_SOTTOCONTO - CHECKTYPE REQUIRED -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -13 -1 "" -END - -BUTTON DLG_DELREC 10 2 -BEGIN - PROMPT -23 -1 "" -END - -BUTTON DLG_CANCEL 10 2 -BEGIN - PROMPT -33 -1 "" -END - -ENDPAGE - -ENDMASK diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 689f7c35f..2fa075667 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -249,32 +249,36 @@ const char* iva2name(TipoIVA iva) const TString& cap2comune(const TString& cap, const TString& denom) { - TString8 cappone = cap; - if (cappone[2] == '1') //e' un capoluogo di provincia - cappone.overwrite("00", 3, 2); - - TRelation relcom(LF_COMUNI); - TRectype& comrec = relcom.curr(); - comrec.put(COM_CAPCOM, cappone); - - TCursor comuni (&relcom, "", 3, &comrec, &comrec); - const TRecnotype items = comuni.items(); - - comuni.freeze(); - - TString4 codcom; - double cmp = 0.69; - for (comuni = 0L; comuni.pos() < items; ++comuni) + if (cap.len() == 5 && denom.full()) { - const TString& denominazione = comrec.get(COM_DENCOM); - const double fc = xvt_str_fuzzy_compare (denom, denominazione); - if (fc > cmp) - { - codcom = comrec.get(COM_COM); - cmp = fc; - } - } - return get_tmp_string() = codcom; + TString8 cappone = cap; + if (cappone[2] == '1') //e' un capoluogo di provincia + cappone.overwrite("00", 3, 2); + + TRelation relcom(LF_COMUNI); + TRectype& comrec = relcom.curr(); + comrec.put(COM_CAPCOM, cappone); + + TCursor comuni (&relcom, "", 3, &comrec, &comrec); + const TRecnotype items = comuni.items(); + comuni.freeze(); + + TString4 codone; + double cmp = 0.69; + for (comuni = 0L; comuni.pos() < items; ++comuni) + { + const TString& denominazione = comrec.get(COM_DENCOM); + const double fc = xvt_str_fuzzy_compare (denom, denominazione); + if (fc > cmp) + { + codone = comrec.get(COM_COM); + cmp = fc; + } + } + if (codone.full()) + return get_tmp_string() = codone; + } + return EMPTY_STRING; } /////////////////////////////////////////////////////////// diff --git a/cg/cglib01.h b/cg/cglib01.h index 6dede549d..bd37768f2 100755 --- a/cg/cglib01.h +++ b/cg/cglib01.h @@ -145,7 +145,7 @@ public: // TObject const real percentuale() const { return get_real("R0"); } const TString& tipo() const { return get("S1"); } int detraibilita() const { return get_int("I1"); } - int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); } +int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7");} real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index ccc0bce58..8a7af216a 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -87,7 +87,13 @@ TSaldo::TSaldo() : _saldi(LF_SALDI), _saldoiniziale(ZERO), _saldo_iniziale(ZERO) _rec_presente_ec(FALSE), _rec_presente_ep(FALSE), _causali_apertura(LF_CAUSALI, CAU_MOVAP) -{} +{ + for (int i = 0; i < 12; i++) + { + _prg_dare_mese[i] = ZERO; + _prg_avere_mese[i] = ZERO; + } +} real TSaldo::saldofin_esprec(int annoes, int g, int c, long s, bool saldo_chiusura, bool provvis) { @@ -282,6 +288,12 @@ bool TSaldo::ultima_immissione_verifica(int annoes,int g,int c,long s,int indbil _saldofin = ZERO; _sezsf = ' '; + for (int i = 0; i < 12; i++) + { + _prg_dare_mese[i] = ZERO; + _prg_avere_mese[i] = ZERO; + } + _saldi.zero(); _saldi.put(SLD_ANNOES,annoes); _saldi.put(SLD_GRUPPO,g); @@ -379,6 +391,12 @@ bool TSaldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil _rec_presente_ep = FALSE; _prec = FALSE; + for (int i = 0; i < 12; i++) + { + _prg_dare_mese[i] = ZERO; + _prg_avere_mese[i] = ZERO; + } + _saldi.zero(); _saldi.put(SLD_ANNOES,annoes); _saldi.put(SLD_GRUPPO,g); @@ -459,7 +477,13 @@ const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const _rec_presente_ep = false; _rec_presente_ec = false; _prec = false; - + + for (int i = 0; i < 12; i++) + { + _prg_dare_mese[i] = ZERO; + _prg_avere_mese[i] = ZERO; + } + TEsercizi_contabili es; const int codes = es.date2esc(dal); const TDate inizio = es.esercizio(codes).inizio(); @@ -523,11 +547,18 @@ const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const if (_datacomp >= dal && _datacomp <= al) { _movimentato = true; + const int m = _datacomp.month() - 1; - if (sezione == 'D') + if (sezione == 'D') + { _prg_dare += importo; + _prg_dare_mese[m] += importo; + } else + { _prg_avere += importo; + _prg_avere_mese[m] += importo; + } } else if (_datacomp >= inizio && _datacomp < dal) diff --git a/cg/cglib02.h b/cg/cglib02.h index ca5440a77..1cc67305a 100755 --- a/cg/cglib02.h +++ b/cg/cglib02.h @@ -71,6 +71,8 @@ class TSaldo : public TObject real _saldo_iniziale; real _prg_dare; real _prg_avere; + real _prg_dare_mese[12]; + real _prg_avere_mese[12]; real _saldofin; real _saldo; int _annoes; @@ -95,7 +97,7 @@ protected: real calcola_saldo_iniziale(int g, int c, long s, int indbil, bool provvis); bool prg_saldo(int, TConto&, real&, real&, bool); const real& iniziale() const { return _saldo_iniziale;} - void set_iniziale(const real& val) { _saldo_iniziale = val; } + void set_iniziale(const real& val) { _saldo_iniziale = val; } public: @@ -109,10 +111,10 @@ public: bool causale_mov(long, const TDate&, const TDate&, TString&); - bool ultima_immissione_bilancio(int anno,int g,int c,long s,int indbil,int prov,bool saldo_chiusura = TRUE); - bool ultima_immissione_verifica(int anno,int g,int c,long s,int indbil,int prov); - bool data_limite_bilancio(int,int,int,long,const TDate&,const TDate&,int,int, const char* = NULL); - const real& saldo_periodo(int g,int c,long s,const TDate& dal,const TDate& al,int indbil, bool provv); + bool ultima_immissione_bilancio(int annoes, int g,int c,long s,int indbil,int prov,bool saldo_chiusura = true); + bool ultima_immissione_verifica(int annoes, int g,int c,long s,int indbil,int prov); + bool data_limite_bilancio(int annoes,int g,int c,long s,const TDate& data_inf,const TDate& data_suo,int indbil,int stp_prov, const char* filter = NULL); + const real& saldo_periodo(int g,int c,long s,const TDate& dal,const TDate& al,int indbil, bool provv, const TString & codcomm = EMPTY_STRING); bool ricerca_progr_prec(int, int, int, long); @@ -127,6 +129,8 @@ public: const real& saldoinisusaldi() const { return _saldoiniziale;} const real& prgdare() const { return _prg_dare;} const real& prgavere() const { return _prg_avere;} + const real& prgdare(int month) const { return _prg_dare_mese[month - 1];} + const real& prgavere(int month) const { return _prg_avere_mese[month - 1];} const real& saldofin() const { return _saldofin;} const char sezsf() const { return _sezsf;} const bool flagprec() { return _prec; } diff --git a/cg/cgp4.cpp b/cg/cgp4.cpp deleted file mode 100755 index 47fe193ce..000000000 --- a/cg/cgp4.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#include "cgp4.h" - -int main(int argc,char** argv) -{ - const int s = (argc > 1) ? argv[1][1] - '0' : 0; - - switch (s) - { - case 1 : - cgp4200(argc,argv) ; break; // Importa stipendi in prima nota (OMASA) - default: cgp4100(argc,argv) ; break; // Importazione clienti (GSA/CODFIDI) - - } - exit(0); - return 0; -} - diff --git a/cg/cgp4.h b/cg/cgp4.h deleted file mode 100755 index d60ba79e3..000000000 --- a/cg/cgp4.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __CGP4_H -#define __CGP4_H - -int cgp4100(int argc, char* argv[]); - -#endif // __CGP4_H - diff --git a/cg/cgp4100.cpp b/cg/cgp4100.cpp deleted file mode 100755 index 3442a39b6..000000000 --- a/cg/cgp4100.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// OMASA - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cgp4.h" -#include "cgp4100a.h" -#include "cgp4100b.h" -#include "cgp4100C.h" -#include "cglib01.h" - -#include -#include -#include -#include - - -#define MAX_CG_ROWS 98 - -// tabella per la conversione dei numeri negativi (schede perforate????) -static unsigned char _tabella[10] = {'p','q','r','s','t','u','v','w','x','y'}; - -// TAutomask - -class TOmasa_mask : public TAutomask -{ -protected: - bool on_field_event(TOperable_field& o, TField_event e, long jolly); -public: - TOmasa_mask(); - virtual ~TOmasa_mask(){}; -}; - -TOmasa_mask::TOmasa_mask() :TAutomask ("cgp4100a") -{ -} - -bool TOmasa_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) -{ - return TRUE; -} - - -// TFile_text - -class TOmasa_file: public TFile_text -{ -protected: - virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str); - -public: - TOmasa_file(const TString& file_name); - virtual ~TOmasa_file() { } -}; - -TOmasa_file::TOmasa_file(const TString& file_name) - : TFile_text(file_name, "omasa.ini") -{ -} - -void TOmasa_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str) -{ - const TString code(s.get(0)); - TString valore = str; - if (code == "_UPPERCASE") - { - valore.upper(); - } - else NFCHECK("Macro non definita: %s", (const char *)code); - str = valore; -} - -// TSkeleton_application - -class TOmasa : public TSkeleton_application -{ - TOmasa_mask* _msk; - TOmasa_file* _trasfile; - TConfig* _configfile; - TRelation* _rel; - TCursor* _cur; - TProgind* _prog; - TEsercizi_contabili* _esc; - - long _numreg; - -public: - virtual bool create(); - virtual bool destroy(); - virtual void main_loop(); - virtual void ini2mask(); - virtual void mask2ini(); - bool transfer(); - void negativo(TString& importo); - int strip_zero(TString& importo); - bool my_isdigit(unsigned char ch); - int look(unsigned char carattere); - - TOmasa() {} -}; - -TOmasa& app() { return (TOmasa&) main_app(); } - -bool TOmasa::create() -{ - open_files(LF_TABCOM, LF_TAB, LF_SALDI, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA, - LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0); - - TFilename configname = "cgp4100a.ini"; - configname.custom_path(); - _configfile = new TConfig(configname); - _msk = new TOmasa_mask(); - _rel = new TRelation (LF_PCON); - _cur = new TCursor(_rel,"((GRUPPO!=\"\")&&(CONTO!=\"\")&&(SOTTOCONTO==\"\"))",1); - _esc = new TEsercizi_contabili; - - return TSkeleton_application::create(); -} - -bool TOmasa::destroy() -{ - delete _esc; - delete _cur; - delete _rel; - delete _msk; - delete _configfile; - - return TApplication::destroy(); -} - -int TOmasa::strip_zero(TString& importo) -{ - TString16 app; - - int size = importo.len(); - - for (int i = 0; i < size; i++) - if (importo[i] != '0') break; - - if (i > 0) - { - app = importo.mid(importo[i] == '.' ? i - 1 : i); - importo = app; - } - - return (i ? i - 1 : i); -} - -bool TOmasa::my_isdigit(unsigned char ch) -{ - return (ch >= '0' && ch <= '9'); -} - -int TOmasa::look(unsigned char carattere) -{ - for (int i = 0; i < 10; i++) - if (_tabella[i] == carattere) - return i; - - return -1; -} - -void TOmasa::negativo(TString& importo) -{ - strip_zero(importo); - int size = importo.len(); - if (!size) return; - unsigned char last = importo[size - 1]; - if (!my_isdigit(last)) - { - int new_last = look(last); - TString16 dep; dep << new_last; - if (new_last >= 0) - { - importo[size - 1] = dep[0]; - importo.insert("-"); - } - } -} - -void TOmasa::mask2ini() -{ - TSheet_field& sheet = (TSheet_field&)_msk->field(F_SHEET_CONTI); - for (int i=0;iset(contoomasa, conto, "CONTI"); - } - TSheet_field& sheetcms = (TSheet_field&)_msk->field(F_SHEET_CMS); - for (i=0;iset(cmsomasa, cms, "COMMESSE"); - } - _configfile->set_paragraph("CONTI"); -} - -void TOmasa::ini2mask() -{ - TString_array vl; - _configfile->list_variables(vl,TRUE, "CONTI", TRUE); - TSheet_field& sheet = (TSheet_field&)_msk->field(F_SHEET_CONTI); - sheet.destroy(); - int i=0; - FOR_EACH_ARRAY_ROW(vl,r,s) - { - TToken_string& riga = sheet.row(i); - TString16 contoomasa = (*s).get(); - TToken_string conto = _configfile->get(contoomasa, "CONTI"); - riga.add(contoomasa); - riga.add(conto.get(0)); - riga.add(conto.get(1)); - riga.add(conto.get(2)); - sheet.check_row(i); - i++; - } - _configfile->list_variables(vl,TRUE, "COMMESSE", TRUE); - TSheet_field& sheetcms = (TSheet_field&)_msk->field(F_SHEET_CMS); - sheetcms.destroy(); - i=0; - FOR_EACH_ARRAY_ROW(vl,rc,sc) - { - TToken_string& riga = sheetcms.row(i); - TString16 cmsomasa = (*sc).get(); - TString80 cms = (*sc).get(); - riga.add(cmsomasa); - riga.add(cms); - sheetcms.check_row(i); - i++; - } -} - -void TOmasa::main_loop() -{ - KEY tasto; - _msk->set(F_PERCORSO, _configfile->get("PERCORSO", "MAIN")); - _msk->set(F_CODCAUS, _configfile->get("CODCAUS", "MOVIMENTO")); - ini2mask(); - tasto = _msk->run(); - if (tasto == K_ENTER) - { - mask2ini(); - _numreg = 0; - if (transfer()) - { - _configfile->set("PERCORSO", _msk->get(F_PERCORSO), "MAIN"); - _configfile->set("CODCAUS", _msk->get(F_CODCAUS), "MOVIMENTO"); - message_box(TR("Importazione stipendi completata")); - } - } -} - -bool TOmasa::transfer() -{ - TString_array transactions; - TFilename tempdir; - tempdir.tempdir(); - - TString80 listfiles = tempdir; - listfiles << "\\oo*.ini"; - list_files(listfiles, transactions); - FOR_EACH_ARRAY_ROW(transactions, row, name) - remove(*name); - - TConfig* movpn=NULL; - - _trasfile = new TOmasa_file(_msk->get(F_PERCORSO)); - _trasfile->open(_msk->get(F_PERCORSO),'r'); - - // creazione file temporanei per commessa e conto dare e avere - const long dimension = fsize(_msk->get(F_PERCORSO)); - TProgind pi(dimension,"Importazione in corso..."); - - TRecord_text curr; - while (_trasfile->read(curr) == NOERR) - { - pi.setstatus(_trasfile->read_file()->tellg()); - TString impstr = curr.get(F_VALOREVOCE); - impstr.insert(".",11); - negativo(impstr); - const real importo(impstr); - TString16 contodare = curr.get(F_CONTODARE); - TString16 contoavere = curr.get(F_CONTOAVERE); - if ((!real::is_null(impstr)) && (!contodare.blank() || !contoavere.blank())) - { - TString16 codcms = curr.get(F_CENTROCOSTO); - codcms.trim(); - TString80 cms = _configfile->get(codcms, "COMMESSE"); - if (cms.empty()) - { - TMask mskcms("cgp4100c"); - mskcms.set(F_CMSOMASA, codcms); - if (mskcms.run() == K_ENTER) - _configfile->set(codcms, mskcms.get(F_CODCMS), "COMMESSE"); - else - return TRUE; - } - TFilename name; - name.tempdir(); - name.add(format("oo%s", (const char*) codcms)); - name.ext(".ini"); - movpn = new TConfig(name); - movpn->set_paragraph("MAIN"); - movpn->set("CODCMS",codcms); - if (!contodare.blank()) - { - movpn->set_paragraph("IMPORTI"); - contodare.trim(); - impstr = movpn->get(contodare, "IMPORTI"); - real importomem(impstr); - importomem+=importo; - movpn->set(contodare, importomem.string()); - } - if (!contoavere.blank()) - { - movpn->set_paragraph("IMPORTI"); - contoavere.trim(); - impstr = movpn->get(contoavere, "IMPORTI"); - real importomem(impstr); - importomem-=importo; - movpn->set(contoavere, importomem.string()); - } - delete movpn; - if (pi.iscancelled()) - return TRUE; - } - } - _trasfile->close(); - delete _trasfile; - - // creazione .ini per la prima nota - const TDate datareg = _msk->get_date(F_DATAREG); - const int annoes = _esc->date2esc(datareg); - const TString8 codcaus = _msk->get(F_CODCAUS); - - listfiles = tempdir; - listfiles << "\\oo*.ini"; - list_files(listfiles, transactions); - FOR_EACH_ARRAY_ROW(transactions, row_oo, name_oo) - { - TConfig* movpn=NULL; - TConfig file_oo(*name_oo); - TString16 codcms = file_oo.get("CODCMS", "MAIN"); - codcms.trim(); - TFilename name; - name.tempdir(); - name.add(format("ooo%s", (const char*) codcms)); - name.ext(".ini"); - movpn = new TConfig(name); - - movpn->set_paragraph("Transaction"); - movpn->set("Action","INSERT"); - movpn->set("Mode","AUTO"); - - movpn->set_paragraph(format("%d",LF_MOV)); - movpn->set("ANNOES", annoes); - movpn->set("DATACOMP", datareg); - movpn->set("DATAREG", datareg); - movpn->set("DESCR", cache().get(LF_CAUSALI, codcaus, CAU_DESCR)); - movpn->set("CODCAUS", codcaus); - - int numrig = 0; - - TString_array vl; - file_oo.list_variables(vl,TRUE, "IMPORTI", TRUE); - FOR_EACH_ARRAY_ROW(vl,r,s) - { - TString16 contoomasa = (*s).get(); - TString16 importos = (*s).get(); - TToken_string conto = _configfile->get(contoomasa, "CONTI"); - if (conto.empty()) - { - TMask mskconto("cgp4100b"); - mskconto.set(F_CONTOOMASA, contoomasa); - if (mskconto.run() == K_ENTER) - { - const int gr = mskconto.get_int(F_GRUPPO); - const int co = mskconto.get_int(F_CONTO); - const long so = mskconto.get_long(F_SOTTOCONTO); - conto.format("%d|%d|%ld", gr, co, so); - _configfile->set(contoomasa, conto, "CONTI"); - } - else - return TRUE; - } - numrig++; - movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig)); - movpn->set("ANNOES", annoes); - movpn->set("DATAREG", datareg); - movpn->set("NUMRIG", numrig); - real importo(importos); - if (importo > 0) - movpn->set("SEZIONE", "D"); - else - movpn->set("SEZIONE", "A"); - importos.strip("-"); - movpn->set("IMPORTO", importos); - TString16 contoindbil; - contoindbil.format("%s|%s", conto.get(0), conto.get(1)); - const char indbil = cache().get(LF_PCON, contoindbil, PCN_INDBIL)[0]; - if ((indbil != '1') && (indbil != '2')) - movpn->set("CODCMS", _configfile->get(codcms, "COMMESSE")); - movpn->set("GRUPPO", conto.get(0)); - movpn->set("CONTO", conto.get(1)); - movpn->set("SOTTOCONTO", conto.get(2)); - } - delete movpn; - } - - tempdir.tempdir(); - TString80 applicat = "cg2.exe -0 -i"; - applicat << tempdir; - applicat << "\\ooo*.ini"; - TExternal_app primanota(applicat); - primanota.run(); - - listfiles = tempdir; - listfiles << "\\oo*.ini"; - list_files(listfiles, transactions); - FOR_EACH_ARRAY_ROW(transactions, rowf, namef) - remove(*namef); - return TRUE; -} - -int cgp4100 (int argc, char* argv[]) -{ - TOmasa main_app; - main_app.run(argc, argv, TR("Importazione stipendi")); - return TRUE; -} diff --git a/cg/cgp4100a.h b/cg/cgp4100a.h deleted file mode 100755 index 67bca8ef2..000000000 --- a/cg/cgp4100a.h +++ /dev/null @@ -1,40 +0,0 @@ -// campi della maschera principale - -#define F_PERCORSO 101 -#define F_DATAREG 102 -#define F_CODCAUS 103 -#define F_DESCR 104 -#define F_SHEET_CONTI 105 -#define F_SHEET_CMS 106 - -// campi della maschera di conversione conti -#define F_S_CONTOOMASA 101 -#define F_S_GRUPPO 102 -#define F_S_CONTO 103 -#define F_S_SOTTOCONTO 104 -#define F_S_DESCRIZIONE 105 - -// campi della maschera di conversione commesse -#define F_S_CMSOMASA 101 -#define F_S_CODCMS 102 -#define F_S_DESCRCMS 103 - -// campi del tracciato record - -#define F_CODAZIENDA 0 -#define F_CODDIP 1 -#define F_VOCE 2 -#define F_TIPOVOCE 3 -#define F_QUOTAVOCE 4 -#define F_VALOREVOCE 5 -#define F_IMPORTO 6 -#define F_CONTODARE 7 -#define F_CONTOAVERE 8 -#define F_CENTROCOSTO 9 -#define F_SEDELAVORO 10 -#define F_SEDEINPS 11 -#define F_QUALIFICA 12 -#define F_POSINAIL 13 -#define F_VARIABILE 14 -#define F_CONTRATTO 15 -#define F_FILLER 16 \ No newline at end of file diff --git a/cg/cgp4100a.ini b/cg/cgp4100a.ini deleted file mode 100755 index 7e82a9b14..000000000 --- a/cg/cgp4100a.ini +++ /dev/null @@ -1,14 +0,0 @@ -[MAIN] -PERCORSO = c:\temp\outretr.seq - -[CONTI] -420010=15|70|1 -421000=15|70|1 -421100=15|70|1 -424000=15|70|1 -601000=15|70|1 -601050=15|70|1 -601010=15|70|1 -601300=15|70|1 -601385=15|70|1 - diff --git a/cg/cgp4100a.uml b/cg/cgp4100a.uml deleted file mode 100755 index 15f3609aa..000000000 --- a/cg/cgp4100a.uml +++ /dev/null @@ -1,188 +0,0 @@ -#include "cgp4100a.h" - -TOOLBAR "" 0 20 0 2 - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -PAGE "Importazione stipendi" 0 -1 0 19 - -STRING F_PERCORSO 50 -BEGIN -PROMPT 2 2 "File da trasferire " - CHECKTYPE REQUIRED - VALIDATE FILENAME_FUNC - FLAGS "A" - HELP "Percorso e nome file da trasferire" - WARNING "E' necessario specificare il nome del file da trasferire" -END - -DATE F_DATAREG -BEGIN - PROMPT 2 3 "Data registrazione " - CHECKTYPE REQUIRED - HELP "Data di registrazione dei movimenti contabili" - WARNING "E' necessario specificare la data di registrazione" -END - -STRING F_CODCAUS 4 -BEGIN - PROMPT 2 4 "Causale " - FLAGS "UZ" - USE LF_CAUSALI - INPUT CODCAUS F_CODCAUS - DISPLAY "Codice" CODCAUS - DISPLAY "Descrizione@60" DESCR - OUTPUT F_CODCAUS CODCAUS - OUTPUT F_DESCR DESCR - CHECKTYPE SEARCH -END - -STRING F_DESCR 50 -BEGIN - PROMPT 17 4 "" - USE LF_CAUSALI KEY 2 - INPUT DESCR F_DESCR - DISPLAY "Descrizione@60" DESCR - DISPLAY "Codice" CODCAUS - COPY OUTPUT F_CODCAUS - CHECKTYPE SEARCH -END - -SPREADSHEET F_SHEET_CONTI 70 6 -BEGIN - PROMPT 2 6 "Tabella conversione conti" - ITEM "Conto OMASA" - ITEM "Gruppo" - ITEM "Conto" - ITEM "Sottoc." - ITEM "Descrizione" -END - -SPREADSHEET F_SHEET_CMS 70 6 -BEGIN - PROMPT 2 14 "Tabella conversione commesse" - ITEM "Cms OMASA" - ITEM "Corrispondente" - ITEM "Descrizione" -END - -ENDPAGE - -ENDMASK - -PAGE "Conversione conti" 0 -1 0 10 - -STRING F_S_CONTOOMASA 14 -BEGIN - PROMPT 2 2 "Conto OMASA " - FLAGS "D" -END - -NUMBER F_S_GRUPPO 3 -BEGIN - PROMPT 2 4 "Conto corrispon." - USE LF_PCON KEY 1 SELECT (CONTO="") - INPUT GRUPPO F_S_GRUPPO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_S_GRUPPO GRUPPO - CHECKTYPE NORMAL -END - -NUMBER F_S_CONTO 3 -BEGIN - PROMPT 24 4 "" - USE LF_PCON KEY 1 SELECT (SOTTOCONTO="") - INPUT GRUPPO F_S_GRUPPO - INPUT CONTO F_S_CONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_S_CONTO CONTO - OUTPUT F_S_GRUPPO GRUPPO - CHECKTYPE NORMAL -END - -NUMBER F_S_SOTTOCONTO 6 -BEGIN - PROMPT 30 4 "" - USE LF_PCON - INPUT GRUPPO F_S_GRUPPO - INPUT CONTO F_S_CONTO - INPUT SOTTOCONTO F_S_SOTTOCONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_S_SOTTOCONTO SOTTOCONTO - OUTPUT F_S_GRUPPO GRUPPO - OUTPUT F_S_CONTO CONTO - OUTPUT F_S_DESCRIZIONE DESCR - CHECKTYPE NORMAL -END - -STRING F_S_DESCRIZIONE 50 -BEGIN - PROMPT 39 4 "" - USE LF_PCON KEY 2 - INPUT DESCR F_S_DESCRIZIONE - DISPLAY "Descrizione@50" DESCR - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - OUTPUT F_S_SOTTOCONTO SOTTOCONTO - OUTPUT F_S_CONTO CONTO - OUTPUT F_S_GRUPPO GRUPPO - OUTPUT F_S_DESCRIZIONE DESCR - CHECKTYPE NORMAL -END - -ENDPAGE - -ENDMASK - -PAGE "Conversione commesse" 0 -1 0 10 - -STRING F_S_CMSOMASA 14 -BEGIN - PROMPT 2 2 "Commessa OMASA " - FLAGS "D" -END - -STRING F_S_CODCMS 20 -BEGIN - PROMPT 2 4 "Commessa corrispondente " - FLAGS "UZ" - USE CMS - INPUT CODTAB F_S_CODCMS - DISPLAY "Codice@20" CODTAB - DISPLAY "Descrizione@50" S0 - OUTPUT F_S_CODCMS CODTAB - OUTPUT F_S_DESCRCMS S0 - CHECKTYPE NORMAL -END - -STRING F_S_DESCRCMS 50 -BEGIN - PROMPT 39 4 "" - USE CMS KEY 2 - INPUT S0 F_S_DESCRCMS - DISPLAY "Descrizione@50" S0 - DISPLAY "Codice@20" CODTAB - COPY OUTPUT F_S_CODCMS - CHECKTYPE NORMAL -END - -ENDPAGE - -ENDMASK diff --git a/cg/cgp4100b.h b/cg/cgp4100b.h deleted file mode 100755 index 628a1e9e7..000000000 --- a/cg/cgp4100b.h +++ /dev/null @@ -1,7 +0,0 @@ -// campi della maschera cgp4100b.uml - -#define F_CONTOOMASA 101 -#define F_GRUPPO 102 -#define F_CONTO 103 -#define F_SOTTOCONTO 104 -#define F_DESCRIZIONE 105 \ No newline at end of file diff --git a/cg/cgp4100b.uml b/cg/cgp4100b.uml deleted file mode 100755 index 4ba331a67..000000000 --- a/cg/cgp4100b.uml +++ /dev/null @@ -1,87 +0,0 @@ -#include "cgp4100b.h" - -TOOLBAR "" 0 20 0 2 - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -PAGE "Conversione conti" 0 -1 0 10 - -STRING F_CONTOOMASA 14 -BEGIN - PROMPT 2 2 "Conto OMASA " - FLAGS "D" -END - -NUMBER F_GRUPPO 3 -BEGIN - PROMPT 2 4 "Conto corrispondente " - USE LF_PCON KEY 1 SELECT (CONTO="") - INPUT GRUPPO F_GRUPPO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPO GRUPPO - CHECKTYPE NORMAL -END - -NUMBER F_CONTO 3 -BEGIN - PROMPT 29 4 "" - USE LF_PCON KEY 1 SELECT (SOTTOCONTO="") - INPUT GRUPPO F_GRUPPO - INPUT CONTO F_CONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_CONTO CONTO - OUTPUT F_GRUPPO GRUPPO - CHECKTYPE NORMAL -END - -NUMBER F_SOTTOCONTO 6 -BEGIN - PROMPT 35 4 "" - USE LF_PCON - INPUT GRUPPO F_GRUPPO - INPUT CONTO F_CONTO - INPUT SOTTOCONTO F_SOTTOCONTO - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_SOTTOCONTO SOTTOCONTO - OUTPUT F_GRUPPO GRUPPO - OUTPUT F_CONTO CONTO - OUTPUT F_DESCRIZIONE DESCR - CHECKTYPE NORMAL -END - -STRING F_DESCRIZIONE 50 -BEGIN - PROMPT 44 4 "" - USE LF_PCON KEY 2 - INPUT DESCR F_DESCRIZIONE - DISPLAY "Descrizione@50" DESCR - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Sottoconto" SOTTOCONTO - OUTPUT F_SOTTOCONTO SOTTOCONTO - OUTPUT F_CONTO CONTO - OUTPUT F_GRUPPO GRUPPO - OUTPUT F_DESCRIZIONE DESCR - CHECKTYPE NORMAL -END - -ENDPAGE -ENDMASK - - diff --git a/cg/cgp4100c.h b/cg/cgp4100c.h deleted file mode 100755 index 7970d3753..000000000 --- a/cg/cgp4100c.h +++ /dev/null @@ -1,5 +0,0 @@ -// campi della maschera cgp4100c.uml - -#define F_CMSOMASA 101 -#define F_CODCMS 102 -#define F_DESCRCMS 103 \ No newline at end of file diff --git a/cg/cgp4100c.uml b/cg/cgp4100c.uml deleted file mode 100755 index d621b700f..000000000 --- a/cg/cgp4100c.uml +++ /dev/null @@ -1,52 +0,0 @@ -#include "cgp4100c.h" - -TOOLBAR "" 0 20 0 2 - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -PAGE "Conversione commesse" 0 -1 0 10 - -STRING F_CMSOMASA 14 -BEGIN - PROMPT 2 2 "Commessa OMASA " - FLAGS "D" -END - -STRING F_CODCMS 20 -BEGIN - PROMPT 2 4 "Commessa corrispondente " - FLAGS "UZ" - USE CMS - INPUT CODTAB F_CODCMS - DISPLAY "Codice@20" CODTAB - DISPLAY "Descrizione@50" S0 - OUTPUT F_CODCMS CODTAB - OUTPUT F_DESCRCMS S0 - CHECKTYPE NORMAL -END - -STRING F_DESCRCMS 50 -BEGIN - PROMPT 2 5 "Descrizione " - USE CMS KEY 2 - INPUT S0 F_DESCRCMS - DISPLAY "Descrizione@50" S0 - DISPLAY "Codice@20" CODTAB - COPY OUTPUT F_CODCMS - CHECKTYPE NORMAL -END - -ENDPAGE -ENDMASK - - diff --git a/cg/f26.dir b/cg/f26.dir index 23b37d699..b5f03fcbc 100755 --- a/cg/f26.dir +++ b/cg/f26.dir @@ -1,3 +1,4 @@ 26 0 -$caus|0|0|79|0|Causali contabili|60|| +$caus|0|0|82|0|Causali contabili|60|| + diff --git a/cg/f26.trr b/cg/f26.trr index b6416ff62..36e3638a8 100755 --- a/cg/f26.trr +++ b/cg/f26.trr @@ -1,5 +1,5 @@ 26 -22 +23 CODCAUS|1|3|0|Codice causale DESCR|1|50|0|Descrizione causale TIPODOC|1|2|0|Tipo documento @@ -22,6 +22,7 @@ VALINTRA|8|1|0|Gestione valuta intra-comunitaria MOVIND|1|1|0|Causale per contabilita' industriale SOLOIVA|8|1|0|Movimento di sola IVA PROVV|1|1|0|Tipo movimento (" " Normale, "P" Provvisorio cancellabile, "C" Provvisorio da cepiti) +CODCAUREG|1|3|0|Causale regolarizzazione IVA 2 CODCAUS| UPPER(DESCR)|X diff --git a/cg/omasa.ini b/cg/omasa.ini deleted file mode 100755 index a440cd332..000000000 --- a/cg/omasa.ini +++ /dev/null @@ -1,141 +0,0 @@ -[MAIN] -DECSEP = -FIELDSEP = -RECORDSEP = \n -RECORDSIZE = 0 -SKIPLINES = 0 -TYPEFIELD = -1 -TYPELEN = -1 -TYPEPOS = -1 - -[TYPE FISSO] -ALIGN = -DATA = -DECIMAL = 0 -FILLER = ' ' -LENGTH = 0 -PICTURE = - -[TYPE DATA] -ALIGN = -DATA = D -DECIMAL = 0 -FILLER = -LENGTH = 8 -PICTURE = - -[TYPE NUMERO] -ALIGN = R -DATA = -DECIMAL = 0 -FILLER = '0' -LENGTH = 0 -PICTURE = - -[TYPE IMPORTO] -ALIGN = R -DATA = -DECIMAL = 2 -FILLER = '0' -LENGTH = 13 -PICTURE = - -[TYPE STRINGA] -ALIGN = L -DATA = S -DECIMAL = 0 -FILLER = ' ' -LENGTH = 0 -PICTURE = - -[RECORD] -NAME(0) = CODICE AZIENDA -TYPE(0) = NUMERO -POSITION(0) = 0 -LENGTH(0) = 4 - -NAME(1) = CODICE DIPENDENTE -TYPE(1) = NUMERO -POSITION(1) = 4 -LENGTH(1) = 6 - -NAME(2) = VOCE -TYPE(2) = NUMERO -POSITION(2) = 10 -LENGTH(2) = 4 - -NAME(3) = TIPO VOCE -TYPE(3) = STRINGA -POSITION(3) = 14 -LENGTH(3) = 1 - -NAME(4) = QUOTA VOCE -TYPE(4) = NUMERO -POSITION(4) = 15 -LENGTH(4) = 6 -DECIMAL(4) = 2 - -NAME(5) = VALORE VOCE -TYPE(5) = NUMERO -POSITION(5) = 21 -LENGTH(5) = 13 -DECIMAL(5) = 2 -MESSAGE(5) = _IMPORTO - -NAME(6) = IMPORTO UNITARIO -TYPE(6) = IMPORTO -POSITION(6) = 34 -LENGTH(6) = 13 -DECIMAL(6) = 2 -MESSAGE(6) = _IMPORTO - -NAME(7) = CONTO DARE -TYPE(7) = STRINGA -POSITION(7) = 47 -LENGTH(7) = 14 - -NAME(8) = CONTO AVERE -TYPE(8) = STRINGA -POSITION(8) = 61 -LENGTH(8) = 14 - -NAME(9) = CENTRO DI COSTO -TYPE(9) = STRINGA -POSITION(9) = 75 -LENGTH(9) = 12 - -NAME(10) = SEDE DI LAVORO -TYPE(10) = STRINGA -POSITION(10) = 87 -LENGTH(10) = 2 - -NAME(11) = SEDE INPS -TYPE(11) = STRINGA -POSITION(11) = 89 -LENGTH(11) = 2 - -NAME(12) = QUALIFICA -TYPE(12) = STRINGA -POSITION(12) = 91 -LENGTH(12) = 1 - -NAME(13) = POSIZIONE INAIL -TYPE(13) = STRINGA -POSITION(13) = 92 -LENGTH(13) = 2 - -NAME(14) = VARIABILE -TYPE(14) = STRINGA -POSITION(14) = 94 -LENGTH(14) = 40 - -NAME(15) = CONTRATTO -TYPE(15) = STRINGA -POSITION(15) = 134 -LENGTH(15) = 2 - -NAME(16) = FILLER -TYPE(16) = STRINGA -POSITION(16) = 136 -LENGTH(16) = 6 - diff --git a/cg/zucchett.ini b/cg/zucchett.ini index 1df9d70eb..df0f6ae29 100755 --- a/cg/zucchett.ini +++ b/cg/zucchett.ini @@ -580,7 +580,6 @@ NAME(29) = SEGNO TYPE(29) = STRINGA POSITION(29) = 155 LENGTH(29) = 1 -MESSAGE(29) = _SEGNO NAME(30) = RITENUTA ACCONTO TYPE(30) = IMPORTO