From c66486725c031f89a949fe78672c71c3661a10ab Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 27 Feb 2009 16:55:21 +0000 Subject: [PATCH] Patch level : 10.0 250 Files correlati : ve0.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.2 patch 1350 git-svn-id: svn://10.65.10.50/trunk@18386 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/velib.h | 3 +++ ve/velib03.cpp | 11 +++++++++-- ve/velib04a.cpp | 42 ++++++++++++++++++++++++++---------------- ve/velib04b.cpp | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 19 deletions(-) diff --git a/ve/velib.h b/ve/velib.h index b1d4b9730..42b31fd00 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -743,6 +743,7 @@ public: bool tipo_valido() const { return get("TIPODOC").not_empty(); } const TTipo_documento& tipo() const; int tipo_riclassificato() const; + static const TCodice_numerazione& codice_numerazione(const char * numerazione); const TCodice_numerazione& codice_numerazione() const; void set_tipo(const char * tipo) { head().put("TIPODOC", tipo);} bool provvisorio() const { return get_char("PROVV") == 'P'; } @@ -773,6 +774,8 @@ public: void set_fields(TAuto_variable_rectype & rec); void set_riga_esenzione(); + bool ha_riga_sconto() const { return _sconto != NULL; } + bool ha_riga_esenzione() const { return _esenzione != NULL; } void iva_esente(TString & codiva_es) const; real spese_incasso(real &imp, int ndec, TTipo_importo netto = _lordo) const ; diff --git a/ve/velib03.cpp b/ve/velib03.cpp index cbfb4c105..34e12741a 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -1617,7 +1617,7 @@ TRiga_documento & TDocumento::row(int index) if (index == nrows + 1) { r = _sconto != NULL ? _sconto : _esenzione; - } + } else if (index == nrows + 2) r = _esenzione; } @@ -1670,6 +1670,12 @@ const TTipo_documento& TDocumento::tipo() const return cached_tipodoc(tipodoc); } +const TCodice_numerazione& TDocumento::codice_numerazione(const char * numerazione) +{ + return cached_numerazione(numerazione); +} + + const TCodice_numerazione& TDocumento::codice_numerazione() const { return cached_numerazione(numerazione()); @@ -1946,7 +1952,7 @@ void TDocumento::update_tabella_iva(bool solo_imponibili) TString4 codiva_es; iva_esente(codiva_es); - for (int i = righe.last_row(); i > 0; i = righe.pred_row(i)) + for (int i = items; i > 0; i--) { const TRiga_documento& r = row(i); const real imponibile = doc_al_lordo ? r.importo(true, true, ndec) : r.imponibile(); @@ -1993,6 +1999,7 @@ void TDocumento::update_tabella_iva(bool solo_imponibili) TGeneric_distrib d(tot_sconti, ndec); real tot_sconti_imp = tot_sconti - tot_sconti_perc; + if (!table.empty()) { FOR_EACH_ASSOC_OBJECT(table, obj, key, o) { diff --git a/ve/velib04a.cpp b/ve/velib04a.cpp index df8209125..957d53010 100755 --- a/ve/velib04a.cpp +++ b/ve/velib04a.cpp @@ -74,6 +74,13 @@ void TFatturazione_bolle::campi_raggruppamento(TToken_string& campi) const if (doc_uguale(u)) campi.add(cond[u]); } +bool TFatturazione_bolle::doc_raggruppabili(const TDocumento& doc_in, const TDocumento& doc_out, TToken_string& campi) const +{ + if (doc_in.ha_riga_esenzione() != doc_out.ha_riga_esenzione()) + return false; + return doc_in.raggruppabile(doc_out, campi); +} + void TFatturazione_bolle::create_row(TDocumento& doc_out, const TRiga_documento & rin) { TRiga_documento& rout = doc_out.new_row(); // ... crea una riga nuova e @@ -289,7 +296,7 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do TBit_array closed; - campi_raggruppamento( campi_doc); + campi_raggruppamento(campi_doc); for (int id = 0; id < doc_in.items(); id++) { @@ -305,32 +312,35 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do if (tipo != doc_out[od].get_char(DOC_TIPOCF) || codice != doc_out[od].get_long(DOC_CODCF)) - return error_box("Documenti incompatibili : cliente/fornitore diverso"); + return error_box("Documenti incompatibili: cliente/fornitore diverso"); } else { - if (doc_raggruppabile(campione)) // Se il documento ha il flag di raggruppabilita' ... -// if (campione.raggruppabile()) // Se il documento ha il flag di raggruppabilita' ... + if (doc_raggruppabile(campione)) // Se il documento ha il flag di raggruppabilita' ... { for (od = 0; od < tot; od++) // ... cerca un documento compatibile. { - const int in_rows = campione.rows(); - const int out_rows = doc_out[od].rows(); + if (!closed[od]) + { + const int in_rows = campione.rows(); + const int out_rows = doc_out[od].rows(); - if (in_rows + out_rows > 990) - closed.set(od); - else - if (!closed[od] && doc_raggruppabile(campione, doc_out[od], campi_doc)) -// if (campione.raggruppabile(doc_out[od], campi_doc)) - break; + if (in_rows + out_rows > 990) + closed.set(od); + else + { + if (doc_raggruppabili(campione, doc_out[od], campi_doc)) + break; + } + } } } - } + } if (od >= tot) // Se non ho trovato un documento compatibile ... { // ... creane uno nuovo (certamente compatibile) const int anno = data_elab.year(); - const TString4 codnum(campione.get("CODNUM")); + const TString4 codnum(campione.get(DOC_CODNUM)); const TString4 tipo_out(get("S8")); // Tipo del documento di output TDocumento* new_doc = new TDocumento('D', anno, codnum, -1); @@ -342,7 +352,7 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do TDocumento::copy_data(new_doc->head(), campione.head()); // Copio la testata // td = old_tipo_in; // Ripristino il vecchio - new_doc->put("DATADOC", data_elab); + new_doc->put(DOC_DATADOC, data_elab); // Aggiungilo alla lista dei documenti in uscita od = doc_out.add(new_doc); @@ -360,7 +370,7 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do for (int i = 0; i < tot; i++) // Forza tipo e numerazione documento. { TDocumento & d = doc_out[i]; - d.put("CODNUM", codnum); + d.put(DOC_CODNUM, codnum); TToken_string key; key.add(d.get(DOC_TIPOCF)); key.add(d.get(DOC_CODCF)); const TRectype & cfven = cache().get(LF_CFVEN, key); diff --git a/ve/velib04b.cpp b/ve/velib04b.cpp index 9102aa550..69340eef4 100755 --- a/ve/velib04b.cpp +++ b/ve/velib04b.cpp @@ -2411,11 +2411,43 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) if (!iva_mov) { - const int cgitems = _movimento->cg_items(); + static int __check_sez = 2; + if (__check_sez > 1) + { + TConfig c(CONFIG_DITTA, "ve"); + + __check_sez = c.get_bool("CHECK_SEZ", false); + } + bool swap = false; + + if (__check_sez) + { + const TString4 sz = _movimento->cg(0).get(RMV_SEZIONE); + + for (int row = 1; !swap && row <= doc.physical_rows(); row++) + { + const TRiga_documento & r = doc[row]; + + if (r.is_spese()) + { + const TSpesa_prest s(r.get(RDOC_CODART)); + const TString & sez = s.get("S11"); + + swap = sez == sz; + } + } + } + + const int cgitems = _movimento->cg_items(); for (int i = cgitems - 1 ; i >= 0; i--) { TRectype& rec_cg = _movimento->cg(i); rec_cg.zero(RMV_ROWTYPE); + if (__check_sez && swap) + { + const TString4 sez = rec_cg.get(RMV_SEZIONE); + rec_cg.put(RMV_SEZIONE, sez == "D" ? "A" :"D"); + } } _movimento->destroy_iva_row(); }