Modifiche alla liquidazione per corrispettivi + errori 1211 1212
git-svn-id: svn://10.65.10.50/trunk@352 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									35aabacbc8
								
							
						
					
					
						commit
						0b55fb6316
					
				
							
								
								
									
										134
									
								
								cg/cg4300.cpp
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								cg/cg4300.cpp
									
									
									
									
									
								
							| @ -25,16 +25,14 @@ void CG4300_App::user_create() | ||||
| 
 | ||||
|   for (_nditte->first(); !_nditte->eof(); _nditte->next()) | ||||
|   { | ||||
|     TString cod  = _nditte_r->get("CODDITTA"); | ||||
|     TString vers = _nditte_r->get("FREQVIVA"); | ||||
|     _n_ditte++; | ||||
| 
 | ||||
|     TToken_string* d = new TToken_string(64); | ||||
|      | ||||
|     // add record 
 | ||||
|     (*d) = cod; | ||||
|     d->add(_nditte_r->get("CODDITTA")); | ||||
|     d->add(_nditte_r->get("RAGSOC")); | ||||
|     d->add(vers); | ||||
|     d->add(_nditte_r->get("FREQVIVA")); | ||||
|     _nomiditte.add(d); | ||||
|   } | ||||
| 
 | ||||
| @ -261,20 +259,20 @@ bool CG4300_App::set_liquidazione() | ||||
|       if (to.empty()) to = "999999"; | ||||
|       for (i = 0; i < _nomiditte.items(); i++) | ||||
|       { | ||||
|         TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); | ||||
|         TString cod  = d.get(0); | ||||
|         TString vers = d.get(2); | ||||
|         if ((_what == mnt     && vers == "T") || | ||||
|             (_what == quarter && vers == "M")) | ||||
|           continue; | ||||
|          | ||||
|         if (atol(cod) >= atol(from) && atol(cod) <= atol(to)) | ||||
|           _selected.set(chk++); | ||||
|         TToken_string& d = (TToken_string&) _nomiditte[i]; | ||||
| 	TString16 cod  = d.get(0); | ||||
| 	TString16 vers = d.get(2); | ||||
| 	if ((_what == mnt     && vers == "T") || | ||||
| 	    (_what == quarter && vers == "M")) | ||||
| 	  continue; | ||||
|        | ||||
| 	if (atol(cod) >= atol(from) && atol(cod) <= atol(to)) | ||||
| 	  _selected.set(chk++); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|      | ||||
|    | ||||
|     switch(k) | ||||
|     {  | ||||
|     case DLG_SELECT: | ||||
| @ -282,69 +280,69 @@ bool CG4300_App::set_liquidazione() | ||||
|       _ditte->destroy(); chk = 0l; | ||||
|       for (i = 0; i < _nomiditte.items(); i++) | ||||
|       { | ||||
|         if (_selected[i]) continue; | ||||
|         TToken_string d((const TToken_string&)_nomiditte[i]); | ||||
|         TString cod  = d.get(0); | ||||
|         TString vers = d.get(2); | ||||
|         if ((_what == mnt     && vers == "T") || | ||||
|             (_what == quarter && vers == "M")) | ||||
|           continue; | ||||
| 	if (_selected[i]) continue; | ||||
| 	TToken_string& d =  (TToken_string&) _nomiditte[i]; | ||||
| 	TString16 cod  = d.get(0); | ||||
| 	TString16 vers = d.get(2); | ||||
| 	if ((_what == mnt     && vers == "T") || | ||||
| 	    (_what == quarter && vers == "M")) | ||||
| 	  continue; | ||||
| 	 | ||||
| 	_ditte->add(d); | ||||
| 
 | ||||
|         _ditte->add(d); | ||||
| 
 | ||||
|         // check        
 | ||||
|         if (!from.empty() || !to.empty()) | ||||
|         { | ||||
|           if (from.empty()) from = "0"; | ||||
|           if (to.empty()) to = "999999"; | ||||
|           if (atol(cod) >= atol(from) && atol(cod) <= atol(to)) | ||||
|           { | ||||
|             _ditte->check(chk);  | ||||
|             _selected.set(chk++); | ||||
|           } | ||||
|         } | ||||
| 	// check        
 | ||||
| 	if (!from.empty() || !to.empty()) | ||||
| 	{ | ||||
| 	  if (from.empty()) from = "0"; | ||||
| 	  if (to.empty()) to = "999999"; | ||||
| 	  if (atol(cod) >= atol(from) && atol(cod) <= atol(to)) | ||||
| 	  { | ||||
| 	    _ditte->check(chk);  | ||||
|           _selected.set(chk++); | ||||
| 	  } | ||||
| 	} | ||||
|       } | ||||
|        | ||||
|       // seleziona e aggiungi alle gia' selezionate 
 | ||||
|       if (_ditte->run() == K_ENTER) | ||||
|       { | ||||
|         cnt = 0; | ||||
|         for (j = 0l; j < _n_ditte; j++) | ||||
|         { | ||||
|           if (_selected[j]) continue; | ||||
|           if (_ditte->checked(cnt++)) | ||||
|             selected.set(j); | ||||
|         } | ||||
|         _selected |= selected; | ||||
|         selected.reset(); | ||||
|       } | ||||
|       m.field(CG43_FLD_SELECTED).set(format("%ld",(long)_selected.ones())); | ||||
|       break; | ||||
|     case CG43_BUT_ANN: | ||||
|       _selected.reset(); | ||||
|       m.field(CG43_FLD_SELECTED).set("0"); | ||||
|       break; | ||||
|     case CG43_BUT_CHK: | ||||
|     // seleziona e aggiungi alle gia' selezionate 
 | ||||
|     if (_ditte->run() == K_ENTER) | ||||
|     { | ||||
|       _ditte->destroy(); | ||||
|       for (i = 0; i < _nomiditte.items(); i++) | ||||
|       cnt = 0; | ||||
|       for (j = 0l; j < _n_ditte; j++) | ||||
|       { | ||||
|         TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); | ||||
|         _ditte->add(d); | ||||
|         if (_selected[i]) _ditte->check(i); | ||||
|         if (_selected[j]) continue; | ||||
|         if (_ditte->checked(cnt++)) | ||||
|           selected.set(j); | ||||
|       } | ||||
|       _ditte->disable_check(); | ||||
|       _ditte->run(); | ||||
|       _ditte->enable_check(); | ||||
|       _selected |= selected; | ||||
|       selected.reset(); | ||||
|     } | ||||
|       break; | ||||
|     m.field(CG43_FLD_SELECTED).set(format("%ld",(long)_selected.ones())); | ||||
|     break; | ||||
|   case CG43_BUT_ANN: | ||||
|     _selected.reset(); | ||||
|     m.field(CG43_FLD_SELECTED).set("0"); | ||||
|     break; | ||||
|   case CG43_BUT_CHK: | ||||
|   { | ||||
|     _ditte->destroy(); | ||||
|     for (i = 0; i < _nomiditte.items(); i++) | ||||
|     { | ||||
|       TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); | ||||
|       _ditte->add(d); | ||||
|       if (_selected[i]) _ditte->check(i); | ||||
|     } | ||||
|   }   | ||||
|   while (k != K_ENTER && k != K_ESC);       | ||||
|    | ||||
|    | ||||
|     _ditte->disable_check(); | ||||
|     _ditte->run(); | ||||
|     _ditte->enable_check(); | ||||
|   } | ||||
|     break; | ||||
|   } | ||||
| }   | ||||
| while (k != K_ENTER && k != K_ESC);       | ||||
| 
 | ||||
