Files correlati : co0.exe co1.exe Ricompilazione Demo : [ ] Commento : aggiunta stampa progressivi conferimenti Varie stampe dei vongolari. stampa per data licenza Modificato il tracciato dell'importazione conferimenti Non genera piu' documenti se il totale documento campione e' 0 Prima prova di filtro per stampa soci INAIL Creazione report , stampa soci inail Acconto 8% sui progressivi piu' modifiche alle stampe 8% e stampa progressivi Filtro sulla stampa co2200a per data licenza Totale sulla stampa progressivi Progressivi modificabili con shift f12 aggiunta stampa registro carico scarico Dalla versione 3.2 git-svn-id: svn://10.65.10.50/trunk@20584 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			440 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			440 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include "../ve/velib.h"
 | 
						|
#include "../ve/sconti.h"
 | 
						|
#include "../mg/mglib.h"
 | 
						|
 | 
						|
#include "../ve/vepriv.h"
 | 
						|
#include "../ve/veuml.h"
 | 
						|
 | 
						|
#include <automask.h>
 | 
						|
#include <defmask.h>
 | 
						|
#include <execp.h>
 | 
						|
#include <agasys.h>
 | 
						|
#include <recset.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include "../mg/anamag.h"
 | 
						|
#include "../ve/ve0100.h"
 | 
						|
#include "../ve/veini.h"
 | 
						|
#include "../ve/veuml.h"
 | 
						|
#include "../ve/veuml1.h"
 | 
						|
#include "../ve/verig.h"
 | 
						|
 | 
						|
#include <clifo.h>
 | 
						|
#include "socicoop.h"
 | 
						|
#include "co0700b.h"
 | 
						|
 | 
						|
#include <user.h>
 | 
						|
 | 
						|
#include "colib.h"
 | 
						|
 | 
						|
 | 
						|
// Definizione della classe dell'applicazione motore
 | 
						|
class TConferimenti_application : public TMotore_application
 | 
						|
{
 | 
						|
	TAssoc_array _masks; // assoc_array delle maschere da utilizzare
 | 
						|
	TString4 _tipodoc; 
 | 
						|
	real	_ritprezzo;
 | 
						|
	real	_ritqta;
 | 
						|
	TString_array _speserit;
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual TMask* get_mask( int mode );
 | 
						|
	virtual void on_firm_change();
 | 
						|
  virtual int read( TMask& m );
 | 
						|
	int write( const TMask& m );
 | 
						|
	int rewrite( const TMask& m );
 | 
						|
	real get_perc_socio(const long codsocio, const TString& codcomp) const;
 | 
						|
 | 
						|
public:
 | 
						|
  virtual TMask & query_mask();
 | 
						|
  virtual TDocumento_mask & edit_mask() const;
 | 
						|
	real ritprezzo() {return _ritprezzo;};
 | 
						|
	real ritqta() {return _ritqta;};
 | 
						|
	TString_array& speserit() {return _speserit;};
 | 
						|
 | 
						|
	TConferimenti_application() {}
 | 
						|
};
 | 
						|
 | 
						|
inline TConferimenti_application& cfapp() { return (TConferimenti_application &) main_app(); };
 | 
						|
 | 
						|
// maschera di ricerca
 | 
						|
class TConferimenti_query_mask : public TAutomask
 | 
						|
{
 | 
						|
protected:
 | 
						|
public:
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
 | 
						|
  TConferimenti_query_mask() : TAutomask("co0700a") {}
 | 
						|
  virtual ~TConferimenti_query_mask() {}
 | 
						|
};
 | 
						|
 | 
						|
// maschera di edit
 | 
						|
class TConferimenti_mask : public TDocumento_mask
 | 
						|
{
 | 
						|
	bool _rigaspesa;
 | 
						|
 | 
						|
protected:
 | 
						|
 | 
						|
public:
 | 
						|
  virtual TVariable_mask* riga_mask(int numriga);
 | 
						|
  TConferimenti_mask(const char* tipodoc);
 | 
						|
  virtual ~TConferimenti_mask() {}
 | 
						|
};
 | 
						|
 | 
						|
