Correzione errori

git-svn-id: svn://10.65.10.50/trunk@2495 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-01-23 15:37:14 +00:00
parent 34765dc516
commit fa9dfaa9d0
8 changed files with 124 additions and 71 deletions

View File

@ -401,9 +401,6 @@ BEGIN
OUTPUT SK_VALUTA CODTAB
CHECKTYPE NORMAL
WARNING "Codice valuta assente"
MESSAGE EMPTY CLEAR,SK_CAMBIO|CLEAR,SK_TOTDOCVAL
MESSAGE ENABLE,SK_CAMBIO|ENABLE,SK_TOTDOCVAL
MESSAGE DIRTY,SK_DATACAMBIO|K_TAB,SK_DATACAMBIO
END
DATE SK_DATACAMBIO

View File

@ -258,7 +258,7 @@ BEGIN
DISPLAY "Descrizione@50" S0
OUTPUT S_CODDESC CODTAB
OUTPUT S_DESCAGG S0
CHECKTYPE NORMAL
CHECKTYPE SEARCH
END
STRING S_DESCAGG 50

View File

@ -525,7 +525,8 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
TMask& m = f.mask();
const long numreg = m.get_long(F_NUMREG);
TImporto saldaconto;
const bool in_valuta = m.get(SK_VALUTA).not_empty();
TImporto saldaconto, saldaconto_val;
TSheet_field& cg = app().cgs();
bool empty = TRUE;
@ -559,7 +560,11 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
}
}
if (strchr("ACGKP", tipo) != NULL)
{
saldaconto += importo;
if (in_valuta)
saldaconto_val += app().partite().importo_speso(numreg, i+1, TRUE);
}
}
}
}
@ -582,6 +587,25 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
(const char*)ss, saldaconto.sezione(),
(const char*)sr);
}
if (in_valuta)
{
const real t(f.mask().get(SK_TOTDOCVAL));
const TImporto totdoc(s, t);
TImporto residuo(totdoc); residuo += saldaconto_val; residuo.normalize();
if (!residuo.is_zero())
{
const TString st(totdoc.valore().string(".3"));
const TString ss(saldaconto_val.valore().string(".3"));
const TString sr(residuo.valore().string(".3"));
return f.error_box("Il totale documento in valuta e' %s %c,\n"
"i pagamenti e le spese ammontano a %s %c,\n"
"per cui il residuo e' %s.",
(const char*)st, totdoc.sezione(),
(const char*)ss, saldaconto.sezione(),
(const char*)sr);
}
}
}
if (app().is_fattura())
@ -1679,7 +1703,7 @@ bool TPrimanota_application::datadoc_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.to_check(key, TRUE) && app().is_saldaconto())
{
const TDate dd(f.get()); // Fattura o nota credito
const TDate dd(f.get()); // Fattura o nota credito
if (dd.ok())
{
if (m.get(F_ANNORIF).empty() && m.insert_mode())
@ -1848,7 +1872,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
m.set(F_CODPAG, s, s.not_empty());
}
if (app().is_fattura() && f.focusdirty())
if (f.focusdirty() && app().is_saldaconto())
{
if (m.field(SK_VALUTA).active() && m.get(SK_VALUTA).empty())
{
@ -1857,18 +1881,21 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
m.set(SK_VALUTA, valuta, TRUE);
}
if (clifo.get(CLI_CODCAB).not_empty())
if (app().is_fattura())
{
m.set(FS_VSABI, clifo.get(CLI_CODABI));
m.set(FS_VSCAB, clifo.get(CLI_CODCAB));
m.send_key(K_TAB, FS_VSCAB);
}
const TString& agente = cliforel.curr(LF_CFVEN).get(CLI_CODAG);
if (agente.not_empty())
{
m.set(FS_AGENTE, agente, TRUE);
m.send_key(K_TAB, FS_AGENTE);
if (clifo.get(CLI_CODCAB).not_empty())
{
m.set(FS_VSABI, clifo.get(CLI_CODABI));
m.set(FS_VSCAB, clifo.get(CLI_CODCAB));
m.send_key(K_TAB, FS_VSCAB);
}
const TString& agente = cliforel.curr(LF_CFVEN).get(CLI_CODAG);
if (agente.not_empty())
{
m.set(FS_AGENTE, agente, TRUE);
m.send_key(K_TAB, FS_AGENTE);
}
}
}
}
@ -1948,7 +1975,7 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
void TPrimanota_application::gioca_cambi(int force)
{
TMask& m = curr_mask();
if (!m.field(SK_CAMBIO).enabled())
if (m.get(SK_VALUTA).empty())
return;
const real totale = m.get(F_TOTALE);
@ -2216,17 +2243,15 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key)
if (key == K_SPACE)
{
TMask& m = f.mask();
bool anchecg = !m.get_bool(F_SOLAIVA);
bool anchecg = f.get().empty();
bool recalcg = anchecg;
if (m.is_running() && app().is_fattura() && app()._scad_free)
if (m.is_running() && app().is_fattura())
{
const TPartita* game = app().partite().first();
if (anchecg)
{
m.enable(F_NUMRIF);
m.enable(F_ANNORIF);
if (game != NULL)
{
m.set(F_ANNORIF, game->anno());
@ -2240,22 +2265,26 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key)
del = f.yesno_box("Si desidera cancellare il saldaconto?");
if (del)
{
m.set(F_NUMRIF, "", TRUE); m.disable(F_NUMRIF);
m.reset(F_ANNORIF); m.disable(F_ANNORIF);
m.set(F_NUMRIF, "", TRUE);
m.reset(F_ANNORIF);
}
else
{
anchecg = TRUE;
f.reset();
anchecg = TRUE;
recalcg = FALSE;
}
}
}
m.show(F_SHEETCG, anchecg);
m.show(F_DARE, anchecg);
m.show(F_AVERE, anchecg);
m.enable(F_ANNORIF, anchecg);
m.enable(F_NUMRIF, anchecg);
if (m.is_running() && anchecg)
m.show(F_SHEETCG, anchecg);
m.show(F_DARE, anchecg);
m.show(F_AVERE, anchecg);
if (m.is_running() && recalcg)
{
TSheet_field& iva = app().ivas();
const int righe = iva.items();

View File

@ -294,7 +294,8 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
if (key == K_ENTER)
{
const bool required = m.insert_mode() || !m.get(F_NUMRIF).blank();
const bool required = (m.insert_mode() && !m.get_bool(F_SOLAIVA)) ||
!m.get(F_NUMRIF).blank();
if (required && f.get().empty())
{
error_box("Il codice di pagamento e' obbligatorio!\n"
@ -351,12 +352,11 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
if (f.to_check(key, TRUE))
{
TMask& m = f.mask();
const bool empty = f.get().blank() && !m.get_bool(F_SOLAIVA);
const TString16 numprot(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC));
const bool empty = f.get().blank();
if (empty && numprot.not_empty() && f.focusdirty() && m.insert_mode())
if (empty && f.focusdirty() && m.insert_mode() && !m.get_bool(F_SOLAIVA))
{
f.set(numprot);
f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC));
if (m.get(F_CODPAG).empty())
{
TMask_field& clifo = m.field(app().iva() == iva_vendite ? F_CLIENTE : F_FORNITORE);
@ -371,7 +371,7 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
if (key == K_ENTER && m.edit_mode())
{
const TPartita* old = app().partite().first();
if (old && old->anno() > 0 && empty) // Se esisteva una partita ma ora non piu'
if (old && old->ok() && empty) // Se esisteva una partita ma ora non piu'
{
const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n"
"Premere SI per cancellarla, NO per ripristinarla, ANNULLA per modificarla",
@ -400,13 +400,28 @@ bool TPrimanota_application::valuta_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.to_check(key, TRUE))
{
TMask& m = f.mask();
const TString16 val(f.get());
const TString val = f.get();
const bool full = val.not_empty();
if (val.not_empty())
{
if (m.get(SK_DATACAMBIO).empty()) // Inizializza data cambio se assente
if (full)
{
TMask_field& dc = m.field(SK_DATACAMBIO);
if (dc.get().empty()) // Inizializza data cambio se assente
m.set(SK_DATACAMBIO, m.get(F_DATADOC), TRUE);
else if (f.focusdirty())
{
dc.set_dirty();
dc.check(RUNNING_CHECK); // Forza ricerca cambio
dc.on_hit(); // Forza messaggi (eventuale copia a pag. 3)
}
}
else
{
m.set(SK_CAMBIO, "", TRUE);
m.set(SK_TOTDOCVAL, "", TRUE);
}
m.enable(SK_CAMBIO, full);
m.enable(SK_TOTDOCVAL, full);
if (app().is_fattura())
m.set(FS_VALUTA, val); // Copia a pagina 3
@ -480,8 +495,6 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key)
const bool on = pag.tipo_prima_rata() < 4 || !recalc_aut;
ps.enable_cell(0, 1, on);
ps.enable_cell(0, 2, on);
// if (recalc_aut)
// ps.disable_cell(0, 3, );
ps.enable_cell(0, 3, on);
ps.force_update();
}
@ -643,25 +656,28 @@ void TPrimanota_application::set_scadenze(TMask& m)
bool TPrimanota_application::read_scadenze(TMask& m)
{
const TRectype& testa = _rel->curr();
const long nreg = testa.get_long(MOV_NUMREG);
const TDate datadoc = testa.get_date(MOV_DATADOC);
const TRectype& prima = _rel->cg(0);
TBill clifo; clifo.get(prima);
const int anno = m.get_int(F_ANNORIF);
const TString16 numpart(m.get(F_NUMRIF));
partite().destroy();
if (anno <= 0 || numpart.blank()) // Partita vuota
return FALSE;
TBill clifo; cerca_conto_cf(clifo);
const TPartita& part = partite().partita(clifo, anno, numpart);
const TRectype& testa = _rel->curr();
const long nreg = testa.get_long(MOV_NUMREG);
const TDate datadoc = testa.get_date(MOV_DATADOC);
TString codpag = testa.get(MOV_CODPAG); // Puo' variare!
const int npart = part.prima_fattura(nreg);
if (npart <= 0) // la gh'e' no!
return FALSE;
const TRiga_partite& partita = part.riga(npart);
TString codpag = testa.get(MOV_CODPAG);
if (npart <= 0) // Non esiste una riga per questo movimento
{
partite().destroy();
return FALSE; // Non dovrebbe succedere mai!
}
const TRiga_partite& partita = part.riga(npart);
if (partita.rate() > 0)
{
const TRiga_scadenze& primarata = partita.rata(1);
@ -1137,6 +1153,7 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig)
{
bool found = FALSE;
const long nreg = curr_mask().get_long(F_NUMREG);
partite().add_numreg(nreg);
for (TPartita* game = partite().first(); game; game = partite().next())
found |= notify_cgline_deletion(*game, nreg, numrig);
return found;

View File

@ -66,10 +66,11 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
set(S_NUMDOC, fatt.get(PART_NUMDOC)); // Numero documento
set(S_DATADOC, fatt.get(PART_DATADOC)); // Data documento
set(S_NUMPROT, fatt.get(PART_PROTIVA)); // Protocollo IVA
set(S_DESCR, sum.get(PART_DESCR)); // Descrizione documento
set(S_DESCR, fatt.get(PART_DESCR)); // Descrizione fattura
set(S_DATAPAG, sum.get(PART_DATAPAG)); // Data pagamento
set(S_TIPOPAG, sum.get(PART_TIPOPAG)); // Tipo pagamento
set(S_DESCAGG, sum.get(PART_DESCR)); // Descrizione documento
set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
@ -495,9 +496,9 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE && f.focusdirty())
TGame_mask& gm = (TGame_mask&)f.mask();
if (k == K_SPACE && gm.is_running())
{
TGame_mask& gm = (TGame_mask&)f.mask();
gm.fill_partite();
}
return TRUE;
@ -614,6 +615,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
const bool changing_row = gm._riga_partite != r;
if (!changing_row)
return TRUE;
main_app().begin_wait();
gm._riga_partite = r;
TSheet_field& sheet = gm.scadenze();
@ -830,7 +834,10 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
sheet.force_update();
if (sheet.items() > 0 && sheet.selected() > 0)
sheet.select(0, TRUE);
main_app().end_wait();
}
if (k == K_INS)
{
gm.send_key(K_CTRL + 'N', 0, &partite); // Simula la pressione del tasto nuovo
@ -1075,7 +1082,9 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
if (game.ok())
{
gm.update_partita(game, gm._riga_partite);
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
const int r = gm._riga_partite;
gm._riga_partite = -1; // Forza aggiornamento sheet
partite_notify(gm.partite(), r, K_TAB);
}
else
{
@ -1231,11 +1240,10 @@ int TGame_mask::update_partita(const TPartita& game, int prow)
TImporto saldo, doc, pag, imp;
game.calcola_saldo(saldo, doc, pag, imp);
TSheet_field& games = partite();
int riga_fatt = game.prima_fattura();
if (riga_fatt <= 0) riga_fatt = game.first(); // E' un anticipo
TSheet_field& games = partite();
TToken_string &r = games.row(prow); // Stringa di lavoro per lo sheet
if (game.esiste(riga_fatt)) // Esiste veramente
{
@ -1425,7 +1433,6 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
const TRiga_scadenze& scaden = p.rata(nriga, nrata);
m.set_pag(oldpag, scaden, _residuo);
}
m.set(S_DESCAGG, somma.get(PART_DESCR));
const bool nuovo = oldpag.get(PAGSCA_ACCSAL) != "S" &&
oldpag.get_real(PAGSCA_IMPORTO).is_zero() &&

View File

@ -11,6 +11,7 @@ BEGIN
PROMPT 1 3 "Importo "
PICTURE "."
CHECKTYPE REQUIRED
WARNING "L'importo della rata non puo' essere nullo"
END
BOOLEAN 112
@ -32,6 +33,7 @@ NUMBER 104 6 2
BEGIN
PROMPT 1 2 "Percentuale "
PICTURE ".2"
FLAGS "U"
END
NUMBER 105 1

View File

@ -1102,7 +1102,7 @@ bool TPartita::esiste(int nriga, int nrata, int nrigp) const
}
// Ritorna l'importo in lire speso su di una riga contabile
TImporto TPartita::importo_speso(long nreg, int numrig) const
TImporto TPartita::importo_speso(long nreg, int numrig, bool valuta) const
{
TImporto imp;
@ -1110,7 +1110,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig) const
{
const TRiga_partite& row = riga(r);
if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG))
imp += row.importo(FALSE); // Importo in lire
imp += row.importo(valuta);
}
return imp;
@ -1533,7 +1533,6 @@ int TPartita::tipopag2causale(int tipo) const
switch (tipo)
{
case 2: // Tratta
case 7: // Tratta accettata
caus = 3; break;
case 3: // Ricevuta bancaria
caus = 4; break;
@ -1543,6 +1542,8 @@ int TPartita::tipopag2causale(int tipo) const
caus = 6; break;
case 6: // Fattura di credito
caus = 7; break;
case 7: // Tratta accettata
caus = 8; break;
case 1: // Rimessa
case 8: // Rapporti interbancari diretti
case 9: // Bonifico
@ -1678,12 +1679,12 @@ bool TPartite_array::utilizzata(long numreg, int numrig)
return ok;
}
TImporto TPartite_array::importo_speso(long nreg, int numrig)
TImporto TPartite_array::importo_speso(long nreg, int numrig, bool valuta)
{
TImporto imp;
add_numreg(nreg);
for (TPartita* game = first(); game; game = next())
imp += game->importo_speso(nreg, numrig);
imp += game->importo_speso(nreg, numrig, valuta);
imp.normalize();
return imp;
}

View File

@ -280,7 +280,7 @@ public:
const TString& numero() const { return _num; }
const TString& descrizione() const;
TImporto importo_speso(long numreg, int numrig) const;
TImporto importo_speso(long numreg, int numrig, bool valuta) const;
void update_reg(long nreg, const TRectype& mov, const TRecord_array& cg);
void calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const;
TImporto calcola_saldo(bool valuta) const;
@ -331,7 +331,7 @@ public:
bool rewrite() { return write(TRUE); }
int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg
TImporto importo_speso(long numreg, int numrig);
TImporto importo_speso(long numreg, int numrig, bool valuta = FALSE);
void update_reg(const TRectype& mov, const TRecord_array& cg, long old_reg = 0);
// Controlla se esistono righe di pagamento relative alla riga numrig