Patch level : 10.0 278

Files correlati     :  cg4.exe cg5.exe cg5300a.uml cg5500b.uml cg5500d.uml
                       cg5500a.rep cg5500b.rep 
Ricompilazione Demo : [ ]
Commento            :

Modifiche al prospetto della liquidazione iva. Implementare la gestione del credito iva infrannuale e modifiche a quello dell'anno precedente.
Aggiunta stampa dei prospetti di liquidazione.
Considerato il credito utilizzato a inizio anno come utilizzato e solo se il credito è compensabile in F24 a Gennaio. In realtà era già così

git-svn-id: svn://10.65.10.50/branches/R_10_00@23221 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
bonazzi 2016-09-05 22:01:25 +00:00
parent c93f5b89bd
commit a2de8ed91a
17 changed files with 5890 additions and 5595 deletions

View File

@ -114,11 +114,13 @@ bool TLiquidazione_app::user_create()
#ifdef DBG #ifdef DBG
else if (argv(2)[1] == 'C') else if (argv(2)[1] == 'C')
{ {
subj = "2012|12|9058|R|12-12-2012|c:/Temp/110|X|60"; subj = "2016|9|1|R|01-01-2016|c:/Temp/110|X|60";
_is_interactive = false; _is_interactive = false;
} }
#endif #endif
open_files(LF_TAB, LF_TABCOM, LF_NDITTE, LF_MOV, LF_ATTIV, LF_CLIFO, LF_OCCAS, LF_RMOV, LF_RMOVIVA,
LF_COMUNI, LF_ANAG, LF_UNLOC, LF_CAUSALI, LF_RMOVIVA, LF_INDLIB, 0);
TProgress_monitor pnd(3, TR("Preparazione archivi"), false); TProgress_monitor pnd(3, TR("Preparazione archivi"), false);
@ -194,13 +196,11 @@ bool TLiquidazione_app::user_create()
_ppa = new TTable("PPA"); _ppa = new TTable("PPA");
_plm = new TTable("PLM"); _plm = new TTable("PLM");
_pia = new TTable("PIA"); _pia = new TTable("PIA");
_lim = new TTable("LIM");
_lam = new TTable("LAM"); _lam = new TTable("LAM");
_pla = new TTable("%PLA"); _pla = new TTable("%PLA");
_reg = new TTable("REG"); _reg = new TTable("REG");
_iva = new TTable("%IVA"); _iva = new TTable("%IVA");
_del = new TTable("%DEL"); _del = new TTable("%DEL");
_lia = new TTable("%LIA");
_mov = &_cur->file(LF_MOV); _mov = &_cur->file(LF_MOV);
_rmoviva = &_cur->file(LF_RMOVIVA); _rmoviva = &_cur->file(LF_RMOVIVA);
@ -218,7 +218,6 @@ bool TLiquidazione_app::user_create()
_pom_r = &(_pom->curr()); _pom_r = &(_pom->curr());
_iva_r = &(_iva->curr()); _iva_r = &(_iva->curr());
_del_r = &(_del->curr()); _del_r = &(_del->curr());
_lim_r = &(_lim->curr());
_lam_r = &(_lam->curr()); _lam_r = &(_lam->curr());
_pla_r = &(_pla->curr()); _pla_r = &(_pla->curr());
_ppa_r = &(_ppa->curr()); _ppa_r = &(_ppa->curr());
@ -294,8 +293,6 @@ bool TLiquidazione_app::user_create()
_del_mese = new TRecfield(*_del_r,"CODTAB",9,10); _del_mese = new TRecfield(*_del_r,"CODTAB",9,10);
_del_tipo = new TRecfield(*_del_r,"CODTAB",11,11); _del_tipo = new TRecfield(*_del_r,"CODTAB",11,11);
_lim_anno = new TRecfield(*_lim_r,"CODTAB",0,3);
_lim_mese = new TRecfield(*_lim_r,"CODTAB",4,6);
_lam_anno = new TRecfield(*_lam_r,"CODTAB",0,3); _lam_anno = new TRecfield(*_lam_r,"CODTAB",0,3);
_lam_mese = new TRecfield(*_lam_r,"CODTAB",4,6); _lam_mese = new TRecfield(*_lam_r,"CODTAB",4,6);
@ -314,13 +311,13 @@ bool TLiquidazione_app::user_create()
TApplication::set_firm(__firm); TApplication::set_firm(__firm);
set_real_picture(REAL_PICTURE); set_real_picture(REAL_PICTURE);
set_magic_currency(TRUE); set_magic_currency(true);
if (!_is_interactive) if (!_is_interactive)
{ {
TTemp_window w(TASK_WIN); TTemp_window w(TASK_WIN);
if (_recalc_only) if (_recalc_only)
_isprint = FALSE; _isprint = false;
//else printer().set_export_file(filename, is_header, headerlen); //else printer().set_export_file(filename, is_header, headerlen);
else else
printer().set_export_file(filename, is_header); printer().set_export_file(filename, is_header);
@ -330,7 +327,9 @@ bool TLiquidazione_app::user_create()
_recalc = nocalc ? never : needed; _recalc = nocalc ? never : needed;
TApplication::set_firm(ditta); TApplication::set_firm(ditta);
if (!look_lia()) const TRectype & lia = get_lia();
if (lia.empty())
return false; return false;
TIva_round ir; // Imposta arrotondamento iva TIva_round ir; // Imposta arrotondamento iva
@ -339,7 +338,7 @@ bool TLiquidazione_app::user_create()
_nditte->zero(); _nditte->zero();
_nditte_r->put("CODDITTA", ditta); _nditte_r->put("CODDITTA", ditta);
_nditte->read(); _nditte->read();
_freqviva = _lia->get("S7"); _freqviva = lia.get("S7");
TRectype& mov = _cur->curr(); TRectype& mov = _cur->curr();
TRectype from(_cur->curr()); from.zero(); TRectype from(_cur->curr()); from.zero();
@ -359,7 +358,9 @@ bool TLiquidazione_app::user_create()
bool need_refresh = false; bool need_refresh = false;
for (int m = 1; m < _month; m++) for (int m = 1; m < _month; m++)
{ {
if (is_month_ok_strict(m) && (!look_lim(m) || !_lim->get_bool("B0"))) const TRectype & lim = get_lim(m) ;
if (is_month_ok_strict(m) && !lim.get_bool("B0"))
{ {
need_refresh = true; need_refresh = true;
break; break;
@ -399,12 +400,17 @@ bool TLiquidazione_app::user_create()
// se ci sono altri mesi dopo l'ultimo calcolato, invalida il // se ci sono altri mesi dopo l'ultimo calcolato, invalida il
// flag 'calcolato' del primo, per causare il ricalcolo dei // flag 'calcolato' del primo, per causare il ricalcolo dei
// successivi (evitando problemi per credito precedente) // successivi (evitando problemi per credito precedente)
for (int m = _month+1; m <= 13; m++) if (look_lim(m)) for (int m = _month+1; m <= 13; m++)
{ {
_lim->zero("B0"); TRectype lim = get_lim(m);
_lim->rewrite();
break; if (lim.not_empty())
} {
lim.zero("B0");
put_lim(lim);
break;
}
}
} }
TApplication::set_firm(__firm); TApplication::set_firm(__firm);
@ -467,8 +473,6 @@ bool TLiquidazione_app::user_destroy()
delete _pom_codatt; delete _pom_codatt;
delete _pom_anno; delete _pom_anno;
delete _pom_mese; delete _pom_mese;
delete _lim_anno;
delete _lim_mese;
delete _lam_anno; delete _lam_anno;
delete _lam_mese; delete _lam_mese;
delete _pla_anno; delete _pla_anno;
@ -489,7 +493,6 @@ bool TLiquidazione_app::user_destroy()
delete _ppa; delete _ppa;
delete _plm; delete _plm;
delete _pia; delete _pia;
delete _lim;
delete _lam; delete _lam;
delete _pla; delete _pla;
delete _del; delete _del;
@ -523,9 +526,9 @@ bool TLiquidazione_app::set_print(int)
break; break;
/* /*
case 2: // estrazione deleghe case 2: // estrazione deleghe
_isprint = FALSE; _isprint = false;
_selected.reset(); _selected.reset();
_ditte->check(-1, FALSE); _ditte->check(-1, false);
build_ditte_sheet(all); build_ditte_sheet(all);
while (set_deleghe()) while (set_deleghe())
{ {
@ -540,10 +543,10 @@ bool TLiquidazione_app::set_print(int)
*/ */
case 3: // calcolo acconto case 3: // calcolo acconto
{ {
_isprint = TRUE; _isprint = true;
_month = 12; _month = 12;
_selected.reset(); _selected.reset();
_ditte->check(-1, FALSE); _ditte->check(-1, false);
build_ditte_sheet(all); build_ditte_sheet(all);
real inf; real ina; // cotale obbrobrio non fu da me cercato, ne' mai condiviso real inf; real ina; // cotale obbrobrio non fu da me cercato, ne' mai condiviso
while (set_acconto(inf, ina)) while (set_acconto(inf, ina))
@ -561,6 +564,7 @@ bool TLiquidazione_app::set_print(int)
break; break;
} }
return false; return false;
} }
long TLiquidazione_app::select_firm_range(long from, long to, wht freq) long TLiquidazione_app::select_firm_range(long from, long to, wht freq)
@ -586,7 +590,7 @@ long TLiquidazione_app::select_firm_range(long from, long to, wht freq)
} }
else else
{ {
_selected.set(i,FALSE); _selected.set(i,false);
_ditte->uncheck(i); _ditte->uncheck(i);
} }
} }
@ -618,33 +622,26 @@ void TLiquidazione_app::build_nomiditte()
for (dt.first(); !dt.eof(); dt.next()) for (dt.first(); !dt.eof(); dt.next())
{ {
// check no archivi if (prefix().exist(dt.get_long("CODDITTA"))) // check no archivi
bool good = prefix().exist(dt.get_long("CODDITTA")); {
const TRectype & lia = get_lia(dt.get_long("CODDITTA"));
TToken_string d(63);
if (good) // add record
{ d.add(dt.get("CODDITTA"));
// check no parametri liquidazione d.add(dt.get("RAGSOC"));
good = look_lia(dt.get_long("CODDITTA")); if (lia.not_empty())
} {
else d.add(lia.get("S7"));
continue; d.add(lia.get("B5")); // IVA per cassa
}
TToken_string* d = new TToken_string(63); else
{
// add record d.add("??");
d->add(dt.get("CODDITTA")); d.add("??");
d->add(dt.get("RAGSOC")); }
if (good) _nomiditte.add(d);
{ }
d->add(_lia->get("S7"));
d->add(_lia->get("B5")); // IVA per cassa
}
else
{
d->add("??");
d->add("??");
}
_nomiditte.add(d);
} }
} }
@ -797,7 +794,7 @@ bool TLiquidazione_app::chk_final_handler(TMask_field& f, KEY key)
void TLiquidazione_app::reset_choices(TMask& m) void TLiquidazione_app::reset_choices(TMask& m)
{ {
_selected.reset(); _selected.reset();
_ditte->check(-1, FALSE); _ditte->check(-1, false);
if (m.source_file().ends_with("cg4300a.msk")) if (m.source_file().ends_with("cg4300a.msk"))
{ {
const long ditta = get_firm(); const long ditta = get_firm();
@ -805,9 +802,11 @@ void TLiquidazione_app::reset_choices(TMask& m)
m.set(CG43_FLD_DTO, ditta, 0x2); m.set(CG43_FLD_DTO, ditta, 0x2);
wht freq = all; wht freq = all;
if (look_lia(ditta, false, m.get_int(CG43_FLD_ANNO))) const TRectype & lia = get_lia(ditta, false, m.get_int(CG43_FLD_ANNO));
if (lia.not_empty())
{ {
freq = _lia->get_char("S7") == 'T' ? trimestre : mnt; freq = lia.get_char("S7") == 'T' ? trimestre : mnt;
if (m.get_int(CG43_RDB_VERS) != freq) if (m.get_int(CG43_RDB_VERS) != freq)
m.set(CG43_RDB_VERS, freq, 0x3); m.set(CG43_RDB_VERS, freq, 0x3);
} }

View File

@ -169,7 +169,7 @@ public:
_r20, _r21, _r22, _r23, _r24, _r25, _r26, _r27, _r28, _r29, _r20, _r21, _r22, _r23, _r24, _r25, _r26, _r27, _r28, _r29,
_r30, _r31, _r32, _r33; _r30, _r31, _r32, _r33;
TArray _arr; TArray _arr;
TDate _d0; TDate _d0, _d1;
real _diff_ven_ap, _diff_ven_ap_iva, _diff_acq_ap, _diff_acq_ap_iva; real _diff_ven_ap, _diff_ven_ap_iva, _diff_acq_ap, _diff_acq_ap_iva;
_DescrItem(word f) : _flags(f), _f0(0), _f1(0), _f2(0) { } _DescrItem(word f) : _flags(f), _f0(0), _f1(0), _f2(0) { }
@ -326,14 +326,12 @@ class TLiquidazione_app : public TPrint_application
TTable* _pom; TTable* _pom;
TTable* _plm; TTable* _plm;
TTable* _pia; TTable* _pia;
TTable* _lim;
TTable* _lam; TTable* _lam;
TTable* _pla; TTable* _pla;
TTable* _ppa; TTable* _ppa;
TTable* _reg; TTable* _reg;
TTable* _iva; TTable* _iva;
TTable* _del; TTable* _del;
TTable* _lia;
// a reference rectype per file/table // a reference rectype per file/table
TRectype* _mov_r; TRectype* _mov_r;
@ -354,7 +352,6 @@ class TLiquidazione_app : public TPrint_application
TRectype* _plm_r; TRectype* _plm_r;
TRectype* _pia_r; TRectype* _pia_r;
TRectype* _ppa_r; TRectype* _ppa_r;
TRectype* _lim_r;
TRectype* _lam_r; TRectype* _lam_r;
TRectype* _del_r; TRectype* _del_r;
TRectype* _att_r; TRectype* _att_r;
@ -418,8 +415,6 @@ class TLiquidazione_app : public TPrint_application
TRecfield* _del_anno; TRecfield* _del_anno;
TRecfield* _del_mese; TRecfield* _del_mese;
TRecfield* _del_tipo; TRecfield* _del_tipo;
TRecfield* _lim_anno;
TRecfield* _lim_mese;
TRecfield* _lam_anno; TRecfield* _lam_anno;
TRecfield* _lam_mese; TRecfield* _lam_mese;
@ -468,8 +463,8 @@ public:
bool recalc_all(); bool recalc_all();
// ricalcolo progressivi mese // ricalcolo progressivi mese
bool update_firm (int month, bool recalc = TRUE); bool update_firm (int month, bool recalc = true);
bool update_att (int month, const char* codatt, bool recalc = TRUE); bool update_att (int month, const char* codatt, bool recalc = true);
void zero_att (int month, const char* codatt); void zero_att (int month, const char* codatt);
void zero_annual (int month); void zero_annual (int month);
void recalc_att (int month, const char* codatt); void recalc_att (int month, const char* codatt);
@ -482,8 +477,8 @@ public:
// Scorre tutti i PIM della ditta, per completare _iva11_arr prima di chiamare write_IVA11() // Scorre tutti i PIM della ditta, per completare _iva11_arr prima di chiamare write_IVA11()
void iva11_set_arr_phase_2 (const TString& codatt); void iva11_set_arr_phase_2 (const TString& codatt);
// Scrive per la ditta/attivita' corrente, i dati relativi al trasferimento IVA11 // Scrive per la ditta/attivita' corrente, i dati relativi al trasferimento IVA11
// Se viene passato TRUE come parametro, azzera i campi R1 ed R2. // Se viene passato true come parametro, azzera i campi R1 ed R2.
void iva11_write (bool reset_r1r2 = FALSE); void iva11_write (bool reset_r1r2 = false);
// ricalcolo liquidazioni dai progressivi mensili // ricalcolo liquidazioni dai progressivi mensili
void write_liq (int month, const char* atts); void write_liq (int month, const char* atts);
@ -500,8 +495,8 @@ public:
real credito_costo_prec(int month); real credito_costo_prec(int month);
// ritorna i versamenti effettuati nel mese per // ritorna i versamenti effettuati nel mese per
// i tipi delega passati (stile tokenstring) sommando // i tipi delega passati (stile tokenstring) sommando
// gli interessi se interesse = TRUE // gli interessi se interesse = true
real versamenti_IVA(int month, const char* types, bool interesse = FALSE); real versamenti_IVA(int month, const char* types, bool interesse = false);
// Ritorna il valore dell'iva da riportare (solitamente 50500) // Ritorna il valore dell'iva da riportare (solitamente 50500)
real iva_da_riportare(int month); real iva_da_riportare(int month);
@ -596,31 +591,33 @@ public:
void set_liqacc_2000(_DescrItem& d); void set_liqacc_2000(_DescrItem& d);
// Utility per stampare nella colonna debito o credito // Utility per stampare nella colonna debito o credito
void print_importo(int rw, const char* prompt, real imp, bool red = FALSE); void print_importo(int rw, const char* prompt, real imp, bool red = false);
// cercapalle in tabelle con opzione di creazione se serve // cercapalle in tabelle con opzione di creazione se serve
bool look_pim(int m, const char* a, const char* r, const char* cr, bool look_pim(int m, const char* a, const char* r, const char* cr,
const char* i, int tipodet = 0, bool create = FALSE); const char* i, int tipodet = 0, bool create = false);
bool look_pis(int m, const char* a, const char* r, const char* cr, bool look_pis(int m, const char* a, const char* r, const char* cr,
const char* i, int tipodet = 0, bool create = FALSE); const char* i, int tipodet = 0, bool create = false);
bool look_prm(int m, const char* a, const char* r, const char* cr, bool look_prm(int m, const char* a, const char* r, const char* cr,
const char* i, int tipodet = 0, bool create = FALSE); const char* i, int tipodet = 0, bool create = false);
bool look_prp(int m, const char* a, const char* r, const char* cr, bool look_prp(int m, const char* a, const char* r, const char* cr,
const char* i, int tipodet = 0, bool create = FALSE); const char* i, int tipodet = 0, bool create = false);
bool look_pum(int m, const char* a, bool create = FALSE); bool look_pum(int m, const char* a, bool create = false);
bool look_pam(int m, const char* a, bool create = FALSE); bool look_pam(int m, const char* a, bool create = false);
bool look_pem(TTable & pem, int codreg); bool look_pem(TTable & pem, int codreg);
bool look_pom(int m, const char* a, bool create = FALSE); bool look_pom(int m, const char* a, bool create = false);
bool look_plm(int m, const char* a, bool create = FALSE); bool look_plm(int m, const char* a, bool create = false);
bool look_pia(int m, const char* a, const char* cod1, const char* cod2, bool create = FALSE); bool look_pia(int m, const char* a, const char* cod1, const char* cod2, bool create = false);
bool look_lim(int m, bool create = FALSE); const TRectype & get_lim(int month, bool create = false);
bool look_lam(int m, bool create = FALSE); const int put_lim(const TRectype & lim, bool re = true);
bool look_pla(const char* a, bool create = FALSE); bool look_lam(int m, bool create = false);
bool look_ppa(int m, const char* a, int t, bool create = FALSE); bool look_pla(const char* a, bool create = false);
bool look_del(int month, int type, bool create = FALSE); bool look_ppa(int m, const char* a, int t, bool create = false);
bool look_del(int month, int type, bool create = false);
bool look_iva(const char* cod); bool look_iva(const char* cod);
bool look_reg(const char* reg); bool look_reg(const char* reg);
bool look_lia(long ditta = 0l, bool create = FALSE, int anno = 0); const TRectype & get_lia(long ditta = 0l, bool create = false, int anno = 0);
const int put_lia(const TRectype & lia, bool re = true);
int count_activities() const; int count_activities() const;
@ -641,7 +638,7 @@ public:
// il ricalcolo annuale // il ricalcolo annuale
bool is_month_ok(int x, int mtocalc) const; bool is_month_ok(int x, int mtocalc) const;
// is_month_ok_strict controlla che il mese sia OK per la // is_month_ok_strict controlla che il mese sia OK per la
// liquidazione, ma ritorna TRUE per le trimestrali solo // liquidazione, ma ritorna true per le trimestrali solo
// se il mese cade ESATTAMENTE su un trimestre // se il mese cade ESATTAMENTE su un trimestre
bool is_month_ok_strict(int x, int month = -1) const; bool is_month_ok_strict(int x, int month = -1) const;
// questa e' la piu' semplice, per vedere se devo // questa e' la piu' semplice, per vedere se devo
@ -661,7 +658,7 @@ public:
bool set_deleghe(); bool set_deleghe();
bool extract_deleghe(); bool extract_deleghe();
bool extract_delega(int m, TArray& desc); bool extract_delega(int m, TArray& desc);
bool video_conferma(const real&, const real&, const real&, bool to_del = FALSE); bool video_conferma(const real&, const real&, const real&, bool to_del = false);
*/ */
// stampa // stampa
@ -679,7 +676,11 @@ public:
void set_acconto_p(_DescrItem& d); void set_acconto_p(_DescrItem& d);
void set_acchead_p(_DescrItem& d); void set_acchead_p(_DescrItem& d);
real credito_utilizzato(int month, bool iva, bool f24) const;
const real credito_utilizzato_F24(int month) const;
const real credito_utilizzato_IVA(int month) const;
const real credito_utilizzato(int month) const { return credito_utilizzato_F24(month) + credito_utilizzato_IVA(month);}
const real credito_autorizzato(int month) const;
// cippiuppiu' // cippiuppiu'
TLiquidazione_app(int men); TLiquidazione_app(int men);

View File

@ -108,11 +108,16 @@ bool TLiquidazione_app::recalc_all()
{ {
int m = _month == 13 ? _month : 1; int m = _month == 13 ? _month : 1;
for (; m < _month; m++) for (; m < _month; m++)
if (is_month_ok_strict(m) && (!look_lim(m) || !_lim->get_bool("B0"))) if (is_month_ok_strict(m))
{ {
need_refresh = true; const TRectype & lim = get_lim(m);
break;
} if (lim.empty() || !lim.get_bool("B0"))
{
need_refresh = true;
break;
}
}
if (need_refresh && yesno_box(TR("Alcuni mesi precedenti non " if (need_refresh && yesno_box(TR("Alcuni mesi precedenti non "
"risultano ricalcolati. E' consigliabile il ricalcolo. " "risultano ricalcolati. E' consigliabile il ricalcolo. "
@ -129,11 +134,16 @@ bool TLiquidazione_app::recalc_all()
// se ci sono altri mesi dopo l'ultimo calcolato, invalida il // se ci sono altri mesi dopo l'ultimo calcolato, invalida il
// flag 'calcolato' del primo, per causare il ricalcolo dei // flag 'calcolato' del primo, per causare il ricalcolo dei
// successivi (evitando problemi per credito precedente) // successivi (evitando problemi per credito precedente)
for (m = _month+1; m <= 13; m++) if (look_lim(m)) for (m = _month+1; m <= 13; m++)
{ {
_lim->zero("B0"); TRectype lim = get_lim(m);
_lim->rewrite();
break; if (lim.not_empty())
{
lim.zero("B0");
put_lim(lim);
break;
}
} }
_month = save_month; _month = save_month;
@ -149,10 +159,10 @@ bool TLiquidazione_app::recalc_all()
bool TLiquidazione_app::update_firm(int month, bool recalc) bool TLiquidazione_app::update_firm(int month, bool recalc)
{ {
// Se recalc e' TRUE considera la necessita' di ricalcolare e le // Se recalc e' true considera la necessita' di ricalcolare e le
// opzioni utente. Se FALSE se ne impipa dell'utente e ricalcola // opzioni utente. Se false se ne impipa dell'utente e ricalcola
// se necessario (serve nelle chiamate ricorsive) // se necessario (serve nelle chiamate ricorsive)
// Ritorna FALSE soltanto se il ricalcolo era necessario e non e' // Ritorna false soltanto se il ricalcolo era necessario e non e'
// stato effettuato per scelta dello stronzo commercialista. // stato effettuato per scelta dello stronzo commercialista.
// Gestione IVA differita, da non confondere con _isdifferita // Gestione IVA differita, da non confondere con _isdifferita
@ -170,18 +180,18 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
} }
} }
look_lim(liq_month(month), true);
_isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA _isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA
_isdifferita = _isdiffacc; _isdifferita = _isdiffacc;
look_lia(); const TRectype & lia = get_lia();
_isintr = _freqviva == "T" && !_lia->get_bool("B3"); // was CNF_DITTA->InTrtr
_gest4 = _isbenzinaro && _lia->get_bool("B4"); // was CNF_DITTA->Gest74 _isintr = _freqviva == "T" && !lia.get_bool("B3"); // was CNF_DITTA->InTrtr
_gest4 = _isbenzinaro && lia.get_bool("B4"); // was CNF_DITTA->Gest74
const bool has_single_activity = count_activities() == 1; const bool has_single_activity = count_activities() == 1;
// controlla che il periodo corrente non sia l'inizio dell'attivita' // controlla che il periodo corrente non sia l'inizio dell'attivita'
// nel caso, differita va a FALSE // nel caso, differita va a false
_monthinatt = 1; _monthinatt = 1;
const TDate inatt = _nditte->curr().get(NDT_DINIZIOATT); const TDate inatt = _nditte->curr().get(NDT_DINIZIOATT);
if (is_in_liq_period(inatt)) if (is_in_liq_period(inatt))
@ -193,7 +203,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
// ricalcolo normale // ricalcolo normale
// lim c'e' solo per i trimestri // lim c'e' solo per i trimestri
bool ok = _lim->get_bool("B0"); const TRectype & lim = get_lim(liq_month(month), true);
bool ok = lim.get_bool("B0");
if (ok && !recalc) if (ok && !recalc)
return true; return true;
if (_recalc_regis) if (_recalc_regis)
@ -207,8 +219,8 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
TToken_string cattivs; TToken_string cattivs;
// casini per stampa minchie in coda ai registri // casini per stampa minchie in coda ai registri
bool riepliq = _isregis ? _riepilogo : FALSE; bool riepliq = _isregis ? _riepilogo : false;
bool stliq = TRUE; bool stliq = true;
_nditte->save_status(); _nditte->save_status();
if (_nditte->is_first_match(LF_ATTIV)) if (_nditte->is_first_match(LF_ATTIV))
@ -221,7 +233,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
quater = _nditte->curr().get_bool("FLIVA11Q"); quater = _nditte->curr().get_bool("FLIVA11Q");
// attività mista: ce ne sono in realtà due // attività mista: ce ne sono in realtà due
// viene calcolato nel ciclo su tipoatt (che viene ripetuto solo se diventa TRUE); // viene calcolato nel ciclo su tipoatt (che viene ripetuto solo se diventa true);
_mixed = false; _mixed = false;
if (_prind) if (_prind)
@ -369,18 +381,21 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
if (_recalc_regis) if (_recalc_regis)
{ {
_nditte->restore_status(); _nditte->restore_status();
// Se trattasi di ricalcolo per registri, setta il flag relativo, onde evitare ricalcoli // Se trattasi di ricalcolo per registri, setta il flag relativo, onde evitare ricalcoli
// nel caso di registro riepilogativo: se i PRM esistono già (perchè creati // nel caso di registro riepilogativo: se i PRM esistono già (perchè creati
// da stampa bollato precedente o altro riepilogo) non vanno ricalcolati. // da stampa bollato precedente o altro riepilogo) non vanno ricalcolati.
look_lim(month, TRUE); // Crea se non esiste
_lim->put("B1","X"); TRectype lim = get_lim(month, true); // Crea se non esiste
_lim->rewrite();
return TRUE; lim.put("B1","X");
put_lim(lim);
return true;
} }
// se quater stampa riepilogo // se quater stampa riepilogo
if (quater && month == _month && riepliq) if (quater && month == _month && riepliq)
describe_att(month,atts, TRUE, 'Q'); describe_att(month,atts, true, 'Q');
// occorre poterla chiamare altre volte con mesi diversi // occorre poterla chiamare altre volte con mesi diversi
_nditte->restore_status(); _nditte->restore_status();
@ -415,11 +430,17 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
//describe_liq(_month, atts, _isregis ? NULL : rimb_d); //describe_liq(_month, atts, _isregis ? NULL : rimb_d);
describe_liq(_month, atts, rimb_d); describe_liq(_month, atts, rimb_d);
} }
if (_month == 13 && look_lim(_month)) // scrive i risultati solo in annuale if (_month == 13) // scrive i risultati solo in annuale
{ {
real r0 = _lim->get_real("R0"); const TRectype & lim = get_lim(_month);
iva11_write(rimb_d == NULL || r0.sign() >= 0); // scrive su tab1100 at last.
} if (lim.not_empty()) // scrive i risultati solo in annuale
{
const real r0 = lim.get_real("R0");
iva11_write(rimb_d == NULL || r0 >= ZERO); // scrive su tab1100 at last.
}
}
} }
//in caso di stampa registri e in caso sia //in caso di stampa registri e in caso sia
@ -441,14 +462,14 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
bool TLiquidazione_app::update_att(int month, const char* codatt, bool recalc) bool TLiquidazione_app::update_att(int month, const char* codatt, bool recalc)
// viene passato un codice attivita' con codatt+tipoatt // viene passato un codice attivita' con codatt+tipoatt
// vedi update_firm per il burdel dei calc e recalc // vedi update_firm per il burdel dei calc e recalc
// occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati // occhecasino. Se _comp_acconto e' true, i movimenti considerati
// saranno solo quelli di dicembre per data <= 20/12; // saranno solo quelli di dicembre per data <= 20/12;
// il ricalcolo e' FORZATO da _recalc messo a one // il ricalcolo e' FORZATO da _recalc messo a one
{ {
look_plm(month, codatt, true); look_plm(month, codatt, true);
bool ok = _plm->get_bool("B0"); bool ok = _plm->get_bool("B0");
if (_recalc_regis) if (_recalc_regis)
ok = FALSE; // Se sta ricalcolando i PRM/PRP se ne sbatte dei PLM ok = false; // Se sta ricalcolando i PRM/PRP se ne sbatte dei PLM
if (ok && !recalc) if (ok && !recalc)
return true; return true;
bool calc = _recalc == ever || (_recalc == one && is_month_ok(month,_month)); bool calc = _recalc == ever || (_recalc == one && is_month_ok(month,_month));
@ -869,7 +890,7 @@ static bool is_autofattura_articolo_17(const TRectype& mov)
void TLiquidazione_app::recalc_att(int month, const char* codatt) void TLiquidazione_app::recalc_att(int month, const char* codatt)
// il codatt passato e' codice att + tipo att ( IN {1|2} ) // il codatt passato e' codice att + tipo att ( IN {1|2} )
// occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati // occhecasino. Se _comp_acconto e' true, i movimenti considerati
// saranno solo quelli di dicembre per data <= 20/12; // saranno solo quelli di dicembre per data <= 20/12;
{ {
const bool has_sc = has_module(SCAUT, CHK_DONGLE) && ini_get_bool(CONFIG_DITTA, "cg", "GesSal"); const bool has_sc = has_module(SCAUT, CHK_DONGLE) && ini_get_bool(CONFIG_DITTA, "cg", "GesSal");
@ -2119,14 +2140,14 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
} // non sosp_imp ne' altre casistiche che escludono la liq. } // non sosp_imp ne' altre casistiche che escludono la liq.
/* /*
* se ign == TRUE non bisogna neppure PROGRESSIVARLI * se ign == true non bisogna neppure PROGRESSIVARLI
*/ */
const bool sosp_vaf = sosp_imp == vol_affari; const bool sosp_vaf = sosp_imp == vol_affari;
const bool sosp_liq = sosp_imp == liquidazione; const bool sosp_liq = sosp_imp == liquidazione;
bool ign = sosp_imp == normale || (fattrit && month != 13) || noninc; bool ign = sosp_imp == normale || (fattrit && month != 13) || noninc;
/* /*
* se liq == FALSE gli importi non contano ai fini * se liq == false gli importi non contano ai fini
* del calcolo liquidazione * del calcolo liquidazione
*/ */
bool liq = !(tipodet == 1 || tipodet == 3 || tipodet == 9 || ign || sosp_vaf); bool liq = !(tipodet == 1 || tipodet == 3 || tipodet == 9 || ign || sosp_vaf);
@ -2252,7 +2273,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
*/ */
if (tipodoc == "CR" || tipodoc == "RF" || tipodoc == "SC") if (tipodoc == "CR" || tipodoc == "RF" || tipodoc == "SC")
{ {
true_corrisp = TRUE; true_corrisp = true;
_pim->put("I0",LORDO); _pim->put("I0",LORDO);
// questi sono corrispettivi davvero; comportamento normale // questi sono corrispettivi davvero; comportamento normale
if (tipoiva == "VE") // da ventilare if (tipoiva == "VE") // da ventilare
@ -2272,7 +2293,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
else if (tipodoc == "FF") // CM500415: prima non c'era questo if else if (tipodoc == "FF") // CM500415: prima non c'era questo if
{ {
// queste sono fatture fiscali // queste sono fatture fiscali
true_corrisp = TRUE; true_corrisp = true;
real tot = imponibile + imposta; real tot = imponibile + imposta;
lor += tot; lor += tot;
@ -2413,16 +2434,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
switch (i) switch (i)
{ {
case 1: // Progressivi Iva mensili da periodo Successivo case 1: // Progressivi Iva mensili da periodo Successivo
look_pis(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE); look_pis(month, codatt, reg, tipocr_s, codiva, tipodet, true);
break; break;
case 2: // Progressivi Registri iva Mensili case 2: // Progressivi Registri iva Mensili
look_prm(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE); look_prm(month, codatt, reg, tipocr_s, codiva, tipodet, true);
break; break;
case 3: // Progressivi Registri iva Mensili da periodo Precedente case 3: // Progressivi Registri iva Mensili da periodo Precedente
look_prp(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE); look_prp(month, codatt, reg, tipocr_s, codiva, tipodet, true);
break; break;
default: // Progressivi Iva Mensili normali default: // Progressivi Iva Mensili normali
look_pim(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE); look_pim(month, codatt, reg, tipocr_s, codiva, tipodet, true);
break; break;
} }
@ -2652,7 +2673,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
prorata += prorata_diff; prorata += prorata_diff;
fdiffinc_iva_acq -= prorata_diff; // Rettifica acquisti_iva differiti incassati fdiffinc_iva_acq -= prorata_diff; // Rettifica acquisti_iva differiti incassati
} }
look_plm(month, codatt, TRUE); look_plm(month, codatt, true);
/* /*
* ACHTUNG: l'iva sulle vendite e' calcolata sommando anche i * ACHTUNG: l'iva sulle vendite e' calcolata sommando anche i
@ -3505,7 +3526,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
/* Cazzata galattica: già gestito BENE da update_firm, prima di chiamare questa funzione /* Cazzata galattica: già gestito BENE da update_firm, prima di chiamare questa funzione
// evita casino se differita ma si sta ricalcolando il primo mese con ricalcolo di piu' mesi // evita casino se differita ma si sta ricalcolando il primo mese con ricalcolo di piu' mesi
const bool wasdifferita = (_isdifferita && month <= _monthinatt && _month > _monthinatt); const bool wasdifferita = (_isdifferita && month <= _monthinatt && _month > _monthinatt);
if (wasdifferita) _isdifferita = FALSE; if (wasdifferita) _isdifferita = false;
*/ */
// liq. differita: considera mese precedente (solo per i risultati) // liq. differita: considera mese precedente (solo per i risultati)
int deltam = month; int deltam = month;
@ -3513,8 +3534,9 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
month -= (_freqviva == "T" ? 3 : 1); month -= (_freqviva == "T" ? 3 : 1);
deltam -= month; deltam -= month;
look_lia(); const TRectype & lia = get_lia();
const bool new_age_2000 = (_lia->get("S9") == "NV");
const bool credito_compensabile = (lia.get("S9") == "CM");
real risultato = ZERO; real risultato = ZERO;
@ -3567,19 +3589,19 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
real vol_aff_l = ZERO; real vol_aff_l = ZERO;
real tot_cong = ZERO; real tot_cong = ZERO;
bool differita = FALSE; bool differita = false;
bool almeno_una_agricola = FALSE; bool almeno_una_agricola = false;
bool almeno_una_normale = FALSE; bool almeno_una_normale = false;
int attc = 0; // counter attivita' int attc = 0; // counter attivita'
// nuova liquidazione // nuova liquidazione
real credito_utilizzabile_inizio_anno = ZERO; real credito_utilizzabile_inizio_anno = ZERO;
real credito_utilizzato_inizio_anno = ZERO; real credito_utilizzato_inizio_anno = ZERO;
real credito_utilizzato_iva = ZERO; real credito_utilizzato_iva = ZERO;
if (new_age_2000) if (credito_compensabile)
{ {
credito_utilizzato_inizio_anno = _lia->get_real("R15"); credito_utilizzato_inizio_anno = lia.get_real("R15");
credito_utilizzabile_inizio_anno = _lia->get_real("R0") - credito_utilizzato_inizio_anno; credito_utilizzabile_inizio_anno = lia.get_real("R0") - credito_utilizzato_inizio_anno;
if (credito_utilizzabile_inizio_anno < ZERO) if (credito_utilizzabile_inizio_anno < ZERO)
credito_utilizzabile_inizio_anno = ZERO; credito_utilizzabile_inizio_anno = ZERO;
} }
@ -3600,13 +3622,15 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
{ {
// usa i totali del mese di dicembre dell'anno // usa i totali del mese di dicembre dell'anno
// precedente // precedente
differita = TRUE; differita = true;
const TString4 yr(_year); // Salvo anno corrente const TString4 yr(_year); // Salvo anno corrente
_year.format("%d", year_int-1); _year.format("%d", year_int-1);
if (!look_lim(12)) //controlla solamente, il vero posizionamento lo fa dopo const TRectype & lim = get_lim(12);
if (lim.empty()) //controlla solamente, il vero posizionamento lo fa dopo
{ {
_year = yr; // Ripristino anno corrente _year = yr; // Ripristino anno corrente
differita = FALSE; differita = false;
} }
} }
@ -3617,7 +3641,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
continue; continue;
look_plm(differita ? 12 : m, att); look_plm(differita ? 12 : m, att);
bool is_lim = look_lim(_isdifferita ? m+deltam : m); TRectype lim = get_lim(_isdifferita ? m+deltam : m);
bool is_lim = lim.not_empty();
// Se trattasi di annuale considera solo PLM/PUM del mese 13 // Se trattasi di annuale considera solo PLM/PUM del mese 13
if ((month == 13 && m == 13) || month != 13) if ((month == 13 && m == 13) || month != 13)
@ -3740,8 +3765,9 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
*/ */
if (attc == 0 && is_lim && m < 13 && is_month_ok_strict(m,month)) if (attc == 0 && is_lim && m < 13 && is_month_ok_strict(m,month))
{ {
const real rimborso_richiesto = _lim->get_real("R1"); const real rimborso_richiesto = lim.get_real("R1");
risultato += rimborso_richiesto;
risultato += rimborso_richiesto;
rimborsi += rimborso_richiesto; rimborsi += rimborso_richiesto;
res_debt += rimborso_richiesto; res_debt += rimborso_richiesto;
} }
@ -3754,12 +3780,13 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
const bool somma_rettifiche = month < 13 || m < 13; // CM00278 const bool somma_rettifiche = month < 13 || m < 13; // CM00278
if (somma_rettifiche) if (somma_rettifiche)
{ {
const real rett = _lim->get_real("R5"); const real rett = lim.get_real("R5");
if (!rett.is_zero())
if (rett.not_zero())
{ {
risultato += rett; risultato += rett;
rettifiche += rett; rettifiche += rett;
if (rett.sign() < 0) if (rett < ZERO)
res_cred -= rett; res_cred -= rett;
else else
res_debt += rett; res_debt += rett;
@ -3772,20 +3799,23 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
*/ */
if (attc == 0 && is_lim && m < 13 && is_month_ok_strict(m,month)) if (attc == 0 && is_lim && m < 13 && is_month_ok_strict(m,month))
{ {
const real r17 = _lim->get_real("R17"); const real r17 = lim.get_real("R17");
variazioni_imposta += r17; variazioni_imposta += r17;
risultato += r17; risultato += r17;
if (r17.sign() >= 0) if (r17 >= ZERO)
res_debt += r17; res_debt += r17;
else else
res_cred -= r17; res_cred -= r17;
const real r18 = _lim->get_real("R18"); const real r18 = lim.get_real("R18");
imposta_non_versata += r18; imposta_non_versata += r18;
risultato += r18; risultato += r18;
res_debt += r18; res_debt += r18;
const real r19 = _lim->get_real("R19"); const real r19 = lim.get_real("R19");
crediti_speciali += r19; crediti_speciali += r19;
risultato -= r19; risultato -= r19;
res_cred += r19; res_cred += r19;
@ -3841,6 +3871,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
} // end ciclo su attivita' } // end ciclo su attivita'
real credito_utilizzabile = ZERO; real credito_utilizzabile = ZERO;
const bool utilizza_credito_autorizzato = lia.get_bool("B6");
if (month < 13) // va bene anche se differita sommando deltam (che e' 0 normalmente) if (month < 13) // va bene anche se differita sommando deltam (che e' 0 normalmente)
{ {
@ -3853,17 +3884,35 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
risultato += debt_precd; risultato += debt_precd;
res_debt += debt_precd; res_debt += debt_precd;
if (new_age_2000 && credito_utilizzabile_inizio_anno > ZERO &&
(_freqviva == "M" || is_trim(month+deltam))) if (credito_compensabile && credito_utilizzabile_inizio_anno > ZERO &&
(_freqviva == "M" || is_trim(month + deltam)))
{ {
real debiti = res_debt; round_imposta(debiti); real debiti = res_debt; round_imposta(debiti);
real crediti = res_cred; round_imposta(crediti); real crediti = res_cred; round_imposta(crediti);
const real risul = debiti - crediti; const real risul = debiti - crediti;
TRectype lim = get_lim(month+deltam);
const real cred_util_F24 = lim.get_real("R16");
credito_utilizzabile = credito_utilizzabile_inizio_anno;
credito_utilizzabile -= credito_utilizzato(month + deltam);
if (utilizza_credito_autorizzato)
credito_utilizzabile += credito_autorizzato(month + deltam);
credito_utilizzabile -= cred_util_F24;
if (utilizza_credito_autorizzato)
{
const real cred_aut_F24 = lim.get_real("R20");
credito_utilizzabile += cred_aut_F24;
}
if (credito_utilizzabile < ZERO)
credito_utilizzabile = ZERO;
if (risul > ZERO) if (risul > ZERO)
{ {
credito_utilizzabile = credito_utilizzabile_inizio_anno;
credito_utilizzabile -= credito_utilizzato(month+deltam, TRUE, TRUE);
if (credito_utilizzabile < ZERO) credito_utilizzabile = ZERO;
credito_utilizzato_iva = min(risul, credito_utilizzabile); credito_utilizzato_iva = min(risul, credito_utilizzabile);
res_cred += credito_utilizzato_iva; res_cred += credito_utilizzato_iva;
risultato -= credito_utilizzato_iva; risultato -= credito_utilizzato_iva;
@ -3872,18 +3921,19 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
} }
else else
{ {
if (new_age_2000) if (credito_compensabile)
{ {
cred_prec = ZERO; cred_prec = ZERO;
if (credito_utilizzabile_inizio_anno > ZERO) if (credito_utilizzabile_inizio_anno > ZERO)
{ {
credito_utilizzato_iva = credito_utilizzato(13, TRUE, FALSE); // CM00285 credito_utilizzato_iva = credito_utilizzato_IVA(13); // CM00285
res_cred += credito_utilizzato_iva; res_cred += credito_utilizzato_iva;
risultato -= credito_utilizzato_iva; risultato -= credito_utilizzato_iva;
// Calcola credito utilizzabile da riportare nell'anno successivo // Calcola credito utilizzabile da riportare nell'anno successivo
credito_utilizzabile = credito_utilizzabile_inizio_anno; credito_utilizzabile = credito_utilizzabile_inizio_anno;
credito_utilizzabile -= credito_utilizzato(13, TRUE, TRUE); credito_utilizzabile -= credito_utilizzato(13);
credito_utilizzabile += credito_autorizzato(13);
if (credito_utilizzabile < ZERO) if (credito_utilizzabile < ZERO)
credito_utilizzabile = ZERO; credito_utilizzabile = ZERO;
} }
@ -3892,7 +3942,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
{ {
// per l'annuale considera solo il credito a inizio anno // per l'annuale considera solo il credito a inizio anno
cred_prec = credito_prec(_freqviva == "M" ? 1 : 3); cred_prec = credito_prec(_freqviva == "M" ? 1 : 3);
cred_trasf = _lia->get_real("R15"); cred_trasf = lia.get_real("R15");
const real cred_res = cred_prec - cred_trasf; const real cred_res = cred_prec - cred_trasf;
risultato -= cred_res; risultato -= cred_res;
res_cred += cred_res; res_cred += cred_res;
@ -3928,9 +3978,9 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
real es_c1a_am = _pla->get_real("R17"); real es_c1a_am = _pla->get_real("R17");
real csamm = _pla->get_real("R4"); real csamm = _pla->get_real("R4");
real ven_rev = _pla->get_real("R18"); real ven_rev = _pla->get_real("R18");
real prorata = 0.0; real prorata;
real conguaglio = 0.0; real conguaglio;
real topay = 0.0; real topay;
const real ris = vf1 + vf2; // gia' esclusi: NS, B3, cess. amm const real ris = vf1 + vf2; // gia' esclusi: NS, B3, cess. amm
// calcola nuovo prorata dal 1998 per ogni attivita' (miste: 1+2) // calcola nuovo prorata dal 1998 per ogni attivita' (miste: 1+2)
@ -3971,13 +4021,15 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
look_pla(att, true); look_pla(att, true);
_pla->put("R8", prorata); _pla->put("R8", prorata);
_pla->rewrite(); _pla->rewrite();
if (look_lia(0l, true)) TRectype lia = get_lia(0l, true);
if (lia.not_empty())
{ {
real cc = cred_cost; real cc = cred_cost;
round_imposta(cc); round_imposta(cc);
_lia->put("R5", cc); lia.put("R5", cc);
_lia->rewrite(); put_lia(lia);
} }
_year = yr; _year = yr;
// Aggiusta DiffIncIVAAcq sul record della 13ma che non poteva ancora sapere il prorata definitivo! // Aggiusta DiffIncIVAAcq sul record della 13ma che non poteva ancora sapere il prorata definitivo!
@ -3994,12 +4046,13 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
} }
} }
look_lia(); TRectype lia = get_lia();
_lia->put("R1", vol_aff_l);
_lia->put("R2", vol_aff_1); lia.put("R1", vol_aff_l);
_lia->put("R3", vol_aff_2); lia.put("R2", vol_aff_1);
_lia->rewrite(); lia.put("R3", vol_aff_2);
} put_lia(lia);
}
// comprende anche il conguaglio prorata // comprende anche il conguaglio prorata
risultato += tot_cong; risultato += tot_cong;
@ -4016,23 +4069,26 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
res_cred += abs(tot_cong); res_cred += abs(tot_cong);
} }
look_lim(month+deltam,TRUE); TRectype lim = get_lim(month+deltam, true);
// azzeriamo tutto (tranne r1, r5, s1, s0, s7) const TString16 codtab = lim.get("CODTAB");
const TString16 codtab = _lim->get("CODTAB");
real rimborso = _lim->get("R1"); /*
real r5 = _lim->get("R5"); // Rettifiche // azzeriamo tutto (tranne r1, r5, s1, s0, s7)
real credito_utilizzato_f24 = _lim->get("R16"); const real rimborso = _lim->get("R1");
real r17 = _lim->get("R17"); const real r5 = _lim->get("R5"); // Rettifiche
real r18 = _lim->get("R18"); const real credito_utilizzato_f24 = _lim->get("R16");
real r19 = _lim->get("R19"); const real r17 = _lim->get("R17");
TString s7 = _lim->get("S7"); const real r18 = _lim->get("R18");
const real r19 = _lim->get("R19");
const real credito_autorizzato_f24 = _lim->get_real("R20");
const TDate data_autorizzazione = _lim->get_date("D1");
const TString s7 = _lim->get("S7");
const TString s0 = _lim->get("S0"); // Descrizioni rettifiche const TString s0 = _lim->get("S0"); // Descrizioni rettifiche
const TString s1 = _lim->get("S1"); const TString s1 = _lim->get("S1");
const TString s2 = _lim->get("S2"); const TString s2 = _lim->get("S2");
const TString s3 = _lim->get("S3"); const TString s3 = _lim->get("S3");
bool wasb0 = _lim->get_bool("B0"); const bool wasb0 = _lim->get_bool("B0");
bool wasb1 = _lim->get_bool("B1"); const bool wasb1 = _lim->get_bool("B1");
_lim->zero(); _lim->zero();
_lim->put("CODTAB", codtab); _lim->put("CODTAB", codtab);
@ -4042,13 +4098,15 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
_lim->put("R17", r17); _lim->put("R17", r17);
_lim->put("R18", r18); _lim->put("R18", r18);
_lim->put("R19", r19); _lim->put("R19", r19);
_lim->put("R20", credito_autorizzato_f24);
_lim->put("D1", data_autorizzazione);
_lim->put("S0", s0); _lim->put("S0", s0);
_lim->put("S1", s1); _lim->put("S1", s1);
_lim->put("S2", s2); _lim->put("S2", s2);
_lim->put("S3", s3); _lim->put("S3", s3);
_lim->put("S7", s7); _lim->put("S7", s7);
_lim->put("B0", wasb0 ? "X" : ""); _lim->put("B0", wasb0 ? "X" : "");
_lim->put("B1", wasb1 ? "X" : ""); _lim->put("B1", wasb1 ? "X" : ""); */
/* /*
@ -4072,20 +4130,21 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
// se no il conguaglio prorata fa casino // se no il conguaglio prorata fa casino
round_al_centesimo(risultato); round_al_centesimo(risultato);
_lim->put("R0",risultato); lim.put("R0", risultato);
_lim->put("R2",cred_cost); lim.put("R2", cred_cost);
_lim->put("R3",deb_mens); lim.put("R3", deb_mens);
_lim->put("R4",perc_r); lim.put("R4", perc_r);
if (almeno_una_normale) if (almeno_una_normale)
_lim->put("R6",detrazioni); lim.put("R6", detrazioni);
else // per evitare sbagli nei ricalcoli esterni else // per evitare sbagli nei ricalcoli esterni
_lim->put("R6",""); lim.zero("R6");
if (month == 13 || differita) if (month == 13 || differita)
{ {
// Arrotonda totali in quanto possono avere un arrotondamento diverso dal mensile // Arrotonda totali in quanto possono avere un arrotondamento diverso dal mensile
TIva_round ir; TIva_round ir;
ir.round(rimborsi); ir.round(rimborsi);
ir.round(rettifiche); ir.round(rettifiche);
ir.round(variazioni_imposta); ir.round(variazioni_imposta);
@ -4095,19 +4154,19 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
// scrivi totali rettifiche e rimborsi // scrivi totali rettifiche e rimborsi
// nella finale oppure se copiati da // nella finale oppure se copiati da
// anno precedente // anno precedente
_lim->put("R1",rimborsi); lim.put("R1",rimborsi);
_lim->put("R5",rettifiche); lim.put("R5",rettifiche);
_lim->put("R17", variazioni_imposta); lim.put("R17", variazioni_imposta);
_lim->put("R18", imposta_non_versata); lim.put("R18", imposta_non_versata);
_lim->put("R19", crediti_speciali); lim.put("R19", crediti_speciali);
} }
/* /*
* Interessi dovuti solo da trimestrali in periodica, * Interessi dovuti solo da trimestrali in periodica,
* Era anche non benzinari, smentito da Cinzia (MI0853); * Era anche non benzinari, smentito da Cinzia (MI0853);
* Ora gestito esplicitamente nei parametri ditta, forzato * Ora gestito esplicitamente nei parametri ditta, forzato
* FALSE per ditte mensili e liq. annuale * false per ditte mensili e liq. annuale
* Ulteriormente smentito e rettificato * Ulteriormente smentito e rettificato
*/ */
bool true_trim = (month == 3 || month == 6 || month == 9); bool true_trim = (month == 3 || month == 6 || month == 9);
@ -4118,44 +4177,45 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
const real r = risultato - imposta_non_versata; // CM 26-09-2000 const real r = risultato - imposta_non_versata; // CM 26-09-2000
real ivi = r.sign() > 0 ? (r * interesse / CENTO) : ZERO; real ivi = r.sign() > 0 ? (r * interesse / CENTO) : ZERO;
round_al_centesimo(ivi); round_al_centesimo(ivi);
_lim->put("R14", ivi); lim.put("R14", ivi);
} }
//questo serve anche per la visualizzazione e per l'estrazione deleghe //questo serve anche per la visualizzazione e per l'estrazione deleghe
if (_isintr && ( true_trim || (month == 12 && _isbenzinaro && _gest4) if (_isintr && ( true_trim || (month == 12 && _isbenzinaro && _gest4)
|| (month == 13 && !(_isbenzinaro && _gest4)) )) || (month == 13 && !(_isbenzinaro && _gest4)) ))
_lim->put("R10",interesse_trimestrale(_month)); lim.put("R10", interesse_trimestrale(_month));
_lim->put("R7", tot_cong); // totale conguaglio su tutte le attivita' lim.put("R7", tot_cong); // totale conguaglio su tutte le attivita'
_lim->put("R8", versamenti); lim.put("R8", versamenti);
_lim->put("R9", vers_int); lim.put("R9", vers_int);
_lim->put("R11", acc_dec); lim.put("R11", acc_dec);
_lim->put("R12", res_cred); lim.put("R12", res_cred);
_lim->put("R13", res_debt); lim.put("R13", res_debt);
_lim->put("R26", fdiff_imp); // Imponibile IVA diff Fatture di vendita lim.put("R26", fdiff_imp); // Imponibile IVA diff Fatture di vendita
_lim->put("R27", fdiff_iva); // Imposta IVA diff Fatture di vendita lim.put("R27", fdiff_iva); // Imposta IVA diff Fatture di vendita
_lim->put("R28", fdiffinc_imp); // Imponibile IVA diff Incassi lim.put("R28", fdiffinc_imp); // Imponibile IVA diff Incassi
_lim->put("R29", fdiffinc_iva); // Imposta IVA diff Incassi lim.put("R29", fdiffinc_iva); // Imposta IVA diff Incassi
_lim->put("R30", fdiff_imp_acq); // Imponibile IVA diff Fatture di acquisto lim.put("R30", fdiff_imp_acq); // Imponibile IVA diff Fatture di acquisto
_lim->put("R31", fdiff_iva_acq); // Imposta IVA diff Fatture di acquisto lim.put("R31", fdiff_iva_acq); // Imposta IVA diff Fatture di acquisto
_lim->put("R32", fdiffinc_imp_acq); // Imponibile IVA diff Pagamenti lim.put("R32", fdiffinc_imp_acq); // Imponibile IVA diff Pagamenti
_lim->put("R33", fdiffinc_iva_acq); // Imposta IVA diff Pagamenti lim.put("R33", fdiffinc_iva_acq); // Imposta IVA diff Pagamenti
look_lam(month+deltam, true);
_lam->put("R0", iva_vend); _lam->put("R0", iva_vend);
_lam->put("R1", iva_acq); _lam->put("R1", iva_acq);
_lam->put("R2", cred_prec); _lam->put("R2", cred_prec);
_lam->put("R3", debt_precd); _lam->put("R3", debt_precd);
if (!_recalc_only && _recalc != never) if (!_recalc_only && _recalc != never)
_lim->put("B0","X"); lim.put("B0","X");
if (_recalc_only) if (_recalc_only)
_lim->put("B1", "X"); lim.put("B1", "X");
/* Cazzata galattica: vedi sopra /* Cazzata galattica: vedi sopra
if (wasdifferita) _isdifferita = TRUE; if (wasdifferita) _isdifferita = true;
*/ */
// AWFUL! se siamo in annuale, occorre arrotondare alle 1000 lire // AWFUL! se siamo in annuale, occorre arrotondare alle 1000 lire
@ -4223,49 +4283,48 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
_lam->put("R3", debt_precd); _lam->put("R3", debt_precd);
_lam->put("R4", cred_trasf); _lam->put("R4", cred_trasf);
_lim->put("R0", risultato); lim.put("R0", risultato);
_lim->put("R1", rimborsi); lim.put("R1", rimborsi);
_lim->put("R2", cred_cost); lim.put("R2", cred_cost);
_lim->put("R3", deb_mens); lim.put("R3", deb_mens);
_lim->put("R5", rettifiche); lim.put("R5", rettifiche);
_lim->put("R6", detrazioni); lim.put("R6", detrazioni);
_lim->put("R7", tot_cong); lim.put("R7", tot_cong);
_lim->put("R8", versamenti); lim.put("R8", versamenti);
_lim->put("R9", vers_int); lim.put("R9", vers_int);
_lim->put("R11", acc_dec); lim.put("R11", acc_dec);
_lim->put("R12", res_cred); lim.put("R12", res_cred);
_lim->put("R13", res_debt); lim.put("R13", res_debt);
real ivi = _lim->get("R14"); round_imposta(ivi); real ivi = lim.get("R14"); round_imposta(ivi);
_lim->put("R14", ivi); lim.put("R14", ivi);
_lim->put("R15", credito_utilizzato_iva); lim.put("R15", credito_utilizzato_iva);
if (month == 13) if (month == 13)
{ {
// Riporta eventuale credito nella tabella parametri liquidazione dell'anno successivo // Riporta eventuale credito nella tabella parametri liquidazione dell'anno successivo
const real riporto = credito_utilizzabile - risultato; real riporto = credito_utilizzabile - risultato;
if (riporto >= ZERO) // Risultato a credito
{ if (riporto < ZERO)
const int anno_prossimo = atoi(_year) + 1; riporto = ZERO;
if (look_lia(0l, TRUE, anno_prossimo))
{ const int anno_prossimo = atoi(_year) + 1;
_lia->put("R0", riporto); TRectype lia = get_lia(0l, true, anno_prossimo);
_lia->rewrite();
} lia.put("R0", riporto);
} put_lia(lia);
} }
_lim->put("R26", fdiff_imp); lim.put("R26", fdiff_imp);
_lim->put("R27", fdiff_iva); lim.put("R27", fdiff_iva);
_lim->put("R28", fdiffinc_imp); lim.put("R28", fdiffinc_imp);
_lim->put("R29", fdiffinc_iva); lim.put("R29", fdiffinc_iva);
_lim->put("R30", fdiff_imp_acq); lim.put("R30", fdiff_imp_acq);
_lim->put("R31", fdiff_iva_acq); lim.put("R31", fdiff_iva_acq);
_lim->put("R32", fdiffinc_imp_acq); lim.put("R32", fdiffinc_imp_acq);
_lim->put("R33", fdiffinc_iva_acq); lim.put("R33", fdiffinc_iva_acq);
// ciapa // ciapa
} }
put_lim(lim);
_lim->rewrite();
_lam->rewrite(); _lam->rewrite();
} }

View File

@ -16,11 +16,11 @@
#include <nditte.h> #include <nditte.h>
bool TLiquidazione_app::is_trim(int x) bool TLiquidazione_app::is_trim(int x)
// TRUE se il mese passato e' un trimestre // true se il mese passato e' un trimestre
{ return x == 3 || x == 6 || x == 9 || x == 12; } { return x == 3 || x == 6 || x == 9 || x == 12; }
bool TLiquidazione_app::is_month_ok_strict(int x, int month) const bool TLiquidazione_app::is_month_ok_strict(int x, int month) const
// TRUE se il mese passato e' compatibile con il regime // true se il mese passato e' compatibile con il regime
// di liquidazione e (opz) non e' maggiore di quello scelto // di liquidazione e (opz) non e' maggiore di quello scelto
{ {
if (month == -1) month = x; if (month == -1) month = x;
@ -43,7 +43,7 @@ bool TLiquidazione_app::is_month_plain(int x) const
} }
bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const
// TRUE se il mese passato e' compatibile con il mese da calcolare // true se il mese passato e' compatibile con il mese da calcolare
// rispetto al regime di liquidazione scelto // rispetto al regime di liquidazione scelto
{ {
bool ret = x == mtocalc; bool ret = x == mtocalc;
@ -55,7 +55,7 @@ bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const
} }
else if (!ret && mtocalc == 13) else if (!ret && mtocalc == 13)
{ {
// per l'annuale ritorna TRUE per tutti i mesi da liquidare // per l'annuale ritorna true per tutti i mesi da liquidare
ret = x <= 13; ret = x <= 13;
} }
return ret; return ret;
@ -80,7 +80,7 @@ int TLiquidazione_app::next_trim(int x)
bool TLiquidazione_app::is_in_liq_period(const TDate& d) bool TLiquidazione_app::is_in_liq_period(const TDate& d)
{ {
bool ok = FALSE; bool ok = false;
const int y = atoi(_year); const int y = atoi(_year);
if (_freqviva == "M") if (_freqviva == "M")
{ {
@ -110,7 +110,7 @@ int TLiquidazione_app::previous_month(int m) const
} }
bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int year) const bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int year) const
// TRUE se la data passata va considerata nel // true se la data passata va considerata nel
// ricalcolo dei progressivi mensili per il mese e anno // ricalcolo dei progressivi mensili per il mese e anno
// selezionati. Vedi cg4301.cpp per maggiori informazioni // selezionati. Vedi cg4301.cpp per maggiori informazioni
// sul nuovo filtro di selezione movimenti. // sul nuovo filtro di selezione movimenti.
@ -249,7 +249,7 @@ bool TLiquidazione_app::look_pim(int month, const char* codatt, const char* codr
const char* tipocr, const char* codiva, int tipodet, const char* tipocr, const char* codiva, int tipodet,
bool create) bool create)
// ritorna il PIM corrispondente alla chiave passata; se // ritorna il PIM corrispondente alla chiave passata; se
// create = TRUE lo crea se non lo trova. Ritorna se c'era // create = true lo crea se non lo trova. Ritorna se c'era
{ {
_pim_r->zero(); _pim_r->zero();
(*_pim_anno) = _year; (*_pim_anno) = _year;
@ -377,7 +377,7 @@ bool TLiquidazione_app::look_plm(int m, const char* att, bool create)
bool TLiquidazione_app::look_pia(int m, const char* a, const char* cod1, const char* cod2, bool create) bool TLiquidazione_app::look_pia(int m, const char* a, const char* cod1, const char* cod2, bool create)
{ {
bool ok = FALSE; bool ok = false;
(*_pia_codatt) = format("%6s", a); (*_pia_codatt) = format("%6s", a);
(*_pia_mese) = format("%02d",m); (*_pia_mese) = format("%02d",m);
@ -400,7 +400,7 @@ bool TLiquidazione_app::look_pia(int m, const char* a, const char* cod1, const c
bool TLiquidazione_app::look_pum(int m, const char* a, bool create) bool TLiquidazione_app::look_pum(int m, const char* a, bool create)
{ {
bool ok = FALSE; bool ok = false;
_pum->zero(); _pum->zero();
(*_pum_codatt) = format("%6s", a); (*_pum_codatt) = format("%6s", a);
@ -475,26 +475,40 @@ bool TLiquidazione_app::look_pam(int m, const char* a, bool create)
return ok; return ok;
} }
bool TLiquidazione_app::look_lim(int m, bool create) const TRectype & TLiquidazione_app::get_lim(int month, bool create)
{ {
_lim_r->zero(); TString key = _year ; key << format("%02d", month);
(*_lim_mese) = format("%02d",m);
(*_lim_anno) = _year;
const TString8 s = _lim_r->get("CODTAB"); TRectype & lim = (TRectype &) cache().get("LIM", key);
const bool ok = _lim->read() == NOERR;
if (!ok && create) if (lim.empty() && create)
{ {
_lim_r->zero(); TRectype l(lim);
_lim_r->put("CODTAB",s);
_lim->write(); l.put("CODTAB", key);
put_lim(l, false);
} }
// crea o posiziona la tabella gemella LAM // crea o posiziona la tabella gemella LAM
look_lam(m, !ok); // look_lam(m, !ok);
return ok; return (const TRectype &) lim;
}
const int TLiquidazione_app::put_lim(const TRectype & lim, bool re)
{
TTable tablim("LIM");
tablim.curr() = lim;
if (re)
{
const int err = tablim.rewrite();
cache().discard("LIM", lim.get("CODTAB"));
return err;
}
else
return tablim.write();
} }
bool TLiquidazione_app::look_lam(int m, bool create) bool TLiquidazione_app::look_lam(int m, bool create)
@ -552,7 +566,7 @@ bool TLiquidazione_app::look_pla(const char* a, bool create)
bool TLiquidazione_app::look_reg(const char* reg) bool TLiquidazione_app::look_reg(const char* reg)
{ {
TString16 s; s << _year; s << format("%-3s",reg); TString16 s; s << _year; s << format("%-3s",reg);
bool rt = TRUE; bool rt = true;
const bool is_key = _reg_arr.is_key(s); const bool is_key = _reg_arr.is_key(s);
if (is_key) if (is_key)
_reg->curr() = (TRectype&) _reg_arr[s]; _reg->curr() = (TRectype&) _reg_arr[s];
@ -563,7 +577,7 @@ bool TLiquidazione_app::look_reg(const char* reg)
if (_reg->read() == NOERR) if (_reg->read() == NOERR)
_reg_arr.add(s,_reg->curr()); _reg_arr.add(s,_reg->curr());
else else
rt = FALSE; rt = false;
} }
return rt; return rt;
} }
@ -617,7 +631,7 @@ bool TLiquidazione_app::look_del(int month, int type, bool create)
// codici tributo, concessione, conto fiscale anche se la // codici tributo, concessione, conto fiscale anche se la
// delega esiste gia' // delega esiste gia'
// Molto pericoloso chiamare con create = TRUE: // Molto pericoloso chiamare con create = true:
// se e' gia' stata fatta l'estrazione versamenti // se e' gia' stata fatta l'estrazione versamenti
// e l'utente cambia titcf e isdel sull'anagrafica // e l'utente cambia titcf e isdel sull'anagrafica
// sono c... suoi!!! (Maurizio) // sono c... suoi!!! (Maurizio)
@ -643,8 +657,8 @@ bool TLiquidazione_app::look_del(int month, int type, bool create)
if (create) if (create)
{ {
// vedi se titolare conto fiscale // vedi se titolare conto fiscale
bool titcf = FALSE; bool titcf = false;
bool isdel = FALSE; bool isdel = false;
int uffiva; int uffiva;
TString16 key; TString16 key;
@ -765,35 +779,53 @@ bool TLiquidazione_app::look_del(int month, int type, bool create)
return ok; return ok;
} }
bool TLiquidazione_app::look_lia(long ditta, bool create, int year) const TRectype & TLiquidazione_app::get_lia(long ditta, bool create, int year)
{ {
if (year <= 0) year = atoi(_year); if (year <= 0) year = atoi(_year);
if (ditta <= 0l) ditta = get_firm(); if (ditta <= 0l) ditta = get_firm();
TString16 y; y.format("%05ld%04d", ditta, year); TString16 key; key.format("%05ld%04d", ditta, year);
_lia->put("CODTAB", y); TRectype & lia = (TRectype &) cache().get("%LIA", key);
const bool ok = _lia->read() == NOERR;
if (!ok) if (lia.empty())
{ {
_lia->zero(); lia.zero();
_lia->put("CODTAB", y); lia.put("CODTAB", key);
_lia->put("S7", _freqviva); lia.put("S7", _freqviva);
if (create) if (create)
_lia->write(); put_lia(lia, false);
} }
return ok; return (const TRectype &) lia;
} }
const int TLiquidazione_app::put_lia(const TRectype & lia, bool re)
{
TTable tablia("%LIA");
tablia.curr() = lia;
if (re)
{
const int err = tablia.rewrite();
cache().discard("%LIA", lia.get("CODTAB"));
return err;
}
else
return tablia.write();
}
real TLiquidazione_app::result_liq(int month) real TLiquidazione_app::result_liq(int month)
// risultato esatto della liquidazione del mese month, <0 a credito // risultato esatto della liquidazione del mese month, <0 a credito
// > 0 a debito; comprende TUTTI, anche il conguaglio prorata in annuale // > 0 a debito; comprende TUTTI, anche il conguaglio prorata in annuale
{ {
real r;
// ulteriori detrazioni, acconti, versamenti, // ulteriori detrazioni, acconti, versamenti,
// rettifiche, conguagli sono gia' compresi in R0 // rettifiche, conguagli sono gia' compresi in R0
if (look_lim(month)) const TRectype & lim = get_lim(month);
r = _lim->get_real("R0");
return r; return lim.get_real("R0");
} }
real TLiquidazione_app::iva_da_riportare(int month) real TLiquidazione_app::iva_da_riportare(int month)
@ -818,12 +850,9 @@ real TLiquidazione_app::debt_prec(int month)
real r; real r;
if (!is_first_month(month)) if (!is_first_month(month))
{ {
if (look_lim(previous_month(month))) r = result_liq(previous_month(month));
{ if (!(r > ZERO && r < iva_da_riportare(month)))
r = result_liq(previous_month(month)); r = ZERO;
if (!(r > ZERO && r < iva_da_riportare(month)))
r = ZERO;
}
} }
return r; return r;
} }
@ -836,43 +865,29 @@ real TLiquidazione_app::credito_prec(int month)
if (!(_freqviva =="M" || is_trim(month))) // Aggiunto il 10/11/2014 if (!(_freqviva =="M" || is_trim(month))) // Aggiunto il 10/11/2014
return c; return c;
const bool lia_ok = look_lia(); if (is_first_month(month)) // credito inizio anno
const bool credito_visibile = _lia->get("S9") != "NV"; {
const TRectype & lia = get_lia();
const bool credito_compensabile = (lia.get("S9") == "CM");
if (is_first_month(month)) c = lia.get_real("R0");
{ if (credito_compensabile)
// credito inizio anno {
if (lia_ok) const real cred_util = lia.get_real("R15");
{
// Dal 2000 se S9="NV" il credito precedente non esiste piu'
if (credito_visibile)
c = _lia->get_real("R0");
}
// e' positivo o 0
}
else
{
c = result_liq(previous_month(month));
if (c < ZERO)
c = -c;
else
c = ZERO;
// Dal 2000 se S9="NV" il credito trasferito non esiste piu' c -= cred_util;
if (credito_visibile) }
{ if (c < ZERO)
// Nel caso di trimestrali considera dal trimestre corrispondente a c = ZERO;
// quello impostato+1. Ad es. se m == 1 considera dal I trim. (m=3) }
// se m == 2 idem (m=3). Se m == 3 considera dal II trim. (m=6). else
const int crm = _lia->get_int("I0") + 1; {
if (lia_ok && crm > 1) // Vale dal mese successivo a quello impostato c = result_liq(previous_month(month));
{ if (c < ZERO)
// Toglie il Credito Trasferito c = -c;
if (month == liq_month(crm)) else
c -= _lia->get_real("R15"); c = ZERO;
} }
}
}
return c; return c;
} }
@ -885,16 +900,17 @@ real TLiquidazione_app::credito_costo_prec(int month)
if (is_first_month(month) || month == 13) if (is_first_month(month) || month == 13)
{ {
// credito inizio anno // credito inizio anno
if (look_lia()) const TRectype & lia = get_lia();
c = _lia->get_real("R5");
c = lia.get_real("R5");
} }
else else
{ {
if (look_lim(previous_month(month))) const TRectype & lim = get_lim(previous_month(month));
// qui il rimborso non c'e'
c = _lim->get_real("R2"); c = lim.get_real("R2"); // qui il rimborso non c'e'
} }
look_lim(month); // look_lim(month);
return c; return c;
} }
@ -957,13 +973,11 @@ void TLiquidazione_app::round_al_centesimo(real& d) const
// Analogamente per l'anno // Analogamente per l'anno
bool TLiquidazione_app::is_acconto_differito(long firm, int year) bool TLiquidazione_app::is_acconto_differito(long firm, int year)
{ {
bool diff = false;
const long d = (firm <= 0) ? _nditte->curr().get_long(NDT_CODDITTA) : firm; const long d = (firm <= 0) ? _nditte->curr().get_long(NDT_CODDITTA) : firm;
const int y = (year <= 0) ? atoi(_year) : year; const int y = (year <= 0) ? atoi(_year) : year;
if (look_lia(d, y > 0, y)) // 26/03/2012 aggiunto ,y) const TRectype & lia = get_lia(d, y > 0, y); // 26/03/2012 aggiunto ,y)
diff = _lia->get_bool("B1");
return diff; return lia.get_bool("B1");
} }
real TLiquidazione_app::aliquota_agvia() real TLiquidazione_app::aliquota_agvia()
@ -1013,7 +1027,7 @@ bool TLiquidazione_app::look_conc(TString& uffcon, TString& uffiva)
const TRectype comuni = cache().get(LF_COMUNI, key); const TRectype comuni = cache().get(LF_COMUNI, key);
if (comuni.empty()) return FALSE; if (comuni.empty()) return false;
const int uffa = comuni.get_int("UFFCONC"); const int uffa = comuni.get_int("UFFCONC");
if (uffcon.empty()) if (uffcon.empty())
@ -1028,23 +1042,47 @@ bool TLiquidazione_app::look_conc(TString& uffcon, TString& uffiva)
return true; return true;
} }
real TLiquidazione_app::credito_utilizzato(int month, bool iva, bool f24) const const real TLiquidazione_app::credito_utilizzato_F24(int month) const
{ {
real credito; real credito;
TString16 cod;
TTable lim("LIM"); for (int m = 1; (m < month && m < 13); m++)
TString16 cod;
for (int m = 1; m <= month; m++)
{ {
cod.format("%s%02d", (const char*)_year, m); cod.format("%s%02d", (const char*)_year, m);
lim.put("CODTAB", cod); const TRectype & lim = cache().get("LIM", cod);
if (lim.read() == NOERR)
{ credito += lim.get_real("R16"); // Credito utilizzato F24
if (iva && m < month) }
credito += lim.get_real("R15"); // Credito utilizzato IVA return credito;
if (f24 && m < 13) }
credito += lim.get_real("R16"); // Credito utilizzato F24
} const real TLiquidazione_app::credito_utilizzato_IVA(int month) const
{
real credito;
TString16 cod;
for (int m = 1; m < month; m++)
{
cod.format("%s%02d", (const char*)_year, m);
const TRectype & lim = cache().get("LIM", cod);
credito += lim.get_real("R15"); // Credito utilizzato IVA
}
return credito;
}
const real TLiquidazione_app::credito_autorizzato(int month) const
{
real credito;
TString16 cod;
for (int m = 1; m < month; m++)
{
cod.format("%s%02d", (const char*)_year, m);
const TRectype & lim = cache().get("LIM", cod);
credito += lim.get_real("R20"); // Credito autorizzato F24
} }
return credito; return credito;

View File

@ -611,9 +611,10 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
if (rimborsami && is_month_ok_strict(month)) if (rimborsami && is_month_ok_strict(month))
{ {
look_lim(month); TRectype lim = get_lim(month);
_lim->put("B2", "X");
_lim->rewrite(); lim.put("B2", "X");
put_lim(lim);
} }
return d; return d;
} }

View File

@ -33,7 +33,7 @@ void TLiquidazione_app::set_page(int file, int cnt)
{ {
_DescrItem& d = (_DescrItem&)_descr_arr[cnt]; _DescrItem& d = (_DescrItem&)_descr_arr[cnt];
set_auto_ff(FALSE); set_auto_ff(false);
reset_print(); reset_print();
switch(d._flags) switch(d._flags)
@ -194,30 +194,32 @@ void TLiquidazione_app::describe_liqacc()
{ {
if (!_isprint || !_canprint) return; if (!_isprint || !_canprint) return;
if (!look_lia()) return; const TRectype & lia = get_lia();
if (_lia->get("S8") != "A") return; if (lia.not_empty() && lia.get("S8") == "A")
{
_DescrItem* d = new _DescrItem(LIQACC); _DescrItem* d = new _DescrItem(LIQACC);
d->_r0 = _lia->get_real("R7"); d->_r0 = lia.get_real("R7");
d->_r1 = _lia->get_real("R13"); d->_r1 = lia.get_real("R13");
d->_r2 = _lia->get_real("R14"); d->_r2 = lia.get_real("R14");
d->_r3 = _lia->get_real("R9"); d->_r3 = lia.get_real("R9");
d->_r4 = _lia->get_real("R10"); d->_r4 = lia.get_real("R10");
d->_r5 = _lia->get_real("R8"); d->_r5 = lia.get_real("R8");
d->_r6 = _lia->get_real("R12"); d->_r6 = lia.get_real("R12");
d->_r7 = _lia->get_real("R11"); d->_r7 = lia.get_real("R11");
d->_r8 = _lia->get_real("R4"); d->_r8 = lia.get_real("R4");
d->_r29 = _lia->get_real("R29"); d->_r29 = lia.get_real("R29");
d->_r33 = _lia->get_real("R33"); d->_r33 = lia.get_real("R33");
TToken_string ff(_lia->get("S1"),'!'); TToken_string ff(lia.get("S1"),'!');
real cre_pre (ff.get(0)); real cre_pre (ff.get(0));
real acq_intr (ff.get(1)); real acq_intr (ff.get(1));
d->_r9 = cre_pre; d->_r9 = cre_pre;
d->_r10 = acq_intr; d->_r10 = acq_intr;
_descr_arr.add(d); _descr_arr.add(d);
}
} }
void TLiquidazione_app::describe_plafond(int month, const char* codatt) void TLiquidazione_app::describe_plafond(int month, const char* codatt)
@ -430,63 +432,66 @@ void TLiquidazione_app::describe_agricolo(int month, const char* codatt)
void TLiquidazione_app::describe_viaggio(int month, const char* codatt) void TLiquidazione_app::describe_viaggio(int month, const char* codatt)
{ {
if (!look_lim(month)) return; const TRectype & lim = get_lim(month);
_DescrItem* d = new _DescrItem(REGVIA); if (lim.not_empty())
{
_DescrItem* d = new _DescrItem(REGVIA);
for (int mese = month == 13 ? 13 : 1; mese <= month; mese++) for (int mese = month == 13 ? 13 : 1; mese <= month; mese++)
{ {
if (!is_month_ok(mese,month) || !look_plm(mese, codatt)) if (!is_month_ok(mese,month) || !look_plm(mese, codatt))
continue; continue;
d->_r0 += _plm->get_real("R5"); // corrispettivi CEE d->_r0 += _plm->get_real("R5"); // corrispettivi CEE
d->_r1 += _plm->get_real("R9"); // corrispettivi misti CEE d->_r1 += _plm->get_real("R9"); // corrispettivi misti CEE
d->_r2 += _plm->get_real("R6"); // corrispettivi fuori CE d->_r2 += _plm->get_real("R6"); // corrispettivi fuori CE
d->_r3 += _plm->get_real("R7"); // acquisti CEE d->_r3 += _plm->get_real("R7"); // acquisti CEE
d->_r4 += _plm->get_real("R10"); // acquisti misti parte CEE d->_r4 += _plm->get_real("R10"); // acquisti misti parte CEE
d->_r5 += _plm->get_real("R8"); // acquisti fuori CEE d->_r5 += _plm->get_real("R8"); // acquisti fuori CEE
d->_r6 += _plm->get_real("R11"); // acquisti misti parte fuori CEE d->_r6 += _plm->get_real("R11"); // acquisti misti parte fuori CEE
} }
// credito di costo precedente (CHECK annuale) // credito di costo precedente (CHECK annuale)
d->_r8 = credito_costo_prec(month); d->_r8 = credito_costo_prec(month);
// Solita minchiatina dell'arrotondamento alle 1000 lirette se siamo in annuale // Solita minchiatina dell'arrotondamento alle 1000 lirette se siamo in annuale
if (month == 13 || atoi(_year) >= 2000) // CM500314 e CM500315 if (month == 13 || atoi(_year) >= 2000) // CM500314 e CM500315
{ {
round_imposta(d->_r0); round_imposta(d->_r0);
round_imposta(d->_r1); round_imposta(d->_r1);
round_imposta(d->_r2); round_imposta(d->_r2);
round_imposta(d->_r3); round_imposta(d->_r3);
round_imposta(d->_r4); round_imposta(d->_r4);
round_imposta(d->_r5); round_imposta(d->_r5);
round_imposta(d->_r6); round_imposta(d->_r6);
round_imposta(d->_r8); round_imposta(d->_r8);
} }
d->_r7 = d->_r4.is_zero() ? ZERO : (d->_r4 * CENTO)/(d->_r4 + d->_r6); d->_r7.round(2); // percentuale 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; d->_r9 = (d->_r1 * d->_r7)/CENTO;
if (month == 13) if (month == 13)
round_imposta(d->_r9); round_imposta(d->_r9);
else else
round_al_centesimo(d->_r9); round_al_centesimo(d->_r9);
// Calcola l'iva a debito, visto che servira' anche nel calcolo liquidazione (solo annuale) // Calcola l'iva a debito, visto che servira' anche nel calcolo liquidazione (solo annuale)
const real aliva = aliquota_agvia(); const real aliva = aliquota_agvia();
const real alcnt = aliva + CENTO; const real alcnt = aliva + CENTO;
d->_r10 = (d->_r0 + d->_r9) - (d->_r3 + d->_r4 + d->_r8); // base imponibile lorda d->_r10 = (d->_r0 + d->_r9) - (d->_r3 + d->_r4 + d->_r8); // base imponibile lorda
if (d->_r10.sign() > 0) if (d->_r10.sign() > 0)
{ {
// d->_r11 = (d->_r10/(alcnt/CENTO)) * (aliva/CENTO); // iva dovuta // d->_r11 = (d->_r10/(alcnt/CENTO)) * (aliva/CENTO); // iva dovuta
d->_r11 = d->_r10 * aliva / alcnt; // iva dovuta d->_r11 = d->_r10 * aliva / alcnt; // iva dovuta
if (month == 13) if (month == 13)
round_imposta(d->_r11); round_imposta(d->_r11);
else else
round_al_centesimo(d->_r11); round_al_centesimo(d->_r11);
} }
_descr_arr.add(d); _descr_arr.add(d);
}
} }
void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool describe_pis) void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool describe_pis)
@ -1216,101 +1221,111 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem*
if (!_isprint || !_canprint) if (!_isprint || !_canprint)
return; return;
if (!look_lim(month)) const TRectype & lim = get_lim(month);
return;
_DescrItem* d = new _DescrItem(THE_END); if (lim.not_empty())
{
_DescrItem* d = new _DescrItem(THE_END);
// gli diamo la stessa struttura di LIM // gli diamo la stessa struttura di LIM
d->_r0 = _lim->get_real("R0"); // Risultato d->_r0 = lim.get_real("R0"); // Risultato
d->_r1 = _lim->get_real("R1"); // Rimborso d->_r1 = lim.get_real("R1"); // Rimborso
d->_r2 = _lim->get_real("R2"); d->_r2 = lim.get_real("R2");
d->_r3 = _lim->get_real("R3"); d->_r3 = lim.get_real("R3");
d->_r4 = _lim->get_real("R4"); d->_r4 = lim.get_real("R4");
d->_r5 = _lim->get_real("R5"); // rettifiche d->_r5 = lim.get_real("R5"); // rettifiche
d->_r6 = _lim->get_real("R6"); d->_r6 = lim.get_real("R6");
d->_r7 = _lim->get_real("R14"); d->_r7 = lim.get_real("R14");
d->_r9 = _lim->get_real("R9"); d->_r9 = lim.get_real("R9");
d->_r29 = _lim->get_real("R29"); // fdiffinc_iva_ven d->_r29 = lim.get_real("R29"); // fdiffinc_iva_ven
d->_r33 = _lim->get_real("R33"); // fdiffinc_iva_acq d->_r33 = lim.get_real("R33"); // fdiffinc_iva_acq
TToken_string tt(80); look_lam(month);
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; TToken_string tt(80);
d->_s1 = _lim->get("R11"); // Acc. dec.
d->_s2 = _lim->get("R12");
d->_s3 = _lim->get("R13");
// descrizione rettifiche tt.add(_lam->get("R0")); // IVA Vendite
if (month < 13) tt.add(_lam->get("R1")); // IVA Acquisti
{ tt.add(_lam->get("R2")); // Credito precedente
d->_s4 = _lim->get("S0"); tt.add(_lam->get("R3")); // Debito precedente
d->_s5 = _lim->get("S1"); tt.add(_lam->get("R4"));
d->_s6 = _lim->get("S2");
}
d->_r11 = _lim->get_real("R10"); // tasso di interesse (Non arrotondare!) d->_s0 = tt;
d->_r15 = _lim->get_real("R15"); // Credito utilizzato IVA d->_s1 = lim.get("R11"); // Acc. dec.
d->_r16 = _lim->get_real("R16"); // Credito utilizzato F24 d->_s2 = lim.get("R12");
d->_r17 = _lim->get_real("R17"); // Variazioni d'imposta d->_s3 = lim.get("R13");
d->_r18 = _lim->get_real("R18"); // Imposta non versata
d->_r19 = _lim->get_real("R19"); // Crediti speciali
d->_f1 = is_first_month(month); // descrizione rettifiche
if (month < 13)
{
d->_s4 = lim.get("S0");
d->_s5 = lim.get("S1");
d->_s6 = lim.get("S2");
}
// rispettiamo tutte le casistiche per i versamenti se non siamo in visualizzazione d->_r11 = lim.get_real("R10"); // tasso di interesse (Non arrotondare!)
// analogamente in Visualizzazione ma solo nel caso dell'annuale. d->_r15 = lim.get_real("R15"); // Credito utilizzato IVA
// In tutti gli altri casi va a cercare la delega d->_r16 = lim.get_real("R16"); // Credito utilizzato F24
d->_r8 = (_month == 13 || !_is_visliq) ? _lim->get_real("R8") : versamenti_IVA(_month, "1"); 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
if (_month == 13) d->_d1 = lim.get_date("D1"); // Data autorizzazione
{
const int anno = atoi(_year);
// Credito utilizzato inizio anno (aggiunto 29-07-2014)
if (look_lia(0l, false, anno))
{
if (_lia->get("S6") != "NV")
d->_r15 = _lia->get_real("R15");
}
if (look_lia(0l, false, anno+1)) d->_f1 = is_first_month(month);
d->_r20 = _lia->get_real("R0"); // Credito da riportare all'anno prossimo
}
// aggiunge eventuale satellite per rimborso infraannuale // rispettiamo tutte le casistiche per i versamenti se non siamo in visualizzazione
if (di != NULL) // analogamente in Visualizzazione ma solo nel caso dell'annuale.
{ // In tutti gli altri casi va a cercare la delega
if (d->_r0.sign() < 0) d->_r8 = (_month == 13 || !_is_visliq) ? lim.get_real("R8") : versamenti_IVA(_month, "1");
d->_arr.add(di);
else
delete di;
}
if (!_is_visliq) if (_month == 13)
{ {
_DescrItem* dv = describe_deleghe(month); const int anno = atoi(_year);
if (dv != NULL) d->_arr.add(dv); 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");
_descr_arr.add(d); 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) _DescrItem* TLiquidazione_app::describe_deleghe(int month)
{ {
_stampa_vers = _stampa_acc = FALSE; _stampa_vers = _stampa_acc = false;
if (_lim->get_real("R0") > ZERO) const TRectype & lim = get_lim(month);
if (lim.get_real("R0") > ZERO)
{ {
real iva = _lim->get_real("R0") + _lim->get_real("R14"); real iva = lim.get_real("R0") + lim.get_real("R14");
if (month == 13) if (month == 13)
round_imposta(iva); round_imposta(iva);
if (iva >= iva_da_riportare(_month)) if (iva >= iva_da_riportare(_month))
_stampa_vers = TRUE; _stampa_vers = true;
} }
_stampa_acc = (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4))) _stampa_acc = (month == 12 && (_freqviva == "M" || (_isbenzinaro && _gest4)))
@ -1385,7 +1400,7 @@ void TLiquidazione_app::describe_consistence(const char* codatt)
if (_freqviva == "T" && !_isbenzinaro) if (_freqviva == "T" && !_isbenzinaro)
{ {
bool err = FALSE; bool err = false;
if (_isservizio) err = va > SOGLIA_TRIM_SERVIZI; if (_isservizio) err = va > SOGLIA_TRIM_SERVIZI;
else err = va > SOGLIA_TRIM_ALTRE; else err = va > SOGLIA_TRIM_ALTRE;
if (err) if (err)
@ -1516,7 +1531,7 @@ void TLiquidazione_app::set_att(_DescrItem& d)
{ j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); } { j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); }
} }
if (j) if (j)
set_auto_ff(TRUE); set_auto_ff(true);
} }
void TLiquidazione_app::set_plafond(_DescrItem& d) void TLiquidazione_app::set_plafond(_DescrItem& d)
@ -1535,7 +1550,7 @@ void TLiquidazione_app::set_plafond(_DescrItem& d)
real disponibile = d._r2 + d._r5 + d._r8; real disponibile = d._r2 + d._r5 + d._r8;
real riporto = disponibile - r1 - r2 -r3; real riporto = disponibile - r1 - r2 -r3;
set_print_zero(TRUE); set_print_zero(true);
set_row(1,TR("QUADRO RELATIVO ALLA DISPONIBILITA' ED ALL'UTILIZZO MENSILE DEI PLAFONDS")); set_row(1,TR("QUADRO RELATIVO ALLA DISPONIBILITA' ED ALL'UTILIZZO MENSILE DEI PLAFONDS"));
@ -1556,7 +1571,7 @@ void TLiquidazione_app::set_plafond(_DescrItem& d)
set_row(14,FR("Utilizzato per l'importazione@48g%r"), &(d._r7) ); set_row(14,FR("Utilizzato per l'importazione@48g%r"), &(d._r7) );
set_row(15,FR("@31gRiporto@48g%r"), &(riporto)); set_row(15,FR("@31gRiporto@48g%r"), &(riporto));
set_print_zero(FALSE); set_print_zero(false);
set_auto_ff(); set_auto_ff();
} }
@ -2141,49 +2156,49 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d)
if (!(aqsi.is_zero() && aqsv.is_zero())) if (!(aqsi.is_zero() && aqsv.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Acquisti in sospensione di imposta@50g%r@69g%r"), set_row(row++, FR("Acquisti in sospensione di imposta@50g%r@69g%r"),
&aqsi, &aqsi,
&aqsv); &aqsv);
} }
if (!(vnsi.is_zero() && vnsv.is_zero())) if (!(vnsi.is_zero() && vnsv.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Vendite in sospensione di imposta@50g%r@69g%r"), set_row(row++, FR("Vendite in sospensione di imposta@50g%r@69g%r"),
&vnsi, &vnsi,
&vnsv); &vnsv);
} }
if (!(aqli.is_zero() && aqlv.is_zero())) if (!(aqli.is_zero() && aqlv.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("IVA ad esigibilità differ. da detrarre nel periodo@50g%r@69g%r"), set_row(row++, FR("IVA ad esigibilità differ. da detrarre nel periodo@50g%r@69g%r"),
&aqli, &aqli,
&aqlv); &aqlv);
} }
if (!(vnli.is_zero() && vnlv.is_zero())) if (!(vnli.is_zero() && vnlv.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("IVA ad esigibilità differ. da pagare nel periodo@50g%r@69g%r"), set_row(row++, FR("IVA ad esigibilità differ. da pagare nel periodo@50g%r@69g%r"),
&vnli, &vnli,
&vnlv); &vnlv);
} }
if (!(d._r8.is_zero() && d._r9.is_zero())) if (!(d._r8.is_zero() && d._r9.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Cessione beni ammortizzabili@50g%r@69g%r"), set_row(row++, FR("Cessione beni ammortizzabili@50g%r@69g%r"),
&(d._r8), &(d._r8),
&(d._r9)); &(d._r9));
} }
if (! (d._r4.is_zero() && d._r5.is_zero())) if (! (d._r4.is_zero() && d._r5.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Acquisto beni destinati alla rivendita@50g%r@69g%r"), set_row(row++, FR("Acquisto beni destinati alla rivendita@50g%r@69g%r"),
&(d._r4), &(d._r4),
&(d._r5)); &(d._r5));
} }
if (! (ammindi.is_zero() && ammindv.is_zero())) if (! (ammindi.is_zero() && ammindv.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r"), set_row(row++, FR("Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r"),
&ammindi, &ammindi,
&ammindv); &ammindv);
@ -2197,21 +2212,21 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d)
} }
if (!(d._r6.is_zero() && d._r7.is_zero())) if (!(d._r6.is_zero() && d._r7.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Altri beni strumentali acquisiti in leasing@50g%r@69g%r"), set_row(row++, FR("Altri beni strumentali acquisiti in leasing@50g%r@69g%r"),
&(d._r6), &(d._r6),
&(d._r7)); &(d._r7));
} }
if (!(d._r2.is_zero() && d._r3.is_zero())) if (!(d._r2.is_zero() && d._r3.is_zero()))
{ {
printed = TRUE; printed = true;
// real rn = d._r2 * real(DETRAZIONE_6PERCENTO); // Detrazione obsoleta CM500344 // real rn = d._r2 * real(DETRAZIONE_6PERCENTO); // Detrazione obsoleta CM500344
set_row(row++, FR("Acquisto beni soggetti a detrazione (6%%)" set_row(row++, FR("Acquisto beni soggetti a detrazione (6%%)"
"@50g%r@69g%r"), &(d._r2), &(d._r3)); "@50g%r@69g%r"), &(d._r2), &(d._r3));
} }
if (!(spgn.is_zero() && spgn_iva.is_zero())) if (!(spgn.is_zero() && spgn_iva.is_zero()))
{ {
printed = TRUE; printed = true;
set_row(row++, FR("Spese generali@50g%r@69g%r"), set_row(row++, FR("Spese generali@50g%r@69g%r"),
&spgn, &spgn,
&spgn_iva); &spgn_iva);
@ -2220,7 +2235,7 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d)
int yy = atoi(_year); int yy = atoi(_year);
if (d._f0) if (d._f0)
{ {
printed = TRUE; printed = true;
real prc(dp.get(0)); real prc(dp.get(0));
real rprc = CENTO - prc; real rprc = CENTO - prc;
@ -2277,7 +2292,7 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d)
// form feed // form feed
if (d._f2) if (d._f2)
set_auto_ff(TRUE); set_auto_ff(true);
} }
/* /*
@ -2498,14 +2513,22 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
real rett_cred(0.0); real rett_cred(0.0);
real& interesse = d._r11; real& interesse = d._r11;
real& credito_utilizzato_iva = d._r15; real& credito_utilizzato_IVA = d._r15;
real& credito_utilizzato_f24 = d._r16; real& credito_utilizzato_F24 = d._r16;
real& variazioni_imposta = d._r17; real& variazioni_imposta = d._r17;
real& imposta_non_versata = d._r18; real& imposta_non_versata = d._r18;
real& crediti_speciali = d._r19; real& crediti_speciali = d._r19;
real& credito_autorizzato_F24 = d._r20;
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 utilizza_credito_autorizzato = lia.get_bool("B6");
const bool credito_compensabile = lia.get("S9") == "CM";
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(" @66gCredito@84gDebito")); set_row(rw++,"");
@ -2544,16 +2567,28 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
print_importo(rw++, TR("Imposta non versata"), imposta_non_versata, _is_visliq); print_importo(rw++, TR("Imposta non versata"), imposta_non_versata, _is_visliq);
if (debt_prec > ZERO) if (debt_prec > ZERO)
set_row(rw++,FR("@11gDebito o credito da liquidazione precedente@75g%r"), &debt_prec); {
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 else
{ {
cred_prec -= rimborso;
if (cred_prec > ZERO) if (cred_prec > ZERO)
set_row(rw++,FR("@11gDebito o credito da liquidazione precedente@58g%r"), &cred_prec); set_row(rw++,FR("@11gCredito da liquidazione precedente@58g%r"), &cred_prec);
if (_month < 13 && credito_compensabile && credito_autorizzato_F24 > ZERO)
{
cred_prec -= 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@58g%r"), &credito_utilizzato_IVA);
} }
set_row(rw++,FR("%s@11gRimborsi%s@75g%r"),
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &rimborso);
set_row(rw++, FR("@11gCredito IVA compensabile detratto@58g%r"), &credito_utilizzato_iva);
real cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int; real cre_deb_per = risultato + crediti_speciali + acc_dec + vers_int;
if (_month == 13) cre_deb_per += versamenti; if (_month == 13) cre_deb_per += versamenti;
@ -2588,6 +2623,17 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
if (_is_visliq) rw++; if (_is_visliq) rw++;
const real iva = risultato + interessi; const real iva = risultato + interessi;
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 > ZERO)
{ {
if (iva >= iva_da_riportare(_month)) if (iva >= iva_da_riportare(_month))
@ -2630,6 +2676,52 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
if (d._s6.not_empty()) { set_row(rw++, "@11g%t", &(d._s6)); } 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("@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@75g%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);
}
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("@11gCredito compensabile da liquidazione precedente@58g%r"), &credito_utilizzabile);
if (credito_autorizzato_annuale_F24 > ZERO)
{
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) static void imp2string(const real& n, TString& str)
@ -2737,7 +2829,7 @@ void TLiquidazione_app::set_grand(_DescrItem& d)
{ {
if (!_isregis || (_isregis && !_isfinal)) if (!_isregis || (_isregis && !_isfinal))
{ {
set_print_zero(TRUE); set_print_zero(true);
set_row(rw++,""); set_row(rw++,"");
set_row(rw++,""); set_row(rw++,"");
@ -2838,8 +2930,8 @@ void TLiquidazione_app::set_grand(_DescrItem& d)
} }
} }
if (!_is_visliq) set_auto_ff(TRUE); if (!_is_visliq) set_auto_ff(true);
else set_auto_ff(FALSE); else set_auto_ff(false);
_firm_bookmark = -1; _firm_bookmark = -1;
} }
@ -2884,7 +2976,7 @@ bool TLiquidazione_app::set_annual(_DescrItem& d)
set_row(row++,FR("Totale vendite al fine del calcolo del pro-rata @69g%r"), &vol_aff); set_row(row++,FR("Totale vendite al fine del calcolo del pro-rata @69g%r"), &vol_aff);
set_row(row++,FR("Detraibilità @69g%r%%"), &perc_det); set_row(row++,FR("Detraibilità @69g%r%%"), &perc_det);
set_print_zero(FALSE); set_print_zero(false);
} }
return ret; return ret;
} }
@ -2934,18 +3026,18 @@ void TLiquidazione_app::set_ventila(_DescrItem& d)
set_row(row+i+1,""); set_row(row+i+1,"");
set_row(row+i+2,FR("@10gTotale@41g%r@68g%r@89g%r"), set_row(row+i+2,FR("@10gTotale@41g%r@68g%r@89g%r"),
&t1, &t2, &t3); &t1, &t2, &t3);
set_auto_ff(TRUE); set_auto_ff(true);
} }
static void real2string(const real& r, TString& str) static void real2string(const real& r, TString& str)
{ {
TCurrency cur(r); TCurrency cur(r);
str = cur.string(TRUE); str = cur.string(true);
} }
void TLiquidazione_app::set_regagr(_DescrItem& d) void TLiquidazione_app::set_regagr(_DescrItem& d)
{ {
set_print_zero(TRUE); set_print_zero(true);
real& agr_1 = d._r0; real& agr_1 = d._r0;
real& agr_2 = d._r1; real& agr_2 = d._r1;
@ -3016,7 +3108,7 @@ void TLiquidazione_app::set_regagr(_DescrItem& d)
middle.fill('-',ln); middle.fill('-',ln);
middle << "@" << times_sign << "gx " << pdetr.string("."); middle << "@" << times_sign << "gx " << pdetr.string(".");
middle << " = " << TCurrency(ivadt).string(TRUE); middle << " = " << TCurrency(ivadt).string(true);
set_row(r++, ""); set_row(r++, "");
set_row(r++, "@56g%r", &agr_7); set_row(r++, "@56g%r", &agr_7);
@ -3065,8 +3157,8 @@ void TLiquidazione_app::set_regagr(_DescrItem& d)
set_row(r++,FR("Totale@56g%r@100g%r"),&t1,&t2); set_row(r++,FR("Totale@56g%r@100g%r"),&t1,&t2);
} }
set_auto_ff(TRUE); set_auto_ff(true);
set_print_zero(FALSE); set_print_zero(false);
} }
void TLiquidazione_app::set_viaggio(_DescrItem& d) void TLiquidazione_app::set_viaggio(_DescrItem& d)
@ -3096,7 +3188,7 @@ void TLiquidazione_app::set_viaggio(_DescrItem& d)
real tco = acq_CEE + acq_noCEE + acq_misCEE + acq_misnoCEE; real tco = acq_CEE + acq_noCEE + acq_misCEE + acq_misnoCEE;
real tma = acq_CEE + acq_misCEE; real tma = acq_CEE + acq_misCEE;
set_print_zero(TRUE); set_print_zero(true);
set_bookmark(FR("Prospetto 74 ter"), _att_bookmark); set_bookmark(FR("Prospetto 74 ter"), _att_bookmark);
@ -3235,8 +3327,8 @@ void TLiquidazione_app::set_viaggio(_DescrItem& d)
set_row(29,FR("CREDITO DI COSTO DA RIPORTARE@100g%r"), &bi); set_row(29,FR("CREDITO DI COSTO DA RIPORTARE@100g%r"), &bi);
} }
set_print_zero(FALSE); set_print_zero(false);
set_auto_ff(TRUE); set_auto_ff(true);
} }
void TLiquidazione_app::set_acconto_p(_DescrItem& d) void TLiquidazione_app::set_acconto_p(_DescrItem& d)
@ -3391,6 +3483,6 @@ void TLiquidazione_app::set_deltab(_DescrItem& d, bool iscred)
set_row(rw++, "@8g%-30s", (const char*)rgs.get(i)); set_row(rw++, "@8g%-30s", (const char*)rgs.get(i));
} }
} }
set_auto_ff(TRUE); set_auto_ff(true);
} }

View File

@ -17,410 +17,6 @@
#include "cg4300c.h" #include "cg4300c.h"
#include "cg4800b.h" #include "cg4800b.h"
/*
// -------------------------------------------------- estrazione deleghe
bool TLiquidazione_app::set_deleghe()
{
TMask m("cg4300b.msk");
m.field(FLD_CGB_YEAR).set_handler(ch_year_handler);
m.field(FLD_CGB_YEAR).set(_year);
m.field(CHK_CGB_PRINT).set(_isprint ? "X" : "");
int k = 0;
long j;
_calcall = FALSE;
for (;;)
{
if (k == K_ESC || k == K_QUIT || k == K_ENTER)
break;
k = m.run();
_isprint = m.get_bool(CHK_CGB_PRINT);
switch (k)
{
case DLG_SELECT:
_ditte->run();
for (j = 0l; j < _ditte->items(); j++)
if (_ditte->checked(j)) _selected.set(j);
break;
case BUT_CGB_ALL:
_ditte->check(-1);
for (j = 0l; j < _ditte->items(); j++)
if (_ditte->checked(j) && !_ditte->row_disabled(j))
_selected.set(j);
_calcall = TRUE;
k = K_ENTER;
break;
}
}
if (k == K_ENTER)
{
_year = m.get(FLD_CGB_YEAR);
_month = atoi(m.get(FLD_CGB_MONTH));
}
return k == K_ENTER;
}
bool TLiquidazione_app::extract_deleghe()
{
TString buf(256); TArray desc;
_prind = new TProgind(_calcall ? _n_ditte : _selected.ones(),
TR(" Estrazione deleghe \n"
" preparazione archivi \n "
" \n "),
TRUE,TRUE);
if (_ver->read(atoi(_year),(_month > 12) ? 12 : _month) != NOERR)
warning_box(FR("Errore %d in lettura tabella versamenti ed interessi."),_ver->status());
for (int l = 0; l < _ditte->items(); l++)
{
if (_prind->iscancelled())
break;
if (!(_calcall || _selected[l]) || _ditte->row_disabled(l))
continue;
const long ditta = _ditte->row(l).get_long(1);
TApplication::set_firm(ditta);
TIva_round ir; ir.set_default_iva_mode(atoi(_year), _month > 12, ditta);
_nditte->curr().zero();
_nditte->curr().put("CODDITTA", ditta);
_nditte->read();
// must succeed
look_lia();
_freqviva = _lia->get("S7");
buf.format(FR("Estrazione deleghe (%d):\nditta %s\n "),
_month, (const char*)_nditte_r->get("RAGSOC"));
_prind->set_text(buf);
if (is_month_ok_strict(_month) || _month == 13)
{
const bool mens = _freqviva == "M";
_isbenzinaro = _nditte->curr(LF_ATTIV).get_bool("ART74_4");
_isriepilogo = _month == 13;
_isendliq = _isannual || _isriepilogo;
if (mens || _isbenzinaro || _month!=12)
extract_delega(_month, desc);
}
_prind->addstatus(1);
}
TApplication::set_firm(__firm);
delete _prind;
if (_isprint)
{
_DescrItem* ddeb = NULL;
_DescrItem* dcrd = NULL;
// scorri desc e prepara descritems
for (int i = 0; i < desc.items(); i++)
{
TToken_string& tt = (TToken_string&)desc[i];
real tp(tt.get(3));
if (tp.sign() > 0)
{
if (ddeb == NULL)
{
ddeb = new _DescrItem(DELDEB);
ddeb->_f0 = _month;
}
ddeb->_arr.add(tt);
}
else
{
if (dcrd == NULL)
{
dcrd = new _DescrItem(DELCRED);
dcrd->_f0 = _month;
}
dcrd->_arr.add(tt);
}
}
if (dcrd != NULL) _descr_arr.add(dcrd);
if (ddeb != NULL) _descr_arr.add(ddeb);
}
return TRUE;
}
bool TLiquidazione_app::extract_delega(int month, TArray& desc)
{
const bool has_f24 = main_app().has_module(GVAUT);
TToken_string* tt = NULL;
bool versare = FALSE;
bool skip_print = FALSE;
if (look_lim(month))
{
real topay = result_liq(month); // TBC non si puo' fa' accussi'!!!!! pena il casino!
if (month == 12)
{
if (topay > _ver->get(I_ANNUALE))
versare = TRUE;
}
else if (topay > _ver->get(I_PERIODICO))
versare = TRUE;
real intr = _lim->get_real("R14");
topay += intr; // lo vogliono registrato con interessi
real nrnd = topay;
round_imposta(topay); // importo totale del versamento arrotondato
bool wasdel = look_del(month, 1);
//la stampa deve essere fatta sia se a credito che a debito
if (!topay.is_zero())
{
tt = new TToken_string(80);
tt->add(_nditte->curr().get("CODDITTA"));
tt->add(_nditte->curr().get("RAGSOC"));
tt->add(_freqviva);
tt->add(topay.string());
tt->add("");
}
if (versare)
{
look_del(month, 1, TRUE); //ci mette abi, cab o con
//che legge dall'anagrafica!!!
bool stampato = _del->get_bool("B0");
if (stampato) //se esiste e stampato si richiede conferma aggiornamento
{
if (topay != _del->get_real("R0"))
skip_print = !video_conferma(topay, intr, nrnd); // se non conferma o annulla, salta il tabulato
else
skip_print = true; // Se l'importo e' lo stesso e la delega era gia' stampata, salta il tabulato
}
else //aggiorna importo versamento
{
_del->put("R0",topay);
_del->put("R1",intr);
_del->put("R2",nrnd); // non arrotondato, per calcolo risultato a debito/cr
_del->rewrite();
}
if (has_f24)
{
TLocalisamfile f24(LF_RIGHEF24);
TTable trib("%TRB");
long progr = 0L;
TString descr("IVA annuale");
const bool mensile = _freqviva == "M";
const int codtrib = mensile ? 6000 + month : 6031 + (month / 3);
TDate scad(16, (mensile ? month : ((month + 2) / 3) * 3), atoi(_year));
const long codditta = _nditte->lfile().get_long("CODDITTA");
if (month < 13)
scad.addmonth(mensile ? 1 : 2);
while (scad.wday() > 5)
++scad;
if (month < 13)
{
if (mensile)
descr.format("IVA mese di %s %s", itom(month), (const char *)_year);
else
descr.format("IVA %s Trimestre %s", itor(month / 3 + 1), (const char *)_year);
}
trib.put("CODTAB", codtrib);
if (trib.read() != NOERR)
{
int g = 0, c = 0;
long s = 0;
trib.put("CODTAB", 6001);
if (trib.read(_isgteq) == NOERR)
{
const int cod = trib.get_int("CODTAB");
if (cod > 6000 && cod < 6036)
{
g = trib.get_int("I0");
c = trib.get_int("I1");
s = trib.get_long("I2");
}
}
trib.zero();
trib.put("CODTAB", codtrib);
TString d(descr);
trib.put("S0", d.rtrim(5));
trib.put("S6", "E");
trib.put("I0", g);
trib.put("I1", c);
trib.put("I2", s);
trib.write();
}
f24.setkey(4);
f24.put(F24_TIPOINTEST, "D");
f24.put(F24_INTEST, codditta);
f24.put(F24_ANNO, _year);
f24.put(F24_TRIBUTO, codtrib);
if (f24.read() == NOERR)
{
if (f24.get(F24_DATAVERS).blank() || skip_print)
{
f24.put(F24_IMPORTODEB, topay);
f24.put(F24_INTIVATRIM, intr);
f24.put(F24_DATASCAD, scad);
const int err = f24.rewrite();
if (err != NOERR)
error_box(FR("Ditta %ld\n%s\nerrore %d"), codditta, (const char *) descr, err);
}
}
else
{
f24.setkey(1);
if (f24.last() == NOERR)
progr = f24.get_long(F24_PROGR);
progr++;
f24.zero();
f24.put(F24_PROGR, progr);
f24.put(F24_TRIBUTO, codtrib);
f24.put(F24_TIPOINTEST, "D");
f24.put(F24_INTEST, codditta);
f24.put(F24_DESCR, descr);
f24.put(F24_DATASCAD, scad);
f24.put(F24_ANNO, _year);
f24.put(F24_IMPORTODEB, topay);
f24.put(F24_INTIVATRIM, intr);
const int err = f24.write();
if (err != NOERR)
error_box(FR("Ditta %ld\n%s\nerrore %d"), codditta, (const char *) descr, err);
}
}
tt->add(_del->get("S7"));
tt->add(_del->get("S8"));
tt->add(_del->get("S9"));
tt->add(_nditte->curr().get("PTEL"));
tt->add(_nditte->curr().get("TEL"));
TString desc;
if (_del->get("S9").not_empty())
{
const TRectype & ucc = cache().get("%UCC", _del->get("S9"));
if (!ucc.empty())
desc = ucc.get("S0");
}
if (_del->get("S7").not_empty())
{
TString16 cod;
cod = _del->get("S7");
if (_del->get("S8").not_empty()) cod << _del->get("S8");
const TRectype & ban = cache().get("%BAN", cod);
if (!ban.empty())
desc = ban.get("S0");
}
tt->add(desc);
}
else if (wasdel) //se esiste e no versare
{
bool stampato = _del->get_bool("B0");
TString buf;
buf.format(FR("Il versamento relativo alla ditta %ld e' gia' stato stampato. Si desidera eliminare il flag di stampa definitiva?"),_nditte->lfile().get_long("CODDITTA"));
if (stampato && yesno_box(buf))
{ // Se la delega e' gia' stampata in definitva, chiede se deve eliminare il flag di stampa
_del->put("B0",FALSE);
_del->rewrite();
}
// Se non e' stampata invece visualizza la delega presente su file e l'importo a credito che ha calcolato
// chiedendo cosa fare: Registra elimina fisicamente la delega dal file, Annulla lo fa proseguire
if (!stampato)
video_conferma(topay, intr, nrnd, TRUE);
}
}
if (tt != NULL && !skip_print) // Se il tabulato deve essere stampato per questa delega...
desc.add(tt);
return true;
}
bool TLiquidazione_app::video_conferma(const real& newimp, const real& intr,
const real& narr, bool to_del)
{
TMask m("cg4800b");
m.set_caption(to_del ? TR("Conferma eliminazione") : TR("Estrazione versamenti")); // Modifica il titolo...
m.field(F_CODDITTA).set(_nditte->lfile().get("CODDITTA"));
m.field(F_RAGSOC).set(_nditte->lfile().get("RAGSOC"));
m.field(F_DATAVER).set(_del->get_date("D0"));
m.field(F_ABI).set(_del->get("S7"));
m.field(F_CAB).set(_del->get("S8"));
m.field(F_CON).set(_del->get("S9"));
m.field(F_IMPVER).set(_del->get("R0"));
if (to_del)
{
real xr = abs(newimp);
m.hide(F_NEWIMP);
m.show(F_NEWIMPCRED);m.disable(F_NEWIMPCRED);
m.field(F_NEWIMPCRED).set(xr.string());
}
else
m.field(F_NEWIMP).set(newimp.string());
KEY k;
for (bool stop = FALSE; !stop;)
{
k = m.run();
switch(k)
{
case K_SAVE:
{
k = yesnocancel_box(to_del ?
TR("Si desidera veramente confermare l'eliminazione?")
:
TR("Delega gia' stampata. Si desidera ugualmente confermare l'aggiornamento?"));
if (k == K_YES)
{
if (to_del)
_del->remove();
else
{
_del->put("B0", false);
_del->put("R0",newimp);
_del->put("R1",intr);
_del->put("R2",narr);
_del->rewrite();
}
}
if (k == K_YES || k == K_NO)
stop = TRUE;
}
break;
case K_ESC:
//case K_QUIT:
stop = TRUE;
break;
}
}
return k == K_YES;
}
*/
// -------------------------------------------- calcolo acconto dicembre // -------------------------------------------- calcolo acconto dicembre
bool TLiquidazione_app::set_acconto(real& inf, real& ina) bool TLiquidazione_app::set_acconto(real& inf, real& ina)
@ -513,10 +109,11 @@ bool TLiquidazione_app::recalc_acconti(real& inf, real& ina)
_isbenzinaro = _nditte->curr(LF_ATTIV).get_bool("ART74_4"); _isbenzinaro = _nditte->curr(LF_ATTIV).get_bool("ART74_4");
look_lia(); const TRectype & lia = get_lia();
_freqviva = _lia->get("S7");
inf = _lia->get_real("R13"); _freqviva = lia.get("S7");
ina = _lia->get_real("R14"); inf = lia.get_real("R13");
ina = lia.get_real("R14");
buf.format(FR("Calcolo acconto:\nditta %s"), buf.format(FR("Calcolo acconto:\nditta %s"),
(const char*)_nditte_r->get("RAGSOC")); (const char*)_nditte_r->get("RAGSOC"));
@ -563,11 +160,13 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
const TString4 thyear = _year; const TString4 thyear = _year;
_year.format("%d", atoi(_year)-1); _year.format("%d", atoi(_year)-1);
if (!look_lia()) const TRectype & lia = get_lia();
if (lia.empty())
error = 3; error = 3;
else else
{ {
char ohh = _lia->get_char("S7"); char ohh = lia.get_char("S7");
if (ohh == 'M') history = thh == 'M' ? mm : mt; if (ohh == 'M') history = thh == 'M' ? mm : mt;
if (ohh == 'T') history = thh == 'M' ? tm : tt; if (ohh == 'T') history = thh == 'M' ? tm : tt;
@ -587,69 +186,88 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
const TRectype & atts = cache().get(LF_ATTIV, key); const TRectype & atts = cache().get(LF_ATTIV, key);
if (atts.get_bool("ART74_4")) // e' proprio un gran benzinaro if (atts.get_bool("ART74_4")) // e' proprio un gran benzinaro
history = _lia->get_bool("B4") ? mm : tt; // Was CNF_DITTA->GesT74 history = lia.get_bool("B4") ? mm : tt; // Was CNF_DITTA->GesT74
switch (history) switch (history)
{ {
case mm: case mm:
{
// base calcolo: 12a anno preced, Rideterminare a seconda dell'acconto // base calcolo: 12a anno preced, Rideterminare a seconda dell'acconto
// versato; ris = 88% del debito (0 se credito) // versato; ris = 88% del debito (0 se credito
if (!look_lim(12)) error = 2; const TRectype & lim = get_lim(12);
else
{ if (lim.empty())
bc += _lim->get_real("R0"); error = 2;
real av = _lim->get_real("R11"); else
bc += av; {
} bc += lim.get_real("R0");
const real av = lim.get_real("R11");
bc += av;
}
}
break; break;
case tt: case tt:
case tm: case tm:
// base calcolo: 13a anno precedente. Rideterm. per eventuale acconto {
if (!look_lim(13)) error = 2; // TBC sara' 13a davvero? Secondo me e' 12 // base calcolo: 13a anno precedente. Rideterm. per eventuale acconto
else const TRectype & lim = get_lim(13); // TBC sara' 13a davvero? Secondo me e' 12
{
bc += _lim->get_real("R0"); if (lim.empty())
real av = _lim->get_real("R11"); error = 2;
bc += av; else
} {
if (history == tm) bc += lim.get_real("R0");
// tm come tt ma si divide per 3 la base di calcolo prima di calcolare l'88% const real av = lim.get_real("R11");
divide_by_three = 3.0; bc += av;
}
if (history == tm)
// tm come tt ma si divide per 3 la base di calcolo prima di calcolare l'88%
divide_by_three = 3.0;
}
break; break;
case mt: case mt:
{
// basecalcolo: 10, 11, 12 anno prec., 10 e 11 se a debito, 12 vedi acconto; // basecalcolo: 10, 11, 12 anno prec., 10 e 11 se a debito, 12 vedi acconto;
// sommare e prendi 88% se a debito // sommare e prendi 88% se a debito
if (!look_lim(10)) error = 2; const TRectype & lim10 = get_lim(10);
else const TRectype & lim11 = get_lim(11);
{ const TRectype & lim12 = get_lim(12);
real app = _lim->get_real("R0");
if (app.sign() > 0) //a debito if (lim10.empty())
bc += app; error = 2;
} else
if (!look_lim(11)) error = 2; {
else const real app = lim10.get_real("R0");
{
real app = _lim->get_real("R0"); if (app > ZERO) //a debito
if (app.sign() > 0) //a debito bc += app;
bc += app; }
} if (lim11.empty())
if (!look_lim(12)) error = 2; error = 2;
else else
{ {
bc += _lim->get_real("R0"); const real app = lim11.get_real("R0");
real av = _lim->get_real("R11"); if (app > ZERO) //a debito
bc += av; bc += app;
} }
if (lim12.empty())
error = 2;
else
{
bc += lim12.get_real("R0");
const real av = lim12.get_real("R11");
bc += av;
}
}
break; break;
} }
round_imposta(bc); round_imposta(bc);
if (bc.sign() > 0) //debito if (bc > ZERO) //debito
{ {
acc = ((bc / divide_by_three) * _ver->get(isdifferita ? B_LIQ_DIFF : B_LIQ_NORM))/CENTO; acc = ((bc / divide_by_three) * _ver->get(isdifferita ? B_LIQ_DIFF : B_LIQ_NORM)) / CENTO;
acc.round(TCurrency::get_firm_dec()); acc.round(TCurrency::get_firm_dec());
} }
tipo_acc = "S"; tipo_acc = "S";
} }
_year = thyear; _year = thyear;
@ -663,11 +281,16 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
_recalc = one; _recalc = one;
int need_refresh = FALSE; int need_refresh = FALSE;
for (int mese = 1; mese < _month; mese++) for (int mese = 1; mese < _month; mese++)
if (is_month_ok_strict(mese) && (!look_lim(mese) || !_lim->get_bool("B0"))) if (is_month_ok_strict(mese))
{ {
need_refresh = TRUE; const TRectype & lim = get_lim(mese);
break;
} if (lim.empty() || !lim.get_bool("B0"))
{
need_refresh = true;
break;
}
}
if (need_refresh && yesno_box(FR("Alcuni mesi precedenti non risultano ricalcolati:\n" if (need_refresh && yesno_box(FR("Alcuni mesi precedenti non risultano ricalcolati:\n"
"è consigliabile il ricalcolo. Si desidera eseguirlo?"))) "è consigliabile il ricalcolo. Si desidera eseguirlo?")))
_recalc = ever; _recalc = ever;
@ -681,28 +304,34 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
} }
// calcola l'acconto // calcola l'acconto
if (look_lim(12)) //posiziona anche la tabella lam TRectype lim = get_lim(12);
if (lim.not_empty())
{ {
cre = _lim->get_real("R12"); cre = lim.get_real("R12");
cre -= _lim->get_real("R19"); cre -= lim.get_real("R19");
deb = _lim->get_real("R13") + inf + ina; deb = lim.get_real("R13") + inf + ina;
deb -= _lim->get_real("R18") + _lim->get_real("R1"); // CM600446 deb -= lim.get_real("R18"); // CM600446
deb -= lim.get_real("R1"); // CM600446
if (_lim->get_real("R17") > ZERO) if (lim.get_real("R17") > ZERO)
deb -= _lim->get_real("R17"); deb -= lim.get_real("R17");
else else
cre += _lim->get_real("R17"); cre += lim.get_real("R17");
bc = deb - cre; bc = deb - cre;
if (bc.sign() > 0) acc = bc; if (bc > ZERO)
acc = bc;
look_lam(12); //posiziona anche la tabella lam
iva_ven = _lam->get_real("R0"); //iva sulle vendite annotate fino al 20/12 iva_ven = _lam->get_real("R0"); //iva sulle vendite annotate fino al 20/12
iva_acq = _lam->get_real("R1"); //iva sugli acquisti annotati fino al 20/12 iva_acq = _lam->get_real("R1"); //iva sugli acquisti annotati fino al 20/12
cre_pre = _lam->get_real("R2"); //credito precedente cre_pre = _lam->get_real("R2"); //credito precedente
iva_ret = _lim->get_real("R5"); //rettifica iva_ret = lim.get_real("R5"); //rettifica
iva_rim = _lim->get_real("R1"); //iva chiesta a rimborso iva_rim = lim.get_real("R1"); //iva chiesta a rimborso
ult_det = _lim->get_real("R6"); //ulteriori detrazioni ult_det = lim.get_real("R6"); //ulteriori detrazioni
//iva_pro: //iva relativa alla percentuale di prorata //iva_pro: //iva relativa alla percentuale di prorata
TTable plm ("PLM"); TTable plm ("PLM");
plm.zero(); plm.zero();
@ -736,40 +365,43 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
for (int i = 1; i <= _month; i++) for (int i = 1; i <= _month; i++)
if (is_month_plain(i)) if (is_month_plain(i))
update_firm(i); update_firm(i);
lim.put("B0","");
put_lim(lim);
_lim->put("B0",""); lim = get_lim(13);
_lim->rewrite(); if (lim.not_empty())
if (look_lim(13))
{ {
_lim->put("B0",""); lim.put("B0","");
_lim->rewrite(); put_lim(lim);
} }
//fine //fine
_isprint = TRUE; _isprint = true;
} }
// sbatti l'acconto (e non solo!) in LIA // sbatti l'acconto (e non solo!) in LIA
if (look_lia()) TRectype lia = get_lia();
if (lia.not_empty())
{ {
if (isdifferita && _basecalc == incorso) if (isdifferita && _basecalc == incorso)
{ {
acc *= real(2.0); acc *= real(2.0);
acc /= real(3.0); acc /= real(3.0);
} }
_lia->put("R4",acc); lia.put("R4",acc);
_lia->put("R7",iva_ven); lia.put("R7",iva_ven);
_lia->put("R8",iva_acq); lia.put("R8",iva_acq);
_lia->put("R9",iva_ret); lia.put("R9",iva_ret);
_lia->put("R10",iva_rim); lia.put("R10",iva_rim);
_lia->put("R11",ult_det); lia.put("R11",ult_det);
_lia->put("R12",iva_pro); lia.put("R12",iva_pro);
TToken_string rr("",'!'); TToken_string rr("",'!');
rr.add(cre_pre.string(),0); rr.add(cre_pre.string(),0);
rr.add(acq_intr.string(),1); rr.add(acq_intr.string(),1);
_lia->put("S1",rr); lia.put("S1",rr);
_lia->put("S8",tipo_acc); lia.put("S8",tipo_acc);
_lia->rewrite(); put_lia(lia);
} }
// per questa volta lasciamo perdere la describe_acconto // per questa volta lasciamo perdere la describe_acconto

