diff --git a/ve/velib03.cpp b/ve/velib03.cpp index a4bea43e4..19d638bfb 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -1856,8 +1856,8 @@ real TDocumento::imponibile(bool spese, int ndec) const if (physical_rows() > 0) { TAssoc_array & table = ((TDocumento *)this)->tabella_iva(); - for (TRiepilogo_iva * ri = (TRiepilogo_iva *) table.get(); ri != NULL; - ri = (TRiepilogo_iva *) table.get()) + table.restart(); + for (TRiepilogo_iva* ri = (TRiepilogo_iva*)table.get(); ri != NULL; ri = (TRiepilogo_iva*)table.get()) val += ri->imponibile(spese); if (ndec == AUTO_DECIMALS) @@ -2370,12 +2370,12 @@ real TDocumento::provvigione(bool first, int ndec) const real TDocumento::valore(bool totale, bool lordo, int ndec) const { real val; - for (int i = physical_rows(); i>0; i--) + TDocumento& doc = *(TDocumento*)this; + FOR_EACH_PHYSICAL_RDOC_BACK(doc, i, r) { - const TRiga_documento &r = physical_row(i); - //if (r.is_merce() || r.is_spese() || r.is_prestazione()) - if (strchr("MSPRA", r.tipo().tipo()) != NULL) // Merce, Spese, Prestazioni, Risorse, Attrezzature - val += r.valore(totale, lordo, ndec); + const char t = r->tipo().tipo(); + if (strchr("MSPRA", t) != NULL) // Merce, Spese, Prestazioni, Risorse, Attrezzature + val += r->valore(totale, lordo, ndec); } return val; } diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index 4fd35cf01..1aa369dfa 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -2304,7 +2304,7 @@ bool sppr_handler( TMask_field& f, KEY key ) if (posiva >= 0) iva_handler(row_mask.fld(posiva), 0); - if (row_mask.id2pos(FR_CDC1) >= 0) + if (row_mask.id2pos(FR_CDC1) >= 0 && sp.get("S1").full()) { const TString80 cdc(sp.cdc()); const TString80 cms(sp.cms()); @@ -2319,13 +2319,20 @@ bool sppr_handler( TMask_field& f, KEY key ) const TFieldref& fr = *e.field(); if (fr.name() == RDOC_CODCOSTO) - e.set(cdc.sub(fr.from(), fr.to())); - else - if (fr.name() == RDOC_CODCMS) - e.set(cms.sub(fr.from(), fr.to())); - else - if (fr.name() == RDOC_FASCMS) - e.set(fase.sub(fr.from(), fr.to())); + { + if (cdc.full()) + e.set(cdc.sub(fr.from(), fr.to())); + } else + if (fr.name() == RDOC_CODCMS) + { + if (cms.full()) + e.set(cms.sub(fr.from(), fr.to())); + } else + if (fr.name() == RDOC_FASCMS) + { + if (fase.full()) + e.set(fase.sub(fr.from(), fr.to())); + } } } }