Files correlati : ve0.exe ve6.exe Ricompilazione Demo : [ ] Commento : Bug 0001690: Gestione documenti (ve0), Contabilizzazione documenti( ve6) Aggiungere la possibilità di distribuire le spese sui conti contabili quando quest'ultime non hanno un conto proprio git-svn-id: svn://10.65.10.50/branches/R_10_00@20829 c028cbd2-c16b-5b4b-a496-9718f37d4682
240 lines
5.7 KiB
C++
Executable File
240 lines
5.7 KiB
C++
Executable File
#include <applicat.h>
|
|
#include "clifor.h"
|
|
#include "velib.h"
|
|
#include "../li/letint.h"
|
|
#include <modaut.h>
|
|
#include <relation.h>
|
|
|
|
TOccasionale::TOccasionale() : TRectype(LF_OCCAS)
|
|
{ }
|
|
TOccasionale::TOccasionale(const TRectype& r) : TRectype(r)
|
|
{ }
|
|
|
|
TOccasionale::TOccasionale(const TOccasionale& r) : TRectype(r)
|
|
{
|
|
}
|
|
|
|
TRectype& TOccasionale::operator=(const TRectype& r)
|
|
{
|
|
return TRectype::operator=(r);
|
|
}
|
|
|
|
TOccasionale& TOccasionale::operator=(const TOccasionale& r)
|
|
{
|
|
TRectype::operator=(r);
|
|
return *this;
|
|
}
|
|
|
|
TOccasionale::~TOccasionale()
|
|
{ }
|
|
|
|
int TCli_for::write_rewrite(TBaseisamfile& f, bool re) const
|
|
{
|
|
int err = TMultiple_rectype::write_rewrite(f, re);
|
|
|
|
if (err == NOERR)
|
|
{
|
|
TLocalisamfile v(LF_CFVEN);
|
|
TRectype & v_rec = vendite();
|
|
err = v.write(v_rec);
|
|
if (err == _isreinsert)
|
|
err = v.write(v_rec);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
TRectype& TCli_for::vendite() const
|
|
{
|
|
const char t = tipo();
|
|
const long c = codice();
|
|
|
|
if (_ven_rec.empty() || t != *(const char *) (*_ven_tipo) || c != (long) *_ven_codice)
|
|
{
|
|
TLocalisamfile v(LF_CFVEN);
|
|
TRectype& vr = ((TCli_for *)this)->_ven_rec; // fool const
|
|
|
|
vr.zero();
|
|
vr.put(CFV_TIPOCF,t);
|
|
vr.put(CFV_CODCF, c);
|
|
const TRectype v_rec(vr);
|
|
if (vr.read(v) != NOERR)
|
|
vr = v_rec;
|
|
}
|
|
return (TRectype &) _ven_rec;
|
|
}
|
|
|
|
bool TCli_for::read_lettera(const TDate & data, bool extended)
|
|
{
|
|
|
|
if (_use_lettere)
|
|
{
|
|
if (data != _last_data)
|
|
{
|
|
_letint.zero();
|
|
TRelation * r = new TRelation(LF_LETINT);
|
|
TRectype to(r->curr());
|
|
|
|
to.put(LETINT_ANNO, data.year());
|
|
to.put(LETINT_CODCLI, codice());
|
|
|
|
TRectype from(to);
|
|
|
|
from.put(LETINT_ANNO, data.year() - 1);
|
|
|
|
TCursor c(r, "", 2 ,&from, &to);
|
|
const int items = c.items();
|
|
|
|
if (items > 0)
|
|
{
|
|
TDate dal;
|
|
TDate al(31, 12, data.year());
|
|
|
|
for (long pos = items - 1; pos >= 0L; pos--)
|
|
{
|
|
c = pos;
|
|
|
|
const int tipo = c.curr().get_int(LETINT_TIPOOP);
|
|
|
|
if (tipo == 3)
|
|
{
|
|
dal = c.curr().get_date(LETINT_DAL);
|
|
al = c.curr().get_date(LETINT_AL);
|
|
}
|
|
else
|
|
{
|
|
dal = c.curr().get_date(LETINT_VSDATA);
|
|
if (c.pos() < items - 1)
|
|
{
|
|
++c;
|
|
const int tipo_next = c.curr().get_int(LETINT_TIPOOP);
|
|
if (tipo_next == 3)
|
|
al = c.curr().get_date(LETINT_DAL);
|
|
else
|
|
al = c.curr().get_date(LETINT_VSDATA);
|
|
--c;
|
|
}
|
|
}
|
|
if (dal <= data)
|
|
{
|
|
_letint = c.curr();
|
|
break;
|
|
}
|
|
}
|
|
_lettera_found = !_letint.empty();
|
|
if (_lettera_found && !extended)
|
|
_lettera_found = data <= al;
|
|
}
|
|
_last_data = data;
|
|
}
|
|
}
|
|
return _lettera_found;
|
|
}
|
|
|
|
int TCli_for::read(const TRectype & rec, word op, word lockop)
|
|
{
|
|
_ven_rec.zero();
|
|
int err = TMultiple_rectype::read(rec, op, lockop);
|
|
_last_data = botime;
|
|
return err;
|
|
}
|
|
|
|
int TCli_for::read(char tipo, long codice, word op, word lockop)
|
|
{
|
|
int err = NOERR;
|
|
_ven_rec.zero();
|
|
zero();
|
|
if (tipo > ' ' && codice > 0L)
|
|
{
|
|
put(CLI_TIPOCF, tipo);
|
|
put(CLI_CODCF, codice);
|
|
err = TMultiple_rectype::read(op, lockop);
|
|
}
|
|
_last_data = botime;
|
|
return err;
|
|
}
|
|
|
|
int TCli_for::remove(TBaseisamfile& f) const
|
|
{
|
|
TLocalisamfile v(LF_CFVEN);
|
|
|
|
const int err = vendite().remove(v);
|
|
if (err != NOERR && err != _iskeynotfound)
|
|
return err;
|
|
return TMultiple_rectype:: remove(f);
|
|
}
|
|
|
|
void TCli_for::init()
|
|
{
|
|
_tipo = new TRecfield(*this, CLI_TIPOCF);
|
|
_codice = new TRecfield(*this, CLI_CODCF);
|
|
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
|
|
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
|
|
_use_lettere = main_app().has_module(LIAUT, CHK_DONGLE);
|
|
if (_use_lettere)
|
|
_use_lettere = ini_get_bool(CONFIG_DITTA, "ve", "USELETTERE");
|
|
}
|
|
|
|
void TCli_for::cli2doc(TDocumento & doc)
|
|
{
|
|
const TRectype & v = vendite();
|
|
|
|
doc.put(DOC_CODVAL, get(CLI_CODVAL));
|
|
doc.put(DOC_CODLIN, get(CLI_CODLIN));
|
|
doc.put(DOC_CODPAG, get(CLI_CODPAG));
|
|
doc.put(DOC_CODABIA, get(CLI_CODABI));
|
|
doc.put(DOC_CODCABA, get(CLI_CODCAB));
|
|
doc.put(DOC_IBAN, get(CLI_IBAN));
|
|
doc.put(DOC_CODABIP, v.get(CFV_CODABIPR));
|
|
doc.put(DOC_CODCABP, v.get(CFV_CODCABPR));
|
|
doc.put(DOC_RAGGR, v.get(CFV_RAGGDOC));
|
|
doc.put(DOC_RAGGREFF, v.get(CFV_RAGGEFF));
|
|
doc.put(DOC_CODINDSP, v.get(CFV_CODINDSP));
|
|
doc.put(DOC_CODAG, v.get(CFV_CODAG));
|
|
doc.put(DOC_CODAGVIS, v.get(CFV_CODAG1));
|
|
doc.put(DOC_CODSPMEZZO, v.get(CFV_CODSPMEZZO));
|
|
doc.put(DOC_CODPORTO, v.get(CFV_CODPORTO));
|
|
doc.put(DOC_CODNOTESP1, v.get(CFV_CODNOTESP1));
|
|
doc.put(DOC_CODNOTESP2, v.get(CFV_CODNOTESP2));
|
|
doc.put(DOC_CODNOTE, v.get(CFV_CODNOTE));
|
|
doc.put(DOC_CODVETT1, v.get(CFV_CODVETT1));
|
|
doc.put(DOC_CODVETT2, v.get(CFV_CODVETT2));
|
|
doc.put(DOC_CODVETT3, v.get(CFV_CODVETT3));
|
|
doc.put(DOC_PERCSPINC, v.get(CFV_PERCSPINC));
|
|
doc.put(DOC_ADDBOLLI, v.get(CFV_ADDBOLLI));
|
|
doc.put(DOC_CATVEN, v.get(CFV_CATVEN));
|
|
doc.put(DOC_LIQDIFF, get_int(CLI_ALLEG) == 7 && v.get_bool(CFV_FATTSOSP) ? "X" : "");
|
|
}
|
|
|
|
|
|
TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN),
|
|
_letint(LF_LETINT), _use_lettere(false), _lettera_found(false)
|
|
{
|
|
init();
|
|
add_file(LF_INDSP, IND_CODIND);
|
|
if (tipo > ' ' && codice > 0L)
|
|
read(tipo, codice);
|
|
}
|
|
|
|
TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN),
|
|
_letint(LF_LETINT), _use_lettere(false), _lettera_found(false)
|
|
{
|
|
init();
|
|
add_file(LF_INDSP, IND_CODIND);
|
|
read(rec);
|
|
}
|
|
|
|
TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec),
|
|
_letint(LF_LETINT), _use_lettere(false), _lettera_found(false)
|
|
{
|
|
init();
|
|
}
|
|
|
|
TCli_for::~TCli_for()
|
|
{
|
|
delete _tipo;
|
|
delete _codice;
|
|
delete _ven_tipo;
|
|
delete _ven_codice;
|
|
}
|
|
|