From 53330f618f44c3bbf6b40cf27e7a6c6f967ad6a8 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 11 Jul 2006 15:45:54 +0000 Subject: [PATCH] Patch level : 4.0 451 Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 650 git-svn-id: svn://10.65.10.50/trunk@14160 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/velib.h | 988 ------------------------------------------------ ve/velib06.cpp | 23 -- ve/velib06a.cpp | 337 ----------------- 3 files changed, 1348 deletions(-) diff --git a/ve/velib.h b/ve/velib.h index c2f0e2368..50f47637f 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -139,9 +139,6 @@ public: TSpesa_prest(const char* codice = NULL, char tipo = 'S'); TSpesa_prest(const TRectype& rec); virtual ~TSpesa_prest() {} -======= - ->>>>>>> 1.67.2.32 }; class TExpr_documento : public TExpression // velib01 @@ -155,27 +152,7 @@ protected: public: // @cmember Duplica l'espressione -<<<<<<< velib.h virtual TObject* dup() const; -======= - virtual TObject* dup() const; - - // @cmember Assegna il documento corrente - void set_doc(TDocumento* doc) { _doc = doc; } - // @cmember Assegna il documento corrente - void set_row(TRiga_documento* row) { _row = row; } - // @cmember Costruttore (assegna l'estressione e il suo tipo) - TExpr_documento(const char* expression, TTypeexp type = _numexpr, - TDocumento* doc = NULL, TRiga_documento * row = NULL); - // @cmember Costruttore (assegna il tipo dell'istruzione) - TExpr_documento(TTypeexp type = _numexpr, - TDocumento* doc = NULL, TRiga_documento* row = NULL) - : TExpression(type, true), _doc(doc), _row(row) {} - // @cmember Costruttore di copia - TExpr_documento(const TExpr_documento & expr) - : TExpression(expr), _doc(expr._doc), _row(expr._row) {} ->>>>>>> 1.67.2.32 - // @cmember Assegna il documento corrente void set_doc(TDocumento* doc) { _doc = doc; } // @cmember Assegna il documento corrente @@ -197,182 +174,32 @@ public: enum TTipo_formula { _documento, _riga }; -<<<<<<< velib.h class TFormula_documento : public TRectype // velib01 { TString4 _tab; TExpr_documento* _expr; -======= -class TFormula_documento : public TRectype // velib01 -{ - TExpr_documento * _expr; - ->>>>>>> 1.67.2.32 protected: int read(const char* codice, const char* expr = NULL, bool numexpr = true); public: -<<<<<<< velib.h TObject* dup() const { return new TFormula_documento(_tab == "%FRD" ? _documento : _riga, codice(), NULL, true); } -======= - virtual TObject* dup() const; ->>>>>>> 1.67.2.32 public: const TString& codice() const { return get("CODTAB");} const TString& name() const { return codice();} TExpr_documento* expr() const { return _expr;} -<<<<<<< velib.h const TString& descrizione() const { return get("S0"); } const TString& expr_string() const { return get("S1"); } TTypeexp expr_type() const { return get_bool("B0") ? _numexpr : _strexpr;} -======= -class TTipo_documento : public TRectype // velib03 -{ - enum { _altro, _bolla, _fattura, _ordine}; - - static TAssoc_array _formule_documento; - TToken_string _formule; - TString_array _keys_descrs; // Tipi riga per listbox - TString_array _defaults; // Defaults per i campi della maschera - TString_array _sheet_columns; // Colonne dello spreadsheet - TString_array _handlers; // Handlers - TString16 _imponibile; - TString16 _totale; - TString16 _totale_netto; - TString16 _basesconto; - TString16 _spese; - TString16 _totprovv; - TString16 _valore; - TString16 _totvalres; - TString16 _totvalore; - TString16 _totale_cont; - TString16 _field_prezzo; - TString16 _field_qta, _field_qtaevasa; // Veri campi Quantità e Quantità Evasa - TString _str_desc_doc, _str_desc_rdoc; - char _tipocf; - char _check_qta; - bool _cnt_prezzi, _show_evaded_lines; - - -protected: - void add_formula_if_needed(TConfig& profile, TString& variable, const char* varname, const char* formula); - void read_formule(); - int read(const char* tipodoc); - -public: - TObject* dup() const { return new TTipo_documento(codice()); } ->>>>>>> 1.67.2.32 - -<<<<<<< velib.h TFormula_documento(TTipo_formula tipo = _documento, const char* codice = NULL, const char* expr = NULL, bool numexpr = true); TFormula_documento(const TRectype& rec); virtual ~TFormula_documento(); -======= -public: -// const TString& profile_name() const { return get("S4"); } - const TFilename& profile_name(TFilename& name) const; - - // Funzioni che effettuano la cache di importanti valori contenuti nel profilo - const char tipocf() const; - void set_defaults(TMask& m) const; - const TString_array& keys_descrs(); - const TString_array& sheet_columns(); - const TString_array& handlers(); - - const TString& mask_name() const { return get("S4");} - const TString& causale() const { return get("S6"); } - int tipo() const { return get_int("I1"); } - const TString& codice() const { return get("CODTAB");} - - bool is_generic() const { return tipo() == _altro; } - bool is_fattura() const { return tipo() == _fattura; } - bool is_bolla() const { return tipo() == _bolla; } - bool is_ordine() const { return tipo() == _ordine; } - bool controllo_prezzi() const { return _cnt_prezzi; } - const char * field_prezzo() const { return _field_prezzo; } - const TString& field_qta() const { return _field_qta; } - const TString& field_qtaevasa() const { return _field_qtaevasa; } - bool check_giac() const { return _check_qta == 'G'; } - bool check_disp() const { return _check_qta == 'D'; } - - - const TString & descrizione() const { return get("S0"); } - const TString & riferimento(const TDocumento& doc, TString& rif) const; - const TString & imponibile() const { return _imponibile;} - const TString & totale_doc() const { return _totale;} - const TString & totale_netto() const { return _totale_netto; } - const TString & totale_doc_cont() const { return _totale_cont;} - const TString & basesconto() const { return _basesconto;} - const TString & spese() const { return _spese;} - const TString & totprovv() const { return _totprovv;} - const TString & valore() const { return _valore;} - const TString & totvalres() const { return _totvalres;} - const TString & totvalore() const { return _totvalore;} - bool mov_mag() const { return get_bool("B1"); } - bool statistiche() const { return get_bool("B2"); } - bool provvigioni() const { return get_bool("B3"); } - const char stato_mov_iniziale() const {return get_char("S7"); } - const char stato_mov_finale() const {return get_char("S8"); } - const char stato_provvigioni() const {return get_char("S3"); } - const TString & caus_mov() const {return get("S9"); } - const TString & caus_anticipo() const {return get("S10"); } - const TString & tipi_iva_validi() const {return get("S11"); } - const char stato_finale_inserimento() const {return get("S2")[0]; } - const char stato_finale_stampa() const {return get("S2")[1]; } - const char stato_bloccato() const {return get("S2")[2]; } - const TString & stati_iniziali_modifica() const {return get("S2").mid(9,20); } - const TString & stati_iniziali_cancellazione() const {return get("S2").mid(29,20); } - const TString & stati_iniziali_stampa() const {return get("S2").mid(49,20); } - bool stato_with_mov_mag(const char stato) const; - bool scarica_residuo() const; - bool clifo_optional() const { return get_bool("B5"); } - bool printable() const { return !get("S5").empty(); } - const TString& main_print_profile() const { return get("S5").left(8); } - const TString& additional_print_profile() const { return get("S5").mid(8); } - - TFormula_documento * first_formula() { return succ_formula(TRUE); } - TFormula_documento * succ_formula(bool restart = FALSE); - - const int ncopie() const { return get_int("I0"); } - const int additional_ncopie() const { return get_int("I2"); } - bool spese_aut() const { return get_bool("B0"); } - bool nota_credito() const { return get_bool("B7"); } - bool add_conai() const { return get_bool("B6"); } - bool calcolo_lordo() const { return get_bool("B8"); } - bool fattura_commerciale() const { return get_bool("B9"); } - bool allega_documenti() const { return get_bool("B10"); } - - const TString& stringa_descrizione_documento() const { return _str_desc_doc; } - const TString& stringa_descrizione_riga() const { return _str_desc_rdoc; } - bool mostra_righe_evase_in_elaborazione() const { return _show_evaded_lines; } - - TTipo_documento(const char* tipodoc = NULL); - TTipo_documento(const TRectype& rec); - virtual ~TTipo_documento(); ->>>>>>> 1.67.2.32 }; -<<<<<<< velib.h class TTipo_documento : public TRectype // velib03 -======= - -class TTipi_documento_cache : public TRecord_cache -{ -protected: - virtual TObject* rec2obj(const TRectype& rec) const; - -public: - TTipo_documento& tipo(const char* key); - TTipi_documento_cache(); - virtual ~TTipi_documento_cache() { } -}; - -class TCodice_numerazione : public TRectype ->>>>>>> 1.67.2.32 { static TAssoc_array _formule_documento; TToken_string _formule; @@ -492,211 +319,25 @@ public: TTipo_documento(const TRectype& rec); virtual ~TTipo_documento(); -<<<<<<< velib.h -======= -public: - int read(const char* cod); - const TString& codice() const { return get("CODTAB"); } - const TString& descrizione() const { return get("S0"); } - const TString& prefisso() const { return get("S6"); } - const TString& postfisso() const { return get("S7"); } - const bool num_provv() const { return get_bool("B0"); } - const bool auto_num() const { return get_bool("B1"); } - const bool dont_test_datadoc() const { return get_bool("B2"); } - const bool fattura_emettere_ricevere() const { return get_bool("B3"); } - const bool save_and_new() const { return get_bool("B4"); } - const bool test_eser() const { return ! get_bool("B5"); } - - const TString & tipo_doc(int i) const; - int ntipi_doc() const; - - void complete_num(long num, TString& codnum) const; - bool ok() const { return !empty(); } - TCodice_numerazione(const char* codnum = NULL); - TCodice_numerazione(const TRectype& rec); - virtual ~TCodice_numerazione(); ->>>>>>> 1.67.2.32 }; -<<<<<<< velib.h class TTipi_documento_cache : public TRecord_cache { -======= -class TTipo_riga_documento : public TRectype // velib02 -{ - static TAssoc_array _formule_riga; - TToken_string _formule; - TString_array _defaults; - - TString16 _imponibile, _field_imposta; - TString16 _quant, _quantevasa, _qtares; - TString16 _valore, _valres; - - TString16 _field_provv; - TString16 _field_qta, _field_qtaevasa; // Veri campi Quantità e Quantità Evasa - TToken_string _search_nums; - int _search_years; - int _max_rows_art; - bool _no_desc; - - int _decrp, _incrp; - - ->>>>>>> 1.67.2.32 protected: virtual TObject* rec2obj(const TRectype& rec) const; public: -<<<<<<< velib.h TTipo_documento& tipo(const char* key); TTipi_documento_cache(); virtual ~TTipi_documento_cache() { } -======= - TObject* dup() const { return new TTipo_riga_documento(codice()); } - -public: - const TFilename& profile_name(TFilename& name) const; - const TString& mask_name(TString& name) const; - const TString& codice() const { return get("CODTAB");} - - const TString& descrizione() const { return get("S0"); } - char tipo() const { return get_char("S7"); } - bool has_formula(const char * name) { return _formule.get_pos(name) >= 0; } - - const TString& imponibile() const { return _imponibile;} - const TString& imposta() const { return _field_imposta;} - const TString& quant() const { return _quant;} - const TString& quantevasa() const { return _quantevasa;} - const TString& field_qta() const { return _field_qta;} - const TString& field_qtaevasa() const { return _field_qtaevasa;} - TToken_string& search_nums() { return _search_nums;} - int max_rows_art() const { return _max_rows_art;} - int search_years() const { return _search_years;} - bool no_desc() const { return _no_desc;} - - const TString& provv() const { return _field_provv;} - const int incr_perc_prezzo() const { return _incrp;} - const int decr_perc_prezzo() const { return _decrp;} - - bool formfeed() const { return get_bool("B0"); } - int detraibilita() const { return get_int("I0"); } - real perc_indetraibilita() const { return get_real("R0"); } - - TFormula_documento* first_formula() { return succ_formula(TRUE); } - TFormula_documento* succ_formula(bool restart = FALSE); - - int read(const char* tiporig); - void set_defaults(TSheet_field& s, int row) const; - - TTipo_riga_documento(const char* tiporig = NULL); - TTipo_riga_documento(const TRectype& rec); - virtual ~TTipo_riga_documento() { } ->>>>>>> 1.67.2.32 }; class TCodice_numerazione : public TRectype { int _status; -<<<<<<< velib.h public: TObject* dup() const { return new TCodice_numerazione(*this); } -======= -protected: - // @cmember Setta il contenuto del campo

