Corretta gestione esercizi contabili
git-svn-id: svn://10.65.10.50/trunk@2170 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									0e625361e3
								
							
						
					
					
						commit
						30314e7e70
					
				@ -1,7 +1,5 @@
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <mailbox.h>
 | 
			
		||||
#include <tabutil.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
#include <urldefid.h>
 | 
			
		||||
#include <execp.h>
 | 
			
		||||
 | 
			
		||||
@ -402,9 +400,12 @@ TMask* TPrimanota_application::get_mask(int mode)
 | 
			
		||||
 | 
			
		||||
void TPrimanota_application::on_firm_change()
 | 
			
		||||
{
 | 
			
		||||
  TRelation_application::on_firm_change();
 | 
			
		||||
  TRelation_application::on_firm_change();        // May be useful, who knows?
 | 
			
		||||
  
 | 
			
		||||
  _rel->lfile().last();
 | 
			
		||||
  _lastreg = _rel->lfile().get_long(MOV_NUMREG);  // Init last registration number
 | 
			
		||||
  
 | 
			
		||||
  _esercizi.update();                             // Init exercises
 | 
			
		||||
}  
 | 
			
		||||
 | 
			
		||||
void TPrimanota_application::on_config_change()
 | 
			
		||||
@ -505,30 +506,30 @@ void TPrimanota_application::fill_sheet(TMask& m) const
 | 
			
		||||
// Certified 100%
 | 
			
		||||
const char* TPrimanota_application::get_next_key()
 | 
			
		||||
{ 
 | 
			
		||||
  TToken_string k(80);
 | 
			
		||||
  k.add(F_NUMREG); k.add(_lastreg+1);
 | 
			
		||||
  _tmp.cut(0);
 | 
			
		||||
  _tmp.add(F_NUMREG); _tmp.add(_lastreg+1);
 | 
			
		||||
  
 | 
			
		||||
  if (_rel->good())                                 // Not reinsert
 | 
			
		||||
  {
 | 
			
		||||
    TMask& m = curr_mask();
 | 
			
		||||
    if (m.insert_mode())
 | 
			
		||||
    {
 | 
			
		||||
      k.add(F_CODCAUS);  k.add(m.get(F_CODCAUS));   // Ricopia causale
 | 
			
		||||
      k.add(F_DATAREG);  k.add(m.get(F_DATAREG));   //         data operazione 
 | 
			
		||||
      k.add(F_DATACOMP); k.add(m.get(F_DATACOMP));  //              competenza
 | 
			
		||||
      _tmp.add(F_CODCAUS);  _tmp.add(m.get(F_CODCAUS));   // Ricopia causale
 | 
			
		||||
      _tmp.add(F_DATAREG);  _tmp.add(m.get(F_DATAREG));   //         data operazione 
 | 
			
		||||
      _tmp.add(F_DATACOMP); _tmp.add(m.get(F_DATACOMP));  //              competenza
 | 
			
		||||
      
 | 
			
		||||
      if (iva() == iva_vendite)
 | 
			
		||||
      {
 | 
			
		||||
        k.add(F_DATADOC);  k.add(m.get(F_DATADOC)); // Ricopia data documento
 | 
			
		||||
        _tmp.add(F_DATADOC); _tmp.add(m.get(F_DATADOC));  // Ricopia data documento
 | 
			
		||||
 | 
			
		||||
        const long n = m.get_long(F_NUMDOC);
 | 
			
		||||
        if (n > 0)
 | 
			
		||||
        { k.add(F_NUMDOC); k.add(n+1); }            // incrementa numero documento
 | 
			
		||||
        { _tmp.add(F_NUMDOC); _tmp.add(n+1); }            // incrementa numero documento
 | 
			
		||||
      }  
 | 
			
		||||
    }  
 | 
			
		||||
  }  
 | 
			
		||||
 | 
			
		||||
  return strcpy(__tmp_string, k);
 | 
			
		||||
  return _tmp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -863,22 +864,27 @@ int TPrimanota_application::write(const TMask& m)
 | 
			
		||||
    {
 | 
			
		||||
      causale().reg().reread();                         // Aggiorna protocollo IVA
 | 
			
		||||
      if (is_saldaconto())
 | 
			
		||||
      {
 | 
			
		||||
        if (m.page_enabled(2))
 | 
			
		||||
          write_scadenze(m);
 | 
			
		||||
      }  
 | 
			
		||||
      else 
 | 
			
		||||
      {
 | 
			
		||||
        if (!m.get_bool(F_SOLAIVA) && !is_saldaconto())                     
 | 
			
		||||
      {   
 | 
			
		||||
        switch (causale().tipomov()) 
 | 
			
		||||
        {
 | 
			
		||||
          const TString16 causimm(causale().causale_inc_imm());
 | 
			
		||||
          if (causimm.not_empty())
 | 
			
		||||
            genera_incasso(causimm);                    // Genera incasso immediato
 | 
			
		||||
        case 1:
 | 
			
		||||
          write_scadenze(m); break;                     // Salva fattura
 | 
			
		||||
        case 2:  
 | 
			
		||||
          salvaconto = TRUE; break;                     // Salva nota credito
 | 
			
		||||
        default:
 | 
			
		||||
          break;
 | 
			
		||||
        }    
 | 
			
		||||
      }  
 | 
			
		||||
      else 
 | 
			
		||||
      {  
 | 
			
		||||
        // Genera incasso immediato se e' una fattura e non c'e' gestione saldaconto
 | 
			
		||||
        if (!m.get_bool(F_SOLAIVA) && !gestione_saldaconto())                     
 | 
			
		||||
        {
 | 
			
		||||
          const TString causimm(causale().causale_inc_imm());
 | 
			
		||||
          if (causimm.not_empty())
 | 
			
		||||
            genera_incasso(causimm);                    
 | 
			
		||||
        }    
 | 
			
		||||
      }  
 | 
			
		||||
      
 | 
			
		||||
      if (causale().tipomov() == 2)
 | 
			
		||||
        salvaconto = TRUE;
 | 
			
		||||
    }    
 | 
			
		||||
    else 
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -12,6 +12,7 @@
 | 
			
		||||
#include <rmoviva.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
// Calcola l'anno di esercizio di una data, e se prevesc != NULL calcola anche l'anno precedente                                
 | 
			
		||||
// Certified 99%
 | 
			
		||||
int date2esc(const TDate& d, int* prevesc)
 | 
			
		||||
@ -44,7 +45,8 @@ int date2esc(const TDate& d, int* prevesc)
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return anno;
 | 
			
		||||
}
 | 
			
		||||
} 
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// Movimento di prima nota
 | 
			
		||||
 | 
			
		||||