View File

@ -30,7 +30,6 @@ protected: // Applicat
static bool agrmin_handler(TMask_field& f, KEY k); static bool agrmin_handler(TMask_field& f, KEY k);
static bool credres_handler(TMask_field& f, KEY k); static bool credres_handler(TMask_field& f, KEY k);
static bool credpreccost_handler(TMask_field& f, KEY k); static bool credpreccost_handler(TMask_field& f, KEY k);
static bool utcred_handler(TMask_field& f, KEY k);
protected: // Relapp protected: // Relapp
virtual bool user_create(); virtual bool user_create();
@ -132,18 +131,6 @@ bool TParaliq_app::credres_handler(TMask_field& f, KEY k)
r.round(euro ? m.get_int(F_ROUNDDIC) : -3); r.round(euro ? m.get_int(F_ROUNDDIC) : -3);
f.set(r.string()); f.set(r.string());
} }
if (k == K_ENTER) // In uscita dalla maschera
{
const TMask& m = f.mask();
const short id = f.dlg();
const real r = m.get_real(F_CRED_RES);
const int i = m.get_int(F_MESE_RES_AL);
if (id == F_MESE_RES_AL && r != 0.0 && i == 0)
return f.error_box(TR("Impostare anche il mese."));
if (id == F_CRED_RES && i != 0 && r == 0.0)
return f.error_box(TR("Impostare anche il credito residuo."));
}
return true; return true;
} }
@ -161,46 +148,6 @@ bool TParaliq_app::credpreccost_handler(TMask_field& f, KEY k)
return true; return true;
} }
bool TParaliq_app::utcred_handler(TMask_field& f, KEY k)
{
TMask & m = f.mask();
if ((k == K_TAB && f.focusdirty()) || !m.is_running())
{
const int anno_liq = m.get_int(F_YEAR);
TString80 cod_mesi;
TString des_mesi(128);
TString8 mese;
TList_field& mese_res = m.lfield(F_MESE_RES_AL);
if (anno_liq >= 2000 && !f.get().not_empty())
{
m.field(F_CRED_PREC).set_prompt(TR("Credito compensabile inizio anno "));
m.field(F_CRED_RES).set_prompt(TR("Credito in compensaz.utilizzato "));
m.enable(F_UTCR_IVA);
cod_mesi = "0|-1";
des_mesi = FR(" |Inizio Anno");
mese = !m.field(F_CRED_RES).empty() ? "-1" : "0";
}
else
{
m.field(F_CRED_PREC).set_prompt(TR("Credito precedente "));
m.field(F_CRED_RES).set_prompt(TR("Credito residuo "));
cod_mesi = "0|1|2|3|4|5|6|7|8|9|10|11|12";
des_mesi = FR(" |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
mese = app().rel().lfile().get("I0");
if (!m.edit_mode() || atoi(mese) < 0)
mese.cut(0);
}
const TString16 oldmese = m.get(F_MESE_RES_AL);
mese_res.replace_items(cod_mesi, des_mesi);
if (m.is_running())
m.set(F_MESE_RES_AL, mese);
else
m.set(F_MESE_RES_AL, oldmese);
}
return true;
}
void TParaliq_app::check_registers(int year) void TParaliq_app::check_registers(int year)
{ {
// controlla che per ogni data attività esistano almeno un registro // controlla che per ogni data attività esistano almeno un registro
@ -298,7 +245,6 @@ bool TParaliq_app::user_create()
_msk->set_handler(F_CRED_PREC,credpreccost_handler); _msk->set_handler(F_CRED_PREC,credpreccost_handler);
_msk->set_handler(F_CRED_COST,credpreccost_handler); _msk->set_handler(F_CRED_COST,credpreccost_handler);
_msk->set_handler(F_CODDITTA,ditta_handler); _msk->set_handler(F_CODDITTA,ditta_handler);
_msk->set_handler(F_UTCR_IVA,utcred_handler);
_msk->sfield(F_SHEET_PLA).set_notify(sheet_action); _msk->sfield(F_SHEET_PLA).set_notify(sheet_action);
return true; return true;

View File

@ -16,6 +16,7 @@
#define F_GESIC 216 #define F_GESIC 216
#define F_ICDAL 217 #define F_ICDAL 217
#define F_ICAL 218 #define F_ICAL 218
#define F_UTILAUT 219
#define F_ROUNDLIQ 221 #define F_ROUNDLIQ 221
#define F_ROUNDDIC 222 #define F_ROUNDDIC 222

View File

@ -107,8 +107,8 @@ BOOLEAN F_GESIC
BEGIN BEGIN
PROMPT 4 7 "Gestione IVA per cassa" PROMPT 4 7 "Gestione IVA per cassa"
FIELD B5 FIELD B5
MESSAGE false DISABLE,F_ICDAL|DISABLE,F_ICAL MESSAGE FALSE DISABLE,F_ICDAL|DISABLE,F_ICAL
MESSAGE true ENABLE,F_ICDAL|ENABLE,F_ICAL MESSAGE TRUE ENABLE,F_ICDAL|ENABLE,F_ICAL
MODULE IC MODULE IC
END END
@ -128,6 +128,12 @@ BEGIN
MODULE IC MODULE IC
END END
BOOLEAN F_UTILAUT
BEGIN
PROMPT 4 8 "Riutilizza il credito autorizzato in IVA"
FIELD B6
END
GROUPBOX DLG_NULL 78 6 GROUPBOX DLG_NULL 78 6
BEGIN BEGIN
PROMPT 1 10 "@bCredito" PROMPT 1 10 "@bCredito"
@ -136,7 +142,7 @@ END
CURRENCY F_CRED_COST 18 CURRENCY F_CRED_COST 18
BEGIN BEGIN
PROMPT 4 11 "Credito di costo " PROMPT 4 11 "Credito di costo "
HELP "Eventuale credito di costo dell'anno precedente" HELP "Eventuale credito di costo dell'anno precedente"
FIELD R5 FIELD R5
DRIVENBY F_CODVAL DRIVENBY F_CODVAL
@ -144,15 +150,18 @@ END
LISTBOX F_UTCR_IVA 2 34 LISTBOX F_UTCR_IVA 2 34
BEGIN BEGIN
PROMPT 4 12 "Utilizzo credito IVA " PROMPT 4 12 "Utilizzo credito IVA "
ITEM " |Visibile e utilizzato solo in IVA" ITEM " |Utilizzato solo in IVA"
ITEM "NV|Non visibile ma compensabile" MESSAGE CLEAR,F_CRED_RES
ITEM "CM|Compensabile con altre imposte"
MESSAGE ENABLE,F_CRED_RES
FIELD S9 FIELD S9
END END
CURRENCY F_CRED_PREC 18 CURRENCY F_CRED_PREC 18
BEGIN BEGIN
PROMPT 4 13 "Credito compensabile inizio anno " PROMPT 4 13 "Credito IVA inizio anno "
HELP "Eventuale credito di imposta dell'anno precedente" HELP "Eventuale credito di imposta dell'anno precedente"
FIELD R0 FIELD R0
DRIVENBY F_CODVAL DRIVENBY F_CODVAL
@ -160,20 +169,13 @@ END
CURRENCY F_CRED_RES 18 CURRENCY F_CRED_RES 18
BEGIN BEGIN
PROMPT 4 14 "Credito in compensaz.utilizzato " PROMPT 4 14 "Credito IVA utilizzato a Gennaio "
FIELD R15 FIELD R15
DRIVENBY F_CODVAL DRIVENBY F_CODVAL
NUM_EXPR #THIS<=#F_CRED_PREC NUM_EXPR #THIS<=#F_CRED_PREC
WARNING "L'importo non puo' essere maggiore del Credito Precedente" WARNING "L'importo non puo' essere maggiore del Credito Precedente"
END END
LISTBOX F_MESE_RES_AL 2 14
BEGIN
PROMPT 57 14 "A "
ITEM "0|"
FIELD I0
END
SPREADSHEET F_SHEET_PLA 78 SPREADSHEET F_SHEET_PLA 78
BEGIN BEGIN
PROMPT 1 16 "Parametri attività" PROMPT 1 16 "Parametri attività"

View File

@ -1,10 +1,13 @@
#include <browfile.h> #include <browfile.h>
#include <colors.h>
#include <defmask.h>
#include <execp.h> #include <execp.h>
#include <msksheet.h> #include <msksheet.h>
#include <mailbox.h> #include <mailbox.h>
#include <progind.h> #include <progind.h>
#include <relation.h> #include <relation.h>
#include <recarray.h> #include <recarray.h>
#include <reprint.h>
#include <sheet.h> #include <sheet.h>
#include <viswin.h> #include <viswin.h>
@ -115,7 +118,6 @@ bool Visliq_app::ch_year_handler(TMask_field& f, KEY key)
return true; return true;
} }
void Visliq_app::build_ditte_sheet() void Visliq_app::build_ditte_sheet()
{ {
// build sheet // build sheet
@ -249,6 +251,10 @@ const char* Visliq_app::link_handler(TMask& m,
{ group = -7; firstfoc = F_IMPNONVER; } { group = -7; firstfoc = F_IMPNONVER; }
if (st.find(TR("Crediti")) >= 0) if (st.find(TR("Crediti")) >= 0)
{ group = -8; firstfoc = F_CREDSPEC; } { group = -8; firstfoc = F_CREDSPEC; }
if (st.find(TR("Credito IVA compensabile detratto in F24")) >= 0)
{ group = -9; firstfoc = F_CREDUTIL; }
if (st.find(TR("Credito IVA autorizzato in F24")) >= 0)
{ group = -10; firstfoc = F_CREDAUT; }
m.show(group); m.show(group);
if (app()._is_annual && (group != -3 || app()._freqviva == "M")) if (app()._is_annual && (group != -3 || app()._freqviva == "M"))
@ -343,6 +349,34 @@ bool Visliq_app::set_ragsoc(TMask_field& f, KEY k)
return found; return found;
} }
void Visliq_app::print()
{
TReport_book book("Stampa prospetti liquidazione");
TProgram_report rep;
rep.load("cg5500a");
TRecordset* r = rep.recordset();
TString key ; key.format("%05ld%04d", get_firm(), year());
TString key1; key1 << "\"" << key << "\"";
r->set_var("#FILTER", key1, true);
r->set_var("#ANNO", TVariant((long)year()), true);
book.add(rep);
rep.load("cg5500b");
r = rep.recordset();
r->set_var("#FILTER", key, true);
r->set_var("#ANNO", TVariant((long)year()), true);
book.add(rep);
book.print_or_preview();
}
bool Visliq_app::print_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
app().print();
return true;
}
bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k) bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k)
{ {
@ -372,13 +406,14 @@ bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k)
else else
ok = true; ok = true;
TMask& sm = sh.sheet_mask(); TMask& sm = sh.sheet_mask();
if (ok) if (ok)
{ {
if (sm.is_running()) sm.stop_run(K_ENTER); if (sm.is_running()) sm.stop_run(K_ENTER);
app().vis_one(month); app().vis_one(month);
const bool non_vis_ma_comp = app()._lia->get("S9") == "NV"; const bool compensabile = app()._lia->get("S9") == "CM";
if (non_vis_ma_comp) if (compensabile)
app().read_general(m); app().read_general(m);
} }
@ -412,6 +447,33 @@ bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k)
return true; return true;
} }
bool Visliq_app::enable_date(TMask_field& f, KEY k)
{
if (k == K_TAB && (f.focusdirty()|| !f.mask().is_running()))
{
const bool enable = f.mask().get(104).full() || f.mask().get(109).full();
f.mask().enable(110, enable);
if (!enable)
f.mask().set(110, "");
}
return true;
}
bool Visliq_app::check_date(TMask_field& f, KEY k)
{
if (k == K_TAB && (f.focusdirty()|| !f.mask().is_running()))
{
const TDate d(f.get());
const int row = f.mask().get_sheet()->selected();
if (d.year() != app().year())
return f.error_box(FR("L'anno deve essere %d"), app().year());
if (d.month() != row + 1)
return f.error_box(FR("Il mese deve essere %s"), itom(row + 1));
}
return true;
}
bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k) bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k)
{ {
@ -445,14 +507,14 @@ bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k)
{ {
if (sv.is_running()) sv.stop_run(K_ENTER); if (sv.is_running()) sv.stop_run(K_ENTER);
app().vis_one(month); app().vis_one(month);
const bool new_age_2000 = (app()._year >= 2000) && (app()._lia->get("S9") == "NV"); const bool compensabile = app()._lia->get("S9") == "CM";
if (new_age_2000) if ((app()._year >= 2000) && compensabile)
app().read_general(m); app().read_general(m);
} }
app().set_vers_rows(sh); app().set_vers_rows(sh);
if (app().look_del(month, /* sel == (sh.items() - 1) ? 7 : */ 1)) if (app().look_del(month, 1))
{ {
TToken_string& tv = sh.row(sel); TToken_string& tv = sh.row(sel);
tv.add(app().del()->get("D0"),1); tv.add(app().del()->get("D0"),1);
@ -528,24 +590,33 @@ bool Visliq_app::vis_all()
// qui occorre modificare le deleghe // qui occorre modificare le deleghe
sv.set_notify(vers_action); sv.set_notify(vers_action);
sh.sheet_mask().set_handler(100,sel_mese_sh1); _mask->set_handler(DLG_PRINT, print_handler);
sv.sheet_mask().set_handler(100,sel_mese_sh2); sh.sheet_mask().set_handler(100, sel_mese_sh1);
sh.sheet_mask().set_handler(104, enable_date);
sh.sheet_mask().set_handler(109, enable_date);
sh.sheet_mask().set_handler(110, check_date);
sv.sheet_mask().set_handler(100, sel_mese_sh2);
const bool new_print_2000 = true; // _year >= 2000; const bool new_print_2000 = true; // _year >= 2000;
const bool new_age_2000 = _lia->get("S9") == "NV"; const bool compensabile = _lia->get("S9") == "CM";
TMask& shm = sh.sheet_mask(); TMask& shm = sh.sheet_mask();
for (int id = 103; shm.id2pos(id) > 0; id++) if (compensabile)
{ for (int id = 103; shm.id2pos(id) > 0; id++)
TMask_field& f = shm.field(id); {
if ((f.in_group(11) && new_print_2000) || (f.in_group(12) && !new_print_2000)) /*
TMask_field& f = shm.field(id);
if ((f.in_group(11) && true) || (f.in_group(12) && !true))
{ {
f.hide(); f.hide();
sh.delete_column(id); sh.delete_column(id);
} }
if (id == 108 || id == 110) */
sh.enable_column(id, new_age_2000); if ((id >= 107 && id <= 110) || id == 112)
} sh.enable_column(id, true);
}
// fill the mask in // fill the mask in
read_general(*_mask); read_general(*_mask);
@ -643,47 +714,44 @@ bool Visliq_app::vis_one(int m)
if (_lim->get_bool("B2")) if (_lim->get_bool("B2"))
nomem << TR(" (diritto al rimborso infraannuale)"); nomem << TR(" (diritto al rimborso infraannuale)");
real acconto(0.0); real acconto;
if (m == 12 && look_del(12,7)) if (m == 12 && look_del(12,7))
acconto = _del->get_real("R0"); else acconto = _del->get_real("R0");
if (m == 13) else
acconto = _lim->get_real("R11"); if (m == 13)
acconto = _lim->get_real("R11");
msk.field(F_YEAR).set(nomem); msk.set(F_YEAR, nomem);
msk.set(F_RIMBORSO, rimborso); msk.set(F_RIMBORSO, rimborso);
// Ottima procedura di 16 righe, di cui 14 inutili! // Ottima procedura di 16 righe, di cui 14 inutili!
if (rettifica.sign() < 0) if (!rettifica.is_zero())
{ {
real rabs = abs(rettifica); msk.set(F_DEBCRE, rettifica > ZERO ? "D" : "C");
msk.field(F_RETTIFICA).set(rabs.string()); rettifica = abs(rettifica);
msk.field(F_DEBCRE).set("C"); msk.set(F_RETTIFICA, rettifica);
} }
else if (rettifica.sign() > 0)
{
msk.field(F_RETTIFICA).set(rettifica.string());
msk.field(F_DEBCRE).set("D");
}
else
{
msk.field(F_RETTIFICA).set("");
msk.field(F_DEBCRE).set("");
}
TString desc1 = _lim->get("S0"), desc2 = _lim->get("S1"), desc3 = _lim->get("S2"); TString desc1 = _lim->get("S0"), desc2 = _lim->get("S1"), desc3 = _lim->get("S2"), desc4 = _lim->get("S3");
msk.field(F_DESCR1).set(desc1);
msk.field(F_DESCR2).set(desc2); msk.set(F_DESCR1, desc1);
msk.field(F_DESCR3).set(desc3); msk.set(F_DESCR2, desc2);
msk.set(F_DESCR3, desc3);
msk.set(F_DESCR4, desc4);
msk.set(F_ACCONTO, acconto); msk.set(F_ACCONTO, acconto);
real varimp = _lim->get("R17"); real varimp = _lim->get("R17");
real impnonver= _lim->get("R18"); real impnonver= _lim->get("R18");
real credspec = _lim->get("R19"); real credspec = _lim->get("R19");
msk.set(F_VARIMP, varimp >= ZERO ? varimp : -varimp); if (!varimp.is_zero())
msk.set(F_VARIMP_DC, varimp >= ZERO ? "D" : "C"); {
msk.set(F_VARIMP_DC, varimp > ZERO ? "D" : "C");
varimp = abs(varimp);
msk.set(F_VARIMP, varimp);
}
msk.set(F_IMPNONVER, impnonver); msk.set(F_IMPNONVER, impnonver);
msk.set(F_CREDSPEC, credspec); msk.set(F_CREDSPEC, credspec);
@ -695,7 +763,7 @@ bool Visliq_app::vis_one(int m)
TViswin & vsw = brw.vis_win(); TViswin & vsw = brw.vis_win();
bool is_delega = false; bool is_delega = false;
real vers; TDate date; TString abi(5), cab(5), con(3); real vers; TDate date; TString8 abi, cab, con;
if (is_delega = look_del(m,1)) if (is_delega = look_del(m,1))
{ {
@ -706,141 +774,95 @@ bool Visliq_app::vis_one(int m)
con = _del->get("S9"); con = _del->get("S9");
} }
msk.field(F_DELDATE).set(date.string()); msk.set(F_DELDATE, date);
msk.field(F_DELIMP).set(vers.string()); msk.set(F_DELIMP, vers);
msk.field(F_DELABI).set(abi); msk.set(F_DELABI, abi);
msk.field(F_DELCAB).set(cab); msk.set(F_DELCAB, cab);
msk.field(F_DELCON).set(con); msk.set(F_DELCON, con);
bool l_mod = false; real cred_util = _lim->get_real("R16");
bool d_mod = false;
msk.set(F_CREDUTIL, cred_util);
real cred_aut = _lim->get_real("R20");
TDate data_aut = _lim->get_date("D1");
msk.set(F_CREDAUT, cred_aut);
msk.set(F_DATAAUT, data_aut);
_from_one = true; _from_one = true;
for(;;) KEY k;
while ((k = msk.run()) != K_ESC && msk.dirty())
{ {
KEY k = msk.run(); acconto = msk.get_real(F_ACCONTO);
rettifica = msk.get_real(F_RETTIFICA);
if (k == K_ESC) break; if (msk.field(F_DEBCRE).get()[0] == 'C')
rettifica = -rettifica;
real n_acconto (msk.get(F_ACCONTO));
real n_rimborso (msk.get(F_RIMBORSO));
real n_rettifica(msk.get(F_RETTIFICA));
real n_delimp(msk.get(F_DELIMP));
TString n_desc1 (msk.get(F_DESCR1));
TString n_desc2 (msk.get(F_DESCR2));
TString n_desc3 (msk.get(F_DESCR3));
real n_vers (msk.get(F_DELIMP));
TDate n_date (msk.get(F_DELDATE));
TString n_abi (msk.get(F_DELABI));
TString n_cab (msk.get(F_DELCAB));
TString n_con (msk.get(F_DELCON));
real n_varimp(msk.get(F_VARIMP));
real n_impnonver(msk.get(F_IMPNONVER));
real n_credspec(msk.get(F_CREDSPEC));
if (msk.field(F_DEBCRE).get()[0] == 'C')
n_rettifica = -n_rettifica;
if (msk.get(F_VARIMP_DC)[0] == 'C') if (msk.get(F_VARIMP_DC)[0] == 'C')
n_varimp = -n_varimp; varimp = -varimp;
desc1 = msk.get(F_DESCR1);
desc2 = msk.get(F_DESCR2);
desc3 = msk.get(F_DESCR3);
desc4 = msk.get(F_DESCR4);
vers = msk.get_real(F_DELIMP);
date = msk.get_date(F_DELDATE);
abi = msk.get(F_DELABI);
cab = msk.get(F_DELCAB);
con = msk.get(F_DELCON);
varimp = msk.get_real(F_VARIMP);
impnonver = msk.get_real(F_IMPNONVER);
credspec = msk.get_real(F_CREDSPEC);
cred_util = msk.get_real(F_CREDUTIL);
cred_aut = msk.get_real(F_CREDAUT);
data_aut = msk.get_date(F_DATAAUT);
bool l_mod = msk.field(F_ACCONTO).dirty() ||
msk.field(F_RETTIFICA).dirty() || msk.field(F_DEBCRE).dirty() ||
msk.field(F_VARIMP).dirty() || msk.field(F_VARIMP_DC).dirty() ||
msk.field(F_DESCR1).dirty() ||
msk.field(F_DESCR2).dirty() ||
msk.field(F_DESCR3).dirty() ||
msk.field(F_CREDSPEC).dirty() ||
msk.field(F_CREDUTIL).dirty() ||
msk.field(F_CREDAUT).dirty() ||
msk.field(F_DATAAUT).dirty() ? true : false;
bool d_mod = msk.field(F_DELDATE).dirty() ||
msk.field(F_DELIMP).dirty() ||
msk.field(F_DELABI).dirty() ||
msk.field(F_DELCAB).dirty() ||
msk.field(F_DELCON).dirty() ? true : false;
if (msk.field(F_RETTIFICA).dirty() || msk.field(F_DEBCRE).dirty())
{
rettifica = n_rettifica;
l_mod = true;
}
if (msk.field(F_ACCONTO).dirty())
{
acconto = n_acconto;
l_mod = true;
}
if (msk.field(F_RIMBORSO).dirty()) if (msk.field(F_RIMBORSO).dirty())
{ {
// check diritto (se non ce n'era già uno prima)
const bool old_rim = !rimborso.is_zero();
real nuovo_rimborso = msk.get_real(F_RIMBORSO);
bool ok = true; bool ok = true;
if (!n_rimborso.is_zero())
{ if (!nuovo_rimborso.is_zero() && !_lim->get_bool("B2") && !old_rim)
const bool old_rim = !rimborso.is_zero();
// check diritto (se non ce n'era già uno prima)
if (!_lim->get_bool("B2") && !old_rim)
ok = yesno_box(FR("Non risulta diritto al rimborso per il mese %d. Si desidera " ok = yesno_box(FR("Non risulta diritto al rimborso per il mese %d. Si desidera "
"confermare ugualmente?"), m); "confermare ugualmente?"), m);
}
if (ok) if (ok)
{ {
rimborso = n_rimborso; rimborso = nuovo_rimborso;
l_mod = true; l_mod = true;
} }
else else
{ {
msk.field(F_RIMBORSO).set(rimborso.string()); msk.set(F_RIMBORSO, rimborso);
msk.field(F_RIMBORSO).set_dirty(false); msk.field(F_RIMBORSO).set_dirty(false);
} }
} }
if (msk.field(F_DESCR1).dirty()) if (recorded)
{ recorded = !(d_mod || l_mod);
desc1 = n_desc1;
l_mod = true;
}
if (msk.field(F_DESCR2).dirty())
{
desc2 = n_desc2;
l_mod = true;
}
if (msk.field(F_DESCR3).dirty())
{
desc3 = n_desc3;
l_mod = true;
}
if (msk.field(F_DELDATE).dirty())
{
date = n_date;
d_mod = true;
}
if (msk.field(F_DELIMP).dirty())
{
real itt = _lim->get_real("R10");
vers = n_vers;
d_mod = true;
}
if (msk.field(F_DELABI).dirty())
{
abi = n_abi;
d_mod = true;
}
if (msk.field(F_DELCAB).dirty())
{
cab = n_cab;
d_mod = true;
}
if (msk.field(F_DELCON).dirty())
{
con = n_con;
d_mod = true;
}
if (msk.field(F_VARIMP).dirty() || msk.field(F_VARIMP_DC).dirty())
{
varimp = n_varimp;
l_mod = true;
}
if (msk.field(F_IMPNONVER).dirty())
{
impnonver = n_impnonver;
l_mod = true;
}
if (msk.field(F_CREDSPEC).dirty())
{
credspec = n_credspec;
l_mod = true;
}
if (recorded) recorded = !(d_mod || l_mod);
if (k == K_INS || k == K_SAVE) if (k == K_INS || k == K_SAVE)
{ {
recalc_liq_data(&vsw, rimborso, rettifica, vers, acconto, varimp, impnonver, credspec, recalc_liq_data(&vsw, rimborso, rettifica, vers, acconto, varimp, impnonver, credspec,
desc1, desc2, desc3, date, abi, cab, con); desc1, desc2, desc3, desc4, date, abi, cab, con,
cred_util, cred_aut, data_aut);
} }
if (k == K_SAVE) if (k == K_SAVE)
{ {
@ -877,20 +899,35 @@ bool Visliq_app::vis_one(int m)
real Visliq_app::credito_utilizzato(int year, int month) const real Visliq_app::credito_utilizzato(int year, int month) const
{ {
real credito; real credito;
TTable lim("LIM");
TString16 cod; TString16 cod;
for (int m = 1; m <= month; m++)
for (int m = 1; m <= month; m++)
{ {
cod.format("%04d%02d", year, m); cod.format("%04d%02d", year, m);
lim.put("CODTAB", cod);
if (lim.read() == NOERR) const TRectype& lim = cache().get("LIM", cod);
{
if (m < month) if (m < month)
credito += lim.get_real("R15"); // Credito utilizzato IVA credito += lim.get_real("R15"); // Credito utilizzato IVA
if (m < 13) if (m < 13)
credito += lim.get_real("R16"); // Credito utilizzato F24 credito += lim.get_real("R16"); // Credito utilizzato F24
} }
return credito;
}
real Visliq_app::credito_autorizzato(int year, int month) const
{
real credito;
TString16 cod;
for (int m = 1; m <= month; m++)
{
cod.format("%04d%02d", year, m);
const TRectype& lim = cache().get("LIM", cod);
credito += lim.get_real("R20"); // Credito utilizzato IVA
} }
return credito; return credito;
@ -929,8 +966,10 @@ real Visliq_app::min_vers(int anno, int month)
void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& vers, void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& vers,
real& acc, real& varimp, real& impnonver, real & credspec, real& acc, real& varimp, real& impnonver, real & credspec,
TString& d1, TString& d2, TString& d3, TDate& date, TString& d1, TString& d2, TString& d3, TString& d4,
TString& abi, TString& cab, TString& con) TDate& date, TString& abi, TString& cab, TString& con,
real & credito_utilizzato_F24,
real & credito_autorizzato_F24, TDate & data_autorizzazione)
{ {
// ricalcola tutto, scrive nei lim, NON salva e riaggiusta // ricalcola tutto, scrive nei lim, NON salva e riaggiusta
// la paginata della liquidazione // la paginata della liquidazione
@ -952,7 +991,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver
real crd = _lim->get_real("R12"); // totale a credito si real crd = _lim->get_real("R12"); // totale a credito si
real dbt = _lim->get_real("R13"); // totale a debito si real dbt = _lim->get_real("R13"); // totale a debito si
real itr = _lim->get_real("R14"); // interesse totale si real itr = _lim->get_real("R14"); // interesse totale si
real cui = _lim->get_real("R15"); // Credito utilizzato iva si real cui = _lim->get_real("R15"); // Credito util.IVA prec. si
real var = _lim->get_real("R17"); // Variazioni d'imposta no real var = _lim->get_real("R17"); // Variazioni d'imposta no
real inv = _lim->get_real("R18"); // Imposta non versata no real inv = _lim->get_real("R18"); // Imposta non versata no
real crs = _lim->get_real("R19"); // Crediti speciali no real crs = _lim->get_real("R19"); // Crediti speciali no
@ -983,31 +1022,24 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver
// calcola vecchio risultato: se e' diverso da R0 ci sono cazzi strani // calcola vecchio risultato: se e' diverso da R0 ci sono cazzi strani
// e invalidiamo B0 cosi' impara // e invalidiamo B0 cosi' impara
real risul = iva_ven - iva_acq - udt + rmb + cgp - vri + rtt - act - cre_pre + deb_pre + real risul = iva_ven - iva_acq - udt + rmb + cgp - vri + rtt - act - cre_pre + deb_pre +
var + inv - cui - crs; var + inv - cui - crs; //qui
if (risul != ris)
{
#ifdef DBG
yesnofatal_box("Porca vacca: Risultato non coincidente!");
#endif
_lim->put("B0", "X");
}
// calcola nuovi dati // calcola nuovi dati
real riscr = iva_acq + udt + acc + cre_pre + credspec; real riscr = iva_acq + udt + acc + cre_pre + credspec;
real risdb = iva_ven + rimb + deb_pre + impnonver; real risdb = iva_ven + rimb + deb_pre + impnonver;
if (rett.sign() < 0) riscr -= rett; if (rett < ZERO) riscr -= rett;
else risdb += rett; else risdb += rett;
if (cgp.sign() < 0) riscr -= cgp; if (cgp < ZERO) riscr -= cgp;
else riscr += cgp; else riscr += cgp;
if (varimp.sign() < 0) riscr -= varimp; if (varimp < ZERO) riscr -= varimp;
else risdb += varimp; else risdb += varimp;
real credito_utilizzato_iva = ZERO; real credito_utilizzato_iva = ZERO;
const bool new_age_2000 = (_year >= 2000) && look_lia() && (_lia->get("S9") == "NV"); const bool compensabile = _lia->get("S9") == "CM";
if (new_age_2000)
// if ((_year >= 2000) && look_lia() && compensabile)
if (look_lia() && compensabile)
{ {
real credito_utilizzabile_inizio_anno = _lia->get_real("R0") - _lia->get_real("R15"); real credito_utilizzabile_inizio_anno = _lia->get_real("R0") - _lia->get_real("R15");
if (credito_utilizzabile_inizio_anno < ZERO) if (credito_utilizzabile_inizio_anno < ZERO)
@ -1018,6 +1050,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver
{ {
real credito_utilizzabile = credito_utilizzabile_inizio_anno; real credito_utilizzabile = credito_utilizzabile_inizio_anno;
credito_utilizzabile += credito_autorizzato(year, month);
credito_utilizzabile -= credito_utilizzato(year, month); credito_utilizzabile -= credito_utilizzato(year, month);
if (credito_utilizzabile < ZERO) credito_utilizzabile = ZERO; if (credito_utilizzabile < ZERO) credito_utilizzabile = ZERO;
if (month < 13) if (month < 13)
@ -1031,12 +1064,23 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver
risul = risdb - riscr; risul = risdb - riscr;
real intr(0.0); const real check01 = risul.round(2);
const real check02 = ris.round(2);
if (!itt.is_zero() && risul.sign() > 0) if (check01 != check02)
{
#ifdef DBG
yesnofatal_box("Porca vacca: Risultato non coincidente!");
#endif
_lim->put("B0", "X");
}
real intr;
if (!itt.is_zero() && risul > ZERO)
{ {
// calcola interesse // calcola interesse
intr = risul * itt / real(100.0); intr = risul * itt / CENTO;
intr.ceil(); intr.ceil();
if (after2000) if (after2000)
round_imposta(intr); round_imposta(intr);
@ -1052,13 +1096,19 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver
_lim->put("R13", risdb); _lim->put("R13", risdb);
_lim->put("R14", intr); _lim->put("R14", intr);
_lim->put("R15", credito_utilizzato_iva); _lim->put("R15", credito_utilizzato_iva);
_lim->put("R16", credito_utilizzato_F24);
_lim->put("R17", varimp); _lim->put("R17", varimp);
_lim->put("R18", impnonver); _lim->put("R18", impnonver);
_lim->put("R19", credspec); _lim->put("R19", credspec);
_lim->put("R20", credito_autorizzato_F24);
_lim->put("D1", data_autorizzazione);
_lim->put("S0", d1); _lim->put("S0", d1);
_lim->put("S1", d2); _lim->put("S1", d2);
_lim->put("S2", d3); _lim->put("S2", d3);
_lim->put("S3", d4);
// i dati dei versamenti si schiaffano in LIM: // i dati dei versamenti si schiaffano in LIM:
// D0 la data, S4/5/6 le tre cazzate ABI CAB CON // D0 la data, S4/5/6 le tre cazzate ABI CAB CON
@ -1303,6 +1353,10 @@ void Visliq_app::recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field
int step = _freqviva == "M" ? 1 : 3; int step = _freqviva == "M" ? 1 : 3;
real rstart = _lim->get("R0"); real rstart = _lim->get("R0");
real cr_res = _lia->get_real("R0");
const bool compensabile = _lia->get("S9") == "CM";
cr_res -= _lia->get_real("R15");
for (int i = start_month; i < 13; i += step) for (int i = start_month; i < 13; i += step)
{ {
@ -1322,6 +1376,7 @@ void Visliq_app::recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field
real risd = _lim->get_real("R13"); real risd = _lim->get_real("R13");
real intt = _lim->get_real("R10"); real intt = _lim->get_real("R10");
real crf24 = _lim->get_real("R16"); real crf24 = _lim->get_real("R16");
real autf24 = _lim->get_real("R20");
// toglie vecchio credito e debito // toglie vecchio credito e debito
risl += cred; risl += cred;
@ -1352,7 +1407,7 @@ void Visliq_app::recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field
_lim->put("R0", risl); _lim->put("R0", risl);
_lim->put("R12", risc); _lim->put("R12", risc);
_lim->put("R13", risd); _lim->put("R13", risd);
if (intt.sign() > 0) // interessi if (intt > ZERO) // interessi
{ {
real intr = risl * intt / real(100.0); real intr = risl * intt / real(100.0);
if (_year >= 2000) if (_year >= 2000)
@ -1360,6 +1415,7 @@ void Visliq_app::recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field
_lim->put("R14",intr); _lim->put("R14",intr);
} }
_lim->put("R16", crf24); _lim->put("R16", crf24);
_lim->put("R20", autf24);
_lim->rewrite(); _lim->rewrite();
_lam->rewrite(); _lam->rewrite();
@ -1372,27 +1428,62 @@ void Visliq_app::recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field
TToken_string& t = sl->row(row); TToken_string& t = sl->row(row);
t.add(itoname(i),0); t.add(itoname(i),0);
int sr0 = (_lim->get_real("R0")).sign(); const real r0 = _lim->get_real("R0");
int sr5 = (_lim->get_real("R5")).sign(); const real r1 = _lim->get_real("R1");
bool enable_date = !r1.is_zero();
const real r5 = _lim->get_real("R5");
real r0abs = abs(_lim->get_real("R0")); real absv = abs(r0);
real r5abs = abs(_lim->get_real("R5")); t.add(absv, 1);
t.add(r0abs.string(),1); if (!r0.is_zero())
t.add(sr0 == 0 ? "" : (sr0 > 0 ? "D" : "C"), 2); t.add(r0 > ZERO ? "D" : "C", 2);
t.add((_lim->get_real("R1")).string(),3); t.add(r1, 3);
t.add(r5abs.string(),4); absv = abs(r5);
t.add(absv, 4);
if (!r5.is_zero())
t.add(r5 >ZERO ? "D" : "C", 5);
t.add(sr5 == 0 ? "" : (sr5 > 0 ? "D" : "C"),5); const real criva = _lim->get_real("R15");
const real crf24 = _lim->get_real("R16");
const real autf24 = _lim->get_real("R20");
TDate dautf24 = _lim->get_date("D1");
enable_date |= !autf24.is_zero();
t.add(criva, 6);
t.add(crf24, 7);
t.add(autf24, 8);
if (enable_date)
t.add(dautf24, 9);
if (compensabile)
{
cr_res += autf24;
cr_res -= crf24;
cr_res -= criva;
if (cr_res < ZERO)
{
sl->set_back_and_fore_color(COLOR_LTYELLOW, COLOR_DKRED, row, 7);
t.add("", 10);
}
else
{
sl->set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, row, 7);
t.add(cr_res, 10);
}
}
else
t.add("", 10);
t.add(_lim->get("S3"), 11);
for (int kk = 3; kk < 6 ; kk++) for (int kk = 3; kk < 6 ; kk++)
sl->enable_cell(row, kk); sl->enable_cell(row, kk);
sl->enable_cell(row, 7); sl->enable_cell(row, 7);
sl->enable_cell(row, 8);
sl->enable_cell(row, 9); sl->enable_cell(row, 9);
sl->enable_cell(row, 9, enable_date);
sl->force_update(row); sl->enable_cell(row, 12);
} }
} }
sl->force_update();
// se non si fa questa non scrive una delega, // se non si fa questa non scrive una delega,
// bensi' una bovazza (escremento bovino) // bensi' una bovazza (escremento bovino)
look_lim(start_month); look_lim(start_month);
@ -1459,20 +1550,23 @@ void Visliq_app::read_general(TMask& m)
TString8 cab; TString8 cab;
TString4 cnc; TString4 cnc;
const int step = _freqviva == "M" ? 1 : 3; const int step = _freqviva == "M" ? 1 : 3;
const bool new_age_2000 = _lia->get("S9") == "NV"; const bool compensabile = _lia->get("S9") == "CM";
TSheet_field& sh = m.sfield(F_VISLIQ1); TSheet_field& sh = m.sfield(F_VISLIQ1);
TSheet_field& sv = m.sfield(F_VISLIQ2); TSheet_field& sv = m.sfield(F_VISLIQ2);
TMask_field& crprec = m.field(F_CREDPREC);
if (new_age_2000) /* if (compensabile)
crprec.set_prompt(TR("Credito compensabile inizio anno ")); crprec.set_prompt(TR("Credito compensabile inizio anno "));
else else
crprec.set_prompt(TR("Credito inizio anno ")); crprec.set_prompt(TR("Credito inizio anno ")); */
real cr_res = _lia->get_real("R0");
crprec.set(cr_res.string()); real cr_res = _lia->get_real("R0");
if (new_age_2000) real cr_util = _lia->get_real("R15");
cr_res -= _lia->get_real("R15");
m.set(F_CREDPREC, cr_res);
m.set(F_CREDUTILIN, cr_util);
cr_res -= cr_util;
// set sheet // set sheet
for (int i = step; i < 13; i+=step) for (int i = step; i < 13; i+=step)
@ -1498,8 +1592,10 @@ void Visliq_app::read_general(TMask& m)
else else
tt = &(sh.row(row)); tt = &(sh.row(row));
real r0abs = abs(_lim->get_real("R0")); const real r0abs = abs(_lim->get_real("R0"));
real r5abs = abs(_lim->get_real("R5")); const real r1 = _lim->get_real("R1");
const real r5abs = abs(_lim->get_real("R5"));
tt->add(itoname(i),0); tt->add(itoname(i),0);
tt->add(r0abs.string(),1); tt->add(r0abs.string(),1);
@ -1507,31 +1603,47 @@ void Visliq_app::read_general(TMask& m)
int sr5 = (_lim->get_real("R5")).sign(); int sr5 = (_lim->get_real("R5")).sign();
tt->add(sr0 == 0 ? "" : (sr0 > 0 ? "D" : "C"),2); tt->add(sr0 == 0 ? "" : (sr0 > 0 ? "D" : "C"),2);
tt->add(_lim->get_real("R1").string(),3); tt->add(r1.string(),3);
tt->add(r5abs.string(),4); tt->add(r5abs.string(),4);
bool enable_date = !r1.is_zero();
tt->add(sr5 == 0 ? "" : (sr5 > 0 ? "D" : "C"),5); tt->add(sr5 == 0 ? "" : (sr5 > 0 ? "D" : "C"),5);
const real criva = _lim->get_real("R15"); const real criva = _lim->get_real("R15");
tt->add(criva.string(), 6); tt->add(criva.string(), 6);
const real crf24 = _lim->get_real("R16"); const real crf24 = _lim->get_real("R16");
tt->add(crf24.string(),7); tt->add(crf24.string(),7);
if (new_age_2000) const real autf24 = _lim->get_real("R20");
tt->add(autf24.string(),8);
enable_date |= !autf24.is_zero();
TDate dautf24 = _lim->get_date("D1");
if (enable_date)
tt->add(dautf24.string(),9);
sh.enable_cell(row, 9, enable_date);
if (compensabile)
{ {
if (cr_res > ZERO) // if (cr_res > ZERO)
{ // {
cr_res -= crf24; cr_res += autf24;
cr_res -= criva; cr_res -= crf24;
} cr_res -= criva;
if (cr_res < ZERO) if (cr_res < ZERO)
cr_res = ZERO; {
tt->add(cr_res.string(), 8); sh.set_back_and_fore_color(COLOR_LTYELLOW, COLOR_DKRED, row, 7);
tt->add("", 10);
}
else
{
sh.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, row, 7);
tt->add(cr_res.string(), 10);
}
} }
else else
tt->add("", 8); tt->add("", 10);
tt->add(_lim->get("S3"), 9); tt->add(_lim->get("S3"), 11);
sh.row(row) = (*tt); sh.row(row) = (*tt);
// sh.force_update(row);
} }
sh.force_update();
// calcola versamenti // calcola versamenti
real versamenti[13]; real versamenti[13];
@ -1611,25 +1723,23 @@ void Visliq_app::write_general(TMask& m)
{ {
TSheet_field& sh = m.sfield(F_VISLIQ1); TSheet_field& sh = m.sfield(F_VISLIQ1);
TSheet_field& sv = m.sfield(F_VISLIQ2); TSheet_field& sv = m.sfield(F_VISLIQ2);
const bool new_age_2000 = _lia->get("S9") == "NV"; const bool compensabile = _lia->get("S9") == "CM";
if (m.field(F_CREDPREC).dirty()) real rstart = m.get_real(F_CREDPREC);
{ real rutil = m.get_real(F_CREDUTILIN);
const real r = m.get(F_CREDPREC);
_lia->put("R0",r); _lia->put("R0", rstart);
_lia->rewrite(); _lia->put("R15", rutil);
} _lia->rewrite();
// credito iniziale // credito iniziale
real rstart = _lia->get_real("R0");
real cr_res; real cr_res;
if (!new_age_2000)
{ rstart -= rutil;
if (!rstart.is_zero()) if (!compensabile)
rstart = -rstart; rstart = -rstart;
}
else else
cr_res = rstart - _lia->get_real("R15"); cr_res = rstart;
// indicatore ricalcolo crediti e debiti OK // indicatore ricalcolo crediti e debiti OK
int step = _freqviva == "M" ? 1 : 3; int step = _freqviva == "M" ? 1 : 3;
@ -1652,7 +1762,7 @@ void Visliq_app::write_general(TMask& m)
// risolve menata del dettaglio si'/no // risolve menata del dettaglio si'/no
if (lfrommask) if (lfrommask)
{ {
for (int i = 1; i <= 9; i++) for (int i = 1; i <= 11; i++)
tt_ln.add(shm.get(101+i),i); tt_ln.add(shm.get(101+i),i);
} }
@ -1674,6 +1784,8 @@ void Visliq_app::write_general(TMask& m)
real overs(tt_vo.get(5)); real overs(tt_vo.get(5));
real nvers(tt_vn.get(5)); real nvers(tt_vn.get(5));
real crf24(tt_ln.get(7)); real crf24(tt_ln.get(7));
real autf24(tt_ln.get(8));
TDate dautf24(tt_ln.get(9));
TDate odate(tt_vo.get(1)); TDate odate(tt_vo.get(1));
TDate ndate(tt_vn.get(1)); TDate ndate(tt_vn.get(1));
TString odbcr(tt_lo.get(5)); TString odbcr(tt_lo.get(5));
@ -1684,7 +1796,7 @@ void Visliq_app::write_general(TMask& m)
TString8 ncab (tt_vn.get(3)); TString8 ncab (tt_vn.get(3));
TString ocon (tt_vo.get(4)); TString ocon (tt_vo.get(4));
TString ncon (tt_vn.get(4)); TString ncon (tt_vn.get(4));
TString descr(tt_ln.get(9)); TString descr(tt_ln.get(11));
if (odbcr == "C") orett = -orett; if (odbcr == "C") orett = -orett;
if (ndbcr == "C") nrett = -nrett; if (ndbcr == "C") nrett = -nrett;
@ -1868,16 +1980,23 @@ void Visliq_app::write_general(TMask& m)
} }
_lim->put("R16", crf24); _lim->put("R16", crf24);
if (new_age_2000) _lim->put("R20", autf24);
_lim->put("D1", dautf24);
if (compensabile)
{ {
const real criva(tt_ln.get(6)); const real criva(tt_ln.get(6));
if (cr_res > ZERO) // if (cr_res > ZERO)
{ // {
cr_res += autf24;
cr_res -= crf24; cr_res -= crf24;
cr_res -= criva; cr_res -= criva;
} // }
if (cr_res < ZERO) // if (cr_res < ZERO)
cr_res = ZERO; // cr_res = ZERO;
if (cr_res < ZERO)
sh.set_back_and_fore_color(COLOR_LTYELLOW, COLOR_DKRED, row, 7);
else
sh.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, row, 7);
} }
_lim->put("S3", descr); _lim->put("S3", descr);
@ -1897,8 +2016,10 @@ void Visliq_app::write_general(TMask& m)
if (orimb != nrimb) if (orimb != nrimb)
_lim->put("R1", nrimb); _lim->put("R1", nrimb);
_lim->put("R16", crf24); _lim->put("R16", crf24);
_lim->put("S3", descr); _lim->put("R20", autf24);
_lim->put("B0", ""); _lim->put("D1", dautf24);
_lim->put("S3", descr);
_lim->zero("B0");
_lim->rewrite(); _lim->rewrite();
} }
} }
@ -1914,12 +2035,14 @@ void Visliq_app::write_general(TMask& m)
tt_ln.add(r0abs.string(),1); tt_ln.add(r0abs.string(),1);
tt_ln.add(sr0 == 0 ? "" : (sr0 > 0 ? "D" : "C"), 2); tt_ln.add(sr0 == 0 ? "" : (sr0 > 0 ? "D" : "C"), 2);
tt_ln.add((_lim->get_real("R1")).string(),3); tt_ln.add((_lim->get_real("R1")).string(),3);
tt_ln.add(r5abs.string(),4); tt_ln.add(r5abs.string(),4);
tt_ln.add(sr5 == 0 ? "" : (sr5 > 0 ? "D" : "C"),5); tt_ln.add(sr5 == 0 ? "" : (sr5 > 0 ? "D" : "C"),5);
tt_ln.add(cr_res.string(),8); if ( cr_res < ZERO)
tt_ln.add("",10);
// sh.force_update(row); else
tt_ln.add(cr_res.string(),10);
} }
_from_one = false; _from_one = false;
} // for mese liq. (riga sheet) } // for mese liq. (riga sheet)

View File

@ -56,7 +56,10 @@ protected:
// handlers // handlers
static bool set_ditta(TMask_field&, KEY); static bool set_ditta(TMask_field&, KEY);
static bool set_ragsoc(TMask_field&, KEY); static bool set_ragsoc(TMask_field&, KEY);
static bool print_handler(TMask_field&, KEY);
static bool sel_mese_sh1 (TMask_field&, KEY); static bool sel_mese_sh1 (TMask_field&, KEY);
static bool enable_date (TMask_field&, KEY);
static bool check_date (TMask_field&, KEY);
static bool sel_mese_sh2 (TMask_field&, KEY); static bool sel_mese_sh2 (TMask_field&, KEY);
static bool ch_year_handler(TMask_field& f, KEY key); static bool ch_year_handler(TMask_field& f, KEY key);
@ -64,6 +67,7 @@ protected:
static bool sheet_action(TSheet_field& s, int r, KEY k); static bool sheet_action(TSheet_field& s, int r, KEY k);
static bool vers_action(TSheet_field& s, int r, KEY k); static bool vers_action(TSheet_field& s, int r, KEY k);
virtual void print();
public: public:
virtual bool firm_change_enabled() const { return false; } virtual bool firm_change_enabled() const { return false; }
@ -95,6 +99,7 @@ public:
// 2 palle // 2 palle
TMask* get_main_mask() { return _mask; } TMask* get_main_mask() { return _mask; }
int year() { return _year;}
bool select_butt(TMask& m); bool select_butt(TMask& m);
TTable* del() { return _del; } TTable* del() { return _del; }
@ -102,11 +107,15 @@ public:
// riaggiusta la liquidazione del mese dato // riaggiusta la liquidazione del mese dato
void recalc_liq_data(TViswin* v, real& rimb, real& rett, real& vers, real& acc, void recalc_liq_data(TViswin* v, real& rimb, real& rett, real& vers, real& acc,
real& varimp, real& impnonver, real& credspec, real& varimp, real& impnonver, real& credspec,
TString& d1, TString& d2, TString& d3, TDate& date, TString& d1, TString& d2, TString& d3, TString& d4,
TString& abi, TString& cab, TString& con); TDate& date, TString& abi, TString& cab, TString& con,
real & credito_utilizzato_F24,
real & credito_autorizzato_F24, TDate & data_autorizzazione);
// Calcolo del credito utilizzato IVA ed F24 // Calcolo del credito utilizzato IVA ed F24
real credito_utilizzato(int year, int month) const; real credito_utilizzato(int year, int month) const;
// Calcolo del credito autorizzato F24
real credito_autorizzato(int year, int month) const;
// riaggiusta le liquidazioni successive se serve // riaggiusta le liquidazioni successive se serve
void recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field* sv); void recalc_next_liq(int start_month, TSheet_field* sl, TSheet_field* sv);

