Files correlati : Ricompilazione Demo : [ ] Commento : Modificata stima ricavi competenza (ca3900) in modo da tener conto dei saldi preventivi futuri. Modificata bilancio di commessa (ca3800) in modo da usare detrazioni sempre a consuntivo (prima era sceglibile solo nel caso di stima a tempo) git-svn-id: svn://10.65.10.50/trunk@20275 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			264 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			264 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						||
#include <defmask.h>
 | 
						||
 | 
						||
#include "ca3.h"
 | 
						||
#include "ca3883.h"
 | 
						||
#include "ca3883a.h"
 | 
						||
#include "calib01.h"
 | 
						||
#include "calib02.h"
 | 
						||
#include "pconana.h"
 | 
						||
 | 
						||
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
//	MASCHERA
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
class TPrint_stima_ricavi_mask : public TAnal_report_mask
 | 
						||
{
 | 
						||
protected:
 | 
						||
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
	const TString& get_report_class() const; 
 | 
						||
  bool test_compatible_report();
 | 
						||
	
 | 
						||
public:
 | 
						||
  TPrint_stima_ricavi_mask();
 | 
						||
  virtual ~TPrint_stima_ricavi_mask() {}
 | 
						||
};
 | 
						||
 | 
						||
const TString& TPrint_stima_ricavi_mask::get_report_class() const
 | 
						||
{
 | 
						||
  TString& classe = get_tmp_string();
 | 
						||
  classe = "ca3900a";
 | 
						||
  return classe;
 | 
						||
}
 | 
						||
 | 
						||
bool TPrint_stima_ricavi_mask::test_compatible_report()
 | 
						||
{
 | 
						||
	const TString& cls = get_report_class();
 | 
						||
  const TString& name = get(F_REPORT);
 | 
						||
  bool ok = name.not_empty();
 | 
						||
  if (ok)
 | 
						||
  {
 | 
						||
    TReport rep; 
 | 
						||
    ok = rep.load(name);
 | 
						||
    if (ok)
 | 
						||
    {
 | 
						||
      const TString& classe = rep.get_class();
 | 
						||
      ok = classe == cls;
 | 
						||
    }
 | 
						||
  }
 | 
						||
  if (!ok)
 | 
						||
  {
 | 
						||
    set(F_REPORT, cls);
 | 
						||
		TFilename path = cls;
 | 
						||
    path.ext("rep");
 | 
						||
    ok = path.custom_path();
 | 
						||
  }
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
bool TPrint_stima_ricavi_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
  case DLG_PRINT:
 | 
						||
    if (e == fe_button)
 | 
						||
    {
 | 
						||
      main_app().print();
 | 
						||
      return false;
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  case DLG_PREVIEW:
 | 
						||
    if (e == fe_button)
 | 
						||
    {
 | 
						||
      main_app().preview();
 | 
						||
      return false;
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  case F_REPORT:
 | 
						||
    if (e == fe_button)
 | 
						||
    {
 | 
						||
      const TString8 lib = get_report_class();
 | 
						||
      TFilename path = o.get();
 | 
						||
      if (select_custom_file(path, "rep", lib))
 | 
						||
      {
 | 
						||
        path = path.name();
 | 
						||
        path.ext("");
 | 
						||
        o.set(path);
 | 
						||
      }
 | 
						||
    } else
 | 
						||
    if (e == fe_close)
 | 
						||
    {
 | 
						||
      if (!test_compatible_report())
 | 
						||
        return error_box(TR("Impossibile trovare un report compatibile"));
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  default: 
 | 
						||
		break;
 | 
						||
  }
 | 
						||
	return TAnal_report_mask::on_field_event(o, e, jolly);
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
TPrint_stima_ricavi_mask::TPrint_stima_ricavi_mask()
 | 
						||
								        :TAnal_report_mask("ca3900")
 | 
						||
{
 | 
						||
	TConfig& cfg = ca_config();
 | 
						||
	const bool use_pdcc = cfg.get_bool("UsePdcc");
 | 
						||
 | 
						||
  const TMultilevel_code_info& pconana_info = ca_multilevel_code_info(LF_PCONANA);
 | 
						||
  const int pconana_levels = pconana_info.levels();
 | 
						||
  
 | 
						||
  int prefix = cfg.get_int("PdcPrefix");
 | 
						||
  if (prefix >= pconana_levels)
 | 
						||
    prefix = pconana_levels - 1;
 | 
						||
 | 
						||
	  // Controllo se voglio (e posso) usare il conto analitico come prefisso di quello contabile
 | 
						||
  if (use_pdcc && prefix > 0)
 | 
						||
  {
 | 
						||
    const TMultilevel_code_info& info = ca_multilevel_code_info(LF_PCONANA);
 | 
						||
    const int levels = info.levels();
 | 
						||
    if (levels >= 2 && prefix < levels && esistono_riclassificazioni())
 | 
						||
    {
 | 
						||
    	ca_create_fields(*this, 0, LF_PCONANA, 1, 13, F_PRE1, F_PREDES1, 0x0, PCONANA_CODCONTO);
 | 
						||
 | 
						||
      // Nascondi i campi che non fanno parte del prefisso
 | 
						||
	    for (int i = 0; i < levels; i++)
 | 
						||
	    {
 | 
						||
        if (i < prefix)
 | 
						||
        {
 | 
						||
          field(F_PRE1 + i).check_type(CHECK_REQUIRED);
 | 
						||
          field(F_PRE1 + i).set_group(6);
 | 
						||
          field(F_PREDES1 + i).set_group(6);
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          field(F_PRE1 + i).hide();
 | 
						||
          field(F_PREDES1 + i).hide();
 | 
						||
        }
 | 
						||
      }
 | 
						||
    }
 | 
						||
  }
 | 
						||
	
 | 
						||
	// setta gli handlers a tutti i campi generati della maschera;senza questa chiamata la on_field_event
 | 
						||
	// non puo' funzionare sui campi generati!!!
 | 
						||
	set_handlers();
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////////
 | 
						||
//	RECORDSET 
 | 
						||
///////////////////////////////////////////////////////////////
 | 
						||
class TPrint_stima_ricavi_recordset : public TPrint_saldana_recordset
 | 
						||
{
 | 
						||
 | 
						||
public:
 | 
						||
  TPrint_stima_ricavi_recordset() : TPrint_saldana_recordset(9) {}
 | 
						||
};
 | 
						||
 | 
						||
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
//	REPORT
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
class TPrint_stima_ricavi_rep : public TAnal_report
 | 
						||
{
 | 
						||
 | 
						||
protected:
 | 
						||
	virtual bool set_recordset();
 | 
						||
	virtual bool get_usr_val(const TString& name, TVariant& var) const;
 | 
						||
 | 
						||
public:
 | 
						||
	void set_filter(const TPrint_stima_ricavi_mask& msk);
 | 
						||
};
 | 
						||
 | 
						||
bool TPrint_stima_ricavi_rep::get_usr_val(const TString& name, TVariant& var) const
 | 
						||
{
 | 
						||
	return TAnal_report::get_usr_val(name, var);
 | 
						||
}
 | 
						||
 | 
						||
bool TPrint_stima_ricavi_rep::set_recordset()
 | 
						||
{
 | 
						||
  TPrint_stima_ricavi_recordset* rs = new TPrint_stima_ricavi_recordset();
 | 
						||
  return TAnal_report::set_recordset(rs);
 | 
						||
}
 | 
						||
 | 
						||
void TPrint_stima_ricavi_rep::set_filter(const TPrint_stima_ricavi_mask& msk)
 | 
						||
{
 | 
						||
	TPrint_stima_ricavi_recordset* recset = new TPrint_stima_ricavi_recordset(); 
 | 
						||
 | 
						||
  recset->set_filter(msk, "");
 | 
						||
	TAnal_report::set_recordset(recset);
 | 
						||
}
 | 
						||
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
//	APPLICAZIONE
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
class TPrint_stima_ricavi : public TSkeleton_application
 | 
						||
{
 | 
						||
  TPrint_stima_ricavi_mask* _mask;
 | 
						||
 | 
						||
protected:
 | 
						||
  void print_or_preview(const bool stampa);
 | 
						||
  virtual void print();
 | 
						||
  virtual void preview();
 | 
						||
 | 
						||
  virtual void main_loop();
 | 
						||
};
 | 
						||
 | 
						||
void TPrint_stima_ricavi::print()
 | 
						||
{
 | 
						||
  print_or_preview(true);
 | 
						||
}
 | 
						||
 | 
						||
void TPrint_stima_ricavi::preview()
 | 
						||
{
 | 
						||
  print_or_preview(false);
 | 
						||
}
 | 
						||
 | 
						||
void TPrint_stima_ricavi::print_or_preview(const bool stampa)
 | 
						||
{
 | 
						||
	//report e book dei report
 | 
						||
	TReport_book book;
 | 
						||
	TString path = _mask->get(F_REPORT);
 | 
						||
	if (path.empty())
 | 
						||
		path = "ca3900a";
 | 
						||
	TPrint_stima_ricavi_rep rep;
 | 
						||
	rep.load(path);
 | 
						||
 | 
						||
	rep.set_filter(*_mask);	
 | 
						||
	book.add(rep);
 | 
						||
 | 
						||
  if (stampa)
 | 
						||
    book.print();
 | 
						||
  else
 | 
						||
    book.preview();
 | 
						||
}
 | 
						||
 | 
						||
void TPrint_stima_ricavi::main_loop()
 | 
						||
{
 | 
						||
  _mask = new TPrint_stima_ricavi_mask;
 | 
						||
  _mask->run();
 | 
						||
  delete _mask;
 | 
						||
  _mask = NULL;
 | 
						||
}
 | 
						||
 | 
						||
int ca3900(int argc, char* argv[])
 | 
						||
{
 | 
						||
  TPrint_stima_ricavi a;
 | 
						||
  a.run(argc, argv, TR("Stampa stima ricavi di competenza"));
 | 
						||
  return 0;
 | 
						||
}
 | 
						||
 | 
						||
//Istruzioni per i programmi ca3800 e ca3900
 | 
						||
//------------------------------------------
 | 
						||
// CA_3800
 | 
						||
// Gestore maschera ca3800 (Analisi Bilancio di Commessa)
 | 
						||
// Creatore del report e dell'applicazione
 | 
						||
 | 
						||
// CA_3801
 | 
						||
// Gestore dei report a colonne variabili (stampa in base a struttura scelta per il PCONANA). Serve solo per ca3800.
 | 
						||
 | 
						||
// CA_3883
 | 
						||
// Gestore del recordset per il calcolo dei valori da mettere sulle stampe (<28> il nucleo dei programmi ca3800 e ca3900)
 | 
						||
 | 
						||
// CA_3900
 | 
						||
// Gestore maschera ca3900 (Stima ricavi di competenza)
 | 
						||
// Creatore del report e dell'applicazione
 |