|   return k == K_ENTER; | ||||
| 
 | ||||
| 
 | ||||
| return k == K_ENTER; | ||||
| } | ||||
| 
 | ||||
| int cg4300(int argc, char* argv[]) | ||||
|  | ||||
							
								
								
									
										14
									
								
								cg/cg4300.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								cg/cg4300.h
									
									
									
									
									
								
							| @ -97,6 +97,18 @@ public:                // vedi sopra per le fisime morali | ||||
|   virtual ~_VendItem() {} | ||||
| }; | ||||
| 
 | ||||
| class _CorrItem : public TObject | ||||
| { | ||||
| public:                // vedi sopra per le fisime morali
 | ||||
|   real    _totale;     // totale vendite per registro
 | ||||
|   TString _codreg;     // codice registro
 | ||||
|   int     _month;      // mese
 | ||||
|   real    _aliquota;    // aliquota iva
 | ||||
|   TString _codiva;      // codice iva
 | ||||
|   _CorrItem() : _codreg(5) {} | ||||
|   virtual ~_CorrItem() {} | ||||
| }; | ||||
| 
 | ||||
| class _DescrItem : public TObject | ||||
| // Sembra triste e brutto esattamente come i files tabella
 | ||||
| // Ma la verita' e' che non e' affatto inefficiente 
 | ||||
