diff --git a/src/cg/cglib.h b/src/cg/cglib.h index 4f51d7a31..327ee3484 100644 --- a/src/cg/cglib.h +++ b/src/cg/cglib.h @@ -30,6 +30,7 @@ #endif #ifndef __PROGIND_H +class TDocumento; class TProgind; #endif @@ -1008,15 +1009,23 @@ public: int iva_rows() const { return iva().rows(); } bool solo_IVA() const { return iva_rows() > 0 && cg_rows() == 0; } - virtual int readat(TBaseisamfile& f, TRecnotype nrec, word lockop = _nolock); - virtual int read(TBaseisamfile & f, word op = _isequal, word lockop = _nolock); + virtual int readat(TRecnotype nrec, word lockop = _nolock); + virtual int read(word op = _isequal, word lockop = _nolock); virtual int TMovimento_contabile::remove(); - - void adjust_rowtypes(); + + virtual TMovimento_contabile & copy(const TMovimento_contabile & mov); + virtual TObject* dup() const { return new TMovimento_contabile(*this); } + virtual TMovimento_contabile& operator =(const TMovimento_contabile& mov) { return copy(mov); } + virtual TRectype& operator =(const TRectype & mov); + + void adjust_rowtypes(); real imponibile(const char * codiva = nullptr) const ; real imposta(const char * codiva = nullptr) const ; TMovimento_contabile(); + TMovimento_contabile(const TMovimento_contabile& mov); + TMovimento_contabile(long numreg); + TMovimento_contabile(const TRectype& mov); virtual ~TMovimento_contabile() {} }; diff --git a/src/cg/cglib06.cpp b/src/cg/cglib06.cpp index 0d669688f..ead7b2e6b 100644 --- a/src/cg/cglib06.cpp +++ b/src/cg/cglib06.cpp @@ -89,9 +89,34 @@ TMovimento_contabile::TMovimento_contabile() add_file(LF_RMOVIVA, RMV_NUMRIG); } -int TMovimento_contabile::readat(TBaseisamfile& f, TRecnotype nrec, word lockop) +TMovimento_contabile::TMovimento_contabile(const TMovimento_contabile& mov) + : TMultiple_rectype(LF_MOV), _old_iva(LF_RMOVIVA, RMI_NUMRIG) { - const int err = TMultiple_rectype::readat(f, nrec, lockop); + copy(mov); +} + +TMovimento_contabile::TMovimento_contabile(long numreg) + : TMultiple_rectype(LF_MOV), _old_iva(LF_RMOVIVA, RMI_NUMRIG) +{ + add_file(LF_RMOV, RMV_NUMRIG); + add_file(LF_RMOVIVA, RMV_NUMRIG); + put(MOV_NUMREG, numreg); + read(_isequal, _nolock); +} + +TMovimento_contabile::TMovimento_contabile(const TRectype& mov) + : TMultiple_rectype(LF_MOV), _old_iva(LF_RMOVIVA, RMI_NUMRIG) +{ + add_file(LF_RMOV, RMV_NUMRIG); + add_file(LF_RMOVIVA, RMV_NUMRIG); + *this = mov; + read(_isequal, _nolock); +} + +int TMovimento_contabile::readat(TRecnotype nrec, word lockop) +{ + TLocalisamfile f(LF_MOV); + const int err = TMultiple_rectype::readat(f, nrec, lockop); if (err == NOERR) { @@ -110,9 +135,9 @@ int TMovimento_contabile::readat(TBaseisamfile& f, TRecnotype nrec, word lockop) return err; } -int TMovimento_contabile::read(TBaseisamfile & f, word op, word lockop) +int TMovimento_contabile::read( word op, word lockop) { - const int err = TMultiple_rectype::read(f, op, lockop); + const int err = TMultiple_rectype::read(op, lockop); if (err == NOERR) { @@ -255,6 +280,21 @@ int TMovimento_contabile::write_rewrite(TBaseisamfile& f, bool re) const return err; } +TMovimento_contabile& TMovimento_contabile::copy(const TMovimento_contabile & mov) +{ + TMultiple_rectype::operator=((TMultiple_rectype &)mov); + + _old_iva = mov._old_iva; + _olddataliq = mov._olddataliq; + return *this; +} + +TRectype & TMovimento_contabile::operator =(const TRectype & mov) +{ + return TMultiple_rectype::operator=(mov); +} + + void TMovimento_contabile::find_movcoll() { if (get_long(MOV_MOVCOLL) == 0L)