538 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			538 lines
		
	
	
		
			18 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 "ce1201a.h"
 | |
| #include "../cg/cglib01.h"
 | |
| 
 | |
| #include "movce.h"
 | |
| #include "cespi.h"
 | |
| #include "salce.h"
 | |
| #include "ammce.h"
 | |
| #include "movam.h"
 | |
| #include "ammmv.h"
 | |
| 
 | |
| 
 | |
| //-----------------------------------------------------------------------------------------------------------------------//
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Maschera di selezione
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TForce_mov_qmask : public TAutomask
 | |
| {      
 | |
|   int _staat, _ammoelim;
 | |
|   real _residuof, _residuoc, _difff, _diffc;
 | |
| 
 | |
| 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();
 | |
|   int calcola_ammo_eliminate();
 | |
| 
 | |
| public:
 | |
|   int stato_attivita() const { return _staat; }
 | |
|   int ammo_eliminate() const { return _ammoelim; }
 | |
|   real get_residuof() const { return _residuof; }
 | |
|   real get_residuoc() const { return _residuoc; }
 | |
|   real get_plusminusf() const { return _difff; }
 | |
|   real get_plusminusc() const { return _diffc; }  
 | |
|   void calc_res_mov(TCespite& ces, const TRectype& movce, const TRectype& ammmv);
 | |
|   
 | |
|   TForce_mov_qmask();
 | |
| };
 | |
| 
 | |
| int TForce_mov_qmask::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;
 | |
| }
 | |
| 
 | |
| int TForce_mov_qmask::calcola_ammo_eliminate() 
 | |
| {
 | |
|   const int ese = get_int(F_ESERCIZIO);
 | |
| 
 | |
|   TString16 str;  
 | |
|   str.format("%04d", ese);
 | |
|   
 | |
|   const TRectype& curr_cce = cache().get("CCE", str);
 | |
|   if (curr_cce.get_bool("B3")) //possibilitá ammortamenti su parti eliminate (si prosegue solo se TRUE)
 | |
|     _ammoelim = 1;
 | |
|     
 | |
|   return _ammoelim;  
 | |
| }
 | |
| 
 | |
| void TForce_mov_qmask::calc_res_mov(TCespite& ces, const TRectype& movce, const TRectype& ammmv)
 | |
| {               
 | |
| // calcolo ammortamento sul cespite (per sit. fiscale(tpamm=1) o civilistica(tpamm=2))
 | |
|   const TDate dtmov = movce.get_date(MOVCE_DTMOV);
 | |
|   const int tpamm = ammmv.get_int(AMMMV_TPAMM);  
 | |
|   ces.calc_amm(tpamm, dtmov);
 | |
|   TLocalisamfile f_ammmv (LF_AMMMV);
 | |
| 	f_ammmv.curr() = ammmv;
 | |
|   f_ammmv.read();    //il record di movam si rilegge in versione aggiornata dal calc_amm
 | |
|   
 | |
|   const real impven = movce.get_real(MOVCE_IMPVEN);
 | |
|   real plus = f_ammmv.curr().get_real(AMMMV_PLUS);
 | |
|   if (plus == ZERO)
 | |
|     plus = - f_ammmv.curr().get_real(AMMMV_MINUS);
 | |
|     
 | |
|   const real residuo = impven - plus;  
 | |
| // determinazione del residuo fiscale
 | |
|   if (tpamm == 1)
 | |
|   {
 | |
|     _residuof = residuo;
 | |
|     _difff = plus;
 | |
|   }
 | |
| // determinazione del residuo civilistico
 | |
|   if (tpamm == 2)
 | |
|   {
 | |
|     _residuoc = residuo;
 | |
|     _diffc = plus;
 | |
|   }    
 | |
| }
 | |
| 
 | |
