Patch level :
Files correlati : mg1 Ricompilazione Demo : [ ] Commento : Ottimizzato ricalcolo saldi ed aaggiunta compattazione file giacenze git-svn-id: svn://10.65.10.50/branches/R_10_00@22458 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									e3d6bc759a
								
							
						
					
					
						commit
						77f9314dec
					
				| @ -599,17 +599,11 @@ bool TMov_mag::update_balances(bool lock) | ||||
| { | ||||
|   bool updated_bal = true; | ||||
| 
 | ||||
|   TLocalisamfile mag(LF_MAG); | ||||
|   mag.setkey(2); | ||||
|   TRectype& magcurr = mag.curr(); | ||||
| 
 | ||||
|   const TRecord_array& b = body(); | ||||
| 	const TString8 hcodcaus = get(MOVMAG_CODCAUS); | ||||
| 
 | ||||
|   for (int i = b.last_row(); i > 0; i = b.pred_row(i)) | ||||
|     if (causale(i).update_ultcos()) | ||||
|   for (int i = b.last_row(); i > 0; i = b.pred_row(i)) if (causale(i).update_ultcos()) | ||||
|   {  | ||||
| 
 | ||||
| 		const TRectype & rec = b[i]; | ||||
| 		TArticolo & art = articolo(i); | ||||
| 
 | ||||
| @ -630,14 +624,25 @@ bool TMov_mag::update_balances(bool lock) | ||||
| 
 | ||||
|   if (_saldi_mag.items() > 0) | ||||
| 	{ | ||||
|     TFast_isamfile mag(LF_MAG); | ||||
|     mag.setkey(2); | ||||
|     TRectype& magcurr = mag.curr(); | ||||
| 
 | ||||
| 		TString_array keys_mag; | ||||
| 
 | ||||
| 		_saldi_mag.get_keys(keys_mag); | ||||
| 		keys_mag.sort(); | ||||
| 
 | ||||
| 		for (TToken_string* curr_key = (TToken_string*)keys_mag.first_item(); | ||||
| 				 curr_key != NULL; curr_key = (TToken_string*)keys_mag.succ_item()) | ||||
|     TProgind* pi = NULL; | ||||
|     if (keys_mag.items() >= 32) | ||||
|     { | ||||
|       TString msg; msg << TR("Aggiornamento saldi del movimento ") << get(MOVMAG_NUMREG); | ||||
|       pi = new TProgind(keys_mag.items(), msg, false, true); | ||||
|     } | ||||
| 
 | ||||
|     FOR_EACH_ARRAY_ROW(keys_mag, r, curr_key) | ||||
| 		{ | ||||
|       if (pi) pi->addstatus(1); | ||||
| 			const TSaldo_mag& saldo = (const TSaldo_mag&)_saldi_mag[*curr_key]; | ||||
|       const TCodice_articolo& codart = saldo.codart(); | ||||
| 			TArticolo_giacenza& art = cached_article_balances(codart); | ||||
| @ -664,11 +669,13 @@ bool TMov_mag::update_balances(bool lock) | ||||
| 					art.unlock(); | ||||
| 			}        | ||||
| 		}  | ||||
| 
 | ||||
|     if (pi) delete pi; | ||||
| 	} | ||||
| 
 | ||||
| 	if (_saldi_mag_clifo.items() > 0) | ||||
| 	{ | ||||
|     TLocalisamfile clifomag(LF_CLIFOGIAC); | ||||
|     TFast_isamfile clifomag(LF_CLIFOGIAC); | ||||
|     clifomag.setkey(2); | ||||
|     TRectype& clifomag_curr = clifomag.curr(); | ||||
| 
 | ||||
| @ -1035,24 +1042,30 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz, | ||||
| 	p.codl = codlis; | ||||
| 	p.tipov = tipo_valorizz; | ||||
| 	 | ||||
|   // azzera tutte giacenze (ciclo sulle giacenze)
 | ||||
| 	TCursor anamag_cur(new TRelation(LF_ANAMAG)); | ||||
|   TString msg; | ||||
|   | ||||
|   { | ||||
|     // azzera tutte giacenze (ciclo sulle giacenze)
 | ||||
|     TRelation anamag_rel(LF_ANAMAG); | ||||
| 	  TCursor anamag_cur(&anamag_rel); | ||||
|    | ||||
| 	  anamag_cur.relation()->lfile().set_curr(new TArticolo_giacenza()); | ||||
| 	anamag_cur.freeze(); | ||||
| 	  msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento..."), codes); | ||||
| 	  anamag_cur.scan(reset_giac, (void*)&p, msg); | ||||
|   } | ||||
| 
 | ||||
|   { | ||||
| 	  TString filter; filter << CLIFOGIAC_ANNOES << "==" << p.codesprec; | ||||
| 	TCursor c(new TRelation(LF_CLIFOGIAC), filter); | ||||
|     TRelation clifogiac_rel(LF_CLIFOGIAC); | ||||
| 	  TCursor c(&clifogiac_rel, filter); | ||||
| 
 | ||||
| 	  msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento giacenze clienti..."), codes); | ||||
| 	  c.scan(rel_reset_clifogiac, (void*)&p, msg); | ||||
|   } | ||||
|    | ||||
|   // ricostruisce i saldi (ciclo sui movimenti)
 | ||||
|   bool ok = true; | ||||
| 
 | ||||
|   { | ||||
|     TRelation relmovmag(LF_MOVMAG); | ||||
| 	  TRectype& rec = relmovmag.curr(); | ||||
| 	  rec.put(MOVMAG_ANNOES, codes); | ||||
| @ -1061,7 +1074,15 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz, | ||||
|     relmovmag.lfile().set_curr(new TMov_mag()); | ||||
| 	  msg.format(FR("Ricostruzione saldi esercizio %04d : ricalcolo..."), codes); | ||||
| 	  mov_cur.scan(recalc_mov, (void*)&ok, msg); | ||||
|   } | ||||
| 
 | ||||
| 	a.close(); | ||||
| 
 | ||||
|   if (ok) | ||||
|   { | ||||
|   	TSystemisamfile mag(LF_MAG); | ||||
|     mag.pack(true, true); | ||||
|   } | ||||
|    | ||||
|   return ok; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user