Patch level : 12.0 386
Files correlati : tf Commento : - Aggiunto controllo sul credito dell'anno precedente, se negativo il programma va a controllare il campo nei periodi precedenti per effettuare il calcolo e fa la differenza. Se il risultato di questo rimane negativo avvisa di aver sforato la somma. git-svn-id: svn://10.65.10.50/branches/R_10_00@23780 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4a54418279
								
							
						
					
					
						commit
						75216c1af6
					
				@ -162,11 +162,62 @@ int calc_inc_diff(int anno, int mese, int tipoiva, real& imponibile_diff, real&
 | 
			
		||||
  return flag;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Funzione per determinare il credito dell'anno precedente delle dichiarazioni precedenti */
 | 
			
		||||
real calcolaCreditoAnnoPrec(bool mensile, int anno, int mese)
 | 
			
		||||
{
 | 
			
		||||
	// Credito anno precedente
 | 
			
		||||
	/* Per calcolare il credito dell'anno precedente inizio a leggere i record precedenti su IVALIQ
 | 
			
		||||
	 * fino a quando ne trovo uno >= 0.
 | 
			
		||||
	 * Questi geni hanno messo la possibilità di mettere un valore <0 se voglio utilizzare del credito precedente */ 
 | 
			
		||||
	
 | 
			
		||||
	real creaprec = ZERO;
 | 
			
		||||
	TRectype rowLia = getLIA(anno);
 | 
			
		||||
 | 
			
		||||
	if(mensile || (!mensile && ((mese - 1) % 3) == 0))
 | 
			
		||||
	{
 | 
			
		||||
		TRelation ivaLiq(LF_IVALIQ);
 | 
			
		||||
		TRectype from(ivaLiq.curr()); from.put("ANNO", anno); from.put("MESE", 1);
 | 
			
		||||
		// Fino al mese precedente
 | 
			
		||||
		TRectype to(ivaLiq.curr()); to.put("ANNO", anno); to.put("MESE", mese - 1);	
 | 
			
		||||
 | 
			
		||||
		TSorted_cursor curLiq(&ivaLiq, "MESE-", "GENERATA!=\"G\"", 1, &from, &to);
 | 
			
		||||
		bool trovato = false;
 | 
			
		||||
		for(curLiq = 0; curLiq.pos() < curLiq.items() && !trovato; ++curLiq)
 | 
			
		||||
		{
 | 
			
		||||
			TRectype rowLiq = curLiq.curr();
 | 
			
		||||
			if(rowLiq.get_int("MESE") >= mese) continue;	// Perchè li prende lo stesso?
 | 
			
		||||
			creaprec = creaprec + rowLiq.get_real("CREAPREC") - rowLiq.get_real("IVADOV");
 | 
			
		||||
 | 
			
		||||
			// Se è > 0 Ho trovato il primo valore messo nella dichiarazione
 | 
			
		||||
			if(rowLiq.get_real("CREAPREC") > ZERO)
 | 
			
		||||
			{
 | 
			
		||||
				trovato = true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if(!trovato)
 | 
			
		||||
		{
 | 
			
		||||
			creaprec = rowLia.get_real("R0");
 | 
			
		||||
		}
 | 
			
		||||
		else if(creaprec < ZERO)
 | 
			
		||||
		{
 | 
			
		||||
			creaprec = ZERO;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/* Se siamo in una liquidazione trimestrale la scadenza della dichiarazione IVA è il 28 febbraio 
 | 
			
		||||
	 * quindi so per certo che il valore calcolato in LIA.R0 è stato trasmesso */
 | 
			
		||||
	else if(!mensile && mese == 3)
 | 
			
		||||
	{
 | 
			
		||||
		creaprec		= rowLia.get_real("R0");
 | 
			
		||||
	}
 | 
			
		||||
	return creaprec;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ComLiqPerIva_mask : public TAutomask
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
	bool mensile;
 | 
			
		||||
	TRectype trueData;
 | 
			
		||||
 | 
			
		||||
	virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
			
		||||
	void extractinator();
 | 
			
		||||
	void checkOldValue(int field, real val);
 | 
			
		||||
@ -202,7 +253,7 @@ bool ComLiqPerIva_mask::on_field_event(TOperable_field& o, TField_event e, long
 | 
			
		||||
				enable(F_TRIMESTRE);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if(e == fe_init)
 | 
			
		||||
		else if(e == fe_init && !query_mode())
 | 
			
		||||
		{ 
 | 
			
		||||
			// Per trovare un valore tento per 5 anni di vedere se c'è una liquidazione aperta, così da valorizzare tutta la roba
 | 
			
		||||
			int year = TDate(TODAY).year();
 | 
			
		||||
@ -314,7 +365,21 @@ bool ComLiqPerIva_mask::on_field_event(TOperable_field& o, TField_event e, long
 | 
			
		||||
			{
 | 
			
		||||
				// Ricalcolo VP13 e VP14
 | 
			
		||||
				real debito = get_real(F_IVADOV) + get_real(F_DEBPREC) + get_real(F_INTLIQTRI);
 | 
			
		||||
				real credito = get_real(F_IVADOVC) + get_real(F_CREPREC) + get_real(F_CREAPREC) + get_real(F_VEAUE) + get_real(F_CREIMP) + get_real(F_ACCDOV);
 | 
			
		||||
				
 | 
			
		||||
				/* Se il credito anno precedente è negativo devo mantenerlo tale ma sottrarlo al credito dell'anno precedente delle dichiarazioni precedenti */
 | 
			
		||||
				real creaprec = get_real(F_CREAPREC);
 | 
			
		||||
				if(creaprec < ZERO)
 | 
			
		||||
				{
 | 
			
		||||
					creaprec = calcolaCreditoAnnoPrec(mensile, get_int(F_ANNO), get_int(F_MESE)) + creaprec;
 | 
			
		||||
					// Controllo che il credito non sia sforato sotto 0
 | 
			
		||||
					if (creaprec < ZERO)
 | 
			
		||||
					{
 | 
			
		||||
						TString msg = "Attenzione! hai sforato il tuo credito dell'anno precedente di "; msg << (creaprec * - UNO).stringa(0,2) << "€";
 | 
			
		||||
						warning_box(msg);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				real credito = get_real(F_IVADOVC) + get_real(F_CREPREC) + creaprec + get_real(F_VEAUE) + get_real(F_CREIMP) + get_real(F_ACCDOV);
 | 
			
		||||
				if(debito - credito >= ZERO)
 | 
			
		||||
				{
 | 
			
		||||
					set(F_IVAVER, debito - credito);
 | 
			
		||||
@ -497,45 +562,7 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Credito anno precedente
 | 
			
		||||
		/* Per calcolare il credito dell'anno precedente inizio a leggere i record precedenti su IVALIQ
 | 
			
		||||
		 * fino a quando ne trovo uno >= 0.
 | 
			
		||||
		 * Questi geni hanno messo la possibilità di mettere un valore <0 se voglio utilizzare del credito precedente */ 
 | 
			
		||||
		if(mensile || (!mensile && ((start - 1) % 3) == 0))
 | 
			
		||||
		{
 | 
			
		||||
			TRelation ivaLiq(LF_IVALIQ);
 | 
			
		||||
			TRectype from(ivaLiq.curr()); from.put("ANNO", anno); from.put("MESE", 1);
 | 
			
		||||
			// Fino al mese precedente
 | 
			
		||||
			TRectype to(ivaLiq.curr()); to.put("ANNO", anno); to.put("MESE", start - 1);	
 | 
			
		||||
 | 
			
		||||
			TSorted_cursor curLiq(&ivaLiq, "MESE-", "GENERATA!=\"G\"", 1, &from, &to);
 | 
			
		||||
			bool trovato = false;
 | 
			
		||||
			for(curLiq = 0; curLiq.pos() < curLiq.items() && !trovato; ++curLiq)
 | 
			
		||||
			{
 | 
			
		||||
				TRectype rowLiq = curLiq.curr();
 | 
			
		||||
				if(rowLiq.get_int("MESE") >= start) continue;	// Perchè li prende lo stesso?
 | 
			
		||||
				creaprec = creaprec + rowLiq.get_real("CREAPREC") - rowLiq.get_real("IVADOV");
 | 
			
		||||
 | 
			
		||||
				// Se è > 0 Ho trovato il primo valore messo nella dichiarazione
 | 
			
		||||
				if(rowLiq.get_real("CREAPREC") > ZERO)
 | 
			
		||||
				{
 | 
			
		||||
					trovato = true;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if(!trovato)
 | 
			
		||||
			{
 | 
			
		||||
				creaprec = rowLia.get_real("R0");
 | 
			
		||||
			}
 | 
			
		||||
			else if(creaprec < ZERO)
 | 
			
		||||
			{
 | 
			
		||||
				creaprec = ZERO;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		/* Se siamo in una liquidazione trimestrale la scadenza della dichiarazione IVA è il 28 febbraio 
 | 
			
		||||
		 * quindi so per certo che il valore calcolato in LIA.R0 è stato trasmesso */
 | 
			
		||||
		else if(!mensile && start == 3)
 | 
			
		||||
		{
 | 
			
		||||
			creaprec		= rowLia.get_real("R0");
 | 
			
		||||
		}
 | 
			
		||||
		creaprec = calcolaCreditoAnnoPrec(mensile, anno, start);
 | 
			
		||||
 | 
			
		||||
		intliqtri		= intliqtri + rowLim.get_real("R14");
 | 
			
		||||
		accdov			= accdov + rowLim.get_real("R11");
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user