cg2100.cpp :

cg2102.cpp   :
cg2104.cpp   :
cg2105.cpp   : corretti errori PR
pagament.h   :
pagament.cpp : corretto test su P_NEG
*.uml        : Cambiato nome colonna


git-svn-id: svn://10.65.10.50/trunk@2440 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-01-12 17:43:52 +00:00
parent 04c9d7c1ae
commit efe30ac51e
8 changed files with 103 additions and 70 deletions

View File

@ -489,24 +489,24 @@ void TPrimanota_application::init_mask(TMask& m)
// Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRLIRE, F_CORRVAL (GROUP 4)
m.show(-4, valintra);
m.show(F_CODIVA, m.mode() == MODE_INS); // Codice IVA standard
m.show(F_CODIVA, m.insert_mode()); // Codice IVA standard
if (is_fattura())
{
const TPartita* game = partite().first();
const bool scad_free = game == NULL || !game->esistono_abbuoni_diffcam(m.get_long(F_NUMREG));
m.enable(DLG_DELREC, scad_free); // Disabilita tasto cancella
m.enable(-1, scad_free); // Disabilita cliente
if (m.edit_mode())
m.enable(DLG_DELREC, scad_free); // Disabilita tasto elimina
m.enable(-1, scad_free); // Disabilita cliente
m.enable(-2, scad_free);
m.enable(F_ANNORIF, scad_free); // Disabilita anno e numero partita
m.enable(F_ANNORIF, scad_free); // Disabilita anno e numero partita
m.enable(F_NUMRIF, scad_free);
m.enable(F_CODPAG, scad_free); // Disabilita codice pagamento
m.enable(FS_RESET, scad_free); // Disabilita tasto di reset
m.enable(F_CODPAG, scad_free); // Disabilita codice pagamento
m.enable(FS_RESET, scad_free); // Disabilita tasto di reset
if (!scad_free)
m.set(FS_RECALC, "", TRUE);
m.enable(FS_RECALC, scad_free); // Disabilita ricalcolo automatico
m.set(FS_RECALC, "", TRUE); // Disabilita ricalcolo automatico
m.enable(FS_RECALC, scad_free);
}
}

View File

@ -521,9 +521,9 @@ BEGIN
VALIDATE REQIF_FUNC 1 F_CORRVALUTA
END
NUMBER F_CAMBIOINTRA 12 5
NUMBER F_CAMBIOINTRA 15 5
BEGIN
PROMPT 37 17 "Cambio intracom. "
PROMPT 37 17 "Cambio intracom. "
FIELD CAMBIOI
FLAGS "RU"
GROUP 4

View File

