Files correlati : Ricompilazione Demo : [ ] Commento :bug 830 git-svn-id: svn://10.65.10.50/trunk@17605 c028cbd2-c16b-5b4b-a496-9718f37d4682
458 lines
11 KiB
C++
Executable File
458 lines
11 KiB
C++
Executable File
// cg3301.cpp
|
|
//
|
|
// classi di supporto per cg3300_application
|
|
//
|
|
|
|
#include <stdlib.h>
|
|
#include <diction.h>
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
#include <scanner.h>
|
|
|
|
#include <comuni.h>
|
|
#include <clifo.h>
|
|
#include <alleg.h>
|
|
#include <nditte.h>
|
|
#include <anagr.h>
|
|
#include <anafis.h>
|
|
#include <anagiu.h>
|
|
|
|
#include "cg3300.h"
|
|
|
|
//
|
|
// SortRecord
|
|
//
|
|
|
|
SortRecord::SortRecord()
|
|
{
|
|
_all = new struct alleg_sort;
|
|
azzera_struttura();
|
|
}
|
|
|
|
SortRecord::~SortRecord()
|
|
{
|
|
delete _all;
|
|
}
|
|
|
|
const char* SortRecord::decodifica_desc_att (const TString& codatt)
|
|
{ return cache().get("%AIS", codatt, "S0"); }
|
|
|
|
const TRectype & SortRecord::look_com(const char * cod)
|
|
{
|
|
TString8 key;
|
|
key << '|' << cod;
|
|
return cache().get(LF_COMUNI, key);
|
|
}
|
|
|
|
//
|
|
// Ricerca la ragione sociale in clifo
|
|
// Controlla il tipo di persona , se fisica scrive nome e cognome
|
|
// e tipo di persona nella struttura puntata da _RecordSort->Strutt
|
|
// Se e' persona fisica mette a '\0' il campo ragsoc_dett
|
|
//
|
|
// Ritorna la ragione sociale oppure NULL
|
|
//
|
|
const char * SortRecord::fill_dati_dettaglio (char tipocf, long codcf)
|
|
{
|
|
TString8 key;
|
|
key << tipocf << '|' << codcf;
|
|
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
TString indcf;
|
|
|
|
indcf = clifo.get (CLI_INDCF);
|
|
indcf << ", " << clifo.get (CLI_CIVCF);
|
|
strcpy (_all->via_dett, indcf);
|
|
strcpy (_all->paiva_dett, clifo.get (CLI_PAIV));
|
|
strcpy (_all->statopaiva_dett, clifo.get (CLI_STATOPAIV));
|
|
|
|
const TRectype & dep = look_com ((const char *)clifo.get (CLI_COMCF));
|
|
|
|
strcpy (_all->comune_dett, dep.get(COM_DENCOM));
|
|
strcpy (_all->prov_dett, dep.get(COM_PROVCOM));
|
|
|
|
const TString & rag = clifo.get (CLI_RAGSOC);
|
|
if (clifo.get (CLI_TIPOPERS) == "F")
|
|
{
|
|
strcpy (_all->cognome_dett, rag.left(30));
|
|
strcpy (_all->nome_dett, rag.mid(30));
|
|
strcpy (_all->ragsoc_dett, "");
|
|
}
|
|
else
|
|
strcpy (_all->ragsoc_dett, rag);
|
|
|
|
return rag;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
//
|
|
// SortRecord::somma
|
|
//
|
|
// Somma gli importi dal record corrente di alleg nella struttura
|
|
// corrente.
|
|
// Incrementa SOLO i totali di riga (che sono nella struttura)
|
|
// NON i totali e i riporti in fondo alla pagina
|
|
//
|
|
void SortRecord::somma (const TRectype& alleg, stampe tipo_stampa)
|
|
{
|
|
switch (tipo_stampa)
|
|
{
|
|
case fornitori:
|
|
case clienti:
|
|
_all->impesc += alleg.get_real (ALL_IMPESC);
|
|
_all->ivaesc += alleg.get_real (ALL_IVAESC);
|
|
_all->niesc += alleg.get_real (ALL_NIESC);
|
|
_all->e8esc += alleg.get_real (ALL_E8ESC);
|
|
_all->ndocesc += alleg.get_int (ALL_NDOCESC);
|
|
|
|
_all->impesp += alleg.get_real (ALL_IMPESP);
|
|
_all->ivaesp += alleg.get_real (ALL_IVAESP);
|
|
_all->niesp += alleg.get_real (ALL_NIESP);
|
|
_all->e8esp += alleg.get_real (ALL_E8ESP);
|
|
_all->ndocesp += alleg.get_int (ALL_NDOCESP);
|
|
|
|
// Incremento totali di riga
|
|
_all->tot_rigac += _all->impesc + _all->ivaesc + _all->niesc + _all->e8esc;
|
|
_all->tot_rigap += _all->impesp + _all->ivaesp + _all->niesp + _all->e8esp;
|
|
|
|
break;
|
|
|
|
case modulo101:
|
|
case modulo102:
|
|
_all->prog101102 += alleg.get_real("ALL_PROG101102");
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SortRecord::azzera_struttura()
|
|
{
|
|
_all->codditta_dic = -1;
|
|
strcpy (_all->tipopers_dic, "\0");
|
|
strcpy (_all->paiva_dic, "\0");
|
|
strcpy (_all->cognome_dic, "\0");
|
|
strcpy (_all->nome_dic, "\0");
|
|
strcpy (_all->ragsoc_dic, "\0");
|
|
_all->datana_dic = "";
|
|
strcpy (_all->sesso_dic, "\0");
|
|
strcpy (_all->comunena_dic, "\0");
|
|
strcpy (_all->provna_dic, "\0");
|
|
strcpy (_all->viafis_dic, "\0"); // via + numero civico
|
|
strcpy (_all->comunefis_dic, "\0");
|
|
strcpy (_all->provfis_dic , "\0");
|
|
strcpy (_all->attivita_dic , "\0");
|
|
strcpy (_all->codatt_dic , "\0");
|
|
|
|
_all->natgiu_dic = 0;
|
|
|
|
strcpy (_all->codatt_dett, "\0");
|
|
strcpy (_all->tipopers_dett, "\0");
|
|
|
|
_all->codcf_dett = -1; // usato in da_sommare() per distinguere
|
|
// il primo record
|
|
|
|
strcpy (_all->ragsoc_dett , "\0");
|
|
strcpy (_all->cognome_dett , "\0");
|
|
strcpy (_all->nome_dett , "\0");
|
|
strcpy (_all->via_dett , "\0");
|
|
strcpy (_all->comune_dett , "\0");
|
|
strcpy (_all->prov_dett , "\0");
|
|
strcpy (_all->statopaiva_dett , "\0");
|
|
strcpy (_all->paiva_dett , "\0");
|
|
|
|
_all->anno = 0;
|
|
_all->immesso = FALSE;
|
|
|
|
_all->impesc = 0.00;
|
|
_all->ivaesc = 0.00;
|
|
_all->niesc = 0.00;
|
|
_all->e8esc = 0.00;
|
|
_all->ndocesc = 0;
|
|
|
|
_all->impesp = 0.00;
|
|
_all->ivaesp = 0.00;
|
|
_all->niesp = 0.00;
|
|
_all->e8esp = 0.00;
|
|
_all->ndocesp = 0;
|
|
|
|
_all->tot_rigac = 0.00;
|
|
_all->tot_rigap = 0.00;
|
|
|
|
_all->prog101102 = 0.00;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
// COMPILA
|
|
//
|
|
// Compila la struttura _RecordSort->Strutt leggendo da _alleg
|
|
// Scarta i record con l'anno diverso da quello specificato
|
|
// nella maschera.
|
|
//
|
|
void SortRecord::compila(const TRectype& alleg)
|
|
{
|
|
// azzera_struttura();
|
|
|
|
const char tipoa = alleg.get_char(ALL_TIPOCF);
|
|
_all->tipopers_dett[0] = tipoa;
|
|
_all->tipopers_dett[1] = '\0';
|
|
|
|
// strcpy (_all->tipopers_dett, _alleg->curr().get (ALL_TIPOCF));
|
|
|
|
const long codcf = alleg.get_long (ALL_CODCF);
|
|
_all->codcf_dett = codcf;
|
|
|
|
// _RecordSort->Strutt()->codcf_dett = _alleg->curr().get_long (ALL_CODCF);
|
|
|
|
// strcpy (_RecordSort->Strutt()->paiva_dett, get_paiva_cf (tipoa, codcf));
|
|
|
|
//
|
|
// QUI CAMBIA IL CODICE ATTIVITA
|
|
//
|
|
strcpy (_all->codatt_dett, alleg.get (ALL_CODATT));
|
|
|
|
_all->immesso = alleg.get_bool (ALL_IMMESSO);
|
|
|
|
_all->impesc = alleg.get_real (ALL_IMPESC);
|
|
_all->ivaesc = alleg.get_real (ALL_IVAESC);
|
|
_all->niesc = alleg.get_real (ALL_NIESC);
|
|
_all->e8esc = alleg.get_real (ALL_E8ESC);
|
|
_all->ndocesc = alleg.get_int (ALL_NDOCESC);
|
|
|
|
_all->impesp = alleg.get_real (ALL_IMPESP);
|
|
_all->ivaesp = alleg.get_real (ALL_IVAESP);
|
|
_all->niesp = alleg.get_real (ALL_NIESP);
|
|
_all->e8esp = alleg.get_real (ALL_E8ESP);
|
|
_all->ndocesp = alleg.get_int (ALL_NDOCESP);
|
|
|
|
_all->prog101102 = alleg.get_real (ALL_PROG101102);
|
|
|
|
fill_dati_dettaglio (tipoa, codcf);
|
|
}
|
|
|
|
bool SortRecord::fill_dati_anag_dic (const TRectype & ditta)
|
|
{
|
|
long codanagr;
|
|
TString tipoa;
|
|
TString str;
|
|
|
|
_all->codditta_dic = ditta.get_long(NDT_CODDITTA);
|
|
str = ditta.get(NDT_CODATTPREV);
|
|
|
|
str = decodifica_desc_att (str);
|
|
if (str.not_empty())
|
|
strcpy (_all->codatt_dic, str);
|
|
|
|
strcpy (_all->attivita_dic, str);
|
|
|
|
codanagr = ditta.get_long(NDT_CODANAGR);
|
|
tipoa = ditta.get(NDT_TIPOA);
|
|
|
|
strcpy (_all->tipopers_dic, tipoa);
|
|
|
|
TString16 key;
|
|
|
|
key.format("%s|%ld", (const char *) tipoa, codanagr);
|
|
|
|
const TRectype & anag = cache().get(LF_ANAG, key);
|
|
|
|
strcpy (_all->paiva_dic, anag.get (ANA_PAIV));
|
|
strcpy (_all->ragsoc_dic , anag.get(ANA_RAGSOC));
|
|
strcpy (_all->comunefis_dic, anag.get(ANA_COMRF));
|
|
|
|
if (_all->comunefis_dic[0] == '\0')
|
|
{
|
|
strcpy (_all->comunefis_dic, anag.get(ANF_COMRES));
|
|
|
|
const TRectype & dep = look_com (_all->comunefis_dic);
|
|
|
|
strcpy (_all->comunefis_dic , dep.get(COM_DENCOM));
|
|
strcpy (_all->provfis_dic , dep.get(COM_PROVCOM));
|
|
str = anag.get(ANA_INDRES);
|
|
str << " " << anag.get(ANA_CIVRES);
|
|
strcpy (_all->viafis_dic , (const char *) str);
|
|
}
|
|
else
|
|
{
|
|
const TRectype & dep = look_com (_all->comunefis_dic);
|
|
strcpy (_all->comunefis_dic, dep.get(COM_DENCOM));
|
|
strcpy (_all->provfis_dic , dep.get(COM_PROVCOM));
|
|
str = anag.get(ANA_INDRF);
|
|
str << " " << anag.get (ANA_CIVRF);
|
|
strcpy (_all->viafis_dic, str);
|
|
}
|
|
|
|
key.format("%ld", codanagr);
|
|
|
|
if (tipoa[0] == 'F')
|
|
{
|
|
str = _all->ragsoc_dic;
|
|
strcpy (_all->cognome_dic, str.left(30));
|
|
strcpy (_all->nome_dic, str.mid(30));
|
|
|
|
const TRectype &anagfis = cache().get(LF_ANAGFIS, key);
|
|
|
|
_all->datana_dic = anagfis.get_date(ANF_DATANASC);
|
|
strcpy (_all->sesso_dic, anagfis.get(ANF_SESSO));
|
|
|
|
const TRectype & dep = look_com (anagfis.get(ANF_COMNASC));
|
|
|
|
strcpy (_all->comunena_dic, dep.get(COM_DENCOM));
|
|
strcpy (_all->provna_dic, dep.get(COM_PROVCOM));
|
|
}
|
|
else
|
|
if (tipoa[0] == 'G')
|
|
{
|
|
// Leggo natura giuridica dal anagrafe giuridiche
|
|
const TRectype &anaggiu = cache().get(LF_ANAGGIU, key);
|
|
|
|
_all->natgiu_dic = anaggiu.get_int(ANG_NATGIU);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//
|
|
// Totali
|
|
//
|
|
|
|
//
|
|
// I riporti sono i totali della pagina precedente..
|
|
//
|
|
void Totali::compila_riporti()
|
|
{
|
|
_rip_tot_es = _tot_esc;
|
|
_rip_tot_impes = _tot_impesc;
|
|
_rip_tot_ivaes = _tot_ivaesc;
|
|
_rip_tot_nies = _tot_niesc;
|
|
_rip_tot_e8es = _tot_e8esc;
|
|
}
|
|
|
|
void Totali::azzera_totali()
|
|
{
|
|
_rip_tot_es = 0;
|
|
_rip_tot_impes = 0.00;
|
|
_rip_tot_ivaes = 0.00;
|
|
_rip_tot_nies = 0.00;
|
|
_rip_tot_e8es = 0.00;
|
|
|
|
_tot_esc = 0;
|
|
_tot_impesc = 0.00;
|
|
_tot_ivaesc = 0.00;
|
|
_tot_niesc = 0.00;
|
|
_tot_e8esc = 0.00;
|
|
|
|
_tot_esp = 0;
|
|
_tot_impesp = 0.00;
|
|
_tot_ivaesp = 0.00;
|
|
_tot_niesp = 0.00;
|
|
_tot_e8esp = 0.00;
|
|
}
|
|
|
|
//
|
|
// Incrementa i totali in fondo alla pagina
|
|
//
|
|
void Totali::incrementa_totali(struct alleg_sort* buf, stampe tipo_stampa)
|
|
{
|
|
switch (tipo_stampa)
|
|
{
|
|
case fornitori:
|
|
case clienti:
|
|
_tot_tot_rigac += buf->tot_rigac;
|
|
_tot_tot_rigap += buf->tot_rigap;
|
|
|
|
_tot_esc += buf->ndocesc;
|
|
_tot_impesc += buf->impesc + buf->impesp;
|
|
_tot_ivaesc += buf->ivaesc + buf->ivaesp;
|
|
_tot_niesc += buf->niesc + buf->niesp;
|
|
_tot_e8esc += buf->e8esc + buf->e8esp;
|
|
|
|
_tot_esp += buf->ndocesp;
|
|
_tot_impesp += buf->impesp;
|
|
_tot_ivaesp += buf->ivaesp;
|
|
_tot_niesp += buf->niesp;
|
|
_tot_e8esp += buf->e8esp;
|
|
|
|
break;
|
|
|
|
case modulo101:
|
|
case modulo102:
|
|
_tot_col_101102 += buf->prog101102;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Array_desc_campi
|
|
//
|
|
|
|
void Array_desc_campi::leggi_modulo (const char * file, const char *modulo)
|
|
{
|
|
TScanner s(file);
|
|
|
|
if (s.paragraph(modulo))
|
|
{
|
|
s.equal();
|
|
_passo = s.integer();
|
|
|
|
s.equal();
|
|
_righe_modulo = s.integer();
|
|
|
|
while (s.ok())
|
|
{
|
|
const int riga = s.integer();
|
|
if (riga <= 0) // Ho raggiunto una riga vuota in fondo
|
|
break;
|
|
const TString& formato = s.string();
|
|
add (riga, formato);
|
|
}
|
|
}
|
|
else
|
|
error_box(FR("Impossibile trovare la sezione '%s' sul file '%s'"), modulo, file);
|
|
}
|
|
|
|
void Array_desc_campi::add(int r, const char* f)
|
|
{
|
|
CHECKD(r > 0, "Bad print row ", r);
|
|
|
|
desc_campo * descr = new desc_campo;
|
|
descr->_riga = r;
|
|
descr->_formato = f;
|
|
_campi.add(descr);
|
|
|
|
}
|
|
|
|
//
|
|
// Record_B
|
|
//
|
|
|
|
void Record_B::compila(const TRectype& all)
|
|
{
|
|
esc = all.get_int (ALL_NDOCESC);
|
|
impesc = all.get_real(ALL_IMPESC);
|
|
ivaesc = all.get_real(ALL_IVAESC);
|
|
tot = impesc + ivaesc;
|
|
}
|
|
|
|
void Record_B::azzera()
|
|
{
|
|
tot = 0.00;
|
|
esc = 0;
|
|
impesc = 0.00;
|
|
ivaesc = 0.00;
|
|
}
|
|
|
|
void Record_B::somma()
|
|
{
|
|
tot = impesc + ivaesc;
|
|
}
|
|
|
|
|