Corretto azzeramento righe iva
git-svn-id: svn://10.65.10.50/trunk@959 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									fa97dca95b
								
							
						
					
					
						commit
						a33eb771fb
					
				@ -718,12 +718,11 @@ void TPrimanota_application::mask2rel(const TMask& m)
 | 
				
			|||||||
    _rel->lfile().put("TOTDOC", totale);
 | 
					    _rel->lfile().put("TOTDOC", totale);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  ivas_pack();
 | 
				
			||||||
  TArray& irows = ivas().rows_array();
 | 
					  TArray& irows = ivas().rows_array();
 | 
				
			||||||
  for (int i = 0; i < irows.items(); i++)
 | 
					  for (int i = 0; i < irows.items(); i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TToken_string& row = (TToken_string&)irows[i];
 | 
					    TToken_string& row = (TToken_string&)irows[i];
 | 
				
			||||||
    if (row.empty_items())
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TRectype &r = _rel->iva(i);
 | 
					    TRectype &r = _rel->iva(i);
 | 
				
			||||||
    r.zero();
 | 
					    r.zero();
 | 
				
			||||||
 | 
				
			|||||||
@ -387,12 +387,11 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void TPrimanota_application::cgs_pack()
 | 
					void TPrimanota_application::cgs_pack()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TArray& rows = cgs().rows_array();
 | 
					  TString_array& rows = cgs().rows_array();
 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int max = rows.items();
 | 
					  const int max = rows.items();
 | 
				
			||||||
  for (int i = 0; i < max; i++)
 | 
					  for (int i = 0; i < max; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TToken_string& r = (TToken_string&)rows[i];
 | 
					    TToken_string& r = rows.row(i);
 | 
				
			||||||
    bool del = FALSE;
 | 
					    bool del = FALSE;
 | 
				
			||||||
    if (r.empty_items())             // Remove all empty strings
 | 
					    if (r.empty_items())             // Remove all empty strings
 | 
				
			||||||
      del = TRUE;
 | 
					      del = TRUE;
 | 
				
			||||||
@ -412,25 +411,27 @@ void TPrimanota_application::cgs_pack()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool TPrimanota_application::ci_sono_importi() const
 | 
					bool TPrimanota_application::ci_sono_importi() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TArray& rows = cgs().rows_array();
 | 
					  TString_array& rows = cgs().rows_array();
 | 
				
			||||||
  for (int i = 0; i < rows.items(); i++)
 | 
					  for (int i = 0; i < rows.items(); i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TToken_string& r = (TToken_string&)rows[i];
 | 
					    TToken_string& r = rows.row(i);
 | 
				
			||||||
    if (r.get_char(0) > '0') return TRUE;
 | 
					    const real dare(r.get(0));
 | 
				
			||||||
    if (r.get_char() > '0') return TRUE;
 | 
					    if (dare != ZERO) return TRUE;
 | 
				
			||||||
 | 
					    const real avere(r.get());
 | 
				
			||||||
 | 
					    if (avere != ZERO) return TRUE;
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
  return FALSE;
 | 
					  return FALSE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
real TPrimanota_application::calcola_saldo() const
 | 
					real TPrimanota_application::calcola_saldo() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TArray& rows = cgs().rows_array();
 | 
					  TString_array& rows = cgs().rows_array();
 | 
				
			||||||
  const int max = rows.items();
 | 
					  const int max = rows.items();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  real tdare, tavere;
 | 
					  real tdare, tavere;
 | 
				
			||||||
  for (int i = 0; i < max; i++)
 | 
					  for (int i = 0; i < max; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TToken_string& r = (TToken_string&)rows[i];
 | 
					    TToken_string& r = rows.row(i);
 | 
				
			||||||
    tdare += real(r.get(0));
 | 
					    tdare += real(r.get(0));
 | 
				
			||||||
    tavere += real(r.get());
 | 
					    tavere += real(r.get());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -821,6 +822,24 @@ real TPrimanota_application::calcola_imp() const
 | 
				
			|||||||
  return imponibili+imposte;
 | 
					  return imponibili+imposte;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPrimanota_application::ivas_pack()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString_array& rows = ivas().rows_array();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  const int max = rows.items();
 | 
				
			||||||
 | 
					  for (int i = 0; i < max; i++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    TToken_string& r = rows.row(i);
 | 
				
			||||||
 | 
					    const real imponibile(r.get(0));
 | 
				
			||||||
 | 
					    if (imponibile != ZERO) continue;
 | 
				
			||||||
 | 
					    const real imposta(r.get(3));
 | 
				
			||||||
 | 
					    if (imposta != ZERO) continue;
 | 
				
			||||||
 | 
					    rows.destroy(i, FALSE);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  rows.pack();           // Pack array
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Certified 50%
 | 
					// Certified 50%
 | 
				
			||||||
bool TPrimanota_application::iva_notify(int r, KEY k)
 | 
					bool TPrimanota_application::iva_notify(int r, KEY k)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -884,7 +903,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if (k == K_ENTER)
 | 
					  if (k == K_ENTER)
 | 
				
			||||||
  {   
 | 
					  {   
 | 
				
			||||||
    int delimp = -1, deliva = -1;              // Eventuali righe da cancellare
 | 
					    int delimp = -1, deliva = -1;              // Eventuali righe contabili da cancellare
 | 
				
			||||||
    if (oldpos >= 0)                           // Se il conto esisteva anche prima ...
 | 
					    if (oldpos >= 0)                           // Se il conto esisteva anche prima ...
 | 
				
			||||||
    {                                          // sottrai il vecchio imponibile
 | 
					    {                                          // sottrai il vecchio imponibile
 | 
				
			||||||
      const TImporto imp = app().sub_cgs_imp(oldpos, oldimp);
 | 
					      const TImporto imp = app().sub_cgs_imp(oldpos, oldimp);
 | 
				
			||||||
@ -922,7 +941,10 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
 | 
				
			|||||||
    if (newpos < 0)
 | 
					    if (newpos < 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (delimp >= 0)       
 | 
					      if (delimp >= 0)       
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
        app().reset_cgs_row(delimp);           // Cancella vecchia riga
 | 
					        app().reset_cgs_row(delimp);           // Cancella vecchia riga
 | 
				
			||||||
 | 
					        if (deliva > delimp) deliva--;
 | 
				
			||||||
 | 
					      }  
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      const TImporto val(app().real2imp(imponibile, 'I'));         
 | 
					      const TImporto val(app().real2imp(imponibile, 'I'));         
 | 
				
			||||||
      if (conto.ok() && !val.is_zero())        // Se c'e' imponibile ...
 | 
					      if (conto.ok() && !val.is_zero())        // Se c'e' imponibile ...
 | 
				
			||||||
@ -949,11 +971,11 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
 | 
				
			|||||||
    const char tipod = detrarre ? 'D' : 'N';
 | 
					    const char tipod = detrarre ? 'D' : 'N';
 | 
				
			||||||
    int newposiva = type2pos(tipod);
 | 
					    int newposiva = type2pos(tipod);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (deliva >= 0 && newposiva != deliva)                 // E' cambiato il tipo d'imposta
 | 
				
			||||||
 | 
					      app().reset_cgs_row(deliva);                          // Azzera il vecchio tipo se necessario
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if (newposiva < 0)
 | 
					    if (newposiva < 0)
 | 
				
			||||||
    {                                          
 | 
					    {                                          
 | 
				
			||||||
      if (deliva >= 0)
 | 
					 | 
				
			||||||
        app().reset_ivas_row(deliva);
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      if (!imposta.is_zero())                               // Se  c'e' imposta ...
 | 
					      if (!imposta.is_zero())                               // Se  c'e' imposta ...
 | 
				
			||||||
      {                                                     // ... crea nuova riga per l'IVA
 | 
					      {                                                     // ... crea nuova riga per l'IVA
 | 
				
			||||||
        const TImporto val(app().real2imp(imposta, 'I'));         
 | 
					        const TImporto val(app().real2imp(imposta, 'I'));         
 | 
				
			||||||
@ -965,7 +987,7 @@ else
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  TImporto val(app().real2imp(imposta, 'I'));         
 | 
					  TImporto val(app().real2imp(imposta, 'I'));         
 | 
				
			||||||
  val = app().add_cgs_imp(newposiva, val);
 | 
					  val = app().add_cgs_imp(newposiva, val);
 | 
				
			||||||
  if (val.is_zero())                                    // Se la riga si e' azzerata ...
 | 
					  if (val.is_zero())                                    // Se l'imposta si e' azzerata ...
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    app().reset_cgs_row(newposiva);                     // ... cancellala
 | 
					    app().reset_cgs_row(newposiva);                     // ... cancellala
 | 
				
			||||||
    newposiva = -1;
 | 
					    newposiva = -1;
 | 
				
			||||||
@ -978,9 +1000,6 @@ oldposiva = newposiva;
 | 
				
			|||||||
if (r == 0)                                             // Se cambio la prima riga ...
 | 
					if (r == 0)                                             // Se cambio la prima riga ...
 | 
				
			||||||
  app().add_cgs_tot(app().curr_mask());                 // ... ricalcola conti
 | 
					  app().add_cgs_tot(app().curr_mask());                 // ... ricalcola conti
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (imponibile.is_zero() && imposta.is_zero())          // Svuota riga iva nulla
 | 
					 | 
				
			||||||
  app().reset_ivas_row(r);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  app().calcola_imp();                                    // Ricalcola totale IVA
 | 
					  app().calcola_imp();                                    // Ricalcola totale IVA
 | 
				
			||||||
  app().calcola_saldo();                                  // Ricalcola sbilanci
 | 
					  app().calcola_saldo();                                  // Ricalcola sbilanci
 | 
				
			||||||
}                                                         
 | 
					}                                                         
 | 
				
			||||||
 | 
				
			|||||||
@ -169,6 +169,7 @@ protected:
 | 
				
			|||||||
  TImporto add_cgs_imp(int n, const TImporto& importo);
 | 
					  TImporto add_cgs_imp(int n, const TImporto& importo);
 | 
				
			||||||
  TImporto sub_cgs_imp(int n, const real& imp);
 | 
					  TImporto sub_cgs_imp(int n, const real& imp);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  void ivas_pack();
 | 
				
			||||||
  void cgs_pack();
 | 
					  void cgs_pack();
 | 
				
			||||||
  bool ci_sono_importi() const;
 | 
					  bool ci_sono_importi() const;
 | 
				
			||||||
  real calcola_saldo() const;
 | 
					  real calcola_saldo() const;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user