@ -5,8 +5,6 @@
 | 
			
		||||
#include <relation.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int date2esc(const TDate& d, int* prevesc = NULL);
 | 
			
		||||
 | 
			
		||||
class TMovimentoPN : public TRelation
 | 
			
		||||
{
 | 
			
		||||
  // class TMovimentoPN : public TRelation
 | 
			
		||||
 | 
			
		||||
@ -1418,12 +1418,12 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
 | 
			
		||||
  
 | 
			
		||||
  if ((key == K_TAB && m.is_running()) || key == K_ENTER)
 | 
			
		||||
  {   
 | 
			
		||||
    const TDate dr(f.get());                   // Data dell'operazione
 | 
			
		||||
    const TDate dr(f.get());                         // Data dell'operazione
 | 
			
		||||
    if (dr > TDate(TODAY))
 | 
			
		||||
      return f.error_box("La data dell'operazione e' superiore quella di sistema");
 | 
			
		||||
    
 | 
			
		||||
    const int ae = date2esc(dr);               // Anno esercizio
 | 
			
		||||
    if (ae == 0) 
 | 
			
		||||
    const int ae = app()._esercizi.date2esc(dr);     // Anno esercizio
 | 
			
		||||
    if (ae <= 0) 
 | 
			
		||||
      return f.error_box("La data dell'operazione non appartiene a nessun esercizio");
 | 
			
		||||
    
 | 
			
		||||
    if (m.query_mode() || app().giornale().year() != ae)
 | 
			
		||||
@ -1488,8 +1488,8 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
 | 
			
		||||
        
 | 
			
		||||
        if (reg.iva() != nessuna_iva && app()._rel->controlla_liquidazione(dr) == TRUE)
 | 
			
		||||
        {
 | 
			
		||||
          const char* m = itom(dr.month());
 | 
			
		||||
          f.warning_box("La liquidazione IVA relativa al mese di %s e' gia' stata calcolata", m);
 | 
			
		||||
          const char* const mese = itom(dr.month());
 | 
			
		||||
          f.warning_box("La liquidazione IVA relativa al mese di %s e' gia' stata calcolata", mese);
 | 
			
		||||
        }
 | 
			
		||||
      }  
 | 
			
		||||
    }  
 | 
			
		||||
