Corretto errore n. 1191 sulla stampa conti

Corretti errori n. MI2014 MI2015 MI2016 MI2020 MI2021 sulla stampa registri


git-svn-id: svn://10.65.10.50/trunk@476 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
nik 1994-10-28 11:33:56 +00:00
parent 86f781e5e8
commit 5e41aa2169
6 changed files with 1070 additions and 396 deletions

View File

@ -23,26 +23,56 @@ const int CODTABLEN = 15;
enum stampe {
completa=1,
con_IV_direttiva=2,
senza_IV_direttiva=3,
con_ana_bil=4,
senza_ana_bil=5
con_IV_direttiva,
senza_IV_direttiva,
completa_bil,
con_ana_bil,
senza_ana_bil
};
extern char __tmp [MAXSTR];
static TFixed_string tmp(__tmp, MAXSTR);
class CG1100_application : public TPrintapp
{
struct bil_ivd
{
char sez;
char let;
char numr[5];
char num[4];
char gruppo[4];
char conto[4];
char sottoc[8];
char descr[52];
char sez_opp;
char let_opp;
char numr_opp[5];
int num_opp;
};
bil_ivd* _bil;
TTable _tab; // tabella codici IV direttiva
TTable _tab_anabil ; // tabella codici analisi di bilancio
TRectype* _rec;
TSort* _sort;
TRelation* _rel;
TMask* _msk;
TParagraph_string * _descr;
const char* _buf;
stampe _tipo_stampa;
bool _salto_pag;
bool _salto_pag,_resetta_righe_stampa;
int _old_gruppo;
int _pcont_reclen;
int _pcont_reclen,_i;
int _cur_c1, _cur_c2;
TString _clivd, _clivdo;
char _sez_da_stamp,_sez_stamp,_let_da_stamp,_let_stamp;
TString _numr_da_stamp,_numr_stamp;
int _gruppo,_conto,_num_da_stamp,_num_stamp,_g_prec,_c_prec;
long _sottoc,_s_prec;
TString _classe_da_stampare,_classe_stampata;
bool _conto_classificato,_sottoc_classificato,_stampa_riga_vuota;
bool _prima_volta;
public:
@ -53,11 +83,13 @@ public:
virtual bool preprocess_print (int,int);
virtual bool preprocess_page (int,int);
virtual print_action postprocess_page (int,int);
virtual void postclose_print ();
virtual bool set_print(int);
void intesta (stampe);
bool elabora_riga(); // decide se fare salto pagina o no
void scegli_cur();
void set_completa ();
@ -65,11 +97,22 @@ public:
void set_senza_IV ();
void set_con_ana ();
void set_senza_ana ();
void init_sort();
const char* descrizione_numero(char, char, int, int);
void setta_righe_descr(TParagraph_string*);
const char * decodifica_codanabil (const char * );
int leggo_sottoc(int,int,long);
void riempi_record(char,char,const TString&,int,int,int,long,const TString&,char,char,const TString&,int);
void set_bil_key(bil_ivd* b, char sezione, char lettera,
const char* numero_romano, int numero,
int gruppo = 0, int conto = 0, long sottoconto = 0L);
void set_bil_val(bil_ivd* b, const char* descr,char sez_opp,char let_opp,
const char* numr_opp,int num_opp);
const char * decodifica_IV_dir (const char * sezivd,
const char * lettivd = "",
int numrivd = 0, int numivd = 0);
void process_link(int id, const char* txt);
CG1100_application() : _tab (TAB_IVD), _tab_anabil (TAB_ANABIL), _clivd(8),
@ -86,6 +129,62 @@ void CG1100_application::process_link(int id, const char* txt)
if (cg0.run()) beep();
}
void CG1100_application::init_sort()
{
_bil = new bil_ivd;
_sort = new TSort (sizeof(bil_ivd));
_sort -> addsortkey ((char*)&(_bil->sez) - (char*)&(_bil->sez),1);
_sort -> addsortkey ((char*)&(_bil->let) - (char*)&(_bil->sez),1);
_sort -> addsortkey ((char*)&(_bil->numr) - (char*)&(_bil->sez),4);
_sort -> addsortkey ((char*)&(_bil->num) - (char*)&(_bil->sez),2);
_sort -> addsortkey ((char*)&(_bil->gruppo) - (char*)&(_bil->sez),3);
_sort -> addsortkey ((char*)&(_bil->conto) - (char*)&(_bil->sez),3);
_sort -> addsortkey ((char*)&(_bil->sottoc) - (char*)&(_bil->sez),6);
_sort->init();
}
void CG1100_application::set_bil_key(bil_ivd* b, char sezione, char lettera,
const char* numero_romano, int numero,
int gruppo, int conto,long sottoconto)
{
b->sez = sezione;
b->let = lettera;
strcpy(b->numr, numero_romano);
sprintf(b->num , "%2d", numero);
sprintf(b->gruppo , "%3d", gruppo);
sprintf(b->conto , "%3d", conto);
sprintf(b->sottoc , "%6ld", sottoconto);
}
void CG1100_application::set_bil_val(bil_ivd* b, const char* descr,
char sez_opp,char let_opp,
const char* numr_opp,int num_opp)
{
strcpy(b->descr, descr);
b->sez_opp = sez_opp;
b->let_opp = let_opp;
strcpy(b->numr_opp, numr_opp);
b->num_opp = num_opp;
}
void CG1100_application::riempi_record(char sez,char let,const TString& numr,
int numero,int g,int c,long s,
const TString& descr,char sez_opp,
char let_opp,const TString& numr_opp,
int num_opp)
{
set_bil_key(_bil, sez, let, numr, numero, g, c, s);
set_bil_val(_bil, descr, sez_opp, let_opp, numr_opp, num_opp);
_sort->sort ((const char*) _bil);
}
void CG1100_application::postclose_print()
{
if (_tipo_stampa == con_IV_direttiva)
delete _sort;
}
print_action CG1100_application::postprocess_page(int file,int counter)
{
switch (_tipo_stampa)
@ -97,10 +196,47 @@ print_action CG1100_application::postprocess_page(int file,int counter)
case con_IV_direttiva:
case con_ana_bil:
{
const char * buf;
if ( (buf = _sort->retrieve()) != NULL)
//const char * buf;
struct bil_ivd* bil = (struct bil_ivd*) _buf;
if (_sez_da_stamp != _sez_stamp)
{
(*_rec) = buf;
if (_sez_da_stamp == '5' || _sez_da_stamp == '9')
{
reset_print();
_i = 1;
set_con_IV();
_resetta_righe_stampa = FALSE;
}
else
_resetta_righe_stampa = TRUE;
}
else
_resetta_righe_stampa = TRUE;
_sez_stamp = _sez_da_stamp;
_let_stamp = _let_da_stamp;
_numr_stamp = _numr_da_stamp;
_num_stamp = _num_da_stamp;
_classe_stampata.format("%c%c%s%2d",_sez_stamp,_let_stamp,(const char*)_numr_stamp,_num_stamp);
if ( (_buf = _sort->retrieve()) != NULL)
{
bil = (struct bil_ivd*) _buf;
_sez_da_stamp = bil->sez;
_let_da_stamp = bil->let;
_numr_da_stamp = bil->numr;
_numr_da_stamp.ltrim();
_num_da_stamp = atoi(bil->num);
_gruppo = atoi(bil->gruppo);
_conto = atoi(bil->conto);
_sottoc = atol(bil->sottoc);
_classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp);
set_auto_ff(FALSE);
return REPEAT_PAGE;
}
break;
@ -114,14 +250,33 @@ print_action CG1100_application::postprocess_page(int file,int counter)
void CG1100_application::set_page(int file,int counter)
{
//const char* buf;
intesta (_tipo_stampa);
switch (_tipo_stampa)
{
case completa:
set_completa();
break;
case con_IV_direttiva:
{
if (_resetta_righe_stampa)
{
reset_print();
_i = 1;
}
if (_sez_da_stamp != _sez_stamp)
{
if (_sez_da_stamp=='1' || _sez_da_stamp=='2')
set_con_IV ();
if (_sez_da_stamp == '5' || _sez_da_stamp == '9')
{
set_row (_i,"%s","");
set_auto_ff(TRUE);
}
}
else
if (_buf != NULL)
set_con_IV();
}
break;
case con_ana_bil:
set_con_ana();
@ -132,9 +287,9 @@ void CG1100_application::set_page(int file,int counter)
case senza_ana_bil:
set_senza_ana();
break;
default:
default:
break;
}
}
}
//////////////////////////////////////////////////////////////
@ -149,17 +304,12 @@ void CG1100_application::scegli_cur()
break;
case con_IV_direttiva:
{
TRecfield sezivd (*_rec, PCN_SEZIVD);
TRecfield lettivd (*_rec, PCN_LETTIVD);
TRecfield numrivd (*_rec, PCN_NUMRIVD);
TRecfield numivd (*_rec, PCN_NUMIVD);
char sez_conto,let_conto;
TString numr_conto;
int num_conto;
bool classe_conto = FALSE;
_sort->addsortkey (sezivd);
_sort->addsortkey (lettivd);
_sort->addsortkey (numrivd);
_sort->addsortkey (numivd);
_sort->init();
init_sort();
select_cursor (_cur_c1);
@ -167,31 +317,68 @@ void CG1100_application::scegli_cur()
TRectype & rec = cursor->curr();
long last = cursor->items();
TString c1(4), c2(4), c3(4), c4(4);
for ( *cursor = 0; cursor->pos() < last; ++(*cursor) )
{
if (rec.get(PCN_CONTO).not_empty() && rec.get(PCN_SOTTOCONTO).empty())
int g = rec.get_int(PCN_GRUPPO);
int c = rec.get_int(PCN_CONTO);
long s = rec.get_int(PCN_SOTTOCONTO);
if (g != 0 && c == 0 && s == 0) continue;
char sez = rec.get_char(PCN_SEZIVD);
char let = rec.get_char(PCN_LETTIVD);
TString numr = rec.get (PCN_NUMRIVD);
int num = rec.get_int (PCN_NUMIVD);
TString descr = rec.get (PCN_DESCR);
char sez_opp = rec.get_char(PCN_SEZIVDOPP);
char let_opp = rec.get_char(PCN_LETTIVDOPP);
TString numr_opp = rec.get (PCN_NUMRIVDOPP);
int num_opp = rec.get_int (PCN_NUMIVDOPP);
if ((g != 0) && (c != 0) && (s == 0))
{
c1 = rec.get(PCN_SEZIVD);
c2 = rec.get(PCN_LETTIVD);
c3 = rec.get(PCN_NUMRIVD);
c4 = rec.get(PCN_NUMIVD);
if (sez != '0')
{
sez_conto = sez;
if (let != '\0')
let_conto = let;
else
if ((sez == '1')||(sez == '2'))
let_conto = 'Z';
else
let_conto = let;
numr_conto = numr;
num_conto = num;
classe_conto = TRUE;
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp);
}
else
if (rec.get(PCN_SOTTOCONTO).not_empty() && rec.get(PCN_SEZIVD).empty())
{
rec.put(PCN_SEZIVD, c1);
rec.put(PCN_LETTIVD, c2);
rec.put(PCN_NUMRIVD, c3);
rec.put(PCN_NUMIVD, c4);
classe_conto = FALSE;
}
if ((g != 0) && (c != 0) && (s != 0))
{
if (classe_conto)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp);
else
{
if (sez != '0')
{
if (let == '\0')
if ((sez == '1')||(sez == '2'))
let = 'Z';
riempi_record(sez,let,numr,num,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp);
}
}
}
if (rec.get_int(PCN_SEZIVD) != 0)
_sort->sort (rec.string());
}
_sort->endsort();
delete _bil;
select_cursor (_cur_c2);
break;
@ -241,103 +428,242 @@ void CG1100_application::scegli_cur()
bool CG1100_application::preprocess_print (int file,int counter)
{
const char * buf;
reset_print();
set_auto_ff (FALSE);
scegli_cur();
//scegli_cur();
switch (_tipo_stampa)
{
case con_IV_direttiva:
case con_ana_bil:
if ((buf = _sort->retrieve()) != NULL)
{
(*_rec) = buf;
struct bil_ivd* bil = (struct bil_ivd*) _buf;
if ((_buf = _sort->retrieve()) != NULL)
{
bil = (struct bil_ivd*) _buf;
_sez_da_stamp = bil->sez;
_let_da_stamp = bil->let;
_numr_da_stamp = bil->numr;
_numr_da_stamp.ltrim();
_num_da_stamp = atoi(bil->num);
_gruppo = atoi(bil->gruppo);
_conto = atoi(bil->conto);
_sottoc = atol(bil->sottoc);
_classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp);
return TRUE;
}
else
return FALSE;
default:
break;
}
break;
default:
break;
}
return TRUE;
}
void CG1100_application::set_con_IV()
{
static char old_sez[3] = "";
struct bil_ivd* bil = (struct bil_ivd*) _buf;
const TString c1(_rec->get(PCN_SEZIVD));
const TString c2(_rec->get(PCN_LETTIVD));
const int c3 = _rec->get_int(PCN_NUMRIVD);
const int c4 = _rec->get_int(PCN_NUMIVD);
TString descrizione,descr;
char sez_opp,let_opp;
int num_opp,numr_opp;
bool stampa_classe = TRUE;
int numr = atoi(_numr_da_stamp);
TString numrom = itor(numr);
int r = 1;
reset_row (1);
reset_row (2);
reset_row (3);
reset_row (4);
if (_rec->get(PCN_SEZIVD) != old_sez)
sez_opp = bil->sez_opp;
let_opp = bil->let_opp;
numr_opp = atoi(bil->numr_opp);
TString numrom_opp = itor(numr_opp);
num_opp = bil->num_opp;
descrizione = descrizione_numero(_sez_da_stamp,_let_da_stamp,numr,_num_da_stamp);
descr = bil->descr;
//Se la classe prelevata dal record corrente del sort e' diversa dalla classe
//prelevata dal record precedente, allora stampo la nuova classe con i relativi
//sottoconti. In caso contrario continuo a stampare solo i sottoconti.
if (_classe_da_stampare != _classe_stampata)
{
if (*old_sez) r++;
strcpy(old_sez, _rec->get(PCN_SEZIVD));
TString dsez(decodifica_IV_dir(c1));
set_row (r++, "%1s@19g%-50s", (const char *) c1, (const char *) dsez);
if (_sez_da_stamp != _sez_stamp)
{
if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE ATTIVI");
set_row (_i++,"@0g%c", app);
stampa_classe = FALSE;
}
else
if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gATTIVO");
set_row (_i++,"@0g%c", app);
}
set_row (r, "@3g%-3s #-8t ", (const char *) c2, &_clivd);
if (c4 != 0) set_row (r, "%2d", c4);
const TString s(decodifica_IV_dir (c1, c2, c3, c4));
if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE PASSIVI");
set_row(_i++,"@0g%c", app);
stampa_classe = FALSE;
}
else
if ((_sez_da_stamp == '2')&&(_let_da_stamp != 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gPASSIVO");
set_row(_i++,"@0g%c", app);
}
set_row (r, "@19g%-40s", (const char *) s);
set_row (r, "@60g$[r]%3d$[n] $[r]%3d$[n] $[r]%6ld$[n]",
_rec->get_int (PCN_GRUPPO), _rec->get_int (PCN_CONTO),
_rec->get_long (PCN_SOTTOCONTO));
if (_sez_da_stamp == '5')
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE");
set_row(_i++,"@0g%c", app);
stampa_classe = FALSE;
}
TParagraph_string s1(_rec->get (PCN_DESCR), 30);
if (_sez_da_stamp == '9')
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTO ECONOMICO");
set_row(_i++,"@0g%c", app);
}
}
else
if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp))
{
if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE ATTIVI");
set_row (_i++,"@0g%c", app);
stampa_classe = FALSE;
}
if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE PASSIVI");
set_row(_i++,"@0g%c", app);
stampa_classe = FALSE;
}
}
set_row (r, "@78g%-30s", s1.get());
if (stampa_classe)
{
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9'))
{
if (_let_da_stamp != ' ')
set_row(_i,"@0g%c", _let_da_stamp);
const TString o1(_rec->get (PCN_SEZIVDOPP));
const TString o2(_rec->get (PCN_LETTIVDOPP));
if (_numr_da_stamp != "")
set_row(_i,"@2g%8s", (const char*) numrom);
set_row (r, "@110g%1s %-3s #-8t ", (const char *) o1, (const char *) o2,
&_clivdo);
if (_num_da_stamp != 0)
set_row(_i,"@11g%2d", _num_da_stamp);
const int o4 = _rec->get_int (PCN_NUMIVDOPP);
*_descr = (const char*) descrizione;
setta_righe_descr(_descr);
}
}
}
set_row (_i,"@58g%3d", _gruppo);
set_row (_i,"@62g%3d", _conto);
if (_sottoc != 0)
set_row (_i,"@66g%6ld", _sottoc);
set_row (_i,"@73g%.40s", (const char*) descr);
if (o4 != 0) set_row (r, "%2d", o4);
if (sez_opp != '0')
{
set_row (_i,"@116g%c", sez_opp);
const char * s2 = s1.get();
if (let_opp != '\0')
set_row (_i,"@118g%c", let_opp);
if (s2)
set_row (++r, "@78g%-30s", s2);
if (numr_opp != 0)
set_row (_i,"@120g%8s", (const char*) numrom_opp);
if (num_opp != 0)
set_row (_i++,"@129g%2d", num_opp);
}
else
_i++;
}
void CG1100_application::setta_righe_descr(TParagraph_string* str)
{
const char* r;
while ((r = str->get()) != NULL)
{
set_row (_i,"@14g%s",r);
_i++;
}
}
void CG1100_application::set_senza_IV()
{
int i;
reset_row (1);
TRectype & rec = current_cursor()->curr();
set_row (1, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]",
int gruppo = rec.get_int (PCN_GRUPPO);
int conto = rec.get_int (PCN_CONTO);
long sottoc = rec.get_long(PCN_SOTTOCONTO);
reset_print ();
i = 1;
if (_prima_volta)
{
_g_prec = gruppo;
_c_prec = conto;
_prima_volta = FALSE;
}
if (sottoc == 0L) // Se si tratta di un conto
{
if (gruppo != _g_prec)
_stampa_riga_vuota = TRUE;
}
else
{
if (gruppo != _g_prec || conto != _c_prec)
_stampa_riga_vuota = TRUE;
}
if (_stampa_riga_vuota)
{
char app = ' ';
set_row (i++,"@0g%c", app);
_stampa_riga_vuota = FALSE;
}
set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]",
FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"),
FLD(LF_PCON, PCN_SOTTOCONTO, "######"));
set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) );
set_row (i, "@16g@50s", FLD(LF_PCON,PCN_DESCR) );
set_row (1, "@69g@1s", FLD(LF_PCON, PCN_SEZIVD) );
set_row (1, "@71g@1s", FLD(LF_PCON, PCN_LETTIVD) );
set_row (1, "@73g#-8t", &_clivd);
set_row (1, "@82g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") );
set_row (1, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") );
set_row (1, "@92g@1s", FLD(LF_PCON, PCN_TMCF) );
set_row (1, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) );
set_row (1, "@107g@f", FLD(LF_PCON, PCN_COMPENS) );
set_row (1, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) );
set_row (1, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) );
set_row (i, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") );
set_row (i, "@92g@1s", FLD(LF_PCON, PCN_TMCF) );
set_row (i, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) );
set_row (i, "@107g@f", FLD(LF_PCON, PCN_COMPENS) );
set_row (i, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) );
set_row (i, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) );
}
void CG1100_application::set_con_ana()
@ -403,26 +729,61 @@ void CG1100_application::set_senza_ana()
void CG1100_application::set_completa()
{
TRectype & rec = current_cursor()->curr();
char sezione;
int i;
reset_row (1);
int gruppo = rec.get_int (PCN_GRUPPO);
int conto = rec.get_int (PCN_CONTO);
long sottoc = rec.get_long(PCN_SOTTOCONTO);
sezione = rec.get_char(PCN_SEZIVD);
TString desc = rec.get(PCN_DESCR);
set_row (1, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]",
if (_prima_volta)
{
_s_prec = 0;
_prima_volta = FALSE;
}
if (sottoc != 0l && _s_prec != 0l)
i = 1;
else
{
i = 1;
char app = ' ';
set_row (i++,"@0g%c", app);
}
reset_print ();
set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]",
FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"),
FLD(LF_PCON, PCN_SOTTOCONTO, "######"));
set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) );
set_row (1, "@69g@1s", FLD(LF_PCON, PCN_SEZIVD) );
set_row (1, "@71g@1s", FLD(LF_PCON, PCN_LETTIVD) );
set_row (1, "@73g#-8t", &_clivd );
set_row (1, "@82g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") );
// set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) );
set_row (i, "@16g%.40s", (const char*) desc);
set_row (1, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") );
set_row (1, "@92g@1s", FLD(LF_PCON, PCN_TMCF) );
set_row (1, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) );
set_row (1, "@107g@f", FLD(LF_PCON, PCN_COMPENS) );
set_row (1, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) );
set_row (1, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) );
if (sezione != '0' && sezione != '9')
set_row (i, "@58g@1s", FLD(LF_PCON, PCN_SEZIVD) );
set_row (i, "@60g@1s", FLD(LF_PCON, PCN_LETTIVD) );
set_row (i, "@62g#-8t", &_clivd );
set_row (i, "@71g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") );
if (conto != 0 && sottoc == 0l)
{
set_row (i, "@76g@pn", FLD(LF_PCON, PCN_INDBIL, "##") );
set_row (i, "@82g@1s", FLD(LF_PCON, PCN_TMCF) );
set_row (i, "@89g@f", FLD(LF_PCON, PCN_STSOTTBIL) );
set_row (i, "@98g@f", FLD(LF_PCON, PCN_COMPENS) );
}
if (sottoc != 0l)
{
set_row (i, "@104g@1n", FLD(LF_PCON, PCN_RICSER) );
set_row (i, "@109g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) );
set_row (i, "@115g@1s", FLD(LF_PCON, PCN_SEZSALDI) );
}
_s_prec = sottoc;
}
bool CG1100_application::elabora_riga()
@ -466,7 +827,7 @@ bool CG1100_application::elabora_riga()
}
// Gestione salto pagina
if (_tipo_stampa == con_ana_bil || _tipo_stampa == con_IV_direttiva)
if (_tipo_stampa == con_ana_bil) // || _tipo_stampa == con_IV_direttiva)
return FALSE;
int new_gruppo = curr_rec.get_int(PCN_GRUPPO);
@ -480,24 +841,104 @@ bool CG1100_application::elabora_riga()
return FALSE;
}
int CG1100_application::leggo_sottoc(int gruppo,int conto,long sottoc)
{
TLocalisamfile pconti (LF_PCON,FALSE);
char sez;
int gr,co;
int esito = 0;
bool esiste_conto_classificato = FALSE;
bool esiste_conto_non_classificato = FALSE;
pconti.zero();
pconti.put(PCN_GRUPPO, gruppo);
pconti.put(PCN_CONTO, conto);
pconti.put(PCN_SOTTOCONTO, sottoc);
for (pconti.read(); !pconti.eof() ;pconti.next())
{
gr = pconti.get_int (PCN_GRUPPO);
co = pconti.get_int (PCN_CONTO);
if (gruppo != gr || conto != co) break;
sez = pconti.get_char(PCN_SEZIVD);
if (sez != '0')
esiste_conto_classificato = TRUE;
if (sez == '0')
esiste_conto_non_classificato = TRUE;
}
if (esiste_conto_classificato && esiste_conto_non_classificato)
esito = 1;
return esito;
}
bool CG1100_application::preprocess_page(int file,int counter)
{
static int c1 = 0;
static TString16 a1;
char sez;
if (_tipo_stampa == completa)
set_completa();
if (_tipo_stampa == senza_IV_direttiva)
{
if (file == LF_PCON)
{
TRectype & rec = current_cursor()->curr();
int gruppo = rec.get_int (PCN_GRUPPO);
int conto = rec.get_int (PCN_CONTO);
long sottoc = rec.get_long(PCN_SOTTOCONTO);
if (rec.get_int(PCN_CONTO) == 0) return FALSE;
if (rec.get_long(PCN_SOTTOCONTO) == 0L)
c1 = rec.get_int(PCN_SEZIVD);
force_setpage();
if (conto == 0) return FALSE; //Scarto i gruppi
if (sottoc == 0L) // Se si tratta di un conto
{
sez = rec.get_char(PCN_SEZIVD);
if (sez == '0')
{
_conto_classificato = FALSE;
_sottoc_classificato = 2;
}
else
if (rec.get_int(PCN_SEZIVD) == 0)
rec.put(PCN_SEZIVD, c1);
if (rec.get_int(PCN_SEZIVD) != 0)
{
_conto_classificato = TRUE;
return FALSE;
}
}
else // Se si tratta di un sottoconto
{
if (!_conto_classificato)
{
if (_sottoc_classificato == 2)
_sottoc_classificato = leggo_sottoc(gruppo,conto,sottoc);
if (_sottoc_classificato == 0)
return FALSE;
else
if (_sottoc_classificato == 1)
{
char sezione = rec.get_char(PCN_SEZIVD);
if (sezione != '0')
return FALSE;
}
}
else
return FALSE;
}
_g_prec = gruppo;
_c_prec = conto;
}
}
if (_tipo_stampa == senza_ana_bil)
{
TRectype & rec = current_cursor()->curr();
@ -537,6 +978,24 @@ bool CG1100_application::set_print(int)
// scegli_cur();
enable_link("Collegamento Piano dei conti : ", 'r');
set_multiple_link(TRUE);
_sez_stamp = ' ';
_let_stamp = ' ';
_numr_stamp = "";
_num_stamp = 0;
_classe_stampata = "";
if (_tipo_stampa == senza_IV_direttiva)
{
_conto_classificato = TRUE;
_sottoc_classificato = 0;
_stampa_riga_vuota = FALSE;
_prima_volta = TRUE;
}
scegli_cur();
_resetta_righe_stampa = TRUE;
return TRUE;
}
return FALSE;
@ -560,38 +1019,47 @@ void CG1100_application::intesta (stampe tipo)
set_header (soh++, "Ditta : %ld %s@110gData : @< Pag. @#", firm, (const char *) s);
set_header (soh++,"@58gPIANO DEI CONTI");
s.fill('_');
set_header (soh++, (const char *) s);
set_header (soh,"@0gPIANO DEI CONTI");
switch (tipo)
{
case completa:
set_header (soh++, "Conto @67gSez. Classe@85gTipo@96gDettaglio@112gSpesa @123gDet.bil.");
set_header (soh++, "Sottoconto @16gDescrizione@68gIV dir. @85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez");
set_header (soh++, "@20gStampa completa per IV direttiva");
s.fill('-');
set_header (soh++, (const char *) s);
set_header (soh++, "Conto @59gSez. Classe@75gTipo@86gDettaglio@104gT@107gSpesa@118gDet.alleg.bil.");
set_header (soh++, "Sottoconto @16gDescrizione@61gIV dir.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov.");
break;
case con_IV_direttiva:
set_header (soh++, "@60gCodici Piano@111gSez. e Classe");
set_header (soh++, "Classe@19gDescrizione@60gdei Conti @78gDescrizione@110g classe opposta");
set_header (soh++, "@20gStampa conti riclassificati per IV direttiva");
s.fill('_');
set_header (soh++, (const char *) s);
set_header (soh++, "@58gCodici Piano@116gSez. e Classe");
set_header (soh++, "Classe@14gDescrizione@58gdei Conti @73gDescrizione@116gclasse opposta");
break;
case senza_IV_direttiva:
set_header (soh++, "@20gStampa conti non collegati per IV direttiva");
s.fill('_');
set_header (soh++, (const char *) s);
set_header (soh++, "Conto@85gTipo@96gDettaglio@112gSpesa @123gDet.bil.");
set_header (soh++, "Sottoconto @16gDescrizione@85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez");
break;
case con_ana_bil:
s.fill('_');
set_header (soh++, (const char *) s);
set_header (soh++, "Codice @61gCodici Piano@113gDett.alleg.Bilancio");
set_header (soh++, "Tabella@16gDescrizione@60gdei Conti @78gDescrizione @113gSot.con. * Moviment.");
break;
case senza_ana_bil:
s.fill('_');
set_header (soh++, (const char *) s);
set_header (soh++, "Conto @67gSez. Classe@85gTipo@96gDettaglio@112gSpesa @123gDet.bil.");
set_header (soh++, "Sottoconto @16gDescrizione@68gIV dir. @85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez");
break;
@ -605,6 +1073,40 @@ void CG1100_application::intesta (stampe tipo)
}
const char* CG1100_application::descrizione_numero(char sezione, char lettera, int numr, int numero)
{
TTable tabivd(TAB_IVD);
TString dep,dep2;
tabivd.zero();
if (numr == 0 && numero == 0)
dep = format("%c%c",sezione,lettera);
else
if (numero == 0)
{
if (numr != 0)
dep = format("%1c%1c%04d",sezione, lettera, numr);
else
dep = format("%c%c ",sezione,lettera);
}
else
{
if (numr != 0)
dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero);
else
dep = format("%c%c %02d",sezione,lettera,numero);
}
tabivd.put("CODTAB", dep);
tabivd.read();
dep2 = tabivd.get("CODTAB");
if (dep == dep2)
tmp = tabivd.get("S0");
else
tmp = "";
return (__tmp);
}
const char * CG1100_application::decodifica_IV_dir (const char * sezivd, const char * lettivd, int numrivd, int numivd)
{
TString dep (CODTABLEN);
@ -655,6 +1157,7 @@ void CG1100_application::user_create()
_cur_c2 = add_cursor (NULL);
add_file(LF_PCON);
_descr = new TParagraph_string ("",40);
_tipo_stampa = completa;
_salto_pag = FALSE;
@ -666,7 +1169,7 @@ void CG1100_application::user_destroy()
delete _msk;
delete _rel;
delete _rec;
delete _sort;
delete _descr;
}
int cg1100(int argc, char* argv[])

