2Patch level : 12.0 972
Files correlati : cg1.3x3 cg1500a.msk cg1600a.msk Commento : Sampa bilanco e bilancio IV direttiva per data competenza costi/ricavi
This commit is contained in:
parent
50628e2df5
commit
390ad54a8c
@ -1,13 +1,13 @@
|
||||
// Esercizi contabili e registri IVA
|
||||
|
||||
#include "cglib01.h"
|
||||
#include "cglib.h"
|
||||
|
||||
#include <config.h>
|
||||
#include <diction.h>
|
||||
#include <mask.h>
|
||||
#include <tabutil.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <relation.h>
|
||||
#include <tabutil.h>
|
||||
|
||||
#include <clifo.h>
|
||||
#include <comuni.h>
|
||||
@ -18,7 +18,457 @@
|
||||
#include <rmoviva.h>
|
||||
#include <rmov.h>
|
||||
|
||||
#include "comuni.h"
|
||||
#include <comuni.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Causale
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TCausale::TCausale(const char* cod, int year)
|
||||
: TArray(12), _rec(LF_CAUSALI),
|
||||
_iva(iva_errata), _corrisp(false),
|
||||
_sezione_clifo(' '), _provvisorio(' '),
|
||||
_sezione_ritsoc(' '), _sezione_ritfis(' '), _sezione_revcharge(' '),
|
||||
_regolarizzazione(false)
|
||||
|
||||
|
||||
{
|
||||
if (cod && *cod)
|
||||
read(cod, year);
|
||||
if (soloiva())
|
||||
{
|
||||
TCursor c(new TRelation(LF_CAUSALI));
|
||||
int items = c.items();
|
||||
|
||||
for (c = 0L; c.pos() < items && !_regolarizzazione; ++c)
|
||||
_regolarizzazione = c.curr().get(CAU_CODCAUREG) == codice();
|
||||
}
|
||||
}
|
||||
|
||||
bool TCausale::reread()
|
||||
{
|
||||
const TString4 cod = codice();
|
||||
|
||||
if (cod.full())
|
||||
{
|
||||
const int year = _reg.year();
|
||||
|
||||
if (year > 0)
|
||||
return read(cod, year);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Legge le righe della causale attualmente selezionata sulla maschera
|
||||
bool TCausale::read(const char* cod, int year)
|
||||
{
|
||||
_rec.zero(); // Delete header
|
||||
destroy(); // Delete all rows
|
||||
_iva = iva_errata; // Delete misc info
|
||||
_sezione_clifo = _sezione_ritsoc = _provvisorio = ' ';
|
||||
_corrisp = false;
|
||||
|
||||
if (cod && *cod > ' ')
|
||||
{
|
||||
_rec = cache().get(LF_CAUSALI, cod);
|
||||
if (_rec.empty())
|
||||
return false;
|
||||
|
||||
_provvisorio = _rec.get_char(CAU_PROVV);
|
||||
TLocalisamfile rcaus(LF_RCAUSALI);
|
||||
rcaus.put(CAU_CODCAUS, cod);
|
||||
rcaus.put(CAU_NRIGA, 0);
|
||||
|
||||
int err;
|
||||
for (err = rcaus.read(_isgteq); // Find first line
|
||||
err == NOERR && rcaus.get(CAU_CODCAUS) == cod;
|
||||
err = rcaus.next()) // Read next line
|
||||
{
|
||||
const int riga = rcaus.get_int(CAU_NRIGA);
|
||||
add(rcaus.curr(), riga);
|
||||
}
|
||||
|
||||
const TString4 codreg(_rec.get(CAU_REG));
|
||||
const bool ok = _reg.read(codreg, year); // Read register
|
||||
if (!ok && codreg.not_empty())
|
||||
return error_box(FR("Non esiste il registro '%s' del %d"),
|
||||
(const char*)codreg, year);
|
||||
calcIVA();
|
||||
}
|
||||
else
|
||||
{
|
||||
_iva = nessuna_iva; // Clear IVA data
|
||||
_corrisp = false;
|
||||
_reg.read("", year);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TBill& TCausale::bill(int num, TBill& conto) const
|
||||
{
|
||||
const TRectype* rec = row(num);
|
||||
|
||||
if (rec != nullptr)
|
||||
conto.set(rec->get_int(RCA_GRUPPO), rec->get_int(RCA_CONTO),
|
||||
rec->get_long(RCA_SOTTOCONTO), rec->get_char(RCA_TIPOCF));
|
||||
return conto;
|
||||
}
|
||||
|
||||
const char* TCausale::cod_desc_agg(int num) const
|
||||
{
|
||||
const TRectype* rec = row(num);
|
||||
if (rec)
|
||||
return rec->get(RCA_CODDESC);
|
||||
return ""; // ho problemi con ? :
|
||||
}
|
||||
|
||||
const char* TCausale::desc_agg(int num) const
|
||||
{
|
||||
const char* cod = cod_desc_agg(num);
|
||||
if (cod && *cod)
|
||||
return cache().get("%DPN", cod, "S0");
|
||||
return ""; // ho problemi con ? :
|
||||
}
|
||||
|
||||
const char* TCausale::descrizione() const
|
||||
{
|
||||
return _rec.get(CAU_DESCR);
|
||||
}
|
||||
|
||||
const char* TCausale::codice() const
|
||||
{
|
||||
return _rec.get(CAU_CODCAUS);
|
||||
}
|
||||
|
||||
bool TCausale::data_doc() const
|
||||
{
|
||||
return _rec.get_bool(CAU_DATADOC);
|
||||
}
|
||||
|
||||
bool TCausale::num_doc() const
|
||||
{
|
||||
return _rec.get_bool(CAU_NUMDOC);
|
||||
}
|
||||
|
||||
bool TCausale::apertura() const
|
||||
{
|
||||
return _rec.get_char(CAU_MOVAP) == 'A';
|
||||
}
|
||||
|
||||
bool TCausale::chiusura() const
|
||||
{
|
||||
return _rec.get_char(CAU_MOVAP) == 'C';
|
||||
}
|
||||
|
||||
bool TCausale::sezionale() const
|
||||
{
|
||||
return _rec.get_bool(CAU_MOVSEZ);
|
||||
}
|
||||
|
||||
bool TCausale::valuta() const
|
||||
{
|
||||
return _rec.get_bool(CAU_MOVVAL);
|
||||
}
|
||||
|
||||
bool TCausale::intra() const
|
||||
{
|
||||
return _rec.get_bool(CAU_INTRACOM);
|
||||
}
|
||||
|
||||
bool TCausale::valintra() const
|
||||
{
|
||||
return _rec.get_bool(CAU_VALINTRA);
|
||||
}
|
||||
|
||||
bool TCausale::soloiva() const
|
||||
{
|
||||
return _rec.get_bool(CAU_SOLOIVA);
|
||||
}
|
||||
|
||||
int TCausale::regime_speciale() const
|
||||
{
|
||||
return _rec.get_int(CAU_REGSPIVA);
|
||||
}
|
||||
|
||||
bool TCausale::regolarizzazione() const
|
||||
{
|
||||
return _regolarizzazione;
|
||||
}
|
||||
|
||||
bool TCausale::ril_fat_em_ric() const
|
||||
{
|
||||
return _rec.get_bool(CAU_RILFTEMRI);
|
||||
}
|
||||
|
||||
bool TCausale::datareg_prec() const
|
||||
{
|
||||
return _rec.get_bool(CAU_DATAREGPR);
|
||||
}
|
||||
|
||||
bool TCausale::reverse_charge() const
|
||||
{
|
||||
const int rsi = regime_speciale();
|
||||
return (rsi >= 13 && rsi <= 18) || rsi == 50 || rsi == 51; // Reverse charge!
|
||||
}
|
||||
|
||||
bool TCausale::reverse_charge_pubb() const
|
||||
{
|
||||
const int rsi = regime_speciale();
|
||||
return (rsi >= 13 && rsi <= 19) || rsi == 50 || rsi == 51; // Reverse charge!
|
||||
}
|
||||
|
||||
bool TCausale::esclusione_allegati() const
|
||||
{
|
||||
return _rec.get_bool(CAU_ALLEG);
|
||||
}
|
||||
|
||||
const TString& TCausale::causale_collegata() const
|
||||
{
|
||||
return _rec.get(CAU_CODCAUSIM);
|
||||
}
|
||||
|
||||
const TString& TCausale::causale_reg_iva() const
|
||||
{
|
||||
return _rec.get(CAU_CODCAUREG);
|
||||
}
|
||||
|
||||
const TString& TCausale::tipo_doc() const
|
||||
{
|
||||
return _rec.get(CAU_TIPODOC);
|
||||
}
|
||||
|
||||
tipo_movimento TCausale::tipomov() const
|
||||
{
|
||||
return tipo_movimento(_rec.get_int(CAU_TIPOMOV));
|
||||
}
|
||||
|
||||
const TString& TCausale::tipodoc() const
|
||||
{
|
||||
return _rec.get(CAU_TIPODOC);
|
||||
}
|
||||
|
||||
bool TCausale::saldaconto(const TDate& datareg) const
|
||||
{
|
||||
bool yes = tipomov() > 0;
|
||||
if (yes && datareg.ok())
|
||||
{
|
||||
static TDate _data_sal = ini_get_string(CONFIG_DITTA, "cg", "DatSal");
|
||||
yes = datareg >= _data_sal;
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
int TCausale::link_m770() const
|
||||
{
|
||||
return _rec.get_int(CAU_M770);
|
||||
}
|
||||
|
||||
char TCausale::link_cespiti() const
|
||||
{
|
||||
return _rec.get_char(CAU_COLLCESP);
|
||||
}
|
||||
|
||||
bool TCausale::link_analitica() const
|
||||
{
|
||||
return _rec.get_bool(CAU_MOVIND);
|
||||
}
|
||||
|
||||
bool TCausale::link_industriale() const
|
||||
{
|
||||
return _rec.exist(CAU_MOVCGIND) && _rec.get_bool(CAU_MOVCGIND);
|
||||
}
|
||||
|
||||
bool TCausale::ok() const
|
||||
{
|
||||
return iva() != iva_errata;
|
||||
}
|
||||
|
||||
char TCausale::sezione(int riga, bool low_level) const
|
||||
{
|
||||
const TRectype* rec = row(riga);
|
||||
char sez = rec ? toupper(rec->get_char(RCA_SEZIONE)) : ' ';
|
||||
if (sez <= ' ' && !low_level) // Guess section on tipocf
|
||||
{
|
||||
const TRectype* uno = row(1);
|
||||
char tipocf = uno ? toupper(uno->get_char(RCA_TIPOCF)) : ' ';
|
||||
if (tipocf <= ' ')
|
||||
tipocf = (iva() == iva_vendite) ? 'C' : 'F'; // Guess tipocf on IVA
|
||||
sez = (tipocf == 'C') ? 'D' : 'A';
|
||||
}
|
||||
return sez;
|
||||
}
|
||||
|
||||
char TCausale::sezione_clifo() const
|
||||
{
|
||||
if (_sezione_clifo <= ' ')
|
||||
(char&)_sezione_clifo = sezione(1);
|
||||
return _sezione_clifo;
|
||||
}
|
||||
|
||||
char TCausale::sezione_ritsoc() const
|
||||
{
|
||||
if (_sezione_ritsoc <= ' ')
|
||||
{
|
||||
const tipo_movimento tm = tipomov();
|
||||
(char&)_sezione_ritsoc = sezione(tm <= tm_nota_credito ? RIGA_RITENUTE_SOCIALI : RIGA_PAG_RITSOC, true);
|
||||
if (_sezione_ritsoc < 'A')
|
||||
(char&)_sezione_ritsoc = (tm <= tm_nota_credito ? sezione_clifo() : (sezione_clifo() == 'D' ? 'A' : 'D'));
|
||||
}
|
||||
return _sezione_ritsoc;
|
||||
}
|
||||
|
||||
char TCausale::sezione_ritfis() const
|
||||
{
|
||||
if (_sezione_ritfis == ' ')
|
||||
{
|
||||
const tipo_movimento tm = tipomov();
|
||||
(char&)_sezione_ritfis = sezione(tm <= tm_nota_credito ? RIGA_RITENUTE_FISCALI : RIGA_PAG_RITFIS, true); // Fatture o Pagamenti
|
||||
if (_sezione_ritfis < 'A')
|
||||
(char&)_sezione_ritfis = (tm <= tm_nota_credito ? sezione_clifo() : (sezione_clifo() == 'D' ? 'A' : 'D'));
|
||||
}
|
||||
return _sezione_ritfis;
|
||||
}
|
||||
|
||||
char TCausale::sezione_revcharge() const
|
||||
{
|
||||
if (_sezione_revcharge <= ' ')
|
||||
{
|
||||
(char&)_sezione_revcharge = sezione(RIGA_REVERSE_CHARGE);
|
||||
if (_sezione_revcharge < 'A')
|
||||
(char&)_sezione_revcharge = sezione_clifo();
|
||||
}
|
||||
return _sezione_revcharge;
|
||||
}
|
||||
|
||||
bool TCausale::fattura_in_ritardo() const
|
||||
{
|
||||
return _rec.get_bool(CAU_RITFATT);
|
||||
}
|
||||
|
||||
|
||||
void TCausale::calcIVA()
|
||||
{
|
||||
TipoIVA i = nessuna_iva; // Tipo IVA di default
|
||||
bool c = false; // Corrispettivi di default
|
||||
|
||||
const TString& td = tipo_doc();
|
||||
if (td.full())
|
||||
{
|
||||
const TRectype& tpd = cache().get("%TPD", td);
|
||||
if (!tpd.empty())
|
||||
{
|
||||
i = (TipoIVA)tpd.get_int("I0"); // IVA acquisti, vendite, generica
|
||||
const TipoIVA ri = _reg.iva();
|
||||
if (i == iva_generica)
|
||||
i = ri;
|
||||
if (i != ri)
|
||||
{
|
||||
error_box(FR("Tipo documento '%s' incompatibile con tipo registro"), (const char*)td);
|
||||
i = iva_errata;
|
||||
}
|
||||
c = tpd.get_bool("B0"); // B0 flag corrispettivi
|
||||
}
|
||||
else
|
||||
error_box(FR("Tipo documento sconosciuto: '%s'"), (const char*)td);
|
||||
}
|
||||
_iva = i;
|
||||
_corrisp = c;
|
||||
}
|
||||
|
||||
const TString& TCausale::compatible(const TCausale& c) const
|
||||
{
|
||||
const char* err = nullptr;
|
||||
|
||||
if (sezionale() != c.sezionale())
|
||||
err = TR("il segnale di sezionale");
|
||||
if (intra() != c.intra())
|
||||
err = TR("la gestione dei movimenti intra");
|
||||
if (valuta() != c.valuta())
|
||||
err = TR("la gestione valuta");
|
||||
if (valintra() != c.valintra())
|
||||
err = TR("la gestione valuta intracomunitaria");
|
||||
if (corrispettivi() != c.corrispettivi())
|
||||
err = TR("la gestione dei corrispettivi");
|
||||
if (iva() != c.iva())
|
||||
err = TR("il tipo di IVA");
|
||||
if (tipomov() != c.tipomov())
|
||||
err = TR("il tipo di movimento");
|
||||
|
||||
if (err != nullptr)
|
||||
{
|
||||
TString& msg = get_tmp_string();
|
||||
|
||||
msg.format(FR("Causale incompatibile per %s"), err);
|
||||
return msg;
|
||||
}
|
||||
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
bool TCausale::IVA2bill(const TCodiceIVA& iva, TBill& c) const
|
||||
{
|
||||
const TString& tipo = iva.tipo();
|
||||
|
||||
if (tipo.not_empty())
|
||||
{
|
||||
if (tipo == "ES") bill(5, c); else
|
||||
if (tipo == "NI") bill(6, c); else
|
||||
if (tipo == "NS") bill(7, c);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCache_causali
|
||||
///////////////////////////////////////////////////////////
|
||||
class TCache_causale : public TCache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key);
|
||||
|
||||
public:
|
||||
const TCausale & caus(const char* key, const int anno = 0);
|
||||
|
||||
TCache_causale() : TCache() { }
|
||||
virtual ~TCache_causale() { }
|
||||
};
|
||||
|
||||
TObject* TCache_causale::key2obj(const char* key)
|
||||
{
|
||||
TToken_string k(key);
|
||||
TString4 cod;
|
||||
k.get(0, cod);
|
||||
cod.trim();
|
||||
int year; k.get(1, year);
|
||||
return new TCausale(cod, year);
|
||||
}
|
||||
|
||||
const TCausale & TCache_causale::caus(const char* key, const int anno)
|
||||
{
|
||||
TToken_string k(key);
|
||||
k.add(anno);
|
||||
return (const TCausale &)*objptr(k);
|
||||
}
|
||||
|
||||
const TCausale & cached_causale(const char * codcaus, int year)
|
||||
{
|
||||
HIDDEN TCache_causale __cache_causale;
|
||||
|
||||
return __cache_causale.caus(codcaus, year);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione Tabella esercizi
|
||||
|
@ -16,6 +16,7 @@ protected: // TSortable
|
||||
virtual int compare(const TSortable& s) const;
|
||||
|
||||
public:
|
||||
bool ok() const { return _codice != 0; }
|
||||
int codice() const { return _codice; }
|
||||
const TDate& inizio() const { return _inizio; }
|
||||
const TDate& fine() const { return _fine; }
|
||||
@ -58,6 +59,7 @@ public:
|
||||
int last() const;
|
||||
int last_mag() const;
|
||||
bool exist(int codice) const;
|
||||
bool exist(const TDate & data) const { return exist(date2esc(data)); }
|
||||
bool code2range(int codice, TDate& dal, TDate& al) const;
|
||||
|
||||
TEsercizi_contabili();
|
||||
@ -65,6 +67,8 @@ public:
|
||||
};
|
||||
|
||||
TEsercizi_contabili& esercizi();
|
||||
inline const TEsercizio & esercizio(const TDate & data) { return esercizi().esercizio(data); }
|
||||
inline const TEsercizio& esercizio(int codice) { return esercizi().esercizio(codice); };
|
||||
|
||||
enum TipoIVA
|
||||
{
|
||||
|
@ -5,15 +5,13 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "cglib01.h"
|
||||
#include "cglib02.h"
|
||||
#include "cglib.h"
|
||||
|
||||
#include <diction.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
|
||||
#include <causali.h>
|
||||
#include <mov.h>
|
||||
#include <pconti.h>
|
||||
#include <rmov.h>
|
||||
#include <saldi.h>
|
||||
@ -26,12 +24,28 @@
|
||||
// Cerca l'esercizio precedente di EseCorr
|
||||
// Se EseCorr e' già il primo ritorna 0
|
||||
//
|
||||
|
||||
HIDDEN int EsePre(const int EseCorr)
|
||||
{
|
||||
TEsercizi_contabili esc;
|
||||
return esc.pred(EseCorr);
|
||||
}
|
||||
|
||||
HIDDEN const char * date_field_name(TTipo_data tipo) { return __date_field_name[tipo]; }
|
||||
|
||||
const TDate get_date_mov(const TRectype & mov, TTipo_data tipo_data)
|
||||
{
|
||||
TDate data = mov.get_date(date_field_name(tipo_data));
|
||||
|
||||
if (tipo_data == CostiRicavi && !data.ok())
|
||||
data = mov.get_date(date_field_name(Competenza));
|
||||
#ifdef DBG
|
||||
else
|
||||
int i = 1;
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
// aep e' l'esercizio precedente
|
||||
TSaldi_list::TSaldi_list(int gr, int co, int aec, int aep_par)
|
||||
{
|
||||
@ -183,24 +197,10 @@ real TSaldo::calcola_saldo_iniziale(int g,int c,long s,int indbil, int provv)
|
||||
return _saldo_iniziale;
|
||||
}
|
||||
|
||||
bool TSaldo::leggi_mov(long nr)
|
||||
{
|
||||
const TRectype& mov = cache().get(LF_MOV, nr);
|
||||
const bool ok = !mov.empty();
|
||||
if (ok)
|
||||
{
|
||||
_codcaus = mov.get(MOV_CODCAUS);
|
||||
_datareg = mov.get(MOV_DATAREG);
|
||||
_provv = mov.get(MOV_PROVVIS); // _provv.trim();
|
||||
_datacomp = mov.get(MOV_DATACOMP);
|
||||
}
|
||||
else
|
||||
NFCHECK("Testata assente: %ld", nr);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
//per bilancio scalare (ovvero a sezioni contrapposte) per data limite
|
||||
bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf,
|
||||
bool TSaldo::data_limite_bilancio(TTipo_data tipo_data, int g, int c, long s, const TDate& data_inf,
|
||||
const TDate& data_sup, int indbil, int provv, const char* filter)
|
||||
{
|
||||
_saldo_iniziale = ZERO;
|
||||
@ -225,55 +225,44 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
|
||||
if ((provv & 0x1) && (filter == nullptr || *filter == '\0'))
|
||||
_saldo = calcola_saldo_iniziale(g,c,s,indbil,provv);
|
||||
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
const long num_reg = rmov.get_long(RMV_NUMREG);
|
||||
|
||||
if (!leggi_mov(num_reg)) // Leggo la testata
|
||||
continue; // Evita righe orfane!
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
const long numreg = rmov.get_long(RMV_NUMREG);
|
||||
const TRectype& mov = cache().get(LF_MOV, numreg);
|
||||
const TDate data = get_date_mov(mov, tipo_data);
|
||||
|
||||
TDate data_mov;
|
||||
if (bilancio == DataLimite)
|
||||
data_mov = _datacomp;
|
||||
else
|
||||
{
|
||||
if (_annoes == 0)
|
||||
data_mov = _datareg;
|
||||
else
|
||||
data_mov = _datacomp;
|
||||
}
|
||||
|
||||
if (data_mov < data_inf || data_mov > data_sup)
|
||||
continue;
|
||||
|
||||
// "Se la causale del movimento e' di chiusura,
|
||||
// o di apertura il movimento non va considerato"
|
||||
if (_codcaus.full())
|
||||
{
|
||||
const TString& movap = _causali_apertura.decode(_codcaus);
|
||||
if (movap == "C")
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((provv & 0x1) && _provv.blank()) ||
|
||||
((provv & 0x2) && ((_provv == "P") || (_provv == "N"))) ||
|
||||
((provv & 0x4) && (_provv == "B")) || ((provv & 0x8) && (_provv == "C")))
|
||||
if (data.ok() && data >= data_inf && data <= data_sup)
|
||||
{
|
||||
const char sezione = rmov.get_char(RMV_SEZIONE);
|
||||
const real importo = rmov.get_real(RMV_IMPORTO);
|
||||
const TString8 codcaus = mov.get(MOV_CODCAUS);
|
||||
|
||||
// I mov. di puro riferimento (= con importo = 0) vanno scartati
|
||||
if (importo != ZERO)
|
||||
// "Se la causale del movimento e' di chiusura,
|
||||
// o di apertura il movimento non va considerato"
|
||||
if (codcaus.full())
|
||||
{
|
||||
_movimentato = true;
|
||||
if (sezione == 'D')
|
||||
_saldo += importo;
|
||||
else
|
||||
_saldo -= importo;
|
||||
const TString& movap = _causali_apertura.decode(codcaus);
|
||||
if (movap == "C")
|
||||
continue;
|
||||
}
|
||||
|
||||
const TString4 tipoprovv = mov.get(MOV_PROVVIS);
|
||||
|
||||
if (check_mov(provv, tipoprovv))
|
||||
{
|
||||
const char sezione = rmov.get_char(RMV_SEZIONE);
|
||||
const real importo = rmov.get_real(RMV_IMPORTO);
|
||||
|
||||
// I mov. di puro riferimento (= con importo = 0) vanno scartati
|
||||
if (importo != ZERO)
|
||||
{
|
||||
_movimentato = true;
|
||||
if (sezione == 'D')
|
||||
_saldo += importo;
|
||||
else
|
||||
_saldo -= importo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef DBG
|
||||
xvtil_statbar_refresh();
|
||||
#endif
|
||||
@ -465,7 +454,7 @@ bool TSaldo::ultima_immissione_bilancio(int annoes,int g,int c,long s,int indbil
|
||||
return _movimentato;
|
||||
}
|
||||
|
||||
const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const TDate& al,
|
||||
const real& TSaldo::saldo_periodo(TTipo_data tipo_data, int g, int c, long s, const TDate& dal, const TDate& al,
|
||||
int indbil, int provv)
|
||||
|
||||
{
|
||||
@ -522,27 +511,29 @@ const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const
|
||||
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
p.addstatus(1L);
|
||||
|
||||
const long num_reg = rmov.get_long(RMV_NUMREG);
|
||||
const real importo = rmov.get_real(RMV_IMPORTO);
|
||||
|
||||
if (!importo.is_zero())
|
||||
p.addstatus(1L);
|
||||
|
||||
const real importo = rmov.get_real(RMV_IMPORTO);
|
||||
|
||||
if (importo != ZERO)
|
||||
{
|
||||
const char sezione = rmov.get_char(RMV_SEZIONE);
|
||||
// "Se la causale del movimento e' di chiusura,
|
||||
// o di apertura il movimento non va considerato"
|
||||
leggi_mov(num_reg);
|
||||
const TString& movap = _causali_apertura.decode(_codcaus);
|
||||
const long numreg = rmov.get_long(RMV_NUMREG);
|
||||
const TRectype& mov = cache().get(LF_MOV, numreg);
|
||||
const TDate data = get_date_mov(mov, tipo_data);
|
||||
const TString8 codcaus = mov.get(MOV_CODCAUS);
|
||||
const TString4 tipoprovv = mov.get(MOV_PROVVIS);
|
||||
const TString& movap = _causali_apertura.decode(codcaus);
|
||||
|
||||
if (!((provv & 0x1) || _provv.empty()) && movap.blank()) // ????
|
||||
if (!((provv & 0x1) || tipoprovv.empty()) && movap.blank()) // ????
|
||||
{
|
||||
if (_datacomp >= dal && _datacomp <= al)
|
||||
const char sezione = rmov.get_char(RMV_SEZIONE);
|
||||
|
||||
if (data.ok() && data >= dal && data <= al)
|
||||
{
|
||||
_movimentato = true;
|
||||
const int m = _datacomp.month() - 1;
|
||||
const int m = data.month() - 1;
|
||||
|
||||
if (sezione == 'D')
|
||||
_movimentato = true;
|
||||
if (sezione == 'D')
|
||||
{
|
||||
_prg_dare += importo;
|
||||
_prg_dare_mese[m] += importo;
|
||||
@ -554,7 +545,7 @@ const real& TSaldo::saldo_periodo(int g, int c, long s, const TDate& dal, const
|
||||
}
|
||||
}
|
||||
else
|
||||
if (_datacomp >= inizio && _datacomp < dal)
|
||||
if (data >= inizio && data < dal)
|
||||
{
|
||||
if (sezione == 'D')
|
||||
_saldo_iniziale += importo;
|
||||
@ -616,7 +607,7 @@ bool TSaldo::prg_saldo(int annoes, TConto& conto, real& prgdare, real& prgavere,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TSaldo::saldo_cont_sep(int g, int c, long s, const int codes, TDate al,
|
||||
bool TSaldo::saldo_cont_sep(TTipo_data tipo_data, int g, int c, long s, const int codes, TDate al,
|
||||
int indbil, const char * cont_sep, int provv, bool chiusura, bool first)
|
||||
|
||||
{
|
||||
@ -679,17 +670,14 @@ bool TSaldo::saldo_cont_sep(int g, int c, long s, const int codes, TDate al,
|
||||
{
|
||||
if (( cont_sep != nullptr && *cont_sep == '\0') || mov.get(MOV_CONTSEP) == cont_sep)
|
||||
{
|
||||
_codcaus = mov.get(MOV_CODCAUS);
|
||||
_datareg = mov.get(MOV_DATAREG);
|
||||
_provv = mov.get(MOV_PROVVIS);
|
||||
_datacomp = mov.get(MOV_DATACOMP);
|
||||
const TString& movap = _causali_apertura.decode(_codcaus);
|
||||
const TString8 codcaus = mov.get(MOV_CODCAUS);
|
||||
const TString4 tipoprovv = mov.get(MOV_PROVVIS);
|
||||
const TDate data = get_date_mov(mov, tipo_data);
|
||||
const TString& movap = _causali_apertura.decode(codcaus);
|
||||
|
||||
if (((provv & 0x1) && _provv.empty()) ||
|
||||
((provv & 0x2) && (_provv == "P" || _provv == "N")) ||
|
||||
(provv & 0x4) && (_provv == "B") || (provv & 0x8) && (_provv == "C"))
|
||||
if (check_mov(provv, tipoprovv))
|
||||
{
|
||||
if (_datacomp >= inizio && _datacomp <= al)
|
||||
if (data.ok() && data >= inizio && data <= al)
|
||||
{
|
||||
if (movap.blank())
|
||||
{
|
||||
|
@ -9,8 +9,25 @@
|
||||
|
||||
#ifndef __CGLIB01_H
|
||||
#include "../cg/cglib01.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __MOV_H
|
||||
#include <mov.h>
|
||||
#endif
|
||||
|
||||
#define PROVV "P"
|
||||
#define PROVV_NON_CANC "N"
|
||||
#define PROVV_BIL "B"
|
||||
#define PROVV_CESP "C"
|
||||
|
||||
static const char * __date_field_name[] = { MOV_DATAREG, MOV_DATACOMP, MOV_DATACOMPCR };
|
||||
inline bool check_mov(const int tipomovprovv, const TString & provvis)
|
||||
{
|
||||
return ((tipomovprovv & 0x1) && provvis.blank()) ||
|
||||
((tipomovprovv & 0x2) && ((provvis == PROVV) || (provvis == PROVV_NON_CANC))) ||
|
||||
((tipomovprovv & 0x4) && (provvis == PROVV_BIL)) ||
|
||||
((tipomovprovv & 0x8) && (provvis == PROVV_CESP));
|
||||
}
|
||||
#ifndef __CG2103_H
|
||||
class TCausale;
|
||||
#endif
|
||||
@ -71,8 +88,11 @@ public:
|
||||
TRectype* saldi() const;
|
||||
};
|
||||
|
||||
enum tipobil { DataLimite=1, UltimaImmissione };
|
||||
enum tipobil { DataLimite = 1, UltimaImmissione };
|
||||
enum tiposal { normale, apertura, chiusura };
|
||||
enum TTipo_data { Registrazione, Competenza, CostiRicavi};
|
||||
|
||||
const TDate get_date_mov(const TRectype & mov, TTipo_data tipo_data);
|
||||
|
||||
class TSaldo : public TObject
|
||||
{
|
||||
@ -90,10 +110,6 @@ class TSaldo : public TObject
|
||||
int _annoes;
|
||||
int _indbil;
|
||||
TDate _inizioEs, _fineEs;
|
||||
TString4 _codcaus;
|
||||
TDate _datareg;
|
||||
TDate _datacomp;
|
||||
TString _provv;
|
||||
|
||||
bool _prec;
|
||||
bool _movimentato;
|
||||
@ -129,9 +145,9 @@ public:
|
||||
|
||||
bool ultima_immissione_bilancio(int annoes, int g,int c,long s,int indbil,int provv = 0x1,bool saldo_chiusura = true);
|
||||
bool ultima_immissione_verifica(int annoes, int g,int c,long s,int indbil,int provv = 0x1);
|
||||
bool data_limite_bilancio(int annoes,int g,int c,long s,const TDate& data_inf,const TDate& data_suo,int indbil, int provv = 0x1, const char* filter = nullptr);
|
||||
const real& saldo_periodo(int g, int c, long s, const TDate& dal, const TDate& al, int indbil, int provv = 0x1);
|
||||
bool saldo_cont_sep(int g, int c, long s, const int codes, TDate al, int indbil, const char * cont_sep, int provv = 0x1, bool chiusura = false, bool first = true);
|
||||
bool data_limite_bilancio(TTipo_data tipo_data, int g, int c, long s, const TDate& data_inf, const TDate& data_suo, int indbil, int provv = 0x1, const char* filter = nullptr);
|
||||
const real& saldo_periodo(TTipo_data tipo_data, int g, int c, long s, const TDate& dal, const TDate& al, int indbil, int provv = 0x1);
|
||||
bool saldo_cont_sep(TTipo_data tipo_data, int g, int c, long s, const int codes, TDate al, int indbil, const char * cont_sep, int provv = 0x1, bool chiusura = false, bool first = true);
|
||||
bool ricerca_progr_prec(int, int, int, long);
|
||||
|
||||
real saldofin_esprec(int,int,int,long,bool saldo_chiusura = FALSE, int provv = 0x1);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "cg2103.h"
|
||||
#include "cglib03.h"
|
||||
#include "cglib.h"
|
||||
|
||||
#include <diction.h>
|
||||
#include <dongle.h>
|
||||
@ -108,7 +107,6 @@ int analizza_IVA(const real& imptot, const real& ivatot, const real perc_ind,
|
||||
iva_ind = ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -458,6 +456,13 @@ bool TDociva_array::add_riga(const char* _descrdociva, const real& _importo,cons
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief
|
||||
* \param tipodoc
|
||||
* \param descrdoc
|
||||
* \param totdoc
|
||||
* \return
|
||||
*/
|
||||
bool TTipodoc_array::add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc)
|
||||
{
|
||||
bool found = false;
|
||||
|
@ -3,8 +3,8 @@
|
||||
#ifndef __CGLIB03_H
|
||||
#define __CGLIB03_H
|
||||
|
||||
#ifndef __CG2103_H
|
||||
#include "cg2103.h"
|
||||
#ifndef __CGLIB_H
|
||||
#include "cglib.h"
|
||||
#endif
|
||||
|
||||
#ifndef __TABUTIL_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include "cglib04.h"
|
||||
#include "cglib.h"
|
||||
#include "cgsaldac.h"
|
||||
|
||||
#include <codeb.h> // RED ALERT!
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <relation.h>
|
||||
|
||||
#include "cgsaldac.h"
|
||||
#include "cg2103.h"
|
||||
#include "cglib.h"
|
||||
|
||||
#include <doc.h>
|
||||
#include <mov.h>
|
||||
@ -462,9 +462,9 @@ char TRiga_scadenze::calcola_abbuono(int p, TImporto& abbuono, bool update)
|
||||
if (sign != 0)
|
||||
{
|
||||
if (sign > 0)
|
||||
ap = abbuono.sezione() == 'D' ? 'A' : 'P';
|
||||
ap = abbuono.sezione() == 'D' ? cgrowtype_abbattivo : cgrowtype_abbpassivo;
|
||||
else
|
||||
ap = abbuono.sezione() == 'D' ? 'P' : 'A';
|
||||
ap = abbuono.sezione() == 'D' ? cgrowtype_abbpassivo : cgrowtype_abbattivo;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <recarray.h>
|
||||
#endif
|
||||
|
||||
#ifndef __CGLIB01_H
|
||||
#include "../cg/cglib01.h"
|
||||
#ifndef __CGLIB_H
|
||||
#include "cglib.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PARTITE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user