git-svn-id: svn://10.65.10.50/branches/R_10_00@22918 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b11c9705e4
commit
d42478793d
@ -1677,7 +1677,7 @@ END
|
||||
|
||||
STRING F_CODCAUS 3
|
||||
BEGIN
|
||||
PROMPT 41 11 "Causale contabile "
|
||||
PROMPT 43 11 "Causale contabile "
|
||||
FIELD LF_CFVEN->CODCAUS
|
||||
USE LF_CAUSALI
|
||||
INPUT CODCAUS F_CODCAUS
|
||||
@ -1703,7 +1703,7 @@ END
|
||||
|
||||
STRING F_CODCAUSINC 3
|
||||
BEGIN
|
||||
PROMPT 41 12 "Causale contabile Anticipi "
|
||||
PROMPT 43 12 "Causale contabile Anticipi "
|
||||
FIELD LF_CFVEN->CODCAUSINC
|
||||
USE LF_CAUSALI
|
||||
INPUT CODCAUS F_CODCAUSINC
|
||||
|
@ -127,12 +127,15 @@ int cg1300(int argc, char* argv[])
|
||||
a.run(argc, argv, TR("Aggiornamento tipo conto")); // cg1302
|
||||
}
|
||||
break;
|
||||
case 'Z':
|
||||
elimina_zoppi(argc, argv);
|
||||
break;
|
||||
case 'M':
|
||||
setta_meseliq(argc, argv);
|
||||
break;
|
||||
case 'X':
|
||||
xref_check(argc, argv);
|
||||
break;
|
||||
case 'Z':
|
||||
elimina_zoppi(argc, argv);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3,3 +3,4 @@ void elimina_zoppi(int argc, char* argv[]);
|
||||
void setta_meseliq(int argc, char* argv[]);
|
||||
void controlla_PIVA(int argc, char* argv[]);
|
||||
void agg_iban(int argc, char* argv[]);
|
||||
void xref_check(int argc, char* argv[]);
|
||||
|
@ -14,6 +14,7 @@
|
||||
// Campi su file
|
||||
#include <clifo.h>
|
||||
#include <cfven.h>
|
||||
#include <causali.h>
|
||||
#include <rcausali.h>
|
||||
|
||||
// Campi su maschera
|
||||
@ -734,6 +735,14 @@ bool TPrimanota_application::can_I_write(const TRelation* rel) const
|
||||
return TRelation_application::can_I_write(rel);
|
||||
}
|
||||
|
||||
const char* TPrimanota_application::record_description(const TRelation& rel) const
|
||||
{
|
||||
const TString& desc = cache().get(LF_CAUSALI, rel.curr().get(MOV_CODCAUS), CAU_DESCR);
|
||||
if (desc.full())
|
||||
return desc;
|
||||
return TR("Movimento");
|
||||
}
|
||||
|
||||
// Ritorna il prossimo numero di registrazione libero
|
||||
// Certified 100%
|
||||
bool TPrimanota_application::get_next_key(TToken_string& tmp)
|
||||
@ -2315,11 +2324,11 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action)
|
||||
bool TPrimanota_application::link_anal(const TMask& msk, const char* action)
|
||||
{
|
||||
// Controlla autorizzazione
|
||||
if (!(has_module(CMAUT) || has_module(CAAUT)))
|
||||
if (!(has_module(CMAUT) || has_module(CAAUT) || has_module(CIAUT)))
|
||||
return false;
|
||||
|
||||
// Controlla flag sulla causale
|
||||
if (!causale().link_analitica())
|
||||
if (!(causale().link_analitica() || causale().link_industriale()))
|
||||
return false;
|
||||
|
||||
// Controlla l'esistenza del programma dei movimenti analitici
|
||||
@ -2387,6 +2396,8 @@ bool TPrimanota_application::link_anal(const TMask& msk, const char* action)
|
||||
{
|
||||
TConfig config(ini, "Transaction");
|
||||
config.set("Action", action);
|
||||
if (has_module(CIAUT) && !has_module(CAAUT))
|
||||
config.set("Mode", "A"); // Salva automaticamente i movimenti di sola industriale
|
||||
|
||||
TString4 para; para << LF_MOVANA;
|
||||
config.set_paragraph(para);
|
||||
|
@ -191,6 +191,7 @@ protected: // TRelation_application
|
||||
virtual void write_enable(bool) {}
|
||||
virtual bool protected_record(TRectype& rec);
|
||||
virtual bool can_I_write(const TRelation* rel) const;
|
||||
virtual const char* record_description(const TRelation& rel) const;
|
||||
|
||||
protected:
|
||||
void check_saldi();
|
||||
|
@ -1099,7 +1099,51 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
row.add(sum.get(PART_TIPOMOV), 11);
|
||||
tot_lit += soc;
|
||||
}
|
||||
}
|
||||
|
||||
// Gli abbuoni e le differenze cambio esistono solo se e' a saldo
|
||||
// NON sarebbe possibile, ma la contabilizzazione potrebbe mettere a saldo i non assegnati
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S' || !pag.get_real(PAGSCA_ABBUONI).is_zero())
|
||||
{
|
||||
const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI));
|
||||
if (!abb.is_zero())
|
||||
{
|
||||
const char tipo_abb = pag.get_char(PAGSCA_PASSATT);
|
||||
TToken_string& rabb = gm.add_colored_row(sheet, tipo_abb);
|
||||
rabb.add(tipo_abb == 'A' ? TR("Abbuoni attivi") : TR("Abbuoni passivi"), 4);
|
||||
if (in_valuta)
|
||||
{
|
||||
TImporto abb_lit = abb;
|
||||
prima_valuta.val2eur(abb_lit);
|
||||
gm.add_importo(rabb, abb_lit);
|
||||
gm.add_importo(rabb, abb, prima_valuta.codice());
|
||||
|
||||
tot_lit += abb_lit;
|
||||
tot_val += abb;
|
||||
}
|
||||
else
|
||||
{
|
||||
gm.add_importo(rabb, abb);
|
||||
rabb.add("");
|
||||
tot_lit += abb;
|
||||
}
|
||||
rabb.add(sum.get(PART_TIPOMOV), 11);
|
||||
}
|
||||
/* Continuo a ritenre impossibile ... per ora
|
||||
// Le differenze cambio possono esistere solo in valuta
|
||||
if (in_valuta)
|
||||
{
|
||||
const TImporto diff(sez, pag.get_real(PAGSCA_DIFFCAM));
|
||||
if (!diff.is_zero())
|
||||
{
|
||||
TToken_string& rdiff = gm.add_colored_row(sheet, 'C');
|
||||
rdiff.add(TR("Differenza cambio"), 4);
|
||||
gm.add_importo(rdiff, diff);
|
||||
rdiff.add(sum.get(PART_TIPOMOV), 11);
|
||||
}
|
||||
}
|
||||
*/
|
||||
} // Il pagamento era a saldo
|
||||
} // Fine ciclo non assegnati
|
||||
|
||||
if (lastrow > 0)
|
||||
{
|
||||
@ -1148,7 +1192,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
return FALSE; // Rifiuta l'aggiunta di una riga
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TGame_mask::scadenze_notify(TSheet_field& scadenze, int r, KEY k)
|
||||
@ -1159,7 +1203,7 @@ bool TGame_mask::scadenze_notify(TSheet_field& scadenze, int r, KEY k)
|
||||
gm.send_key(K_CTRL + 'N', 0, &scadenze); // Simula la pressione del tasto nuovo
|
||||
return FALSE; // Rifiuta l'aggiunta di una riga
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,7 +92,8 @@ class TMastrini_application : public TPrintapp
|
||||
real _saldo_movimenti,_saldo_progressivi,_totale_saldo,_riporto_footer_dare,_riporto_footer_avere;
|
||||
TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc;
|
||||
long _codice_ditta,_s_prec;
|
||||
TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva,_g_contr,_c_contr,_s_contr,_descrcontr,_numivd;
|
||||
TString4 _tipodoc,_codcaus,_regiva;
|
||||
TString _descrcaus,_descrdociva,_g_contr,_c_contr,_s_contr,_descrcontr,_numivd;
|
||||
char _sezivd,_lettivd;
|
||||
TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr;
|
||||
TString _dataregs, _datadocs;
|
||||
@ -1426,7 +1427,7 @@ bool TMastrini_application::preprocess_page(int file, int counter)
|
||||
|
||||
// Controlla se saldo e' diverso da 0
|
||||
|
||||
if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0.0))
|
||||
if (((_annoes == _annomsk) || (_annomsk == 0)) && (!_totale_saldo.is_zero()))
|
||||
{
|
||||
_sezione = rmov.get(RMV_SEZIONE);
|
||||
|
||||
@ -2163,8 +2164,7 @@ void TMastrini_application::stampa_totaliiva()
|
||||
// sull'archivio CAUS.dta
|
||||
void TMastrini_application::descrizione_causale()
|
||||
{
|
||||
const TRectype & caus = cache().get(LF_CAUSALI, _codcaus);
|
||||
|
||||
const TRectype& caus = cache().get(LF_CAUSALI, _codcaus);
|
||||
_descrcaus = caus.get(CAU_DESCR);
|
||||
}
|
||||
|
||||
@ -2188,14 +2188,14 @@ void TMastrini_application::documenti_iva()
|
||||
void TMastrini_application::ricerca_regiva()
|
||||
{
|
||||
_tabreg->zero();
|
||||
_tipo = 0;
|
||||
if (_annoiva > 0 && _regiva.full())
|
||||
{
|
||||
TString8 dep;
|
||||
dep.format("%04d%3s", _annoiva, (const char*)_regiva);
|
||||
TString8 dep; dep.format("%04d%3s", _annoiva, (const char*)_regiva);
|
||||
_tabreg->put("CODTAB", dep);
|
||||
_tabreg->read();
|
||||
if (_tabreg->read() == NOERR)
|
||||
_tipo = _tabreg->get_int("I0");
|
||||
}
|
||||
_tipo = _tabreg->get_int("I0");
|
||||
}
|
||||
|
||||
bool TMastrini_application::preprocess_print(int file, int counter)
|
||||
@ -2366,7 +2366,7 @@ bool TMastrini_application::set_print(int m)
|
||||
}
|
||||
|
||||
enable_print_menu();
|
||||
enable_link("Collegamento prima nota: ", 'b');
|
||||
enable_link(TR("Collegamento prima nota: "), 'b');
|
||||
|
||||
do
|
||||
print();
|
||||
@ -3699,10 +3699,10 @@ bool TMastrini_application::user_create()
|
||||
_rel->add("CMS", "CODTAB==CODCMS", 1, LF_RMOV, 501);
|
||||
_rel->add("FSC", "CODTAB==FASCMS", 1, LF_RMOV, 502);
|
||||
|
||||
_cur1=add_cursor(new TCursor(_rel,"FLSCA=\" \"",2));
|
||||
_cur1=add_cursor(new TCursor(_rel, "FLSCA<=\" \"",2));
|
||||
open_files(LF_TAB, LF_TABCOM,LF_NDITTE, LF_UNLOC, LF_COMUNI, LF_MOV,
|
||||
LF_CLIFO, LF_CAUSALI, 0);
|
||||
_cur2=add_cursor(new TSorted_cursor(_rel,"DESCR","FLSCA=\" \"",2));
|
||||
_cur2=add_cursor(new TSorted_cursor(_rel, "DESCR","FLSCA<=\" \"",2));
|
||||
|
||||
_tabivd = new TTable (TAB_IVD);
|
||||
_tabtpd = new TTable (TAB_TPD);
|
||||
|
@ -662,8 +662,6 @@ int TStampa_giornale::set_headers()
|
||||
{
|
||||
int r=1;
|
||||
TString riga(_stampa_width);
|
||||
TString16 data_da = _data_da.string();
|
||||
TString16 data_a = _data_a.string();
|
||||
|
||||
if (_stampa_intesta || !_stampa_definitiva)
|
||||
r = stampa_intestazione_ditta();
|
||||
@ -673,6 +671,9 @@ int TStampa_giornale::set_headers()
|
||||
if (_stampa_definitiva)
|
||||
set_header(r++, FR("Codice libro: %s %s "),(const char *) _reg_cod, (const char *) _reg_descr);
|
||||
else
|
||||
{
|
||||
const TString16 data_da = _data_da.string();
|
||||
const TString16 data_a = _data_a.string();
|
||||
set_header(r++, FR("Codice libro: %s %s @%dgdalla data: %s alla data: %s @%dgEsercizio: %04d"),
|
||||
(const char *) _reg_cod, (const char *) _reg_descr,
|
||||
_stampa_width == 132 ? 69 : 135,
|
||||
@ -680,6 +681,7 @@ int TStampa_giornale::set_headers()
|
||||
_stampa_width == 132 ? 117 : 183,
|
||||
_ae
|
||||
);
|
||||
}
|
||||
|
||||
riga.fill('-');
|
||||
set_header(r++, riga);
|
||||
@ -736,6 +738,7 @@ void TStampa_giornale::preprocess_header()
|
||||
const int anno = esc[esercizio].inizio().year(); //anno finale dell'esercizio
|
||||
TString16 numpag, riga;
|
||||
numpag.format("%d/%d", anno, _pagina_da+pag);
|
||||
//numpag.format("%d/%d", esercizio, _pagina_da+pag); // Mediapadania 2013
|
||||
const int tab = _stampa_width - numpag.len();
|
||||
riga.format("@%dg%s", tab, (const char*)numpag);
|
||||
set_header(2, riga); // Sempre quasi sulla prima riga!
|
||||
|
@ -106,55 +106,63 @@ bool CG4100_App::sort_sal()
|
||||
{
|
||||
if (!prnd.addstatus(1))
|
||||
break;
|
||||
if (_year == rmov.get_int(RMV_ANNOES))
|
||||
if (_year != rmov.get_int(RMV_ANNOES))
|
||||
continue;
|
||||
|
||||
numreg = rmov.get_long(RMV_NUMREG);
|
||||
|
||||
gruppo = rmov.get_int(RMV_GRUPPO);
|
||||
conto = rmov.get_int(RMV_CONTO);
|
||||
sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
||||
|
||||
bool scaricato = false;
|
||||
if (numreg != oldnumreg)
|
||||
{
|
||||
numreg = rmov.get_long(RMV_NUMREG);
|
||||
|
||||
gruppo = rmov.get_int(RMV_GRUPPO);
|
||||
conto = rmov.get_int(RMV_CONTO);
|
||||
sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
||||
bool scaricato = FALSE;
|
||||
|
||||
if (numreg != oldnumreg)
|
||||
if (sal.items() > 0)
|
||||
{
|
||||
if (sal.items() > 0)
|
||||
{
|
||||
sal.registra();
|
||||
sal.reset();
|
||||
}
|
||||
oldnumreg = numreg;
|
||||
mov.zero();
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
mov.read();
|
||||
CHECK(mov.good(),"Archivi movimenti e righe inconsistenti");
|
||||
|
||||
// Tipo saldo normale per default
|
||||
tsal = normale;
|
||||
const TString& codcaus = mov.get(MOV_CODCAUS);
|
||||
const TRectype& causale = cache().get(LF_CAUSALI, codcaus);
|
||||
if (!causale.empty())
|
||||
{
|
||||
const char ac = causale.get_char(CAU_MOVAP);
|
||||
if (ac == 'A')
|
||||
tsal = apertura; else
|
||||
if (ac == 'C')
|
||||
tsal = chiusura;
|
||||
}
|
||||
|
||||
scaricato = mov.get_bool(MOV_SCARCON);
|
||||
provvis = mov.get(MOV_PROVVIS).not_empty();
|
||||
datareg = mov.get_date(MOV_DATAREG);
|
||||
|
||||
sal.set_anno_es(_year);
|
||||
sal.set_tipo_saldo(tsal);
|
||||
sal.set_movprovv(provvis);
|
||||
sal.set_data_ulmov(datareg);
|
||||
sal.set_num_ulmov(oldnumreg);
|
||||
sal.registra();
|
||||
sal.reset();
|
||||
}
|
||||
const char sezione = rmov.get(RMV_SEZIONE)[0];
|
||||
const real importo = rmov.get(RMV_IMPORTO);
|
||||
oldnumreg = numreg;
|
||||
mov.zero();
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
mov.read();
|
||||
CHECK(mov.good(),"Archivi movimenti e righe inconsistenti");
|
||||
|
||||
sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, TRUE, scaricato);
|
||||
// Tipo saldo normale per default
|
||||
tsal = normale;
|
||||
const TString& codcaus = mov.get(MOV_CODCAUS);
|
||||
const TRectype& causale = cache().get(LF_CAUSALI, codcaus);
|
||||
if (!causale.empty())
|
||||
{
|
||||
const char ac = causale.get_char(CAU_MOVAP);
|
||||
if (ac == 'A')
|
||||
tsal = apertura; else
|
||||
if (ac == 'C')
|
||||
tsal = chiusura;
|
||||
}
|
||||
|
||||
scaricato = mov.get_bool(MOV_SCARCON);
|
||||
provvis = mov.get(MOV_PROVVIS).not_empty();
|
||||
datareg = mov.get_date(MOV_DATAREG);
|
||||
|
||||
sal.set_anno_es(_year);
|
||||
sal.set_tipo_saldo(tsal);
|
||||
sal.set_movprovv(provvis);
|
||||
sal.set_data_ulmov(datareg);
|
||||
sal.set_num_ulmov(oldnumreg);
|
||||
}
|
||||
const char sezione = rmov.get(RMV_SEZIONE)[0];
|
||||
const real importo = rmov.get(RMV_IMPORTO);
|
||||
|
||||
if (!importo.is_zero())
|
||||
{
|
||||
if (gruppo <= 0 || conto <= 0 || sottoconto <= 0)
|
||||
{
|
||||
warning_box(FR("Conto non valido alla riga %d nel movimento %ld"), rmov.get_int(RMV_NUMRIG), numreg);
|
||||
continue;
|
||||
}
|
||||
sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, true, scaricato);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,13 +79,12 @@ const real& _ProrataItem::percentuale(const char* year) const
|
||||
inline TLiquidazione_app& app()
|
||||
{ return (TLiquidazione_app&)main_app(); }
|
||||
|
||||
TLiquidazione_app::TLiquidazione_app(int m) :
|
||||
_ditte(NULL), _selected(16),
|
||||
_year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
|
||||
TLiquidazione_app::TLiquidazione_app(int m)
|
||||
: _ditte(NULL), _selected(16), _nomiditte(16), _menu(m), _firm_bookmark(-1)
|
||||
{
|
||||
_isprint = _is_interactive = _canprint = true;
|
||||
_isplafond = _printonly = _is_visliq = false;
|
||||
_isvent = _isagricolo = _isbenzinaro = _isviaggio = _isdiff = false;
|
||||
_isvent = _isagricolo = _isbenzinaro = _isviaggio = _isdiff = _isdiffacc = false;
|
||||
_row = 1; _what = all; _comp_acconto = false;
|
||||
_isriepilogo = false; _calcall = false;
|
||||
_recalc_only = _recalc_regis = _isfinal = _isregis = false;
|
||||
@ -121,11 +120,7 @@ bool TLiquidazione_app::user_create()
|
||||
#endif
|
||||
|
||||
|
||||
TProgind* pnd = NULL;
|
||||
if (_is_interactive)
|
||||
pnd = new TProgind (3,TR("Preparazione archivi"), false, true);
|
||||
else
|
||||
begin_wait();
|
||||
TProgress_monitor pnd(3, TR("Preparazione archivi"), false);
|
||||
|
||||
_nditte = new TRelation(LF_NDITTE);
|
||||
_nditte->add(LF_ATTIV,"CODDITTA=CODDITTA");
|
||||
@ -179,8 +174,7 @@ bool TLiquidazione_app::user_create()
|
||||
is_header = subj.items() == 8;
|
||||
printer().formlen(bodylen);
|
||||
}
|
||||
|
||||
if(pnd) pnd->addstatus(1);
|
||||
pnd.add_status(1);
|
||||
|
||||
_rel = new TRelation(LF_MOV);
|
||||
_rel->add(LF_RMOVIVA,"NUMREG=NUMREG");
|
||||
@ -309,15 +303,15 @@ bool TLiquidazione_app::user_create()
|
||||
|
||||
__firm = TApplication::get_firm();
|
||||
|
||||
if (pnd) pnd->addstatus(1);
|
||||
pnd.add_status(1);
|
||||
|
||||
if (_is_interactive)
|
||||
{
|
||||
build_nomiditte(pnd);
|
||||
build_nomiditte();
|
||||
build_ditte_sheet(all);
|
||||
}
|
||||
|
||||
if (pnd) pnd->addstatus(1);
|
||||
pnd.add_status(1);
|
||||
|
||||
TApplication::set_firm(__firm);
|
||||
set_real_picture(REAL_PICTURE);
|
||||
@ -338,7 +332,7 @@ bool TLiquidazione_app::user_create()
|
||||
TApplication::set_firm(ditta);
|
||||
|
||||
if (!look_lia())
|
||||
{ end_wait(); return FALSE; }
|
||||
{ end_wait(); return false; }
|
||||
|
||||
TIva_round ir; // Imposta arrotondamento iva
|
||||
ir.set_default_iva_mode(atoi(_year), _month > 12, ditta);
|
||||
@ -415,11 +409,8 @@ bool TLiquidazione_app::user_create()
|
||||
}
|
||||
|
||||
TApplication::set_firm(__firm);
|
||||
end_wait();
|
||||
user_destroy();
|
||||
}
|
||||
else
|
||||
delete pnd;
|
||||
|
||||
return _is_interactive;
|
||||
}
|
||||
@ -620,7 +611,7 @@ bool TLiquidazione_app::ch_year_handler(TMask_field& f, KEY key)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TLiquidazione_app::build_nomiditte(TProgind* pnd)
|
||||
void TLiquidazione_app::build_nomiditte()
|
||||
{
|
||||
_nomiditte.destroy();
|
||||
// ricostruire _nomiditte e rifare build_ditte_sheet
|
||||
@ -657,8 +648,6 @@ void TLiquidazione_app::build_nomiditte(TProgind* pnd)
|
||||
}
|
||||
_nomiditte.add(d);
|
||||
}
|
||||
if (pnd)
|
||||
pnd->addstatus(1);
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::to_ditt_handler(TMask_field& f, KEY key)
|
||||
|
19
cg/cg4300.h
19
cg/cg4300.h
@ -448,8 +448,7 @@ protected:
|
||||
|
||||
static TLiquidazione_app& app() { return (TLiquidazione_app&)main_app(); }
|
||||
|
||||
bool residuo_da_liquidare(long numreg, int numrig, const TDate& last_pag,
|
||||
real& importo_res, real& imponibile_res, real& imposta_res) const;
|
||||
bool residuo_da_liquidare(const TRectype& lastid, real& importo_res, real& imponibile_res, real& imposta_res) const;
|
||||
bool print_inc_diff_log(int& rw, int tipoatt, int tipoiva);
|
||||
bool print_dainc_diff_log(int& rw, int tipoatt, int tipoiva);
|
||||
bool ivadiff_chiusa(const TRectype& mov, const TDate& fine) const;
|
||||
@ -467,7 +466,7 @@ public:
|
||||
void build_ditte_sheet(wht);
|
||||
void reset_choices(TMask&);
|
||||
void set_choice_limits(TMask&);
|
||||
void build_nomiditte(TProgind* pnd = NULL);
|
||||
void build_nomiditte();
|
||||
void set_year(const char* y) { _year = y; }
|
||||
void set_month(const int m) { _month = m; }
|
||||
|
||||
@ -555,7 +554,7 @@ public:
|
||||
// e' scritto sui parametri liquidazione (LIA)
|
||||
// Se si passa 0 (default) vede prende la ditta correntemente in corso di calcolo
|
||||
// Analogamente per l'anno
|
||||
bool is_differita(long firm = 0, int year = 0);
|
||||
bool is_acconto_differito(long firm = 0, int year = 0);
|
||||
|
||||
// ritorna l'aliquota ordinaria dal
|
||||
// codice IVA apposito immesso nei parametri studio
|
||||
@ -587,7 +586,7 @@ public:
|
||||
void set_firm(_DescrItem& d);
|
||||
void set_att(_DescrItem& d);
|
||||
void set_pim(_DescrItem& d);
|
||||
void set_pumpam(_DescrItem& d);
|
||||
void set_pumpam(const _DescrItem& d);
|
||||
void set_plm_diff(const _DescrItem& d);
|
||||
void set_plm(_DescrItem& d);
|
||||
bool set_annual(_DescrItem& d);
|
||||
@ -645,18 +644,18 @@ public:
|
||||
// da prendere in considerazione per la liquidazione
|
||||
// controllando il regime trimestrale o mensile e
|
||||
// il ricalcolo annuale
|
||||
bool is_month_ok(int x, int mtocalc);
|
||||
bool is_month_ok(int x, int mtocalc) const;
|
||||
// is_month_ok_strict controlla che il mese sia OK per la
|
||||
// liquidazione, ma ritorna TRUE per le trimestrali solo
|
||||
// se il mese cade ESATTAMENTE su un trimestre
|
||||
bool is_month_ok_strict(int x, int month = -1);
|
||||
bool is_month_ok_strict(int x, int month = -1) const;
|
||||
// questa e' la piu' semplice, per vedere se devo
|
||||
// calcolare il mese fottendomene dell'annuale
|
||||
bool is_month_plain(int x);
|
||||
bool is_month_plain(int x) const;
|
||||
// questa serve per i progressivi: la data passata va bene
|
||||
// se il movimento deve essere considerato in calcolo e riepilogo
|
||||
// per la liquidazione di month
|
||||
bool is_date_ok (const TDate& d, int month, int liqmonth, int year);
|
||||
bool is_date_ok (const TDate& d, int month, int liqmonth, int year) const;
|
||||
bool is_in_liq_period(const TDate& d);
|
||||
bool is_first_month (int m);
|
||||
int liq_month(int x);
|
||||
@ -689,7 +688,7 @@ public:
|
||||
|
||||
// cippiuppiu'
|
||||
TLiquidazione_app(int men);
|
||||
virtual ~TLiquidazione_app() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ NUMBER CG43_FLD_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 28 2 "Anno "
|
||||
HELP "Anno per cui effettuare il calcolo"
|
||||
FLAGS "Z"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
|
418
cg/cg4301.cpp
418
cg/cg4301.cpp
@ -36,15 +36,19 @@ bool TLiquidazione_app::recalc_all()
|
||||
TString msg;
|
||||
msg = _printonly ? TR("Stampa") : TR("Calcolo");
|
||||
msg << TR(" liquidazione:\npreparazione archivi...");
|
||||
_prind = new TProgind(_selected.ones()*2, msg, true, true);
|
||||
const int nSel = _selected.ones();
|
||||
if (nSel > 1)
|
||||
_prind = new TProgind(nSel, msg, true, true);
|
||||
else
|
||||
_prind = new TProgind(1, msg, false, false);
|
||||
|
||||
for (int l = 0; l < _ditte->items(); l++)
|
||||
{
|
||||
if (_prind->iscancelled())
|
||||
break;
|
||||
|
||||
if (_selected[(long)l])
|
||||
{
|
||||
if (!_prind->addstatus(1))
|
||||
break;
|
||||
|
||||
TToken_string& nomeditta = _ditte->row(l);
|
||||
const long codditta = nomeditta.get_long(1);
|
||||
const int save_month = _month;
|
||||
@ -87,8 +91,7 @@ bool TLiquidazione_app::recalc_all()
|
||||
TIva_round ir;
|
||||
ir.set_default_iva_mode(atoi(_year), _isannual, codditta);
|
||||
|
||||
_prind->addstatus(1);
|
||||
|
||||
|
||||
/*
|
||||
* trimestrali impropriamente selezionate per mesi intermedi
|
||||
* provocano il ricalcolo dei progressivi mensili ma non la stampa
|
||||
@ -120,11 +123,7 @@ bool TLiquidazione_app::recalc_all()
|
||||
for (m = 1; m <= _month; m++) // fino a 13 compreso
|
||||
{
|
||||
if (is_month_plain(m) || _recalc == ever)
|
||||
{
|
||||
if (_prind->iscancelled())
|
||||
break;
|
||||
update_firm(m);
|
||||
}
|
||||
}
|
||||
|
||||
// se ci sono altri mesi dopo l'ultimo calcolato, invalida il
|
||||
@ -140,13 +139,12 @@ bool TLiquidazione_app::recalc_all()
|
||||
_month = save_month;
|
||||
}
|
||||
}
|
||||
bool canc = _prind->iscancelled();
|
||||
if (!canc) _prind->addstatus(1);
|
||||
const bool good = _prind->addstatus(1);
|
||||
|
||||
TApplication::set_firm(__firm);
|
||||
delete _prind; _prind = NULL;
|
||||
|
||||
return !canc;
|
||||
return good;
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
@ -171,9 +169,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
}
|
||||
}
|
||||
|
||||
look_lim(liq_month(month), TRUE);
|
||||
_isdiffacc = is_differita(); // Gestione differimento acconto IVA
|
||||
_isdifferita = _isdiffacc;
|
||||
look_lim(liq_month(month), true);
|
||||
_isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA
|
||||
_isdifferita = _isdiffacc; // Gestione IVA differita con stesso flag!
|
||||
|
||||
look_lia();
|
||||
_isintr = _freqviva == "T" && !_lia->get_bool("B3"); // was CNF_DITTA->InTrtr
|
||||
@ -358,7 +356,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
|
||||
// se attività mista stampa riepilogo
|
||||
if (_mixed && month == _month && riepliq)
|
||||
describe_att(month,cattivs, TRUE, 'M');
|
||||
describe_att(month,cattivs, true, 'M');
|
||||
|
||||
// se sta calcolando l'annuale, scrive tutti i dati calcolati per il trasferimento
|
||||
// sui files adibiti a mantenere le informazioni per IVA 11: tab1100a e tab1100b
|
||||
@ -506,7 +504,8 @@ void TLiquidazione_app::zero_att(int month, const char* codatt)
|
||||
{
|
||||
TTable * tab = (TTable*) arr[i];
|
||||
CHECK(tab, "Invalid table element");
|
||||
for (tab->first(); !tab->eof(); tab->next()) // Ciclo per i record di tabella
|
||||
tab->zero(); tab->put("CODTAB", _year);
|
||||
for (int err = tab->read(_isgteq); err == NOERR; err = tab->next()) // Ciclo per i record di tabella
|
||||
{
|
||||
codtab = tab->get("CODTAB");
|
||||
m = atoi(codtab.mid(13,2));
|
||||
@ -526,7 +525,7 @@ void TLiquidazione_app::zero_att(int month, const char* codatt)
|
||||
if (look_plm(month, codatt))
|
||||
{
|
||||
// zero PLM, POM, PAM, PUM
|
||||
const TString16 codtab(_plm->get("CODTAB"));
|
||||
const TString16 codtab = _plm->get("CODTAB");
|
||||
_plm->zero();
|
||||
_pom->zero();
|
||||
_pam->zero();
|
||||
@ -560,7 +559,7 @@ void TLiquidazione_app::zero_att(int month, const char* codatt)
|
||||
if (_isplafond && month != 13)
|
||||
zero_plafond(month,codatt);
|
||||
|
||||
if (month != 13 && !_recalc_regis) // Aggiunto test per evitare azzeramenti in stampa registri 19-06-2013
|
||||
if (!_recalc_regis) // Aggiunto test per evitare azzeramenti in stampa registri 19-06-2013
|
||||
zero_diff(month,codatt);
|
||||
}
|
||||
|
||||
@ -569,7 +568,8 @@ bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) c
|
||||
const long numreg = mov.get_long(MOV_NUMREG);
|
||||
|
||||
TString query;
|
||||
query << "USA IVADIFF SELECT BETWEEN(DATAREGP,0," << fine.date2ansi() << ')'
|
||||
query << "USE IVADIFF"
|
||||
<< "\nSELECT BETWEEN(DATAREGP,0," << fine.date2ansi() << ")"
|
||||
<< "\nFROM NUMREG=" << numreg
|
||||
<< "\nTO NUMREG=" << numreg;
|
||||
TISAM_recordset id(query);
|
||||
@ -648,19 +648,21 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::residuo_da_liquidare(long numreg, int numrig, const TDate& last_pag,
|
||||
real& importo_res, real& imponib_res, real& imposta_res) const
|
||||
bool TLiquidazione_app::residuo_da_liquidare(const TRectype& lastid, real& importo_res, real& imponib_res, real& imposta_res) const
|
||||
{
|
||||
const long numreg = lastid.get_long(RMI_NUMREG);
|
||||
const int numrig = lastid.get_int(RMI_NUMRIG);
|
||||
CHECKD(numreg > 0 && numrig > 0, "Numero registrazione non valido ", numreg);
|
||||
const long lastpro = lastid.get_long("NUMPRO");
|
||||
|
||||
bool found = false;
|
||||
|
||||
if (!found)
|
||||
if (!found) // dummy bracketing test
|
||||
{
|
||||
TString query;
|
||||
query << "USE " << LF_IVADIFF
|
||||
<< "\nFROM NUMREG=" << numreg << " NUMRIG=" << numrig
|
||||
<< "\nTO NUMREG=" << numreg << " NUMRIG=" << numrig;
|
||||
query << "USE IVADIFF"
|
||||
<< "\nFROM NUMREG=" << numreg << " NUMRIG=" << numrig
|
||||
<< "\nTO NUMREG=" << numreg << " NUMRIG=" << numrig;
|
||||
TISAM_recordset id(query);
|
||||
found = id.items() >= 2; // riga fattura ed almeno un pagamento o nota di credito
|
||||
if (found)
|
||||
@ -669,22 +671,13 @@ bool TLiquidazione_app::residuo_da_liquidare(long numreg, int numrig, const TDat
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
const char sez = id.get("SEZIONE").as_string()[0];
|
||||
const tipo_movimento tipomov = (tipo_movimento)id.get(PART_TIPOMOV).as_int();
|
||||
if (tipomov <= tm_nota_credito || !last_pag.ok())
|
||||
const long numpro = id.get("NUMPRO").as_int();
|
||||
if (numpro != lastpro)
|
||||
{
|
||||
importo += TImporto(sez, id.get(PAGSCA_IMPORTO).as_real());
|
||||
imponib += TImporto(sez, id.get(RMI_IMPONIBILE).as_real());
|
||||
imposta += TImporto(sez, id.get(RMI_IMPOSTA).as_real());
|
||||
}
|
||||
else
|
||||
{
|
||||
const TDate data_pag = id.get("DATAREGP").as_date();
|
||||
if (data_pag >= last_pag)
|
||||
continue;
|
||||
importo += TImporto(sez, id.get(PAGSCA_IMPORTO).as_real());
|
||||
imponib += TImporto(sez, id.get(RMI_IMPONIBILE).as_real());
|
||||
imposta += TImporto(sez, id.get(RMI_IMPOSTA).as_real());
|
||||
}
|
||||
}
|
||||
|
||||
bool is_good = imponib.valore() > ZERO;
|
||||
@ -730,6 +723,70 @@ static bool partita_chiusa_al(const TPartita& p, const TDate& d)
|
||||
return c;
|
||||
}
|
||||
|
||||
static void LOG_IVA_DIFF(const TRectype& id)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
static FILE* file[3] = { NULL, NULL, NULL };
|
||||
|
||||
if (id.get_int(PART_TIPOMOV) < 3)
|
||||
return;
|
||||
int nf = 0;
|
||||
if (id.get_int("TIPOIVA") == 2) // Acquisti
|
||||
nf += 2;
|
||||
else
|
||||
nf += id.get_int("TIPODIFF") == 1; // Differita
|
||||
FILE*& f = file[nf];
|
||||
if (f == NULL)
|
||||
{
|
||||
const char* name = NULL;
|
||||
switch (nf)
|
||||
{
|
||||
case 0: name = "IVA_Ven_xCas.log"; break;
|
||||
case 1: name = "IVA_Ven_Diff.log"; break;
|
||||
case 2: name = "IVA_Acq_xCas.log"; break;
|
||||
default: break;
|
||||
}
|
||||
fopen_s(&f, name, "w");
|
||||
if (f == NULL)
|
||||
{
|
||||
cantwrite_box(name);
|
||||
fopen_s(&f, name, "w");
|
||||
}
|
||||
if (f != NULL)
|
||||
fprintf(f, "NUMREG\tNUMRIG\tNUMPRO\tNUMREGP\tDATAPAG\t \tGen\tFeb\tMar\tApr\tMag\tGiu\tLug\tAgo\tSet\tOtt\tNov\tDic\n");
|
||||
}
|
||||
if (f != NULL)
|
||||
{
|
||||
TToken_string msg(255, '\t');
|
||||
msg.add(id.get(RMI_NUMREG));
|
||||
msg.add(id.get(RMI_NUMRIG));
|
||||
msg.add(id.get("NUMPRO"));
|
||||
msg.add(id.get("NUMREGP"));
|
||||
msg.add(id.get("DATAREGP"));
|
||||
for (int i = id.get_int("MESELIQ"); i > 0; i--)
|
||||
msg.add(" ");
|
||||
msg.add(id.get_real(RMI_IMPOSTA).stringa(0,2));
|
||||
fprintf(f, "%s\n", (const char*)msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool is_autofattura_articolo_17(const TRectype& mov)
|
||||
{
|
||||
// E' giusto prendere il tipo documento dal movimento senza fidarsi della causale? si.
|
||||
bool af = mov.get(MOV_TIPODOC) == "AF"; // Semplice autofattura (Adesso il tipocr==4 non c'entra piu' un tubo)
|
||||
// Dal 24-02-2014 controlliamo meglio
|
||||
if (af)
|
||||
{
|
||||
TString8 key;
|
||||
key << mov.get(MOV_TIPO) << '|' << mov.get(MOV_CODCF);
|
||||
const int tp = atoi(cache().get(LF_CLIFO, key, CLI_ALLEG));
|
||||
af = tp == 5 || tp == 9; // cliente estero CEE o non CEE
|
||||
}
|
||||
|
||||
return af;
|
||||
}
|
||||
|
||||
void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
// il codatt passato e' codice att + tipo att ( IN {1|2} )
|
||||
// occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati
|
||||
@ -844,9 +901,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
// ma con anno documento precedente. Di conseguenza per un corretto calcolo prorata
|
||||
// e' necessario distinguire gli importi, appunto, per anno.
|
||||
// Questo nuovo calcolo prorata, vale solo per gli anni oltre il 1998.
|
||||
TAssoc_array acq_iva_anni_prec;
|
||||
TAssoc_array acq_iva_anni_prec;
|
||||
|
||||
TTable *arr[4] = { _pim, _pis, _prm, _prp }; //Tabelle con la stessa struttura
|
||||
TTable *arr[4] = { _pim, _pis, _prm, _prp }; //Tabelle con la stessa struttura
|
||||
|
||||
const int year_int = atoi(_year); // Basta con le atoi()...
|
||||
|
||||
@ -896,7 +953,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
}
|
||||
|
||||
//TDate f(1, month == 13 ? 1 : month, year_int);
|
||||
const TDate fromdate(1, month == 13 ? 1 : month, year_int);
|
||||
TDate t;
|
||||
TDate f74;
|
||||
@ -908,8 +964,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (_isviaggio)
|
||||
f74 = TDate(1, 1, year_int-1);
|
||||
|
||||
// if (_isdiff)
|
||||
// f = TDate(1, 1, year_int-5);
|
||||
if (year_int < 1998 || _recalc_regis) // Vecchia selezione o calcolo progressivi per stampa registri bollati
|
||||
{
|
||||
t.set_month(month == 13 ? 12 : month);
|
||||
@ -950,7 +1004,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
|
||||
*_cur = 0;
|
||||
|
||||
TString16 trueatt(codatt);
|
||||
TString8 trueatt(codatt);
|
||||
const int tipatt = trueatt[5] - '0';
|
||||
trueatt.cut(5);
|
||||
|
||||
@ -977,9 +1031,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (tipodoc == "NC")
|
||||
tm = tm_nota_credito;
|
||||
}
|
||||
|
||||
if (_mov->get_long(MOV_NUMREG) == 29103)
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (_mov->get_long(MOV_NUMREG) == 14281)
|
||||
int cazzone = 1;
|
||||
#endif
|
||||
|
||||
if (_isviaggio)
|
||||
{
|
||||
@ -994,7 +1050,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const bool cau_valintra = rcs.get_bool(CAU_VALINTRA);
|
||||
|
||||
// Inizio gestione IVA differita
|
||||
const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
|
||||
const bool iva_diff = _mov->get_bool(MOV_LIQDIFF);
|
||||
const bool iva_cass = !iva_diff && _mov->get_bool(MOV_IVAXCASSA) && tm > 0;
|
||||
const bool movdiff = (iva_diff || iva_cass) && !_recalc_regis; // Aggiunto test su ricalcolo da registri 13-12-2012
|
||||
bool dok = is_date_ok(date, month, liqmonth, year_int);
|
||||
@ -1018,11 +1074,26 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const TPartita* p = arrpart.first();
|
||||
const int row = p ? p->mov2rig(numreg, 0) : 0;
|
||||
game_found = row > 0;
|
||||
if (game_found && !ivadiff_chiusa(_mov->curr(), fine))
|
||||
if (game_found && !ivadiff_chiusa(_mov->curr(), inizio)) // 25-02-2014 sostituito inizio al posto di fine
|
||||
{
|
||||
const TRiga_partite& rp = p->riga(row);
|
||||
TImporto pg, nc;
|
||||
flag_pg_nc = rp.calcola_pagato_periodo(inizio+1L, fine, pg, nc, &pagscatt);
|
||||
if (pagscatt.items() >= 2)
|
||||
{
|
||||
// Fondo righe generate dallo stesso pagamento
|
||||
for (int p = pagscatt.last(); p > 0; p--)
|
||||
{
|
||||
const TRectype& p0 = (const TRectype&)pagscatt[p];
|
||||
const TRectype& p1 = (const TRectype&)pagscatt[p-1];
|
||||
if (p0.get_int(PAGSCA_NRIGP) == p1.get_int(PAGSCA_NRIGP))
|
||||
{
|
||||
const real imp = p0.get_real(PAGSCA_IMPORTO);
|
||||
((TRectype&)p1).add(PAGSCA_IMPORTO, imp);
|
||||
pagscatt.destroy(p, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sarebbe_da_pagare(_mov->curr(), fine))
|
||||
{
|
||||
rp.calcola_pagato_periodo(TDate(0L), fine, pg, nc, NULL);
|
||||
@ -1128,11 +1199,21 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
real nin_imp = ZERO; // imponibile non incassati
|
||||
real nin_iva = ZERO; // imposta non incassati
|
||||
|
||||
look_iva(_rmoviva->get(RMI_CODIVA));
|
||||
const TString4 codiva = _iva->get("CODTAB");
|
||||
const TString4 codiva = _rmoviva->get(RMI_CODIVA);
|
||||
if (!look_iva(codiva))
|
||||
{
|
||||
error_box(FR("Codice IVA \"%s\" non riconosciuto alla riga %d del movimento %ld."),
|
||||
(const char*)codiva, _rmoviva->get_int(RMI_NUMRIG), _rmoviva->get_long(RMI_NUMREG));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECKS(codiva == _iva->get("CODTAB"), "Codice IVA simile ", (const char*)codiva);
|
||||
}
|
||||
|
||||
const TString4 tipoiva = _iva->get("S1");
|
||||
const TString8 tipoes_v = _iva->get("S2");
|
||||
const TString8 tipoes_a = _iva->get("S9");
|
||||
const TString4 tipoes_v = _iva->get("S2");
|
||||
const TString4 tipoes_a = _iva->get("S9");
|
||||
const int tipoagr = _iva->get_int("S4");
|
||||
const int tipoag = _iva->get_int("S5");
|
||||
const int tipopla = _iva->get_int("S3");
|
||||
@ -1144,9 +1225,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const int tipocr = atoi(tipocr_s);
|
||||
const bool intra = _rmoviva->get_bool(RMI_INTRA);
|
||||
|
||||
// autofatture art. 17 per non residenti, con trattamento
|
||||
// speciale in liquidazione annuale
|
||||
const bool autodafe = tipodoc == "AF"; //Adesso il tipocr==4 non c'entra piu' un tubo
|
||||
// autofatture art. 17 per non residenti, con trattamento speciale in liquidazione annuale
|
||||
const bool autodafe = is_autofattura_articolo_17(_mov->curr());
|
||||
// vendite art. 40 c. 5/6/8 acq.intra., con trattamento
|
||||
// speciale in liquidazione annuale (VA7 in stampa)
|
||||
const bool art40 = (tipodoc != "AF" && tipoiva != "NS" && !rcs.get_bool("AUTOFATT") && rcs.get_bool("VALINTRA") && !intra);
|
||||
@ -1183,6 +1263,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt);
|
||||
id.put("TIPOATT", rmi_tipoatt);
|
||||
id.put("ANNOLIQ", datareg.year());
|
||||
|
||||
int mesereg = datareg.month();
|
||||
if (_freqviva[0] == 'T')
|
||||
{
|
||||
@ -1190,11 +1271,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (resto > 0)
|
||||
mesereg += 3-resto;
|
||||
}
|
||||
|
||||
id.put("MESELIQ", mesereg);
|
||||
id.put("TIPOIVA", tipomov == 2 ? 2 : 1);
|
||||
id.put("TIPODIFF", iva_cass ? 2 : 1);
|
||||
id.put(MOV_DATAREG, _mov->get(MOV_DATADOC));
|
||||
id.put(RMI_CODIVA, _rmoviva->get(RMI_CODIVA));
|
||||
id.put(RMI_CODIVA, codiva);
|
||||
id.put("SEZIONE", sezfat);
|
||||
|
||||
id.put("IMPORTO", imponibile_orig+imposta_orig);
|
||||
@ -1221,22 +1303,33 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const real totfat = _mov->get(MOV_TOTDOC);
|
||||
|
||||
TLocalisamfile id(LF_IVADIFF);
|
||||
TRectype& idcurr = id.curr();
|
||||
FOR_EACH_ARRAY_ITEM(pagscatt, r, obj)
|
||||
{
|
||||
const TRectype& pagsca = *(TRectype*)obj;
|
||||
const int nrigp = pagsca.get_int(PAGSCA_NRIGP);
|
||||
|
||||
id.zero();
|
||||
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
|
||||
id.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
|
||||
id.put(MOV_DATAREG, _mov->get(MOV_DATADOC));
|
||||
idcurr.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
|
||||
idcurr.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
|
||||
CHECKD(nrigp > 0, "Invalid NRIGP ", nrigp);
|
||||
id.put("NUMPRO", min(nrigp, 999));
|
||||
idcurr.put("NUMPRO", min(nrigp, 999));
|
||||
if (id.read(_isequal, _lock) != NOERR)
|
||||
{
|
||||
id.zero();
|
||||
idcurr.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
|
||||
idcurr.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
|
||||
idcurr.put("NUMPRO", min(nrigp, 999));
|
||||
if (id.write() != NOERR)
|
||||
error_box("Errore %d in creazione record IVADIFF", id.status());
|
||||
}
|
||||
|
||||
idcurr.put(MOV_DATAREG, _mov->get(MOV_DATADOC));
|
||||
CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt);
|
||||
id.put("TIPOATT", rmi_tipoatt);
|
||||
id.put("TIPOIVA", tipomov == 2 ? 2 : 1);
|
||||
id.put("TIPODIFF", iva_cass ? 2 : 1);
|
||||
id.put(RMI_CODIVA, _rmoviva->get(RMI_CODIVA));
|
||||
idcurr.put("TIPOATT", rmi_tipoatt);
|
||||
idcurr.put("TIPOIVA", tipomov == 2 ? 2 : 1);
|
||||
idcurr.put("TIPODIFF", iva_cass ? 2 : 1);
|
||||
idcurr.put(RMI_CODIVA, codiva);
|
||||
|
||||
TImporto pagtmp;
|
||||
bool ultimo = false;
|
||||
@ -1246,41 +1339,31 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const TPartita& p = arrpart.partita(pagsca);
|
||||
const TRiga_partite& rp = p.riga(nrigp);
|
||||
tipomov_pag = rp.tipo();
|
||||
id.put(PART_TIPOMOV, tipomov_pag);
|
||||
id.put("NUMREGP", rp.get(PART_NREG));
|
||||
id.put("NUMRIGP", rp.get(PART_NUMRIG));
|
||||
idcurr.put(PART_TIPOMOV, tipomov_pag);
|
||||
idcurr.put("NUMREGP", rp.get(PART_NREG));
|
||||
idcurr.put("NUMRIGP", rp.get(PART_NUMRIG));
|
||||
TDate d = rp.get(PART_DATAPAG);
|
||||
if (!d.ok())
|
||||
d = rp.get(PART_DATADOC);
|
||||
if (!d.ok())
|
||||
d = rp.get(PART_DATAREG);
|
||||
id.put("DATAREGP", d);
|
||||
idcurr.put("DATAREGP", d);
|
||||
pagtmp = p.importo_pagsca(pagsca);
|
||||
if (tipomov_pag >= tm_pagamento && partita_chiusa_al(p, fine))
|
||||
{
|
||||
ultimo = true;
|
||||
for (int r = p.last(); r > nrigp; r = p.pred(r))
|
||||
{
|
||||
if (p.riga(r).tipo() >= tm_pagamento)
|
||||
{
|
||||
ultimo = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pagtmp.normalize(sezpag);
|
||||
ultimo = (r == pagscatt.last()) && partita_chiusa_al(p, fine);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Falso record generato da datainc
|
||||
id.put(PART_TIPOMOV, tipomov_pag);
|
||||
id.put("NUMREGP", _mov->get(MOV_NUMREG));
|
||||
id.put("NUMRIGP", nrigp);
|
||||
id.put("DATAREGP", _mov->get(MOV_DATAINC));
|
||||
idcurr.put(PART_TIPOMOV, tipomov_pag);
|
||||
idcurr.put("NUMREGP", _mov->get(MOV_NUMREG));
|
||||
idcurr.put("NUMRIGP", nrigp);
|
||||
idcurr.put("DATAREGP", _mov->get(MOV_DATAINC));
|
||||
pagtmp.set(sezpag, pagsca.get_real(PAGSCA_IMPORTO));
|
||||
ultimo = true;
|
||||
}
|
||||
|
||||
id.put("ANNOLIQ", year_int);
|
||||
idcurr.put("ANNOLIQ", year_int);
|
||||
int meseliq = id.get_date("DATAREGP").month();
|
||||
if (_freqviva[0] == 'T')
|
||||
{
|
||||
@ -1288,47 +1371,49 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (resto > 0)
|
||||
meseliq += 3-resto;
|
||||
}
|
||||
id.put("MESELIQ", meseliq);
|
||||
idcurr.put("MESELIQ", meseliq);
|
||||
|
||||
id.put("SEZIONE", pagtmp.sezione());
|
||||
if (pagtmp.sezione() != sezpag)
|
||||
int cazzone = 2;
|
||||
idcurr.put("SEZIONE", pagtmp.sezione());
|
||||
if (ultimo)
|
||||
{
|
||||
real importo, imponibile, imposta;
|
||||
residuo_da_liquidare(id.get_long(RMI_NUMREG), id.get_int(RMI_NUMRIG), id.get_date("DATAREGP"),
|
||||
importo, imponibile, imposta);
|
||||
id.put(PAGSCA_IMPORTO, importo);
|
||||
id.put(RMI_IMPONIBILE, imponibile);
|
||||
id.put(RMI_IMPOSTA, imposta);
|
||||
|
||||
incdiff_imp += imponibile;
|
||||
incdiff_iva += imposta;
|
||||
residuo_da_liquidare(idcurr, importo, imponibile, imposta);
|
||||
idcurr.put("IMPORTO", importo);
|
||||
idcurr.put(RMI_IMPONIBILE, imponibile);
|
||||
idcurr.put(RMI_IMPOSTA, imposta);
|
||||
if (tipomov_pag >= tm_pagamento) // 5-3-2014 incremento incdiff_imp solo coi pagamenti! Coerentemente con !ultimo
|
||||
{
|
||||
incdiff_imp += imponibile;
|
||||
incdiff_iva += imposta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Spostato in basso ricalcolo importo ragguagliato 24/09/2013
|
||||
// id.put(PAGSCA_IMPORTO, pagtmp.valore());
|
||||
// pagtmp.normalize(sezpag);
|
||||
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
|
||||
real val_imp = imponibile_orig * perc;
|
||||
round_imposta(val_imp);
|
||||
id.put(RMI_IMPONIBILE, val_imp);
|
||||
|
||||
if (tipomov_pag >= tm_pagamento)
|
||||
incdiff_imp += val_imp;
|
||||
|
||||
round_al_centesimo(val_imp);
|
||||
|
||||
real val_iva = imposta_orig * perc;
|
||||
round_imposta(val_iva);
|
||||
id.put(RMI_IMPOSTA, val_iva);
|
||||
round_al_centesimo(val_iva);
|
||||
|
||||
idcurr.put("IMPORTO", val_imp + val_iva);
|
||||
idcurr.put(RMI_IMPONIBILE, val_imp);
|
||||
idcurr.put(RMI_IMPOSTA, val_iva);
|
||||
|
||||
if (tipomov_pag >= tm_pagamento)
|
||||
{
|
||||
incdiff_imp += val_imp;
|
||||
incdiff_iva += val_iva;
|
||||
|
||||
id.put(PAGSCA_IMPORTO, val_imp + val_iva); // Ricalcolo importo
|
||||
}
|
||||
}
|
||||
|
||||
int err = id.write_rewrite();
|
||||
int err = id.rewrite();
|
||||
if (err != NOERR)
|
||||
error_box("Errore %d in aggiornamento file IVADIFF", err);
|
||||
LOG_IVA_DIFF(id.curr());
|
||||
|
||||
const long numreg = _rmoviva->get_long(RMI_NUMREG);
|
||||
if (numreg > 0) // Chiude o riapre la partita
|
||||
@ -1347,19 +1432,25 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
}
|
||||
}
|
||||
diff_imp = imponibile_orig;
|
||||
diff_iva = imposta_orig;
|
||||
if (is_date_ok(date, month, liqmonth, year_int)) // 5-3-2014
|
||||
{
|
||||
diff_imp = imponibile_orig;
|
||||
diff_iva = imposta_orig;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (movdiff)
|
||||
{
|
||||
diff_imp = imponibile_orig;
|
||||
diff_iva = imposta_orig;
|
||||
if (is_date_ok(date, month, liqmonth, year_int)) // 5-3-2014
|
||||
{
|
||||
diff_imp = imponibile_orig;
|
||||
diff_iva = imposta_orig;
|
||||
}
|
||||
}
|
||||
else
|
||||
analizza_IVA(imponibile_orig, imposta_orig, percind, corrisp, false, codiva,
|
||||
impon_det, impos_det, impon_ind, impos_ind);
|
||||
impon_det, impos_det, impon_ind, impos_ind);
|
||||
}
|
||||
|
||||
for (int is_detraibile = 0; is_detraibile < 2; is_detraibile++)
|
||||
@ -1433,6 +1524,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11");
|
||||
if (iva_vpn.full())
|
||||
{
|
||||
if (_mov->get(MOV_ANNOIVA) != _year)
|
||||
{
|
||||
int cazzone = 2;
|
||||
}
|
||||
else
|
||||
switch (tipomov)
|
||||
{
|
||||
case vendita: // CD1 - 1 2 3 4
|
||||
@ -1442,29 +1538,23 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione;
|
||||
if (is_valid)
|
||||
{
|
||||
if (movdiff) // 21-02-2013 Comprendere IVA differita registrata nell'anno! (imponibile=0)
|
||||
{
|
||||
if (date.year() == year_int)
|
||||
cessioni_cd1_1 += imponibile_orig;
|
||||
}
|
||||
else
|
||||
cessioni_cd1_1 += imponibile;
|
||||
cessioni_cd1_1 += imponibile_orig;
|
||||
if (iva_vpn.starts_with("CD1"))
|
||||
{
|
||||
if (tipocr == 4)
|
||||
cessioni_cd1_5 += imponibile;
|
||||
cessioni_cd1_5 += imponibile_orig;
|
||||
}
|
||||
if (!cau_intra)
|
||||
{
|
||||
if (iva_vpn == "CD12")
|
||||
cessioni_cd1_2 += imponibile; else
|
||||
cessioni_cd1_2 += imponibile_orig; else
|
||||
if (iva_vpn == "CD13")
|
||||
cessioni_cd1_3 += imponibile;
|
||||
cessioni_cd1_3 += imponibile_orig;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iva_vpn == "CD14")
|
||||
cessioni_cd1_4 += imponibile;
|
||||
cessioni_cd1_4 += imponibile_orig;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1472,34 +1562,34 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
break;
|
||||
case acquisto: // CD2 - 1 2 3 4
|
||||
{
|
||||
acquisti_cd2_1 += imponibile;
|
||||
acquisti_cd2_1 += imponibile_orig;
|
||||
if (iva_vpn.starts_with("CD2"))
|
||||
{
|
||||
if (tipocr == 2 || tipocr == 3 || tipocr == 8)
|
||||
acquisti_cd2_5 += imponibile;
|
||||
acquisti_cd2_5 += imponibile_orig;
|
||||
}
|
||||
if (!cau_intra)
|
||||
{
|
||||
if (iva_vpn == "CD22")
|
||||
acquisti_cd2_2 += imponibile;
|
||||
acquisti_cd2_2 += imponibile_orig;
|
||||
else
|
||||
if (iva_vpn == "CD23")
|
||||
acquisti_cd2_3 += imponibile;
|
||||
acquisti_cd2_3 += imponibile_orig;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iva_vpn == "CD24")
|
||||
acquisti_cd2_4 += imponibile;
|
||||
acquisti_cd2_4 += imponibile_orig;
|
||||
}
|
||||
if (iva_vpn == "CD31")
|
||||
{
|
||||
oroargento_cd3_1 += imponibile;
|
||||
oroargento_cd3_2 += imposta;
|
||||
oroargento_cd3_1 += imponibile_orig;
|
||||
oroargento_cd3_2 += imposta_orig;
|
||||
}
|
||||
if (iva_vpn == "CD33")
|
||||
{
|
||||
rottami_cd3_3 += imponibile;
|
||||
rottami_cd3_4 += imposta;
|
||||
rottami_cd3_3 += imponibile_orig;
|
||||
rottami_cd3_4 += imposta_orig;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1662,7 +1752,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
|
||||
// operazioni esenti
|
||||
if (tipoiva == "ES")
|
||||
if (tipoiva == "ES" && !imponibile.is_zero())
|
||||
{
|
||||
if (tipomov == vendita)
|
||||
{
|
||||
@ -1777,10 +1867,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (look_iva(_pcon_2_r->get(PCN_IVACOMP)))
|
||||
ivacomp = _iva->get("CODTAB"); // Ecco il codice IVA di compensazione
|
||||
}
|
||||
look_pia(month, codatt, codiva, ivacomp, TRUE); // Crea il record in tabella se non esiste
|
||||
real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna...
|
||||
look_pia(month, codatt, codiva, ivacomp, true); // Crea il record in tabella se non esiste
|
||||
real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna...
|
||||
_pia->put("R0", pia_imp);
|
||||
_pia->put("B0", TRUE); // Seguo l'esempio dei PIM per il ricalcolo acquisti alla fine del ciclo
|
||||
_pia->put("B0", true); // Seguo l'esempio dei PIM per il ricalcolo acquisti alla fine del ciclo
|
||||
_pia->rewrite(); // infine scrive
|
||||
}
|
||||
}
|
||||
@ -1988,7 +2078,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
lor += imponibile + imposta;
|
||||
lorcor += imponibile+imposta;
|
||||
real tot = imponibile+imposta;
|
||||
if (liq) add_corrisp(month, reg, tot, perciva, tipodet, codiva, codatt);
|
||||
if (liq)
|
||||
add_corrisp(month, reg, tot, perciva, tipodet, codiva, codatt);
|
||||
}
|
||||
}
|
||||
else if (tipodoc == "FF") // CM500415: prima non c'era questo if
|
||||
@ -2213,9 +2304,20 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
{
|
||||
if (tipomov == vendita)
|
||||
{
|
||||
// fatture vendita a liquidazione differita
|
||||
#ifndef NDEBUG
|
||||
if (month == 7 && reg == "VEN" && !incdiff_iva.is_zero())
|
||||
{
|
||||
const real oldv = _pim->get("R29");
|
||||
const real newv = oldv + incdiff_iva;
|
||||
__trace("%s %s\t%s\t%s\t%7ld\t%s\t+\t%s\t=\t%s", tab->name(), (const char*)tab->curr().get("CODTAB"), (const char*)reg, (const char*)tipocr_s,
|
||||
_mov->get_long(MOV_NUMREG), oldv.stringa(12, 2), incdiff_iva.stringa(12, 2), newv.stringa(12, 2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// fatture vendita a liquidazione differita
|
||||
tab->curr().add("R26", diff_imp);
|
||||
tab->curr().add("R27", diff_iva);
|
||||
tab->curr().add("R27", diff_iva);
|
||||
tab->curr().add("R28", incdiff_imp);
|
||||
tab->curr().add("R29", incdiff_iva);
|
||||
fdiff_imp += diff_imp;
|
||||
@ -2237,7 +2339,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
tab->curr().add("R33", incdiff_iva);
|
||||
fdiff_imp_acq += diff_imp;
|
||||
fdiff_iva_acq += diff_iva;
|
||||
fdiffinc_imp_acq += incdiff_imp;
|
||||
fdiffinc_imp_acq += incdiff_imp;
|
||||
fdiffinc_iva_acq += incdiff_iva;
|
||||
if (_mov->get_int(MOV_ANNOIVA) < year_int)
|
||||
{
|
||||
@ -2541,8 +2643,8 @@ void TLiquidazione_app::iva11_set_arr_phase_1(const TString& codatt)
|
||||
const TString4 codiva = _iva->get("CODTAB");
|
||||
const TString4 tipoiva = _iva->get("S1");
|
||||
const real ali = _iva->get_real("R0");
|
||||
const TString16 tipoes_v = _iva->get("S2");
|
||||
const TString16 tipoes_a = _iva->get("S9");
|
||||
const TString4 tipoes_v = _iva->get("S2");
|
||||
const TString4 tipoes_a = _iva->get("S9");
|
||||
const int tipoagr = _iva->get_int("S4");
|
||||
const TRectype& rcs = _cur->curr(LF_CAUSALI);
|
||||
const bool autofattura = rcs.get_bool("AUTOFATT");
|
||||
@ -2748,7 +2850,7 @@ void TLiquidazione_app::iva11_set_arr_phase_1(const TString& codatt)
|
||||
|
||||
if (intracom || !valintra)
|
||||
{
|
||||
if (tipoes_v.not_empty()) // Inutile fare troppi controlli...
|
||||
if (tipoes_v.full()) // Inutile fare troppi controlli...
|
||||
{
|
||||
if (tipoes_v == "24")
|
||||
array.add(imponibile,TAB11_EC106);
|
||||
@ -2952,7 +3054,7 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt)
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
array.add(imp,TAB11_IMA03);
|
||||
array.add(imp,TAB11_IMA03);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -3224,6 +3326,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
const bool new_age_2000 = (year_int >= 2000) && (_lia->get("S9") == "NV");
|
||||
|
||||
real risultato = ZERO;
|
||||
|
||||
real detrazioni = ZERO;
|
||||
real versamenti = ZERO;
|
||||
real vers_int = ZERO;
|
||||
@ -3352,7 +3455,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
|
||||
iva_vend += vend;
|
||||
iva_acq += acq;
|
||||
risultato += (vend - acq + diffinc_iva - diffinc_iva_acq);
|
||||
risultato += (vend - acq + diffinc_iva - diffinc_iva_acq);
|
||||
|
||||
res_debt += vend + diffinc_iva;
|
||||
res_cred += acq;
|
||||
fdiff_imp += diff_imp;
|
||||
@ -3548,12 +3652,10 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
}
|
||||
if (attivita_agricola)
|
||||
{
|
||||
real perc; // percentuale di deducibilita'
|
||||
real iva_ded; // iva deducibile
|
||||
|
||||
perc = imp_agr2.is_zero() ? ZERO : imp_agr2 / (imp_agr1 + imp_agr2);
|
||||
// percentuale di deducibilita'
|
||||
real perc = imp_agr2.is_zero() ? ZERO : imp_agr2 / (imp_agr1 + imp_agr2);
|
||||
perc.round(2);
|
||||
iva_ded = acq_noCEE * perc;
|
||||
real iva_ded = acq_noCEE * perc; // iva deducibile
|
||||
round_al_centesimo(iva_ded);
|
||||
iva_acq += iva_ded;
|
||||
res_debt += iva_vend;
|
||||
@ -3606,7 +3708,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
// Calcola credito utilizzabile da riportare nell'anno successivo
|
||||
credito_utilizzabile = credito_utilizzabile_inizio_anno;
|
||||
credito_utilizzabile -= credito_utilizzato(13, TRUE, TRUE);
|
||||
if (credito_utilizzabile < ZERO) credito_utilizzabile = ZERO;
|
||||
if (credito_utilizzabile < ZERO)
|
||||
credito_utilizzabile = ZERO;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3717,7 +3820,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
}
|
||||
_year = yr;
|
||||
|
||||
// Aggiusta DiffIncIVAAcq sul record della 13ma che non poteva ancora sapere il proata definitivo!
|
||||
// Aggiusta DiffIncIVAAcq sul record della 13ma che non poteva ancora sapere il prorata definitivo!
|
||||
if (!prorata.is_zero() && look_plm(13, att))
|
||||
{
|
||||
const real old_r33 = _plm->get("R33");
|
||||
@ -4065,12 +4168,13 @@ void TLiquidazione_app::recalc_annual(const char* att)
|
||||
_CorrItem *cc;
|
||||
bool is_key;
|
||||
|
||||
for (_pim->first(); !_pim->eof(); _pim->next())
|
||||
_pim->zero(); _pim->put("CODTAB", _year); // 24-02-2014 Partiamo dall'anno giusto
|
||||
for (int err = _pim->read(_isgteq); err == NOERR; err = _pim->next())
|
||||
{
|
||||
if (_year != *_pim_anno || _month != atoi(*_pim_mese)) // In questo caso _month vale sempre 13
|
||||
continue;
|
||||
|
||||
int tipocr = atoi(*_pim_tipocr);
|
||||
const int tipocr = atoi(*_pim_tipocr);
|
||||
codiva = *_pim_codiva;
|
||||
reg = *_pim_codreg;
|
||||
look_iva(codiva); look_reg(reg);
|
||||
|
@ -12,21 +12,22 @@
|
||||
#include "cglib03.h"
|
||||
#include "cg4300.h"
|
||||
|
||||
bool TLiquidazione_app::is_trim(int x)
|
||||
#include <attiv.h>
|
||||
#include <nditte.h>
|
||||
|
||||
bool TLiquidazione_app::is_trim(int x)
|
||||
// TRUE se il mese passato e' un trimestre
|
||||
{ return x == 3 || x == 6 || x == 9 || x == 12; }
|
||||
|
||||
bool TLiquidazione_app::is_month_ok_strict(int x, int month)
|
||||
bool TLiquidazione_app::is_month_ok_strict(int x, int month) const
|
||||
// TRUE se il mese passato e' compatibile con il regime
|
||||
// di liquidazione e (opz) non e' maggiore di quello scelto
|
||||
{
|
||||
if (month == -1) month = x;
|
||||
return _freqviva == "M" ?
|
||||
( x > 0 && x <= month) :
|
||||
( x <= month && is_trim(x));
|
||||
return _freqviva == "M" ? ( x > 0 && x <= month) : ( x <= month && is_trim(x));
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::is_month_plain(int x)
|
||||
bool TLiquidazione_app::is_month_plain(int x) const
|
||||
// la piu' semplice: vero se mese == _month o se fa parte del
|
||||
// trimestre indicato da month
|
||||
{
|
||||
@ -41,7 +42,7 @@ bool TLiquidazione_app::is_month_plain(int x)
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::is_month_ok(int x, int mtocalc)
|
||||
bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const
|
||||
// TRUE se il mese passato e' compatibile con il mese da calcolare
|
||||
// rispetto al regime di liquidazione scelto
|
||||
{
|
||||
@ -107,36 +108,36 @@ int TLiquidazione_app::previous_month(int m) const
|
||||
return m == 3 ? 3 : m - 3;
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int year)
|
||||
bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int year) const
|
||||
// TRUE se la data passata va considerata nel
|
||||
// ricalcolo dei progressivi mensili per il mese e anno
|
||||
// selezionati. Vedi cg4301.cpp per maggiori informazioni
|
||||
// sul nuovo filtro di selezione movimenti.
|
||||
{
|
||||
if (d.year() != year)
|
||||
return false;
|
||||
CHECKD(year > 2000, "Invalid year ", year);
|
||||
const int regmonth = d.month();
|
||||
const int regyear = d.year();
|
||||
|
||||
// if (regyear() != year) return false;
|
||||
if (year < 1998 || _recalc_regis) // Vecchia selezione o calcolo progressivi per stampa registri bollati
|
||||
{
|
||||
if (d.month() > month || d.year() != atoi(_year))
|
||||
if (regyear != year || regmonth > month)
|
||||
return false;
|
||||
|
||||
if (month == 13)
|
||||
return d.month() <= month;
|
||||
return true; // was regmonth <= month;
|
||||
else
|
||||
{
|
||||
if (_freqviva == "M") // Guy!!!
|
||||
return d.month() == month;
|
||||
return regmonth == month;
|
||||
else
|
||||
return d.month() >= month-2 && d.month() <= month;
|
||||
return regmonth >= month-2 && regmonth <= month;
|
||||
}
|
||||
}
|
||||
else // Nuova selezione dal 1998 in poi
|
||||
{
|
||||
const int regmonth = d.month();
|
||||
const int regyear = d.year();
|
||||
|
||||
if (month <= 12)
|
||||
return (regmonth == month && liqmonth == 0) || (liqmonth == month);
|
||||
return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month));
|
||||
else // Annuale, month == 13
|
||||
return (regyear == year && liqmonth != 12) || (regyear == year + 1 && liqmonth == 12);
|
||||
}
|
||||
@ -357,7 +358,7 @@ bool TLiquidazione_app::look_plm(int m, const char* att, bool create)
|
||||
(*_plm_anno) = _year;
|
||||
|
||||
const TString16 s = _plm_r->get("CODTAB");
|
||||
bool ok = _plm->read() == NOERR;
|
||||
const bool ok = _plm->read() == NOERR;
|
||||
|
||||
if (!ok && create)
|
||||
{
|
||||
@ -366,9 +367,10 @@ bool TLiquidazione_app::look_plm(int m, const char* att, bool create)
|
||||
_plm->write();
|
||||
}
|
||||
// crea/posiziona tabelle gemelle PAM, PUM, POM
|
||||
look_pam(m,att,!ok);
|
||||
look_pum(m,att,!ok);
|
||||
look_pom(m,att,!ok);
|
||||
look_pam(m, att, !ok);
|
||||
look_pum(m, att, !ok);
|
||||
look_pom(m, att, !ok);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -454,16 +456,14 @@ bool TLiquidazione_app::look_pom(int m, const char* a, bool create)
|
||||
|
||||
bool TLiquidazione_app::look_pam(int m, const char* a, bool create)
|
||||
{
|
||||
bool ok = FALSE;
|
||||
|
||||
_pam->zero();
|
||||
(*_pam_codatt) = format("%6s", a);
|
||||
(*_pam_mese) = format("%02d",m);
|
||||
(*_pam_anno) = _year;
|
||||
|
||||
TString s = _pam->get("CODTAB");
|
||||
_pam->read();
|
||||
ok = _pam->good();
|
||||
const TString16 s = _pam->get("CODTAB");
|
||||
|
||||
const bool ok = _pam->read() == NOERR;
|
||||
|
||||
if (!ok && create)
|
||||
{
|
||||
@ -480,8 +480,9 @@ bool TLiquidazione_app::look_lim(int m, bool create)
|
||||
(*_lim_mese) = format("%02d",m);
|
||||
(*_lim_anno) = _year;
|
||||
|
||||
const TString s = _lim_r->get("CODTAB");
|
||||
const TString8 s = _lim_r->get("CODTAB");
|
||||
const bool ok = _lim->read() == NOERR;
|
||||
|
||||
if (!ok && create)
|
||||
{
|
||||
_lim_r->zero();
|
||||
@ -501,7 +502,7 @@ bool TLiquidazione_app::look_lam(int m, bool create)
|
||||
(*_lam_mese) = format("%02d",m);
|
||||
(*_lam_anno) = _year;
|
||||
|
||||
const TString s = _lam_r->get("CODTAB");
|
||||
const TString8 s = _lam_r->get("CODTAB");
|
||||
const bool ok = _lam->read() == NOERR;
|
||||
if (!ok && create)
|
||||
{
|
||||
@ -516,7 +517,7 @@ int TLiquidazione_app::count_activities() const
|
||||
{
|
||||
TRelation rel(LF_ATTIV);
|
||||
TRectype& rec = rel.curr();
|
||||
rec.put("CODDITTA", get_firm());
|
||||
rec.put(ATT_CODDITTA, get_firm());
|
||||
TCursor cur(&rel, "", 1, &rec, &rec);
|
||||
return cur.items();
|
||||
}
|
||||
@ -788,7 +789,7 @@ real TLiquidazione_app::result_liq(int month)
|
||||
// risultato esatto della liquidazione del mese month, <0 a credito
|
||||
// > 0 a debito; comprende TUTTI, anche il conguaglio prorata in annuale
|
||||
{
|
||||
real r(0.0);
|
||||
real r;
|
||||
// ulteriori detrazioni, acconti, versamenti,
|
||||
// rettifiche, conguagli sono gia' compresi in R0
|
||||
if (look_lim(month))
|
||||
@ -953,13 +954,14 @@ void TLiquidazione_app::round_al_centesimo(real& d) const
|
||||
// e' scritto sui parametri liquidazione (LIA)
|
||||
// Se si passa 0 (default) vede prende la ditta correntemente in corso di calcolo
|
||||
// Analogamente per l'anno
|
||||
bool TLiquidazione_app::is_differita(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("CODDITTA") : firm;
|
||||
const long d = (firm <= 0) ? _nditte->curr().get_long(NDT_CODDITTA) : firm;
|
||||
const int y = (year <= 0) ? atoi(_year) : year;
|
||||
if (look_lia(d, y > 0, y)) // 26/03/2012 aggiunto ,y)
|
||||
diff = _lia->get_bool("B1");
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
@ -987,23 +989,23 @@ bool TLiquidazione_app::look_conc(TString& uffcon, TString& uffiva)
|
||||
// c'e', dal comune (primo non vuoto) se non
|
||||
|
||||
// Assume _nditte correctly positioned
|
||||
TString ana(_nditte->lfile().get("TIPOA"));
|
||||
TString codana(_nditte->lfile().get("CODANAGR"));
|
||||
const TString4 ana(_nditte->lfile().get("TIPOA"));
|
||||
const TString8 codana(_nditte->lfile().get("CODANAGR"));
|
||||
// look anagrafica
|
||||
TString16 key;
|
||||
|
||||
key.format("%s|%s", (const char *) ana, (const char *) codana);
|
||||
|
||||
const TRectype & anag = cache().get(LF_ANAG, key);
|
||||
if (anag.empty()) return FALSE;
|
||||
if (anag.empty()) return false;
|
||||
|
||||
// becca comune residenza fiscale
|
||||
TString com(anag.get("COMRF"));
|
||||
TString4 com(anag.get("COMRF"));
|
||||
// se non c'e', residenza
|
||||
if (com.empty())
|
||||
com = anag.get("COMRES");
|
||||
|
||||
if (com.empty()) return FALSE;
|
||||
if (com.empty())
|
||||
return false;
|
||||
|
||||
// becca comune
|
||||
key.format("|%s", (const char *) com);
|
||||
@ -1021,7 +1023,8 @@ bool TLiquidazione_app::look_conc(TString& uffcon, TString& uffiva)
|
||||
if (!ucc.empty())
|
||||
uffiva = ucc.get("S0");
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
real TLiquidazione_app::credito_utilizzato(int month, bool iva, bool f24) const
|
||||
@ -1045,3 +1048,4 @@ real TLiquidazione_app::credito_utilizzato(int month, bool iva, bool f24) const
|
||||
|
||||
return credito;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
#include "cg4300.h"
|
||||
|
||||
#include "recset.h"
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
|
||||
void TLiquidazione_app::add_plafond(int month, const char* codatt, int type,
|
||||
const real& howmuch, bool intra)
|
||||
@ -631,25 +633,25 @@ void TLiquidazione_app::zero_diff(int month, const char* codatt)
|
||||
if (!_nditte->is_first_match(LF_ATTIV))
|
||||
return;
|
||||
|
||||
if (month > 12 || (_freqviva == "T" && (month % 3) != 1))
|
||||
if (month > 12 || (_freqviva == "T" && (month % 3) != 1))
|
||||
return;
|
||||
|
||||
#ifdef DBG
|
||||
TString msg; msg.
|
||||
format("Azzeramento IVADIFF mese %s %s attività %s",
|
||||
itom(month), (const char*)_year, codatt);
|
||||
xvtil_statbar_set(msg);
|
||||
#endif
|
||||
|
||||
|
||||
TFast_isamfile fid(LF_IVADIFF);
|
||||
TString query;
|
||||
query << "USE IVADIFF KEY 2";
|
||||
query << "\nFROM ANNOLIQ=" << _year;
|
||||
// Se calcolo gennaio (o marzo trimestrale) azzero tutto l'anno, altrimenti solo il mese selezionato
|
||||
if (month > (_freqviva == "T" ? 3 : 1))
|
||||
query << " MESELIQ=" << month;
|
||||
TISAM_recordset id(query);
|
||||
|
||||
TString msg;
|
||||
msg.format("Azzeramento IVADIFF %s %s attività %s", month <= 12 ? itom(month) : "13ma", (const char*)_year, codatt);
|
||||
TProgress_monitor pi(id.items(), msg, false);
|
||||
TLocalisamfile& file = id.cursor()->file();
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
pi.add_status(1);
|
||||
file.zero("ANNOLIQ");
|
||||
file.zero("MESELIQ");
|
||||
file.zero("IMPORTO");
|
||||
|
@ -553,27 +553,30 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
{
|
||||
const TString8 att(tmpatt);
|
||||
|
||||
for (tab->first(); !tab->eof(); tab->next())
|
||||
tab->zero(); tab->put("CODTAB", _year); // 24-02-2014 partiamo dall'anno giusto!
|
||||
for (int terr = tab->read(_isgteq); terr == NOERR; terr = tab->next())
|
||||
{
|
||||
_DescrItem* d = NULL;
|
||||
// compute
|
||||
const TString80 codtab = tab->get("CODTAB");
|
||||
const TString4 anno = codtab.mid(0,4);
|
||||
const TString8 activity= codtab.mid(4,6);
|
||||
const TString4 codreg = codtab.mid(10,3);
|
||||
const int mese = atoi(codtab.mid(13,2));
|
||||
TString4 codiva = codtab.mid(16,4); codiva.trim();
|
||||
const int tipodet = atoi(codtab.mid(20,1));
|
||||
bool ok = look_reg(codreg);
|
||||
ok |= look_iva(codiva);
|
||||
|
||||
if (!ok) continue;
|
||||
|
||||
tiporeg tipomov = (tiporeg)_reg->get_long("I0");
|
||||
bool corrisp = _reg->get_bool("B0");
|
||||
TString tipoiva = _iva->get("S1");
|
||||
const TString4 codreg = codtab.mid(10,3);
|
||||
if (!look_reg(codreg))
|
||||
continue;
|
||||
|
||||
TString4 codiva = codtab.mid(16,4); codiva.trim();
|
||||
if (!look_iva(codiva))
|
||||
continue;
|
||||
|
||||
tiporeg tipomov = (tiporeg)_reg->get_int("I0");
|
||||
bool corrisp = _reg->get_bool("B0");
|
||||
const TString4 tipoiva = _iva->get("S1");
|
||||
const TString4 other = tab->get("S4");
|
||||
TToken_string s1(tab->get("S1"),'!'); // Imponibile/iva fatture in ritardo
|
||||
TToken_string s1(tab->get("S1"), '!'); // Imponibile/iva fatture in ritardo
|
||||
real rit_imp(s1.get(0));
|
||||
real rit_iva(s1.get(1));
|
||||
|
||||
@ -593,7 +596,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
diffincimp = tab->get_real("R28");
|
||||
diffinciva = tab->get_real("R29");
|
||||
|
||||
diffimp_acq = tab->get_real("R30");
|
||||
diffimp_acq = tab->get_real("R30");
|
||||
diffiva_acq = tab->get_real("R31");
|
||||
diffincimp_acq = tab->get_real("R32");
|
||||
diffinciva_acq = tab->get_real("R33");
|
||||
@ -863,13 +866,12 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
t31 += diffiva_acq;
|
||||
}
|
||||
*/
|
||||
if (!diffincimp.is_zero() || !diffinciva.is_zero() ||
|
||||
if (!diffincimp.is_zero() || !diffinciva.is_zero() ||
|
||||
!diffincimp_acq.is_zero() || !diffinciva_acq.is_zero())
|
||||
{
|
||||
const word id = describe_pis ? PIS_ROW_DI : PIM_ROW_DI;
|
||||
int j;
|
||||
|
||||
d = NULL;
|
||||
int j;
|
||||
for (j = totpos + 1; j < _descr_arr.items(); j++)
|
||||
{
|
||||
_DescrItem* wd = (_DescrItem*)&_descr_arr[j];
|
||||
@ -1243,8 +1245,10 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem*
|
||||
d->_r29 = _lim->get_real("R29"); // fdiffinc_iva_ven
|
||||
d->_r33 = _lim->get_real("R33"); // fdiffinc_iva_acq
|
||||
|
||||
if (atoi(_year) <= 1997) // Dal 1998 in poi il conguaglio prorata non va stampato, ma conglobato nell'iva acquisti
|
||||
/* Dal 1998 in poi il conguaglio prorata non va stampato, ma conglobato nell'iva acquisti
|
||||
if (atoi(_year) <= 1997)
|
||||
d->_r10 = _lim->get_real("R7"); // totale conguaglio prorata
|
||||
*/
|
||||
|
||||
TToken_string tt(80);
|
||||
tt.add(_lam->get_real("R0").string()); // IVA Vendite
|
||||
@ -1638,9 +1642,8 @@ int TLiquidazione_app::calc_inc_diff(int tipoiva, real& imponibile_diff, real& i
|
||||
|
||||
TString limit; limit << "ANNOLIQ=" << _year;
|
||||
if (_month < 13) limit << " MESELIQ=" << _month;
|
||||
TString query; // righe pagamento (TIPOMOV>=3) relative a fatture (TOTDOC>0) ed escluse NC!
|
||||
query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(MOV.TOTDOC>0)&&(TIPOIVA=" << tipoiva << ')'
|
||||
<< "\nJOIN MOV INTO NUMREG==NUMREG"
|
||||
TString query; // righe pagamento (TIPOMOV>=3) ed escluse NC!
|
||||
query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(TIPOIVA=" << tipoiva << ')'
|
||||
<< "\nFROM " << limit << "\nTO " << limit;
|
||||
|
||||
TISAM_recordset id(query);
|
||||
@ -2007,21 +2010,21 @@ void TLiquidazione_app::set_pim(_DescrItem& d)
|
||||
|
||||
if (d._flags == PIM_ROW || d._flags == PIS_ROW)
|
||||
{
|
||||
set_row(rw++,"%4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r",
|
||||
set_row(rw++,"%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r",
|
||||
(const char*)d._s1, (const char*)d._s2,
|
||||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5));
|
||||
}
|
||||
else
|
||||
if (d._flags == PIM_ROW_D || d._flags == PIS_ROW_D)
|
||||
{
|
||||
set_row(rw++,"%4s %s@25g%r@41g%r@91g%r@107g%r",
|
||||
set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r",
|
||||
(const char*)d._s1, (const char*)d._s2,
|
||||
&(d._r26), &(d._r27), &(d._r30), &(d._r31));
|
||||
}
|
||||
else
|
||||
if (d._flags == PIM_ROW_DI || d._flags == PIS_ROW_DI)
|
||||
{
|
||||
set_row(rw++,"%4s %s@25g%r@41g%r@91g%r@107g%r",
|
||||
set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r",
|
||||
(const char*)d._s1, (const char*)d._s2,
|
||||
&(d._r28), &(d._r29), &(d._r32), &(d._r33));
|
||||
}
|
||||
@ -2112,7 +2115,7 @@ void TLiquidazione_app::set_plm(_DescrItem& d)
|
||||
}
|
||||
|
||||
|
||||
void TLiquidazione_app::set_pumpam(_DescrItem& d)
|
||||
void TLiquidazione_app::set_pumpam(const _DescrItem& d)
|
||||
{
|
||||
bool printed = FALSE;
|
||||
|
||||
@ -2455,9 +2458,10 @@ void TLiquidazione_app::print_importo(int rw, const char* prompt, real imp, bool
|
||||
set_row(rw, str, &imp);
|
||||
}
|
||||
|
||||
// d._flags == THE_END
|
||||
void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
|
||||
{
|
||||
const real& risultato = d._r0;
|
||||
real risultato = d._r0; // Figuccia lo puo' cambiare
|
||||
const real& rimborso = d._r1;
|
||||
const real& cred_cost = d._r2;
|
||||
const real& deb_mens = d._r3;
|
||||
@ -2538,6 +2542,8 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
|
||||
real iva_deb_cred = iva_vend - iva_acq + diffinc_iva - diffinc_iva_acq + xcasinc_iva - xcasinc_iva_acq;
|
||||
if (_is_visliq)
|
||||
iva_deb_cred += rett_debt - rett_cred;
|
||||
if (_isannual)
|
||||
iva_deb_cred.round(0);
|
||||
|
||||
print_importo(rw++, TR("IVA a debito o a credito per il periodo"), iva_deb_cred);
|
||||
|
||||
@ -2556,7 +2562,7 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
|
||||
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;
|
||||
if (_month == 13) cre_deb_per += versamenti;
|
||||
|
||||
@ -2566,43 +2572,28 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw)
|
||||
set_row(rw++,FR("%s@11gCrediti speciali%s@58g%r"),
|
||||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &crediti_speciali);
|
||||
|
||||
if (_freqviva == "T" && interessi != ZERO)
|
||||
if (_freqviva == "T" && !interessi.is_zero())
|
||||
set_row(rw++,FR("@11gInteressi dovuti per liquidazioni trimestrali %6.2r%%@75g%r"),&interesse, &interessi);
|
||||
else
|
||||
{
|
||||
if (_is_visliq)
|
||||
rw++;
|
||||
}
|
||||
if (_is_visliq) rw++;
|
||||
|
||||
if (!acc_dec.is_zero())
|
||||
set_row(rw++,FR("%s@11gAcconto versato%s@58g%r"),
|
||||
_is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &acc_dec);
|
||||
else
|
||||
{
|
||||
if (_is_visliq)
|
||||
rw++;
|
||||
}
|
||||
if (_is_visliq) rw++;
|
||||
|
||||
// versamenti effettuati
|
||||
if (!versamenti.is_zero() && (_month==13 || !_is_visliq))
|
||||
{
|
||||
set_row(rw++,FR("@11gVersamenti effettuati@58g%r"), &versamenti);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_is_visliq)
|
||||
rw++;
|
||||
}
|
||||
if (_is_visliq) rw++;
|
||||
|
||||
// versamenti integrativi
|
||||
if (!vers_int.is_zero() && !_is_visliq)
|
||||
{
|
||||
set_row(rw++,FR("@11gVersamenti integrativi@58g%r"), &vers_int);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_is_visliq)
|
||||
rw++;
|
||||
}
|
||||
if (_is_visliq) rw++;
|
||||
|
||||
const real iva = risultato + interessi;
|
||||
if (iva > ZERO)
|
||||
|
@ -546,7 +546,7 @@ bool TLiquidazione_app::recalc_acconto(real& inf, real& ina)
|
||||
real iva_pro = 0.0;
|
||||
real cre_pre = 0.0;
|
||||
real acq_intr = 0.0;
|
||||
const bool isdifferita = is_differita(); // MI3262...
|
||||
const bool isdifferita = is_acconto_differito(); // MI3262...
|
||||
int error = FALSE;
|
||||
|
||||
TString16 tipo_acc;
|
||||
|
@ -1911,7 +1911,7 @@ bool TStampa_registri_app::some_IVAxCassa(int da_mese, int a_mese) const
|
||||
return false;
|
||||
|
||||
TString query;
|
||||
query = "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)";
|
||||
query = "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(MESELIQ<13)";
|
||||
query << "\nFROM ANNOLIQ=" << _data_da.year() << " MESELIQ=" << da_mese;
|
||||
query << "\nTO ANNOLIQ=" << _data_a.year() << " MESELIQ=" << a_mese;
|
||||
TISAM_recordset id(query);
|
||||
@ -1924,8 +1924,7 @@ bool TStampa_registri_app::some_IVAxCassa(int da_mese, int a_mese) const
|
||||
else
|
||||
msg << "Nel mese di " << itom(da_mese);
|
||||
msg << " ci sarebbero " << recs << " incassi/pagamenti per cassa.";
|
||||
xvtil_statbar_set(msg);
|
||||
xvt_sys_sleep(1000);
|
||||
__trace(msg);
|
||||
#endif
|
||||
|
||||
return recs > 0;
|
||||
@ -1959,7 +1958,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month)
|
||||
}
|
||||
|
||||
TString query;
|
||||
query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(MOV.TOTDOC>0))";
|
||||
query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(STR((MESELIQ<13)&&(TIPOMOV>2)&&(MOV.TOTDOC>0)))";
|
||||
query << "\nBY DATAREGP DATAREG NUMPRO";
|
||||
query << "\nJOIN MOV INTO NUMREG==NUMREG";
|
||||
query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF";
|
||||
@ -1980,7 +1979,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month)
|
||||
else
|
||||
msg << "Nel mese di " << itom(da_month);
|
||||
msg << " ci sono effettivamente " << recs << " incassi/pagamenti per cassa.";
|
||||
xvtil_statbar_set(msg);
|
||||
__trace(msg);
|
||||
#endif
|
||||
|
||||
if (recs > 0)
|
||||
|
@ -256,23 +256,15 @@ bool TAp_eser::check_esercizio(const int cod_es, TDate s1, TDate f1)
|
||||
|
||||
int cg4500 (int argc, char* argv[])
|
||||
{
|
||||
switch (toupper(*argv[2]))
|
||||
if (toupper(*argv[2]) == 'I')
|
||||
{
|
||||
case 'C':
|
||||
{
|
||||
TAp_eser a;
|
||||
a.run(argc, argv, TR("Apertura nuovo esercizio"));
|
||||
}
|
||||
break;
|
||||
case 'I':
|
||||
{
|
||||
TAp_iva a;
|
||||
a.run(argc, argv, TR("Apertura nuovo esercizio IVA"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_box("Uso: cg4 -4 [C,I]");
|
||||
break;
|
||||
TAp_iva a;
|
||||
a.run(argc, argv, TR("Apertura nuovo esercizio IVA"));
|
||||
}
|
||||
else
|
||||
{
|
||||
TAp_eser a;
|
||||
a.run(argc, argv, TR("Apertura nuovo esercizio"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <relation.h>
|
||||
#include <tabutil.h>
|
||||
|
||||
|
||||
#include <nditte.h>
|
||||
|
||||
bool TAp_iva::mask_annoiva (TMask_field& f, KEY k)
|
||||
@ -17,7 +16,7 @@ bool TAp_iva::mask_annoiva (TMask_field& f, KEY k)
|
||||
if (annoivap > 0 && annoiva != annoivap + 1)
|
||||
return f.error_box(FR("Il nuovo anno esercizio IVA deve essere %d"), (annoivap+1));
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TAp_iva::create()
|
||||
@ -28,6 +27,7 @@ bool TAp_iva::create()
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
/*
|
||||
void TAp_iva::libro_unico()
|
||||
{
|
||||
TString4 annoiva;
|
||||
@ -64,6 +64,7 @@ void TAp_iva::libro_unico()
|
||||
lbu.write();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
bool TAp_iva::apertura_iva()
|
||||
{
|
||||
@ -153,8 +154,7 @@ bool TAp_iva::apertura_iva()
|
||||
}
|
||||
|
||||
//viene aggiornato l'anno iva sui parametri ditta
|
||||
TConfig conf(CONFIG_DITTA);
|
||||
conf.set("AnLiIv", annoiva);
|
||||
ini_set_int(CONFIG_DITTA, "cg", "AnLiIv", _annoiva);
|
||||
|
||||
//sull'anagrafica ditte viene aggiornata la frequenza versamento
|
||||
TLocalisamfile nditte (LF_NDITTE);
|
||||
|
@ -232,7 +232,7 @@ class TDich_periodica_iva_mask : public TAutomask
|
||||
_is_euro; // importi in euro
|
||||
protected:
|
||||
void read_iva_data();
|
||||
real imposta_diff() const;
|
||||
real imposta_diff(int tipo) const;
|
||||
|
||||
public:
|
||||
void set_prospect();
|
||||
@ -261,7 +261,8 @@ TDich_periodica_iva_mask::TDich_periodica_iva_mask(TDich_periodica_selfirm_mask
|
||||
}
|
||||
}
|
||||
|
||||
real TDich_periodica_iva_mask::imposta_diff() const
|
||||
// tipo=1 vendite; 2 = acquisti
|
||||
real TDich_periodica_iva_mask::imposta_diff(int tipo) const
|
||||
{
|
||||
real imposta;
|
||||
|
||||
@ -270,8 +271,9 @@ real TDich_periodica_iva_mask::imposta_diff() const
|
||||
const TDate data_a(31,12,anno);
|
||||
|
||||
TString query;
|
||||
query = "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(TIPOMOV>2)&&(STR(MOV.TOTDOC>0))";
|
||||
query << "\nBY DATAREGP DATAREG";
|
||||
query << "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(STR("
|
||||
<< "(MOV.TOTDOC>0)&&(TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')'
|
||||
<< "))";
|
||||
query << "\nJOIN MOV INTO NUMREG==NUMREG";
|
||||
TISAM_recordset id(query);
|
||||
id.set_var("#DAL", data_da);
|
||||
@ -360,12 +362,13 @@ void TDich_periodica_iva_mask::read_iva_data()
|
||||
const real rettifica = lim.get_real("R5"); // Rettifiche
|
||||
|
||||
real cd4 = lam.get_real("R0"); // Iva esigibile per il periodo
|
||||
cd4 += imposta_diff();
|
||||
cd4 += imposta_diff(1);
|
||||
if (rettifica > ZERO)
|
||||
cd4 += rettifica;
|
||||
cd4.round();
|
||||
|
||||
real cd5 = lam.get_real("R1"); // Iva che si detrae per il periodo
|
||||
cd5 += imposta_diff(2);
|
||||
if (rettifica < ZERO && !exclude_sign)
|
||||
cd5 += abs(rettifica);
|
||||
cd5.round();
|
||||
|
@ -181,7 +181,8 @@ Item_09 = "Correzione righe di prima nota", "cg1 -2 Z", "FP"
|
||||
Item_10 = "Impostazione mese liquidazione", "cg1 -2 M", "FP"
|
||||
Item_11 = "Controllo P.I. e C.F. clienti/fornitori", "cg1 -2 L", "FP"
|
||||
Item_12 = "Allineamento IBAN su Banche x Cliente", "cg1 -2 B", "FP"
|
||||
Item_13 = "Collegamento bilanci", [CGMENU_025]
|
||||
Item_13 = "Controllo integrità archivi", "cg1 -2 X", "F"
|
||||
Item_14 = "Collegamento bilanci", [CGMENU_025]
|
||||
|
||||
[CGMENU_019]
|
||||
Caption = "Invio"
|
||||
|
@ -1166,17 +1166,29 @@ int TRiga_partite::calcola_pagato_periodo(const TDate& dal, const TDate& al, TIm
|
||||
}
|
||||
}
|
||||
|
||||
// Ordino i pagamenti per DATAPAG/NRATA/NRIGP
|
||||
for (int i = 0; i < pags.items(); i++)
|
||||
{
|
||||
for (int j = i+1; j < pags.items(); j++)
|
||||
{
|
||||
const TRectype& pi = *(TRectype*)pags.objptr(i);
|
||||
const TRectype& pj = *(TRectype*)pags.objptr(j);
|
||||
const TRiga_partite& si = partita().riga(pi.get_int(PAGSCA_NRIGP));
|
||||
const TRiga_partite& sj = partita().riga(pj.get_int(PAGSCA_NRIGP));
|
||||
const int ni = pi.get_int(PAGSCA_NRIGP);
|
||||
const int nj = pj.get_int(PAGSCA_NRIGP);
|
||||
const TRiga_partite& si = partita().riga(ni);
|
||||
const TRiga_partite& sj = partita().riga(nj);
|
||||
const TDate di = si.get(PART_DATAPAG);
|
||||
const TDate dj = sj.get(PART_DATAPAG);
|
||||
if (di > dj)
|
||||
long cmp = di - dj;
|
||||
if (cmp == 0)
|
||||
{
|
||||
const int ri = pi.get_int(PAGSCA_NRATA);
|
||||
const int rj = pj.get_int(PAGSCA_NRATA);
|
||||
cmp = ri - rj;
|
||||
if (cmp == 0)
|
||||
cmp = ni - nj;
|
||||
}
|
||||
if (cmp > 0)
|
||||
pags.swap(i, j);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user