| bool TForce_mov_qmask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| { 
 | |
|   switch (o.dlg())
 | |
|   {
 | |
|   case F_ESERCIZIO:            
 | |
|     if (e == fe_close)
 | |
|     {
 | |
|       calcola_stato_attivita();
 | |
|       calcola_ammo_eliminate();
 | |
|       if (_ammoelim != 1)
 | |
|         return error_box(TR("Non previsti ammortamenti sulle parti eliminate"));
 | |
|     }
 | |
|     break;
 | |
| 
 | |
|   case F_IDCESPITE:
 | |
|     if (e == fe_init || e == fe_modify)   //seleziona il filtro da applicare alla maschera nel campo del movimento
 | |
|     {
 | |
|       const TString& ces = get(F_IDCESPITE);
 | |
|       const bool cesok = !real::is_null(ces);
 | |
|       TString filter;
 | |
|       filter << "(IDRET=\"\")&&(ANSI(DTMOV)>=ANSI(#" << F_INIZIO_ES 
 | |
|              << "))&&(ANSI(DTMOV)<=ANSI(#" << F_FINE_ES << "))";
 | |
|       if (cesok)                                 // se viene selezionato un particolare cespite al filtro si aggiunge il suo codice
 | |
|         filter << "&&(IDCESPITE==\"" << ces << "\")";
 | |
|         
 | |
|       TEdit_field& m = efield(F_IDMOV);    // setta il filtro della ricerca sulla maschera
 | |
|       m.browse()->set_filter(filter);
 | |
|        
 | |
|     }
 | |
|     if (e == fe_close)  
 | |
|     { 
 | |
|       if (stato_attivita() == 1)
 | |
|         warning_box(TR("E' stato stampato il bollato dell'anno:\nnon sono permesse forzature"));
 | |
|       if (ammo_eliminate() == 0)
 | |
|         warning_box(TR("Non é previsto l'ammortamento sulle parti eliminate nell'esercizio selezionato"));
 | |
|     }
 | |
|     break;
 | |
|   
 | |
|   case F_IDMOV:
 | |
|     if (e == fe_close)
 | |
|     { 
 | |
|       const TRectype& curr_movce = cache().get(LF_MOVCE, get(F_IDMOV));  //seleziona il cespite corrente in base al movimento
 | |
|       const TString16 idcespite = curr_movce.get(MOVCE_IDCESPITE);       //selezionato nella maschera (qsto x poter lasciare idcespite vuoto)
 | |
|       
 | |
| 			TString key;
 | |
| 
 | |
| 			key = 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 (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("Ammortamenti non effettuabili perché la categoria del cespite non é ammortizzabile"));
 | |
|         
 | |
|       if (!curr_movce.empty())
 | |
|       {
 | |
|         const TRectype& curr_tmc = cache().get("%TMC", curr_movce.get(MOVCE_CODMOV));
 | |
|         if (!curr_tmc.get_bool("B4")) // non ammessi ammortamenti sul tipomov selezionato
 | |
|           return error_box(TR("Non sono ammessi ammortamenti su questo tipo movimento"));
 | |
|         if (!curr_tmc.get_int("I0") == 1)   // non ammessi ammortamenti su movimenti di rettifica
 | |
|           return error_box(TR("Non sono ammessi ammortamenti sulle rettifiche")); 
 | |
|         
 | |
|         const TDate dtmov = curr_movce.get_date(MOVCE_DTMOV);   // controlla che datamovimento sia inclusa nell'esercizio selezionato
 | |
|         const TDate dataini(get(F_INIZIO_ES));  
 | |
|         const TDate datafine(get(F_FINE_ES));
 | |
|         if ( dtmov < dataini || dtmov > datafine)
 | |
|           return error_box(TR("Il movimento selezionato non é di competenza dell'esercizio selezionato"));
 | |
|       }
 | |
|         
 | |
| 			key.format("%s|%s|1", (const char *) idcespite, (const char *) get(F_IDMOV));
 | |
| 
 | |
| 			{
 | |
| 				const TRectype & movam = cache().get(LF_MOVAM, key);
 | |
| 	      if (movam.empty())
 | |
| 		      return error_box(TR("Movimenti dei fondi fiscali incoerenti per il movimento selezionato"));
 | |
| 			}
 | |
|       
 | |
| 			key.format("%s|%s|2", (const char *) idcespite, (const char *) get(F_IDMOV));
 | |
| 
 | |
| 			{
 | |
| 				const TRectype & movam = cache().get(LF_MOVAM, key);
 | |
| 				if (movam.empty())
 | |
| 					return error_box(TR("Movimenti dei fondi civilistici incoerenti per il movimento selezionato"));
 | |
| 			}
 | |
| 
 | |
| 			key.format("%s|%s|1", (const char *) idcespite, (const char *) get(F_IDMOV));
 | |
| 
 | |
|       {
 | |
| 				const TRectype & ammmv = cache().get(LF_AMMMV, key);                  // controlla la consistenza degli ammortamenti sui movimenti
 | |
| 				if (ammmv.empty())
 | |
| 					return error_box(TR("Ammortamenti fiscali sui movimenti incoerenti per il movimento selezionato"));
 | |
| 				calc_res_mov(ces, curr_movce, ammmv);             //calcolo del residuo fiscale in uscita maschera di selezione
 | |
| 				if (_residuof==ZERO)
 | |
| 					return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo fiscale\nda ammortizzare per le parti eliminate del cespite"));
 | |
| 			}
 | |
| 
 | |
| 			key.format("%s|%s|2", (const char *) idcespite, (const char *) get(F_IDMOV));
 | |
| 			
 | |
| 			{
 | |
| 				const TRectype & ammmv = cache().get(LF_AMMMV, key);                  // controlla la consistenza degli ammortamenti sui movimenti
 | |
| 				if (ammmv.empty())
 | |
| 					return error_box(TR("Ammortamenti civilistici sui movimenti incoerenti per il movimento selezionato"));      
 | |
| 				calc_res_mov(ces, curr_movce, ammmv);             //calcolo del residuo civilistico in uscita maschera di selezione
 | |
| 				if (_residuoc==ZERO)
 | |
| 					return error_box(TR("Impossibile forzare ammortamento perché non esiste residuo civilistico\nda ammortizzare per le parti eliminate del cespite"));      
 | |
| 			}
 | |
|    
 | |
|     }
 | |
|     break;
 | |
|     
 | |
|   default:
 | |
|   break;
 | |
|   }  
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| TForce_mov_qmask::TForce_mov_qmask() : TAutomask("ce1201a") 
 | |
| {
 | |
|   first_focus(F_IDMOV);
 | |
| }
 | |
| 
 | |
| 
 | |
| //-----------------------------------------------------------------------------------------------------------------------//
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Maschera di forzatura
 | |
| ///////////////////////////////////////////////////////////
 | |
| class TForce_mov_fmask : public TAutomask
 | |
| { 
 | |
|   TTipo_cespite _tipo;
 | |
|   int _staat;
 | |
| 
 | |
| 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; }
 | |
| 
 | |
|   TForce_mov_fmask() : TAutomask("ce1201b") { }
 | |
| };
 | |
