From fae432278fe71f03695e71a6e208a4b3a76b6892 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 Jul 2013 15:35:51 +0000 Subject: [PATCH] Correzioni per liquidazione iba differita e gestione nuovo saldaconto in prima nota git-svn-id: svn://10.65.10.50/branches/R_10_00@22881 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0500.h | 1 + cg/cg0500a.uml | 14 +- cg/cg2100.cpp | 54 ++-- cg/cg2100c.uml | 4 +- cg/cg2102.h | 6 +- cg/cg2103.cpp | 3 + cg/cg2103.h | 1 + cg/cg2105.cpp | 8 +- cg/cg2106.cpp | 704 ++++++++++++++++++++++++------------------------ cg/cg3400.cpp | 114 ++++---- cg/cg4301.cpp | 55 ++-- cg/cg4302.cpp | 19 +- cg/cg4303.cpp | 72 ++--- cg/cg4304.cpp | 49 ++-- cg/cg4400.cpp | 58 ++-- cg/cg5.cpp | 2 +- cg/cg5100.cpp | 8 +- cg/cg5300.cpp | 24 +- cg/cg5300a.uml | 2 +- cg/cg5500.cpp | 8 +- cg/cg5900.cpp | 401 +++++++++++++++++++++++++++ cg/cg5900a.h | 11 + cg/cg5900a.rep | 125 +++++++++ cg/cg5900a.uml | 102 +++++++ cg/cg6800.cpp | 14 +- cg/cglib01.cpp | 6 +- cg/cglib02.cpp | 10 +- cg/cglib03.cpp | 2 +- cg/cglib04.cpp | 31 ++- cg/cglib04.h | 2 +- cg/cgmenu.men | 21 +- cg/cgsalda3.cpp | 5 + cg/f26.dir | 2 +- cg/f26.trr | 7 +- 34 files changed, 1326 insertions(+), 619 deletions(-) create mode 100644 cg/cg5900.cpp create mode 100644 cg/cg5900a.h create mode 100644 cg/cg5900a.rep create mode 100644 cg/cg5900a.uml diff --git a/cg/cg0500.h b/cg/cg0500.h index 92122e733..cce943082 100755 --- a/cg/cg0500.h +++ b/cg/cg0500.h @@ -35,6 +35,7 @@ #define F_PROVV 232 #define F_CODCAUREG 233 #define F_REGSPIVA 234 +#define F_CONTIND 235 #define SS_TIPO 101 #define SS_SEZIONE 102 diff --git a/cg/cg0500a.uml b/cg/cg0500a.uml index 691835272..a7822391a 100755 --- a/cg/cg0500a.uml +++ b/cg/cg0500a.uml @@ -329,6 +329,7 @@ BEGIN ITEM "4|Versamento contributi dipendente" ITEM "5|Compensi non soggetti" ITEM "6|Ritenute per prestazioni occasionali" + MODULE 77 END LIST F_COLL_CESP 1 40 @@ -346,12 +347,23 @@ BEGIN ITEM "T|Trasferimento" ITEM "V|Vendita cespite" ITEM "Z|Rettifica vendita" + MODULE ce END BOOLEAN F_MOVIND BEGIN - PROMPT 2 18 "Contabilita' analitica" + PROMPT 2 18 "Contabilità analitica" FIELD MOVIND + MODULE ca,cm + MESSAGE FALSE CLEAR,F_CONTIND + MESSAGE TRUE ENABLE,F_CONTIND +END + +BOOLEAN F_CONTIND +BEGIN + PROMPT 34 18 "Contabilità industriale" + FIELD MOVCGIND + MODULE ci END NUMBER F_REGSPIVA 2 diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index e01861a3a..c50f732e8 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -700,6 +700,7 @@ void TPrimanota_application::fill_sheet(TMask& m) const bool TPrimanota_application::can_I_write(const TRelation* rel) const { +/* static int err = -1; if (err < 0) { @@ -729,6 +730,8 @@ bool TPrimanota_application::can_I_write(const TRelation* rel) const } return yes; +*/ + return TRelation_application::can_I_write(rel); } // Ritorna il prossimo numero di registrazione libero @@ -1383,7 +1386,7 @@ int TPrimanota_application::write(const TMask& m) { TCausale c(causauto); if ((!gestione_saldaconto() || c.tipomov() == 0) && c.iva() == nessuna_iva) - tipauto = causauto.full() ? 1 : 0; + tipauto = 1; } } } @@ -1409,9 +1412,9 @@ int TPrimanota_application::write(const TMask& m) } link_m770(); - link_cesp(m, "Insert"); + link_cesp (m, "Insert"); link_intra(m, "Insert"); - link_anal(m, "Insert"); + link_anal (m, "Insert"); } lasterr = err; @@ -1456,9 +1459,9 @@ int TPrimanota_application::rewrite(const TMask& m) } link_m770(); - link_cesp(m, "Modify"); + link_cesp (m, "Modify"); link_intra(m, "Modify"); - link_anal(m, "Modify"); + link_anal (m, "Modify"); } return err; @@ -1488,9 +1491,9 @@ bool TPrimanota_application::remove() partite().rewrite(); } } - link_cesp(m, "Remove"); + link_cesp (m, "Remove"); link_intra(m, "Remove"); - link_anal(m, "Remove"); + link_anal (m, "Remove"); } return ok; } @@ -1715,6 +1718,7 @@ bool TPrimanota_application::link_m770() if (!has_module(M77AUT) || iva() == iva_vendite || m770 == 0) return false; + const TMask& cm = curr_mask(); int tipo_coll = 0; char tipper = ' '; long codper = 0; @@ -1724,7 +1728,7 @@ bool TPrimanota_application::link_m770() { if (m770 == 1 || m770 == 5) { - const long forn = curr_mask().get_long(F_FORNITORE); + const long forn = cm.get_long(F_FORNITORE); if (is_percipient(forn, tipper, codper)) calcola_m770(tipo_coll = 1, spese, compenso, imposte, ritenute); } @@ -1754,18 +1758,18 @@ bool TPrimanota_application::link_m770() } } - if (tipo_coll) + if (tipo_coll > 0) { TToken_string s(80); s.add(tipo_coll); - s.add(curr_mask().insert_mode() ? "I" : "M"); + s.add(cm.insert_mode() ? "I" : "M"); s.add(tipper); s.add(codper); - s.add(curr_mask().get(F_NUMREG)); - s.add(curr_mask().get(F_NUMDOC)); - s.add(curr_mask().get(F_DATADOC)); + s.add(cm.get(F_NUMREG)); + s.add(cm.get(F_NUMDOC)); + s.add(cm.get(F_DATADOC)); if (iva() == iva_acquisti) - s.add(curr_mask().get(F_TOTALE)); + s.add(cm.get(F_TOTALE)); else s.add(""); s.add(spese.string()); @@ -2322,12 +2326,11 @@ bool TPrimanota_application::link_anal(const TMask& msk, const char* action) if (!fexist("ca2.exe")) return false; - TConfig cfg(CONFIG_DITTA, "ca"); - const TDate data_att = cfg.get("DtAttCa"); + const TDate data_att = ini_get_string(CONFIG_DITTA, "ca", "DtAttCa"); if (data_att.ok()) { - //la data competenza puo' essere vuota nel caso l'utonto non abbia i permessi per compilarla.. - //..ovvero lavora a Dinamica + // la data competenza puo' essere vuota nel caso l'utonto non abbia i permessi per compilarla... + // ...ovvero lavora a Dinamica TDate data_cmp = msk.get_date(F_DATACOMP); if(!data_cmp.ok()) data_cmp = msk.get_date(F_DATAREG); @@ -2347,12 +2350,10 @@ bool TPrimanota_application::link_anal(const TMask& msk, const char* action) } if (action[0] == 'I') - { // Se non ci sono conti analitici è inutile inserire if (!bAnalBill) return false; - } // Controllo se esiste già il movimento @@ -2399,7 +2400,6 @@ bool TPrimanota_application::link_anal(const TMask& msk, const char* action) app.run(); return true; - } bool TPrimanota_application::protected_record(TRectype& mov) @@ -2413,18 +2413,18 @@ bool TPrimanota_application::protected_record(TRectype& mov) { if (mov.get_bool(MOV_STAMPATO)) { - ok = yesno_box(FR("Il movimento %ld è già stato stampato sul libro giornale:\n" - "si desidera eliminarlo ugualmente?"), numreg); + ok = delete_box(FR("Il movimento %ld è già stato stampato sul libro giornale:\n" + "si desidera eliminarlo ugualmente?"), numreg); } if (ok && mov.get_bool(MOV_REGST)) { - ok = yesno_box(FR("Il movimento %ld è già stato stampato sul bollato:\n" - "si desidera eliminarlo ugualmente?"), numreg); + ok = delete_box(FR("Il movimento %ld è già stato stampato sul bollato:\n" + "si desidera eliminarlo ugualmente?"), numreg); } if (ok && mov.get_bool(MOV_INVIATO)) { - ok = yesno_box(FR("Il movimento %ld è stato inviato ad un'altra contabilità:\n" - "si desidera eliminarlo ugualmente?"), numreg); + ok = delete_box(FR("Il movimento %ld è stato inviato ad un'altra contabilità:\n" + "si desidera eliminarlo ugualmente?"), numreg); } if (ok) last_checked_numreg = numreg; diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index 44d5a6064..22f94ccfc 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -394,9 +394,9 @@ BEGIN GROUP 2 END -BUTTON F_OCCASEDIT 56 +BUTTON F_OCCASEDIT 50 BEGIN - PROMPT 1 10 "Dati anagrafici del cliente o fornitore occasionale" + PROMPT 1 10 "Dati del cliente o fornitore occasionale" FLAGS "H" END diff --git a/cg/cg2102.h b/cg/cg2102.h index 858c7c282..1b8d6ec8e 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -295,10 +295,10 @@ protected: bool is_percipient(long forn, char& tipper, long& codper) const; long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis); bool link_m770(); - bool link_cesp(const TMask& msk, const char* action); + bool link_cesp (const TMask& msk, const char* action); bool link_intra(const TMask& msk, const char* action); - bool link_anal(const TMask& msk, const char* action); - + bool link_anal (const TMask& msk, const char* action); + public: static int type2pos(char tipo); static char row_type(const TToken_string& s); diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 6567a1ae7..31cd7643d 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -164,6 +164,9 @@ char TCausale::link_cespiti() const bool TCausale::link_analitica() const { return _rec.get_bool(CAU_MOVIND); } +bool TCausale::link_industriale() const +{ return _rec.exist(CAU_MOVCGIND) && _rec.get_bool(CAU_MOVCGIND); } + bool TCausale::ok() const { return iva() != iva_errata; } diff --git a/cg/cg2103.h b/cg/cg2103.h index ccbdacf32..52038c939 100755 --- a/cg/cg2103.h +++ b/cg/cg2103.h @@ -58,6 +58,7 @@ public: int link_m770() const; char link_cespiti() const; bool link_analitica() const; + bool link_industriale() const; const TString& compatible(const TCausale& c) const; diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index 27e90ea14..6acd11c9f 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -2158,14 +2158,17 @@ bool TPrimanota_application::edit_partite(const TMask& m, int riga) bool TPrimanota_application::crea_partita(const TBill& bill, int anno, const TString& numero, int numrig, const TImporto& importo) { + TMask& cm = curr_mask(); + TPartita& partita = app().partite().partita(bill, anno, numero); TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota const int nriga = part.get_int(PART_NRIGA); // Nuova riga // Copia dati movimento corrente - part.put(PART_NREG, NUMREG_PROVVISORIO); // Numero operazione - part.put(PART_NUMRIG, numrig); // Riga su cui ho cliccato + const long numreg = cm.insert_mode() ? NUMREG_PROVVISORIO : cm.get_long(F_NUMREG); + part.put(PART_NREG, numreg); // Numero operazione + part.put(PART_NUMRIG, numrig); // Riga su cui ho cliccato // Forza il gruppo/conto cliente corretto (lo fa gia' anche la new_row) part.put(PART_GRUPPOCL, bill.gruppo()); @@ -2175,7 +2178,6 @@ bool TPrimanota_application::crea_partita(const TBill& bill, int anno, const TSt const tipo_movimento tm = (tipo_movimento)causale.tipomov(); part.put(PART_TIPOMOV, int(tm)); - TMask& cm = app().curr_mask(); // Setta il cambio corrente const TValuta valuta(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); diff --git a/cg/cg2106.cpp b/cg/cg2106.cpp index 2ecec3c17..8757e23a6 100755 --- a/cg/cg2106.cpp +++ b/cg/cg2106.cpp @@ -1,353 +1,353 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cg2100.h" -#include "cg2102.h" - -/////////////////////////////////////////////////////////// -// Maschere per colori -/////////////////////////////////////////////////////////// - -class TColor_mask : public TAutomask -{ - const char* const _tipi; - -protected: - TProp_field& props() { return (TProp_field&)field(DLG_USER); } - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - void load_props(); - void reset_props(); - void save_props(); - -public: - TColor_mask(); -}; - -bool TColor_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - switch (o.dlg()) - { - case DLG_DELREC: - if (e == fe_button) - { - reset_props(); - return false; // Evita chiusura maschera - } - break; - case DLG_USER: - switch (e) - { - case fe_init: - xvt_vobj_maximize(props().win().win()); - load_props(); - break; - case fe_close: - save_props(); - break; - default: - break; - } - break; - default: break; - } - return true; -} - -void TColor_mask::load_props() -{ - const char* const desc[] = - { - TR("Totale documento/saldo partite"), - TR("Ritenute fiscali"), - TR("Ritenute sociali"), - TR("Generata (Imponibile)"), - TR("IVA detraibile"), - TR("IVA non detraibile"), - TR("Abbuoni attivi"), - TR("Abbuoni passivi"), - TR("Ritenute professionali"), - TR("Differenza cambi"), - TR("Spese"), - TR("Contropartita spese"), - TR("Riga Cliente/Fornitore"), - TR("Riga Collegata") - }; - - TPrimanota_application& a = app(); - TProp_field& ps = props(); - ps.freeze(true); - - int d = 0; - char prop[4] = "T_B"; - for (const char* k = _tipi; *k; k++, d++) - { - COLOR back, fore; - a.type2colors(*k, back, fore); - - prop[0] = *k; prop[1] = '\0'; - ps.set_property(prop, (const char*)NULL, desc[d]); - - prop[0] = *k; prop[1] = '_'; prop[2] = 'B'; - ps.set_property(prop, back, TR("Sfondo")); - - prop[2] = 'F'; - ps.set_property(prop, fore, TR("Testo")); - } - ps.freeze(false); -} - -void TColor_mask::reset_props() -{ - TProp_field& ps = props(); - ps.freeze(true); - char prop[4] = "T_B"; - for (const char* k = _tipi; *k; k++) - { - prop[0] = *k; - prop[2] = 'B'; - ps.set_property(prop, NORMAL_BACK_COLOR); - prop[2] = 'F'; - ps.set_property(prop, NORMAL_COLOR); - } - ps.freeze(false); -} - -void TColor_mask::save_props() -{ - TPrimanota_application& a = app(); - TProp_field& ps = props(); - - char prop[4] = "T_B"; - for (const char* k = _tipi; *k; k++) - { - prop[0] = *k; - prop[2] = 'B'; - const COLOR back = ps.get_color_property(prop); - prop[2] = 'F'; - const COLOR fore = ps.get_color_property(prop); - a.set_type_colors(*k, back, fore); - } -} - -TColor_mask::TColor_mask() : TAutomask("cg2100k"), _tipi("TFSIDNAPRCGLKX") -{ } - -/////////////////////////////////////////////////////////// -// Gestione righe colorate -/////////////////////////////////////////////////////////// - -void TPrimanota_application::load_colors() -{ - TConfig conf(CONFIG_USER, "cg2"); - TAssoc_array& colori = (TAssoc_array&)conf.list_variables(); - for (THash_object* o = colori.get_hashobj(); o; o = colori.get_hashobj()) - { - const TString& key = o->key(); - if (key.len() == 7 && key.compare("Color", 5, TRUE) == 0) - { - const COLOR col = conf.get_color(key); - TString* strcol = new TString(15); - strcol->format("%ld", col); - _colori.add(key.mid(5), strcol); - } - } -} - -void TPrimanota_application::save_colors() -{ - TConfig conf(CONFIG_USER, "cg2"); - TString16 tmp; - for (THash_object* o = _colori.get_hashobj(); o; o = _colori.get_hashobj()) - { - tmp = "Color"; tmp << o->key(); - const COLOR col = atol((TString&)o->obj()); - - bool should_delete = FALSE; - if (tmp[5] == 'B') - should_delete = same_color(col, NORMAL_BACK_COLOR); - else - should_delete = same_color(col, NORMAL_COLOR); - - if (should_delete) - conf.remove(tmp); - else - conf.set_color(tmp, col); - } -} - -COLOR TPrimanota_application::type2color(char tipor, char tipoc) -{ - COLOR col; - if (tipor > ' ') - { - const char key[3] = { tipoc, tipor, '\0' }; - TString* colstr = (TString*)_colori.objptr(key); - if (colstr == NULL) - { - colstr = new TString(8); - if (tipor == 'X') - colstr->format("%ld", tipoc == 'B' ? FOCUS_BACK_COLOR : FOCUS_COLOR); - else - colstr->format("%ld", tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR); - _colori.add(key, colstr); - } - col = atol(*colstr); - } - else - { - col = tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR; - } - return col; -} - -void TPrimanota_application::set_type_color(char tipor, char tipoc, COLOR col) -{ - if (tipor > ' ') - { - const char key[3] = { tipoc, tipor, '\0' }; - TString* colstr = (TString*)_colori.objptr(key); - if (colstr == NULL) - { - colstr = new TString(8); - _colori.add(key, colstr); - } - colstr->format("%ld", col); - } -} - -void TPrimanota_application::type2colors(char tipor, COLOR& back, COLOR& fore) -{ - back = type2color(tipor, 'B'); - fore = type2color(tipor, 'F'); -} - -void TPrimanota_application::set_type_colors(char tipor, COLOR back, COLOR fore) -{ - set_type_color(tipor, 'B', back); - set_type_color(tipor, 'F', fore); -} - -void TPrimanota_application::reset_colors() -{ - _colori.destroy(); -} - -void TPrimanota_application::set_colors() -{ - TColor_mask colors; - if (colors.run() == K_ENTER) - save_colors(); - else - load_colors(); -} - -bool TPrimanota_application::colors_handler(TMask_field& f, KEY k) -{ - if (k == K_SPACE) - app().set_colors(); - return true; -} - +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cg2100.h" +#include "cg2102.h" + +/////////////////////////////////////////////////////////// +// Maschere per colori +/////////////////////////////////////////////////////////// + +class TColor_mask : public TAutomask +{ + const char* const _tipi; + +protected: + TProp_field& props() { return (TProp_field&)field(DLG_USER); } + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + void load_props(); + void reset_props(); + void save_props(); + +public: + TColor_mask(); +}; + +bool TColor_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case DLG_DELREC: + if (e == fe_button) + { + reset_props(); + return false; // Evita chiusura maschera + } + break; + case DLG_USER: + switch (e) + { + case fe_init: + xvt_vobj_maximize(props().win().win()); + load_props(); + break; + case fe_close: + save_props(); + break; + default: + break; + } + break; + default: break; + } + return true; +} + +void TColor_mask::load_props() +{ + const char* const desc[] = + { + TR("Totale documento/saldo partite"), + TR("Ritenute fiscali"), + TR("Ritenute sociali"), + TR("Generata (Imponibile)"), + TR("IVA detraibile"), + TR("IVA non detraibile"), + TR("Abbuoni attivi"), + TR("Abbuoni passivi"), + TR("Ritenute professionali"), + TR("Differenza cambi"), + TR("Spese"), + TR("Contropartita spese"), + TR("Riga Cliente/Fornitore"), + TR("Riga Collegata") + }; + + TPrimanota_application& a = app(); + TProp_field& ps = props(); + ps.freeze(true); + + int d = 0; + char prop[4] = "T_B"; + for (const char* k = _tipi; *k; k++, d++) + { + COLOR back, fore; + a.type2colors(*k, back, fore); + + prop[0] = *k; prop[1] = '\0'; + ps.set_property(prop, (const char*)NULL, desc[d]); + + prop[0] = *k; prop[1] = '_'; prop[2] = 'B'; + ps.set_property(prop, back, TR("Sfondo")); + + prop[2] = 'F'; + ps.set_property(prop, fore, TR("Testo")); + } + ps.freeze(false); +} + +void TColor_mask::reset_props() +{ + TProp_field& ps = props(); + ps.freeze(true); + char prop[4] = "T_B"; + for (const char* k = _tipi; *k; k++) + { + prop[0] = *k; + prop[2] = 'B'; + ps.set_property(prop, NORMAL_BACK_COLOR); + prop[2] = 'F'; + ps.set_property(prop, NORMAL_COLOR); + } + ps.freeze(false); +} + +void TColor_mask::save_props() +{ + TPrimanota_application& a = app(); + TProp_field& ps = props(); + + char prop[4] = "T_B"; + for (const char* k = _tipi; *k; k++) + { + prop[0] = *k; + prop[2] = 'B'; + const COLOR back = ps.get_color_property(prop); + prop[2] = 'F'; + const COLOR fore = ps.get_color_property(prop); + a.set_type_colors(*k, back, fore); + } +} + +TColor_mask::TColor_mask() : TAutomask("cg2100k"), _tipi("TFSIDNAPRCGLKX") +{ } + +/////////////////////////////////////////////////////////// +// Gestione righe colorate +/////////////////////////////////////////////////////////// + +void TPrimanota_application::load_colors() +{ + TConfig conf(CONFIG_USER, "cg2"); + TAssoc_array& colori = (TAssoc_array&)conf.list_variables(); + for (THash_object* o = colori.get_hashobj(); o; o = colori.get_hashobj()) + { + const TString& key = o->key(); + if (key.len() == 7 && key.compare("Color", 5, TRUE) == 0) + { + const COLOR col = conf.get_color(key); + TString* strcol = new TString(15); + strcol->format("%ld", col); + _colori.add(key.mid(5), strcol); + } + } +} + +void TPrimanota_application::save_colors() +{ + TConfig conf(CONFIG_USER, "cg2"); + TString16 tmp; + for (THash_object* o = _colori.get_hashobj(); o; o = _colori.get_hashobj()) + { + tmp = "Color"; tmp << o->key(); + const COLOR col = atol((TString&)o->obj()); + + bool should_delete = FALSE; + if (tmp[5] == 'B') + should_delete = same_color(col, NORMAL_BACK_COLOR); + else + should_delete = same_color(col, NORMAL_COLOR); + + if (should_delete) + conf.remove(tmp); + else + conf.set_color(tmp, col); + } +} + +COLOR TPrimanota_application::type2color(char tipor, char tipoc) +{ + COLOR col; + if (tipor > ' ') + { + const char key[3] = { tipoc, tipor, '\0' }; + TString* colstr = (TString*)_colori.objptr(key); + if (colstr == NULL) + { + colstr = new TString(8); + if (tipor == 'X') + colstr->format("%ld", tipoc == 'B' ? FOCUS_BACK_COLOR : FOCUS_COLOR); + else + colstr->format("%ld", tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR); + _colori.add(key, colstr); + } + col = atol(*colstr); + } + else + { + col = tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR; + } + return col; +} + +void TPrimanota_application::set_type_color(char tipor, char tipoc, COLOR col) +{ + if (tipor > ' ') + { + const char key[3] = { tipoc, tipor, '\0' }; + TString* colstr = (TString*)_colori.objptr(key); + if (colstr == NULL) + { + colstr = new TString(8); + _colori.add(key, colstr); + } + colstr->format("%ld", col); + } +} + +void TPrimanota_application::type2colors(char tipor, COLOR& back, COLOR& fore) +{ + back = type2color(tipor, 'B'); + fore = type2color(tipor, 'F'); +} + +void TPrimanota_application::set_type_colors(char tipor, COLOR back, COLOR fore) +{ + set_type_color(tipor, 'B', back); + set_type_color(tipor, 'F', fore); +} + +void TPrimanota_application::reset_colors() +{ + _colori.destroy(); +} + +void TPrimanota_application::set_colors() +{ + TColor_mask colors; + if (colors.run() == K_ENTER) + save_colors(); + else + load_colors(); +} + +bool TPrimanota_application::colors_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + app().set_colors(); + return true; +} + #ifdef PRORATA100 - -/////////////////////////////////////////////////////////// -// Gestione cambiamento prorata -/////////////////////////////////////////////////////////// - -bool TPrimanota_application::test_prorata() -{ - if (iva() != iva_acquisti || !cgs().shown() || _as400) - return true; - - bool esistono_righe_senza_tipo_detrazione = false; - - const TString_array& righe_iva = ivas().rows_array(); - for (int r = 0; r < righe_iva.items(); r++) - { - const TToken_string& row = righe_iva.row(r); - real imp_det, iva_det, imp_ind, iva_ind; - get_importi_iva(row, imp_det, iva_det, imp_ind, iva_ind); - if (!iva_det.is_zero()) - { - esistono_righe_senza_tipo_detrazione = true; - break; - } - } - - bool ok = true; - if (esistono_righe_senza_tipo_detrazione) - { - int annodoc = _msk[2]->get_date(F_DATADOC).year(); - if (annodoc < 1900) - annodoc = _msk[2]->get_int(F_ANNOIVA); - - const bool prorata100 = causale().reg().prorata100(annodoc); - const bool esiste_riga_iva_detraibile = type2pos('D') >= 0; - if (prorata100) - ok = !esiste_riga_iva_detraibile; - else - ok = _msk[2]->get_real(F_TOTALE).is_zero() || esiste_riga_iva_detraibile; - } - - return ok; -} - -bool TPrimanota_application::aggiusta_prorata() -{ - TWait_cursor hourglass; - - if (test_prorata()) - return FALSE; - - TRegistro& reg = causale().reg(); - int annodoc = _msk[2]->get_date(F_DATADOC).year(); - if (annodoc < 1900) - annodoc = _msk[2]->get_int(F_ANNOIVA); - const real prorata_attuale = reg.prorata(annodoc); - const real vecchio_prorata = prorata_attuale < CENTO ? CENTO : ZERO; - - TSheet_field& iva_sheet = ivas(); - TString_array& righe_iva = iva_sheet.rows_array(); - - TToken_string oldrow(128); - for (int i = 0; i < righe_iva.items(); i++) - { - TToken_string& r = righe_iva.row(i); - if (!r.empty_items()) - { - oldrow = r; // Memorizza riga iva - reg.set_prorata(annodoc, vecchio_prorata); - iva_notify(iva_sheet, i, K_SPACE); - r.add("", 0); r.add("", 3); // Simula l'azzeramento degli importi - iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga - - reg.set_prorata(annodoc, prorata_attuale); - iva_notify(iva_sheet, i, K_SPACE); - r = oldrow; // Simula riscrittura importi - iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga - } - else - break; - } - - return TRUE; -} - -bool TPrimanota_application::prorata_handler(TMask_field& f, KEY k) -{ - if (k == K_SPACE) - { - if (app().aggiusta_prorata()) - f.hide(); - } - - return TRUE; -} - -#endif + +/////////////////////////////////////////////////////////// +// Gestione cambiamento prorata +/////////////////////////////////////////////////////////// + +bool TPrimanota_application::test_prorata() +{ + if (iva() != iva_acquisti || !cgs().shown() || _as400) + return true; + + bool esistono_righe_senza_tipo_detrazione = false; + + const TString_array& righe_iva = ivas().rows_array(); + for (int r = 0; r < righe_iva.items(); r++) + { + const TToken_string& row = righe_iva.row(r); + real imp_det, iva_det, imp_ind, iva_ind; + get_importi_iva(row, imp_det, iva_det, imp_ind, iva_ind); + if (!iva_det.is_zero()) + { + esistono_righe_senza_tipo_detrazione = true; + break; + } + } + + bool ok = true; + if (esistono_righe_senza_tipo_detrazione) + { + int annodoc = _msk[2]->get_date(F_DATADOC).year(); + if (annodoc < 1900) + annodoc = _msk[2]->get_int(F_ANNOIVA); + + const bool prorata100 = causale().reg().prorata100(annodoc); + const bool esiste_riga_iva_detraibile = type2pos('D') >= 0; + if (prorata100) + ok = !esiste_riga_iva_detraibile; + else + ok = _msk[2]->get_real(F_TOTALE).is_zero() || esiste_riga_iva_detraibile; + } + + return ok; +} + +bool TPrimanota_application::aggiusta_prorata() +{ + TWait_cursor hourglass; + + if (test_prorata()) + return FALSE; + + TRegistro& reg = causale().reg(); + int annodoc = _msk[2]->get_date(F_DATADOC).year(); + if (annodoc < 1900) + annodoc = _msk[2]->get_int(F_ANNOIVA); + const real prorata_attuale = reg.prorata(annodoc); + const real vecchio_prorata = prorata_attuale < CENTO ? CENTO : ZERO; + + TSheet_field& iva_sheet = ivas(); + TString_array& righe_iva = iva_sheet.rows_array(); + + TToken_string oldrow(128); + for (int i = 0; i < righe_iva.items(); i++) + { + TToken_string& r = righe_iva.row(i); + if (!r.empty_items()) + { + oldrow = r; // Memorizza riga iva + reg.set_prorata(annodoc, vecchio_prorata); + iva_notify(iva_sheet, i, K_SPACE); + r.add("", 0); r.add("", 3); // Simula l'azzeramento degli importi + iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga + + reg.set_prorata(annodoc, prorata_attuale); + iva_notify(iva_sheet, i, K_SPACE); + r = oldrow; // Simula riscrittura importi + iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga + } + else + break; + } + + return TRUE; +} + +bool TPrimanota_application::prorata_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + if (app().aggiusta_prorata()) + f.hide(); + } + + return TRUE; +} + +#endif diff --git a/cg/cg3400.cpp b/cg/cg3400.cpp index 64309bde1..f404463d3 100755 --- a/cg/cg3400.cpp +++ b/cg/cg3400.cpp @@ -224,7 +224,7 @@ HIDDEN TStampa_giornale& app() { return (TStampa_giornale&)main_app(); } bool TStampa_giornale::filtra_reg(const TRelation * r) { - bool ok = TRUE; + bool ok = true; if (app()._ae_solare) { const TRectype& rec = r->lfile().curr(); @@ -241,13 +241,13 @@ bool TStampa_giornale::filter_func(const TRelation * r) // Scarto SEMPRE i provvisori const TString& provvis = recmov.get(MOV_PROVVIS); if (!provvis.blank()) - return FALSE; + return false; // Scarto i movimenti che hanno il registro ai soli fini della liquidazione const TRectype& reg = r->lfile("REG").curr(); const tipo_sospensione ts = reg.get_bool("B1") ? (tipo_sospensione) reg.get_int("I9") : nessuna; if (ts == liquidazione) - return FALSE; + return false; // In caso di NO libro con iva scarta quelli che non hanno righe contabili if (!app()._libro_giornale_iva_unico) @@ -264,7 +264,7 @@ bool TStampa_giornale::filter_func(const TRelation * r) return numreg2 == numreg; } } - return TRUE; + return true; } @@ -360,7 +360,7 @@ bool TStampa_giornale::user_create() add_file (LF_MOV); add_file (LF_RMOV); add_file (LF_RMOVIVA); - return TRUE; + return true; } bool TStampa_giornale::user_destroy() @@ -370,7 +370,7 @@ bool TStampa_giornale::user_destroy() delete _RecArrivoA; delete _tabreg; - return TRUE; + return true; } void TStampa_giornale::aggiorna_mov() @@ -381,14 +381,14 @@ void TStampa_giornale::aggiorna_mov() _cur->setregion(*_RecPartoDa, *_RecArrivoA); const long items = _cur->items(); - TProgind prnd (items, TR("Aggiornamento movimenti ..."), FALSE, TRUE); + TProgind prnd (items, TR("Aggiornamento movimenti ..."), false, true); for ((*_cur) = 0L; _cur->pos() < items; ++(*_cur)) { const bool gia_stampato = _cur->file(LF_MOV).get_bool(MOV_STAMPATO); if (!gia_stampato) { - _cur->file(LF_MOV).put (MOV_STAMPATO, TRUE); + _cur->file(LF_MOV).put (MOV_STAMPATO, true); _cur->file(LF_MOV).put (MOV_NUMGIO, nprog); mov.rewrite(); nprog++; @@ -467,7 +467,7 @@ void TStampa_giornale::preprocess_footer() TString progr_dare_ap(22), progr_avere_ap(22); TString progr_dare(25), progr_avere(25), dts(25), ats(25); TString256 riga; - bool ap = FALSE; + bool ap = false; int r=1; // was 2 const int STUMB = 42; real dt, at; @@ -478,7 +478,7 @@ void TStampa_giornale::preprocess_footer() { real2currency(progr_dare_ap, _tot_dare_progr_ap); real2currency(progr_avere_ap, _tot_avere_progr_ap); - ap = TRUE; + ap = true; } // @@ -510,10 +510,10 @@ void TStampa_giornale::preprocess_footer() (const char *) ats); set_footer (r++, (const char*) riga); - _forza_ariportare = FALSE; + _forza_ariportare = false; if (_devo_riportare > 1) - _devo_riportare = FALSE; + _devo_riportare = false; } } @@ -523,7 +523,7 @@ int TStampa_giornale::set_totali_pagina(int righe) TString progr_dare_ap(22), progr_avere_ap(22); TString progr_dare(22), progr_avere(22), dts(22), ats(22); TString256 riga; - bool ap = FALSE; + bool ap = false; const int SHIFT = 15; const int STUMB = 51 + SHIFT; real dt, at; @@ -533,7 +533,7 @@ int TStampa_giornale::set_totali_pagina(int righe) { real2currency(progr_dare_ap, _tot_dare_progr_ap); real2currency(progr_avere_ap, _tot_avere_progr_ap); - ap = TRUE; + ap = true; } if (_cur->pos() == _cur->items()-1) // se sono sull'ultimo @@ -596,10 +596,10 @@ int TStampa_giornale::set_totali_pagina(int righe) // Determina se le righe settate finora stanno in questa pagina oppure no _gia_settato_ariportare = righe_rimaste() > righe; -// La fill_page mette forza_ariportare a TRUE +// La fill_page mette forza_ariportare a true // nel caso di pagine con solo i totali (v. fax VLADIMIRO) bisogna impedire // che venga stampato di nuovo "Totale ..." nella preprocess_footer - _forza_ariportare = FALSE; + _forza_ariportare = false; dt = _tot_dare_progr + _tot_dare_progr_ap; at = _tot_avere_progr + _tot_avere_progr_ap; @@ -741,7 +741,7 @@ void TStampa_giornale::preprocess_header() set_header(2, riga); // Sempre quasi sulla prima riga! } -// _gia_settato_ariportare = FALSE; +// _gia_settato_ariportare = false; if (pag > 0) // Stampa riporti { @@ -798,7 +798,7 @@ bool TStampa_giornale::preprocess_print(int file, int counter) switch (file) { case LF_MOV: - _nuovo_mese = FALSE; + _nuovo_mese = false; _iva_array.destroy(); _nprog_mov = _nprog_da; *_RecPartoDa = _cur->curr(); @@ -806,7 +806,7 @@ bool TStampa_giornale::preprocess_print(int file, int counter) default: break; } - return TRUE; + return true; } int TStampa_giornale::righe_rimaste() const @@ -858,14 +858,14 @@ print_action TStampa_giornale::postprocess_print(int file, int counter) print_action TStampa_giornale::postprocess_page(int file, int counter) { int righe_iva_settate=0; -// bool FINITO = FALSE; +// bool FINITO = false; if (counter) { if (_nuovo_mese) { printer().formfeed(); - _nuovo_mese = FALSE; + _nuovo_mese = false; } return NEXT_PAGE; } @@ -889,7 +889,7 @@ print_action TStampa_giornale::postprocess_page(int file, int counter) --(*_cur); _cur->restore_status(); - _devo_riportare = TRUE; + _devo_riportare = true; const bool last_row = _cur->pos() == _cur->items()-1; if (_data_corr != _data_succ || last_row) @@ -901,9 +901,9 @@ print_action TStampa_giornale::postprocess_page(int file, int counter) righe = set_totali_pagina(righe); if (righe - 1 > (int)printer().rows_left()) - _devo_riportare = 3; // Very TRUE! + _devo_riportare = 3; // Very true! else - _devo_riportare = FALSE; + _devo_riportare = false; // Nella stampa su bollato metto un segno su tutte le righe if (_stampa_definitiva) @@ -922,7 +922,7 @@ print_action TStampa_giornale::postprocess_page(int file, int counter) // pagina dopo if (!_totals_updated) update_totals(_sezione, _importo); - _gia_settato_ariportare = FALSE; + _gia_settato_ariportare = false; break; default: break; @@ -1145,11 +1145,11 @@ void TStampa_giornale::set_rows (int file, int counter) const int left = printer().rows_left(); if (left > 0 && left < rows) { - _totals_updated = TRUE; + _totals_updated = true; update_totals(_sezione, _importo); } else - _totals_updated = FALSE; + _totals_updated = false; } } break; @@ -1166,7 +1166,7 @@ void TStampa_giornale::set_rows (int file, int counter) // bool TStampa_giornale::preprocess_page(int file, int counter) { - if (counter) return TRUE; + if (counter) return true; switch (file) { @@ -1184,7 +1184,7 @@ bool TStampa_giornale::preprocess_page(int file, int counter) if (_data_corr > _ultima_data_mov) _ultima_data_mov = _data_corr; _mese_corr = _data_corr.month(); - _devo_riportare = TRUE; + _devo_riportare = true; } break; @@ -1199,7 +1199,7 @@ bool TStampa_giornale::preprocess_page(int file, int counter) break; } set_rows (file, counter); - return TRUE; + return true; } void TStampa_giornale::calcola_iva() @@ -1450,27 +1450,27 @@ bool TStampa_giornale::controlla_mov_aep() fine_ep = esc[aep].fine(); } else - return TRUE; // = e' il primo esercizio + return true; // = e' il primo esercizio TRectype da(LF_MOV), a(LF_MOV); da.put(MOV_DATAREG, inizio_ep); a.put (MOV_DATAREG, fine_ep); _cur->setregion(da, a); _cur->setfilter(""); - _cur->set_filterfunction(filter_func, TRUE); + _cur->set_filterfunction(filter_func, true); const TRecnotype items = _cur->items(); _cur->freeze(); - TProgind pi(items, TR("Controllo movimenti esercizio precedente"), FALSE, TRUE); + TProgind pi(items, TR("Controllo movimenti esercizio precedente"), false, true); - bool gia_stampati = TRUE; + bool gia_stampati = true; for (*_cur = 0L ; _cur->pos() < items; ++(*_cur)) { pi.addstatus(1); gia_stampati = _cur->file().get_bool("STAMPATO"); if (!gia_stampati) break; // basta trovarne uno ancora da stampare } - _cur->freeze(FALSE); + _cur->freeze(false); if (!gia_stampati) error_box(TR("Impossibile proseguire con la stampa:\n" "Esistono movimenti nell'esercizio precedente\n" @@ -1527,7 +1527,7 @@ bool TStampa_giornale::data_a_hndl (TMask_field& f, KEY k) const TDate data_a(f.get()); if (!data_a.ok()) - return TRUE; + return true; TEsercizi_contabili esc; const int esercizio = esc.date2esc(data_a); @@ -1560,7 +1560,7 @@ bool TStampa_giornale::data_a_hndl (TMask_field& f, KEY k) } } // if K_ENTER - return TRUE; + return true; } bool TStampa_giornale::data_da_hndl(TMask_field& f, KEY k) @@ -1573,7 +1573,7 @@ bool TStampa_giornale::data_da_hndl(TMask_field& f, KEY k) const TDate data_a(m.get(DATA_A)); if (!data_da.ok() || !data_a.ok()) - return TRUE; + return true; if (data_da.year() != data_a.year()) return f.error_box(TR("Le due date non appartengono allo stesso anno")); @@ -1594,7 +1594,7 @@ bool TStampa_giornale::data_da_hndl(TMask_field& f, KEY k) if (data_da.ok() && data_da > data_a) return f.warning_box(TR("La data di partenza non puo' essere maggiore della data finale")); } - return TRUE; + return true; } // @@ -1614,7 +1614,7 @@ bool TStampa_giornale::mask_a_cod_reg (TMask_field& f, KEY k) // 25/11 controlli sul registro solo DOPO aver messo la DATA_A if (data_astr.empty()) - return TRUE; + return true; else { TEsercizi_contabili esc; @@ -1633,7 +1633,7 @@ bool TStampa_giornale::mask_a_cod_reg (TMask_field& f, KEY k) m.set(REG_DESC, a._reg_descr); m.set(ANNO_ESER, a._ae_solare); } - return TRUE; + return true; } // @@ -1653,27 +1653,27 @@ bool TStampa_giornale::mask_b_ripristina (TMask_field& f, KEY k) m.set(N_RIGA_STAMPATO, a._nprog_da); m.set(PAGINA_DA, a._pagine_stampate); } - return TRUE; + return true; } bool TStampa_giornale::mask_b_warning (TMask_field& f, KEY k) { - static bool gia_detto = FALSE; + static bool gia_detto = false; if (k == K_TAB && !f.mask().is_running()) - gia_detto = FALSE; + gia_detto = false; if (!gia_detto) { if (k == K_SPACE) { f.warning_box(TR("Le modifiche a questi progressivi saranno scritte nel registro")); - gia_detto = TRUE; - return TRUE; + gia_detto = true; + return true; } } - return TRUE; + return true; } void TStampa_giornale::init_print() @@ -1696,7 +1696,7 @@ void TStampa_giornale::init_print() for (int i=1; isetregion(da, a); - _cur->set_filterfunction(filter_func, TRUE); + _cur->set_filterfunction(filter_func, true); _cur->setfilter(_stampa_definitiva ? "STAMPATO!=\"X\"" : ""); (*_cur) = 0L; @@ -1759,7 +1759,7 @@ bool TStampa_giornale::init_cursor() return warning_box(TR("Non ci sono movimenti da stampare nel periodo selezionato.\nLa stampa e' annullata")); } - return TRUE; + return true; } bool TStampa_giornale::set_print(int) @@ -1772,7 +1772,7 @@ bool TStampa_giornale::set_print(int) // set_reg_filter(ma); _pagina_da = 0; // Parto dall'inizio - _forza_ariportare = FALSE; + _forza_ariportare = false; KEY tasto; while ((tasto = ma.run()) != K_QUIT) @@ -1787,7 +1787,7 @@ bool TStampa_giornale::set_print(int) _stampa_width = ma.get_int(STAMPA_WIDTH); _stampa_len = ma.get_int(STAMPA_LEN); - set_magic_currency(TRUE); + set_magic_currency(true); // set_curr_codval(ma.get(F_CODVAL)); // Se stampa definitiva DALLA_DATA e' la data di inizio esercizio @@ -1840,14 +1840,14 @@ bool TStampa_giornale::set_print(int) init_print(); init_totals(); - return TRUE; + return true; } - return FALSE; + return false; } -int cg3400 (int argc, char * argv[]) +int cg3400(int argc, char * argv[]) { TStampa_giornale app; app.run(argc, argv, TR("Stampa libro giornale")); - return TRUE; + return true; } diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index b335ba1a1..ca06b5a6a 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -214,10 +214,11 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) _nditte->save_status(); if (_nditte->is_first_match(LF_ATTIV)) { + const TRectype& ndt_att = _nditte->curr(LF_ATTIV); do { - const TString8 codatt = _nditte->curr(LF_ATTIV).get("CODATT"); - const TString80 desatt = _nditte->curr(LF_ATTIV).get("DESCR"); + const TString8 codatt = ndt_att.get("CODATT"); + const TString80 desatt = ndt_att.get("DESCR"); quater = _nditte->curr().get_bool("FLIVA11Q"); // attività mista: ce ne sono in realtà due @@ -227,9 +228,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) if (_prind) { TString buf(80); - buf.format( _printonly ? FR("Stampa liquidazione (mese %d)...\n%s: %s\n") : - FR("Calcolo liquidazione (mese %d)...\n%s: %s\n"), - month, (const char*)_nditte_r->get(NDT_RAGSOC), (const char*)desatt); + buf.format( _printonly ? FR("Stampa liquidazione (mese %d %d)...\n%s: %s\n") : + FR("Calcolo liquidazione (mese %d %d)...\n%s: %s\n"), + month, atoi(_year), (const char*)_nditte_r->get(NDT_RAGSOC), (const char*)desatt); _prind->set_text(buf); } @@ -282,10 +283,10 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) look_pla(cattiv, false); } else - _isservizio = _nditte->curr(LF_ATTIV).get("TIPOATT") == "S"; + _isservizio = ndt_att.get("TIPOATT") == "S"; - _isviaggio = _nditte->curr(LF_ATTIV).get_bool("REG74TER"); - _isagricolo = _nditte->curr(LF_ATTIV).get_bool("REGAGR"); + _isviaggio = ndt_att.get_bool("REG74TER"); + _isagricolo = ndt_att.get_bool("REGAGR"); _isagr98 = _isagricolo && atoi(_year) >= 1998; _isvent = false; @@ -559,7 +560,7 @@ void TLiquidazione_app::zero_att(int month, const char* codatt) if (_isplafond && month != 13) zero_plafond(month,codatt); - if (month != 13) + if (month != 13 && !_recalc_regis) // Aggiunto test per evitare azzeramenti in stampa registri 19-06-2013 zero_diff(month,codatt); } @@ -569,8 +570,8 @@ bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) c TString query; query << "USA IVADIFF SELECT BETWEEN(DATAREGP,0," << fine.date2ansi() << ')' - << "\nFROM NUMREG==" << numreg - << "\nTO NUMREG==" << numreg; + << "\nFROM NUMREG=" << numreg + << "\nTO NUMREG=" << numreg; TISAM_recordset id(query); const TRectype& rid = id.cursor()->curr(); @@ -971,18 +972,15 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (_isviaggio) { - if (tipomov == vendita && !(_mov->get(MOV_DATA74TER).empty())) + if (tipomov == vendita && _mov->get(MOV_DATA74TER).not_empty()) date = _mov->get_date(MOV_DATA74TER); if (date.year() != year_int) // Controlla anno di appartenenza, altrimenti is_date_ok potrebbe non funzionare continue; } const TRectype& rcs = _cur->curr(LF_CAUSALI); - const bool fattrit = rcs.get_bool("RITFATT"); - const bool cau_intra = rcs.get_bool("INTRACOM"); - const bool cau_valintra = rcs.get_bool("VALINTRA"); - - if (_mov->get_long(MOV_NUMREG) == 10146) - int cazzone = 1; + const bool fattrit = rcs.get_bool(CAU_RITFATT); + const bool cau_intra = rcs.get_bool(CAU_INTRACOM); + const bool cau_valintra = rcs.get_bool(CAU_VALINTRA); // Inizio gestione IVA differita const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF); @@ -1201,11 +1199,19 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) else id.put(RMI_IMPOSTA, imposta_orig); - id.write_rewrite(); + const int ew = id.write_rewrite(); + if (ew != NOERR) + cantwrite_box(id.description()); } if (!pagscatt.empty()) { +#ifdef DBG + if (_mov->get_long(MOV_NUMREG) == 13871) + xvt_dm_popup_message("Aggiornamento IVADIFF per movimento 13871"); +#endif + + const char sezpag = tipomov == vendita ? 'A' : 'D'; const real totfat = _mov->get(MOV_TOTDOC); @@ -2067,7 +2073,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) vendite += iii; } - if (autodafe) // autofatture non residenti art, 17 + if (autodafe) // autofatture non residenti art.17 { /* * Si devono riportare a parte in annuale @@ -3048,20 +3054,23 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt) } } // is_vendita - // Boia chi linka! // Sommatoria per il calcolo aliquote medie vendite/acquisti... if (_pim->get_bool("B3")) // E' un record valido per fare questa cosa? { if ((tiporeg)_pim->get_long("I1") == vendita) { //vendite - vtot += imp; ivav+=iva; + vtot += imp; + ivav += iva; } else + { //acquisti if (tipodet != 9) // Evita di sommare quelli con tipo detraibilita' 9 (MI2209) { - atot += imp; ivaa+=iva; + atot += imp; + ivaa += iva; } + } } } diff --git a/cg/cg4302.cpp b/cg/cg4302.cpp index b38568669..fa4856a2f 100755 --- a/cg/cg4302.cpp +++ b/cg/cg4302.cpp @@ -568,21 +568,22 @@ bool TLiquidazione_app::look_reg(const char* reg) bool TLiquidazione_app::look_iva(const char* cod) { - bool rt = TRUE; - TString16 s(cod); - const bool is_key = _codiva_arr.is_key(cod); + bool rt = true; + + TString4 s = cod; s.trim(); + const bool is_key = _codiva_arr.is_key(s); if (is_key) - _iva->curr() = (TRectype&) _codiva_arr[s]; + _iva->curr() = (const TRectype&)_codiva_arr[s]; else { _iva->zero(); - _iva->put("CODTAB",s); - if (_iva->read() == NOERR) - _codiva_arr.add(s,_iva->curr()); - else - rt = FALSE; + _iva->put("CODTAB", s); + rt = _iva->read() == NOERR; + if (rt) + _codiva_arr.add(s, _iva->curr()); } + return rt; } diff --git a/cg/cg4303.cpp b/cg/cg4303.cpp index 165498d14..ec7cf9d6e 100755 --- a/cg/cg4303.cpp +++ b/cg/cg4303.cpp @@ -368,7 +368,8 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) { look_iva(vv->_codiva); _pim->put("I1", (long)vendita); - if (!_iva->get_bool("B4")) _pim->put("B3", "X"); + if (!_iva->get_bool("B4")) + _pim->put("B3", "X"); } _pim->rewrite(); } @@ -626,37 +627,44 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts, // Azzera tabella IVA x CASSA void TLiquidazione_app::zero_diff(int month, const char* codatt) { - // Azzero tuttp al momento dell'azzeramento della prima attività - if (_nditte->is_first_match(LF_ATTIV)) - { - if (month > 12 || (_freqviva == "T" && (month % 3) != 1)) - return; + // Azzero tutto al momento dell'azzeramento della prima attività + if (!_nditte->is_first_match(LF_ATTIV)) + return; - TString query; - query << "USE IVADIFF KEY 2"; - query << "\nFROM ANNOLIQ=" << _year; - if (month > (_freqviva == "T" ? 3 : 1)) - query << " MESELIQ=" << month; - TISAM_recordset id(query); - TLocalisamfile& file = id.cursor()->file(); - for (bool ok = id.move_first(); ok; ok = id.move_next()) - { - file.zero("ANNOLIQ"); - file.zero("MESELIQ"); - file.zero("IMPORTO"); - file.zero("IMPONIBILE"); - file.zero("IMPOSTA"); - file.zero("DATAREG"); - file.zero("NUMREGP"); - file.zero("NUMRIGP"); - file.zero("DATAREGP"); - file.zero("DATAREGP"); - file.zero("TIPOMOV"); - file.zero("TIPOIVA"); - file.zero("TIPOATT"); - file.zero("TIPODIFF"); - file.zero("CHIUSA"); - file.rewrite(); - } + if (month > 12 || (_freqviva == "T" && (month % 3) != 1)) + return; + +#ifdef DBG + TString msg; msg. + format("Azzeramento IVADIFF mese %s %s attività %s", + itom(month), (const char*)_year, codatt); + xvtil_statbar_set(msg); +#endif + + TString query; + query << "USE IVADIFF KEY 2"; + query << "\nFROM ANNOLIQ=" << _year; + if (month > (_freqviva == "T" ? 3 : 1)) + query << " MESELIQ=" << month; + TISAM_recordset id(query); + TLocalisamfile& file = id.cursor()->file(); + for (bool ok = id.move_first(); ok; ok = id.move_next()) + { + file.zero("ANNOLIQ"); + file.zero("MESELIQ"); + file.zero("IMPORTO"); + file.zero("IMPONIBILE"); + file.zero("IMPOSTA"); + file.zero("DATAREG"); + file.zero("NUMREGP"); + file.zero("NUMRIGP"); + file.zero("DATAREGP"); + file.zero("DATAREGP"); + file.zero("TIPOMOV"); + file.zero("TIPOIVA"); + file.zero("TIPOATT"); + file.zero("TIPODIFF"); + file.zero("CHIUSA"); + file.rewrite(); } } diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 2f2af4d9a..2aca755a5 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -171,14 +171,11 @@ void TLiquidazione_app::describe_name(int month, const TToken_string& codatts, c d->_s0 = _nditte->curr().get(NDT_CODDITTA); d->_s1 = _nditte->curr().get(NDT_RAGSOC); - if (atoi(_year) > 2007) - { - const TString16 codateco = _nditte->curr(LF_ATTIV).get(ATT_CODATECO); - d->_s2 = codateco; - } - else - d->_s2 = _nditte->curr(LF_ATTIV).get(ATT_CODATT); - d->_s3 = single_att ? (const char*)_nditte->curr(LF_ATTIV).get(ATT_DESCR) : ""; + const TRectype& ndt_att = _nditte->curr(LF_ATTIV); + d->_s2 = ndt_att.get(ATT_CODATECO); + if (d->_s2.blank()) + d->_s2 = ndt_att.get(ATT_CODATT); + d->_s3 = single_att ? (const char*)ndt_att.get(ATT_DESCR) : ""; d->_s4 = _freqviva; d->_f1 = month; @@ -565,7 +562,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool const TString8 activity= codtab.mid(4,6); const TString4 codreg = codtab.mid(10,3); const int mese = atoi(codtab.mid(13,2)); - TString4 codiva = codtab.mid(16,4); + TString4 codiva = codtab.mid(16,4); codiva.trim(); const int tipodet = atoi(codtab.mid(20,1)); bool ok = look_reg(codreg); ok |= look_iva(codiva); @@ -806,7 +803,6 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool } autodafe += adf; - autodafe_iva += adi; art40 += va7i; art40_iva += va7v; } @@ -972,7 +968,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; - ads->_s1 = "AF"; // cosi' vollero, inoltre non e' piu' A35 ma AF, come sul dio sistema + ads->_s1 = "AF"; // così vollero, inoltre non è più A35 ma AF, come sul dio sistema ads->_r0 = autodafe; ads->_r1 = autodafe_iva; ads->_f0 = false; @@ -1642,28 +1638,25 @@ int TLiquidazione_app::calc_inc_diff(int tipoiva, real& imponibile_diff, real& i TString limit; limit << "ANNOLIQ=" << _year; if (_month < 13) limit << " MESELIQ=" << _month; - TString query; - query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(TIPOIVA=" << tipoiva << ')'; - query << "\nFROM " << limit << "\nTO " << limit; + TString query; // righe pagamento (TIPOMOV>=3) relative a fatture (TOTDOC>0) ed escluse NC! + query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(MOV.TOTDOC>0)&&(TIPOIVA=" << tipoiva << ')' + << "\nJOIN MOV INTO NUMREG==NUMREG" + << "\nFROM " << limit << "\nTO " << limit; TISAM_recordset id(query); const TRectype& rec = id.cursor()->curr(); for (bool ok = id.move_first(); ok; ok = id.move_next()) { const real iva = rec.get_real(RMI_IMPOSTA); - if (iva > ZERO) + if (!iva.is_zero()) { - const real imp = rec.get_real(RMI_IMPONIBILE); const int tipodiff = rec.get_int("TIPODIFF"); - if (tipodiff == 1) + const real imp = rec.get_real(RMI_IMPONIBILE); + switch (tipodiff) { - imponibile_diff += imp; - imposta_diff += iva; - } else - if (tipodiff == 2) - { - imponibile_xcas += imp; - imposta_xcas += iva; + case 1: imponibile_diff += imp; imposta_diff += iva; break; + case 2: imponibile_xcas += imp; imposta_xcas += iva; break; + default: break; } flag |= tipodiff; } @@ -1677,8 +1670,8 @@ int TLiquidazione_app::print_acc_diff_xcassa(const _DescrItem& d) int i = 9; const real& totiva = d._r0; - real ivadiff_inc = d._r29; - real ivadiff_pag = d._r33; + const real ivadiff_inc = d._r29; + const real ivadiff_pag = d._r33; real ivaxcas_inc, ivaxcas_pag; @@ -2483,12 +2476,12 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw) { real dimp, diva, ximp, xiva; - if (!diffinc_iva.is_zero() && calc_inc_diff(1, dimp, diva, ximp, xiva) & 0x2) + if (!diffinc_iva.is_zero() && calc_inc_diff(1, dimp, diva, ximp, xiva)) { diffinc_iva = diva; xcasinc_iva = xiva; } - if (!diffinc_iva_acq.is_zero() && calc_inc_diff(2, dimp, diva, ximp, xiva) & 0x2) + if (!diffinc_iva_acq.is_zero() && calc_inc_diff(2, dimp, diva, ximp, xiva)) { diffinc_iva_acq = diva; xcasinc_iva_acq = xiva; diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index 4dcb2cf46..a7a4bbe06 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -1915,7 +1915,20 @@ bool TStampa_registri_app::some_IVAxCassa(int da_mese, int a_mese) const query << "\nFROM ANNOLIQ=" << _data_da.year() << " MESELIQ=" << da_mese; query << "\nTO ANNOLIQ=" << _data_a.year() << " MESELIQ=" << a_mese; TISAM_recordset id(query); - return id.items() > 0; + const TRecnotype recs = id.items(); + +#ifdef DBG + TString msg; + if (a_mese > da_mese) + msg << "Nei mesi da " << itom(da_mese) << " a " < itom(a_mese); + else + msg << "Nel mese di " << itom(da_mese); + msg << " ci sarebbero " << recs << " incassi/pagamenti per cassa."; + xvtil_statbar_set(msg); + xvt_sys_sleep(1000); +#endif + + return recs > 0; } bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) @@ -1923,6 +1936,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) if (_tipo_reg != vendita && _tipo_reg != acquisto) return false; + // Non stampare il prospetto IVA differita sui registri if (ini_get_bool(CONFIG_STUDIO, "cg", "NoIdRg")) { _riga_prospettoXcassa.destroy(); @@ -1946,7 +1960,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) TString query; query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(MOV.TOTDOC>0))"; - query << "\nBY DATAREGP DATAREG"; + query << "\nBY DATAREGP DATAREG NUMPRO"; query << "\nJOIN MOV INTO NUMREG==NUMREG"; query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; TISAM_recordset id(query); @@ -1958,10 +1972,21 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) const bool il = _intesta_liq; _intesta_liq = true; - if (id.items() > 0) + const TRecnotype recs = id.items(); +#ifdef DBG + TString msg; + if (a_month > a_month) + msg << "Nei mesi da " << itom(da_month) << " a " < itom(a_month); + else + msg << "Nel mese di " << itom(da_month); + msg << " ci sono effettivamente " << recs << " incassi/pagamenti per cassa."; + xvtil_statbar_set(msg); +#endif + + if (recs > 0) { riga.reset(); - if (pr.rows_left() < id.items()+8) + if (pr.rows_left() < pr.rows() && pr.rows_left() < id.items()+8) { pr.formfeed(); riga.put(linea, 0); @@ -1972,7 +1997,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) if (_tipo_reg == vendita) riga.put(TR("DETTAGLIO INCASSI FATTURE CON IVA DIFFERITA O PER CASSA"), 40); else - riga.put(TR("DETTAGLIO PAGAMENTI FATTURE CON IVA DIFFERITA O PER CASSA"), 40); + riga.put(TR("DETTAGLIO PAGAMENTI FATTURE CON IVA PER CASSA"), 40); pr.print(riga); riga.reset(); pr.print(riga); @@ -3344,7 +3369,12 @@ void TStampa_registri_app::no_movimenti() _mov_empty = true; int da = 1, a = _fino_a_mese; if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale) - da = 1; + { + if (_tipo_stampa == rif_giornale) + da = 1; + else + da = _frequiva == 'M' ? _fino_a_mese : _fino_a_mese-2; // Mi sembra più sensato 19/06/2013 + } if (_tipo_stampa == libro_unico) da = _fino_a_mese; if (_tipo_stampa == prova) @@ -3369,8 +3399,7 @@ void TStampa_registri_app::no_movimenti() TFilename app; app.temp(); int mese = a; - //se la frequenza e' trimestrale - //aggiusta il mese al trimestre a cui appartiene + // se la frequenza e' trimestrale aggiusta il mese al trimestre a cui appartiene if (_frequiva == 'T') { mese += 2 - ((mese-1) % 3); @@ -3730,10 +3759,9 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) const long item = _cur->items(); // 17.5.95 Leggo parametri di stampa del registro - TString16 config; + const long codditta = get_firm(); - const char* reg = (const char*)_codreg; - config.format("REG%05ld%s", codditta, reg); + TString16 config; config.format("REG%05ld%s", codditta, (const char*)_codreg); printer().read_configuration(config); _mov_empty = true; @@ -3743,9 +3771,8 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) print(); if (is_cancelled()) return false; - } - //non ci sono movimenti da stampare nel periodo richiesto! - else + } + else //non ci sono movimenti da stampare nel periodo richiesto! no_movimenti(); if (_tipo_stampa == libro_unico && _rif_vid) @@ -3792,7 +3819,8 @@ bool TStampa_registri_app::stampa_registri_IVA(const TMask& m) if (_u_data.ok()) if (_data_a < _u_data) //e' molto imp. che rimanga < e non <= !!! { //(per via del discorso liq. annuale) - message_box(FR("Ditta %ld: Il registro %s e' gia' stato stampato come bollato di %s"), _ditta, (const char*) _codreg, itom(_fino_a_mese)); + message_box(FR("Ditta %ld: Il registro %s e' gia' stato stampato come bollato di %s"), + _ditta, (const char*) _codreg, itom(_fino_a_mese)); continue; } } diff --git a/cg/cg5.cpp b/cg/cg5.cpp index b29b6278d..de89efda6 100755 --- a/cg/cg5.cpp +++ b/cg/cg5.cpp @@ -16,7 +16,7 @@ int main(int argc,char** argv) case 6: cg5600(argc,argv); break; // Ripristino liquidazione case 7: cg5700(argc,argv); break; // Comunicazione annuale dati IVA case 8: cg5800(argc,argv); break; // Quadro VT - case 9: cg5900(argc,argv); break; // Stampa Prorata + case 9: cg5900(argc,argv); break; // Stampa pro-rata default: cg5000(argc,argv); break; // Parametri Studio } return 0; diff --git a/cg/cg5100.cpp b/cg/cg5100.cpp index 57b1f3cbd..d8561347d 100755 --- a/cg/cg5100.cpp +++ b/cg/cg5100.cpp @@ -43,7 +43,7 @@ bool TParametri_ditta::user_create() cur.freeze(); for (cur = 0L; cur.pos() < items; ++cur) - // istanzia array _atts on le attivita' della ditta corrente + // istanzia array _atts on le attività della ditta corrente _atts.add(r.get(ATT_CODATT)); return TRUE; @@ -52,7 +52,7 @@ bool TParametri_ditta::user_create() void TParametri_ditta::check_registers(int year) { - // controlla che per ogni data attivita' esistano almeno un registro + // controlla che per ogni data attività esistano almeno un registro // acquisti, vendite e giornale; warning appropriato in caso negativo const byte R_ACQ = 0x01; const byte R_VEN = 0x02; @@ -92,7 +92,7 @@ void TParametri_ditta::check_registers(int year) } if (flags < R_ALL) { - TString wrn(TR("I seguenti registri non esistono per l'attivita' ")); + TString wrn(TR("I seguenti registri non esistono per l'attività ")); wrn << att << " (" << year << "):"; if ((flags & R_VEN) == 0x00) wrn << TR("\n\tregistro vendite"); if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti"); @@ -100,7 +100,7 @@ void TParametri_ditta::check_registers(int year) } } - // libro giornale non si controlla per attivita' + // libro giornale non si controlla per attività if(!is_giornale) warning_box(FR("Non esiste probabilmente nessun libro giornale per l'anno %d"), year); } diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index be84953de..3bc3a8976 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -1,5 +1,5 @@ // cg5300.cpp -// modifica parametri contabilita' relativi alla liquidazione +// modifica parametri contabilità relativi alla liquidazione #include #include @@ -89,7 +89,7 @@ bool TParaliq_app::gelidi_handler(TMask_field& f, KEY k) { f.set(" "); f.error_box(TR("La gestione della liquidazione differita richiede " - "la data di inizio attivita' sull'anagrafica della ditta.")); + "la data di inizio attività sull'anagrafica della ditta.")); } } } @@ -114,7 +114,7 @@ bool TParaliq_app::agrmin_handler(TMask_field& f, KEY k) { f.set(" "); f.error_box(TR("La gestione degli agricoltori minimi richiede " - "il settaggio del regime agricolo sull'attivita'.")); + "il settaggio del regime agricolo sull'attività.")); } } } @@ -203,7 +203,7 @@ bool TParaliq_app::utcred_handler(TMask_field& f, KEY k) void TParaliq_app::check_registers(int year) { - // controlla che per ogni data attivita' esistano almeno un registro + // controlla che per ogni data attività esistano almeno un registro // acquisti, vendite e giornale; warning appropriato in caso negativo TSheet_field& sf = _msk->sfield(F_SHEET_PLA); const byte R_ACQ = 0x01; @@ -240,7 +240,7 @@ void TParaliq_app::check_registers(int year) } if (flags < R_ALL) { - TString wrn(TR("I seguenti registri non esistono per l'attivita' ")); + TString wrn(TR("I seguenti registri non esistono per l'attività ")); wrn << att << "(" << year << "):"; if ((flags & R_VEN) == 0x00) wrn << TR("\n\tregistro vendite"); if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti"); @@ -325,7 +325,7 @@ void TParaliq_app::init_query_mode(TMask& m) void TParaliq_app::init_insert_mode(TMask& m) { - // Inizializza array delle attivita' + // Inizializza array delle attività init_array(m, TRUE); m.set(F_ROUNDLIQ, TCurrency::get_firm_dec()); } @@ -355,7 +355,7 @@ int TParaliq_app::rewrite(const TMask& m) TTable pla(TAB_PLA); pla.put("CODTAB", codtab); - pla.remove(); // Rimuove dalla tabella PLA il record senza il tipo attivita' ad 1 (se non c'e' fa lo stesso) + pla.remove(); // Rimuove dalla tabella PLA il record senza il tipo attività ad 1 (se non c'e' fa lo stesso) codtab << "1"; // Questo invece e' il codice che deve esistere realmente pla.put("CODTAB", codtab); was = (pla.read() == NOERR); @@ -369,7 +369,7 @@ int TParaliq_app::rewrite(const TMask& m) pla.put("CODTAB", codtab); // scrive i campi (vedi a read() per i nomi) // in base alla riga sheet - pla.put("S7", tips); // tipo attivita' + pla.put("S7", tips); // tipo attività pla.put("R8", tt.get()); // prorata pla.put("R5", tt.get()); // plafond art. 8 pla.put("R6", tt.get()); // plafond art. 8bis @@ -439,7 +439,7 @@ int TParaliq_app::rewrite(const TMask& m) int TParaliq_app::read(TMask& m) { // legge da LIA (si istanziano i campi credito prec. e Freq. Vers - // prende le attivita' una per una da _atts e + // prende le attività una per una da _atts e // crea le righe sheet m.autoload(*get_relation()); @@ -457,16 +457,16 @@ int TParaliq_app::read(TMask& m) TCursor cur(&relpla, "", 1, &pla, &pla); const TRecnotype items = cur.items(); - init_array(m, FALSE); // Carica tutti i codici attivita' + init_array(m, FALSE); // Carica tutti i codici attività cur.freeze(); for (cur = 0L; cur.pos() < items; ++cur) { - tt = pla.get("CODTAB").mid(9,5); // codice attivita' + tt = pla.get("CODTAB").mid(9,5); // codice attività int i; for (i = 0; i < sf.items(); i++) // Cerca riga corrispondente sullo sheet if (tt == sf.row(i).get(0)) break; - tt.add(pla.get("S7")); // tipo attivita' + tt.add(pla.get("S7")); // tipo attività tt.add(pla.get("R8")); // prorata tt.add(pla.get("R5")); // plafond art. 8 tt.add(pla.get("R6")); // plafond art. 8bis diff --git a/cg/cg5300a.uml b/cg/cg5300a.uml index f8fc64f31..18fc6b7c9 100755 --- a/cg/cg5300a.uml +++ b/cg/cg5300a.uml @@ -239,7 +239,7 @@ END LIST F_TIPOATT 26 BEGIN PROMPT 4 3 "Tipo " - HELP "Tipo di attivita' della ditta" + HELP "Tipo di attività della ditta" ITEM " |Altre" ITEM "E|Mista evid." ITEM "S|Serv. o mista gen." diff --git a/cg/cg5500.cpp b/cg/cg5500.cpp index 06e297ef5..92a6b232f 100755 --- a/cg/cg5500.cpp +++ b/cg/cg5500.cpp @@ -781,7 +781,7 @@ bool Visliq_app::vis_one(int m) if (!n_rimborso.is_zero()) { const bool old_rim = !rimborso.is_zero(); - // check diritto (se non ce n'era gia' uno prima) + // check diritto (se non ce n'era già uno prima) if (!_lim->get_bool("B2") && !old_rim) ok = yesno_box(FR("Non risulta diritto al rimborso per il mese %d. Si desidera " "confermare ugualmente?"), m); @@ -1716,7 +1716,7 @@ void Visliq_app::write_general(TMask& m) if (odbcr == "C") orett = -orett; if (ndbcr == "C") nrett = -nrett; - // acconto (si considerera' solo a dicembre) + // acconto (si considererà solo a dicembre) TToken_string& vo = (TToken_string&)_vers_rows[_freqviva == "M" ? 11 : 3]; TToken_string& vn = sv.row(_freqviva == "M" ? 11 : 3); real oacct (vo.get(5)); @@ -1824,7 +1824,7 @@ void Visliq_app::write_general(TMask& m) } // controlla se qualcosa e' modificato e scrivi - // il valore; check compatibilita' versamenti e rimborsi + // il valore; check compatibilità versamenti e rimborsi // rileggi dati real cred = _lam->get_real("R2"); @@ -1858,7 +1858,7 @@ void Visliq_app::write_general(TMask& m) // se modificato rimborso sistemare if (nrimb != orimb && !_from_one) { - // check compatibilita' + // check compatibilità bool ok = TRUE; if (!nrimb.is_zero()) diff --git a/cg/cg5900.cpp b/cg/cg5900.cpp new file mode 100644 index 000000000..bfc0d866b --- /dev/null +++ b/cg/cg5900.cpp @@ -0,0 +1,401 @@ +// Programma per la gestione e la stampa della dichiarazione periodica IVA +#include +#include +#include +#include +#include +#include +#include + +#include "cg5900a.h" +#include "cglib03.h" + +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////// +// TProrata_set +/////////////////////////////////////////////////////////// + +static int _year = 0; +static long _attiv = 0; +static TAssoc_array _causali; + +static bool prorata_filter(const TRelation* rel) +{ + const TRectype& mov = rel->curr(LF_MOV); + + if (mov.get_char(MOV_TIPO) != 'F') // Solo movimenti fornitori + return false; + + if (mov.get_char(MOV_PROVVIS) > ' ') // Solo movimenti definitivi + return false; + + if (_year > 0) + { + const int anno = mov.get_int(MOV_ANNOIVA); + if (anno != _year) + return false; + } + + const TBill zio(rel->curr()); + const int cric = zio.tipo_cr(); + if (cric >= 2 && cric <= 4) // Beni strumentali + return false; + + const TString& codcaus = mov.get(MOV_CODCAUS); + TCausale* caus = (TCausale*)_causali.objptr(codcaus); + if (caus == NULL) + { + caus = new TCausale(codcaus, _year); + _causali.add(codcaus, caus); + } + if (caus->iva() != iva_acquisti) + return false; + + if (caus->intra()) + return false; + + if (caus->tipodoc() == "AF") + return false; + + if (_year > 0 && _attiv > 0) + { + const TRegistro& reg = caus->reg(); + const long attiv = atol(reg.attivita()); + if (attiv != _attiv) + return false; + } + + return true; +} + +class TProrata_set : public TISAM_recordset +{ +protected: + virtual void set_custom_filter(TCursor& c) const; + virtual const TVariant& get_field(int logic, const char* fldname) const; + real perc_det() const; + +public: + TProrata_set(const char* sql) : TISAM_recordset(sql) { } +}; + +void TProrata_set::set_custom_filter(TCursor& c) const +{ + c.set_filterfunction(prorata_filter); +} + +real TProrata_set::perc_det() const +{ + real i = CENTO; + const TRectype& rmi = cursor()->curr(); + if (rmi.get(RMI_TIPODET).full()) + { + const TRectype& mov = cursor()->curr(LF_MOV); + real percind; get_tipodet_from_rmi(rmi, mov, percind); + i = CENTO-percind; + } + return i; +} + +const TVariant& TProrata_set::get_field(int logic, const char* fldname) const +{ + const TVariant& var = TISAM_recordset::get_field(logic, fldname); + if (logic == 0 || logic == LF_RMOVIVA) + { + if (xvt_str_compare_ignoring_case(fldname, RMI_IMPOSTA) == 0) + { + const real pd = perc_det(); + if (pd < CENTO) + { + real i = var.as_real() * pd / CENTO; + return get_tmp_var() = i.round(2); + } + } else + if (xvt_str_compare_ignoring_case(fldname, "PERCDET") == 0) + { + return get_tmp_var() = perc_det(); + } + } + return var; +} + +/////////////////////////////////////////////////////////// +// TProrata_rep +/////////////////////////////////////////////////////////// + +class TProrata_rep : public TReport +{ +protected: + virtual bool use_mask() { return false; } + virtual bool set_recordset(const TString& sql); + +public: + TProrata_rep(); +}; + +bool TProrata_rep::set_recordset(const TString& sql) +{ + TString query = sql; + + if (_year > 0 && query.find("FROM ") < 0) + { + const TDate dal( 1, 1, _year); + const TDate al(31, 12, _year); + TISAM_recordset mov("USE MOV KEY 2\nFROM DATAREG=#DAL\nTO DATAREG=#AL"); + mov.set_var("#DAL", dal); + mov.set_var("#AL", al); + + long danumreg = 0; + long anumreg = 0; + const TRectype& curr = mov.cursor()->curr(); + for (bool good = mov.move_first(); good; good = mov.move_next()) + { + const long numreg = curr.get_long(MOV_NUMREG); + if (danumreg == 0 || numreg < danumreg) + danumreg = numreg; + if (numreg > anumreg) + anumreg = numreg; + } + query << "\nFROM NUMREG=" << danumreg << "\nTO NUMREG=" << anumreg; + } + + TProrata_set* prs = new TProrata_set(query); + return TReport::set_recordset(prs); +} + +TProrata_rep::TProrata_rep() +{ + if (!load("cg5900a")) + cantread_box("cg5900a.rep"); +} + +/////////////////////////////////////////////////////////// +// TProrata_msk +/////////////////////////////////////////////////////////// + +class TProrata_msk : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + real calc_prorata(); + bool genera_mov(TFilename& ininame); + +public: + TProrata_msk() : TAutomask("cg5900a") {} +}; + +real TProrata_msk::calc_prorata() +{ + const long f = get_long(F_CODDITTA); + const int y = get_date(F_DATAFIN).year(); + const long a = get_long(F_CODATT); + TString16 codtab; + codtab.format("%05ld%4d%05ld1", f, y, a); + const real pr = cache().get("%PLA", codtab, "R8"); + set(F_PRORATA, pr); + _year = y; + + TToken_string key; key.format("%05ld", prefix().get_codditta()); + TRecord_array att(key, LF_ATTIV); + if (att.rows() > 1) + _attiv = a; + else + _attiv = 0; + return pr; +} + +bool TProrata_msk::genera_mov(TFilename& ininame) +{ + ininame.temp("cg5900", "ini"); + TConfig trans(ininame, "Transaction"); + trans.set("Action", "INSERT"); + + const TString& codcaus = get(F_CAUSALE); + const TCausale caus(codcaus, _year); + + trans.set_paragraph("23"); + trans.set(MOV_CODCAUS, codcaus); + trans.set(MOV_DATAREG, TDate(TODAY)); + TString descr; descr << "PRO-RATA " << _year; + trans.set(MOV_DESCR, descr); + + TProrata_rep rep; + rep.mask2report(*this); + TRecordset& recset = *rep.recordset(); + TProgind pi(recset.items(), TR("Calcolo pro-rata"), false, true); + + TAssoc_array mconti; + TString80 key; + + const real prorata = calc_prorata(); + + for (bool good = recset.move_first(); good; good = recset.move_next()) + { + pi.addstatus(1); + + const real impdet = recset.get(RMI_IMPOSTA).as_real(); // Imposta detraibile + if (!impdet.is_zero()) + { + const int gruppo = recset.get(RMI_GRUPPO).as_int(); + const int conto = recset.get(RMI_CONTO).as_int(); + const long sottoconto = recset.get(RMI_SOTTOCONTO).as_int(); + const TString& codiva = recset.get(RMI_CODIVA).as_string(); + key.format("%03d|%03d|%06ld|%s", gruppo, conto, sottoconto, (const char*)codiva); + real* pr = (real*)mconti.objptr(key); + if (pr == NULL) + { + pr = new real; + mconti.add(key, pr); + } + + real imp = impdet * prorata / CENTO; + imp.round(2); + *pr += imp; + } + } + + TString_array aconti; + FOR_EACH_ASSOC_OBJECT(mconti, o, k, i) + { + TToken_string* row = new TToken_string(k); + *row << '|' << *i; + aconti.add(row); + } + aconti.sort(); + int riga = 0; + real tot; + const char* seziva = caus.sezione(1) == 'A' ? "A" : "D"; + const char* sezimp = caus.sezione(1) == 'A' ? "D" : "A"; + + TString8 para; + + FOR_EACH_ARRAY_ROW(aconti, r, row) + { + const int gruppo = row->get_int(0); + const int conto = row->get_int(); + const long sottoconto = row->get_long(); + const TString4 codiva = row->get(); + const real imp = row->get(); + if (!imp.is_zero()) + { + para.format("%d,%d", LF_RMOV, ++riga); + trans.set_paragraph(para); + trans.set(RMV_SEZIONE, sezimp); + trans.set(RMV_IMPORTO, imp.string()); + trans.set(RMV_GRUPPO, gruppo); + trans.set(RMV_CONTO, conto); + trans.set(RMV_SOTTOCONTO, sottoconto); + descr.cut(0) << TR("Codice IVA") << ' ' << codiva; + trans.set(RMV_DESCR, descr); + tot += imp; + } + } + + TBill civa; caus.bill(1, civa); + para.format("%d,%d", LF_RMOV, ++riga); + trans.set_paragraph(para); + trans.set(RMV_SEZIONE, seziva); + trans.set(RMV_IMPORTO, tot.string()); + trans.set(RMV_GRUPPO, civa.gruppo()); + trans.set(RMV_CONTO, civa.conto()); + trans.set(RMV_SOTTOCONTO, civa.sottoconto()); + + return true; +} + +bool TProrata_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case DLG_PREVIEW: + case DLG_PRINT: + if (e == fe_button) + { + TProrata_rep rep; + if (rep.ok()) + { + rep.mask2report(*this); + if (o.dlg() == DLG_PRINT) + rep.print(); + else + rep.preview(); + } + return false; + } + break; + case F_CODATT: + if (e == fe_init) + { + TBrowse& b = *((TEdit_field&)o).browse(); + TCursor& c = *b.cursor(); + const TRecnotype i = c.items(); + if (i > 0) + { + c = 0L; + o.set(c.curr().get(ATT_CODATT)); + b.do_output(); + o.enable(i > 1); + } + else + o.disable(); + } + if (!o.empty() && (e == fe_init || e == fe_modify)) + calc_prorata(); + break; + case F_DATAINI: + if (e == fe_init) + { + const TDate oggi(TODAY); + o.set(TDate(1,1,oggi.year()-1)); + set(F_DATAFIN, TDate(31,12,oggi.year()-1), 0x3); + } + break; + case F_DATAFIN: + if (!o.empty() && (e == fe_init || e == fe_modify)) + calc_prorata(); + break; + case DLG_ELABORA: + if (e == fe_button) + { + TFilename ininame; + if (genera_mov(ininame)) + { + TString app; app << "cg2 -0 /i" << ininame; + TExternal_app a(app); + a.run(); + } + } + break; + default: + break; + } + return true; +} + +/////////////////////////////////////////////////////////// +// TProrata_app +/////////////////////////////////////////////////////////// + +class TProrata_app : public TSkeleton_application +{ +public: + virtual void main_loop(); +}; + +void TProrata_app::main_loop() +{ + TProrata_msk m; + m.run(); +} + +int cg5900(int argc, char* argv[]) +{ + TProrata_app a; + a.run(argc, argv, TR("Stampa pro-rata")); + return 0; +} diff --git a/cg/cg5900a.h b/cg/cg5900a.h new file mode 100644 index 000000000..545c8eeca --- /dev/null +++ b/cg/cg5900a.h @@ -0,0 +1,11 @@ +#define F_CODDITTA 101 +#define F_RAGSOC 102 + + +#define F_CODATT 105 +#define F_DESCATT 106 +#define F_PRORATA 107 +#define F_CAUSALE 108 + +#define F_DATAINI 111 +#define F_DATAFIN 112 diff --git a/cg/cg5900a.rep b/cg/cg5900a.rep new file mode 100644 index 000000000..8f8087a75 --- /dev/null +++ b/cg/cg5900a.rep @@ -0,0 +1,125 @@ + + + Stampa Prorata + +
+ + + + + + + + + + + + + +
+
+ + + +
+
+ GRUPPO+CONTO+SOTTOCONTO+CODIVA+TIPODET + MESSAGE RESET,F2.110|RESET,F2.111|RESET,F2.113 + + + + + + + +
+
+
+ + + + +
+
+
+ + + + + + + + + +
+
+ + + + + + + + MESSAGE COPY,F2.101 + + + MESSAGE COPY,F2.102 + + + MESSAGE COPY,F2.103 + + + + + + + MESSAGE ADD,F1.110 + + + MESSAGE ADD,F1.111 + + + #PRORATA + + + MESSAGE ADD,F1.113 + +
+ USE RMOVIVA SELECT (BETWEEN(MOV.DATAREG,#DATAINI,#DATAFIN))(STR(400@-E;R0E;0)) +BY GRUPPO CONTO SOTTOCONTO CODIVA TIPODET +JOIN MOV INTO NUMREG==NUMREG +JOIN %IVA ALIAS 400 INTO CODTAB==CODIVA + + \ No newline at end of file diff --git a/cg/cg5900a.uml b/cg/cg5900a.uml new file mode 100644 index 000000000..c45000b69 --- /dev/null +++ b/cg/cg5900a.uml @@ -0,0 +1,102 @@ +#include "cg5900a.h" + +PAGE "Stampa pro-rata" -1 -1 72 6 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 1 1 "Ditta " + FLAGS "FDGZ" + USE LF_NDITTE + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 19 1 "" + FLAGS "D" +END + +NUMBER F_CODATT 5 +BEGIN + PROMPT 1 2 "Attività " + USE LF_ATTIV + INPUT CODDITTA F_CODDITTA SELECT + INPUT CODATT F_CODATT + DISPLAY "Ditta" CODDITTA + DISPLAY "Attività" CODATT + DISPLAY "Descrizione@50" DESCR + OUTPUT F_CODATT CODATT + OUTPUT F_DESCATT DESCR + CHECKTYPE REQUIRED + FIELD #CODATT +END + +NUMBER F_PRORATA 3 +BEGIN + PROMPT 1 3 "Pro-rata " + FLAGS "D" + FIELD #PRORATA +END + +STRING F_CAUSALE 4 +BEGIN + PROMPT 31 3 "Causale per movimento contabile " + USE LF_CAUSALI SELECT (REG="")&&(TIPOMOV="")&&(MOVAP="") + INPUT CODCAUS F_CAUSALE + DISPLAY "Codice" CODCAUS + DISPLAY "Descrizione@50" DESCR + OUTPUT F_CAUSALE CODCAUS + CHEKCTYPE NORMAL + FLAGS "U" + ADD RUN cg0 -4 + MESSAGE EMPTY DISABLE,DLG_ELABORA + MESSAGE ENABLE,DLG_ELABORA +END + +STRING F_DESCATT 50 +BEGIN + PROMPT 19 2 "" + FLAGS "D" +END + +DATE F_DATAINI +BEGIN + PROMPT 1 4 "Data iniziale " + FIELD #DATAINI + CHECKTYPE REQUIRED +END + +DATE F_DATAFIN +BEGIN + PROMPT 31 4 "Data finale " + FIELD #DATAFIN + CHECKTYPE REQUIRED +END + +ENDPAGE + +TOOLBAR "Topbar" 0 0 0 2 + +BUTTON DLG_ELABORA 2 2 +BEGIN + PROMPT 1 1 "Prima Nota" + PICTURE TOOL_ELABORA +END + +BUTTON DLG_NULL 2 2 +BEGIN +END + +BUTTON DLG_PREVIEW 2 2 +BEGIN + PROMPT 2 1 "Anteprima" + PICTURE TOOL_PREVIEW +END + +#include + +ENDPAGE + +ENDMASK diff --git a/cg/cg6800.cpp b/cg/cg6800.cpp index cdf5b1d7f..a63431666 100755 --- a/cg/cg6800.cpp +++ b/cg/cg6800.cpp @@ -368,7 +368,7 @@ bool TVar_mov::video_IVA() { TMask* mask = new TMask("cg6800c"); - TString regiva = _rec_mov->get(MOV_REG); + const TString4 regiva = _rec_mov->get(MOV_REG); if (!setta_campi_maschera_iva(*mask)) { @@ -529,14 +529,14 @@ void TVar_mov::setta_campi_maschera(TMask& m) TDate datacomp(_rec_mov->get_date(MOV_DATACOMP)); int anno = _rec_mov->get_int (MOV_ANNOES); - TString numdoc = _rec_mov->get (MOV_NUMDOC); - TString regiva = _rec_mov->get (MOV_REG); + const TString16 numdoc = _rec_mov->get (MOV_NUMDOC); + TString4 regiva = _rec_mov->get (MOV_REG); regiva.trim(); long protiva = _rec_mov->get_long(MOV_PROTIVA); long nuprotiva = _rec_mov->get_long(MOV_UPROTIVA); - TString provvis = _rec_mov->get (MOV_PROVVIS); - TString codcaus = _rec_mov->get (MOV_CODCAUS); - TString codpag = _rec_mov->get (MOV_CODPAG); + TString4 provvis = _rec_mov->get (MOV_PROVVIS); + TString4 codcaus = _rec_mov->get (MOV_CODCAUS); + TString8 codpag = _rec_mov->get (MOV_CODPAG); codpag.trim(); m.set(F_NUMREG, _numreg); @@ -628,7 +628,7 @@ bool TVar_mov::setta_campi_maschera_iva(TMask& m) TDate datareg (_rec_mov->get_date(MOV_DATAREG)); TDate data74ter (_rec_mov->get_date(MOV_DATA74TER)); int meseliq = _rec_mov->get_int(MOV_MESELIQ); - TString regiva = _rec_mov->get (MOV_REG); + TString4 regiva = _rec_mov->get (MOV_REG); regiva.trim(); TString codcaus = _rec_mov->get (MOV_CODCAUS); long codcf = _rec_mov->get_long(MOV_CODCF); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index ff41f4115..76e8f84b4 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -486,7 +486,7 @@ bool TRegistro::read_att() chiave << prefix().get_codditta() << '|' << attivita(); _att = cache().get(LF_ATTIV, chiave); - // Ditta - Anno - Attivita' - Tipo Attivita' (fissata a 1) + // Ditta - Anno - Attività - Tipo Attività (fissata a 1) chiave.format("%05ld", prefix().get_codditta()); chiave << year(); // non fare << year() << attivita() chiave << attivita() << "1"; @@ -498,7 +498,7 @@ bool TRegistro::read_att() { chiave.format("%d", year()); _prorata.add(chiave, pla.get_real("R8")); - _att.put("TIPOATT", pla.get("S7")); // Aggiorna tipo attivita' + _att.put("TIPOATT", pla.get("S7")); // Aggiorna tipo attività } return !_att.empty(); @@ -519,7 +519,7 @@ const TString& TRegistro::tipo_attivita() real* TRegistro::read_prorata(int anno) const { - TString16 chiave; // Ditta - Anno - Attivita' - Tipo Attivita' (fissata a 1) + TString16 chiave; // Ditta - Anno - Attività - Tipo Attività (fissata a 1) chiave.format("%05ld", prefix().get_codditta()); chiave << anno << attivita() << "1"; diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index 53dfb49d1..910ba0b74 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -24,7 +24,7 @@ // // Cerca l'esercizio precedente di EseCorr -// Se EseCorr e' gia' il primo ritorna 0 +// Se EseCorr e' già il primo ritorna 0 // HIDDEN int EsePre(const int EseCorr) { @@ -64,7 +64,7 @@ TSaldi_list::TSaldi_list(int gr, int co, int aec, int aep_par) const TRectype& r = cf.curr(); key.format("%3d%3d%6ld", g, c, s); - // Se avevo chiesto anche l'es. prec. puo' darsi che l'abbia gia' trovato + // Se avevo chiesto anche l'es. prec. puo' darsi che l'abbia già trovato bool force = !aep_par; add(key, r, force); } @@ -136,7 +136,7 @@ real TSaldo::saldofin_esprec(int annoes, int g, int c, long s, bool saldo_chiusu } //richiamata nel bilancio a sez.contr per data limite -//in realta' calcola il saldo finale es.prec +//in realtà calcola il saldo finale es.prec real TSaldo::calcola_saldo_iniziale(int g,int c,long s,int indbil, bool provvis) { real saldoini; @@ -370,7 +370,7 @@ bool TSaldo::ultima_immissione_verifica(int annoes,int g,int c,long s,int indbil // e' true. A cosa serve ? Serve per includere nel calcolo del saldo all' ultima immissione // anche il saldo finale compilato nei movimenti di chiusura (se non venisse considerato i conti // risulterebbero aperti); siccome alcuni programmi (esempio il bilancio IV dir. CEE) non ne -// devono tenere conto, si e' data la possibilita' di usare la funzione passandogli il parametro a false. +// devono tenere conto, si e' data la possibilità di usare la funzione passandogli il parametro a false. // Modifica del 09-07-96 bool TSaldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil,int stp_prov,bool saldo_chiusura) { @@ -927,7 +927,7 @@ void TSaldo_agg::clear_saldi(int year) // // Scorro la tabella dei conti interna _tab_conti. // Per ogni conto cerco il record su saldi, se non c'e' lo creo. -// Se c'e' gia' lo aggiorno nel seguente modo: +// Se c'e' già lo aggiorno nel seguente modo: // GLOP /////////////////////////////////////////////////////////////////////////////// diff --git a/cg/cglib03.cpp b/cg/cglib03.cpp index 13c97b3ae..785d058a7 100755 --- a/cg/cglib03.cpp +++ b/cg/cglib03.cpp @@ -134,7 +134,7 @@ bool gestione_IVAxCassa(const TDate& data, long firm) } // Anticamente TIPODET conteneva in tipo di indetraibilita, -// ora invece trattasi di un codice di indetraibilita' +// ora invece trattasi di un codice di indetraibilità // associato ad un motivo ed una percentuale di indetraibilita' int get_tipodet_from_rmi(const TRectype& rmi, const TRectype& mov,real& percind, const bool is_liq) { diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 18b68184e..c0102219e 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -1586,9 +1586,9 @@ void TTransfer_file::write_tmp_movPN(TString& record) if (fname == MOV_REG) { if (real::is_natural(field)) - field.format("%03s", (const char*) field); + field.format("%03s", (const char*)field); else - field.format("%-3s", (const char*) field); + field.format("%-3s", (const char*)field); } //Il codice pagamento su AS400 e' un alfanumerico di due, mentre su PC e' un @@ -1608,7 +1608,7 @@ void TTransfer_file::write_tmp_movPN(TString& record) int nr = atoi(record.sub(8,10)); if (nr == 1) { - TString descr = record.sub(44,74); + const TString& descr = record.sub(44,74); dep->put(RMV_DESCR, descr); // Descrizione della prima riga riportata sulla testata } } @@ -1795,9 +1795,9 @@ void TTransfer_file::write_tmp_movIVA(const TString& record) if (trc.is_key(key)) { //ai fini del trasferimento (flag record gia trasferito e nuovo ultimo numero di registrazione). - TIsamtempfile* file = NULL; - TRectype* dep = NULL; - TFilename tmp_path; + TIsamtempfile* file = NULL; + TRectype* dep = NULL; + TFilename tmp_path; TString16 cfpi; int logicnum_p = 0; @@ -3423,8 +3423,6 @@ void TTransfer_file::scrivi_PN(long nrec) void TTransfer_file::scrivi_IVA(long nrec) { - TString buffer(sizeT); - _prog = new TProgind(nrec,TR("Trasferimento Movimenti IVA"),false, true); const TRic_recfield recf(_ttab->curr(), "S0", 0, sizeT); @@ -3433,10 +3431,11 @@ void TTransfer_file::scrivi_IVA(long nrec) _ttab->put("CODTAB", "U1"); for (int err = _ttab->read(_isgteq); err == NOERR; err = _ttab->next()) { - const TString& trec = _ttab->get("CODTAB").left(2); - if (trec != "U1") break; + const TString& trec = _ttab->get("CODTAB"); + if (!trec.starts_with("U1")) + break; - buffer = (const char*)recf; + const TFixed_string buffer((const char*)recf, sizeT); write_tmp_movIVA(buffer); } delete _prog; @@ -4034,10 +4033,10 @@ int TTransfer_file::annoes_PC(const TString& data) const return anno; } -void TTransfer_file::causale(TString& cau,TString& tipo,TString& descr) +void TTransfer_file::causale(const TString& cau, TString& tipo,TString& descr) const { +/* TLocalisamfile caus (LF_CAUSALI); - caus.setkey(1); caus.zero(); caus.put(CAU_CODCAUS, cau); @@ -4051,6 +4050,10 @@ void TTransfer_file::causale(TString& cau,TString& tipo,TString& descr) descr = ""; tipo = ""; } +*/ + const TRectype& caus = cache().get(LF_CAUSALI, cau); + descr = caus.get(CAU_DESCR); + tipo = caus.get(CAU_TIPODOC); } int TTransfer_file::registro(const TString& reg, int anno) const @@ -4181,7 +4184,7 @@ void TTransfer_file::write_testata_movimenti(TString& record) if (fname == MOV_REG) { - const int tipo = registro (field,annoiva); + const int tipo = registro(field, annoiva); if (tipo == 1 || tipo == 2) _depmov->put(MOV_TIPO, tipo == 1 ? 'C' : 'F'); } diff --git a/cg/cglib04.h b/cg/cglib04.h index f6d1bde23..f624fd8e3 100755 --- a/cg/cglib04.h +++ b/cg/cglib04.h @@ -247,7 +247,7 @@ private: void write_pagsca(const TString& record); int annoes_PC(const TString& data) const; - void causale(TString& cau,TString& tipo,TString& descr); + void causale(const TString& cau,TString& tipo,TString& descr) const; int registro(const TString& reg,int anno) const; public: diff --git a/cg/cgmenu.men b/cg/cgmenu.men index 1a37771f1..1406c7ceb 100755 --- a/cg/cgmenu.men +++ b/cg/cgmenu.men @@ -95,7 +95,7 @@ Item_05 = "Ricalcolo saldi", "cg4 -0", "F" Item_06 = "IVA", [CGMENU_010] Item_07 = "Stampe di contabilità", [CGMENU_023] Item_08 = "Saldaconto", -Item_09 = "Tracciabilita' CUP-CIG", +Item_09 = "Tracciabilità CUP-CIG", [CGMENU_010] Caption = "IVA" @@ -107,12 +107,13 @@ Item_02 = "Liquidazione", "cg4 -2", "F" Item_03 = "Visualizzazione liquidazione", "cg5 -5", "F" Item_04 = "Riepilogo progressivi", "cg0 -3", "F" Item_05 = "Stampa registri", "cg4 -3", "F" -Item_06 = "Liste fatture", [CGMENU_026] -Item_07 = "Gestione acconti IVA", [CGMENU_027] -Item_08 = "Gestione versamenti IVA", [CGMENU_022] -Item_09 = "Operazioni annuali", [CGMENU_029] -Item_10 = "IVA per cassa / differita", -Item_11 = "Gestione autotrasportatori", "cg4 -9", "F" +Item_06 = "Stampa pro-rata", "cg5 -9", "F" +Item_07 = "Liste fatture", [CGMENU_026] +Item_08 = "Gestione acconti IVA", [CGMENU_027] +Item_09 = "Gestione versamenti IVA", [CGMENU_022] +Item_10 = "Operazioni annuali", [CGMENU_029] +Item_11 = "IVA per cassa / differita", +Item_12 = "Gestione autotrasportatori", "cg4 -9", "F" [CGMENU_011] Caption = "Tabelle ministeriali" @@ -189,8 +190,8 @@ Module = 0 Flags = "" Item_01 = "Tabella studio per invio", "cg6 -4 %ins", "F" Item_02 = "Tabella ditta per invio", "cg6 -4 %ind", "F" -Item_03 = "Invio contabilita' a sistema", "cg6 -8 S", "F" -Item_04 = "Invio contabilita' a PC", "cg6 -8 P", "F" +Item_03 = "Invio contabilità a sistema", "cg6 -8 S", "F" +Item_04 = "Invio contabilità a PC", "cg6 -8 P", "F" Item_05 = "Ripristino movimenti da inviare", "cg6 -8 R", "F" Item_06 = "Eliminazione file invio", "cg6 -8 C", "FP" @@ -220,7 +221,7 @@ Flags = "" Item_01 = "Apertura nuovo esercizio", "cg4 -4 C", "F" Item_02 = "Apertura nuovo esercizio IVA", "cg4 -4 I", "F" Item_03 = "Chiusura/Apertura conti", "cg4 -5", "F" -Item_04 = "Chiusura/Apertura conti Contabilita' sep.", "np0 -1", "F" +Item_04 = "Chiusura/Apertura conti Contabilità sep.", "np0 -1", "F" [CGMENU_022] Caption = "Gestione versamenti IVA" diff --git a/cg/cgsalda3.cpp b/cg/cgsalda3.cpp index 06d9d9779..bf0f8bab0 100755 --- a/cg/cgsalda3.cpp +++ b/cg/cgsalda3.cpp @@ -104,6 +104,11 @@ bool TPartite_cache::add_game(int anno, const char* partita) const TPartita game(_bill, anno, partita); const bool chiusa = game.chiusa(true); can_add = (_flags == sct_closed_games) == chiusa; + if (!can_add) // Faccio un'eccezione per le mie partite + { + for (int i = game.last(); i > 0 && !can_add; i = game.pred(i)) + can_add = game.riga(i).get_long(PART_NREG) == _numreg; + } } if (can_add) add(key); diff --git a/cg/f26.dir b/cg/f26.dir index f4991528e..456230009 100755 --- a/cg/f26.dir +++ b/cg/f26.dir @@ -1,3 +1,3 @@ 26 0 -$caus|0|0|85|0|Causali contabili||| +$caus|0|0|86|0|Causali contabili||| diff --git a/cg/f26.trr b/cg/f26.trr index c1e4ceb0d..42cadb2bc 100755 --- a/cg/f26.trr +++ b/cg/f26.trr @@ -1,5 +1,5 @@ 26 -25 +26 CODCAUS|1|3|0|Codice causale DESCR|1|50|0|Descrizione causale TIPODOC|1|2|0|Tipo documento @@ -12,14 +12,15 @@ DATADOC|8|1|0|Data documento NUMDOC|8|1|0|Numero documento AUTOFATT|8|1|0|Autofattura art. ?? MOVSEZ|8|1|0|Movimento sezionale ?? -TIPOMOV|2|1|0|Tipo movimento +TIPOMOV|2|1|0|Tipo movimento saldaconto RITFATT|8|1|0| COLLCESP|1|1|0|Collegamnto ai cespiti M770|1|1|0|Collegamento al 770 CODCAUSIM|1|3|0|Codice causale incasso immediato SOSPESO|8|1|0|Causale sospesa VALINTRA|8|1|0|Gestione valuta intra-comunitaria -MOVIND|1|1|0|Causale per contabilita' industriale +MOVIND|1|1|0|Causale per contabilità analitica +MOVCGIND|8|1|0|Causale per contabilità industriale SOLOIVA|8|1|0|Movimento di sola IVA PROVV|1|1|0|Tipo movimento (" " Normale, "P" Provvisorio cancellabile, "C" Provvisorio da cepiti) REGSPIVA|2|2|0|Regimi speciali IVA