Nuove tecnologie ricombinanti per ricalcolo automatico
git-svn-id: svn://10.65.10.50/trunk@2541 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a28b1b54d0
commit
826499de7f
@ -122,7 +122,6 @@ class TPrimanota_application : public TRelation_application
|
|||||||
static bool ratalit_handler(TMask_field& f, KEY key);
|
static bool ratalit_handler(TMask_field& f, KEY key);
|
||||||
static bool rataval_handler(TMask_field& f, KEY key);
|
static bool rataval_handler(TMask_field& f, KEY key);
|
||||||
|
|
||||||
|
|
||||||
static bool iva_notify(TSheet_field& s, int r, KEY key);
|
static bool iva_notify(TSheet_field& s, int r, KEY key);
|
||||||
static bool iva_handler(TMask_field& f, KEY key);
|
static bool iva_handler(TMask_field& f, KEY key);
|
||||||
static bool cg_notify(TSheet_field& s, int r, KEY key);
|
static bool cg_notify(TSheet_field& s, int r, KEY key);
|
||||||
@ -226,7 +225,7 @@ protected:
|
|||||||
|
|
||||||
void set_pagamento(const char* c, const char* d);
|
void set_pagamento(const char* c, const char* d);
|
||||||
void set_totale_pagamento();
|
void set_totale_pagamento();
|
||||||
void reset_pagamento(TMask& m);
|
void reset_pagamento();
|
||||||
void set_scadenze(TMask& m);
|
void set_scadenze(TMask& m);
|
||||||
bool read_scadenze(TMask& m);
|
bool read_scadenze(TMask& m);
|
||||||
void write_scadenze(const TMask& m);
|
void write_scadenze(const TMask& m);
|
||||||
|
@ -23,6 +23,7 @@ TPagamento& TPrimanota_application::pagamento() const
|
|||||||
CHECK(_pag, "Pagamento nullo");
|
CHECK(_pag, "Pagamento nullo");
|
||||||
return *_pag;
|
return *_pag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
||||||
{
|
{
|
||||||
TPagamento& pag = app().pagamento();
|
TPagamento& pag = app().pagamento();
|
||||||
@ -484,7 +485,7 @@ bool TPrimanota_application::reset_handler(TMask_field& f, KEY key)
|
|||||||
if (key == K_SPACE)
|
if (key == K_SPACE)
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
TMask& m = f.mask();
|
||||||
app().reset_pagamento(m);
|
app().reset_pagamento();
|
||||||
app().set_scadenze(m);
|
app().set_scadenze(m);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -494,12 +495,66 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key)
|
|||||||
{
|
{
|
||||||
if (key == K_SPACE)
|
if (key == K_SPACE)
|
||||||
{
|
{
|
||||||
const bool recalc_aut = f.get().not_empty();
|
// disclaimer: aver bisogno di mangiare significa anche fare
|
||||||
const TMask& m = f.mask();
|
// cose come quella che segue
|
||||||
|
// ----------------------------------------------------
|
||||||
|
// sembra dunque intollerabile che non si sia gia' pensato
|
||||||
|
// a questo: se c'era il ricalcolo e lo si toglie, il pagamento
|
||||||
|
// di tipo > 3 diventa del corrispondente tipo > 1 e < 3, in quanto
|
||||||
|
// cosi' la modifica della percentuale sulla prima rata puo'
|
||||||
|
// essere correttamente eseguita
|
||||||
|
// cio' implica, evidentemente, che si memorizzi non solo il
|
||||||
|
// nuovo tpr ma anche il fatto che lo si e' cambiato, in quanto
|
||||||
|
// se si riattiva il ricalcolo occorre rimetterlo come era
|
||||||
|
// in precedenza, aggiungendo (su conferma) un pompino
|
||||||
|
// di emergenza salvaguai al gentile cliente
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
TMask& m = f.mask();
|
||||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||||
|
TPagamento& pag = app().pagamento();
|
||||||
|
|
||||||
|
const bool recalc_aut = f.get().not_empty();
|
||||||
|
|
||||||
|
if (!recalc_aut && pag.tipo_prima_rata() > 3)
|
||||||
|
{
|
||||||
|
// SE CAMBIANO I SIGNIFICATI DEL TIPO PRIMA RATA BISOGNA RIFARE TUTTO
|
||||||
|
pag.set_tipo_prima_rata(pag.tipo_prima_rata() - 3);
|
||||||
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||||
|
pag.set_tpr4(TRUE);
|
||||||
|
}
|
||||||
|
else if (recalc_aut && pag.was_tpr4())
|
||||||
|
{
|
||||||
|
// SE CAMBIANO I SIGNIFICATI DEL TIPO PRIMA RATA BISOGNA RIFARE TUTTO
|
||||||
|
pag.set_tpr4(FALSE);
|
||||||
|
bool yak = pag.tpay_rata(0) != pag.importo_da_non_dividere();
|
||||||
|
if (yak)
|
||||||
|
{
|
||||||
|
if (yesno_box("L'importo della prima rata e' stato modificato. "
|
||||||
|
"Con il ricalcolo automatico esso non sara' piu'"
|
||||||
|
" modificabile. Si desidera "
|
||||||
|
#ifdef DBG
|
||||||
|
"un sapiente pompino?"))
|
||||||
|
#else
|
||||||
|
"riportare le rate alle condizioni iniziali?"))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
pag.set_tipo_prima_rata(pag.tipo_prima_rata() + 3);
|
||||||
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||||
|
app().reset_pagamento();
|
||||||
|
app().set_scadenze(m);
|
||||||
|
}
|
||||||
|
else warning_box("Il tipo prima rata rimane modificato in %s",
|
||||||
|
pag.desc_tpr());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pag.set_tipo_prima_rata(pag.tipo_prima_rata() + 3);
|
||||||
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ps.enable_column(3, recalc_aut);
|
ps.enable_column(3, recalc_aut);
|
||||||
ps.sheet_mask().enable(DLG_DELREC, !recalc_aut);
|
ps.sheet_mask().enable(DLG_DELREC, !recalc_aut);
|
||||||
TPagamento& pag = app().pagamento();
|
|
||||||
const bool on = pag.tipo_prima_rata() < 4 || !recalc_aut;
|
const bool on = pag.tipo_prima_rata() < 4 || !recalc_aut;
|
||||||
ps.enable_cell(0, 1, on);
|
ps.enable_cell(0, 1, on);
|
||||||
ps.enable_cell(0, 2, on);
|
ps.enable_cell(0, 2, on);
|
||||||
@ -582,7 +637,7 @@ bool TPrimanota_application::rataval_handler(TMask_field& f, KEY key)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrimanota_application::reset_pagamento(TMask&)
|
void TPrimanota_application::reset_pagamento()
|
||||||
{
|
{
|
||||||
TPagamento& pag = pagamento();
|
TPagamento& pag = pagamento();
|
||||||
pag.read();
|
pag.read();
|
||||||
|
@ -126,19 +126,20 @@ void TPagamento::set_tipo_prima_rata(int v, int sscad)
|
|||||||
_dirty = FALSE;
|
_dirty = FALSE;
|
||||||
if (_tpr == v) return;
|
if (_tpr == v) return;
|
||||||
|
|
||||||
if (v < 4 && _tpr > 3)
|
if (!_inited)
|
||||||
{
|
{
|
||||||
for (int i = n_rate() - 1; i > 0; i--)
|
if (v < 4 && _tpr > 3)
|
||||||
{
|
{
|
||||||
TToken_string& tt = rata(i);
|
for (int i = n_rate() - 1; i > 0; i--)
|
||||||
tt.add(scad_rata(i-1),0);
|
{
|
||||||
tt.add(tipo_rata(i-1),2);
|
TToken_string& tt = rata(i);
|
||||||
tt.add(ulc_rata(i-1),5);
|
tt.add(scad_rata(i-1),0);
|
||||||
|
tt.add(tipo_rata(i-1),2);
|
||||||
|
tt.add(ulc_rata(i-1),5);
|
||||||
|
}
|
||||||
|
_rate.destroy(0, TRUE);
|
||||||
}
|
}
|
||||||
_rate.destroy(0, TRUE);
|
else if ( _tpr < 4 && v > 3)
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( _tpr < 4 && v > 3)
|
|
||||||
{
|
{
|
||||||
TToken_string* ttn = new TToken_string(32);
|
TToken_string* ttn = new TToken_string(32);
|
||||||
ttn->add(0, 0);
|
ttn->add(0, 0);
|
||||||
@ -146,7 +147,7 @@ void TPagamento::set_tipo_prima_rata(int v, int sscad)
|
|||||||
ttn->add(1, 2);
|
ttn->add(1, 2);
|
||||||
ttn->add("", 3);
|
ttn->add("", 3);
|
||||||
ttn->add("", 4);
|
ttn->add("", 4);
|
||||||
ttn->add("", 5);
|
ttn->add("", 5);
|
||||||
_rate.insert(ttn,0);
|
_rate.insert(ttn,0);
|
||||||
for (int i = 0; i < (n_rate()-1); i++)
|
for (int i = 0; i < (n_rate()-1); i++)
|
||||||
{
|
{
|
||||||
@ -161,7 +162,18 @@ void TPagamento::set_tipo_prima_rata(int v, int sscad)
|
|||||||
TToken_string& tt = rata(1);
|
TToken_string& tt = rata(1);
|
||||||
tt.add(_int_rate, 0);
|
tt.add(_int_rate, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((_tpr > 3 && (v > 0 && v < 3)) || (v > 3 && (_tpr > 0 && _tpr < 3)))
|
||||||
|
{
|
||||||
|
// swap _firstr and _secndr
|
||||||
|
real tmp(_firstr);
|
||||||
|
_firstr = _secndr;
|
||||||
|
_secndr = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
_tpr = v;
|
_tpr = v;
|
||||||
_dirty = TRUE;
|
_dirty = TRUE;
|
||||||
}
|
}
|
||||||
@ -1573,7 +1585,17 @@ void TPagamento::set_rate_auto()
|
|||||||
main_app().end_wait();
|
main_app().end_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const real& TPagamento::importo_da_dividere() const
|
||||||
|
{
|
||||||
|
if (_tpr < 4) return _firstr;
|
||||||
|
else return _secndr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const real& TPagamento::importo_da_non_dividere() const
|
||||||
|
{
|
||||||
|
if (_tpr < 4) return _secndr;
|
||||||
|
else return _firstr;
|
||||||
|
}
|
||||||
|
|
||||||
void TPagamento::set_total(const real& imponibile, const real& imposta, const real& spese)
|
void TPagamento::set_total(const real& imponibile, const real& imposta, const real& spese)
|
||||||
{
|
{
|
||||||
@ -1761,7 +1783,8 @@ void TPagamento::adjust_fixed_scad()
|
|||||||
TPagamento::TPagamento(const char* codtab, const char* data) :
|
TPagamento::TPagamento(const char* codtab, const char* data) :
|
||||||
_slicer(0.0,0), _new(FALSE), _mcomm(FALSE), _imponibile(0.0), _imposta(0.0),
|
_slicer(0.0,0), _new(FALSE), _mcomm(FALSE), _imponibile(0.0), _imposta(0.0),
|
||||||
_spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE),
|
_spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE),
|
||||||
_def_tpr(1), _def_ulc(""), _round(0), _int_rate(30), _tpr(0), _rdiff(FALSE)
|
_def_tpr(1), _def_ulc(""), _round(0), _int_rate(30), _tpr(0), _rdiff(FALSE),
|
||||||
|
_was_tpr4(FALSE)
|
||||||
{
|
{
|
||||||
_fixd[0] = _fixd[1] = _fixd[2] = 0;
|
_fixd[0] = _fixd[1] = _fixd[2] = 0;
|
||||||
if (data != NULL && *data)
|
if (data != NULL && *data)
|
||||||
|
@ -63,6 +63,8 @@ class TPagamento : public TObject
|
|||||||
int _def_tpr; // tipo rata default
|
int _def_tpr; // tipo rata default
|
||||||
TString16 _def_ulc; // ulteriore classificazione default
|
TString16 _def_ulc; // ulteriore classificazione default
|
||||||
|
|
||||||
|
bool _was_tpr4; // chiederne ragione ai responsabili morali (bonazzi, gabriella)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// gestione casino se si modificano importi o percentuali rate
|
// gestione casino se si modificano importi o percentuali rate
|
||||||
word change_value(int rata, real new_val, int rdiff, bool is_perc, bool mcomm);
|
word change_value(int rata, real new_val, int rdiff, bool is_perc, bool mcomm);
|
||||||
@ -89,10 +91,13 @@ public:
|
|||||||
bool is_new() const { return _new; }
|
bool is_new() const { return _new; }
|
||||||
bool dirty() const { return _dirty; }
|
bool dirty() const { return _dirty; }
|
||||||
|
|
||||||
real imponibile() const { return _imponibile; }
|
const real& imponibile() const { return _imponibile; }
|
||||||
real imposta() const { return _imposta; }
|
const real& imposta() const { return _imposta; }
|
||||||
real spese() const { return _spese; }
|
const real& spese() const { return _spese; }
|
||||||
|
|
||||||
|
const real& importo_da_dividere() const;
|
||||||
|
const real& importo_da_non_dividere() const;
|
||||||
|
|
||||||
const int round() const { return _round; }
|
const int round() const { return _round; }
|
||||||
|
|
||||||
int scad_rata(int n) const { return _rata_ifield(n,0);}
|
int scad_rata(int n) const { return _rata_ifield(n,0);}
|
||||||
@ -200,8 +205,11 @@ public:
|
|||||||
void adjust_fixed_scad();
|
void adjust_fixed_scad();
|
||||||
// determina la prossima scadenza
|
// determina la prossima scadenza
|
||||||
void next_scad(TDate& d, int scad, bool mcomm, int rata);
|
void next_scad(TDate& d, int scad, bool mcomm, int rata);
|
||||||
|
|
||||||
|
// folies bergeres pretese, delle quali non rispondo a nessuno
|
||||||
|
bool was_tpr4() const { return _was_tpr4; }
|
||||||
|
void set_tpr4(bool b) { _was_tpr4 = b; }
|
||||||
|
|
||||||
// se codtab non e' NULL legge da file (e da' errore se non c'e')
|
// se codtab non e' NULL legge da file (e da' errore se non c'e')
|
||||||
// se si vuole fare un pagamento nuovo si da' il codice con set_code
|
// se si vuole fare un pagamento nuovo si da' il codice con set_code
|
||||||
TPagamento(const char* codtab = NULL, const char* data = NULL);
|
TPagamento(const char* codtab = NULL, const char* data = NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user