2b27fb4ab7
git-svn-id: svn://10.65.10.50/trunk@1081 c028cbd2-c16b-5b4b-a496-9718f37d4682
487 lines
12 KiB
C++
Executable File
487 lines
12 KiB
C++
Executable File
//
|
|
//Riepilogo Progressivi IVA
|
|
//
|
|
#include <applicat.h>
|
|
#include <date.h>
|
|
#include <lffiles.h>
|
|
#include <mask.h>
|
|
#include <isam.h>
|
|
#include <printapp.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
#include <nditte.h>
|
|
#include <anagr.h>
|
|
#include <comuni.h>
|
|
#include "classpim.h"
|
|
#include "cg0.h"
|
|
#include "cg0400.h"
|
|
|
|
struct Importi {
|
|
real imponibile;
|
|
real imposta;
|
|
};
|
|
|
|
class CG0400_application : public TPrintapp
|
|
{
|
|
TTable* _tabpim, * _tabreg;
|
|
TLocalisamfile* _nditte, * _attiv, * _anag, * _com;
|
|
TMask* _msk;
|
|
TDate _data;
|
|
int _sospmsk, _tipoprog, _livelloprog, _tipo_crmsk, _annoiva, _i;
|
|
TString _cap,_cofi,_paiva,_ragsoc,_comunefis,_provfis,_viafis,_codivamsk,_codattmsk;
|
|
//bool _vuoilordi;
|
|
Importi _mesi[13];
|
|
|
|
public:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual bool set_print(int);
|
|
virtual bool preprocess_page(int,int);
|
|
virtual print_action postprocess_page(int,int);
|
|
void cerca_i_pim();
|
|
void azzera_mesi();
|
|
void get_dati_ditta();
|
|
void setta_intestazione();
|
|
void calcola_totali(real&,real&);
|
|
int stampa_intestazione_ditta();
|
|
|
|
CG0400_application(){};
|
|
};
|
|
|
|
|
|
bool CG0400_application::user_create()
|
|
{
|
|
_tabpim = new TTable(TAB_PIM);
|
|
_tabreg = new TTable(TAB_REG);
|
|
_anag = new TLocalisamfile(LF_ANAG);
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
_attiv = new TLocalisamfile(LF_ATTIV);
|
|
_com = new TLocalisamfile(LF_COMUNI);
|
|
_msk = new TMask("cg0400a");
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG0400_application::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _tabpim;
|
|
delete _tabreg;
|
|
delete _anag;
|
|
delete _nditte;
|
|
delete _com;
|
|
delete _attiv;
|
|
return TRUE;
|
|
}
|
|
|
|
void CG0400_application::azzera_mesi()
|
|
{
|
|
for (int i=0; i<=12; i++)
|
|
{
|
|
_mesi[i].imponibile = ZERO;
|
|
_mesi[i].imposta = ZERO;
|
|
}
|
|
}
|
|
|
|
void CG0400_application::cerca_i_pim()
|
|
{
|
|
TTable pim("PIM");
|
|
for (pim.first(); !pim.eof(); pim.next())
|
|
{
|
|
real imponibile, imposta, impo, impos;
|
|
tiporec tipo;
|
|
|
|
TString80 codtab = pim.get("CODTAB");
|
|
int anno = atoi(codtab.mid(0,4));
|
|
TString16 codatt = codtab.mid(4,5);
|
|
int mese = atoi(codtab.mid(13,2));
|
|
TString16 codiva = codtab.mid(16,4);
|
|
|
|
if (anno != _annoiva) continue;
|
|
|
|
if (_livelloprog == 1) //riepilogo per aliquota
|
|
{
|
|
codiva = codiva.trim();
|
|
if (codiva != _codivamsk) continue;
|
|
}
|
|
|
|
if (_livelloprog == 2) //riepilogo per attivita'
|
|
{
|
|
codatt = codatt.trim();
|
|
if (codatt != _codattmsk) continue;
|
|
}
|
|
|
|
impo = impos = ZERO;
|
|
|
|
while (classify_pim(pim.curr(), imponibile, imposta, tipo))
|
|
{
|
|
switch(tipo)
|
|
{
|
|
case acq_norm:
|
|
if (_tipoprog == 1) break; //vendite
|
|
if (_tipo_crmsk == 1) //nella maschera e' stato richiesto
|
|
{ //acquisti in genere
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case vend_norm:
|
|
if (_tipoprog == 2) break; //acquisti
|
|
if (_sospmsk == 1) //nella maschera e' stato richiesto
|
|
{ //vendite in genere
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case vend_simp:
|
|
if (_tipoprog == 2) break; //acquisti
|
|
if (_sospmsk == 2) //nella maschera e' stato richiesto
|
|
{ //vendite in sospensione d'imposta
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_ind_op_es:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 2)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_ind_pass_int:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 3)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_ind_art_19:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 4)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case base_ventilazione:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 5)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case bolle_doganali:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 6)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_beni_riv:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 1)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_beni_ammort:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 2)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_beni_ammort_nd:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 3)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_beni_leasing:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 4)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
case acq_amm_ultdetr:
|
|
if (_tipoprog == 1) break;
|
|
if (_tipo_crmsk == 6)
|
|
{
|
|
impo += imponibile;
|
|
impos += imposta;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} //fine while
|
|
_mesi[mese].imponibile += impo;
|
|
_mesi[mese].imposta += impos;
|
|
impo = impos = ZERO;
|
|
}
|
|
}
|
|
|
|
|
|
bool CG0400_application::set_print(int)
|
|
{
|
|
KEY tasto;
|
|
tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_annoiva = _msk->get_int(F_ANNO);
|
|
//_vuoilordi = _msk->get_bool(F_VUOILORDI);
|
|
_tipoprog = _msk->get_int(F_TIPO); // 1 <=> vendite; 2 <=> acquisti
|
|
if (_tipoprog == 1)
|
|
_sospmsk = _msk->get_int(F_TIPOTAB); //vendite in genere; vendite in sospensione d'imposta
|
|
_livelloprog = _msk->get_int(F_LIVELLO);
|
|
_codivamsk = _msk->get(F_CODIVA);
|
|
_codattmsk = _msk->get(F_ATTIVITA);
|
|
//if (_tipoprog == 2)
|
|
if (_livelloprog == 1) //si tratta di una aliquota
|
|
_tipo_crmsk = _msk->get_int(F_TIPOTABE);
|
|
else //si tratta di una attivita'
|
|
_tipo_crmsk = _msk->get_int(F_TIPOTABEL);
|
|
|
|
set_real_picture("###.###.###.###");
|
|
set_print_zero();
|
|
|
|
setta_intestazione();
|
|
|
|
azzera_mesi();
|
|
cerca_i_pim();
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void CG0400_application::calcola_totali(real& imp, real& imps)
|
|
{
|
|
for (int i=0; i<=12; i++)
|
|
{
|
|
imp += _mesi[i].imponibile;
|
|
imps += _mesi[i].imposta;
|
|
}
|
|
}
|
|
|
|
|
|
bool CG0400_application::preprocess_page(int file, int counter)
|
|
{
|
|
reset_print();
|
|
|
|
if (counter)
|
|
_i++;
|
|
else
|
|
_i = 1;
|
|
|
|
const char* mese = itom(_i);
|
|
|
|
set_row(1,"%s", mese);
|
|
set_row(1,"@26g%r", &_mesi[_i].imponibile);
|
|
set_row(1,"@56g%r", &_mesi[_i].imposta);
|
|
//if (_vuoilordi)
|
|
// set_row(1,"@48g%r", &_lordo_v);
|
|
|
|
if (_i == 12)
|
|
{
|
|
real tot_impo = ZERO;
|
|
real tot_imposta = ZERO;
|
|
|
|
calcola_totali(tot_impo, tot_imposta);
|
|
|
|
TString dep = "";
|
|
set_row(2,(const char*) dep);
|
|
set_row(3,"@8gTotale");
|
|
set_row(3,"@26g%r", &tot_impo);
|
|
set_row(3,"@56g%r", &tot_imposta);
|
|
// if (_vuoilordi)
|
|
// set_row(3,"@48g%r", &_totlordo_v);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
TRectype& look_com (const char * cod, TLocalisamfile *comuni)
|
|
{
|
|
comuni->zero();
|
|
comuni->put(COM_COM, cod);
|
|
comuni->read();
|
|
if (comuni->bad())
|
|
comuni->zero();
|
|
|
|
return comuni->curr();
|
|
}
|
|
|
|
void CG0400_application::get_dati_ditta()
|
|
{
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
TLocalisamfile anag(LF_ANAG);
|
|
TString codanagr;
|
|
TString tipoa;
|
|
|
|
nditte.zero();
|
|
nditte.put(NDT_CODDITTA, get_firm());
|
|
nditte.read();
|
|
|
|
if (nditte.bad()) nditte.zero();
|
|
|
|
codanagr = nditte.get(NDT_CODANAGR);
|
|
tipoa = nditte.get(NDT_TIPOA);
|
|
_ragsoc = nditte.get(NDT_RAGSOC);
|
|
|
|
anag.setkey(1);
|
|
anag.zero();
|
|
anag.put (ANA_TIPOA, tipoa);
|
|
anag.put (ANA_CODANAGR, codanagr);
|
|
anag.read();
|
|
if (anag.bad()) anag.zero();
|
|
|
|
_cofi = anag.get(ANA_COFI);
|
|
_paiva = anag.get(ANA_PAIV);
|
|
_comunefis = anag.get(ANA_COMRF);
|
|
|
|
if (_comunefis.empty())
|
|
_comunefis = anag.get(ANA_COMRES);
|
|
|
|
TRectype dep = look_com (_comunefis, _com);
|
|
|
|
_comunefis = dep.get(COM_DENCOM);
|
|
_provfis = dep.get(COM_PROVCOM);
|
|
_cap = dep.get(COM_CAPCOM);
|
|
if (_comunefis.empty())
|
|
{
|
|
_viafis = anag.get(ANA_INDRF);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRF);
|
|
}
|
|
else
|
|
{
|
|
_viafis = anag.get(ANA_INDRES);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRES);
|
|
}
|
|
}
|
|
|
|
int CG0400_application::stampa_intestazione_ditta()
|
|
{
|
|
int r = 1;
|
|
TString codice_ditta;
|
|
TString riga(132);
|
|
|
|
get_dati_ditta();
|
|
codice_ditta << get_firm();
|
|
|
|
set_header (r, "Ditta %s %s %s %s %s %s", (const char*)codice_ditta,
|
|
(const char*)_ragsoc, (const char*)_viafis,
|
|
(const char*)_cap, (const char*)_comunefis,
|
|
(const char*)_provfis);
|
|
r++;
|
|
riga = "Data @< Pag. @#";
|
|
riga.right_just(127);
|
|
riga.overwrite (format ("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi));
|
|
set_header (r, "%s", (const char*) riga);
|
|
r+=3;
|
|
|
|
return r;
|
|
}
|
|
|
|
void CG0400_application::setta_intestazione()
|
|
{
|
|
int r = 1;
|
|
|
|
reset_header();
|
|
|
|
r = stampa_intestazione_ditta();
|
|
|
|
if (_livelloprog == 1)
|
|
set_header(r++, "Gestione Iva@b@50gPROGRESSIVI IVA PER ALIQUOTA");
|
|
else set_header(r++, "Gestione Iva@b@50gPROGRESSIVI IVA PER ATTIVITA'");
|
|
r++;
|
|
set_header(r++, "Anno liquidazione %d", _annoiva);
|
|
if (_tipoprog == 1) //vendite
|
|
{
|
|
if (_sospmsk == 1)
|
|
set_header(r, "Vendite in genere");
|
|
else set_header(r, "Vendite in sospensione d'imposta");
|
|
}
|
|
else //acquisti
|
|
{
|
|
if (_livelloprog == 1) //per codice iva
|
|
switch (_tipo_crmsk)
|
|
{
|
|
case 1:
|
|
set_header(r, "Acquisti in genere");
|
|
break;
|
|
case 2:
|
|
set_header(r, "Acquisti indetraibili su operazioni esenti");
|
|
break;
|
|
case 3:
|
|
set_header(r, "Acquisti indetraibili passaggi interni");
|
|
break;
|
|
case 4:
|
|
set_header(r, "Acquisti indetraibili art.19");
|
|
break;
|
|
case 5:
|
|
set_header(r, "Acquisti base di calcolo per la ventilazione");
|
|
break;
|
|
case 6:
|
|
set_header(r, "Bolle doganali");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
else //per attivita'
|
|
switch (_tipo_crmsk)
|
|
{
|
|
case 1:
|
|
set_header(r, "Acquisti beni per rivendita");
|
|
break;
|
|
case 2:
|
|
set_header(r, "Acquisti beni da ammortizzare detraibili");
|
|
break;
|
|
case 3:
|
|
set_header(r, "Acquisti beni da ammortizzare non detraibili");
|
|
break;
|
|
case 4:
|
|
set_header(r, "Altri beni strumentali acquisiti in leasing");
|
|
break;
|
|
case 5:
|
|
set_header(r, "Acquisti beni da ammortizzare ult.detr. 6%");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
r++;
|
|
if (_livelloprog == 1)
|
|
set_header(r++, "IVA %s",(const char*) _codivamsk);
|
|
else set_header(r++, "ATTIVITA' %s",(const char*)_codattmsk);
|
|
set_header(++r, "@29gImponibile@60gImposta");
|
|
//if (_vuoilordi)
|
|
// set_header(r, "@21gImponibile@40gImposta@50gImporto lordo");
|
|
//else set_header(r, "@21gImponibile@40gImposta");
|
|
}
|
|
|
|
print_action CG0400_application::postprocess_page(int file, int counter)
|
|
{
|
|
if (_i < 12) return REPEAT_PAGE;
|
|
else return NEXT_PAGE;
|
|
}
|
|
|
|
int cg0400(int argc,char* argv[])
|
|
{
|
|
CG0400_application a;
|
|
a.run(argc, argv, "Riepilogo progressivi IVA");
|
|
return 0;
|
|
}
|
|
|