diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 11d639784..3cd212efb 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -44,7 +44,7 @@ protected: virtual void init_query_mode(TMask& m); virtual void init_query_insert_mode(TMask& m) {init_query_mode(m);} virtual void init_insert_mode(TMask& m) {init_query_mode(m);} - virtual bool change_config(const char* val, const char* old, const char* nuo); + virtual void on_config_change(); //////////// static bool indsp_notify(int r, KEY key); @@ -350,29 +350,12 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key) return TRUE; } -bool TClifo_application::change_config(const char* val, const char* old, const char* nuo) +void TClifo_application::on_config_change() { - bool init = FALSE; - - const TFixed_string var(val); - if (var == "GesVen") - { - if (!_ignoreven) - { - _gesven = *nuo > ' '; - init = TRUE; - } - } - else - if (var == "GsLbCn") - { - _lbcn = *nuo > ' '; - init = TRUE; - } - - if (init) init_pages(*_msk); - - return TRUE; + TConfig cnf(CONFIG_DITTA); + _gesven = _ignoreven ? FALSE : cnf.get_bool("GesVen"); + _lbcn = cnf.get_bool("GsLbCn"); + init_pages(*_msk); } @@ -627,11 +610,6 @@ bool TClifo_application::user_create() // initvar e arrmask TConfig config(CONFIG_STUDIO); _savenew = !config.get_bool("Cg02SN"); - TConfig conf(CONFIG_DITTA, "cg"); - _lbcn = conf.get_bool("GsLbCn"); - _gesven = _ignoreven ? FALSE : conf.get_bool("GesVen"); - init_pages(*_msk); - return TRUE; } diff --git a/cg/cg0500.cpp b/cg/cg0500.cpp index 3b621030a..25a753d80 100755 --- a/cg/cg0500.cpp +++ b/cg/cg0500.cpp @@ -19,7 +19,6 @@ typedef enum { no_descr, acquisto, vendita, incasso_pagamento, ritenuta_occas, incasso_pagamento_gesval } tipo_descr; - class TCaus_app : public TRelation_application { TRelation* _rel; // Relazione principale @@ -79,15 +78,14 @@ protected: virtual bool changing_mask(int mode) {return FALSE; } virtual bool remove(); - void read_firm_params(); void init_mask(TMask&); - virtual bool change_config(const char* var, const char* old, const char* nuo); + virtual void on_config_change(); virtual void init_query_mode(TMask&); virtual void init_insert_mode(TMask&); virtual void init_modify_mode(TMask&); virtual int rewrite(const TMask& m); virtual int write(const TMask& m); - int re_write (const TMask& m, bool rewrite=FALSE); + int re_write (const TMask& m, bool rewrite); virtual int read(TMask& m); // int cancella(long items); @@ -307,18 +305,20 @@ bool TCaus_app::tipodoc_hndl (TMask_field& f, KEY k) const TipoIVA i = (TipoIVA)tabtpd.get_int("I0"); // IVA acquisti, vendite, generica const bool corrisp = tabtpd.get_bool("B0"); - if (i == 1) // vendite + if (i == 1) // vendite { - if (corrisp) { // vendite con corrispettivi + if (corrisp) // vendite con corrispettivi + { app()._filtro = 2; field_reg.browse()->cursor()->set_filterfunction(filtra_reg); } - else { // vendite senza corrispettivi + else // vendite senza corrispettivi + { app()._filtro = 1; field_reg.browse()->cursor()->set_filterfunction(filtra_reg); } } else - if ( i == 2 ) // acquisti + if ( i == 2 ) // acquisti { app()._filtro = 3; field_reg.browse()->cursor()->set_filterfunction(filtra_reg); @@ -849,6 +849,7 @@ bool TCaus_app::remove() void TCaus_app::init_mask(TMask& m) { m.set(F_ANNOES, _anno_iva); + carica_righe_libere(); } void TCaus_app::init_query_mode(TMask& m) @@ -870,24 +871,13 @@ void TCaus_app::init_modify_mode(TMask& m) } -bool TCaus_app::change_config(const char* var, const char* old, const char* nuo) -{ - const TFixed_string v(var); - - if (v == "GesSal") _saldaconto = *nuo > ' '; else - if (v == "GesVal") _valuta = *nuo > ' '; else - if (v == "AnLiIv") _anno_iva = atoi(nuo); - - return TRUE; -} - -void TCaus_app::read_firm_params() -{ +void TCaus_app::on_config_change() +{ TConfig conf(CONFIG_DITTA); - + _saldaconto = conf.get_bool("GesSal"); _valuta = conf.get_bool("GesVal"); - _anno_iva = (int)conf.get_long("AnLiIv", "cg"); + _anno_iva = (int)conf.get_long("AnLiIv"); if (_anno_iva < 1800) { _anno_iva = TDate(TODAY).year(); @@ -896,6 +886,7 @@ void TCaus_app::read_firm_params() } } + bool TCaus_app::user_create() { _rel = new TRelation (LF_CAUSALI); @@ -904,8 +895,6 @@ bool TCaus_app::user_create() _msk = new TMask("cg0500a"); _sheet = &(TSheet_field&)_msk->field(F_SHEET_GCS); - read_firm_params(); - _msk->show(F_TIPO_MOV_1, saldaconto()); _msk->show(F_TIPO_MOV_2, saldaconto()); _msk->show (F_MOV_SEZ, saldaconto()); diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 35d0f6e04..b9ebc90b5 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -137,13 +137,8 @@ bool TPrimanota_application::user_create() _rel = new TMovimentoPN; _rel->add(LF_PARTITE, "NREG=NUMREG", 2); - _rel->lfile().last(); - _lastreg = _rel->lfile().get_long(MOV_NUMREG); // Init last registration number - set_search_field(F_NUMREG); // Set field for default search - read_firm_params(); - load_mask(0); return TRUE; @@ -334,19 +329,17 @@ TMask* TPrimanota_application::get_mask(int mode) } -void TPrimanota_application::read_firm_params() +void TPrimanota_application::on_firm_change() { - TConfig c(CONFIG_DITTA, "cg"); - _ges_val = c.get_bool("GesVal"); - _ges_sal = c.get_bool("GesSal"); -} + _rel->lfile().last(); + _lastreg = _rel->lfile().get_long(MOV_NUMREG); // Init last registration number +} -bool TPrimanota_application::change_config(const char* var, const char* old, const char* val) +void TPrimanota_application::on_config_change() { - const TFixed_string v(var); - if (v == "GesVal") _ges_val = *val > ' '; else - if (v == "GesSal") _ges_sal = *val > ' '; - return TRUE; + TConfig cnf(CONFIG_DITTA); + _ges_val = cnf.get_bool("GesVal"); + _ges_sal = cnf.get_bool("GesSal"); } @@ -377,14 +370,15 @@ void TPrimanota_application::init_mask(TMask& m) m.send_key(K_SHIFT+K_CTRL+forg, -2); // GROUP 2 (fornitori) if (corrisp) m.hide(F_STATOPAIV); - m.show(F_CORRLIRE, valintra); - m.show(F_CORRVALUTA, valintra); - m.show(F_CODIVA, m.mode() == MODE_INS); + // Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRLIRE, F_CORRVAL (GROUP 4) + m.show(-4, valintra); + + m.show(F_CODIVA, m.mode() == MODE_INS); // Codice IVA standard } // Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3) - const bool valuta = valintra || (_ges_val && _causale.valuta()); - m.send_key(K_SHIFT+K_CTRL+(valuta ? 's' : 'h'), -3); + const bool valuta = _ges_val && _causale.valuta(); + m.show(-3, valuta); if (valuta) { const bool ok = m.get(F_VALUTA).not_empty(); @@ -407,7 +401,8 @@ void TPrimanota_application::fill_sheet(TMask& m) const { TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA); for (r = ivas.items(); r < 16; r++) ivas.row(r); - ivas.enable_column(4, _iva == iva_acquisti); + ivas.enable_column(2, _iva == iva_acquisti); // Tipo detrazione + ivas.enable_column(4, _iva == iva_acquisti); // Tipo costo ricavo } } diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index ab57c0ca6..bec2de8c7 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -512,7 +512,7 @@ BEGIN HELP "Codice della valuta per operazione intracomunitaria" FIELD CODVALI FLAGS "U" - GROUP 3 + GROUP 4 USE %VAL INPUT CODTAB F_VALUTAINTRA DISPLAY "Codice" CODTAB @@ -520,7 +520,7 @@ BEGIN DISPLAY "Cambio@15" R10 DISPLAY "Ultimo aggiornamento" D0 OUTPUT F_VALUTAINTRA CODTAB - OUTPUT F_CAMBIOINTRA R10 +// OUTPUT F_CAMBIOINTRA R10 CHECKTYPE NORMAL WARNING "Codice valuta assente" END @@ -531,7 +531,7 @@ BEGIN HELP "Cambio della valuta per operazione intracomunitaria" FIELD CAMBIOI FLAGS "RU" - GROUP 3 + GROUP 4 PICTURE ".5" END @@ -542,6 +542,7 @@ BEGIN FIELD LF_MOV->CORRLIRE FLAGS "R" PICTURE "." + GROUP 4 END NUMBER F_CORRVALUTA 15 2 @@ -551,6 +552,7 @@ BEGIN FIELD LF_MOV->CORRVALUTA FLAGS "R" PICTURE ".2" + GROUP 4 END ENDPAGE diff --git a/cg/cg2101.cpp b/cg/cg2101.cpp index cc0dfb077..dce0b02b3 100755 --- a/cg/cg2101.cpp +++ b/cg/cg2101.cpp @@ -100,22 +100,20 @@ int TMovimentoPN::read_mov_rows() int TMovimentoPN::read(TIsamop op, TReclock lockop, TDate& atdate) { int err = file().read(op, lockop, atdate); - if (err == NOERR) err = read_mov_rows(); + if (err == NOERR) + { + _olddate = file().get("DATAREG"); + err = read_mov_rows(); + } return err; } int TMovimentoPN::write_rec(bool re, const TRectype& rec, TLocalisamfile& f) -{ - if (re) - { - const bool scrivi = f.rewrite(rec) != NOERR; - if (scrivi) f.write(rec); - } - else - { +{ + const bool scrivi = re ? (f.rewrite(rec) != NOERR) : TRUE; + if (scrivi) f.write(rec); - } return f.status(); } @@ -155,23 +153,30 @@ char TMovimentoPN::frequenza_versamenti(int year) const } else last_freq = lia.get_char("S7"); - CHECK(last_freq == 'M' || last_freq == 'T', "Frequenza versamento IVA assurda"); + CHECK(last_freq == 'M' || last_freq == 'T', "Frequenza versamenti IVA assurda"); } return last_freq; } +int TMovimentoPN::date2liq(const TDate& data) const +{ + const int anno = data.year(); + int mese = data.month(); + if (frequenza_versamenti(anno) == 'T') + mese += 2 - ((mese-1) % 3); + return mese; +} + + bool TMovimentoPN::controlla_liquidazione(const TDate& data, bool reset) const { bool calcolata = FALSE; const int anno = data.year(); - int mese = data.month(); - if (frequenza_versamenti(anno) == 'T') - mese += 2 - ((mese-1) % 3); + const int mese = date2liq(data); // Chiave di LIM: Anno (1-4), Mese (5-6) - TTable lim("LIM"); TString16 key; key << anno << mese; @@ -246,16 +251,19 @@ int TMovimentoPN::registra(bool re, bool force) _oldiva = iva_items(); // Aggiorna data registrazione e protocollo IVA sul registro + const TDate datareg(m.get("DATAREG")); if (reg.not_empty()) { const long protiva = m.get_long("PROTIVA"); const long uprotiva = m.get_long("UPROTIVA"); - const TDate datareg = m.get_date("DATAREG"); registro.update(max(protiva, uprotiva), datareg); } - const TDate d(m.get("DATAREG")); - controlla_liquidazione(d, TRUE); + // Aggiorna flags di ricalcolo liquidazione + + controlla_liquidazione(datareg, TRUE); + if (re && datareg != _olddate) + controlla_liquidazione(_olddate, TRUE); const int att = att_mista ? 2 : 1; // Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12) @@ -263,7 +271,7 @@ int TMovimentoPN::registra(bool re, bool force) for (int a = 1; a <= att; a++) { TString16 chiave; - chiave << d.year() << registro.attivita() << a << d.month(); + chiave << annoiva << registro.attivita() << a << date2liq(datareg); plm.put("CODTAB", chiave); if (plm.read() == NOERR) { diff --git a/cg/cg2101.h b/cg/cg2101.h index 1302cf8d7..daeacf7f3 100755 --- a/cg/cg2101.h +++ b/cg/cg2101.h @@ -15,7 +15,7 @@ class TMovimentoPN : public TRelation // @DPRIV TArray _cg, _iva; int _oldcg, _oldiva; - real _balance; + TDate _olddate; // @END protected: @@ -44,6 +44,7 @@ public: int iva_items() const { return _iva.items(); } void destroy_rows(); + int date2liq(const TDate& data) const; // Estrae dalla data il mese di liquidazione char frequenza_versamenti(int year) const; // Ritorna 'M'ensile o 'T'rimestrale bool controlla_liquidazione(const TDate& data, bool reset = FALSE) const; diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index c3badf34d..f60623185 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -747,7 +747,7 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) if (key == K_ENTER) { const real imponibile(f.mask().get(101)); - const real& percent = cod2IVA(f.mask()); + const real& percent = app().causale().corrispettivi() ? ZERO : cod2IVA(f.mask()); real imposta = abs(imponibile) * percent / 100.0; imposta.ceil(); if (imponibile.sign() < 0) imposta = -imposta; @@ -755,13 +755,8 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) const real val(f.get()); if (val != imposta) { - if (val != 0.0 || !app().causale().corrispettivi()) - { - const TString16 wrong(val.string(".")); - const TString16 right(imposta.string(".")); - f.warning_box("Imposta di '%s' errata: dovrebbe essere '%s'", - (const char*)wrong, (const char*)right); - } + f.warning_box("L'imposta dovrebbe essere %s", (const char*)imposta.string(".")); + if (val.is_zero()) f.set(imposta.string()); } } else if (key == K_F8) @@ -993,7 +988,7 @@ bool TPrimanota_application::iva_handler(TMask_field& f, KEY k) bool TPrimanota_application::cg_conto_handler(TMask_field& f, KEY key) { - if (key == K_TAB || key == K_ENTER) + if (key == K_ENTER) { TMask& m = f.mask(); if (m.get(115)[0] == 'T') // Se riga totale documento @@ -1604,7 +1599,7 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key) if (m.get(F_CORRVALUTA).not_empty()) m.field(F_CORRVALUTA).on_hit(); else - key == K_F8; + key = K_F8; } if (key == K_F8) diff --git a/cg/cg2102.h b/cg/cg2102.h index 1bf6e5191..1fd00f666 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -93,7 +93,8 @@ protected: virtual bool user_create(); virtual bool user_destroy(); virtual void print(); - virtual bool change_config(const char* var, const char* old, const char* val); + virtual void on_firm_change(); + virtual void on_config_change(); virtual bool changing_mask(int mode); virtual TMask* get_mask(int mode); virtual TRelation* get_relation() const { return _rel; } @@ -125,7 +126,6 @@ protected: void fill_sheet(TMask& m) const; - void read_firm_params(); void init_mask(TMask& m); TSheet_field& cgs() const; diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index c93e6e03e..7b599a04a 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -249,25 +249,6 @@ bool TLibro_giornale::read(int y) return found; } -/* Now obsolete - TDate TLibro_giornale::global_last_print() const - { - TTable reg("REG"); - reg.setkey(1); - - TDate last(botime); - for (int err = reg.first(); err == NOERR; err = reg.next()) - { - if (reg.get_int("I0") == libro_giornale) - { - const TDate l(reg.get("D3")); - if (l > last) last = l; - } - } - return last; - } - */ - TLibro_giornale::TLibro_giornale(int y) { read(y); diff --git a/cg/cg2103.h b/cg/cg2103.h index b19bcf1d4..7bc147462 100755 --- a/cg/cg2103.h +++ b/cg/cg2103.h @@ -14,7 +14,8 @@ enum TipoIVA iva_errata = -1, nessuna_iva = 0, iva_vendite = 1, - iva_acquisti = 2, + iva_acquisti = 2, + libro_giornale = 5, iva_generica = 9 }; @@ -25,7 +26,6 @@ class TRegistro : public TObject bool read_att(); protected: - enum TipoRegistro { libro_giornale = 5 }; TRectype _rec, _att; real _prorata; @@ -49,7 +49,7 @@ public: bool agenzia_viaggi(); const TString& tipo_attivita(); - bool attivita_mista() { const char a = tipo_attivita()[0]; return a == 'M' || a == 'E'; } + bool attivita_mista() { const char a = tipo_attivita()[0]; return a == 'E'; } const real& prorata(); bool update(long uprotiva, const TDate& lastreg); diff --git a/cg/cg21cg.uml b/cg/cg21cg.uml index 2b143ad8a..a9ff5cca7 100755 --- a/cg/cg21cg.uml +++ b/cg/cg21cg.uml @@ -83,7 +83,6 @@ BEGIN OUTPUT 104 GRUPPO OUTPUT 105 CONTO OUTPUT 107 DESCR - ADD RUN CG0 -0 CHECKTYPE NORMAL MESSAGE DIRTY,106|DIRTY,206|DIRTY,306 WARNING "Conto inesistente o mancante sulla riga contabile" diff --git a/cg/cg5300a.uml b/cg/cg5300a.uml index a112a0108..01b52b19e 100755 --- a/cg/cg5300a.uml +++ b/cg/cg5300a.uml @@ -85,7 +85,7 @@ END SPREADSHEET F_SHEET_PLA 78 6 BEGIN PROMPT 1 10 "Parametri attivita'" - ITEM "Attivita'@5" + ITEM "Attivita'@5F" ITEM "Tipo@1" ITEM "% Pro-rata@6" ITEM "Plafond art.8@15"