From 43c00e8eefdcf06d2d8bc02da0b0385454611601 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 29 Aug 1997 16:42:42 +0000 Subject: [PATCH] Sistemati errori sulla generazione delle righe omaggio ( focus e prezzo) Sistemato output su sconti Sistemata stampa documenti git-svn-id: svn://10.65.10.50/trunk@5140 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/sconti.cpp | 27 +++- ve/ve1100.cpp | 428 +++++++++++++++++-------------------------------- ve/ve2100.cpp | 4 +- ve/ve2100i.uml | 1 - ve/ve2100r.uml | 4 - ve/velib06.cpp | 4 +- 6 files changed, 166 insertions(+), 302 deletions(-) diff --git a/ve/sconti.cpp b/ve/sconti.cpp index bf8b95155..9b346c184 100755 --- a/ve/sconti.cpp +++ b/ve/sconti.cpp @@ -533,7 +533,7 @@ void TCond_vendita::update_omaggi(bool full) { static TString16 tipo_riga("_"); TSheet_field & sh = (TSheet_field &) testa().field(F_SHEET); - const int current_doc_row = sh.selected() + 1; + int current_doc_row = sh.selected() + 1; TDocumento & doc = testa().doc(); bool update = FALSE; @@ -546,6 +546,7 @@ void TCond_vendita::update_omaggi(bool full) if (r.is_omaggio() && r.is_generata()) { + sh.update_row(current_doc_row - 1); doc.destroy_row(current_doc_row + 1, TRUE); sh.destroy(current_doc_row, FALSE); update = TRUE; @@ -553,6 +554,7 @@ void TCond_vendita::update_omaggi(bool full) } real qta = _riga->get(FR_QTA); + bool creata = FALSE; if (full || qta != ZERO) { @@ -566,10 +568,14 @@ void TCond_vendita::update_omaggi(bool full) qta /= _rcondv.get_real("QBASE"); qta.floor(); qta *= _rcondv.get_real("QOM"); - if (codart_omaggio.not_empty() && tipo_riga.not_empty() && qta != ZERO) + creata = codart_omaggio.not_empty() && tipo_riga.not_empty() && qta != ZERO; + + if (creata) { - TRiga_documento & curr_row = doc[current_doc_row]; - + TRiga_documento & curr_row = doc[current_doc_row]; + TToken_string & rw = sh.row(current_doc_row - 1); + + sh.update_row(current_doc_row - 1); curr_row.autosave(sh); TRiga_documento & r = doc.insert_row(current_doc_row + 1, tipo_riga); @@ -580,7 +586,8 @@ void TCond_vendita::update_omaggi(bool full) r.put("CODART", codart_omaggio); r.put("UMQTA", _rcondv.get("UMOM")); r.put("QTA", qta); -// r.put("PREZZO", _rcondv.get("PROMAGGIO")); + real prezzo(_rcondv.get("PROMAGGIO")); + const TString16 codval(_condv.get("CODVAL")); const TString16 codiva_cli(clifo().vendite().get(CFV_ASSFIS)); if (codiva_cli.not_empty()) r.put("CODIVA", codiva_cli); @@ -592,14 +599,18 @@ void TCond_vendita::update_omaggi(bool full) sh.check_row(current_doc_row); r.autosave(sh); - const real prezzo_omaggio = normalize_valuta(_rcondv.get_real("PROMAGGIO"), _condv.get("CODVAL")); - r.put("PREZZO", prezzo_omaggio); + prezzo = normalize_valuta(prezzo, codval); + r.put("PREZZO", prezzo); + r.autoload(sh); update = TRUE; - curr_row.autoload(sh); +// curr_row.autoload(sh); } } if (update) + { sh.force_update(); + sh.select(creata ? current_doc_row : current_doc_row - 1); + } } TCond_vendita::TCond_vendita(TCli_for * clifo, TConfig * ditta, TDocumento_mask * testa, TMask * riga, diff --git a/ve/ve1100.cpp b/ve/ve1100.cpp index 32ce0e7ee..00bbf082c 100755 --- a/ve/ve1100.cpp +++ b/ve/ve1100.cpp @@ -452,110 +452,13 @@ void TDocumento_form::extended_parse_general(TScanner &scanner) } } -bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { +bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) +{ const TString code(s.get(0)); // prende il primo parametro, il codice del messaggio TString valore; - if (code== "_ISAMREAD") { - // lettura generica di un file del database - // sintassi: _ISAMREAD,,[!!...],{|[!!...]} - // dove: è il numero logico del file o il nome della tabella - // è un'espressione del tipo = - // è un'espressione di costanti numeriche, stringhe e valori di campi della form (indicati con il loro numero preceduto da #) - // è un'espressione del tipo = (se è un gruppo deve essere seguito da @) oppure solo (il campo della form è quello corrente) - int i, j, poseq, posrv, itms; - pagetype pt; - char sec; - TLocalisamfile *file; - TString f_code(s.get()); // prende il codice del file da leggere - if (atoi(f_code) != 0) file= new TLocalisamfile(atoi(f_code)); // se il codice è numerico allora è un file - else file= new TTable(f_code); // altrimenti è una tabella - file->zero(); // vuota il record corrente del file - TToken_string in(s.get(), '!'); - for (i=0; iput(fld, (const char *)rval); // scrive il risultato dell'espressione nel campo del file - } - if (file->read()== NOERR) { // tenta una lettura del file - TToken_string out(s.get(), '!'); - for (i=0; iget(curr); // preleva il nome del campo del file e lo legge dal record - cf.put_paragraph(dat); - } else { - TString fld(curr.left(poseq)); // preleva il nome del campo del form alla sinistra dell'uguale - const TString &dat= file->get(curr.mid(posrv)); // preleva il nome del campo del file alla destra dell'uguale e lo legge dal record - if (fld[0]=='#') fld.ltrim(1); - if (fld.right(1)== "@") { // se c'è la a-commerciale è un gruppo - if (fld.find("->") != -1) { // se nel gruppo c'è la freccia si riferisce ad un'altra sezione - sec= fld[0]; - if (fld[1] != '-') pt= char2page(fld[1]); - else pt= even_page; - itms= section(sec, pt).fields(); - } else { // altrimenti si riferisce alla sezione corrente - sec= cf.section().section_type(); - pt= cf.section().page_type(); - itms= cf.section().fields(); - } - for (j=0; j,, - // dove: nome tabella da leggere - // costante stringa o riferimento a campo della form (preceduto da '#') da usare come chiave di ricerca - // identificativo del campo da leggere dalla tabella - TTable tab(s.get()); // prende il nome della tabella - tab.zero(); // vuota il record corrente della tabella - TString in(s.get()); // prende il valore o il campo da usare come codice di ricerca - if (in[0]== '#') { - in.ltrim(1); - TForm_item &fi= cf.find_field(in); - in= fi.get(); - } - tab.put("CODTAB", in); // setta la chiave nella tabella - if (tab.read()== NOERR) { - const TString &fld= s.get(); // prende il nome del campo da leggere... - valore = tab.get(fld); - cf.put_paragraph(valore); - } - return (TRUE); - } // fine _TABLEREAD - - if (code== "_DITTA") { + if (code== "_DITTA") + { // lettura dei dati della ditta // sintassi: _DITTA,{|} // dove: è un riferimento alla relazione di gestione dei dati della ditta (es. 113@->DENCOM è la denominazione del comune di residenza della ditta) @@ -578,68 +481,106 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { // + %COMUNI (113@) Comune di residenza // + %COMUNI (213@) Comune di residenza fiscale TString in(s.get()); - if (in[0]=='!') { + + if (in[0]!='!') + { + cf.set(_firmrel.curr().get(in)); + return TRUE; + } + else + { in.ltrim(1); bool _fisc= _firmrel.lfile(6).get("INDRF").not_empty(); - if (in=="RAGSOC") - valore = _firmrel.lfile().get("RAGSOC"); - if (in=="IND") { + if (in=="RAGSOC") + { + cf.set(_firmrel.lfile().get("RAGSOC")); + return TRUE; + } + if (in=="IND") + { if (_fisc) - valore = _firmrel.lfile(6).get("INDRF"); + cf.set(_firmrel.lfile(6).get("INDRF")); else - valore = _firmrel.lfile(6).get("INDRES"); + cf.set(_firmrel.lfile(6).get("INDRES")); + return TRUE; } - if (in=="NUM") { + if (in=="NUM") + { if (_fisc) - valore = _firmrel.lfile(6).get("CIVRF"); + cf.set(_firmrel.lfile(6).get("CIVRF")); else - valore = _firmrel.lfile(6).get("CIVRES"); + cf.set(_firmrel.lfile(6).get("CIVRES")); + return TRUE; } - if (in=="CAP") { + if (in=="CAP") + { if (_fisc) - valore = _firmrel.lfile(6).get("CAPRF"); + cf.set(_firmrel.lfile(6).get("CAPRF")); else - valore = _firmrel.lfile(6).get("CAPRES"); + cf.set(_firmrel.lfile(6).get("CAPRES")); + return TRUE; } - if (in=="COM") { + if (in=="COM") + { if (_fisc) - valore = _firmrel.lfile(-213).get("DENCOM"); + cf.set(_firmrel.lfile(-213).get("DENCOM")); else - valore = _firmrel.lfile(-113).get("DENCOM"); + cf.set(_firmrel.lfile(-113).get("DENCOM")); + return TRUE; } - if (in=="PROV") { + if (in=="PROV") + { if (_fisc) - valore = _firmrel.lfile(-213).get("PROVCOM"); + cf.set(_firmrel.lfile(-213).get("PROVCOM")); else - valore = _firmrel.lfile(-113).get("PROVCOM"); + cf.set(_firmrel.lfile(-113).get("PROVCOM")); + return TRUE; } if (in=="IVA") - valore = _firmrel.lfile(6).get("PAIV"); + { + cf.set(_firmrel.lfile(6).get("PAIV")); + return TRUE; + } if (in=="CF") - _firmrel.lfile(6).get("COFI"); - if (in=="TEL") { + { + cf.set(_firmrel.lfile(6).get("COFI")); + return TRUE; + } + if (in=="TEL") + { valore = _firmrel.lfile().get("PTEL"); valore << "/" << _firmrel.lfile().get("TEL"); + cf.set(valore); + return TRUE; } - if (in=="FAX") { + if (in=="FAX") + { valore = _firmrel.lfile().get("PFAX"); valore << "/" << _firmrel.lfile().get("FAX"); + cf.set(valore); + return TRUE; } - if (in=="REGSOC") { + if (in=="REGSOC") + { valore = _firmrel[LF_UNLOC].get("REGTRIB"); - valore << " Vol. " << _firmrel[LF_UNLOC].get("VOLTRIB"); - valore << " Fasc. " << _firmrel[LF_UNLOC].get("FASCTRIB"); + const TString & vol = _firmrel[LF_UNLOC].get("VOLTRIB"); + if (vol.not_empty()) + valore << " Vol. " << vol; + const TString & fasc = _firmrel[LF_UNLOC].get("FASCTRIB"); + if (fasc.not_empty()) + valore << " Fasc. " << fasc; + cf.set(valore); + return TRUE; } - if (in=="CCIAA") { - valore = _firmrel[LF_UNLOC].get("NUMCCIAA"); - valore << " del " << _firmrel[LF_UNLOC].get("DATAICCIAA"); + if (in=="CCIAA") + { + valore = _firmrel[LF_UNLOC].get("NUMCCIAA"); + const TString & data = _firmrel[LF_UNLOC].get("DATAICCIAA"); + if (data.not_empty()) + valore << " del " << data; + return TRUE; } - } else { - TFieldref fref(in, 0); - valore = fref.read(_firmrel); } - cf.put_paragraph(valore); - return (TRUE); } // fine _DITTA if (code== "_CLIENTE") @@ -663,61 +604,64 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { TCli_for & cli_for = _doc->clifor(); TString in(s.get()); // prende la macro o il fieldref if (in[0] != '!') - valore = cli_for.get(in); - else { - in.ltrim(1); - if (in=="INDNUM") - { - valore = cli_for.get(CLI_INDCF); - valore << " " << cli_for.get(CLI_CIVCF); - } - else - if (in.find("COM") == 0) - { - in.ltrim(3); - TLocalisamfile com(LF_COMUNI); - const bool nascita = in[0] == 'N'; - if (nascita) - { - in.ltrim(3); - com.put("STATO", cli_for.get(CLI_STATOCF)); - com.put("COM", cli_for.get(CLI_COMCF)); - } - else - { - in.ltrim(2); - com.put("STATO", cli_for.get(CLI_STATONASC)); - com.put("COM", cli_for.get(CLI_COMNASC)); - } - if (com.read() == NOERR) - valore = com.get(in); - } - else - if (in.find("TEL") == 0) - { - if (in.len() == 3) - in << "1"; - const TString num(cli_for.get(in)); - in.insert("P"); - valore = cli_for.get(in); - valore << "/" << num; - } - else - if (in=="FAX") - { - valore = cli_for.get("PFAX"); - valore << "/" << cli_for.get("FAX"); - } - else - if (in=="RAGSOC") - { - valore = cli_for.get(in); - valore.strip_d_spaces(); - } + cf.set(cli_for.get(in)); + return TRUE; + } + in.ltrim(1); + if (in=="INDNUM") + { + valore = cli_for.get(CLI_INDCF); + valore << " " << cli_for.get(CLI_CIVCF); + cf.set(valore); + return TRUE; + } + if (in.find("COM") == 0) + { + const bool nascita = in[3] == 'N'; + const int p = in.find("->"); + if (p > 0) + in.ltrim(p + 2); + TLocalisamfile com(LF_COMUNI); + if (nascita) + { + com.put("STATO", cli_for.get(CLI_STATONASC)); + com.put("COM", cli_for.get(CLI_COMNASC)); + } + else + { + com.put("STATO", cli_for.get(CLI_STATOCF)); + com.put("COM", cli_for.get(CLI_COMCF)); + } + if (com.read() == NOERR) + cf.set(com.get(in)); + return TRUE; + } + if (in.find("TEL") == 0) + { + if (in.len() == 3) + in << "1"; + const TString num(cli_for.get(in)); + in.insert("P"); + valore = cli_for.get(in); + valore << "/" << num; + cf.set(valore); + return TRUE; + } + if (in=="FAX") + { + valore = cli_for.get("PFAX"); + valore << "/" << cli_for.get("FAX"); + cf.set(valore); + return TRUE; + } + if (in=="RAGSOC") + { + valore = cli_for.get(in); + valore.strip_d_spaces(); + cf.set(valore); + return TRUE; } - cf.put_paragraph(valore); - return (TRUE); } // fine _CLIENTE if (code == "_DESCRIGA") @@ -732,78 +676,16 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { descrizione << s; } - cf.put_paragraph(descrizione); + cf.set(descrizione); + TParagraph_string p(descrizione, cf.width()); + const int h = cf.height(); + for (int i=0; p.get() != NULL && i < h; i++); +// cf.put_paragraph(descrizione); // Setta l'altezza effettiva del body, per evitare sprechi di righe - cf.section().set_height(cf.effective_height()); + cf.section().set_height(i); + return TRUE; } - if (code== "_ALIGN") - { - // allineamento della posizione di un campo rispetto ad un altro - // sintassi: _ALIGN,[,][,...] - // dove: è il campo della form (preceduto da '#') da cui prendere l'allineamento - // è uno dei seguenti valori: - // TOP allinea sulla riga d'inizio - // MIDDLE allinea al centro (effettivo) - // BOTTOM allinea sulla riga di fine (effettiva, non preimpostata) - // LEFT allinea sulla colonna d'inizio - // RIGHT allinea sulla colonna di fine - TString in(s.get()); - if (in[0]== '#') in.ltrim(1); - TForm_item &fi= cf.find_field(in); - const int width = cf.width(); - valore = cf.get(); - TString clear(width); - TString picture(cf.picture()); - clear.spaces(); - int i= 2; - short save_x = cf.x(); - short save_y = cf.y(); - short save_height = cf.height(); - cf.height() = 2; // Solo temporaneamente per far si' che stampi alla giusta posizione - cf.set(clear); - cf.put_paragraph(clear); - while (isummary_set_next(); - real x(value); - if (x.is_real(value)) - { - TString picture(cf.picture()); - if (x != ZERO) - value = x.string(picture); // Riformatta il valore - else - value = ""; - } - cf.put_paragraph(value); + cf.set(value); } } else error_box("Numero di parametri non corretto in _RIEPILOGOIVA"); - return (TRUE); + return TRUE; } // fine _RIEPILOGOIVA if (code == "_TOTIMPONIBILI") @@ -867,12 +739,7 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { byte sel = atoi(s.get()); real x = sel == 0 ? _doc->imponibile(TRUE): _doc->tot_imponibili(sel); - TString picture(cf.picture()); - if (x != 0.0) - valore = x.string(picture); // Riformatta il valore - else - valore = ""; - cf.put_paragraph(valore); + cf.set(x.string()); return (TRUE); } // fine _TOTIMPONIBILI @@ -889,21 +756,12 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) { TString what(s.get()); TString value(_doc->scadenze_get(what)); - real x(value); - if (x.is_real(value)) - { - TString picture(cf.picture()); - if (x != 0.0) - value = x.string(picture); // Riformatta il valore - else - value = ""; - } - what = s.get(); const bool next = what == "1"; if (next) _doc->scadenze_set_next(); - cf.put_paragraph(value); + cf.set(value); } + return TRUE; } return TForm::validate(cf, s); // se il codice del messaggio non è identificato viene passato alla funzione standard diff --git a/ve/ve2100.cpp b/ve/ve2100.cpp index a7334ca44..ba4539009 100755 --- a/ve/ve2100.cpp +++ b/ve/ve2100.cpp @@ -189,11 +189,11 @@ bool TTabelle_sconti::handle_check(TMask_field &f, KEY k) { if (f.to_check(k)) { - TEditable_field & check_field = (TEditable_field &) f.mask().field(f.dlg() + 100); + TEditable_field & check_field = f.mask().efield(f.dlg() + 100); check_field.set(f.get()); if (!check_field.check()) - return check_field.error_box(check_field.get_warning()); + return f.error_box(check_field.get_warning()); } return TRUE; } diff --git a/ve/ve2100i.uml b/ve/ve2100i.uml index a9c6eee54..f5d4e7a35 100755 --- a/ve/ve2100i.uml +++ b/ve/ve2100i.uml @@ -41,7 +41,6 @@ BEGIN DISPLAY "Cod.pag." CODART[5,8] DISPLAY "Sconto@25" SCONTO OUTPUT F_I_RICERCA CODCAT - OUTPUT F_I_DESVEN -201->S0 OUTPUT F_I_RICERCA_SC CODART[1,2] OUTPUT F_I_RICERCA_ZO CODART[3,4] OUTPUT F_I_RICERCA_CO CODART[5,8] diff --git a/ve/ve2100r.uml b/ve/ve2100r.uml index ca7824706..00b91cee8 100755 --- a/ve/ve2100r.uml +++ b/ve/ve2100r.uml @@ -78,7 +78,6 @@ BEGIN OUTPUT F_R_TIPO_RIGA TIPORIGA OUTPUT F_R_CODART_A CODART OUTPUT F_R_UM UM - OUTPUT F_R_DESART LF_ANAMAG->DESCR OUTPUT F_R_SCA NSCAGL CHECKYTPE REQUIRED GROUP 1 @@ -125,7 +124,6 @@ BEGIN OUTPUT F_R_TIPO_RIGA TIPORIGA OUTPUT F_R_RFA_A CODART OUTPUT F_R_UM UM - OUTPUT F_R_DESART RFA->S0 OUTPUT F_R_SCA NSCAGL CHECKYTPE REQUIRED GROUP 2 @@ -170,7 +168,6 @@ BEGIN OUTPUT F_R_TIPO_RIGA TIPORIGA OUTPUT F_R_GRM_A CODART OUTPUT F_R_UM UM - OUTPUT F_R_DESART GMC->S0 OUTPUT F_R_SCA NSCAGL CHECKYTPE REQUIRED GROUP 3 @@ -215,7 +212,6 @@ BEGIN OUTPUT F_R_TIPO_RIGA TIPORIGA OUTPUT F_R_SGM_A CODART OUTPUT F_R_UM UM - OUTPUT F_R_DESART GMC->S0 OUTPUT F_R_SCA NSCAGL CHECKYTPE REQUIRED GROUP 3 diff --git a/ve/velib06.cpp b/ve/velib06.cpp index 0db1683ec..b303f4a78 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -273,10 +273,10 @@ void TDocumento_mask::sconto_testa2mask( TCli_for & c, TConfig & ditta ) break; case 'A': // Gestione archivio sconti { - TString16 cod; + TString16 cod; const TRectype & ven_rec = c.vendite(); TLocalisamfile sconti(LF_SCONTI ); - + sconti.setkey(1); sconti.zero(); sconti.put("TIPO", "I");