From 0d2e2d4bca0ef6abeb93fb6ab45d0b8cf88febb9 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 10 Dec 2014 16:04:44 +0000 Subject: [PATCH] Migliorata gestione ammortamenti su parti eliminate git-svn-id: svn://10.65.10.50/branches/R_10_00@23019 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ce/ce0100.cpp | 59 ++++++++++++++++++++++++++++++-------------------- ce/ce1200.cpp | 33 ++++++++++++++-------------- ce/ce1201a.uml | 7 ++++-- ce/ce4.cpp | 14 +++++------- ce/ce4200.cpp | 3 +-- ce/ce4300.cpp | 2 +- ce/ce4400.cpp | 4 ++-- ce/cemenu.men | 3 +-- ce/cetbccc.uml | 6 ++--- 9 files changed, 69 insertions(+), 62 deletions(-) diff --git a/ce/ce0100.cpp b/ce/ce0100.cpp index 2c6be8fec..c1e5cdbe6 100755 --- a/ce/ce0100.cpp +++ b/ce/ce0100.cpp @@ -140,25 +140,22 @@ class TCCC_mask : public TAutomask public: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - TCCC_mask(); - virtual ~TCCC_mask() { } }; //costruttore: se la chiave ha l'analitica fa comparire i campi per cms/cdc/fase //se inoltre ha UsePdcc=false (ovvero usa pdc analitico puro) -> ci vogliono anche i conti! -TCCC_mask::TCCC_mask() - : TAutomask("cetbccc") +TCCC_mask::TCCC_mask() : TAutomask("cetbccc") { //parte nascondendo i campi analitici hide(-2); - - //controllo analitica su chiave - _has_ca = dongle().active(CAAUT); - + //inizializza i flag che servono un pò dappertutto //di base usa il pdcc TConfig& cfg = ca_config(); + + //controllo analitica su chiave e parametri + _has_ca = cfg.get_int("Authorizations") > 1; _use_pdcc = cfg.get_bool("UsePdcc"); //se la chiave ha CA -> campi cms/cdc/fase! @@ -171,7 +168,7 @@ TCCC_mask::TCCC_mask() { const int logicnum = LF_PCONANA; const int nfields = ca_create_fields(*this, 1, LF_PCONANA, 2, 1, F_PDA1_NOR, F_DES1_NOR, 0x0, "S3"); - ca_create_fields(*this, 1, LF_PCONANA, 2, 7, F_PDA1_ACC, F_DES1_ACC, 0x0, "S4"); + ca_create_fields(*this, 1, LF_PCONANA, 2, 7, F_PDA1_ACC, F_DES1_ACC, 0x0, "S4"); ca_create_fields(*this, 1, LF_PCONANA, 2, 13, F_PDA1_ANT, F_DES1_ANT, 0x0, "S5"); for (int i = 0; i < nfields; i++) @@ -346,17 +343,27 @@ bool TCCE_mask::is_leap(int year) const real TCCE_mask::calc_coeff(const TDate& ies, const TDate& fes) const { - const real tot_es = fes - ies + 1; - real max_es = 365; - const int im = ies.month(); - const int iy = ies.year(); - const int fm = fes.month(); - const int fy = fes.year(); - if ((im < 3 && (fm >= 3 || fy > iy) && is_leap(iy)) || - (fm >= 3 && (im < 3 || iy < fy) && is_leap(fy))) - max_es += 1.0; - real coeff = tot_es / max_es; - coeff.round(9); + const bool rip_by_day = get_int(F_TIPO_RIP) != 1; + real coeff = UNO; + if (rip_by_day) // ripartizione per giorno + { + const real tot_es = fes - ies + 1; + real max_es = 365; + const int im = ies.month(); + const int iy = ies.year(); + const int fm = fes.month(); + const int fy = fes.year(); + if ((im < 3 && (fm >= 3 || fy > iy) && is_leap(iy)) || + (fm >= 3 && (im < 3 || iy < fy) && is_leap(fy))) + max_es += 1.0; + coeff = tot_es / max_es; + } + else // ripartizione mensile + { + const int fm = fes.year()*12 + fes.month(); + const int sm = ies.year()*12 + ies.month(); + coeff = real(fm - sm + 1) / real(12); + } return coeff; } @@ -379,13 +386,17 @@ bool TCCE_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) a.run(); } break; - case F_DURATA: - if (e == fe_init && !field(F_CODESER).empty()) + case F_TIPO_RIP: + if (e == fe_modify || e == fe_init) { const TDate ies = get_date(F_DATAINI); const TDate fes = get_date(F_DATAFINE); - set(F_DURATA, fes-ies+1); - set(F_COEFF_DURATA, calc_coeff(ies, fes)); + if (ies.ok() && fes >= ies) + { + set(F_DURATA, fes-ies+1); + TReal_field& cd = (TReal_field&)efield(F_COEFF_DURATA); + cd.set(calc_coeff(ies, fes).string(0, cd.decimals())); + } } break; default: diff --git a/ce/ce1200.cpp b/ce/ce1200.cpp index 898b66903..dae797ef9 100755 --- a/ce/ce1200.cpp +++ b/ce/ce1200.cpp @@ -57,6 +57,8 @@ int TForce_mov_qmask::calcola_stato_attivita() const TRectype& curr_ccb = cache().get("CCB", str); if (curr_ccb.get_bool("B1")) // Bollato stampato _staat = 1; + else + _staat = 0; TDitta_cespiti& dc = ditta_cespiti(); dc.set_attivita(ese, gru, spe); @@ -67,13 +69,12 @@ int TForce_mov_qmask::calcola_stato_attivita() int TForce_mov_qmask::calcola_ammo_eliminate() { const int ese = get_int(F_ESERCIZIO); - TString4 str; str.format("%04d", ese); - const TRectype& curr_cce = cache().get("CCE", str); if (curr_cce.get_bool("B3")) //possibilitá ammortamenti su parti eliminate (si prosegue solo se TRUE) _ammoelim = 1; - + else + _ammoelim = 0; return _ammoelim; } @@ -117,7 +118,7 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j calcola_stato_attivita(); calcola_ammo_eliminate(); if (_ammoelim != 1) - return error_box(TR("Non previsti ammortamenti sulle parti eliminate")); + return error_box(FR("Non è previsto l'ammortamento sulle parti parti eliminate nell'esercizio %s"), (const char*)o.get()); } break; @@ -125,23 +126,21 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j if (e == fe_init || e == fe_modify) //seleziona il filtro da applicare alla maschera nel campo del movimento { const TString& ces = get(F_IDCESPITE); - const bool cesok = !real::is_null(ces); TString filter; - filter << "(IDRET=\"\")&&(ANSI(DTMOV)>=ANSI(#" << F_INIZIO_ES - << "))&&(ANSI(DTMOV)<=ANSI(#" << F_FINE_ES << "))"; - if (cesok) // se viene selezionato un particolare cespite al filtro si aggiunge il suo codice + filter << "(IDRET=\"\")&&(BETWEEN(DTMOV,#" << F_INIZIO_ES + << ",#" << F_FINE_ES << "))"; + if (ces.full()) // se viene selezionato un particolare cespite al filtro si aggiunge il suo codice filter << "&&(IDCESPITE==\"" << ces << "\")"; TEdit_field& m = efield(F_IDMOV); // setta il filtro della ricerca sulla maschera - m.browse()->set_filter(filter); - + m.browse()->set_filter(filter); } if (e == fe_close) { if (stato_attivita() == 1) warning_box(TR("E' stato stampato il bollato dell'anno:\nnon sono permesse forzature")); if (ammo_eliminate() == 0) - warning_box(TR("Non é previsto l'ammortamento sulle parti eliminate nell'esercizio selezionato")); + warning_box(TR("Non è previsto l'ammortamento sulle parti eliminate nell'esercizio selezionato")); } break; @@ -169,7 +168,7 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j const TRectype& categoria = ces.categoria(); bool non_ammortizzabile = categoria.get_bool("B0"); if (non_ammortizzabile) - return error_box(TR("Ammortamenti non effettuabili perché la categoria del cespite non é ammortizzabile")); + return error_box(TR("Ammortamenti non effettuabili perché la categoria del cespite non è ammortizzabile")); if (!curr_movce.empty()) { @@ -183,7 +182,7 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j const TDate dataini(get(F_INIZIO_ES)); const TDate datafine(get(F_FINE_ES)); if ( dtmov < dataini || dtmov > datafine) - return error_box(TR("Il movimento selezionato non é di competenza dell'esercizio selezionato")); + return error_box(TR("Il movimento selezionato non è di competenza dell'esercizio selezionato")); } key.format("%s|%s|1", (const char *) idcespite, (const char *) get(F_IDMOV)); @@ -209,8 +208,8 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j if (ammmv.empty()) return error_box(TR("Ammortamenti fiscali sui movimenti incoerenti per il movimento selezionato")); calc_res_mov(ces, curr_movce, ammmv); //calcolo del residuo fiscale in uscita maschera di selezione - if (_residuof==ZERO) - return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo fiscale\nda ammortizzare per le parti eliminate del cespite")); + if (_residuof.is_zero()) + warning_box(TR("Non esiste residuo fiscale\nda ammortizzare per le parti eliminate del cespite")); } key.format("%s|%s|2", (const char *) idcespite, (const char *) get(F_IDMOV)); @@ -220,8 +219,8 @@ bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long j if (ammmv.empty()) return error_box(TR("Ammortamenti civilistici sui movimenti incoerenti per il movimento selezionato")); calc_res_mov(ces, curr_movce, ammmv); //calcolo del residuo civilistico in uscita maschera di selezione - if (_residuoc==ZERO) - return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo civilistico\nda ammortizzare per le parti eliminate del cespite")); + if (_residuoc.is_zero()) + warning_box(TR("Non esiste residuo civilistico\nda ammortizzare per le parti eliminate del cespite")); } } diff --git a/ce/ce1201a.uml b/ce/ce1201a.uml index 76a200011..c28f31b73 100755 --- a/ce/ce1201a.uml +++ b/ce/ce1201a.uml @@ -47,6 +47,7 @@ BEGIN DISPLAY "Codice esercizio" CODTAB DISPLAY "Inizio esercizio" 104@->D0 DISPLAY "Fine esercizio" 104@->D1 + DISPLAY "Ammortamento\nparti vendute@12C" B3 OUTPUT F_ESERCIZIO CODTAB OUTPUT F_INIZIO_ES 104@->D0 OUTPUT F_FINE_ES 104@->D1 @@ -136,12 +137,14 @@ NUMBER F_IDMOV 11 BEGIN PROMPT 1 10 "Movimento " FLAGS "Z" - USE LF_MOVCE SELECT (IDRET="")&&(ANSI(DTMOV)>=ANSI(#F_INIZIO_ES))&&(ANSI(DTMOV)<=ANSI(#F_FINE_ES)) + USE LF_MOVCE SELECT (IDRET="")&&(BETWEEN(DTMOV,#F_INIZIO_ES,#F_FINE_ES)) JOIN LF_CESPI INTO IDCESPITE==IDCESPITE + JOIN %TMC INTO CODTAB==CODMOV INPUT IDMOV F_IDMOV DISPLAY "Movimento@11" IDMOV DISPLAY "Data mov.@10" DTMOV - DISPLAY "Cod. tipo mov." CODMOV + DISPLAY "Tipo\nmov.@4" CODMOV + DISPLAY "Ammesso\nAmmort.@7C" 4->B4 DISPLAY "Data doc.@10" DTDOC DISPLAY "Tipo doc." TPDOC DISPLAY "Numero doc." NDOC diff --git a/ce/ce4.cpp b/ce/ce4.cpp index 8e01bede5..85a95ff9f 100755 --- a/ce/ce4.cpp +++ b/ce/ce4.cpp @@ -7,16 +7,12 @@ int main(int argc,char** argv) const int r = (argc > 1) ? (argv[1][1]-'0') : 0; switch (r) { - case 1: - ce4200(argc,argv); break; //calcolo cespiti per commessa - case 2: - ce4300(argc,argv); break; //stampa proiezione ammortamenti cespiti - case 3: - ce4400(argc,argv); break; //contabilizzazione cespiti - case 4: - ce4500(argc,argv); break; //stampa cespiti in contabilità analitica + case 1: ce4200(argc,argv); break; //calcolo cespiti per commessa + case 2: ce4300(argc,argv); break; //stampa proiezione ammortamenti cespiti + case 3: ce4400(argc,argv); break; //contabilizzazione cespiti + case 4: ce4500(argc,argv); break; //stampa cespiti in contabilità analitica case 0: - default: ce4100(argc,argv) ; break; // ripartizione analitica cespiti + default: ce4100(argc,argv); break; // ripartizione analitica cespiti } return 0; } diff --git a/ce/ce4200.cpp b/ce/ce4200.cpp index 210837e35..8df0366e5 100755 --- a/ce/ce4200.cpp +++ b/ce/ce4200.cpp @@ -110,7 +110,7 @@ public: // real TCalc_cesp_cms::calc_perc_util_cesp(const TRectype& salcecms_rec, const TDate& dtinices, const TDate& dtfineces) { -//adeesso prende la percentuale di utilizzo del cespite nella commessa.. +//adesso prende la percentuale di utilizzo del cespite nella commessa.. real percutil = salcecms_rec.get_real(SALCECMS_PERCUTIL); //normalizza la percentuale... percutil = percutil / CENTO; @@ -130,7 +130,6 @@ real TCalc_cesp_cms::calc_perc_util_cesp(const TRectype& salcecms_rec, const TDa if (!dtfinecms.ok()) dtfinecms = cms.get_date(COMMESSE_DATAFINE); if (dtfinecms.ok() && (dtfinecms < dtfineces)) - dtfine = dtfinecms; TDate dtini = dtinices; diff --git a/ce/ce4300.cpp b/ce/ce4300.cpp index b21b3cf2a..522c424f5 100755 --- a/ce/ce4300.cpp +++ b/ce/ce4300.cpp @@ -229,7 +229,7 @@ void TStampa_proiez_ammo_rep::set_filter(const TStampa_proiez_ammo_mask& msk) const TString idcespite = rel_cespi.curr().get(CESPI_IDCESPITE); const int codcat = rel_cespi.curr().get_int(CESPI_CODCAT); - //NOVITA'! usa l'ggetto TCespite per completezza di calcoli + //NOVITA'! usa l'oggetto TCespite per completezza di calcoli TCespite cespite(idcespite); cespite.load_saldi(1, _anno); diff --git a/ce/ce4400.cpp b/ce/ce4400.cpp index 394a1ebc2..5495fb150 100755 --- a/ce/ce4400.cpp +++ b/ce/ce4400.cpp @@ -242,7 +242,7 @@ bool TSaldo_per_codice::use_pdcc() const static char _use_pdcc = ' '; if (_use_pdcc == ' ') { - TConfig cfg = ca_config(); + TConfig& cfg = ca_config(); _use_pdcc = cfg.get_bool("UsePdcc"); } return _use_pdcc != '\0'; @@ -478,7 +478,7 @@ int TSaldo_per_codice::compila_rmov_CG(const int tipo, const int riga_nor, TArra if (!ok) { TString msg; - msg.format(FR("Il codice cespite %s non e' un sottoconto valido"), (const char*)_idcespite); + msg.format(FR("Il codice cespite %s non è un sottoconto valido"), (const char*)_idcespite); log.log(2, msg); } } diff --git a/ce/cemenu.men b/ce/cemenu.men index 3e7580085..a500e53dc 100755 --- a/ce/cemenu.men +++ b/ce/cemenu.men @@ -123,8 +123,7 @@ Picture = Module = 11 Flags = "" Item_01 = "Cambio esercizio", "ce2 -1", "F" -Item_02 = "Riattribuzione percentuali", "", "" -Item_03 = "Rispristino stampa bollato", "ce2 -4", "F" +Item_02 = "Rispristino stampa bollato", "ce2 -4", "F" [CEMENU_013] Caption = "Cespiti per contabilità analitica" diff --git a/ce/cetbccc.uml b/ce/cetbccc.uml index 46f96e204..ae1e7b8be 100755 --- a/ce/cetbccc.uml +++ b/ce/cetbccc.uml @@ -515,17 +515,17 @@ PAGE "Conti CA" 0 2 0 0 GROUPBOX DLG_NULL 76 6 BEGIN - PROMPT 1 0 "@bAmm. Normali" + PROMPT 1 0 "@bAmmortamenti Normali" END GROUPBOX DLG_NULL 76 6 BEGIN - PROMPT 1 6 "@bAmm. Accelerati" + PROMPT 1 6 "@bAmmortamenti Accelerati" END GROUPBOX DLG_NULL 76 6 BEGIN - PROMPT 1 12 "@bAmm. Anticipati" + PROMPT 1 12 "@bAmmortamenti Anticipati" END ENDPAGE