1995-11-18 11:09:06 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <prefix.h>
|
1994-11-10 14:25:26 +00:00
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
|
|
#include "cg2103.h"
|
|
|
|
|
|
|
|
#include <causali.h>
|
|
|
|
#include <rcausali.h>
|
|
|
|
|
|
|
|
const char* iva2name(TipoIVA iva)
|
|
|
|
{
|
|
|
|
const char* i;
|
|
|
|
switch(iva)
|
|
|
|
{
|
|
|
|
case nessuna_iva:
|
|
|
|
i = "Nessuna IVA"; break;
|
|
|
|
case iva_acquisti:
|
|
|
|
i = "IVA Acquisti"; break;
|
|
|
|
case iva_vendite:
|
|
|
|
i = "IVA Vendite"; break;
|
|
|
|
case iva_generica:
|
|
|
|
i = "IVA Generica"; break;
|
|
|
|
default:
|
|
|
|
i = "IVA ERRATA!"; break;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Registro
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TRegistro::TRegistro(const char* cod, int year) : _rec(LF_TAB), _att(LF_ATTIV)
|
|
|
|
{
|
|
|
|
read(cod, year);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TRegistro::read(const char* cod, int year)
|
|
|
|
{
|
|
|
|
if (year <= 0)
|
|
|
|
{
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
year = oggi.year();
|
|
|
|
}
|
|
|
|
|
|
|
|
int err = ~NOERR;
|
|
|
|
|
|
|
|
TTable reg("REG");
|
1994-12-05 14:21:36 +00:00
|
|
|
reg.setkey(1);
|
1994-11-10 14:25:26 +00:00
|
|
|
if (cod && *cod > ' ')
|
|
|
|
{
|
|
|
|
TString16 chiave; chiave.format("%04d%s", year, cod);
|
|
|
|
reg.put("CODTAB", chiave);
|
|
|
|
err = reg.read();
|
|
|
|
}
|
|
|
|
_rec = reg.curr();
|
|
|
|
|
|
|
|
if (err != NOERR)
|
|
|
|
_rec.zero();
|
1994-12-13 13:49:49 +00:00
|
|
|
read_att();
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
return err == NOERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRegistro::reread()
|
|
|
|
{
|
|
|
|
if (ok())
|
|
|
|
{
|
|
|
|
const TString16 n(name());
|
|
|
|
const int y = year();
|
|
|
|
return read(n, y);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TRegistro::year() const
|
|
|
|
{
|
1994-12-07 11:08:53 +00:00
|
|
|
TString16 anno(_rec.get("CODTAB"));
|
|
|
|
anno.cut(4);
|
|
|
|
return atoi(anno);
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TString& TRegistro::name() const
|
|
|
|
{
|
1994-12-07 11:08:53 +00:00
|
|
|
return _rec.get("CODTAB").mid(4);
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TRegistro& TRegistro::operator =(const TRegistro& r)
|
|
|
|
{
|
|
|
|
_rec = r._rec;
|
|
|
|
_att = r._att;
|
|
|
|
_prorata = r._prorata;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int TRegistro::tipo() const
|
|
|
|
{
|
1994-12-07 11:08:53 +00:00
|
|
|
const int t = _rec.get_int("I0");
|
1994-11-10 14:25:26 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TRegistro::corrispettivi() const
|
|
|
|
{
|
1994-12-07 11:08:53 +00:00
|
|
|
const bool c = _rec.get_bool("B0");
|
1994-11-10 14:25:26 +00:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TipoIVA TRegistro::iva() const
|
|
|
|
{
|
|
|
|
TipoIVA i = (TipoIVA)tipo();
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case nessuna_iva:
|
|
|
|
case iva_vendite:
|
|
|
|
case iva_acquisti:
|
|
|
|
break;
|
|
|
|
case libro_giornale:
|
|
|
|
i = nessuna_iva;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error_box("Il registro '%s' non e' un registro IVA o contabile: tipo %d",
|
|
|
|
(const char*)name(), i);
|
|
|
|
i = nessuna_iva;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRegistro::read_att()
|
|
|
|
{
|
|
|
|
if (!_att.empty())
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
TLocalisamfile attiv(LF_ATTIV);
|
1994-12-05 14:21:36 +00:00
|
|
|
attiv.setkey(1);
|
1995-11-18 11:09:06 +00:00
|
|
|
attiv.put("CODDITTA", prefix().get_codditta());
|
1994-11-10 14:25:26 +00:00
|
|
|
attiv.put("CODATT", attivita());
|
|
|
|
const int err = attiv.read();
|
|
|
|
_att = attiv.curr();
|
|
|
|
if (err != NOERR)
|
|
|
|
_att.zero();
|
1994-12-02 13:28:21 +00:00
|
|
|
|
1995-02-13 17:20:26 +00:00
|
|
|
TString16 chiave; // Ditta - Anno - Attivita' - Tipo Attivita' (fissata a 1)
|
1995-11-18 11:09:06 +00:00
|
|
|
chiave.format("%05ld", prefix().get_codditta());
|
1994-12-02 13:28:21 +00:00
|
|
|
chiave << year(); // non fare << year() << attivita()
|
|
|
|
chiave << attivita() << "1";
|
|
|
|
|
1995-02-13 17:20:26 +00:00
|
|
|
TTable pla("%PLA");
|
1995-01-16 15:08:33 +00:00
|
|
|
attiv.setkey(1);
|
1994-12-02 13:28:21 +00:00
|
|
|
pla.put("CODTAB", chiave);
|
|
|
|
if (pla.read() == NOERR)
|
|
|
|
{
|
|
|
|
_prorata = pla.get_real("R8");
|
|
|
|
_att.put("TIPOATT", pla.get("S7")); // Aggiorna tipo attivita'
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_prorata = 0.0;
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
return err == NOERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRegistro::agenzia_viaggi()
|
|
|
|
{
|
|
|
|
bool av = FALSE;
|
1995-03-09 12:00:59 +00:00
|
|
|
if (iva() == iva_vendite)
|
1994-11-10 14:25:26 +00:00
|
|
|
av = _att.get_bool("REG74TER");
|
|
|
|
return av;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TString& TRegistro::tipo_attivita()
|
|
|
|
{
|
|
|
|
return _att.get("TIPOATT");
|
|
|
|
}
|
|
|
|
|
1994-12-02 13:28:21 +00:00
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
const real& TRegistro::prorata()
|
|
|
|
{
|
|
|
|
return _prorata;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Certified 99%
|
|
|
|
bool TRegistro::update(long protiva, const TDate& datareg)
|
|
|
|
{
|
|
|
|
bool updated = TRUE;
|
|
|
|
|
|
|
|
if (protiva > _rec.get_long("I5"))
|
|
|
|
{
|
|
|
|
_rec.put("I5", protiva);
|
|
|
|
updated = FALSE;
|
|
|
|
}
|
|
|
|
if (datareg > _rec.get_date("D2"))
|
|
|
|
{
|
|
|
|
_rec.put("D2", datareg);
|
|
|
|
updated = FALSE;
|
|
|
|
}
|
|
|
|
if (!updated)
|
|
|
|
{
|
|
|
|
TTable reg("REG");
|
|
|
|
updated = reg.rewrite(_rec) == NOERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Libro giornale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Legge il libro giornale dell'anno specificato
|
|
|
|
bool TLibro_giornale::read(int y)
|
|
|
|
{
|
1994-12-05 14:21:36 +00:00
|
|
|
bool found = FALSE;
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
if (y <= 0)
|
|
|
|
{
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
y = oggi.year();
|
|
|
|
}
|
|
|
|
|
|
|
|
TString16 anno; anno.format("%04d", y);
|
1994-12-05 14:21:36 +00:00
|
|
|
TTable reg("REG");
|
1994-11-10 14:25:26 +00:00
|
|
|
reg.setkey(1);
|
|
|
|
reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y
|
|
|
|
|
|
|
|
for (int err = reg.read(_isgteq); err == NOERR; err = reg.next())
|
|
|
|
{
|
1995-03-08 13:23:55 +00:00
|
|
|
//if (reg.get("CODTAB").compare(anno, 4) != 0) break;
|
1994-11-10 14:25:26 +00:00
|
|
|
if (reg.get_int("I0") == libro_giornale)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) reg.zero(); // Memorizza record (anche vuoto)
|
|
|
|
_rec = reg.curr();
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
TLibro_giornale::TLibro_giornale(int y)
|
|
|
|
{
|
|
|
|
read(y);
|
|
|
|
}
|
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Codice IVA
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM)
|
|
|
|
{
|
|
|
|
read(cod);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TCodiceIVA::read(const char* cod)
|
|
|
|
{
|
|
|
|
int err = ~NOERR;
|
|
|
|
if (cod && *cod)
|
|
|
|
{
|
|
|
|
TTable iva("%IVA");
|
|
|
|
iva.put("CODTAB", cod);
|
|
|
|
err = iva.read();
|
|
|
|
TRectype::operator=(iva.curr());
|
|
|
|
}
|
|
|
|
if (err != NOERR)
|
|
|
|
zero();
|
|
|
|
return err == NOERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
real TCodiceIVA::scorpora(real& imponibile) const
|
|
|
|
{
|
|
|
|
const real percent = percentuale();
|
|
|
|
real imposta = abs(imponibile) * percent / (percent + 100.0); imposta.ceil();
|
|
|
|
if (imponibile.sign() < 0) imposta = -imposta;
|
|
|
|
imponibile -= imposta;
|
|
|
|
return imposta;
|
|
|
|
}
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Causale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TCausale::TCausale(const char* cod, int year)
|
1994-12-05 14:21:36 +00:00
|
|
|
: TArray(12), _rec(LF_CAUSALI),
|
|
|
|
_iva(iva_errata), _corrisp(FALSE),
|
|
|
|
_sezione_clifo(' '), _sezione_ritsoc(' ')
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
if (*cod) read(cod, year);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Legge le righe della causale attualmente selezionata sulla maschera
|
|
|
|
bool TCausale::read(const char* cod, int year)
|
|
|
|
{
|
1995-11-23 14:20:03 +00:00
|
|
|
_rec.zero(); // Delete header
|
1994-11-10 14:25:26 +00:00
|
|
|
destroy(); // Delete all rows
|
|
|
|
_iva = iva_errata; // Delete misc info
|
|
|
|
_sezione_clifo = _sezione_ritsoc = ' ';
|
|
|
|
_corrisp = FALSE;
|
|
|
|
|
|
|
|
if (*cod > ' ')
|
|
|
|
{
|
1995-12-13 15:12:13 +00:00
|
|
|
TLocalisamfile caus(LF_CAUSALI);
|
1994-11-10 14:25:26 +00:00
|
|
|
caus.put(CAU_CODCAUS, cod);
|
|
|
|
|
|
|
|
int err = caus.read();
|
1995-12-13 15:12:13 +00:00
|
|
|
if (err != NOERR)
|
|
|
|
return FALSE;
|
1994-11-10 14:25:26 +00:00
|
|
|
_rec = caus.curr();
|
|
|
|
|
|
|
|
TLocalisamfile rcaus(LF_RCAUSALI);
|
|
|
|
rcaus.put(CAU_CODCAUS, cod);
|
|
|
|
rcaus.put(CAU_NRIGA, 0);
|
|
|
|
|
1994-11-15 17:13:31 +00:00
|
|
|
for (err = rcaus.read(_isgteq); // Find first line
|
|
|
|
err == NOERR && rcaus.get(CAU_CODCAUS) == cod;
|
|
|
|
err = rcaus.next() // Read next line
|
|
|
|
)
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
const int riga = rcaus.get_int(CAU_NRIGA);
|
|
|
|
add(rcaus.curr(), riga);
|
|
|
|
}
|
1995-12-13 15:12:13 +00:00
|
|
|
|
|
|
|
/*
|
1994-11-10 14:25:26 +00:00
|
|
|
rcaus.zero();
|
|
|
|
for (int riga = 1; riga < size(); riga++) // Fill gaps
|
1995-12-13 15:12:13 +00:00
|
|
|
if (row(riga) == NULL) add(rcaus.curr(), riga);
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TString codreg(caus.get(CAU_REG));
|
1994-11-10 14:25:26 +00:00
|
|
|
const bool ok = _reg.read(codreg, year); // Read register
|
|
|
|
if (!ok && codreg.not_empty())
|
|
|
|
return error_box("Non esiste il registro '%s' per l'anno %d",
|
|
|
|
(const char*)codreg, year);
|
1994-12-05 14:21:36 +00:00
|
|
|
calcIVA();
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_iva = nessuna_iva; // Clear IVA data
|
|
|
|
_corrisp = FALSE;
|
|
|
|
_reg.read("", year);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TBill& TCausale::bill(int num, TBill& conto) const
|
|
|
|
{
|
1995-12-13 15:12:13 +00:00
|
|
|
const TRectype* rec = row(num);
|
1994-11-11 18:03:21 +00:00
|
|
|
if (rec != NULL)
|
|
|
|
conto.set(rec->get_int(RCA_GRUPPO), rec->get_int(RCA_CONTO),
|
|
|
|
rec->get_long(RCA_SOTTOCONTO), rec->get_char(RCA_TIPOCF));
|
1994-11-10 14:25:26 +00:00
|
|
|
return conto;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* TCausale::desc_agg(int num) const
|
1995-12-13 15:12:13 +00:00
|
|
|
{
|
|
|
|
const char* deag = "";
|
|
|
|
|
|
|
|
const TRectype* rec = row(num);
|
|
|
|
if (rec != NULL)
|
|
|
|
{
|
|
|
|
const TString& cod = rec->get(RCA_CODDESC);
|
|
|
|
if (cod.not_empty())
|
|
|
|
{
|
|
|
|
TTable da("%DPN");
|
|
|
|
da.put("CODTAB", cod);
|
|
|
|
if (da.read() == NOERR)
|
|
|
|
deag = da.get("S0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return deag;
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* TCausale::descrizione() const
|
1994-12-07 11:08:53 +00:00
|
|
|
{ return _rec.get(CAU_DESCR); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
const char* TCausale::codice() const
|
1994-12-07 11:08:53 +00:00
|
|
|
{ return _rec.get(CAU_CODCAUS); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool TCausale::data_doc() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_DATADOC); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool TCausale::num_doc() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_NUMDOC); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool TCausale::apertura() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_char(CAU_MOVAP) == 'A'; }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1996-05-20 09:26:39 +00:00
|
|
|
bool TCausale::chiusura() const
|
|
|
|
{ return _rec.get_char(CAU_MOVAP) == 'C'; }
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
bool TCausale::sezionale() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_MOVSEZ); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool TCausale::valuta() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_MOVVAL); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool TCausale::intra() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_INTRACOM); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool TCausale::valintra() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_bool(CAU_VALINTRA); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
const TString& TCausale::causale_inc_imm() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get(CAU_CODCAUSIM); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
const TString& TCausale::tipo_doc() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get(CAU_TIPODOC); }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-03-27 14:35:06 +00:00
|
|
|
int TCausale::tipomov() const
|
1995-06-01 09:07:09 +00:00
|
|
|
{ return _rec.get_int(CAU_TIPOMOV); }
|
1995-03-27 14:35:06 +00:00
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
bool TCausale::saldaconto() const
|
1995-03-27 14:35:06 +00:00
|
|
|
{ return tipomov() > 0; }
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-06-01 09:07:09 +00:00
|
|
|
int TCausale::link_m770() const
|
|
|
|
{ return _rec.get_int(CAU_M770); }
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
bool TCausale::ok() const
|
|
|
|
{
|
|
|
|
if (iva() == iva_errata)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (corrispettivi() != reg().corrispettivi())
|
|
|
|
return error_box("Tipo documento e registro incongruenti per i corrispettivi");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-03-09 12:00:59 +00:00
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
char TCausale::sezione(int riga) const
|
1995-12-13 15:12:13 +00:00
|
|
|
{
|
|
|
|
const TRectype* rec = row(riga);
|
|
|
|
char sez = rec ? toupper(rec->get_char(RCA_SEZIONE)) : ' ';
|
1994-11-10 14:25:26 +00:00
|
|
|
if (sez <= ' ') // Guess section on tipocf
|
|
|
|
{
|
1995-12-13 15:12:13 +00:00
|
|
|
const TRectype* uno = row(1);
|
|
|
|
char tipocf = uno ? toupper(uno->get_char(RCA_TIPOCF)) : ' ';
|
1994-11-10 14:25:26 +00:00
|
|
|
if (tipocf <= ' ')
|
|
|
|
tipocf = (iva() == iva_vendite) ? 'C' : 'F'; // Guess tipocf on IVA
|
|
|
|
sez = (tipocf == 'C') ? 'D' : 'A';
|
|
|
|
}
|
|
|
|
return sez;
|
|
|
|
}
|
|
|
|
|
|
|
|
char TCausale::sezione_clifo()
|
|
|
|
{
|
|
|
|
if (_sezione_clifo == ' ')
|
|
|
|
_sezione_clifo = sezione(1);
|
|
|
|
return _sezione_clifo;
|
|
|
|
}
|
|
|
|
|
|
|
|
char TCausale::sezione_ritsoc()
|
|
|
|
{
|
|
|
|
if (_sezione_ritsoc == ' ')
|
|
|
|
_sezione_ritsoc = sezione(9);
|
|
|
|
return _sezione_ritsoc;
|
|
|
|
}
|
|
|
|
|
1994-12-05 14:21:36 +00:00
|
|
|
void TCausale::calcIVA()
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1994-12-05 14:21:36 +00:00
|
|
|
TipoIVA i = nessuna_iva; // Tipo IVA di default
|
|
|
|
bool c = FALSE; // Corrispettivi di default
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
const TString& td = tipo_doc();
|
1995-06-01 09:07:09 +00:00
|
|
|
if (td.not_empty())
|
1994-12-05 14:21:36 +00:00
|
|
|
{
|
|
|
|
TTable tpd("%TPD");
|
1995-06-01 09:07:09 +00:00
|
|
|
tpd.put("CODTAB", td);
|
1994-12-05 14:21:36 +00:00
|
|
|
if (tpd.read() == NOERR)
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1994-12-05 14:21:36 +00:00
|
|
|
i = (TipoIVA)tpd.get_int("I0"); // IVA acquisti, vendite, generica
|
|
|
|
const TipoIVA ri = _reg.iva();
|
|
|
|
if (i == iva_generica)
|
|
|
|
i = ri;
|
|
|
|
if (i != ri)
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1995-06-01 09:07:09 +00:00
|
|
|
error_box("Tipo documento '%s' incompatibile con tipo registro", (const char*)td);
|
1994-12-05 14:21:36 +00:00
|
|
|
i = iva_errata;
|
|
|
|
}
|
|
|
|
c = tpd.get_bool("B0");
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
1995-06-01 09:07:09 +00:00
|
|
|
else error_box("Tipo documento sconosciuto: '%s'", (const char*)td);
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
1994-12-05 14:21:36 +00:00
|
|
|
_iva = i;
|
|
|
|
_corrisp = c;
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TCausale::similar(const TCausale& c) const
|
|
|
|
{
|
|
|
|
const char* err = "";
|
|
|
|
if (sezionale() != c.sezionale()) err = "il segnale di sezionale";
|
|
|
|
if (intra() != c.intra()) err = "la gestione dei movimenti intra";
|
|
|
|
if (valuta() != c.valuta()) err = "la gestione valuta";
|
1995-12-29 11:55:59 +00:00
|
|
|
if (valintra() != c.valintra()) err = "la gestione valuta intracomunitaria";
|
1994-11-10 14:25:26 +00:00
|
|
|
if (corrispettivi() != c.corrispettivi()) err = "la gestione dei corrispettivi";
|
1995-12-18 10:56:53 +00:00
|
|
|
if (iva() != c.iva()) err = "il tipo di IVA";
|
|
|
|
if (tipomov() != c.tipomov()) err = "il tipo di movimento";
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
if (*err)
|
|
|
|
error_box("La causale e' diversa per %s", err);
|
|
|
|
|
|
|
|
return *err ? FALSE : TRUE;
|
|
|
|
}
|
1996-01-11 15:44:06 +00:00
|
|
|
|
|
|
|
bool TCausale::IVA2bill(const TCodiceIVA& iva, TBill& c) const
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1996-01-11 15:44:06 +00:00
|
|
|
const TString& tipo = iva.tipo();
|
|
|
|
|
|
|
|
if (tipo.not_empty())
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1996-01-11 15:44:06 +00:00
|
|
|
if (tipo == "ES") bill(5, c); else
|
|
|
|
if (tipo == "NI") bill(6, c); else
|
|
|
|
if (tipo == "NS") bill(7, c);
|
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
if (!c.ok())
|
|
|
|
bill(2, c);
|
|
|
|
|
|
|
|
const int spric = c.tipo_cr();
|
|
|
|
if (spric == 2 || spric == 3)
|
|
|
|
{
|
|
|
|
const TString& td = tipo_doc();
|
|
|
|
if (td == "FV" || td == "NC")
|
|
|
|
c.tipo_cr(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
|