@ -1590,7 +1590,7 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
const char* data = "del 74/ter";
if (f.dlg() == F_DATACOMP)
{
m.set(F_ANNOES, ae);
m.set(F_ANNOES, ae, TRUE); // Aggiorna anno esercizio in entrambe le pagine
data = "di competenza";
}
@ -1774,15 +1774,16 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
p.add_numreg(m.get_long(F_NUMREG));
const TPartita* game = p.first();
if (game != NULL)
if (game != NULL && atol(f.get()) != game->conto().codclifo())
{
const bool del = f.yesno_box("Si desidera cancellare i pagamenti effettuati?");
if (!del) // Ripristina codice copiandolo dalla prima partita
{
TString cod; cod << game->conto().sottoconto();
TString cod; cod << game->conto().codclifo();
f.set(cod);
return TRUE;
}
f.set_dirty(); // yesno_box cleared the dirty flag
app().notify_cgline_deletion(-1);
}
}
@ -1925,23 +1926,25 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
void TPrimanota_application::gioca_cambi(int force)
{
TMask& m = curr_mask();
const TValuta valuta(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
if (valuta.in_lire())
if (!m.field(SK_CAMBIO).enabled())
return;
const real totale = m.get(F_TOTALE);
const real totval = m.get(SK_TOTDOCVAL);
const real cambio = m.get(SK_CAMBIO);
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) )
{
const real new_totale = valuta.val2lit(totval);
const TValuta cam(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
const real new_totale = cam.val2lit(totval);
if (new_totale != totale)
m.set(F_TOTALE, new_totale, TRUE);
}
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero()) )
{
const real new_totval = valuta.lit2val(totale);
const TValuta cam(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
const real new_totval = cam.lit2val(totale);
if (new_totval != totval)
m.set(SK_TOTDOCVAL, new_totval, TRUE);
}

View File

@ -49,7 +49,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
{
case K_SPACE:
{
const bool can = !recalc && (pag.n_rate() > 1) && (*ts.get(11) != 'X');
const bool can = !recalc && pag.n_rate() > 1 && ps.row(r).get_char(11) != 'X';
ps.sheet_mask().enable(DLG_DELREC, can);
}
break;
@ -87,7 +87,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
break;
case K_DEL:
doit = !recalc && (pag.n_rate() > 1) && *ts.get(11) != 'X';
doit = !recalc && pag.n_rate() > 1 && ps.row(r).get_char(11) != 'X';
if (doit)
{
pag.remove_rata(r);
@ -386,33 +386,42 @@ bool TPrimanota_application::valuta_handler(TMask_field& f, KEY key)
bool TPrimanota_application::datacambio_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty() && app().is_fattura())
{
TMask& m = f.mask();
m.set(FS_DATACAMBIO, f.get()); // Copia a pagina 3
if (key == K_TAB && f.to_check(key, TRUE))
{
if (app().is_fattura())
f.mask().set(FS_DATACAMBIO, f.get()); // Copia a pagina 3
}
return TRUE;
}
bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
{
app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire
if (key == K_TAB)
{
TMask& m = f.mask();
if (app().is_fattura())
{
TPagamento& pag = app().pagamento();
const real ex(f.get());
pag.set_cambio(ex); // Aggiorna cambio sul pagamento
m.set(FS_CAMBIO, ex); // Copia a pagina 3
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
pag.set_sheet(ps);
app().pag_rows() = ps.rows_array();
}
bool update = FALSE; // Devo ricopiarmi a pagina 3?
if (f.focusdirty())
{
app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire
if (app().is_fattura())
{
TPagamento& pag = app().pagamento();
const real ex(f.get());
pag.set_cambio(ex); // Aggiorna cambio sul pagamento
update = TRUE;
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
pag.set_sheet(ps);
app().pag_rows() = ps.rows_array();
}
}
else
update = app().is_fattura() && !m.is_running();
if (update)
m.set(FS_CAMBIO, f.get()); // Copia a pagina 3
}
return TRUE;
}
@ -791,7 +800,6 @@ void TPrimanota_application::write_scadenze(const TMask& m)
scadenza.put(SCAD_CODABI, row.get(9));
scadenza.put(SCAD_CODCAB, row.get(10));
scadenza.put(SCAD_CODAG, agente);
scadenza.put(SCAD_PAGATA, pag.ratapagata(i));
}
}

View File

