diff --git a/mg/mglib01.h b/mg/mglib01.h deleted file mode 100755 index c42e04740..000000000 --- a/mg/mglib01.h +++ /dev/null @@ -1,338 +0,0 @@ -// ******************************* -// LIBRERIA DI utility del magazzino -// ******************************* - -// ************************************** -// ************************************** -// ************************************** -// *** classi per la libreria -// *** -#include -#include -#ifndef __MGLIB_H -#define __MGLIB_H -class THead_lines_record ; -//************************************** -// classe per il controllo dei record composti da una testata e N righe -// è implementato come un TRectype che contiene anche un TRecord_array -// -class THead_lines_record : public TAuto_variable_rectype { - - // @ cmember Array di TRectype per le righe - TRecord_array * _rows; // - // @ cmember flag indicatore di record nuovo - bool _nuovo; - // @ cmember file principale - int _file; - // @ cmember file delle righe - int _rfile; - // @ cmember nome del campo "numeratore" delle righe - TString _numfield; - - -protected: - // @ cmember restituisce la riga del corpo - virtual TRectype & row(int index) const; - virtual void put_str(const char* fieldname, const char* val); - // @ cmember funzione per estrarre dal record della testata la chiave delle righe - virtual void copy_linekey(const TRectype & headrecord, TRectype & linesrecord)=0; - // @ cmember renumer la chiave del corpo - virtual long renum(long numdoc=-1)=0; - - int write_rewrite(TBaseisamfile& f ,bool re = FALSE) const ; -public: - //*********************** - // struttura - // @ cmember restituisce il record di testata - const TAuto_variable_rectype& head() const { return *this; } // Ritorna la testata del documento - // @ cmember restituisce il record di testata - TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento - - // @ cmember restituisce il numero di record nel corpo - int rows() const { return _rows->rows(); } - // @ cmember restituisce il record array del corpo - TRecord_array * rows_record() { return _rows; } - - // @ cmember restituisce il record n-esimo del del corpo - virtual const TRectype& operator[](int index) const - { return (const TRectype&)((THead_lines_record *)this)->row(index); } - // @ cmember restituisce il record n-esimo del del corpo - virtual TRectype& operator[](int index) - { return (TRectype&)row(index); } - - TRectype & insert_row(int row, const char *tipo = NULL); - TRectype & new_row(const char *tipo = NULL); - bool destroy_row(int n, bool pack = FALSE) { return _rows->destroy_row(n, pack); } - void destroy_rows() { _rows->destroy_rows(); } - - //*********************** - // record e I/O - virtual void dirty_fields(); - - virtual const char *get_next_key() =0 ; - virtual void renum_key(const char * kfield,const char * val); - virtual TRectype & operator =(const TRectype & r); - virtual TRectype & operator =(const char * r); - virtual void zero(const char * fieldname); - virtual void zero(char c = '\0'); - - void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); } - virtual void set_fields(TAuto_variable_rectype & rec); - - virtual int readat(TBaseisamfile& f, TRecnotype nrec, word lockop= _nolock); - virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock); - - virtual int write(TBaseisamfile& f) const ; - virtual int rewrite(TBaseisamfile& f) const ; - virtual int remove(TBaseisamfile& f) const ; - - //************************** - // @ cmember costruttore dal numero del file - THead_lines_record(int hfn, int rfn,const char *numfield); - // @ cmember costruttore dal file - THead_lines_record(const TBaseisamfile* head_file,int rfn,const char *numfield); - // @ cmember costruttore dal record - THead_lines_record(const TRectype & r,int rfn,const char *numfield); - // @ cmember costruttore di copia - THead_lines_record(const THead_lines_record& r); - virtual ~THead_lines_record(); -}; - - -// ************************************** -// ************************************** -// ************************************** -// fine classi da portare in libreria: - -// ******************************* -// LIBRERIA DI utility del magazzino -// ******************************* -//#include "..\ve\velib03.h" - - -#define MANY_MAG_LEV 10 -#define MAX_GIAC_LEVEL 4 -class TMag_livelli { - bool _enabled[MANY_MAG_LEV]; - int _code_lenght[MANY_MAG_LEV]; - TString _name[MANY_MAG_LEV]; - TString _picture[MANY_MAG_LEV]; - int _last_level; - -public: - int last_level() const {return _last_level;}; // Ritorna il numero di livelli abilitati - const bool enabled(int levnum=1); // Ritorna se il livello è abilitato - const TString & name(int levnum); // Ritorna il nome (descrizione) di quel livello - const TString & picture(int levnum);// Ritorna la stringa di picture per i codici gruppo di quel livello - const int code_lenght(int levnum); // Ritorna la lunghezza dei codici gruppo di quel livello - const int packed_lenght(int levnum); // Ritorna la lunghezza del codice compatto fino a quel livello - - void pack_grpcode(TString & pc, const TString &codlev, const int levnum); // Inserisce il codice del gruppo del livello levnum in pc - TString unpack_grpcode(const TString & pc, const int levnum); // Estrae il codice del gruppo del livello levnum da pc - TString build_tabcode(const TString & pc, const int levnum); - - TMag_livelli(const char *tabname); // costruttore - ~TMag_livelli() {}; // distruttore -}; - - -// ******************************* -// ******************************* -#define MAXSIMBOLS 256 -#define MAXSTATES 25 -class TStateset { - unsigned char _container[MAXSTATES]; - int _current; -public: - TStateset & empty(); - TStateset & enclose(int e); - TStateset & singleton(int e); - TStateset & cap(TStateset & s); - int get_first() ; - int get_next() ; - bool is_empty() const; - bool is_member(int e) const; - TStateset(); - ~TStateset() {}; -}; - -struct TAutoma_state { - short _transaction[MAXSIMBOLS]; - TString16 * _label; - bool _final; -}; - -// ******************************* -// ******************************* -// automa per il riconoscimento di metacaratteri -class TR_automa { - TAutoma_state st[MAXSTATES]; - short _maxstate; -protected: - TStateset union_of_closures(TStateset &s); - - bool is_final(int statenum) const; - bool is_final(TStateset states) const; - - TR_automa & set_label(int statenum, const char *label); - bool is_state(int statenum); - const char *label(int statenum); - int label2state(const char * label); - - void del_trans(int statenum,unsigned char symbol); - int trans_to(int statenum,unsigned char symbol); - bool _isdeterministic; - -public: - TR_automa & reset_state(int statenum=-1); - - void add_tran(int statenum,unsigned char symbol,int next);// aggiunge una transizione - int add_state(const char * label);// aggiunge uno stato - TR_automa & set_final(int statenum,bool v=TRUE); // pone lo stato come finale - - bool is_deterministic() {return _isdeterministic;}; // - bool recognized(const char * s); // tenta di riconoscere la stringa passata - - TR_automa(TR_automa *a=NULL,bool makedet=FALSE); // duplica un automa (e lo rende deterministico) - ~TR_automa(); - static void set2label(const TStateset ss,TString16 & label); - static void label2set(const TString16 & label,TStateset & ss); - -}; - - -// ******************************* -// ******************************* -// riconoscimento di metacaratteri -class TMetachar { - TR_automa * _au; - TString _language; - char _metach_mand[10]; - char _metach_opz[10]; - - void set_language(const char * language); // setta l'automa che ricosce il linguaggio passato - void add_tran(int statenum,unsigned char symbol,int next);// aggiunge le transizioni all'automa -public: - const char * language() const; // restituisce la stringa di metacaratteri del linguaggio riconosciuto - bool recognized(const char * pattern); - - bool has_opzchars(const char * pattern); - bool has_mandchars(const char * pattern); - - int maxstrlen(const char * pattern) const; - const char *mand_chars() {return _metach_mand;}; - const char *opz_chars() {return _metach_opz;}; - TMetachar(const char * str); - TMetachar(); - ~TMetachar(); -}; - -// ********************* -// classe che incapsula le causali di magazzino (record della tabella CAU) -typedef enum { - s_giac, - s_acq,s_ent, - s_ven,s_usc, - s_ordc,s_ordf, - s_acl,s_incl, - s_prodc,s_prodf, - s_rim, - s_scart, - s_label -} TTipo_saldomag; - -class TCausale_magazzino : public TRectype { -public: - const char * get_descr() {return get("S0");} - const char get_tipoprz() {return get_char("S6");} - const char get_tipomov() {return get_char("S7");} - const char * get_raggfisc() {return get("S8");} - int sgn(TTipo_saldomag fieldname) ; - TCausale_magazzino(const char * codice); - ~TCausale_magazzino(); -}; - - - -class TLine_movmag ; // convenience... - -// dati della linea di movimento di magazzino -class TLine_movmag : public TObject { -public: - TString16 um; - real quant; - real prezzo; - int operator==(TLine_movmag &); - - virtual TObject* dup() const {return new TLine_movmag(*this);}; - - TLine_movmag() {}; - TLine_movmag(const TLine_movmag &); - virtual ~TLine_movmag() {}; -}; - - -bool lock_anamag(const char *codart); -bool unlock_anamag(const char *codart) ; - -// classe per la definizione dei movimenti di magazzino -// ( un movimento (testata+righe) == un oggetto TMov_mag ) -class TMov_mag : public THead_lines_record { - - // - TString16 _codcaus; - TString16 _annoes; - // - TString16 _nextcod; - // - TAssoc_array lines_to_add; - TAssoc_array lines_to_subtract; - -protected: - virtual void copy_linekey(const TRectype & headrecord, TRectype & linesrecord ); - virtual long renum(long numdoc=-1); // rinumerazione ; - - // ************ gestione saldi - // @member: compone le parti chiave + dati a partire dalla riga dello sheet - void line2key_data(int numriga, TToken_string &key,TLine_movmag &rest) const; - // @member: compone la chiave a partire dalla riga dello sheet - TToken_string line2key(int numriga) const; - // @member: compone la dati a partire dalla riga dello sheet - TLine_movmag line2data(int numriga) const; - // @member: estrae dalla Tokenstring della chiave i valori corrispondenti ai campi del file - static TString key2field(TToken_string &key,const char * f); - // @member: memorizza la linea come "da togliere" - int delete_line(TToken_string &key,TLine_movmag &rest); - // @member: memorizza la linea come "da aggiungere" - int insert_line(TToken_string &key,TLine_movmag &rest); - // @member: effettua l'aggiornamento dei saldi relativi alle giacenze interessate al movimento - int update_balances() const; - // @member: effettua l'aggiornamento dei saldi di una giacenza - int update_balances(TRectype & magrec, const TLine_movmag &l,TString16 codcaus,int sign) const; - // @member: effettua l'aggiornamento di un saldo di una giacenza - void update_balance(TRectype & magrec, const char * fieldname, real diff) const; - - static void giac_putkey(TLocalisamfile & mag,TString16 annoes,TToken_string curr_key); - static bool lock_anamag(const char *codart); - static bool unlock_anamag(const char *codart) ; - -public: -// IO ad alto livello - virtual const char *get_next_key() ; - virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock); - virtual int remove(TBaseisamfile& f) const ; - virtual int write(TBaseisamfile& f) const ; - virtual int rewrite(TBaseisamfile& f) const ; - int force_update_bal(); - - // - int codice_esercizio(TDate &d); - // costruttori e distruttori - TMov_mag(); - virtual ~TMov_mag(); - -}; - -bool rebuild_balances(TString16 annoes, bool reset_giac=FALSE); - -#endif //__MGLIB_H diff --git a/mg/mglib02.h b/mg/mglib02.h deleted file mode 100755 index 431f5c45f..000000000 --- a/mg/mglib02.h +++ /dev/null @@ -1,233 +0,0 @@ -// ******************************* -// LIBRERIA di magazzino per le valorizzazioni e le chiusure -// ******************************* -#ifndef __MGLIB02_H -#define __MGLIB02_H - -#ifndef __RELATION_H -#include -#endif - -#ifndef __RECARRAY_H -#include -#endif - -#ifndef __VARREC_H -#include -#endif - -#ifndef __MSKSHEET_H -#include -#endif - -#ifndef __ANAMAG_H -#include "anamag.h" -#endif - -#ifndef __UMART_H -#include "umart.h" -#endif - -#ifndef __CODCORR_H -#include "codcorr.h" -#endif - -#ifndef __DESLIN_H -#include "deslin.h" -#endif - -#ifndef __MAG_H -#include "mag.h" -#endif - -#ifndef __STOMAG_H -#include "stomag.h" -#endif -class TMultiple_rectype ; -//************************************** -// classe per il controllo dei record composti da una testata e N file di righe -// è implementato come un TRectype che contiene anche un TRecord_array -// -class TMultiple_rectype : public TAuto_variable_rectype -{ - enum { maxfiles = 20}; - // @ cmember Array di TRecord array per le righe - TArray _files; // - // @ cmember flag indicatore di record nuovo - bool _nuovo; - // @ cmember numero di file righe - short _nfiles; - // @ cmember file delle righe - int _logicnums[maxfiles]; - // @ cmember Array di nomi di campo "numeratore" delle righe - TString_array _numfields; - - -protected: - const TArray & files() const { return _files;} - // @ cmember funzione per costruire la chiave delle righe - virtual void set_body_key(TRectype & rowrec) pure; - // @ cmember renumber la chiave del corpo - virtual long renum(long numdoc = -1) { return -1; } - virtual TRectype & get_body_record(int logicnum = 0) { return *(new TRectype(logicnum ? logicnum : _logicnums[0])); } - virtual void load_rows_file(int logicnum); - // @cmember Ritorna l'indice di

