Aggiunta gestione IVA per cassa
git-svn-id: svn://10.65.10.50/branches/R_10_00@22755 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b4692685a8
commit
200b962343
@ -384,8 +384,7 @@ bool TClifo_application::crea_percipienti(TMask_field& f, KEY key)
|
||||
{
|
||||
if (tipo == 'F')
|
||||
{
|
||||
TLocalisamfile anafis(LF_ANAGFIS);
|
||||
|
||||
TLocalisamfile anafis(LF_ANAGFIS);
|
||||
anafis.put(ANF_CODANAGR, percip);
|
||||
anafis.put(ANF_DATANASC, m.get(F_DATANASC));
|
||||
anafis.put(ANF_SESSO, atoi(m.get(F_COFI).mid(9, 2)) > 31 ? 'F' : 'M');
|
||||
@ -397,9 +396,7 @@ bool TClifo_application::crea_percipienti(TMask_field& f, KEY key)
|
||||
else
|
||||
{
|
||||
TLocalisamfile anagiu(LF_ANAGGIU);
|
||||
|
||||
anagiu.put(ANG_CODANAGR, percip);
|
||||
|
||||
err = anagiu.write();
|
||||
if (err != NOERR)
|
||||
return cantwrite_box(anagiu.description());
|
||||
|
@ -14,6 +14,5 @@ int main(int argc,char** argv)
|
||||
default:
|
||||
cg2100(argc, argv); break;
|
||||
}
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1557,7 +1557,7 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm)
|
||||
case 2: // Regolarizzazione IVA
|
||||
{
|
||||
// Reperisce l'eventuale cliente associato al fornitore e lo propone
|
||||
TString16 forn; forn.format("F|%ld", _automatico->_clifo.codclifo());
|
||||
TString8 forn; forn.format("F|%ld", _automatico->_clifo.codclifo());
|
||||
const TString& clnt = cache().get(LF_CLIFO, forn, CLI_CODCFASS);
|
||||
m.set(F_CLIENTE, clnt);
|
||||
m.set(F_TOTALE, _automatico->_totale); // Imposta il totale documento e ...
|
||||
@ -1719,6 +1719,7 @@ bool TPrimanota_application::link_m770()
|
||||
}
|
||||
}
|
||||
else // Movimento puramente contabile
|
||||
{
|
||||
switch (m770)
|
||||
{
|
||||
case 1:
|
||||
@ -1739,6 +1740,7 @@ bool TPrimanota_application::link_m770()
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tipo_coll)
|
||||
@ -1760,7 +1762,7 @@ bool TPrimanota_application::link_m770()
|
||||
s.add(imposte.string());
|
||||
s.add(ritenute.string());
|
||||
|
||||
const char* name = (tipo_coll == 4) ? "770 -1" : "770 -0";
|
||||
const char* const name = (tipo_coll == 4) ? "770 -1" : "770 -0";
|
||||
TMessage m(name, "LINK770", s);
|
||||
m.send();
|
||||
|
||||
|
@ -77,6 +77,7 @@
|
||||
#define F_ADJUST_IVA 148
|
||||
#define F_DATAINC 149
|
||||
#define F_LIQDIFF 150
|
||||
#define F_IVAXCASSA 167
|
||||
|
||||
#define F_GRUPPO 180
|
||||
#define F_CONTO 181
|
||||
|
@ -592,22 +592,28 @@ BEGIN
|
||||
FIELD DATA74TER
|
||||
END
|
||||
|
||||
BOOLEAN F_IVAXCASSA
|
||||
BEGIN
|
||||
PROMPT 1 17 "IVA per cassa"
|
||||
FIELD IVAXCASSA
|
||||
MODULE IC
|
||||
END
|
||||
|
||||
BOOLEAN F_LIQDIFF
|
||||
BEGIN
|
||||
PROMPT 38 15 "Liq.differita"
|
||||
PROMPT 25 17 "Liquidazione differita"
|
||||
WARNING "Data di incasso per liquidazione differita"
|
||||
FIELD LIQDIFF
|
||||
MESSAGE FALSE HIDE,F_DATAINC|RESET,F_DATAINC
|
||||
MESSAGE TRUE SHOW,F_DATAINC
|
||||
MESSAGE FALSE CLEAR,F_DATAINC
|
||||
MESSAGE TRUE ENABLE,F_DATAINC
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
DATE F_DATAINC
|
||||
BEGIN
|
||||
PROMPT 54 15 "Data incasso "
|
||||
PROMPT 52 17 "Data incasso "
|
||||
WARNING "Data di incasso per liquidazione differita"
|
||||
FIELD DATAINC
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
NUMBER F_ANNORIF 4
|
||||
@ -626,7 +632,7 @@ END
|
||||
|
||||
STRING F_VALUTAINTRA 3
|
||||
BEGIN
|
||||
PROMPT 1 17 "Cambio intracom. "
|
||||
PROMPT 1 18 "Cambio intracom. "
|
||||
FIELD CODVALI
|
||||
FLAGS "UZ"
|
||||
GROUP 4
|
||||
@ -644,7 +650,7 @@ END
|
||||
|
||||
NUMBER F_CAMBIOINTRA 15 6
|
||||
BEGIN
|
||||
PROMPT 25 17 ""
|
||||
PROMPT 25 18 ""
|
||||
FIELD CAMBIOI
|
||||
FLAGS "U"
|
||||
GROUP 4
|
||||
@ -653,20 +659,20 @@ END
|
||||
|
||||
DATE F_DATAINTRA
|
||||
BEGIN
|
||||
PROMPT 43 17 "Data competenza intra "
|
||||
PROMPT 43 18 "Data competenza intra "
|
||||
FIELD DATACOMPI
|
||||
END
|
||||
|
||||
CURRENCY F_CORRISPETTIVO 18
|
||||
BEGIN
|
||||
PROMPT 1 18 "Corrispettivo "
|
||||
PROMPT 1 19 "Corrispettivo "
|
||||
FIELD CORRLIRE
|
||||
GROUP 4
|
||||
END
|
||||
|
||||
CURRENCY F_CORRVALUTA 18
|
||||
BEGIN
|
||||
PROMPT 39 18 "Corrispet. valuta "
|
||||
PROMPT 39 19 "Corrispet. valuta "
|
||||
FIELD CORRVALUTA
|
||||
GROUP 4
|
||||
VALIDATE REQIF_FUNC 1 F_VALUTAINTRA
|
||||
@ -675,7 +681,7 @@ END
|
||||
|
||||
STRING NP_CONTSEP 6
|
||||
BEGIN
|
||||
PROMPT 1 19 "Cont. separata "
|
||||
PROMPT 1 20 "Cont. separata "
|
||||
USE &NPENT
|
||||
INPUT CODTAB NP_CONTSEP
|
||||
DISPLAY "Codice@6" CODTAB
|
||||
@ -688,7 +694,7 @@ END
|
||||
|
||||
STRING NP_DESCONTSEP 50
|
||||
BEGIN
|
||||
PROMPT 25 19 ""
|
||||
PROMPT 25 20 ""
|
||||
USE &NPENT KEY 2
|
||||
INPUT S0 NP_DESCONTSEP
|
||||
DISPLAY "Descrizione@50" S0
|
||||
|
@ -217,7 +217,7 @@ int TMovimentoPN::registra(bool re, bool force)
|
||||
const int annoiva = m.get_int(MOV_ANNOIVA);
|
||||
const TString4 reg(m.get(MOV_REG));
|
||||
TRegistro registro(reg, annoiva);
|
||||
const bool att_mista = reg.empty() ? FALSE : registro.attivita_mista();
|
||||
const bool att_mista = reg.empty() ? false : registro.attivita_mista();
|
||||
|
||||
for (int i = 0 ; i < iva_items(); i++)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <automask.h>
|
||||
#include <colors.h>
|
||||
#include <dongle.h>
|
||||
#include <execp.h>
|
||||
#include <msksheet.h>
|
||||
#include <progind.h>
|
||||
@ -2241,7 +2242,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
const TDate oggi(TODAY);
|
||||
TDate dr(f.get()); // Data dell'operazione
|
||||
if (dr > oggi)
|
||||
return f.error_box(TR("La data dell'operazione e' superiore quella di sistema"));
|
||||
return f.error_box(TR("La data dell'operazione è superiore quella di sistema"));
|
||||
|
||||
TMask& m = f.mask();
|
||||
if (dr == oggi && m.query_mode() && !m.field(F_NUMREG).empty())
|
||||
@ -2270,6 +2271,8 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
|
||||
if (key == K_ENTER || f.focusdirty())
|
||||
{
|
||||
m.enable(F_IVAXCASSA, a.gestione_IVAxCassa(dr));
|
||||
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
const bool error = numreg == 0 || numreg > a._lastreg;
|
||||
|
||||
@ -2301,8 +2304,8 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
a.read_caus(m.get(F_CODCAUS), ar);
|
||||
|
||||
TRegistro& reg = a.causale().reg();
|
||||
const TString codreg(reg.name());
|
||||
if (codreg.not_empty())
|
||||
const TString4 codreg = reg.name();
|
||||
if (codreg.full())
|
||||
{
|
||||
if (reg.year() != ar)
|
||||
{
|
||||
@ -2715,7 +2718,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
const bool del = f.yesno_box(TR("Si desidera cancellare i pagamenti effettuati?"));
|
||||
if (!del) // Ripristina codice copiandolo dalla prima partita
|
||||
{
|
||||
TString cod; cod << game->conto().codclifo();
|
||||
TString8 cod; cod << game->conto().codclifo();
|
||||
f.set(cod);
|
||||
return true;
|
||||
}
|
||||
@ -2805,7 +2808,6 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
m.set(FS_NSCAB, clifov.get(CFV_CODCABPR));
|
||||
m.send_key(K_TAB, FS_NSCAB);
|
||||
}
|
||||
|
||||
const TString& agente = clifov.get(CLI_CODAG);
|
||||
if (agente.full())
|
||||
{
|
||||
@ -2826,7 +2828,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
|
||||
if (occas && a.is_fattura() && a.partite().first() != NULL)
|
||||
{
|
||||
f.warning_box(TR("Attenzione, il saldaconto verra' eliminato!"));
|
||||
f.warning_box(TR("Attenzione, il saldaconto verrà eliminato!"));
|
||||
f.set_dirty(); // warning_box cleans the field!
|
||||
}
|
||||
a.activate_numrif(m, true);
|
||||
@ -2836,6 +2838,12 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
a.add_cgs_tot(m);
|
||||
if (occas && a.occas_mask().get(O_CODICE).blank())
|
||||
m.send_key(K_SPACE, F_OCCASEDIT); // Lancia maschera occasionali
|
||||
|
||||
if (m.field(F_IVAXCASSA).active())
|
||||
{
|
||||
const int alleg = clifo.get_int(CLI_ALLEG);
|
||||
m.set(F_IVAXCASSA, alleg != 6);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -3275,6 +3283,25 @@ bool TPrimanota_application::corrvaluta_handler(TMask_field& f, KEY key)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::gestione_IVAxCassa(const TDate& data) const
|
||||
{
|
||||
bool yes = has_module(ICAUT);
|
||||
if (yes)
|
||||
{
|
||||
TString16 codtab;
|
||||
codtab.format("%05ld%04d", get_firm(), data.year());
|
||||
const TRectype& lia = cache().get("%LIA", codtab);
|
||||
yes = lia.get_bool("B5");
|
||||
if (yes)
|
||||
{
|
||||
TDate dal = lia.get("D0"); if (!dal.ok()) dal = TDate(1,1,data.year());
|
||||
TDate al = lia.get("D1"); if (!al.ok()) dal = TDate(31,12,data.year());
|
||||
yes = data >= dal && data <= al;
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::activate_numrif(TMask& m, bool init_pag)
|
||||
{
|
||||
// Il numero riferimento esiste
|
||||
|
@ -206,7 +206,8 @@ protected:
|
||||
char clifo() const { return iva() == iva_vendite ? 'C' : 'F'; }
|
||||
bool gestione_valuta() const { return _ges_val; }
|
||||
bool gestione_saldaconto() const { return _ges_sal; }
|
||||
bool npart_is_prot() { return _npart_is_prot; }
|
||||
bool npart_is_prot() const { return _npart_is_prot; }
|
||||
bool gestione_IVAxCassa(const TDate& data) const;
|
||||
|
||||
bool is_saldaconto() const { return _is_saldaconto; }
|
||||
bool is_fattura() const { return is_saldaconto() && causale().tipomov() == 1; }
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <isam.h>
|
||||
#include <mask.h>
|
||||
#include <progind.h>
|
||||
#include <recset.h>
|
||||
#include <relation.h>
|
||||
#include <sort.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -71,8 +73,7 @@ bool CG4100_App::sort_sal()
|
||||
if (!set_parms())
|
||||
return FALSE;
|
||||
|
||||
TSystemisamfile saldi(LF_SALDI); saldi.open(_excllock);
|
||||
TLocalisamfile rmov(LF_RMOV);
|
||||
TSystemisamfile saldi(LF_SALDI); saldi.open(_excllock);
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
TSaldo_agg sal;
|
||||
|
||||
@ -82,12 +83,8 @@ bool CG4100_App::sort_sal()
|
||||
int gruppo, conto;
|
||||
const int year = _year;
|
||||
long oldnumreg = 0L, sottoconto;
|
||||
TProgind prnd(rmov.items(),
|
||||
TR("Riordino archivio saldi in corso\nLettura archivio movimenti..."),
|
||||
FALSE,TRUE);
|
||||
|
||||
mov.setkey(1);
|
||||
rmov.first();
|
||||
sal.reset();
|
||||
sal.set_anno_es(year);
|
||||
sal.clear_saldi(year);
|
||||
@ -95,9 +92,20 @@ bool CG4100_App::sort_sal()
|
||||
tiposal tsal = normale;
|
||||
bool provvis = FALSE;
|
||||
TDate datareg;
|
||||
|
||||
TString query; query << "USE RMOV SELECT ANNOES=" << _year;
|
||||
TISAM_recordset righe(query);
|
||||
|
||||
TProgind prnd(righe.items(),
|
||||
TR("Riordino archivio saldi in corso\nLettura archivio movimenti..."),
|
||||
FALSE, TRUE);
|
||||
|
||||
const TRectype& rmov = righe.cursor()->curr();
|
||||
|
||||
while (!rmov.eof())
|
||||
for (bool ok = righe.move_first(); ok; ok = righe.move_next())
|
||||
{
|
||||
if (!prnd.addstatus(1))
|
||||
break;
|
||||
if (_year == rmov.get_int(RMV_ANNOES))
|
||||
{
|
||||
numreg = rmov.get_long(RMV_NUMREG);
|
||||
@ -109,10 +117,10 @@ bool CG4100_App::sort_sal()
|
||||
|
||||
if (numreg != oldnumreg)
|
||||
{
|
||||
if (oldnumreg !=0)
|
||||
if (sal.items() > 0)
|
||||
{
|
||||
if (sal.items() > 0)
|
||||
sal.registra();
|
||||
sal.registra();
|
||||
sal.reset();
|
||||
}
|
||||
oldnumreg = numreg;
|
||||
mov.zero();
|
||||
@ -123,25 +131,20 @@ bool CG4100_App::sort_sal()
|
||||
// Tipo saldo normale per default
|
||||
tsal = normale;
|
||||
const TString& codcaus = mov.get(MOV_CODCAUS);
|
||||
if (codcaus.not_empty()) // cerca causale per determinare il tipo del saldo
|
||||
const TRectype& causale = cache().get(LF_CAUSALI, codcaus);
|
||||
if (!causale.empty())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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.reset();
|
||||
sal.set_anno_es(_year);
|
||||
sal.set_tipo_saldo(tsal);
|
||||
sal.set_movprovv(provvis);
|
||||
@ -149,21 +152,16 @@ bool CG4100_App::sort_sal()
|
||||
sal.set_num_ulmov(oldnumreg);
|
||||
}
|
||||
const char sezione = rmov.get(RMV_SEZIONE)[0];
|
||||
real importo(rmov.get(RMV_IMPORTO));
|
||||
const real importo = rmov.get(RMV_IMPORTO);
|
||||
|
||||
sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, TRUE, scaricato);
|
||||
}
|
||||
rmov.next();
|
||||
prnd.addstatus(1);
|
||||
do_events();
|
||||
}
|
||||
|
||||
if (sal.items() > 0)
|
||||
sal.registra();
|
||||
sal.registra();
|
||||
|
||||
remove("__sal__.sav");
|
||||
saldi.close();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
int cg4100(int argc, char* argv[])
|
||||
|
@ -80,7 +80,7 @@ inline TLiquidazione_app& app()
|
||||
{ return (TLiquidazione_app&)main_app(); }
|
||||
|
||||
TLiquidazione_app::TLiquidazione_app(int m) :
|
||||
_ditte(NULL), _selected(10000),
|
||||
_ditte(NULL), _selected(16),
|
||||
_year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
|
||||
{
|
||||
_isprint = _is_interactive = _canprint = true;
|
||||
@ -517,7 +517,8 @@ bool TLiquidazione_app::set_print(int)
|
||||
{
|
||||
if (_selected.ones() > 0l)
|
||||
return recalc_all() && _isprint;
|
||||
else warning_box(TR("Nessuna ditta selezionata!"));
|
||||
else
|
||||
warning_box(TR("Nessuna ditta selezionata!"));
|
||||
}
|
||||
break;
|
||||
case 2: // estrazione deleghe
|
||||
@ -558,7 +559,8 @@ bool TLiquidazione_app::set_print(int)
|
||||
|
||||
long TLiquidazione_app::select_firm_range(long from, long to, wht freq)
|
||||
{
|
||||
if (to == 0l) to = 99999L;
|
||||
if (to < from)
|
||||
to = 99999L;
|
||||
|
||||
for (int i = 0; i < _ditte->items(); i++)
|
||||
{
|
||||
@ -591,9 +593,8 @@ long TLiquidazione_app::select_firm_range(long from, long to, wht freq)
|
||||
bool TLiquidazione_app::ch_year_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
|
||||
TWait_cursor hourglass;
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
app().reset_choices(f.mask());
|
||||
app().set_year(f.get());
|
||||
app().build_nomiditte();
|
||||
@ -711,13 +712,14 @@ bool TLiquidazione_app::what_freq_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (month > 3)
|
||||
while (!is_trim(month)) month--;
|
||||
else month = 3;
|
||||
else
|
||||
month = 3;
|
||||
|
||||
f.mask().set(CG43_LST_TRIM,month);
|
||||
}
|
||||
app().set_month(month);
|
||||
app().reset_choices(f.mask());
|
||||
app().build_ditte_sheet((wht)atoi(f.get()));
|
||||
app().reset_choices(f.mask());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -794,29 +796,32 @@ bool TLiquidazione_app::chk_final_handler(TMask_field& f, KEY key)
|
||||
void TLiquidazione_app::reset_choices(TMask& m)
|
||||
{
|
||||
_selected.reset();
|
||||
_ditte->check(-1, FALSE);
|
||||
if (m.source_file() == "cg4300a.msk")
|
||||
{
|
||||
m.reset(CG43_FLD_SELECTED);
|
||||
m.reset(CG43_FLD_DFR);
|
||||
m.reset(CG43_FLD_DTO);
|
||||
const long ditta = get_firm();
|
||||
m.set(CG43_FLD_DFR, ditta, 0x2);
|
||||
m.set(CG43_FLD_DTO, ditta, 0x2);
|
||||
const wht freq = (wht)m.get_int(CG43_RDB_VERS);
|
||||
select_firm_range(ditta, ditta, freq);
|
||||
set_choice_limits(m);
|
||||
}
|
||||
_ditte->check(-1, FALSE);
|
||||
}
|
||||
|
||||
void TLiquidazione_app::set_choice_limits(TMask& m)
|
||||
{
|
||||
long first = -1l, last = -1l;
|
||||
long first = 0, last = 0;
|
||||
for (int i = 0; i < _ditte->items(); i++)
|
||||
{
|
||||
if (_selected[i])
|
||||
{
|
||||
const long dit = _ditte->row(i).get_long(1);
|
||||
if (first == -1l) first = dit;
|
||||
if (last < dit) last = dit;
|
||||
if (first <= 0) first = dit;
|
||||
if (last < dit) last = dit;
|
||||
}
|
||||
}
|
||||
if (first != -1) m.set(CG43_FLD_DFR, first);
|
||||
if (last != -1) m.set(CG43_FLD_DTO, last);
|
||||
m.set(CG43_FLD_DFR, first, 0x2);
|
||||
m.set(CG43_FLD_DTO, last, 0x2);
|
||||
m.set(CG43_FLD_SELECTED, _selected.ones());
|
||||
}
|
||||
|
||||
@ -867,10 +872,8 @@ bool TLiquidazione_app::set_liquidazione()
|
||||
m.set_handler(CG43_BUT_SEL, select_button);
|
||||
m.set_handler(CG43_BUT_ANN, reset_button);
|
||||
m.set_handler(CG43_CHK_FINAL, chk_final_handler);
|
||||
|
||||
m.set(CG43_FLD_SELECTED, _selected.ones());
|
||||
|
||||
m.set(CG43_FLD_ANNO, _year);
|
||||
set_choice_limits(m);
|
||||
|
||||
// stampa abilitata per default
|
||||
m.set(CG43_CHK_STAMPA,"X");
|
||||
|
29
cg/cg4300.h
29
cg/cg4300.h
@ -177,10 +177,8 @@ public:
|
||||
TDate _d0;
|
||||
real _diff_ven_ap, _diff_ven_ap_iva, _diff_acq_ap, _diff_acq_ap_iva;
|
||||
|
||||
_DescrItem(word f) : _f0(0), _f1(0), _f2(0)
|
||||
{ _flags = f; }
|
||||
virtual ~_DescrItem()
|
||||
{ }
|
||||
_DescrItem(word f) : _flags(f), _f0(0), _f1(0), _f2(0) { }
|
||||
virtual ~_DescrItem() { }
|
||||
};
|
||||
|
||||
class _ErrItem : public TObject
|
||||
@ -189,8 +187,7 @@ class _ErrItem : public TObject
|
||||
public:
|
||||
|
||||
TString _err;
|
||||
TString _att;
|
||||
TString _firm;
|
||||
TString8 _att, _firm;
|
||||
_ErrItem(const char* err, const char* att, const char* firm)
|
||||
{ _err = err; _att = att; _firm = firm; }
|
||||
virtual ~_ErrItem() {}
|
||||
@ -245,7 +242,7 @@ class TLiquidazione_app : public TPrint_application
|
||||
wht _what;
|
||||
TBit_array _selected;
|
||||
int _menu; // 1 = Liquidazione, 2 = Deleghe, 3 = Acconti
|
||||
TString16 _year; // anno di calcolo
|
||||
TString4 _year; // anno di calcolo
|
||||
int _month; // mese da calcolare
|
||||
TDate _date; // data di stampa
|
||||
bool _isprint; // vuoi stampare o no?
|
||||
@ -281,7 +278,7 @@ class TLiquidazione_app : public TPrint_application
|
||||
bool _riepilogo; // stampa riepilogo sul registro
|
||||
bool _sind11; // somma imposte non detraibili in trasferimento IVA11 (da configurazione dati studio)
|
||||
tbc _basecalc; // tipo base di calcolo acconto
|
||||
TString16 _freqviva; // frequenza versamenti (M|T)
|
||||
TString4 _freqviva; // frequenza versamenti (M|T)
|
||||
long _n_ditte; // numero ditte
|
||||
bool _comp_acconto; // stiamo calcolando l'acconto
|
||||
TArray _nomiditte; // array descr. ditte per sheet
|
||||
@ -450,7 +447,11 @@ protected:
|
||||
static bool chk_final_handler(TMask_field& f, KEY key);
|
||||
|
||||
static TLiquidazione_app& app() { return (TLiquidazione_app&)main_app(); }
|
||||
bool print_diff_log(int& rw);
|
||||
|
||||
bool residuo_da_liquidare(long numreg, int numrig, const TDate& last_pag,
|
||||
real& importo_res, real& imponibile_res, real& imposta_res) const;
|
||||
bool print_inc_diff_log(int& rw, int tipoatt);
|
||||
bool print_dainc_diff_log(int& rw, int tipoatt);
|
||||
|
||||
public:
|
||||
|
||||
@ -509,17 +510,15 @@ public:
|
||||
// Ritorna il valore dell'iva da riportare (solitamente 50500)
|
||||
real iva_da_riportare(int month);
|
||||
|
||||
// Funzione personale di arrotondamento alle 1000 LIRE o all'euro.
|
||||
// Risolve il seguente problema: da 0 a 500 lire arrotonda alle mille inferiori
|
||||
// da 501 a 999 arrotonda alle mille superiori.
|
||||
// Funzione personale di arrotondamento all'euro.
|
||||
void round_imposta(real& d) const;
|
||||
// Funzione personale di arrotondamento alla lira o centesimo di euro.
|
||||
void round_alla_lira(real& d, bool superiore = FALSE);
|
||||
void round_al_centesimo(real& d) const;
|
||||
|
||||
// supporto stampa
|
||||
void describe_firm(int month);
|
||||
void describe_att(int month, const char* codatt, bool isresult, char flags);
|
||||
void describe_name(int month, TToken_string& atts, char flags);
|
||||
void describe_name(int month, const TToken_string& atts, char flags);
|
||||
void describe_plafond(int month, const char* codatt);
|
||||
void describe_ventilation(int month, const char* codatt);
|
||||
void describe_agricolo(int month, const char* codatt);
|
||||
@ -584,7 +583,7 @@ public:
|
||||
void set_att(_DescrItem& d);
|
||||
void set_pim(_DescrItem& d);
|
||||
void set_pumpam(_DescrItem& d);
|
||||
void set_plm_diff(_DescrItem& d);
|
||||
void set_plm_diff(const _DescrItem& d);
|
||||
void set_plm(_DescrItem& d);
|
||||
bool set_annual(_DescrItem& d);
|
||||
void set_grand(_DescrItem& d);
|
||||
|
704
cg/cg4301.cpp
704
cg/cg4301.cpp
@ -7,6 +7,7 @@
|
||||
#include <config.h>
|
||||
#include <modaut.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <progind.h>
|
||||
#include <sheet.h>
|
||||
|
||||
@ -157,7 +158,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
// Ritorna FALSE soltanto se il ricalcolo era necessario e non e'
|
||||
// stato effettuato per scelta dello stronzo commercialista.
|
||||
|
||||
TConfig c(CONFIG_DITTA);
|
||||
TConfig c(CONFIG_DITTA, "cg");
|
||||
|
||||
_isdiff = c.get_bool("GesLiqDiff");
|
||||
if (_isdiff)
|
||||
@ -170,7 +171,6 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
if (month == 13 && recalc)
|
||||
{
|
||||
TTable pem("PEM");
|
||||
|
||||
for (int reg = 0; reg < 23; reg++)
|
||||
{
|
||||
look_pem(pem, reg);
|
||||
@ -194,25 +194,23 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
_monthinatt = 1;
|
||||
const TDate inatt = _nditte->curr().get("DINIZIOATT");
|
||||
if (is_in_liq_period(inatt))
|
||||
_isdifferita = FALSE;
|
||||
_isdifferita = false;
|
||||
if (inatt.year() == atoi(_year))
|
||||
_monthinatt = inatt.month();
|
||||
|
||||
{
|
||||
TConfig cnf1(CONFIG_STUDIO, "cg");
|
||||
_isricacq = cnf1.get_bool("RicAcq") && month == 13;
|
||||
}
|
||||
_isricacq = (month == 13) && ini_get_bool(CONFIG_STUDIO, "cg", "RicAcq");
|
||||
|
||||
// ricalcolo normale
|
||||
// lim c'e' solo per i trimestri
|
||||
bool ok = _lim->get_bool("B0");
|
||||
if (ok && !recalc) return TRUE;
|
||||
if (ok && !recalc)
|
||||
return true;
|
||||
if (_recalc_regis)
|
||||
ok = FALSE; // Se sta ricalcolando i PRM/PRP se ne sbatte delle LIM
|
||||
ok = false; // Se sta ricalcolando i PRM/PRP se ne sbatte delle LIM
|
||||
bool calc = (_recalc == ever || (_recalc == one && is_month_ok(month,_month)));
|
||||
if (!calc && _recalc != never) calc = !ok;
|
||||
bool gheravergot = FALSE;
|
||||
bool quater = FALSE;
|
||||
bool gheravergot = false;
|
||||
bool quater = false;
|
||||
|
||||
TToken_string atts;
|
||||
TToken_string cattivs;
|
||||
@ -232,9 +230,8 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
quater = _nditte->curr().get_bool("FLIVA11Q");
|
||||
|
||||
// attivita' mista: ce ne sono in realta' due
|
||||
// viene calcolato nel ciclo su tipoatt (che viene ripetuto solo
|
||||
// se diventa TRUE);
|
||||
_mixed = FALSE;
|
||||
// viene calcolato nel ciclo su tipoatt (che viene ripetuto solo se diventa TRUE);
|
||||
_mixed = false;
|
||||
|
||||
buf.format( _printonly ? FR("Stampa liquidazione (%d)...\n%s: %s\n") :
|
||||
FR("Calcolo liquidazione (%d)...\n%s: %s\n"),
|
||||
@ -258,18 +255,19 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
|
||||
for (int tipoatt = 1; tipoatt <= (_mixed ? 2 : 1); tipoatt++)
|
||||
{
|
||||
TString8 cattiv(codatt); bool waspla;
|
||||
bool waspla = false;
|
||||
|
||||
TString8 cattiv(codatt);
|
||||
cattiv << tipoatt;
|
||||
if (tipoatt == 1 && (waspla = look_pla(cattiv, FALSE)))
|
||||
if (tipoatt == 1 && (waspla = look_pla(cattiv, false)))
|
||||
{
|
||||
_p8 = _pla->get_real("R5");
|
||||
_p8b = _pla->get_real("R6");
|
||||
_p9 = _pla->get_real("R7");
|
||||
_isplafond = !(_p8.is_zero() && _p8b.is_zero() &&
|
||||
_p9.is_zero());
|
||||
_isservizio = _pla->get("S7") == "S";
|
||||
_mixed = _pla->get("S7") == "M" || _pla->get("S7") == "E";
|
||||
_isplafond = !(_p8.is_zero() && _p8b.is_zero() && _p9.is_zero());
|
||||
const char s7 = _pla->get_char("S7");
|
||||
_isservizio = (s7 == 'S');
|
||||
_mixed = (s7 == 'M') || (s7 == 'E');
|
||||
|
||||
const TString4 yr(_year);
|
||||
TAssoc_array& pa = _prorata.perc_array();
|
||||
@ -281,12 +279,12 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
|
||||
for (int i = atoi(_year); i>=anno; i--)
|
||||
{
|
||||
_year = format("%d", i);
|
||||
_year.format("%d", i);
|
||||
if (look_pla(cattiv, FALSE)) // Reperisce percentuale prorata anno indicato (se esiste la tabella)
|
||||
pa.add(_year, _pla->get_real("R8"));
|
||||
}
|
||||
_year = yr; // Risetta l'anno corretto e riposiziona la tabella...
|
||||
look_pla(cattiv, FALSE);
|
||||
look_pla(cattiv, false);
|
||||
}
|
||||
else
|
||||
_isservizio = _nditte->curr(LF_ATTIV).get("TIPOATT") == "S";
|
||||
@ -294,7 +292,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
_isviaggio = _nditte->curr(LF_ATTIV).get_bool("REG74TER");
|
||||
_isagricolo = _nditte->curr(LF_ATTIV).get_bool("REGAGR");
|
||||
_isagr98 = _isagricolo && atoi(_year) >= 1998;
|
||||
_isvent = FALSE;
|
||||
_isvent = false;
|
||||
|
||||
if (!_recalc_regis && tipoatt == 1 && waspla && month == 13)
|
||||
{
|
||||
@ -349,13 +347,11 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
if (!gheravergot)
|
||||
{
|
||||
look_plm(month,cattiv);
|
||||
gheravergot = !_plm->get_real("R0").is_zero() ||
|
||||
!_plm->get_real("R1").is_zero();
|
||||
gheravergot = !_plm->get_real("R0").is_zero() || !_plm->get_real("R1").is_zero();
|
||||
}
|
||||
|
||||
if (month == _month && riepliq)
|
||||
describe_att(month, cattiv, gheravergot,
|
||||
'0' + (_mixed ? tipoatt : 0));
|
||||
describe_att(month, cattiv, gheravergot, '0' + (_mixed ? tipoatt : 0));
|
||||
|
||||
atts.add(cattiv);
|
||||
cattivs.add(cattiv);
|
||||
@ -364,7 +360,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
if (_recalc_regis)
|
||||
continue;
|
||||
|
||||
// se attivita' mista stampa riepilogo
|
||||
// se attività mista stampa riepilogo
|
||||
if (_mixed && month == _month && riepliq)
|
||||
describe_att(month,cattivs, TRUE, 'M');
|
||||
|
||||
@ -379,7 +375,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
{
|
||||
_nditte->restore_status();
|
||||
// Se trattasi di ricalcolo per registri, setta il flag relativo, onde evitare ricalcoli
|
||||
// nel caso di registro riepilogativo: se i PRM esistono gia' (perche' creati
|
||||
// nel caso di registro riepilogativo: se i PRM esistono già (perchè creati
|
||||
// da stampa bollato precedente o altro riepilogo) non vanno ricalcolati.
|
||||
look_lim(month, TRUE); // Crea se non esiste
|
||||
_lim->put("B1","X");
|
||||
@ -447,21 +443,22 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
return ok || calc;
|
||||
}
|
||||
|
||||
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
|
||||
// vedi update_firm per il burdel dei calc e recalc
|
||||
// occhecasino. Se _comp_acconto e' TRUE, i movimenti considerati
|
||||
// saranno solo quelli di dicembre per data <= 20/12;
|
||||
// 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");
|
||||
if (_recalc_regis)
|
||||
ok = FALSE; // Se sta ricalcolando i PRM/PRP se ne sbatte dei PLM
|
||||
if (ok && !recalc) return TRUE;
|
||||
if (ok && !recalc)
|
||||
return true;
|
||||
bool calc = _recalc == ever || (_recalc == one && is_month_ok(month,_month));
|
||||
if (!calc && _recalc != never) calc = !ok;
|
||||
if (!calc && _recalc != never)
|
||||
calc = !ok;
|
||||
|
||||
if (calc || !recalc)
|
||||
{
|
||||
@ -566,6 +563,92 @@ void TLiquidazione_app::zero_att(int month, const char* codatt)
|
||||
zero_plafond(month,codatt);
|
||||
}
|
||||
|
||||
// Fattura più vecchia di un anno a ente NON pubblico
|
||||
static bool sarebbe_da_pagare(const TRectype& mov, const TDate& fine)
|
||||
{
|
||||
const TDate datareg = mov.get(MOV_DATAREG);
|
||||
const long giorni = fine - datareg;
|
||||
if (giorni <= 365)
|
||||
return false; // E' passato meno di un anno
|
||||
|
||||
const TDate datainc = mov.get(MOV_DATAINC);
|
||||
if (datainc.ok() && datainc <= fine)
|
||||
return false; // Già pagata senza saldaconto
|
||||
|
||||
TString8 key; key.format("%c|%ld", mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF));
|
||||
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
||||
return clifo.get_int(CLI_ALLEG) != 7; // Non è un ente pubblico
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::residuo_da_liquidare(long numreg, int numrig, const TDate& last_pag,
|
||||
real& importo_res, real& imponib_res, real& imposta_res) const
|
||||
{
|
||||
CHECKD(numreg > 0 && numrig > 0, "Numero registrazione non valido ", numreg);
|
||||
|
||||
bool found = false;
|
||||
|
||||
if (!found)
|
||||
{
|
||||
TString query;
|
||||
query << "USE " << LF_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)
|
||||
{
|
||||
TImporto importo, imponib, imposta;
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
const char sez = id.get("SEZIONE").as_string()[0];
|
||||
const int tipomov = id.get(PART_TIPOMOV).as_int();
|
||||
if ((tipomov == 1 || tipomov == 2) || !last_pag.ok())
|
||||
{
|
||||
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;
|
||||
|
||||
const TImporto vers(sez, id.get("VERSATA").as_real());
|
||||
if (!vers.is_zero())
|
||||
{
|
||||
importo += TImporto(sez, id.get(PAGSCA_IMPORTO).as_real());
|
||||
imponib += TImporto(sez, id.get(RMI_IMPONIBILE).as_real());
|
||||
imposta += vers;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (importo.valore() > ZERO)
|
||||
{
|
||||
importo_res = importo.valore();
|
||||
imponib_res = imponib.valore();
|
||||
imposta_res = imposta.valore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
TLocalisamfile rmi(LF_RMOVIVA);
|
||||
rmi.put(RMI_NUMREG, numreg);
|
||||
rmi.put(RMI_NUMRIG, numrig);
|
||||
found = rmi.read() == NOERR;
|
||||
if (found)
|
||||
{
|
||||
imposta_res = rmi.get_real(RMI_IMPOSTA);
|
||||
imponib_res = rmi.get_real(RMI_IMPONIBILE);
|
||||
importo_res = imponib_res + imposta_res;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
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
|
||||
@ -777,34 +860,33 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
filter << format("||((ANSI(DATA74TER)>=%ld)&&(ANSI(DATA74TER)<=%ld))", f74.date2ansi(), t.date2ansi());
|
||||
if (_isdiff)
|
||||
filter << "|| NUM(LIQDIFF==\"X\")";
|
||||
// format( ||((ANSI(DATAINC)>=%ld)&&(ANSI(DATAINC)<=%ld))", fromdate.date2ansi(), t.date2ansi());
|
||||
}
|
||||
_cur->setfilter(filter);
|
||||
const long items = _cur->items();
|
||||
_cur->freeze();
|
||||
|
||||
*_cur = 0;
|
||||
|
||||
TString16 trueatt(codatt);
|
||||
const int tipatt = atoi(trueatt.sub(5));
|
||||
|
||||
TString16 trueatt(codatt);
|
||||
const int tipatt = trueatt[5] - '0';
|
||||
trueatt.cut(5);
|
||||
|
||||
TString pimsg; pimsg << TR("Ricalcolo attività ") << trueatt << " (" << month << ')';
|
||||
TString pimsg; pimsg << TR("Ricalcolo attività ") << trueatt << " (mese " << month << ')';
|
||||
TProgind pi(items, pimsg, false, true);
|
||||
for (; _cur->pos() < items; ++(*_cur))
|
||||
{
|
||||
if (!pi.setstatus(_cur->pos()))
|
||||
break;
|
||||
|
||||
TDate date(_mov->get(MOV_DATAREG));
|
||||
TDate date = _mov->get(MOV_DATAREG);
|
||||
const int liqmonth = _mov->get_int(MOV_MESELIQ);
|
||||
const TString4 reg = _mov->get("REG");
|
||||
const bool isreg = look_reg(_mov->get("REG"));
|
||||
const bool isreg = look_reg(reg);
|
||||
const TString4 tipodoc = _mov->get(MOV_TIPODOC);
|
||||
const bool corrisp = _reg->get_bool("B0");
|
||||
const tiporeg tipomov = (tiporeg)_reg->get_int("I0");
|
||||
// Controlla se la data del documento si riferisce all'anno precedente (PRORATA 1998)
|
||||
TDate datedoc(_mov->get(MOV_DATADOC));
|
||||
const TDate datedoc(_mov->get(MOV_DATADOC));
|
||||
|
||||
if (_isviaggio)
|
||||
{
|
||||
@ -814,90 +896,85 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
continue;
|
||||
}
|
||||
const TRectype& rcs = _cur->curr(LF_CAUSALI);
|
||||
const bool fattrit = rcs.get_bool("RITFATT");
|
||||
const bool fattrit = rcs.get_bool("RITFATT");
|
||||
const bool cau_intra = rcs.get_bool("INTRACOM");
|
||||
const bool cau_valintra = rcs.get_bool("VALINTRA");
|
||||
|
||||
// Inizio gestione IVA differita
|
||||
const bool movdiff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
|
||||
|
||||
// Se c'è data incasso, normalmente vuol dire che: NO saldaconto e pagamento completo
|
||||
TDate datainc = _mov->get_date(MOV_DATAINC);
|
||||
if (movdiff && !datainc.ok())
|
||||
{
|
||||
const long codcf = _mov->get_long(MOV_CODCF);
|
||||
TString8 key(_mov->get(MOV_TIPO)); key << "|" << codcf;
|
||||
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
||||
|
||||
// se non e' un ente pubblico forzo data incasso un anno dopo il documento
|
||||
if (clifo.get_int(CLI_ALLEG) < 7)
|
||||
{
|
||||
datainc = _mov->get_date(MOV_DATADOC);
|
||||
if (datainc.ok())
|
||||
datainc.addyear();
|
||||
}
|
||||
}
|
||||
|
||||
// datainc_ok significa che la data incasso è compresa nel periodo di liquidazione in corso di calcolo
|
||||
bool datainc_ok = is_date_ok(datainc, month, liqmonth, year_int);
|
||||
const bool diffpayed = movdiff && datainc_ok;
|
||||
const bool difftopay = movdiff && !diffpayed;
|
||||
|
||||
// Se ho fatto un pagamento differito porto la data di registrazione alla data incasso
|
||||
if (diffpayed)
|
||||
date = datainc;
|
||||
|
||||
real totfat, pagatt, ncatt;
|
||||
const bool iva_cass = has_module(ICAUT) && _mov->get_bool(MOV_IVAXCASSA);
|
||||
const bool iva_diff = _isdiff && _mov->get_bool(MOV_LIQDIFF);
|
||||
const bool movdiff = iva_diff || iva_cass;
|
||||
bool dok = is_date_ok(date, month, liqmonth, year_int);
|
||||
|
||||
TPartite_array arrpart; // Partite interessate
|
||||
TPointer_array pagscatt; // Righe di pagsca interessate
|
||||
|
||||
const long numreg = _mov->get_long(MOV_NUMREG);
|
||||
|
||||
// In presenza di saldaconto determino meglio la data incasso in base alle righe di pagamento
|
||||
if (has_sc && movdiff && (!datainc.ok() || datainc > inizio))
|
||||
if (movdiff)
|
||||
{
|
||||
//arrpart.add_numreg(numreg);
|
||||
//if (arrpart.utilizzata(numreg, 1))
|
||||
if (arrpart.add_numreg(numreg)) // Ovviamente più efficiente di quanto sopra
|
||||
// Sezione preferita per fatture decisa in base a vendita->'A' o acquisto->'D'
|
||||
const char sezfat = tipomov == vendita ? 'D' : 'A';
|
||||
const char sezpag = tipomov == vendita ? 'A' : 'D';
|
||||
const long numreg = _mov->get_long(MOV_NUMREG);
|
||||
TDate datainc;
|
||||
real tot_incassato, tot_da_incassare;
|
||||
int flag_pg_nc = 0; // Ci sono pagamenti (0x1) e/o note di credito(0x2) ?
|
||||
bool game_found = false;
|
||||
if (has_sc)
|
||||
{
|
||||
arrpart.add_numreg(numreg);
|
||||
const TPartita* p = arrpart.first();
|
||||
const int row = p ? p->mov2rig(numreg, 0) : 0;
|
||||
game_found = row > 0;
|
||||
if (game_found)
|
||||
{
|
||||
const TRiga_partite& rp = p->riga(row);
|
||||
TImporto pg, nc;
|
||||
flag_pg_nc = rp.calcola_pagato_periodo(inizio+1L, fine, pg, nc, &pagscatt);
|
||||
if (!p->chiusa() && sarebbe_da_pagare(_mov->curr(), fine))
|
||||
{
|
||||
rp.calcola_pagato_periodo(TDate(1,1,date.year()), fine, pg, nc, NULL);
|
||||
TImporto saldo = rp.importo(false);
|
||||
saldo += pg; saldo += nc;
|
||||
saldo.normalize(sezfat);
|
||||
if (saldo.valore() > ZERO)
|
||||
tot_da_incassare = saldo.valore();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!game_found) // No saldaconto o partita assente
|
||||
{
|
||||
datainc = _mov->get(MOV_DATAINC);
|
||||
if (datainc.ok() && datainc <= fine)
|
||||
tot_incassato = _mov->get_real(MOV_TOTDOC);
|
||||
else
|
||||
{
|
||||
// Fattura più vecchia di un anno a ente NON pubblico
|
||||
if (sarebbe_da_pagare(_mov->curr(), fine))
|
||||
tot_da_incassare = _mov->get_real(MOV_TOTDOC);
|
||||
}
|
||||
}
|
||||
// Simulo incasso se necessario
|
||||
if (!tot_da_incassare.is_zero()) // già controllato se sarebbe_da_pagare(_mov->curr(), fine)
|
||||
{
|
||||
// Sezione preferita per fatture decisa in base a vendita->'A' o acquisto->'D'
|
||||
const char sezfat = tipomov == vendita ? 'D' : 'A';
|
||||
const char sezpag = tipomov == vendita ? 'A' : 'D';
|
||||
for (TPartita * p = arrpart.first(); p != NULL; p = arrpart.next())
|
||||
{
|
||||
const int row = p->mov2rig(numreg, 0);
|
||||
if (row > 0)
|
||||
{
|
||||
const TRiga_partite& rp = p->riga(row);
|
||||
TImporto pg, nc;
|
||||
TDate lastpg, lastnc;
|
||||
const int flag = rp.calcola_pagato_periodo(inizio+1L, fine, pg, nc, &pagscatt);
|
||||
if (flag)
|
||||
{
|
||||
TImporto importo = rp.importo(false, 0x1);
|
||||
importo.normalize(sezfat);
|
||||
totfat = importo.valore();
|
||||
CHECK(totfat >= ZERO, "Fattura negativa inattesa qui");
|
||||
if (flag & 1)
|
||||
{
|
||||
pg.normalize(sezpag);
|
||||
pagatt += pg.valore();
|
||||
}
|
||||
if (flag & 2)
|
||||
{
|
||||
nc.normalize(sezpag);
|
||||
ncatt += nc.valore();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((diffpayed && dok) || (pagatt > totfat))
|
||||
pagatt = totfat;
|
||||
if (pagatt > ZERO)
|
||||
dok = true;
|
||||
tot_incassato = tot_da_incassare;
|
||||
datainc = fine;
|
||||
_mov->put(MOV_DATAINC, datainc);
|
||||
}
|
||||
if (tot_incassato > ZERO && is_date_ok(datainc, month, liqmonth, year_int))
|
||||
{
|
||||
flag_pg_nc = 0x1;
|
||||
TRectype* pagsca = new TRectype(LF_PAGSCA);
|
||||
pagsca->put(PAGSCA_TIPOC, _mov->get(MOV_TIPO));
|
||||
pagsca->put(PAGSCA_SOTTOCONTO, _mov->get(MOV_CODCF));
|
||||
pagsca->put(PAGSCA_ANNO, year_int);
|
||||
pagsca->put(PAGSCA_NRIGA, 1);
|
||||
pagsca->put(PAGSCA_NRATA, 1);
|
||||
pagsca->put(PAGSCA_NRIGP, 9999);
|
||||
pagsca->put(PAGSCA_IMPORTO, tot_incassato);
|
||||
pagscatt.add(pagsca);
|
||||
}
|
||||
if (flag_pg_nc)
|
||||
dok = true;
|
||||
}
|
||||
/*
|
||||
* check register present, rmoviva present and date OK
|
||||
@ -908,9 +985,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
* la lettura dei movimenti.
|
||||
*/
|
||||
|
||||
const bool sreg = !isreg;
|
||||
const bool rs8 = _reg->get("S8") != trueatt;
|
||||
const bool cmt = !_cur->is_first_match(LF_RMOVIVA);
|
||||
const bool sreg = !isreg;
|
||||
const bool rs8 = _reg->get("S8") != trueatt;
|
||||
const bool cmt = !_cur->is_first_match(LF_RMOVIVA);
|
||||
|
||||
if (!dok || sreg || rs8 || cmt)
|
||||
continue;
|
||||
@ -923,13 +1000,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
* Da oggi vengono sommati nei real di S2 in pim
|
||||
* assieme alle FS per stampa registri
|
||||
*/
|
||||
bool noninc = (tipodoc == "SN" || tipodoc == "CN" || tipodoc == "RN" ||
|
||||
tipodoc == "IN" || tipodoc == "PG");
|
||||
const bool noninc = (tipodoc == "SN" || tipodoc == "CN" || tipodoc == "RN" || tipodoc == "IN" || tipodoc == "PG");
|
||||
|
||||
/*
|
||||
* check date: se si calcola l'acconto, solo da 1/12 a 20/12
|
||||
*/
|
||||
int accmonth = _isdifferita ? 11 : 12;
|
||||
const int accmonth = _isdifferita ? 11 : 12;
|
||||
|
||||
/*
|
||||
* Patrizia: se e' differita i mov. vanno da 1/11 a 30/11
|
||||
@ -942,15 +1018,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (!_isdifferita && date.day() > 20)
|
||||
continue;
|
||||
|
||||
// Ciclo sulle righe iva del movimento
|
||||
do
|
||||
{
|
||||
int tipoatt = _rmoviva->get_int(RMI_TIPOATT);
|
||||
/*
|
||||
* puo' capitare per motivi brutalmente prassici
|
||||
* SENSU Sergio 1995, Guido
|
||||
*/
|
||||
if (tipoatt == 0) tipoatt = 1;
|
||||
if (tipoatt != tipatt)
|
||||
{
|
||||
const int rmi_tipoatt = max(_rmoviva->get_int(RMI_TIPOATT), 1); // Poteva capitare tipoatt == 0
|
||||
if (rmi_tipoatt != tipatt)
|
||||
continue;
|
||||
|
||||
// totali parziali registrati nei pim per motivi ignoti
|
||||
@ -1007,183 +1079,155 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
real impon_det; // Imponibile detraibile
|
||||
real impos_det; // Imposta detraibile
|
||||
|
||||
if (pagatt > ZERO || ncatt > ZERO)
|
||||
{
|
||||
// Il totale dei pagamenti chiude la fattura?
|
||||
if (pagatt >= totfat) // Calcolo del cavolo: dovrebbe guardare il saldo fattura, no?
|
||||
{
|
||||
TDate from(_mov->get(MOV_DATAREG));
|
||||
real impprec, ivaprec, ncprec;
|
||||
if (month < 13)
|
||||
{
|
||||
TDate to(inizio);
|
||||
if (movdiff)
|
||||
{
|
||||
const char sezfat = tipomov == vendita ? 'D' : 'A';
|
||||
const TDate datareg = _mov->get(MOV_DATAREG);
|
||||
|
||||
from.set_day(1);
|
||||
--from;
|
||||
while (from < to)
|
||||
{
|
||||
TDate endp(from);
|
||||
TLocalisamfile id(LF_IVADIFF);
|
||||
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
|
||||
id.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
|
||||
id.put(PART_TIPOMOV, 1);
|
||||
id.put("NUMPRO", 0);
|
||||
id.put("TIPOATT", rmi_tipoatt);
|
||||
id.put("ANNOLIQ", datareg.year());
|
||||
int mesereg = datareg.month();
|
||||
if (_freqviva == "T")
|
||||
{
|
||||
const int resto = mesereg % 3;
|
||||
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("SEZIONE", sezfat);
|
||||
id.put("IMPORTO", imponibile_orig+imposta_orig);
|
||||
id.put(RMI_IMPONIBILE, imponibile_orig);
|
||||
id.put(RMI_IMPOSTA, imposta_orig);
|
||||
id.write_rewrite();
|
||||
}
|
||||
|
||||
if (_freqviva == "M")
|
||||
endp.addmonth();
|
||||
else
|
||||
endp.set_month((endp.month() / 3 + 1) * 3);
|
||||
endp.set_end_month();
|
||||
if (arrpart.utilizzata(numreg, 1))
|
||||
{
|
||||
const int items = arrpart.items();
|
||||
const char sez = (tipomov == vendita ? 'A' : 'D');
|
||||
TImporto pagtmp;
|
||||
// Inizio aggiunte di Bonazzi del 16/02/2012
|
||||
TImporto nctmp;
|
||||
// Fine aggiunte di Bonazzi del 16/02/2012
|
||||
if (!pagscatt.empty())
|
||||
{
|
||||
const char sezpag = tipomov == vendita ? 'A' : 'D';
|
||||
const real totfat = _mov->get(MOV_TOTDOC);
|
||||
|
||||
for (TPartita* p = arrpart.first(); p != NULL; p = arrpart.next())
|
||||
{
|
||||
const int row = p->mov2rig(numreg, 1);
|
||||
if (row > 0)
|
||||
{
|
||||
const TRiga_partite& rp = p->riga(row);
|
||||
rp.calcola_pagato_periodo(from+1L, endp, pagtmp, nctmp);
|
||||
}
|
||||
}
|
||||
pagtmp.normalize(sez);
|
||||
TLocalisamfile id(LF_IVADIFF);
|
||||
FOR_EACH_ARRAY_ITEM(pagscatt, r, obj)
|
||||
{
|
||||
const TRectype& pagsca = *(TRectype*)obj;
|
||||
const int nrigp = pagsca.get_int(PAGSCA_NRIGP);
|
||||
|
||||
if (!pagtmp.is_zero())
|
||||
{
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
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));
|
||||
id.put("NUMPRO", nrigp);
|
||||
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));
|
||||
|
||||
real val = imponibile_orig * perc;
|
||||
val.round(TCurrency::get_firm_dec());
|
||||
impprec += val;
|
||||
val = imposta_orig * perc;
|
||||
val.round(TCurrency::get_firm_dec());
|
||||
ivaprec += val;
|
||||
}
|
||||
// Inizio aggiunte di Bonazzi del 16/02/2012
|
||||
if (!nctmp.is_zero())
|
||||
ncprec += nctmp.valore();
|
||||
// Fine aggiunte di Bonazzi del 16/02/2012
|
||||
from = endp;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (from.year() != fromdate.year())
|
||||
{
|
||||
if (arrpart.utilizzata(numreg, 1))
|
||||
{
|
||||
TDate to(31,12, from.year());
|
||||
const int items = arrpart.items();
|
||||
const char sez = (tipomov == vendita ? 'A' : 'D');
|
||||
TImporto pagtmp, nctmp;
|
||||
for (TPartita * p = arrpart.first(); p != NULL; p = arrpart.next())
|
||||
{
|
||||
const int row = p->mov2rig(numreg, 1);
|
||||
if (row >= 0)
|
||||
{
|
||||
const TRiga_partite& rp = p->riga(row);
|
||||
rp.calcola_pagato_periodo(botime, to, pagtmp, nctmp);
|
||||
}
|
||||
}
|
||||
if (!pagtmp.is_zero())
|
||||
{
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
real val = imponibile_orig * perc;
|
||||
|
||||
val.round(decimals);
|
||||
impprec = val;
|
||||
val = imposta_orig * perc;
|
||||
val.round(decimals);
|
||||
ivaprec = val;
|
||||
}
|
||||
if (!nctmp.is_zero())
|
||||
ncprec = nctmp.valore();
|
||||
}
|
||||
}
|
||||
}
|
||||
incdiff_imp = imponibile_orig - impprec;
|
||||
incdiff_iva = imposta_orig - ivaprec;
|
||||
ncatt -= ncprec;
|
||||
|
||||
const real ncperc = ncatt / totfat;
|
||||
|
||||
real val = imponibile_orig * ncperc;
|
||||
val.round(decimals);
|
||||
diff_imp = -val;
|
||||
incdiff_imp -= val;
|
||||
val = imposta_orig * ncperc;
|
||||
val.round(decimals);
|
||||
diff_iva = -val;
|
||||
incdiff_iva -= val;
|
||||
}
|
||||
else
|
||||
{ // La fattura è ancora aperta
|
||||
// Calcolo rapporto tra pagamento e totale fattura
|
||||
const real perc = pagatt / totfat;
|
||||
|
||||
incdiff_imp = imponibile_orig * perc;
|
||||
incdiff_imp.round(decimals);
|
||||
incdiff_iva = imposta_orig * perc;
|
||||
incdiff_iva.round(decimals);
|
||||
if (month == 13)
|
||||
{
|
||||
diff_imp = imponibile_orig - incdiff_imp;
|
||||
diff_iva = imposta_orig - incdiff_iva;
|
||||
}
|
||||
|
||||
/* Guy 08-08-2012: Mi pare una cosa inutile
|
||||
// Calcolo rapporto tra nota credito e totale fattura
|
||||
const real ncperc = ncatt / totfat;
|
||||
real val = imponibile_orig * ncperc;
|
||||
val.round(TCurrency::get_firm_dec());
|
||||
diff_imp = -val;
|
||||
incdiff_imp -= val;
|
||||
val = imposta_orig * ncperc;
|
||||
val.round(TCurrency::get_firm_dec());
|
||||
diff_iva = -val;
|
||||
incdiff_iva -= val;
|
||||
*/
|
||||
|
||||
if (pagatt > ZERO && !pagscatt.empty())
|
||||
TImporto pagtmp;
|
||||
bool ultimo = false;
|
||||
if (nrigp > 0 && nrigp < 9999)
|
||||
{
|
||||
TFilename tmp; tmp.tempdir();
|
||||
tmp.add("liqdiff.txt");
|
||||
ofstream log(tmp, ios_base::app);
|
||||
|
||||
const TRectype& rec = (TRectype&)pagscatt[pagscatt.last()];
|
||||
const TPartita& par = arrpart.partita(rec);
|
||||
const TRiga_partite& sum = par.riga(rec.get_int(PAGSCA_NRIGP));
|
||||
|
||||
log << codiva << '\t' << pagatt.string() << '\t'
|
||||
<< incdiff_imp.string() << '\t' << incdiff_iva.string() << '\t'
|
||||
<< sum.get(PART_NREG) << '\t' << sum.get_date(PART_DATAPAG) << '\t'
|
||||
<< numreg << '\t' << date.string() << endl;
|
||||
const TPartita& p = arrpart.partita(pagsca);
|
||||
const TRiga_partite& rp = p.riga(nrigp);
|
||||
id.put(PART_TIPOMOV, rp.tipo());
|
||||
id.put("NUMREGP", rp.get(PART_NREG));
|
||||
id.put("NUMRIGP", rp.get(PART_NUMRIG));
|
||||
id.put("DATAREGP", rp.get(PART_DATAPAG));
|
||||
pagtmp = p.importo_pagsca(pagsca);
|
||||
if (p.chiusa() && rp.tipo() >= 3)
|
||||
{
|
||||
ultimo = true;
|
||||
for (int r = p.last(); r > nrigp; r = p.pred(r))
|
||||
{
|
||||
if (p.riga(r).tipo() >= tm_pagamento)
|
||||
{
|
||||
ultimo = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Falso record generato da datainc
|
||||
id.put(PART_TIPOMOV, 3);
|
||||
id.put("NUMREGP", _mov->get(MOV_NUMREG));
|
||||
id.put("NUMRIGP", nrigp);
|
||||
id.put("DATAREGP", _mov->get(MOV_DATAINC));
|
||||
pagtmp.set(sezpag, pagsca.get_real(PAGSCA_IMPORTO));
|
||||
ultimo = true;
|
||||
}
|
||||
|
||||
id.put("ANNOLIQ", year_int);
|
||||
int meseliq = id.get_date("DATAREGP").month();
|
||||
if (_freqviva == "T")
|
||||
{
|
||||
const int resto = meseliq % 3;
|
||||
if (resto > 0)
|
||||
meseliq += 3-resto;
|
||||
}
|
||||
id.put("MESELIQ", meseliq);
|
||||
|
||||
id.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;
|
||||
}
|
||||
else
|
||||
{
|
||||
id.put(PAGSCA_IMPORTO, pagtmp.valore());
|
||||
pagtmp.normalize(sezpag);
|
||||
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
real val = imponibile_orig * perc;
|
||||
round_imposta(val);
|
||||
id.put(RMI_IMPONIBILE, val);
|
||||
incdiff_imp += val;
|
||||
|
||||
val = imposta_orig * perc;
|
||||
round_imposta(val);
|
||||
id.put(RMI_IMPOSTA, val);
|
||||
incdiff_iva += val;
|
||||
}
|
||||
|
||||
if (_isfinal && id.get_int(PART_TIPOMOV) > 2)
|
||||
id.put("VERSATA", id.get(RMI_IMPOSTA));
|
||||
else
|
||||
id.zero("VERSATA");
|
||||
|
||||
id.write_rewrite();
|
||||
}
|
||||
diff_imp = imponibile_orig - incdiff_imp;
|
||||
diff_iva = imposta_orig - incdiff_iva;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (difftopay)
|
||||
if (movdiff)
|
||||
{
|
||||
diff_imp = imponibile_orig;
|
||||
diff_iva = imposta_orig;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (diffpayed)
|
||||
{
|
||||
incdiff_imp = imponibile_orig;
|
||||
incdiff_iva = imposta_orig;
|
||||
}
|
||||
else
|
||||
analizza_IVA(imponibile_orig, imposta_orig, percind, corrisp, false, codiva,
|
||||
impon_det, impos_det, impon_ind, impos_ind);
|
||||
}
|
||||
analizza_IVA(imponibile_orig, imposta_orig, percind, corrisp, false, codiva,
|
||||
impon_det, impos_det, impon_ind, impos_ind);
|
||||
}
|
||||
|
||||
// qui
|
||||
for (int is_detraibile = 0; is_detraibile < 2; is_detraibile++)
|
||||
{
|
||||
const int tipodet = is_detraibile ? 0 : tipoind;
|
||||
@ -1224,8 +1268,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
|
||||
if (tipoiva.empty() && codcf != 0)
|
||||
{
|
||||
TString8 key(_mov->get(MOV_TIPO)); key << "|" << codcf;
|
||||
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
||||
TString8 key; key.format("%c|%ld", _mov->get_char(MOV_TIPO), codcf);
|
||||
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
||||
int codreg = 0; // codice regione x privati 22 == partite iva 0 == senza codice
|
||||
const int tipoalleg = clifo.get_int(CLI_ALLEG);
|
||||
|
||||
@ -1344,19 +1388,19 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
|
||||
switch (sosp_imp)
|
||||
{
|
||||
case normale:
|
||||
assp_imp += asimp_imp;
|
||||
assp_iva += asimp_iva;
|
||||
vssp_imp += vsimp_imp;
|
||||
vssp_iva += vsimp_iva;
|
||||
break;
|
||||
case liquidazione:
|
||||
assl_imp += asimp_imp;
|
||||
assl_iva += asimp_iva;
|
||||
vssl_imp += vsimp_imp;
|
||||
vssl_iva += vsimp_iva;
|
||||
default:
|
||||
break;
|
||||
case normale:
|
||||
assp_imp += asimp_imp;
|
||||
assp_iva += asimp_iva;
|
||||
vssp_imp += vsimp_imp;
|
||||
vssp_iva += vsimp_iva;
|
||||
break;
|
||||
case liquidazione:
|
||||
assl_imp += asimp_imp;
|
||||
assl_iva += asimp_iva;
|
||||
vssl_imp += vsimp_imp;
|
||||
vssl_iva += vsimp_iva;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (fattrit) // Possono essere solo acquisti
|
||||
@ -1765,8 +1809,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
if (year_int > 1997 && (yr < (year_int-1) && yr > (year_int-4))) // Prende un intervallo di 2 anni al massimo
|
||||
{ // Quelli relativi all'anno in corso e precedente vanno assieme.
|
||||
// Se abilitato, somma l'iva acquisti relativi ai documenti memorizzati con anni precedenti
|
||||
TString16 yy;
|
||||
yy << datedoc.year();
|
||||
TString4 yy; yy << datedoc.year();
|
||||
const bool is_key = acq_iva_anni_prec.is_key(yy);
|
||||
if (!is_key)
|
||||
acq_iva_anni_prec.add(yy, new real, is_key);
|
||||
@ -1952,18 +1995,18 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 1: // Progressivi Iva mensili da periodo Successivo
|
||||
look_pis(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
case 2: // Progressivi Registri iva Mensili
|
||||
look_prm(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
case 3: // Progressivi Registri iva Mensili da periodo Precedente
|
||||
look_prp(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
default: // Progressivi Iva Mensili normali
|
||||
look_pim(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
case 1: // Progressivi Iva mensili da periodo Successivo
|
||||
look_pis(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
case 2: // Progressivi Registri iva Mensili
|
||||
look_prm(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
case 3: // Progressivi Registri iva Mensili da periodo Precedente
|
||||
look_prp(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
default: // Progressivi Iva Mensili normali
|
||||
look_pim(month, codatt, reg, tipocr_s, codiva, tipodet, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
TTable *tab = arr[i];
|
||||
@ -2022,11 +2065,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
|
||||
if (is_detraibile == 0 &&
|
||||
(!diff_imp.is_zero() ||!diff_iva.is_zero() ||
|
||||
!incdiff_imp.is_zero() || !incdiff_imp.is_zero()))
|
||||
!incdiff_imp.is_zero() || !incdiff_iva.is_zero()))
|
||||
{
|
||||
if (tipomov == vendita)
|
||||
{
|
||||
// fatture a liquidazione differita
|
||||
// fatture vendita a liquidazione differita
|
||||
tab->curr().add("R26", diff_imp);
|
||||
tab->curr().add("R27", diff_iva);
|
||||
tab->curr().add("R28", incdiff_imp);
|
||||
@ -2043,7 +2086,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
else
|
||||
{
|
||||
// fatture a liquidazione differita
|
||||
// fatture acquisto a liquidazione differita
|
||||
tab->curr().add("R30", diff_imp);
|
||||
tab->curr().add("R31", diff_iva);
|
||||
tab->curr().add("R32", incdiff_imp);
|
||||
@ -2088,7 +2131,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
real perc = _iva->get_real("R0");
|
||||
|
||||
real new_iva = _pim->get_real("R0") * perc / CENTO;
|
||||
round_alla_lira(new_iva, TRUE);
|
||||
round_al_centesimo(new_iva);
|
||||
|
||||
if (new_iva != old_iva)
|
||||
{
|
||||
@ -2119,7 +2162,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
real perc = _iva->get_real("R0");
|
||||
|
||||
real iva = _pia->get_real("R0") * perc / CENTO;
|
||||
round_alla_lira(iva, TRUE);
|
||||
round_al_centesimo(iva);
|
||||
agr_detIA += iva;
|
||||
_pia->put("R1",iva);
|
||||
// resetta in modo da non vederlo il mese dopo
|
||||
@ -2234,7 +2277,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
real pdetr = (agr_2i / (agr_1i + agr_2i));
|
||||
pdetr.round(2);
|
||||
acquisti_iva += agr_7 * pdetr;
|
||||
round_alla_lira(acquisti_iva, true);
|
||||
round_al_centesimo(acquisti_iva);
|
||||
}
|
||||
|
||||
if (_isagr98)
|
||||
@ -3333,7 +3376,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
{
|
||||
// calcolo credito costo, debito mensile, perc. ripart.
|
||||
perc_r = a_mCEE.is_zero() ? ZERO : (a_mCEE * CENTO)/(a_mCEE + a_meCEE); perc_r.round(2);
|
||||
real ivm = (c_mCEE * perc_r)/CENTO; round_alla_lira(ivm, TRUE);
|
||||
real ivm = (c_mCEE * perc_r)/CENTO; round_al_centesimo(ivm);
|
||||
real tc = (c_iCEE + ivm);
|
||||
real ta = (a_iCEE + a_mCEE);
|
||||
real bi = tc - ta - credito_costo_prec(month);
|
||||
@ -3342,17 +3385,14 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
// credito di costo
|
||||
{
|
||||
cred_cost = abs(bi);
|
||||
if (atoi(_year) < 2000)
|
||||
round_alla_lira(cred_cost);
|
||||
else
|
||||
round_imposta(cred_cost);
|
||||
round_imposta(cred_cost);
|
||||
}
|
||||
else
|
||||
{
|
||||
const real ali_via = aliquota_agvia();
|
||||
// deb_mens = (bi /((CENTO + ali_via)/CENTO)) * (ali_via/CENTO);
|
||||
deb_mens = bi * ali_via / (ali_via+CENTO);
|
||||
round_alla_lira(deb_mens, TRUE); // ceil voluto MI3074
|
||||
round_al_centesimo(deb_mens); // ceil voluto MI3074
|
||||
risultato += deb_mens;
|
||||
res_debt += deb_mens;
|
||||
iva_vend += deb_mens;
|
||||
@ -3367,7 +3407,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
perc = imp_agr2.is_zero() ? ZERO : imp_agr2 / (imp_agr1 + imp_agr2);
|
||||
perc.round(2);
|
||||
iva_ded = acq_noCEE * perc;
|
||||
round_alla_lira(iva_ded);
|
||||
round_al_centesimo(iva_ded);
|
||||
iva_acq += iva_ded;
|
||||
res_debt += iva_vend;
|
||||
res_cred += iva_acq;
|
||||
@ -3626,7 +3666,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
|
||||
// in annuale si arrotondera' a 1000 in stampa
|
||||
// se no il conguaglio prorata fa casino
|
||||
round_alla_lira(risultato);
|
||||
round_al_centesimo(risultato);
|
||||
|
||||
_lim->put("R0",risultato);
|
||||
_lim->put("R2",cred_cost);
|
||||
@ -3673,7 +3713,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
const real interesse = interesse_trimestrale(_month);
|
||||
const real r = risultato - imposta_non_versata; // CM 26-09-2000
|
||||
real ivi = r.sign() > 0 ? (r * interesse / CENTO) : ZERO;
|
||||
round_alla_lira(ivi, TRUE);
|
||||
round_al_centesimo(ivi);
|
||||
_lim->put("R14", ivi);
|
||||
}
|
||||
|
||||
|
@ -936,24 +936,8 @@ void TLiquidazione_app::round_imposta(real& d) const
|
||||
ir.round(d);
|
||||
}
|
||||
|
||||
void TLiquidazione_app::round_alla_lira(real& d, bool sup)
|
||||
{
|
||||
const int dec = TCurrency::get_firm_dec();
|
||||
if (dec == 0) // lire
|
||||
{
|
||||
if (sup)
|
||||
{
|
||||
if (d >= ZERO)
|
||||
d.ceil(0);
|
||||
else
|
||||
d.floor(0);
|
||||
}
|
||||
else
|
||||
d.round(0);
|
||||
}
|
||||
else
|
||||
d.round(dec);
|
||||
}
|
||||
void TLiquidazione_app::round_al_centesimo(real& d) const
|
||||
{ d.round(2); }
|
||||
|
||||
|
||||
// Ritorna il parametro della liquidazione differita per la ditta corrente, cosi come
|
||||
@ -962,12 +946,12 @@ void TLiquidazione_app::round_alla_lira(real& d, bool sup)
|
||||
// Analogamente per l'anno
|
||||
bool TLiquidazione_app::is_differita(long firm, int year)
|
||||
{
|
||||
long d = (firm <= 0) ? _nditte->curr().get_long("CODDITTA") : firm;
|
||||
int y = (year <= 0) ? atoi(_year) : year;
|
||||
bool diff = false;
|
||||
const long d = (firm <= 0) ? _nditte->curr().get_long("CODDITTA") : firm;
|
||||
const int y = (year <= 0) ? atoi(_year) : year;
|
||||
if (look_lia(d, y > 0, y)) // 26/03/2012 aggiunto ,y)
|
||||
return _lia->get_bool("B1");
|
||||
else
|
||||
return false;
|
||||
diff = _lia->get_bool("B1");
|
||||
return diff;
|
||||
}
|
||||
|
||||
real TLiquidazione_app::aliquota_agvia()
|
||||
|
@ -326,7 +326,7 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt)
|
||||
{
|
||||
_VentItem* vv = (_VentItem*)&_vent_arr[j];
|
||||
imponibile = vv->_totale * moltiplicatore; // Importo lordo vendite
|
||||
round_alla_lira(imponibile);
|
||||
round_al_centesimo(imponibile);
|
||||
lordo2netto(imponibile, imposta, vv->_aliquota); // Scorpora l'iva
|
||||
// aggiusto l'IVA vendite nei plm
|
||||
look_plm(month, codatt);
|
||||
@ -420,7 +420,7 @@ void TLiquidazione_app::recalc_viaggio(int month, const char* codatt)
|
||||
if (month == 13)
|
||||
round_imposta(ivm);
|
||||
else
|
||||
round_alla_lira(ivm, TRUE);
|
||||
round_al_centesimo(ivm);
|
||||
|
||||
const real tc = c_CEE + ivm;
|
||||
const real ta = a_CEE + a_mCEE;
|
||||
@ -435,7 +435,7 @@ void TLiquidazione_app::recalc_viaggio(int month, const char* codatt)
|
||||
if (month == 13)
|
||||
round_imposta(deb_mens);
|
||||
else
|
||||
round_alla_lira(deb_mens, TRUE);
|
||||
round_al_centesimo(deb_mens);
|
||||
}
|
||||
if (look_plm(month,codatt))
|
||||
{
|
||||
|
320
cg/cg4304.cpp
320
cg/cg4304.cpp
@ -6,10 +6,15 @@
|
||||
|
||||
#include <currency.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "cg4300.h"
|
||||
|
||||
#include <attiv.h>
|
||||
#include <nditte.h>
|
||||
#include <rmoviva.h>
|
||||
|
||||
// flags per annuale
|
||||
#define IS_PRORATA 0x0001
|
||||
|
||||
@ -124,55 +129,62 @@ bool TLiquidazione_app::preprocess_page(int file, int cnt)
|
||||
// Print description
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
void TLiquidazione_app::describe_att(int month, const char* codatt,
|
||||
bool isresult, char flags)
|
||||
void TLiquidazione_app::describe_att(int month, const char* codatt, bool /*isresult*/, char flags)
|
||||
{
|
||||
TToken_string atts(codatt);
|
||||
|
||||
if (_isprint && _canprint)
|
||||
{
|
||||
TToken_string atts(codatt);
|
||||
const bool single_att = atts.items() == 1;
|
||||
|
||||
describe_name(month, atts, flags);
|
||||
if (atts.items() == 1 && _isplafond)
|
||||
describe_plafond(month, codatt);
|
||||
if (atts.items() == 1 && _isvent)
|
||||
describe_ventilation(month, codatt);
|
||||
if (atts.items() == 1 && _isagricolo)
|
||||
describe_agricolo(month, codatt);
|
||||
if (atts.items() == 1 && _isviaggio)
|
||||
describe_viaggio(month, codatt);
|
||||
describe_pims(month,codatt,FALSE);
|
||||
// if (atoi(_year) > 1997) // Descrive anche i PIS se esistono
|
||||
describe_pims(month,codatt,TRUE);
|
||||
if (atts.items() == 1)
|
||||
|
||||
if (single_att)
|
||||
{
|
||||
if (_isplafond)
|
||||
describe_plafond(month, codatt);
|
||||
if (_isvent)
|
||||
describe_ventilation(month, codatt);
|
||||
if (_isagricolo)
|
||||
describe_agricolo(month, codatt);
|
||||
if (_isviaggio)
|
||||
describe_viaggio(month, codatt);
|
||||
}
|
||||
|
||||
describe_pims(month, codatt, false); // PIM
|
||||
describe_pims(month, codatt, true); // PIS
|
||||
|
||||
if (single_att)
|
||||
describe_consistence(codatt);
|
||||
}
|
||||
}
|
||||
|
||||
void TLiquidazione_app::describe_name(int month, TToken_string& codatts, char flags)
|
||||
void TLiquidazione_app::describe_name(int month, const TToken_string& codatts, char flags)
|
||||
{
|
||||
const bool single_att = codatts.items() == 1;
|
||||
|
||||
_DescrItem* d = new _DescrItem(CHG_PARMS);
|
||||
|
||||
d->_s0 = _nditte->curr().get("CODDITTA");
|
||||
d->_s1 = _nditte->curr().get("RAGSOC");
|
||||
d->_s0 = _nditte->curr().get(NDT_CODDITTA);
|
||||
d->_s1 = _nditte->curr().get(NDT_RAGSOC);
|
||||
|
||||
if (atoi(_year) > 2007)
|
||||
{
|
||||
const TString16 codateco = _nditte->curr(LF_ATTIV).get(ATT_CODATECO);
|
||||
|
||||
d->_s2 = codateco;
|
||||
}
|
||||
else
|
||||
d->_s2 = _nditte->curr(LF_ATTIV).get("CODATT");
|
||||
d->_s3 = codatts.items() == 1 ? (const char*)_nditte->curr(LF_ATTIV).get("DESCR") : "";
|
||||
d->_s2 = _nditte->curr(LF_ATTIV).get(ATT_CODATT);
|
||||
d->_s3 = single_att ? (const char*)_nditte->curr(LF_ATTIV).get(ATT_DESCR) : "";
|
||||
d->_s4 = _freqviva;
|
||||
|
||||
d->_f1 = month;
|
||||
d->_f2 = _isbenzinaro;
|
||||
d->_f3 = (word)flags;
|
||||
|
||||
if (_mixed && codatts.items() == 1)
|
||||
d->_f0 = 0;
|
||||
if (_mixed && single_att)
|
||||
d->_f0 = atoi(codatts.mid(5));
|
||||
else d->_f0 = 0;
|
||||
|
||||
_descr_arr.add(d);
|
||||
}
|
||||
|
||||
@ -420,10 +432,10 @@ void TLiquidazione_app::describe_agricolo(int month, const char* codatt)
|
||||
// _r9 mantiene la percentuale (gia' arrotondata!)
|
||||
// _r10 mantiene l'iva detraibile calcolata!
|
||||
d->_r9 = d->_r8 / (d->_r7 + d->_r8);
|
||||
d->_r9.round(2);
|
||||
round_al_centesimo(d->_r9);
|
||||
d->_r10 = d->_r6 * d->_r9;
|
||||
d->_r9 *= CENTO;
|
||||
round_alla_lira(d->_r10, TRUE);
|
||||
round_al_centesimo(d->_r10);
|
||||
|
||||
_descr_arr.add(d);
|
||||
}
|
||||
@ -471,7 +483,7 @@ void TLiquidazione_app::describe_viaggio(int month, const char* codatt)
|
||||
if (month == 13)
|
||||
round_imposta(d->_r9);
|
||||
else
|
||||
round_alla_lira(d->_r9);
|
||||
round_al_centesimo(d->_r9);
|
||||
|
||||
// Calcola l'iva a debito, visto che servira' anche nel calcolo liquidazione (solo annuale)
|
||||
const real aliva = aliquota_agvia();
|
||||
@ -484,17 +496,17 @@ void TLiquidazione_app::describe_viaggio(int month, const char* codatt)
|
||||
if (month == 13)
|
||||
round_imposta(d->_r11);
|
||||
else
|
||||
round_alla_lira(d->_r11, TRUE);
|
||||
round_al_centesimo(d->_r11);
|
||||
}
|
||||
_descr_arr.add(d);
|
||||
}
|
||||
|
||||
void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool describe_pis)
|
||||
// le si passa una tokenstring (o un codatt) e lei, da brava, calcola
|
||||
// cumulando per tutte le attivita' nominatele
|
||||
// cumulando per tutte le attività nominatele
|
||||
// ogni riga riguarda un codiva ma tutti i registri
|
||||
// se il mese e' 13 si guarda tutto l'anno
|
||||
// se si tratta di una sola attivita' in att. mista evidenziata o servizievole,
|
||||
// se si tratta di una sola attività in att. mista evidenziata o servizievole,
|
||||
// stampa solo vendite e corrispettivi
|
||||
// L'ultimo parametro serve per calcolare i PIS (progressivi del periodo successivo)
|
||||
{
|
||||
@ -536,12 +548,6 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
_CorrItem cx;
|
||||
bool is_key;
|
||||
|
||||
// Never mind the bollox
|
||||
TString80 codtab;
|
||||
TString8 activity;
|
||||
TString4 codreg, codiva, anno;
|
||||
int mese;
|
||||
|
||||
FOR_EACH_TOKEN(atts, tmpatt)
|
||||
{
|
||||
const TString8 att(tmpatt);
|
||||
@ -550,12 +556,13 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
{
|
||||
_DescrItem* d = NULL;
|
||||
// compute
|
||||
codtab = tab->get("CODTAB");
|
||||
anno = codtab.mid(0,4);
|
||||
activity= codtab.mid(4,6);
|
||||
codreg = codtab.mid(10,3);
|
||||
mese = atoi(codtab.mid(13,2));
|
||||
codiva = codtab.mid(16,4);
|
||||
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);
|
||||
const int tipodet = atoi(codtab.mid(20,1));
|
||||
bool ok = look_reg(codreg);
|
||||
ok |= look_iva(codiva);
|
||||
|
||||
@ -564,12 +571,12 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
tiporeg tipomov = (tiporeg)_reg->get_long("I0");
|
||||
bool corrisp = _reg->get_bool("B0");
|
||||
TString tipoiva = _iva->get("S1");
|
||||
int tipodet = atoi(codtab.mid(20,1));
|
||||
TString other = tab->get("S4");
|
||||
const TString4 other = tab->get("S4");
|
||||
TToken_string s1(tab->get("S1"),'!'); // Imponibile/iva fatture in ritardo
|
||||
real rit_imp(s1.get(0));
|
||||
real rit_iva(s1.get(1));
|
||||
|
||||
/* Perchè _pim invece di tab ? 17-10-2012
|
||||
diffimp = _pim->get_real("R26");
|
||||
diffiva = _pim->get_real("R27");
|
||||
diffincimp = _pim->get_real("R28");
|
||||
@ -578,7 +585,17 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
diffimp_acq = _pim->get_real("R30");
|
||||
diffiva_acq = _pim->get_real("R31");
|
||||
diffincimp_acq = _pim->get_real("R32");
|
||||
diffinciva_acq = _pim->get_real("R33");
|
||||
diffinciva_acq = _pim->get_real("R33"); */
|
||||
|
||||
diffimp = tab->get_real("R26");
|
||||
diffiva = tab->get_real("R27");
|
||||
diffincimp = tab->get_real("R28");
|
||||
diffinciva = tab->get_real("R29");
|
||||
|
||||
diffimp_acq = tab->get_real("R30");
|
||||
diffiva_acq = tab->get_real("R31");
|
||||
diffincimp_acq = tab->get_real("R32");
|
||||
diffinciva_acq = tab->get_real("R33");
|
||||
|
||||
const bool is_rit= tipodet != 0 && month == 13 && rit_imp != 0.0; //Se fattura in ritardo con tipo detr. != 0 e si sta calcolando l'annuale
|
||||
const tipo_sospensione sosp_imp = _reg->get_bool("B1") ? (tipo_sospensione) _reg->get_int("I9") : nessuna;
|
||||
@ -586,7 +603,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
|
||||
// ACHTUNG! Corrispettivi da ventileer possono ventilare
|
||||
// ad un altro codiva; in tal caso si scrive quello
|
||||
if (corrisp && !other.empty())
|
||||
if (corrisp && other.full())
|
||||
{
|
||||
look_iva(other);
|
||||
codiva = other;
|
||||
@ -627,13 +644,10 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
{
|
||||
// vedi se c'e' gia' un item corrispondente
|
||||
int i;
|
||||
|
||||
for(i = last+1; i < _descr_arr.items(); i++)
|
||||
{
|
||||
_DescrItem * wd = (_DescrItem*)&_descr_arr[i];
|
||||
if (wd->_flags == PIM_PIS &&
|
||||
wd->_s0 == ref &&
|
||||
wd->_s1 == codiva)
|
||||
_DescrItem* wd = (_DescrItem*)&_descr_arr[i];
|
||||
if (wd->_flags == PIM_PIS && wd->_s0 == ref && wd->_s1 == codiva)
|
||||
{
|
||||
d = wd;
|
||||
break;
|
||||
@ -647,12 +661,12 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
}
|
||||
if (d == NULL)
|
||||
{
|
||||
bool isfirst = (hea == NULL);
|
||||
const bool isfirst = (hea == NULL);
|
||||
|
||||
if (isfirst)
|
||||
{
|
||||
hea = new _DescrItem(describe_pis ? PIS_HEAD : PIM_HEAD);
|
||||
hea->_f0 = skip_acq; // cosi' non compare nemmeno la colonnina! contento?
|
||||
hea->_f0 = skip_acq; // così non compare nemmeno la colonnina! contento?
|
||||
hea->_f1 = true;
|
||||
_descr_arr.insert(hea, i++);
|
||||
tot = new _DescrItem(TOT_ROW);
|
||||
@ -794,7 +808,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
}
|
||||
}
|
||||
// if (tipomov == vendita)
|
||||
// {
|
||||
{
|
||||
if (!diffimp.is_zero() || !diffiva.is_zero() ||
|
||||
!diffimp_acq.is_zero() || !diffiva_acq.is_zero())
|
||||
{
|
||||
@ -854,7 +868,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
d = NULL;
|
||||
for (j = totpos + 1; j < _descr_arr.items(); j++)
|
||||
{
|
||||
_DescrItem * wd = (_DescrItem*)&_descr_arr[j];
|
||||
_DescrItem* wd = (_DescrItem*)&_descr_arr[j];
|
||||
const bool found = wd->_flags == id && wd->_s0 == ref;
|
||||
|
||||
if (found && wd->_s1 == codiva)
|
||||
@ -876,6 +890,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
_descr_arr.insert(headi, j++);
|
||||
headi->_f0 = false;
|
||||
headi->_f1 = true;
|
||||
headi->_f2 = atoi(activity.right(1)); // Tipo attività = 1 (servizi) o 2 (mista)
|
||||
totdi = new _DescrItem(TOT_ROW_DI);
|
||||
_descr_arr.insert(totdi, j);
|
||||
}
|
||||
@ -894,7 +909,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool
|
||||
t32 += diffincimp_acq;
|
||||
t33 += diffinciva_acq;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
} // End of _pim cycle
|
||||
|
||||
@ -1435,6 +1450,7 @@ void TLiquidazione_app::set_firm(_DescrItem& d)
|
||||
if (j) set_row(i+3,"");
|
||||
}
|
||||
|
||||
static int _tipo_attivita_corrente = 0;
|
||||
|
||||
void TLiquidazione_app::set_att(_DescrItem& d)
|
||||
{
|
||||
@ -1444,7 +1460,7 @@ void TLiquidazione_app::set_att(_DescrItem& d)
|
||||
|
||||
// Bookmark
|
||||
TString book_name(d._s3);
|
||||
char flags = (char)d._f3;
|
||||
const char flags = (char)d._f3;
|
||||
|
||||
if (flags == '1') book_name << TR(" (servizi)");
|
||||
else if (flags == '2') book_name << TR(" (altre)");
|
||||
@ -1473,22 +1489,17 @@ void TLiquidazione_app::set_att(_DescrItem& d)
|
||||
(const char*)_year);
|
||||
}
|
||||
|
||||
TString tipatt;
|
||||
|
||||
const char* tipatt = "";
|
||||
if (d._f0 > 0)
|
||||
tipatt.format(d._f0 == 1 ? TR("SERVIZI") : TR("ALTRE ATTIVITA'"));
|
||||
tipatt = d._f0 == 1 ? TR("SERVIZI") : TR("ALTRE ATTIVITA'");
|
||||
|
||||
if (d._s3.empty())
|
||||
{
|
||||
att_title = flags == 'M' ? TR("Riepilogo attività mista") :
|
||||
TR("Riepilogo quater");
|
||||
att_title = flags == 'M' ? TR("Riepilogo attività mista") : TR("Riepilogo quater");
|
||||
// att_title << d._s2;
|
||||
}
|
||||
else
|
||||
att_title = format(FR("Attività %s %s %s"),
|
||||
(const char*)(d._s2),
|
||||
(const char*)(d._s3),
|
||||
(const char*)tipatt);
|
||||
att_title = format(FR("Attività %s %s %s"), (const char*)(d._s2), (const char*)(d._s3), tipatt);
|
||||
|
||||
reset_header();
|
||||
int soh = 1;
|
||||
@ -1697,47 +1708,121 @@ void TLiquidazione_app::set_liqacc_2000(_DescrItem& d)
|
||||
set_auto_ff();
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::print_diff_log(int& rw)
|
||||
bool TLiquidazione_app::print_dainc_diff_log(int& rw, int tipoatt)
|
||||
{
|
||||
if (_isregis || _isfinal)
|
||||
if (_isregis)
|
||||
return false;
|
||||
|
||||
TFilename tmp; tmp.tempdir();
|
||||
tmp.add("liqdiff.txt");
|
||||
ifstream f(tmp);
|
||||
TToken_string str(256, '\t');
|
||||
TString limit; limit << "ANNOLIQ=" << _year;
|
||||
if (_month < 13) limit << " MESELIQ=" << _month;
|
||||
TString query;
|
||||
query << "USE IVADIFF KEY 2 SELECT (TIPOMOV==1)";
|
||||
if (tipoatt == 1 || tipoatt == 2)
|
||||
query << " &&(TIPOATT==" << tipoatt << ")";
|
||||
query << "\nBY TIPOIVA DATAREG";
|
||||
query << "\nJOIN MOV INTO NUMREG==NUMREG";
|
||||
query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF";
|
||||
query << "\nFROM " << limit << "\nTO " << limit;
|
||||
|
||||
bool header = false;
|
||||
int header = 0;
|
||||
|
||||
while (f.good())
|
||||
TISAM_recordset id(query);
|
||||
const int rfat = id.items();
|
||||
if (rfat > 0)
|
||||
{
|
||||
f.getline(str.get_buffer(), str.size()); str.trim();
|
||||
if (str.full())
|
||||
const TRectype& rec = id.cursor()->curr();
|
||||
bool header_printed = false;
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
if (!header)
|
||||
real importo, imponibile, imposta;
|
||||
const TDate nulldate;
|
||||
residuo_da_liquidare(rec.get_long(RMI_NUMREG), rec.get_int(RMI_NUMRIG), nulldate,
|
||||
importo, imponibile, imposta);
|
||||
if (!importo.is_zero())
|
||||
{
|
||||
header = true;
|
||||
set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@64gPagamento@96gFattura");
|
||||
}
|
||||
const int ti = rec.get_int("TIPOIVA");
|
||||
if (ti != header)
|
||||
{
|
||||
if (ti < 2)
|
||||
set_row(rw++, TR("Fatture a liquidazione differita o per cassa da incassare"));
|
||||
else
|
||||
set_row(rw++, TR("Fatture a liquidazione differita o per cassa da pagare"));
|
||||
set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@58gTipologia@71gFattura@92gRagione sociale");
|
||||
header = ti;
|
||||
}
|
||||
|
||||
const TString4 codiva = str.get(0);
|
||||
const real importo = str.get();
|
||||
const real imponibile = str.get();
|
||||
const real imposta = str.get();
|
||||
const TString16 numpag = str.get();
|
||||
const TString16 datapag = str.get();
|
||||
const TString16 numfat = str.get();
|
||||
const TString16 datafat = str.get();
|
||||
set_row(rw++, "%s@9g%r@25g%r@41g%r@64g%s@80g%s@96g%s@112g%s",
|
||||
(const char*)codiva, &importo, &imponibile, &imposta,
|
||||
(const char*)numpag, (const char*)datapag, (const char*)numfat, (const char*)datafat);
|
||||
str.cut(0);
|
||||
const TString4 codiva = rec.get("CODIVA");
|
||||
const TString16 numfat = id.get("MOV.NUMDOC").as_string();
|
||||
const TString16 datafat = rec.get("DATAREG");
|
||||
const char* tipolog = id.get("TIPODIFF").as_int() == 2 ? TR("Per Cassa") : TR("Differita");
|
||||
|
||||
TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 40);
|
||||
set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@71g%s@81g%s@92g%s",
|
||||
(const char*)codiva, &importo, &imponibile, &imposta,
|
||||
tipolog, (const char*)numfat, (const char*)datafat,
|
||||
clifo.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return header;
|
||||
return rfat > 0;
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::print_inc_diff_log(int& rw, int tipoatt)
|
||||
{
|
||||
if (_isregis)
|
||||
return false;
|
||||
|
||||
TString limit; limit << "ANNOLIQ=" << _year;
|
||||
if (_month < 13) limit << " MESELIQ=" << _month;
|
||||
TString query;
|
||||
query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)";
|
||||
if (tipoatt == 1 || tipoatt == 2)
|
||||
query << "&&(TIPOATT==" << tipoatt << ")";
|
||||
query << "\nBY TIPOIVA DATAREGP";
|
||||
query << "\nJOIN MOV INTO NUMREG==NUMREG";
|
||||
query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF";
|
||||
query << "\nFROM " << limit << "\nTO " << limit;
|
||||
|
||||
TISAM_recordset id(query);
|
||||
const int rpag = id.items();
|
||||
if (rpag > 0)
|
||||
{
|
||||
const TRectype& rec = id.cursor()->curr();
|
||||
int header = 0;
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
const int ti = rec.get_int("TIPOIVA");
|
||||
if (ti != header)
|
||||
{
|
||||
if (ti < 2)
|
||||
set_row(rw++, TR("Fatture a liquidazione differita o per cassa incassate"));
|
||||
else
|
||||
set_row(rw++, TR("Fatture a liquidazione differita o per cassa pagate"));
|
||||
set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@58gPagamento@71gFattura@92gRagione sociale");
|
||||
header = ti;
|
||||
}
|
||||
|
||||
const TString4 codiva = rec.get(RMI_CODIVA);
|
||||
const real importo = rec.get("IMPORTO");
|
||||
const real imponibile = rec.get(RMI_IMPONIBILE);
|
||||
const real imposta = rec.get(RMI_IMPOSTA);
|
||||
const TString16 datapag = rec.get("DATAREGP");
|
||||
const TString16 numfat = id.get("MOV.NUMDOC").as_string();
|
||||
const TString16 datafat = rec.get("DATAREG");
|
||||
TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 40);
|
||||
set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@71g%s@81g%s@92g%s",
|
||||
(const char*)codiva, &importo, &imponibile, &imposta,
|
||||
(const char*)datapag, (const char*)numfat, (const char*)datafat,
|
||||
clifo.get());
|
||||
}
|
||||
}
|
||||
|
||||
return rpag > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TLiquidazione_app::set_pim_head(_DescrItem& d)
|
||||
{
|
||||
int r = 1;
|
||||
@ -1749,15 +1834,14 @@ void TLiquidazione_app::set_pim_head(_DescrItem& d)
|
||||
set_row(r++,"");
|
||||
if (d._flags == PIM_HEAD_D)
|
||||
{
|
||||
set_row(r++, TR("Fatture a liquidazione differita da incassare"));
|
||||
set_bookmark(TR("Riepilogo progressivi a liquidazione differita"), _att_bookmark);
|
||||
print_dainc_diff_log(r, d._f2);
|
||||
}
|
||||
else
|
||||
if (d._flags == PIM_HEAD_DI)
|
||||
{
|
||||
set_row(r++, TR("Fatture a liquidazione differita incassate"));
|
||||
set_bookmark(TR("Riepilogo progressivi a liquidazione differita incassati"), _att_bookmark);
|
||||
print_diff_log(r);
|
||||
print_inc_diff_log(r, d._f2);
|
||||
}
|
||||
else // PIS_HEAD
|
||||
{
|
||||
@ -1778,7 +1862,6 @@ void TLiquidazione_app::set_pim_head(_DescrItem& d)
|
||||
{
|
||||
set_row(r++, TR("Fatture a liquidazione differita incassate"));
|
||||
set_bookmark(TR("Riepilogo progressivi successivi a liquidazione differita incassati"), _att_bookmark);
|
||||
print_diff_log(r);
|
||||
}
|
||||
}
|
||||
set_row(r++,"");
|
||||
@ -1864,7 +1947,7 @@ void TLiquidazione_app::set_pim(_DescrItem& d)
|
||||
}
|
||||
}
|
||||
|
||||
void TLiquidazione_app::set_plm_diff(_DescrItem& d)
|
||||
void TLiquidazione_app::set_plm_diff(const _DescrItem& d)
|
||||
{
|
||||
int rw = 1;
|
||||
|
||||
@ -1886,21 +1969,12 @@ void TLiquidazione_app::set_plm_diff(_DescrItem& d)
|
||||
void TLiquidazione_app::set_plm(_DescrItem& d)
|
||||
{
|
||||
int rw = 1;
|
||||
if (!(d._r0.is_zero() &&
|
||||
d._r1.is_zero() &&
|
||||
d._r2.is_zero() &&
|
||||
d._r3.is_zero() &&
|
||||
d._r4.is_zero() &&
|
||||
d._r5.is_zero()))
|
||||
if (!(d._r0.is_zero() && d._r1.is_zero() && d._r2.is_zero() &&
|
||||
d._r3.is_zero() && d._r4.is_zero() && d._r5.is_zero()))
|
||||
{
|
||||
set_row(rw++,""); set_row(rw++,"");
|
||||
set_row(rw++,FR("Totale@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||||
&(d._r0),
|
||||
&(d._r1),
|
||||
&(d._r2),
|
||||
&(d._r3),
|
||||
&(d._r4),
|
||||
&(d._r5));
|
||||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5));
|
||||
set_row(rw++,"");
|
||||
}
|
||||
if (!(d._r7.is_zero() && d._r8.is_zero()))
|
||||
@ -1911,8 +1985,7 @@ void TLiquidazione_app::set_plm(_DescrItem& d)
|
||||
if (! (d._r9.is_zero() && d._r10.is_zero()))
|
||||
{
|
||||
set_row(rw++, FR("Totale acquisti indeducibili su ricavi esenti@91g%r@107g%r"),
|
||||
&(d._r9),
|
||||
&(d._r10));
|
||||
&(d._r9), &(d._r10));
|
||||
}
|
||||
|
||||
real acq_pint(d._s0);
|
||||
@ -1938,32 +2011,18 @@ void TLiquidazione_app::set_plm(_DescrItem& d)
|
||||
// per ora lascio r2 e r3 anche se sono sempre 0
|
||||
set_row(rw++, "");
|
||||
set_row(rw++,FR("Totale Generale IVA@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||||
&(d._r0),
|
||||
&(d._r1),
|
||||
&(d._r2),
|
||||
&(d._r3),
|
||||
&tot1,
|
||||
&tot2);
|
||||
&(d._r0), &(d._r1), &(d._r2), &(d._r3), &tot1, &tot2);
|
||||
}
|
||||
|
||||
// Stampa il totale progressivo da registri, comprensivo dei movimenti valevoli per il calcolo vol. affari.
|
||||
real pr_imp(d._s2);
|
||||
real pr_iva(d._s3);
|
||||
if (!(d._r11.is_zero() &&
|
||||
d._r12.is_zero() &&
|
||||
d._r13.is_zero() &&
|
||||
d._r14.is_zero() &&
|
||||
pr_imp.is_zero() &&
|
||||
pr_iva.is_zero()))
|
||||
if (!(d._r11.is_zero() && d._r12.is_zero() && d._r13.is_zero() &&
|
||||
d._r14.is_zero() && pr_imp.is_zero() && pr_iva.is_zero()))
|
||||
{
|
||||
set_row(rw++,""); set_row(rw++,"");
|
||||
set_row(rw++,FR("Totale Prog. da registri@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"),
|
||||
&(d._r11),
|
||||
&(d._r12),
|
||||
&(d._r13),
|
||||
&(d._r14),
|
||||
&(pr_imp),
|
||||
&(pr_iva));
|
||||
&(d._r11), &(d._r12), &(d._r13), &(d._r14), &(pr_imp), &(pr_iva));
|
||||
set_row(rw++,"");
|
||||
}
|
||||
}
|
||||
@ -3201,3 +3260,4 @@ void TLiquidazione_app::set_deltab(_DescrItem& d, bool iscred)
|
||||
}
|
||||
set_auto_ff(TRUE);
|
||||
}
|
||||
|
||||
|
467
cg/cg4400.cpp
467
cg/cg4400.cpp
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,9 @@
|
||||
#define F_UTCR_IVA 213
|
||||
#define F_INTRTR 214
|
||||
#define F_GEST74 215
|
||||
#define F_GESIC 216
|
||||
#define F_ICDAL 217
|
||||
#define F_ICAL 218
|
||||
|
||||
#define F_ROUNDLIQ 221
|
||||
#define F_ROUNDDIC 222
|
||||
|
@ -8,9 +8,9 @@ ENDPAGE
|
||||
|
||||
PAGE "Liquidazione" 0 0 0 2
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
GROUPBOX DLG_NULL 78 10
|
||||
BEGIN
|
||||
PROMPT 1 0 "@bDitta"
|
||||
PROMPT 1 0 "@bParametri Ditta"
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
@ -64,19 +64,14 @@ BEGIN
|
||||
FLAGS "HD"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 10
|
||||
BEGIN
|
||||
PROMPT 1 4 "@bParametri ditta"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 4 5 "Frequenza versamenti"
|
||||
PROMPT 4 3 "Frequenza versamenti"
|
||||
END
|
||||
|
||||
RADIOBUTTON F_FREQ_VERS 1 38
|
||||
BEGIN
|
||||
PROMPT 29 4 ""
|
||||
PROMPT 29 2 ""
|
||||
HELP "Indicare la frequenza dei versamenti delle liquidazioni IVA"
|
||||
ITEM "M|Mensile" MESSAGE ENABLE,F_GELIDI|CLEAR,F_INTRTR|CLEAR,F_GEST74
|
||||
ITEM "T|Trimestrale" MESSAGE CLEAR,F_GELIDI|ENABLE,F_INTRTR|ENABLE,F_GEST74
|
||||
@ -86,40 +81,70 @@ END
|
||||
|
||||
BOOLEAN F_GELIDI
|
||||
BEGIN
|
||||
PROMPT 4 6 "Liquidazione differita "
|
||||
PROMPT 4 4 "Liquidazione differita "
|
||||
FIELD B1
|
||||
END
|
||||
|
||||
BOOLEAN F_AGRMIN
|
||||
BEGIN
|
||||
PROMPT 47 6 "Agricoltore minimo "
|
||||
PROMPT 47 4 "Agricoltore minimo "
|
||||
FIELD B2
|
||||
END
|
||||
|
||||
BOOLEAN F_INTRTR
|
||||
BEGIN
|
||||
PROMPT 4 7 "Non calcolare interessi per frequenza versamenti trimestrale"
|
||||
PROMPT 4 5 "Non calcolare interessi per frequenza versamenti trimestrale"
|
||||
FIELD B3
|
||||
END
|
||||
|
||||
BOOLEAN F_GEST74
|
||||
BEGIN
|
||||
PROMPT 4 8 "Gestione versamenti 4.tr per soggetti art. 74/4"
|
||||
PROMPT 4 6 "Gestione versamenti 4.tr per soggetti art. 74/4"
|
||||
FIELD B4
|
||||
END
|
||||
|
||||
BOOLEAN F_GESIC
|
||||
BEGIN
|
||||
PROMPT 4 7 "Gestione IVA per cassa"
|
||||
FIELD B5
|
||||
MESSAGE FALSE DISABLE,F_ICDAL|DISABLE,F_ICAL
|
||||
MESSAGE TRUE ENABLE,F_ICDAL|ENABLE,F_ICAL
|
||||
MODULE IC
|
||||
END
|
||||
|
||||
DATA F_ICDAL
|
||||
BEGIN
|
||||
PROMPT 40 7 "Dal "
|
||||
CHECKTYPE REQUIRED
|
||||
FIELD D0
|
||||
MODULE IC
|
||||
END
|
||||
|
||||
DATA F_ICAL
|
||||
BEGIN
|
||||
PROMPT 60 7 "Al "
|
||||
CHECKTYPE REQUIRED
|
||||
FIELD D1
|
||||
MODULE IC
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 6
|
||||
BEGIN
|
||||
PROMPT 1 10 "@bCredito"
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
CURRENCY F_CRED_COST 18
|
||||
BEGIN
|
||||
PROMPT 4 9 "Credito di costo "
|
||||
PROMPT 4 11 "Credito di costo "
|
||||
HELP "Eventuale credito di costo dell'anno precedente"
|
||||
FIELD R5
|
||||
DRIVENBY F_CODVAL
|
||||
END
|
||||
|
||||
|
||||
LISTBOX F_UTCR_IVA 2 34
|
||||
BEGIN
|
||||
PROMPT 4 10 "Utilizzo credito IVA "
|
||||
PROMPT 4 12 "Utilizzo credito IVA "
|
||||
ITEM " |Visibile e utilizzato solo in IVA"
|
||||
ITEM "NV|Non visibile ma compensabile"
|
||||
FIELD S9
|
||||
@ -127,7 +152,7 @@ END
|
||||
|
||||
CURRENCY F_CRED_PREC 18
|
||||
BEGIN
|
||||
PROMPT 4 11 "Credito compensabile inizio anno "
|
||||
PROMPT 4 13 "Credito compensabile inizio anno "
|
||||
HELP "Eventuale credito di imposta dell'anno precedente"
|
||||
FIELD R0
|
||||
DRIVENBY F_CODVAL
|
||||
@ -135,7 +160,7 @@ END
|
||||
|
||||
CURRENCY F_CRED_RES 18
|
||||
BEGIN
|
||||
PROMPT 4 12 "Credito in compensaz.utilizzato "
|
||||
PROMPT 4 14 "Credito in compensaz.utilizzato "
|
||||
FIELD R15
|
||||
DRIVENBY F_CODVAL
|
||||
NUM_EXPR #THIS<=#F_CRED_PREC
|
||||
@ -144,14 +169,14 @@ END
|
||||
|
||||
LISTBOX F_MESE_RES_AL 2 14
|
||||
BEGIN
|
||||
PROMPT 57 12 "A "
|
||||
PROMPT 57 14 "A "
|
||||
ITEM "0|"
|
||||
FIELD I0
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEET_PLA 78
|
||||
BEGIN
|
||||
PROMPT 1 14 "Parametri attivita'"
|
||||
PROMPT 1 16 "Parametri attivita'"
|
||||
ITEM "Attiv.@5F"
|
||||
ITEM "Tipo@3"
|
||||
ITEM "Prorata"
|
||||
|
@ -882,14 +882,14 @@ void TSaldo_agg::reset()
|
||||
|
||||
void TSaldo_agg::clear_saldi(int year)
|
||||
{
|
||||
TLocalisamfile saldi(LF_SALDI);
|
||||
TFast_isamfile saldi(LF_SALDI);
|
||||
|
||||
set_anno_es(year);
|
||||
saldi.zero();
|
||||
if (anno_es() != 0)
|
||||
saldi.put(SLD_ANNOES, anno_es());
|
||||
|
||||
TRectype last(saldi.curr());
|
||||
const TRectype last = saldi.curr();
|
||||
|
||||
for (saldi.read(_isgteq, _lock);
|
||||
!saldi.eof() && saldi.curr() <= last;
|
||||
@ -926,7 +926,7 @@ void TSaldo_agg::registra()
|
||||
TDate data_ulmov;
|
||||
long num_ulmov;
|
||||
TLocalisamfile saldi(LF_SALDI);
|
||||
int conti = _tab_conti.items();
|
||||
const int conti = _tab_conti.items();
|
||||
|
||||
_tab_conti.restart();
|
||||
for (int i = 0; i < conti; i++)
|
||||
@ -1055,7 +1055,8 @@ void TSaldo_agg::registra()
|
||||
si = saldo.saldofin_esprec(annoes, tcon.gruppo(), tcon.conto(), tcon.sottoconto());
|
||||
if (si < ZERO)
|
||||
{
|
||||
flag_salini = 'A'; si = -si;
|
||||
flag_salini = 'A';
|
||||
si = -si;
|
||||
}
|
||||
else
|
||||
flag_salini = 'D';
|
||||
@ -1072,7 +1073,7 @@ void TSaldo_agg::registra()
|
||||
const TImporto avere('A', saldi.get_real(SLD_PAVERE));
|
||||
sf += dare;
|
||||
sf += avere;
|
||||
sf.normalize(+1); // Rendi sempre positivo
|
||||
sf.normalize(+1); // Rendi sempre positivo
|
||||
tcon.saldo_finale() = sf;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class TSaldo : public TObject
|
||||
int _annoes;
|
||||
int _indbil;
|
||||
TDate _inizioEs, _fineEs;
|
||||
TString16 _codcaus;
|
||||
TString4 _codcaus;
|
||||
TDate _datareg;
|
||||
TDate _datacomp;
|
||||
TString _provv;
|
||||
|
@ -93,7 +93,7 @@ Item_03 = "Visualizzazione mastrini", "cg3 -5", "F"
|
||||
Item_04 = "Visualizzazione saldi", "cg5 -2", "F"
|
||||
Item_05 = "Ricalcolo saldi", "cg4 -0", "F"
|
||||
Item_06 = "IVA", [CGMENU_010]
|
||||
Item_07 = "Stampe di contabilita`", [CGMENU_023]
|
||||
Item_07 = "Stampe di contabilità", [CGMENU_023]
|
||||
Item_08 = "Saldaconto", <scmenu.men>
|
||||
Item_09 = "Tracciabilita' CUP-CIG", <ctmenu.men>
|
||||
|
||||
@ -111,7 +111,8 @@ Item_06 = "Liste fatture", [CGMENU_026]
|
||||
Item_07 = "Gestione acconti IVA", [CGMENU_027]
|
||||
Item_08 = "Gestione versamenti IVA", [CGMENU_022]
|
||||
Item_09 = "Operazioni annuali", [CGMENU_029]
|
||||
Item_10 = "Gestione autotrasportatori", "cg4 -9", "F"
|
||||
Item_10 = "IVA per cassa / differita", <icmenu.men>
|
||||
Item_11 = "Gestione autotrasportatori", "cg4 -9", "F"
|
||||
|
||||
[CGMENU_011]
|
||||
Caption = "Tabelle ministeriali"
|
||||
|
@ -297,9 +297,15 @@ bool TRiga_scadenze::chiusa(bool update) const
|
||||
return chiusa;
|
||||
}
|
||||
|
||||
static TImporto extract_importo(const TRectype& pag, const TRiga_partite& sum, bool val, int mode)
|
||||
TImporto TPartita::importo_pagsca(const TRectype& pag, bool val, int mode) const
|
||||
{
|
||||
CHECK(pag.num() == LF_PAGSCA, "Solo PAGSCA prego");
|
||||
TImporto totale;
|
||||
const int nrigp = pag.get_int(PAGSCA_NRIGP);
|
||||
if (!esiste(nrigp))
|
||||
return totale;
|
||||
|
||||
const TRiga_partite& sum = riga(nrigp);
|
||||
|
||||
// Inizio aggiunte di Bonazzi del 16/02/2012
|
||||
if (mode & 0x10) // solo le note di credito
|
||||
@ -1093,6 +1099,9 @@ TImporto TRiga_partite::calcola_pagato_al(bool valuta,const TDate& al, const TDa
|
||||
}
|
||||
*/
|
||||
|
||||
TImporto TRiga_partite::importo_pagsca(const TRectype& pag, bool val, int mode) const
|
||||
{ return partita().importo_pagsca(pag, val, mode); }
|
||||
|
||||
int TRiga_partite::calcola_pagato_periodo(const TDate& dal, const TDate& al, TImporto& pg, TImporto& nc, TPointer_array* pagsca) const
|
||||
{
|
||||
int flag = 0;
|
||||
@ -1138,12 +1147,27 @@ int TRiga_partite::calcola_pagato_periodo(const TDate& dal, const TDate& al, TIm
|
||||
}
|
||||
}
|
||||
|
||||
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 TDate di = si.get(PART_DATAPAG);
|
||||
const TDate dj = sj.get(PART_DATAPAG);
|
||||
if (di > dj)
|
||||
pags.swap(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
FOR_EACH_ARRAY_ITEM(pags, p, obj)
|
||||
{
|
||||
const TRectype& pag = *(TRectype*)obj;
|
||||
const TRiga_partite& sum = partita().riga(pag.get_int(PAGSCA_NRIGP));
|
||||
const tipo_movimento tm = sum.tipo();
|
||||
const TImporto imp = extract_importo(pag, sum, false, 0xF);
|
||||
const TImporto imp = importo_pagsca(pag);
|
||||
if (tm == tm_nota_credito)
|
||||
{
|
||||
nc += imp;
|
||||
@ -1153,9 +1177,9 @@ int TRiga_partite::calcola_pagato_periodo(const TDate& dal, const TDate& al, TIm
|
||||
{
|
||||
pg += imp;
|
||||
flag |= 1;
|
||||
if (pagsca != NULL && tm == tm_pagamento || tm == tm_pagamento_insoluto)
|
||||
pagsca->add(obj);
|
||||
}
|
||||
if (pagsca != NULL)
|
||||
pagsca->add(obj);
|
||||
}
|
||||
|
||||
return flag;
|
||||
@ -1772,15 +1796,11 @@ int TPartita::prima_riga(long nreg, tipo_movimento tipo) const
|
||||
|
||||
// Trova la prima riga della partita contenente una fattura
|
||||
int TPartita::prima_fattura(long nreg) const
|
||||
{
|
||||
return prima_riga(nreg, tm_fattura);
|
||||
}
|
||||
{ return prima_riga(nreg, tm_fattura); }
|
||||
|
||||
// Trova la prima riga della partita contenente una pagamento
|
||||
int TPartita::primo_pagamento(long nreg) const
|
||||
{
|
||||
return prima_riga(nreg, tm_pagamento);
|
||||
}
|
||||
{ return prima_riga(nreg, tm_pagamento); }
|
||||
|
||||
void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const
|
||||
{
|
||||
@ -1794,16 +1814,10 @@ void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImp
|
||||
const tipo_movimento tipo = row.tipo();
|
||||
switch (tipo)
|
||||
{
|
||||
case tm_fattura:
|
||||
case tm_nota_credito:
|
||||
doc += i; // documenti
|
||||
break;
|
||||
case tm_pagamento:
|
||||
pag += i; // pagamenti
|
||||
break;
|
||||
default:
|
||||
imp += i; // altri importi
|
||||
break;
|
||||
case tm_fattura : // fatture
|
||||
case tm_nota_credito: doc += i; break; // note di credito
|
||||
case tm_pagamento : pag += i; break; // pagamenti
|
||||
default : imp += i; break;// altri importi
|
||||
}
|
||||
|
||||
if (tipo >= tm_pagamento)
|
||||
@ -1904,9 +1918,11 @@ real TPartita::calcola_scaduto_al(bool valuta,const TDate& al) const
|
||||
const TBill & c = conto();
|
||||
char sezione = ' ';
|
||||
|
||||
if (c.tipo() == 'C') sezione = 'D';
|
||||
if (c.tipo() == 'C')
|
||||
sezione = 'D';
|
||||
else
|
||||
if (c.tipo() == 'F') sezione = 'A';
|
||||
if (c.tipo() == 'F')
|
||||
sezione = 'A';
|
||||
else
|
||||
{
|
||||
const TRiga_partite& row = riga(ultima);
|
||||
@ -1924,9 +1940,8 @@ real TPartita::calcola_scaduto_al(bool valuta,const TDate& al) const
|
||||
{
|
||||
for (int s = row.rate(); s > 0 ;s--)
|
||||
{
|
||||
const TRiga_scadenze & rata = row.rata(s);
|
||||
const TDate data(rata.get(SCAD_DATASCAD));
|
||||
|
||||
const TRiga_scadenze& rata = row.rata(s);
|
||||
const TDate data = rata.get(SCAD_DATASCAD);
|
||||
if (data <= al)
|
||||
{
|
||||
scaduto += rata.importo(valuta);
|
||||
@ -2099,7 +2114,6 @@ void TPartita::rimuovi_riga(int r)
|
||||
chiusa(true);
|
||||
}
|
||||
|
||||
|
||||
static void somma(const TRectype& vec, TRectype& nuo, const char* field)
|
||||
{
|
||||
real totale(vec.get(field));
|
||||
|
@ -194,7 +194,7 @@ public:
|
||||
|
||||
TImporto importo(bool valuta, int mode = 0xF) const;
|
||||
TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const;
|
||||
//TImporto calcola_pagato_al(bool valuta, const TDate& al, const TDate & data_scaduto, const TDate& data_rischio, int mode = 0xF) const;
|
||||
TImporto importo_pagsca(const TRectype& pag, bool val = false, int mode = 0xF) const; // low level
|
||||
int calcola_pagato_periodo(const TDate& dal, const TDate& al, TImporto& pag, TImporto& nc, TPointer_array* pagsca = NULL) const;
|
||||
|
||||
const TString& codice_valuta() const;
|
||||
@ -305,6 +305,7 @@ public:
|
||||
TImporto calcola_saldo_al(bool valuta, const TDate& al, const TDate& data_scaduto, const TDate& data_rischio) const;
|
||||
real calcola_scaduto_al(bool valuta, const TDate& al = botime) const;
|
||||
TImporto importo_pagato_unassigned(bool val, int mode = 0xF) const;
|
||||
TImporto importo_pagsca(const TRectype& pag, bool val = false, int mode = 0xF) const; // low level
|
||||
|
||||
bool modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
|
3
cg/f171.dir
Normal file
3
cg/f171.dir
Normal file
@ -0,0 +1,3 @@
|
||||
171
|
||||
0
|
||||
$ivadiff|0|0|127|0|IVA ad esigibilità differita o per cassa|||
|
24
cg/f171.trr
Normal file
24
cg/f171.trr
Normal file
@ -0,0 +1,24 @@
|
||||
171
|
||||
19
|
||||
NUMREG|3|7|0|Numero operazione Fattura
|
||||
NUMRIG|2|3|0|Numero riga IVA
|
||||
NUMPRO|2|3|0|Numero progressivo PAG o NC
|
||||
TIPOMOV|2|1|0|Tipo movimento (1=Fattura;2=Nota credito;3=Pagamento)
|
||||
DATAREG|5|8|0|Data fattura
|
||||
NUMREGP|3|7|0|Numero operazione PAG o NC
|
||||
NUMRIGP|2|3|0|Numero riga PAG o NC
|
||||
DATAREGP|5|8|0|Data pagamento
|
||||
ANNOLIQ|2|4|0|Anno liquidazione
|
||||
MESELIQ|2|2|0|Mese liquidazione
|
||||
TIPOATT|2|1|0|Tipo attività (1=Normale; 2=Mista)
|
||||
TIPOIVA|2|1|0|Tipo IVA (1=Vendite; 2=Acquisti)
|
||||
TIPODIFF|2|1|0|IVA differita (1) o per Cassa (2)
|
||||
CODIVA|1|4|0|Codice IVA
|
||||
SEZIONE|1|1|0|Sezione <D>are <A>vere
|
||||
IMPORTO|4|18|3|Importo
|
||||
IMPONIBILE|4|18|3|Imponibile
|
||||
IMPOSTA|4|18|3|Imposta
|
||||
VERSATA|4|18|3|Imposta Versata
|
||||
2
|
||||
NUMREG+NUMRIG+NUMPRO|
|
||||
ANNOLIQ+MESELIQ+DATAREGP|X
|
@ -1,3 +1,3 @@
|
||||
23
|
||||
0
|
||||
$mov|0|0|420|0|Movimenti di prima nota|||
|
||||
$mov|0|0|421|0|Movimenti di prima nota|||
|
||||
|
@ -1,5 +1,5 @@
|
||||
23
|
||||
53
|
||||
54
|
||||
ANNOES|9|4|0|Codice esercizio
|
||||
NUMREG|3|7|0|Numero di operazione
|
||||
DATAREG|5|8|0|Data operazione
|
||||
@ -47,6 +47,7 @@ DCODNUM|1|4|0|Documento originale CODNUM
|
||||
DNDOC|3|7|0|Documento originale NDOC
|
||||
DATAINC|5|8|0|Data di incasso per liquidazione differita
|
||||
LIQDIFF|8|1|0|Flag di movimento a liquidazione differita
|
||||
IVAXCASSA|8|1|0|Flag di movimento IVA per cassa
|
||||
MODPAG|2|1|0|Modalità di pagamento 1=Non frazionato; 2=Frazionato; 3=Periodico
|
||||
CONTRATTO|1|18|0|Contratto con importo > 3000 Euro
|
||||
DATARETT|5|8|0|Data documento rettificato
|
||||
|
Loading…
x
Reference in New Issue
Block a user