From 7fa5b469bfff6651a9459f26197609a78bb454fe Mon Sep 17 00:00:00 2001 From: Mattia Tollari Date: Tue, 2 Apr 2019 14:55:59 +0200 Subject: [PATCH] Patch level : 12.0 752 Files correlati : ve Commento : Aggiunto calcolo della ritenuta passato da Alessandro --- src/ve/velib02.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/ve/velib02.cpp b/src/ve/velib02.cpp index 4ec5a488d..ff31c2784 100755 --- a/src/ve/velib02.cpp +++ b/src/ve/velib02.cpp @@ -746,15 +746,44 @@ real TRiga_documento::ritenuta(const char tipor, bool lordo, int ndec) const real val; if (tipo().tipo() == RIGA_SPESEDOC) - { - const char tipo_rit = spesa().tipo_ritenuta(); + { + const char tipo_rit = spesa().tipo_ritenuta(); - if ((tipor != '\0' && tipo_rit == tipor) || (tipor == '\0' && tipo_rit != '\0')) - { + if ((tipor != '\0' && tipo_rit == tipor) || (tipor == '\0' && tipo_rit != '\0')) + { _rit_calc = true; - val = importo(true, lordo, ndec); + if (spesa().is_percentuale() && spesa().field_perc().blank()) + { + real imponibile; + + FOR_EACH_PHYSICAL_RDOC(doc(), r, rdoc1) + { + if (rdoc1->is_prestazione()) + { + imponibile += rdoc1->imponibile(); + } + } + + // Riciclo per sommare la % delle spese da sommare + FOR_EACH_PHYSICAL_RDOC(doc(), r, rdoc2) + { + if (rdoc2->is_spese() && rdoc2->spesa().spe_cal_rit()) + { + if (rdoc2->spesa().is_percentuale()) + val += imponibile * rdoc2->spesa().perc() / CENTO; + else + val = rdoc2->importo(true, lordo, ndec); + } + } + + val += imponibile; + val *= spesa().perc() / CENTO; + val.round(2); + } + else + val = importo(true, lordo, ndec); _rit_calc = false; - } + } } return val; }