| 
 | |
| bool TForce_mov_fmask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| { 
 | |
|   switch (o.dlg())
 | |
|   {      
 | |
|   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);
 | |
|       real maxresf = get_real(F_RIS_AMMNOR_F)+get_real(F_RIS_AMMACC_F)+get_real(F_RIS_AMMANT_F)+get_real(F_RIS_QUOTE_PERSE)+get_real(F_RIS_PRIVATO)+get_real(F_RIS_QUOTE_PRIV)+get_real(F_RESIDUO_F);
 | |
|       if (sumf > maxresf)
 | |
|         return error_box(TR("Attenzione: l'ammortamento richiesto supera il residuo fiscale delle parti eliminate"));  
 | |
|     }
 | |
|     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);
 | |
|       real maxresc = get_real(F_RIS_AMMNOR_C)+get_real(F_RIS_AMMACC_C)+get_real(F_RIS_AMMANT_C)+get_real(F_RESIDUO_C);
 | |
|       if (sumc > maxresc)
 | |
|         return error_box(TR("Attenzione: l'ammortamento richiesto supera il residuo civilistico delle parti eliminate"));      
 | |
|     }
 | |
|     break;
 | |
|   default:
 | |
|   break;  
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| //-------------------------------------------------------------------------------------------------------------------------
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Applicazione principale
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TForza_amm_movce : public TRelation_application
 | |
