Gestione NUMREG_PROVVISORIO per gestione saldaconto "in rete"
git-svn-id: svn://10.65.10.50/trunk@6644 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									7118e6ea56
								
							
						
					
					
						commit
						b36ea6d65b
					
				@ -641,7 +641,7 @@ void TPrimanota_application::init_insert_mode(TMask& m)
 | 
			
		||||
    m.hide(F_ADJUST_PRORATA);  // In inserimento non puo' esistere un pro-rata errato!
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  partite().destroy();
 | 
			
		||||
  partite().destroy();         // Elimina tutte le partite in memoria
 | 
			
		||||
  if (is_fattura())
 | 
			
		||||
  { 
 | 
			
		||||
    activate_numrif(m, FALSE);
 | 
			
		||||
@ -728,7 +728,6 @@ bool TPrimanota_application::test_swap(bool ritsoc)
 | 
			
		||||
  return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int TPrimanota_application::read(TMask& m)
 | 
			
		||||
{
 | 
			
		||||
  m.reset();           // Azzera campi e relativi dirty = 3
 | 
			
		||||
@ -737,6 +736,8 @@ int TPrimanota_application::read(TMask& m)
 | 
			
		||||
  const long numreg = _rel->curr().get_long(MOV_NUMREG);
 | 
			
		||||
 | 
			
		||||
  partite().destroy(); // Azzera tutte le partite
 | 
			
		||||
  if (gestione_saldaconto() && causale().tipomov())
 | 
			
		||||
    partite().add_numreg(numreg);  // Carica le partite interessate
 | 
			
		||||
  
 | 
			
		||||
  cgs().reset();       // Azzera tutte le righe contabili
 | 
			
		||||
 | 
			
		||||
@ -1065,8 +1066,9 @@ int TPrimanota_application::write(const TMask& m)
 | 
			
		||||
    check_saldi();
 | 
			
		||||
    
 | 
			
		||||
    bool salvaconto = FALSE;
 | 
			
		||||
    const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
 | 
			
		||||
    
 | 
			
		||||
//    const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
 | 
			
		||||
    const long old_nreg = NUMREG_PROVVISORIO;
 | 
			
		||||
 | 
			
		||||
    if (iva() != nessuna_iva)
 | 
			
		||||
    {
 | 
			
		||||
      causale().reg().reread();                         // Aggiorna protocollo IVA
 | 
			
		||||
@ -1075,7 +1077,7 @@ int TPrimanota_application::write(const TMask& m)
 | 
			
		||||
        switch (causale().tipomov()) 
 | 
			
		||||
        {
 | 
			
		||||
        case tm_fattura:
 | 
			
		||||
          partite().update_reg(_rel->curr(), old_nreg);
 | 
			
		||||
//          partite().update_reg(_rel->curr(), old_nreg);  // L'array e' sempre vuoto!
 | 
			
		||||
          write_scadenze(m);                            // Salva fattura
 | 
			
		||||
          break;
 | 
			
		||||
        case tm_nota_credito:  
 | 
			
		||||
@ -1103,7 +1105,6 @@ int TPrimanota_application::write(const TMask& m)
 | 
			
		||||
    
 | 
			
		||||
    if (salvaconto)
 | 
			
		||||
    {     
 | 
			
		||||
      const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
 | 
			
		||||
      partite().update_reg(_rel->curr(), old_nreg);
 | 
			
		||||
      partite().write();
 | 
			
		||||
    }  
 | 
			
		||||
 | 
			
		||||
@ -583,7 +583,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
 | 
			
		||||
    const bool nota = a.is_nota_credito() && m.field(F_NUMRIF).active(); 
 | 
			
		||||
    const bool fatt = a.is_fattura() && m.page_enabled(2);
 | 
			
		||||
    
 | 
			
		||||
    const long numreg = m.get_long(F_NUMREG);
 | 
			
		||||
    const long numreg = m.insert_mode() ? NUMREG_PROVVISORIO : m.get_long(F_NUMREG);
 | 
			
		||||
    
 | 
			
		||||
    const bool in_valuta = m.get(SK_VALUTA).not_empty();
 | 
			
		||||
    TImporto saldaconto, saldaconto_val;
 | 
			
		||||
@ -988,8 +988,9 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
 | 
			
		||||
  const int currig = cgs.selected();
 | 
			
		||||
  
 | 
			
		||||
  if (k == K_F8 && a.is_pagamento())
 | 
			
		||||
  {                        
 | 
			
		||||
    const long numreg = a.curr_mask().get_long(F_NUMREG);
 | 
			
		||||
  { 
 | 
			
		||||
    const TMask cm = a.curr_mask();
 | 
			
		||||
    const long numreg = cm.insert_mode() ? NUMREG_PROVVISORIO : cm.get_long(F_NUMREG);
 | 
			
		||||
    const TImporto speso = a.partite().importo_speso(numreg, currig+1);
 | 
			
		||||
    
 | 
			
		||||
    const char* ss = speso.valore().string();
 | 
			
		||||
@ -2032,8 +2033,8 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
 | 
			
		||||
    if (f.focusdirty() && a.is_nota_credito())
 | 
			
		||||
    {   
 | 
			
		||||
      TPartite_array& p = a.partite();
 | 
			
		||||
      if (m.edit_mode())
 | 
			
		||||
        p.add_numreg(m.get_long(F_NUMREG));
 | 
			
		||||
//      if (m.edit_mode())
 | 
			
		||||
//        p.add_numreg(m.get_long(F_NUMREG));    // Gia' fatto dalla read!
 | 
			
		||||
 | 
			
		||||
      const TPartita* game = p.first();
 | 
			
		||||
      if (game != NULL && atol(f.get()) != game->conto().codclifo())  
 | 
			
		||||
 | 
			
		||||
@ -1011,7 +1011,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
 | 
			
		||||
    
 | 
			
		||||
    if (k == K_ENTER)
 | 
			
		||||
    {                                
 | 
			
		||||
      const long curreg = cm.get_long(F_NUMREG);
 | 
			
		||||
      const long curreg = cm.insert_mode() ? NUMREG_PROVVISORIO : cm.get_long(F_NUMREG);
 | 
			
		||||
      const TImporto importo(a.get_cgs_imp(riga));
 | 
			
		||||
      const TImporto speso(a.partite().importo_speso(curreg, riga+1));
 | 
			
		||||
 | 
			
		||||
@ -1276,9 +1276,11 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
 | 
			
		||||
bool TPrimanota_application::notify_cgline_deletion(int numrig)
 | 
			
		||||
{                           
 | 
			
		||||
  bool found = FALSE;
 | 
			
		||||
  
 | 
			
		||||
  const long nreg = curr_mask().get_long(F_NUMREG);
 | 
			
		||||
  partite().add_numreg(nreg);
 | 
			
		||||
 | 
			
		||||
//  if (curr_mask().edit_mode())
 | 
			
		||||
//    partite().add_numreg(nreg);  // Gia' fatto dalla read
 | 
			
		||||
 | 
			
		||||
  for (TPartita* game = partite().first(); game; game = partite().next())
 | 
			
		||||
    found |= notify_cgline_deletion(*game, nreg, numrig);
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
@ -1664,7 +1664,9 @@ bool TGame_mask::same_number(const char* key, const char* num) const
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TGame_mask::fill_partite()
 | 
			
		||||
{                                                 
 | 
			
		||||
{ 
 | 
			
		||||
  TWait_cursor hourglass;
 | 
			
		||||
                                                
 | 
			
		||||
  const int annorif = get_int(P_ANNO);           // Anno corrente    
 | 
			
		||||
  const TString numrif = get(P_NUMERO);          // Partita corrente
 | 
			
		||||
  const bool all = get(P_SHOWALL).not_empty();   // Visualizza anche partite chiuse
 | 
			
		||||
@ -1672,8 +1674,6 @@ void TGame_mask::fill_partite()
 | 
			
		||||
  TString_array& a = partite().rows_array();
 | 
			
		||||
  a.destroy();
 | 
			
		||||
 | 
			
		||||
  app().begin_wait();
 | 
			
		||||
  
 | 
			
		||||
  TPartite_array& giochi = app().partite();
 | 
			
		||||
  for (TPartita* gioco = giochi.first(); gioco != NULL; gioco = giochi.next())
 | 
			
		||||
  {     
 | 
			
		||||
@ -1725,7 +1725,7 @@ void TGame_mask::fill_partite()
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  a.sort();
 | 
			
		||||
  for (int r = a.items()-1; r > 0; r--)
 | 
			
		||||
  for (int r = a.last(); r > 0; r--)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& row = a.row(r);
 | 
			
		||||
    if (annorif == row.get_int(0) && same_number(numrif, row.get(1)))
 | 
			
		||||
@ -1745,10 +1745,8 @@ void TGame_mask::fill_partite()
 | 
			
		||||
  {
 | 
			
		||||
    scadenze().destroy();
 | 
			
		||||
  }  
 | 
			
		||||
  app().end_wait();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const
 | 
			
		||||
{ 
 | 
			
		||||
  TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
 | 
			
		||||
@ -1851,10 +1849,14 @@ bool TPrimanota_application::edit_partite(const TMask& m, int riga)
 | 
			
		||||
    
 | 
			
		||||
  TMovimentoPN* pn = (TMovimentoPN*)get_relation();
 | 
			
		||||
  curr_mask().autosave(*pn);   // Aggiorna i dati della testata sulle partite
 | 
			
		||||
  long numreg = pn->curr().get_long(MOV_NUMREG);
 | 
			
		||||
  if (curr_mask().insert_mode())
 | 
			
		||||
    numreg = NUMREG_PROVVISORIO;
 | 
			
		||||
  
 | 
			
		||||
  partite().update_reg(pn->curr());
 | 
			
		||||
  
 | 
			
		||||
  // Esecuzione maschera di selezione partite
 | 
			
		||||
  TGame_mask* mask = new TGame_mask(b, pn->curr().get_long(MOV_NUMREG), riga+1); 
 | 
			
		||||
  TGame_mask* mask = new TGame_mask(b, numreg, riga+1); 
 | 
			
		||||
  mask->run();        
 | 
			
		||||
  const bool changed = mask->changed();
 | 
			
		||||
  delete mask;
 | 
			
		||||
 | 
			
		||||
@ -1273,7 +1273,6 @@ bool TPartita::elimina_pagamento(int nriga, int nrata, int nrigp)
 | 
			
		||||
TImporto TPartita::importo_speso(long nreg, int numrig, bool valuta, int mode) const
 | 
			
		||||
{           
 | 
			
		||||
  TImporto imp;
 | 
			
		||||
  
 | 
			
		||||
  for (int r = last(); r > 0; r = pred(r))
 | 
			
		||||
  {
 | 
			
		||||
    const TRiga_partite& row = riga(r);
 | 
			
		||||
@ -1983,7 +1982,7 @@ bool TPartite_array::utilizzata(long numreg, int numrig)
 | 
			
		||||
TImporto TPartite_array::importo_speso(long nreg, int numrig, bool valuta, int mode)
 | 
			
		||||
{
 | 
			
		||||
  TImporto imp;
 | 
			
		||||
  add_numreg(nreg);
 | 
			
		||||
//  add_numreg(nreg);   // Gia' fatto nella read del movimento nreg
 | 
			
		||||
  for (TPartita* game = first(); game; game = next())
 | 
			
		||||
    imp += game->importo_speso(nreg, numrig, valuta, mode);
 | 
			
		||||
  imp.normalize();
 | 
			
		||||
@ -1992,9 +1991,9 @@ TImporto TPartite_array::importo_speso(long nreg, int numrig, bool valuta, int m
 | 
			
		||||
 | 
			
		||||
void TPartite_array::update_reg(const TRectype& mov, long old_nreg)
 | 
			
		||||
{
 | 
			
		||||
  if (old_nreg <= 0)
 | 
			
		||||
  if (old_nreg <= 0 && old_nreg != NUMREG_PROVVISORIO)
 | 
			
		||||
    old_nreg = mov.get_long(MOV_NUMREG);
 | 
			
		||||
  add_numreg(old_nreg);
 | 
			
		||||
//  add_numreg(nreg);   // Non farlo mai piu', carica movimenti registrati contemporaneamente!
 | 
			
		||||
  
 | 
			
		||||
  const int tot = items();
 | 
			
		||||
  if (tot > 0)
 | 
			
		||||
@ -2007,7 +2006,7 @@ void TPartite_array::update_reg(const TRectype& mov, long old_nreg)
 | 
			
		||||
    while (--i >= 0)
 | 
			
		||||
      giochi[i]->update_reg(old_nreg, mov, *this);
 | 
			
		||||
      
 | 
			
		||||
    delete giochi;  
 | 
			
		||||
    delete [] giochi;  
 | 
			
		||||
  }    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -298,7 +298,7 @@ public:
 | 
			
		||||
  TPartita(const TBill& clifo, int anno, const char* num);
 | 
			
		||||
  TPartita(const TRectype& part);
 | 
			
		||||
  virtual ~TPartita();
 | 
			
		||||
};           
 | 
			
		||||
};    
 | 
			
		||||
 | 
			
		||||
class TPartite_array : private TAssoc_array
 | 
			
		||||
{ 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user