diff --git a/ve/ve6200.cpp b/ve/ve6200.cpp index d01a63d5b..2f57c44f5 100755 --- a/ve/ve6200.cpp +++ b/ve/ve6200.cpp @@ -46,7 +46,6 @@ bool TFatturazione_bolle_app::process(TIndwin& iw, TElaborazione & eld, else ok = error_box("Errore %d durante l'aggiornamento dei documenti da raggruppare!", err); } - else return ok; } diff --git a/ve/velib04.h b/ve/velib04.h index 7fd65ac55..a459a9eb9 100755 --- a/ve/velib04.h +++ b/ve/velib04.h @@ -617,7 +617,7 @@ class TContabilizzazione_analitica : public TElaborazione // velib04f protected: bool find_conti_iva_indetraibile(const TRiga_documento& riga, const TBill & bill, TString_array& conti, int annoes, const char tipomov, bool & pareggio); bool spalma_spese() const { return get("I2") == "X"; } - void split_sp_amount(TAnal_mov & mov, bool pareggio, const TImporto & totdoc, const real & amount, const real & no_ca_amount, int decimals); + void split_sp_amount(TAnal_mov & mov, bool pareggio, const TImporto & totdoc, const TBit_array & spese, const real & amount, const real & no_ca_amount, int decimals); bool find_conti(const TRiga_documento& riga, TString_array& conti, int annoes, bool riclassifica_fdr_fde, const char tipomov, real & amount_to_split, real & no_ca_amount, const real & valore, bool & pareggio); void init(); diff --git a/ve/velib04b.cpp b/ve/velib04b.cpp index 753aed5f7..31fb7b75d 100755 --- a/ve/velib04b.cpp +++ b/ve/velib04b.cpp @@ -1782,7 +1782,7 @@ error_type TContabilizzazione::search_costo_ricavo(TBill& conto, const TRiga_doc { const char tipo = r.doc()[i].tipo().tipo(); - if (tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_OMAGGI) + if (tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_OMAGGI && tipo != RIGA_SPESEDOC) row = i; } if (row > 0) @@ -2239,22 +2239,32 @@ void TContabilizzazione::split_sp_amount(const real & amount, int decimals) FOR_EACH_ASSOC_OBJECT((*_righe_iva), obj, key, itm) { + const bool spese = key && *key == '3'; TRectype & r = (TRectype &)*itm; const real imp = r.get_real(RMI_IMPONIBILE); - d.add(imp); + if (spese) + d.add(ZERO); + else + d.add(imp); } FOR_EACH_ASSOC_OBJECT((*_righe_iva), obj1, key1, itm1) { + const bool spese = key1 && *key1 == '3'; TRectype & r = (TRectype &)*itm1; - real imp = r.get_real(RMI_IMPONIBILE); - const TCodiceIVA i(r.get(RMI_CODIVA)); + if (spese) + d.get(); + else + { + real imp = r.get_real(RMI_IMPONIBILE); + const TCodiceIVA i(r.get(RMI_CODIVA)); - imp += d.get(); - r.put(RMI_IMPONIBILE, imp); - real const imposta = i.imposta(imp); - r.put(RMI_IMPOSTA, imposta); + imp += d.get(); + r.put(RMI_IMPONIBILE, imp); + real const imposta = i.imposta(imp); + r.put(RMI_IMPOSTA, imposta); + } } } diff --git a/ve/velib04f.cpp b/ve/velib04f.cpp index 2e08e1426..fe4c8d1d5 100755 --- a/ve/velib04f.cpp +++ b/ve/velib04f.cpp @@ -274,7 +274,7 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r, for (int i = 1; row < 0 && i <= rows; i++) { const char tipo = r.doc()[i].tipo().tipo(); - if (tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_OMAGGI) + if (tipo != RIGA_DESCRIZIONI && tipo != RIGA_SCONTI && tipo != RIGA_OMAGGI && tipo != RIGA_SPESEDOC) row = i; } if (row > 0) @@ -507,7 +507,9 @@ void TContabilizzazione_analitica::calcola_date_comp(const TDocumento& doc, TDat annoes = esercizi().date2esc(datacomp); //ci potrebbe andare datacomp? All'analisi l'ardua sentenza } -void TContabilizzazione_analitica::split_sp_amount(TAnal_mov & mov, bool pareggio, const TImporto & totdoc, const real & amount, const real & no_ca_amount, int decimals) +void TContabilizzazione_analitica::split_sp_amount(TAnal_mov & mov, bool pareggio, const TImporto & totdoc, + const TBit_array & spese, const real & amount, const real & no_ca_amount, + int decimals) { char sezione = totdoc.sezione(); TGeneric_distrib w(amount, decimals); @@ -525,7 +527,10 @@ void TContabilizzazione_analitica::split_sp_amount(TAnal_mov & mov, bool pareggi TImporto imp(r.get_char(RMOVANA_SEZIONE), r.get_real(RMOVANA_IMPORTO)); imp.normalize(sezione); - d.add(imp.valore()); + if (spese[r.get_int(RMOVANA_NUMRIG)]) + d.add(ZERO); + else + d.add(imp.valore()); } for (int i = pareggio ? 2 : 1; i <= rows; i++) { @@ -547,6 +552,7 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis TString descr, msg, codcaus; bool dare = false; TCausale & caus = (TCausale &) doc2caus(doc); + TBit_array spese; if (numreg_cg > 0) { @@ -671,6 +677,8 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis FOR_EACH_ARRAY_ROW(conti_ind, j, row_ind) { TRectype& rmov = mov.new_row(); + + spese.set(rmov.get_int(RMOVANA_NUMRIG), riga.is_spese()); rmov.put(RMOVANA_ANNOES, annoes); rmov.put(RMOVANA_CODCONTO, row_ind->get(0)); rmov.put(RMOVANA_CODCCOSTO,row_ind->get()); @@ -722,7 +730,9 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis FOR_EACH_ARRAY_ROW(conti, i, row) { TRectype& rmov = mov.new_row(); - rmov.put(RMOVANA_ANNOES, annoes); + + spese.set(rmov.get_int(RMOVANA_NUMRIG), riga.is_spese()); + rmov.put(RMOVANA_ANNOES, annoes); rmov.put(RMOVANA_CODCONTO, row->get(0)); rmov.put(RMOVANA_CODCCOSTO,row->get()); rmov.put(RMOVANA_CODCMS, row->get()); @@ -762,6 +772,7 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis { TRectype& rmov = mov.new_row(); + spese.set(rmov.get_int(RMOVANA_NUMRIG)); rmov.put(RMOVANA_ANNOES, annoes); rmov.put(RMOVANA_CODCONTO, cinc.string(0x8)); rmov.put(RMOVANA_CODCCOSTO, doc.codice_costo()); @@ -781,6 +792,7 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis { TRectype& rmov = mov.new_row(); + spese.set(rmov.get_int(RMOVANA_NUMRIG)); rmov.put(RMOVANA_ANNOES, annoes); rmov.put(RMOVANA_CODCONTO, cbol.string(0x8)); rmov.put(RMOVANA_CODCCOSTO, doc.codice_costo()); @@ -798,7 +810,7 @@ bool TContabilizzazione_analitica::elabora(TDocumento& doc, long numreg_cg, TVis } if (amount_to_split != ZERO) - split_sp_amount(mov, has_pareggio, totdoc, amount_to_split, no_ca_amount, doc.decimals()); + split_sp_amount(mov, has_pareggio, totdoc, spese, amount_to_split, no_ca_amount, doc.decimals()); if (can_write && mov.rows() > 0) {