del numero logico passato - int log2ind(int logicnum) const; - virtual int find(int logicnum, const char * fieldname, const char * s, int from = 0, bool reverse = FALSE) const ; - virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const; - void remove_body(int logicnum); - -public: - //*********************** - // struttura - // @ cmember restituisce il record di testata - const TAuto_variable_rectype& head() const { return *this; } // Ritorna la testata del documento - // @ cmember restituisce il record di testata - TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento - - - // @ cmember restituisce il record array del corpo - TRecord_array & body(int logicnum = 0) const; - // @ cmember restituisce il numero di record nel corpo - int rows(int logicnum = 0) const { return body(logicnum).rows(); } - - // @ cmember restituisce il record n-esimo del del corpo - virtual const TRecord_array & operator[](int logicnum) const { return (const TRecord_array &)((TMultiple_rectype *)this)->body(logicnum); } - // @ cmember restituisce il record n-esimo del del corpo - virtual TRecord_array & operator[](int logicnum) { return (TRecord_array &)body(logicnum); } - - bool destroy_row(int n, bool pack = FALSE, int logicnum = 0) { return body(logicnum).destroy_row(n, pack); } - void destroy_rows(int logicnum = 0) { body(logicnum).destroy_rows(); } - - //*********************** - // record e I/O - virtual void dirty_fields() {} - virtual void set_fields(TAuto_variable_rectype & rec) {} - virtual void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); } - - virtual void renum_key(const char * kfield,const char * val); - virtual TRectype & operator =(const TRectype & r); - virtual TRectype & operator =(const char * r); - virtual void zero(char c = '\0'); - - virtual int read(TRectype & rec, word op = _isequal, word lockop = _nolock); - virtual int read(word op = _isequal, word lockop = _nolock) { return read(*this, op, lockop); } - int read(TBaseisamfile & f, word op = _isequal, word lockop = _nolock) { return read(f.curr(), op, lockop); } - - virtual int write(TBaseisamfile& f) const - { return write_rewrite(f);} - virtual int rewrite(TBaseisamfile& f) const - { return write_rewrite(f,TRUE);} - virtual int remove(TBaseisamfile& f) const; - - int write() const { TBaseisamfile f(num()); return write(f);} - int rewrite() const { TBaseisamfile f(num()); return rewrite(f);} - int remove() const { TBaseisamfile f(num()); return remove(f);} - - - void add_file(int logicnum, const char * numfield); - //************************** - // @ cmember costruttore dal numero del file - TMultiple_rectype(int hfn); - // @ cmember costruttore dal file - TMultiple_rectype(const TBaseisamfile* file); - // @ cmember costruttore dal record - TMultiple_rectype(const TRectype & rec); - // @ cmember costruttore di copia - TMultiple_rectype(const TMultiple_rectype& r); - virtual ~TMultiple_rectype() {} -}; - -char * TNome_valorizz[]; - -typedef enum { - valorizz_ultcos , valorizz_mediacos , valorizz_przlist , - valorizz_coststd , valorizz_costmedio , - valorizz_FIFOa , valorizz_LIFOa , - valorizz_FIFO , valorizz_LIFO, - valorizz_FIFOr , valorizz_LIFOr -} TTipo_valorizz; - -class TArticolo : public TMultiple_rectype -{ - TRecfield * _codice; - -protected: - virtual const TString & get_str(const char* fieldname) const ; - virtual void set_body_key(TRectype & rowrec); - -public: - - virtual int read(const char * cod, word op = _isequal, word lockop = _nolock); - virtual int read(TRectype & rec, word op = _isequal, word lockop = _nolock) { return read( rec.get(ANAMAG_CODART), op, lockop); } - - TObject* dup() const { return new TArticolo(codice()); } - - const TString codice() const { return (const char *) *_codice;} - const TString& descrizione(const char * lingua = NULL) const; - - bool unlock() ; - bool lock_and_prompt() ; - void update_ultcosti(real costo,TDate data) ; - - int find_um(const char * um, int from = 0) const { return find(LF_UMART, UMART_UM, um, from); } - int find_deslin(const char * deslin, int from = 0) const { return find(LF_DESLIN, DESLIN_CODLIN, deslin, from); } - int find_codcorr(const char * codcorr, int from = 0) const { return find(LF_CODCORR, CODCORR_CODARTALT, codcorr, from); } - TRecord_array & um() const { return body(LF_UMART); } - TRecord_array & deslin() const { return body(LF_DESLIN); } - TRecord_array & codcorr() const { return body(LF_CODCORR); } - - TArticolo(const char* codice = NULL); - TArticolo(const TRectype& rec); - virtual ~TArticolo(); -}; - -class TArticolo_giacenza : public TArticolo -{ - TString16 _anno_mag; - TString16 _anno_sto; - -protected: - virtual const TString & get_str(const char* fieldname) const ; - virtual void set_body_key(TRectype & rowrec); - void set_anno_mag (const char * anno = NULL); - void set_anno_sto (const char * anno = NULL); - void reset_anno_mag () { set_anno_mag();} - void reset_anno_sto () { set_anno_sto();} - -public: - - TObject* dup() const { return new TArticolo_giacenza(codice()); } - virtual void zero(char c = '\0'); - - int find_mag(const char * annoes, const char * codmag = NULL, const char * livello = NULL, int from = 0) const ; - int find_storico(const char * annoesrif, const char * annoes = NULL, int from = 0) const; - TRecord_array & mag(const char * annoes) const; - TRecord_array & storico(const char * annoesrif) const; - - real ultimo_costo(const char * annoes) const; - real media_costi(const char * annoes) const; - real prezzo_listino(const char * annoes, const char * catven ,const char * codlist) const; - real costo_standard(const char * annoes) const; - real costo_medio(const char * annoes, const char * codmag, const char * livello) const; - real LIFO_annuale(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - real FIFO_annuale(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - real LIFO(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - real FIFO(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - real LIFO_ragionieristico(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - real FIFO_ragionieristico(const char * annoes, const char * codmag, const char * livello, - bool giacenza_effettiva = TRUE, bool valorizza_componenti = TRUE) const; - - TArticolo_giacenza(const char* codice = NULL); - TArticolo_giacenza(const TRectype& rec); - virtual ~TArticolo_giacenza() {} -}; - -#endif - -