View File

@ -1,32 +1,37 @@
#define F_CODDITTA 151 #define F_CODDITTA 151
#define F_RAGSOC 152 #define F_RAGSOC 152
#define F_MONTHS 153 #define F_MONTHS 153
#define F_TRIMS 154 #define F_TRIMS 154
#define F_YEAR 155 #define F_YEAR 155
#define F_VISLIQ1 156 #define F_VISLIQ1 156
#define F_VISLIQ2 157 #define F_VISLIQ2 157
#define F_CREDPREC 158 #define F_CREDPREC 158
#define F_VISFLQ 109 #define F_CREDUTILIN 159
#define F_ACCONTO 110 #define F_VISFLQ 109
#define F_RIMBORSO 111 #define F_ACCONTO 110
#define F_RETTIFICA 112 #define F_RIMBORSO 111
#define F_DESCR1 113 #define F_RETTIFICA 112
#define F_DESCR2 114 #define F_DESCR1 113
#define F_DEBCRE 115 #define F_DESCR2 114
#define F_SELECT 116 #define F_DEBCRE 115
#define F_DELDATE 117 #define F_SELECT 116
#define F_DELIMP 118 #define F_DELDATE 117
#define F_DELABI 119 #define F_DELIMP 118
#define F_DELCAB 120 #define F_DELABI 119
#define F_DELCON 121 #define F_DELCAB 120
#define F_PERIODOM 122 #define F_DELCON 121
#define F_PERIODOT 123 #define F_PERIODOM 122
#define F_DESCR3 124 #define F_PERIODOT 123
#define F_VARIMP 125 #define F_DESCR3 124
#define F_VARIMP_DC 126 #define F_VARIMP 125
#define F_IMPNONVER 127 #define F_VARIMP_DC 126
#define F_CREDSPEC 128 #define F_IMPNONVER 127
#define F_CREDSPEC 128
#define F_CREDUTIL 129
#define F_CREDAUT 130
#define F_DATAAUT 131
#define F_DESCR4 132
#define F_CODDITTA2 201 #define F_CODDITTA2 201
#define F_RAGSOC2 202 #define F_RAGSOC2 202

