From a6ab3a26776152462650f7bad8af16a55f72bfc8 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 Oct 2012 08:35:30 +0000 Subject: [PATCH] Corretto allineamento tra ditta 770 e ditta contabile git-svn-id: svn://10.65.10.50/branches/R_10_00@22743 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- m770/770100.cpp | 130 ++++++++++++++++++++--------------------------- m770/770100a.h | 2 + m770/770100a.uml | 66 ++++++++++++++++++++---- m770/770102.h | 4 +- m770/770200.cpp | 15 +++--- m770/776100.cpp | 43 ++++++---------- m770/77lib01.cpp | 110 ++++++++++++++++----------------------- m770/77stq.cpp | 19 ++----- 8 files changed, 185 insertions(+), 204 deletions(-) diff --git a/m770/770100.cpp b/m770/770100.cpp index b817cbfc7..1a7d6eba8 100755 --- a/m770/770100.cpp +++ b/m770/770100.cpp @@ -8,6 +8,8 @@ #include "rpag.h" #include "perc.h" #include "../cg/cgsaldac.h" + +#include #include #include #include @@ -49,9 +51,6 @@ const char* ITEMS_LA[] = { "A|A", "B|B", "C|C", "D|D", "E|E", "F|F", "G|G", "H|H", "I|I", "L|L", "M|M", "N|N", "P|P", "Q|Q", "R|R", "S|S", "T|T", "U|U", "V|V", "W|W", "Z|Z", NULL }; - -HIDDEN TString80 __tmp; - TSchedaPercipienti::TSchedaPercipienti(): _rel(NULL), _flag_cg(false) { _from_modify = false; @@ -151,7 +150,7 @@ TMask* TSchedaPercipienti::load_mask(int n) //////////////////////////////////////////////////////////////////////// // Handler versamenti //////////////////////////////////////////////////////////////////////// - TSheet_field& vers = (TSheet_field&) m->field(F_VERSAMENTI); + TSheet_field& vers = m->sfield(F_VERSAMENTI); vers.set_notify(vers_notify); vers.sheet_mask().set_handler(F_VERS_1015, vers1015_handler); vers.sheet_mask().set_handler(DLG_SELPAG, pag_select); @@ -174,8 +173,8 @@ bool TSchedaPercipienti::setta_nprog(TMask& m, const bool variazione, const char { long nprog = 0L; const char tipoa = m.get(F_TIPOA)[0]; - TString8 codanagr(codanag ? codanag : m.get(F_CODANAGR)); - const long codditta = app().tipo_coll()==nessuno ? get_firm_770() : app().get_firm(); + const TString8 codanagr(codanag && *codanag ? codanag : m.get(F_CODANAGR)); + const long codditta = get_firm_770(); // Scrivi nprog solo se il percipiente ESISTE sull'arkivio if (!app().esiste_perc(m, codanagr)) @@ -189,7 +188,7 @@ bool TSchedaPercipienti::setta_nprog(TMask& m, const bool variazione, const char if (numreg > 0L) { scperc.setkey(3); - scperc.put(SPR_CODDITTA, prefix().get_codditta()); + scperc.put(SPR_CODDITTA, codditta); scperc.put(SPR_NUMREG, numreg); if (scperc.read(_isgteq) == NOERR && scperc.get_long(SPR_NUMREG) == numreg) @@ -234,16 +233,10 @@ bool TSchedaPercipienti::setta_nprog(TMask& m, const bool variazione, const char bool TSchedaPercipienti::codditta_handler(TMask_field& f, KEY k) { - if (k == K_TAB && !(f.mask().is_running()) ) + if (k == K_TAB && !f.mask().is_running()) { - TString16 codditta; - // Se chiamata dalla contabilita' prendo ditta con get_firm - if (app().tipo_coll() == nessuno) - codditta << get_firm_770(); - else - codditta << app().get_firm(); - - if (codditta != "0") + const long codditta = get_firm_770(); + if (codditta > 0) { f.set(codditta); f.check(); @@ -259,7 +252,7 @@ bool TSchedaPercipienti::codanagr_handler(TMask_field& f, KEY k) TMask& m = f.mask(); const bool variazione = app().coll_variazione(); TString8 codanagr(f.get()); - if (codanagr.not_empty()) + if (codanagr.full()) { if (!app().esiste_perc(m, codanagr)) return f.warning_box("Percipiente non valido"); @@ -267,9 +260,9 @@ bool TSchedaPercipienti::codanagr_handler(TMask_field& f, KEY k) } // faccio a mano decodifica del percipiente // perchč l'automatismo non funziona - long tmp_codanagr = atol(codanagr); - TString4 tmp_tipoa = m.get(F_TIPOA); - TString80 tmp_ragsoc = app().get_ragsoc(tmp_tipoa, tmp_codanagr); + const long tmp_codanagr = atol(codanagr); + const TString4 tmp_tipoa = m.get(F_TIPOA); + const TString& tmp_ragsoc = app().get_ragsoc(tmp_tipoa, tmp_codanagr); m.set(F_RAGSOCPER, tmp_ragsoc); m.set(F_RAGSOCCOM, tmp_ragsoc); } @@ -520,9 +513,8 @@ void TSchedaPercipienti::agg_pagamenti(const TRectype & sch) bool schede(const TRelation& rel, void* pJolly) { - const TRectype & sch = rel.lfile().curr(); - TSchedaPercipienti * schper = (TSchedaPercipienti *) pJolly; - + const TRectype& sch = rel.curr(); + TSchedaPercipienti* schper = (TSchedaPercipienti *) pJolly; schper->agg_pagamenti(sch); return true; } @@ -532,36 +524,29 @@ bool TSchedaPercipienti::aggpag_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TLocalisamfile fsch(LF_SCPERC); - TRectype from(fsch.curr()); - TLocalisamfile mov(LF_MOV); - - from.put("CODDITTA", prefix().get_codditta()); - - TRectype to(from); - TCursor c(new TRelation(LF_SCPERC), "", 1, &from, &to); - - c.scan(schede, &app(), "Aggiornamento schede"); - + TRectype from(LF_SCPERC); + from.put("CODDITTA", get_firm_770()); + TRelation rel(LF_SCPERC); + TCursor c(&rel, "", 1, &from, &from); + c.scan(schede, &app(), TR("Aggiornamento schede")); } return true; } -bool TSchedaPercipienti::esiste_perc(TMask& m, const char* codanag) +bool TSchedaPercipienti::esiste_perc(const TMask& m, const char* codanag) { - const char tipoa = m.get(F_TIPOA)[0]; - TString16 codanagr(codanag ? codanag : m.get(F_CODANAGR)); + const char tipoa = m.get(F_TIPOA)[0]; + const TString8 codanagr(codanag && *codanag ? codanag : m.get(F_CODANAGR)); // Controllo che l'anagrafica esista - TLocalisamfile anag(LF_ANAG); - anag.zero(); - anag.put("TIPOA", tipoa); - anag.put("CODANAGR", codanagr); - const bool esiste_anagr = anag.read() == NOERR; + TString8 key; key.format("%c|%ld", tipoa, atol(codanagr)); + const TRectype& anag = cache().get(LF_ANAG, key); + const bool esiste_anagr = !anag.empty(); // memorizzo flag soggetto non residente nel dato membro usato // nei controlli if (esiste_anagr) - _soggnres = anag.get_bool("SOGGNRES"); + _soggnres = anag.get_bool(ANA_SOGGNRES); return esiste_anagr; } @@ -585,7 +570,7 @@ bool TSchedaPercipienti::nprog_handler(TMask_field& f, KEY key) { app()._flag_cg = FALSE; // avoid recursion if (nprog==0 || !app().esiste_perc(f.mask())) - return FALSE; + return false; } return TRUE; } @@ -635,17 +620,21 @@ bool TSchedaPercipienti::user_create() if ( !_coll.read(msg->body()) ) { NFCHECK("Errore nei parametri passati"); - return FALSE; + return false; } - const long ditta_cg = get_firm(); - if (!exist_dichiar_770(ditta_cg)) - if (yesno_box(FR("Creare la dichiarazione per la ditta %ld"), ditta_cg)) - if (!enter_dichiar_770(ditta_cg)) + const long ditta = get_firm_770(); + if (!exist_dichiar_770(ditta)) + { + if (yesno_box(FR("Creare la dichiarazione per la ditta %ld"), ditta)) + { + if (!enter_dichiar_770(ditta)) { NFCHECK("Creazione dichiarazione fallita!"); - return FALSE; + return false; } + } + } } load_mask(0); @@ -699,17 +688,10 @@ bool TSchedaPercipienti::coll_variazione() const tipo_coll() == pagamento_piu_perc; } -TString80 TSchedaPercipienti::get_ragsoc(const char* tipoa, const long codanagr) +const TString& TSchedaPercipienti::get_ragsoc(const char* tipoa, const long codanagr) const { - TLocalisamfile anag(LF_ANAG); - anag.zero(); - anag.setkey(1); - anag.put("TIPOA", tipoa); - anag.put("CODANAGR", codanagr); - const int rc = anag.read(); - if (rc != NOERR) - anag.zero(); - return anag.get("RAGSOC"); + TString8 key; key.format("%c|%ld", *tipoa, codanagr); + return cache().get(LF_ANAG, key, ANA_RAGSOC); } void TSchedaPercipienti::init_modify_mode(TMask& m) @@ -1325,10 +1307,8 @@ void TSchedaPercipienti::mask2rel(const TMask& m) TMask& TSchedaPercipienti::TheMask() const { - if (_msk[1] == NULL) - error_box("Maschera di inserimento/modifica non ancora istanziata!"); - - return *(_msk[1]); + CHECK(_msk[1] != NULL, "Maschera di inserimento/modifica non ancora istanziata!"); + return *_msk[1]; } TSheet_field& TSchedaPercipienti::pag_sheet_enabled(TMask& m, bool force_enable) const @@ -1336,10 +1316,10 @@ TSheet_field& TSchedaPercipienti::pag_sheet_enabled(TMask& m, bool force_enable) TSheet_field* s = NULL; // istanza reference sheet a disposizione - TSheet_field& s_C = (TSheet_field&)m.field(F_PAGAMENTI_C); - TSheet_field& s_E = (TSheet_field&)m.field(F_PAGAMENTI_C); - TSheet_field& s_F = (TSheet_field&)m.field(F_PAGAMENTI_D); - TSheet_field& s_G = (TSheet_field&)m.field(F_PAGAMENTI_D); + TSheet_field& s_C = m.sfield(F_PAGAMENTI_C); + TSheet_field& s_E = m.sfield(F_PAGAMENTI_C); + TSheet_field& s_F = m.sfield(F_PAGAMENTI_D); + TSheet_field& s_G = m.sfield(F_PAGAMENTI_D); // forza la disabilitazione di tutti se richiesta // l'abilitazionein base al quadro @@ -2116,13 +2096,13 @@ Pag_struct& TSchedaPercipienti::calcola_riga_pag(Pag_struct& s, clear_struct(c); // calcolo CPA - c.impcpa = (s.compenso * h_PercCassaPrev) / (100.00 + h_PercCassaPrev); + c.impcpa = (s.compenso * h_PercCassaPrev) / (CENTO + h_PercCassaPrev); c.impcpa.round(fdec); if (s.impcpa == ZERO || force) s.impcpa = c.impcpa; // calcolo imponibile - c.imponibile = ((s.compenso - s.impcpa) * h_PercAssImp) / 100.00; + c.imponibile = ((s.compenso - s.impcpa) * h_PercAssImp) / CENTO; c.imponibile.round(fdec); if (s.imponibile == ZERO || force) s.imponibile = c.imponibile; @@ -2132,7 +2112,7 @@ Pag_struct& TSchedaPercipienti::calcola_riga_pag(Pag_struct& s, s.perc = h_PercRitenuta; // calcolo ritenuta lorda - c.ritlorda = (s.imponibile * s.perc) / 100.00; + c.ritlorda = (s.imponibile * s.perc) / CENTO; c.ritlorda.round(fdec); s.ritlorda = c.ritlorda; @@ -2152,16 +2132,16 @@ Pag_struct& TSchedaPercipienti::calcola_riga_pag(Pag_struct& s, s.alqimp10 = h_PercAssImpInps; // calcolo contributo Inps complessivo - c.ctssncomp = (((s.compenso * s.alqimp10) / 100.00) * h_PercInps) / 100.00; + c.ctssncomp = (((s.compenso * s.alqimp10) / CENTO) * h_PercInps) / CENTO; c.ctssncomp.round(fdec); if (s.ctssncomp == ZERO || force) s.ctssncomp = c.ctssncomp; // calcolo contributo Inps del percipiente if (h_PercCommitInps <= ZERO) - c.ctssnperc = s.ctssncomp - ((s.ctssncomp * 2) / 3); + c.ctssnperc = s.ctssncomp - (s.ctssncomp * 2.0 / 3.0); else - c.ctssnperc = s.ctssncomp - ((s.ctssncomp * h_PercCommitInps) / CENTO); + c.ctssnperc = s.ctssncomp - (s.ctssncomp * h_PercCommitInps / CENTO); c.ctssnperc.round(fdec); if (s.ctssnperc == ZERO || force) s.ctssnperc = c.ctssnperc; @@ -2171,7 +2151,7 @@ Pag_struct& TSchedaPercipienti::calcola_riga_pag(Pag_struct& s, s.utpagati = s.imponibile; // calcolo ritenute utili pagati - c.ritutpag = (s.utpagati * s.perc) / 100.00; + c.ritutpag = s.utpagati * s.perc / CENTO; c.ritutpag.round(fdec); if (s.ritutpag == ZERO || force) s.ritutpag = c.ritutpag; @@ -2327,6 +2307,6 @@ void TSchedaPercipienti::build_causqua_items(TMask& m, const TString& quadro) co int SchedaPerc (int argc, char* argv[]) { TSchedaPercipienti a; - a.run(argc, argv, "Scheda Percipienti"); + a.run(argc, argv, TR("Scheda Percipienti")); return 0; } diff --git a/m770/770100a.h b/m770/770100a.h index 1bb648ff8..1a901e21c 100755 --- a/m770/770100a.h +++ b/m770/770100a.h @@ -19,6 +19,8 @@ #define F_RAGSOCCOM 208 #define F_RAGSOCPER 209 #define F_AGGPAG 210 +#define F_COFI 211 +#define F_COFICOM 212 // m70100b #define F_RAGSOC2 300 diff --git a/m770/770100a.uml b/m770/770100a.uml index 8723d22ad..c04c2cd15 100755 --- a/m770/770100a.uml +++ b/m770/770100a.uml @@ -15,7 +15,7 @@ END NUMBER F_CODDITTA 5 BEGIN PROMPT 3 1 "Ditta " - FLAGS "DFGP" + FLAGS "DGP" KEY 1 CHECKTYPE REQUIRED USE LF_NDITTE KEY 1 @@ -36,14 +36,14 @@ BEGIN FLAGS "DRP" END -TEXT DLG_NULL +GROUPBOX DLG_NULL 78 4 BEGIN PROMPT 1 7 "@bDati percipiente" END LIST F_TIPOA 1 9 BEGIN - PROMPT 1 8 "" + PROMPT 2 8 "" ITEM "F|Fisica" ITEM "G|Giuridica" KEY 1 @@ -61,7 +61,7 @@ END NUMBER F_CODANAGRPERC 5 BEGIN - PROMPT 15 8 "" + PROMPT 16 8 "" USE LF_PERC JOIN LF_ANAG INTO TIPOA=TIPOA CODANAGR=CODANAGR INPUT CODDITTA F_CODDITTA SELECT @@ -70,8 +70,11 @@ BEGIN DISPLAY "Tipo " TIPOA DISPLAY "Codice " CODANAGR DISPLAY "Denominazione@50" LF_ANAG->RAGSOC + DISPLAY "Codice Fiscale" LF_ANAG->COFI + DISPLAY "Ditta" CODDITTA OUTPUT F_CODANAGRPERC CODANAGR OUTPUT F_RAGSOCPER LF_ANAG->RAGSOC + OUTPUT F_COFI LF_ANAG->COFI MESSAGE COPY, F_CODANAGR ADD RUN 775 -0 GROUP 2 @@ -79,16 +82,20 @@ END NUMBER F_CODANAGRCOM 5 BEGIN - PROMPT 15 8 "" - USE LF_ANAG + PROMPT 16 8 "" + USE LF_ANAG SELECT LF_PERC->CODDITTA!=#F_CODDITTA + JOIN LF_PERC INTO CODDITTA=#F_CODDITTA TIPOA=TIPOA CODANAGR==CODANAGR INPUT TIPOA F_TIPOA SELECT INPUT CODANAGR F_CODANAGRCOM DISPLAY "Tipo" TIPOA DISPLAY "Codice" CODANAGR DISPLAY "Denominazione@50" RAGSOC + DISPLAY "Codice Fiscale" COFI + DISPLAY "Ditta" LF_PERC->CODDITTA OUTPUT F_TIPOA TIPOA OUTPUT F_CODANAGRCOM CODANAGR OUTPUT F_RAGSOCCOM RAGSOC + OUTPUT F_COFICOM COFI MESSAGE COPY, F_CODANAGR ADD RUN BA4 -1 FLAGS "H" @@ -98,24 +105,26 @@ END STRING F_RAGSOCCOM 50 BEGIN PROMPT 25 8 "" - USE LF_ANAG KEY 2 + USE LF_ANAG KEY 2 SELECT LF_PERC->CODDITTA!=#F_CODDITTA JOIN LF_PERC INTO CODDITTA=#F_CODDITTA TIPOA=TIPOA CODANAGR==CODANAGR INPUT TIPOA F_TIPOA SELECT INPUT RAGSOC F_RAGSOCCOM DISPLAY "Denominazione@50" RAGSOC DISPLAY "Tipo" TIPOA DISPLAY "Codice" CODANAGR - DISPLAY "Percipiente" LF_PERC->CODANAGR + DISPLAY "Codice Fiscale" COFI + DISPLAY "Ditta" LF_PERC->CODDITTA COPY OUTPUT F_CODANAGRCOM ADD RUN BA4 -1 MESSAGE COPY, F_RAGSOCPER GROUP 1 + FLAGS "H" END STRING F_RAGSOCPER 50 BEGIN PROMPT 25 8 "" - USE LF_ANAG KEY 2 SELECT LF_PERC->CODANAGR!="" + USE LF_ANAG KEY 2 SELECT LF_PERC->CODDITTA==#F_CODDITTA JOIN LF_PERC INTO CODDITTA=#F_CODDITTA TIPOA=TIPOA CODANAGR==CODANAGR INPUT TIPOA F_TIPOA SELECT INPUT RAGSOC F_RAGSOCPER @@ -125,9 +134,46 @@ BEGIN GROUP 2 END +STRING F_COFI 16 +BEGIN + PROMPT 2 9 "Codice Fiscale" + USE LF_ANAG KEY 3 SELECT LF_PERC->CODDITTA==#F_CODDITTA + JOIN LF_PERC INTO CODDITTA=#F_CODDITTA TIPOA=TIPOA CODANAGR==CODANAGR + INPUT TIPOA F_TIPOA SELECT + INPUT COFI F_COFI + DISPLAY "Tipo" TIPOA + DISPLAY "Codice Fiscale" COFI + DISPLAY "Codice" CODANAGR + DISPLAY "Denominazione@50" RAGSOC + DISPLAY "Ditta" LF_PERC->CODDITTA + OUTPUT F_COFI COFI + OUTPUT F_CODANAGRCOM CODANAGR + OUTPUT F_RAGSOCCOM RAGSOC + OUTPUT F_CODANAGR CODANAGR + ADD RUN BA4 -1 + GROUP 2 +END + +STRING F_COFICOM 16 +BEGIN + PROMPT 2 9 "Codice Fiscale" + USE LF_ANAG KEY 3 SELECT LF_PERC->CODDITTA!=#F_CODDITTA + JOIN LF_PERC INTO CODDITTA=#F_CODDITTA TIPOA=TIPOA CODANAGR==CODANAGR + INPUT TIPOA F_TIPOA SELECT + INPUT COFI F_COFICOM + COPY DISPLAY F_COFI + OUTPUT F_COFI COFICOM + OUTPUT F_CODANAGRCOM CODANAGR + OUTPUT F_RAGSOCCOM RAGSOC + OUTPUT F_CODANAGR CODANAGR + ADD RUN BA4 -1 + GROUP 1 +END + + NUMBER F_NPROG 6 BEGIN - PROMPT 1 10 "@bScheda numero " + PROMPT 1 11 "@bScheda numero " CHECKTYPE REQUIRED KEY 1 FIELD LF_SCPERC->NPROG diff --git a/m770/770102.h b/m770/770102.h index 45bf6d10e..47dd5bf39 100755 --- a/m770/770102.h +++ b/m770/770102.h @@ -65,7 +65,7 @@ class TSchedaPercipienti : public TRelation_application real _tot_vers, _tot_rit; private: - TString80 get_ragsoc(const char* tipoa, const long codanagr); + const TString& get_ragsoc(const char* tipoa, const long codanagr) const; static void work_tipoluogo(TMask_field& f); // controlla che il versamento abbia collegato almeno un pagamento @@ -206,7 +206,7 @@ class TSchedaPercipienti : public TRelation_application bool coll_variazione() const; bool coll_datanum() const { return _coll._datadoc.not_empty() && _coll._numdoc.not_empty(); } long coll_numreg() const { return _coll._numreg; } - bool esiste_perc(TMask& m, const char* coda=NULL); + bool esiste_perc(const TMask& m, const char* coda=NULL); void agg_pagamenti(const TRectype & sch); TSheet_field& pags() const; diff --git a/m770/770200.cpp b/m770/770200.cpp index e71a3d763..1942afea1 100755 --- a/m770/770200.cpp +++ b/m770/770200.cpp @@ -68,12 +68,9 @@ class TVersa_rit : public TSkeleton_application TCursor* TVersa_rit::meik_curs(TRelation* rel) { - TString16 filt; - TCursor* cur; - const long codditta = get_firm(); - filt.format("CODDITTA=%ld", codditta); - cur = new TCursor(rel, filt); - return cur; + const long codditta = get_firm_770(); + TString16 filt; filt.format("CODDITTA=%ld", codditta); + return new TCursor(rel, filt); } bool TVersa_rit::create() @@ -466,7 +463,7 @@ bool TVersa_rit::do_all() return FALSE; const long selected = _sheet_perc->selected(); - const long codditta = get_firm(); + const long codditta = get_firm_770(); build_schede_sheet(codditta); @@ -529,7 +526,7 @@ bool TVersa_rit::do_all() void TVersa_rit::attach_pag_vers(TToken_string& r, real& disponibile, bool is_last) { - const long codditta = get_firm(); + const long codditta = get_firm_770(); const char tipoa = r.get_char(1); const long codanagr = r.get_long(2); const int nprog = r.get_int(3); @@ -726,7 +723,7 @@ void TVersa_rit::main_loop() int collega_vers_rit(int argc, char* argv[]) { TVersa_rit a; - a.run(argc, argv, "Versamento ritenute"); + a.run(argc, argv, TR("Versamento ritenute")); return 0; } diff --git a/m770/776100.cpp b/m770/776100.cpp index 5feef1d3b..e3550ca07 100755 --- a/m770/776100.cpp +++ b/m770/776100.cpp @@ -30,7 +30,7 @@ class TManutenzione_quadri : public TSkeleton_application TLocalisamfile* _base, *_basebis; int _anno_dic; bool _soci; - long _codditta, _coddic; + long _coddic; TString _qcomp_prev; protected: @@ -61,7 +61,6 @@ class TManutenzione_quadri : public TSkeleton_application public: TManutenzione_quadri (); - ~TManutenzione_quadri() {}; virtual bool firm_change_enabled() const; }; @@ -93,14 +92,11 @@ bool TManutenzione_quadri::filtra_ditte(const TRelation * r) void TManutenzione_quadri::on_config_change() { - TConfig conf(CONFIG_STUDIO); - _anno_dic = (int)conf.get_long(ANNO_SEL, NULL, -1, TDate(TODAY).year()); + _anno_dic = ini_get_int(CONFIG_STUDIO, "77", ANNO_SEL, TDate(TODAY).year()); } bool TManutenzione_quadri::firm_change_enabled() const -{ - return FALSE; -} +{ return false; } // Lancia la gestione soci passando la ditta bool TManutenzione_quadri::exec_soci(TMask_field& f, KEY k) @@ -109,7 +105,7 @@ bool TManutenzione_quadri::exec_soci(TMask_field& f, KEY k) { TString appname("ba4 -5"); TString body(16); - const long ditta = app()._codditta; + const long ditta = get_firm_770(); body << FLD_SC1_CODDITTA << "|"; body << FLD_SC1_CODDITTA << "="; body << ditta; @@ -128,14 +124,8 @@ bool TManutenzione_quadri::codditta_handler(TMask_field& f, KEY k) { if (k == K_TAB && !(f.mask().is_running()) ) { - TString16 codditta; - app()._codditta = get_firm_770(); - codditta << app()._codditta; - if (codditta != "0") - { - f.set(codditta); - f.check(); - } + f.set(get_firm_770()); + f.check(); } if (f.to_check(k)) @@ -147,7 +137,8 @@ bool TManutenzione_quadri::codditta_handler(TMask_field& f, KEY k) else set_firm_770(codditta); } - return TRUE; + + return true; } TMask* TManutenzione_quadri::load_mask(int n) @@ -348,13 +339,13 @@ void TManutenzione_quadri::init_menu(TMask& m) { m.set(F_ANNODIC, _anno_dic); - _codditta = _msk[0]->get_long(F_CODDITTA); + const long codditta = _msk[0]->get_long(F_CODDITTA); TString80 ragsoc(_msk[0]->get(F_RAGDITTA)); - m.set(F_CODDITTA, _codditta); + m.set(F_CODDITTA, codditta); m.set(F_RAGDITTA, ragsoc); // Se persona giuridica c'e' la voce "Amministratori" - _soci = tipo_persona(_codditta) == 'G'; + _soci = tipo_persona(codditta) == 'G'; m.enable(DLG_MANUTENZ_SOCI, _soci); m.set_handler(DLG_MANUTENZ_SOCI, exec_soci); @@ -368,7 +359,7 @@ void TManutenzione_quadri::init_menu(TMask& m) m.set_handler(DLG_STOPREC_STQD,show_menu); // Se non e' un dichiarante disabilita la corrispondente voce - m.enable(DLG_STOPREC_SD, sogg_dic(_codditta)); + m.enable(DLG_STOPREC_SD, sogg_dic(codditta)); // Evidenzia i quadri compilati o inibiti TString qcomp(NUM_QUADRI), qric(NUM_QUADRI); @@ -376,7 +367,7 @@ void TManutenzione_quadri::init_menu(TMask& m) // 1.5 _basebis->setkey(1); _basebis->zero(); - _basebis->put("CODDITTA", _codditta); + _basebis->put("CODDITTA", codditta); int rt = _basebis->read(); qcomp = _basebis->get("QCOMP"); qric = _basebis->get("QSUPPRIC"); @@ -394,7 +385,7 @@ bool TManutenzione_quadri::lock(const bool lok) base.setkey(1); base.zero(); - base.put("CODDITTA", _codditta); + base.put("CODDITTA", get_firm_770()); const int rt = base.read(_isequal, _testandlock); if (rt != NOERR) return error_box("Impossibile leggere i dati: errore %d", rt); @@ -512,15 +503,13 @@ bool TManutenzione_quadri::query_mask() load_mask(0); init_query_mask(*_msk[0]); _msk[0]->first_focus(DLG_OK); - KEY ch = _msk[0]->run(); - if (ch == K_ENTER) - _codditta = _msk[0]->get_long(F_CODDITTA); + const KEY ch = _msk[0]->run(); return ch == K_ENTER; } int MenuQuadri (int argc, char* argv[]) { TManutenzione_quadri a; - a.run(argc, argv, "Gestione percipienti"); + a.run(argc, argv, TR("Gestione percipienti")); return 0; } diff --git a/m770/77lib01.cpp b/m770/77lib01.cpp index a4e7d6892..881c88c3e 100755 --- a/m770/77lib01.cpp +++ b/m770/77lib01.cpp @@ -1,9 +1,12 @@ // 77lib01.cpp +#include #include #include +#include #include #include +#include #include "scperc.h" #include "perc.h" @@ -73,20 +76,12 @@ const char* cod_fis(const long codditta) anagr.put(ANA_CODANAGR,(long)codanagr); err = anagr.read(); if (err) return NULL; - __tmp = anagr.get(ANA_COFI); - return __tmp; + return anagr.get(ANA_COFI); } const char* get_desc_cau(const char* codcau) { - TTable ca7("%ca7"); - __tmp = ""; - ca7.zero(); - ca7.put("CODTAB", codcau); - const int rc = ca7.read(); - if (rc == NOERR) - __tmp = ca7.get("S0"); - return __tmp; + return cache().get("%CA7", codcau, "S0"); } @@ -94,32 +89,11 @@ const char* get_desc_cau(const char* codcau) // Round_770 // // Round adattata per 770 - 1.12.95 -// Arrotonda cosi': -// se importo > 500 importo -> 1000 -// se importo <= 500 importo -> 0 -// L'unica differenza con round(-3) e' il comportamento -// alle 500 lire. // real round_770(const real& importo) { - const int ndec = TCurrency::get_firm_dec(); - real imp; - if (ndec == 0) - { - imp = importo / 1000.00; - imp = imp + 0.499; - imp.trunc(); - imp *= 1000.00; - /* bel colpo, solo qualche logaritmo naturale in pił e poi sarebbe perfetto: bastava - imp = importo - 1.0; - imp.round(-3); - */ - } - else - { - imp = importo; - imp.round(0); - } + real imp = importo; + imp.round(); // Arrotonda all'Euro return imp; } @@ -147,7 +121,6 @@ int conta_tipiper(const long codit, TString& quadro, int* NumFisiche, int* NumNo file = LF_QUAGD; TLocalisamfile fl(file); - fl.zero(); fl.put("CODDITTA", (long) codit); TRectype dep(fl.curr()); for (fl.read(); !fl.eof(); fl.next()) @@ -171,18 +144,28 @@ int conta_tipiper(const long codit, TString& quadro, int* NumFisiche, int* NumNo // Ritorna l'anno di dichiarazione sui parametri di studio int anno_770() { - TConfig conf(CONFIG_STUDIO); - const int anno = (int)conf.get_long(ANNO_SEL, NULL, -1, TDate(TODAY).year()); + TConfig conf(CONFIG_STUDIO, "77"); + const int anno = conf.get_int(ANNO_SEL, NULL, -1, TDate(TODAY).year()); return anno; } long get_firm_770() { - if (!_codditta_770) + if (_codditta_770 <= 0) { - const char* section = "77"; - TConfig cnf(CONFIG_USER, section); - _codditta_770 = cnf.get_long(DITTA_770, section); + TConfig cnf(CONFIG_USER, "77"); + _codditta_770 = cnf.get_long(DITTA_770); + if (dongle().active(CGAUT)) + { + const long codditta_cg = prefix().get_codditta(); + if (codditta_cg != _codditta_770) + { + if (codditta_cg <= 0) + prefix().set_codditta(_codditta_770, true); + else + cnf.set(DITTA_770, _codditta_770 = codditta_cg); + } + } } return _codditta_770; @@ -190,11 +173,17 @@ long get_firm_770() void set_firm_770(const long codditta) { - if (_codditta_770 == 0 || codditta != _codditta_770) + CHECKD(codditta > 0, "Ditta non valida:", codditta); + if (_codditta_770 <= 0 || codditta != _codditta_770) { - const char* section = "77"; - TConfig cnf(CONFIG_USER, section); + TConfig cnf(CONFIG_USER, "77"); cnf.set(DITTA_770, codditta); + if (dongle().active(CGAUT)) + { + const long codditta_cg = prefix().get_codditta(); + if (codditta_cg != codditta) + prefix().set_codditta(codditta, true); + } } _codditta_770 = codditta; } @@ -202,15 +191,8 @@ void set_firm_770(const long codditta) // Cerca di stabilire se il titolare della ditta e' PF o PG char tipo_persona(long codditta) { - TLocalisamfile nditte(LF_NDITTE); - - nditte.zero(); - nditte.put("CODDITTA", (long)codditta); - - if (nditte.read() == NOERR) - return nditte.get_char("TIPOA"); - else - return NULL; + const char tipoa = cache().get(LF_NDITTE, codditta, NDT_TIPOA)[0]; + return tipoa >= 'F' ? tipoa : '\0'; } // Stabilisce se coddip esiste @@ -249,7 +231,7 @@ bool is_erede(const long codditta, const long coddip) // Se un qualunque codice erede e' stato compilato => e' un deceduto bool is_deceduto(const long codditta, const long coddip) { - TLocalisamfile dip (LF_DIPEND); + TLocalisamfile dip(LF_DIPEND); dip.zero(); dip.put(DIP_CODDITTA, codditta); dip.put(DIP_CODIP, coddip); @@ -259,12 +241,11 @@ bool is_deceduto(const long codditta, const long coddip) { TString campo("CODEREDE"); campo << i; - TString16 dep; - dep = dip.get(campo); - if (dep.not_empty()) - return TRUE; + TString16 dep = dip.get(campo); + if (dep.full()) + return true; } - return FALSE; + return false; } const int MAX_EREDI = 10; @@ -279,7 +260,7 @@ bool scrivi_erede(const long codditta, const long deceduto, const long coddip) dip.put(DIP_CODIP, (long)deceduto); esiste = dip.read(_isequal, _lock) == NOERR; - if (!esiste) return FALSE; + if (!esiste) return false; for (int i=0; i