bool genera_handler(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
	if (key == K_SPACE)
 | 
						|
	{
 | 
						|
		TConferimenti_mask& m =	(TConferimenti_mask&) f.mask();
 | 
						|
		TMask select_mask("co0700b");
 | 
						|
		TDocumento campione(m.doc());
 | 
						|
 | 
						|
		if (campione.totale_doc() != ZERO)
 | 
						|
		{
 | 
						|
			const TDate datadoc = campione.get_date(DOC_DATADOC);
 | 
						|
			long codsocio = campione.get_long(DOC_CODCF);
 | 
						|
 | 
						|
			campione.zero(DOC_NDOC);
 | 
						|
 | 
						|
			if (select_mask.run() == K_ENTER)
 | 
						|
			{
 | 
						|
				TISAM_recordset recset("USE SOCICOOP\nFROM CODCF=#DASOCIO\nTO CODCF=#ASOCIO");
 | 
						|
 | 
						|
				recset.set_var("#DASOCIO", select_mask.get_long(F_DASOCIO));
 | 
						|
				recset.set_var("#ASOCIO", select_mask.get_long(F_ASOCIO));
 | 
						|
				for (bool ok = recset.move_first(); ok; ok = recset.move_next())
 | 
						|
				{
 | 
						|
					const long socio = recset.get(SC_CODCF).as_int();
 | 
						|
 | 
						|
					if (socio != codsocio)
 | 
						|
					{
 | 
						|
						const TDate dataass = recset.get(SC_DATAASS).as_date();
 | 
						|
						const TDate datarec = recset.get(SC_DATAREC).as_date();
 | 
						|
						const bool ok = (!dataass.ok() || dataass <= datadoc) && (!datarec.ok() || datarec >= datadoc);
 | 
						|
 | 
						|
						if (ok)
 | 
						|
						{
 | 
						|
							TDocumento d(campione);
 | 
						|
 | 
						|
							d.put(DOC_CODCF, socio);
 | 
						|
							d.write();
 | 
						|
						}
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return true;
 | 
						|
}
 | 
						|
 | 
						|
TConferimenti_mask::TConferimenti_mask(const char* tipodoc):
 | 
						|
										TDocumento_mask(tipodoc)
 | 
						|
{
 | 
						|
	const int pos = id2pos(499);
 | 
						|
 | 
						|
	if (pos >= 0)
 | 
						|
		set_handler(499, genera_handler);
 | 
						|
}
 | 
						|
 | 
						|
int TConferimenti_application::rewrite( const TMask& m )  
 | 
						|
{          
 | 
						|
	int err = NOERR;
 | 
						|
	const TTipo_documento tipodoc(m.get(172));
 | 
						|
	TDocumento & doc = ((TConferimenti_mask & )m).doc();
 | 
						|
 | 
						|
	if (tipodoc.tipo() == 5)
 | 
						|
	{
 | 
						|
		const long codmercato = m.get_long(343);
 | 
						|
 | 
						|
		doc.put("SPESEUPD", false);
 | 
						|
		doc.put("RAGGR", true);
 | 
						|
		update_spese_doc(codmercato, doc);
 | 
						|
	}
 | 
						|
	
 | 
						|
	const int nrows = doc.physical_rows();
 | 
						|
 | 
						|
	if (tipodoc.tipo() == 6)
 | 
						|
		for (int r = nrows; r >= 1; r--)
 | 
						|
		{
 | 
						|
			TRiga_documento & row = doc[r];
 | 
						|
 | 
						|
			if (row.is_spese())
 | 
						|
			{
 | 
						|
				const TSpesa_prest & s = row.spesa();
 | 
						|
 | 
						|
				if (s.get("S11") == "D")
 | 
						|
				{
 | 
						|
					real val = row.get_real(RDOC_PREZZO);
 | 
						|
 | 
						|
					val = -val;
 | 
						|
					row.put(RDOC_PREZZO, val);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	err = TMotore_application::rewrite(m);
 | 
						|
	return err;
 | 
						|
}
 | 
						|
										
 | 
						|
int TConferimenti_application::read( TMask& m )
 | 
						|
{
 | 
						|
	int	err = TMotore_application::read(m);
 | 
						|
	TDocumento & doc = ((TConferimenti_mask & )m).doc();
 | 
						|
	TSheet_field & sf = ((TConferimenti_mask & )m).sfield(F_SHEET);
 | 
						|
	const int nrows = doc.physical_rows();
 | 
						|
	const TTipo_documento tipodoc(m.get(172));
 | 
						|
 | 
						|
	if (err == NOERR && tipodoc.tipo() == 6)
 | 
						|
	{
 | 
						|
		for (int r = nrows; r >= 1; r--)
 | 
						|
		{
 | 
						|
			TRiga_documento & row = doc[r];
 | 
						|
 | 
						|
			if (row.is_spese())
 | 
						|
			{
 | 
						|
				const TSpesa_prest & s = row.spesa();
 | 
						|
 | 
						|
				if (s.get("S11") == "D")
 | 
						|
				{
 | 
						|
					real val = row.get_real(RDOC_PREZZO);
 | 
						|
 | 
						|
					val = -val;
 | 
						|
					row.put(RDOC_PREZZO, val);
 | 
						|
					row.autoload(sf);;
 | 
						|
				}
 | 
						|
			}
 | 
						|
			sf.force_update();
 | 
						|
		}
 | 
						|
	} 
 | 
						|
	return err;
 | 
						|
}
 | 
						|
 | 
						|
int TConferimenti_application::write( const TMask& m )  
 | 
						|
{          
 | 
						|
	int err = NOERR;
 | 
						|
	TDocumento & doc = ((TConferimenti_mask & )m).doc();
 | 
						|
	const int nrows = doc.physical_rows();
 | 
						|
	bool zero_doc = true;
 | 
						|
	const TTipo_documento tipodoc(m.get(172));
 | 
						|
 | 
						|
	for (int r = nrows; r >= 1; r--)
 | 
						|
	{
 | 
						|
		TRiga_documento & row = doc[r];
 | 
						|
 | 
						|
		if (row.imponibile() != ZERO)
 | 
						|
		{
 | 
						|
			zero_doc = false;
 | 
						|
			if (tipodoc.tipo() == 6	&& row.is_spese())
 | 
						|
			{
 | 
						|
			  const TSpesa_prest & s = row.spesa();
 | 
						|
 | 
						|
				if (s.get("S11") == "D")
 | 
						|
				{
 | 
						|
					real val = row.get_real(RDOC_PREZZO);
 | 
						|
 | 
						|
					val = -val;
 | 
						|
					row.put(RDOC_PREZZO, val);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	if (zero_doc)
 | 
						|
		return false;
 | 
						|
 | 
						|
	if (tipodoc.tipo() == 5)
 | 
						|
	{
 | 
						|
		const char confda = m.get(401)[0];
 | 
						|
		const long codmercato = m.get_long(343);
 | 
						|
		if (confda=='S') // conferimento da socio
 | 
						|
		{
 | 
						|
			TDocumento & doc = ((TConferimenti_mask & )m).doc();
 | 
						|
			doc.put("SPESEUPD", false);
 | 
						|
			doc.put("RAGGR", true);
 | 
						|
			update_spese_doc(codmercato, doc);
 | 
						|
			err = TMotore_application::write(m);
 | 
						|
		}
 | 
						|
		else	// conferimento da compagnia
 | 
						|
		{
 | 
						|
			TDocumento& doc = ((TConferimenti_mask&) m).doc();
 | 
						|
			if (doc.physical_rows() > 0)
 | 
						|
			{
 | 
						|
				const long nfasta	= m.get_long(345);
 | 
						|
				const TString8 codcomp = m.get(344);
 | 
						|
				TLista_documenti listadoc;
 | 
						|
				if (compagnia2soci(doc, codcomp, codmercato, nfasta, listadoc) > 0)
 | 
						|
					err = listadoc.write();
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	else
 | 
						|
		err = TMotore_application::write(m);
 | 
						|
	return err;
 | 
						|
}
 | 
						|
 | 
						|
void TConferimenti_application::on_firm_change()
 | 
						|
{
 | 
						|
	TConfig d(CONFIG_DITTA, "co");
 | 
						|
	_ritprezzo = real(d.get("RitPrezzo"));
 | 
						|
	_ritqta = real(d.get("RitQta"));
 | 
						|
}
 | 
						|
 | 
						|
TMask& TConferimenti_application::query_mask()
 | 
						|
{
 | 
						|
	TMask* m = (TMask*) _masks.objptr("co0700a");
 | 
						|
	if (m == NULL)
 | 
						|
	{
 | 
						|
		m = new TConferimenti_query_mask();
 | 
						|
		_masks.add("co0700a", m);
 | 
						|
	}
 | 
						|
	return *m;
 | 
						|
}
 | 
						|
 | 
						|
TDocumento_mask& TConferimenti_application::edit_mask() const
 | 
						|
{
 | 
						|
	TDocumento_mask* m = (TDocumento_mask*) _masks.objptr(_tipodoc);
 | 
						|
	if (m == NULL)
 | 
						|
	{
 | 
						|
		m = new TConferimenti_mask(_tipodoc);
 | 
						|
		((TAssoc_array&)_masks).add(_tipodoc, m);
 | 
						|
	}
 | 
						|
	return *m;
 | 
						|
}
 | 
						|
 | 
						|
TMask* TConferimenti_application::get_mask( int mode )
 | 
						|
{
 | 
						|
	TMask* m = NULL;
 | 
						|
	if (mode == MODE_MOD || mode == MODE_INS)
 | 
						|
	{
 | 
						|
		_tipodoc = query_mask().get(F_TIPODOC);
 | 
						|
		m = &edit_mask();
 | 
						|
	}
 | 
						|
	else
 | 
						|
		m = &query_mask();
 | 
						|
	return m;
 | 
						|
}
 | 
						|
 | 
						|
bool TConferimenti_query_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{
 | 
						|
	switch (o.dlg())
 | 
						|
	{
 | 
						|
		case F_ANNO:
 | 
						|
			if (e == fe_modify)
 | 
						|
				app().update_navigation_bar();
 | 
						|
			break;
 | 
						|
		case F_CODNUM:
 | 
						|
			if (e == fe_modify)
 | 
						|
			{
 | 
						|
				TMask& m = o.mask();
 | 
						|
    
 | 
						|
				TTable & tabnum  = ((TTable &) ((TEdit_field &)o).browse()->cursor()->file());
 | 
						|
				if ( tabnum.good())
 | 
						|
				{
 | 
						|
					TCodice_numerazione cod_num(tabnum.curr());
 | 
						|
					m.set( F_DESNUM, cod_num.descrizione());
 | 
						|
					// Propone il primo tipo di documento come default
 | 
						|
					if (m.field(F_TIPODOC).empty() || o.focusdirty())
 | 
						|
					{
 | 
						|
						m.set( F_TIPODOC, cod_num.tipo_doc(0));
 | 
						|
						m.send_key( K_TAB, F_TIPODOC );
 | 
						|
					}
 | 
						|
						// Setta la numerazione a definitiva
 | 
						|
				}
 | 
						|
				else
 | 
						|
				{
 | 
						|
					m.set( F_DESNUM, "" );
 | 
						|
					m.set( F_TIPODOC, "" );
 | 
						|
				}
 | 
						|
 | 
						|
				app().update_navigation_bar();
 | 
						|
			}
 | 
						|
			break;
 | 
						|
		case F_TIPODOC:
 | 
						|
			if (e == fe_modify)
 | 
						|
			{
 | 
						|
				TMask& m = o.mask();
 | 
						|
 | 
						|
				if (m.get(F_TIPODOC).full())
 | 
						|
				{
 | 
						|
					TCodice_numerazione cod_num(m.get(F_CODNUM));
 | 
						|
					const TString& tipo = o.get();
 | 
						|
					int last = cod_num.ntipi_doc();
 | 
						|
					for (int i = 0; i < last; i++ )
 | 
						|
					{
 | 
						|
						const TString& curtipo = cod_num.tipo_doc(i);
 | 
						|
						if (curtipo == tipo)
 | 
						|
							return TRUE;
 | 
						|
					}
 | 
						|
					return o.error_box(TR("Tipo non valido per la numerazione selezionata!"));
 | 
						|
				}
 | 
						|
			}
 | 
						|
			break;
 | 
						|
		case F_NUMDOCRIF:
 | 
						|
			if (e == fe_button)
 | 
						|
				TDocumento_mask::numdocrif_search_handler(o, K_F9);
 | 
						|
			break;
 | 
						|
		case F_RAGSOCSEARCH:
 | 
						|
			if (e == fe_button)
 | 
						|
				TDocumento_mask::ragsoc_search_handler(o, K_F9);
 | 
						|
			break;
 | 
						|
 | 
						|
		default:
 | 
						|
			break;
 | 
						|
	}
 | 
						|
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
bool confer_codart_handler(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
	bool ok = codart_handler(f, key);
 | 
						|
  TMask& row_mask = f.mask();   
 | 
						|
 | 
						|
	if (ok && f.to_check(key))
 | 
						|
	{
 | 
						|
    row_mask.set(FR_SCONTO, cfapp().ritprezzo(), true);
 | 
						|
 | 
						|
		const TString & cod = row_mask.get(FR_CODARTMAG);
 | 
						|
		
 | 
						|
		if (cod.full())
 | 
						|
		{
 | 
						|
			const TString & codiva = cache().get(LF_ANAMAG, cod, ANAMAG_CODIVA);
 | 
						|
			if (codiva.full())
 | 
						|
				row_mask.set(FR_CODIVA, codiva);		
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return ok;
 | 
						|
}
 | 
						|
 | 
						|
bool confer_qtagg1_handler(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
	if (f.to_check(key))
 | 
						|
	{
 | 
						|
	  TMask& row_mask = f.mask();   
 | 
						|
		real qtagg1 = f.get();
 | 
						|
		real qta = qtagg1*cfapp().ritqta()/CENTO;
 | 
						|
    row_mask.set(FR_QTA, qtagg1-qta, true);
 | 
						|
	}
 | 
						|
	return true;
 | 
						|
}
 | 
						|
 | 
						|
TVariable_mask* TConferimenti_mask::riga_mask(int numriga)
 | 
						|
{
 | 
						|
	TVariable_mask* m = TDocumento_mask::riga_mask(numriga);
 | 
						|
  const TRiga_documento& riga = doc()[numriga + 1];
 | 
						|
  const TTipo_riga_documento& tiporiga = riga.tipo();
 | 
						|
	if (tiporiga.tipo() == 'M') // riga merce
 | 
						|
	{
 | 
						|
		m->set_handler(FR_CODART, confer_codart_handler);
 | 
						|
		m->set_handler(FR_QTAGG1, confer_qtagg1_handler);
 | 
						|
	}
 | 
						|
  return m;
 | 
						|
}
 | 
						|
 | 
						|
int co0700( int argc, char* argv[])
 | 
						|
{
 | 
						|
  TConferimenti_application a;
 | 
						|
 | 
						|
  a.run( argc, argv, TR("Conferimenti cooperative"));
 | 
						|
  return 0;
 | 
						|
}
 |