2203 lines
60 KiB
C++
Executable File
2203 lines
60 KiB
C++
Executable File
// 774200.cpp - Calcolo riporti dei Quadri
|
|
//
|
|
// Per l'interfaccia vedere 774200.h.
|
|
// Il metodo pubblico che fa tutto il lavoro dalla gestione di
|
|
// un singolo quadro e' set().
|
|
//
|
|
// 774 -1 D : riporto sul quadro I del dichiarante
|
|
//
|
|
// 774 -1 S : livello di studio oppure
|
|
// richiamare la funzione set all' interno
|
|
// di ogni programma di gestione quadri.
|
|
//
|
|
// ATTENZIONE:
|
|
// Se si aggiungono o tolgono quadri in build_fill_string()
|
|
// bisogna cambiare il numero dei quadri.
|
|
//
|
|
// 15.3.96 Allungata la stringa QCOMP per far spazio ai quadri A1-2-3
|
|
//
|
|
#include <applicat.h>
|
|
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
#include <config.h>
|
|
#include <urldefid.h>
|
|
#include "774200.h"
|
|
#include "quadroa.h"
|
|
#include "quadroa3.h"
|
|
#include "quadrob.h"
|
|
#include "quadrob1.h"
|
|
#include "dipend.h"
|
|
#include "quadroh.h"
|
|
#include "quadroc.h"
|
|
#include "quadrod.h"
|
|
#include "quadrod1.h"
|
|
#include "quadroe.h"
|
|
#include "quadroe1.h"
|
|
#include "prospe1.h"
|
|
#include "quadroe2.h"
|
|
#include "quadrif.h"
|
|
#include "quadrog.h"
|
|
#include "quadrogd.h"
|
|
#include "quadrog1.h"
|
|
#include "774200a.h"
|
|
#include "77lib.h"
|
|
|
|
// Costanti
|
|
#define TIPOQUA "TIPOQUA"
|
|
|
|
// NB Tutte da spostare in lffiles
|
|
#define LF_RIGHEF2 100
|
|
#define LF_RIGHEF1 99
|
|
#define LF_RIGHEF 98
|
|
#define LF_QUAGD 101
|
|
|
|
// inizializzato in TRiporti::set() - usato in filter_func()
|
|
HIDDEN TRiporti* this_riporti = NULL;
|
|
|
|
HIDDEN TString80 __tmp;
|
|
|
|
// Costanti usate per il calcolo dei fogli compilati
|
|
HIDDEN const int QE2_FISICHE_PER_FOGLIO = 16;
|
|
HIDDEN const int QE2_NOFISICHE_PER_FOGLIO = 9;
|
|
HIDDEN const int QGD_FISICHE_PER_FOGLIO = 5;
|
|
HIDDEN const int QGD_NOFISICHE_PER_FOGLIO = 6;
|
|
HIDDEN const int QD1_FISICHE_PER_FOGLIO = 24;
|
|
HIDDEN const int QD1_NOFISICHE_PER_FOGLIO = 8;
|
|
HIDDEN const int QD_FISICHE_PER_FOGLIO = 18;
|
|
HIDDEN const int QD_NOFISICHE_PER_FOGLIO = 6;
|
|
HIDDEN const int QE_FISICHE_PER_FOGLIO = 26;
|
|
HIDDEN const int QE_NOFISICHE_PER_FOGLIO = 8;
|
|
HIDDEN const int QE1_PERCIPIENTI_PER_FOGLIO = 25;
|
|
HIDDEN const int QE1_RIGHE_PROSPETTO = 17;
|
|
|
|
HIDDEN long fogli_compilati(const long fisiche, const long nofisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio);
|
|
HIDDEN const char* build_fill_string(TString& qcomp);
|
|
|
|
class TRiporta_quadri : public TApplication
|
|
{
|
|
char _liv;
|
|
TRiporti* _riporta;
|
|
TMask* _msk;
|
|
int _anno_dic;
|
|
static bool codditta_handler(TMask_field& f, KEY k);
|
|
public:
|
|
virtual bool create();
|
|
virtual bool menu(MENU_TAG m);
|
|
virtual bool destroy();
|
|
|
|
TRiporti& riporta() { return *_riporta; }
|
|
|
|
TRiporta_quadri(char livello) : _liv(toupper(livello)) {}
|
|
~TRiporta_quadri() {}
|
|
};
|
|
|
|
TRiporta_quadri& app() { return (TRiporta_quadri&)main_app(); }
|
|
|
|
bool TRiporta_quadri::codditta_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && !(f.mask().is_running()) )
|
|
{
|
|
TString16 codditta;
|
|
codditta << get_firm_770();
|
|
|
|
if (codditta != "0")
|
|
{
|
|
f.set(codditta);
|
|
f.check();
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TRiporta_quadri::menu(MENU_TAG m)
|
|
{
|
|
if (m == BAR_ITEM(1))
|
|
if (_liv == 'D')
|
|
{
|
|
TConfig conf(CONFIG_STUDIO);
|
|
_anno_dic = (int)conf.get_long(ANNO_SEL, NULL);
|
|
_msk->set(F_ANNODIC, _anno_dic);
|
|
KEY tast = _msk->run();
|
|
if (tast != K_ENTER)
|
|
return FALSE;
|
|
const int annod = (int)_msk->get_long(F_ANNODIC);
|
|
_riporta->riporti_dich(get_firm_770(), annod);
|
|
message_box("Generazione riporti terminata");
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool TRiporta_quadri::create()
|
|
{
|
|
TApplication::create();
|
|
_riporta = new TRiporti;
|
|
_msk = new TMask("774200a");
|
|
_msk->set_handler(F_CODDITTA, codditta_handler);
|
|
dispatch_e_menu (BAR_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TRiporta_quadri::destroy()
|
|
{
|
|
delete _riporta;
|
|
delete _msk;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
int riporti_dich(int argc, char* argv[])
|
|
{
|
|
TRiporta_quadri a(*argv[2]);
|
|
a.run(argc, argv, "Generazione riporti");
|
|
return 0;
|
|
}
|
|
|
|
const char* build_fill_string(TString& qcomp)
|
|
{
|
|
// NB cambiare qui il numero dei quadri
|
|
const int NUM_QUADRI = 25; // sono 26 posizioni perche' parte da 0
|
|
const int agg = NUM_QUADRI - qcomp.len();
|
|
__tmp.cut(agg);
|
|
__tmp.fill(' ', agg);
|
|
return __tmp;
|
|
}
|
|
|
|
void TRiporti::setta_flag_quadri_comp(const long codditta, const int quadro, const bool almeno_una_riga, TLocalisamfile& basebis, const long dich)
|
|
{
|
|
/*
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{ */
|
|
TString qcomp(basebis.get(BSE_QCOMP));
|
|
TString dep(build_fill_string(qcomp));
|
|
qcomp << dep;
|
|
|
|
if (almeno_una_riga)
|
|
qcomp[(int)quadro] = 'X';
|
|
else
|
|
qcomp[(int)quadro] = ' ';
|
|
|
|
basebis.put(BSE_QCOMP, qcomp);
|
|
basebis.rewrite();
|
|
/* }
|
|
else
|
|
warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati");
|
|
*/
|
|
//
|
|
// Setta flag quadri compilati del dichiarante; cio' va fatto in 3 casi:
|
|
//
|
|
// 1. dalla gestione dei singoli quadri di una ditta "estinta".
|
|
// 2. dal prg "Riporti" del dichiarante.
|
|
// 3. dalla gestione dei quadri del dichiarante stesso.
|
|
//
|
|
const long codic = sogg_estinto(codditta);
|
|
const long ha_dichiarante = dich ? dich : codic;
|
|
const bool sono_dichiarante = sogg_dic(codditta);
|
|
|
|
if (ha_dichiarante || sono_dichiarante)
|
|
{
|
|
const long lRecno=basebis.recno();
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSE_CODDITTA, sono_dichiarante ? codditta : ha_dichiarante);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
TString qcomp(basebis.get(BSE_QCOMP));
|
|
TString dep(build_fill_string(qcomp));
|
|
qcomp << dep;
|
|
|
|
if (almeno_una_riga)
|
|
qcomp[(int)quadro] = 'X';
|
|
else
|
|
qcomp[(int)quadro] = ' ';
|
|
|
|
basebis.put(BSE_QCOMP, qcomp);
|
|
basebis.rewrite();
|
|
basebis.readat(lRecno);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati");
|
|
}
|
|
}
|
|
|
|
void TRiporti::setta_flag_quadro_I(const long codditta, const long dich)
|
|
{
|
|
bool compilato = FALSE;
|
|
TLocalisamfile base (LF_BASE);
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
|
|
base.setkey(1);
|
|
base.zero();
|
|
base.put(BSE_CODDITTA, codditta);
|
|
base.read(_isequal, _lock);
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSB_CODDITTA, codditta);
|
|
basebis.read(_isequal, _lock);
|
|
|
|
TString qcomp(basebis.get(BSE_QCOMP));
|
|
TString dep(build_fill_string(qcomp));
|
|
qcomp << dep;
|
|
// TString qcomp (format("%25s", (const char*) app));
|
|
|
|
// I campi del quadro I sono in parte su base in parte su basebis
|
|
for (int i = 0; i < CAMPI_IB1; i++)
|
|
if (base.get_real(_campi_I1[i]) != ZERO)
|
|
{
|
|
compilato = TRUE;
|
|
break;
|
|
}
|
|
base.reread(_unlock);
|
|
|
|
if (!compilato)
|
|
{
|
|
/* TLocalisamfile basebis (LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSB_CODDITTA, codditta);
|
|
basebis.read();*/
|
|
for (int i = 0; i < CAMPI_IB2; i++)
|
|
if (basebis.get_real(_campi_I2[i]) != ZERO)
|
|
{
|
|
compilato = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (compilato)
|
|
qcomp[(int)I] = 'X';
|
|
else
|
|
qcomp[(int)I] = ' ';
|
|
|
|
basebis.put(BSE_QCOMP, qcomp);
|
|
basebis.rewrite();
|
|
}
|
|
|
|
|
|
HIDDEN bool filter_func (const TRelation * rel)
|
|
{
|
|
int anno,annod;
|
|
annod = this_riporti->_annodic;
|
|
anno = rel->lfile().get_int(QUH_H1ANNO);
|
|
return anno == annod;
|
|
}
|
|
|
|
bool TRiporti::riporti_dich(const long dich, const int anno)
|
|
{
|
|
long codditta=0L;
|
|
long codic=0L;
|
|
|
|
// Crea il record I "globale" se non c'e'
|
|
enter_dichiar_770(dich, anno, TRUE);
|
|
|
|
TLocalisamfile base(LF_BASE);
|
|
base.setkey(2);
|
|
base.zero();
|
|
base.put("CODDIC", (long)dich);
|
|
// TRectype dep(base.curr());
|
|
|
|
// 1. Riporto dai quadri degli estinti al quadro I globale del dichiarante
|
|
for (base.read(); !base.eof(); base.next())
|
|
{
|
|
codic = base.get_long("CODDIC");
|
|
if (codic != dich) break;
|
|
// if (base.curr() > dep) break;
|
|
codditta = base.get_long("CODDITTA");
|
|
if (codditta == dich) continue; // scarta il dichiarante stesso
|
|
set("*", anno, codditta, dich);
|
|
}
|
|
|
|
// 2. Somma del quadro I "locale" del dichiarante a quello globale
|
|
riporta_I_globale(dich);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TRiporti::riporta_I_globale(const long dich)
|
|
{
|
|
int ret1, ret2;
|
|
long c0nfcom, c0nlass, d0nfcom, d0nlaut, d1nfcom, d1nper;
|
|
long e0nfcom, e0nper, e1nfcom, e1nper;
|
|
real h0codlav, h0coldip;
|
|
real c0snsrit, c0rope, c0actot, d0actot, d0snsrit, d0rope, d1tacor, d1snsrit;
|
|
real d1rope, e0aimp, e0snsrit, e0rope, e1scor, e1bcom, e1rope, e1acom;
|
|
real e1bcom2, e1rope2;
|
|
long cc0nfcom, cc0nlass, dd0nfcom, dd0nlaut, dd1nfcom, dd1nper;
|
|
long ee0nfcom, ee0nper, ee1nfcom, ee1nper;
|
|
real ee0snsrit, ee0rope, ee0aimp, hh0codlav, hh0coldip;
|
|
real cc0snsrit, cc0rope, cc0actot, dd0actot, dd0snsrit, dd0rope, dd1tacor;
|
|
real dd1snsrit, dd1rope;
|
|
real ee1scor, ee1bcom, ee1rope, ee1acom, ee1bcom2, ee1rope2;
|
|
|
|
c0nfcom = c0nlass = d0nfcom = d0nlaut = d1nfcom = d1nper = 0;
|
|
e1nfcom = e1nper = 0;
|
|
|
|
h0codlav = h0coldip = ZERO;
|
|
c0snsrit = c0rope = c0actot = d0actot = ZERO;
|
|
d0snsrit = d0rope = d1tacor = ZERO;
|
|
e1scor = e1bcom = e1rope = ZERO;
|
|
e1acom = e1bcom2 = e1rope2 = ZERO;
|
|
|
|
// 1. Lettura quadro I "locale" del dichiarante
|
|
TLocalisamfile base(LF_BASE);
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
base.zero();
|
|
base.put("CODDITTA", dich);
|
|
if (base.read() != NOERR) return FALSE;
|
|
basebis.zero();
|
|
basebis.put("CODDITTA", dich);
|
|
if (basebis.read() != NOERR) return FALSE;
|
|
|
|
d1nfcom = base.get_int(BSE_D1NFCOM);
|
|
d1nper = base.get_int(BSE_D1NPER);
|
|
d1tacor = base.get_real(BSE_D1TACOR);
|
|
d1snsrit = base.get_real(BSE_D1SNSRIT);
|
|
d1rope = base.get_real(BSE_D1ROPE);
|
|
e1nfcom = basebis.get_int(BSB_E1NFCOM);
|
|
e1nper = basebis.get_int(BSB_E1NPER);
|
|
e1scor = basebis.get_real(BSB_E1SCOR);
|
|
e1bcom = basebis.get_real(BSB_E1BCOM);
|
|
e1rope = basebis.get_real(BSB_E1ROPE);
|
|
e1acom = basebis.get_int(BSB_E1ACOM);
|
|
e1bcom2 = basebis.get_real(BSB_E1BCOM2);
|
|
e1rope2 = basebis.get_real(BSB_E1ROPE2);
|
|
|
|
e0nfcom = basebis.get_int(BSB_E0NFCOM);
|
|
e0nper = basebis.get_int(BSB_E0NPER);
|
|
e0aimp = basebis.get_real(BSB_E0AIMP);
|
|
e0snsrit = basebis.get_real(BSB_E0SNSRIT);
|
|
e0rope = basebis.get_real(BSB_E0ROPE);
|
|
|
|
h0codlav = basebis.get_real(BSB_H0CODLAV);
|
|
h0coldip = basebis.get_real(BSB_H0COLDIP);
|
|
c0nfcom = base.get_int(BSE_C0NFCOM);
|
|
c0nlass = base.get_int(BSE_C0NLASS);
|
|
c0actot = base.get_real(BSE_C0ACTOT);
|
|
c0snsrit = base.get_real(BSE_C0SNSRIT);
|
|
c0rope = base.get_real(BSE_C0ROPE);
|
|
|
|
d0nfcom = base.get_int(BSE_D0NFCOM);
|
|
d0nlaut = base.get_int(BSE_D0NLAUT);
|
|
d0actot = base.get_real(BSE_D0ACTOT);
|
|
d0snsrit = base.get_real(BSE_D0SNSRIT);
|
|
d0rope = base.get_real(BSE_D0ROPE);
|
|
|
|
// 2. Riporto nel quadro I globale
|
|
base.zero();
|
|
// base.setkey(2);
|
|
base.put(TIPOQUA, COD_QUA_I_DIC);
|
|
base.put("CODDITTA", (long)dich);
|
|
TRectype dep(base.curr());
|
|
ret1 = base.read();
|
|
if (ret1 == _iskeynotfound)
|
|
{
|
|
base.curr() = dep;
|
|
base.write();
|
|
}
|
|
basebis.zero();
|
|
basebis.put(TIPOQUA, COD_QUA_I_DIC);
|
|
basebis.put("CODDITTA", (long)dich);
|
|
TRectype dep2(basebis.curr());
|
|
ret2 = basebis.read();
|
|
if (ret2 == _iskeynotfound)
|
|
{
|
|
basebis.curr() = dep2;
|
|
basebis.write();
|
|
}
|
|
|
|
dd1nfcom = base.get_int(BSE_D1NFCOM);
|
|
dd1nper = base.get_int(BSE_D1NPER);
|
|
dd1tacor = base.get_real(BSE_D1TACOR);
|
|
dd1snsrit = base.get_real(BSE_D1SNSRIT);
|
|
dd1rope = base.get_real(BSE_D1ROPE);
|
|
ee1nfcom = basebis.get_int(BSB_E1NFCOM);
|
|
ee1nper = basebis.get_int(BSB_E1NPER);
|
|
ee1scor = basebis.get_real(BSB_E1SCOR);
|
|
ee1bcom = basebis.get_real(BSB_E1BCOM);
|
|
ee1rope = basebis.get_real(BSB_E1ROPE);
|
|
ee1acom = basebis.get_int(BSB_E1ACOM);
|
|
ee1bcom2 = basebis.get_real(BSB_E1BCOM2);
|
|
ee1rope2 = basebis.get_real(BSB_E1ROPE2);
|
|
|
|
ee0nfcom = basebis.get_int(BSB_E0NFCOM);
|
|
ee0nper = basebis.get_int(BSB_E0NPER);
|
|
ee0aimp = basebis.get_real(BSB_E0AIMP);
|
|
ee0snsrit = basebis.get_real(BSB_E0SNSRIT);
|
|
ee0rope = basebis.get_real(BSB_E0ROPE);
|
|
|
|
hh0codlav = basebis.get_real(BSB_H0CODLAV);
|
|
hh0coldip = basebis.get_real(BSB_H0COLDIP);
|
|
cc0nfcom = base.get_int(BSE_C0NFCOM);
|
|
cc0nlass = base.get_int(BSE_C0NLASS);
|
|
cc0actot = base.get_real(BSE_C0ACTOT);
|
|
cc0snsrit = base.get_real(BSE_C0SNSRIT);
|
|
cc0rope = base.get_real(BSE_C0ROPE);
|
|
|
|
dd0nfcom = base.get_int(BSE_D0NFCOM);
|
|
dd0nlaut = base.get_int(BSE_D0NLAUT);
|
|
dd0actot = base.get_real(BSE_D0ACTOT);
|
|
dd0snsrit = base.get_real(BSE_D0SNSRIT);
|
|
dd0rope = base.get_real(BSE_D0ROPE);
|
|
|
|
d1nfcom += dd1nfcom ;
|
|
d1nper += dd1nper ;
|
|
d1tacor += dd1tacor ;
|
|
d1snsrit += dd1snsrit ;
|
|
d1rope += dd1rope ;
|
|
e1nfcom += ee1nfcom ;
|
|
e1nper += ee1nper ;
|
|
e1scor += ee1scor ;
|
|
e1bcom += ee1bcom ;
|
|
e1rope += ee1rope ;
|
|
e1acom += ee1acom ;
|
|
e1bcom2 += ee1bcom2 ;
|
|
e1rope2 += ee1rope2 ;
|
|
e0nfcom += ee0nfcom ;
|
|
e0nper += ee0nper ;
|
|
e0aimp += ee0aimp ;
|
|
e0snsrit += ee0snsrit ;
|
|
e0rope += ee0rope ;
|
|
h0codlav += hh0codlav ;
|
|
h0coldip += hh0coldip ;
|
|
c0nfcom += cc0nfcom ;
|
|
c0nlass += cc0nlass ;
|
|
c0actot += cc0actot ;
|
|
c0snsrit += cc0snsrit ;
|
|
c0rope += cc0rope ;
|
|
d0nfcom += dd0nfcom ;
|
|
d0nlaut += dd0nlaut ;
|
|
d0actot += dd0actot ;
|
|
d0snsrit += dd0snsrit ;
|
|
d0rope += dd0rope ;
|
|
|
|
base.put(BSE_D1NFCOM, d1nfcom);
|
|
base.put(BSE_D1NPER, d1nper);
|
|
base.put(BSE_D1TACOR, d1tacor);
|
|
base.put(BSE_D1SNSRIT, d1snsrit);
|
|
base.put(BSE_D1ROPE, d1rope);
|
|
basebis.put(BSB_E1NFCOM, e1nfcom);
|
|
basebis.put(BSB_E1NPER, e1nper);
|
|
basebis.put(BSB_E1SCOR, e1scor);
|
|
basebis.put(BSB_E1BCOM, e1bcom);
|
|
basebis.put(BSB_E1ROPE, e1rope);
|
|
basebis.put(BSB_E1ACOM, e1acom);
|
|
basebis.put(BSB_E1BCOM2, e1bcom2);
|
|
basebis.put(BSB_E1ROPE2, e1rope2);
|
|
|
|
basebis.put(BSB_E0NFCOM, e0nfcom);
|
|
basebis.put(BSB_E0NPER, e0nper);
|
|
basebis.put(BSB_E0AIMP, e0aimp);
|
|
basebis.put(BSB_E0SNSRIT, e0snsrit);
|
|
basebis.put(BSB_E0ROPE, e0rope);
|
|
|
|
basebis.put(BSB_H0CODLAV, h0codlav);
|
|
basebis.put(BSB_H0COLDIP, h0coldip);
|
|
base.put(BSE_C0NFCOM, c0nfcom);
|
|
base.put(BSE_C0NLASS, c0nlass);
|
|
base.put(BSE_C0ACTOT, c0actot);
|
|
base.put(BSE_C0SNSRIT, c0snsrit);
|
|
base.put(BSE_C0ROPE, c0rope);
|
|
|
|
base.put(BSE_D0NFCOM, d0nfcom);
|
|
base.put(BSE_D0NLAUT, d0nlaut);
|
|
base.put(BSE_D0ACTOT, d0actot);
|
|
base.put(BSE_D0SNSRIT, d0snsrit);
|
|
base.put(BSE_D0ROPE, d0rope);
|
|
|
|
ret1 = base.rewrite();
|
|
ret2 = basebis.rewrite();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// Calcola i riporti dai quadri al quadro I per la ditta codditta.
|
|
// Esegue i riporti anche su dichiarante se specificato
|
|
bool TRiporti::set(const TString& quadro, int anno, const long codditta, const long dichiarante)
|
|
{
|
|
TString16 filt;
|
|
TRelation* rel;
|
|
TCursor* cur;
|
|
long codditta_dich = 0L;
|
|
|
|
_codditta = codditta ? codditta : get_firm_770();
|
|
_annodic = anno ? anno : anno_770();
|
|
_quadro = quadro;
|
|
|
|
this_riporti = this;
|
|
|
|
if (quadro == "A" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAA);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_A(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "A1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAA1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_A1(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "A2" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAA2);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_A2(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "A3" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAA3);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_A3(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "B" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAB);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_B(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "B1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAB1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_B1(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "H" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAH);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
cur->set_filterfunction (filter_func);
|
|
calcola_riporti_H(cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "C" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAC);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_C (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "D" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAD);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_D (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "D1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAD1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_D1 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "E" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAE);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_E (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "E1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAE1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_E1 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "E2" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAE2);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_E2 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "F" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAF);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_F (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "F1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAF1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_F1 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "F2" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAF2);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_F2 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "G" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAG);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_G (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
|
|
if (quadro == "G1" || quadro == "*")
|
|
{
|
|
rel = new TRelation (LF_QUAG1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
cur = new TCursor(rel,filt,1);
|
|
calcola_riporti_G1 (cur, dichiarante);
|
|
delete cur; delete rel;
|
|
}
|
|
setta_flag_quadro_I(_codditta);
|
|
return TRUE;
|
|
}
|
|
|
|
const int NUM_DIP_A = 9;
|
|
|
|
void TRiporti::calcola_riporti_A(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real totale,somme,ritenute;
|
|
bool almeno_una_riga = FALSE;
|
|
long dipendenti,num_rec;
|
|
|
|
real a0cobb,a0cnet,a0eprev,a0iitra,a0cter,a0timp,a0ilor,a0tdet,a0rter,a0rdat;
|
|
real a0erit,a0carr,a0aarr,a0darr,a0rarr,a0cinps,a0ciiaut,a0crimpras,a0incdet;
|
|
|
|
a0cobb = ZERO; a0cnet = ZERO; a0eprev = ZERO; a0iitra = ZERO; a0cter = ZERO;
|
|
a0timp = ZERO; a0ilor = ZERO; a0tdet = ZERO; a0rter = ZERO; a0rdat = ZERO;
|
|
a0erit = ZERO; a0carr = ZERO; a0aarr = ZERO; a0darr = ZERO; a0rarr = ZERO;
|
|
a0cinps = ZERO; a0ciiaut = ZERO; a0crimpras = a0incdet = ZERO;
|
|
|
|
dipendenti = 0;
|
|
num_rec = 0;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
|
|
scritta.format("Calcolo riporti del quadro A per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
long coddipp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
progn.addstatus(1);
|
|
|
|
long coddip = cur->curr().get_long(QUA_CODIP);
|
|
|
|
bool compilato = FALSE;
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
for (int i = 0; i < CAMPI_A; i++)
|
|
if (cur->curr().get_real(_campi_A[i]) != ZERO)
|
|
{
|
|
compilato = TRUE;
|
|
break;
|
|
}
|
|
|
|
if (!compilato)
|
|
continue;
|
|
|
|
num_rec++;
|
|
|
|
if (coddip != coddipp)
|
|
if (!is_erede(_codditta,coddip))
|
|
dipendenti++;
|
|
|
|
coddipp = coddip;
|
|
|
|
int causa = cur->curr().get_int (QUA_CAUSA);
|
|
TString codfis = cur->curr().get (QUA_CODFISDL);
|
|
char retcon = cur->curr().get_char(QUA_RETCON);
|
|
|
|
if (retcon != 'B' && codfis.empty())
|
|
{
|
|
a0cobb += cur->curr().get_real(QUA_COBBDIP);
|
|
a0cnet += cur->curr().get_real(QUA_COMPNETTI);
|
|
a0eprev += cur->curr().get_real(QUA_AIENTIPREV);
|
|
a0iitra += cur->curr().get_real(QUA_TOTIMP);
|
|
// a0cter += cur->curr().get_real(QUA_CCTAMMCONT) + cur->curr().get_real(QUA_CCTAMNACON);
|
|
a0cter += cur->curr().get_real(QUA_CCTAMMCONT);
|
|
a0timp += cur->curr().get_real(QUA_TOTIMP2);
|
|
a0ilor += cur->curr().get_real(QUA_ICTOTIMP);
|
|
a0tdet += cur->curr().get_real(QUA_TOTDET);
|
|
a0rter += cur->curr().get_real(QUA_AMRIOT);
|
|
a0rdat += cur->curr().get_real(QUA_AMRIODL);
|
|
a0erit += cur->curr().get_real(QUA_ECCRITRIMB);
|
|
a0carr += cur->curr().get_real("COBBDIP2"); // cas.46
|
|
a0aarr += cur->curr().get_real(QUA_AMMIMP);
|
|
a0darr += cur->curr().get_real(QUA_DETIMPOS);
|
|
a0rarr += cur->curr().get_real(QUA_RITESEG);
|
|
a0incdet += cur->curr().get_real("INCDETFC"); // cas.38
|
|
}
|
|
}
|
|
|
|
long fogli = num_rec / NUM_DIP_A;
|
|
if (num_rec % NUM_DIP_A)
|
|
fogli++;
|
|
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal,_lock) == NOERR)
|
|
{
|
|
base.put(BSE_A0NFCOM, fogli);
|
|
base.put(BSE_A0NLDIP, (long)dipendenti);
|
|
base.put(BSE_A0COBB, a0cobb);
|
|
base.put(BSE_A0CNET, a0cnet);
|
|
base.put(BSE_A0EPREV, a0eprev);
|
|
base.put(BSE_A0IITRA, a0iitra);
|
|
base.put(BSE_A0CTER, a0cter);
|
|
base.put(BSE_A0TIMP, a0timp);
|
|
base.put(BSE_A0ILOR, a0ilor);
|
|
base.put(BSE_A0TDET, a0tdet);
|
|
base.put(BSE_A0RTER, a0rter);
|
|
base.put(BSE_A0RDAT, a0rdat);
|
|
base.put(BSE_A0ERIT, a0erit);
|
|
base.put(BSE_A0CARR, a0carr);
|
|
base.put(BSE_A0AARR, a0aarr);
|
|
base.put(BSE_A0DARR, a0darr);
|
|
base.put(BSE_A0RARR, a0rarr);
|
|
base.put("A0INCDET", a0incdet);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, A, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti A");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
const int NUM_DIPENDENTI_MODULO_A3 = 35;
|
|
|
|
void TRiporti::calcola_riporti_A3(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
bool almeno_una_riga = FALSE;
|
|
long dipendenti=0L, num_rec=0L;
|
|
real a3rept10=ZERO,a3rept12=ZERO;
|
|
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro A3 per la ditta %ld", _codditta);
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
// fogli per l'elenco delle trasf.
|
|
int iFogliTrasf=0;
|
|
int iDipTrasf=0;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
progn.addstatus(1);
|
|
const long coddip = cur->curr().get_long(QUA_CODIP);
|
|
const long nprog = cur->curr().get_long(QUA_NPROG);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
// Non conta quelli con redditto corrisposto = ZERO
|
|
if ((cur->curr().get_real(QA3_REDCOR16) == ZERO) && (cur->curr().get_real(QA3_REDCOR18) == ZERO))
|
|
continue;
|
|
|
|
// nprog=2 se e' il record della trasformata. Conto i dip.con trasf. per
|
|
// contare i fogli
|
|
if (nprog == 2)
|
|
iDipTrasf++;
|
|
|
|
dipendenti++;
|
|
|
|
a3rept10 += cur->curr().get_real(QA3_REDCOR16);
|
|
a3rept12 += cur->curr().get_real(QA3_REDCOR18);
|
|
}
|
|
|
|
long fogli = dipendenti / NUM_DIPENDENTI_MODULO_A3;
|
|
if (dipendenti % NUM_DIPENDENTI_MODULO_A3)
|
|
fogli++;
|
|
iFogliTrasf = iDipTrasf / NUM_DIPENDENTI_MODULO_A3;
|
|
if (iDipTrasf % NUM_DIPENDENTI_MODULO_A3)
|
|
iFogliTrasf++;
|
|
fogli += iFogliTrasf;
|
|
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal,_lock) == NOERR)
|
|
{
|
|
base.put(BSE_A3NFCOM, fogli);
|
|
base.put(BSE_A3NUMPER, (long)dipendenti);
|
|
base.put(BSE_A3REPT10, a3rept10);
|
|
base.put(BSE_A3REPT12, a3rept12);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, A3, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti A3");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_A1(TCursor* cur, const long dich)
|
|
{
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
|
|
scritta.format("Calcolo riporti del quadro A1 per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
progn.addstatus(1);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
}
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, A1, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti A1");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_A2(TCursor* cur, const long dich)
|
|
{
|
|
bool almeno_una_riga = FALSE;
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro A2 per la ditta %ld", _codditta);
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
progn.addstatus(1);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
}
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, A2, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti A2");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_H(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
real ritdat,ritlav;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
ritdat = ZERO;
|
|
ritlav = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
// if (items == 0L) return;
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro H per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
ritdat += cur->curr().get_real(QUH_H1DAT);
|
|
ritlav += cur->curr().get_real(QUH_H1LAV);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_H0CODLAV, ritdat);
|
|
basebis.put(BSB_H0COLDIP, ritlav);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, H, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
const int NUM_PERC_C = 36;
|
|
|
|
void TRiporti::calcola_riporti_C(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real totale,somme,ritenute,rTotCSSN;
|
|
bool almeno_una_riga = FALSE;
|
|
long percipienti=0L;
|
|
|
|
totale = ZERO;
|
|
somme = ZERO;
|
|
ritenute = ZERO;
|
|
rTotCSSN = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
// if (items == 0L) return;
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro C per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
char tipoa = cur->curr().get_char(QUC_TIPOA);
|
|
long codanagr = cur->curr().get_long(QUC_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
totale += cur->curr().get_real(QUC_TOTALE);
|
|
somme += cur->curr().get_real(QUC_SOMME);
|
|
ritenute += cur->curr().get_real(QUC_RITENUTE);
|
|
rTotCSSN += cur->curr().get_real(QUC_CONTSSN);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
long fogli = percipienti / NUM_PERC_C;
|
|
if (percipienti % NUM_PERC_C)
|
|
fogli++;
|
|
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal,_lock) == NOERR)
|
|
{
|
|
base.put(BSE_C0NFCOM, fogli);
|
|
base.put(BSE_C0NLASS, (long)percipienti);
|
|
base.put(BSE_C0ACTOT, totale);
|
|
base.put(BSE_C0SNSRIT, somme);
|
|
base.put(BSE_C0ROPE, ritenute);
|
|
base.put(BSE_C0CONTSSN, rTotCSSN);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, C, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti C");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_D(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real totale,somme,ritenute;
|
|
bool almeno_una_riga = FALSE;
|
|
int percipienti;
|
|
int fisiche,giuridiche;
|
|
|
|
percipienti = 0;
|
|
fisiche = 0;
|
|
giuridiche = 0;
|
|
|
|
totale = ZERO;
|
|
somme = ZERO;
|
|
ritenute = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
// if (items == 0L) return;
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro D per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
char tipoa = cur->curr().get_char(QUD_TIPOA);
|
|
long codanagr = cur->curr().get_long(QUD_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
if (tipoa == 'F')
|
|
fisiche++;
|
|
else
|
|
if (tipoa == 'G')
|
|
giuridiche++;
|
|
|
|
totale += cur->curr().get_real(QUD_TOTALE);
|
|
somme += cur->curr().get_real(QUD_SOMME);
|
|
ritenute += cur->curr().get_real(QUD_IMPORTO);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
const long fogli = fogli_compilati(fisiche,giuridiche,QD_FISICHE_PER_FOGLIO,QD_NOFISICHE_PER_FOGLIO);
|
|
|
|
base.setkey(1);
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal,_lock) == NOERR)
|
|
{
|
|
base.put(BSE_D0NFCOM, fogli);
|
|
base.put(BSE_D0NLAUT, (long)percipienti);
|
|
base.put(BSE_D0ACTOT, totale);
|
|
base.put(BSE_D0SNSRIT, somme);
|
|
base.put(BSE_D0ROPE, ritenute);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, D, almeno_una_riga, basebis, dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti D");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_D1(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real totale,somme,importo;
|
|
bool almeno_una_riga = FALSE;
|
|
int percipienti,fisiche,giuridiche;
|
|
|
|
percipienti = 0;
|
|
fisiche = 0;
|
|
giuridiche = 0;
|
|
|
|
totale = ZERO;
|
|
somme = ZERO;
|
|
importo = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro D1 per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
char tipoa = cur->curr().get_char(QD1_TIPOA);
|
|
long codanagr = cur->curr().get_long(QD1_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
if (tipoa == 'F')
|
|
fisiche++;
|
|
else
|
|
if (tipoa == 'G')
|
|
giuridiche++;
|
|
|
|
totale += cur->curr().get_real(QD1_TOTALE);
|
|
somme += (cur->curr().get_real(QD1_QUOTAPRO)) + (cur->curr().get_real(QD1_SPESEANT));
|
|
importo += cur->curr().get_real(QD1_IMPORTO);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
const long fogli = fogli_compilati(fisiche,giuridiche,QD1_FISICHE_PER_FOGLIO,QD1_NOFISICHE_PER_FOGLIO);
|
|
|
|
base.setkey(1);
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal,_lock) == NOERR)
|
|
{
|
|
base.put(BSE_D1NFCOM, fogli);
|
|
base.put(BSE_D1NPER, (long)percipienti);
|
|
base.put(BSE_D1TACOR, totale);
|
|
base.put(BSE_D1SNSRIT, somme);
|
|
base.put(BSE_D1ROPE, importo);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, D1, almeno_una_riga,basebis,dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti D1");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_E(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
real imponibile,somme,ritenute;
|
|
bool almeno_una_riga = FALSE;
|
|
int percipienti,fisiche,giuridiche;
|
|
|
|
percipienti = 0;
|
|
fisiche = 0;
|
|
giuridiche = 0;
|
|
|
|
imponibile = ZERO;
|
|
somme = ZERO;
|
|
ritenute = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
// if (items == 0L) return;
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro E per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
char tipoa = cur->curr().get_char(QUE_TIPOA);
|
|
long codanagr = cur->curr().get_long(QUE_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
if (tipoa == 'F')
|
|
fisiche++;
|
|
else
|
|
if (tipoa == 'G')
|
|
giuridiche++;
|
|
|
|
imponibile += cur->curr().get_real(QUE_IMPONIBILE);
|
|
somme += cur->curr().get_real(QUE_SOMME);
|
|
ritenute += cur->curr().get_real(QUE_IMPORTO);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
const long fogli = fogli_compilati(fisiche,giuridiche,QE_FISICHE_PER_FOGLIO,QE_NOFISICHE_PER_FOGLIO);
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal,_lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_E0NFCOM, fogli);
|
|
basebis.put(BSB_E0NPER, (long)percipienti);
|
|
basebis.put(BSB_E0AIMP, imponibile);
|
|
basebis.put(BSB_E0SNSRIT, somme);
|
|
basebis.put(BSB_E0ROPE, ritenute);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, E, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_E1(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
TRelation* relp;
|
|
TCursor* curp;
|
|
TString16 filt;
|
|
real ammontare,somme,ritenute;
|
|
real comp,impo,rite;
|
|
bool almeno_una_riga = FALSE;
|
|
int percipienti,righep;
|
|
|
|
percipienti = 0;
|
|
righep = 0;
|
|
|
|
ammontare = ZERO;
|
|
somme = ZERO;
|
|
ritenute = ZERO;
|
|
|
|
comp = ZERO;
|
|
impo = ZERO;
|
|
rite = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
// if (items == 0L) return;
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro E1 per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
char tipoa = cur->curr().get_char(QE1_TIPOA);
|
|
long codanagr = cur->curr().get_long(QE1_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
ammontare += cur->curr().get_real(QE1_AMMONTARE);
|
|
somme += cur->curr().get_real(QE1_SOMME);
|
|
ritenute += cur->curr().get_real(QE1_IMPORTO);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
relp = new TRelation (LF_PROSPE1);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
curp = new TCursor(relp,filt,1);
|
|
(*curp) = 0L;
|
|
TRecnotype itemp = curp->items();
|
|
scritta.format("Calcolo riporti del prospetto del quadro E1 per la ditta %ld", _codditta);
|
|
TProgind prognp(itemp, scritta, FALSE, TRUE);
|
|
|
|
for (int j = 0; j < itemp; j++, ++(*curp))
|
|
{
|
|
righep++;
|
|
|
|
comp += curp->curr().get_real(PRE_COMPENSO);
|
|
impo += curp->curr().get_real(PRE_IMPONIBILE);
|
|
rite += curp->curr().get_real(PRE_RITENUTA);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
prognp.addstatus(1);
|
|
}
|
|
|
|
delete curp;
|
|
delete relp;
|
|
|
|
const long fogli = fogli_compilati(percipienti,righep,QE1_PERCIPIENTI_PER_FOGLIO,QE1_RIGHE_PROSPETTO);
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_E1NFCOM, fogli);
|
|
basebis.put(BSB_E1NPER, (long)percipienti);
|
|
basebis.put(BSB_E1SCOR, somme);
|
|
basebis.put(BSB_E1BCOM, ammontare );
|
|
basebis.put(BSB_E1ROPE, ritenute );
|
|
basebis.put(BSB_E1ACOM, comp);
|
|
basebis.put(BSB_E1BCOM2, impo);
|
|
basebis.put(BSB_E1ROPE2, rite);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, E1, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_E2(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
long fisiche, no_fisiche;
|
|
long fogli_comp;
|
|
real soggrit, rope;
|
|
real comp,impo,rite;
|
|
bool almeno_una_riga = FALSE;
|
|
double percipienti;
|
|
|
|
fisiche = no_fisiche = fogli_comp = 0L;
|
|
percipienti = 0.00;
|
|
|
|
soggrit = ZERO;
|
|
rope = ZERO;
|
|
|
|
comp = ZERO;
|
|
impo = ZERO;
|
|
rite = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
|
|
TRecnotype items = cur->items();
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro E2 per la ditta %ld", _codditta);
|
|
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
const char tipoa = cur->curr().get_char(QE2_TIPOA);
|
|
const long codanagr = cur->curr().get_long(QE2_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
if (tipoa == 'F')
|
|
fisiche++;
|
|
else
|
|
no_fisiche++;
|
|
|
|
soggrit += cur->curr().get_real(QE2_SOGGRIT);
|
|
rope += cur->curr().get_real(QE2_ROPE);
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
fogli_comp = fogli_compilati(fisiche,no_fisiche,QE2_FISICHE_PER_FOGLIO,QE2_NOFISICHE_PER_FOGLIO);
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_E2NFCOM, fogli_comp);
|
|
basebis.put(BSB_E2NPER, (long)percipienti);
|
|
basebis.put(BSB_E2SSRIT, soggrit);
|
|
basebis.put(BSB_E2ROPE, rope );
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, E2, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_F(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
TLocalisamfile* rf;
|
|
TRecord_array* _prosp_a, *_prosp_b, *_prosp_c, *_prosp_d;
|
|
real a_sogrit, a_rope, a_totacc, f_rope, e_rope, f_sogrit, e_sogrit;
|
|
real b_sogrit, b_rope, c_sogrit, c_rope, d_sogrit, d_rope;
|
|
real i20_1, i20_2, i20_3, i20_4, i20_5, i20_6, i21_1, i21_2, i21_3;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
a_sogrit = a_rope = a_totacc = ZERO;
|
|
b_sogrit = b_rope = c_sogrit = c_rope = d_sogrit = d_rope = ZERO;
|
|
f_rope = e_rope = f_sogrit = e_sogrit = ZERO;
|
|
i20_1 = i20_2 = i20_3 = i20_4 = i20_5 = i20_6 = i21_1 = i21_2 = i21_3 = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro F per la ditta %ld", _codditta);
|
|
|
|
i20_4 = cur->curr().get_real(QF0_A1);
|
|
i20_5 = cur->curr().get_real(QF0_A2);
|
|
i20_6 = cur->curr().get_real(QF0_A3);
|
|
i21_1 = cur->curr().get_real(QF0_A4);
|
|
e_sogrit = cur->curr().get_real(QF0_ESOGRIT);
|
|
f_sogrit = cur->curr().get_real(QF0_FSOGRIT);
|
|
e_rope = cur->curr().get_real(QF0_EROPE);
|
|
f_rope = cur->curr().get_real(QF0_FROPE);
|
|
|
|
// Per stabilire se il quadro e' stato compilato verifica anche i campi
|
|
// fuori dagli spreadsheet
|
|
almeno_una_riga = i20_4 != ZERO || i20_5 != ZERO || i20_6 != ZERO ||
|
|
i21_1 != ZERO || e_sogrit != ZERO || f_sogrit != ZERO || e_rope != ZERO ||
|
|
f_rope != ZERO;
|
|
|
|
rf = new TLocalisamfile(LF_RIGHEF);
|
|
|
|
TRectype dep(rf->curr());
|
|
dep.zero();
|
|
dep.put("CODDITTA", _codditta);
|
|
dep.put("TIPOPRO", "A");
|
|
_prosp_a = new TRecord_array(dep, "NPROG");
|
|
_prosp_a->read(dep);
|
|
dep.put("TIPOPRO", "B");
|
|
_prosp_b = new TRecord_array(dep, "NPROG");
|
|
_prosp_b->read(dep);
|
|
dep.put("TIPOPRO", "C");
|
|
_prosp_c = new TRecord_array(dep, "NPROG");
|
|
_prosp_c->read(dep);
|
|
dep.put("TIPOPRO", "D");
|
|
_prosp_d = new TRecord_array(dep, "NPROG");
|
|
_prosp_d->read(dep);
|
|
|
|
items = _prosp_a->last_row() + _prosp_b->last_row() + _prosp_c->last_row() + _prosp_d->last_row();
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 1; i <= _prosp_a->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_a->row(i, TRUE);
|
|
a_sogrit += r.get_real(RQF0_SOGRIT);
|
|
a_rope += r.get_real(RQF0_ROPE);
|
|
a_totacc += r.get_real(RQF0_TOTACC);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
i20_1 = a_sogrit;
|
|
i20_2 = a_rope;
|
|
i20_3 = a_totacc;
|
|
|
|
for (i = 1; i <= _prosp_b->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_b->row(i, TRUE);
|
|
b_sogrit += r.get_real(RQF0_SOGRIT);
|
|
b_rope += r.get_real(RQF0_ROPE);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
for (i = 1; i <= _prosp_c->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_c->row(i, TRUE);
|
|
c_sogrit += r.get_real(RQF0_SOGRIT);
|
|
c_rope += r.get_real(RQF0_ROPE);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
for (i = 1; i <= _prosp_d->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_d->row(i, TRUE);
|
|
d_sogrit += r.get_real(RQF0_SOGRIT);
|
|
d_rope += r.get_real(RQF0_ROPE);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
i21_2 += b_sogrit + c_sogrit + d_sogrit + e_sogrit + f_sogrit;
|
|
i21_3 += b_rope + c_rope + d_rope + e_rope + f_rope;
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_F0SRITA, i20_1);
|
|
basebis.put(BSB_F0ROPEA, i20_2);
|
|
basebis.put(BSB_F0TACCA, i20_3);
|
|
basebis.put(BSB_F0EDACCA, i20_4);
|
|
basebis.put(BSB_F0ERIMA, i20_5);
|
|
basebis.put(BSB_F0SSVA, i20_6);
|
|
basebis.put(BSB_F0ROPEVA, i21_1);
|
|
basebis.put(BSB_F0SSRITBF, i21_2);
|
|
basebis.put(BSB_F0ROPEBF, i21_3);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, F, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_F1(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
TLocalisamfile* rf;
|
|
TRecord_array* _prosp_b;
|
|
real b_sogrit, b_rope;
|
|
real i22_1, i22_2;
|
|
real f1a1=ZERO, f1a2=ZERO;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
b_sogrit = b_rope = ZERO;
|
|
i22_1 = i22_2 = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro F-1 per la ditta %ld", _codditta);
|
|
|
|
TLocalisamfile f1(LF_QUAF1);
|
|
f1.zero();
|
|
f1.put("CODDITTA", _codditta);
|
|
f1.read();
|
|
f1a1 = f1.get_real("F1_A1");
|
|
f1a2 = f1.get_real("F1_A2");
|
|
almeno_una_riga = (f1a1 != ZERO) || (f1a2 != ZERO);
|
|
|
|
rf = new TLocalisamfile(LF_RIGHEF1);
|
|
|
|
TRectype dep(rf->curr());
|
|
dep.zero();
|
|
dep.put("CODDITTA", _codditta);
|
|
dep.put("TIPOPRO", "B");
|
|
_prosp_b = new TRecord_array(dep, "NPROG");
|
|
_prosp_b->read(dep);
|
|
|
|
items = _prosp_b->last_row();
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
i22_1 = cur->curr().get_real(QF1_A1);
|
|
i22_2 = cur->curr().get_real(QF1_A2);
|
|
|
|
for (int i = 1; i <= _prosp_b->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_b->row(i, TRUE);
|
|
b_sogrit += r.get_real(RQF1_SOGRIT);
|
|
b_rope += r.get_real(RQF1_ROPE);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
i22_1 += b_sogrit;
|
|
i22_2 += b_rope;
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_F1SSRIT, i22_1);
|
|
basebis.put(BSB_F1ROPE, i22_2);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, F1, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_F2(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
TLocalisamfile* rf;
|
|
TRecord_array* _prosp_b;
|
|
real b_sogrit, b_rope;
|
|
real i23_1, i23_2;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
b_sogrit = b_rope = ZERO;
|
|
i23_1 = i23_2 = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro F-2 per la ditta %ld", _codditta);
|
|
|
|
rf = new TLocalisamfile(LF_RIGHEF2);
|
|
|
|
TRectype dep(rf->curr());
|
|
dep.zero();
|
|
dep.put("CODDITTA", _codditta);
|
|
dep.put("TIPOPRO", "B");
|
|
_prosp_b = new TRecord_array(dep, "NPROG");
|
|
_prosp_b->read(dep);
|
|
|
|
items = _prosp_b->last_row();
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 1; i <= _prosp_b->last_row(); i++)
|
|
{
|
|
TRectype& r = _prosp_b->row(i, TRUE);
|
|
b_sogrit += r.get_real(RQF2_SOGRIT);
|
|
b_rope += r.get_real(RQF2_ROPE);
|
|
if (!almeno_una_riga) almeno_una_riga = TRUE;
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
i23_1 += b_sogrit;
|
|
i23_2 += b_rope;
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_F2SSRIT, i23_1);
|
|
basebis.put(BSB_F2ROPE, i23_2);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, F2, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
//
|
|
// fogli_compilati
|
|
//
|
|
// Determina il numero di fogli compilati:
|
|
// Divide il numero di persone (F o G) trovate per il numero
|
|
// di posti previsto nel modulo.
|
|
// Se il resto e' diverso da 0 conta un foglio in piu'
|
|
//
|
|
long fogli_compilati(const long fisiche, const long no_fisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio)
|
|
{
|
|
long fogli_compilati=0L, fogli_fisiche=0L, fogli_nofisiche=0L;
|
|
|
|
if (fisiche > 0L)
|
|
{
|
|
fogli_fisiche = fisiche / fisiche_x_foglio;
|
|
if (fisiche % fisiche_x_foglio)
|
|
fogli_fisiche += 1;
|
|
}
|
|
|
|
if (no_fisiche > 0L)
|
|
{
|
|
fogli_nofisiche = no_fisiche / nofisiche_x_foglio;
|
|
if (no_fisiche % nofisiche_x_foglio)
|
|
fogli_nofisiche += 1;
|
|
}
|
|
fogli_compilati = fogli_fisiche > fogli_nofisiche ? fogli_fisiche : fogli_nofisiche;
|
|
return fogli_compilati;
|
|
}
|
|
|
|
void TRiporti::calcola_riporti_G(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
real b_sogrit, b_rope;
|
|
real i24_1, i24_2, i24_3, i24_4, i24_5, i24_6;
|
|
real i24_7, i24_8, i24_9, i24_10, i24_11, i24_12;
|
|
real i24_13, i25_4;
|
|
bool almeno_una_riga=FALSE, almeno_una_riga_distinta=FALSE,almeno_una_riga_prospetti=FALSE;
|
|
long fogli_comp = 0L, percipienti=0L;
|
|
TRelation* relp;
|
|
TCursor* curp;
|
|
int fisiche = 0, no_fisiche = 0;
|
|
TString filt(20);
|
|
|
|
i24_1 = i24_2 = i24_3 = i24_4 = i24_5 = i24_6 = ZERO;
|
|
i24_7 = i24_8 = i24_9 = i24_10 = i24_11 = i24_12 = ZERO;
|
|
i24_13 = ZERO;
|
|
i25_4 = ZERO;
|
|
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
|
|
// Legge quadro G
|
|
i24_2 = cur->curr().get_real(QG_P1NUMQT);
|
|
i24_3 = cur->curr().get_real(QG_P1AMMT);
|
|
i24_4 = cur->curr().get_real(QG_P2VALT);
|
|
i24_5 = cur->curr().get_real(QG_P22TOT);
|
|
i24_6 = cur->curr().get_real(QG_P33TOT);
|
|
i24_7 = cur->curr().get_real(QG_P35TOT);
|
|
i24_8 = cur->curr().get_real(QG_P36TOT);
|
|
i24_9 = cur->curr().get_real(QG_P37TOT);
|
|
almeno_una_riga_prospetti = i24_2 != ZERO || i24_3 != ZERO
|
|
|| i24_4 != ZERO
|
|
|| i24_5 != ZERO || i24_6 != ZERO || i24_7 != ZERO
|
|
|| i24_8 != ZERO || i24_9 != ZERO;
|
|
|
|
TString scritta(60);
|
|
// scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta);
|
|
|
|
// Scorre quadrogd (distinta)
|
|
relp = new TRelation (LF_QUAGD);
|
|
filt.format("CODDITTA=%ld", _codditta);
|
|
curp = new TCursor(relp,filt,1);
|
|
(*curp) = 0L;
|
|
TRecnotype ItemDistinta = curp->items();
|
|
scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta);
|
|
TProgind progn(ItemDistinta, scritta, FALSE, TRUE);
|
|
|
|
char tipoap = 'Z';
|
|
long codanagrp = -1;
|
|
|
|
for (int i = 0; i < ItemDistinta; i++, ++(*curp))
|
|
{
|
|
const char tipoa = curp->curr().get_char(QGD_TIPOA);
|
|
const long codanagr = curp->curr().get_long(QGD_CODANAGR);
|
|
|
|
if ( (tipoa != tipoap) || (codanagr != codanagrp) )
|
|
percipienti++;
|
|
|
|
tipoap = tipoa;
|
|
codanagrp = codanagr;
|
|
|
|
if (tipoa == 'F')
|
|
fisiche++;
|
|
else
|
|
no_fisiche++;
|
|
|
|
i24_11 += curp->curr().get_real(QGD_UTSPETT);
|
|
i24_12 += curp->curr().get_real(QGD_UTPAG);
|
|
i24_13 += curp->curr().get_real(QGD_ROPE);
|
|
i25_4 += curp->curr().get_real(QGD_ROPESPET);
|
|
|
|
almeno_una_riga_distinta = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
// E' compilato se c'e' qualcosa nel G o nella distinta fax 15.7.96 p.1
|
|
almeno_una_riga = almeno_una_riga_prospetti || almeno_una_riga_distinta;
|
|
|
|
fogli_comp = fogli_compilati(fisiche,no_fisiche,QGD_FISICHE_PER_FOGLIO,QGD_NOFISICHE_PER_FOGLIO);
|
|
// Considera anche la parte del G (prospetti 1-2-3-4)
|
|
if (almeno_una_riga_prospetti && fogli_comp==0)
|
|
fogli_comp++;
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_G0NFCOM, (long)fogli_comp);
|
|
basebis.put(BSB_G0NPER, (long)percipienti);
|
|
basebis.put(BSB_G0USPE, i24_11);
|
|
basebis.put(BSB_G0UPAG, i24_12);
|
|
basebis.put(BSB_G0ROPE, i24_13);
|
|
basebis.put(BSB_G0NAZI1, i24_2);
|
|
basebis.put(BSB_G0UDEN1, i24_3);
|
|
basebis.put(BSB_G0UNAT1, i24_4);
|
|
basebis.put(BSB_G0IUTI2, i24_5);
|
|
basebis.put(BSB_G0USRIT3, i24_6);
|
|
basebis.put(BSB_G0RACC3, i24_7);
|
|
basebis.put(BSB_G0RIMP3, i24_8);
|
|
basebis.put(BSB_G0UNSRIT3, i24_9);
|
|
basebis.put(BSB_G0RITSPET, i25_4);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, G, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
}
|
|
|
|
|
|
void TRiporti::calcola_riporti_G1 (TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile basebis (LF_BASEBIS);
|
|
real i27_1, i27_2, i27_3, i27_4, i27_5;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
i27_1 = i27_2 = i27_3 = i27_4 = i27_5 = ZERO;
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
|
|
i27_1 = cur->curr().get_real(QG1_P12TOT);
|
|
i27_2 = cur->curr().get_real(QG1_P13TOT);
|
|
i27_3 = cur->curr().get_real(QG1_P15TOT);
|
|
i27_4 = cur->curr().get_real(QG1_P16TOT);
|
|
i27_5 = cur->curr().get_real(QG1_P17TOT);
|
|
|
|
almeno_una_riga = (i27_1 != ZERO) || (i27_2 != ZERO) || (i27_3 != ZERO) ||
|
|
(i27_4 != ZERO) || (i27_5 != ZERO);
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro G-1 per la ditta %ld", _codditta);
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
if (dich)
|
|
{
|
|
basebis.put("TIPOQUA", COD_QUA_I_DIC);
|
|
basebis.put(BSB_CODDITTA, dich);
|
|
}
|
|
else
|
|
basebis.put(BSB_CODDITTA, _codditta);
|
|
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
{
|
|
basebis.put(BSB_G1UCOR, i27_1);
|
|
basebis.put(BSB_G1USRIT, i27_2);
|
|
basebis.put(BSB_G1RACC, i27_3);
|
|
basebis.put(BSB_G1RIMP, i27_4);
|
|
basebis.put(BSB_G1UNSRIT, i27_5);
|
|
basebis.rewrite();
|
|
setta_flag_quadri_comp(_codditta, G1, almeno_una_riga,basebis,dich);
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
HIDDEN const int QB_NUMPERC_PER_FOGLIO = 16;
|
|
|
|
void TRiporti::calcola_riporti_B (TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real c3,c4,c5,c6,c7,c8,c9,c10;
|
|
real tc3,tc4,tc5,tc6,tc7,tc8,tc9,tc10;
|
|
int c2=0;
|
|
long c1=0L;
|
|
bool almeno_una_riga = FALSE;
|
|
int NumPerc=0;
|
|
long fogli_comp=0L;
|
|
TBit_array baGiaVisto;
|
|
|
|
c3=c4=c5=c6=c7=c8=c9=c10=ZERO;
|
|
tc3=tc5=tc6=tc7=tc8=tc9=tc10=ZERO;
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
almeno_una_riga = items > 0L;
|
|
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro B per la ditta %ld", _codditta);
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
const long codditta = cur->curr().get_long(QB_CODDITTA);
|
|
const long coddip = cur->curr().get_long(QB_CODDIP);
|
|
|
|
if (!baGiaVisto[coddip])
|
|
{
|
|
baGiaVisto.set(coddip);
|
|
if (!is_erede(codditta, coddip))
|
|
NumPerc++;
|
|
}
|
|
|
|
c3 = cur->curr().get_real(QB_C20);
|
|
c4 = cur->curr().get_real(QB_C24);
|
|
c5 = cur->curr().get_real(QB_C25);
|
|
c6 = cur->curr().get_real(QB_C26);
|
|
c7 = cur->curr().get_real(QB_C27);
|
|
c8 = cur->curr().get_real(QB_C36);
|
|
c9 = cur->curr().get_real(QB_C37);
|
|
c10 = cur->curr().get_real(QB_C43);
|
|
|
|
tc3 += c3;
|
|
tc4 += c4;
|
|
tc5 += c5;
|
|
tc6 += c6;
|
|
tc7 += c7;
|
|
tc8 += c8;
|
|
tc9 += c9;
|
|
tc10 += c10;
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
fogli_comp = fogli_compilati(items,0L,QB_NUMPERC_PER_FOGLIO,0);
|
|
|
|
c1 = fogli_comp;
|
|
c2 = NumPerc;
|
|
|
|
base.setkey(1);
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal, _lock) == NOERR)
|
|
{
|
|
base.put(I8_1,c1);
|
|
base.put(I8_2,(long)c2);
|
|
base.put(I8_3,tc3);
|
|
base.put(I8_4,tc4);
|
|
base.put(I8_5,tc5);
|
|
base.put(I8_6,tc6);
|
|
base.put(I9_7,tc7);
|
|
base.put(I9_8,tc8);
|
|
base.put(I9_9,tc9);
|
|
base.put(I9_10,tc10);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, B, almeno_una_riga,basebis,dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti B");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
HIDDEN const int QB1_NUMPERC_PER_FOGLIO = 14;
|
|
|
|
void TRiporti::calcola_riporti_B1(TCursor* cur, const long dich)
|
|
{
|
|
TLocalisamfile base (LF_BASE);
|
|
real c3,c4,c5;
|
|
real tc3,tc4,tc5;
|
|
int c2=0;
|
|
bool almeno_una_riga = FALSE;
|
|
int NumPerc=0;
|
|
long fogli_comp=0L, c1=0L;
|
|
|
|
c3=c4=c5=ZERO;
|
|
tc3=tc4=tc5=ZERO;
|
|
(*cur) = 0L;
|
|
TRecnotype items = cur->items();
|
|
almeno_una_riga = items > 0L;
|
|
|
|
TString scritta(60);
|
|
scritta.format("Calcolo riporti del quadro B-1 per la ditta %ld", _codditta);
|
|
TProgind progn(items, scritta, FALSE, TRUE);
|
|
|
|
for (int i = 0; i < items; i++, ++(*cur))
|
|
{
|
|
c3 = cur->curr().get_real(QB1_C11);
|
|
c4 = cur->curr().get_real(QB1_C12);
|
|
c5 = cur->curr().get_real(QB1_C18);
|
|
|
|
tc3 += c3;
|
|
tc4 += c4;
|
|
tc5 += c5;
|
|
|
|
NumPerc++;
|
|
|
|
if (!almeno_una_riga)
|
|
almeno_una_riga = TRUE;
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
fogli_comp = fogli_compilati(items,0L,QB1_NUMPERC_PER_FOGLIO,0);
|
|
|
|
c1 = fogli_comp;
|
|
// c2 = items;
|
|
|
|
base.setkey(1);
|
|
base.zero();
|
|
if (dich)
|
|
{
|
|
base.put("TIPOQUA", COD_QUA_I_DIC);
|
|
base.put(BSE_CODDITTA, dich);
|
|
}
|
|
else
|
|
base.put(BSE_CODDITTA, _codditta);
|
|
|
|
if (base.read(_isequal, _lock) == NOERR)
|
|
{
|
|
base.put(I11_1,c1);
|
|
base.put(I11_2,(long)items);
|
|
base.put(I11_3,tc3);
|
|
base.put(I11_4,tc4);
|
|
base.put(I11_5,tc5);
|
|
base.rewrite();
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, _codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(_codditta, B1, almeno_una_riga,basebis,dich);
|
|
else
|
|
warning_box("Lock fallito in calcola_riporti B1");
|
|
}
|
|
else
|
|
warning_box("Dichiarazione non presente. Impossibile registrare i riporti");
|
|
|
|
progn.addstatus(1);
|
|
}
|
|
|
|
|
|
void TRiporti::set_compilato(const long codditta, const int posquadro, const bool compilato)
|
|
{
|
|
TLocalisamfile basebis(LF_BASEBIS);
|
|
basebis.setkey(1);
|
|
basebis.zero();
|
|
basebis.put(BSE_CODDITTA, codditta);
|
|
if (basebis.read(_isequal, _lock) == NOERR)
|
|
setta_flag_quadri_comp(codditta,posquadro,compilato,basebis);
|
|
else
|
|
warning_box("Lock fallito in set_compilato");
|
|
}
|
|
|