Files correlati :lv2.exe Ricompilazione Demo : [ ] Commento Primo commit della fatturazioine git-svn-id: svn://10.65.10.50/trunk@18489 c028cbd2-c16b-5b4b-a496-9718f37d4682
291 lines
8.1 KiB
C++
Executable File
291 lines
8.1 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <progind.h>
|
|
#include <recarray.h>
|
|
#include "../ve/ve6200.h"
|
|
#include "../ve/ve6200a.h"
|
|
#include <doc.h>
|
|
#include "lvlib.h"
|
|
#include "lvcondv.h"
|
|
#include "lvrcondv.h"
|
|
#include "lv2500a.h"
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFatturazione_lavanderie
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TFatturazione_lavanderie:public TFatturazione_bolle
|
|
{
|
|
TDate _data_elab;
|
|
|
|
protected:
|
|
virtual void add_rows(TRiga_documento & rout, TRiga_documento & rin);
|
|
virtual void create_row(TDocumento& doc_out, const TRiga_documento & rin);
|
|
real fat_lav_pre(TRiga_documento & rin, const real& qta);
|
|
virtual void post_process(TDocumento & doc);
|
|
|
|
public:
|
|
TFatturazione_lavanderie(const char* cod);
|
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
|
const TDate& data_elab, bool interattivo = false);
|
|
|
|
};
|
|
|
|
TFatturazione_lavanderie::TFatturazione_lavanderie(const char* cod)
|
|
: TFatturazione_bolle(cod)
|
|
{
|
|
}
|
|
|
|
|
|
real TFatturazione_lavanderie::fat_lav_pre(TRiga_documento & rin, const real& qta)
|
|
{
|
|
const TString80 codart=rin.get(RDOC_CODART);
|
|
const long clifo=rin.doc().get_long(DOC_CODCF);
|
|
const int indsped=rin.doc().get_int(DOC_CODINDSP);
|
|
const TString8 causale=rin.get(RDOC_CODAGG1);
|
|
|
|
real new_qta;
|
|
|
|
const TRectype& cau = cache().get("&CAU", causale);
|
|
//movimento o meno la dotazione temporanea/odierna a seconda di cosa prevede la causale
|
|
|
|
/* if (cau.get_bool("B0"))
|
|
{
|
|
const TCausale_magazzino& rit = cached_causale_magazzino(cau.get("S1"));
|
|
int sgn_rit = rit.sgn(s_consmese);
|
|
|
|
}*/
|
|
|
|
if (cau.get_bool("B1"))
|
|
{
|
|
const TCausale_magazzino& con = cached_causale_magazzino(cau.get("S2"));
|
|
int sgn_con = con.sgn(s_consmese);
|
|
new_qta=sgn_con*qta;
|
|
}
|
|
|
|
TLaundry_contract contr(clifo,indsped,_data_elab);
|
|
const TRectype & rcont=contr.row(codart);
|
|
|
|
const TString4 tipodot=rcont.get(LVRCONDV_NOLCIC);
|
|
const TString4 artcli=rcont.get(LVRCONDV_VCARTCLI);
|
|
const real dot;
|
|
|
|
TArticolo_lavanderie artlav(codart,'C',clifo,indsped);
|
|
|
|
return new_qta;
|
|
|
|
}
|
|
|
|
void TFatturazione_lavanderie::post_process(TDocumento & doc)
|
|
{
|
|
const int rows = doc.physical_rows();
|
|
for (int i = 1; i <= rows; i++)
|
|
{
|
|
TRiga_documento& rout = doc[i];
|
|
const TString80 codart=rout.get(RDOC_CODART);
|
|
const long clifo=rout.doc().get_long(DOC_CODCF);
|
|
const int indsped=rout.doc().get_int(DOC_CODINDSP);
|
|
|
|
TLaundry_contract contr(clifo,indsped,_data_elab);
|
|
const TRectype & rcont=contr.row(codart);
|
|
|
|
const TString4 tipodot=rcont.get(LVRCONDV_NOLCIC);
|
|
const TString4 artcli=rcont.get(LVRCONDV_VCARTCLI);
|
|
real dot;
|
|
TArticolo_lavanderie artlav(codart,'C',clifo,indsped);
|
|
|
|
if (tipodot=="I")
|
|
dot=artlav.get_real("DOTIN");
|
|
else
|
|
dot=artlav.get_real("DOTOD");
|
|
|
|
int tipoforf=rcont.get_int(LVRCONDV_TIPOFORF);
|
|
|
|
switch (tipoforf)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZZO));
|
|
break;
|
|
case 2:
|
|
{
|
|
rout.put(RDOC_QTA, UNO);
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_IMPFISART));
|
|
// gestione in base codice per valore fisso ??? tolta la scelta dell'articolo o del cliente
|
|
}
|
|
break;
|
|
case 3:
|
|
{
|
|
int tipolist=contr.get_int(LVCONDV_TIPOLIS);
|
|
|
|
if (tipolist==0)
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZZO));
|
|
else
|
|
{
|
|
TString query;
|
|
query << "USE UMART KEY 2 \n"
|
|
<< "FROM " << "CODART=#CODART UM=#UM \n"
|
|
<< "TO " << "TCODART=#CODART UM=#UM \n";
|
|
|
|
TISAM_recordset recset(query);
|
|
recset.set_var("#CODART",clifo);
|
|
recset.set_var("#UM",rcont.get(LVRCONDV_UM));
|
|
|
|
rout.put(RDOC_PREZZO,recset.get(UMART_PREZZO).as_real());
|
|
}
|
|
|
|
rout.put(RDOC_QTA, dot);
|
|
}
|
|
break;
|
|
case 4:
|
|
{
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZZO));
|
|
const real cicl=rcont.get_real(LVRCONDV_MINCIC)*dot;
|
|
const real qta=rout.get(RDOC_QTA);
|
|
rout.put(RDOC_QTA, cicl > qta ? cicl : qta);
|
|
}
|
|
break;
|
|
case 5:
|
|
{
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_VALCONV));
|
|
rout.put(RDOC_QTA, dot*rcont.get_real(LVRCONDV_FORFPERCL));
|
|
}
|
|
break;
|
|
case 6:
|
|
{
|
|
rout.put(RDOC_PREZZO, rcont.get_real(LVRCONDV_PREZZO));
|
|
|
|
rout.put(RDOC_QTA, dot);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void TFatturazione_lavanderie::add_rows(TRiga_documento & rout, TRiga_documento & rin)
|
|
{
|
|
const real qta=rin.get_real(RDOC_QTA);
|
|
|
|
rout.add(RDOC_QTA, fat_lav_pre(rin,qta) );
|
|
}
|
|
|
|
void TFatturazione_lavanderie::create_row(TDocumento& doc_out, const TRiga_documento & rin)
|
|
{
|
|
TFatturazione_bolle::create_row(doc_out, rin);
|
|
}
|
|
|
|
bool TFatturazione_lavanderie::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
|
const TDate& data_elab, bool interattivo)
|
|
{
|
|
_data_elab=data_elab;
|
|
bool ok=TFatturazione_bolle::elabora(doc_in, doc_out, data_elab, interattivo);
|
|
return ok;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFatturazione_msk
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
class TFatturazione_msk: public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly){return true;}
|
|
public:
|
|
TFatturazione_msk();
|
|
};
|
|
|
|
TFatturazione_msk::TFatturazione_msk():TAutomask("lv2500a")
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFatturazione_lav_app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TFatturazione_lav_app: public TSkeleton_application
|
|
{
|
|
protected:
|
|
virtual void main_loop();
|
|
};
|
|
|
|
void TFatturazione_lav_app::main_loop()
|
|
{
|
|
TFatturazione_msk msk;
|
|
while (msk.run()!=K_QUIT)
|
|
{
|
|
TString query;
|
|
query << "USE DOC KEY 2 SELECT BETWEEN(DATADOC,#DADATA,#ADATA)\n"
|
|
<< "FROM " << "TIPOCF=C PROVV=D ANNO=#ANNO DATADOC=#DADATA \n"
|
|
<< "TO " << "TIPOCF=C PROVV=D ANNO=#ANNO DATADOC=#ADATA \n";
|
|
|
|
TISAM_recordset recset(query);
|
|
recset.set_var("#DADATA",msk.get_date(F_DADATA));
|
|
recset.set_var("#ADATA",msk.get_date(F_ADATA));
|
|
recset.set_var("#ANNO",long(msk.get_date(F_ADATA).year()));
|
|
|
|
TFatturazione_lavanderie elab(msk.get(F_CODICE_ELAB));
|
|
TLista_documenti docsin;
|
|
TLista_documenti docsout;
|
|
long lastcli=0;
|
|
const int period=msk.get_int(F_PERFAT);
|
|
const TDate datafat=msk.get_date(F_DATAFAT);
|
|
long indsped;
|
|
|
|
|
|
for (bool ok=recset.move_first(); ok; ok=recset.move_next())
|
|
{
|
|
const long clifo=recset.get(DOC_CODCF).as_int();
|
|
|
|
if (clifo!=lastcli)
|
|
{
|
|
if (docsin.items()!=0)
|
|
{
|
|
elab.elabora(docsin,docsout,datafat);
|
|
docsout.write();
|
|
docsout.destroy(-1) ;
|
|
docsin.rewrite();
|
|
docsin.destroy(-1);
|
|
// gestire qui salvataggio fatture
|
|
}
|
|
lastcli=clifo;
|
|
}
|
|
|
|
if (elab.is_document_ok(recset.cursor()->curr()))
|
|
{
|
|
indsped=recset.get(DOC_CODINDSP).as_int();
|
|
TLaundry_contract contr(clifo,indsped,datafat);
|
|
int contrper=contr.get_int(LVCONDV_PERFATT);
|
|
|
|
if (contrper<=period)
|
|
{
|
|
docsin.add(new TDocumento(recset.cursor()->curr()));
|
|
}
|
|
}
|
|
}
|
|
if (docsin.items()!=0)
|
|
{
|
|
elab.elabora(docsin,docsout,datafat);
|
|
docsout.write();
|
|
docsout.destroy(-1);
|
|
docsin.rewrite();
|
|
docsin.destroy(-1);
|
|
// gestire qui salvataggio fatture
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
int lv2500(int argc, char *argv[])
|
|
{
|
|
TFatturazione_lav_app a;
|
|
a.run (argc, argv, "Fatturazione lavanderie");
|
|
return TRUE;
|
|
}
|