From e7a8be790876896723c5ddcd557ffdc0d0317e3c Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 26 Oct 1996 11:15:22 +0000 Subject: [PATCH] Aggiunto metodo TRiga_documento::tipo_valido() per sapere se il tipo di riga non e' vuoto. Corretto errore su bolli() e sul settaggio del tipo di riga in caso di descrizione di riferimento. git-svn-id: svn://10.65.10.50/trunk@3829 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/velib01.cpp | 28 ++++++++++++++++------------ ve/velib01.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ve/velib01.cpp b/ve/velib01.cpp index f52e5e571..1a8b5dac9 100755 --- a/ve/velib01.cpp +++ b/ve/velib01.cpp @@ -620,7 +620,8 @@ real TDocumento::bolli(real & imp, int ndec, bool netto) const for (int i = 0; i < nscagl - 1; i++) if ((real &) sca_bolli[i] >= imp) break; - tot_bolli += (real &) imp_bolli[i]; + if (imp_bolli.items() > 0) + tot_bolli += (real &) imp_bolli[i]; } break; case _tratta: @@ -1344,7 +1345,7 @@ bool TRiga_documento::sola_descrizione() const void TRiga_documento::forza_sola_descrizione() { // In realta' il test serve anche a caricare la lista dei tipi riga! - if (tipo().tipo() != 'D') + if (!tipo_valido() || tipo().tipo() != 'D') { _tipi.restart(); for (const TObject* o = _tipi.get(); o; o = _tipi.get()) @@ -1552,28 +1553,31 @@ void TRiga_documento::dirty_fields(bool dirty_document) bool TRiga_documento::doc_dependent() const { - const char tipor = tipo().tipo(); - - if (tipor == 'S') - return spesa().tipo() == 'P'; - else - if (tipor == 'C') - return get("SCONTO").not_empty(); + if (tipo_valido()) + { + const char tipor = tipo().tipo(); + if (tipor == 'S') + return spesa().tipo() == 'P'; + else + if (tipor == 'C') + return get("SCONTO").not_empty(); + } return FALSE; } void TRiga_documento::put_str(const char* fieldname, const char* val) { - if (strcmp(fieldname, "TIPORIGA") == 0 && TRectype::get("TIPORIGA") != val) + TString v(val); + if (strcmp(fieldname, "TIPORIGA") == 0 && TRectype::get("TIPORIGA") != v) { - TAuto_variable_rectype::put_str(fieldname, val); + TAuto_variable_rectype::put_str(fieldname, v); reset_fields(*this); set_fields(*this); } else { - TAuto_variable_rectype::put_str(fieldname, val); + TAuto_variable_rectype::put_str(fieldname, v); dirty_fields(); } } diff --git a/ve/velib01.h b/ve/velib01.h index e1acbedd2..c98360ff5 100755 --- a/ve/velib01.h +++ b/ve/velib01.h @@ -280,6 +280,7 @@ public: static const TIVA & iva(const char * codice); const TIVA & iva() const {const TString16 cod(get("CODIVA")); return iva(cod);} + const bool tipo_valido() const { return get("TIPORIGA").not_empty(); } void set_tipo(const char * tipo) { put("TIPORIGA", tipo);} bool sola_descrizione() const; void forza_sola_descrizione();