Files correlati : cf4.exe Commento : Nella stampa registri la variabile agenzie di viagio non ere inizializzata per cui poteva considerare agenzie di viaggio per l'IVA per cassa anche ditte che non lo erano. Nella liquidazione IVA la restore status non funzionava più. Questo aveva efftto per i trimestrali che cacolano 3 mesi e stampano sul terzo che non veniva mai esaminato.
3393 lines
109 KiB
C++
Executable File
3393 lines
109 KiB
C++
Executable File
// ------------------------------------------------------------
|
||
// Calcolo liquidazioni
|
||
// Part 5: stampa
|
||
// fv 21-1-94
|
||
// ------------------------------------------------------------
|
||
|
||
#include <modaut.h>
|
||
#include <recarray.h>
|
||
#include <recset.h>
|
||
#include <utility.h>
|
||
|
||
#include "cg4300.h"
|
||
|
||
#include <attiv.h>
|
||
#include <nditte.h>
|
||
#include <rmoviva.h>
|
||
#include "ivadiff.h"
|
||
|
||
// flags per annuale
|
||
#define IS_PRORATA 0x0001
|
||
|
||
// minchietta per prospetto ventilazione
|
||
struct _vDesc : public TObject
|
||
{
|
||
TString4 _codiva;
|
||
real _acq, _vnd, _viv;
|
||
};
|
||
|
||
const char* const sep =
|
||
"------------------------------------------------------------------"
|
||
"------------------------------------------------------------------";
|
||
|
||
void TLiquidazione_app::set_page(int file, int cnt)
|
||
{
|
||
_DescrItem& d = (_DescrItem&)_descr_arr[cnt];
|
||
|
||
set_auto_ff(false);
|
||
reset_print();
|
||
|
||
switch(d._flags)
|
||
{
|
||
case CHG_PARMS:
|
||
set_att(d);
|
||
break;
|
||
case SET_FIRM:
|
||
set_firm(d);
|
||
break;
|
||
case PIS_ROW:
|
||
case PIM_ROW:
|
||
case PIS_ROW_D:
|
||
case PIM_ROW_D:
|
||
case PIS_ROW_DI:
|
||
case PIM_ROW_DI:
|
||
set_pim(d);
|
||
break;
|
||
case PIS_HEAD:
|
||
case PIM_HEAD:
|
||
case PIS_HEAD_D:
|
||
case PIM_HEAD_D:
|
||
case PIS_HEAD_DI:
|
||
case PIM_HEAD_DI:
|
||
set_pim_head(d);
|
||
break;
|
||
case MISC_LIQ:
|
||
set_pumpam(d);
|
||
break;
|
||
case TOT_ROW:
|
||
set_plm(d);
|
||
break;
|
||
case TOT_ROW_D:
|
||
case TOT_ROW_DI:
|
||
set_plm_diff(d);
|
||
break;
|
||
case PLAFOND:
|
||
set_plafond(d);
|
||
break;
|
||
case VENTILA:
|
||
set_ventila(d);
|
||
break;
|
||
case REGAGR:
|
||
set_regagr(d);
|
||
break;
|
||
case REGVIA:
|
||
set_viaggio(d);
|
||
break;
|
||
case THE_END:
|
||
set_grand(d);
|
||
break;
|
||
case LIQACC:
|
||
set_liqacc_2000(d);
|
||
break;
|
||
case ACCONTO:
|
||
set_acconto_p(d);
|
||
break;
|
||
case ACCHEAD:
|
||
set_acchead_p(d);
|
||
break;
|
||
case DELDEB:
|
||
set_deltab(d, false);
|
||
break;
|
||
case DELCRED:
|
||
set_deltab(d, true);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
print_action TLiquidazione_app::postprocess_page(int file, int cnt)
|
||
{
|
||
if (_descr_arr.items() == 0 || cnt == _descr_arr.items()-1)
|
||
return NEXT_PAGE;
|
||
return REPEAT_PAGE;
|
||
}
|
||
|
||
bool TLiquidazione_app::preprocess_page(int file, int cnt)
|
||
{
|
||
return _descr_arr.items() != 0;
|
||
}
|
||
|
||
// ----------------------------------------------------------------
|
||
// Print description
|
||
// ----------------------------------------------------------------
|
||
|
||
void TLiquidazione_app::describe_att(int month, const char* codatt, bool /*isresult*/, char flags)
|
||
{
|
||
if (_isprint && _canprint)
|
||
{
|
||
TToken_string atts(codatt);
|
||
const bool single_att = atts.items() == 1;
|
||
|
||
describe_name(month, atts, flags);
|
||
|
||
if (single_att)
|
||
{
|
||
if (_isplafond)
|
||
describe_plafond(month, codatt);
|
||
if (_isvent)
|
||
describe_ventilation(month, codatt);
|
||
if (_isagricolo)
|
||
describe_agricolo(month, codatt);
|
||
if (_isviaggio)
|
||
describe_viaggio(month, codatt);
|
||
}
|
||
|
||
describe_pims(month, codatt, false); // PIM
|
||
describe_pims(month, codatt, true); // PIS
|
||
|
||
if (single_att)
|
||
describe_consistence(codatt);
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::describe_name(int month, const TToken_string& codatts, char flags)
|
||
{
|
||
const bool single_att = codatts.items() == 1;
|
||
|
||
_DescrItem* d = new _DescrItem(CHG_PARMS);
|
||
|
||
d->_s0 = _nditte->curr().get(NDT_CODDITTA);
|
||
d->_s1 = _nditte->curr().get(NDT_RAGSOC);
|
||
|
||
const TRectype& ndt_att = _nditte->curr(LF_ATTIV);
|
||
d->_s2 = ndt_att.get(ATT_CODATECO);
|
||
if (d->_s2.blank())
|
||
d->_s2 = ndt_att.get(ATT_CODATT);
|
||
d->_s3 = single_att ? (const char*)ndt_att.get(ATT_DESCR) : "";
|
||
d->_s4 = _freqviva;
|
||
|
||
d->_f1 = month;
|
||
d->_f2 = _isbenzinaro;
|
||
d->_f3 = (word)flags;
|
||
|
||
d->_f0 = 0;
|
||
if (_mixed && single_att)
|
||
d->_f0 = atoi(codatts.mid(5));
|
||
|
||
_descr_arr.add(d);
|
||
}
|
||
|
||
void TLiquidazione_app::describe_firm(int month)
|
||
{
|
||
if (!_isprint || !_canprint) return;
|
||
|
||
_DescrItem* d = new _DescrItem(SET_FIRM);
|
||
|
||
d->_s0 = _nditte->curr().get("CODDITTA");
|
||
d->_s1 = _nditte->curr().get("RAGSOC");
|
||
d->_s2 = _freqviva;
|
||
d->_f1 = month;
|
||
_descr_arr.add(d);
|
||
}
|
||
|
||
void TLiquidazione_app::describe_liqacc()
|
||
{
|
||
if (!_isprint || !_canprint) return;
|
||
|
||
const TRectype & lia = get_lia();
|
||
|
||
if (lia.not_empty() && lia.get("S8") == "A")
|
||
{
|
||
|
||
_DescrItem* d = new _DescrItem(LIQACC);
|
||
|
||
d->_r0 = lia.get_real("R7");
|
||
d->_r1 = lia.get_real("R13");
|
||
d->_r2 = lia.get_real("R14");
|
||
d->_r3 = lia.get_real("R9");
|
||
d->_r4 = lia.get_real("R10");
|
||
d->_r5 = lia.get_real("R8");
|
||
d->_r6 = lia.get_real("R12");
|
||
d->_r7 = lia.get_real("R11");
|
||
d->_r8 = lia.get_real("R4");
|
||
d->_r29 = lia.get_real("R29");
|
||
d->_r33 = lia.get_real("R33");
|
||
TToken_string ff(lia.get("S1"),'!');
|
||
real cre_pre (ff.get(0));
|
||
real acq_intr (ff.get(1));
|
||
d->_r9 = cre_pre;
|
||
|
||
_descr_arr.add(d);
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::describe_plafond(int month, const char* codatt)
|
||
{
|
||
TString att(codatt);
|
||
// prepara la descrizione del riepilogo da stampare e lo accoda
|
||
real t1, t2, t3;
|
||
_DescrItem* d = new _DescrItem(PLAFOND);
|
||
|
||
if (month == 13)
|
||
look_pla(codatt);
|
||
for (int jj = 1; jj <= 3; jj++) // three types of plafond
|
||
{
|
||
t1 = 0.0; t2 = 0.0; t3 = 0.0;
|
||
|
||
if (month < 13)
|
||
{
|
||
look_ppa(_freqviva == "M" ? month : next_trim(month) -2, codatt,jj);
|
||
t3 = _ppa->get_real("R2");
|
||
}
|
||
for (int m = 1; m <= month && m < 13; m++)
|
||
{
|
||
if (is_month_ok(m,month) && look_ppa(m,codatt,jj))
|
||
{
|
||
t1 += _ppa->get_real("R0");
|
||
t2 += _ppa->get_real("R1");
|
||
}
|
||
}
|
||
switch (jj)
|
||
{
|
||
case 1:
|
||
d->_r0 = t1; d->_r1 = t2;
|
||
d->_r2 = month < 13 ? t3 : _pla->get_real("R5");
|
||
break;
|
||
case 2:
|
||
d->_r3 = t1; d->_r4 = t2;
|
||
d->_r5 = month < 13 ? t3 : _pla->get_real("R6");
|
||
break;
|
||
case 3:
|
||
d->_r6 = t1; d->_r7 = t2;
|
||
d->_r8 = month < 13 ? t3 : _pla->get_real("R7");
|
||
break;
|
||
}
|
||
} // for tipo esenzione plafond
|
||
|
||
_descr_arr.add(d);
|
||
|
||
// bookmark
|
||
}
|
||
|
||
void TLiquidazione_app::describe_ventilation(int month, const char* codatt)
|
||
{
|
||
if (!_isvent || _isagricolo || _isviaggio)
|
||
return;
|
||
|
||
_DescrItem* d = new _DescrItem(VENTILA);
|
||
TString16 att = codatt;
|
||
|
||
look_plm(month, att);
|
||
|
||
for (_pim->first(); !_pim->eof(); _pim->next())
|
||
{
|
||
if (strcmp(*_pim_codatt,att) != 0)
|
||
continue;
|
||
|
||
look_reg(*_pim_codreg);
|
||
look_iva(*_pim_codiva);
|
||
|
||
int tipocr = atoi(*_pim_tipocr);
|
||
int tipodet = atoi(*_pim_tipodet);
|
||
int mese = atoi(*_pim_mese);
|
||
bool corrisp = _reg->get_bool("B0");
|
||
real imponibile = _pim->get_real("R0");
|
||
real imposta = _pim->get_real("R1");
|
||
tiporeg tipomov = (tiporeg)_reg->get_long("I0");
|
||
TString4 tipoiva = _iva->get("S1");
|
||
|
||
if (_year != *_pim_anno || (month == 13 && mese < 13))
|
||
continue;
|
||
|
||
if (imponibile.is_zero() && imposta.is_zero()) continue;
|
||
|
||
// questi non vanno in liquidazione, i totali sono
|
||
// gia' calcolati altrove
|
||
if (tipodet == 1 || (tipodet == 3 && tipocr == 5) || tipodet == 9)
|
||
continue;
|
||
|
||
// questi non si devono vedere perche' so' bbrutti
|
||
if (tipoiva == "NS" || tipoiva == "ES" || tipoiva == "NI")
|
||
continue;
|
||
|
||
if (mese <= month)
|
||
{
|
||
if (tipocr == 1 && tipomov == acquisto)
|
||
{
|
||
// somma agli acquisti
|
||
_vDesc* vd = NULL;
|
||
for (int i = 0; i < d->_arr.items(); i++)
|
||
{
|
||
_vDesc* vv = (_vDesc*)&(d->_arr[i]);
|
||
if (strcmp(vv->_codiva,*_pim_codiva) == 0)
|
||
{ vd = vv; break; }
|
||
}
|
||
if (vd == NULL) { vd = new _vDesc; }
|
||
|
||
vd->_acq += (imponibile+imposta);
|
||
d->_r0 += (imponibile+imposta);
|
||
|
||
if (vd->_codiva.empty())
|
||
{
|
||
vd->_codiva = *_pim_codiva;
|
||
d->_arr.add(vd);
|
||
}
|
||
}
|
||
else if ((is_month_ok(mese,month) || month == 13) && corrisp
|
||
&& _pim->get_bool("B1") &&
|
||
tipocr == 0 && tipomov == vendita)
|
||
// non sono sicurissimo della above condition
|
||
{
|
||
// somma alle vendite
|
||
_vDesc* vd = NULL;
|
||
for (int i = 0; i < d->_arr.items(); i++)
|
||
{
|
||
_vDesc* vv = (_vDesc*)&(d->_arr[i]);
|
||
if (strcmp(vv->_codiva,*_pim_codiva) == 0)
|
||
{ vd = vv; break; }
|
||
}
|
||
if (vd == NULL) { vd = new _vDesc; }
|
||
|
||
vd->_vnd += imponibile;
|
||
vd->_viv += imposta;
|
||
|
||
d->_r1 += imponibile+imposta;
|
||
|
||
if (vd->_codiva.empty())
|
||
{
|
||
vd->_codiva = *_pim_codiva;
|
||
d->_arr.add(vd);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
d->_r0 = _pam->get_real("R2"); // Totale acquisti
|
||
d->_r1 = _pam->get_real("R3"); // Totale vendite
|
||
|
||
if (d->_r1.is_zero() || d->_r0.is_zero())
|
||
delete d;
|
||
else
|
||
{
|
||
// Questo e' il fantastico moltiplicatore
|
||
d->_r2 = d->_r1 / d->_r0;
|
||
_descr_arr.add(d);
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::describe_agricolo(int month, const char* codatt)
|
||
{
|
||
_DescrItem* d = new _DescrItem(REGAGR);
|
||
|
||
// Setta l'array interno con tutti gli items relativi alla tabella PIA
|
||
TArray& agr_array = d->_arr;
|
||
for (_pia->first(); !_pia->eof(); _pia->next()) // Scorre i progressivi agricoli
|
||
{
|
||
if (strcmp((const char*)*_pia_codatt, codatt) == 0 &&
|
||
is_month_plain(atoi(*_pia_mese)) && _year == *_pia_anno) // E sono gia' in ordine di codice...
|
||
{
|
||
_DescrItem* p = new _DescrItem(PROGAGR);
|
||
p->_r0 = _pia->get_real("R0"); // Imponibile
|
||
p->_r1 = _pia->get_real("R1"); // Imposta
|
||
p->_s0 = *_pia_codord; // Codice iva ordinario
|
||
p->_s1 = *_pia_codcom; // Codice iva compensazione
|
||
if (p->_r0 != ZERO || p->_r1 != ZERO)
|
||
agr_array.add(p); // Aggiunge il fottuto item agricolo
|
||
}
|
||
}
|
||
|
||
for (int mese = month == 13 ? 13 : 1; mese <= month; mese++)
|
||
{
|
||
if (!is_month_ok(mese,month))
|
||
continue;
|
||
|
||
if (!look_plm(mese, codatt))
|
||
continue;
|
||
|
||
d->_r0 += _plm->get_real("R5");
|
||
d->_r1 += _plm->get_real("R6");
|
||
d->_r2 += _plm->get_real("R7");
|
||
d->_r3 += _plm->get_real("R8");
|
||
d->_r4 += _plm->get_real("R9");
|
||
d->_r5 += _plm->get_real("R10");
|
||
d->_r6 += _plm->get_real("R11");
|
||
d->_r7 += _pum->get_real("R10");
|
||
d->_r8 += _pum->get_real("R11");
|
||
d->_r11 += _plm->get_real("R13");
|
||
}
|
||
// Aggiungo anche questi per comodita' futura.
|
||
// in caso di ditta a regime agricolo
|
||
// alias:
|
||
// _r9 mantiene la percentuale (gia' arrotondata!)
|
||
// _r10 mantiene l'iva detraibile calcolata!
|
||
d->_r9 = d->_r8 / (d->_r7 + d->_r8);
|
||
round_al_centesimo(d->_r9);
|
||
d->_r10 = d->_r6 * d->_r9;
|
||
d->_r9 *= CENTO;
|
||
round_al_centesimo(d->_r10);
|
||
|
||
_descr_arr.add(d);
|
||
}
|
||
|
||
void TLiquidazione_app::describe_viaggio(int month, const char* codatt)
|
||
{
|
||
const TRectype & lim = get_lim(month);
|
||
|
||
if (lim.not_empty())
|
||
{
|
||
_DescrItem* d = new _DescrItem(REGVIA);
|
||
|
||
|
||
for (int mese = month == 13 ? 13 : 1; mese <= month; mese++)
|
||
{
|
||
if (!is_month_ok(mese,month) || !look_plm(mese, codatt))
|
||
continue;
|
||
|
||
d->_r0 += _plm->get_real("R5"); // corrispettivi CEE
|
||
d->_r1 += _plm->get_real("R9"); // corrispettivi misti CEE
|
||
d->_r2 += _plm->get_real("R6"); // corrispettivi fuori CE
|
||
d->_r3 += _plm->get_real("R7"); // acquisti CEE
|
||
d->_r4 += _plm->get_real("R10"); // acquisti misti parte CEE
|
||
d->_r5 += _plm->get_real("R8"); // acquisti fuori CEE
|
||
d->_r6 += _plm->get_real("R11"); // acquisti misti parte fuori CEE
|
||
}
|
||
|
||
// credito di costo precedente (CHECK annuale)
|
||
d->_r8 = credito_costo_prec(month);
|
||
|
||
// Solita minchiatina dell'arrotondamento alle 1000 lirette se siamo in annuale
|
||
if (month == 13 || atoi(_year) >= 2000) // CM500314 e CM500315
|
||
{
|
||
round_imposta(d->_r0);
|
||
round_imposta(d->_r1);
|
||
round_imposta(d->_r2);
|
||
round_imposta(d->_r3);
|
||
round_imposta(d->_r4);
|
||
round_imposta(d->_r5);
|
||
round_imposta(d->_r6);
|
||
round_imposta(d->_r8);
|
||
}
|
||
|
||
d->_r7 = d->_r4.is_zero() ? ZERO : (d->_r4 * CENTO)/(d->_r4 + d->_r6); d->_r7.round(2); // percentuale
|
||
d->_r9 = (d->_r1 * d->_r7)/CENTO;
|
||
|
||
if (month == 13)
|
||
round_imposta(d->_r9);
|
||
else
|
||
round_al_centesimo(d->_r9);
|
||
|
||
// Calcola l'iva a debito, visto che servira' anche nel calcolo liquidazione (solo annuale)
|
||
const real aliva = aliquota_agvia();
|
||
const real alcnt = aliva + CENTO;
|
||
d->_r10 = (d->_r0 + d->_r9) - (d->_r3 + d->_r4 + d->_r8); // base imponibile lorda
|
||
if (d->_r10.sign() > 0)
|
||
{
|
||
// d->_r11 = (d->_r10/(alcnt/CENTO)) * (aliva/CENTO); // iva dovuta
|
||
d->_r11 = d->_r10 * aliva / alcnt; // iva dovuta
|
||
if (month == 13)
|
||
round_imposta(d->_r11);
|
||
else
|
||
round_al_centesimo(d->_r11);
|
||
}
|
||
_descr_arr.add(d);
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool describe_pis)
|
||
// le si passa una tokenstring (o un codatt) e lei, da brava, calcola
|
||
// cumulando per tutte le attivit<69> nominatele
|
||
// ogni riga riguarda un codiva ma tutti i registri
|
||
// se il mese e' 13 si guarda tutto l'anno
|
||
// se si tratta di una sola attivit<69> in att. mista evidenziata o servizievole,
|
||
// stampa solo vendite e corrispettivi
|
||
// L'ultimo parametro serve per calcolare i PIS (progressivi del periodo successivo)
|
||
{
|
||
TToken_string atts(codatt);
|
||
const TString8 ref(atts.items() == 1 ? codatt : "ALL");
|
||
int last = _descr_arr.last();
|
||
bool issosp = false;
|
||
real t0, t1, t2, t3, t4, t5, t15, t16, t26, t27, t28, t29, t30, t31, t32, t33;
|
||
real rt0, rt1, rt2, rt3, rt4, rt5;
|
||
real autodafe, autodafe_iva, art40, art40_iva;
|
||
real diffimp, diffiva, diffincimp, diffinciva;
|
||
real diffimp_acq, diffiva_acq, diffincimp_acq, diffinciva_acq;
|
||
const bool skip_acq = atts.items() == 1 && _mixed;
|
||
|
||
// descrittore riga autodafe'
|
||
_DescrItem* ads = NULL;
|
||
// descrittore riga iva dovuta ag. viaggio'
|
||
_DescrItem* iads = NULL;
|
||
|
||
// Seleziona la tabella corretta: PIM o PIS e l'identificatore
|
||
TTable* tab = describe_pis ? _pis : _pim;
|
||
const word PIM_PIS = describe_pis ? PIS_ROW : PIM_ROW;
|
||
|
||
// questa cazzata serve per far apparire l'intestazione delle colonne
|
||
// anche se le colonne non ci sono; in tal modo si ottiene una peggior
|
||
// chiarezza, una peggiore efficienza, una gran rottura di coglioni,
|
||
// ma risulta identico al dio Sistema.
|
||
_DescrItem * hea = NULL;
|
||
_DescrItem * head = NULL;
|
||
_DescrItem * headi = NULL;
|
||
_DescrItem * tot = NULL;
|
||
_DescrItem * totd = NULL;
|
||
_DescrItem * totdi = NULL;
|
||
int totpos = 0;
|
||
|
||
// Assoc array per memorizzare i corrispettivi da scorporare. Tali corrispettivi verranno
|
||
// aggiunti alla fine del ciclo, scorrendo tutte le righe generate.
|
||
TAssoc_array corr_ann;
|
||
_CorrItem cx;
|
||
|
||
FOR_EACH_TOKEN(atts, tmpatt)
|
||
{
|
||
const TString8 att(tmpatt);
|
||
|
||
tab->zero(); tab->put("CODTAB", _year); // 24-02-2014 partiamo dall'anno giusto!
|
||
for (int terr = tab->read(_isgteq); terr == NOERR; terr = tab->next())
|
||
{
|
||
_DescrItem* d = NULL;
|
||
// compute
|
||
const TString80 codtab = tab->get("CODTAB");
|
||
const TString4 anno = codtab.mid(0,4);
|
||
|
||
if (anno != _year)
|
||
break; // 27-02-2014 finiamo con l'anno sbagliato!
|
||
|
||
const TString8 activity= codtab.mid(4,6);
|
||
const int mese = atoi(codtab.mid(13,2));
|
||
const int tipodet = atoi(codtab.mid(20,1));
|
||
|
||
const TString4 codreg = codtab.mid(10,3);
|
||
if (!look_reg(codreg))
|
||
continue;
|
||
|
||
TString4 codiva = codtab.mid(16,4); codiva.trim();
|
||
if (!look_iva(codiva))
|
||
continue;
|
||
|
||
tiporeg tipomov = (tiporeg)_reg->get_int("I0");
|
||
bool corrisp = _reg->get_bool("B0");
|
||
const TString4 tipoiva = _iva->get("S1");
|
||
const TString4 other = tab->get("S4");
|
||
TToken_string s1(tab->get("S1"), '!'); // Imponibile/iva fatture in ritardo
|
||
real rit_imp(s1.get(0));
|
||
real rit_iva(s1.get(1));
|
||
|
||
/* Perch<63> _pim invece di tab ? 17-10-2012
|
||
diffimp = _pim->get_real("R26");
|
||
diffiva = _pim->get_real("R27");
|
||
diffincimp = _pim->get_real("R28");
|
||
diffinciva = _pim->get_real("R29");
|
||
|
||
diffimp_acq = _pim->get_real("R30");
|
||
diffiva_acq = _pim->get_real("R31");
|
||
diffincimp_acq = _pim->get_real("R32");
|
||
diffinciva_acq = _pim->get_real("R33"); */
|
||
|
||
diffimp = tab->get_real("R26");
|
||
diffiva = tab->get_real("R27");
|
||
diffincimp = tab->get_real("R28");
|
||
diffinciva = tab->get_real("R29");
|
||
|
||
diffimp_acq = tab->get_real("R30");
|
||
diffiva_acq = tab->get_real("R31");
|
||
diffincimp_acq = tab->get_real("R32");
|
||
diffinciva_acq = tab->get_real("R33");
|
||
|
||
const bool is_rit= tipodet != 0 && month == 13 && !rit_imp.is_zero(); //Se fattura in ritardo con tipo detr. != 0 e si sta calcolando l'annuale
|
||
const TRegistro & reg = cached_registro(_reg->curr());
|
||
const tipo_sospensione sosp_imp = reg.sospensione();
|
||
|
||
issosp |= (sosp_imp != nessuna_sospensione); // Setta il flag di presenza registri in sospensione (qualsiasi tipo: sospensione_normale, vol_affari, liquidazione)
|
||
// ACHTUNG! Corrispettivi da ventileer possono ventilare ad un altro codiva; in tal caso si scrive quello
|
||
if (corrisp && other.full())
|
||
{
|
||
look_iva(other);
|
||
codiva = other;
|
||
}
|
||
// se e' corrispettivo da ventilare non scrivo un cannolo ripieno visto che e' stato ventilato
|
||
if (tipomov == vendita && tipoiva == "VE" && !describe_pis)
|
||
continue;
|
||
|
||
// se e' il dettaglio di una attivita' mista non stampa gli acquisti, il perche' losalamadonna
|
||
if (tipomov == acquisto && skip_acq)
|
||
continue;
|
||
|
||
// questi non vanno in liquidazione, i totali sono gia' calcolati altrove
|
||
|
||
// se ha tutti gli importi nulli viene da un annullamento di
|
||
// progressivi esistenti (achtung fatture con scontrino)
|
||
if (tab->get_real("R0").is_zero() &&
|
||
tab->get_real("R1").is_zero() &&
|
||
tab->get_real("R2").is_zero() &&
|
||
tab->get_real("R5").is_zero() &&
|
||
tab->get_real("R6").is_zero() &&
|
||
tab->get_real("R26").is_zero() &&
|
||
tab->get_real("R27").is_zero() &&
|
||
tab->get_real("R28").is_zero() &&
|
||
tab->get_real("R29").is_zero() &&
|
||
tab->get_real("R30").is_zero() &&
|
||
tab->get_real("R31").is_zero() &&
|
||
tab->get_real("R32").is_zero() &&
|
||
tab->get_real("R33").is_zero())
|
||
continue;
|
||
|
||
if (activity == att && is_month_plain(mese) /*&& _year == anno*/) // commentato 27-02-2015
|
||
{
|
||
// vedi se c'e' gia' un item corrispondente
|
||
int i;
|
||
for(i = last+1; i < _descr_arr.items(); i++)
|
||
{
|
||
_DescrItem& wd = (_DescrItem&)_descr_arr[i];
|
||
if (wd._flags == PIM_PIS && wd._s0 == ref && wd._s1 == codiva)
|
||
{
|
||
d = &wd;
|
||
break;
|
||
}
|
||
if (wd._flags == TOT_ROW)
|
||
break;
|
||
if (wd._flags == PIM_PIS &&
|
||
wd._s0 == ref &&
|
||
wd._s1 > codiva)
|
||
break;
|
||
}
|
||
if (d == NULL)
|
||
{
|
||
const bool isfirst = (hea == NULL);
|
||
|
||
if (isfirst)
|
||
{
|
||
hea = new _DescrItem(describe_pis ? PIS_HEAD : PIM_HEAD);
|
||
hea->_f0 = skip_acq; // cos<6F> non compare nemmeno la colonnina! contento?
|
||
hea->_f1 = true;
|
||
_descr_arr.insert(hea, i++);
|
||
tot = new _DescrItem(TOT_ROW);
|
||
totpos = _descr_arr.insert(tot, i);
|
||
}
|
||
else
|
||
totpos++;
|
||
d = new _DescrItem(PIM_PIS);
|
||
d->_f0 = isfirst;
|
||
d->_s0 = ref;
|
||
d->_s1 = codiva;
|
||
_descr_arr.insert(d, i);
|
||
}
|
||
if ((tipodet == 1 || tipodet == 3 || tipodet == 9) && !is_rit)
|
||
{
|
||
if (PIM_PIS == PIS_ROW)
|
||
{
|
||
d->_r15 += tab->get_real("R0");
|
||
d->_r16 += tab->get_real("R1");
|
||
t15 += tab->get_real("R0");
|
||
t16 += tab->get_real("R1");
|
||
}
|
||
continue;
|
||
}
|
||
if (tipomov == acquisto)
|
||
{
|
||
// Ci sono anche le fatture in ritardo (solo in annuale)! Con tipo detraibilita' 1,3,9
|
||
if (sosp_imp != vol_affari)
|
||
{
|
||
d->_r4 += is_rit ? rit_imp : tab->get_real("R0");
|
||
d->_r5 += is_rit ? rit_iva : tab->get_real("R1");
|
||
t4 += is_rit ? rit_imp : tab->get_real("R0");
|
||
t5 += is_rit ? rit_iva : tab->get_real("R1");
|
||
}
|
||
// Totalizza anche quelli valevoli per vol. affari.
|
||
if (sosp_imp != liquidazione)
|
||
{
|
||
rt4 += is_rit ? rit_imp : tab->get_real("R0");
|
||
rt5 += is_rit ? rit_iva : tab->get_real("R1");
|
||
}
|
||
}
|
||
else // vendita
|
||
{
|
||
const bool is_key = corr_ann.is_key(codiva);
|
||
cx._totale = 0;
|
||
_CorrItem& ca = is_key ? (_CorrItem&) corr_ann[codiva] : cx;
|
||
if (sosp_imp != vol_affari)
|
||
ca._totale += tab->get_real(tipoiva == "VE" ? "R2" : "R3"); // Se e' codice IVA da Vent. stiamo scorrendo i PIS: va stampato il lordo dei progressivi successivi
|
||
if (sosp_imp != liquidazione)
|
||
ca._totale_vf += tab->get_real(tipoiva == "VE" ? "R2" : "R3");
|
||
if (!is_key) // se non c'e' lo aggiunge
|
||
{
|
||
ca._aliquota = _iva->get_real("R0")/CENTO; // Se e' nuovo setta l'aliquota
|
||
corr_ann.add(codiva,ca);
|
||
}
|
||
// vedi corrispettivi veri e falsi
|
||
real cvi = tab->get_real("R0"); // imp. totale
|
||
real cvv = tab->get_real("R1"); // iva totale
|
||
real cfi = tab->get_real("R13"); // imp. falsi corrispettivi
|
||
real cfv = tab->get_real("R14"); // iva falsi corrispettivi
|
||
// MI3404...
|
||
// Giochiamo sopra la particolarita' che se non e' un registro di corrispettivi
|
||
// allora se R5 o R6 sono <> 0 significa che trattasi di documento FS,
|
||
// che pertanto va stornato dal totale corrispettivi. (Cosi' volle Vladimiro)
|
||
const real ifs(tab->get_real("R5")); // imp. fatture con scontrino
|
||
const real vfs(tab->get_real("R6")); // iva fatture con scontrino
|
||
if (!corrisp)
|
||
{
|
||
if (sosp_imp != vol_affari)
|
||
{
|
||
d->_r2 -= ifs; // tolgo FS dai corrispettivi
|
||
d->_r3 -= vfs;
|
||
t2 -= ifs; // idem per i totali
|
||
t3 -= vfs;
|
||
}
|
||
if (sosp_imp != liquidazione)
|
||
{
|
||
rt2 -= ifs;
|
||
rt3 -= vfs;
|
||
}
|
||
}
|
||
|
||
if (corrisp)
|
||
{
|
||
cvi -= cfi;
|
||
cvv -= cfv;
|
||
}
|
||
|
||
if (corrisp)
|
||
{
|
||
// usa R0 e R1 visto che la ventilazione e' gia'
|
||
// stata calcolata
|
||
if (sosp_imp != vol_affari)
|
||
{
|
||
d->_r2 += (cvi /* - ifs */); // tolgo FS dai corrispettivi
|
||
d->_r3 += (cvv /* - vfs */);
|
||
d->_r0 += ifs; // aggiungo FS alle vendite
|
||
d->_r1 += vfs;
|
||
t2 += (cvi /* - ifs */); // idem per i totali
|
||
t3 += (cvv /* - vfs */); // non sono molto convinto ma vogliono cio'
|
||
t0 += ifs; // ...avevo ragione e infatti l'ho cambiato
|
||
t1 += vfs;
|
||
}
|
||
if (sosp_imp != liquidazione)
|
||
{
|
||
rt2 += cvi;
|
||
rt3 += cvv;
|
||
rt0 += ifs;
|
||
rt1 += vfs;
|
||
}
|
||
}
|
||
|
||
if (!corrisp || (!cfv.is_zero() || !cfi.is_zero()))
|
||
{
|
||
real adf, adi; // autofatture non residenti art. 17
|
||
real va7i, va7v; // ammontare art 40 c. 5/6/8
|
||
|
||
real vendi = corrisp ? cfi : tab->get_real("R0");
|
||
real vendv = corrisp ? cfv : tab->get_real("R1");
|
||
|
||
// si scorporano solo per l'annuale, altrimenti
|
||
// vengono normalmente considerati nelle vendite
|
||
if (month == 13)
|
||
{
|
||
TToken_string kr(tab->get("S0"),'!');
|
||
va7i = kr.get(0);
|
||
va7v = kr.get(1);
|
||
adf = tab->get_real("R7");
|
||
adi = tab->get_real("R8");
|
||
}
|
||
|
||
if (sosp_imp != vol_affari)
|
||
{
|
||
d->_r0 += vendi - adf - va7i;
|
||
d->_r1 += vendv - adi - va7v;
|
||
t0 += vendi /* - adf */;
|
||
t1 += vendv /* - adi */;
|
||
}
|
||
if (sosp_imp != liquidazione)
|
||
{
|
||
rt0 += vendi;
|
||
rt1 += vendv;
|
||
}
|
||
|
||
autodafe += adf;
|
||
art40 += va7i;
|
||
art40_iva += va7v;
|
||
}
|
||
}
|
||
if (!diffincimp.is_zero() || !diffinciva.is_zero() ||
|
||
!diffincimp_acq.is_zero() || !diffinciva_acq.is_zero())
|
||
{
|
||
const word id = describe_pis ? PIS_ROW_DI : PIM_ROW_DI;
|
||
d = NULL;
|
||
int j;
|
||
for (j = totpos + 1; j < _descr_arr.items(); j++)
|
||
{
|
||
_DescrItem& wd = (_DescrItem&)_descr_arr[j];
|
||
const bool found = wd._flags == id && wd._s0 == ref;
|
||
|
||
if (found && wd._s1 == codiva)
|
||
{
|
||
d = &wd;
|
||
break;
|
||
}
|
||
if (wd._flags == TOT_ROW_DI)
|
||
break;
|
||
if (found && wd._s1 > codiva)
|
||
break;
|
||
}
|
||
if (d == NULL)
|
||
{
|
||
const bool isfirst = headi == NULL;
|
||
if (isfirst)
|
||
{
|
||
headi = new _DescrItem(describe_pis ? PIS_HEAD_DI : PIM_HEAD_DI);
|
||
_descr_arr.insert(headi, j++);
|
||
headi->_f0 = false;
|
||
headi->_f1 = true;
|
||
headi->_f2 = atoi(activity.right(1)); // Tipo attivit<69> = 1 (servizi) o 2 (mista)
|
||
headi->_f3 = tipomov;
|
||
totdi = new _DescrItem(TOT_ROW_DI);
|
||
_descr_arr.insert(totdi, j);
|
||
}
|
||
d = new _DescrItem(id);
|
||
_descr_arr.insert(d, j);
|
||
d->_f0 = isfirst;
|
||
d->_s0 = ref;
|
||
d->_s1 = codiva;
|
||
}
|
||
d->_r28 += diffincimp;
|
||
d->_r29 += diffinciva;
|
||
t28 += diffincimp;
|
||
t29 += diffinciva;
|
||
d->_r32 += diffincimp_acq;
|
||
d->_r33 += diffinciva_acq;
|
||
t32 += diffincimp_acq;
|
||
t33 += diffinciva_acq;
|
||
}
|
||
|
||
}
|
||
} // End of _pim cycle
|
||
|
||
real impc,ivac; // Aggiunge lo scorporo dei corrispettivi
|
||
const int ditems = _descr_arr.items();
|
||
for (int i=last+1;i<ditems;i++) // scorre le righe memorizzate
|
||
{
|
||
_DescrItem& dd = (_DescrItem&) _descr_arr[i];
|
||
if (corr_ann.is_key(dd._s1) && dd._flags == PIM_PIS && dd._s0 == ref) // Se esiste il codice iva corrispondente sull'array corrispettivi
|
||
{
|
||
_CorrItem& cc = (_CorrItem &) corr_ann[dd._s1];
|
||
lordo2netto(cc._totale,impc,ivac,cc._aliquota);
|
||
dd._r2 += impc; // allora effettua lo scorporo e aggiorna i totali
|
||
dd._r3 += ivac;
|
||
t2 += impc;
|
||
t3 += ivac;
|
||
// Calcola lo scorporo per quelli comprensivi/validi per Vol.affari
|
||
lordo2netto(cc._totale_vf,impc,ivac,cc._aliquota);
|
||
rt2 += impc;
|
||
rt3 += ivac;
|
||
}
|
||
}
|
||
corr_ann.destroy();
|
||
look_plm(month,att);
|
||
const real iva74t = _pom->get_real("R13");
|
||
if (!describe_pis && iva74t > ZERO)
|
||
{
|
||
if(iads == NULL) iads = new _DescrItem(PIM_ROW);
|
||
iads->_s0 = "74TER"; // cosi' vollero
|
||
iads->_s1 = "IVA "; // cosi' vollero
|
||
iads->_s2 = " dovuta - 74 ter"; // cosi' vollero
|
||
iads->_r1 += iva74t;
|
||
t1 += iva74t;
|
||
rt1 += iva74t;
|
||
iads->_f0 = false;
|
||
}
|
||
} // fine while (codatt)
|
||
|
||
if (!describe_pis && (art40 > ZERO || art40_iva > ZERO))
|
||
{
|
||
_DescrItem* ads = new _DescrItem(PIM_ROW);
|
||
ads->_s0 = ref;
|
||
ads->_s1 = "VA7";
|
||
ads->_r0 = art40;
|
||
ads->_r1 = art40_iva;
|
||
ads->_f0 = false;
|
||
_descr_arr.insert(ads, totpos++);
|
||
}
|
||
|
||
if (!describe_pis && (autodafe > ZERO || autodafe_iva > ZERO))
|
||
{
|
||
_DescrItem* ads = new _DescrItem(PIM_ROW);
|
||
ads->_s0 = ref;
|
||
ads->_s1 = "AF"; // cos<6F> vollero, inoltre non <20> pi<70> A35 ma AF, come sul dio sistema
|
||
ads->_r0 = autodafe;
|
||
ads->_r1 = autodafe_iva;
|
||
ads->_f0 = false;
|
||
_descr_arr.insert(ads, totpos++);
|
||
}
|
||
|
||
// ag. viaggio: iva dovuta 74 ter la vogliono in mezzo ai progressivi
|
||
if (iads != NULL)
|
||
_descr_arr.insert(iads, totpos++);
|
||
|
||
|
||
// prepara una bella riga di totali
|
||
if (tot != NULL)
|
||
{
|
||
tot->_r0 = t0; tot->_r1 = t1;
|
||
tot->_r2 = t2; tot->_r3 = t3;
|
||
tot->_r4 = t4; tot->_r5 = t5;
|
||
tot->_r15 = t15; tot->_r16 = t16;
|
||
}
|
||
if (totd != NULL)
|
||
{
|
||
totd->_r26 = t26;
|
||
totd->_r27 = t27;
|
||
totd->_r30 = t30;
|
||
totd->_r31 = t31;
|
||
}
|
||
if (totdi != NULL)
|
||
{
|
||
totdi->_r28 = t28;
|
||
totdi->_r29 = t29;
|
||
totdi->_r32 = t32;
|
||
totdi->_r33 = t33;
|
||
totdi->_diff_ven_ap = _diff_ven_ap;
|
||
totdi->_diff_ven_ap_iva = _diff_ven_ap_iva;
|
||
totdi->_diff_acq_ap = _diff_acq_ap;
|
||
totdi->_diff_acq_ap_iva = _diff_acq_ap_iva;
|
||
}
|
||
// Totali progressivi da registri, comprensivi dei valori per calcolo vol affari.
|
||
if (tot != NULL && issosp) // Setta i valori (e la conseguente stampa della riga) solo se presenti registri in sospensione
|
||
{
|
||
tot->_r11 = rt0; tot->_r12 = rt1;
|
||
tot->_r13 = rt2; tot->_r14 = rt3;
|
||
tot->_s2 = rt4.string(); tot->_s3 = rt5.string();
|
||
}
|
||
|
||
// aggiunge dati ptm
|
||
_DescrItem* t = new _DescrItem(MISC_LIQ);
|
||
t->_f2 = describe_pis; //isfirst; // per il form feed o meno alla fine
|
||
|
||
if (!describe_pis)
|
||
{
|
||
TToken_string ttm("0|0|0");
|
||
|
||
const bool annual = month == 13;
|
||
const int limit = annual ? 13 : month;
|
||
int m = annual ? month : 1;
|
||
for (; m <= limit; m++)
|
||
{
|
||
if (!is_month_ok(m,month))
|
||
continue;
|
||
|
||
FOR_EACH_TOKEN (atts, tmpatt)
|
||
{
|
||
const TString8 att(tmpatt);
|
||
look_plm(m, att);
|
||
real ad1, ad2;
|
||
|
||
if (tot == NULL)
|
||
{
|
||
tot = new _DescrItem(TOT_ROW);
|
||
_descr_arr.insert(tot, -1);
|
||
}
|
||
|
||
tot->_r6 += _pom->get_real("R0"); // acq. intracomunitari
|
||
tot->_r7 += _pom->get_real("R1"); // inded. art 19
|
||
tot->_r8 += _pom->get_real("R2"); // IVA su inded. art. 19
|
||
t->_r0 += _pom->get_real("R3"); // acq. ammortizz. detr
|
||
t->_r1 += _pom->get_real("R4"); // IVA acq. ammort. detr
|
||
t->_r2 += _pum->get_real("R2"); // ammort. detr. 6%
|
||
t->_r3 += _pum->get_real("R3"); // IVA ammort detr. 6%
|
||
t->_r4 += _pom->get_real("R5"); // acq. beni rivendita
|
||
t->_r5 += _pom->get_real("R6"); // IVA acq. beni rivendita
|
||
t->_r6 += _pom->get_real("R7"); // acq. leasing
|
||
t->_r7 += _pom->get_real("R8"); // IVA acq. leasing
|
||
t->_r8 += _pum->get_real("R0"); // cessioni beni ammort.
|
||
t->_r9 += _pum->get_real("R1"); // IVA su cessioni ammort.
|
||
t->_r10 += _pum->get_real("R4"); // tot. esenti IVA
|
||
if (!annual) // Se non siamo in annuale prende il prorata su doc. acq. anno precedente
|
||
{
|
||
t->_r12 += _plm->get_real("R14");
|
||
t->_r13 = _plm->get_real("R4"); // percentuale prorata anno precedente
|
||
t->_r14 += _plm->get_real("R15");
|
||
t->_r15 = _plm->get_real("R16"); // percentuale prorata 2 anni addietro
|
||
}
|
||
|
||
// pro-rata indetraibile sui doc. acq. anno attuale
|
||
// in caso di liq. annuale prende il totale (tutto R2)
|
||
t->_r11 += _plm->get_real("R2");
|
||
t->_r11 -= _plm->get_real("R14") + _plm->get_real("R15");
|
||
|
||
ad1 = real(ttm.get(1));
|
||
ad2 = real(ttm.get(2));
|
||
ad1 += _pom->get_real("R11");
|
||
ad2 += _pom->get_real("R12");
|
||
ttm.add(_plm->get_real("R12"), 0); // % pro-rata anno corrente
|
||
ttm.add(ad1.string(),1); // imp. acq. amm. indetr.
|
||
ttm.add(ad2.string(),2); // IVA acq. amm. indetr
|
||
t->_s0 = ttm;
|
||
|
||
t->_f0 = _prorata.percentuale(_year)!=INVALID_PRORATA && (month != 13); // flag per segnalare l'esistenza
|
||
tot->_r9 += _pom->get_real("R9"); // acq. inded. su ricavi esenti
|
||
tot->_r10 += _pom->get_real("R10"); // IVA acq. inded. su ricavi esenti
|
||
|
||
// passaggi interni
|
||
real aipip(tot->_s0); // progressivo ...
|
||
real aipivp(tot->_s1); // ... (che mazzata sulle palle...)
|
||
aipip += _pum->get_real("R8"); // acq. inded. per pass. int
|
||
aipivp += _pum->get_real("R9"); // IVA acq. inded. per pass. int
|
||
tot->_s0 = aipip.string(); // risbatto ...
|
||
tot->_s1 = aipivp.string(); // ..
|
||
|
||
// spese generali.
|
||
real spgnp(t->_s2); // progressivo ...
|
||
real spgnvp(t->_s3); // ... (che doppia mazzata sulle palle...)
|
||
spgnp += _pam->get_real("R10"); // spese generali.
|
||
spgnvp += _pam->get_real("R11"); // IVA spese generali.
|
||
t->_s2 = spgnp.string(); // risbatto ...
|
||
t->_s3 = spgnvp.string(); // ..
|
||
|
||
// sospensione imposta: non piu' due palle, ma QUATTRO...
|
||
// caro Ferdinando... ora son divenute ben OTTO...
|
||
// grazie all'iva ad esigibilit<69> differita da pagare/de"TRARRE"
|
||
TToken_string tt(t->_s4);
|
||
real aqsi(tt.get(0));
|
||
real aqsv(tt.get(1));
|
||
real vnsi(tt.get(2));
|
||
real vnsv(tt.get(3));
|
||
real aqli(tt.get(4));
|
||
real aqlv(tt.get(5));
|
||
real vnli(tt.get(6));
|
||
real vnlv(tt.get(7));
|
||
|
||
aqsi += _pam->get_real("R6");
|
||
aqsv += _pam->get_real("R7");
|
||
vnsi += _pam->get_real("R8");
|
||
vnsv += _pam->get_real("R9");
|
||
aqli += _pam->get_real("R12");
|
||
aqlv += _pam->get_real("R13");
|
||
vnli += _pam->get_real("R14");
|
||
vnlv += _pam->get_real("R15");
|
||
|
||
tt = "";
|
||
tt.add(aqsi.string());
|
||
tt.add(aqsv.string());
|
||
tt.add(vnsi.string());
|
||
tt.add(vnsv.string());
|
||
tt.add(aqli.string());
|
||
tt.add(aqlv.string());
|
||
tt.add(vnli.string());
|
||
tt.add(vnlv.string());
|
||
t->_s4 = tt;
|
||
|
||
} // while (attivita')
|
||
} // for (mese ok)
|
||
|
||
// Cazzata orrenda ma necessaria CM500308
|
||
if (tot != NULL && issosp)
|
||
{
|
||
rt4 += tot->_r7; rt5 += tot->_r8; // Det 1
|
||
rt4 += tot->_r9; rt5 += tot->_r10; // Det 3
|
||
rt4 += real(tot->_s0); rt5 += real(tot->_s1); // Det 9
|
||
tot->_s2 = rt4.string(); tot->_s3 = rt5.string();
|
||
}
|
||
|
||
// annual follows in _arr
|
||
if (month == 13 && ref != "ALL")
|
||
{
|
||
// tutte quelle cose che vanno alla liquidazione annuale, come il
|
||
// calcolo del prorata o del nuovo plafond o ....
|
||
if (look_pla(codatt))
|
||
{
|
||
real v1 = _pla->get_real("R14"); // Volume d'affari I attivit<69>
|
||
real v2 = _pla->get_real("S1"); // Volume d'affari II attivit<69>
|
||
real ris = v1 + v2;
|
||
real e1 = _pla->get_real("R1"); // Totale vendite esenti B1
|
||
real e2 = _pla->get_real("R2"); // Totale vendite esenti B2
|
||
real e3 = _pla->get_real("R3"); // Totale vendite esenti B3
|
||
real e4 = _pla->get_real("R15"); // Totale vendite esenti B4
|
||
real e5 = _pla->get_real("R16"); // Totale vendite beni ammortizzabili esenti B3
|
||
real e6 = _pla->get_real("R17"); // Totale vendite beni ammortizzabili esenti B4
|
||
real bam = _pla->get_real("R4"); // Cessione beni ammortizzabili
|
||
real vrc = _pla->get_real("R18"); // Vendite reverse charge
|
||
real iaq = _pla->get_real("R11"); // IVA acquisti
|
||
real ppg = _pla->get_real("R12"); // pro-rata pagato
|
||
real num_amm = _pla->get_real("R21");
|
||
// calcola nuovo prorata per ogni attivita' (miste: 1+2)
|
||
real prorata;
|
||
real rsd;
|
||
real rsn;
|
||
|
||
if (_prorata_nd)
|
||
{
|
||
rsd = _pla->get_real("R20");
|
||
rsn = _pla->get_real("R19") + num_amm;
|
||
}
|
||
else
|
||
{
|
||
rsd = ris - (e3 - e5) - (e4 - e6) - vrc;
|
||
rsn = rsd - e1;
|
||
}
|
||
if (!rsd.is_zero())
|
||
prorata = CENTO - (rsn * CENTO / rsd); // Percentuale di indetraibilita: reciproco della percentuale di detraibilita'
|
||
prorata.round(0);
|
||
|
||
real co = 0.0;
|
||
real topay = 0.0;
|
||
|
||
// calcolo conguaglio -- se positivo e' a debito
|
||
const TRectype & lia = get_lia();
|
||
|
||
if (prorata > ZERO && lia.get_bool("B7"))
|
||
{
|
||
topay = (iaq + ppg) * prorata / CENTO;
|
||
round_imposta(topay);
|
||
}
|
||
else
|
||
prorata = ZERO;
|
||
co = topay - ppg;
|
||
round_imposta(co);
|
||
|
||
_DescrItem* dd = new _DescrItem(ANNUAL);
|
||
|
||
// MonsterFish: arrotonda all'Euro B1,B2,B3,B4
|
||
round_imposta(e1);
|
||
round_imposta(e2);
|
||
round_imposta(e3);
|
||
round_imposta(e4);
|
||
round_imposta(e5);
|
||
round_imposta(e6);
|
||
round_imposta(bam);
|
||
round_imposta(ris);
|
||
round_imposta(vrc);
|
||
round_imposta(num_amm);
|
||
|
||
// segna flag prorata
|
||
if (_prorata_nd)
|
||
{
|
||
if (rsn != rsd)
|
||
dd->_f0 |= IS_PRORATA;
|
||
}
|
||
else
|
||
if ((e1+e2+e3+e4) > ZERO)
|
||
{
|
||
dd->_f0 |= IS_PRORATA;
|
||
dd->_r18 = _pla->get_real("R18");
|
||
}
|
||
dd->_r0 = ris;
|
||
dd->_r1 = e1;
|
||
dd->_r2 = prorata;
|
||
dd->_r3 = co;
|
||
dd->_r4 = e2;
|
||
dd->_r5 = e3;
|
||
dd->_r6 = topay;
|
||
dd->_r7 = e4;
|
||
dd->_r8 = e5;
|
||
dd->_r9 = e6;
|
||
dd->_r10 = vrc;
|
||
dd->_ra0 = rsn;
|
||
dd->_ra1 = rsd;
|
||
dd->_ra2 = vrc;
|
||
dd->_ra3 = num_amm;
|
||
t->_arr.add(dd);
|
||
}
|
||
}
|
||
}
|
||
_descr_arr.add(t);
|
||
}
|
||
|
||
void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem* di)
|
||
{
|
||
if (!_isprint || !_canprint)
|
||
return;
|
||
|
||
const TRectype & lim = get_lim(month);
|
||
|
||
if (lim.not_empty())
|
||
{
|
||
_DescrItem* d = new _DescrItem(THE_END);
|
||
|
||
// gli diamo la stessa struttura di LIM
|
||
d->_r0 = lim.get_real("R0"); // Risultato
|
||
d->_r1 = lim.get_real("R1"); // Rimborso
|
||
d->_r2 = lim.get_real("R2");
|
||
d->_r3 = lim.get_real("R3");
|
||
d->_r4 = lim.get_real("R4");
|
||
d->_r5 = lim.get_real("R5"); // rettifiche
|
||
d->_r6 = lim.get_real("R6");
|
||
d->_r7 = lim.get_real("R14");
|
||
d->_r9 = lim.get_real("R9");
|
||
d->_r25 = lim.get_real("R25"); // credito per fatture in ritardo
|
||
d->_r29 = lim.get_real("R29"); // fdiffinc_iva_ven
|
||
d->_r33 = lim.get_real("R33"); // fdiffinc_iva_acq
|
||
|
||
look_lam(month);
|
||
|
||
TToken_string tt(80);
|
||
|
||
tt.add(_lam->get("R0")); // IVA Vendite
|
||
tt.add(_lam->get("R1")); // IVA Acquisti
|
||
tt.add(_lam->get("R2")); // Credito precedente
|
||
tt.add(_lam->get("R3")); // Debito precedente
|
||
tt.add(_lam->get("R4"));
|
||
d->_s0 = tt;
|
||
d->_ra5 = _lam->get_real("R5");
|
||
d->_ra6 = _lam->get_real("R6");
|
||
d->_ra7 = _lam->get_real("R7");
|
||
d->_ra8 = _lam->get_real("R8");
|
||
d->_s1 = lim.get("R11"); // Acc. dec.
|
||
d->_s2 = lim.get("R12");
|
||
d->_s3 = lim.get("R13");
|
||
|
||
// descrizione rettifiche
|
||
if (month < 13)
|
||
{
|
||
d->_s4 = lim.get("S0");
|
||
d->_s5 = lim.get("S1");
|
||
d->_s6 = lim.get("S2");
|
||
}
|
||
|
||
d->_r11 = lim.get_real("R10"); // tasso di interesse (Non arrotondare!)
|
||
d->_r15 = lim.get_real("R15"); // Credito utilizzato IVA
|
||
d->_r16 = lim.get_real("R16"); // Credito utilizzato F24
|
||
d->_r17 = lim.get_real("R17"); // Variazioni d'imposta
|
||
d->_r18 = lim.get_real("R18"); // Imposta non versata
|
||
d->_r19 = lim.get_real("R19"); // Crediti speciali
|
||
d->_r20 = lim.get_real("R20"); // Credito autorizzato in F24
|
||
d->_r25 = lim.get_real("R25"); // Credito da fatture in ritardo
|
||
|
||
d->_d1 = lim.get_date("D1"); // Data autorizzazione
|
||
|
||
d->_f1 = is_first_month(month);
|
||
|
||
// rispettiamo tutte le casistiche per i versamenti se non siamo in visualizzazione
|
||
// analogamente in Visualizzazione ma solo nel caso dell'annuale.
|
||
// In tutti gli altri casi va a cercare la delega
|
||
d->_r8 = (_month == 13 || !_is_visliq) ? lim.get_real("R8") : versamenti_IVA(_month, "1");
|
||
d->_r34 = (_month == 13 || !_is_visliq) ? lim.get_real("R34") : ZERO;
|
||
|
||
if (_month == 13)
|
||
{
|
||
const int anno = atoi(_year);
|
||
const TRectype & lia = get_lia(0L, false, anno);
|
||
// Credito utilizzato inizio anno (aggiunto 29-07-2014)
|
||
if (lia.not_empty())
|
||
d->_r15 = lia.get_real("R15");
|
||
|
||
const TRectype & liasucc = get_lia(0L, false, anno + 1);
|
||
|
||
if (liasucc.not_empty())
|
||
d->_r20 = liasucc.get_real("R0"); // Credito da riportare all'anno prossimo
|
||
}
|
||
|
||
// aggiunge eventuale satellite per rimborso infraannuale
|
||
if (di != NULL)
|
||
{
|
||
if (d->_r0.sign() < 0)
|
||
d->_arr.add(di);
|
||
else
|
||
delete di;
|
||
}
|
||
|
||
if (!_is_visliq)
|
||
{
|
||
_DescrItem* dv = describe_deleghe(month);
|
||
if (dv != NULL) d->_arr.add(dv);
|
||
}
|
||
|
||
_descr_arr.add(d);
|
||
}
|
||
}
|
||
|
||
_DescrItem* TLiquidazione_app::describe_deleghe(int month)
|
||
{
|
||
_stampa_vers = _stampa_acc = false;
|
||
|
||
const TRectype & lim = get_lim(month);
|
||
|
||
if (lim.get_real("R0") > ZERO)
|
||
{
|
||
real iva = lim.get_real("R0") + lim.get_real("R14");
|
||
if (month == 13)
|
||
round_imposta(iva);
|
||
if (iva >= iva_da_riportare(_month))
|
||
_stampa_vers = true;
|
||
}
|
||
|
||
_stampa_acc = (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4)))
|
||
||(month == 13 && _freqviva == "T" && !(_isbenzinaro && _gest4));
|
||
|
||
if (!_stampa_vers && !(_stampa_acc && look_del(12,7))) return NULL;
|
||
|
||
_DescrItem* d = new _DescrItem(DELEGA);
|
||
|
||
d->_f0 = 0;
|
||
|
||
//prospettino versamento
|
||
if (_stampa_vers) //solo se sono a debito
|
||
if (look_del(month,month == 13 ? 2 : 1))
|
||
{
|
||
if (_del->get_bool("B0")) // Stampata?
|
||
{
|
||
//_del->S2 descr. ufficio iva/concessione
|
||
//_del->S1 descrizione banca
|
||
d->_s0 = _del->get("S9"); // Cod Ufficio concessione
|
||
d->_s1 = _del->get("S7"); // Cod ABI
|
||
d->_s2 = _del->get("S8"); // Cod CAB
|
||
d->_r0 = _del->get_real("R0");
|
||
d->_d0 = _del->get_date("D0");
|
||
} // altrimenti lascia tutto in bianco e ci scriveranno i dati a mano
|
||
}
|
||
|
||
//prospettino acconto
|
||
if ( (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4)))
|
||
|| (month == 13 && _freqviva == "T" && !(_isbenzinaro && _gest4)) )
|
||
{
|
||
if (look_del(12,7)) //sia che sia a debito che a credito
|
||
{
|
||
d->_s4 = "ACC";
|
||
TToken_string t;
|
||
if (_del->get_bool("B0")) // Stampata?
|
||
{
|
||
//_del->S2 descr. ufficio iva/concessione
|
||
//_del->S1 descrizione banca
|
||
t.add(_del->get("S9")); // Cod Conc
|
||
t.add(_del->get("S7")); // Cod ABI
|
||
t.add(_del->get("S8")); // Cod CAB
|
||
t.add(_del->get_real("R0").string());
|
||
t.add(_del->get("D0"));
|
||
}
|
||
d->_s5 = t;
|
||
}
|
||
}
|
||
return d;
|
||
}
|
||
|
||
void TLiquidazione_app::describe_consistence(const char* codatt)
|
||
{
|
||
// controlla eventuali condizioni di conflitto con le normative
|
||
// per la ditta e crea i messaggi appropriati
|
||
// tutte le condizioni sono valutate sull'esercizio precedente
|
||
int pryear = atoi(_year) - 1;
|
||
TString att = codatt;
|
||
|
||
_pla->zero();
|
||
*_pla_ditta = get_firm();
|
||
*_pla_anno = pryear;
|
||
*_pla_codatt = att;
|
||
|
||
if (_pla->read() == NOERR)
|
||
{
|
||
real va = _pla->get_real("R0");
|
||
|
||
// 1) consistenza volume d'affari <-> frequenza versamenti
|
||
// deve essere: trimestrale ammesso solo se < 360.000.000
|
||
// per servizi, < 1.000.000.000 per altre imprese
|
||
// a meno che non sia benzinaro che ha diritto comunque
|
||
|
||
if (_freqviva == "T" && !_isbenzinaro)
|
||
{
|
||
bool err = false;
|
||
if (_isservizio) err = va > SOGLIA_TRIM_SERVIZI;
|
||
else err = va > SOGLIA_TRIM_ALTRE;
|
||
if (err)
|
||
describe_error(TR("Incoerenza volume affari/frequenza versamenti"),
|
||
att);
|
||
}
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::describe_error(const char* err, const char* codatt)
|
||
{
|
||
if (!_isprint || !_canprint || (_isregis && _isfinal))
|
||
return;
|
||
_errors.add(new _ErrItem(err, codatt, _nditte->curr().get(NDT_CODDITTA)));
|
||
}
|
||
|
||
// ----------------------------------------------------------------
|
||
// Setrows
|
||
// ----------------------------------------------------------------
|
||
|
||
void TLiquidazione_app::set_firm(_DescrItem& d)
|
||
{
|
||
TString tim_title(80);
|
||
tim_title << TR("Liquidazione IVA");
|
||
|
||
if (d._f1 == 13)
|
||
tim_title << format(FR(": Riepilogo Annuale %s"), (const char*)_year);
|
||
else
|
||
{
|
||
if (d._s2 == "T")
|
||
tim_title << format(FR(" del %d<> Trimestre %s"), (d._f1 - 1) / 3 + 1, (const char*) _year);
|
||
else
|
||
if (_is_liq_acconto)
|
||
tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year);
|
||
else
|
||
tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year);
|
||
}
|
||
|
||
reset_header();
|
||
int soh = 1;
|
||
if (!_isregis)
|
||
{
|
||
set_header(soh++,FR("Ditta %s %s@107gData @>@125gPag. @#"),
|
||
(const char*)d._s0, (const char*)d._s1);
|
||
set_header(soh++,"");
|
||
}
|
||
set_header(soh++,sep);
|
||
set_header(soh++,FR("%s@102gFrequenza %s"),
|
||
(const char*)tim_title, d._s2 == "T" ? TR("Trimestrale") : TR("Mensile"));
|
||
set_header(soh++,sep);
|
||
set_header(soh++,"");
|
||
|
||
// notify errors if any
|
||
int j = 0;
|
||
int i = 0;
|
||
for (i = 0; i < _errors.items(); i++)
|
||
{
|
||
_ErrItem& s = (_ErrItem&)_errors[i];
|
||
if (s._att == "ALL" && s._firm == d._s0)
|
||
{ j++; set_row(i+3, "@5g@b*** %s ***@r", (const char*)s._err); }
|
||
}
|
||
if (j) set_row(i+3,"");
|
||
}
|
||
|
||
static int _tipo_attivita_corrente = 0;
|
||
|
||
void TLiquidazione_app::set_att(_DescrItem& d)
|
||
{
|
||
// set header
|
||
TString tim_title(78);
|
||
TString att_title(48);
|
||
|
||
// Bookmark
|
||
TString book_name(d._s3);
|
||
const char flags = (char)d._f3;
|
||
|
||
if (flags == '1') book_name << TR(" (servizi)");
|
||
else if (flags == '2') book_name << TR(" (altre)");
|
||
else if (flags == 'M') book_name = TR("Riepilogo att. mista");
|
||
else if (flags == 'Q') book_name = TR("Riepilogo quater");
|
||
|
||
if (_firm_bookmark == -1)
|
||
_firm_bookmark = set_bookmark(d._s1);
|
||
_att_bookmark = set_bookmark(book_name, _firm_bookmark);
|
||
|
||
tim_title << TR("Liquidazione IVA");
|
||
|
||
if (d._f1 == 13)
|
||
{
|
||
tim_title << format(FR(": Riepilogo Annuale %s"),(const char*)_year);
|
||
}
|
||
else
|
||
{
|
||
if (d._s4 == "T")
|
||
tim_title << format(FR(" del %d<> Trimestre %s"), (d._f1 - 1) / 3 + 1, (const char*)_year);
|
||
else
|
||
if (_is_liq_acconto)
|
||
tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year);
|
||
else
|
||
tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year);
|
||
}
|
||
|
||
const char* tipatt = "";
|
||
if (d._f0 > 0)
|
||
tipatt = d._f0 == 1 ? TR("SERVIZI") : TR("ALTRE ATTIVITA'");
|
||
|
||
if (d._s3.empty())
|
||
{
|
||
att_title = flags == 'M' ? TR("Riepilogo attivit<69> mista") : TR("Riepilogo quater");
|
||
// att_title << d._s2;
|
||
}
|
||
else
|
||
att_title = format(FR("Attivit<EFBFBD> %s %s %s"), (const char*)(d._s2), (const char*)(d._s3), tipatt);
|
||
|
||
reset_header();
|
||
int soh = 1;
|
||
if (!_isregis)
|
||
{
|
||
set_header(soh++,FR("Ditta %s %s@107gData @>@125gPag. @#"),
|
||
(const char*)(d._s0), (const char*)(d._s1));
|
||
set_header(soh++,"");
|
||
}
|
||
set_header(soh++,sep);
|
||
set_header(soh++,"%s@55g%s", (const char*)tim_title, (const char*)att_title);
|
||
set_header(soh++,sep);
|
||
set_header(soh++,"");
|
||
|
||
// notify errors if any
|
||
int j = 0;
|
||
for (int i = 0; i < _errors.items(); i++)
|
||
{
|
||
_ErrItem& s = (_ErrItem&)_errors[i];
|
||
if (d._s2 == s._att && s._firm == d._s0)
|
||
{ j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); }
|
||
}
|
||
if (j)
|
||
set_auto_ff(true);
|
||
}
|
||
|
||
void TLiquidazione_app::set_plafond(_DescrItem& d)
|
||
{
|
||
// In caso di stampa liquidazione da stampa registri, il prospetto plafond
|
||
// complessivo va evidenziato in testa; solo nel caso di trimestrali.
|
||
|
||
if (_isregis && _freqviva == "M") return;
|
||
|
||
set_bookmark(TR("Quadro plafond"), _att_bookmark);
|
||
|
||
real r1 = d._r1 + d._r0;
|
||
real r2 = d._r4 + d._r3;
|
||
real r3 = d._r7 + d._r6;
|
||
|
||
real disponibile = d._r2 + d._r5 + d._r8;
|
||
real riporto = disponibile - r1 - r2 -r3;
|
||
|
||
set_print_zero(true);
|
||
|
||
set_row(1,TR("QUADRO RELATIVO ALLA DISPONIBILITA' ED ALL'UTILIZZO MENSILE DEI PLAFONDS"));
|
||
|
||
set_row(2,"");
|
||
set_row(3,FR("@31gDisponibile@48g%r"), &(disponibile));
|
||
set_row(4,TR("Art. 8 1<> comma lettere a-b"));
|
||
set_row(5,FR("Utilizzato all'interno@48g%r"), &(d._r0));
|
||
set_row(6,FR("Utilizzato per l'importazione@48g%r"),&(d._r1));
|
||
|
||
set_row(7,"");
|
||
set_row(8,TR("Art. 8bis 1<> comma"));
|
||
set_row(9,FR("Utilizzato all'interno@48g%r"), &(d._r3));
|
||
set_row(10,FR("Utilizzato per l'importazione@48g%r"), &(d._r4));
|
||
|
||
set_row(11,"");
|
||
set_row(12,TR("Art. 9 1<> comma"));
|
||
set_row(13,FR("Utilizzato all'interno@48g%r"), &(d._r6));
|
||
set_row(14,FR("Utilizzato per l'importazione@48g%r"), &(d._r7) );
|
||
set_row(15,FR("@31gRiporto@48g%r"), &(riporto));
|
||
|
||
set_print_zero(false);
|
||
set_auto_ff();
|
||
}
|
||
|
||
int TLiquidazione_app::print_acc_diff_xcassa(const _DescrItem& d)
|
||
{
|
||
int i = 9;
|
||
|
||
const real& totiva = d._r0;
|
||
const real ivadiff_inc = d._r29;
|
||
const real ivadiff_pag = d._r33;
|
||
|
||
real ivaxcas_inc, ivaxcas_pag;
|
||
|
||
if (has_module(ICAUT))
|
||
{
|
||
// Calcolare qui la quota per cassa e toglierla a quella differita gloable
|
||
}
|
||
|
||
if (!_isdiffacc)
|
||
{
|
||
set_row(i++,FR("@11gIva esigibile fino al 20/12@81g%r"), &totiva);
|
||
|
||
if (ivadiff_inc > ZERO)
|
||
set_row(i++,FR("@11gIVA a liquidazione differita incassata fino al 20/12@75g%r"), &ivadiff_inc);
|
||
if (ivadiff_pag > ZERO)
|
||
set_row(i++,FR("@11gIVA a liquidazione differita pagata fino al 20/12@64g%r"), &ivadiff_pag);
|
||
|
||
if (ivaxcas_inc > ZERO)
|
||
set_row(i++,FR("@11gIVA per cassa incassata fino al 20/12@75g%r"), &ivaxcas_inc);
|
||
if (ivaxcas_pag > ZERO)
|
||
set_row(i++,FR("@11gIVA per cassa pagata fino al 20/12@64g%r"), &ivaxcas_pag);
|
||
}
|
||
else
|
||
{
|
||
set_row(i++,FR("@11gIva sulle operazioni di vendita@81g%r"), &totiva);
|
||
|
||
if (ivadiff_inc > ZERO)
|
||
set_row(i++,FR("@11gIVA a liquidazione differita incassata@75g%r"), &ivadiff_inc);
|
||
if (ivadiff_pag > ZERO)
|
||
set_row(i++,FR("@11gIVA a liquidazione differita pagata@64g%r"), &ivadiff_pag);
|
||
|
||
if (ivadiff_inc > ZERO)
|
||
set_row(i++,FR("@11gIVA per cassa incassata@75g%r"), &ivaxcas_inc);
|
||
if (ivadiff_pag > ZERO)
|
||
set_row(i++,FR("@11gIVA per cassa pagata@64g%r"), &ivaxcas_pag);
|
||
}
|
||
return i;
|
||
}
|
||
|
||
void TLiquidazione_app::set_liqacc_2000(_DescrItem& d)
|
||
{
|
||
set_row(1,""); set_row(2,""); set_row(3,""); set_row(4,"");
|
||
set_row(5,FR("@11gCALCOLO ACCONTO SU OPERAZIONI EFFETTUATE"));
|
||
if (!_isdiffacc)
|
||
set_row(5,TR(" FINO AL 20 DICEMBRE"));
|
||
|
||
set_row(6,"");
|
||
set_row(7,FR("@72gCredito@90gDebito")); set_row(8,"");
|
||
|
||
if (d._r3 > ZERO)
|
||
d._r0 += d._r3; // Aggiungi rettifiche a debito
|
||
|
||
int i = print_acc_diff_xcassa(d);
|
||
|
||
if (!_isdiffacc)
|
||
{
|
||
set_row(i++,FR("@11gIva esigibile fino al 20/12 di cui non fatturata@81g%r"), &d._r1);
|
||
set_row(i++,FR("@11gIva esigibile fino al 20/12 di cui non annotata@81g%r"), &d._r2);
|
||
}
|
||
if (d._r3 < ZERO)
|
||
d._r5 -= d._r3; // Aggiungi rettifiche a credito
|
||
if (!_isdiffacc)
|
||
set_row(i++,FR("@11gIva che si detrae fino al 20/12@64g%r"), &d._r5);
|
||
else
|
||
set_row(i++,FR("@11gIva sulle operazioni di acquisto@64g%r"), &d._r5);
|
||
|
||
set_row(i,FR("@11gIVA a debito/credito per il periodo"));
|
||
real iva_dov_cre = d._r0 + d._r1 + d._r2 - d._r5;
|
||
if (iva_dov_cre >= ZERO)
|
||
set_row(i++,"@81g%r", &iva_dov_cre);
|
||
else
|
||
{
|
||
const real tmp = -iva_dov_cre;
|
||
set_row(i++,"@64g%r", &tmp);
|
||
}
|
||
|
||
set_row(i++, FR("@11gDebito/Credito da periodo precedente@64g%r"), &d._r9);
|
||
|
||
set_row(i,FR("@11gIVA Dovuta o a Credito"));
|
||
const real risultato = iva_dov_cre - d._r9;
|
||
if (risultato >= ZERO)
|
||
set_row(i++,"@81g%r", &risultato);
|
||
else
|
||
{
|
||
const real tmp = -risultato;
|
||
set_row(i++,"@64g%r", &tmp);
|
||
}
|
||
|
||
// Acconto
|
||
if (d._r8 < ZERO)
|
||
{
|
||
const real ab = abs(d._r8);
|
||
set_row(i++,FR("@23gCREDITO DA EVIDENZIARE@64g%r"), &ab);
|
||
}
|
||
else if (d._r8 > ZERO)
|
||
{
|
||
const real acconto_minimo = _ver->get(I_ACCONTOIVA);
|
||
if (d._r8 > acconto_minimo)
|
||
set_row(i++,FR("@23gACCONTO DA VERSARE@81g%r"), &d._r8);
|
||
else
|
||
set_row(i++,FR("@23gACCONTO DA NON VERSARE@81g%r"), &d._r8);
|
||
}
|
||
|
||
set_auto_ff();
|
||
}
|
||
|
||
void TLiquidazione_app::set_pim_head(_DescrItem& d)
|
||
{
|
||
int r = 1;
|
||
|
||
if (d._flags == PIM_HEAD)
|
||
set_bookmark(TR("Riepilogo progressivi"), _att_bookmark);
|
||
else
|
||
{
|
||
set_row(r++,"");
|
||
if (d._flags == PIM_HEAD_D)
|
||
{
|
||
TString msg;
|
||
msg = TR("Movimenti registrati nel periodo a liquidazione differita");
|
||
const TDate data(1, _month <= 12 ? _month : 12 , atoi(_year));
|
||
if (gestione_IVAxCassa(data))
|
||
msg << TR(" o per cassa");
|
||
set_row(r++, msg);
|
||
set_bookmark(TR("Riepilogo progressivi a liquidazione differita"), _att_bookmark);
|
||
// print_dainc_diff_log(r, d._f2, d._f3); // 15-03-2013 obosleto in quanto stampato su registri?
|
||
}
|
||
else
|
||
if (d._flags == PIM_HEAD_DI)
|
||
{
|
||
TString msg;
|
||
msg = TR("Incassi/pagamenti a liquidazione differita");
|
||
|
||
const TDate data(1, _month <= 12 ? _month : 12 , atoi(_year));
|
||
if (gestione_IVAxCassa(data))
|
||
msg << TR(" o per cassa");
|
||
|
||
set_row(r++, msg);
|
||
set_bookmark(TR("Riepilogo progressivi a liquidazione differita incassati"), _att_bookmark);
|
||
// print_inc_diff_log(r, d._f2, d._f3);
|
||
}
|
||
else // PIS_HEAD
|
||
{
|
||
if (d._flags == PIS_HEAD)
|
||
{
|
||
set_row(r++,TR(" Di cui da periodo successivo"));
|
||
set_row(r++,"");
|
||
set_bookmark(TR("Riepilogo progressivi successivi"), _att_bookmark);
|
||
}
|
||
else
|
||
if (d._flags == PIS_HEAD_D)
|
||
{
|
||
set_row(r++, TR("Fatture a liquidazione differita da incassare"));
|
||
set_bookmark(TR("Riepilogo progressivi successivi a liquidazione differita"), _att_bookmark);
|
||
}
|
||
else
|
||
if (d._flags == PIS_HEAD_DI)
|
||
{
|
||
set_row(r++, TR("Fatture a liquidazione differita incassate"));
|
||
set_bookmark(TR("Riepilogo progressivi successivi a liquidazione differita incassati"), _att_bookmark);
|
||
}
|
||
}
|
||
set_row(r++,"");
|
||
}
|
||
if (d._f0)
|
||
{
|
||
if (d._flags == PIM_HEAD || d._flags == PIS_HEAD)
|
||
{
|
||
set_row(r++,FR(" Cod.@41gVENDITE@71gCORRISPETTIVI"));
|
||
set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta"));
|
||
set_row(r,"");
|
||
}
|
||
/* else
|
||
{
|
||
set_row(r++,FR(" Cod.@41gVENDITE"));
|
||
set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta"));
|
||
} */
|
||
}
|
||
else
|
||
{
|
||
if (d._flags == PIM_HEAD)
|
||
{
|
||
set_row(r++, FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI"));
|
||
set_row(r++, FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta@96gImponibile@115gImposta"));
|
||
set_row(r, "");
|
||
}
|
||
else
|
||
{
|
||
if (d._flags == PIS_HEAD)
|
||
{
|
||
set_row(r++, FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI"));
|
||
set_row(r++, FR(" @99gACQUISTI INDETRAIBILI"));
|
||
set_row(r++, FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta@96gImponibile@115gImposta"));
|
||
// set_row(r++, FR(" @96gImponibile@115gImposta"));
|
||
set_row(r, "");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::set_pim(_DescrItem& d)
|
||
{
|
||
// succede con le autocazzate non residenti non movimentate eccetera
|
||
const bool a = (d._r0 + d._r1) == ZERO;
|
||
const bool b = (d._r2 + d._r3) == ZERO;
|
||
const bool c = (d._r4 + d._r5) == ZERO;
|
||
const bool e = (d._r26 + d._r27) == ZERO;
|
||
const bool f = (d._r28 + d._r29) == ZERO;
|
||
const bool g = (d._r30 + d._r31) == ZERO;
|
||
const bool h = (d._r32 + d._r33) == ZERO;
|
||
|
||
if (a && b && c && e && f && g && h)
|
||
return;
|
||
|
||
int rw = 1;
|
||
if (d._s1 == "AF") //Il dio sistema colpisce ancora, non va bene A35, ma AF...
|
||
d._s2 = TR("Artt.17c3/74c1"); // La descrizione non la metto uguale perche' cosi e' piu' fika
|
||
else if (d._s1 == "VA7") // Sempre per merito del dio sistema ho dovuto aggiungere VA7.
|
||
d._s2 = TR("Art.40c5/6/8 a.i.");
|
||
else if (d._s0 == "74TER")
|
||
rw++;
|
||
else
|
||
{
|
||
look_iva(d._s1);
|
||
d._s2 = _iva->get("S0");
|
||
if (d._s2.len() > 19) d._s2.cut(19);
|
||
}
|
||
|
||
if (d._flags == PIM_ROW)
|
||
{
|
||
set_row(rw++, "%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2,
|
||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5));
|
||
}
|
||
else
|
||
if (d._flags == PIS_ROW)
|
||
{
|
||
set_row(rw++, "%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2,
|
||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5));
|
||
if (d._r15 != ZERO)
|
||
set_row(rw++, "@91g%r@107g%r", &(d._r15), &(d._r16));
|
||
}
|
||
else
|
||
if (d._flags == PIM_ROW_D || d._flags == PIS_ROW_D)
|
||
{
|
||
set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r",
|
||
(const char*)d._s1, (const char*)d._s2,
|
||
&(d._r26), &(d._r27), &(d._r30), &(d._r31));
|
||
}
|
||
else
|
||
if (d._flags == PIM_ROW_DI || d._flags == PIS_ROW_DI)
|
||
{
|
||
set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r",
|
||
(const char*)d._s1, (const char*)d._s2,
|
||
&(d._r28), &(d._r29), &(d._r32), &(d._r33));
|
||
}
|
||
|
||
}
|
||
|
||
void TLiquidazione_app::set_plm_diff(const _DescrItem& d)
|
||
{
|
||
int rw = 1;
|
||
|
||
set_row(rw++,""); set_row(rw++,"");
|
||
if (d._flags == TOT_ROW_D)
|
||
{
|
||
set_row(rw++, FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r26), &(d._r27), &(d._r30), &(d._r31));
|
||
}
|
||
else
|
||
{
|
||
// Totale incassi/pagamenti ad IVA differita o per cassa
|
||
set_row(rw++,FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r28), &(d._r29), &(d._r32), &(d._r33));
|
||
if (_isannual)
|
||
{
|
||
rw++;
|
||
set_row(rw++,FR("Totale anni prec. @25g%r@41g%r@91g%r@107g%r"), &(d._diff_ven_ap), &(d._diff_ven_ap_iva), &(d._diff_acq_ap), &(d._diff_acq_ap_iva));
|
||
}
|
||
}
|
||
set_row(rw++,"");
|
||
}
|
||
|
||
void TLiquidazione_app::set_plm(_DescrItem& d)
|
||
{
|
||
int rw = 1;
|
||
if (!(d._r0.is_zero() && d._r1.is_zero() && d._r2.is_zero() &&
|
||
d._r3.is_zero() && d._r4.is_zero() && d._r5.is_zero()))
|
||
{
|
||
set_row(rw++,""); set_row(rw++,"");
|
||
set_row(rw++,FR("Totale@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5));
|
||
if(d._r15 != ZERO)
|
||
set_row(rw++, FR("@91g%r@107g%r"), &(d._r15), &(d._r16));
|
||
set_row(rw++,"");
|
||
}
|
||
if (!(d._r7.is_zero() && d._r8.is_zero()))
|
||
{
|
||
set_row(rw++,FR("Totale acquisti indeducibili per art.19@91g%r@107g%r"),
|
||
&(d._r7), &(d._r8));
|
||
}
|
||
if (! (d._r9.is_zero() && d._r10.is_zero()))
|
||
{
|
||
set_row(rw++, FR("Totale acquisti indeducibili su ricavi esenti@91g%r@107g%r"),
|
||
&(d._r9), &(d._r10));
|
||
}
|
||
|
||
real acq_pint(d._s0);
|
||
real acq_pint_iva(d._s1);
|
||
|
||
if (! (acq_pint.is_zero() && acq_pint_iva.is_zero()))
|
||
{
|
||
set_row(rw++, FR("Totale acquisti indeducibili per passaggi interni@91g%r@107g%r"),
|
||
&acq_pint,
|
||
&acq_pint_iva);
|
||
}
|
||
|
||
real tot1 = d._r7 + d._r4 + d._r9 + acq_pint;
|
||
real tot2 = d._r8 + d._r5 + d._r10 + acq_pint_iva;
|
||
|
||
if (tot1 != d._r4 || tot2 != d._r5)
|
||
{
|
||
// i corrispettivi finiscono nelle vendite
|
||
d._r0 += d._r2;
|
||
d._r1 += d._r3;
|
||
d._r2 = ZERO;
|
||
d._r3 = ZERO;
|
||
// per ora lascio r2 e r3 anche se sono sempre 0
|
||
set_row(rw++, "");
|
||
set_row(rw++,FR("Totale Generale IVA@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &tot1, &tot2);
|
||
}
|
||
|
||
// Stampa il totale progressivo da registri, comprensivo dei movimenti valevoli per il calcolo vol. affari.
|
||
real pr_imp(d._s2);
|
||
real pr_iva(d._s3);
|
||
if (!(d._r11.is_zero() && d._r12.is_zero() && d._r13.is_zero() &&
|
||
d._r14.is_zero() && pr_imp.is_zero() && pr_iva.is_zero()))
|
||
{
|
||
set_row(rw++,""); set_row(rw++,"");
|
||
set_row(rw++,FR("Totale Prog. da registri@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||
&(d._r11), &(d._r12), &(d._r13), &(d._r14), &(pr_imp), &(pr_iva));
|
||
set_row(rw++,"");
|
||
}
|
||
}
|
||
|
||
|
||
void TLiquidazione_app::set_pumpam(const _DescrItem& d)
|
||
{
|
||
bool printed = false;
|
||
|
||
// d._f1 dice se c'era qualcosa sopra nella stessa pagina
|
||
real spgn(d._s2);
|
||
real spgn_iva(d._s3);
|
||
|
||
TToken_string tt(d._s4); // Token String
|
||
TToken_string dp(d._s0); // Due Palle
|
||
real aqsi(tt.get(0));
|
||
real aqsv(tt.get(1));
|
||
real vnsi(tt.get(2));
|
||
real vnsv(tt.get(3));
|
||
real aqli(tt.get(4));
|
||
real aqlv(tt.get(5));
|
||
real vnli(tt.get(6));
|
||
real vnlv(tt.get(7));
|
||
real ammindi(dp.get(1));
|
||
real ammindv(dp.get(2));
|
||
|
||
int row = 5;
|
||
|
||
if (!(aqsi.is_zero() && aqsv.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Acquisti in sospensione di imposta@50g%r@69g%r"),
|
||
&aqsi,
|
||
&aqsv);
|
||
}
|
||
if (!(vnsi.is_zero() && vnsv.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Vendite in sospensione di imposta@50g%r@69g%r"),
|
||
&vnsi,
|
||
&vnsv);
|
||
}
|
||
if (!(aqli.is_zero() && aqlv.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("IVA ad esigibilit<69> differ. da detrarre nel periodo@50g%r@69g%r"),
|
||
&aqli,
|
||
&aqlv);
|
||
}
|
||
if (!(vnli.is_zero() && vnlv.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("IVA ad esigibilit<69> differ. da pagare nel periodo@50g%r@69g%r"),
|
||
&vnli,
|
||
&vnlv);
|
||
}
|
||
if (!(d._r8.is_zero() && d._r9.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Cessione beni ammortizzabili@50g%r@69g%r"),
|
||
&(d._r8),
|
||
&(d._r9));
|
||
}
|
||
if (! (d._r4.is_zero() && d._r5.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Acquisto beni destinati alla rivendita@50g%r@69g%r"),
|
||
&(d._r4),
|
||
&(d._r5));
|
||
}
|
||
if (! (ammindi.is_zero() && ammindv.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r"),
|
||
&ammindi,
|
||
&ammindv);
|
||
}
|
||
if (! (d._r0.is_zero() && d._r1.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r"),
|
||
&(d._r0),
|
||
&(d._r1));
|
||
}
|
||
if (!(d._r6.is_zero() && d._r7.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Altri beni strumentali acquisiti in leasing@50g%r@69g%r"),
|
||
&(d._r6),
|
||
&(d._r7));
|
||
}
|
||
if (!(d._r2.is_zero() && d._r3.is_zero()))
|
||
{
|
||
printed = true;
|
||
// real rn = d._r2 * real(DETRAZIONE_6PERCENTO); // Detrazione obsoleta CM500344
|
||
set_row(row++, FR("Acquisto beni soggetti a detrazione (6%%)"
|
||
"@50g%r@69g%r"), &(d._r2), &(d._r3));
|
||
}
|
||
if (!(spgn.is_zero() && spgn_iva.is_zero()))
|
||
{
|
||
printed = true;
|
||
set_row(row++, FR("Spese generali@50g%r@69g%r"),
|
||
&spgn,
|
||
&spgn_iva);
|
||
}
|
||
// Prorata...
|
||
int yy = atoi(_year);
|
||
if (d._f0)
|
||
{
|
||
printed = true;
|
||
|
||
real prc(dp.get(0));
|
||
real rprc = CENTO - prc;
|
||
TString ss(rprc.string());
|
||
|
||
if (d._r11 != ZERO)
|
||
set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"),
|
||
(const char*)ss, (const char*)prc.string(), &(d._r11));
|
||
else
|
||
set_row(row++, FR("%% PRO-RATA (%s%%)"), (const char*)ss);
|
||
yy-=2;
|
||
if (d._r13 != INVALID_PRORATA)
|
||
{
|
||
rprc = CENTO - d._r13;
|
||
ss = rprc.string();
|
||
if (d._r12 != ZERO)
|
||
set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), yy, (const char*)ss, (const char*)d._r13.string(), &(d._r12));
|
||
else
|
||
set_row(row++, FR("%% PRO-RATA %d (%s%%)"), yy, (const char*)ss);
|
||
}
|
||
else
|
||
if (!_isfinal && d._r13 == INVALID_PRORATA_ASSERT)
|
||
set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy);
|
||
|
||
yy--;
|
||
if (d._r15 != INVALID_PRORATA)
|
||
{
|
||
rprc = CENTO - d._r15;
|
||
ss = rprc.string();
|
||
if (d._r14 != ZERO)
|
||
set_row(row++, FR("%% PRO-RATA %d (%s%%) ed IVA non detraibile (%s%%)@69g%r"), yy, (const char*) ss, (const char*)d._r15.string(), &(d._r14));
|
||
else
|
||
set_row(row++, FR("%% PRO-RATA %d (%s%%)"), yy, (const char*)ss);
|
||
}
|
||
else
|
||
if (!_isfinal && d._r15 == INVALID_PRORATA_ASSERT)
|
||
set_row(row++, FR("Impossibile reperire la %% PRO-RATA relativa all'anno %d."), yy);
|
||
}
|
||
|
||
// items vari per dichiarazione annuale
|
||
for (int i = 0; i < d._arr.items(); i++)
|
||
{
|
||
_DescrItem& dd = (_DescrItem&)d._arr[i];
|
||
printed |= set_annual(dd);
|
||
}
|
||
|
||
if (printed)
|
||
{
|
||
set_bookmark(TR("Altri dati"), _att_bookmark);
|
||
|
||
set_row(1,"");
|
||
set_row(2,"");
|
||
set_row(3,FR("ALTRI DATI RELATIVI ALLA DICHIARAZIONE@55gimponibile"
|
||
"@77gimposta@91gdetrazione"));
|
||
set_row(4,"");
|
||
set_row(row++,"");
|
||
set_row(row,"");
|
||
}
|
||
else
|
||
set_row(1,"");
|
||
|
||
// form feed
|
||
if (d._f2)
|
||
set_auto_ff(true);
|
||
}
|
||
|
||
/*
|
||
void TLiquidazione_app::set_grand_1999(_DescrItem& d, int& rw)
|
||
{
|
||
real& risultato = d._r0;
|
||
real& rimborso = d._r1;
|
||
real& cred_cost = d._r2;
|
||
real& deb_mens = d._r3;
|
||
real& rettifiche = d._r5;
|
||
real& detrazioni = d._r6;
|
||
real& interessi = d._r7;
|
||
real& versamenti = d._r8;
|
||
real& vers_int = d._r9;
|
||
real& conguaglio = d._r10;
|
||
TToken_string tt(d._s0);
|
||
real iva_vend(tt.get(0));
|
||
real iva_acq(tt.get(1));
|
||
real cred_prec(tt.get(2));
|
||
real debt_prec(tt.get(3));
|
||
real cred_trasf(tt.get(4)); cred_trasf = -cred_trasf;
|
||
|
||
real acc_dec(d._s1);
|
||
real res_cred(d._s2);
|
||
real res_debt(d._s3);
|
||
real rett_debt(0.0);
|
||
real rett_cred(0.0);
|
||
real& interesse = d._r11;
|
||
|
||
if (rettifiche.sign() > 0) rett_debt = rettifiche;
|
||
if (rettifiche.sign() < 0) rett_cred = -rettifiche;
|
||
|
||
set_row(rw++,FR(" @66gCredito@84gDebito")); set_row(rw++,"");
|
||
set_row(rw++,FR("@11gIva sulle operazioni di vendita@75g%r"), &iva_vend);
|
||
set_row(rw++,FR("%s@11gRettifiche IVA a debito%s@75g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rett_debt);
|
||
set_row(rw++,FR("%s@11gIva chiesta a rimborso%s@75g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso);
|
||
|
||
// conguaglio prorata
|
||
if (conguaglio.sign() > 0)
|
||
set_row(rw++,FR("@11gConguaglio pro-rata@75g%r"), &conguaglio);
|
||
|
||
// debito liq. precedente < 50000
|
||
if (debt_prec > ZERO)
|
||
set_row(rw++,FR("@11gDebito da liquidazione precedente@75g%r"), &debt_prec);
|
||
|
||
set_row(rw++,FR("@11gRISULTATO@75g%r"), &res_debt);
|
||
set_row(rw++,FR("@11gIva ammessa in detrazione@58g%r"), &iva_acq);
|
||
if (_isannual || d._f1)
|
||
{
|
||
set_row(rw++,FR("@11gCredito inizio anno@58g%r"), &cred_prec);
|
||
if (cred_trasf != ZERO)
|
||
set_row(rw++,FR("@11gCredito trasferito @58g%r"), &cred_trasf);
|
||
}
|
||
else
|
||
set_row(rw++,FR("@11gCredito precedente@58g%r"), &cred_prec);
|
||
|
||
if (!acc_dec.is_zero())
|
||
set_row(rw++,FR("%s@11gVersamento acconto dicembre%s@58g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &acc_dec);
|
||
|
||
if (!detrazioni.is_zero())
|
||
set_row(rw++,FR("@11gUlteriori detrazioni@58g%r"), &detrazioni);
|
||
|
||
set_row(rw++,FR("%s@11gRettifiche IVA a credito%s@58g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rett_cred);
|
||
|
||
// versamenti effettuati
|
||
if (!versamenti.is_zero() && (_month==13 || !_is_visliq))
|
||
{
|
||
set_row(rw++,FR("@11gVersamenti effettuati@58g%r"), &versamenti);
|
||
}
|
||
// versamenti integrativi
|
||
if (!vers_int.is_zero() && !_is_visliq)
|
||
{
|
||
set_row(rw++,FR("@11gVersamenti integrativi@58g%r"), &vers_int);
|
||
}
|
||
if (conguaglio.sign() < 0)
|
||
{
|
||
real cg = conguaglio;
|
||
cg = -cg;
|
||
set_row(rw++,FR("@11gConguaglio pro-rata@58g%r"), &cg);
|
||
}
|
||
|
||
set_row(rw++,FR("@11gRISULTATO@58g%r"), &res_cred);
|
||
|
||
// se non c'e' nulla da versare stampa solo una riga vuota
|
||
// Serve, non toglierla, stronzo.
|
||
if (risultato.is_zero())
|
||
set_row(rw++,"");
|
||
else
|
||
{
|
||
if (risultato.sign() < 0)
|
||
{
|
||
real iva = abs(risultato);
|
||
if (_isannual || _isriepilogo)
|
||
round_imposta(iva);
|
||
set_row(rw++,FR("@23gCREDITO ATTUALE@58g%r"),&iva);
|
||
if (_is_visliq)
|
||
{ // se chiamata dalla visualizzazione mette 2 righe vuote se non vi sono interessi
|
||
// poiche' con le rettifiche a credito/debito posso volerle visualizzare
|
||
set_row(rw++,"");
|
||
set_row(rw++,"");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (_month == 13)
|
||
round_imposta(interessi);
|
||
real iva = risultato + interessi;
|
||
if (_isannual || _isriepilogo)
|
||
round_imposta(iva);
|
||
if (!iva.is_zero())
|
||
{
|
||
if (!interessi.is_zero())
|
||
{
|
||
set_row(rw++,FR("@23gIVA DOVUTA@75g%r"),&risultato);
|
||
set_row(rw++,FR("@23gInteresse @33g%6.2r @41g%%@75g%r"),&interesse, &interessi);
|
||
}
|
||
else
|
||
if (_is_visliq)
|
||
{ // vedi sopra...
|
||
set_row(rw++,"");
|
||
set_row(rw++,"");
|
||
}
|
||
if (iva >= iva_da_riportare(_month))
|
||
set_row(rw++,FR("@23gIVA DA VERSARE@75g%r"),&iva);
|
||
else
|
||
set_row(rw++,FR("@23gIVA A DEBITO DA NON VERSARE@75g%r"),&iva);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (_is_visliq && _month != 13)
|
||
{
|
||
// stampa versamenti (anche 0) ad uso visualizzazione liquidazione IVA
|
||
rw++;
|
||
set_row(rw++,FR("@11g$[r]Versamenti effettuati$[n]@58g%r"), &versamenti);
|
||
set_row(rw++, "");
|
||
set_row(rw++, "");
|
||
}
|
||
|
||
if (!_is_visliq)
|
||
{
|
||
// descrizione rettifiche
|
||
if (d._s4.not_empty() || d._s5.not_empty())
|
||
{
|
||
rw++;
|
||
set_row(rw++, FR("@11g@bDESCRIZIONE RETTIFICHE@r"));
|
||
rw++;
|
||
if (d._s4.not_empty()) { set_row(rw++, "@11g%t", &(d._s4)); }
|
||
if (d._s5.not_empty()) { set_row(rw++, "@11g%t", &(d._s5)); }
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
void TLiquidazione_app::print_importo(int rw, const char* prompt, real imp, bool red)
|
||
{
|
||
int tab = 75;
|
||
if (imp < ZERO)
|
||
{ imp = -imp; tab = 58; }
|
||
TString256 str;
|
||
str << "@11g";
|
||
if (red) str << "$[r]";
|
||
str << prompt;
|
||
if (red) str << "$[n]";
|
||
str << '@' << tab << "g%r";
|
||
set_row(rw, str, &imp);
|
||
}
|
||
|
||
// d._flags == THE_END
|
||
void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
|
||
{
|
||
const real risultato = d._r0; // Figuccia lo poteva cambiare, ora tornato const :-)
|
||
const real& rimborso = d._r1;
|
||
const real& cred_cost = d._r2;
|
||
const real& deb_mens = d._r3;
|
||
const real& rettifiche = d._r5;
|
||
const real& detrazioni = d._r6;
|
||
const real& interessi = d._r7;
|
||
const real& versamenti = d._r8;
|
||
const real& versamenti_interessi = d._r34;
|
||
const real& vers_int = d._r9;
|
||
|
||
real diffinc_iva = d._ra5;
|
||
real diffinc_iva_acq = d._ra7;
|
||
real xcasinc_iva = d._ra6;
|
||
real xcasinc_iva_acq = d._ra8;
|
||
|
||
real perc_prorata;
|
||
|
||
if (_month == 13)
|
||
perc_prorata = _perc_ind_annual;
|
||
else
|
||
{
|
||
TString query = "USE PLM";
|
||
query << "\nFROM CODTAB=" << _year << "\nTO CODTAB=" << _year;
|
||
TISAM_recordset ip(query);
|
||
const TRectype& recp = ip.cursor()->curr();
|
||
|
||
for (bool ok = ip.move_first(); ok && perc_prorata == ZERO; ok = ip.move_next())
|
||
{
|
||
int m = atoi(ip.get("CODTAB").as_string().mid(10));
|
||
real p = ip.get("R12").as_real();
|
||
if (m == _month && (p > ZERO && p <= CENTO))
|
||
perc_prorata = p;
|
||
}
|
||
}
|
||
|
||
if (perc_prorata > ZERO)
|
||
{
|
||
if (diffinc_iva_acq != ZERO)
|
||
{
|
||
real ind = diffinc_iva_acq * perc_prorata / CENTO;
|
||
ind.round(TCurrency::get_firm_dec());
|
||
diffinc_iva_acq -= ind;
|
||
}
|
||
if (xcasinc_iva_acq != ZERO)
|
||
{
|
||
real ind = xcasinc_iva_acq * perc_prorata / CENTO;
|
||
ind.round(TCurrency::get_firm_dec());
|
||
xcasinc_iva_acq -= ind;
|
||
}
|
||
}
|
||
|
||
TToken_string tt(d._s0);
|
||
real iva_vend(tt.get(0));
|
||
real iva_acq(tt.get(1));
|
||
real cred_prec(tt.get(2));
|
||
real debt_prec(tt.get(3));
|
||
real cred_trasf(tt.get(4)); cred_trasf = -cred_trasf;
|
||
|
||
real acc_dec(d._s1);
|
||
real corr_acc;
|
||
|
||
if (_is_liq_acconto)
|
||
{
|
||
corr_acc = acc_dec;
|
||
acc_dec = ZERO;
|
||
}
|
||
real res_cred(d._s2);
|
||
real res_debt(d._s3);
|
||
real rett_debt(0.0);
|
||
real rett_cred(0.0);
|
||
real& interesse = d._r11;
|
||
|
||
real& credito_utilizzato_IVA = d._r15;
|
||
real& credito_utilizzato_F24 = d._r16;
|
||
real& variazioni_imposta = d._r17;
|
||
real& imposta_non_versata = d._r18;
|
||
real& crediti_speciali = d._r19;
|
||
real& credito_autorizzato_F24 = d._r20;
|
||
real& cred_fattrit = d._r25;
|
||
const TDate &data_autorizzazione = d._d1;
|
||
|
||
if (credito_autorizzato_F24 < ZERO) credito_autorizzato_F24 = ZERO;
|
||
if (rettifiche > ZERO) rett_debt = rettifiche;
|
||
if (rettifiche < ZERO) rett_cred =-rettifiche;
|
||
|
||
const TRectype & lia = get_lia();
|
||
const bool credito_compensabile = lia.get("S9") == "CM";
|
||
|
||
|
||
set_row(rw++,FR(" @66gCredito@84gDebito")); set_row(rw++,"");
|
||
|
||
// Se sono in visualizzazione stampo i due importi separati, altrimenti li sommo
|
||
if (!_is_visliq)
|
||
iva_vend += rett_debt;
|
||
set_row(rw++, FR("@11g@bIVA esigibile@r per il periodo@75g%r"), &iva_vend);
|
||
if (!diffinc_iva.is_zero())
|
||
set_row(rw++,FR("@11g a liquidazione differita@75g%r"), &diffinc_iva);
|
||
if (!xcasinc_iva.is_zero())
|
||
set_row(rw++,FR("@11g per cassa@75g%r"), &xcasinc_iva);
|
||
if (_is_visliq)
|
||
set_row(rw++,FR("@11g$[r]Rettifiche IVA a debito$[n]@75g%r"), &rett_debt); // Rettifiche modificabili
|
||
|
||
// Se sono in visualizzazione stampo i due importi separati, altrimenti li sommo
|
||
if (!_is_visliq)
|
||
iva_acq += rett_cred;
|
||
iva_acq -= cred_fattrit;
|
||
set_row(rw++, FR("@11g@bIVA detraibile@r per il periodo@58g%r"), &iva_acq);
|
||
if (!diffinc_iva_acq.is_zero())
|
||
set_row(rw++,FR("@11g a liquidazione differita@58g%r"), &diffinc_iva_acq);
|
||
if (!xcasinc_iva_acq.is_zero())
|
||
set_row(rw++,FR("@11g per cassa@58g%r"), &xcasinc_iva_acq);
|
||
if (_is_visliq)
|
||
set_row(rw++,FR("@11g$[r]Rettifiche IVA a credito$[n]@58g%r"), &rett_cred);
|
||
|
||
real iva_deb_cred = iva_vend - iva_acq + diffinc_iva - diffinc_iva_acq + xcasinc_iva - xcasinc_iva_acq;
|
||
if (_is_visliq)
|
||
iva_deb_cred += rett_debt - rett_cred;
|
||
|
||
print_importo(rw++, TR("IVA a debito o a credito per il periodo"), iva_deb_cred);
|
||
|
||
rw++;
|
||
print_importo(rw++, TR("Variazioni d'imposta"), variazioni_imposta, _is_visliq);
|
||
print_importo(rw++, TR("Imposta non versata"), imposta_non_versata, _is_visliq);
|
||
|
||
real cre_deb_per;
|
||
|
||
if (debt_prec > ZERO)
|
||
{
|
||
set_row(rw++,FR("@11gDebito da liquidazione precedente@75g%r"), &debt_prec);
|
||
set_row(rw++,FR("%s@11gRimborsi%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso);
|
||
}
|
||
else
|
||
{
|
||
cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int;
|
||
if (cred_prec > ZERO)
|
||
set_row(rw++,FR("@11gCredito da liquidazione precedente@58g%r"), &cred_prec);
|
||
if (cred_fattrit > ZERO)
|
||
set_row(rw++,FR("@11gCredito da fatture in ritardo@58g%r"), &cred_fattrit);
|
||
|
||
if (_month < 13 && credito_compensabile && credito_autorizzato_F24 > ZERO)
|
||
{
|
||
cred_prec -= credito_autorizzato_F24;
|
||
// cre_deb_per += credito_autorizzato_F24;
|
||
set_row(rw++,FR("%s@11gCredito IVA autorizzato in F24%s@75g%r@100gil %s"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &credito_autorizzato_F24, (const char *) data_autorizzazione);
|
||
}
|
||
cred_prec -= rimborso;
|
||
set_row(rw++,FR("%s@11gRimborsi%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso);
|
||
if (cred_prec > ZERO)
|
||
set_row(rw++,FR("@11gCredito utilizzabile@58g%r"), &cred_prec);
|
||
if (_month < 13)
|
||
set_row(rw++, FR("@11gCredito IVA compensabile detratto@75g%r"), &credito_utilizzato_IVA);
|
||
}
|
||
|
||
if (_month == 13) cre_deb_per += versamenti;
|
||
|
||
print_importo(rw++, TR("IVA dovuta o a credito per il periodo"), cre_deb_per + corr_acc);
|
||
|
||
if (crediti_speciali != ZERO || _is_visliq)
|
||
set_row(rw++,FR("%s@11gCrediti speciali%s@58g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &crediti_speciali);
|
||
|
||
if (_freqviva == "T" && !interessi.is_zero())
|
||
set_row(rw++,FR("@11gInteressi dovuti per liquidazioni trimestrali %6.2r%%@75g%r"),&interesse, &interessi);
|
||
else
|
||
if (_is_visliq) rw++;
|
||
if (!acc_dec.is_zero())
|
||
set_row(rw++,FR("%s@11gAcconto versato%s@58g%r"),
|
||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &acc_dec);
|
||
else
|
||
if (_is_visliq) rw++;
|
||
// versamenti effettuati
|
||
if (!versamenti.is_zero() && (_month == 13 || !_is_visliq))
|
||
set_row(rw++, FR("@11gVersamenti effettuati@58g%r"), &versamenti);
|
||
else
|
||
if (_is_visliq) rw++;
|
||
// versamenti integrativi
|
||
if (!vers_int.is_zero() && !_is_visliq)
|
||
set_row(rw++,FR("@11gVersamenti integrativi@58g%r"), &vers_int);
|
||
else
|
||
if (_is_visliq) rw++;
|
||
|
||
const real tot_vers = acc_dec + versamenti + vers_int;
|
||
if (!tot_vers.is_zero() && (_month == 13 || !_is_visliq))
|
||
set_row(rw++, FR("@11gTotale versamenti effettuati@58g%r"), &tot_vers);
|
||
else
|
||
if (_is_visliq) rw++;
|
||
|
||
const real iva = risultato + interessi + corr_acc;
|
||
if (_month == 13 && credito_compensabile)
|
||
{
|
||
real credito_utilizzabile = lia.get_real("R0");
|
||
|
||
credito_utilizzabile -= lia.get_real("R15");
|
||
credito_utilizzabile -= credito_utilizzato(13);
|
||
credito_utilizzabile += credito_autorizzato(13);
|
||
if (credito_utilizzabile < ZERO)
|
||
credito_utilizzabile = ZERO;
|
||
set_row(rw++,FR("@11gCredito compensabile attuale@58g%r"), &credito_utilizzabile);
|
||
}
|
||
if (iva > ZERO)
|
||
{
|
||
if (iva >= iva_da_riportare(_month))
|
||
set_row(rw++,FR("@23gIMPORTO DA VERSARE@75g%r"),&iva);
|
||
else
|
||
set_row(rw++,FR("@23gIMPORTO DA NON VERSARE@75g%r"),&iva);
|
||
}
|
||
else
|
||
{
|
||
if (_month == 12)
|
||
print_importo(rw++, TR("IMPORTO A CREDITO"), iva);
|
||
else
|
||
if (_isannual && d._r20 > ZERO)
|
||
print_importo(rw++, TR("CREDITO RIPORTATO NELL'ANNO SUCCESSIVO"), -d._r20);
|
||
if (_is_visliq)
|
||
rw++;
|
||
}
|
||
|
||
if (_is_visliq && _month != 13)
|
||
{
|
||
rw++;
|
||
set_row(rw++,FR("@11g$[r]Descrizione$[n]"));
|
||
|
||
// stampa versamenti (anche 0) ad uso visualizzazione liquidazione IVA
|
||
rw++;
|
||
set_row(rw++,FR("@11g$[r]Versamenti effettuati$[n]@58g%r"), &versamenti);
|
||
set_row(rw++, "");
|
||
set_row(rw++, "");
|
||
}
|
||
else
|
||
if (_month == 13 && !versamenti_interessi.is_zero())
|
||
set_row(rw++, FR("@11gVersamenti effettuati interessi @58g%r"), &versamenti_interessi);
|
||
|
||
if (!_is_visliq)
|
||
{
|
||
// descrizione rettifiche
|
||
if (d._s6.not_empty())
|
||
{
|
||
rw++;
|
||
set_row(rw++, FR("@11g@bDESCRIZIONE RETTIFICHE@r"));
|
||
rw++;
|
||
if (d._s6.not_empty()) { set_row(rw++, "@11g%t", &(d._s6)); }
|
||
}
|
||
}
|
||
if (credito_compensabile)
|
||
{
|
||
real credito_utilizzabile = lia.get_real("R0");
|
||
|
||
rw++;
|
||
credito_utilizzabile -= lia.get_real("R15");
|
||
if (_month < 13)
|
||
{
|
||
credito_utilizzabile -= credito_utilizzato(_month);
|
||
credito_utilizzabile += credito_autorizzato(_month);
|
||
if (credito_utilizzabile < ZERO)
|
||
credito_utilizzabile = ZERO;
|
||
|
||
set_row(rw++, FR("@11g@bPROSPETTO COMPENSAZIONI@r"));
|
||
rw++;
|
||
set_row(rw++,FR("@11gCredito compensabile da liquidazione precedente@58g%r"), &credito_utilizzabile);
|
||
if (credito_autorizzato_F24 > ZERO)
|
||
{
|
||
credito_utilizzabile += credito_autorizzato_F24;
|
||
set_row(rw++,FR("%s@11gCredito IVA autorizzato in F24%s@58g%r@100gil %s"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &credito_autorizzato_F24, (const char *) data_autorizzazione);
|
||
}
|
||
set_row(rw++, FR("@11gCredito IVA compensabile detratto@75g%r"), &credito_utilizzato_IVA);
|
||
credito_utilizzabile -= credito_utilizzato_IVA;
|
||
set_row(rw++, FR("%s@11gCredito IVA compensabile detratto in F24%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &credito_utilizzato_F24);
|
||
credito_utilizzabile -= credito_utilizzato_F24;
|
||
set_row(rw++,FR("@11gCredito compensabile attuale@58g%r"), &credito_utilizzabile);
|
||
if (credito_utilizzabile > ZERO && cre_deb_per < ZERO)
|
||
{
|
||
const real cred = credito_utilizzabile - cre_deb_per;
|
||
|
||
set_row(rw++, FR("@11gCredito complessivo@58g%r"), &cred);
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
const real credito_utilizzato_annuale_IVA = TLiquidazione_app::credito_utilizzato_IVA(13);
|
||
const real credito_utilizzato_annuale_F24 = TLiquidazione_app::credito_utilizzato_F24(13);
|
||
const real credito_autorizzato_annuale_F24 = credito_autorizzato(13);
|
||
|
||
set_row(rw++, FR("@11g@bPROSPETTO COMPENSAZIONI@r"));
|
||
rw++;
|
||
set_row(rw++,FR("@11gCredito compensabile da liquidazione precedente@58g%r"), &credito_utilizzabile);
|
||
credito_utilizzabile += credito_autorizzato_annuale_F24;
|
||
set_row(rw++,FR("@11gCredito IVA autorizzato in F24@58g%r"), &credito_autorizzato_annuale_F24);
|
||
set_row(rw++, FR("@11gCredito IVA compensabile detratto@75g%r"), &credito_utilizzato_annuale_IVA);
|
||
credito_utilizzabile -= credito_utilizzato_annuale_IVA;
|
||
set_row(rw++, FR("@11gCredito IVA compensabile detratto in F24@75g%r"), &credito_utilizzato_annuale_F24);
|
||
credito_utilizzabile -= credito_utilizzato_annuale_F24;
|
||
if (credito_utilizzabile < ZERO)
|
||
credito_utilizzabile = ZERO;
|
||
set_row(rw++,FR("@11gCredito compensabile attuale@58g%r"), &credito_utilizzabile);
|
||
}
|
||
}
|
||
}
|
||
|
||
static void imp2string(const real& n, TString& str)
|
||
{
|
||
if (!n.is_zero())
|
||
{
|
||
const TCurrency c(n);
|
||
str = c.string(true);
|
||
str.right_just(15);
|
||
}
|
||
else
|
||
str.spaces(15);
|
||
}
|
||
|
||
void TLiquidazione_app::set_iva_succ(int& rw)
|
||
{
|
||
TString query;
|
||
const TDate da_datareg(1, 1, atoi(_year));
|
||
const TDate a_datareg(31, 12, atoi(_year));
|
||
|
||
// query << "USE IVADIFF KEY 2 SELECT BETWEEN(DATAREG,#DAL,#AL)";
|
||
query << "USE IVADIFF KEY 4";
|
||
if (!_end_cassa)
|
||
query << "\nFROM DATAREG=" << da_datareg;
|
||
|
||
query << "\nTO DATAREG=" << a_datareg;
|
||
TISAM_recordset id(query);
|
||
/* const TDate da_datareg(1, 1, atoi(_year));
|
||
const TDate a_datareg(31, 12, atoi(_year));
|
||
|
||
id.set_var("DAL", _end_cassa ? botime : da_datareg);
|
||
id.set_var("AL", a_datareg); */
|
||
|
||
TImporto ven_diff, ven_xcas, acq_xcas, acq_diff;
|
||
TString8 codiva;
|
||
TString8 tipo_aliquota;
|
||
TToken_string key;
|
||
TImporto tot_iva;
|
||
|
||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||
{
|
||
const int tipodiff = id.get(ID_TIPODIFF).as_int();
|
||
const int tipoiva = id.get(ID_TIPOIVA).as_int();
|
||
const char sezione = id.get(ID_SEZIONE).as_string()[0];
|
||
const TImporto imp(sezione, id.get(RMI_IMPONIBILE).as_real());
|
||
|
||
key = id.get(ID_NUMREG).as_string();
|
||
key.add(id.get(ID_NUMRIG).as_string());
|
||
codiva = cache().get(LF_RMOVIVA, key, RMI_CODIVA);
|
||
key = codiva;
|
||
tipo_aliquota = cache().get("%IVA", key, "S1");
|
||
|
||
if (tipo_aliquota.blank())
|
||
{
|
||
const TDate datapag = id.get(ID_DATAREGP).as_date();
|
||
|
||
if (datapag <= a_datareg)
|
||
{
|
||
if (tipoiva == 1) // Vendite
|
||
{
|
||
if (tipodiff == 1)
|
||
ven_diff += imp;
|
||
else
|
||
ven_xcas += imp;
|
||
}
|
||
else
|
||
{
|
||
if (tipodiff == 1)
|
||
acq_diff += imp;
|
||
else
|
||
acq_xcas += imp;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!ven_diff.is_zero() || !ven_xcas.is_zero() || !acq_xcas.is_zero())
|
||
{
|
||
ven_diff.normalize('D');
|
||
ven_xcas.normalize('D');
|
||
acq_xcas.normalize('A');
|
||
acq_diff.normalize('A');
|
||
if (_end_cassa)
|
||
set_row(rw++, FR("@11g@bOPERAZIONI EFFETTUATE FINO ALL'ANNO CON IMPOSTA ESIGIBILE NEGLI ANNI SUCCESSIVI@r"));
|
||
else
|
||
set_row(rw++, FR("@11g@bOPERAZIONI EFFETTUATE NELL'ANNO CON IMPOSTA ESIGIBILE NEGLI ANNI SUCCESSIVI@r"));
|
||
const real vd = ven_diff.valore();
|
||
const real vc = ven_xcas.valore();
|
||
const real vt = vc+vd;
|
||
const real ac = acq_xcas.valore();
|
||
const real ad = acq_diff.valore();
|
||
const real at = ac+ad;
|
||
|
||
set_row(rw++, "Totale vendite con IVA esigibile negli anni successivi@66g%r", &vt);
|
||
set_row(rw++, "Di cui con IVA per cassa@66g%r", &vc);
|
||
set_row(rw++, "Totale acquisti con IVA detraibile negli anni successivi@66g%r", &at);
|
||
set_row(rw++, "Di cui con IVA per cassa@66g%r", &at);
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::set_grand(_DescrItem& d)
|
||
{
|
||
int rw = 1;
|
||
|
||
if (_isannual) // Stampa annuale evidenzia importi esigibili l'anno dopo
|
||
set_iva_succ(rw);
|
||
|
||
set_bookmark(TR("Riepilogativo liquidazione"), _firm_bookmark);
|
||
set_row(rw++,""); set_row(rw++,""); set_row(rw++,""); set_row(rw++,"");
|
||
set_row(rw++,FR("@11g@bCALCOLO LIQUIDAZIONE D'IMPOSTA@r"));
|
||
|
||
/*
|
||
const bool new_print = atoi(_year) >= 2000;
|
||
if (new_print)
|
||
set_grand_2000(d, rw);
|
||
else
|
||
set_grand_1999(d, rw);
|
||
*/
|
||
set_grand_2000(d, rw);
|
||
|
||
|
||
// rapportini per rimborso infraannuale
|
||
// non si stampano se la stampa serve per la visualizz.
|
||
// solo in st.di prova in coda ai registri deve scendere
|
||
// il prospetto di rimborso
|
||
// sempre (cioe' in bollato e in prova) deve scendere
|
||
// il prospettino versamento
|
||
if (d._arr.items() > 0 && !_is_visliq)
|
||
{
|
||
for (int i = 0; i < d._arr.items(); i++)
|
||
{
|
||
const _DescrItem& di = (_DescrItem&)d._arr[i];
|
||
|
||
if (di._flags == RIMBORSO)
|
||
{
|
||
if (!_isregis || (_isregis && !_isfinal))
|
||
{
|
||
set_print_zero(true);
|
||
set_row(rw++,"");
|
||
set_row(rw++,"");
|
||
|
||
set_bookmark(TR("Prospetto di rimborso"), _firm_bookmark);
|
||
|
||
set_row(rw++, TR(" PROSPETTO DI RIMBORSO"));
|
||
|
||
if (di._f0)
|
||
{
|
||
// esenti e non imponibili
|
||
set_row(rw++,"");
|
||
set_row(rw++,TR("1) Soggetto con quota di operazioni esenti e non imponibili superiore al 25%%"));
|
||
|
||
real perc = di._r0 * CENTO / di._r1; perc.round(0);
|
||
|
||
TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
|
||
set_row(rw++,"");
|
||
set_row(rw++,FR("@26gTotale operazioni esenti e non imp.@66g%r"),
|
||
&(di._r0));
|
||
set_row(rw++,FR("@66g%t x 100 = %3r%%"), &sep, &perc);
|
||
set_row(rw++,FR("@26gVolume di affari lordo@66g%r"), &(di._r1));
|
||
set_row(rw++,"");
|
||
}
|
||
|
||
if (di._f1)
|
||
{
|
||
set_row(rw++,"");
|
||
set_row(rw++,TR("2) Soggetto con acquisti ad aliquota media superiore a quella delle vendite"));
|
||
TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
|
||
set_row(rw++,"");
|
||
set_row(rw++,FR("@26gTotale imposte sugli acquisti@66g%r"), &(di._r5));
|
||
set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r7));
|
||
set_row(rw++,FR("@26gTotale imponibili sugli acquisti@66g%r"),
|
||
&(di._r3));
|
||
set_row(rw++,"");
|
||
set_row(rw++,FR("@26gTotale imposte sulle vendite@66g%r"), &(di._r4));
|
||
set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r6));
|
||
set_row(rw++,FR("@26gTotale imponibili sulle vendite@66g%r"), &(di._r2));
|
||
}
|
||
|
||
set_print_zero(false);
|
||
}
|
||
}
|
||
// prospettino versamento
|
||
else if (di._flags == DELEGA)
|
||
{
|
||
const bool acconto = di._s4 == "ACC";
|
||
int rr = rw;
|
||
int cont = 10;
|
||
if (acconto)
|
||
{
|
||
TToken_string ac(di._s5);
|
||
if (!ac.empty_items() && _stampa_vers)
|
||
cont = 14;
|
||
}
|
||
if (rw < (printer().formlen() - cont))
|
||
rw = printer().formlen() - cont;
|
||
|
||
for (int i = rr; i < rw; i++)
|
||
set_row(i,"");
|
||
|
||
set_bookmark(TR("Riepilogo versamenti"), _firm_bookmark);
|
||
|
||
if (acconto) // Acconto
|
||
{
|
||
TToken_string ac(di._s5);
|
||
if (!ac.empty_items())
|
||
{
|
||
TString16 dt (ac.get(4));
|
||
real app (ac.get(3));
|
||
TString16 vr; imp2string(app, vr);
|
||
TString4 con (ac.get(0));
|
||
TString8 abi (ac.get(1));
|
||
TString8 cab (ac.get(2));
|
||
|
||
set_row(rw++, TR("- ACCONTO DICEMBRE -"));
|
||
set_row(rw, FR(" Versamento di %s effettuato il %s"),
|
||
(const char*)vr,
|
||
(const char*)dt);
|
||
set_row(rw++, FR("@68gCod Conc.: %3s"),(const char*)con);
|
||
set_row(rw++, FR("@68gCod. ABI: %5s Cod. CAB o Cod. Dipendenza: %5s"),(const char*)abi,(const char*)cab);
|
||
}
|
||
}
|
||
|
||
if (_stampa_acc && _stampa_vers)
|
||
set_row(rw++, "- SALDO -");
|
||
|
||
if (_stampa_vers)
|
||
{
|
||
TString16 dt = di._d0.string();
|
||
TString16 vr; imp2string(di._r0, vr);
|
||
set_row(rw, FR(" Versamento di %s effettuato il %s"),
|
||
(const char*)vr, (const char*)dt);
|
||
set_row(rw++, FR("@68gCod Conc.: %3s"),(const char*)di._s0);
|
||
set_row(rw++, FR("@68gCod. ABI: %5s Cod. CAB o Cod. Dipendenza: %5s"),(const char*)di._s1,(const char*)di._s2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!_is_visliq) set_auto_ff(true);
|
||
else set_auto_ff(false);
|
||
|
||
_firm_bookmark = -1;
|
||
}
|
||
|
||
|
||
bool TLiquidazione_app::set_annual(_DescrItem& d)
|
||
{
|
||
// chiamata internamente a set_pims
|
||
bool ret = false;
|
||
|
||
int row = get_maxrow()+1;
|
||
if (row == 1) row = 4;
|
||
|
||
// if ((d._r2 > ZERO) && (d._f0 & IS_PRORATA))
|
||
if (d._f0 & IS_PRORATA)
|
||
{
|
||
// non lo ha stampato prima se annuale, perche' Vladimiro il nefido pretende l'assurdo aggiornamento della perc. a quella nuova
|
||
const int year_int = atoi(_year);
|
||
|
||
row++;
|
||
set_row(++row, TR("CALCOLO DELLA PERCENTUALE DI DETRAIBILITA'"));
|
||
row++;
|
||
|
||
set_bookmark(TR("Calcolo pro-rata"), _att_bookmark);
|
||
|
||
ret = true;
|
||
set_print_zero(true);
|
||
set_row(row++,"");
|
||
|
||
const real perc_det = CENTO - d._r2;
|
||
_perc_ind_annual = d._r2;
|
||
real vol_aff = d._r0;
|
||
const real rev_charge = d._r18;
|
||
const TString16 s1 = perc_det.stringa();
|
||
const TString16 s2 = d._r2.stringa();
|
||
if (d._r6 > ZERO)
|
||
set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), (const char*)s1, (const char*)s2, &(d._r6));
|
||
else
|
||
set_row(row++, FR("%% PRO-RATA (%s%%)"), (const char*)s1);
|
||
set_row(row++, FR("Detraibilit<EFBFBD> @69g%r%%"), &perc_det);
|
||
row++;
|
||
if (_prorata_nd)
|
||
{
|
||
set_row(row++, FR(" - Numeratore pro-rata @69g%r"), &d._ra0);
|
||
set_row(row++, FR(" - di cui cessioni esenti art.10 di beni ammortizzabili @69g%r"), &d._ra3);
|
||
const real diff = d._ra0 - d._ra3;
|
||
|
||
set_row(row++, FR(" - Denominatore @69g%r"), &d._ra1);
|
||
}
|
||
else
|
||
{
|
||
set_row(row++, FR(" - Volume d'affari @69g%r"), &vol_aff);
|
||
set_row(row++, FR("B1 - Operazioni esenti escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &d._r1);
|
||
set_row(row++, FR("B2 - Operazioni esenti di cui nr. 11 art. 10 @69g%r"), &d._r4);
|
||
set_row(row++, FR("B3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &d._r5);
|
||
set_row(row++, FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &d._r8);
|
||
|
||
const real diff1 = d._r5 - d._r8;
|
||
|
||
if (diff1 != ZERO)
|
||
{
|
||
set_row(row++, FR("@69g----------------"));
|
||
set_row(row++, FR("6gDifferenza @69g%r"), &diff1);
|
||
row++;
|
||
}
|
||
set_row(row++, FR("B4 - Operazioni esenti di cui all'art.10 n. 27 quinquies @69g%r"), &d._r7);
|
||
set_row(row++, FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &d._r9);
|
||
|
||
const real diff2 = d._r7 - d._r9;
|
||
|
||
if (diff2 != ZERO)
|
||
{
|
||
set_row(row++, FR("@69g----------------"));
|
||
set_row(row++, FR("6gDifferenza @69g%r"), &diff2);
|
||
row++;
|
||
}
|
||
set_row(row++, FR(" - Vendite Reverse Charge @69g%r"), &d._ra2);
|
||
row++;
|
||
set_row(row++, FR(" - Numeratore pro-rata @69g%r"), &d._ra0);
|
||
set_row(row++, FR(" Volume d'affari - B3(senza beni amm.) - B4(senza beni amm.) - vendite reverse charge "));
|
||
set_row(row++, FR(" - Denominatore @69g%r"), &d._ra1);
|
||
set_row(row++, FR(" Denominatore - B1 "));
|
||
}
|
||
set_print_zero(false);
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
|
||
void TLiquidazione_app::set_ventila(_DescrItem& d)
|
||
{
|
||
if (d._arr.items() == 0 || d._r0.is_zero())
|
||
return;
|
||
|
||
set_bookmark(TR("Prospetto ventilazione"), _att_bookmark);
|
||
|
||
set_row(1,FR("@54gPROSPETTO VENTILAZIONE"));
|
||
set_row(2,"");
|
||
set_row(3,"");
|
||
set_row(4,FR("@10gTotale acquisti destinati alla rivendita@55g%r"),
|
||
&(d._r0));
|
||
set_row(5,FR("@10gTotale dei corrispettivi da ventilare@55g%r"),
|
||
&(d._r1));
|
||
set_row(6,FR("@10gMoltiplicatore@59g%3.9r"),&(d._r2));
|
||
set_row(7,"");
|
||
set_row(8,FR("@10gCod."));
|
||
set_row(9,FR("@10gIVA@17gDescrizione@48gAcquisti"
|
||
"@65gImponibile vendite@89gImposta vendite"));
|
||
set_row(10,"");
|
||
int row = 11;
|
||
real t1, t2, t3;
|
||
TString80 s0;
|
||
int i;
|
||
|
||
for(i = 0; i < d._arr.items(); i++)
|
||
{
|
||
_vDesc& vd = (_vDesc&)d._arr[i];
|
||
look_iva(vd._codiva);
|
||
s0 = _iva->get("S0"); s0.cut(23);
|
||
|
||
set_row(row+i,"@8g%5s@17g%-23s@41g%r@68g%r@89g%r",
|
||
(const char*)vd._codiva,
|
||
(const char*)s0,
|
||
&(vd._acq),
|
||
&(vd._vnd),
|
||
&(vd._viv));
|
||
t1 += vd._acq;
|
||
t2 += vd._vnd;
|
||
t3 += vd._viv;
|
||
}
|
||
set_row(row+i+1,"");
|
||
set_row(row+i+2,FR("@10gTotale@41g%r@68g%r@89g%r"),
|
||
&t1, &t2, &t3);
|
||
set_auto_ff(true);
|
||
}
|
||
|
||
static void real2string(const real& r, TString& str)
|
||
{
|
||
TCurrency cur(r);
|
||
str = cur.string(true);
|
||
}
|
||
|
||
void TLiquidazione_app::set_regagr(_DescrItem& d)
|
||
{
|
||
set_print_zero(true);
|
||
|
||
real& agr_1 = d._r0;
|
||
real& agr_2 = d._r1;
|
||
real& agr_3 = d._r2;
|
||
real& agr_4 = d._r3;
|
||
real& agr_5 = d._r4;
|
||
real& agr_6 = d._r5;
|
||
real& agr_7 = d._r6;
|
||
real& agr_1i = d._r7;
|
||
real& agr_2i = d._r8;
|
||
real& pdetr = d._r9;
|
||
real& ivadt = d._r10;
|
||
real& iva_detIA = d._r11;
|
||
|
||
real ara = agr_5 + agr_6;
|
||
real arn = agr_3 + agr_4;
|
||
real agr_ven = agr_1 + agr_2;
|
||
real ivadt_amm = agr_3 + ivadt + iva_detIA;
|
||
|
||
set_bookmark(TR("Prospetto regime agricolo"), _att_bookmark);
|
||
int r = 1;
|
||
|
||
set_row(r++,FR("@50gPROSPETTO REGIME AGRICOLO"));
|
||
set_row(r++,"");
|
||
|
||
// percentuale detraibilita'
|
||
set_row(r++, FR("Iva vendite beni I parte Tabella A @56g%r"),&agr_1);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Iva vendite beni diversi da I parte Tabella A @56g%r"),&agr_2);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Totale iva sulle operazioni di vendita @56g%r"), &agr_ven);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Iva acquisti in regime agricolo@56g%r"),&ara);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Iva acquisti per operazioni diverse I parte Tabella A@56g%r"),&arn);
|
||
set_row(r++, FR("... di cui beni ammortizzabili@56g%r"),&agr_4);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Iva acquisti ad uso promiscuo@56g%r"),&agr_7);
|
||
|
||
TString dn,riga;
|
||
if (agr_1i != ZERO)
|
||
{
|
||
real2string(agr_1i, riga);
|
||
dn << riga << " + ";
|
||
}
|
||
real2string(agr_2i, riga);
|
||
dn << riga;
|
||
int ln = max(riga.len(),dn.len()) + 2;
|
||
int corr = ln % 2 == 0 ? 0 : 1;
|
||
TString middle(ln); middle.fill('-');
|
||
int xl = 71 - riga.len()/2;
|
||
int times_sign = xl + ln/2 + 3; // per allineare i segni moltiplicativi
|
||
middle << "@" << times_sign << "gx 100 = " << pdetr.string(".") << " %";
|
||
|
||
set_row(r++, "");
|
||
set_row(r++, "@56g%r",&agr_2i);
|
||
riga.format(FR("Percentuale delle operazioni diverse@%dg%%s"),xl - corr - ln/2);
|
||
set_row(r++, riga, (const char*)middle);
|
||
corr = dn.len() % 2 == 0 ? 0 : 1;
|
||
riga.format("@%dg%%s",xl - corr - dn.len()/2);
|
||
set_row(r++, riga, (const char*)dn);
|
||
|
||
real2string(agr_7, riga);
|
||
dn = "100";
|
||
ln = max(riga.len(),dn.len()) + 2;
|
||
xl = 71 - riga.len()/2;
|
||
corr = ln % 2 == 0 ? 0 : 1;
|
||
|
||
middle.fill('-',ln);
|
||
middle << "@" << times_sign << "gx " << pdetr.string(".");
|
||
middle << " = " << TCurrency(ivadt).string(true);
|
||
|
||
set_row(r++, "");
|
||
set_row(r++, "@56g%r", &agr_7);
|
||
riga.format(FR("IVA ammessa in detrazione sugli acquisti promiscui@%dg%%s"),xl - corr - ln/2);
|
||
set_row(r++, riga, (const char*)middle);
|
||
corr = dn.len() % 2 == 0 ? 0 : 1;
|
||
riga.format("@%dg%%s",xl - corr - dn.len()/2);
|
||
set_row(r++, riga, (const char*)dn);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Iva ammessa in detrazione I parte tabella A@56g%r"),&iva_detIA);
|
||
set_row(r++, "");
|
||
set_row(r++, FR("Totale iva ammessa in detrazione@56g%r"),&ivadt_amm);
|
||
|
||
// Last pain...
|
||
TArray& agr_array = d._arr;
|
||
const int pia_items = agr_array.items();
|
||
|
||
if (pia_items) // Se non siamo ancora nel 1998 questo vale 0, ossia non vi sono items.
|
||
{
|
||
real t1,t2; // Totale imponibile/imposta
|
||
TString des; // Descrizione codice iva ordinario
|
||
real al; // Aliquota IVA
|
||
r+=2;
|
||
// Stampa l' intestazione...
|
||
set_row(r++,FR(" Codice IVA@45gAliquota IVA@73gCodice IVA@88gAliquota IVA"));
|
||
set_row(r++,FR(" Ordinario@45gOrdinaria@61gImponibile@73gCompensazione@88gCompensazione@108gImposta"));
|
||
set_row(r++,"");
|
||
for (int i=0; i<pia_items; i++)
|
||
{
|
||
_DescrItem& di = (_DescrItem&) agr_array[i];
|
||
if (di._flags != PROGAGR)
|
||
continue;
|
||
look_iva(di._s0);
|
||
des = _iva->get("S0"); des.cut(25);
|
||
al = _iva->get_real("R0");
|
||
set_row(r,"%4s %-25s@48g%s %%", (const char*) di._s0, (const char*) des, al.string("#@,@@"));
|
||
set_row(r,"@56g%r@75g%4s",&di._r0, (const char*)di._s1);
|
||
look_iva(di._s1);
|
||
al = _iva->get_real("R0");
|
||
set_row(r++,"@92g%s %%@100g%r", al.string("#@,@@"), &di._r1);
|
||
t1 += di._r0;
|
||
t2 += di._r1;
|
||
}
|
||
// ... ed il totale minchiativo
|
||
r++;
|
||
set_row(r++,FR("Totale@56g%r@100g%r"),&t1,&t2);
|
||
}
|
||
|
||
set_auto_ff(true);
|
||
set_print_zero(false);
|
||
}
|
||
|
||
void TLiquidazione_app::set_viaggio(_DescrItem& d)
|
||
{
|
||
// the longest & stronzest
|
||
// Nel corso della scrittura di questa funzione
|
||
// Berlusconi + Fini + Bossi hanno vinto le elezioni
|
||
// ... lungo commento cancellato
|
||
|
||
real& corr_CEE = d._r0;
|
||
real& corr_misCEE = d._r1;
|
||
real& corr_noCEE = d._r2;
|
||
real& acq_CEE = d._r3;
|
||
real& acq_misCEE = d._r4;
|
||
real& acq_noCEE = d._r5;
|
||
real& acq_misnoCEE = d._r6;
|
||
real& perc_r = d._r7;
|
||
real& cred_cos = d._r8;
|
||
real& ivm = d._r9;
|
||
|
||
real tc = (corr_CEE + ivm);
|
||
real ta = (acq_CEE + acq_misCEE);
|
||
real& bi = d._r10;
|
||
real& dovuta = d._r11;
|
||
|
||
real tcc = corr_CEE + corr_noCEE + corr_misCEE;
|
||
real tco = acq_CEE + acq_noCEE + acq_misCEE + acq_misnoCEE;
|
||
real tma = acq_CEE + acq_misCEE;
|
||
|
||
set_print_zero(true);
|
||
|
||
set_bookmark(FR("Prospetto 74 ter"), _att_bookmark);
|
||
|
||
set_row(1,"");
|
||
set_row(2,FR("@54gRIEPILOGO 74 TER"));
|
||
set_row(3,"");
|
||
set_row(4,FR("Ammontare dei corrispettivi relativi a viaggi eseguiti"
|
||
" interamente nella CEE .....................@100g%r"), &(corr_CEE));
|
||
set_row(5,FR("Ammontare dei corrispettivi relativi a viaggi misti (dentro"
|
||
" e fuori CEE) ......................... @100g%r"), &(corr_misCEE));
|
||
set_row(6,FR("Ammontare dei corrispettivi relativi a viaggi eseguiti"
|
||
" interamente fuori CEE ..................... @100g%r"), &(corr_noCEE));
|
||
|
||
|
||
set_row(7,"");
|
||
set_row(8,FR("@56gTotale corrispettivi@100g%r"), &tcc);
|
||
set_row(9,"");
|
||
|
||
set_row(10,FR("Ammontare dei costi relativi a viaggi interamente"
|
||
" svolti nella CEE ............................... @100g%r"),
|
||
&(acq_CEE));
|
||
set_row(11,FR("Ammontare dei costi relativi a viaggi misti (per la"
|
||
" parte CEE) ................................... @100g%r"),
|
||
&(acq_misCEE));
|
||
set_row(12,FR("Ammontare dei costi relativi a viaggi interamente"
|
||
" svolti fuori CEE ............................... @100g%r"),
|
||
&(acq_noCEE));
|
||
set_row(13,FR("Ammontare dei costi relativi a viaggi misti (per la"
|
||
" parte fuori CEE) .............................@100g%r"),
|
||
&(acq_misnoCEE));
|
||
|
||
set_row(14,"");
|
||
set_row(15,FR("@64gTotale costi@100g%r"), &tco);
|
||
|
||
set_row(16,"");
|
||
set_row(17,TR("DETERMINAZIONE CORRISPETTIVI IMPONIBILI "
|
||
"RELATIVI A VIAGGI MISTI"));
|
||
set_row(18,"");
|
||
|
||
// la bella frazioncina della percentuale di ripartizione
|
||
TString tmp; real2string(acq_misCEE, tmp);
|
||
TString up = tmp;
|
||
up << " x 100";
|
||
TString dn = tmp;
|
||
real2string(acq_misnoCEE, tmp);
|
||
dn << " + " << tmp;
|
||
int ln = max(up.len(), dn.len()) + 2;
|
||
TString den(ln); den.fill('-');
|
||
up.center_just(ln); dn.center_just(ln);
|
||
|
||
// la bella frazioncina degli imponibili viaggi misti
|
||
TString tmp2; real2string(corr_misCEE, tmp2);
|
||
TString up2 = tmp2;
|
||
const TString16 perc_r_str = perc_r.string("###,@@");
|
||
up2 << " x" << perc_r_str;
|
||
TString dn2 = "100";
|
||
int ln2 = max(up2.len(), 3) + 2;
|
||
TString den2(ln2); den2.fill('-');
|
||
up2.center_just(ln2); dn2.center_just(ln2);
|
||
|
||
// la gran frazionazza centrata e stupenda
|
||
int tot = 35 + ln + ln2;
|
||
int rem1 = (100 - tot)/2; if (rem1 < 0) rem1 = 0;
|
||
int pos1 = rem1 + 13;
|
||
int rem2 = pos1+ den.len() + 11;
|
||
int pos2 = rem2 + 20;
|
||
|
||
set_row(19,format("@%dg%%t@%dg%%t", pos1, pos2),
|
||
&up, &up2);
|
||
set_row(20,format(FR("@%dgPerc. rip. = %%t = %%t; @%dg"
|
||
"Imp. viaggi misti = %%t = @100g%%r"),
|
||
rem1, rem2),
|
||
&den, &perc_r_str, &den2, &ivm);
|
||
set_row(21,format("@%dg%%t@%dg%%t", pos1, pos2),
|
||
&dn, &dn2);
|
||
|
||
real tmr = corr_CEE + ivm;
|
||
|
||
// whew, come dicono su Topolino
|
||
|
||
real2string(corr_CEE, tmp);
|
||
up = "("; up << tmp << " + ";
|
||
real2string(ivm, tmp);
|
||
up << tmp << ")";
|
||
den.fill('.',59-up.len());
|
||
set_row(23,FR("Ammontare dei corrispettivi imponibili@40g%t %t@100g%r"),
|
||
&up, &den, &tmr);
|
||
|
||
// se e' l'annuale non ha senso altro
|
||
if (d._f1) return;
|
||
|
||
real2string(acq_CEE, tmp);
|
||
up = "("; up << tmp << " + ";
|
||
real2string(acq_misCEE, tmp);
|
||
up << tmp << ")";
|
||
den.fill('.',59-up.len());
|
||
set_row(24,FR("Ammontare dei costi deducibili@40g%t %t@100g%r"),
|
||
&up, &den, &tma);
|
||
den.fill('.',60);
|
||
set_row(25,FR("Credito di costo precedente @40g%t@100g%r"), &den, &(cred_cos));
|
||
|
||
real2string(tmr, tmp);
|
||
up = "["; up << tmp << " - (";
|
||
real2string(tma, tmp);
|
||
up << tmp << " + ";
|
||
real2string(d._r8, tmp);
|
||
up << tmp << ")]";
|
||
den.fill('.',59-up.len());
|
||
|
||
set_row(26,FR("Base imponibile lorda@40g%t %t@100g%r"), &up, &den, &bi);
|
||
set_row(27,"");
|
||
|
||
if (bi > ZERO)
|
||
{
|
||
const real aliva = aliquota_agvia();
|
||
const real alcnt = aliva + CENTO;
|
||
|
||
real2string(bi, tmp);
|
||
up = tmp;
|
||
up << " x" << aliva.string("###,@@");
|
||
dn = alcnt.string("###,@@");
|
||
ln = max(up.len(), 3) + 2;
|
||
den.fill('-',ln);
|
||
up.center_just(ln); dn.center_just(ln);
|
||
|
||
tmp.fill('.', 59 - den.len());
|
||
|
||
set_row(28,"@40g%t",&up);
|
||
set_row(29,FR("IVA A DEBITO@40g%t %t@100g%r"), &den, &tmp, &dovuta);
|
||
set_row(30,"@40g%t", &dn);
|
||
}
|
||
else if (bi.sign() < 0)
|
||
{
|
||
bi = abs(bi);
|
||
set_row(28,"");
|
||
set_row(29,FR("CREDITO DI COSTO DA RIPORTARE@100g%r"), &bi);
|
||
}
|
||
|
||
set_print_zero(false);
|
||
set_auto_ff(true);
|
||
}
|
||
|
||
void TLiquidazione_app::set_acconto_p(_DescrItem& d)
|
||
{
|
||
const char* errmsg[3] = {
|
||
{TR("manca la tabella risultati liquidazione per l'anno corrente")},
|
||
{TR("manca la tabella risultati liquidazione per l'anno precedente")},
|
||
{TR("manca la tabella dichiarazione annuale per l'anno precedente")}};
|
||
|
||
set_row(1,"%t@7g%t",&(d._s0), &(d._s1));
|
||
if (d._f2)
|
||
set_row(1,"@50g@b*** %s ***@r", errmsg[d._f2 -1]);
|
||
else
|
||
{
|
||
if (d._f0) // base anno in corso
|
||
{
|
||
if (d._f1) // stampa base di calcolo
|
||
{
|
||
set_row(1,"@58g%r@74g%r@96g%r@122g%s", &(d._r3),
|
||
&(d._r2), &(d._r1), d._f3 ? "Si" : "No");
|
||
}
|
||
else
|
||
set_row(1,"@62g%r@91g%s", &(d._r1), d._f3 ? "Si" : "No");
|
||
}
|
||
else //metodo storico
|
||
{
|
||
if (d._f1 && (d._r0).sign()>0) // stampa base di calcolo
|
||
set_row(1,"@58g%r@88g%r", &(d._r0), &(d._r1));
|
||
else
|
||
set_row(1,"@87g%r",&(d._r1));
|
||
}
|
||
}
|
||
}
|
||
|
||
void TLiquidazione_app::set_acchead_p(_DescrItem& d)
|
||
{
|
||
reset_header();
|
||
set_header(1,FR("Gestione IVA@107gData @>@125gPag. @#"));
|
||
set_header(3,sep);
|
||
|
||
if (d._f0) // base anno in corso
|
||
{
|
||
set_header(2,FR("@40gCALCOLO ACCONTI IVA DICEMBRE %s "
|
||
"(base anno in corso)"), (const char*) _year);
|
||
if (d._f1) // stampa base calcolo
|
||
{
|
||
set_header(4,FR("@58g------- Base di calcolo -------"));
|
||
set_header(5,FR("Ditta@7gDenominazione@62gDebito@78gCredito"
|
||
"@94gACCONTO calcolato@115gLiq. differita"));
|
||
set_header(6,sep);
|
||
set_header(7,"");
|
||
}
|
||
else
|
||
{
|
||
set_header(4,FR("Ditta@7gDenominazione@60gACCONTO calcolato"
|
||
"@84gLiq. differita"));
|
||
set_header(5,sep);
|
||
set_header(6,"");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
set_header(2,FR("@40gCALCOLO ACCONTI IVA DICEMBRE %s"), (const char*) _year);
|
||
set_header(5,sep);
|
||
set_header(6,"");
|
||
if (d._f1)
|
||
set_header(4,FR("Ditta@7gDenominazione@58gBase di calcolo"
|
||
"@86gACCONTO calcolato"));
|
||
else
|
||
set_header(4,FR("Ditta@7gDenominazione@85gACCONTO calcolato"));
|
||
}
|
||
}
|
||
|
||
|
||
// ---------------------------------------------------------------------
|
||
// Tabulato deleghe
|
||
// ---------------------------------------------------------------------
|
||
|
||
void TLiquidazione_app::set_deltab(_DescrItem& d, bool iscred)
|
||
{
|
||
reset_header();
|
||
int rw = 1;
|
||
static bool credpr;
|
||
|
||
if (iscred)
|
||
{
|
||
// set header
|
||
set_header(1,FR("ELENCO DITTE A CREDITO@30g%s %s@107gData @>@125gPag. @#"),
|
||
d._f0 == 13 ? TR("Annuale ") : itom(d._f0), (const char*)_year);
|
||
set_header(2,sep);
|
||
set_header(3,FR("@40gF@60gImporto a"));
|
||
set_header(4,FR("Cod.@8gDenominazione@40gR@62gcredito"));
|
||
set_header(5,sep);
|
||
set_header(6,"");
|
||
|
||
// set rows
|
||
for (int i = 0; i < d._arr.items(); i++)
|
||
{
|
||
TToken_string& tt = (TToken_string&)(d._arr)[i];
|
||
TString cod(tt.get(0));
|
||
TParagraph_string rgs(tt.get(1), 30);
|
||
TString diocantaro(rgs.get(0));
|
||
TString frq(tt.get(2));
|
||
real tp (tt.get(3));
|
||
real in (tt.get(4));
|
||
tp -= in;
|
||
tp = -tp;
|
||
set_row(rw++, "%-5s@8g%-30s@40g%1s@54g%r",
|
||
(const char*)cod, (const char*)diocantaro,
|
||
(const char*)frq, &tp);
|
||
for (int i = 1; i < rgs.items(); i++)
|
||
set_row(rw++, "@8g%-30s", (const char*)rgs.get(i));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// set header
|
||
set_header(1,FR("ELENCO DITTE A DEBITO@30g%s %s@107gData @>@125gPag. @#"),
|
||
d._f0 == 13 ? TR("Annuale ") : itom(d._f0), (const char*)_year);
|
||
set_header(2,sep);
|
||
set_header(3,FR("@40gF@60gImporto da@73gCodice@83gCod."));
|
||
set_header(4,FR("Cod.@8gDenominazione@40gR Numero telefonico@63gversare Banca Dip. Con."));
|
||
set_header(5,sep);
|
||
set_header(6,"");
|
||
|
||
|
||
// set rows
|
||
for (int i = 0; i < d._arr.items(); i++)
|
||
{
|
||
TToken_string& tt = (TToken_string&)(d._arr)[i];
|
||
TString cod(tt.get(0));
|
||
TParagraph_string rgs(tt.get(1), 30);
|
||
TString diocantaro(rgs.get(0));
|
||
TString frq(tt.get(2));
|
||
real tp (tt.get(3));
|
||
real in (tt.get(4));
|
||
TString abi(tt.get(5));
|
||
TString cab(tt.get(6));
|
||
TString con(tt.get(7));
|
||
TString tel(tt.get(8));
|
||
if (!tel.blank())
|
||
tel << '/';
|
||
tel << tt.get(9);
|
||
TString desc(tt.get(10));
|
||
|
||
set_row(rw++, "%-5s@8g%-30s@40g%1s %s @55g%r %5s %5s %3s %-.45s",
|
||
(const char*)cod, (const char*)diocantaro, (const char*)frq,
|
||
(const char*)tel, &tp, (const char*)abi,
|
||
(const char*)cab, (const char*)con, (const char*)desc);
|
||
|
||
for (int i = 1; i < rgs.items(); i++)
|
||
set_row(rw++, "@8g%-30s", (const char*)rgs.get(i));
|
||
}
|
||
}
|
||
set_auto_ff(true);
|
||
}
|
||
|