Files correlati : cg4.exe Ricompilazione Demo : [ ] Commento : Aggiunto il supporto delle lingue a cg4 git-svn-id: svn://10.65.10.50/trunk@10946 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			217 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			217 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <recarray.h>
 | |
| #include <relation.h>
 | |
| 
 | |
| #include "cg4501.h"
 | |
| #include "cg4500b.h"
 | |
| #include "nditte.h"
 | |
| 
 | |
| bool TAp_iva::mask_annoiva (TMask_field& f, KEY k)
 | |
| {
 | |
|   if ( (k == K_ENTER) && f.to_check(k) )
 | |
|   {
 | |
|     int annoiva = f.mask().get_int(F_ANNOIVA);
 | |
|     TConfig conf(CONFIG_DITTA);
 | |
|     int annoivap = conf.get_int("AnLiIv");
 | |
|     if (annoivap > 0 && annoiva != annoivap + 1)
 | |
|       return f.error_box(FR("Il nuovo anno esercizio IVA deve essere %d"), (annoivap+1));
 | |
|   }
 | |
|   return TRUE;
 | |
| }  
 | |
| 
 | |
| bool TAp_iva::create()
 | |
| {
 | |
|   open_files(LF_TAB, LF_TABCOM, LF_NDITTE, 0);
 | |
|   enable_menu_item(M_FILE_NEW, FALSE);
 | |
| 
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| 
 | |
| bool TAp_iva::apertura_iva()
 | |
| {
 | |
|   TString16 annoiva;
 | |
| 	TString16	codlia;
 | |
|   TDate data;
 | |
| 
 | |
|   int annop = _annop;
 | |
|   annoiva.format("%04d", _annoiva);
 | |
|   
 | |
|   //viene aggiornata la tabella LIA (liquidazione iva annuale)
 | |
|   TTable tablia ("%LIA");
 | |
| 
 | |
|   codlia.format("%05ld%04d", get_firm(), _annoiva); 
 | |
|   tablia.put ("CODTAB", codlia);
 | |
|   if (tablia.read() == NOERR)
 | |
|     tablia.remove();
 | |
|   
 | |
|   tablia.zero();
 | |
|   codlia.format("%05ld%04d", get_firm(), annop); 
 | |
|   tablia.put ("CODTAB", codlia);
 | |
|   
 | |
|   if (tablia.read() != NOERR)
 | |
|     return error_box(TR("Non esiste il record relativo all'anno iva precedente sulla tabella liquidazione annuale iva"));
 | |
| 	else
 | |
|   {
 | |
|     codlia.format("%05ld%04d", get_firm(), _annoiva); 
 | |
|     tablia.put("CODTAB", codlia);
 | |
|     tablia.put("S7", _frequenza);
 | |
|     tablia.put("B2", _is_minagr);
 | |
|     tablia.zero("R0");
 | |
|     tablia.write();
 | |
|   }   
 | |
|   
 | |
|   //viene aggiornata la tabella del libro unico. 
 | |
|   TRelation lbu("%LBU");
 | |
| 	TRectype & tablbu = lbu.curr();
 | |
| 
 | |
|   tablbu.put ("CODTAB", annoiva);
 | |
|   
 | |
|   TCursor cur(&lbu, "", 1, &tablbu, &tablbu);
 | |
| 	TRecnotype items = cur.items();
 | |
|   
 | |
|   cur.freeze();
 | |
| 	
 | |
| 	for (cur = 0L; cur.pos() < items; ++cur)
 | |
|     lbu.remove(); 
 | |
| 	
 | |
|   cur.freeze(FALSE);
 | |
|  	tablbu.zero();
 | |
|   tablbu.put ("CODTAB", _annop);
 | |
| 	cur.setregion(tablbu, tablbu);
 | |
|   items = cur.items();
 | |
|   
 | |
|   cur.freeze();
 | |
| 
 | |
| 	for (cur = 0L; cur.pos() < items; ++cur)
 | |
|   { 
 | |
|     TString16 cod(tablbu.get("CODTAB"));
 | |
|     
 | |
|     cod.overwrite(annoiva); 
 | |
|     tablbu.put("CODTAB", cod);
 | |
|     tablbu.zero("I0");
 | |
|     lbu.write();  
 | |
|   }   
 | |
|   
 | |
|   //viene aggiornata la tabella dei registri. 
 | |
|   TRelation reg("REG");
 | |
| 	TRectype & tabreg = reg.curr();
 | |
| 
 | |
|   tabreg.put ("CODTAB", annoiva);
 | |
|   
 | |
|   TCursor cur_reg(®, "", 1, &tabreg, &tabreg);
 | |
| 
 | |
| 	items = cur_reg.items();
 | |
|   cur_reg.freeze();
 | |
| 	for (cur_reg = 0L; cur_reg.pos() < items; ++cur_reg)
 | |
|   {
 | |
|     const int tiporeg = tabreg.get_int("I0");
 | |
|     if ((tiporeg == 1) || (tiporeg == 2) || (tiporeg == 3) || (tiporeg==9))
 | |
|       reg.remove();
 | |
|   }
 | |
|   
 | |
|   cur_reg.freeze(FALSE);
 | |
|   tabreg.zero();
 | |
|   tabreg.put ("CODTAB", _annop);
 | |
| 	cur_reg.setregion(tabreg, tabreg);
 | |
| 	items = cur_reg.items();
 | |
|   cur_reg.freeze();
 | |
| 	for (cur_reg = 0L; cur_reg.pos() < items; ++cur_reg)
 | |
|   { 
 | |
|     int tiporeg     = tabreg.get_int("I0");
 | |
|     if ( (tiporeg == 1)||(tiporeg == 2)||(tiporeg==3)||(tiporeg==9))
 | |
|     {
 | |
| 	    TString16 cod = tabreg.get("CODTAB");
 | |
| 
 | |
|       cod.overwrite(annoiva);  
 | |
|       tabreg.put("CODTAB", cod);
 | |
|       tabreg.zero("I1");
 | |
|       tabreg.zero("I2");
 | |
|       tabreg.zero("I4");
 | |
|       tabreg.zero("I5");
 | |
|       tabreg.zero("I6");
 | |
|       tabreg.zero("S1");
 | |
|       tabreg.put("D0", data);
 | |
|       tabreg.put("D2", data);
 | |
|       tabreg.put("D3", data);
 | |
|       tabreg.zero("R1");
 | |
|       tabreg.zero("R2");
 | |
|       
 | |
|       reg.write();
 | |
|     }   
 | |
|   }
 | |
| 
 | |
|   //viene aggiornato l'anno iva sui parametri ditta 
 | |
|   TConfig conf(CONFIG_DITTA);
 | |
|   conf.set("AnLiIv", annoiva);
 | |
| 
 | |
|   //sull'anagrafica ditte viene aggiornata la frequenza versamento
 | |
|   TLocalisamfile nditte (LF_NDITTE);
 | |
| 
 | |
|   nditte.put("CODDITTA", _ditta);
 | |
|   if (nditte.read(_isequal, _lock) == NOERR)
 | |
|   {
 | |
|     nditte.put(NDT_FREQVIVA, _frequenza);
 | |
|     nditte.rewrite();
 | |
|   }
 | |
|   message_box(TR("Apertura nuovo esercizio IVA completata"));
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TAp_iva::main_loop()
 | |
| {
 | |
|   TMask msk ("cg4500b");
 | |
| 
 | |
|   TConfig conf(CONFIG_DITTA);
 | |
|   _annop    = conf.get_int("AnLiIv");
 | |
|   if (_annop <= 0)
 | |
|     _annop = TDate(TODAY).year() - 1;
 | |
|   int aivap = _annop;
 | |
|   int anno = aivap+1;
 | |
|   _is_minagr = FALSE;
 | |
|   
 | |
|   TTable tablia ("%LIA");
 | |
|   TString16 chiave;
 | |
| 	
 | |
|   tablia.zero();    
 | |
| 	chiave.format("%05ld%04d", get_firm(), anno);
 | |
|   tablia.put("CODTAB",chiave);
 | |
|   if (tablia.read() == NOERR)
 | |
|   {
 | |
|     msk.set(F_FREQUENZA, tablia.get("S7")); 
 | |
|     _is_minagr = tablia.get_bool("B2");
 | |
|   }
 | |
|   else
 | |
|   {  
 | |
|     tablia.zero();         
 | |
|     chiave = "";
 | |
|     chiave.format("%05ld%04d", get_firm(), aivap);
 | |
|     tablia.put("CODTAB", chiave);
 | |
|     if (tablia.read() == NOERR)
 | |
|     {
 | |
|       msk.set(F_FREQUENZA, tablia.get("S7"));
 | |
|       _is_minagr = tablia.get_bool("B2");
 | |
|     }
 | |
|     else
 | |
|     { 
 | |
| 			TString16 key;
 | |
| 
 | |
| 			key.format("%ld", get_firm());
 | |
| 
 | |
| 	    const TString & freq_iva = cache().get(LF_NDITTE, key, NDT_FREQVIVA);
 | |
| 
 | |
|       msk.set(F_FREQUENZA, freq_iva);
 | |
|     }
 | |
|   }
 | |
|   
 | |
|   msk.set(F_ANNOIVA, anno);  
 | |
| 
 | |
|   msk.set_handler (F_ANNOIVA, mask_annoiva);
 | |
| 
 | |
|   if (msk.run() == K_ENTER)
 | |
|   {
 | |
|     _ditta     = msk.get_long(F_CODDITTA); 
 | |
|     _annoiva   = msk.get_int(F_ANNOIVA);   
 | |
|     _frequenza = msk.get(F_FREQUENZA)[0];
 | |
|     
 | |
|     apertura_iva();
 | |
|   }
 | |
| } |