| {         
 | |
|   TRelation* _rel;
 | |
|   TForce_mov_qmask* _qmask;
 | |
|   TForce_mov_fmask* _fmask;
 | |
| 
 | |
| private:
 | |
|   void update_amm(const TMask& m);
 | |
|   void update_plusminus();
 | |
|   void init_mask(TMask& m);
 | |
|   
 | |
| protected:
 | |
| //inizializzazione dati utente                                  
 | |
|   virtual bool user_create();
 | |
| //distruzione dati utente  
 | |
|   virtual bool user_destroy();
 | |
|   virtual bool changing_mask(int mode) { return TRUE; }
 | |
| //richiede la maschera da usare
 | |
|   virtual TMask* get_mask(int mode);
 | |
| //ritorna la relazione da modificare
 | |
|   virtual TRelation* get_relation() const { return _rel; }
 | |
|   
 | |
|   virtual void init_query_mode(TMask& m);
 | |
|   virtual void init_insert_mode(TMask& m);
 | |
|   virtual void init_modify_mode(TMask& m);
 | |
|   virtual int write(const TMask& m);
 | |
|   virtual int rewrite(const TMask& m);
 | |
|   
 | |
| public:
 | |
|   TForza_amm_movce() { }
 | |
| };
 | |
| 
 | |
| 
 | |
| TMask* TForza_amm_movce::get_mask(int mode)
 | |
| {
 | |
|   return mode == MODE_QUERY ? (TMask*)_qmask : (TMask*)_fmask;
 | |
| }
 | |
| 
 | |
| void TForza_amm_movce::init_mask(TMask& m)     //funzione per settare i dati ditta in ingresso
 | |
| { 
 | |
|   const int ese = _qmask->get_int(F_ESERCIZIO);
 | |
|   const int gru = _qmask->get_int(F_GRUPPO);
 | |
|   const char* spe = _qmask->get(F_SPECIE);
 | |
|   
 | |
|   TDitta_cespiti& dc = ditta_cespiti();
 | |
|   dc.set_attivita(ese, gru, spe);
 | |
|   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
 | |
|   
 | |
|   TCespite ces(_fmask->get(F_IDCESPITE));
 | |
|   const TRectype& movce = get_relation()->curr();
 | |
|   TRectype ammmv1 = get_relation()->curr(-69);
 | |
|   
 | |
|   _qmask->calc_res_mov(ces, movce, ammmv1); // ricalcola il residuo fiscale in forzatura
 | |
|   _fmask->set(F_RESIDUO_F, _qmask->get_residuof());     //prende il residuo fiscale del cespite calcolato in Qmask e lo mette in Fmask
 | |
|   _fmask->set(F_PLUSMINUS_F, _qmask->get_plusminusf());
 | |
|                                                                   
 | |
|   TRectype ammmv2 = get_relation()->curr(-77);
 | |
|   
 | |
|   _qmask->calc_res_mov(ces, movce, ammmv2); // ricalcola il residuo civilistico in forzatura
 | |
|   _fmask->set(F_RESIDUO_C, _qmask->get_residuoc());     //prende il residuo civilistico del cespite calcolato in Qmask e lo mette in Fmask
 | |
|   _fmask->set(F_PLUSMINUS_C, _qmask->get_plusminusc());
 | |
| }
 | |
| 
 | |
| void TForza_amm_movce::init_query_mode(TMask& m)
 | |
| {
 | |
|   ditta_cespiti().init_mask(m);
 | |
| }
 | |
| 
 | |
| void TForza_amm_movce::init_insert_mode(TMask& m)
 | |
| {
 | |
|   init_mask(m);
 | |
| }
 | |
| 
 | |
| void TForza_amm_movce::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:           //controllo sull'immaterialitá del cespite....
 | |
|       if (cac.get_int("I1")!=0)
 | |
|       {
 | |
|         m.disable(F_FORZATURA_P_F);
 | |
|         m.disable(F_FORZATURA_P_C);
 | |
|       }    
 | |
