Patch level :4.0
Files correlati : Ricompilazione Demo : [ ] Commento :riportate modifiche al calcolo dei cespiti dalla 3.1 git-svn-id: svn://10.65.10.50/trunk@15892 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
50d9454013
commit
a7038abcc0
@ -926,8 +926,12 @@ void TAnacespi::init_insert_mode(TMask& m)
|
||||
{
|
||||
m.set(F_SPEMAN, 1);
|
||||
m.disable(F_SPEMAN);
|
||||
TDitta_cespiti& dc = ditta_cespiti();
|
||||
const TRectype& cac = dc.categoria(0, NULL, m.get_int(F_CATEGORIA));
|
||||
m.set(F_ANNIRIC, cac.get("I3"));
|
||||
}
|
||||
m.set(F_ESCLPR, _emask->tipo_cespite() != tc_pluriennale ? "X" : "");
|
||||
|
||||
// Extra: non richiesti da analisi, ma obbligatori
|
||||
m.set(F_VEICOLO, 1);
|
||||
m.set(F_USOPROM, 1);
|
||||
@ -1011,16 +1015,22 @@ int TAnacespi::write(const TMask& m)
|
||||
}
|
||||
else // Anni
|
||||
{
|
||||
const int anni = cac.get_int("I3");
|
||||
((TMask&)m).set(F_ANNIRIC, anni);
|
||||
curr.zero(CESPI_PIMM);
|
||||
curr.put(CESPI_ANNIRIC, cac.get("I3"));
|
||||
curr.put(CESPI_ANNIRIC, anni);
|
||||
curr.put(CESPI_VINCOLO, 2);
|
||||
}
|
||||
break;
|
||||
case tc_pluriennale:
|
||||
curr.put(CESPI_VINCOLO, cac.get("I2"));
|
||||
curr.put(CESPI_PMINP, cac.get("R14"));
|
||||
curr.put(CESPI_PMAXP, cac.get("R15"));
|
||||
curr.put(CESPI_ANNIRIC, cac.get("I3"));
|
||||
{
|
||||
const int anni = cac.get_int("I3");
|
||||
((TMask&)m).set(F_ANNIRIC, anni);
|
||||
curr.put(CESPI_VINCOLO, cac.get("I2"));
|
||||
curr.put(CESPI_PMINP, cac.get("R14"));
|
||||
curr.put(CESPI_PMAXP, cac.get("R15"));
|
||||
curr.put(CESPI_ANNIRIC, anni);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
153
ce/ce2101.cpp
153
ce/ce2101.cpp
@ -95,7 +95,7 @@ real TCespite::un_milione() const
|
||||
if (million.is_zero())
|
||||
{
|
||||
million = 1000000.0;
|
||||
if (is_euro_value(""))
|
||||
if (is_euro_value("")) // Se la ditta corrente e' in Euro
|
||||
{
|
||||
million /= 1936.27;
|
||||
million.round(2);
|
||||
@ -138,8 +138,9 @@ void TCespite::read_sal(int esercizio)
|
||||
if (!_salini.get_real(SALCE_VNONAMM).is_zero() &&
|
||||
_salini.get_real(SALCE_VNONAMMC).is_zero())
|
||||
{
|
||||
TEsercizi_contabili esc;
|
||||
if (esc[esercizio].inizio() < TDate(4,7,2006))
|
||||
TDate di, df;
|
||||
ditta_cespiti().esercizio_corrente(di, df);
|
||||
if (di < TDate(4,7,2006))
|
||||
_salini.put(SALCE_VNONAMMC, _salini.get(SALCE_VNONAMM));
|
||||
}
|
||||
}
|
||||
@ -151,25 +152,26 @@ void TCespite::read_sal(int esercizio)
|
||||
|
||||
_salpro = _salini;
|
||||
_salpro.put(SALCE_TPSALDO, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Lettura ed eventuale creazione degli ammortamenti iniziali e progressivi
|
||||
// Certified 99%
|
||||
void TCespite::read_amm(int esercizio)
|
||||
{
|
||||
TLocalisamfile ammce(LF_AMMCE);
|
||||
fill_amm_key(ammce.curr(), esercizio, 1);
|
||||
TRectype& curr = ammce.curr();
|
||||
fill_amm_key(curr, esercizio, 1);
|
||||
if (ammce.read() == NOERR)
|
||||
_ammini = ammce.curr();
|
||||
_ammini = curr;
|
||||
else
|
||||
{
|
||||
fill_amm_key(_ammini, esercizio, 1);
|
||||
_ammini.write(ammce);
|
||||
}
|
||||
|
||||
fill_amm_key(ammce.curr(), esercizio, 2);
|
||||
fill_amm_key(curr, esercizio, 2);
|
||||
if (ammce.read() == NOERR)
|
||||
_ammpro = ammce.curr();
|
||||
_ammpro = curr;
|
||||
else
|
||||
{
|
||||
fill_amm_key(_ammpro, esercizio, 2);
|
||||
@ -198,27 +200,45 @@ void TCespite::read_amm(int esercizio)
|
||||
// Salva SALPRO
|
||||
// Certified 100%
|
||||
void TCespite::save_sal() const
|
||||
{
|
||||
TLocalisamfile salce(LF_SALCE);
|
||||
int err = _salpro.rewrite(salce);
|
||||
if (err != NOERR)
|
||||
err = _salpro.write(salce);
|
||||
if (err != NOERR)
|
||||
error_box(FR("Errore %d durante la scrittura sui saldi del cespite %s"), err, (const char*)get(CESPI_IDCESPITE));
|
||||
log(FR("- Scrittura salpro %d: errore %d"), _tipo_sit, err);
|
||||
{
|
||||
if (!_in_memory)
|
||||
{
|
||||
TLocalisamfile salce(LF_SALCE);
|
||||
int err = _salpro.rewrite_write(salce);
|
||||
if (err != NOERR)
|
||||
error_box(FR("Errore %d durante la scrittura sui saldi del cespite %s"), err, (const char*)get(CESPI_IDCESPITE));
|
||||
log(FR("- Scrittura salpro %d: errore %d"), _tipo_sit, err);
|
||||
}
|
||||
}
|
||||
|
||||
// Salva AMMPRO
|
||||
// Certified 100%
|
||||
void TCespite::save_amm() const
|
||||
{
|
||||
TLocalisamfile ammce(LF_AMMCE);
|
||||
int err = _ammpro.rewrite(ammce);
|
||||
if (err != NOERR)
|
||||
err = _ammpro.write(ammce);
|
||||
if (err != NOERR)
|
||||
error_box(TR("Errore %d durante la scrittura sugli ammortamenti del cespite %s"), err, (const char*)get(CESPI_IDCESPITE));
|
||||
log(TR("- Scrittura ammpro %d: errore %d"), _tipo_sit, err);
|
||||
if (_in_memory)
|
||||
{
|
||||
if (_fraction > ZERO && _fraction < UNO) // Simulazione con data limite operazioni
|
||||
{
|
||||
const TDitta_cespiti& cce = ditta_cespiti();
|
||||
const char* field[] = { AMMCE_QNOR, AMMCE_QANT, AMMCE_QACC,
|
||||
AMMCE_QPERSE, AMMCE_FPRIVATO, AMMCE_QPPRIVATE, NULL };
|
||||
for (int i = 0; field[i]; i++)
|
||||
{
|
||||
real val = _ammpro.get(field[i]);
|
||||
val *= _fraction;
|
||||
cce.arrotonda(val);
|
||||
((TRectype&)_ammpro).put(field[i], val);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TLocalisamfile ammce(LF_AMMCE);
|
||||
int err = _ammpro.rewrite_write(ammce);
|
||||
if (err != NOERR)
|
||||
error_box(TR("Errore %d durante la scrittura sugli ammortamenti del cespite %s"), err, (const char*)get(CESPI_IDCESPITE));
|
||||
log(TR("- Scrittura ammpro %d: errore %d"), _tipo_sit, err);
|
||||
}
|
||||
}
|
||||
|
||||
// Ritorna il record della categoria del cespite
|
||||
@ -250,6 +270,7 @@ TTipoFabbricato TCespite::fabbricato() const
|
||||
case 2: tf = tf_altro; break;
|
||||
default: break;
|
||||
}
|
||||
CHECK(tf == tf_nessuno || veicolo() == tv_nessuno, "Fabbricato veicolato");
|
||||
return tf;
|
||||
}
|
||||
|
||||
@ -264,6 +285,7 @@ TTipoVeicolo TCespite::veicolo() const
|
||||
case 5: tv = tv_altro; break;
|
||||
default: break;
|
||||
}
|
||||
CHECK(tv == tv_nessuno || fabbricato() == tf_nessuno, "Veicolo fabbricato");
|
||||
return tv;
|
||||
}
|
||||
|
||||
@ -383,7 +405,11 @@ real TCespite::val_amm() const
|
||||
}
|
||||
|
||||
// Novita' 2006: gestione VNONAMM06 e VNONAMMC
|
||||
val -= _salpro.get_real(SALCE_VNONAMM06);
|
||||
if (_tipo_sit == 1)
|
||||
{
|
||||
val -= _salpro.get_real(SALCE_VNONAMM06); // Considero i fabbricati solo in fiscale
|
||||
}
|
||||
|
||||
if (_tipo_sit == 2)
|
||||
{
|
||||
val += _salpro.get_real(SALCE_VNONAMM); // Metto nuovamente il VNONAMM fiscale ...
|
||||
@ -744,7 +770,8 @@ void TCespite::rip_jolly(TRelation& rel, const real& num, const real& den, int m
|
||||
}
|
||||
movsem.put(flm[i], n);
|
||||
}
|
||||
rel.lfile(LF_MOVCE).rewrite();
|
||||
if (!_in_memory)
|
||||
rel.lfile(LF_MOVCE).rewrite();
|
||||
}
|
||||
|
||||
if (mode & 0x2)
|
||||
@ -764,7 +791,8 @@ void TCespite::rip_jolly(TRelation& rel, const real& num, const real& den, int m
|
||||
}
|
||||
movam.put(fla[i], n);
|
||||
}
|
||||
rel.lfile(LF_MOVAM).rewrite();
|
||||
if (!_in_memory)
|
||||
rel.lfile(LF_MOVAM).rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,13 +890,11 @@ real TCespite::calc_quota(const real& valamm, const real& perric,
|
||||
// Caso normale
|
||||
real quota = valamm * perric / CENTO;
|
||||
pereff = perric;
|
||||
|
||||
|
||||
const TDitta_cespiti& cce = ditta_cespiti();
|
||||
if (mov != NULL && cce.ragguaglio_ammortamenti_parti_vendute())
|
||||
{
|
||||
TRectype& ammmv = mov->curr(LF_AMMMV);
|
||||
TString note;
|
||||
if (!ammmv.get_bool(AMMMV_FZQUO) && !ammmv.get_bool(AMMMV_FZPER))
|
||||
{
|
||||
TDate inies, fines;
|
||||
@ -878,11 +904,14 @@ real TCespite::calc_quota(const real& valamm, const real& perric,
|
||||
const long giorni_possesso = dtmov - fnc_max(inies, dtcomp) + 1;
|
||||
const long giorni_esercizio = fines - inies + 1;
|
||||
quota = quota * giorni_possesso / giorni_esercizio;
|
||||
TString256 note;
|
||||
note.format(
|
||||
FR("Ammortamenti ragguagliati a %d giorni di possesso su %d d'esercizio"),
|
||||
giorni_possesso, giorni_esercizio);
|
||||
ammmv.put(AMMMV_NOTE, note);
|
||||
}
|
||||
ammmv.put(AMMMV_NOTE, note);
|
||||
else
|
||||
ammmv.zero(AMMMV_NOTE); // nessuna nota da registrare
|
||||
}
|
||||
|
||||
const real coeff_durata = cce.coefficiente_durata_esercizio();
|
||||
@ -902,7 +931,6 @@ real TCespite::calc_quote_perse(const real& valamm, const real& peric, const rea
|
||||
{
|
||||
const TDitta_cespiti& cce = ditta_cespiti();
|
||||
const real coeff_durata = cce.coefficiente_durata_esercizio();
|
||||
|
||||
real quota = valamm * coeff_durata * peric / CENTO;
|
||||
if (mov_vend)
|
||||
{
|
||||
@ -968,10 +996,13 @@ void TCespite::agg_quota(const real& movvalamm, TRectype& rec, const char* field
|
||||
HIDDEN const TString& catdi_get(const TRectype* pcatdi, const char* name, int sit)
|
||||
{
|
||||
CHECK(pcatdi, "NULL CATDI record");
|
||||
TString16 fname(name);
|
||||
if (sit != 1)
|
||||
{
|
||||
TString16 fname(name);
|
||||
fname.overwrite("PC", 0);
|
||||
return pcatdi->get(fname);
|
||||
return pcatdi->get(fname);
|
||||
}
|
||||
return pcatdi->get(name);
|
||||
}
|
||||
|
||||
// Non sempre basta prendere un campo da AMMINI così com'è:
|
||||
@ -985,6 +1016,7 @@ const TString& TCespite::ammini_get(const char* pstar) const
|
||||
const int fld = special.get_pos(pstar);
|
||||
if (fld >= 0) // Should ALWAYS happen: tuttavia non è affatto grave!
|
||||
{
|
||||
const TDitta_cespiti& dc = ditta_cespiti();
|
||||
const TRectype* pcatdi = NULL;
|
||||
const TRectype* pcac = NULL;
|
||||
|
||||
@ -992,7 +1024,7 @@ const TString& TCespite::ammini_get(const char* pstar) const
|
||||
int scelte = _ammini.get_int(AMMCE_SCELTE);
|
||||
if (scelte != 1) // Cerco se esiste un record appropriato su CATDI
|
||||
{
|
||||
const int anno = ditta_cespiti().esercizio_corrente();
|
||||
const int anno = dc.esercizio_corrente();
|
||||
const int gruppo = get_int(CESPI_CODCGRA);
|
||||
const TString4 specie = get(CESPI_CODSPA);
|
||||
const int categ = get_int(CESPI_CODCAT);
|
||||
@ -1033,7 +1065,7 @@ const TString& TCespite::ammini_get(const char* pstar) const
|
||||
if (!dtfunz.ok())
|
||||
{
|
||||
TDate dtdummy;
|
||||
ditta_cespiti().esercizio_corrente(dtfunz, dtdummy);
|
||||
dc.esercizio_corrente(dtfunz, dtdummy);
|
||||
}
|
||||
const int anno_funz = dtfunz.year();
|
||||
if (scelte == 2)
|
||||
@ -1074,7 +1106,7 @@ const TString& TCespite::ammini_get(const char* pstar) const
|
||||
if (!dtfunz.ok())
|
||||
{
|
||||
TDate dtdummy;
|
||||
ditta_cespiti().esercizio_corrente(dtfunz, dtdummy);
|
||||
dc.esercizio_corrente(dtfunz, dtdummy);
|
||||
}
|
||||
const int anno_funz = dtfunz.year();
|
||||
if (anno_funz < 1988)
|
||||
@ -1095,7 +1127,7 @@ const TString& TCespite::ammini_get(const char* pstar) const
|
||||
bool TCespite::ammini_get_bool(const char* pfield) const
|
||||
{
|
||||
const TString& val = ammini_get(pfield);
|
||||
return !val.blank();
|
||||
return val.full();
|
||||
}
|
||||
|
||||
real TCespite::ammini_get_real(const char* pfield) const
|
||||
@ -1473,7 +1505,8 @@ void TCespite::elabora_mov_neg(TRelation& rel, TRectype& tmv, TRectype& tmvam)
|
||||
if (tmc.get_bool("B5")) // Calcolo plus/minus valenza
|
||||
cal_valenza(tmv, tmvam, ammmv);
|
||||
|
||||
rel.lfile(LF_AMMMV).rewrite();
|
||||
if (!_in_memory)
|
||||
rel.lfile(LF_AMMMV).rewrite();
|
||||
}
|
||||
|
||||
// Scandisce tutti i movimenti del cespite fino alla data_limite
|
||||
@ -1575,15 +1608,20 @@ void TCespite::scansione_movimenti(const TDate& data_limite, bool is_valid)
|
||||
|
||||
bool TCespite::controllo_fringe_benefit()
|
||||
{
|
||||
const real fringe_benefit = ammini_get_real(AMMCE_FRINGEBEN);
|
||||
real fringe_benefit = ammini_get_real(AMMCE_FRINGEBEN);
|
||||
if (fringe_benefit <= ZERO)
|
||||
return false; // Niente fringe benefit: inutile continuare!
|
||||
|
||||
const TDitta_cespiti& dc = ditta_cespiti();
|
||||
|
||||
// SOLO situazione fiscale di veicoli in uso a dipendenti dal 2006
|
||||
if (_tipo_sit != 1 || !get_bool(CESPI_VEIDIP) || !auto_o_moto() ||
|
||||
!ditta_cespiti().legge_223_06())
|
||||
!dc.legge_223_06())
|
||||
return false;
|
||||
|
||||
fringe_benefit *= dc.coefficiente_durata_esercizio();
|
||||
dc.arrotonda(fringe_benefit);
|
||||
|
||||
const real quote = sum_fields(_ammpro, AMMCE_QNOR, AMMCE_QACC, AMMCE_QANT);
|
||||
if (quote > fringe_benefit)
|
||||
{
|
||||
@ -1804,7 +1842,7 @@ void TCespite::calc_amm_residui(bool is_valid)
|
||||
|
||||
const int uso_promiscuo = get_int(CESPI_USOPROM);
|
||||
if (_tipo_sit == 1 && uso_promiscuo > 1)
|
||||
agg_quota(valamm, _ammpro, "QNOR", true);
|
||||
agg_quota(valamm, _ammpro, AMMCE_QNOR, true);
|
||||
else
|
||||
zero_fields(_ammpro, AMMCE_FPRIVATO, AMMCE_QPPRIVATE, NULL);
|
||||
resamm -= qnor + _ammpro.get_real(AMMCE_FPRIVATO);
|
||||
@ -1816,7 +1854,7 @@ void TCespite::calc_amm_residui(bool is_valid)
|
||||
_ammpro.put(AMMCE_QACC, qacc);
|
||||
ammpro_put_perc(AMMCE_PACC, per_eff);
|
||||
if (_tipo_sit == 1 && uso_promiscuo > 1)
|
||||
agg_quota(valamm, _ammpro, "QACC", false);
|
||||
agg_quota(valamm, _ammpro, AMMCE_QACC, false);
|
||||
else
|
||||
_ammpro.zero(AMMCE_FPRIVATO);
|
||||
resamm -= qacc;
|
||||
@ -1838,7 +1876,7 @@ void TCespite::calc_amm_residui(bool is_valid)
|
||||
_ammpro.put(AMMCE_QANT, qant);
|
||||
ammpro_put_perc(AMMCE_PANT, per_eff);
|
||||
if (_tipo_sit == 1 && uso_promiscuo > 1)
|
||||
agg_quota(valamm, _ammpro, "QANT", false);
|
||||
agg_quota(valamm, _ammpro, AMMCE_QANT, false);
|
||||
else
|
||||
_ammpro.zero(AMMCE_FPRIVATO);
|
||||
}
|
||||
@ -1917,7 +1955,7 @@ void TCespite::calc_amm_residui(bool is_valid)
|
||||
|
||||
void TCespite::agg_spe_man(bool is_valid)
|
||||
{
|
||||
if (_tipo_sit != 1 || !is_valid || tipo() != tc_materiale)
|
||||
if (_tipo_sit != 1 || !is_valid || tipo() != tc_materiale || _in_memory)
|
||||
return;
|
||||
|
||||
const real vspmanu = _salpro.get(SALCE_VSPMANU);
|
||||
@ -1925,7 +1963,7 @@ void TCespite::agg_spe_man(bool is_valid)
|
||||
{
|
||||
log(TR("- Aggiornamento spese di manutenzione"));
|
||||
TDitta_cespiti& cce = ditta_cespiti();
|
||||
const int tpspeman = get_int(CESPI_TPSPEMAN);
|
||||
const int tpspeman = get_int(CESPI_TPSPEMAN);
|
||||
|
||||
const char* field = NULL; // Nome del campo da incrementare
|
||||
if (tpspeman == 2 || (tpspeman == 4 && !cce.esente_art14()))
|
||||
@ -1941,7 +1979,7 @@ void TCespite::agg_spe_man(bool is_valid)
|
||||
TString16 key;
|
||||
key.format("%04d%s%s", es, (const char*)gr, (const char*)sp);
|
||||
|
||||
TTable ccb("CCB"); // Uso TTable e non cache perche' devo anche aggiornare
|
||||
TTable ccb("CCB");
|
||||
ccb.put("CODTAB", key);
|
||||
const int err = ccb.read();
|
||||
if (err != NOERR)
|
||||
@ -1955,6 +1993,7 @@ void TCespite::agg_spe_man(bool is_valid)
|
||||
speman += vspmanu * 0.25; // 25%
|
||||
else
|
||||
speman += vspmanu * 0.05; // 5%
|
||||
cce.arrotonda(speman);
|
||||
|
||||
ccb.put(field, speman);
|
||||
ccb.put("D0", TDate(TODAY));
|
||||
@ -1967,9 +2006,30 @@ void TCespite::agg_spe_man(bool is_valid)
|
||||
}
|
||||
}
|
||||
|
||||
bool TCespite::calc_amm(int tipo_sit, const TDate& data_limite, bool recalc_spe_man)
|
||||
bool TCespite::calc_amm(int tipo_sit, const TDate& data_limite,
|
||||
bool recalc_spe_man, bool in_memory)
|
||||
{
|
||||
_tipo_sit = tipo_sit;
|
||||
|
||||
_in_memory = in_memory;
|
||||
if (in_memory)
|
||||
{
|
||||
TDate ini_es, fin_es;
|
||||
const int cod_es = ditta_cespiti().esercizio_corrente(ini_es, fin_es);
|
||||
if (data_limite >= ini_es && data_limite < fin_es)
|
||||
{
|
||||
real giorni = data_limite - ini_es + 1;
|
||||
real totali = fin_es - ini_es + 1;
|
||||
// se sono a fine mese di un anno normale approssimo al mese commerciale
|
||||
if ((totali == 365 || totali == 366) && data_limite.is_end_month())
|
||||
{
|
||||
giorni /= 30; giorni.round();
|
||||
totali = 12; // totali /= 30; totali.round();
|
||||
}
|
||||
_fraction = giorni / totali;
|
||||
}
|
||||
}
|
||||
|
||||
const TString16 idcespite = get(CESPI_IDCESPITE); // Keep it handy for debug purposes
|
||||
log(FR("* Inizio calcolo situazione %d cespite %s"), tipo_sit, (const char*)idcespite);
|
||||
|
||||
@ -2042,7 +2102,6 @@ void TCespite::load_saldi(const int tiposit, const int esercizio)
|
||||
_ammpro = _ammini;
|
||||
}
|
||||
|
||||
|
||||
TCespite::TCespite()
|
||||
: TRectype(LF_CESPI), _salini(LF_SALCE), _salpro(LF_SALCE), _ammini(LF_AMMCE), _ammpro(LF_AMMCE)
|
||||
{
|
||||
|
@ -14,6 +14,8 @@ class TCespite : public TRectype
|
||||
int _tipo_sit;
|
||||
TRectype _salini, _salpro;
|
||||
TRectype _ammini, _ammpro;
|
||||
bool _in_memory;
|
||||
real _fraction;
|
||||
|
||||
protected:
|
||||
real un_milione() const;
|
||||
@ -73,7 +75,8 @@ protected:
|
||||
bool controllo_fringe_benefit();
|
||||
|
||||
public:
|
||||
bool calc_amm(int tipo_sit, const TDate& data_limite, bool calc_spe_man = FALSE);
|
||||
bool calc_amm(int tipo_sit, const TDate& data_limite,
|
||||
bool calc_spe_man = false, bool in_memory = false);
|
||||
|
||||
const TRectype& categoria() const;
|
||||
TTipo_cespite tipo() const;
|
||||
|
@ -38,36 +38,54 @@ TOpenesc_mask::TOpenesc_mask()
|
||||
// Controlla che siano stati stampati i bollati e chiuse le attivita
|
||||
bool TOpenesc_mask::check_oldes()
|
||||
{
|
||||
bool ok = TRUE;
|
||||
bool ok = true;
|
||||
const TString& oldes = get(F_OLDES);
|
||||
|
||||
TRelation rel("CCB");
|
||||
TRectype& ccb = rel.curr();
|
||||
ccb.put("CODTAB", get(F_OLDES));
|
||||
ccb.put("CODTAB", oldes);
|
||||
TCursor cur(&rel, "", 1, &ccb, &ccb);
|
||||
const long items = cur.items();
|
||||
cur.freeze();
|
||||
|
||||
TString msg;
|
||||
int error = 0;
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
const bool b1 = ccb.get_bool("B1");
|
||||
const bool b2 = ccb.get_bool("B2");
|
||||
if (!b1 || b2)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Non è possibile aprire il nuovo esercizio in quanto ");
|
||||
if (!b1)
|
||||
msg << TR("non è stato stampato il bollato");
|
||||
{
|
||||
msg << TR("Non è stato stampato il bollato dell'attività");
|
||||
error |= 0x1;
|
||||
}
|
||||
else
|
||||
msg << TR("è già stata effettuata la chiusura");
|
||||
{
|
||||
msg << TR("E' già stata effettuata la chiusura dell'attività");
|
||||
error |= 0x2;
|
||||
}
|
||||
const TString8 codatt = ccb.get("CODTAB").mid(4);
|
||||
msg << TR("\ndell'attività ") << cache().get("%CAT", codatt, "S0");
|
||||
#ifdef DBG
|
||||
msg << "\nSi desidera forzare la riapertura?";
|
||||
ok = yesno_box(msg);
|
||||
#else
|
||||
ok = error_box(msg);
|
||||
#endif
|
||||
break;
|
||||
msg << ' ' << oldes << ' ' << cache().get("%CAT", codatt, "S0") << ".\n";
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
if (get_int(F_NEWES) >= _dc.esercizio_corrente())
|
||||
{
|
||||
if (error & 0x1)
|
||||
{
|
||||
msg << TR("Verra' effettuata un'apertura provvisoria.") << '\n';
|
||||
set(F_PROVVIS, true);
|
||||
}
|
||||
msg << TR("Si desidera proseguire ugualmente?");
|
||||
ok = yesno_box(msg);
|
||||
}
|
||||
else
|
||||
ok = error_box(msg);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -135,7 +153,7 @@ protected:
|
||||
|
||||
public:
|
||||
bool crea_esercizio(int oldes, int newes, const TDate& ies, const TDate& fes) const;
|
||||
void crea_attivita(int oldes, int newes) const;
|
||||
void crea_attivita(int oldes, int newes, bool provvis) const;
|
||||
void crea_registro(int oldes, int newes) const;
|
||||
void crea_categorie(int oldes, int newes) const;
|
||||
void crea_saldi(int oldes, int newes) const;
|
||||
@ -224,7 +242,7 @@ bool TOpenesc::crea_esercizio(int oldes, int newes, const TDate& ies, const TDat
|
||||
return true;
|
||||
}
|
||||
|
||||
void TOpenesc::crea_attivita(int oldes, int newes) const
|
||||
void TOpenesc::crea_attivita(int oldes, int newes, bool provvis) const
|
||||
{
|
||||
TRelation rel("CCB");
|
||||
TRectype& ccb = rel.curr();
|
||||
@ -234,12 +252,14 @@ void TOpenesc::crea_attivita(int oldes, int newes) const
|
||||
cur.freeze();
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
ccb.put("B2", TRUE); // Setta flag di chiusa
|
||||
rel.rewrite();
|
||||
|
||||
if (!provvis)
|
||||
{
|
||||
ccb.put("B2", true); // Setta flag di chiusa
|
||||
rel.rewrite();
|
||||
}
|
||||
// Crea nuova attività
|
||||
TString16 codtab = ccb.get("CODTAB");
|
||||
TString8 str; str.format("%04d", newes);
|
||||
TString4 str; str.format("%04d", newes);
|
||||
codtab.overwrite(str);
|
||||
const bool leasing = ccb.get_bool("B0");
|
||||
const TString8 codreg = ccb.get("S6");
|
||||
@ -247,7 +267,9 @@ void TOpenesc::crea_attivita(int oldes, int newes) const
|
||||
ccb.put("CODTAB", codtab);
|
||||
ccb.put("B0", leasing);
|
||||
ccb.put("S6", codreg);
|
||||
rel.write();
|
||||
int err = rel.write();
|
||||
if (err != NOERR)
|
||||
rel.rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +309,9 @@ void TOpenesc::crea_categorie(int oldes, int newes) const
|
||||
cat.put(CATDI_CODES, newes);
|
||||
cat.zero(CATDI_DATE);
|
||||
cat.zero(CATDI_TPOP);
|
||||
rel.write();
|
||||
int err = rel.write();
|
||||
if (err != NOERR)
|
||||
rel.rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +326,8 @@ void TOpenesc::incr_riv(TRectype& rec, const char* riv, const char* anni) const
|
||||
|
||||
void TOpenesc::test_alien(const TRectype& salce, const TDate& fines) const
|
||||
{
|
||||
if (null_fields(salce, SALCE_NUMELE, SALCE_CSTO, SALCE_RIV75, SALCE_RIV83, SALCE_RIV90, SALCE_RIV91, SALCE_RIVGF))
|
||||
if (null_fields(salce, SALCE_NUMELE, SALCE_CSTO, SALCE_RIV75, SALCE_RIV83,
|
||||
SALCE_RIV90, SALCE_RIV91, SALCE_RIVGF, SALCE_RIVGC))
|
||||
{
|
||||
const TString16 idcespite = salce.get(SALCE_IDCESPITE);
|
||||
TLocalisamfile cespiti(LF_CESPI);
|
||||
@ -334,7 +359,7 @@ void TOpenesc::crea_saldi(int oldes, int newes) const
|
||||
TEsercizi_contabili esc;
|
||||
const TDate fines = esc[oldes].fine();
|
||||
|
||||
TProgind pi(items, "Apertura saldi", FALSE, TRUE);
|
||||
TProgind pi(items, TR("Apertura saldi"), FALSE, TRUE);
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
@ -359,9 +384,7 @@ void TOpenesc::crea_saldi(int oldes, int newes) const
|
||||
|
||||
const int err = rel.write();
|
||||
if (err != NOERR) // Should never happen!
|
||||
{
|
||||
rel.rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,9 +446,10 @@ void TOpenesc::main_loop()
|
||||
const int newes = m.get_int(F_NEWES);
|
||||
const TDate ies(m.get(F_NEWINIZIO));
|
||||
const TDate fes(m.get(F_NEWFINE));
|
||||
const bool provvis = m.get_bool(F_PROVVIS);
|
||||
if (crea_esercizio(oldes, newes, ies, fes))
|
||||
{
|
||||
crea_attivita(oldes, newes);
|
||||
crea_attivita(oldes, newes, provvis);
|
||||
crea_registro(oldes, newes);
|
||||
crea_categorie(oldes, newes);
|
||||
crea_saldi(oldes, newes);
|
||||
@ -438,6 +462,6 @@ void TOpenesc::main_loop()
|
||||
int ce2200(int argc, char* argv[])
|
||||
{
|
||||
TOpenesc a;
|
||||
a.run(argc, argv, TR("Cambio esercizio"));
|
||||
a.run(argc, argv, TR("Apertura esercizio cespiti"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -6,3 +6,4 @@
|
||||
#define F_NEWES 106
|
||||
#define F_NEWINIZIO 107
|
||||
#define F_NEWFINE 108
|
||||
#define F_PROVVIS 109
|
||||
|
@ -88,6 +88,11 @@ BEGIN
|
||||
WARNING "La data di fine esercizio deve essere successiva a quella di inizio"
|
||||
END
|
||||
|
||||
BOOLEAN F_PROVVIS
|
||||
BEGIN
|
||||
PROMPT 2 5 "Apertura provvisoria (per simulazioni)"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 12 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user