1995-07-13 12:38:04 +00:00
|
|
|
//********************************
|
|
|
|
//* Riepilogo Progressivi IVA *
|
|
|
|
//********************************
|
|
|
|
#include <mask.h>
|
|
|
|
#include <printapp.h>
|
|
|
|
#include <tabutil.h>
|
1997-06-20 08:52:24 +00:00
|
|
|
//#include <utility.h>
|
1997-01-31 09:29:15 +00:00
|
|
|
#include <prefix.h>
|
1995-11-18 11:47:15 +00:00
|
|
|
|
|
|
|
#include "cg0.h"
|
|
|
|
#include "cg0400.h"
|
|
|
|
|
1997-06-20 08:52:24 +00:00
|
|
|
#include "cgpim.h"
|
1995-11-18 11:47:15 +00:00
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
#include <anagr.h>
|
|
|
|
#include <comuni.h>
|
|
|
|
#include <attiv.h>
|
|
|
|
#include <nditte.h>
|
1995-11-18 11:47:15 +00:00
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
|
|
|
|
HIDDEN TString80 TMP;
|
|
|
|
|
|
|
|
enum liste {
|
|
|
|
visualizza=1,
|
|
|
|
stampa=2,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Importi {
|
|
|
|
real imponibile;
|
|
|
|
real imposta;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TRiga_gen : public TArray
|
|
|
|
{
|
|
|
|
TString16 _codiva;
|
|
|
|
real _impoven, _imposven; //imponibile e imposta vendite
|
|
|
|
real _impoacq, _imposacq; //imponibile e imposta acquisti
|
|
|
|
real _impobd, _imposbd; //imponibile e imposta importazioni (ovvero bolle doganali)
|
|
|
|
|
|
|
|
TRiga_gen (const char* codiva, const real& impov, const real& imposv, const real& impoa, const real& imposa, const real& impobd, const real& imposbd):
|
|
|
|
_codiva(codiva),_impoven(impov),_imposven(imposv),_impoacq(impoa),_imposacq(imposa),_impobd(impobd),_imposbd(imposbd) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TGen_array : public TArray
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool add_riga(const char* codiva, const real& imponibilev, const real& impostav, const real& imponibilea, const real& impostaa, const real& imponibilebd, const real& impostabd);
|
|
|
|
TRiga_gen& riga(int i) { return (TRiga_gen&)(*this)[i]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TGen_array::add_riga(const char* codiva, const real& imponibilev, const real& impostav, const real& imponibilea, const real& impostaa, const real& imponibilebd, const real& impostabd)
|
|
|
|
{
|
|
|
|
bool found = FALSE;
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
{
|
|
|
|
TRiga_gen& r = riga(i);
|
|
|
|
if (r._codiva==codiva)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
r._impoven += imponibilev;
|
|
|
|
r._imposven += impostav;
|
|
|
|
r._impoacq += imponibilea;
|
|
|
|
r._imposacq += impostaa;
|
|
|
|
r._impobd += imponibilebd;
|
|
|
|
r._imposbd += impostabd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
TRiga_gen* r = new TRiga_gen(codiva,imponibilev,impostav,imponibilea,impostaa,imponibilebd,impostabd);
|
|
|
|
add(r);
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TRiga_iva : public TArray
|
|
|
|
{
|
|
|
|
tiporec _tipo;
|
|
|
|
real _imponibile, _imposta, _detrazione;
|
|
|
|
|
|
|
|
TRiga_iva (const tiporec& tipo, const real& impo, const real& impos, const real& detr):
|
|
|
|
_tipo(tipo),_imponibile(impo),_imposta(impos), _detrazione(detr) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TIva_array : public TArray
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool add_riga(const tiporec& tipo, const real& imponibile,
|
|
|
|
const real& imposta, const real& detr);
|
|
|
|
TRiga_iva& riga(int i) { return (TRiga_iva&)(*this)[i]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TIva_array::add_riga(const tiporec& tipo, const real& imponibile,
|
|
|
|
const real& imposta, const real& detr)
|
|
|
|
{
|
|
|
|
bool found = FALSE;
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
{
|
|
|
|
TRiga_iva& r = riga(i);
|
|
|
|
if (r._tipo == tipo)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
r._imponibile += imponibile;
|
|
|
|
r._imposta += imposta;
|
|
|
|
r._detrazione += detr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
TRiga_iva* r = new TRiga_iva(tipo,imponibile,imposta,detr);
|
|
|
|
add(r);
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
};
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
class TProgressivi_iva : public TPrintapp
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
1997-01-31 09:29:15 +00:00
|
|
|
TTable* _tablia;
|
1995-07-13 12:38:04 +00:00
|
|
|
TLocalisamfile* _nditte, * _anag, * _com, * _attiv;
|
|
|
|
TMask* _msk;
|
|
|
|
TDate _data;
|
|
|
|
int _sospmsk, _tipoprog, _livelloprog, _tipo_aliq, _tipo_attiv, _annoiva, _i;
|
|
|
|
int _mese, _anno;
|
1995-09-18 10:45:10 +00:00
|
|
|
long _codditta;
|
1995-07-13 12:38:04 +00:00
|
|
|
bool _st_inizio_anno, _prima_pagina;
|
|
|
|
TIva_array _iva_array,_iva1_array;
|
|
|
|
TGen_array _gen_array,_gen1_array;
|
1997-02-19 08:46:05 +00:00
|
|
|
TAssoc_array _corr_array;
|
1995-07-13 12:38:04 +00:00
|
|
|
TString _cap,_cofi,_paiva,_ragsoc,_comunefis,_provfis,_viafis,_codivamsk,_codattmsk;
|
|
|
|
TString _datast, _cod_att;
|
|
|
|
Importi _mesi[13];
|
|
|
|
liste _tipo_lista;
|
1996-05-20 13:17:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static bool tipo_handler(TMask_field& f, KEY k);
|
1996-09-13 07:34:35 +00:00
|
|
|
static bool selection_handler(TMask_field& f, KEY k);
|
1996-05-20 13:17:58 +00:00
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
virtual bool user_create();
|
|
|
|
virtual bool user_destroy();
|
|
|
|
virtual bool set_print(int);
|
|
|
|
virtual void preprocess_header();
|
|
|
|
virtual bool preprocess_page(int,int);
|
|
|
|
virtual print_action postprocess_page(int,int);
|
|
|
|
|
1997-02-19 08:46:05 +00:00
|
|
|
void lordo2netto(const real& totale, real& imponibile, real& imposta, const real& aliquota);
|
1995-07-13 12:38:04 +00:00
|
|
|
void cerca_i_pim();
|
|
|
|
void azzera_mesi();
|
|
|
|
void get_dati_ditta();
|
|
|
|
void setta_intestazione();
|
|
|
|
void calcola_totali(real&,real&);
|
|
|
|
void cerca_tipo(TIva_array&, tiporec, real&, real&, real&);
|
|
|
|
void prospetto_pagina(TGen_array&, TIva_array&);
|
|
|
|
int stampa_intestazione_ditta();
|
|
|
|
const char* desc_attivita(const char*);
|
1996-12-06 08:16:43 +00:00
|
|
|
const char* desc_iva(const TString&);
|
1995-07-13 12:38:04 +00:00
|
|
|
char look_lia(long ditta = 0l);
|
|
|
|
void look_pim();
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
TProgressivi_iva(){};
|
1995-07-13 12:38:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
|
|
|
|
{
|
|
|
|
TRiga_gen* r1 = (TRiga_gen*)*o1;
|
|
|
|
TRiga_gen* r2 = (TRiga_gen*)*o2;
|
|
|
|
|
|
|
|
return (strcmp((const char*)r1->_codiva, (const char*)r2->_codiva));
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
const char* TProgressivi_iva::desc_attivita(const char* codatt)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
TTable attiv ("%AIS");
|
|
|
|
attiv.zero();
|
|
|
|
attiv.put("CODTAB", codatt);
|
|
|
|
if (attiv.read()==NOERR)
|
|
|
|
TMP = attiv.get("S0");
|
|
|
|
else
|
|
|
|
TMP = "";
|
|
|
|
return TMP;
|
|
|
|
}
|
|
|
|
|
1997-02-19 08:46:05 +00:00
|
|
|
void TProgressivi_iva::lordo2netto(const real& totale, real& imponibile, real& imposta, const real& aliquota)
|
|
|
|
{
|
|
|
|
imposta = (abs(totale) * aliquota)/(aliquota + 1.00);
|
|
|
|
imposta.ceil();
|
|
|
|
if (totale.sign() < 0) imposta = -imposta;
|
|
|
|
imponibile = totale - imposta;
|
|
|
|
real delta = totale - imponibile - imposta;
|
|
|
|
if (!delta.is_zero())
|
|
|
|
imposta += delta;
|
|
|
|
}
|
|
|
|
|
1996-12-06 08:16:43 +00:00
|
|
|
const char* TProgressivi_iva::desc_iva(const TString& cod)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
|
1996-12-06 08:16:43 +00:00
|
|
|
if (cod == "{AF")
|
|
|
|
TMP = "Artt.17c3/74c1";
|
1996-12-09 08:33:02 +00:00
|
|
|
else if (cod == "{A13")
|
1996-12-06 08:16:43 +00:00
|
|
|
TMP = "Art.40c5/6/8 a.i.";
|
1995-07-13 12:38:04 +00:00
|
|
|
else
|
1996-12-06 08:16:43 +00:00
|
|
|
{
|
|
|
|
TTable tab_iva("%IVA");
|
1997-06-20 08:52:24 +00:00
|
|
|
TString16 codtab; codtab.format("%-4s", (const char*)cod);
|
1995-07-13 12:38:04 +00:00
|
|
|
|
1996-12-06 08:16:43 +00:00
|
|
|
tab_iva.zero();
|
|
|
|
tab_iva.put("CODTAB", codtab);
|
|
|
|
if (tab_iva.read()==NOERR)
|
|
|
|
TMP = tab_iva.get("S0");
|
|
|
|
else
|
|
|
|
TMP = "";
|
|
|
|
}
|
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
return TMP;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
char TProgressivi_iva::look_lia(long ditta)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
if (ditta == 0l) ditta = get_firm();
|
|
|
|
|
|
|
|
TString16 y; y.format("%05ld%04d", ditta, _anno);
|
|
|
|
|
|
|
|
_tablia->zero();
|
|
|
|
_tablia->put("CODTAB", y);
|
|
|
|
|
|
|
|
if (_tablia->read() != NOERR)
|
|
|
|
_tablia->zero();
|
|
|
|
|
|
|
|
return _tablia->get_char("S7");
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
bool TProgressivi_iva::user_create()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
_tablia = new TTable("%LIA");
|
|
|
|
_anag = new TLocalisamfile(LF_ANAG);
|
|
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
|
|
_com = new TLocalisamfile(LF_COMUNI);
|
|
|
|
_attiv = new TLocalisamfile(LF_ATTIV);
|
|
|
|
|
|
|
|
set_real_picture("###.###.###.###");
|
|
|
|
set_print_zero(FALSE);
|
|
|
|
printer().footerlen(5);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
bool TProgressivi_iva::user_destroy()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
delete _tablia;
|
|
|
|
delete _anag;
|
|
|
|
delete _nditte;
|
|
|
|
delete _com;
|
|
|
|
delete _attiv;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::azzera_mesi()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
for (int i=0; i<=12; i++)
|
|
|
|
{
|
|
|
|
_mesi[i].imponibile = ZERO;
|
|
|
|
_mesi[i].imposta = ZERO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::look_pim()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
TTable pim("PIM");
|
1996-12-04 09:10:39 +00:00
|
|
|
TTable reg("REG");
|
1997-02-19 08:46:05 +00:00
|
|
|
TTable tabiva("%IVA");
|
1996-12-04 09:10:39 +00:00
|
|
|
TString80 codtab;
|
|
|
|
TString16 codatt,codiva,tipoiva,codreg;
|
1996-12-09 08:33:02 +00:00
|
|
|
TToken_string a13("",'!');
|
|
|
|
real imponibile, imposta,afi,afv,a13i,a13v;
|
1997-02-19 08:46:05 +00:00
|
|
|
real corr_item,*cp,aliquota;
|
|
|
|
bool is_key;
|
|
|
|
|
|
|
|
_corr_array.destroy();
|
1996-12-04 09:10:39 +00:00
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
for (pim.first(); !pim.eof(); pim.next())
|
|
|
|
{
|
1996-12-09 08:33:02 +00:00
|
|
|
imponibile = imposta = afi = afv = a13i = a13v = ZERO;
|
1995-07-13 12:38:04 +00:00
|
|
|
tiporec tipo;
|
|
|
|
|
1996-12-04 09:10:39 +00:00
|
|
|
codtab = pim.get("CODTAB");
|
1995-07-13 12:38:04 +00:00
|
|
|
int anno = atoi(codtab.mid(0,4));
|
|
|
|
int mese = atoi(codtab.mid(13,2));
|
1996-12-04 09:10:39 +00:00
|
|
|
codreg.format("%d%-3s",anno, (const char*)codtab.mid(10,3));
|
|
|
|
codatt = codtab.mid(4,5);
|
|
|
|
codiva = codtab.mid(16,4);
|
|
|
|
tipoiva = pim.get("S5");
|
1995-07-13 12:38:04 +00:00
|
|
|
codiva = codiva.trim();
|
|
|
|
codatt = codatt.trim();
|
|
|
|
|
|
|
|
if (anno != _anno) continue;
|
|
|
|
|
|
|
|
if (_st_inizio_anno)
|
1997-10-23 09:34:10 +00:00
|
|
|
if ((mese > _mese) || (_mese == 13 && mese < 13))
|
1995-07-13 12:38:04 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!_st_inizio_anno)
|
|
|
|
if (mese != _mese)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (codatt != _cod_att) continue;
|
|
|
|
|
|
|
|
//Modifica del 12/07/1995
|
|
|
|
if (tipoiva == "VE") continue; //i codici iva di tipo "VE"
|
1995-09-18 10:45:10 +00:00
|
|
|
//Fine //non devono essere stampati
|
1995-07-13 12:38:04 +00:00
|
|
|
|
1996-12-04 09:10:39 +00:00
|
|
|
reg.put("CODTAB",codreg);
|
|
|
|
if (reg.read() != NOERR) reg.zero();
|
|
|
|
const bool corrisp = reg.get_bool("B0");
|
|
|
|
|
1997-02-19 08:46:05 +00:00
|
|
|
is_key = _corr_array.is_key(codiva);
|
|
|
|
corr_item = ZERO;
|
|
|
|
real& ci = is_key ? (real&) _corr_array[codiva] : corr_item;
|
|
|
|
ci += pim.get_real("R3"); // accumula i corrispettivi
|
|
|
|
if (!is_key)
|
|
|
|
_corr_array.add(codiva,ci);
|
|
|
|
|
1995-11-03 09:44:29 +00:00
|
|
|
while (classify_pim(pim.curr(), imponibile, imposta, tipo, TRUE))
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
switch(tipo)
|
|
|
|
{
|
|
|
|
case acq_norm:
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese != 13)
|
|
|
|
_gen_array.add_riga(codiva,ZERO,ZERO,imponibile,imposta,ZERO,ZERO);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13) //lo metto in un array a parte
|
1995-07-13 12:38:04 +00:00
|
|
|
_gen1_array.add_riga(codiva,ZERO,ZERO,imponibile,imposta,ZERO,ZERO);
|
|
|
|
break;
|
|
|
|
case vend_norm:
|
1996-12-04 09:10:39 +00:00
|
|
|
if (corrisp)
|
|
|
|
{ // Questo perche' i documenti FS sono registrati col segno
|
|
|
|
// negativo in R0/R1 e col segno positivo in R5/R6,
|
1996-12-06 13:58:26 +00:00
|
|
|
imponibile += pim.get_real("R5");
|
|
|
|
imposta += pim.get_real("R6");
|
1996-12-04 09:10:39 +00:00
|
|
|
}
|
1996-12-06 08:16:43 +00:00
|
|
|
if (_mese == 13)
|
1996-12-09 08:33:02 +00:00
|
|
|
{ // Separa le autofatture non residenti(AF) e gli importi A13
|
1996-12-06 08:16:43 +00:00
|
|
|
afi = pim.get_real("R7");
|
|
|
|
afv = pim.get_real("R8");
|
1996-12-09 08:33:02 +00:00
|
|
|
a13 = pim.get("S0");
|
|
|
|
a13i = a13.get(0);
|
|
|
|
a13v = a13.get(1);
|
|
|
|
imponibile -= afi + a13i;
|
|
|
|
imposta -= afv + a13v;
|
1996-12-06 08:16:43 +00:00
|
|
|
_gen1_array.add_riga("{AF",afi,afv,ZERO,ZERO,ZERO,ZERO); // Mette '{' cosi' vengono stampati per ultimi
|
1996-12-09 08:33:02 +00:00
|
|
|
_gen1_array.add_riga("{A13",a13i,a13v,ZERO,ZERO,ZERO,ZERO);
|
1996-12-06 08:16:43 +00:00
|
|
|
}
|
|
|
|
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese != 13)
|
|
|
|
_gen_array.add_riga(codiva,imponibile,imposta,ZERO,ZERO,ZERO,ZERO);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13) //lo metto in un array a parte
|
1995-07-13 12:38:04 +00:00
|
|
|
_gen1_array.add_riga(codiva,imponibile,imposta,ZERO,ZERO,ZERO,ZERO);
|
|
|
|
break;
|
|
|
|
case bolle_doganali:
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese != 13)
|
|
|
|
_gen_array.add_riga(codiva,ZERO,ZERO,ZERO,ZERO,imponibile,imposta);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13)
|
1995-07-13 12:38:04 +00:00
|
|
|
_gen1_array.add_riga(codiva,ZERO,ZERO,ZERO,ZERO,imponibile,imposta);
|
|
|
|
break;
|
|
|
|
case acq_amm_ultdetr:
|
|
|
|
{
|
|
|
|
real detr = imponibile * real(0.06);
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese != 13)
|
|
|
|
_iva_array.add_riga(tipo,imponibile,imposta,detr);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13)
|
1995-07-13 12:38:04 +00:00
|
|
|
_iva1_array.add_riga(tipo,imponibile,imposta,detr);
|
|
|
|
}
|
|
|
|
break;
|
1997-11-19 17:20:26 +00:00
|
|
|
case acq_beni_riv:
|
|
|
|
tabiva.put("CODTAB",codiva);
|
|
|
|
if (tabiva.read() == NOERR)
|
|
|
|
// I non soggetti non vanno considerati nel totale acq. beni rivendita
|
|
|
|
if (tabiva.get("S1") != "NS")
|
|
|
|
{
|
|
|
|
if (_mese != 13)
|
|
|
|
_iva_array.add_riga(tipo,imponibile,imposta,ZERO);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13)
|
|
|
|
_iva1_array.add_riga(tipo,imponibile,imposta,ZERO);
|
|
|
|
}
|
|
|
|
break;
|
1995-07-13 12:38:04 +00:00
|
|
|
default:
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese != 13)
|
|
|
|
_iva_array.add_riga(tipo,imponibile,imposta,ZERO);
|
|
|
|
if ((_st_inizio_anno && mese == _mese) || _mese == 13)
|
1995-07-13 12:38:04 +00:00
|
|
|
_iva1_array.add_riga(tipo,imponibile,imposta,ZERO);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-02-19 08:46:05 +00:00
|
|
|
// Scorpora i corrispettivi
|
|
|
|
for (cp = (real*) _corr_array.first_item(); cp != NULL; cp = (real*) _corr_array.succ_item())
|
|
|
|
{
|
|
|
|
codiva = _corr_array.get_hashobj()->key();
|
|
|
|
tabiva.put("CODTAB",codiva);
|
|
|
|
if (tabiva.read() == NOERR) aliquota = tabiva.get_real("R0");
|
|
|
|
else aliquota = ZERO;
|
|
|
|
lordo2netto(*cp,imponibile,imposta,aliquota/100.0);
|
|
|
|
if (_mese != 13)
|
|
|
|
_gen_array.add_riga(codiva,imponibile,imposta,ZERO,ZERO,ZERO,ZERO);
|
|
|
|
if (_st_inizio_anno || _mese == 13) //lo metto in un array a parte
|
|
|
|
_gen1_array.add_riga(codiva,imponibile,imposta,ZERO,ZERO,ZERO,ZERO);
|
|
|
|
}
|
1995-07-13 12:38:04 +00:00
|
|
|
_gen_array.sort(compare_rows); // ordinamento per codice iva
|
|
|
|
_gen1_array.sort(compare_rows); // ordinamento per codice iva
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::cerca_i_pim()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
TTable pim("PIM");
|
1997-11-19 17:20:26 +00:00
|
|
|
TTable tabiva("%IVA");
|
1996-12-04 09:10:39 +00:00
|
|
|
TTable reg("REG");
|
|
|
|
TString80 codtab;
|
|
|
|
TString16 codatt,codiva,tipoiva,codreg;
|
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
for (pim.first(); !pim.eof(); pim.next())
|
|
|
|
{
|
|
|
|
real imponibile, imposta, impo, impos;
|
|
|
|
tiporec tipo;
|
|
|
|
|
1996-12-04 09:10:39 +00:00
|
|
|
codtab = pim.get("CODTAB");
|
1995-07-13 12:38:04 +00:00
|
|
|
int anno = atoi(codtab.mid(0,4));
|
1996-12-04 09:10:39 +00:00
|
|
|
codatt = codtab.mid(4,5);
|
1995-07-13 12:38:04 +00:00
|
|
|
int mese = atoi(codtab.mid(13,2));
|
1996-12-04 09:10:39 +00:00
|
|
|
codreg.format("%d%-3s",anno, (const char*)codtab.mid(10,3));
|
|
|
|
codiva = codtab.mid(16,4);
|
|
|
|
tipoiva = pim.get("S5");
|
1995-07-13 12:38:04 +00:00
|
|
|
|
|
|
|
if (anno != _annoiva) continue;
|
|
|
|
|
|
|
|
//Modifica del 12/07/1995
|
|
|
|
if (tipoiva == "VE") continue;
|
|
|
|
//Fine
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
1996-12-04 09:10:39 +00:00
|
|
|
reg.put("CODTAB",codreg);
|
|
|
|
if (reg.read() != NOERR) reg.zero();
|
|
|
|
const bool corrisp = reg.get_bool("B0");
|
|
|
|
|
1995-11-03 09:44:29 +00:00
|
|
|
while (classify_pim(pim.curr(), imponibile, imposta, tipo, FALSE))
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
switch(tipo)
|
|
|
|
{
|
|
|
|
case acq_norm:
|
|
|
|
if (_tipoprog == 1) break; //vendite
|
|
|
|
if (_tipo_aliq == 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
|
1996-12-04 09:10:39 +00:00
|
|
|
if (corrisp)
|
|
|
|
{ // Questo perche' i documenti FS sono registrati col segno
|
|
|
|
// negativo in R0/R1 e col segno positivo in R5/R6,
|
1996-12-06 13:58:26 +00:00
|
|
|
imponibile += pim.get_real("R5");
|
|
|
|
imposta += pim.get_real("R6");
|
1996-12-04 09:10:39 +00:00
|
|
|
}
|
1995-07-13 12:38:04 +00:00
|
|
|
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_aliq == 2)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_ind_pass_int:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_aliq == 3)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
1996-09-17 17:32:48 +00:00
|
|
|
case acq_bd_ind_art_19:
|
1995-07-13 12:38:04 +00:00
|
|
|
case acq_ind_art_19:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_aliq == 4)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case base_ventilazione:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_aliq == 5)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case bolle_doganali:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_aliq == 6)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_simp:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_aliq == 7)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_beni_riv:
|
|
|
|
if (_tipoprog == 1) break;
|
1997-11-19 17:20:26 +00:00
|
|
|
tabiva.put("CODTAB",codiva);
|
|
|
|
if (tabiva.read() == NOERR)
|
|
|
|
// I non soggetti non vanno considerati nel totale acq. beni rivendita
|
|
|
|
if (tabiva.get("S1") != "NS")
|
|
|
|
if (_tipo_attiv == 1)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
1995-07-13 12:38:04 +00:00
|
|
|
break;
|
|
|
|
case acq_beni_ammort:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_attiv == 2)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_beni_ammort_nd:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_attiv == 3)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_beni_leasing:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_attiv == 4)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acq_amm_ultdetr:
|
|
|
|
if (_tipoprog == 1) break;
|
|
|
|
if (_tipo_attiv == 5)
|
|
|
|
{
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cess_amm:
|
|
|
|
if (_tipoprog == 2) break;
|
|
|
|
if (_livelloprog == 2) //Nel caso di vendite per attivita' il tipo costo/ricavo
|
|
|
|
{ //viene forzato a 4 => cessione beni ammortizzabili
|
|
|
|
impo += imponibile;
|
|
|
|
impos += imposta;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} //fine while
|
|
|
|
_mesi[mese].imponibile += impo;
|
|
|
|
_mesi[mese].imposta += impos;
|
|
|
|
impo = impos = ZERO;
|
|
|
|
}
|
|
|
|
}
|
1996-05-20 13:17:58 +00:00
|
|
|
|
|
|
|
bool TProgressivi_iva::tipo_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
const int livello = m.get_int(F_LIVELLO);
|
|
|
|
const int tipo = atoi(f.get());
|
|
|
|
bool tab = FALSE, tabe = FALSE, tabel = FALSE;
|
|
|
|
if (livello == 1)
|
|
|
|
{
|
|
|
|
tab = tipo == 1;
|
|
|
|
tabe = tipo == 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tabel = tipo == 2;
|
|
|
|
}
|
|
|
|
m.show(F_TIPOTAB, tab);
|
|
|
|
m.show(F_TIPOTABE, tabe);
|
|
|
|
m.show(F_TIPOTABEL, tabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1995-07-13 12:38:04 +00:00
|
|
|
|
1996-09-13 07:34:35 +00:00
|
|
|
bool TProgressivi_iva::selection_handler(TMask_field& f, KEY k)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
1996-09-13 07:34:35 +00:00
|
|
|
if (k == K_SPACE)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
1996-09-13 07:34:35 +00:00
|
|
|
TMask& m = f.mask();
|
|
|
|
const int sel = atoi(f.get());
|
|
|
|
if (sel == 1)
|
|
|
|
{
|
|
|
|
const bool b = atoi(m.field(F_LIVELLO).get()) == 1 ? TRUE : FALSE;
|
|
|
|
m.show(F_CODIVA,b);
|
|
|
|
m.show(F_ATTIVITA,!b);
|
|
|
|
tipo_handler(m.field(F_TIPO),K_SPACE);
|
|
|
|
}
|
1996-05-20 13:17:58 +00:00
|
|
|
}
|
1996-09-13 07:34:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TProgressivi_iva::set_print(int m)
|
|
|
|
{
|
|
|
|
TMask msk("cg0400a");
|
|
|
|
|
|
|
|
msk.set_handler(F_TIPO, tipo_handler);
|
|
|
|
msk.set_handler(F_SELECTION, selection_handler);
|
1996-05-20 13:17:58 +00:00
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
if (msk.run() != K_ENTER) return FALSE;
|
|
|
|
|
1996-09-13 07:34:35 +00:00
|
|
|
_tipo_lista = msk.get_int(F_SELECTION) == 1 ? visualizza : stampa;
|
|
|
|
|
1995-07-13 12:38:04 +00:00
|
|
|
switch (_tipo_lista)
|
|
|
|
{
|
1996-09-13 07:34:35 +00:00
|
|
|
case visualizza:
|
|
|
|
{
|
|
|
|
_sospmsk = _tipo_aliq = _tipo_attiv = 0;
|
|
|
|
_codditta = msk.get_long(F_CODDITTA);
|
1997-01-31 09:29:15 +00:00
|
|
|
prefix().set_codditta(_codditta);
|
1996-09-13 07:34:35 +00:00
|
|
|
_annoiva = msk.get_int(F_ANNO);
|
|
|
|
_tipoprog = msk.get_int(F_TIPO); // 1 <=> vendite; 2 <=> acquisti
|
|
|
|
_livelloprog = msk.get_int(F_LIVELLO); // 1 <=> aliquota; 2 <=> attivita'
|
|
|
|
_codivamsk = msk.get(F_CODIVA);
|
|
|
|
_codattmsk = msk.get(F_ATTIVITA);
|
|
|
|
if (_livelloprog == 1 && _tipoprog == 2)
|
|
|
|
_tipo_aliq = msk.get_int(F_TIPOTABE);
|
|
|
|
if (_livelloprog == 2 && _tipoprog == 2)
|
|
|
|
_tipo_attiv = msk.get_int(F_TIPOTABEL);
|
|
|
|
if (_tipoprog == 1 && _livelloprog == 1)
|
|
|
|
_sospmsk = msk.get_int(F_TIPOTAB); //vendite in genere; vendite in sospensione d'imposta
|
|
|
|
|
|
|
|
setta_intestazione();
|
|
|
|
azzera_mesi();
|
|
|
|
cerca_i_pim();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case stampa:
|
|
|
|
{
|
|
|
|
_codditta = msk.get_long(F_CODDITTA);
|
|
|
|
_anno = msk.get_int(F_ANNO);
|
|
|
|
_datast = msk.get(F_DATASTAMPA);
|
|
|
|
_mese = msk.get_int(F_MESE);
|
|
|
|
_st_inizio_anno = msk.get_bool(F_STAMPA);
|
1997-01-31 09:29:15 +00:00
|
|
|
prefix().set_codditta(_codditta);
|
|
|
|
|
1996-09-13 07:34:35 +00:00
|
|
|
TLocalisamfile attiv(LF_ATTIV);
|
|
|
|
attiv.zero();
|
|
|
|
attiv.put(ATT_CODDITTA, _codditta);
|
|
|
|
TRectype r(attiv.curr());
|
|
|
|
//prospetto per ogni codice attivita' della ditta
|
|
|
|
for(attiv.read(_isgteq); !attiv.eof(); attiv.next())
|
|
|
|
{
|
|
|
|
if (attiv.curr() != r) break;
|
|
|
|
|
|
|
|
_cod_att = attiv.get("CODATT");
|
|
|
|
_prima_pagina = TRUE;
|
|
|
|
|
|
|
|
_iva_array.destroy();
|
|
|
|
_iva1_array.destroy();
|
|
|
|
_gen_array.destroy();
|
|
|
|
_gen1_array.destroy();
|
|
|
|
|
|
|
|
look_pim();
|
|
|
|
|
|
|
|
print();
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1995-07-13 12:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//set_real_picture("###.###.###.###");
|
|
|
|
//set_print_zero(FALSE);
|
|
|
|
//printer().footerlen(5);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::calcola_totali(real& imp, real& imps)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
for (int i=0; i<=12; i++)
|
|
|
|
{
|
|
|
|
imp += _mesi[i].imponibile;
|
|
|
|
imps += _mesi[i].imposta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::cerca_tipo(TIva_array& iva_array,tiporec t,
|
1995-07-13 12:38:04 +00:00
|
|
|
real& imp, real& imps, real& det)
|
|
|
|
{
|
|
|
|
int k = 0;
|
|
|
|
bool trovato = FALSE;
|
|
|
|
imp = imps = det = ZERO;
|
|
|
|
while ( k < iva_array.items() && !trovato)
|
|
|
|
{
|
|
|
|
TRiga_iva& riga = (TRiga_iva&)iva_array[k];
|
|
|
|
if (t == riga._tipo)
|
|
|
|
trovato = TRUE;
|
|
|
|
else k++;
|
|
|
|
}
|
|
|
|
if (trovato)
|
|
|
|
{
|
|
|
|
TRiga_iva& riga = (TRiga_iva&)iva_array[k];
|
|
|
|
imp = riga._imponibile;
|
|
|
|
imps = riga._imposta;
|
|
|
|
det = riga._detrazione;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
bool TProgressivi_iva::preprocess_page(int file, int counter)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
reset_print();
|
|
|
|
|
|
|
|
switch (_tipo_lista)
|
|
|
|
{
|
|
|
|
case stampa:
|
|
|
|
{
|
|
|
|
if (!_st_inizio_anno)
|
|
|
|
prospetto_pagina(_gen_array,_iva_array);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_prima_pagina)
|
|
|
|
prospetto_pagina(_gen1_array,_iva1_array);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printer().formfeed();
|
|
|
|
prospetto_pagina(_gen_array,_iva_array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case visualizza:
|
|
|
|
{
|
|
|
|
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 (_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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
real t_impov,t_imposv,t_impoa,t_imposa,t_impobd,t_imposbd;
|
|
|
|
t_impov = t_imposv = t_impoa = t_imposa = t_impobd = t_imposbd = ZERO;
|
|
|
|
int r = 1;
|
1996-12-06 08:16:43 +00:00
|
|
|
TString80 descr;
|
1995-07-13 12:38:04 +00:00
|
|
|
|
|
|
|
set_row(++r, "Cod.@40gVENDITE@77gACQUISTI@113gIMPORTAZIONI");
|
|
|
|
set_row(++r, "IVA Descrizione@29gImponibile@48gImposta@67gImponibile@86gImposta@105gImponibile@124gImposta");
|
|
|
|
r+=2;
|
|
|
|
|
|
|
|
for (int k = 0; k < gen.items(); k++)
|
|
|
|
{
|
|
|
|
TRiga_gen& riga = (TRiga_gen&)gen[k];
|
1996-12-06 08:16:43 +00:00
|
|
|
descr = desc_iva(riga._codiva);
|
|
|
|
if (riga._codiva[0] == '{') riga._codiva.ltrim(1);
|
1995-07-13 12:38:04 +00:00
|
|
|
if (riga._impoven != ZERO)
|
|
|
|
set_row(r, "@24g%r", &riga._impoven);
|
|
|
|
if (riga._imposven != ZERO)
|
|
|
|
set_row(r, "@40g%r", &riga._imposven);
|
|
|
|
if (riga._impoacq != ZERO)
|
|
|
|
set_row(r, "@62g%r", &riga._impoacq);
|
|
|
|
if (riga._imposacq != ZERO)
|
|
|
|
set_row(r, "@78g%r", &riga._imposacq);
|
|
|
|
if (riga._impobd != ZERO)
|
|
|
|
set_row(r, "@100g%r", &riga._impobd);
|
|
|
|
if (riga._imposbd != ZERO)
|
|
|
|
set_row(r, "@116g%r", &riga._imposbd);
|
|
|
|
if (riga._impoven != ZERO || riga._imposven != ZERO || riga._impoacq != ZERO
|
|
|
|
|| riga._imposacq != ZERO || riga._impobd != ZERO || riga._imposbd != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r, "@0g%-4s", (const char*)riga._codiva);
|
|
|
|
set_row(r, "@5g%-.18s", (const char*)descr);
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
|
|
|
|
t_impov += riga._impoven;
|
|
|
|
t_imposv += riga._imposven;
|
|
|
|
t_impoa += riga._impoacq;
|
|
|
|
t_imposa += riga._imposacq;
|
|
|
|
t_impobd += riga._impobd;
|
|
|
|
t_imposbd += riga._imposbd;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen.destroy();
|
|
|
|
|
|
|
|
r+=2;
|
|
|
|
set_row(r++, "Totale@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r",
|
|
|
|
&t_impov,&t_imposv,&t_impoa,&t_imposa,&t_impobd,&t_imposbd);
|
|
|
|
r++;
|
1996-09-17 17:32:48 +00:00
|
|
|
real im, is, d, im1, is1, d1; //inizializzati in cerca_tipo()
|
1995-07-13 12:38:04 +00:00
|
|
|
cerca_tipo(iva,acq_ind_op_es,im,is,d);
|
|
|
|
t_impoa += im;
|
|
|
|
t_imposa += is;
|
|
|
|
bool st_riga = FALSE;
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Totali acquisti indeducibili su ricavi esenti@62g%r@78g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_ind_art_19,im,is,d);
|
1996-09-17 17:32:48 +00:00
|
|
|
cerca_tipo(iva,acq_bd_ind_art_19,im1,is1,d1);
|
|
|
|
t_impoa += im;
|
|
|
|
t_imposa += is;
|
|
|
|
t_impobd += im1;
|
|
|
|
t_imposbd += is1;
|
|
|
|
if (im != ZERO || is != ZERO || im1 != ZERO || is1 != ZERO)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
1996-09-17 17:32:48 +00:00
|
|
|
set_row(r++, "Totali acquisti indeducibili per ART.19@62g%r@78g%r@100g%r@116g%r", &im, &is, &im1, &is1);
|
1995-07-13 12:38:04 +00:00
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_ind_pass_int,im,is,d);
|
|
|
|
t_impoa += im;
|
|
|
|
t_imposa += is;
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Totali acquisti indeducibili per passaggi interni@62g%r@78g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
r+=2;
|
|
|
|
if (st_riga)
|
|
|
|
set_row(r++, "Totale generale IVA@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r",
|
|
|
|
&t_impov,&t_imposv,&t_impoa,&t_imposa,&t_impobd,&t_imposbd);
|
|
|
|
r+=3;
|
|
|
|
int kk = r;
|
|
|
|
/*
|
|
|
|
set_row(r++, "ALTRI DATI RELATIVI ALLA DICHIARAZIONE@54gImponibile@74gImposta@91gDetrazione");
|
|
|
|
r++;
|
|
|
|
*/
|
|
|
|
r+=2;
|
|
|
|
|
|
|
|
st_riga = FALSE;
|
|
|
|
cerca_tipo(iva,acq_simp,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Acquisti in sospensione d'imposta@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,vend_simp,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Vendite in sospensione d'imposta@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,cess_amm,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Cessione beni ammortizzabili@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_beni_riv,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Acquisto beni destinati alla rivendita@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_beni_ammort,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Acquisto beni ammortizzabili iva detraibile@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_beni_ammort_nd,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Acquisto beni ammortizzabili iva non detraibile@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_beni_leasing,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Altri beni strumentali acquisiti in leasing@49g%r@66g%r", &im, &is);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
cerca_tipo(iva,acq_amm_ultdetr,im,is,d);
|
|
|
|
if (im != ZERO || is != ZERO)
|
|
|
|
{
|
|
|
|
set_row(r++, "Acquisto beni soggetti a detrazione (6%%)@49g%r@66g%r@86g%r", &im, &is, &d);
|
|
|
|
st_riga = TRUE;
|
|
|
|
}
|
|
|
|
if (st_riga)
|
|
|
|
set_row(kk, "ALTRI DATI RELATIVI ALLA DICHIARAZIONE@54gImponibile@74gImposta@91gDetrazione");
|
|
|
|
|
|
|
|
iva.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::get_dati_ditta()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
|
|
TLocalisamfile anag(LF_ANAG);
|
|
|
|
TString codanagr;
|
|
|
|
TString tipoa;
|
|
|
|
|
|
|
|
nditte.zero();
|
1995-09-18 10:45:10 +00:00
|
|
|
nditte.put(NDT_CODDITTA, _codditta);
|
1995-07-13 12:38:04 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
int TProgressivi_iva::stampa_intestazione_ditta()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
int r = 1;
|
|
|
|
TString riga(132);
|
|
|
|
|
|
|
|
get_dati_ditta();
|
|
|
|
|
1995-09-18 10:45:10 +00:00
|
|
|
set_header (r, "Ditta %ld %s %s %s %s %s", _codditta,
|
1995-07-13 12:38:04 +00:00
|
|
|
(const char*)_ragsoc, (const char*)_viafis,
|
|
|
|
(const char*)_cap, (const char*)_comunefis,
|
|
|
|
(const char*)_provfis);
|
|
|
|
r++;
|
|
|
|
riga = "Data @< Pag. @#";
|
|
|
|
riga.right_just(127);
|
1997-06-20 08:52:24 +00:00
|
|
|
|
|
|
|
TString80 dep; dep.format ("Partita iva %s Codice fiscale %s",
|
|
|
|
(const char*)_paiva, (const char*)_cofi);
|
|
|
|
riga.overwrite (dep);
|
1995-07-13 12:38:04 +00:00
|
|
|
set_header (r, "%s", (const char*) riga);
|
|
|
|
r+=3;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::setta_intestazione()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
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 (_livelloprog == 1)
|
|
|
|
{
|
|
|
|
if (_sospmsk == 1)
|
|
|
|
set_header(r, "Vendite in genere");
|
|
|
|
else set_header(r, "Vendite in sospensione d'imposta");
|
|
|
|
}
|
|
|
|
else set_header(r, "Cessione beni da ammortizzare");
|
|
|
|
}
|
|
|
|
else //acquisti
|
|
|
|
{
|
|
|
|
if (_livelloprog == 1) //per codice iva
|
|
|
|
switch (_tipo_aliq)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
case 7:
|
|
|
|
set_header(r, "Acquisti in sospensione d'imposta");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else //per attivita'
|
|
|
|
switch (_tipo_attiv)
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
void TProgressivi_iva::preprocess_header()
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
if (_tipo_lista == stampa)
|
|
|
|
{
|
|
|
|
int soh = 1;
|
|
|
|
TString sep(132);
|
|
|
|
TString ragsoc(50);
|
|
|
|
//TString attprev(5);
|
|
|
|
TString16 descf;
|
|
|
|
|
|
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
|
|
nditte.zero();
|
1995-09-18 10:45:10 +00:00
|
|
|
nditte.put(NDT_CODDITTA, _codditta);
|
1995-07-13 12:38:04 +00:00
|
|
|
if (nditte.read() == NOERR)
|
|
|
|
{
|
|
|
|
ragsoc = nditte.get(NDT_RAGSOC);
|
|
|
|
//attprev = nditte.get(NDT_CODATTPREV);
|
|
|
|
}
|
|
|
|
|
|
|
|
//TString80 descr = desc_attivita(attprev);
|
|
|
|
|
|
|
|
TString80 descr = desc_attivita(_cod_att);
|
|
|
|
|
|
|
|
reset_header();
|
|
|
|
|
1995-09-18 10:45:10 +00:00
|
|
|
char f = look_lia(_codditta);
|
1995-07-13 12:38:04 +00:00
|
|
|
if (f == 'T')
|
|
|
|
descf = " TRIMESTRALE";
|
|
|
|
else if (f == 'M')
|
|
|
|
descf = " MENSILE";
|
|
|
|
else descf = "";
|
|
|
|
|
1995-09-18 10:45:10 +00:00
|
|
|
sep << "Ditta " << _codditta;
|
1995-07-13 12:38:04 +00:00
|
|
|
sep << " " << ragsoc;
|
|
|
|
sep << " " << descf;
|
|
|
|
|
|
|
|
sep.left_just(132);
|
|
|
|
|
|
|
|
set_header (soh++, (const char*) sep);
|
|
|
|
|
|
|
|
sep = "";
|
|
|
|
sep << "Data " << _datast;
|
|
|
|
sep << " Pag. @#";
|
|
|
|
|
|
|
|
sep.right_just(127);
|
|
|
|
|
|
|
|
sep.overwrite ("RIEPILOGO PROGRESSIVI");
|
|
|
|
set_header (soh++, (const char*)sep);
|
|
|
|
sep.fill('-');
|
|
|
|
set_header (soh++, (const char *) sep);
|
|
|
|
/*
|
|
|
|
set_header (soh++, "Riepilogo progressivi IVA del periodo %s %d Cod. Att. %s %s", itom(_mese), _anno, (const char*) _cod_att, (const char*) descr);
|
|
|
|
set_header (soh++, (const char *) sep);
|
1995-11-03 09:44:29 +00:00
|
|
|
*/
|
1995-07-13 12:38:04 +00:00
|
|
|
if (_st_inizio_anno)
|
|
|
|
{
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_mese == 13 || (_mese == 12 && !_prima_pagina))
|
|
|
|
set_header(soh++, "Riepilogo progressivi IVA annuale %d Cod. Att. %s %s", _anno, (const char*) _cod_att, (const char*) descr);
|
|
|
|
else
|
1995-07-13 12:38:04 +00:00
|
|
|
if (_prima_pagina)
|
|
|
|
set_header(soh++, "Riepilogo progressivi IVA del periodo %s %d Cod. Att. %s %s", itom(_mese), _anno, (const char*) _cod_att, (const char*) descr);
|
|
|
|
else set_header(soh++, "Riepilogo progressivi IVA al Mese di: %s %d Cod. Att. %s %s", itom(_mese), _anno, (const char*) _cod_att, (const char*) descr);
|
|
|
|
}
|
|
|
|
else set_header (soh++, "Riepilogo progressivi IVA del periodo %s %d Cod. Att. %s %s", itom(_mese), _anno, (const char*) _cod_att, (const char*) descr);
|
|
|
|
set_header (soh, (const char *) sep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-20 13:17:58 +00:00
|
|
|
print_action TProgressivi_iva::postprocess_page(int file, int counter)
|
1995-07-13 12:38:04 +00:00
|
|
|
{
|
|
|
|
switch (_tipo_lista)
|
|
|
|
{
|
|
|
|
case stampa:
|
|
|
|
{
|
1996-07-19 09:55:18 +00:00
|
|
|
if (_st_inizio_anno && _mese != 13)
|
1995-07-13 12:38:04 +00:00
|
|
|
if (_prima_pagina)
|
|
|
|
{
|
|
|
|
_prima_pagina = FALSE;
|
|
|
|
return REPEAT_PAGE;
|
|
|
|
}
|
|
|
|
else return NEXT_PAGE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case visualizza:
|
|
|
|
{
|
|
|
|
if (_i < 12) return REPEAT_PAGE;
|
|
|
|
else return NEXT_PAGE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NEXT_PAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cg0400(int argc,char* argv[])
|
|
|
|
{
|
1996-05-20 13:17:58 +00:00
|
|
|
TProgressivi_iva a;
|
1995-07-13 12:38:04 +00:00
|
|
|
a.run(argc, argv, "Riepilogo progressivi IVA");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|