@ -1513,9 +1513,9 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
 | 
			
		||||
      datacomp = dr.string();
 | 
			
		||||
      f.set(datacomp);
 | 
			
		||||
    }
 | 
			
		||||
    const TDate dc(datacomp);              // Data di competenza
 | 
			
		||||
    TEsercizi_contabili esc;
 | 
			
		||||
    const int ae = esc.date2esc(dc);       // Esercizio corrispondente
 | 
			
		||||
    const TDate dc(datacomp);                          // Data di competenza
 | 
			
		||||
    TEsercizi_contabili& esc = app()._esercizi;
 | 
			
		||||
    const int ae = esc.date2esc(dc);                   // Esercizio corrispondente
 | 
			
		||||
    
 | 
			
		||||
    const char* data = "del 74/ter";
 | 
			
		||||
    if (f.dlg() == F_DATACOMP)
 | 
			
		||||
@ -1569,12 +1569,12 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
 | 
			
		||||
{
 | 
			
		||||
  TMask& m = f.mask();
 | 
			
		||||
 | 
			
		||||
  if (key == K_TAB && m.is_running())
 | 
			
		||||
  if (key == K_TAB && m.insert_mode() && app().is_saldaconto())
 | 
			
		||||
  {
 | 
			
		||||
    const TString16 val(f.get());
 | 
			
		||||
 | 
			
		||||
    if (val.not_empty() && m.insert_mode() && m.field(F_ANNORIF).active())                      
 | 
			
		||||
    {                                                    // Se c'e' gestione saldaconto
 | 
			
		||||
    if (val.not_empty())                      
 | 
			
		||||
    {                                                  
 | 
			
		||||
      if (f.dlg() == F_DATADOC)
 | 
			
		||||
      {
 | 
			
		||||
        const TDate dd(val);
 | 
			
		||||
 | 
			
		||||
@ -60,8 +60,11 @@ class TPrimanota_application : public TRelation_application
 | 
			
		||||
  TDate _last_dcom;           // Ultima data competenza inserita
 | 
			
		||||
  
 | 
			
		||||
  TBill _conto_ricavo;        // Conto di ricavo del clifo
 | 
			
		||||
 | 
			
		||||
  TString_array _pag_rows;
 | 
			
		||||
  
 | 
			
		||||
  TToken_string _tmp;         // Stringa temporanea da ritornare
 | 
			
		||||
  TString_array _pag_rows;    // Copia dello sheet delle rate
 | 
			
		||||
  
 | 
			
		||||
  TEsercizi_contabili _esercizi; // Tabella degli esercizi contabili
 | 
			
		||||
  
 | 
			
		||||
  static bool showpartite_handler(TMask_field& f, KEY k);
 | 
			
		||||
  static bool speserimb_handler(TMask_field& f, KEY k);
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
#include <applicat.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include <prefix.h>
 | 
			
		||||
#include <tabutil.h>
 | 
			
		||||
 | 
			
		||||
#include "cg2103.h"
 | 
			
		||||
@ -138,7 +140,7 @@ bool TRegistro::read_att()
 | 
			
		||||
 | 
			
		||||
  TLocalisamfile attiv(LF_ATTIV);
 | 
			
		||||
  attiv.setkey(1);
 | 
			
		||||
  attiv.put("CODDITTA", main_app().get_firm());
 | 
			
		||||
  attiv.put("CODDITTA", prefix().get_codditta());
 | 
			
		||||
  attiv.put("CODATT", attivita());
 | 
			
		||||
  const int err = attiv.read();
 | 
			
		||||
  _att = attiv.curr();
 | 
			
		||||
@ -146,7 +148,7 @@ bool TRegistro::read_att()
 | 
			
		||||
    _att.zero();
 | 
			
		||||
    
 | 
			
		||||
  TString16 chiave;             // Ditta - Anno - Attivita' - Tipo Attivita' (fissata a 1)
 | 
			
		||||
  chiave.format("%05ld", main_app().get_firm());
 | 
			
		||||
  chiave.format("%05ld", prefix().get_codditta());
 | 
			
		||||
  chiave << year();             // non fare << year() << attivita()
 | 
			
		||||
  chiave << attivita() << "1";
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
@ -3,8 +3,6 @@
 | 
			
		||||
// fv 24/8/94
 | 
			
		||||
// --------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
#include <sheet.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
#include "pagament.h"
 | 
			
		||||
#include "saldacon.h"
 | 
			
		||||
 | 
			
		||||
@ -579,7 +577,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
 | 
			
		||||
    partita.put(PART_SPESE,   pag.spese());
 | 
			
		||||
  
 | 
			
		||||
    TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
 | 
			
		||||
    partita.elimina_rate();
 | 
			
		||||
    partita.elimina_rata(-1);
 | 
			
		||||
    for (int i = 0; i < pag.n_rate(); i++)
 | 
			
		||||
    {    
 | 
			
		||||
      TToken_string& row = ps.row(i);
 | 
			
		||||
@ -638,7 +636,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
 | 
			
		||||
    }  
 | 
			
		||||
  } 
 | 
			
		||||
  
 | 
			
		||||
  if (newgame != NULL)          // Se ho cancellato il numero partita ...
 | 
			
		||||
  if (newgame != NULL)           // Se non ho cancellato il numero partita ...
 | 
			
		||||
    newgame->write();            // Salva nuova partita
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,13 @@
 | 
			
		||||
// cglib01.cpp
 | 
			
		||||
// calcolo dei saldi
 | 
			
		||||
 | 
			
		||||
#include <applicat.h>
 | 
			
		||||
// La compilazione e' gia' lenta da sola: evitare include inutili (Guy)
 | 
			
		||||
// #include <applicat.h>
 | 
			
		||||
// #include <utility.h>
 | 
			
		||||
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <isam.h>
 | 
			
		||||
#include <tabutil.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
#include "cglib.h"
 | 
			
		||||
 | 
			
		||||
#include <rmov.h>
 | 
			
		||||
#include <mov.h>
 | 
			
		||||
@ -14,7 +16,6 @@
 | 
			
		||||
#include <causali.h> 
 | 
			
		||||
#include <clifo.h> 
 | 
			
		||||
 | 
			
		||||
#include "cglib.h"
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// Causale
 | 
			
		||||
@ -56,23 +57,12 @@ bool TCaus::apertura() const
 | 
			
		||||
//  
 | 
			
		||||
// Cerca l'esercizio precedente di EseCorr
 | 
			
		||||
// Se EseCorr e' gia' il primo ritorna 0
 | 
			
		||||
// senno' ritorna, astutamente, EseCorr - 1
 | 
			
		||||
// senno' ritorna il precedente (Stavolta meno astutamente, ma correttamente)
 | 
			
		||||
//
 | 
			
		||||
const int EsePre(const int EseCorr)
 | 
			
		||||
{
 | 
			
		||||
  TTable ese("ESC");
 | 
			
		||||
  TString   first(30);
 | 
			
		||||
  TString16 codtab;
 | 
			
		||||
 | 
			
		||||
  ese.first();  
 | 
			
		||||
  first = ese.get("CODTAB");
 | 
			
		||||
  
 | 
			
		||||
  codtab.format("%04d", EseCorr);
 | 
			
		||||
  
 | 
			
		||||
  if (codtab == first)  
 | 
			
		||||
    return 0;
 | 
			
		||||
  
 | 
			
		||||
  return EseCorr - 1;
 | 
			
		||||
  TEsercizi_contabili esc;
 | 
			
		||||
  return esc.pred(EseCorr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// aep e' l'esercizio precedente
 | 
			
		||||
@ -361,7 +351,7 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
 | 
			
		||||
    // "I mov. di puro riferimento (= con importo = 0) vanno scartati"
 | 
			
		||||
    if (importo == ZERO) continue;
 | 
			
		||||
    
 | 
			
		||||
    gcs_corr = format ("%3d%3d%6ld", gruppo, conto, sottoconto);  
 | 
			
		||||
    gcs_corr.format ("%3d%3d%6ld", gruppo, conto, sottoconto);  
 | 
			
		||||
    
 | 
			
		||||
    if (gcs_corr != gcs_prec)  
 | 
			
		||||
    {
 | 
			
		||||
@ -560,10 +550,10 @@ bool TSaldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil
 | 
			
		||||
 | 
			
		||||
TRectype& TSaldo::ricerca_progr_prec (int annoesprec, int g, int c, long s)
 | 
			
		||||
{
 | 
			
		||||
  TLocalisamfile saldi(LF_SALDI, FALSE);
 | 
			
		||||
  TLocalisamfile saldi(LF_SALDI);
 | 
			
		||||
 | 
			
		||||
// Tre righe inutili che vengono gia' eseguite da TLocalisamfile (Guy)
 | 
			
		||||
  const int oldkey = saldi.getkey();       
 | 
			
		||||
 | 
			
		||||
  saldi.setkey(1);  
 | 
			
		||||
  saldi.zero();
 | 
			
		||||
 | 
			
		||||
@ -580,15 +570,15 @@ TRectype& TSaldo::ricerca_progr_prec (int annoesprec, int g, int c, long s)
 | 
			
		||||
    _rec_presente_ep = FALSE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  (*_saldo_ep) = saldi.curr();
 | 
			
		||||
  saldi.setkey(oldkey);
 | 
			
		||||
  *_saldo_ep = saldi.curr();
 | 
			
		||||
 | 
			
		||||
  // riposiziona...
 | 
			
		||||
  // riposiziona...   7 righe inutili (Guy)
 | 
			
		||||
  saldi.setkey(oldkey);
 | 
			
		||||
  saldi.zero();
 | 
			
		||||
  saldi.put(SLD_GRUPPO,g);
 | 
			
		||||
  saldi.put(SLD_CONTO,c);
 | 
			
		||||
  saldi.put(SLD_SOTTOCONTO,s);
 | 
			
		||||
  saldi.put(SLD_ANNOES,annoesprec+1);
 | 
			
		||||
  saldi.put(SLD_ANNOES,annoesprec+1);   // Astuto anche questo (Guy)
 | 
			
		||||
  saldi.read(_isequal);
 | 
			
		||||
 | 
			
		||||
  return (*_saldo_ep);
 | 
			
		||||
 | 
			
		||||
@ -5,10 +5,11 @@
 | 
			
		||||
//
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
// La compilazione e' gia' lenta da sola: evitare include inutili (Guy)
 | 
			
		||||
// #include <stdlib.h>
 | 
			
		||||
// #include <utility.h>
 | 
			
		||||
 | 
			
		||||
#include <applicat.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
#include <prefix.h>
 | 
			
		||||
 | 
			
		||||
#include "cglib.h"
 | 
			
		||||
 | 
			
		||||
@ -165,7 +166,7 @@ void TSaldo_agg::registra()
 | 
			
		||||
    CHECK(tcon.ok(), "Tentavi di saldare un conto incompleto, eh?");
 | 
			
		||||
    
 | 
			
		||||
    saldi.zero();
 | 
			
		||||
    saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)) );
 | 
			
		||||
    saldi.put(SLD_ANNOES, hobj->key().left(4));
 | 
			
		||||
    saldi.put(SLD_GRUPPO, tcon.gruppo());
 | 
			
		||||
    saldi.put(SLD_CONTO,  tcon.conto());
 | 
			
		||||
    saldi.put(SLD_SOTTOCONTO, tcon.sottoconto());
 | 
			
		||||
@ -175,7 +176,7 @@ void TSaldo_agg::registra()
 | 
			
		||||
    if (saldi.read(_isequal, _lock) != NOERR)
 | 
			
		||||
    {
 | 
			
		||||
      saldi.zero();
 | 
			
		||||
      saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)));
 | 
			
		||||
      saldi.put(SLD_ANNOES, hobj->key().left(4));
 | 
			
		||||
      saldi.put(SLD_GRUPPO, tcon.gruppo());
 | 
			
		||||
      saldi.put(SLD_CONTO, tcon.conto());
 | 
			
		||||
      saldi.put(SLD_SOTTOCONTO, tcon.sottoconto());
 | 
			
		||||
@ -279,8 +280,7 @@ TEsercizi_contabili::TEsercizi_contabili() : _firm(0)
 | 
			
		||||
 | 
			
		||||
void TEsercizi_contabili::update()
 | 
			
		||||
{       
 | 
			
		||||
  _firm = main_app().get_firm();
 | 
			
		||||
  
 | 
			
		||||
  _firm = prefix().get_codditta();
 | 
			
		||||
  destroy();
 | 
			
		||||
  TTable esc("ESC");
 | 
			
		||||
  for (int err = esc.first(); err == NOERR; err = esc.next())
 | 
			
		||||
@ -293,7 +293,7 @@ void TEsercizi_contabili::update()
 | 
			
		||||
 | 
			
		||||
void TEsercizi_contabili::check()
 | 
			
		||||
{
 | 
			
		||||
  if (_firm != main_app().get_firm())
 | 
			
		||||
  if (_firm != prefix().get_codditta())
 | 
			
		||||
  {
 | 
			
		||||
#ifdef DBG   
 | 
			
		||||
    if (_firm != 0)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user