|       break;
 | |
|       
 | |
|     case tc_pluriennale:          //...e quindi sulla pluriennalitá
 | |
|       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_movce::update_amm(const TMask& m)
 | |
| { 
 | |
|   const TString16 idces = m.get(F_IDCESPITE);
 | |
|   TCespite ces(idces);
 | |
|   TDate dtmov = m.get_date(F_DTMOV);
 | |
|   ces.calc_amm(1, dtmov);
 | |
|   ces.calc_amm(2, dtmov);
 | |
| }
 | |
| 
 | |
| //funzione per l'aggiornamento dei campi plus-minusvalenza sul file AMMMV
 | |
| void TForza_amm_movce::update_plusminus()
 | |
| {
 | |
|   TRectype& amm1 = _rel->curr(-69);
 | |
|   TRectype& amm2 = _rel->curr(-77);
 | |
|   
 | |
|   const real& difff = _qmask->get_plusminusf();
 | |
|   amm1.put(AMMMV_MINUS, difff<ZERO ? -difff : ZERO);
 | |
|   amm1.put(AMMMV_PLUS, difff>ZERO ? difff : ZERO);
 | |
|   
 | |
|   const real& diffc = _qmask->get_plusminusc();
 | |
|   amm2.put(AMMMV_MINUS, diffc<ZERO ? -diffc : ZERO);
 | |
|   amm2.put(AMMMV_PLUS, diffc>ZERO ? diffc : ZERO);
 | |
| }
 | |
| 
 | |
| //funzione per il ricalcolo automatico dei valori degli ammortamenti dopo la forzatura (in caso di prima forzatura)
 | |
| int TForza_amm_movce::write(const TMask& m)
 | |
| {                 
 | |
|   update_plusminus();
 | |
|   
 | |
|   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_movce::rewrite(const TMask& m)
 | |
| { 
 | |
|   update_plusminus();
 | |
|   
 | |
|   int err = TRelation_application::rewrite(m);
 | |
|   if (err==NOERR)
 | |
|     update_amm(m);
 | |
|   return err;
 | |
| }
 | |
| 
 | |
| bool TForza_amm_movce::user_create()
 | |
| {                   
 | |
|   open_files(LF_TAB, LF_TABCOM, LF_CESPI, LF_AMMCE, LF_MOVCE, LF_MOVAM, LF_AMMMV, LF_SALCE, 0);
 | |
| 
 | |
|   _rel = new TRelation(LF_MOVCE);     // relazione principale su MOVCE
 | |
|   TString expr69;
 | |
|   expr69 << "IDCESPITE==IDCESPITE|IDMOV==IDMOV|TPAMM==1";
 | |
|   _rel->add(LF_AMMMV, expr69, 1, 0, 69);     // prima relazione su AMMMV (alias 69): TPAMM=1
 | |
|   _rel->write_enable(-69);
 | |
|   _rel->add(LF_MOVAM, expr69, 1, 0, 691);    // prima relazione su MOVAM (alias 691): TPAMM=1
 | |
|   TString expr77;
 | |
|   expr77 << "IDCESPITE==IDCESPITE|IDMOV==IDMOV|TPAMM==2";
 | |
|   _rel->add(LF_AMMMV, expr77, 1, 0, 77);     // seconda relazione su AMMMV (alias 77): TPAMM=2
 | |
|   _rel->write_enable(-77);
 | |
|   _rel->add(LF_MOVAM, expr77, 1, 0, 771);     // seconda relazione su MOVAM (alias 771): TPAMM=2 
 | |
|   
 | |
|   _qmask = new TForce_mov_qmask;
 | |
|   _fmask = new TForce_mov_fmask;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TForza_amm_movce::user_destroy()
 | |
| {
 | |
|   delete _fmask;
 | |
|   delete _qmask;
 | |
|   delete _rel;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int ce1200(int argc, char* argv[])
 | |
| {
 | |
|   TForza_amm_movce fm;
 | |
|   fm.run(argc, argv, TR("Forzatura ammortamento sui movimenti"));
 | |
|   return 0;
 | |
| }
 |