Migliorata stampa codici articolo contenenti spazi :-(
git-svn-id: svn://10.65.10.50/branches/R_10_00@22744 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									a6ab3a2677
								
							
						
					
					
						commit
						780e9ec6aa
					
				| @ -301,14 +301,14 @@ bool TForm_schedemag::validate(TForm_item &cf, TToken_string &s) | ||||
| 
 | ||||
|         TString region; | ||||
|         region << MAG_ANNOES << '=' << _anno_prec; | ||||
|         region << ' ' << MAG_CODART << '=' << codart; | ||||
|         region << ' ' << MAG_CODART << "=\"" << codart << "\""; | ||||
| 
 | ||||
|         TString query; | ||||
|         query << "USE " << LF_MAG; | ||||
|         query << "\nFROM " << region; | ||||
|         query << "\nTO " << region; | ||||
|         if (_tolivart <= 0 || _tolivart >= livelli_articolo().last_level()) | ||||
|           query << '~'; | ||||
|           query.insert("~", query.len()-1); | ||||
| 
 | ||||
|         TISAM_recordset magprec(query); | ||||
|         real currsaldo = cf.get(); | ||||
|  | ||||
| @ -507,7 +507,8 @@ TIsamtempfile* TStampa_inventario::calcola_giacenze(const bool giaceff, const bo | ||||
| { | ||||
|   //Scorre l'anagrafica di magazzino e calcola per ognuno la giacenza alla data indicata
 | ||||
|   //Memorizzando i records in un file temporaneo che avrà lo stesso tracciato di LF_MAG
 | ||||
|   TIsamtempfile * temp_mag = new TIsamtempfile(LF_MAG, "tmpmag"); | ||||
|   TIsamtempfile* temp_mag = new TIsamtempfile(LF_MAG, "tmpmag"); | ||||
| 
 | ||||
|   TRectype darec(LF_ANAMAG), arec(LF_ANAMAG); | ||||
| 	TMask& m = mask(); | ||||
| 	 | ||||
| @ -547,9 +548,6 @@ TIsamtempfile* TStampa_inventario::calcola_giacenze(const bool giaceff, const bo | ||||
|   const TRecnotype items = ana_cur.items(); | ||||
|    | ||||
| 	ana_cur.freeze(); | ||||
|   ana_rel.lfile().set_curr(new TArticolo_giacenza_data); | ||||
|    | ||||
|   TArticolo_giacenza_data& art_giac = (TArticolo_giacenza_data&)ana_cur.curr(); | ||||
|   const TEsercizi_contabili esc; | ||||
|   const int anno = esc.date2esc(al); | ||||
|   TString4 annoes; annoes.format("%04d", anno);  | ||||
| @ -563,14 +561,15 @@ TIsamtempfile* TStampa_inventario::calcola_giacenze(const bool giaceff, const bo | ||||
|   { | ||||
|     if (!pi.addstatus(1)) | ||||
| 		  break; | ||||
| 
 | ||||
|     TArticolo_giacenza_data art_giac(ana_cur.curr()); | ||||
|     art_giac.al(al); // Calcola la giacenza alla data per questo articolo
 | ||||
|      | ||||
|     // Scrive i records sul file temporaneo
 | ||||
|     TRecord_array& mag = art_giac.mag(annoes); | ||||
|     for (int i = mag.last_row(); temp_mag->good() && i > 0; i = mag.pred_row(i)) | ||||
|     { | ||||
|       TRectype& magrec = (TRectype&)mag.row(i);  | ||||
|       | ||||
|       TRectype& magrec = (TRectype&)mag.row(i);   | ||||
| 			if (giaceff) | ||||
|       { | ||||
|         const real v = art_giac.giacenza_corretta(magrec, true, valcomp); | ||||
| @ -581,14 +580,12 @@ TIsamtempfile* TStampa_inventario::calcola_giacenze(const bool giaceff, const bo | ||||
|   } | ||||
|    | ||||
|   // Se il file è ok lo sostituisce all'interno della relazione del form
 | ||||
| 
 | ||||
|   if (temp_mag->good()) | ||||
| 		return temp_mag; | ||||
| 	{ | ||||
|     error_box(FR("Errore %d in creazione file temporaneo per saldi di magazzino alla data indicata."), temp_mag->status()); | ||||
| 		delete temp_mag; | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
|   error_box(FR("Errore %d in creazione file temporaneo per saldi di magazzino alla data indicata."), temp_mag->status()); | ||||
| 	delete temp_mag; | ||||
| 	return NULL; | ||||
| } | ||||
| 
 | ||||
| void TStampa_inventario::setprint_permagazzini(const char subordine, const bool alladata, const bool giaceff, bool valcomp, const TDate & al) | ||||
|  | ||||
| @ -553,11 +553,11 @@ protected: | ||||
|   // @member: effettua l'aggiornamento dei saldi relativi alle giacenze interessate al movimento
 | ||||
|   bool update_balances(bool lock = true) ; | ||||
|   // @member: effettua l'aggiornamento dei saldi di una giacenza
 | ||||
|   void update_balances(TRectype & magrec, const TSaldo_mag & s) ; | ||||
|   void update_balances(TRectype& magrec, const TSaldo_mag & s) ; | ||||
|   // @member: effettua l'aggiornamento dei saldi di una giacenza sulle gacenze per ciente/fornitore
 | ||||
|   void update_balances_clifo(TRectype & clifomagrec, const TSaldo_mag_clifo & s); | ||||
|   void update_balances_clifo(TRectype& clifomagrec, const TSaldo_mag_clifo & s); | ||||
| // @member: effettua l'aggiornamento di un saldo di una giacenza
 | ||||
|   void update_balance(TRectype & rec, const char * fieldname, const real& diff, int sgn) const; | ||||
|   void update_balance(TRectype& rec, const char * fieldname, const real& diff, int sgn) const; | ||||
| 
 | ||||
|   void giac_putkey(TRectype& mag, const TSaldo_mag & s); | ||||
| 	void giac_putkey_clifo(TRectype& clifomag, const TSaldo_mag_clifo & s); | ||||
|  | ||||
| @ -1598,24 +1598,30 @@ void TArticolo_giacenza_data::al(const TDate& data, const char* codmag, const ch | ||||
|     TString80 str; str << TR("Calcolo giacenza articolo ") << codice(); | ||||
|     pi = new TProgind(items, str, false, true); | ||||
|   } | ||||
|    | ||||
|   /*
 | ||||
|   TMov_mag* p_movmag = new TMov_mag;   | ||||
|   rel.lfile(LF_MOVMAG).set_curr(p_movmag); | ||||
|   TMov_mag& movmag = *p_movmag; | ||||
|   */ | ||||
|   const TRectype& rmovmag = rel.curr(); | ||||
|   TRecord_array& rmag = mag(anno); | ||||
|    | ||||
|   for (cur = 0; cur.pos() < items; ++cur) | ||||
|   { | ||||
|     if (pi) pi->addstatus(1); | ||||
|     const TDate datacomp = movmag.get_date(MOVMAG_DATACOMP); | ||||
| 		const TString & codart = rmovmag.get(RMOVMAG_CODART); | ||||
|     if (pi && !pi->addstatus(1)) | ||||
|       break; | ||||
|     const TDate datacomp = rel.curr(LF_MOVMAG).get_date(MOVMAG_DATACOMP); | ||||
| 		const TString& codart = rmovmag.get(RMOVMAG_CODART); | ||||
|     if (codart == codice() && datacomp >= inizio && datacomp <= data) | ||||
|     {   | ||||
|       const TString16 codmag = rmovmag.get(RMOVMAG_CODMAG); | ||||
|       const TString16 livello = rmovmag.get(RMOVMAG_LIVGIAC); | ||||
|       const long nreg = rmovmag.get_int(RMOVMAG_NUMREG); | ||||
|       const int nrig = rmovmag.get_int(RMOVMAG_NRIG); | ||||
|       const int i = find_mag(anno, codmag, livello); | ||||
| 
 | ||||
|       TMov_mag movmag(nreg); | ||||
| 
 | ||||
|       if (i >= 0)  // Se il record di giacenza esiste lo aggiorno ...
 | ||||
|       { | ||||
|         TRectype& rec = (TRectype&)rmag.row(i); | ||||
|  | ||||
| @ -5,19 +5,12 @@ | ||||
| #include <diction.h>  | ||||
| #include <progind.h>  | ||||
| #include <recset.h>  | ||||
| #include <utility.h>  | ||||
| 
 | ||||
| #include "clifogiac.h" | ||||
| #include "mglib.h"  | ||||
| #include "movmag.h" | ||||
| #include <cfven.h> | ||||
| 
 | ||||
| #ifndef __CGLIB01_H | ||||
| #include "../cg/cglib01.h" | ||||
| #endif | ||||
| #ifndef __DBLIB_H | ||||
| #include "../db/dblib.h" | ||||
| #endif | ||||
| 
 | ||||
| class TSaldo_mag : public TObject | ||||
| { | ||||
| @ -133,7 +126,7 @@ public: | ||||
|    | ||||
|   virtual TObject* dup() const { return new TSaldo_mag_clifo(*this); } | ||||
|    | ||||
| 	bool is_deletable() const { return _quant == ZERO && _valore == ZERO; } | ||||
| 	bool is_deletable() const { return _quant.is_zero() && _valore.is_zero(); } | ||||
| 	static TToken_string & key(const TRectype & head, const TRectype & row); | ||||
| 	void add_quant(const real & q, bool plus = true) { _quant = _quant + (plus ? q : -q); } | ||||
| 	void add_valore(const real & v, bool plus = true) { _valore = _valore + (plus ? v : -v); } | ||||
| @ -181,8 +174,10 @@ TToken_string & TSaldo_mag_clifo::key(const TRectype & head, const TRectype & ro | ||||
| 	key.add(head.get_int(MOVMAG_CODINDSP)); | ||||
|   key.add(row.get(RMOVMAG_CODART)); | ||||
|   key.add(row.get(RMOVMAG_LIVGIAC)); | ||||
| 	const TString & c = row.get(RMOVMAG_CODCAUS); | ||||
| 
 | ||||
|   const TString& c = row.get(RMOVMAG_CODCAUS); | ||||
| 	key.add(c.full() ? c : head.get(MOVMAG_CODCAUS)); | ||||
|    | ||||
|   return key; | ||||
| } | ||||
| 
 | ||||
| @ -204,37 +199,36 @@ TSaldo_mag_clifo::TSaldo_mag_clifo(const TSaldo_mag_clifo & s) | ||||
| 	set(s._codes, s._tipocf, s._codcf, s._codindsp, s._codart, s._livello, s._codcaus); | ||||
| 	_quant = s._quant; | ||||
| 	_valore = s._valore; | ||||
|  } | ||||
| } | ||||
| 
 | ||||
| // ********************************
 | ||||
| // TMov_mag  
 | ||||
| 
 | ||||
| TMov_mag::TMov_mag() :  | ||||
|   TMultiple_rectype(LF_MOVMAG) | ||||
| {    | ||||
|   add_file(LF_RMOVMAG,"NRIG"); | ||||
| } | ||||
| TMov_mag::TMov_mag() : TMultiple_rectype(LF_MOVMAG) | ||||
| { add_file(LF_RMOVMAG,"NRIG"); } | ||||
| 
 | ||||
| TMov_mag::TMov_mag(long numreg) : | ||||
|   TMultiple_rectype(LF_MOVMAG) | ||||
| TMov_mag::TMov_mag(long numreg) : TMultiple_rectype(LF_MOVMAG) | ||||
| { | ||||
|   add_file(LF_RMOVMAG,"NRIG"); | ||||
|   TLocalisamfile movmag(LF_MOVMAG); | ||||
|   put(MOVMAG_NUMREG, numreg); | ||||
|   read(movmag);  | ||||
|   if (numreg > 0) | ||||
|   { | ||||
|     TLocalisamfile movmag(LF_MOVMAG); | ||||
|     put(MOVMAG_NUMREG, numreg); | ||||
|     read(movmag);  | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| TMov_mag::~TMov_mag()  | ||||
| {    | ||||
| } | ||||
| { } | ||||
| 
 | ||||
| TCausale_magazzino& TMov_mag::causale(int row) const | ||||
| { | ||||
| 	const TRectype & rowrec = body()[row]; | ||||
| 	TString8 cod(rowrec.get(RMOVMAG_CODCAUS)); | ||||
| 
 | ||||
| 	const TRectype& rowrec = body()[row]; | ||||
| 	 | ||||
|   TString8 cod = rowrec.get(RMOVMAG_CODCAUS); | ||||
|   if (cod.blank()) | ||||
|     cod = get(MOVMAG_CODCAUS); | ||||
| 
 | ||||
|   return cached_causale_magazzino(cod); | ||||
| } | ||||
| 
 | ||||
| @ -731,7 +725,7 @@ bool TMov_mag::update_balances(bool lock) | ||||
| 
 | ||||
| // aggiorna i saldi del record corrente 
 | ||||
| // in base alla causale e alla modifica fatta (con segno + o -)
 | ||||
| void TMov_mag::update_balances(TRectype & magrec, const TSaldo_mag & s)  | ||||
| void TMov_mag::update_balances(TRectype& magrec, const TSaldo_mag & s)  | ||||
| { | ||||
|   const TCausale_magazzino& caus = cached_causale_magazzino(s.codcaus()); | ||||
|    | ||||
| @ -846,11 +840,11 @@ void TMov_mag::update_balances(TRectype& magrec, int numrig, bool plus) | ||||
|   TSaldo_mag saldo(*this, rec); | ||||
| 	real quant = rec.get_real(RMOVMAG_QUANT); | ||||
|   const TCausale_magazzino& caus = cached_causale_magazzino(saldo.codcaus()); | ||||
| 	TArticolo & art = articolo(numrig); | ||||
| 	TArticolo& art = articolo(numrig); | ||||
| 
 | ||||
| 	quant = art.convert_to_um(quant, NULL, rec.get(RMOVMAG_UM)); | ||||
| 
 | ||||
| 	real valore = (quant.is_zero() && caus.update_val()) ? rec.get_real(RMOVMAG_PREZZO) : rec.get_real(RMOVMAG_PREZZO) * quant; | ||||
| 	const real valore = (quant.is_zero() && caus.update_val()) ? rec.get_real(RMOVMAG_PREZZO) : rec.get_real(RMOVMAG_PREZZO) * quant; | ||||
| 		 | ||||
| 	saldo.add(quant, valore, plus); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user