diff --git a/src/ve/velib04b.cpp b/src/ve/velib04b.cpp index a95d088a1..4f91ab197 100755 --- a/src/ve/velib04b.cpp +++ b/src/ve/velib04b.cpp @@ -3807,7 +3807,30 @@ error_type TContabilizzazione::write_intra(TDocumento& doc) // Effettuando il raggruppamento in un comodo TAssoc_array TToken_string key; int numrig = 1; - FOR_EACH_PHYSICAL_RDOC(doc, i, prdoc) if (prdoc->is_articolo()) + const real spese = doc.spese(TIPO_SPESE_TRASPORTO); + real speselit = spese; + + if (is_val) + { + TCurrency_documento sp(speselit, doc); + sp.change_to_firm_val(); + speselit = sp.get_num(); + } + + TGeneric_distrib d(spese, doc.decimals()); + TGeneric_distrib dlit(speselit, TCurrency::get_firm_dec()); + + FOR_EACH_PHYSICAL_RDOC(doc, i, prdoc0) if (prdoc0->is_articolo()) + { + const TRiga_documento& rr = doc[i]; + TCurrency_documento imp_val(rr.TVariable_rectype::exist("VALINTRA") ? rr.get_real("VALINTRA") : rr.importo(true, false), doc); + TCurrency_documento imp(imp_val); imp.change_to_firm_val(); + + d.add(imp_val.get_num()); + dlit.add(imp.get_num()); + } + + FOR_EACH_PHYSICAL_RDOC(doc, i, prdoc) if (prdoc->is_articolo()) { const TRiga_documento& rr = doc[i]; const TRectype& rec_anamag = cchh.get(LF_ANAMAG, rr.get(RDOC_CODARTMAG)); @@ -3881,7 +3904,11 @@ error_type TContabilizzazione::write_intra(TDocumento& doc) const real qta = rr.get_real(RDOC_QTA); TCurrency_documento imp_val(rr.TVariable_rectype::exist("VALINTRA") ? rr.get_real("VALINTRA") : rr.importo(true, false), doc); TCurrency_documento imp(imp_val); imp.change_to_firm_val(); - imp_val.change_value(codvali, cambioi); + + imp_val += d.get(); + imp += dlit.get(); + imp_val.change_value(codvali, cambioi); + real ammeuro = rc->get_real("AMMLIRE"); real ammvaluta = rc->get_real("AMMVALUTA"); real massakg = rc->get_real("MASSAKG"); @@ -3963,37 +3990,16 @@ error_type TContabilizzazione::write_intra(TDocumento& doc) totale_righe += imp.get_num(); } - if (nota_credito) - totale_righe -= doc.spese(TIPO_SPESE_TRASPORTO); - else - totale_righe += doc.spese(TIPO_SPESE_TRASPORTO); if (_error == no_error) { - TGeneric_distrib d(doc.spese(TIPO_SPESE_TRASPORTO)); TRectype* rc; - - for(rc = (TRectype*)righe.first_item(); rc != NULL; rc = (TRectype*)righe.succ_item()) - d.add(is_val ? rc->get_real("AMMVALUTA") : rc->get_real("AMMLIRE")); // Copia il contenuto dell'assoc nel record array rc = new TRectype(LF_RINTRA); rc->put("NUMREG", numreg); rintra.set_key(rc); for(rc = (TRectype*)righe.first_item(); rc != NULL; rc = (TRectype*)righe.succ_item()) - { - real amm = is_val ? rc->get_real("AMMVALUTA") : rc->get_real("AMMLIRE"); - - amm += d.get(); - rc->put(is_val ? "AMMVALUTA" : "AMMLIRE", amm); - if (is_val) - { - TCurrency_documento imp(amm, doc); - - imp.change_to_firm_val(); - rc->put("AMMLIRE", imp.get_num()); - } rintra.add_row(*rc); // Devo aggiungere una copia della riga dell'assoc array! - } // Testa (de coccio...) intra.zero(); intra.put("NUMREG", numreg);