diff --git a/fe/felib.cpp b/fe/felib.cpp index ee50dab0f..e645ada71 100644 --- a/fe/felib.cpp +++ b/fe/felib.cpp @@ -39,22 +39,35 @@ bool fe_is_nota_variazione(const TRectype& mov) const int tipomov = mov.get_int(MOV_TIPOMOV); if (tipomov == 2) // Nota di credito/debito per saldaconto - return true; + return true; - const TString& tipodoc = mov.get(MOV_TIPODOC); - if (tipodoc == "NC" || tipodoc == "ND") // Nota di credito/debito senza saldaconto - return true; + if (tipomov <= 1) + { + const TString& tipodoc = mov.get(MOV_TIPODOC); + if (tipodoc == "NC" || tipodoc == "ND") // Nota di credito/debito senza saldaconto + return true; + } } else if (logicnum == LF_ALLEG) { - const TString& numrett = mov.get(ALL_NUMRETT); - if (numrett.full()) + if (mov.get_int(ALL_MODPAG) > 1) + return false; + + if (mov.get(ALL_NUMRETT).full() || mov.get(ALL_DATARETT).full()) return true; const real importo = mov.get_real(ALL_IMPORTO); const real imposta = mov.get_real(ALL_IMPOSTA); if (importo < ZERO || imposta < ZERO) return true; + + const long numreg = mov.get_long(ALL_PROGR); + if (numreg < 900000L) + { + const TRectype& pn = cache().get(LF_MOV, numreg); + if (!pn.empty()) + return fe_is_nota_variazione(pn); + } } else if (logicnum == LF_DOC) {