Patch level : 12.0

Files correlati     : 

Aggiunta cache di causali

git-svn-id: svn://10.65.10.50/branches/R_10_00@23449 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
bonazzi 2016-12-13 13:58:20 +00:00
parent ef13152d92
commit 6d6b371937
2 changed files with 58 additions and 9 deletions

View File

@ -97,15 +97,6 @@ STRING G_DESBANCA 50
BEGIN
PROMPT 28 1 ""
FLAGS "D"
/*
USE %BAN SELECT LF_TAB->CODTAB!=''
JOIN BNP INTO CODTAB==CODTAB
DISPLAY "Descrizione@50" S0
DISPLAY "ABI@5" CODTAB[1,5]
DISPLAY "CAB@5" CODTAB[6,10]
COPY OUTPUT G_CAB
CHECKTYPE NORMAL
*/
END
NUMBER G_GRUPPOC 3

View File

@ -3,6 +3,7 @@
#include <config.h>
#include <diction.h>
#include <recarray.h>
#include <relation.h>
#include <tabutil.h>
#include <causali.h>
@ -19,6 +20,7 @@ TCausale::TCausale(const char* cod, int year)
_sezione_ritsoc(' '), _sezione_ritfis(' '), _sezione_revcharge(' ')
{
_regolarizzazione = 0x2;
if (cod && *cod)
read(cod, year);
}
@ -130,6 +132,23 @@ bool TCausale::soloiva() const
int TCausale::regime_speciale() const
{ return _rec.get_int(CAU_REGSPIVA); }
bool TCausale::regolarizzazione()
{
if ((int) _regolarizzazione == 0x2)
{
_regolarizzazione = false;
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();
}
}
return _regolarizzazione != 0;
}
bool TCausale::reverse_charge() const
{
const int rsi = regime_speciale();
@ -317,3 +336,42 @@ bool TCausale::IVA2bill(const TCodiceIVA& iva, TBill& c) const
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 anno)
{
HIDDEN TCache_causale __cache_causale;
return __cache_causale.caus(codcaus, anno);
}