View File

@ -4,6 +4,8 @@
#define F_DATA_STAMPA 100
#define F_SCELTA_STAMPA 101
#define F_SALTO_PAGINA 102
#define F_CODDITTA 103
#define F_RAGSOC 104
#endif

View File

@ -1,27 +1,47 @@
#include "cg1100.h"
PAGE "" -1 -1 49 12
PAGE "" -1 -1 70 18
NUMBER F_CODDITTA 5
BEGIN
PROMPT 2 1 "Ditta "
FLAGS "FRD"
USE LF_NDITTE KEY 1
CHECKTYPE REQUIRED
INPUT CODDITTA F_CODDITTA
DISPLAY "Codice" CODDITTA
DISPLAY "Ragione sociale @50" RAGSOC
OUTPUT F_CODDITTA CODDITTA
OUTPUT F_RAGSOC RAGSOC
END
STRING F_RAGSOC 50
BEGIN
PROMPT 2 2 "Ragione sociale "
FLAGS "D"
END
DATE F_DATA_STAMPA
BEGIN
PROMPT 2 1 "Data di stampa "
PROMPT 2 4 "Data di stampa "
FLAGS "A"
END
RADIOBUTTON F_SCELTA_STAMPA 42
RADIOBUTTON F_SCELTA_STAMPA 47
BEGIN
PROMPT 2 2 "Tipo di stampa "
PROMPT 2 6 "Tipo di stampa "
HELP "Scegliere il tipo di stampa desiderata"
ITEM "1|Completa"
ITEM "1|Completa per IV direttiva"
ITEM "2|Conti riclassificati per IV direttiva"
ITEM "3|Conti non collegati IV direttiva"
ITEM "4|Conti collegati analisi di bilancio"
ITEM "5|Conti non collegati analisi di bilancio"
ITEM "3|Conti non collegati per IV direttiva"
ITEM "4|Completa per analisi di bilancio"
ITEM "5|Conti riclassificati per analisi di bilancio"
ITEM "6|Conti non collegati per analisi di bilancio"
END
BOOLEAN F_SALTO_PAGINA
BEGIN
PROMPT 3 9 "Salto pagina per cambio gruppo "
PROMPT 3 14 "Salto pagina per cambio gruppo "
HELP "Indicare se si desidera un salto pagina ogni volta che cambia il gruppo"
END

