diff --git a/ve/bollaf.src b/ve/bollaf.src index 9152a7150..a53c327fa 100755 --- a/ve/bollaf.src +++ b/ve/bollaf.src @@ -140,10 +140,13 @@ Col(9) = FR_QTA Col(10) = FR_LORDO Col(11) = FR_PREZZO Col(12) = FR_CODIVA -Col(13) = FR_CAUS -Col(14) = FR_CODMAGC -Col(15) = FR_CODDEPC -Col(16)=FR_TIPORIGA +Col(13)= FR_NCOLLI +Col(14)= FR_PNETTO +Col(15)= FR_TARA +Col(16) = FR_CAUS +Col(17) = FR_CODMAGC +Col(18) = FR_CODDEPC +Col(19) = FR_TIPORIGA [RIGHE] diff --git a/ve/sconti.cpp b/ve/sconti.cpp index 58bda9406..ee0e325d7 100755 --- a/ve/sconti.cpp +++ b/ve/sconti.cpp @@ -17,9 +17,9 @@ #include "../pr/agenti.h" #include "../pr/percprov.h" -bool TCond_vendita::set_sconto( const char * exp, bool signal ) +bool TCond_vendita::set_sconto(const char* exp, bool signal) { - bool valid= scontoexpr2perc(exp,signal,_sconto,_molt_sconto); + bool valid = scontoexpr2perc(exp, signal, _sconto, _molt_sconto); if (_load_mask && _riga && _riga->id2pos(FR_SCONTO) >= 0 && _riga->field(FR_SCONTO).active()) _riga->set(FR_SCONTO, _sconto); return valid; @@ -87,10 +87,9 @@ bool TCond_vendita::cerca( int tiporicerca ) { case A_CONTRATTI: { - const TString16 codcont(testa().get(F_CODCONT)); - - if (codcont.empty()) - return FALSE; + const TString16 codcont = testa().get(F_CODCONT); + if (codcont.blank()) + return false; _condv.put(CONDV_TIPO, "C"); if(config_ditta.get_bool("GESCONCC", "ve")) { @@ -102,10 +101,9 @@ bool TCond_vendita::cerca( int tiporicerca ) break; case A_LISTINI: { - const TString16 codlist(testa().get(F_CODLIST)); - - if (codlist.empty()) - return FALSE; + const TString16 codlist = testa().get(F_CODLIST); + if (codlist.blank()) + return false; _condv.put(CONDV_TIPO, "L"); // Se in ditta h abilitata la gestione della categoria di vendita in chiave // al listino, la carico con gioia @@ -319,6 +317,121 @@ real TCond_vendita::get_percprovv(char tipoprovv, const TString & codpr, bool fi return val; } +bool TCond_vendita::try_sconto(char gestione, bool found_condv, bool load_um_only, bool load_scagl_only) +{ + TString80 sconto; + + switch (gestione) + { + case 'L': + // Percentuale su contratti/offerte/listini/anagrafica + if (found_condv) + { + const bool cv_scagl = _condv.get_bool("GESTSCAGL"); + const bool cv_um = _condv.get_bool("GESTUM"); + + _load_mask |= load_scagl_only && cv_scagl; + _load_mask |= load_um_only && cv_um; + sconto = _rcondv.get("SCONTO"); + _load_mask = !load_um_only && !load_scagl_only; + } + else + sconto = _anamag.get("SCONTO"); + break; + case 'A': + { + TConfig config_ditta(CONFIG_DITTA, "ve"); + const bool sco_scagl = config_ditta.get_bool("GESSCOSCA"); + const bool sco_um_gest = config_ditta.get_bool("GESSCORIGAUM"); + const char rigakey = config_ditta.get_char( "SCORIGAKEY"); + + // Posiziono l'anagrafica + _sconti.setkey(1); + _sconti.put("TIPO", "R"); + if( config_ditta.get_bool("GESSCORIGACV")) + _sconti.put("CODCAT", testa().get(F_CATVEN)); + if (sco_um_gest) + _sconti.put("UM", riga().get( FR_UMQTA)); + _sconti.put("TIPORIGA", rigakey); + + if (sco_scagl) + _sconti.put("NSCAGL", 1); + + switch (rigakey) + { + case 'A': + { + const TString& codriga = riga().get(FR_CODARTMAG); + _sconti.put("CODART", codriga); + _sconti.read(); + } + break; + case 'R': + _sconti.put("CODART", _anamag.get("RAGGFIS")); + _sconti.read(); + break; + case 'C': + { + _sconti.put( "CODART", _anamag.get("GRMERC")); + _sconti.read( ); + } + break; + case 'L': + { + _sconti.put("CODART", _anamag.get("GRMERC").left(3)); + _sconti.read(); + } + break; + default: + { + const TString& codriga = riga().get(FR_CODARTMAG); + _sconti.put("CODART", codriga); + _sconti.read(); + } + break; + } + + const bool found = _sconti.good(); + if (found && sco_scagl) + { + TRectype rec(_sconti.curr()); + int last_scagl = 0; + int scagl = _sconti.get_int("NSCAGL"); + const real qta(_riga->get_real(FR_QTA)); + real qta_lim(_sconti.get_real("QLIM")); + + while (_sconti.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim) + { + if (_sconti.next() == NOERR) + { + last_scagl = scagl; + scagl = _sconti.get_int("NSCAGL"); + qta_lim =_sconti.get_real("QLIM"); + rec = _sconti.curr(); + } + } + _rcondv.read(rec); + } + if (!found) + _sconti.zero(); + _load_mask |= load_scagl_only && sco_scagl; + _load_mask |= load_scagl_only && sco_um_gest; + sconto = _sconti.get("SCONTO"); + _load_mask = !load_um_only && !load_scagl_only; + } + break; + case 'C': + sconto = clifo().vendite().get(CFV_SCONTO); + break; + default: + sconto.cut(0); + break; + } + + return set_sconto(sconto) && sconto.full(); +} + + void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) { const TString80 codriga = riga().get( FR_CODARTMAG ); @@ -342,22 +455,18 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) real prezzo; bool found_prezzo = false; const TArticolo_giacenza & art = cached_article_balances(codriga); - static TTipo_valorizz __tipo = (TTipo_valorizz) -883; const TTipo_riga_documento tiporiga(riga().get(FR_TIPORIGA));; - if (__tipo == -883) - { - TConfig c(CONFIG_DITTA, "ve"); - __tipo = (TTipo_valorizz) (c.get_int("PriceOmaggi") - 1); - } - if (tiporiga.tipo() == RIGA_OMAGGI) + if (tiporiga.tipo() == RIGA_OMAGGI) { const int annoes = esercizi().date2esc(testa().get_date(F_DATADOC)); const TString4 codmag = riga().get(FR_CODMAG); const TString80 livello = riga().get(MAG_LIVELLO); found_prezzo = true; - switch (__tipo) + + const TTipo_valorizz tvo = TTipo_valorizz(ini_get_int(CONFIG_DITTA, "ve", "PriceOmaggi") - 1); + switch (tvo) { case valorizz_ultcos: prezzo = art.ultimo_costo(annoes); @@ -399,9 +508,8 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) } } - const TString16 umriga(riga().get(FR_UMQTA)); - - if (umriga.not_empty()) + const TString4 umriga(riga().get(FR_UMQTA)); + if (umriga.full()) { _umart.setkey(2); _umart.put("CODART", codriga); @@ -411,7 +519,7 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) } bool prezzo_lordo = false; - TString16 valuta; + TString4 valuta; bool found_condv = false; const bool cv_scagl = _condv.get_bool("GESTSCAGL"); const bool cv_um = _condv.get_bool("GESTUM"); @@ -419,7 +527,6 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) if (!found_prezzo) { found_condv = cerca(A_CONTRATTI) || cerca(A_OFFERTE) || cerca(A_LISTINI); - if (found_condv) { _load_mask |= load_scagl_only && cv_scagl; @@ -432,9 +539,8 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) } else { - TString16 field_prezzo(testa().doc().tipo().field_prezzo()); - - if (field_prezzo.empty()) + TString16 field_prezzo = testa().doc().tipo().field_prezzo(); + if (field_prezzo.blank()) prezzo = _umart.get_real("PREZZO"); else prezzo = _anamag.get_real(field_prezzo); @@ -442,12 +548,12 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) _prov = "A"; } } - if (doc_al_lordo) + + if (doc_al_lordo) { if (!prezzo_lordo) { - TCodiceIVA iva(_anamag.get("CODIVA")); - + const TCodiceIVA iva(_anamag.get("CODIVA")); prezzo = iva.lordo(prezzo, AUTO_PRICES_DECIMALS, valuta); } } @@ -455,140 +561,36 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) { if (prezzo_lordo) { - TCodiceIVA iva(_anamag.get("CODIVA")); - + const TCodiceIVA iva(_anamag.get("CODIVA")); iva.scorpora(prezzo, AUTO_PRICES_DECIMALS, valuta); } } - set_prezzo(prezzo, valuta); + set_iva(_anamag.get(_ivarid ? ANAMAG_CODIVAR : ANAMAG_CODIVA)); + + // Gestione sconti di riga + const char gestione1 = ini_get_string(CONFIG_DITTA, "ve", "GESSCORIGA")[0]; + if (!try_sconto(gestione1, found_condv, load_um_only, load_scagl_only) && gestione1 > ' ') + { + const char gestione2 = ini_get_string(CONFIG_DITTA, "ve", "GESSCORIGA2")[0]; + if (gestione2 != gestione1 && (gestione2 == 'A' || gestione2 == 'C' || gestione2 == 'L')) + try_sconto(gestione2, found_condv, load_um_only, load_scagl_only); + } - if (_ivarid) - set_iva(_anamag.get(ANAMAG_CODIVAR)); - else - set_iva(_anamag.get(ANAMAG_CODIVA)); - - TConfig config_ditta(CONFIG_DITTA, "ve"); - const char gestione = config_ditta.get_char( "GESSCORIGA", "ve" ); - const bool sco_scagl = config_ditta.get_bool("GESSCOSCA", "ve"); - const bool sco_um_gest = config_ditta.get_bool("GESSCORIGAUM", "ve"); - - switch (gestione) - { - case 'N': - // Sconti di riga non gestiti - set_sconto(""); - break; - case 'L': - // Percentuale su contratti/offerte/listini/anagrafica - if (found_condv) - { - _load_mask |= load_scagl_only && cv_scagl; - _load_mask |= load_um_only && cv_um; - set_sconto(_rcondv.get("SCONTO")); - _load_mask = !load_um_only && !load_scagl_only; - } - else - set_sconto(_anamag.get("SCONTO")); - break; - case 'A': - { - // Posiziono l'anagrafica - const char rigakey = config_ditta.get_char( "SCORIGAKEY", "ve" ); - - _sconti.setkey(1); - _sconti.put("TIPO", "R"); - if( config_ditta.get_bool("GESSCORIGACV", "ve")) - _sconti.put("CODCAT", testa().get(F_CATVEN)); - if (sco_um_gest) - _sconti.put("UM", riga().get( FR_UMQTA)); - _sconti.put("TIPORIGA", rigakey); - - if (sco_scagl) - _sconti.put("NSCAGL", 1); - - switch (rigakey) - { - case 'A': - _sconti.put("CODART", codriga); - _sconti.read(); - break; - case 'R': - _sconti.put("CODART", _anamag.get("RAGGFIS")); - _sconti.read(); - break; - case 'C': - { - _sconti.put( "CODART", _anamag.get("GRMERC")); - _sconti.read( ); - } - break; - case 'L': - { - _sconti.put("CODART", _anamag.get("GRMERC").left(3)); - _sconti.read(); - } - break; - default: - _sconti.put("CODART", codriga); - _sconti.read(); - break; - } - - const bool found = _sconti.good(); - - if (found && sco_scagl) - { - TRectype rec(_sconti.curr()); - int last_scagl = 0; - int scagl = _sconti.get_int("NSCAGL"); - const real qta(_riga->get_real(FR_QTA)); - real qta_lim(_sconti.get_real("QLIM")); - - while (_sconti.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim) - { - if (_sconti.next() == NOERR) - { - last_scagl = scagl; - scagl = _sconti.get_int("NSCAGL"); - qta_lim =_sconti.get_real("QLIM"); - rec = _sconti.curr(); - } - } - _rcondv.read(rec); - } - if (!found) - _sconti.zero(); - _load_mask |= load_scagl_only && sco_scagl; - _load_mask |= load_scagl_only && sco_um_gest; - set_sconto(_sconti.get("SCONTO")); - _load_mask = !load_um_only && !load_scagl_only; - } - break; - case 'C': - set_sconto(clifo().vendite().get(CFV_SCONTO)); - break; - default: - set_sconto(""); - break; - } - if (_riga && _riga->id2pos(FR_PERCPROV) >= 0 && _riga->field(FR_PERCPROV).active()) { - const TString & codage = _testa->get(F_CODAG); - + const TString& codage = _testa->get(F_CODAG); if (codage.full()) { - const TRectype & age = cache().get(LF_AGENTI, codage); - + const TRectype& age = cache().get(LF_AGENTI, codage); if (!age.empty()) { TString16 seqric(age.get(AGE_SEQRIC)); real percprovv; if (seqric[0] == '-') - seqric = config_ditta.get( "AGETIPOPERC", "ve" ); + seqric = ini_get_string(CONFIG_DITTA, "ve", "AGETIPOPERC"); int len = seqric.len(); int i; @@ -626,27 +628,26 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only) if (!age.empty()) { - TString16 seqric(age.get(AGE_SEQRIC)); - real percprovv; - + TString16 seqric = age.get(AGE_SEQRIC); if (seqric[0] == '-') - seqric = config_ditta.get( "AGETIPOPERC", "ve" ); + seqric = ini_get_string(CONFIG_DITTA, "ve", "AGETIPOPERC"); - int len = seqric.len(); - int i; - + _load_mask |= load_scagl_only && cv_scagl; _load_mask |= load_scagl_only && cv_um; - for (i = 0; percprovv.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++) + + real percprovv; + for (int i = 0; percprovv.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++) { TString16 codric; if (isdigit(seqric[i])) codric = age.get(format("CODRICPR%d", i+1)); percprovv = get_percprovv(seqric[i], codric, false, age); } + real percalt; seqric = age.get(AGE_SEQALT); - for (i = 0; percalt.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++) + for (int i = 0; percalt.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++) { TString16 codric; if (isdigit(seqric[i])) @@ -698,12 +699,12 @@ void TCond_vendita::update_omaggi(bool full) { tipo_riga = "09"; cnf.set("TROMAGGI", tipo_riga); - warning_box(FR("Il tipo riga omaggi non risultava impostato.\nL'applicazione usera' automaticamente il tipo %s"), + warning_box(FR("Il tipo riga omaggi non risultava impostato.\nL'applicazione userà automaticamente il tipo %s"), (const char*) tipo_riga); } } const real qbase = _rcondv.get_real("QBASE"); - if (qbase == ZERO) + if (qbase.is_zero()) qta = ZERO; else { @@ -711,7 +712,7 @@ void TCond_vendita::update_omaggi(bool full) qta.floor(); qta *= _rcondv.get_real(RCONDV_QOM); } - creata = codart_omaggio.not_empty() && tipo_riga.not_empty() && qta != ZERO; + creata = codart_omaggio.not_empty() && tipo_riga.not_empty() && !qta.is_zero(); if (creata) { diff --git a/ve/sconti.h b/ve/sconti.h index 24779a821..33c005a69 100755 --- a/ve/sconti.h +++ b/ve/sconti.h @@ -16,7 +16,7 @@ class TConfig; class TCond_vendita : public TObject { TString80 _sconto; - TString16 _codiva; + TString4 _codiva; TString4 _prov; real _prezzo; real _provv; @@ -47,10 +47,11 @@ protected: TDocumento_mask & testa() const { CHECK(_testa, "Maschera testata non inizializzata"); return * _testa; } TMask & riga() const { CHECK(_riga, "Maschera riga non inizializzata"); return * _riga; } + bool try_sconto(char gestione, bool found_condv, bool load_um_only, bool load_scagl_only); public: TCli_for & clifo() const { return _testa->doc().clifor(); } - bool set_sconto( const char * exp, bool signal = FALSE ); + bool set_sconto( const char* exp, bool signal = false); const TString& get_sconto() const { return _sconto; } real sconto_val() const { return _molt_sconto;} real get_prezzo() const { return _prezzo; } diff --git a/ve/ve0200a.uml b/ve/ve0200a.uml index 4eccefb16..20216e974 100755 --- a/ve/ve0200a.uml +++ b/ve/ve0200a.uml @@ -164,9 +164,9 @@ GROUP 4 FIELD SCOKEY[4] END -LIST F_GESSCORIGA 45 +LIST F_GESSCORIGA 1 45 BEGIN -PROMPT 2 8 "Tipo gestione sconti riga " +PROMPT 2 7 "Gestione sconti riga principale " ITEM "N|Non gestire" MESSAGE CLEAR,5@ ITEM "L|Percentuale su anagrafica/listini/contratti " MESSAGE CLEAR,5@ ITEM "A|Gestione archivio sconti " MESSAGE ENABLE,5@ @@ -174,6 +174,16 @@ ITEM "C|Percentuale indicata su anagrafica cliente " MESSAGE CLEAR,5@ FIELD GESSCORIGA END +LIST F_GESSCORIGA2 1 45 +BEGIN +PROMPT 2 8 "Gestione sconti riga secondaria " +ITEM "N|Non gestire" +ITEM "L|Percentuale su anagrafica/listini/contratti " +ITEM "A|Gestione archivio sconti " MESSAGE ENABLE,5@ +ITEM "C|Percentuale indicata su anagrafica cliente " +FIELD GESSCORIGA2 +END + BOOLEAN F_GESSCORIGACV BEGIN PROMPT 2 9 "Gestione archivio sconti con categorie vendita cliente " diff --git a/ve/veconf.h b/ve/veconf.h index 3b04f1cb5..b8adf15f1 100755 --- a/ve/veconf.h +++ b/ve/veconf.h @@ -28,6 +28,7 @@ #define F_SCOKEY4 124 #define F_GESSCORIGA 125 +#define F_GESSCORIGA2 119 #define F_GESSCORIGACV 126 #define F_SCORIGAKEY 127 diff --git a/ve/velib.h b/ve/velib.h index 62ea02340..b57b5fa13 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -1102,7 +1102,7 @@ public: void set_codnum(const char* codnum); void set_ndoc(const long ndoc); - TDoc_key& operator= (const char* key) {set(key); } + TDoc_key& operator=(const char* key) { set(key); return *this; } TDoc_key(const int anno, const TString& codnum, const long ndoc, const char provv = 'D'); TDoc_key(const TRectype& rec); diff --git a/ve/velib02.cpp b/ve/velib02.cpp index 4f0898b97..682b5d655 100755 --- a/ve/velib02.cpp +++ b/ve/velib02.cpp @@ -554,7 +554,7 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const TCond_vendita cv(NULL, NULL); cv.set_sconto(get("SCONTO")); - if (cv.get_sconto().not_empty()) + if (cv.get_sconto().full()) { importo = doc().basesconto(); importo *= (cv.sconto_val() - UNO); diff --git a/ve/velib06.cpp b/ve/velib06.cpp index 44d3051a2..1e90c0dc4 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -1844,7 +1844,7 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key ) for (int i = 1; i <= rows; i++) if (i != r + 1 && codart == doc[i].get(RDOC_CODART)) - if ( !yesno_box(FR("L'articolo %s e' presente alla riga %d, si desdiera continuare"), (const char *)codart, i)) + if ( !yesno_box(FR("L'articolo %s e' presente alla riga %d, si desidera continuare"), (const char *)codart, i)) return false; } } @@ -3717,7 +3717,7 @@ void TDocumento_mask::user_set_handler(short fieldid, int index) break; case 6: set_field_handler(fieldid, fido_hndl); - break; + break; default: break; } diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index bbc6d0c03..cd7874b3c 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -156,25 +156,26 @@ bool fido_hndl(TMask_field& field, KEY key) { if (key == K_ENTER && !field.empty()) { - TDocumento_mask & m = (TDocumento_mask &) field.mask(); - const real fido_bau(field.get()); - const char tipocf = m.get(F_TIPOCF)[0]; - const long codcf = m.get_long(F_CODCF); - const TDate& datadoc = m.get_date(F_DATADOC); - const int riskdays = ini_get_int(CONFIG_DITTA, "ve", "FIDO_RISKDAYS"); - const real perc_toll = ini_get_string(CONFIG_DITTA, "ve", "FIDO_PERCTOLL"); - //calcola l'esposizione PRIMA del documento corrente - const real esposizione = calcola_fido_cliente (tipocf, codcf, datadoc, riskdays); - //prende il valore del documento corrente - const real totdoc = m.doc().totale_doc(); - //esposizione comprensiva del documento corrente - const real esposizione_totale = esposizione + totdoc; - const real fido_con_tolleranza = fido_bau * (CENTO + perc_toll) / CENTO; - - if (esposizione_totale > fido_con_tolleranza) - return yesno_box(FR("Attenzione! Il cliente %ld risulta fuori fido.\nEsposizione corrente: %s\n" - "Tot. Doc. corrente: %s\nEsposizione totale: %s\nRegistrare ugualmente il documento?"), - codcf, esposizione.stringa(), totdoc.stringa(), esposizione_totale.stringa()); + const TDocumento_mask& m = (TDocumento_mask&)field.mask(); + if (m.insert_mode() || m.get(F_STATO) == "1") + { + const real fido_bau(field.get()); + const long codcf = m.get_long(F_CODCF); + const TDate datadoc = m.get_date(F_DATADOC); + const TDoc_key ignore_key = m.doc(); + const real perc_toll = ini_get_string(CONFIG_DITTA, "ve", "FIDO_PERCTOLL"); + //calcola l'esposizione PRIMA del documento corrente + const real esposizione = calcola_fido_cliente(codcf, datadoc, ignore_key); + //prende il valore del documento corrente + const real totdoc = m.doc().totale_doc(); + //esposizione comprensiva del documento corrente + const real esposizione_totale = esposizione + totdoc; + const real fido_con_tolleranza = fido_bau * (CENTO + perc_toll) / CENTO; + if (esposizione_totale > fido_con_tolleranza) + return yesno_box(FR("Attenzione! Il cliente %ld risulta fuori fido.\nEsposizione corrente: %s\n" + "Tot. Doc. corrente: %s\nEsposizione totale: %s\nRegistrare ugualmente il documento?"), + codcf, esposizione.stringa(), totdoc.stringa(), esposizione_totale.stringa()); + } } return true; } @@ -222,7 +223,7 @@ bool ora_hndl( TMask_field& field, KEY key ) bool dummy_hndl(TMask_field& field, KEY key) { - warning_box(FR("Al campo %d è arrivato un KEY %d"), field.dlg( ), key ); + warning_box(FR("Al campo %d è arrivata una KEY %d"), field.dlg( ), key ); return true; } @@ -234,7 +235,7 @@ bool condpag_hndl( TMask_field& field, KEY key ) if ( field.to_check(key) || (key == K_TAB && !m.is_running())) { const TString& condpag = m.get(F_CODPAG); - if (condpag.not_empty()) + if (condpag.full()) { TDocumento& doc = m.doc(); // Aggiorna dati necessari per determinare il pagamento @@ -2160,14 +2161,13 @@ bool qtaart_handler( TMask_field& f, KEY key ) } real qta(row.get(sf.cid2index(FR_QTA))); - const TString16 caus(mask.get(F_CAUSMAG)); + const TString8 caus = mask.get(F_CAUSMAG); const TCausale_magazzino & c = cached_causale_magazzino(caus); const long nmovmag = doc.get_long(DOC_MOVMAG); if (nmovmag != 0) { - TLocalisamfile rmovmag(LF_RMOVMAG); - + TLocalisamfile rmovmag(LF_RMOVMAG); rmovmag.setkey(2); rmovmag.put(RMOVMAG_CODART, codart); rmovmag.put(RMOVMAG_LIVGIAC, livello); @@ -2180,19 +2180,16 @@ bool qtaart_handler( TMask_field& f, KEY key ) qta *= mask.fconv_qta(); if (doc.tipo().check_giac()) { - real giac(mask.get(F_CURGIAC)); - - if (giac < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione giacenza negativa, Devo continuare ?")) + const real giac = mask.get(F_CURGIAC); + if (giac < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione giacenza negativa: si desidera continuare?")) + return false; + } else + if (doc.tipo().check_disp()) + { + const real disp = mask.get(F_CURDISP); + if (disp < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione disponibilità negativa: si desidera continuare?")) return false; } - else - if (doc.tipo().check_disp()) - { - real disp(mask.get(F_CURDISP)); - - if (disp < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione disponibilita' negativa, Devo continuare ?")) - return false; - } } } } diff --git a/ve/velib07.cpp b/ve/velib07.cpp index 27b5e068e..0b668e11b 100755 --- a/ve/velib07.cpp +++ b/ve/velib07.cpp @@ -628,7 +628,7 @@ static const TString_array& mastro(char tipocf) return a; } -static real calcola_saldo_contabile(const char tipocf, const long codcf, const TDate& datacalc) +static real calcola_saldo_contabile(const long codcf, const TDate& datacalc) { real saldone; @@ -644,7 +644,7 @@ static real calcola_saldo_contabile(const char tipocf, const long codcf, const T datainies.set_month(1); } - const TString_array& a = mastro(tipocf); + const TString_array& a = mastro('C'); //per tutti i mastri selezionati va a calcolare il saldo del cliente/fornitore in input FOR_EACH_ARRAY_ROW(a, i, row) @@ -669,18 +669,18 @@ static TImporto get_importo(const TISAM_recordset& partite, const char* sezione, } -static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays) +static real calcola_esposto_da_saldaconto (long codcf, const TDate& datacalc) { + const int riskdays = ini_get_int(CONFIG_DITTA, "ve", "FIDO_RISKDAYS"); + //estrae le righe partita relative a pagamenti successivi alla data di rischio (e con tipopag >2,<7) TString query; query << "USE PART\nSELECT BETWEEN(DATAPAG,#DATASBF,0)&&BETWEEN(TIPOPAG,2,7)\n"; - query << "FROM TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF ANNO=#ANNO\n"; - query << "TO TIPOC=#TIPOCF GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF"; + query << "FROM TIPOC=C GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF ANNO=#ANNO\n"; + query << "TO TIPOC=C GRUPPO=0 CONTO=0 SOTTOCONTO=#CODCF"; TISAM_recordset partite(query); - TString4 str_tipocf = tipocf; - partite.set_var("#TIPOCF", TVariant(str_tipocf)); partite.set_var("#CODCF", codcf); partite.set_var("#DATACALC", datacalc); //data considerante i giorni di rischio ammessi dall'utonto @@ -719,8 +719,8 @@ static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf, } //la normalizzazione del totale delle partite va fatta in base al fatto che si parli di 'C'liente o 'F'ornitore - const char sezione_finale = (tipocf == 'C') ? 'A' : 'D'; - importone_esposto.normalize(sezione_finale); + //const char sezione_finale = (tipocf == 'C') ? 'A' : 'D'; + importone_esposto.normalize('A'); //valore in output real esposto; @@ -730,69 +730,73 @@ static real calcola_esposto_da_saldaconto (const char tipocf, const long codcf, } -static real calcola_fido_da_documenti(const char tipocf, const long codcf, const TDate& datacalc) +static real calcola_fido_da_documenti(long codcf, const TDate& datacalc, const TDoc_key& ignore) { real totalone; - TConfig config(CONFIG_DITTA, "ve"); - //scansione delle righe FIDO_XX(j)=.. sul paragrafo di configurazione VE per avere i parametri di numerazione/tipo.. - //..da considerare - for (int j = 0;;j++) + // scansione delle righe FIDO_XX(j)=.. sul paragrafo di configurazione VE + // per avere i parametri di numerazione/tipo da considerare + TConfig config(CONFIG_DITTA, "ve"); + for (int j = 0; ;j++) { const TString& num_fido = config.get("FIDO_NUM", NULL, j); //se manca la numerazione si può fermare,in quanto non può esistere un tipo senza numerazione if (num_fido.blank()) break; - const TString& tipo_fido = config.get("FIDO_TIP", NULL, j); - const TString4 da_stato_fido = config.get("FIDO_DASTA", NULL, j); - const TString4 a_stato_fido = config.get("FIDO_ASTA", NULL, j); - const bool residuo_fido = config.get_bool("FIDO_RES", NULL, j); + const TString& tipo_fido = config.get("FIDO_TIP", NULL, j); + const TString& da_stato_fido = config.get("FIDO_DASTA", NULL, j); + const TString& a_stato_fido = config.get("FIDO_ASTA", NULL, j); + const bool residuo_fido = config.get_bool("FIDO_RES", NULL, j); //per la numerazione scelta queryzza gli archivi alla ricerca dei documenti che rientrano nei parametri TString query; query << "USE DOC KEY 2\n"; query << "SELECT (CODNUM=#CODNUM)&&(TIPODOC=#TIPODOC)&&(BETWEEN(STATO,#DASTATO,#ASTATO))\n"; - query << "FROM TIPOCF=#TIPOCF CODCF=#CODCF PROVV='D'\n"; - query << "TO TIPOCF=#TIPOCF CODCF=#CODCF PROVV='D' ANNO=#ANNO DATADOC=#DATACALC"; + query << "FROM TIPOCF=C CODCF=#CODCF PROVV='D'\n"; + query << "TO TIPOCF=C CODCF=#CODCF PROVV='D' ANNO=#ANNO DATADOC=#DATACALC"; TISAM_recordset documenti(query); - const char str_tipocf[2] = { tipocf, 0 }; - documenti.set_var("#TIPOCF", TVariant(str_tipocf)); - documenti.set_var("#CODCF", codcf); - documenti.set_var("#ANNO", TVariant((long)datacalc.year())); + documenti.set_var("#CODCF", codcf); + documenti.set_var("#ANNO", (long)datacalc.year()); documenti.set_var("#DATACALC", datacalc); - documenti.set_var("#CODNUM", TVariant(num_fido)); - documenti.set_var("#TIPODOC", TVariant(tipo_fido)); - documenti.set_var("#DASTATO", TVariant(da_stato_fido)); - documenti.set_var("#ASTATO", TVariant(a_stato_fido)); + documenti.set_var("#CODNUM", num_fido); + documenti.set_var("#TIPODOC", tipo_fido); + documenti.set_var("#DASTATO", da_stato_fido); + documenti.set_var("#ASTATO", a_stato_fido); const int items = documenti.items(); - - //adesso che ha i documenti che cercava.. - for (bool ok = documenti.move_first(); ok; ok = documenti.move_next()) + if (items > 0) { - const TDocumento doc(documenti.cursor()->curr()); - //deve tener conto di eventuali docs in valuta - TCurrency_documento totdoc(ZERO, doc); - - //documento a residuo (tipo ordini) - if (residuo_fido) + const TRectype& curr = documenti.cursor()->curr(); + //adesso che ha i documenti che cercava.. + for (bool ok = documenti.move_first(); ok; ok = documenti.move_next()) { - totdoc.set_num(doc.valore(false, true)); + if (ignore.full()) + { + const TDoc_key k(curr); + if (k == ignore) + continue; + } + + const TDocumento doc(curr); + //deve tener conto di eventuali docs in valuta + TCurrency_documento totdoc(ZERO, doc); + + //documento a residuo (tipo ordini) + if (residuo_fido) + totdoc.set_num(doc.valore(false, true)); + else //documento normale (tipo fattura) + totdoc.set_num(doc.totale_doc()); + + totdoc.change_to_firm_val(); + + //le nac vanno con segno rovesciato + if (doc.is_nota_credito()) + totdoc = -totdoc; + + totalone += totdoc.get_num(); } - else //documento normale (tipo fattura) - { - totdoc.set_num(doc.totale_doc()); - } - - totdoc.change_to_firm_val(); - - //le nac vanno con segno rovesciato - if (doc.is_nota_credito()) - totdoc = -totdoc; - - totalone += totdoc.get_num(); } } @@ -801,14 +805,14 @@ static real calcola_fido_da_documenti(const char tipocf, const long codcf, const //metodo per il calcolo fido di un cliente ad una data definita -real calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays) +real calcola_fido_cliente (long codcf, const TDate& datacalc, const TDoc_key& ignore) { //PRIMA PARTE: controlla i movimenti - real saldo_contabile = calcola_saldo_contabile(tipocf, codcf, datacalc); + real saldo_contabile = calcola_saldo_contabile(codcf, datacalc); //SECONDA PARTE: controlla il saldaconto - real esposto_saldaconto = calcola_esposto_da_saldaconto(tipocf, codcf, datacalc, riskdays); + real esposto_saldaconto = calcola_esposto_da_saldaconto(codcf, datacalc); //TERZA PARTE: controlla i documenti - real tot_documenti = calcola_fido_da_documenti(tipocf, codcf, datacalc); + real tot_documenti = calcola_fido_da_documenti(codcf, datacalc, ignore); return saldo_contabile + esposto_saldaconto + tot_documenti; } diff --git a/ve/velib07.h b/ve/velib07.h index 1ccffd384..3e115416a 100755 --- a/ve/velib07.h +++ b/ve/velib07.h @@ -118,12 +118,12 @@ public: bool load(const char* name); }; - /////////////////////////////////////////////// // Metodi non appartenenti a classi /////////////////////////////////////////////// + //metodo per il calcolo del fido cliente -real calcola_fido_cliente (const char tipocf, const long codcf, const TDate& datacalc, const int riskdays); +real calcola_fido_cliente (long codcf, const TDate& datacalc, const TDoc_key& ignore); #endif diff --git a/ve/vetbatr.h b/ve/vetbatr.h index 1e0dfa258..1b986e4b9 100755 --- a/ve/vetbatr.h +++ b/ve/vetbatr.h @@ -18,6 +18,8 @@ #define ATR_QTA 120 #define ATR_UM 121 #define ATR_PRESTAZ 122 +#define ATR_CODART 123 +#define ATR_DESCART 124 #define ATR_CDC_V1 211 #define ATR_CDC_V2 212 diff --git a/ve/vetbatr.uml b/ve/vetbatr.uml index 1799afd92..0d14ffeb0 100755 --- a/ve/vetbatr.uml +++ b/ve/vetbatr.uml @@ -118,6 +118,32 @@ BEGIN CHECKTYPE NORMAL END +STRING ATR_CODART 20 +BEGIN + PROMPT 2 7 "Articolo (CI) " + USE LF_ANAMAG + INPUT CODART ATR_CODART + DISPLAY "Codice@20" CODART + DISPLAY "Descrizione@50" DESCR + OUTPUT ATR_CODART CODART + OUTPUT ATR_DESCART DESCR + CHECKTYPE NORMAL + FLAGS "U" + FIELD S2 +END + +STRING ATR_DESCART 50 34 +BEGIN + PROMPT 40 7 "" + USE LF_ANAMAG KEY 2 + INPUT DESCR ATR_DESCART + DISPLAY "Descrizione@50" DESCR + DISPLAY "Codice@20" CODART + COPY OUTPUT ATR_CODART + CHECKTYPE NORMAL + FLAGS "U" +END + LISTBOX ATR_CAMPI 15 BEGIN PROMPT 2 8 "Campo default " @@ -166,25 +192,25 @@ END DATE ATR_DISMISS BEGIN - PROMPT 2 11 "Data dismissione " + PROMPT 2 10 "Data dismissione " FIELD D0 END NUMBER ATR_GRUPPOA 3 BEGIN - PROMPT 2 12 "Conto acquisti " + PROMPT 2 11 "Conto acquisti " FIELD I3 END NUMBER ATR_CONTOA 3 BEGIN - PROMPT 22 12 "" + PROMPT 22 11 "" FIELD I4 END NUMBER ATR_SOTTOA 6 BEGIN - PROMPT 28 12 "" + PROMPT 28 11 "" FIELD I5 USE LF_PCON SELECT SOTTOCONTO!="" INPUT GRUPPO ATR_GRUPPOA @@ -205,7 +231,7 @@ END STRING ATR_DESCRCONTOA 50 35 BEGIN - PROMPT 39 12 "" + PROMPT 39 11 "" FLAG "U" USE LF_PCON KEY 2 SELECT SOTTOCONTO!="" INPUT DESCR ATR_DESCRCONTOA diff --git a/ve/vetbrss.h b/ve/vetbrss.h index 3eb5c908a..29cdad529 100755 --- a/ve/vetbrss.h +++ b/ve/vetbrss.h @@ -39,6 +39,8 @@ #define RSS_SOTTOA 139 #define RSS_DESCRCONTOA 140 +#define RSS_CODART 141 +#define RSS_DESCART 142 #define RSS_CDC_V1 151 #define RSS_CDC_V2 152 diff --git a/ve/vetbrss.uml b/ve/vetbrss.uml index 659c6ef12..1521d5a26 100755 --- a/ve/vetbrss.uml +++ b/ve/vetbrss.uml @@ -277,6 +277,32 @@ BEGIN CHECKTYPE NORMAL END +STRING RSS_CODART 20 +BEGIN + PROMPT 1 11 "Articolo (CI) " + USE LF_ANAMAG + INPUT CODART RSS_CODART + DISPLAY "Codice@20" CODART + DISPLAY "Descrizione@50" DESCR + OUTPUT RSS_CODART CODART + OUTPUT RSS_DESCART DESCR + CHECKTYPE NORMAL + FLAGS "U" + FIELD S2 +END + +STRING RSS_DESCART 50 34 +BEGIN + PROMPT 40 11 "" + USE LF_ANAMAG KEY 2 + INPUT DESCR RSS_DESCART + DISPLAY "Descrizione@50" DESCR + DISPLAY "Codice@20" CODART + COPY OUTPUT RSS_CODART + CHECKTYPE NORMAL + FLAGS "U" +END + LISTBOX RSS_CAMPI 15 BEGIN PROMPT 1 12 "Campo default " @@ -411,7 +437,7 @@ END STRING RSS_QUALIFICA 20 BEGIN - PROMPT 2 21 "Qualfica " + PROMPT 2 21 "Qualifica " FIELD S3[41,60] END