517 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			517 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <defmask.h>
 | |
| #include <recarray.h>
 | |
| #include <relapp.h>
 | |
| #include <sheet.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "ce1.h"
 | |
| #include "ce2101.h"
 | |
| #include "celib.h"
 | |
| 
 | |
| #include "ce1101a.h"
 | |
| #include "ce1101b.h"
 | |
| #include "../cg/cglib01.h"
 | |
| 
 | |
| 
 | |
| #include "cespi.h"
 | |
| #include "salce.h"
 | |
| #include "ammce.h"
 | |
| 
 | |
| //-----------------------------------------------------------------------------------------------------------------------//
 | |
| //Maschera di selezione
 | |
| class TQuery_mask : public TAutomask
 | |
| {      
 | |
|   int _staat;
 | |
|   real _residuof, _residuoc;
 | |
|  
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
|   void on_search_event(TOperable_field& o);
 | |
| 
 | |
|   int calcola_stato_attivita();
 | |
|   bool cespite_ok() const;
 | |
|   void set_cespi_filter();
 | |
|   
 | |
| public:
 | |
|    int stato_attivita() const { return _staat; }
 | |
|    real get_residuof() const { return _residuof; }
 | |
|    real get_residuoc() const { return _residuoc; }
 | |
|    void calc_res(bool prec);
 | |
|    
 | |
|   TQuery_mask();
 | |
| };
 | |
| 
 | |
| void TQuery_mask::on_search_event(TOperable_field& o)
 | |
| {
 | |
|   TToken_string order, fields, header;
 | |
|   if (o.dlg() >= F_SEARCH3)
 | |
|   {
 | |
|     order.add(CESPI_STABILIM); header.add(TR("Stabilimento"));
 | |
|     order.add(CESPI_REPARTO); header.add(FR("Reparto@10"));
 | |
|   }
 | |
|   if (o.dlg() >= F_SEARCH2) 
 | |
|   {
 | |
|     order.add(CESPI_CODIMP); header.add(FR("Impianto@10"));
 | |
|   }
 | |
|   if (o.dlg() >= F_SEARCH1)
 | |
|   {
 | |
|     order.add(CESPI_CODCAT); header.add(TR("Cat"));
 | |
|     order.add(CESPI_DTCOMP); header.add(FR("Data Acq.@10"));
 | |
|   }
 | |
| 
 | |
|   order.add(CESPI_IDCESPITE); header.add(FR("Codice@10"));
 | |
|   
 | |
|   fields = order;
 | |
|   fields.add(CESPI_DESC); header.add(FR("Descrizione@50"));
 | |
|   
 | |
|   TRelation rel(LF_CESPI);
 | |
|   
 | |
|   TString filter;
 | |
|   if (get(F_SELECT)[0] == 'I') // Filtro per impianto
 | |
|   {
 | |
|     const TString& imp = get(F_IMPIANTO);
 | |
|     if (!imp.empty())
 | |
|       filter << CESPI_CODIMP << "=\"" << imp << '"';
 | |
|   }
 | |
|   else // Filtro per attività
 | |
|   {
 | |
|     filter << "STR(" << CESPI_CODCGRA << "=" << get(F_GRUPPO) << ')';
 | |
|     filter << "&&(" << CESPI_CODSPA << "=\"" << get(F_SPECIE) << "\")";
 | |
|   }  
 | |
|   
 | |
|   TSorted_cursor cur(&rel, order, filter);
 | |
|   TCursor_sheet sht(&cur, fields, TR("Cespiti"), header, 0, 1);
 | |
|   if (sht.run() == K_ENTER)
 | |
|   { 
 | |
|     TToken_string& row = sht.row();
 | |
|     const int cod_pos = row.items()-2;
 | |
|     set(F_IDCESPITE, row.get(cod_pos), TRUE);
 | |
|     stop_run(K_AUTO_ENTER);
 | |
|   }
 | |
| }
 | |
| 
 | |
| int TQuery_mask::calcola_stato_attivita()
 | |
| {
 | |
|   const int ese = get_int(F_ESERCIZIO);
 | |
|   const int gru = get_int(F_GRUPPO);
 | |
|   const char* spe = get(F_SPECIE);
 | |
| 
 | |
|   TString16 str;  
 | |
|   str.format("%04d%02d%-4s", ese, gru, spe);
 | |
| 
 | |
|   const TRectype& curr_ccb = cache().get("CCB", str);
 | |
|   if (curr_ccb.get_bool("B1")) // Bollato stampato
 | |
|     _staat = 1;
 | |
|   
 | |
|   TDitta_cespiti& dc = ditta_cespiti();
 | |
|   dc.set_attivita(ese, gru, spe);
 | |
|   
 | |
|   return _staat;
 | |
| }
 | |