@ -401,8 +401,11 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
TMask& cm = app().curr_mask(); // Legge valuta dal movimento
val.get(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
set(P_ANNO, cm.get(F_ANNORIF)); // Propone anno e partita
set(P_NUMERO, cm.get(F_NUMRIF));
if (cm.id2pos(F_ANNORIF) > 0) // Se in testata c'e' l'anno di riferimento
{
set(P_ANNO, cm.get(F_ANNORIF)); // Propone anno e partita
set(P_NUMERO, cm.get(F_NUMRIF));
}
}
val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
#endif
@ -594,8 +597,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
gm._riga_partite = r;
TSheet_field& sheet = gm.scadenze();
sheet.destroy(); // Azzera righe
TString_array& scadenze = sheet.rows_array(); // Array delle righe
scadenze.destroy(); // Azzera righe
TToken_string& row = partite.row(r);
const int anno = row.get_int(0); // Anno partita
@ -784,10 +787,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (lastrow > 0)
{
TToken_string& sp = scadenze.row(scadenze.add(""));
sp.add("Saldo ", 4);
sp.add("Saldo partita", 4);
if (cambio.in_valuta())
sp << cambio.codice() << ' ';
sp << anno << ' ' << num;
sp << ' ' << cambio.codice();
gm.add_importo(sp, tot_lit);
gm.add_importo(sp, tot_val, TRUE);
@ -803,7 +805,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
gm._valfirst = in_valuta;
}
sheet.force_update();
sheet.force_update();
if (sheet.selected() > 0)
sheet.select(0);
}
if (k == K_INS)
{
@ -1156,12 +1160,12 @@ void TGame_mask::add_importo(TToken_string& s, const TImporto& i, bool valuta, i
TImporto n(i); n.normalize();
if (valuta)
{
v = n.valore().string(3);
v = n.valore().string(0, 3);
const int sep = v.find('.');
v[sep] = ',';
}
else
v = n.valore().string(0);
v = n.valore().string(0, 0);
v << ' ' << n.sezione();
s.add(v, pos);
}

View File

@ -15,7 +15,7 @@ END
BOOLEAN 112
BEGIN
PROMPT 41 3 "Pagata"
PROMPT 35 1 "Protetta"
FLAGS "D"
END

View File

@ -968,6 +968,15 @@ word TPagamento::change_value(int rata, real user_val, int rdiff, bool is_perc)
return err;
}
// Sulla prima riga, se il tipo rata e > 0 il valore (importo o percentuale)
// puo' anche essere nullo, altrimenti deve essere positivo
bool TPagamento::sign_ok(const real& val, int row) const
{
const bool ok = val.sign() > (row == 0 && _tpr > 0 ? -1 : 0);
return ok;
}
// le quattro che seguono modificano le rate (solo importi o percentuali), e
// lasciano in last_old l'indice dell'ultima rata rimasta dalle vecchie che
// hanno adoperato
@ -983,7 +992,8 @@ word TPagamento::change_value_differenziate(int row, real user_val, bool is_perc
const int first = _tpr > 3 ? 1 : 0;
_rdiff = TRUE;
if (user_div.sign() <= 0) return P_NEG;
if (!sign_ok(user_div, row))
return P_NEG;
// togli rate gia' presenti
for (int i = first; i < row; i++)
@ -1022,8 +1032,8 @@ word TPagamento::change_value_uguali(int row, real user_val, bool is_perc)
const int tok_ind = is_perc ? 1 : 4;
const int first = _tpr > 3 ? 1 : 0;
_rdiff = FALSE;
if (user_div.sign() <= 0)
if (!sign_ok(user_div, row))
return P_NEG;
// la prima viene mantenuta uguale (vale solo per la 0 anche se _tpr > 4)
@ -1126,7 +1136,7 @@ word TPagamento::change_value_uguali_prossima(int row, real user_val, bool is_pe
const int tok_ind = is_perc ? 1 : 4;
const int first = _tpr > 3 ? 1 : 0;
if (user_div.sign() <= 0)
if (!sign_ok(user_div, row))
return P_NEG;
// togli rate gia' presenti
@ -1169,7 +1179,7 @@ word TPagamento::change_value_uguali_possible(int row, real user_val, bool is_pe
const int tok_ind = is_perc ? 1 : 4;
const int first = _tpr > 3 ? 1 : 0;
if (user_div.sign() <= 0)
if (!sign_ok(user_div, row))
return P_NEG;
// togli rate gia' presenti
@ -1467,17 +1477,22 @@ void TPagamento::set_rate_auto()
real r1(0.0), ro(0.0);
if (!_rdiff)
{
int rut = _tpr > 3 ? n_rate() - 1 : n_rate();
// usa la percentuale per la prima rata
r1 = (toslice * perc_rata(first))/real(100.0);
r1.round(_round);
real reminder = toslice - r1;
if (!reminder.is_zero())
const int rut = _tpr > 3 ? n_rate() - 1 : n_rate();
if (rut > 1) // Guy was here! Don't kill me for this
{
ro = reminder/real(rut-1); ro.trunc(_round);
r1 = (toslice - (ro*real(rut-1)));
}
// usa la percentuale per la prima rata
r1 = (toslice * perc_rata(first))/real(100.0);
r1.round(_round);
const real reminder = toslice - r1;
if (!reminder.is_zero())
{
ro = reminder/real(rut-1); ro.trunc(_round);
r1 = (toslice - (ro*real(rut-1)));
}
}
else
r1 = toslice;
}
for (int i = first; i < n_rate(); i++)
@ -1499,9 +1514,9 @@ void TPagamento::set_rate_auto()
void TPagamento::set_total(const real& imponibile, const real& imposta, const real& spese)
{
_imponibile = imponibile;
_imposta = imposta;
_spese = spese;
_imponibile = imponibile; _imponibile.round(_round);
_imposta = imposta; _imposta.round(_round);
_spese = spese; _spese.round(_round);
_inited = TRUE;
// istanzia _firstr e _secndr a seconda di _tpr

View File

@ -61,7 +61,8 @@ class TPagamento : public TObject
int _def_tpr; // tipo rata default
TString16 _def_ulc; // ulteriore classificazione default
protected:
// gestione casino se si modificano importi o percentuali rate
word change_value(int rata, real new_val, int rdiff, bool is_perc);
word change_value_differenziate(int rata, real value, bool is_perc);
@ -74,6 +75,8 @@ class TPagamento : public TObject
// riaggiusta le percentuali o gli importi rispetto al dato modificato
void adjust_perc_imp(bool is_perc, int rdiff);
// controlla il segno di un valore in base a _tpr e row
bool sign_ok(const real& val, int row) const;
public: