Patch level :5.0
Files correlati : Ricompilazione Demo : [ ] Commento :importazione movimenti di budget con fase e controlli! git-svn-id: svn://10.65.10.50/trunk@16710 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4f3b3bb920
								
							
						
					
					
						commit
						bcf75e7bb5
					
				| @ -143,6 +143,7 @@ protected: | ||||
|   void movana_killer(const TAssoc_array& elenco, const bool kill_all); | ||||
| 	void transfer_movimento(const TArray& righe, TLog_report& log); | ||||
| 	const TString& ana2bill(const TString& contone) const; | ||||
|   const TDate str2date(const TString& stringdata); | ||||
| 
 | ||||
| 	long get_next_key(); | ||||
| 
 | ||||
| @ -191,6 +192,24 @@ const TString& TBudget_Import::ana2bill(const TString& contone) const | ||||
| 	return tmp; | ||||
| } | ||||
| 
 | ||||
| const TDate TBudget_Import::str2date(const TString& stringdata) | ||||
| { | ||||
|   const int stringdata_len = stringdata.len(); | ||||
|   TString4 gg = stringdata.left(2); | ||||
| 	TString4 mm = stringdata.mid(3,2); | ||||
|   TString4 yy; | ||||
|   if (stringdata_len == 8)   //se la data ha 8 caratteri (es. 12/06/08)...
 | ||||
|   { | ||||
| 	  yy = stringdata.right(2); | ||||
| 	  yy.insert("20", 0); | ||||
|   } | ||||
|   else  //se invece ne ha 10 (es.12/06/2008)...
 | ||||
|     yy = stringdata.right(4); | ||||
| 
 | ||||
|   const TDate data(atoi(gg),atoi(mm),atoi(yy)); | ||||
|   return data; | ||||
| } | ||||
| 
 | ||||
| //metodo di bassa lega che scrive veramente i movimenti analitici sui file movana e rmovana
 | ||||
| void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
| { | ||||
| @ -207,43 +226,16 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
| 	if (rec_cms.empty()) | ||||
|   { | ||||
|     TString errore; | ||||
|     errore << "La commessa " << codcms << " NON esiste!"; | ||||
|     errore << "La commessa " << codcms << " non esiste"; | ||||
|     log.log(2, errore); | ||||
|   } | ||||
| 
 | ||||
| 	const TString16 str_dataini = curr.get(4); | ||||
| 	const TString16 str_datafine = curr.get(5); | ||||
| 	 | ||||
|   //Controllo del formato date!
 | ||||
|   //Preso atto che il nostro invincibile fuhrer cambia formato date ad ogni importazione, proviamo a..
 | ||||
|   //..rendere piu' intelligente il povero programma
 | ||||
|   const int dataini_len = str_dataini.len(); | ||||
| 	TString4 gg = str_dataini.left(2); | ||||
| 	TString4 mm = str_dataini.mid(3,2); | ||||
|   TString4 yy; | ||||
|   if (dataini_len == 8)   //se la data ha 8 caratteri (es. 12/06/08)...
 | ||||
|   { | ||||
| 	  yy = str_dataini.right(2); | ||||
| 	  yy.insert("20", 0); | ||||
|   } | ||||
|   else  //se invece ne ha 10 (es.12/06/2008)...
 | ||||
|     yy = str_dataini.right(4); | ||||
| 
 | ||||
| 	const TDate dataini(atoi(gg),atoi(mm),atoi(yy)); | ||||
|   const TDate dataini = str2date(curr.get(4)); | ||||
| 	const int annoes = dataini.year(); | ||||
| 
 | ||||
|   const int datafine_len = str_datafine.len(); | ||||
| 	gg = str_datafine.left(2); | ||||
| 	mm = str_datafine.mid(3,2); | ||||
|   if (datafine_len == 8) | ||||
|   { | ||||
| 	  yy = str_datafine.right(2); | ||||
| 	  yy.insert("20", 0); | ||||
|   } | ||||
|   else | ||||
|     yy = str_datafine.right(4); | ||||
| 
 | ||||
| 	const TDate datafine(atoi(gg),atoi(mm),atoi(yy)); | ||||
|   const TDate datafine = str2date(curr.get(5)); | ||||
| 
 | ||||
| 	//cerca il primo posto libero in movana
 | ||||
| 	long numreg = get_next_key(); | ||||
| @ -286,7 +278,7 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
| 	      if (rec_fase.empty()) | ||||
|         { | ||||
|           TString errore; | ||||
|           errore << "La fase " << fase << " NON esiste legata alla commessa" << codcms << "!"; | ||||
|           errore << "La fase " << fase << " non esiste legata alla commessa" << codcms << ""; | ||||
|           log.log(2, errore); | ||||
|         } | ||||
|       } //fase.full...
 | ||||
| @ -300,7 +292,7 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
|     	  if (rec_sede.empty()) | ||||
|         { | ||||
|           TString errore; | ||||
|           errore << "La sede " << sede << " NON esiste!"; | ||||
|           errore << "La sede " << sede << " non esiste"; | ||||
|           log.log(2, errore); | ||||
|         } | ||||
|       } | ||||
| @ -318,7 +310,7 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
| 	  if (items <= 0) | ||||
|     { | ||||
|       TString errore; | ||||
|       errore << "Il sottoconto " << codconto << " NON esiste!"; | ||||
|       errore << "Il sottoconto " << codconto << " non esiste"; | ||||
|       log.log(2, errore); | ||||
|     } | ||||
| 
 | ||||
| @ -331,11 +323,11 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
| 	  pconana.move_last();	//si posiziona sul record corretto
 | ||||
| 	  const TString& contone = pconana.get(PCONANA_CODCONTO).as_string(); | ||||
| 
 | ||||
|     const TString& contcon = ana2bill(contone); | ||||
|     const TString contcon = ana2bill(contone); | ||||
| 	  if (contcon.empty()) | ||||
|     { | ||||
|       TString errore; | ||||
|       errore << "Il conto analitico " << contone <<  " non corrisponde ad alcun conto contabile!"; | ||||
|       errore << "Il conto analitico " << contone <<  " non corrisponde ad alcun conto contabile"; | ||||
|       log.log(2, errore); | ||||
|     } | ||||
|     //deve stabilire se la sezione e' D o A in base all'indbil del conto analitico
 | ||||
| @ -347,7 +339,7 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
|     else | ||||
|     { | ||||
|       TString errore; | ||||
|       errore << "Il conto analitico " << contone <<  " non ha un indicatore di bilancio!"; | ||||
|       errore << "Il conto analitico " << contone <<  " non ha un indicatore di bilancio"; | ||||
|       log.log(2, errore); | ||||
|     } | ||||
| 	  //incrementa l'importo totlae del documento in base a quanto trovato su questa riga
 | ||||
| @ -355,15 +347,15 @@ void TBudget_Import::transfer_movimento(const TArray& righe, TLog_report& log) | ||||
|     totdoc += imp_riga; | ||||
| 
 | ||||
|     //controllo sulle date
 | ||||
| 	  const TString16 curr_str_dataini = curr.get(4); | ||||
| 	  const TString16 curr_str_datafine = curr.get(5); | ||||
|     if (curr_str_dataini != str_dataini) | ||||
| 	  const TDate curr_dataini = str2date(curr.get(4)); | ||||
| 	  const TDate curr_datafine = str2date(curr.get(5)); | ||||
|     if (curr_dataini != dataini) | ||||
|     { | ||||
|       TString errore; | ||||
|       errore << "La commessa " << codcms <<  " ha movimenti con date inizio competenza incongruenti"; | ||||
|       log.log(1, errore); | ||||
|     } | ||||
|     if (curr_str_datafine != str_datafine) | ||||
|     if (curr_datafine != datafine) | ||||
|     { | ||||
|       TString errore; | ||||
|       errore << "La commessa " << codcms <<  " ha movimenti con date fine competenza incongruenti"; | ||||
| @ -451,7 +443,7 @@ void TBudget_Import::movana_killer(const TAssoc_array& elenco, const bool kill_a | ||||
| void TBudget_Import::elabora_input(const TFilename& file, TLog_report& log) | ||||
| { | ||||
|   //array con le commesse da accoppare
 | ||||
|   TAssoc_array commesse; | ||||
|   TAssoc_array movimenti, commesse; | ||||
| 
 | ||||
|   //per cominciare apre il file di input
 | ||||
|   const long dimension = fsize(file); | ||||
| @ -460,23 +452,32 @@ void TBudget_Import::elabora_input(const TFilename& file, TLog_report& log) | ||||
|     _trasfile->open(file,'r'); | ||||
| 
 | ||||
|     TRecord_text curr; | ||||
|     TToken_string key; | ||||
|     TString codcms; | ||||
|    | ||||
|     TProgind pi(dimension, TR("Lettura file di input in corso...")); | ||||
|     //crea un assoc_array di array (e la madona!!!) in cui la chiave e' il codice commessa e gli elementi..
 | ||||
|     //..sono array con le righe del file di input (con la stessa commessa ma fase\conto etc. diversi)
 | ||||
|     //crea un assoc_array di array (e la madona!!!) in cui la chiave e' il codice commessa|dataini|datafine..
 | ||||
|     //..e gli elementi sono array con le righe del file di input (con la stessa key ma fase\conto etc. diversi)
 | ||||
|     while (_trasfile->read(curr) == NOERR)  | ||||
|     { | ||||
|       pi.setstatus(_trasfile->read_file()->tellg()); | ||||
| 
 | ||||
|       codcms = curr.get(0); | ||||
| 	    codcms.replace('_', '/'); | ||||
|       codcms.replace('_', '/'); | ||||
|       key = codcms; | ||||
| 	     | ||||
|       //date
 | ||||
|       const TString16 str_dataini = curr.get(4); | ||||
|       key.add(str_dataini); | ||||
| 	    const TString16 str_datafine = curr.get(5); | ||||
|       key.add(str_datafine); | ||||
| 
 | ||||
|       TArray* righe = (TArray*)commesse.objptr(codcms); | ||||
|       TArray* righe = (TArray*)movimenti.objptr(key); | ||||
|       if (righe == NULL) | ||||
|       { | ||||
|         righe = new TArray; | ||||
|         commesse.add(codcms, righe); | ||||
|         movimenti.add(key, righe); | ||||
|         commesse.add(codcms); //commesse e' l'assoc_array di supporto che si usa nella cancellazione
 | ||||
|       } | ||||
|       righe->add(curr); | ||||
| 	  } | ||||
| @ -492,9 +493,9 @@ void TBudget_Import::elabora_input(const TFilename& file, TLog_report& log) | ||||
| 	_codcaus = _msk->get(F_COD_CAUS); | ||||
| 
 | ||||
|   //scrittura dei record memorizzati sui files di testata e righe dei movimenti analitici
 | ||||
|   const int items = commesse.items(); | ||||
|   const int items = movimenti.items(); | ||||
|   TProgind pi(items, "Generazione movimenti preventivi in corso..."); | ||||
|   FOR_EACH_ASSOC_OBJECT(commesse, obj, key, itm) | ||||
|   FOR_EACH_ASSOC_OBJECT(movimenti, obj, key, itm) | ||||
|   { | ||||
|     pi.addstatus(1); | ||||
|     TArray* righe = (TArray*)itm; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user