197
cg/cg5500a.rep Normal file
View File

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8" ?>
<report name="cg5500a" page_split="1" lpi="6">
<description>Stampa prospetto liquidazione</description>
<font face="Courier New" size="8" />
<section type="Head" pattern="1">
<font face="Courier New" bold="1" size="8" />
<field type="Stringa" align="center" width="175" height="2" pattern="1">
<font face="Arial" bold="1" size="14" />
<prescript description="H0.0 PRESCRIPT">"Stampa Prospetto Liquidazione "
#ANNO @
+
#THIS !</prescript>
</field>
<field type="Testo" width="4" pattern="2" text="Data">
<font italic="1" face="Courier New" bold="1" size="8" />
</field>
<field x="5" type="Data" width="11" pattern="2">
<source>#SYSTEM.DATE</source>
</field>
<field x="165" type="Testo" width="4" pattern="2" text="Pag.">
<font italic="1" face="Courier New" bold="1" size="8" />
</field>
<field x="170" type="Numero" align="right" width="5" pattern="2">
<source>#PAGE</source>
</field>
<field x="0.5" y="2" type="Testo" width="20" pattern="1" text="Ragione sociale" />
<field x="20" y="2" type="Stringa" width="50" pattern="1">
<source>#SYSTEM.RAGSOC</source>
</field>
<field x="80" y="2" type="Testo" width="17" pattern="1" text="Codice fiscale" />
<field x="99" y="2" type="Stringa" width="16" pattern="1">
<prescript description="H0.0 PRESCRIPT">"!CF"
GET_FIRM_DATA </prescript>
</field>
<field x="120" y="2" type="Testo" width="15" pattern="1" text="Partita IVA" />
<field x="134.5" y="2" type="Stringa" width="11" pattern="1">
<prescript description="H0.0 PRESCRIPT">"!IVA"
GET_FIRM_DATA</prescript>
</field>
<field x="111.5" y="3.5" type="Testo" width="25" pattern="1" text="Credito anno precedente" />
<field border="1" y="5" type="Testo" valign="center" align="center" width="13" height="2" pattern="1" text="Mese" />
<field border="1" x="13" y="5" type="Testo" valign="center" align="center" width="22" height="2" pattern="1" text="Risultato" />
<field border="1" x="35" y="5" type="Testo" valign="center" align="center" width="18" height="2" pattern="1" text="Rimborsi" />
<field border="1" x="53" y="5" type="Testo" valign="center" align="center" width="22" height="2" pattern="1" text="Rettifiche" />
<field border="1" x="75" y="5" type="Testo" valign="center" align="center" width="18" height="2" pattern="1" text="Credito utilizz. IVA" />
<field border="1" x="93" y="5" type="Testo" valign="center" align="center" width="18" height="2" pattern="1" text="Credito utilizz. F24 " />
<field border="1" x="111" y="5" type="Testo" valign="center" align="center" width="17" height="2" pattern="1" text="Credito autorizzato" />
<field border="1" x="128" y="5" type="Testo" valign="center" align="center" width="12" height="2" pattern="1" text="Data Autorizz." />
<field border="1" x="140" y="5" type="Testo" valign="center" align="center" width="18" height="2" pattern="1" text="Credito residuo" />
<field border="1" x="158" y="5" type="Testo" valign="center" align="center" width="17" height="2" pattern="1" text="Descrizione" />
<field x="48" y="3.5" type="Valuta" hidden="1" align="right" width="18" id="108" pattern="1" text="#########,@@">
<prescript description="H0.108 PRESCRIPT">"R0"
#FILTER @
"%LIA"
TABLE_READ</prescript>
</field>
<field x="78" y="3.5" type="Valuta" hidden="1" align="right" width="18" id="109" pattern="1" text="#########,@@">
<prescript description="H0.109 PRESCRIPT">"R15"
#FILTER @
"%LIA"
TABLE_READ</prescript>
</field>
<field x="139.5" y="3.5" type="Valuta" align="right" width="18" id="110" pattern="1" text="###.###.###,@@">
<font face="Courier New" size="8" />
<prescript description="H0.110 PRESCRIPT">#108 @
#109 @
-
#THIS !</prescript>
</field>
</section>
<section type="Head" level="1" pattern="1" />
<section type="Body" pattern="1" />
<section type="Body" level="1" pattern="1">
<field border="2" type="Linea" pattern="1" />
<field border="2" x="13" type="Linea" pattern="1" />
<field border="2" x="35" type="Linea" pattern="1" />
<field border="2" x="53" type="Linea" pattern="1" />
<field border="2" x="75" type="Linea" pattern="1" />
<field border="2" x="93" type="Linea" pattern="1" />
<field border="2" x="111" type="Linea" pattern="1" />
<field border="2" x="128" type="Linea" pattern="1" />
<field border="2" x="140" type="Linea" pattern="1" />
<field border="2" x="158" type="Linea" pattern="1" />
<field border="2" x="175" type="Linea" pattern="1" />
<field type="Array" width="13" id="109" pattern="1">
<source>CODTAB[5,7]</source>
<list>
<li Value="Gennaio" Code="01" />
<li Value="Febbraio" Code="02" />
<li Value="Marzo" Code="03" />
<li Value="Aprile" Code="04" />
<li Value="Maggio" Code="05" />
<li Value="Giugno" Code="06" />
<li Value="Luglio" Code="07" />
<li Value="Agosto" Code="08" />
<li Value="Settembre" Code="09" />
<li Value="Ottobre" Code="10" />
<li Value="Novembre" Code="11" />
<li Value="Dicembre" Code="12" />
<li Value="Annuale" Code="13" />
</list>
</field>
<field x="14" type="Valuta" align="right" width="18" id="110" pattern="1" text="###.###.###,@@">
<source>R0</source>
<prescript description="B1.110 PRESCRIPT">#THIS @
0
&#3E;
IF
"D"
ELSE
0
#THIS @
-
#THIS !
"C"
THEN
#201 !</prescript>
</field>
<field x="35" type="Valuta" align="right" width="18" id="111" pattern="1" text="###.###.###,@@">
<source>R1</source>
</field>
<field x="54" type="Valuta" align="right" width="18" id="112" pattern="1" text="###.###.###,@@">
<source>R5</source>
<prescript description="B1.112 PRESCRIPT">#THIS @
0
&#3E;
IF
"D"
ELSE
0
#THIS @
-
#THIS !
"C"
THEN
#202 !</prescript>
</field>
<field x="75" type="Valuta" align="right" width="18" id="113" pattern="1" text="###.###.###,@@">
<source>R15</source>
</field>
<field x="93" type="Valuta" align="right" width="18" id="114" pattern="1" text="###.###.###,@@">
<source>R16</source>
</field>
<field x="111" type="Valuta" align="right" width="17" id="115" pattern="1" text="###.###.###,@@">
<source>R20</source>
</field>
<field x="128" type="Data" align="center" width="12" id="116" pattern="1">
<source>D1</source>
</field>
<field x="140" type="Valuta" align="right" width="18" id="117" pattern="1" text="###.###.###,@@">
<prescript description="B1.117 PRESCRIPT">#H0.110 @
#113 @ -
#114 @ -
#115 @ +
DUP
#THIS !
#H0.110 !</prescript>
</field>
<field x="158" type="Stringa" dynamic_height="1" width="17" height="3" id="118" pattern="1">
<source>S3</source>
</field>
<field x="33" type="Stringa" width="1" id="201" pattern="1" />
<field x="73" type="Stringa" width="1" id="202" pattern="1" />
</section>
<section hidden_if_needed="1" type="Foot" pattern="1">
<field border="2" type="Linea" pattern="1" />
<field border="2" x="13" type="Linea" pattern="1" />
<field border="2" x="35" type="Linea" pattern="1" />
<field border="2" x="53" type="Linea" pattern="1" />
<field border="2" x="75" type="Linea" pattern="1" />
<field border="2" x="93" type="Linea" pattern="1" />
<field border="2" x="111" type="Linea" pattern="1" />
<field border="2" x="128" type="Linea" pattern="1" />
<field border="2" x="140" type="Linea" pattern="1" />
<field border="2" x="158" type="Linea" pattern="1" />
<field border="2" x="175" type="Linea" pattern="1" />
<field border="2" y="1" type="Linea" width="175" height="0" pattern="1" />
</section>
<section type="Foot" level="1" pattern="1">
<font face="Courier New" bold="1" size="10" />
<field border="2" type="Linea" pattern="1" />
<field border="2" x="13" type="Linea" pattern="1" />
<field border="2" x="35" type="Linea" pattern="1" />
<field border="2" x="53" type="Linea" pattern="1" />
<field border="2" x="75" type="Linea" pattern="1" />
<field border="2" x="93" type="Linea" pattern="1" />
<field border="2" x="111" type="Linea" pattern="1" />
<field border="2" x="128" type="Linea" pattern="1" />
<field border="2" x="140" type="Linea" pattern="1" />
<field border="2" x="158" type="Linea" pattern="1" />
<field border="2" x="175" type="Linea" pattern="1" />
<field border="2" y="1" type="Linea" width="175" height="0" pattern="1" />
</section>
<sql>USE LIM
FROM CODTAB=#ANNO
TO CODTAB=#ANNO</sql>
</report>