| 
 | |
| bool TQuery_mask::cespite_ok() const
 | |
| {
 | |
|   const TRectype & cespi = cache().get(LF_CESPI, get(F_IDCESPITE));
 | |
|   const bool ok = !cespi.empty();
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| void TQuery_mask::calc_res(bool prec)
 | |
| {
 | |
|   TCespite ces (get(F_IDCESPITE));                
 | |
| // calcolo ammortamento sul cespite (per sit. fiscale(1) e civilistica(2))        
 | |
|   TDate fine_es(get(F_FINE_ES));  
 | |
|   ces.calc_amm(1, fine_es);
 | |
|   const TRectype& salce2=ces.sal_pro();    //rectype giá di "tipo fiscale"
 | |
|   const TRectype& ammce2=ces.amm_pro();
 | |
| // determinazione del residuo fiscale
 | |
|   _residuof = ZERO;
 | |
|   _residuof = salce2.get_real(SALCE_CSTO)-salce2.get_real(SALCE_VNONAMM)-salce2.get_real(SALCE_PLUSREIN)+salce2.get_real(SALCE_RIV75)+salce2.get_real(SALCE_RIV83)+salce2.get_real(SALCE_RIV90)+salce2.get_real(SALCE_RIV91)+salce2.get_real(SALCE_RIVGF);
 | |
|   _residuof -= ammce2.get_real(AMMCE_QNORP)+ammce2.get_real(AMMCE_QACCP)+ammce2.get_real(AMMCE_QANTP)+ammce2.get_real(AMMCE_QPERSEP)+ammce2.get_real(AMMCE_FPRIVATOP)+ammce2.get_real(AMMCE_QPPRIVATEP);
 | |
|   if (!prec)
 | |
|     _residuof -= ammce2.get_real(AMMCE_QNOR)+ammce2.get_real(AMMCE_QACC)+ammce2.get_real(AMMCE_QANT)+ammce2.get_real(AMMCE_QPERSE)+ammce2.get_real(AMMCE_FPRIVATO)+ammce2.get_real(AMMCE_QPPRIVATE);
 | |
|       
 | |
|   ces.calc_amm(2, fine_es);
 | |
| //rectype giá di "tipo civilistico"
 | |
| // determinazione del residuo civilistico
 | |
|   _residuoc = ZERO;
 | |
|   _residuoc = salce2.get_real(SALCE_CSTO)+salce2.get_real(SALCE_RIV75)+salce2.get_real(SALCE_RIV83)+salce2.get_real(SALCE_RIV90)+salce2.get_real(SALCE_RIV91)+salce2.get_real(SALCE_RIVGC);
 | |
|   _residuoc -= ammce2.get_real(AMMCE_QNORP)+ammce2.get_real(AMMCE_QACCP)+ammce2.get_real(AMMCE_QANTP);
 | |
|   if (!prec)
 | |
|     _residuoc -= ammce2.get_real(AMMCE_QNOR)+ammce2.get_real(AMMCE_QACC)+ammce2.get_real(AMMCE_QANT);
 | |
| }
 | |
| 
 | |
| void TQuery_mask::set_cespi_filter()   //metodo per il filtraggio corretto sulla maschera; stabilisce il tipo di filtro in
 | |
| {                                      //base alla selezone con il radiobutton (per attivitá o per impianto)
 | |
|   TString filter;
 | |
|   if (get(F_SELECT)[0] == 'I') // Filtro per impianto
 | |
|   {
 | |
|     const TString& imp = get(F_IMPIANTO);
 | |
|     if (!imp.empty())
 | |
|       filter << CESPI_CODIMP << "=\"" << imp << '"';
 | |
|   }
 | |
|   else // Filtro per attività
 | |
|   {
 | |
|     filter << "STR(" << CESPI_CODCGRA << "=" << get(F_GRUPPO) << ')';
 | |
|     filter << "&&(" << CESPI_CODSPA << "=\"" << get(F_SPECIE) << "\")";
 | |
|   }  
 | |
|   efield(F_IDCESPITE).browse()->set_filter(filter);
 | |
|   efield(F_DESC).browse()->set_filter(filter);
 | |
| }
 | |
| 
 | |
| bool TQuery_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| {
 | |
|   switch (o.dlg())
 | |
|   {
 | |
|   case F_ESERCIZIO:
 | |
|     if (e == fe_init || e == fe_modify)
 | |
|       set_cespi_filter();          
 | |
|     if (e == fe_close)  //il controllo sul bollato viene fatto solo per l'esercizio
 | |
|       calcola_stato_attivita();
 | |
|     break;  
 | |
|   case F_GRUPPO:
 | |
|   case F_SPECIE:
 | |
|     if (e == fe_modify)
 | |
|       set_cespi_filter();          
 | |
|    break;
 | |
|   case F_SELECT:
 | |
|   case F_IMPIANTO:
 | |
|     if (e == fe_modify)
 | |
|       set_cespi_filter();
 | |
|     break; 
 | |
|        
 | |
|   case F_SEARCH1:
 | |
|   case F_SEARCH2:
 | |
|   case F_SEARCH3:
 | |
|     if (e == fe_button)
 | |
|       on_search_event(o);
 | |
|     break;
 | |
|     
 | |
|   case F_IDCESPITE:
 | |
|     if (e == fe_close)  
 | |
|     { 
 | |
|       if (!cespite_ok())
 | |
|         return error_box(TR("Inserire un cespite valido")); //controlla che esista il cespite
 | |
|       if (stato_attivita() == 1)
 | |
|         warning_box(TR("E' stato stampato il bollato dell'anno:\nnon sono permesse forzature")); //il bollato é stato stampato
 | |
|         
 | |
|  
 | |
| 			TString key;
 | |
| 
 | |
| 			key = get(F_IDCESPITE);
 | |
| 			key << '|' << get(F_ESERCIZIO) << "|1";
 | |
| 
 | |
| 			const TRectype & salce = cache().get(LF_SALCE, key);
 | |
| 			if (salce.empty())
 | |
| 				return error_box(TR("Non esistono saldi per l'anno selezionato")); 
 | |
|       
 | |
| 			key << "|1";
 | |
| 			const TRectype &ammce = cache().get(LF_AMMCE, key);     // controlla che esista almeno un ammortamento (sennó che forzamo?)
 | |
| 			if (ammce.empty())
 | |
| 				return error_box(TR("Non esistono ammortamenti per l'anno selezionato"));
 | |
|         
 | |
|       TCespite ces (get(F_IDCESPITE));                 // controlla che la categoria del cespite sia ammortizzabile
 | |
|       const TRectype& categoria = ces.categoria();
 | |
|       bool non_ammortizzabile = categoria.get_bool("B0");
 | |
|       if (non_ammortizzabile)
 | |
|         return error_box(TR("La categoria del cespite selezionato non é ammortizzabile"));
 | |
|       
 | |
|       calc_res(TRUE);                                  // controllo dei residui fiscale e civilistico in ingresso (prec=TRUE)
 | |
|       if (_residuof==ZERO)
 | |
|         return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo fiscale da ammortizzare per il cespite"));
 | |
|       
 | |
|       if (_residuoc==ZERO)
 | |
|         return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo civilistico da ammortizzare per il cespite"));      
 | |
| 
 | |
|       
 | |
|     } 
 | |
|     break;
 | |
|     
 | |
|   default:
 | |
|   break;
 | |
|   }  
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| TQuery_mask::TQuery_mask() : TAutomask("ce1101a") 
 | |
| {
 | |
|   first_focus(F_IDCESPITE);
 | |
| }
 | |
| 
 | |
| //-----------------------------------------------------------------------------------------------------------------------//
 | |
| //Maschera di forzatura
 | |
| class TForce_mask : public TAutomask
 | |
| { 
 | |
|   TTipo_cespite _tipo;
 | |
|   int _staat;
 | |
|   real _residuof_ini,_residuoc_ini;
 | |
| 
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| 
 | |
| public:
 | |
|   void set_stato_attivita(int sa) { _staat = sa; }
 | |
|   int stato_attivita() const { return _staat; }
 | |
| 
 | |
|   void set_tipo_cespite(TTipo_cespite tc) { _tipo = tc; }
 | |
|   TTipo_cespite tipo_cespite() const { return _tipo; }
 | |
|   
 | |
|   void set_residuof_ini(const real& rfini) { _residuof_ini = rfini; }
 | |
|   void set_residuoc_ini(const real& rcini) { _residuoc_ini = rcini; }
 | |
| 
 | |
|   TForce_mask() : TAutomask("ce1101b") { }
 | |
| };
 | |
| 
 | |
| 
 | |
| bool TForce_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| { 
 | |
|   bool ok = TRUE;
 | |
|   switch (o.dlg())
 | |
|   {
 | |
|   case F_CATEGORIA:
 | |
|     ditta_cespiti().on_category_event(o, e, jolly);
 | |
|     break;
 | |
|       
 | |
|   case F_FORZATURA_Q_F:                                              //gestione reset dei vari checkbox di forzatura
 | |
|     if (e==fe_modify && o.get()=="X" && get(F_FORZATURA_P_F)=="X")
 | |
|       reset(F_FORZATURA_P_F);
 | |
|     break;
 | |
|     
 | |
|   case F_FORZATURA_P_F:
 | |
|     if (e==fe_modify && o.get()=="X" && get(F_FORZATURA_Q_F)=="X")
 | |
|       reset(F_FORZATURA_Q_F);
 | |
|     break;
 | |
|     
 | |
|   case F_FORZATURA_Q_C:
 | |
|     if (e==fe_modify && o.get()=="X" && get(F_FORZATURA_P_C)=="X")
 | |
|       reset(F_FORZATURA_P_C);
 | |
|     break;
 | |
|     
 | |
|   case F_FORZATURA_P_C:
 | |
|     if (e==fe_modify && o.get()=="X" && get(F_FORZATURA_Q_C)=="X")
 | |
|       reset(F_FORZATURA_Q_C);
 | |
|     break;                   
 | |
|     
 | |
|   case F_AMMNOR_F:   // controlla che residuof sia < della somma dei campi quota fiscali (al variare di 
 | |
|   case F_AMMACC_F:   // ognuno dei campi quota componenti, in modo che in caso di errore il campo sia
 | |
|   case F_AMMANT_F:   // subito identificato
 | |
|   case F_QUOTE_PERSE:
 | |
|   case F_PRIVATO:
 | |
|   case F_QUOTE_PRIV:
 | |
|     if (e==fe_close||e==fe_modify)
 | |
|     {
 | |
|       real sumf = get_real(F_AMMNOR_F)+get_real(F_AMMACC_F)+get_real(F_AMMANT_F)+get_real(F_QUOTE_PERSE)+get_real(F_PRIVATO)+get_real(F_QUOTE_PRIV);
 | |
|       if (sumf > _residuof_ini)
 | |
|         return error_box(TR("Attenzione: l'ammortamento richiesto supera il residuo fiscale del cespite"));  
 | |
|     }
 | |
|     break;
 | |
|   case F_AMMNOR_C:   // controlla che residuoc sia < della somma dei campi quota civilistici 
 | |
|   case F_AMMACC_C:   
 | |
|   case F_AMMANT_C:
 | |
|     if (e==fe_close||e==fe_modify)
 | |
|     {
 | |
|       real sumc = get_real(F_AMMNOR_C)+get_real(F_AMMACC_C)+get_real(F_AMMANT_C);
 | |
|       if (sumc > _residuoc_ini)
 | |
|         return error_box(TR("Attenzione: l'ammortamento richiesto supera il residuo civilistico del cespite"));      
 | |
|     }
 | |
|     break;
 | |
|   default:
 | |
|   break;  
 | |
|   }    
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| //-----------------------------------------------------------------------------------------------------------------------//
 | |
| //Applicazione
 | |
| class TForza_amm_cespi : public TRelation_application
 | |
| {
 | |
|   TRelation* _ammce;
 | |
|   
 | |
|   TQuery_mask* _qmask;
 | |
|   TForce_mask* _fmask;
 | |
|   
 | |
| private:
 | |
|   void protect_fields(TMask& m, TToken_string& enabling) const;
 | |
|   void init_mask(TMask& m);
 | |
|   void update_amm(const TMask& m);
 | |
|   
 | |
| protected:
 | |
|   // @cmember Inizializzazione dei dati dell'utente
 | |
|   virtual bool user_create();
 | |
|   // @cmember Distruzione dei dati dell'utente
 | |
|   virtual bool user_destroy();
 | |
|   virtual bool changing_mask(int mode);
 | |
|   // @cmember Richiede la maschera da usare
 | |
|   virtual TMask* get_mask(int mode);
 | |
|   // @cmember Ritorna la relazione da modificare
 | |
|   virtual TRelation* get_relation() const;
 | |
| 
 | |
|   virtual void init_query_mode(TMask& m);
 | |
|   virtual void init_modify_mode(TMask& m);
 | |
|   virtual int write(const TMask& m);
 | |
|   virtual int rewrite(const TMask& m);
 | |
| 
 | |
| };
 | |
| 
 | |
| bool TForza_amm_cespi::changing_mask(int)
 | |
| {
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| TMask* TForza_amm_cespi::get_mask(int mode)
 | |
| {
 | |
|   return mode == MODE_QUERY ? (TMask*)_qmask : (TMask*)_fmask;
 | |
| }
 | |
| 
 | |
| TRelation* TForza_amm_cespi::get_relation() const
 | |
| {                    
 | |
|     return _ammce;
 | |
| }
 | |
| 
 | |
| void TForza_amm_cespi::init_query_mode(TMask& m)
 | |
| {
 | |
|   ditta_cespiti().init_mask(m);
 | |
| }
 | |
| 
 | |
| void TForza_amm_cespi::init_mask(TMask& m)
 | |
| {
 | |
|   TDitta_cespiti& dc = ditta_cespiti();                 //se il bollato dell'esercizio é stato stampato inibisce il REGISTRA
 | |
|   dc.init_mask(m);
 | |
|   const bool can_edit = !dc.bollato_stampato() ;
 | |
|   m.enable(DLG_SAVEREC, can_edit);
 | |
|   m.enable(DLG_DELREC, can_edit);
 | |
|   
 | |
|   _fmask->set_stato_attivita(_qmask->stato_attivita());  //copia lo stato attivitá della precedente 
 | |
| 
 | |
|   _qmask->calc_res(TRUE);                              //calcola residuo precedente (prec=TRUE)
 | |
|   _fmask->set_residuof_ini(_qmask->get_residuof());    //memorizza i residui precedenti nella maschera (non a video)
 | |
|   _fmask->set_residuoc_ini(_qmask->get_residuoc());
 | |
|   
 | |
|   _qmask->calc_res(FALSE);     // ricalcola il residuo fiscale e civilistico in forzatura (prec=FALSE)
 | |
|   _fmask->set(F_RESIDUO_F, _qmask->get_residuof());     //prende il residuo fiscale (civilistico) del cespite calcolato
 | |
|   _fmask->set(F_RESIDUO_C, _qmask->get_residuoc());     //nella maschera di selezione e lo mette nella maschera di forzatura
 | |
| }
 | |
| 
 | |
| 
 | |
| void TForza_amm_cespi::protect_fields(TMask& m, TToken_string& enabling) const
 | |
| {
 | |
|   for (int f = m.fields()-1; f >= 0; f--)
 | |
|   {
 | |
|     TMask_field& fld = m.fld(f);
 | |
|     const short id = fld.dlg();
 | |
|     if (id > 100 && id < 1000 && fld.is_editable() && fld.enabled_default())
 | |
|     {
 | |
|       const bool on = enabling.empty() || enabling.get_pos(fld.dlg()) >= 0;
 | |
|       fld.enable(on);
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TForza_amm_cespi::init_modify_mode(TMask& m)
 | |
| { 
 | |
|   init_mask(m);
 | |
|   
 | |
|   const bool accendiforzatura=_fmask->stato_attivita()!=1;
 | |
|   m.enable(F_FORZATURA_Q_F, accendiforzatura); //abilita i checks della forzatura quando il bollato NON é stampato
 | |
|   m.enable(F_FORZATURA_P_F, accendiforzatura);
 | |
|   m.enable(F_FORZATURA_Q_C, accendiforzatura);
 | |
|   m.enable(F_FORZATURA_P_C, accendiforzatura);
 | |
|   
 | |
|   if (accendiforzatura)    //se lo stato attivitá lascia liberi di forzare, controlla se il tipocespite fa altrettanto...
 | |
|   {
 | |
|     TCespite ces(m.get(F_IDCESPITE));
 | |
|     const TRectype& cac = ces.categoria();    
 | |
|     switch (ces.tipo())
 | |
|     {
 | |
|     case tc_immateriale:
 | |
|       if (cac.get_int("I1")!=0)
 | |
|       {
 | |
|         m.disable(F_FORZATURA_P_F);
 | |
|         m.disable(F_FORZATURA_P_C);
 | |
|       }    
 | |
|       break;
 | |
|       
 | |
|     case tc_pluriennale:
 | |
|       if (cac.get_int("I2")==3)
 | |
|       {
 | |
|         m.disable(F_FORZATURA_P_F);
 | |
|         m.disable(F_FORZATURA_P_C);
 | |
|       }
 | |
|       break;
 | |
|       
 | |
|     default:
 | |
|       break; 
 | |
|     }  
 | |
|   }
 | |
| // aggiornamento della colonna dei valori risultanti
 | |
|   m.set(F_RIS_AMMNOR_F, m.get_real(F_AMMNOR_F));
 | |
|   m.set(F_RIS_AMMACC_F, m.get_real(F_AMMACC_F));
 | |
|   m.set(F_RIS_AMMANT_F, m.get_real(F_AMMANT_F));
 | |
|   m.set(F_RIS_QUOTE_PERSE, m.get_real(F_QUOTE_PERSE));
 | |
|   m.set(F_RIS_PRIVATO, m.get_real(F_PRIVATO));
 | |
|   m.set(F_RIS_QUOTE_PRIV, m.get_real(F_QUOTE_PRIV));
 | |
|   
 | |
|   m.set(F_RIS_AMMNOR_C, m.get_real(F_AMMNOR_C));
 | |
|   m.set(F_RIS_AMMACC_C, m.get_real(F_AMMACC_C));
 | |
|   m.set(F_RIS_AMMANT_C, m.get_real(F_AMMANT_C));
 | |
| }
 | |
| 
 | |
| // funzione per il ricalcolo degli ammortamenti dopo la forzatura
 | |
| void TForza_amm_cespi::update_amm(const TMask& m)
 | |
| {
 | |
|   TCespite ces(m.get(F_IDCESPITE));
 | |
|   TDate fine_es = m.get_date(F_FINE_ES);
 | |
|   ces.calc_amm(1, fine_es);
 | |
|   ces.calc_amm(2, fine_es);
 | |
| }
 | |
| 
 | |
| 
 | |
| //funzione per il ricalcolo automatico dei valori degli ammortamenti dopo la forzatura (in caso di prima forzatura)
 | |
| int TForza_amm_cespi::write(const TMask& m)
 | |
| {
 | |
|   int err = TRelation_application::write(m);
 | |
|   if (err==NOERR)
 | |
|     update_amm(m);
 | |
|   return err;
 | |
| } 
 | |
| 
 | |
| //funzione per il ricalcolo automatico dei valori degli ammortamenti dopo la forzatura
 | |
| int TForza_amm_cespi::rewrite(const TMask& m)
 | |
| {
 | |
|   int err = TRelation_application::rewrite(m);
 | |
|   if (err==NOERR)
 | |
|     update_amm(m);
 | |
|   return err;
 | |
| }
 | |
| 
 | |
| bool TForza_amm_cespi::user_create()
 | |
| {             
 | |
|   open_files(LF_TABCOM, LF_TAB, LF_CESPI, LF_SALCE, LF_AMMCE, 0);
 | |
|   _ammce = new TRelation (LF_AMMCE);                               // relazione principale su AMMCE
 | |
|   TString expr;
 | |
|   expr << "IDCESPITE==IDCESPITE|CODES==CODES|TPSALDO==TPSALDO|TPAMM==2";   //seconda relazione su AMMCE
 | |
|   _ammce->add(LF_AMMCE, expr, 1, 0, 69);                                   //69 é l'alias di AMMCE
 | |
|   _ammce->write_enable(-69);                   //abilita la scrittura su secondo AMMCE
 | |
|   _ammce->add(LF_CESPI, "IDCESPITE==IDCESPITE");    //estende la relazione con CESPI
 | |
|  
 | |
|   _qmask = new TQuery_mask;
 | |
|   _fmask = new TForce_mask;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TForza_amm_cespi::user_destroy()
 | |
| {             
 | |
|   delete _fmask;
 | |
|   delete _qmask;
 | |
|   delete _ammce;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int ce1100(int argc, char* argv[])
 | |
| {
 | |
|   TForza_amm_cespi a;
 | |
|   a.run(argc, argv, TR("Forzatura ammortamento su cespiti"));
 | |
|   return 0;
 | |
| }
 | |
| 
 |