Patch level : 12.0 966
Files correlati : f90.exe d181.des f181.dir f181.trr all-masks Commento : - Aggiunto controllo per estrazione di acquisto nel caso in cui non trovo la fattura elettronica, guardo se ho un doc cartaceo. (Possibilita' per i forfettari). - Corretta diagnostica per acquisti controllava male se in errore.
This commit is contained in:
		
							parent
							
								
									bd8c6c9300
								
							
						
					
					
						commit
						d14564d7e1
					
				@ -201,6 +201,7 @@ int TEstrai_mask::estrai()
 | 
				
			|||||||
  delete progr;
 | 
					  delete progr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  _stats = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 | 
					  _stats = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 | 
				
			||||||
 | 
					  // Effettiva estrazione. Faccio partire diagnostica e scrittura db.
 | 
				
			||||||
  const result_estr result = _estrazione->estrai();
 | 
					  const result_estr result = _estrazione->estrai();
 | 
				
			||||||
#ifdef DBG
 | 
					#ifdef DBG
 | 
				
			||||||
  TString msg;
 | 
					  TString msg;
 | 
				
			||||||
@ -420,7 +421,7 @@ void TMonitor_mask::delete_pack(const bool all) const
 | 
				
			|||||||
        "  SELECT @stato = " DRD_STATO "\n"
 | 
					        "  SELECT @stato = " DRD_STATO "\n"
 | 
				
			||||||
        "  FROM " F9_DRD "\n"
 | 
					        "  FROM " F9_DRD "\n"
 | 
				
			||||||
        "  WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
 | 
					        "  WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
 | 
				
			||||||
        "  IF(@stato = '" D_GEST_ERR "') BEGIN\n"
 | 
					        "  IF(@stato = '" D_GEST_ERR "' OR @stato = '" IN_DIAGN "') BEGIN\n"
 | 
				
			||||||
        "    DELETE FROM " F9_ERR " WHERE " ERR_CODSOC " = '" << codsoc << "' AND " ERR_IDESTR " = '" << id_estr << "';\n"
 | 
					        "    DELETE FROM " F9_ERR " WHERE " ERR_CODSOC " = '" << codsoc << "' AND " ERR_IDESTR " = '" << id_estr << "';\n"
 | 
				
			||||||
        "  END\n"
 | 
					        "  END\n"
 | 
				
			||||||
        "  ELSE BEGIN\n"
 | 
					        "  ELSE BEGIN\n"
 | 
				
			||||||
@ -434,7 +435,7 @@ void TMonitor_mask::delete_pack(const bool all) const
 | 
				
			|||||||
        " SELECT @flag_prov = " DRD_FLAG_PD ", @stato = " DRD_STATO "\n"
 | 
					        " SELECT @flag_prov = " DRD_FLAG_PD ", @stato = " DRD_STATO "\n"
 | 
				
			||||||
        " FROM " F9_DRD "\n"
 | 
					        " FROM " F9_DRD "\n"
 | 
				
			||||||
        " WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
 | 
					        " WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
 | 
				
			||||||
        " IF (@flag_prov = 'P' OR @stato = '" D_GEST_ERR "') BEGIN\n"
 | 
					        " IF (@flag_prov = 'P' OR @stato = '" D_GEST_ERR "' OR @stato = '" IN_DIAGN "') BEGIN\n"
 | 
				
			||||||
        "   DELETE FROM " F9_DRD      " WHERE " DRD_CODSOC " = '" << codsoc << "' AND " DRD_ID_EST " = '" << id_estr << "';\n"
 | 
					        "   DELETE FROM " F9_DRD      " WHERE " DRD_CODSOC " = '" << codsoc << "' AND " DRD_ID_EST " = '" << id_estr << "';\n"
 | 
				
			||||||
        "   DELETE FROM " F9_IVA      " WHERE " IVA_CODSOC " = '" << codsoc << "' AND " IVA_IDLAN  " = '" << id_estr << "';\n"
 | 
					        "   DELETE FROM " F9_IVA      " WHERE " IVA_CODSOC " = '" << codsoc << "' AND " IVA_IDLAN  " = '" << id_estr << "';\n"
 | 
				
			||||||
        "   DELETE FROM " F9_MOVESTR  " WHERE " MES_CODSOC " = '" << codsoc << "' AND " MES_IDESTR " = '" << id_estr << "';\n"
 | 
					        "   DELETE FROM " F9_MOVESTR  " WHERE " MES_CODSOC " = '" << codsoc << "' AND " MES_IDESTR " = '" << id_estr << "';\n"
 | 
				
			||||||
@ -464,7 +465,7 @@ void TMonitor_mask::delete_pack(const bool all) const
 | 
				
			|||||||
void TMonitor_mask::fill() const
 | 
					void TMonitor_mask::fill() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TString query;
 | 
					  TString query;
 | 
				
			||||||
  query << "SELECT * FROM F9DRD00K ORDER BY " << DRD_TIME << " DESC;";
 | 
					  query << "SELECT * FROM F9DRD00K WHERE " DRD_CODSOC " = '" << F9CONF.get_ambiente() << "' ORDER BY " << DRD_TIME << " DESC;";
 | 
				
			||||||
  fp_db().sq_set_exec(query, false);
 | 
					  fp_db().sq_set_exec(query, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  TSheet_field& sf = sfield(S_ELAB);
 | 
					  TSheet_field& sf = sfield(S_ELAB);
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,6 @@
 | 
				
			|||||||
#include <set>
 | 
					#include <set>
 | 
				
			||||||
#include <map>
 | 
					#include <map>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "annessif9.h"
 | 
					#include "annessif9.h"
 | 
				
			||||||
#include "applicat.h"
 | 
					#include "applicat.h"
 | 
				
			||||||
#include "automask.h"
 | 
					#include "automask.h"
 | 
				
			||||||
 | 
				
			|||||||
@ -99,6 +99,14 @@ bool TEstrazione::check_annessi_oblig(const TString& catdoc, const TString& numr
 | 
				
			|||||||
  return ok_ann;
 | 
					  return ok_ann;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TEstrazione::check_cartaceo_acq(const movimento_t& movimento)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TF9_doccart filecart;
 | 
				
			||||||
 | 
					  TFilename   file;
 | 
				
			||||||
 | 
					  TString     reg; reg << movimento.numreg;
 | 
				
			||||||
 | 
					  return filecart.mov2doc(reg, file) && file.exist();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool TEstrazione::check_documento_vendita(const TLocalisamfile& mov, _Out_ bool& exist_doc)
 | 
					bool TEstrazione::check_documento_vendita(const TLocalisamfile& mov, _Out_ bool& exist_doc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (!mov.get(MOV_DPROVV).empty() && !mov.get(MOV_DANNO).empty() && !mov.get(MOV_DCODNUM).empty() && !mov.get(MOV_DNDOC).empty())
 | 
					  if (!mov.get(MOV_DPROVV).empty() && !mov.get(MOV_DANNO).empty() && !mov.get(MOV_DCODNUM).empty() && !mov.get(MOV_DNDOC).empty())
 | 
				
			||||||
@ -184,7 +192,7 @@ void TEstrazione::copy_file_to_webapp_fld(const movimento_t& movimento) const
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#ifdef DBG
 | 
					#ifdef DBG
 | 
				
			||||||
  CHECK(files.items() == categorie.items(), "Numero di file diverso dal numero di categorie");
 | 
					  CHECK(files.items() == categorie.items(), "copy_file_to_webapp_fld: Numero di file diverso dal numero di categorie");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for(int i = 0; i < files.items(); ++i)
 | 
					  for(int i = 0; i < files.items(); ++i)
 | 
				
			||||||
@ -448,10 +456,7 @@ const char* TEstrazione::diagnostica_mov()
 | 
				
			|||||||
        const int         numreg = mov_i.numreg;
 | 
					        const int         numreg = mov_i.numreg;
 | 
				
			||||||
        TLocalisamfile    mov(LF_MOV);
 | 
					        TLocalisamfile    mov(LF_MOV);
 | 
				
			||||||
        mov.put(MOV_NUMREG, numreg);
 | 
					        mov.put(MOV_NUMREG, numreg);
 | 
				
			||||||
#ifdef DBG
 | 
					
 | 
				
			||||||
        if (mov.read() != NOERR)
 | 
					 | 
				
			||||||
          warning_box("OOOOOOOOOHH! E DICE SIII!!");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        mov_i.cartaceo = !is_doc_xml(mov);
 | 
					        mov_i.cartaceo = !is_doc_xml(mov);
 | 
				
			||||||
        const state_fppro res = check_fppro(numreg);
 | 
					        const state_fppro res = check_fppro(numreg);
 | 
				
			||||||
        switch (res)
 | 
					        switch (res)
 | 
				
			||||||
@ -462,7 +467,6 @@ const char* TEstrazione::diagnostica_mov()
 | 
				
			|||||||
        case correct:
 | 
					        case correct:
 | 
				
			||||||
          ok &= true;
 | 
					          ok &= true;
 | 
				
			||||||
          mov_i.err   = false;
 | 
					          mov_i.err   = false;
 | 
				
			||||||
          mov_i.state = res;
 | 
					 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // ERRORS
 | 
					          // ERRORS
 | 
				
			||||||
@ -472,7 +476,6 @@ const char* TEstrazione::diagnostica_mov()
 | 
				
			|||||||
          mov_i.err         = false;
 | 
					          mov_i.err         = false;
 | 
				
			||||||
          mov_i.estratto    = false;
 | 
					          mov_i.estratto    = false;
 | 
				
			||||||
          mov_i.descr_estr  = movimento_t::no_fa;
 | 
					          mov_i.descr_estr  = movimento_t::no_fa;
 | 
				
			||||||
          mov_i.state       = res;
 | 
					 | 
				
			||||||
          ++_stats.fa_skip;
 | 
					          ++_stats.fa_skip;
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -482,45 +485,60 @@ const char* TEstrazione::diagnostica_mov()
 | 
				
			|||||||
          mov_i.err       = true;
 | 
					          mov_i.err       = true;
 | 
				
			||||||
          mov_i.estratto  = false;
 | 
					          mov_i.estratto  = false;
 | 
				
			||||||
          mov_i.descr_err = "Errore controllo movimento: associazione movimento con fattura elettronica passiva sbagliato.";
 | 
					          mov_i.descr_err = "Errore controllo movimento: associazione movimento con fattura elettronica passiva sbagliato.";
 | 
				
			||||||
          mov_i.state     = res;
 | 
					 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case err_read_db:
 | 
					        case err_read_db:
 | 
				
			||||||
          ok &= false;
 | 
					          ok &= false;
 | 
				
			||||||
          mov_i.err       = true;
 | 
					          mov_i.err       = true;
 | 
				
			||||||
          mov_i.estratto  = false;
 | 
					          mov_i.estratto  = false;
 | 
				
			||||||
          mov_i.descr_err = "Errore controllo movimento: errore lettura db.";
 | 
					          mov_i.descr_err = "Errore controllo movimento: errore lettura db.";
 | 
				
			||||||
          mov_i.state     = res;
 | 
					 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case no_guessed:
 | 
					        case no_guessed:
 | 
				
			||||||
          ok &= false;
 | 
					          // Controllo se esiste il cartaceo es. forfettari
 | 
				
			||||||
          mov_i.err       = true;
 | 
					          if(check_cartaceo_acq(mov_i))
 | 
				
			||||||
          mov_i.estratto  = false;
 | 
					          {
 | 
				
			||||||
          mov_i.descr_err = "Non associato a fattura elettr. abbinamento automatico non riuscito. Abbinare manualmente, o escludere";
 | 
					            ok &= true;
 | 
				
			||||||
          mov_i.state     = res;
 | 
					            mov_i.err       = false;
 | 
				
			||||||
 | 
					            mov_i.cartaceo  = true;
 | 
				
			||||||
 | 
					            mov_i.estratto  = true;
 | 
				
			||||||
 | 
					            mov_i.descr_err = "";
 | 
				
			||||||
 | 
					            mov_i.state     = correct;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            ok &= false;
 | 
				
			||||||
 | 
					            mov_i.err = true;
 | 
				
			||||||
 | 
					            mov_i.estratto = false;
 | 
				
			||||||
 | 
					            mov_i.descr_err = "Non associato a fattura elettr. abbinamento automatico non riuscito. Abbinare manualmente, o escludere";
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
        default: break;
 | 
					        default: break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (mov_i.err)
 | 
					        if(mov_i.state == null_state)
 | 
				
			||||||
          ++_stats.fa_err;
 | 
					          mov_i.state = res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (mov_i.err) ++_stats.fa_err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Per quelli che hanno passato il primo controllo errori controllo che debba essere estratto
 | 
					        /* Per quelli che hanno passato il primo controllo errori controllo che debba essere estratto
 | 
				
			||||||
         * secondo le categorie documentali. */
 | 
					         * secondo le categorie documentali. */
 | 
				
			||||||
        if (!mov_i.err && mov_i.estratto)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          std::shared_ptr<TCategorie_doc::classe_doc> cd = categorie_doc().mov2cat(mov_i.numreg);
 | 
					 | 
				
			||||||
          mov_i.estratto    = cd.get();
 | 
					 | 
				
			||||||
          mov_i.descr_estr  = cd ? movimento_t::no_err : movimento_t::no_catdoc;
 | 
					 | 
				
			||||||
          mov_i.catdoc      = cd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          if (mov_i.catdoc)
 | 
					 | 
				
			||||||
            check_annessi(mov_i, numreg);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (mov_i.estratto)
 | 
					        if (mov_i.estratto)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					          if (!mov_i.err)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            // Cerco la categoria documentale
 | 
				
			||||||
 | 
					            std::shared_ptr<TCategorie_doc::classe_doc> cd = categorie_doc().mov2cat(mov_i.numreg);
 | 
				
			||||||
 | 
					            mov_i.estratto    = cd.get();
 | 
				
			||||||
 | 
					            mov_i.descr_estr  = cd ? movimento_t::no_err : movimento_t::no_catdoc;
 | 
				
			||||||
 | 
					            mov_i.catdoc      = cd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (mov_i.catdoc)
 | 
				
			||||||
 | 
					              check_annessi(mov_i, numreg);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          // Se cartaceo preparo il file.
 | 
				
			||||||
          if (mov_i.cartaceo)
 | 
					          if (mov_i.cartaceo)
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            TF9_doccart filecart;
 | 
					            TF9_doccart filecart;
 | 
				
			||||||
            TFilename   file;
 | 
					            TFilename   file;
 | 
				
			||||||
            TString reg; reg << it->numreg;
 | 
					            TString     reg; reg << it->numreg;
 | 
				
			||||||
            if (filecart.mov2doc(reg, file) && file.exist())
 | 
					            if (filecart.mov2doc(reg, file) && file.exist())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              mov_i.nomefilecart << file;
 | 
					              mov_i.nomefilecart << file;
 | 
				
			||||||
@ -536,7 +554,7 @@ const char* TEstrazione::diagnostica_mov()
 | 
				
			|||||||
          copy_file_to_webapp_fld(mov_i);
 | 
					          copy_file_to_webapp_fld(mov_i);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      ok &= mov_i.err;
 | 
					      ok &= !mov_i.err;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (tipo == iva_vendite)
 | 
					  else if (tipo == iva_vendite)
 | 
				
			||||||
@ -709,7 +727,7 @@ result_estr TEstrazione::estrai()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (_head.stato_estr == D_GEST_ERR)
 | 
					  if (_head.stato_estr == D_GEST_ERR)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    warning_box("Attenzione l'estrazione ha prodotto degli errori.\n" \
 | 
					    warning_box("Attenzione l'estrazione ha prodotto degli errori.\n"
 | 
				
			||||||
      "Controllare e correggere eventuali problemi\ndal Controllo Estrazione.");
 | 
					      "Controllare e correggere eventuali problemi\ndal Controllo Estrazione.");
 | 
				
			||||||
    // Se in errore, esporto lista errori sul db
 | 
					    // Se in errore, esporto lista errori sul db
 | 
				
			||||||
    if (!export_error_list())
 | 
					    if (!export_error_list())
 | 
				
			||||||
@ -863,7 +881,7 @@ bool TEstrazione::estrazione_iva(bool escluso)
 | 
				
			|||||||
    iva_query.add(IVA_USERELA, user());
 | 
					    iva_query.add(IVA_USERELA, user());
 | 
				
			||||||
    iva_query.add_getdate(IVA_TIMEELA);
 | 
					    iva_query.add_getdate(IVA_TIMEELA);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (_head.tipo_doc == 'A')
 | 
					    if (_head.tipo_doc == 'A' && !it->cartaceo)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      TToken_string keys(mov.get(MOV_KEYFPPRO), ';');
 | 
					      TToken_string keys(mov.get(MOV_KEYFPPRO), ';');
 | 
				
			||||||
      fppro_db().set_keys(keys);
 | 
					      fppro_db().set_keys(keys);
 | 
				
			||||||
 | 
				
			|||||||
@ -343,8 +343,9 @@ class TEstrazione : public TObject
 | 
				
			|||||||
  bool update_drd_stato_estr() const;
 | 
					  bool update_drd_stato_estr() const;
 | 
				
			||||||
  static const char*  categoria_doc();
 | 
					  static const char*  categoria_doc();
 | 
				
			||||||
  static const char*  caus_sos(const TLocalisamfile& mov, TipoIVA iva);
 | 
					  static const char*  caus_sos(const TLocalisamfile& mov, TipoIVA iva);
 | 
				
			||||||
  static void         check_annessi(movimento_t& mov_i, const TString& numreg);
 | 
					  static void         check_annessi(movimento_t& mov_i, const TString& numreg); // Controllo se ci sono tutti gli annessi obbligatori.
 | 
				
			||||||
  static bool         check_annessi_oblig(const TString& catdoc, const TString& numreg, TToken_string& ann_nexist);
 | 
					  static bool         check_annessi_oblig(const TString& catdoc, const TString& numreg, TToken_string& ann_nexist);
 | 
				
			||||||
 | 
					  static bool         check_cartaceo_acq(const movimento_t& movimento);
 | 
				
			||||||
  static bool         check_documento_vendita(const TLocalisamfile& mov, _Out_ bool& exist_doc);
 | 
					  static bool         check_documento_vendita(const TLocalisamfile& mov, _Out_ bool& exist_doc);
 | 
				
			||||||
  /** CHECK RIFERIMENTO FPPRO
 | 
					  /** CHECK RIFERIMENTO FPPRO
 | 
				
			||||||
   * Per le fatture di acquisto controllo se ho il riferimento nell'FPPRO.
 | 
					   * Per le fatture di acquisto controllo se ho il riferimento nell'FPPRO.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user