129
cg/cg5500b.rep Normal file
View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8" ?>
<report name="cg5500b" page_split="1" lpi="6" command="ba8 -4">
<description>Stampa prospetto versamenti</description>
<font face="Courier New" size="10" />
<section type="Head" pattern="1">
<font face="Courier New" bold="1" size="10" />
<field type="Stringa" align="center" width="80" height="2" pattern="1">
<font face="Arial" bold="1" size="14" />
<prescript description="H0.0 PRESCRIPT">"Stampa Prospetto Versamenti "
#ANNO @
+
#THIS !</prescript>
</field>
<field type="Testo" width="4" pattern="2" text="Data">
<font italic="1" face="Courier New" bold="1" size="10" />
</field>
<field x="5" type="Data" width="11" pattern="2">
<source>#SYSTEM.DATE</source>
</field>
<field x="70" type="Testo" width="4" pattern="2" text="Pag.">
<font italic="1" face="Courier New" bold="1" size="8" />
</field>
<field x="75" type="Numero" align="right" width="5" pattern="2">
<font face="Courier New" bold="1" size="8" />
<source>#PAGE</source>
</field>
<field x="1" y="2" type="Testo" width="18" pattern="1" text="Ragione sociale" />
<field x="18" y="2" type="Stringa" width="50" pattern="1">
<source>#SYSTEM.RAGSOC</source>
</field>
<field x="1" y="3.5" type="Testo" width="15" pattern="1" text="Codice fiscale" />
<field x="15.5" y="3.5" type="Stringa" width="16" pattern="1">
<prescript description="H0.0 PRESCRIPT">"!CF"
GET_FIRM_DATA </prescript>
</field>
<field x="32.5" y="3.5" type="Testo" width="13" pattern="1" text="Partita IVA" />
<field x="44.5" y="3.5" type="Stringa" width="10" pattern="1">
<prescript description="H0.0 PRESCRIPT">"!IVA"
GET_FIRM_DATA</prescript>
</field>
<field border="1" x="10.5" y="5" type="Testo" valign="center" align="center" width="13" height="2" pattern="1" text="Mese" />
<field border="1" x="23.5" y="5" type="Testo" valign="center" align="center" width="11" height="2" pattern="1" text="Data" />
<field border="1" x="34.5" y="5" type="Testo" valign="center" align="center" width="6" height="2" pattern="1" text="ABI" />
<field border="1" x="40.5" y="5" type="Testo" valign="center" align="center" width="6" height="2" pattern="1" text="CAB" />
<field border="1" x="46.5" y="5" type="Testo" valign="center" align="center" width="5" height="2" pattern="1" text="Conc." />
<field border="1" x="51.5" y="5" type="Testo" valign="center" align="center" width="18" height="2" pattern="1" text="Versamento" />
</section>
<section type="Head" level="1" pattern="1" />
<section type="Body" pattern="1" />
<section type="Body" level="1" pattern="1">
<field border="2" x="10.5" type="Linea" pattern="1" />
<field border="2" x="23.5" type="Linea" pattern="1" />
<field border="2" x="34.5" type="Linea" pattern="1" />
<field border="2" x="40.5" type="Linea" pattern="1" />
<field border="2" x="46.5" type="Linea" pattern="1" />
<field border="2" x="51.5" type="Linea" pattern="1" />
<field border="2" x="69.5" type="Linea" pattern="1" />
<field x="10.5" type="Array" width="13" id="109" pattern="1">
<source>CODTAB[10,11]</source>
<list>
<li Value="Gennaio" Code="01" />
<li Value="Febbraio" Code="02" />
<li Value="Marzo" Code="03" />
<li Value="Aprile" Code="04" />
<li Value="Maggio" Code="05" />
<li Value="Giugno" Code="06" />
<li Value="Luglio" Code="07" />
<li Value="Agosto" Code="08" />
<li Value="Settembre" Code="09" />
<li Value="Ottobre" Code="10" />
<li Value="Novembre" Code="11" />
<li Value="Dicembre" Code="12" />
<li Value="Annuale" Code="13" />
</list>
</field>
<field x="23.5" type="Data" align="center" width="11" id="110" pattern="1">
<source>D0</source>
</field>
<field x="34.5" type="Stringa" align="center" width="6" id="111" pattern="1">
<source>S7</source>
</field>
<field x="40.5" type="Stringa" align="center" width="6" id="112" pattern="1">
<source>S8</source>
</field>
<field x="47.5" type="Stringa" width="3" id="113" pattern="1">
<source>S9</source>
</field>
<field x="51.5" type="Valuta" align="right" width="18" id="114" pattern="1" text="###.###.###,@@">
<source>R0</source>
<prescript description="B1.114 PRESCRIPT">#THIS @
0
&#3E;
IF
"D"
ELSE
0
#THIS @
-
#THIS !
"C"
THEN
#201 !</prescript>
</field>
</section>
<section hidden_if_needed="1" type="Foot" pattern="1">
<field border="2" x="10.5" type="Linea" pattern="1" />
<field border="2" x="23.5" type="Linea" pattern="1" />
<field border="2" x="34.5" type="Linea" pattern="1" />
<field border="2" x="40.5" type="Linea" pattern="1" />
<field border="2" x="46.5" type="Linea" pattern="1" />
<field border="2" x="51.5" type="Linea" pattern="1" />
<field border="2" x="69.5" type="Linea" pattern="1" />
<field border="2" x="10.5" y="1" type="Linea" width="59" height="0" pattern="1" />
</section>
<section type="Foot" level="1" pattern="1">
<font face="Courier New" bold="1" size="10" />
<field border="2" x="10.5" type="Linea" pattern="1" />
<field border="2" x="23.5" type="Linea" pattern="1" />
<field border="2" x="34.5" type="Linea" pattern="1" />
<field border="2" x="40.5" type="Linea" pattern="1" />
<field border="2" x="46.5" type="Linea" pattern="1" />
<field border="2" x="51.5" type="Linea" pattern="1" />
<field border="2" x="69.5" type="Linea" pattern="1" />
<field border="2" x="10.5" y="1" type="Linea" width="59" height="0" pattern="1" />
</section>
<sql>USE %DEL
FROM CODTAB=#FILTER
TO CODTAB=#FILTER</sql>
</report>