| @ -298,6 +310,8 @@ public: | ||||
|   // minchia di puro suino
 | ||||
|   void add_vendite     (int month, const char* codreg, real& r); | ||||
|   void add_ventilation (real iva, real sum, const char* codiva); | ||||
|   void add_corrisp     (int month, const char* codreg, real& r, real& p, | ||||
|                         const char * codiva); | ||||
|    | ||||
|   // printappings
 | ||||
|   virtual void         set_page(int file, int counter); | ||||
|  | ||||
| @ -87,6 +87,7 @@ bool CG4300_App::update_firm(int month, bool recalc) | ||||
|                (const char*)desatt); | ||||
|       _prind->set_text(buf); | ||||
|       _vend_arr.destroy(); | ||||
|       _corr_arr.destroy(); | ||||
|        | ||||
|       cattivs = ""; | ||||
|        | ||||
| @ -261,30 +262,19 @@ void CG4300_App::recalc_att(int month, const char* codatt) | ||||
|   for (; _cur->pos() < items; ++(*_cur)) | ||||
|   {       | ||||
|     TDate date(_mov_r->get("DATAREG")); | ||||
|     TString reg = _mov_r->get("REG"); | ||||
|     TString16 reg = _mov_r->get("REG"); | ||||
|     bool isreg   = look_reg(_mov_r->get("REG")); | ||||
|      | ||||
|     /*
 | ||||
|      * check register present, rmoviva present and date OK | ||||
|      */       | ||||
| #ifndef DBG | ||||
| 
 | ||||
|     if (!is_date_ok(date, month) ||   | ||||
|         !isreg || | ||||
|         _reg_r->get("S8") != trueatt || | ||||
|         !_cur->is_first_match(LF_RMOVIVA))  | ||||
|       continue; | ||||
| #else           | ||||
| 
 | ||||
|     bool dok = !is_date_ok(date, month);   | ||||
|     bool sreg = !isreg; | ||||
|     bool rs8  = _reg_r->get("S8") != trueatt; | ||||
|     bool cmt  = !_cur->is_first_match(LF_RMOVIVA); | ||||
|     const bool dok = !is_date_ok(date, month);   | ||||
|     const bool sreg = !isreg; | ||||
|     const bool rs8  = _reg_r->get("S8") != trueatt; | ||||
|     const bool cmt  = !_cur->is_first_match(LF_RMOVIVA); | ||||
|      | ||||
|     if (dok || sreg || rs8 || cmt) continue; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|     /*
 | ||||
|      * check date se si calcola l'acconto | ||||
|      */ | ||||
| @ -466,10 +456,12 @@ void CG4300_App::recalc_att(int month, const char* codatt) | ||||
|       else  | ||||
|         if (corrisp) | ||||
|         { | ||||
|           real perc = _iva->get_real("R0")/100.00; | ||||
| 
 | ||||
|           lor += imponibile; | ||||
|           lor += imposta; | ||||
|           _pim_r->put("I0",LORDO); | ||||
|           add_corrisp(month, reg, imponibile); | ||||
|           add_corrisp(month, reg, imponibile, perc, codiva); | ||||
|         } | ||||
|         else | ||||
|         {  | ||||
| @ -834,7 +826,3 @@ _DescrItem* CG4300_App::recalc_rimborso(int month, const char* codatts) | ||||
|    | ||||
|   return d; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -95,23 +95,28 @@ void CG4300_App::add_vendite(int month, const char* codreg, real& r) | ||||
|   vi->_totale += r; | ||||
| } | ||||
| 
 | ||||
| void CG4300_App::add_corrisp(int month, const char* codreg, real& r) | ||||
| void CG4300_App::add_corrisp(int month, const char* codreg, real& r, | ||||
| 														 real& p, const char * codiva) | ||||
| { | ||||
|   _VendItem* vi = NULL; | ||||
|   _CorrItem* ci = NULL; | ||||
| 	const int nitems = _corr_arr.items(); | ||||
|   | ||||
|   for (int i = 0; i < _vend_arr.items(); i++) | ||||
|     { | ||||
|       vi = (_VendItem*)&_corr_arr[i]; | ||||
|       if (vi->_codreg == codreg && vi->_month == month) | ||||
| 	break; | ||||
|     } | ||||
|   if (i == _vend_arr.items()) | ||||
|     { | ||||
|       _corr_arr.add(vi = new _VendItem); | ||||
|       vi->_codreg      = codreg; | ||||
|       vi->_month       = month; | ||||
|     } | ||||
|   vi->_totale += r; | ||||
|   for (int i = 0; i < nitems; i++) | ||||
| 	{ | ||||
| 		ci = (_CorrItem*)&_corr_arr[i]; | ||||
| 		if (ci->_codreg == codreg && ci->_month == month && | ||||
| 				ci->_codiva == codiva) | ||||
| 			break; | ||||
| 	} | ||||
|   if (i == nitems) | ||||
| 	{ | ||||
| 		_corr_arr.add(ci = new _CorrItem); | ||||
| 		ci->_codreg      = codreg; | ||||
| 		ci->_month       = month; | ||||
| 		ci->_codiva      = codiva; | ||||
| 		ci->_aliquota    = p; | ||||
| 	} | ||||
|   ci->_totale += r; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -335,13 +340,19 @@ real CG4300_App::credito_prec(int month) | ||||
|   real c(0.0); | ||||
| 
 | ||||
|   // se c'e' un credito nei parametri ditta, si usa quello e vaffanculo
 | ||||
|   TConfig cnf(CONFIG_DITTA); | ||||
| // TConfig cnf(CONFIG_DITTA);
 | ||||
|    | ||||
|   c = (const char*)cnf.get("CrIvAp"); | ||||
|   if (!c.is_zero()) return c; | ||||
| //  c = (const char*)cnf.get("CrIvAp");
 | ||||
| //  if (!c.is_zero()) return c;
 | ||||
| 
 | ||||
|   if (is_first_month(month)) | ||||
|     { | ||||
|   { | ||||
|     look_lia(); | ||||
|       if (_lia->status() == NOERR) | ||||
|       { | ||||
| 	c = _lia->get_real("R0"); | ||||
| 	if (!c.iszero()) return c; | ||||
|       } | ||||
|       int yr = atoi(_year) - 1; | ||||
|       _lim->zero(); | ||||
|       *_lim_anno = yr; | ||||
|  | ||||
| @ -99,6 +99,37 @@ void CG4300_App::describe_plafond(int month, const char* codatt) | ||||
| // ricalcolo dei corrispettivi
 | ||||
| void CG4300_App::recalc_corrispettivi(int month, const char* codatt) | ||||
| { | ||||
|   if (_corr_arr.items() == 0) return; | ||||
|   // ricalcola (solo per il mese in corso!) operando sull'array 
 | ||||
|   for (int i = 0; i < _corr_arr.items(); i++) | ||||
|   { | ||||
|     _CorrItem* ci = (_CorrItem*)&_corr_arr[i]; | ||||
|     if (ci->_month != month) | ||||
|       continue; | ||||
|      | ||||
|     real imposta    = ci->_totale/(1.00 + ci->_aliquota); | ||||
|     imposta.ceil(ROUND_LIRA); | ||||
|     real imponibile = ci->_totale - imposta; | ||||
| 
 | ||||
|     // aggiusto l'IVA vendite nei plm
 | ||||
|     look_plm(month, codatt); | ||||
|     real ive = _plm->get_real("R0"); | ||||
|     ive     += imposta; | ||||
|     _plm->put("R0",ive); | ||||
|     _plm->rewrite(); | ||||
| 
 | ||||
|     // Aggiorno i luridi pim
 | ||||
|     look_pim(month, codatt, ci->_codreg, "0", ci->_codiva, TRUE); | ||||
|      | ||||
|     imponibile += _pim->get_real("R0"); | ||||
|     imposta    += _pim->get_real("R1"); | ||||
|     _pim->put("R0", imponibile); | ||||
|     _pim->put("R1", imposta); | ||||
|     _pim->zero("R2"); // e' giusto ???? TBI
 | ||||
|     // segnale per comodita'
 | ||||
|     _pim->put("B1","X"); | ||||
|     _pim->rewrite(); | ||||
|   }    | ||||
| } | ||||
| 
 | ||||
| // ricalcolo della malefica ventilazione
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user