3d7dab8e40
Files correlati : Ricompilazione Demo : [ ] Commento : RIportata la verione 3.2 1167 git-svn-id: svn://10.65.10.50/trunk@16733 c028cbd2-c16b-5b4b-a496-9718f37d4682
283 lines
6.3 KiB
C++
Executable File
283 lines
6.3 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 <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 <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();
|
|
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() {}
|
|
};
|
|
|
|
TConferimenti_mask::TConferimenti_mask(const char* tipodoc):
|
|
TDocumento_mask(tipodoc)
|
|
{
|
|
}
|
|
|
|
int TConferimenti_application::rewrite( const TMask& m )
|
|
{
|
|
int err = NOERR;
|
|
const TTipo_documento tipodoc(m.get(172));
|
|
if (tipodoc.tipo() == 5)
|
|
{
|
|
const long codmercato = m.get_long(343);
|
|
TDocumento & doc = ((TConferimenti_mask & )m).doc();
|
|
doc.put("SPESEUPD", false);
|
|
doc.put("RAGGR", true);
|
|
update_spese_doc(codmercato, doc);
|
|
err = TMotore_application::rewrite(m);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
int TConferimenti_application::write( const TMask& m )
|
|
{
|
|
int err = NOERR;
|
|
const TTipo_documento tipodoc(m.get(172));
|
|
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 TString8 codcomp = m.get(344);
|
|
TLista_documenti listadoc;
|
|
if (compagnia2soci(doc, codcomp, codmercato, 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;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool confer_codart_handler(TMask_field& f, KEY key)
|
|
{
|
|
bool ok = codart_handler(f, key);
|
|
if (ok && f.to_check(key))
|
|
{
|
|
TMask& row_mask = f.mask();
|
|
row_mask.set(FR_SCONTO, cfapp().ritprezzo(), true);
|
|
}
|
|
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;
|
|
}
|