From 7cf6c4d24ad66020a4e80ce47b7944c2a02108e4 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 27 Aug 2008 23:23:05 +0000 Subject: [PATCH] Patch level : 10.0 109 Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.2 1208 git-svn-id: svn://10.65.10.50/trunk@17116 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/clifor.cpp | 98 ++++++++++++++++++--- ve/clifor.h | 10 +++ ve/sconti.cpp | 4 +- ve/ve0100.cpp | 4 +- ve/ve0200b.uml | 5 ++ ve/ve2400.cpp | 119 +++++++++++++++---------- ve/ve2400.h | 1 + ve/ve2400.uml | 8 +- ve/veconf.h | 1 + ve/vefat.rep | 70 +++++++-------- ve/velib.h | 13 ++- ve/velib02.cpp | 3 + ve/velib03.cpp | 55 ++++++++++-- ve/velib04.h | 1 + ve/velib04b.cpp | 50 ++++++++--- ve/velib06.cpp | 225 +++++++++++++++++++++++++++++++++++++++++++++++- ve/velib06a.cpp | 14 ++- ve/velib07.cpp | 110 ++++++++++++++++++++--- ve/velib07.h | 6 +- ve/vepriv.h | 2 +- ve/vetbnum.uml | 2 +- 21 files changed, 665 insertions(+), 136 deletions(-) diff --git a/ve/clifor.cpp b/ve/clifor.cpp index 822d515ad..96cba4195 100755 --- a/ve/clifor.cpp +++ b/ve/clifor.cpp @@ -1,4 +1,8 @@ +#include #include "clifor.h" +#include "../li/letint.h" +#include +#include TOccasionale::TOccasionale() : TRectype(LF_OCCAS) { } @@ -58,10 +62,72 @@ TRectype& TCli_for::vendite() const return (TRectype &) _ven_rec; } +bool TCli_for::read_lettera(const TDate & data, bool extended) +{ + + if (_use_lettere) + { + if (data != _last_data) + { + _letint.zero(); + TRelation * r = new TRelation(LF_LETINT); + TRectype from(r->curr()); + + from.put(LETINT_ANNO, data.year()); + from.put(LETINT_CODCLI, codice()); + + TCursor c(r, "", 2 ,&from, &from); + const int items = c.items(); + + if (items > 0) + { + TDate dal; + TDate al(31, 12, data.year()); + + for (c = items - 1; c.pos() >= 0L; --c) + { + const int tipo = c.curr().get_int(LETINT_TIPOOP); + + if (tipo == 3) + { + dal = c.curr().get_date(LETINT_DAL); + al = c.curr().get_date(LETINT_AL); + } + else + { + dal = c.curr().get_date(LETINT_VSDATA); + if (c.pos() < items - 1) + { + ++c; + const int tipo_next = c.curr().get_int(LETINT_TIPOOP); + if (tipo_next == 3) + al = c.curr().get_date(LETINT_DAL); + else + al = c.curr().get_date(LETINT_VSDATA); + --c; + } + } + if (dal <= data) + { + _letint = c.curr(); + break; + } + } + _lettera_found = !_letint.empty(); + if (_lettera_found && !extended) + _lettera_found = data <= al; + } + _last_data = data; + } + } + return _lettera_found; +} + int TCli_for::read(const TRectype & rec, word op, word lockop) { _ven_rec.zero(); int err = TMultiple_rectype::read(rec, op, lockop); + _last_data = botime; return err; } @@ -76,6 +142,7 @@ int TCli_for::read(char tipo, long codice, word op, word lockop) put(CLI_CODCF, codice); err = TMultiple_rectype::read(op, lockop); } + _last_data = botime; return err; } @@ -89,33 +156,42 @@ int TCli_for::remove(TBaseisamfile& f) const return TMultiple_rectype:: remove(f); } -TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN) +void TCli_for::init() { _tipo = new TRecfield(*this, CLI_TIPOCF); _codice = new TRecfield(*this, CLI_CODCF); _ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF); _ven_codice = new TRecfield(_ven_rec, CFV_CODCF); + _use_lettere = main_app().has_module(LIAUT, CHK_DONGLE); + if (_use_lettere) + { + TConfig c(CONFIG_DITTA, "ve"); + _use_lettere = c.get_bool("USELETTERE"); + } + +} + +TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN), + _letint(LF_LETINT), _use_lettere(false), _lettera_found(false) +{ + init(); add_file(LF_INDSP, IND_CODIND); if (tipo > ' ' && codice > 0L) read(tipo, codice); } -TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN) +TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN), + _letint(LF_LETINT), _use_lettere(false), _lettera_found(false) { - _tipo = new TRecfield(*this, CLI_TIPOCF); - _codice = new TRecfield(*this, CLI_CODCF); - _ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF); - _ven_codice = new TRecfield(_ven_rec, CFV_CODCF); + init(); add_file(LF_INDSP, IND_CODIND); read(rec); } -TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec) +TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec), + _letint(LF_LETINT), _use_lettere(false), _lettera_found(false) { - _tipo = new TRecfield(*this, CLI_TIPOCF); - _codice = new TRecfield(*this, CLI_CODCF); - _ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF); - _ven_codice = new TRecfield(_ven_rec, CFV_CODCF); + init(); } TCli_for::~TCli_for() diff --git a/ve/clifor.h b/ve/clifor.h index 9ef22e105..8ff482adf 100755 --- a/ve/clifor.h +++ b/ve/clifor.h @@ -42,13 +42,23 @@ class TCli_for : public TMultiple_rectype TRecfield * _ven_codice; TRectype _ven_rec; + TRectype _letint; + TDate _last_data; + bool _use_lettere; + bool _lettera_found; + + protected: virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const; + void init(); public: + bool read_lettera(const TDate & data, bool extended = false); bool occasionale() const { return get_bool(CLI_OCCAS); } TRectype & vendite() const; + bool use_lettere() const { return _use_lettere;} + const TRectype & lettera() const { return _letint;} char tipo() const { return *(const char *) (*_tipo); } long codice() const { return (long) *_codice; } diff --git a/ve/sconti.cpp b/ve/sconti.cpp index 82371f5a5..9afade269 100755 --- a/ve/sconti.cpp +++ b/ve/sconti.cpp @@ -668,7 +668,7 @@ void TCond_vendita::update_omaggi(bool full) r.put("QTA", qta); real prezzo(_rcondv.get("PROMAGGIO")); const TString16 codval(_condv.get("CODVAL")); - const TString16 codiva_cli(clifo().vendite().get(CFV_ASSFIS)); + const TString16 codiva_cli(doc.codesiva()); if (codiva_cli.not_empty()) r.put("CODIVA", codiva_cli); else @@ -699,4 +699,4 @@ TCond_vendita::TCond_vendita(TDocumento_mask * testa, TMask * riga) _ivarid(FALSE), _load_mask(FALSE) { } - \ No newline at end of file + diff --git a/ve/ve0100.cpp b/ve/ve0100.cpp index 53274af84..dd5b850e2 100755 --- a/ve/ve0100.cpp +++ b/ve/ve0100.cpp @@ -833,7 +833,7 @@ void TMotore_application::ini2mask(TConfig& ini, TMask& msk, bool query) if (!ini.exist(RDOC_CODIVA) && !(rec.is_descrizione() || rec.is_sconto() || rec.is_sconto_perc())) { - const TString4 codiva = ((TDocumento_mask &) msk).condv().clifo().vendite().get(CFV_ASSFIS); + const TString4 codiva = ((TDocumento_mask &) msk).doc().codesiva(); if (codiva.full()) rec.put(RDOC_CODIVA, codiva); @@ -907,4 +907,4 @@ int ve0100( int argc, char* argv[]) a.run( argc, argv, TR("Gestione documenti")); return 0; -} \ No newline at end of file +} diff --git a/ve/ve0200b.uml b/ve/ve0200b.uml index e3fe76b73..cf44b1ba5 100755 --- a/ve/ve0200b.uml +++ b/ve/ve0200b.uml @@ -95,6 +95,11 @@ BEGIN FIELD LIVPERART END +BOOLEAN F_USELETTERE +BEGIN + PROMPT 2 14 "Utilizzo lettere d'intento" + FIELD USELETTERE +END ENDPAGE ENDMASK diff --git a/ve/ve2400.cpp b/ve/ve2400.cpp index 43cdc4b19..b27d3b66a 100755 --- a/ve/ve2400.cpp +++ b/ve/ve2400.cpp @@ -66,7 +66,7 @@ class TMask_anamag: public TMask void create_user_fields(); public: - bool generate_code(int _type = 0); + bool generate_code(int _type = 0, const char * codart = NULL); void update_ordc_ordf(); void set_parametered_fields(); void ricalcola_giacenze(); @@ -576,12 +576,13 @@ bool TMask_anamag::handle_autoinsert_livgiac(TMask_field &fld, KEY k) // HANDLER DEL CODICE: controlla la corrispondenza al formato previsto -bool TMask_anamag::generate_code(int type) +bool TMask_anamag::generate_code(int type, const char * codart) { + _generated_code.cut(0); if (type <= 0) type = _type_cod; - if (type <= 0) - return false; + //if (type <= 0) + // return false; TString cod(20); long progr = 0; @@ -650,51 +651,79 @@ bool TMask_anamag::generate_code(int type) return error_box(FR("Sono gia' stati generati 1000 codici sul prefisso %s"), (const char*)_ean8_pref); } else - { - if (_ean13_pref.empty()) - return false; - cod = _ean13_pref; - cod << "999999"; - if (_type_cod != 0) - { - TLocalisamfile anamag(LF_ANAMAG); - anamag.put(ANAMAG_CODART, cod); + if (_ean13_pref.full()) + { + return false; + cod = _ean13_pref; + cod << "999999"; + if (_type_cod != 0) + { + TLocalisamfile anamag(LF_ANAMAG); + anamag.put(ANAMAG_CODART, cod); - if (anamag.read(_isgteq) != _isemptyfile) - { - cod = anamag.get(ANAMAG_CODART); + if (anamag.read(_isgteq) != _isemptyfile) + { + cod = anamag.get(ANAMAG_CODART); - if (_ean13_pref < cod.left(6)) - { - anamag.prev(); - cod = anamag.get(ANAMAG_CODART); - } - if (_ean13_pref == cod.left(6)) - progr = atol(cod.right(6)); - } - } - else - { - TLocalisamfile codcorr(LF_CODCORR); - codcorr.setkey(2); - codcorr.put(CODCORR_CODARTALT, cod); + if (_ean13_pref < cod.left(6)) + { + anamag.prev(); + cod = anamag.get(ANAMAG_CODART); + } + if (_ean13_pref == cod.left(6)) + progr = atol(cod.right(6)); + } + } + else + { + TLocalisamfile codcorr(LF_CODCORR); + codcorr.setkey(2); + codcorr.put(CODCORR_CODARTALT, cod); - if (codcorr.read(_isgteq) != _isemptyfile) - { - cod = codcorr.get(CODCORR_CODARTALT); + if (codcorr.read(_isgteq) != _isemptyfile) + { + cod = codcorr.get(CODCORR_CODARTALT); - if (_ean13_pref < cod.left(6)) - { - codcorr.prev(); - cod = codcorr.get(CODCORR_CODARTALT); - } - if (_ean13_pref == cod.left(6)) - progr = atol(cod.right(6)); - } - } + if (_ean13_pref < cod.left(6)) + { + codcorr.prev(); + cod = codcorr.get(CODCORR_CODARTALT); + } + if (_ean13_pref == cod.left(6)) + progr = atol(cod.right(6)); + } + } + progr++; + _generated_code.format("%s%06ld", (const char *)_ean13_pref, progr); + } + if (_generated_code.blank() && codart != NULL) + { + TString scod(codart); + cod = scod; + const int len = scod.len(); + cod << "999999"; + TLocalisamfile anamag(LF_ANAMAG); + anamag.put(ANAMAG_CODART, cod); + TString code; + + if (anamag.read(_isgteq) != _isemptyfile) + { + code = anamag.get(ANAMAG_CODART); + + if (cod < code.left(len) || (scod == code.left(len) && !isdigit(code[len]))) + { + anamag.prev(); + code = anamag.get(ANAMAG_CODART); + } + if (scod == code.left(len)) + progr = atol(code.mid(len)); + else + return false; + } progr++; - _generated_code.format("%s%06ld", (const char *)_ean13_pref, progr); - } + TString fmt(format("%%s%%0%dld", code.len() - len)); + _generated_code.format(fmt, (const char *)scod, progr); + } return true; } @@ -744,7 +773,7 @@ bool TMask_anamag::handle_codice(TMask_field &fld, KEY k) } if (k == K_F8) { - if (mask.generate_code()) + if (mask.generate_code(0, ((TEditable_field&)fld).get_window_data())) { fld.set(mask.generated_code()); mask.stop_run(K_INS); diff --git a/ve/ve2400.h b/ve/ve2400.h index 1174bbf41..a73dc5cfe 100755 --- a/ve/ve2400.h +++ b/ve/ve2400.h @@ -160,6 +160,7 @@ #define F_DESREPARTO 306 #define F_STAGIONE 307 #define F_DESSTAGIONE 308 +#define F_LIVPERART 309 #define F_CONTOPCIA 401 #define F_DESCRCONTOPCIA 411 diff --git a/ve/ve2400.uml b/ve/ve2400.uml index 18d52eee3..29be71b22 100755 --- a/ve/ve2400.uml +++ b/ve/ve2400.uml @@ -963,9 +963,15 @@ BEGIN FLAGS "D" END +BOOLEAN F_LIVPERART +BEGIN + PROMPT 2 5 "Livelli di giacenza definiti per articolo" + FIELD LIVPERART +END + SPREADSHEET F_SHEETGIAC 0 -2 BEGIN - PROMPT 0 5 "Giacenze" + PROMPT 0 6 "Giacenze" FLAGS "A" USE LF_MAG KEY NRIGA INPUT ANNOES F_ANNO diff --git a/ve/veconf.h b/ve/veconf.h index 6063f7011..a5fec9369 100755 --- a/ve/veconf.h +++ b/ve/veconf.h @@ -60,6 +60,7 @@ #define F_GESOCCAS 107 #define F_CONTROEURO_E 108 #define F_LINGUA_ONLY 109 +#define F_USELETTERE 110 // Campi per ve0200c.uml diff --git a/ve/vefat.rep b/ve/vefat.rep index 9ae8dcbd5..383830fed 100755 --- a/ve/vefat.rep +++ b/ve/vefat.rep @@ -123,24 +123,24 @@ MESSAGE APPEND,26 - - - - - - + + + + + + - - - - + + + + - + @@ -201,10 +201,10 @@ MESSAGE APPEND,26 - + - + @@ -222,10 +222,10 @@ MESSAGE APPEND,26 - + - + @@ -240,31 +240,31 @@ MESSAGE APPEND,26 - + - + - + - + - + - + - - - - - - + + + + + +
!((34.TIPORIGA='08')) @@ -280,30 +280,30 @@ MESSAGE ENABLE,51 MESSAGE _DESCRIGA - + 34.UMQTA MESSAGE _ALIGN,#52,BOTTOM - + 30 34.QTA MESSAGE _ALIGN,#52,BOTTOM - + 29 34.PREZZO MESSAGE _ALIGN,#52,BOTTOM - + 34.SCONTO MESSAGE _ALIGN,#52,BOTTOM - + 29 34.IMPNS MESSAGE _ALIGN,#52,BOTTOM - + 34.CODIVA MESSAGE _ALIGN,#52,BOTTOM @@ -345,7 +345,7 @@ MESSAGE ENABLE,51 31 SPESIMB - + 31 33.IMPPAGATO @@ -431,7 +431,7 @@ MESSAGE ENABLE,51 31 BOLLI - + 31 TOTDOC diff --git a/ve/velib.h b/ve/velib.h index af8ee52aa..b5dc0560c 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -397,6 +397,10 @@ class TTipo_riga_documento : public TRectype // velib02 bool _no_desc; TToken_string _search_active_docs; TToken_string _fields_to_update; + TToken_string _field_list; + TToken_string _header; + bool _select_clifo; + int _decrp, _incrp; @@ -430,6 +434,9 @@ public: bool no_desc() const { return _no_desc;} TToken_string& search_active_docs() { return _search_active_docs;} TToken_string& fields_to_update() { return _fields_to_update;} + TToken_string& field_list() { return _field_list;} + TToken_string& header() { return _header;} + bool select_clifo() const { return _select_clifo;} const TString& provv() const { return _field_provv;} const int incr_perc_prezzo() const { return _incrp;} @@ -784,6 +791,9 @@ public: bool is_evaso() const; bool is_nota_credito() const; + const TString & codesiva() const; + void get_protocolli_esenzione(TString & esenzione, TString & data_esenzione, + TString & registrazione, TString & data_registrazione) const; TDocumento (); TDocumento (const TDocumento & d); TDocumento(char provv, int anno, const char* codnum, long numdoc); @@ -865,6 +875,7 @@ protected: public: virtual bool is_omaggio_enabled() { return true;} void update_progs(bool stop_run = false); + TAssoc_array & maskrighe() {return _maskriga;} virtual bool on_key(KEY key); virtual bool stop_run(KEY key); @@ -942,4 +953,4 @@ public: virtual ~TDocumento_mask(); }; -#endif \ No newline at end of file +#endif diff --git a/ve/velib02.cpp b/ve/velib02.cpp index b926f792f..b4cbbb9f3 100755 --- a/ve/velib02.cpp +++ b/ve/velib02.cpp @@ -130,6 +130,9 @@ void TTipo_riga_documento::read_formule() _max_rows_art = profile.get_int("MAXROWSART"); _search_active_docs = profile.get("SEARCHACTDOCS"); _fields_to_update = profile.get("FIELDSTOUPDATE"); + _field_list = profile.get("FIELDLIST"); + _header = profile.get("HEADER"); + _select_clifo = profile.get_bool("SELCLIFO", NULL, -1, true); _no_desc = profile.get_bool("NODESC"); _formule = profile.get("CAMPICALC"); diff --git a/ve/velib03.cpp b/ve/velib03.cpp index 984ef49a7..a61b24ad3 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -7,6 +7,7 @@ #include "../db/dblib.h" #include "../pr/prlib.h" #include "../sv/svlib01.h" +#include "../li/letint.h" #include "veini.h" #include "velib.h" @@ -779,14 +780,16 @@ void TDocumento::set_riga_esenzione() { TCli_for & c = clifor(); const TCodiceIVA codes(c.vendite().get(CFV_ASSFIS)); - const TString16 v_esenzione(c.vendite().get(CFV_VSPROT)); - const TString16 v_data_esenzione(c.vendite().get(CFV_VSDATAREG)); - const TString16 n_registrazione(c.vendite().get(CFV_NSPROT)); - const TString16 n_data_registrazione(c.vendite().get(CFV_NSDATAREG)); + TString16 v_esenzione; + TString16 v_data_esenzione; + TString16 n_registrazione; + TString16 n_data_registrazione; + + if (codes.codice().full()) + get_protocolli_esenzione(v_esenzione, v_data_esenzione, n_registrazione, n_data_registrazione); bool esente = codes.tipo().not_empty() && v_esenzione.not_empty() && v_data_esenzione.not_empty() && n_registrazione.not_empty() && n_data_registrazione.not_empty(); - if (esente) { esente = false; @@ -2452,6 +2455,10 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old, const TString4 cod_iva_cli = cache().get(LF_CFVEN, key, "ASSFIS"); TSpesa_prest sp; + cfven.put("TIPOCF", get("TIPOCF")); + cfven.put("CODCF", get("CODCF")); + if (cfven.read() == NOERR) + cod_iva_cli = codesiva(); for (i = 0; i < nspese; i++) { const TString& s = spese_aut.row(i); @@ -2534,7 +2541,6 @@ real TDocumento::calc_conai_qta(int type) if (r.is_merce()) { const real row_qta = r.calc_conai_qta(type); - qta += row_qta; } } @@ -2610,7 +2616,7 @@ void TDocumento::update_conai() // Genera nuove righe if (cli_add_conai) { - const TString4 cod_iva_cli = cfven.get(CFV_ASSFIS); + const TString4 cod_iva_cli = codesiva() ; TSpesa_prest sp; for (i = 0; i < 6; i++) @@ -2761,3 +2767,38 @@ int TDocumento::tipo_riclassificato() const } return tipo_riclassificato; } + +const TString & TDocumento::codesiva() const +{ + TCli_for & c = clifor(); + + if (!c.use_lettere() || c.read_lettera(get_date(DOC_DATADOC))) + return c.vendite().get(CFV_ASSFIS); + return EMPTY_STRING; +} + +void TDocumento::get_protocolli_esenzione(TString & esenzione, TString & data_esenzione, + TString & registrazione, TString & data_registrazione) const +{ + TCli_for & c = clifor(); + + if (c.use_lettere()) + { + if(c.read_lettera(get_date(DOC_DATADOC), true)) + { + const TRectype & rec = c.lettera(); + + esenzione = rec.get(LETINT_VSPROT); + data_esenzione = rec.get(LETINT_VSDATA); + registrazione = rec.get(LETINT_NUMPROT); + data_registrazione = rec.get(LETINT_DATAREG); + } + } + else + { + esenzione = c.vendite().get(CFV_VSPROT); + data_esenzione = c.vendite().get(CFV_VSDATAREG); + registrazione = c.vendite().get(CFV_NSPROT); + data_registrazione = c.vendite().get(CFV_NSDATAREG); + } +} diff --git a/ve/velib04.h b/ve/velib04.h index c847c1147..d20208a8d 100755 --- a/ve/velib04.h +++ b/ve/velib04.h @@ -363,6 +363,7 @@ class TContabilizzazione : public TElaborazione // velib04b TDate _data_reg; // Data di registrazione documenti long _total_docs;// Numero di documenti contabilizzati error_type _error; // Errore rilevato durante l'elaborazione + int _nrow; // numero di riga documento errata 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 diff --git a/ve/velib04b.cpp b/ve/velib04b.cpp index 6ce8997a0..11fadc0c0 100755 --- a/ve/velib04b.cpp +++ b/ve/velib04b.cpp @@ -756,6 +756,7 @@ TContabilizzazione::TContabilizzazione(const char* cod) _nump_iva = get_bool("B4"); _can_write = true; _error = no_error; + _nrow = 0; _total_docs = 0L; _caus = NULL; } @@ -795,6 +796,7 @@ TContabilizzazione::TContabilizzazione(const TRectype& rec) _can_write = true; _error = no_error; + _nrow = 0; _total_docs = 0L; _caus = NULL; } @@ -1091,7 +1093,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc) // Istanzia la causale del documento corrente... const TTipo_documento& tipo = doc.tipo(); - TString4 codcaus = tipo.causale(); + TString16 codcaus = tipo.causale(); TToken_string key; key.add(doc.get(DOC_TIPOCF)); @@ -1754,6 +1756,7 @@ error_type TContabilizzazione::search_costo_ricavo(TBill& conto, const TRiga_doc { _conto_errato = conto; _error = conto_error; + _nrow = r.get_int(RDOC_NRIGA); } } return _error; @@ -2108,6 +2111,7 @@ error_type TContabilizzazione::create_total_doc_row(TDocumento& doc) gruppo = _co_cliente.gruppo(); conto = _co_cliente.conto(); codcf = _co_cliente.sottoconto(); + _nrow = -1; } TConto contro; @@ -2206,7 +2210,11 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) r.put(RDOC_CODIVA, codiva1); if (riga_omaggio) - _righe_iva->add_omaggi(r, conto, ALL_DECIMALS, perc); + { + _error = _righe_iva->add_omaggi(r, conto, ALL_DECIMALS, perc); + if (_error != no_error) + _nrow = i; + } else _righe_iva->add(r, conto, ALL_DECIMALS, perc); } @@ -2240,7 +2248,11 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) else { if (riga_omaggio) - _righe_iva->add_omaggi(r, conto); + { + _error = _righe_iva->add_omaggi(r, conto); + if (_error != no_error) + _nrow = i; + } else _righe_iva->add(r, conto); @@ -2260,7 +2272,11 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) } } else + { _error = row_type_error; + _nrow = i; + } + } if (good() && _righe_iva->empty()) @@ -2344,7 +2360,11 @@ error_type TContabilizzazione::compile_rows_mov_re(TDocumento& doc) } } else + { _error = row_type_error; + _nrow = i; + } + } if (good() && _righe_iva->items() == 0) @@ -3610,8 +3630,8 @@ void TContabilizzazione::display_error(TDocumento& doc) "Verificare la correttezza della causale '%s'.",(const char*)numerazione,numero,(const char*)causale); break; case ivasto_error: - msg.format("Impossibile determinare il codice IVA di storno per articoli omaggio relativamente al documento %s/%ld." - "Verificare la configurazione contabilizzazione.",(const char*)numerazione,numero); + msg.format("Impossibile determinare il codice IVA di storno per articoli omaggio relativamente al documento %s/%ld riga %d." + "Verificare la configurazione contabilizzazione.",(const char*)numerazione,numero, _nrow); break; case register_error: msg.format("Rilevato un errore caricando il registro relativamente al documento %s/%ld." @@ -3630,8 +3650,8 @@ void TContabilizzazione::display_error(TDocumento& doc) "Verificare l'esistenza del codice pagamento inserito.",(const char*)numerazione,numero); break; case row_type_error: - msg.format("Rilevato un codice tipo riga non esistente relativamente al documento %s/%ld." - "Verificare l'esistenza dei vari codici riga inseriti.",(const char*)numerazione,numero); + msg.format("Rilevato un codice tipo riga non esistente relativamente al documento %s/%ld riga %d." + "Verificare l'esistenza dei vari codici riga inseriti.",(const char*)numerazione, numero, _nrow); break; case no_rows_error: msg.format("Nessuna riga iva contabile e' stata trovata relativamente al documento %s/%ld." @@ -3648,10 +3668,16 @@ void TContabilizzazione::display_error(TDocumento& doc) _conto_errato.tipo(), _conto_errato.gruppo(), _conto_errato.conto(), _conto_errato.sottoconto()); break; case conto_error: - msg.format("Rilevato un conto di costo/ricavo inesistente relativamente al documento %s/%ld." - "Verificare l'esistenza del conto %c %d %d %ld associato alle righe.", - (const char*)numerazione,numero, - _conto_errato.tipo(), _conto_errato.gruppo(), _conto_errato.conto(), _conto_errato.sottoconto()); + if (_nrow < 0) + msg.format("Rilevato un conto cliente/fornitore relativamente al documento %s/%ld." + "Verificare l'esistenza del conto %c %d %d %ld associato alle righe.", + (const char*)numerazione,numero, + _conto_errato.tipo(), _conto_errato.gruppo(), _conto_errato.conto(), _conto_errato.sottoconto()); + else + msg.format("Rilevato un conto di costo/ricavo inesistente relativamente al documento %s/%ld riga %d." + "Verificare l'esistenza del conto %c %d %d %ld associato alle righe.", + (const char*)numerazione,numero, _nrow, + _conto_errato.tipo(), _conto_errato.gruppo(), _conto_errato.conto(), _conto_errato.sottoconto()); break; case sconto_error: msg.format("Non sono stati impostati i conti per la contabilizzazione degli sconti relativamente al documento %s/%ld." @@ -3712,6 +3738,7 @@ void TContabilizzazione::display_error(TDocumento& doc) else error_box(msg); _error = no_error; // reset error, as any other one would do, so you can show me the other ones. + _nrow = 0; _can_write = false; // But from now on u cannot write anymore. U must exit this program and repair errors occurred. } @@ -3793,6 +3820,7 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc TString msg; _error = no_error; + _nrow = 0; _total_docs = 0L; _caus = NULL; _data_reg = data_elab; diff --git a/ve/velib06.cpp b/ve/velib06.cpp index 7d4b1e97c..f10b854e5 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -513,8 +513,6 @@ void TDocumento_mask::update_progs(bool stop_run) const int page = curr_page(); const int last_field = fields() - 1; - doc().set_riga_esenzione(); // da verificare - for (int f = last_field; f >= 0; f--) { const TMask_field & mf = fld(f); @@ -1373,6 +1371,22 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key ) if (s.full()) { + if (r < doc.rows()) + { + TRiga_documento & riga = doc[r + 1]; + if (riga.is_omaggio() && riga.is_generata()) + { + const bool enabled = ss.cell_enabled(r, 0); + + if (!enabled) ss.enable_row(r); + ss.force_update(r); + ss.select(r); + m.send_key(K_CTRL + '+', 0); + if (!enabled) ss.disable_row(r); + ss.force_update(r); + return false; + } + s.left_just(3); s << ven_rec.get(CFV_CODDEP); } @@ -3476,3 +3490,210 @@ bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key ) return ok; } +void TDocumento_mask::update_father_rows(bool add) +{ + if (_auto_reopen_nums.empty()) + return; + const int rows = doc().physical_rows(); + + for (int i = 1; i <= rows; i++) + { + const TRiga_documento & r = doc()[i]; + + if (r.is_merce() || r.is_omaggio()|| r.is_prestazione()) + { + TRiga_documento * original_row = (TRiga_documento *) r.find_original_rdoc(); + + if (original_row != NULL && _auto_reopen_nums.objptr(original_row->get(RDOC_CODNUM)) != NULL) + { + TToken_string key; + + key.add(original_row->get(RDOC_PROVV)); + key.add(original_row->get(RDOC_ANNO)); + key.add(original_row->get(RDOC_CODNUM)); + key.add(original_row->get(RDOC_NDOC)); + key.add(original_row->get(RDOC_IDRIGA)); + + real * qta = (real *) _father_rows.objptr(key); + + if (qta == NULL) + { + qta = new real; + _father_rows.add(key, qta); + } + + real value = r.quantita(); + + if (r.is_articolo()) + { + TArticolo art(r.get(RDOC_CODARTMAG)); + + value = art.convert_to_um(value, original_row->get(RDOC_UMQTA), r.get(RDOC_UMQTA)); + } + if(add) + *qta += value; + else + *qta -= value; + if (*qta == ZERO) + _father_rows.remove(key); + } + } + } +} + +TAssoc_array TDocumento_mask::_father_rows; +TAssoc_array TDocumento_mask::_auto_reopen_nums; +TAssoc_array TDocumento_mask::_tipidoc_rels; + +void TDocumento_mask::save_father_rows() +{ + if (_auto_reopen_nums.empty()) + return; + TLocalisamfile rdoc(LF_RIGHEDOC); + TString_array rows; + TToken_string last_doc; + TToken_string curr_doc; + int nrows = 0; + + FOR_EACH_ASSOC_OBJECT(_father_rows, h, k, o) + { + rows.add(k); + } + rows.sort(); + rows.add(""); + + FOR_EACH_ARRAY_ROW(rows, i, r) + { + curr_doc = r->get(0); + curr_doc.add(r->get()); + curr_doc.add(r->get()); + curr_doc.add(r->get()); + + if (last_doc != curr_doc && nrows > 0) + { + TDocumento d; + + d.read(last_doc.get_char(0), last_doc.get_int(1), last_doc.get(2), last_doc.get_long(3), _isequal, _lock); + for (int j = i - nrows; j < i; j++) + { + TToken_string & key = rows.row(j); + const long idriga = key.get_long(4); + const int nrows = d.physical_rows(); + + for (int k = 1; k <= nrows; k++) + { + TRiga_documento & rdoc_row = d[k]; + + if (idriga == rdoc_row.get_long(RDOC_IDRIGA)) + { + const real * qta = (const real *) _father_rows.objptr(key); + const TString16 name = rdoc_row.field_qtaevasa(); + real qtaevasa = rdoc_row.get_real(name) + * qta; + + if (qtaevasa < ZERO) + qtaevasa = ZERO; + rdoc_row.put(name, qtaevasa); + if (qtaevasa < rdoc_row.quantita()) + rdoc_row.zero(RDOC_RIGAEVASA); + else + rdoc_row.put(RDOC_RIGAEVASA, "X"); + break; + } + } + } + TToken_string key(d.tipo().codice()); + + key.add(doc().tipo().codice()); + + TStati * stati = (TStati *) _tipidoc_rels.objptr(key); + + if (stati != NULL) + { + const int nrows = d.physical_rows(); + bool evaso = true; + + for (int k = 1; evaso && k <= nrows; k++) + evaso &= d[k].is_evasa(); + d.stato(evaso ? stati->finale() : stati->iniziale()); + } + d.rewrite(); + nrows = 0; + } + last_doc = curr_doc; + nrows++; + } + +} + +bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key ) +{ + if (key == K_SPACE) + { + TMask m("ve0100d"); + TDocumento_mask & mask = (TDocumento_mask &) f.mask(); + const TDocumento& src = mask.doc(); + TCodice_numerazione num(src.numerazione()); + TString4 codnum(num.codnumdef()); + TString4 tipodoc(num.tipodocdef()); + if (!num.newnumdef()) + { + codnum = src.get(DOC_CODNUM); + tipodoc = src.get(DOC_TIPODOC); + } + else + { + codnum = num.get("S8"); + tipodoc = num.get("S9"); + } + bool ok = codnum.full() && tipodoc.full(); + + if (!ok) + { + m.set(F_CODNUM, codnum); + m.enable(F_CODNUM, codnum.blank()); + m.enable(F_DESNUM, codnum.blank()); + m.set(F_TIPODOC, tipodoc); + m.enable(F_TIPODOC, tipodoc.blank()); + m.enable(F_DESTIPODOC, tipodoc.blank()); + ok = m.run() == K_ENTER; + if (ok) + { + codnum = m.get(F_CODNUM); + tipodoc = m.get(F_TIPODOC); + } + } + + ok = codnum.full() && tipodoc.full(); + if (ok) + { + TDocumento dest(src); + + dest.put(DOC_CODNUM, codnum); + dest.put(DOC_TIPODOC, tipodoc); + dest.put(DOC_PROVV, "D"); + dest.zero(DOC_NDOC); + + int err = dest.write(); + + if (err == NOERR) + { + err = src.remove(); + if (err != NOERR) + warning_box("Errore %d nell'eliminazione del documento provvisorio", err); + mask.stop_run(K_ESC); + TMask & qmask = app().query_mask(); + qmask.set(F_CODNUM, codnum); + qmask.set(F_PROVV, dest.get_char(DOC_PROVV)); + qmask.set(F_ANNO, dest.get_int(DOC_ANNO)); + qmask.set(F_NDOC, dest.get_long(DOC_NDOC)); + qmask.field(F_NDOC).update_flags("RP"); + +// qmask.send_key(K_ENTER, 0); + } + else + return error_box("Errore %d nella generazione del documento definitivo", err); + } + } + return ok; +} + diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index 6634ec89d..8de0f5288 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -401,7 +401,7 @@ bool iva_handler( TMask_field& f, KEY key ) if (key == 0 || (key == K_ENTER && f.empty())) { - const TString4 codiva = mask.condv().clifo().vendite().get(CFV_ASSFIS); + const TString4 codiva = mask.doc().codesiva(); if (codiva.not_empty()) f.set(codiva); f.check(); @@ -1632,10 +1632,16 @@ bool liv_handler( TMask_field& f, KEY key ) } if (mask.is_running() && checkgiac) { + TMask& row_mask = f.mask(); + const TString80 codart(row_mask.get(FR_CODART)); + const TRectype & rec = cache().get(LF_ANAMAG, codart); + const bool check_art = rec.get_bool(ANAMAG_LIVPERART); + + if (check_art) + { TLocalisamfile fl(LF_MAG); fl.setkey(2); TRectype & r = fl.curr(); - TMask& row_mask = f.mask(); TEsercizi_contabili esc; const int annoes = esc.date2esc(mask.get_date(F_DATADOC)); @@ -1645,7 +1651,6 @@ bool liv_handler( TMask_field& f, KEY key ) codmag.left_just(3); codmag << row_mask.get(FR_CODDEP); r.put(MAG_CODMAG, codmag); - const TString80 codart(row_mask.get(FR_CODART)); r.put(MAG_CODART, codart); TString liv; @@ -1675,6 +1680,9 @@ bool liv_handler( TMask_field& f, KEY key ) if (err != NOERR) ok = error_box("Non sono riuscito a legare il codice di giacenza. Errore %d", err); } + else + return false; + } } } } diff --git a/ve/velib07.cpp b/ve/velib07.cpp index 266268437..22a688812 100755 --- a/ve/velib07.cpp +++ b/ve/velib07.cpp @@ -27,11 +27,24 @@ const TVariant& TMateriali_base_recordset::get(const char* column_name) const var = row->val(); else { - const TRectype * rec = row->rdist_rec(); - - if (rec != NULL) + if (rownum != _lastrow) { - const TString & v = rec->get(column_name); + ((TMateriali_base_recordset *) this)->_lastrow = rownum; + const TCodice_articolo & comp = row->componente(); + const TCodice_articolo & dist = row->distinta(); + TLocalisamfile rd(LF_RDIST); + + rd.setkey(2); + rd.put("CODCOMP", comp); + rd.put("CODDIST", dist); + if (rd.read() == NOERR) + *_rdist = rd.curr(); + } + + + if (_rdist != NULL) + { + const TString & v = _rdist->get(column_name); var = v; } @@ -54,7 +67,7 @@ void TMateriali_base_recordset::requery() TDistinta_tree distinta; _boom.destroy(); - int pos1 = query_text().find("SCALARE"); + int pos1 = query_text().find("MATBASE"); if (pos1 > 0) { pos1 += 7; @@ -62,9 +75,14 @@ void TMateriali_base_recordset::requery() if (_reverse) pos1++; int pos = query_text().find("==", pos1); + int pos2 = -1; if (pos > 0) { TString val(query_text().mid(pos + 2)); + pos2 = val.find("FILTER"); + + if (pos2 > 0) + val.cut(pos2 - 1); if (val.starts_with("\"") || val.starts_with("'")) { @@ -81,8 +99,47 @@ void TMateriali_base_recordset::requery() if (distinta.set_root(art)) { - const int level = atoi(_query.mid(pos1)); - distinta.explode(_boom, true, RAGGR_EXP_UMDIST, level, "AV"); + while (isspace(query_text()[pos1])) + pos1++; + const int level = atoi(query_text().mid(pos1)); + if (level > 0 || query_text()[pos1] =='0') + while (isdigit(query_text()[pos1])) + pos1++; + while (isspace(query_text()[pos1])) + pos1++; + TString8 filter; + if (query_text()[pos1] != 'S') + while (isalpha(query_text()[pos1])) + filter << query_text()[pos1++]; + distinta.explode(_boom, true, RAGGR_EXP_NONE, level, filter); + } + pos = query_text().find("FILTER", pos); + if (pos > 0) + { + pos = query_text().find("==", pos); + if (pos > 0) + { + TString val(query_text().mid(pos + 2)); + + if (val.starts_with("\"") || val.starts_with("'")) + { + val.ltrim(1); + val.rtrim(1); + } + else + { + TVariant var = get(val); + val = var.as_string(); + } + const int items = _boom.items(); + for (int i = 0; i < items; i++) + { + const TRiga_esplosione * row = (const TRiga_esplosione *)_boom.objptr(i); + if ( row != NULL && row->componente() != val) + _boom.destroy(i); + } + _boom.pack(); + } } } } @@ -90,19 +147,20 @@ void TMateriali_base_recordset::requery() TMateriali_base_recordset::TMateriali_base_recordset(const char* use) : _query(use) { - const TRectype rec(LF_RDIST); - const int nfields = rec.items(); + _lastrow = -1; + _rdist = new TRectype(LF_RDIST); + const int nfields = _rdist->items(); int pos = 1; for ( int i = 0 ; i < nfields; i++) { TRecordset_column_info * ci = new TRecordset_column_info; - ci->_name = rec.fieldname(i); + ci->_name = _rdist->fieldname(i); ci->_pos = pos; - ci->_type = rec.type(ci->_name); + ci->_type = _rdist->type(ci->_name); - const int len = rec.length(ci->_name); + const int len = _rdist->length(ci->_name); pos += len; ci->_width = len; @@ -160,6 +218,34 @@ void TScalare_recordset::requery() filter << query_text()[pos1++]; distinta.explode(boom(), false, RAGGR_EXP_NONE, level, filter); } + pos = query().find("FILTER", pos); + if (pos > 0) + { + pos = query_text().find("==", pos); + if (pos > 0) + { + TString val(query_text().mid(pos + 2)); + + if (val.starts_with("\"") || val.starts_with("'")) + { + val.ltrim(1); + val.rtrim(1); + } + else + { + TVariant var = get(val); + val = var.as_string(); + } + const int items = boom().items(); + for (int i = 0; i < items; i++) + { + const TRiga_esplosione * row = (const TRiga_esplosione *)boom().objptr(i); + if ( row != NULL && row->componente() != val) + boom().destroy(i); + } + boom().pack(); + } + } } } } diff --git a/ve/velib07.h b/ve/velib07.h index 7f4b9f124..a118012cc 100755 --- a/ve/velib07.h +++ b/ve/velib07.h @@ -26,6 +26,8 @@ class TMateriali_base_recordset : public TRecordset long _pos; TArray _column; bool _reverse; + long _lastrow; + TRectype * _rdist; protected: @@ -37,7 +39,7 @@ protected: public: virtual TRecnotype items() const { return _boom.items(); } - virtual bool move_to(TRecnotype pos) { _pos = pos; return pos < items();} + virtual bool move_to(TRecnotype pos) { _pos = pos; _lastrow = -1; return pos < items();} virtual TRecnotype current_row() const { return _pos; } virtual void requery(); virtual unsigned int columns() const { return _column.items();} @@ -46,7 +48,7 @@ public: virtual const TVariant& get(const char* column_name) const; TMateriali_base_recordset(const char* use); - virtual ~TMateriali_base_recordset(){ } + virtual ~TMateriali_base_recordset(){ delete _rdist;} }; /////////////////////////////////////////////////////////// diff --git a/ve/vepriv.h b/ve/vepriv.h index 321b0f481..d597c9b84 100755 --- a/ve/vepriv.h +++ b/ve/vepriv.h @@ -6,7 +6,7 @@ enum _formule {_somma, _bolli, _bolli_int, _spinc, _prezzo, _importo, _imponibil _tipo_ritenuta, _quant, _quantevasa, _componente, _comp_qta, _nrate}; enum TTipo_calcolo { _nessun_calcolo, _qtaprezzo, _valore, _percentuale, _scontopi}; -void row_set_handler( TMask& m, const int field, const int index ); +void row_set_handler( TMask& m, const int field, const int index, TTipo_riga_documento & t, const TString & tipodoc ); bool liv_handler( TMask_field& f, KEY key ); bool sppr_handler( TMask_field& f, KEY key ); bool codartmag_handler( TMask_field& f, KEY key ); diff --git a/ve/vetbnum.uml b/ve/vetbnum.uml index b8319020c..95ab07a91 100755 --- a/ve/vetbnum.uml +++ b/ve/vetbnum.uml @@ -70,7 +70,7 @@ PAGE "Numerazione documenti" 0 0 0 0 MESSAGE FALSE CLEAR,2@ MESSAGE TRUE ENABLE,2@ GROUP 1 - FIELD B8 + FIELD B9 FLAGS "DG" END STRING F_CODNUM 4