View File

@ -134,8 +134,7 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k)
TString codtab;
int anno;
//if ( (k == K_TAB) && f.mask().is_running() )
if (k == K_SPACE || k == K_TAB)
if (k == K_TAB || f.focusdirty())
{
TString codlib = f.mask().get(CODICE_LIB_UN);
anno = f.mask().get_int(ANNO);
@ -170,6 +169,18 @@ bool CG4400_application::mask_data (TMask_field& f, KEY k)
return TRUE;
}
bool CG4400_application::mask_tipo (TMask_field& f, KEY k)
{
if (k == K_TAB)
{
TDate data(f.get());
if (data.ok())
if ( data.day() == 31 && data.month() == 12 )
f.mask().show (TIPO_RIEPILOGATIVO);
}
return TRUE;
}
/*
bool mask_fino_a_mese (TMask_field& f, KEY k)
{
@ -385,17 +396,18 @@ void CG4400_application::user_create()
_tab = new TLocalisamfile(LF_TAB);
_tabcom = new TLocalisamfile(LF_TABCOM);
_tabreg = new TTable("REG");
_tabiva = new TTable("%IVA");
_tablbu = new TTable("%LBU");
_tabinl = new TTable("%INL");
_tablim = new TTable("LIM");
_tabpim = new TTable("PIM");
_tablia = new TTable("LIA");
_clifo = new TLocalisamfile(LF_CLIFO);
_occas = new TLocalisamfile(LF_OCCAS);
_rel = new TRelation (LF_MOV);
_rel->add(LF_CAUSALI,"CODCAUS=CODCAUS",1,LF_MOV);
_rel->add(LF_RMOVIVA,"NUMREG=NUMREG",1,LF_MOV);
_cur = new TCursor(_rel, "", 1);
//_cur->set_filterfunction(filter_func);
add_cursor(_cur);
add_file(LF_MOV);
@ -472,20 +484,20 @@ int CG4400_application::riga_rmoviva()
codiva = iva.get(RMI_CODIVA);
impop = imposp = 0.00;
_riga_rmi.add_riga(impo,impos,codiva,tipodet,impop,imposp);
_riga_rmi.add_riga(impo,impos,codiva,tipodet,tipocr,impop,imposp);
if (_tipo_reg == 2) //registro acquisti
{
if (_tipo_stampa != 3) //stampa definitiva
calcola_progressivi(impop,imposp,codiva,tipocr);
_iva_array.add_riga(impo,impos,codiva,tipodet,impop,imposp);
_iva_array.add_riga(impo,impos,codiva,tipodet,tipocr,impop,imposp);
}
impop = imposp = 0.00;
if (_tipo_stampa != 3)
calcola_progressivi(impop,imposp,codiva,tipocr);
_tot_iva_array.add_riga(impo,impos,codiva,impop,imposp);
_tot_iva_array.add_riga(impo,impos,codiva,_tipodoc,impop,imposp);
ok = _cur->next_match(LF_RMOVIVA);
}
@ -520,19 +532,28 @@ bool CG4400_application::controlla_liquidazione()
{
TTable lim ("LIM");
TTable pim ("PIM");
TString16 mesi_ric = "";
TString16 mesi_cal = "";
TTable lia ("LIA");
TString mesi_ric = "";
TString mesi_cal = "";
TString16 chiave = "";
TString16 ditta = "";
int i;
ditta << get_firm();
if (lim.empty())
return yesno_box("Non esiste la tabella liquidazione iva mensile! Vuoi ugualmente continuare la stampa?");
return yesno_box("Ditta %s : non esiste la tabella liquidazione iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta);
if (pim.empty())
return yesno_box("Non esiste la tabella progressivi iva mensile! Vuoi ugualmente continuare la stampa?");
return yesno_box("Ditta %s : non esiste la tabella progressivi iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta);
chiave << _annoes;
lia.put("CODTAB", chiave);
if (lia.read() == NOERR)
_frequiva = lia.get("S7")[0];
if (_frequiva == 'T') //nella tabella LIM ho solo i mesi 3, 6, 9, 12
{
for (i=3; i<=_fino_a_mese+3; i+=3)
for (i=3; i<=_fino_a_mese; i+=3)
{
chiave = "";
chiave << _annoes << i;
@ -543,16 +564,16 @@ bool CG4400_application::controlla_liquidazione()
if (!calcolato)
// return yesno_box("La liquidazione relativa al mese di %s deve essere ricalcolata. Vuoi ugualmente continuare la stampa?", itom(i) );
mesi_ric << itom(i) << "\n\r";
mesi_ric << itom(i) << "\n";
}
else
// return yesno_box("La liquidazione relativa al mese di %s non e' stata calcolata. Vuoi ugualmente continuare la stampa?", itom(i) );
mesi_cal << itom(i) << "\n\r";
mesi_cal << itom(i) << "\n";
}
}
if (_frequiva == 'M')
{
for (i=1; i<=_fino_a_mese; i++);
for (i=1 ; i<=_fino_a_mese; i++)
{
chiave = "";
chiave << _annoes << i;
@ -562,22 +583,22 @@ bool CG4400_application::controlla_liquidazione()
bool calcolato = lim.get_bool("B0");
if (!calcolato)
// return yesno_box("La liquidazione relativa al mese di %s deve essere ricalcolata. Vuoi ugualmente continuare la stampa?", itom(i) );
mesi_ric << itom(i) << "\n\r";
mesi_ric << itom(i) << "\n";
}
else
// return yesno_box("La liquidazione relativa al mese di %s non e' stata calcolata. Vuoi ugualmente continuare la stampa?", itom(i) );
mesi_cal << itom(i) << "\n\r";
mesi_cal << itom(i) << "\n";
}
}
if (mesi_ric.not_empty())
{
warning_box ("Deve essere ricalcolata la liquidazione relativa ai mesi di:\n %s ", (const char *)mesi_ric);
return yesno_box("Vuoi ugualmente continuare la stampa?");
}
if (mesi_ric.not_empty())
{
warning_box ("Ditta %s : deve essere ricalcolata la liquidazione relativa ai mesi di:\n %s ", (const char*)ditta, (const char *)mesi_ric);
return yesno_box("Vuoi ugualmente continuare la stampa?");
}
if (mesi_cal.not_empty())
{
warning_box ("La liquidazione relativa al mese di %s non e' stata calcolata", (const char *)mesi_cal);
warning_box ("Ditta %s : la liquidazione relativa ai mesi di \n %s non e' stata ancora calcolata", (const char*)ditta, (const char *)mesi_cal);
return yesno_box("Vuoi ugualmente continuare la stampa?");
}
return TRUE;
@ -589,6 +610,7 @@ bool CG4400_application::controlla_mov()
TLocalisamfile mov (LF_MOV);
bool ok = TRUE;
byte tipo;
TString16 ditta = "";
TDate udata;
TDate data = format("01/01/%4d", _annoes - 1);
TRecnotype rec = _tabreg->recno();
@ -603,11 +625,13 @@ bool CG4400_application::controlla_mov()
|| ((!_stampa_tutti_i_registri)&&(reg == _codreg)) )
if ( (datareg >= data) && (datareg <= udata) )
{
bool stampato = mov.get_bool(MOV_STAMPATO);
bool stampato = mov.get_bool(MOV_REGST);
long numreg = mov.get_long(MOV_NUMREG);
if (!stampato)
{
warning_box("Il movimento con numero di registrazione %ld non e' ancora stato stampato in forma definitiva!", numreg);
ditta = "";
ditta << get_firm();
warning_box("Ditta %s : il movimento con numero di registrazione %ld non e' ancora stato stampato in forma definitiva!", (const char*)ditta, numreg);
ok = FALSE;
}
}
@ -685,13 +709,27 @@ void CG4400_application::cerca_reg(const TString& c, byte& t, TDate& d)
}
*/
void CG4400_application::set_page_tot_reg()
bool CG4400_application::ventilazione(const char* iva)
{
reset_print();
TString riga(_stampa_width);
int r=1, rr=0, row=0;
real tot_imponib, tot_imposta, tot_imponibp, tot_impostap;
TTable tabiva ("%IVA");
TString16 chiave = "";
chiave << iva;
tabiva.put("CODTAB", chiave);
if (tabiva.read()==NOERR)
{
TString16 vent = tabiva.get("S1");
if (vent == "VE")
return TRUE;
}
return FALSE;
}
int CG4400_application::stampa_prospetto()
{
TString riga(_stampa_width);
int r=1, rr=0;
reset_print();
riga.fill('-');
set_row(r, "%s", (const char *) riga);
r++;
@ -718,7 +756,10 @@ void CG4400_application::set_page_tot_reg()
if (_nrec > 0) //numero records di rmoviva
{
set_row(++rr, "@26g---------- P E R I O D O ----------");
if (_corrispettivi)
set_row(++rr, "@26g------------------ P E R I O D O -------------------");
else
set_row(++rr, "@26g---------- P E R I O D O -----------");
if (_tipo_stampa != 3)
set_row(rr,"@82g------ P R O G R E S S I V I ------");
rr++;
@ -729,49 +770,32 @@ void CG4400_application::set_page_tot_reg()
if (_tipo_stampa != 3)
set_row(rr, "@92gA C Q U I S T I");
}
if (_tipo_reg == 1)
if (_tipo_reg == 1) //un registro corrispettivi puo' solo essere un registro vendite
{
set_row(rr, "@37gV E N D I T E");
if (_corrispettivi)
set_row(rr, "@63gCORRISPETTIVI");
if (_tipo_stampa != 3)
set_row(rr, "@93gV E N D I T E");
}
rr++;
set_row(rr, "iva Descrizione@30gImponibile@49gImposta");
if (_corrispettivi)
set_row(rr, "@63gImporti lordi");
if (_tipo_stampa != 3)
set_row(rr++, "@86gImponibile@106gImposta");
else rr++;
rr++;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00;
_tot_iva_array.sort(compare_rows);
for (int k = 0; k < _tot_iva_array.items(); k++)
{
TRiga& riga = (TRiga&)_tot_iva_array[k];
row = rr+k;
set_row(row, "%3s", (const char*)riga._codiva);
TString descr = descr_iva(riga._codiva);
set_row(row, "@5g%s", (const char*)descr);
set_row(row, "@25g%r", &riga._imponibile);
set_row(row, "@41g%r", &riga._imposta);
if (_tipo_stampa != 3)
{
set_row(row, "@81g%r", &riga._imponibilep);
set_row(row, "@98g%r", &riga._impostap);
}
tot_imponib += riga._imponibile;
tot_imposta += riga._imposta;
tot_imponibp += riga._imponibilep;
tot_impostap += riga._impostap;
}
_tot_iva_array.destroy();
row++;
set_row(++row, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta);
if (_tipo_stampa != 3)
set_row(row, "@81g%r@98g%r", &tot_imponibp, &tot_impostap);
//la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti
return rr;
}
//la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti
void CG4400_application::stampa_acquisti(int row)
{
if (_tipo_reg == 2)
{
real tot_imponib, tot_imposta, tot_imponibp, tot_impostap;
row+=2;
int tdetprec = -1;
int rw = row;
@ -852,6 +876,134 @@ void CG4400_application::set_page_tot_reg()
}
_iva_array.destroy();
}
}
void CG4400_application::set_page_tot_reg()
{
TString16 codivaprec = "";
int row=0, rr=0;
rr = stampa_prospetto();
if (_nrec > 0) //numero di records di rmoviva
{
real tot_imponib, tot_imposta, tot_imponibp, tot_impostap, tot_lordo;
real dep_imponib, dep_imposta, dep_lordo;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = tot_lordo = ZERO;
dep_imponib = dep_imposta = dep_lordo = ZERO;
_tot_iva_array.sort(compare_rows);
for (int k = 0; k < _tot_iva_array.items(); k++)
{
TRiga& riga = (TRiga&)_tot_iva_array[k];
//row = rr+k;
if (codivaprec == "")
codivaprec = riga._codiva;
if (codivaprec != riga._codiva)
{
set_row(rr, "%3s", (const char*)codivaprec);
TString descr = descr_iva(codivaprec);
set_row(rr, "@5g%s", (const char*)descr);
if (dep_imponib != ZERO)
set_row(rr, "@25g%r", &dep_imponib);
if (dep_imposta != ZERO)
set_row(rr, "@41g%r", &dep_imposta);
if (dep_lordo != ZERO)
set_row(rr, "@61g%r", &dep_lordo);
if (_tipo_stampa != 3)
{
set_row(rr, "@81g%r", &riga._imponibilep);
set_row(rr, "@98g%r", &riga._impostap);
}
rr++;
codivaprec = riga._codiva;
dep_imponib = dep_imposta = dep_lordo = ZERO;
}
if (_corrispettivi)
{
if (riga._tipodoc == "CR" || riga._tipodoc == "RF" || riga._tipodoc == "SC")
{
dep_lordo += riga._imponibile;
dep_imposta += riga._imposta;
tot_lordo += riga._imponibile;
tot_imposta += riga._imposta;
}
else if (riga._tipodoc == "CN" || riga._tipodoc == "RN" || riga._tipodoc == "SN" || riga._tipodoc != "FS")
{
dep_imponib += riga._imponibile;
dep_imposta += riga._imposta;
tot_imponib += riga._imponibile;
tot_imposta += riga._imposta;
}
if (riga._tipodoc == "FS")
{
real somma = riga._imponibile + riga._imposta;
if (ventilazione(riga._codiva)) //con ventilazione
{
dep_imponib += somma;
tot_imponib += somma;
somma = -somma;
dep_lordo += somma;
}
else //senza ventilazione
{
dep_imponib += riga._imponibile;
tot_imponib += riga._imponibile;
dep_imposta += riga._imposta;
tot_imposta += riga._imposta;
somma = -somma;
dep_lordo += somma;
}
tot_lordo += somma;
}
}
else //non e' un registro corrispettivo
{
//set_row(row, "@25g%r", &riga._imponibile);
//set_row(row, "@41g%r", &riga._imposta);
dep_imponib += riga._imponibile;
dep_imposta += riga._imposta;
tot_imponib += riga._imponibile;
tot_imposta += riga._imposta;
tot_imponibp += riga._imponibilep;
tot_impostap += riga._impostap;
}
if (k == (_tot_iva_array.items()-1))
{
set_row(rr, "%3s", (const char*)riga._codiva);
TString descr = descr_iva(riga._codiva);
set_row(rr, "@5g%s", (const char*)descr);
if (dep_imponib != ZERO)
set_row(rr, "@25g%r", &dep_imponib);
if (dep_imposta != ZERO)
set_row(rr, "@41g%r", &dep_imposta);
if (dep_lordo != ZERO)
set_row(rr, "@61g%r", &dep_lordo);
if (_tipo_stampa != 3)
{
set_row(rr, "@81g%r", &riga._imponibilep);
set_row(rr, "@98g%r", &riga._impostap);
}
}
/*
if (_tipo_stampa != 3)
{
set_row(rr, "@81g%r", &riga._imponibilep);
set_row(rr, "@98g%r", &riga._impostap);
}
*/
}
_tot_iva_array.destroy();
rr++;
set_row(++rr, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta);
if (_corrispettivi)
if (tot_lordo != ZERO)
set_row(rr, "@61g%r", &tot_lordo);
if (_tipo_stampa != 3)
set_row(rr, "@81g%r@98g%r", &tot_imponibp, &tot_impostap);
stampa_acquisti(rr);
}
}
@ -894,6 +1046,7 @@ bool CG4400_application::compila_reg(const TMask& m)
{
_tipo_reg = _tabreg->get_int("I0");
_pagine_stampate = _tabreg->get_int("I1");
_corrispettivi = _tabreg->get_bool("B0");
//_pagine_numerate = tab_reg.get_int("I2");
//_stampa_ok = tab_reg.get_int("I7");
//_nprog_da = tab_reg.get_long ("I6");
@ -902,10 +1055,10 @@ bool CG4400_application::compila_reg(const TMask& m)
if (_tipo_stampa != 3)
_data_da = _tabreg->get_date ("D3");
if ( _tipo_stampa == 1 || _tipo_stampa == 4 )
if ( _data_a < _data_da)
if ( _data_a <= _data_da)
{
TString16 datas = format("%02d/%4d", _data_da.month(), _data_da.year());
warning_box ("La data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro)", (const char*)datas);
warning_box ("La data specificata deve essere superiore al %s (ultima data di stampa specificata sul registro)", (const char*)datas);
return FALSE;
}
//_stampa_intesta = _tabreg->get_bool ("B9");
@ -990,6 +1143,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
if (file == LF_MOV)
{
if (counter) return TRUE;
reset_print();
int rr = 0;
TString ragsoc;
TString tipo_op = "";
@ -997,20 +1151,10 @@ bool CG4400_application::preprocess_page(int file, int counter)
TLocalisamfile& mov = _cur->file(LF_MOV);
TLocalisamfile& caus = _cur->file(LF_CAUSALI);
//long annoes = mov->get_long(MOV_ANNOES);
//TString16 codreg = mov->get(MOV_REG);
_datareg = mov.get_date(MOV_DATAREG);
//if (codreg != _codreg || annoes != _annoes)
// return FALSE;
//if (_data_da.string() != "" && _data_a.string() != "")
// if ( (_datareg < _data_da || _datareg > _data_a) || (!_datareg.ok()) )
// return FALSE;
_mov_empty = FALSE;
//if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) )
if ( (_datareg.month() != _dataregp.month()) && (_dataregp.ok()) )
{
if (_tipo_stampa == 2)
@ -1030,7 +1174,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
TString ocfpi = mov.get(MOV_OCFPI);
long codcf = mov.get_long(MOV_CODCF);
long numgio = mov.get_long(MOV_NUMGIO);
bool stampato = mov.get_bool(MOV_STAMPATO);
bool stampato = mov.get_bool(MOV_REGST);
bool intra = caus.get_bool(CAU_INTRACOM);
bool autof = caus.get_bool(CAU_AUTOFATT);
TString descrcau = caus.get(CAU_DESCR);
@ -1039,7 +1183,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
if (_tipo_stampa != 3)
if (!stampato)
{
mov.put(MOV_STAMPATO,TRUE);
mov.put(MOV_REGST,TRUE);
mov.rewrite();
}
@ -1092,10 +1236,9 @@ bool CG4400_application::preprocess_page(int file, int counter)
if (_tipo_reg == 2)
set_row(rr, "@107g%d", riga._tipodet);
set_row(rr, "@108g%r", &riga._imposta);
set_row(rr, "@124g%d", riga._tipocr);
}
_riga_rmi.destroy();
int tipocr = _cur->file(LF_RMOVIVA).get_int(RMI_TIPOCR);
set_row(_r, "@124g%d", tipocr);
}
//int tipocr = _cur->file(LF_RMOVIVA)->get_int(RMI_TIPOCR);
//set_row(_r, "@124g%d", tipocr);
@ -1313,7 +1456,9 @@ print_action CG4400_application::postprocess_print(int file, int counter)
bool CG4400_application::set_print(int n)
{
TMask m("cg4400a");
int giorni_del_mese;
// bool ok = set_ditte(m);
if (set_ditte(m))
if (_selected.ones() > 0l)
{
@ -1343,18 +1488,24 @@ bool CG4400_application::set_print(int n)
_u_stampata = m.get_int(ULTIMA_PAGINA);
//set_page_number(_u_stampata + 1);
}
const int giorni_del_mese = TDate::last_day(_fino_a_mese, _annoes);
_data_a=TDate(giorni_del_mese,_fino_a_mese,_annoes);
if (_fino_a_mese == 12)
giorni_del_mese = 31;
else
{
TDate primo = format("01/%02d/%4d", _fino_a_mese+1, _annoes);
--primo;
giorni_del_mese = primo.day();
}
_data_a=format("%02d/%02d/%4d",giorni_del_mese,_fino_a_mese,_annoes);
// NB data_da viene letta nella preprocess_page
}
if (_tipo_stampa == 2)
compila_lib();
stampa_registri_IVA(m);
}
else warning_box("Nessuna ditta selezionata!");
return FALSE;
// return ok;
}
void CG4400_application::stampa_registri_IVA(const TMask& m)
@ -1379,7 +1530,13 @@ void CG4400_application::stampa_registri_IVA(const TMask& m)
if (!ok) continue;
if (!_stampa_tutti_i_registri)
{
(*_cur) = 0L;
const long item = _cur->items();
if (item > 0)
print();
if (_tipo_stampa != 3) aggiorna_reg();
}
else
{
TString16 codtab;
@ -1395,7 +1552,7 @@ void CG4400_application::stampa_registri_IVA(const TMask& m)
if ( tipo == 1 || tipo == 2 ) //registro iva
{
_tipo_reg = _tabreg->get_int("I0");
_desc_lib = _tabreg->get("S0");
_corrispettivi = _tabreg->get_bool("B0");
if (_tipo_stampa != 3)
_data_da = _tabreg->get_date("D3");
_pagine_stampate = _tabreg->get_int("I1");
@ -1441,6 +1598,7 @@ bool CG4400_application::set_ditte(TMask& m)
m.set_handler (A_CODICE, mask_firm_to);
m.set_handler (DA_DATA, mask_data);
m.set_handler (A_DATA, mask_data);
m.set_handler (A_DATA, mask_tipo);
m.set_handler (MESE, mask_mese);
m.set_handler (CODICE_LIB_UN, mask_cod);
m.set_handler (DLG_SELECT, mask_select);
@ -1537,8 +1695,8 @@ int CG4400_application::stampa_intestazione()
//printer().setdate(_data);
if (_tipo_stampa == 3)
riga = "STAMPA DI PROVA Data @<";
else
riga = "Data @<";
//else
// riga = "Data @<";
riga.right_just(_stampa_width-6);
//riga.right_just(127);
riga.overwrite (format ("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi));

View File

@ -21,7 +21,6 @@
#include "cglib03.h"
//enum STAMPA { bollati=1, unici=2 };
const int TABREG = (int)TTable::name2log("REG");
class CG4400_application : public TPrintapp
@ -29,7 +28,7 @@ class CG4400_application : public TPrintapp
TCursor * _cur;
TRelation *_rel;
TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom, *_com, *_anag;
TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim;
TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim, *_tablia, *_tabiva;
TRigaiva_array _iva_array, _riga_rmi;
TTipodoc_array _doc_array;
TRiga_array _tot_iva_array;
@ -39,6 +38,7 @@ class CG4400_application : public TPrintapp
TRecnotype _nrec;
bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri, _auto_intraf;
bool _corrispettivi;
char _frequiva;
TDate _data_da, _data_a, _data_stampa, _dataregp, _dataregs, _datareg;
long _n_ditte, _u_stampata, _primast;
@ -63,6 +63,7 @@ protected:
bool compila_lib();
bool controlla_liquidazione();
bool controlla_mov();
bool ventilazione(const char*);
void cerca_reg(const TString&, byte&, TDate&);
//void leggi_movimenti(const TDate&, const TString&, bool&);
void stampa_registri_IVA(const TMask&);
@ -74,7 +75,9 @@ protected:
void user_destroy();
bool preprocess_page(int, int);
int stampa_intestazione();
int stampa_prospetto();
void get_dati_ditta();
void stampa_acquisti(int);
bool preprocess_print(int, int);
print_action postprocess_print(int, int);
print_action postprocess_page (int, int);
@ -86,6 +89,7 @@ protected:
static bool mask_firm_to (TMask_field&, KEY);
static bool mask_cod (TMask_field&, KEY);
static bool mask_data (TMask_field&, KEY);
static bool mask_tipo (TMask_field&, KEY);
static bool mask_mese (TMask_field&, KEY);
static bool mask_fino_a_mese (TMask_field&, KEY);
static bool mask_select (TMask_field&, KEY);

View File

@ -10,30 +10,15 @@ LISTBOX TIPO_STAMPA 1 48
BEGIN
PROMPT 2 1 "Tipo "
ITEM "1|Libri bollati della ditta"
MESSAGE SHOW,1@|HIDE,2@|HIDE,3@
MESSAGE SHOW,1@|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@
ITEM "2|Libri unici dello studio"
MESSAGE SHOW,2@|HIDE,1@|HIDE,3@
MESSAGE SHOW,2@|HIDE,1@|RESET,1@|HIDE,3@|RESET,3@
ITEM "3|Stampa di prova"
MESSAGE SHOW,3@|HIDE,1@|HIDE,2@|SHOW,CODICE_LIBRO
MESSAGE SHOW,3@|HIDE,1@|RESET,1@|HIDE,2@|RESET,2@|SHOW,CODICE_LIBRO
ITEM "4|Libri con riferimenti al libro giornale"
MESSAGE SHOW,1@|HIDE,2@|HIDE,3@
MESSAGE SHOW,1@|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@
END
/*
NUMBER TIPO_STAMPA 1
BEGIN
PROMPT 2 1 "Tipo stampa "
SHEET "Cod|Descrizione@50"
INPUT TIPO_STAMPA
OUTPUT TIPO_STAMPA
ITEM "1|Libri bollati della ditta"
ITEM "2|Libri unici dello studio"
ITEM "3|Stampa di prova"
ITEM "4|Libri con riferimenti al libro giornale"
END
*/
GROUPBOX DLG_NULL 35 5
BEGIN
PROMPT 20 2 "Scelta ditte"
@ -158,6 +143,8 @@ END
DATE A_DATA
BEGIN
PROMPT 30 9 "Alla data "
VALIDATE DATE_CMP_FUNC >= DA_DATA
WARNING "Inserire una data non inferiore alla data limite inferiore"
GROUP 3
END