View File

@ -9,6 +9,18 @@ PICTURE TOOL_SAVEREC
MESSAGE EXIT,K_SAVE MESSAGE EXIT,K_SAVE
END END
BUTTON DLG_PRINT 2 2
BEGIN
PROMPT 1 1 "Stampa"
PICTURE TOOL_PRINT
END
BUTTON DLG_SETPRINT 2 2
BEGIN
PROMPT 2 1 "Imposta"
PICTURE TOOL_SETPRINT
END
#include <cancelbar.h> #include <cancelbar.h>
ENDPAGE ENDPAGE
@ -39,7 +51,12 @@ END
CURRENCY F_CREDPREC 15 CURRENCY F_CREDPREC 15
BEGIN BEGIN
PROMPT 1 5 "Credito compensabile inizio anno " PROMPT 1 5 "Credito inizio anno "
END
CURRENCY F_CREDUTILIN 15
BEGIN
PROMPT 1 6 "Credito utilizzato a inizio anno "
END END
SPREADSHEET F_VISLIQ1 -2 -1 SPREADSHEET F_VISLIQ1 -2 -1
@ -52,7 +69,9 @@ BEGIN
ITEM "IVA rettifiche@15" ITEM "IVA rettifiche@15"
ITEM "D/C@3" ITEM "D/C@3"
ITEM "Credito\nutilizzato IVA@15" ITEM "Credito\nutilizzato IVA@15"
ITEM "Credito\nutilizzato F24@15" ITEM "Credito utilizzato F24@20"
ITEM "Credito anno in corso\nautorizzato F24@20"
ITEM "Data autorizzazione@20"
ITEM "Credito IVA\nresiduo@15" ITEM "Credito IVA\nresiduo@15"
ITEM "Descrizione@50" ITEM "Descrizione@50"
END END
@ -93,24 +112,30 @@ END
ENDPAGE ENDPAGE
ENDMASK ENDMASK
PAGE "Prospetto mensile" -1 -1 50 10 TOOLBAR "topbar" 0 0 0 2
#include <stdbar.h>
ENDPAGE
PAGE "Prospetto mensile" -1 -1 75 22
STRING 101 20 STRING 101 20
BEGIN BEGIN
PROMPT 1 1 "Mese " PROMPT 1 1 "Mese "
FLAGS "D" FLAGS "D"
END END
CURRENCY 102 15 CURRENCY 102 15
BEGIN BEGIN
PROMPT 1 2 "Risultato " PROMPT 1 2 "Risultato "
FLAGS "D" FLAGS "D"
END END
LIST 103 1 10 LIST 103 1 10
BEGIN BEGIN
PROMPT 35 2 "" PROMPT 57 2 ""
ITEM " | " ITEM " | "
ITEM "D|Debito" ITEM "D|Debito"
ITEM "C|Credito" ITEM "C|Credito"
@ -119,20 +144,20 @@ END
CURRENCY 104 15 CURRENCY 104 15
BEGIN BEGIN
PROMPT 1 3 "IVA rimborso " PROMPT 1 3 "IVA rimborso "
PICTURE "." PICTURE "."
GROUP 11 GROUP 11
END END
CURRENCY 105 15 CURRENCY 105 15
BEGIN BEGIN
PROMPT 1 4 "IVA rettifiche " PROMPT 1 4 "IVA rettifiche "
GROUP 11 GROUP 11
END END
LIST 106 1 10 LIST 106 1 10
BEGIN BEGIN
PROMPT 35 4 "" PROMPT 57 4 ""
ITEM " | " ITEM " | "
ITEM "D|Debito" ITEM "D|Debito"
ITEM "C|Credito" ITEM "C|Credito"
@ -142,48 +167,62 @@ END
CURRENCY 107 15 CURRENCY 107 15
BEGIN BEGIN
PROMPT 1 3 "Credito utilizzato IVA " PROMPT 1 5 "Credito utilizzato IVA "
FLAGS "D" FLAGS "D"
GROUP 12 GROUP 12
END END
CURRENCY 108 15 CURRENCY 108 15
BEGIN BEGIN
PROMPT 1 4 "Credito utilizzato F24 " PROMPT 1 6 "Credito utilizzato F24 anno precedente "
GROUP 12 GROUP 12
FLAGS "D"
END END
CURRENCY 109 15 CURRENCY 109 15
BEGIN BEGIN
PROMPT 1 5 "Credito IVA residuo " PROMPT 1 7 "Credito autorizzato F24 anno in corso "
GROUP 12
FLAGS "D"
END
DATE 110
BEGIN
PROMPT 1 8 "Data di autorizzazione "
GROUP 12
CHECTYPE REQUIRED
WARNING "La data è obbligatoria"
FLAGS "D"
END
CURRENCY 111 15
BEGIN
PROMPT 1 9 "Credito IVA residuo "
FLAGS "D" FLAGS "D"
GROUP 12 GROUP 12
END END
STRING 110 50 35 STRING 112 50 35
BEGIN BEGIN
PROMPT 1 6 "Descr. " PROMPT 1 10 "Descr. "
GROUP 12 GROUP 12
END FLAGS "D"
BUTTON DLG_OK 10 2
BEGIN
PROMPT -13 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -23 -1 ""
END END
BUTTON 100 10 2 BUTTON 100 10 2
BEGIN BEGIN
PROMPT -33 -1 "Dettaglio" PROMPT -11 -1 "Dettaglio"
END END
ENDPAGE ENDPAGE
ENDMASK ENDMASK
TOOLBAR "topbar" 0 0 0 2
#include <stdbar.h>
ENDPAGE
PAGE "Prospetto versamenti" -1 -1 50 12 PAGE "Prospetto versamenti" -1 -1 50 12
STRING 101 20 STRING 101 20
@ -254,20 +293,9 @@ BEGIN
PROMPT 1 6 "Versamenti " PROMPT 1 6 "Versamenti "
END END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -13 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -23 -1 ""
END
BUTTON 100 10 2 BUTTON 100 10 2
BEGIN BEGIN
PROMPT -33 -1 "Dettaglio" PROMPT -11 -1 "Dettaglio"
// FLAGS "H"
END END
ENDPAGE ENDPAGE

View File

@ -237,6 +237,39 @@ BEGIN
PICTURE "." PICTURE "."
END END
/* gruppo 9: edit credito IVA utilizzato un F24*/
CURRENCY F_CREDUTIL 15
BEGIN
PROMPT 2 17 "Credito IVA compensabile detratto in F24 : "
GROUP 9
FLAGS "H"
PICTURE "."
END
/* gruppo 9: edit credito IVA autorizzato in F24 */
CURRENCY F_CREDAUT 15
BEGIN
PROMPT 2 17 "Credito IVA autorizzato in F24 : "
GROUP 10
FLAGS "H"
PICTURE "."
END
DATE F_DATAAUT
BEGIN
PROMPT 50 17 "il "
GROUP 10
FLAGS "H"
END
STRING F_DESCR4 60
BEGIN
PROMPT 2 18 "Descrizione "
GROUP 10
FLAGS "H"
END
ENDPAGE ENDPAGE