(non tipizzata) - virtual void put_str(const char* fieldname, const char* val); - - virtual TRiga_documento & copy(const TRiga_documento & r); - virtual TObject* dup() const { return new TRiga_documento(*this); } - virtual void set_variables(TExpression * e) const ; - - static void test_firm(); - -public: - void dirty_fields(bool dirty_document = TRUE); - bool doc_dependent() const; - int numero() const { return get_int(RDOC_NRIGA); } - void set_numero(int numero) { put(RDOC_NRIGA, numero);} - bool is_generata() const { return get_bool(RDOC_GENERATA);} - void generata(bool on = TRUE) { put(RDOC_GENERATA, on);} - bool is_merce() const { return tipo().tipo() == 'M';} - bool is_spese() const { return tipo().tipo() == 'S';} - bool is_prestazione() const { return tipo().tipo() == 'P';} - bool is_sconto() const {return tipo().tipo() == 'C';} - bool is_sconto_perc() const { return get(RDOC_SCONTO).not_empty();} - bool is_omaggio() const { return tipo().tipo() == 'O';} - bool is_descrizione() const { return tipo().tipo() == 'D';} - bool is_articolo() const; - bool is_checked() const { return get_bool(RDOC_CHECKED);} - bool is_evadibile() const { return is_merce() || is_omaggio() || is_spese() || is_prestazione(); } - bool is_evasa() const; // Ritorna vero se la riga è evasa - void checked(bool on = TRUE) { put(RDOC_CHECKED, (bool)on); } - void unchecked() { checked(FALSE); } - bool linked() const { return get(RDOC_DACODNUM).not_empty();} - // @cmember Assegna il documento corrente - void set_doc(TDocumento * doc) { _doc = doc; } - const TDocumento & doc() const { CHECK(_doc, "Documento nullo"); return *_doc;} - - virtual void zero(const char * fieldname); - virtual void zero(char c = '\0'); - // row -> sheet - void autoload( TSheet_field& f); - // sheet -> row - void autosave( TSheet_field& f); - - const TTipo_riga_documento & tipo() const; - const TSpesa_prest & spesa() const; - static const TCodiceIVA & iva(const char * codice); - const TCodiceIVA & iva() const {const TString4 cod(get(RDOC_CODIVA)); return iva(cod);} - - const bool tipo_valido() const { return get(RDOC_TIPORIGA).not_empty(); } - void set_tipo(const char * tipo) { put(RDOC_TIPORIGA, tipo);} - bool sola_descrizione() const; - void forza_sola_descrizione(); - - void set_original_rdoc_key(const TRectype& orig, int depth = 0); - void reset_original_rdoc_key(); - const TRectype* find_original_rdoc() const; - const TRectype* find_original_doc() const; - - virtual TRiga_documento& operator =(const TRiga_documento& r) { return copy(r);} - virtual TRectype& operator =(const TRectype & r); - virtual TRectype& operator =(const char * r); - - bool raggruppabile(const TRiga_documento& r, TToken_string& campi) const; - TRiga_documento& operator +=(const TRiga_documento& r); - - void reset_fields(TAuto_variable_rectype& rec) { rec.remove_field(); } - void set_fields(TAuto_variable_rectype& rec); - - real prezzo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const ; - real importo(bool scontato , bool lordo, int ndec = AUTO_DECIMALS) const ; - real sconto() const { return importo(FALSE,FALSE) - importo(TRUE,FALSE); } - real iva(int ndec) const; - real imponibile(bool lordo = FALSE) const; - real imponibile_omaggio(int iva_calc_mode = 1) const; - real iva_omaggio(int ndec, int iva_calc_mode = 1) const; - real imposta(bool round = TRUE) const; - real provvigione(int ndec = AUTO_DECIMALS) const; - real ritenuta(const char tipor = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const; - - const TString& field_qta() const; - const TString& field_qtaevasa() const; - real quantita() const; - real qtaevasa() const; - real qtaresidua() const; - real valore(bool totale, int ndec) const; - const TString & codice_commessa() const; - const TString & fase_commessa() const; - TArticolo_giacenza * articolo() const; - - TRiga_documento(TDocumento* doc, const char* tipo = NULL); - TRiga_documento(const TRiga_documento & row); - TRiga_documento(const TRiga_documento& rec, TDocumento* doc, - const char* tipo = NULL); - virtual ~TRiga_documento() {} -}; ->>>>>>> 1.67.2.32 public: int read(const char* cod); @@ -711,189 +352,8 @@ public: const bool save_and_new() const { return get_bool("B4"); } const bool test_eser() const { return !get_bool("B5"); } -<<<<<<< velib.h const TString& tipo_doc(int i) const; int ntipi_doc() const; -======= -class TDocumento : public TMultiple_rectype // velib03 -{ - TRecfield *_tipocf; - TRecfield *_codcf; - TRecfield *_cod_occas; - char _stato_originale; - - TCli_for _cli_for; - TOccasionale _occas; - TPagamento _pag; - TAssoc_array _tabella_iva; // tabella di imponibili ed imposte - - TProvvigioni_agente* _provv_agente; - TString16 _old_agente; // Agente originale - - TRiga_documento * _sconto; // Riga per lo sconto di testata - TRiga_documento * _esenzione; // Riga per l' esenzione iva - - bool _dirty_deny; - - static TAssoc_array _tipi; - static TAssoc_array _numerazioni; - static long _firm; - static TString4 _codiva_spese; - static TString4 _codiva_bolli; - static short _has_mag; - static short _has_stat_ven; - static short _has_provv; - static TCodgiac_livelli *_livelli; - -protected: - virtual TRectype * new_body_record(int logicnum = 0) - { return new TRiga_documento(this); } - - TRiga_documento & row(int index); - const TRiga_documento& physical_row(int index) const; - - long get_next_key(char provv, int anno, const char* codnum) const; - virtual void put_str(const char* fieldname, const char* val); - virtual const TString & get_str(const char* fieldname) const ; - - virtual bool key_complete() { return numero() > 0; } - void set_riga_sconto(); - int write_rewrite(TBaseisamfile & f, bool re) const; - virtual TDocumento & copy(const TDocumento & d); - virtual TObject* dup() const { return new TDocumento(*this); } - void calc_iva_fattura_commerciale(); - void update_tabella_iva(); - void dirty_tabella_iva() { _tabella_iva.destroy();} - static void test_firm(); - - void init(); - void check_modules(); - virtual void set_variables(TExpression * e) const ; - int set_row_ids(); - -public: - long renum_ndoc(long numdoc = 0); - virtual bool renum() { return renum_ndoc() > 0;} - const TString& codiva_spese() const ; - const TString& codiva_bolli() const ; - - TCodgiac_livelli & livelli() const ; - void dirty_fields(); - - TAssoc_array & tabella_iva() { update_tabella_iva(); return _tabella_iva; } - TCli_for & clifor() const; - TOccasionale & occas() const; - const TAgente & agente() const; - const TString & riferimento(TString& rif) const { return tipo().riferimento(*this, rif); } - - virtual TRecord_array& body(int logicnum = 0) const; - virtual TDocumento & operator =(const TDocumento & d) {return copy(d);} - virtual TRectype & operator =(const TRectype & r); - virtual TRectype & operator =(const char * r); - virtual void zero(const char * fieldname); - virtual void zero(char c = '\0') { TMultiple_rectype::zero(c); } - - int physical_rows() const { return body().rows(); } - int rows() const { return physical_rows() + ((_sconto != NULL) ? 1 : 0) + ((_esenzione != NULL) ? 1 : 0); } - const TRiga_documento& operator[](int index) const { return (const TRiga_documento&)((TDocumento *)this)->row(index); } - TRiga_documento& operator[](int index) { return (TRiga_documento&)row(index); } - const TRiga_documento* get_row_id(long id) const; - - TRiga_documento& insert_row(int row, const char *tipo = NULL); - TRiga_documento& new_row(const char *tipo = NULL); - virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock); - virtual int write(TBaseisamfile& f) const { return write_rewrite(f, FALSE); } - virtual int rewrite(TBaseisamfile& f) const { return write_rewrite(f, TRUE); } - virtual int remove(TBaseisamfile& f) const; - - int read(char provv, int anno, const char* codnum, long numdoc, word op = _isequal, word lockop = _nolock); - int read(const TRectype& rec, word op = _isequal, word lockop = _nolock) { *this = rec; return read(op, lockop); } - int read(word op = _isequal, word lockop = _nolock) { TLocalisamfile f(LF_DOC); return read(f, op, lockop);} - - int write(bool re = FALSE) const { TLocalisamfile f(LF_DOC); return write_rewrite(f, re);} - int rewrite() const { return write(TRUE); } - int remove() const { TLocalisamfile f(LF_DOC); return remove(f);} - int decimals(bool price = FALSE) const; - - void flush_rows(); - - TProvvigioni_agente& calc_provvigioni(const bool generata = TRUE); - int write_provvigioni() { return calc_provvigioni().write();} - - char tipo_numerazione() const { return get_char("PROVV"); } - int anno() const { return get_int("ANNO"); } - const TString& numerazione() const { return get("CODNUM"); } - long numero() const { return get_long("NDOC"); } - TDate data() const { return get_date("DATADOC"); } - bool in_valuta() const; - const TString& valuta() const { return get("CODVAL"); } - real cambio() const { return get_real("CAMBIO"); } - bool tipo_valido() const { return get("TIPODOC").not_empty(); } - static const TTipo_documento& tipo(const char * tipodoc); - const TTipo_documento& tipo() 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'; } - char stato() const { return get_char("STATO"); } - void stato(char s) { put("STATO", s); } - const TString & codice_commessa() const { return get(DOC_CODCMS);} - const TString & fase_commessa() const { return get(DOC_FASCMS);} - bool modificabile() const; - bool cancellabile() const; - bool stampabile() const; - bool bloccato() const; - - bool raggruppabile() const { return get_bool("RAGGR"); } - bool raggruppabile(const TDocumento& doc, TToken_string& campi) const; - - char tipocf() const {return *(const char *) (*_tipocf);} - long codcf() const {return (long) *_codcf;} - const char * cod_occas() const { return (const char *) *_cod_occas; } - - static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc); - static void copy_data(TRectype& dst, const TRectype& src); - static void copy_data(TRiga_documento& dst, const TRiga_documento& src); - void copy_contents(const TDocumento & src, bool copy_header = true); - - void set_fields(TAuto_variable_rectype & rec); - void set_riga_esenzione(); - - void iva_esente(TString & codiva_es) const; - real spese_incasso(int ndec, TTipo_importo netto = _lordo) const ; - real bolli(real & imp, int ndec, TTipo_importo netto = _lordo) const ; - - real imponibile(bool spese = FALSE, int ndec = AUTO_DECIMALS) const; - real imposta(bool spese = FALSE, int ndec = AUTO_DECIMALS) const; - real totale_doc() const; - real totale_netto() const; - real basesconto() const; - real spese() const; - real ritenute(const char tipo = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const; - real provvigione(int ndec = AUTO_DECIMALS) const; - real valore(bool totale, int ndec = AUTO_DECIMALS) const; - - TPagamento & pagamento(); - - void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL); - real calc_conai_qta(int type); - void update_conai(); - - bool is_generic() const { return tipo_valido() && tipo().is_generic(); } - bool is_fattura() const { return tipo_valido() && tipo().is_fattura(); } - bool is_bolla() const { return tipo_valido() && tipo().is_bolla(); } - bool is_ordine() const { return tipo_valido() && tipo().is_ordine(); } - bool is_evaso() const; - bool is_nota_credito() const; - - TDocumento (); - TDocumento (const TDocumento & d); - TDocumento(char provv, int anno, const char* codnum, long numdoc); - TDocumento(const TRectype& doc); - virtual ~TDocumento(); - }; ->>>>>>> 1.67.2.32 - void complete_num(long num, TString& codnum) const; bool ok() const { return !empty(); } @@ -905,69 +365,19 @@ public: class TTipo_riga_documento : public TRectype // velib02 { -<<<<<<< velib.h static TAssoc_array _formule_riga; TToken_string _formule; TString_array _defaults; -======= - int _progs_page; // pagina in cui cominciano i progressivi - TSheet_field* _sheet; // Spreadsheet - TDocumento _doc; // documento - TCodgiac_livelli * _livelli_giac;// livelli di giacenza - - TCond_vendita* _condv; // condizioni di vendita - TAssoc_array _maskriga;// Maschere delle righe - TPointer_array _handlers; - TBit_array _calculated_pages; ->>>>>>> 1.67.2.32 -<<<<<<< velib.h TString16 _imponibile, _field_imposta; TString16 _quant; TString16 _quantevasa; TString16 _qtares; TString16 _valore; TString16 _valres; -======= - bool _ges_mag, _ges_dep; - TString _std_mag, _std_dep; - TSmart_card * _smartcard; ->>>>>>> 1.67.2.32 -<<<<<<< velib.h TString16 _field_provv; TString16 _field_qta, _field_qtaevasa; // Veri campi Quantità e Quantità Evasa -======= -protected: - void update_progs(bool stop_run = false); - virtual void next_page(int p); - virtual void start_run(); - virtual bool stop_run(KEY key); - void sconto_testa2mask(); - void spese2mask(); - - void configura_sheet(TSheet_field& sheet); - static bool ss_notify(TSheet_field& ss, int r, KEY key); - static bool ss_handler(TMask_field& f, KEY key); - static TMask* ss_getmask(int numriga, TMask& fullmask); - - void set_field_handler(short fieldid, CONTROL_HANDLER handler); - bool call_handler( TMask_field& f, KEY key); - - static bool universal_handler( TMask_field& f, KEY key); - static bool occas_handler( TMask_field& f, KEY key ); - static bool occas_code_handler( TMask_field& f, KEY key ); - static bool clifo_handler( TMask_field& f, KEY key ); - static bool print_handler( TMask_field& f, KEY key ); - static bool elabora_handler( TMask_field& f, KEY key ); - static bool codlist_handler( TMask_field& f, KEY key ); - static bool codcont_handler( TMask_field& f, KEY key ); - static bool codcamp_handler( TMask_field& f, KEY key ); -// static bool controeuro_handler( TMask_field& f, KEY key ); - static bool datacambio_handler( TMask_field& f, KEY key ); - static bool codval_handler( TMask_field& f, KEY key ); - void user_set_handler( int fieldid, int index); ->>>>>>> 1.67.2.32 TToken_string _search_nums; int _search_years; @@ -976,45 +386,10 @@ protected: int _decrp, _incrp; -<<<<<<< velib.h protected: void read_formule(); void add_formula_if_needed(TConfig& profile, TString& variable, const char* varname, const char* formula); -======= - TDocumento& doc() { return _doc; } - const TDocumento& doc() const { return _doc; } - TCond_vendita & condv() const; - - void occ2mask(); - void cli2mask(); - void doc2mask(bool reload_clifo = TRUE); - void mask2doc(); - - void update_giacenza(); - - const TString& stdmag() const { return _std_mag; } - const TString& stddep() const { return _std_dep; } - - - TSheet_field& sheet() const { return *_sheet; } - TCodgiac_livelli& livelli() const { return *_livelli_giac; } - static bool anno_handler( TMask_field& f, KEY key); - static bool num_handler( TMask_field& f, KEY key ); - static bool tip_handler( TMask_field& f, KEY key ); - static bool numdocrif_search_handler( TMask_field& f, KEY key ); - static bool ragsoc_search_handler( TMask_field& f, KEY key ); - static bool datadocrif_handler(TMask_field& f, KEY key); - - void highlight(COLOR high_back_color, COLOR high_color); - - bool TDocumento_mask::is_calculated_page(int p) { return _calculated_pages[p]; } - TSmart_card * smartcard() const { return _smartcard;} - - TDocumento_mask(const char* tipodoc); - virtual ~TDocumento_mask(); -}; ->>>>>>> 1.67.2.32 public: TObject* dup() const { return new TTipo_riga_documento(codice()); } @@ -1035,24 +410,9 @@ public: const TString& field_qta() const { return _field_qta;} const TString& field_qtaevasa() const { return _field_qtaevasa;} -<<<<<<< velib.h const int search_years() const { return _search_years;} const TToken_string& search_nums() const { return _search_nums;} const int max_rows_art() const { return _max_rows_art;} -======= -public: - int ordina_per_codice(); - int ordina_per_agente(); - int ordina_per_zona(); - - int leggi(long dc, long ac, long da = 0, long aa = 0, const char * dz = "", const char * az = ""); - int leggi_ragsoc(const char *dr, const char * ar, long da = 0, long aa = 0, const char * dz = "", const char * az = ""); - - long operator[] (int n) const { return clifo(n).codice(); } - int items() const { return _clifo.items(); } - int find(long cod) const; - int add(long cod); ->>>>>>> 1.67.2.32 const TString& provv() const { return _field_provv;} const int incr_perc_prezzo() const { return _incrp;} @@ -1062,23 +422,11 @@ public: int detraibilita() const { return get_int("I0"); } real perc_indetraibilita() const { return get_real("R0"); } -<<<<<<< velib.h TFormula_documento* first_formula() { return succ_formula(true); } TFormula_documento* succ_formula(bool restart = FALSE); int read(const char* tiporig); void set_defaults(TSheet_field& s, int row) const; -======= -class TLista_fornitori : public TLista_clifo -{ -protected: - virtual char tipo() const { return 'F'; } -}; - -enum TTipo_elaborazione { _esterna, _consegna_ordini, _fatturazione_bolle, - _contabilizzazione, _copia_documento, - _generazione_effetti, _consuntivazione_produzione }; ->>>>>>> 1.67.2.32 TTipo_riga_documento(const char* tiporig = NULL); TTipo_riga_documento(const TRectype& rec); @@ -1086,54 +434,7 @@ enum TTipo_elaborazione { _esterna, _consegna_ordini, _fatturazione_bolle, }; -<<<<<<< velib.h class TRiga_documento : public TAuto_variable_rectype // velib02 -======= -public: - enum { _max_tipi_doc_elab = 10 }; - const TString& codice() const { return get("CODTAB"); } - const TString& descrizione() const { return get("S0"); } - const TTipo_elaborazione tipo() const { return (TTipo_elaborazione) get_int("I0"); } - - bool doc_uguale(int u) const { return get("S1")[u] == 'X'; } - bool riga_uguale(int u) const { return get("S1")[40+u] == 'X'; } - - bool raggruppa_righe() const { return get_bool("B0"); } - bool gestione_riferimenti() const { return get_bool("B1"); } - bool riferimenti_in_testa() const { return get_bool("B2"); } - bool ignora_descrizioni() const { return get_bool("B3"); } - bool protocollo_da_registro() const { return get_bool("B4"); } - bool prezzo_da_ordine() const { return get_bool("B5"); } - bool aggiorna_testata_se_vuoto() const { return get_bool("B6"); } - bool ordina_per_codice() const { return get_bool("B7"); } - bool usa_doc_rif() const { return get_bool("B8"); } - bool usa_data_consegna() const { return get_bool("B9"); } - bool kill_descrizione_estesa() const { return get_bool("B10"); } - bool calcola_scarti() const { return get_bool("B11"); } - - int intestazioni_sheet() const { return get_int("I1"); } - - const TString& codice_numerazione_iniziale() const { return get("S5"); } - const TString tipo_iniziale(int i) const { return get("S2").smid(i*4, 4).rtrim(); } - const char stato_iniziale(int i) const { return i < 5 ? get("S7")[i] : get("S10")[i - 5]; } - const TString& tipo_finale() const { return get("S8"); } - const TString& stato_finale_doc_iniziale() const { return get("S4"); } - const TString& stato_finale() const { return get("S9"); } - - const TString& codice_numerazione_finale() const { return get("S6"); } - const TString& applicazione_esterna() const { return get("S3"); } - void set_params(const TParametri_elaborazione & parms) { _parms = parms;} - TParametri_elaborazione & params() { return _parms;} - - virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, - const TDate& data_elab, bool interattivo = FALSE) pure; - - TElaborazione(const char* cod); - TElaborazione(const TRectype& rec) : TRectype(rec) { } - virtual ~TElaborazione() { } -}; ->>>>>>> 1.67.2.32 - { TDocumento* _doc; static long _firm; @@ -1225,7 +526,6 @@ public: real provvigione(int ndec = AUTO_DECIMALS) const; real ritenuta(const char tipor = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const; -<<<<<<< velib.h const TString& field_qta() const; const TString& field_qtaevasa() const; real quantita() const; @@ -1242,25 +542,6 @@ public: TRiga_documento(const TRiga_documento& rec, TDocumento* doc, const char* tipo = NULL); virtual ~TRiga_documento() {} -======= -class TConsegna_ordini : public TElaborazione // velib04d -{ -protected: - bool calcola_ncolli_tara_pnetto(const TString& codart, const real& qta, - real& nolli, real& tara, real& pnetto) const; - bool aggiorna_ncolli_tara_pnetto(TRiga_documento& r) const; - -public: - virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, - const TDate& data_elab, bool interattivo = FALSE); ->>>>>>> 1.67.2.32 - -<<<<<<< velib.h -======= - TConsegna_ordini(const char* cod) : TElaborazione(cod) { } - TConsegna_ordini(const TRectype& rec) : TElaborazione(rec) { } - virtual ~TConsegna_ordini() { } ->>>>>>> 1.67.2.32 }; enum TTipo_importo { _lordo, _netto, _imposta }; @@ -1307,7 +588,6 @@ public: class TAgente ; -<<<<<<< velib.h class TDocumento : public TMultiple_rectype // velib03 { TRecfield *_tipocf; @@ -1466,54 +746,9 @@ public: real ritenute(const char tipo = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const; real provvigione(int ndec = AUTO_DECIMALS) const; real valore(bool totale, int ndec = AUTO_DECIMALS) const; -======= -enum error_type { - no_error, - nr_es_error, - nr_reg_error, - nr_doc_error, - chg_stat_error, - clifo_error, - ultprot_error, - datadoc_error, - caus_error, - causre_error, - cauval_error, - ivasto_error, - register_error, - change_error, - val_error, - codpag_error, - row_type_error, - no_rows_error, - conto_error, - sconto_error, - spinbo_error, - movement_error, - write_error, - scadenze_error, - bank_error, - caus_ant_error, - counter_p_ant_error, - cau_abb_error, - cau_spe_error, - write_part_error, - intra_mov_error, - intra_rett_error, - cont_seq_error, - cau_ritintra_error, - generic_error -}; ->>>>>>> 1.67.2.32 -<<<<<<< velib.h TPagamento & pagamento(); -======= -class TBill; -class TSaldo_agg; ->>>>>>> 1.67.2.32 -<<<<<<< velib.h void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL); real calc_conai_qta(int type); void update_conai(); @@ -1530,203 +765,12 @@ class TSaldo_agg; TDocumento(char provv, int anno, const char* codnum, long numdoc); TDocumento(const TRectype& doc); virtual ~TDocumento(); -======= - -/////////////////////////////////////////////////////////// -// TContabilizzazione -/////////////////////////////////////////////////////////// - -// TMovimentoPN_VE -// Classe derivata da TMovimentoPN per calcolare automaticamente le righe conabili -// una volta settate le righe iva e la riga di totale documento -// Sostanzialmente di tratta di aggiungere un metodo in piu' : -// recalc_cg_rows(), liberamente ispirato alla notify_iva() in cg2102.cpp - -class TMovimentoPN_VE : public TMovimentoPN -{ - bool _valuta; - TCausale * _caus; - -protected: - // simula il K_SPACE di iva_notify - void create_row(int i, const TString & descr_cr); - // simula il K_ENTER di iva_notify - void enter_row(int i, const TString & descr_cr); - // verifica se si tratta di iva indetraibile - bool detraibile(TRectype& rec) const ; - // cerca la prima tra quelle di contabilita' che corrisponde al tipo indicato - int type2pos(char tipo); - // Trova nelle righe contabili un conto nelle righe di tipo prescelto - int bill2pos(const TBill& conto, const TString & codcms, const TString & fascms, char tipo); - // trasforma un real in TImporto, in base al tipo riga - TImporto real2imp(const real& r, char row_type); - // setta il record delle righe di contabilita' - int insert_cg_rec(int n, const TImporto& imp, TBill& conto, const char * codcms, const char * fascms, const char* desc, char tipo); - // setta il record delle righe di contabilita' - int set_cg_rec(int n, const TImporto& imp, TBill& conto, const char * codcms, const char * fascms, const char* desc, char tipo); - // aggiunge l'importo indicato alla n-esima riga di contabilita' - bool add_cg_rec(int n, const TImporto& imp); - // Legge l'importo della riga n e lo ritorna col segno dovuto - TImporto get_cg_imp(int n); - // Setta l'importo della riga n - void set_cg_imp(int n, const TImporto& imp); - -public: - void set_caus(TCausale * c) { _caus = c;} - bool movement_ok() ; - void add_row_re(int i); - bool add_row_cp_re(int i); - void map_conto_re(TBill & c); - void destroy_iva_row(int i = -1); - int recalc_cg_rows(const TString & descr_cr, TCausale & caus); - TMovimentoPN_VE(bool valuta) : _valuta(valuta), _caus(NULL) {}; - virtual ~TMovimentoPN_VE() {} }; -class TContabilizzazione : public TElaborazione // velib04b -{ - bool _auto_data; // Flag per data di registrazione automatica - bool _nump_iva; // se TRUE prende il numero protocollo da registro iva, se no prende il numero protocollo dal numero doc. - TDate _data_reg; // Data di registrazione documenti - long _total_docs;// Numero di documenti contabilizzati - error_type _error; // Errore rilevato durante l'elaborazione - bool _can_write; // se TRUE e' abilitata la scrittura. Non appena rileva un errore rimane a FALSE for this instance - TString16 _spin_cod, // codice iva spese d'incasso - _spbo_cod; // codice iva spese bolli - TAssoc_array _totali_lordi;// array per totalizzare i lordi per aliquota, al fine di aggiustare gli imponibili - // nel caso di calcolo lordo sul documento - TIVA_array *_righe_iva; // array per la memorizzazione delle righe iva raggruppate in codesto modo: - // CODICE_IVA+TIPOCF+GRUPPO+CONTO+SOTTOCONTO+COMMESSA+FASE+DETRAIBILITA - // una volta completo, tale array viene scorso per comporre le righe IVA - // del movimento - - // Files, tabelle, oggetti contabili ed altre amenita'... - TLocalisamfile *_anamag, // file delle anagrafiche di magazzino - *_fcaus, - *_frcaus, - *_attiv, - *_part, - *_scad, - *_pags, - *_intra, - *_rintra, - *_occas, - *_saldi, - *_docfile, - *_rdocfile; - - TTable *_cpg, // tabella condizioni di pagamento - *_gmc, // tabella gruppi/sottogruppi merceologici - *_rfa, // tabella raggruppamenti fiscali - *_cve, // tabella categorie di vendita - *_val, // tabella valute estere - *_prs, // tabella prestazioni - *_spp, // tabella spese - *_caa, // tabella categorie acquisto articoli - *_cra, // tabella categorie ricavo articoli - *_cco; // tabella categorie contabili - TRelation *_clifo; // relazione dei clienti e fornitori + cfven - TViswin* _viswin; // Visualizzazione log di elaborazione - TBill _conto_errato; // Conto da visualizzare in messaggio d'errore - bool _check_prev_cont; // Controllare se il documento precedente e' stato contabilizzato - -protected: - // Carica i parametri dalla configurazione - bool load_parameters(); - // Testa il fatto che il documento sia una nota di credito/debito - bool test_swap(); - // Ritorna l'ultimo numero di registrazione disponibile dei movimenti di prima nota - error_type get_next_reg_num(long &); - // Compila la testata del movimento - error_type compile_head_mov(TDocumento&); - // Compila la testata del movimento per le fatture da emettere / ricevere; - error_type compile_head_mov_re(TDocumento&); - // Funzione per ricercare il conto di costo/ricavo - error_type search_costo_ricavo(TBill&, const TRiga_documento&); - // Funzione per aggiungere la riga iva al TAssoc_array _righe_iva - // error_type add_iva_row(const TBill&, const TRiga_documento&, const int ndec, const real p = 1.0); - // Funzione atomica per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva - void calculate_spese(real&, real&, int, bool, bool, const TString &, const TDocumento & ); - // Funzione per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva (chiama calculate_spese()) - error_type add_spese_inbo(TDocumento&, const int); - // Aggiorna le righe di sconto importo o percentuale - error_type adjust_sconto_rows(TDocumento&); - // Controlla la corrispondenza tra limposta del documento e quelle generate - error_type adjust_iva_rows(TDocumento&); - // Crea le righe iva sul movimento - error_type create_iva_rows(TDocumento&); - // Crea la riga di totale documento - error_type create_total_doc_row(TDocumento&); - // Compila le righe del movimento - error_type compile_rows_mov(TDocumento&); - // Compila le righe del movimento per le fatture da emettere / ricevere - error_type compile_rows_mov_re(TDocumento&); - // scrive le scadenze - error_type write_scadenze(TDocumento&); - // scrive il movimento e le scadenze - virtual error_type write_all(TDocumento& doc, TMovimentoPN_VE & movimento); - // scrive il movimento e le scadenze per le fatture da emettere / ricevere - virtual error_type write_all_re(TDocumento& doc, TMovimentoPN_VE & movimento); - // restituisce la sezione per sto cliente - char sezione() const; - // Cerca il conto cliente per il movimento d'anticipo - error_type search_clifo_bill(TString &); - // Cerca il conto di contropartita per il movimento d'anticipo - error_type search_counter_bill(TDocumento&); - // compila la testata del movimento di anticipo - error_type compile_head_anticipo(TDocumento&); - // compila le righe del movimento di anticipo - error_type compile_rows_anticipo(TDocumento&); - // compila e scrive il pagamento del movimento di anticipo - error_type write_pagamento_anticipo(TDocumento&); - // scrive il movimento di anticipo pagamento - error_type write_anticipo(TDocumento&); - // scrive il movimento INTRA - error_type write_intra(TDocumento&); - // Aggiorna i saldi - void aggiorna_saldi(TSaldo_agg& saldo, TMovimentoPN& mv, bool save); - // Visualizza l'ultimo errore rilevato - void display_error(TDocumento&); - // Verifica se non ci sono stati errori - bool good() const { return _error == no_error;} - // Ritorna TRUE se il saldaconto e' abilitato (verifica anche la causale del documento corrente) - bool sc_enabled() const ; - // Ritorna TRUE se il modulo INTRA e' abilitato (verifica anche la causale del documento corrente) - bool in_enabled() const ; - // Controlla se il tipo riga esiste - bool valid_row_type(const char* rt) const; -public: - // Cambia lo stato del documento - error_type change_doc_status(TDocumento&); - virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, - const TDate& data_elab, bool interattivo = FALSE); - void set_auto(const bool a) { _auto_data = a; } - void set_writeable(const bool b) { _can_write = b; } - const long processed_docs() const { return _total_docs; } - void inc_processed_docs() { _total_docs++; } - - // Ritorna il numero dell'eventuale movimento con cui il documento stato contabilizzato - long doc_contabilized(const TDocumento& doc, bool anticipo) const; - - // Personalizzazioni - bool call_exe(const TDocumento& doc, const TMovimentoPN& movimento) const; - - // Ritorna TRUE se il documento precedente a doc e' gia' stato contabilizzato - bool prev_contabilized(const TDocumento& doc) const; - - TContabilizzazione(const char* cod); - TContabilizzazione(const TRectype& rec); - virtual ~TContabilizzazione(); ->>>>>>> 1.67.2.32 -}; - -<<<<<<< velib.h class TCurrency_documento : public TCurrency { protected: void copy(const TCurrency& cur) {TCurrency::copy(cur); } -======= ->>>>>>> 1.67.2.32 public: const TCurrency_documento& operator=(const TCurrency_documento& cur) { copy(cur); return *this; } @@ -1824,7 +868,6 @@ public: void highlight(COLOR high_back_color, COLOR high_color); -<<<<<<< velib.h bool TDocumento_mask::is_calculated_page(int p) { return _calculated_pages[p]; } TSmart_card * smartcard() const { return _smartcard;} @@ -1832,35 +875,4 @@ public: virtual ~TDocumento_mask(); }; -#endif======= -class TConsuntivazione_produzione : public TElaborazione // velib04e -{ -protected: - bool ref2doc(char & provv, int & anno, TString8 & codnum, long & ndoc, int & nriga, const TString & codart); - -public: - virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, - const TDate& data_elab, bool interattivo = FALSE); - - TConsuntivazione_produzione(const char* cod) : TElaborazione(cod) { } - TConsuntivazione_produzione(const TRectype& rec) : TElaborazione(rec) { } - virtual ~TConsuntivazione_produzione() { } -}; - -class TLista_elaborazioni : public TObject // velib04 -{ - TAssoc_array * _elab; - -protected: - void read(); - -public: - TElaborazione & operator [](const char * key) const; - int select(TString_array & result, const char * tipo_iniziale = NULL, const char * stato_iniziale = NULL, const char * tipo_finale = NULL, const char * stato_finale = NULL); - void update(); - TLista_elaborazioni() : _elab(NULL) {} - virtual ~TLista_elaborazioni(); -}; - #endif ->>>>>>> 1.67.2.32 diff --git a/ve/velib06.cpp b/ve/velib06.cpp index e098f0e7b..ec4d51eae 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -47,29 +47,6 @@ bool TOriginal_row_mask::on_key(KEY key) } -class TOriginal_row_mask : public TAutomask -{ - -protected: - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - virtual bool on_key(KEY key); - -public: - TOriginal_row_mask() : TAutomask("ve0100c") { } -}; - -bool TOriginal_row_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - return true; -} - -bool TOriginal_row_mask::on_key(KEY key) -{ - if (key == K_SHIFT + K_F12) - enable(-1); - return TAutomask::on_key(key); -} - TDocumento_mask::TDocumento_mask(const char* td) : TVariable_mask(), _progs_page(-1), _condv(NULL), _smartcard(NULL), diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index b49ed9bfc..54349cba2 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -348,7 +348,6 @@ bool data_hndl( TMask_field& field, KEY key ) return field.error_box("Data documento inferiore alla data del documento precedente"); } } -} return true; } @@ -709,342 +708,6 @@ bool pricerange_handler(TMask_field& f, KEY key ) return true; } - -static bool __in_handler = false; - -int sort_sheet(const TObject** a, const TObject** b) -{ - TToken_string * t1 = (TToken_string *) *a; - TToken_string * t2 = (TToken_string *) *b; - const char * a1 = t1->get(1); - const char * a2 = t2->get(1); - int cmp = strcmp(a1, a2); - - if (cmp == 0) - { - TDate d1(t1->get(2)); - TDate d2(t2->get(2)); - - cmp = d2 - d1; - if (cmp == 0) - return t2->get_int(8) - t1->get_int(8); - } - return cmp; -} - -void search_price(TMask_field& f, KEY key ) -{ - TMask& row_mask = f.mask(); - TSheet_field& sh = *row_mask.get_sheet(); - TDocumento_mask& mask = (TDocumento_mask &)sh.mask(); - TArray_sheet sheet(0, 3, -1, 16, "Ricerca Prezzi", - "N.ro doc.|Codice articolo@20|Data@10|Prezzo@18P|Quantità|Sconto@10|Numerazione@18|Tipo Documento@18", 0, 1); - TString_array & el = sheet.rows_array(); - TString form; - TRelation * rel = new TRelation(LF_DOC); - TRectype from(rel->curr()); - TRectype to(rel->curr()); - TDate datadoc = mask.get_date(F_DATADOC); - const long codcf = mask.get_long(F_CODCF); - const TString16 numdoc(mask.get(F_NDOC)); - const int last_anno = mask.get_int(F_ANNO); - const int current_doc_row = sh.selected() + 1; - const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years(); - TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums()); - const TString& tipocf = mask.get(F_TIPOCF); - - from.put(DOC_TIPOCF, tipocf); - to.put(DOC_TIPOCF, tipocf); - from.put(DOC_CODCF, codcf); - to.put(DOC_CODCF, codcf); - from.put(DOC_PROVV, "D"); - to.put(DOC_PROVV, "D"); - from.put(DOC_ANNO, first_anno); - to.put(DOC_ANNO, last_anno); - to.put(DOC_DATADOC, datadoc); - - - if (nums.empty()) - nums = mask.get(F_CODNUM); - - TString8 first_num(nums.get(0)); - TString8 last_num(first_num);; - - form << "((CODNUM==\"" << first_num << "\")"; - for (const char * s = nums.get(); s && *s; s = nums.get()) - { - if (first_num > s) - first_num = s; - if (last_num < s) - last_num = s; - form << "||(CODNUM==\"" << s << "\")"; - } - form << ")"; - - TCursor cur(rel, form, 2, &from, &to); - const int items = cur.items(); - cur.freeze(); - TRecord_array r(LF_RIGHEDOC, RDOC_NRIGA); - TRectype rec(LF_RIGHEDOC); - - for(cur = 0L; cur.pos() < items; ++cur) - { - const TString16 data(cur.curr().get(DOC_DATADOC)); - const TString80 num(cache().get("%NUM", cur.curr().get(DOC_CODNUM), "S0")); - const TString80 tipo(cache().get("%TIP", cur.curr().get(DOC_TIPODOC), "S0")); - - rec.zero(); - rec.put(RDOC_PROVV, cur.curr().get(DOC_PROVV)); - rec.put(RDOC_ANNO, cur.curr().get(DOC_ANNO)); - rec.put(RDOC_CODNUM, cur.curr().get(DOC_CODNUM)); - rec.put(RDOC_NDOC, cur.curr().get(DOC_NDOC)); - r.read(rec); - - int last_row = r.last_row(); - - for (int i = r.first_row(); i <= last_row; i = r.succ_row(i)) - { - const TRectype & rdoc = r.row(i); - const TString & codart = rdoc.get(RDOC_CODART); - - if (codart.not_empty()) - { - TToken_string row; - - row.add(rdoc.get(RDOC_NDOC)); - row.add(codart); - row.add(data); - row.add(rdoc.get(RDOC_PREZZO)); - row.add(rdoc.get(RDOC_QTA)); - row.add(rdoc.get(RDOC_SCONTO)); - row.add(num); - row.add(tipo); - row.add(rdoc.get(RDOC_NRIGA)); - el.add(row); - } - } - } - el.TArray::sort(sort_sheet); - - const int max_rows = ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).max_rows_art(); - - if (max_rows > 0) - { - const int items = el.items(); - TString80 last_cod; - long last_doc = 0L; - real last_price(ZERO); - int count = 0; - for (int i = 0 ; i < items; i++) - { - const TString & codart = el.row(i).get(1); - long ndoc = el.row(i).get_long(0); - real price(el.row(i).get(3)); - - if (codart != last_cod) - { - last_cod = codart; - last_doc = ndoc; - last_price = price; - count = 1; - } - else - { - if (ndoc == last_doc && price == last_price) - { - el.destroy(i); - } - else - { - last_doc = ndoc; - last_price = price; - count++; - if (count > max_rows) - el.destroy(i); - } - } - } - el.pack(); - } - - if (sheet.run() == K_ENTER) - { - __in_handler = true; - const TString & xx = sheet.row(-1).get(3); - row_mask.set(FR_PREZZO, xx); - const TString & codart_sel = sheet.row(-1).get(1); - row_mask.set(FR_CODART, codart_sel, 3); - row_mask.field(FR_CODART).set_dirty(false); - const TString & prezzo = sheet.row(-1).get(3); - row_mask.set(FR_PREZZO, prezzo); - const TString & sconto = sheet.row(-1).get(5); - row_mask.set(FR_SCONTO, sconto); - __in_handler = false; - } -} - -void search_price_article(TMask_field& f, KEY key ) -{ - TMask& row_mask = f.mask(); - TSheet_field& sh = *row_mask.get_sheet(); - TDocumento_mask& mask = (TDocumento_mask &)sh.mask(); - const int current_doc_row = sh.selected() + 1; - const TString16 numdoc(mask.get(F_NDOC)); - const TString80 codart(row_mask.get(FR_CODART)); - TDate datadoc = mask.get_date(F_DATADOC); - const char tipocf = mask.get(F_TIPOCF)[0]; - const TString16 codcf = mask.get(F_CODCF); - - TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums()); - - if (nums.empty()) - nums = mask.get(F_CODNUM); - - TString8 first_num(nums.get(0)); - TString8 last_num(first_num);; - TString form; - - form << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << (const char *)codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")"; - for (const char * s = nums.get(); s && *s; s = nums.get()) - { - if (first_num > s) - first_num = s; - if (last_num < s) - last_num = s; - form << "||(CODNUM==\"" << s << "\")"; - } - form << ")"; - - TRelation rel(LF_RIGHEDOC); - TRectype from(rel.curr()); - TRectype to(rel.curr()); - rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC"); - - const int last_anno = mask.get_int(F_ANNO); - const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years(); - - from.put(RDOC_CODART, codart); - from.put(RDOC_CODNUM, first_num); - from.put(RDOC_ANNO, first_anno); - from.put(RDOC_PROVV, "D"); - to.put(RDOC_CODART, codart); - to.put(RDOC_CODNUM, last_num); - to.put(RDOC_ANNO, last_anno); - to.put(RDOC_PROVV, "D"); - TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", form, 5, &from, &to); - cur.items(); - cur.freeze(); - cur.relation()->add("%NUM", "CODTAB==CODNUM", 1, 0, 201); - cur.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 202); - - TCursor_sheet sheet(&cur, "NDOC|CODART|33->DATADOC|PREZZO|QTA|SCONTO|-201->S0|-202->S0", - "Ricerca Prezzi", - "N.ro doc.|Codice articolo@20|Data@10|Prezzo@18P|Quantità|Sconto@10|Numerazione@18|Tipo Documento@18", - 0, 4); - - sheet.add_string (101, 0, "Codice Articolo ", 2, 1, 20, "D"); - sheet.add_string (102, 0, "Descrizione ", 2, 3, 50, "D"); - sheet.set(101, codart); - sheet.set(102, cache().get(LF_ANAMAG, codart, "DESCR")); - if (sheet.run() == K_ENTER) - { - __in_handler = true; - row_mask.set(FR_CODART, codart, 3); - row_mask.field(FR_CODART).set_dirty(false); - __in_handler = false; - const TString & prezzo = sheet.row(-1).get(3); - row_mask.set(FR_PREZZO, prezzo); - const TString & sconto = sheet.row(-1).get(5); - row_mask.set(FR_SCONTO, sconto); - } -} - -bool search_price_handler(TMask_field& f, KEY key ) -{ - TMask& row_mask = f.mask(); - TSheet_field& sh = *row_mask.get_sheet(); - - if (key == K_F8 && !sh.sheet_mask().is_running()) - { - const TString & codart = row_mask.get(FR_CODART); - if (codart.empty()) - search_price(f, key); - else - search_price_article(f,key); - return true; - } - else - if ((key == K_TAB && f.focusdirty())) - { - TDocumento_mask& mask = (TDocumento_mask &)sh.mask(); - - const TString80 codart(row_mask.get(FR_CODART)); - - if (!__in_handler && codart.not_empty() && row_mask.get(FR_PREZZO).empty()) - { - TDate datadoc = mask.get_date(F_DATADOC); - const char tipocf = mask.get(F_TIPOCF)[0]; - const TString16 codcf = mask.get(F_CODCF); - const int current_doc_row = sh.selected() + 1; - - TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums()); - - if (nums.empty()) - nums = mask.get(F_CODNUM); - - TString8 first_num(nums.get(0)); - TString8 last_num(first_num);; - - TString form; - form << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << (const char *)codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")"; - for (const char * s = nums.get(); s && *s; s = nums.get()) - { - if (first_num > s) - first_num = s; - if (last_num < s) - last_num = s; - form << "||(CODNUM==\"" << s << "\")"; - } - form << ")"; - - TRelation rel(LF_RIGHEDOC); - TRectype from(rel.curr()); - TRectype to(rel.curr()); - rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC"); - - const int last_anno = mask.get_int(F_ANNO); - const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years(); - - from.put(RDOC_CODART, codart); - from.put(RDOC_CODNUM, first_num); - from.put(RDOC_ANNO, first_anno); - from.put(RDOC_PROVV, "D"); - to.put(RDOC_CODART, codart); - to.put(RDOC_CODNUM, last_num); - to.put(RDOC_ANNO, last_anno); - to.put(RDOC_PROVV, "D"); - - TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", "", 5, &from, &to); - cur.setfilter(form, true); - if (cur.items() > 0L) - { - cur = 0L; - __in_handler = true; - row_mask.set(FR_CODART, codart, 3); - row_mask.field(FR_CODART).set_dirty(false); - __in_handler = false; - const TString & prezzo = cur.curr().get(RDOC_PREZZO); - row_mask.set(FR_PREZZO, prezzo); - const TString & sconto = cur.curr().get(RDOC_SCONTO); - row_mask.set(FR_SCONTO, sconto); - } - } - } - return codart_handler( f, key); -} - - - static bool __in_handler = false; int sort_sheet(const TObject** a, const TObject** b)