Correzioni a errori da PR

git-svn-id: svn://10.65.10.50/trunk@2476 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-01-19 13:09:12 +00:00
parent 5116c3f37e
commit 567eaa4f6e
8 changed files with 153 additions and 82 deletions

View File

@ -83,8 +83,8 @@ TMask* TPrimanota_application::load_mask(int n)
case 2:
if (m)
{
m->set_handler(F_DATADOC, doc_handler);
m->set_handler(F_NUMDOC, doc_handler);
m->set_handler(F_DATADOC, datadoc_handler);
m->set_handler(F_NUMDOC, numdoc_handler);
m->set_handler(F_DATA74TER, data74ter_handler);
m->set_handler(F_PROTIVA, protiva_handler);
m->set_handler(F_CLIENTE, clifo_handler);
@ -494,19 +494,19 @@ void TPrimanota_application::init_mask(TMask& m)
if (is_fattura())
{
const TPartita* game = partite().first();
const bool scad_free = game == NULL || !game->esistono_abbuoni_diffcam(m.get_long(F_NUMREG));
_scad_free = game == NULL || !game->esistono_abbuoni_diffcam(m.get_long(F_NUMREG));
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_NUMRIF, scad_free);
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); // Disabilita ricalcolo automatico
m.enable(FS_RECALC, scad_free);
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_NUMRIF, _scad_free);
m.enable(F_SOLAIVA, _scad_free); // Disabilita movimenti di sola IVA
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); // Disabilita ricalcolo automatico
m.enable(FS_RECALC, _scad_free);
}
}
@ -675,8 +675,7 @@ int TPrimanota_application::read(TMask& m)
return _rel->status();
const bool solaiva = i == 0;
m.set(F_SOLAIVA, solaiva ? "X" : " ");
m.field(F_SOLAIVA).on_hit();
m.set(F_SOLAIVA, solaiva ? "X" : " ", TRUE);
const bool to_swap = test_swap(FALSE);
if (to_swap)

View File

@ -158,9 +158,7 @@ BEGIN
PROMPT 1 9 ""
FLAGS "Z"
ITEM "A|Acconto"
MESSAGE DIRTY,S_IMPORTO|K_TAB,S_IMPORTO|DIRTY,S_IMPORTOVAL|K_TAB,S_IMPORTOVAL
ITEM "S|Saldo"
MESSAGE RESET,S_RESIDUORATA
FIELD ACCSAL
END

View File

@ -586,8 +586,8 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
if (app().is_fattura())
{
TBill contocf;
if (!app().cerca_conto_cf(contocf))
TBill contocf;
if (app().cerca_conto_cf(contocf) < 0)
{
TString msg(80); msg = "Non esiste una riga contabile riferita al ";
msg << (contocf.tipo() == 'C' ? "cliente" : "fornitore") << ' ';
@ -1654,43 +1654,42 @@ bool TPrimanota_application::data74ter_handler(TMask_field& f, KEY key)
return ok;
}
bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
bool TPrimanota_application::numdoc_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
if (key == K_TAB && f.to_check(key, TRUE) && m.insert_mode() && app().is_saldaconto())
{
if (!app().npart_is_prot()) // Copiare numero documento nel numero partita?
{
if (m.get(F_NUMRIF).empty())
m.set(F_NUMRIF, f.get(), TRUE);
}
}
return TRUE;
}
bool TPrimanota_application::datadoc_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
if (key == K_TAB && m.insert_mode() && app().is_saldaconto())
if (key == K_TAB && f.to_check(key, TRUE) && app().is_saldaconto())
{
const TString16 val(f.get());
if (val.not_empty())
{
if (f.dlg() == F_DATADOC)
{
const TDate dd(val); // Fattura o nota credito
if (m.get(F_ANNORIF).empty())
m.set(F_ANNORIF, dd.year()); // copia anno documento
if (app().is_fattura())
const TDate dd(f.get()); // Fattura o nota credito
if (dd.ok())
{
if (m.get(F_ANNORIF).empty())
m.set(F_ANNORIF, dd.year()); // copia anno documento
if (app().is_fattura())
{
if (m.insert_mode())
app().recalc_scadenze(dd);
}
else
if (!app().npart_is_prot())
{
if (m.get(F_NUMRIF).empty())
m.set(F_NUMRIF, val, TRUE); // copia numero documento
}
}
}
else
if (key == K_TAB && m.edit_mode() && app().is_saldaconto())
{
if (f.dlg() == F_DATADOC)
{
const TDate dd(f.get()); // Fattura o nota credito
if (app().is_fattura())
else
app().pagamento().set_datadoc(dd);
}
}
}
}
return TRUE;
}
@ -2213,7 +2212,40 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key)
if (key == K_SPACE)
{
TMask& m = f.mask();
const bool anchecg = !m.get_bool(F_SOLAIVA);
bool anchecg = !m.get_bool(F_SOLAIVA);
if (m.is_running() && app().is_fattura() && app()._scad_free)
{
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());
m.set(F_NUMRIF, game->numero(), TRUE);
}
}
else
{
bool del = TRUE;
if (game != NULL)
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);
}
else
{
anchecg = TRUE;
f.reset();
}
}
}
m.show(F_SHEETCG, anchecg);
m.show(F_DARE, anchecg);

View File

@ -47,7 +47,8 @@ class TPrimanota_application : public TRelation_application
bool _sheet_shown; // Lo sheet e' gia' stato visualizzato una volta?
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
bool _is_saldaconto; // saldaconto si/no (vede parametri e causale)
bool _scad_free; // posso variare liberamente le rate della fattura
TSaldo_agg _saldi; // Saldi da aggiornare
TPartite_array _partite; // Partite coinvolte
@ -80,7 +81,8 @@ class TPrimanota_application : public TRelation_application
static bool datareg_handler(TMask_field& f, KEY key);
static bool datacomp_handler(TMask_field& f, KEY key);
static bool data74ter_handler(TMask_field& f, KEY key);
static bool doc_handler(TMask_field& f, KEY key);
static bool datadoc_handler(TMask_field& f, KEY key);
static bool numdoc_handler(TMask_field& f, KEY key);
static bool annorif_handler(TMask_field& f, KEY key);
static bool numrif_handler(TMask_field& f, KEY key);
static bool protiva_handler(TMask_field& f, KEY key);
@ -231,7 +233,7 @@ protected:
void renumber_partita(TMask& m, const char* oldp, const char* newp);
void recalc_scadenze(const TDate& d);
bool cerca_conto_cf(TBill& bill) const;
int cerca_conto_cf(TBill& bill) const;
bool edit_partite(const TMask& m, int riga);

View File

@ -351,7 +351,7 @@ 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();
const bool empty = f.get().blank() && !m.get_bool(F_SOLAIVA);
if (empty && f.focusdirty() && m.insert_mode())
{
@ -399,12 +399,16 @@ bool TPrimanota_application::valuta_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.to_check(key, TRUE))
{
TMask& m = f.mask();
TEdit_field& dc = m.efield(SK_DATACAMBIO);
if (dc.get().empty()) // Inizializza data cambio se assente
m.set(SK_DATACAMBIO, m.get(F_DATADOC), TRUE);
const TString16 val(f.get());
if (val.not_empty())
{
if (m.get(SK_DATACAMBIO).empty()) // Inizializza data cambio se assente
m.set(SK_DATACAMBIO, m.get(F_DATADOC), TRUE);
}
if (app().is_fattura())
m.set(FS_VALUTA, f.get()); // Copia a pagina 3
m.set(FS_VALUTA, val); // Copia a pagina 3
}
return TRUE;
}
@ -725,21 +729,22 @@ bool TPrimanota_application::read_scadenze(TMask& m)
return TRUE;
}
bool TPrimanota_application::cerca_conto_cf(TBill& bill) const
int TPrimanota_application::cerca_conto_cf(TBill& bill) const
{
const char tipocf = clifo();
const long codcf = curr_mask().get_long(tipocf == 'C' ? F_CLIENTE : F_FORNITORE);
TString_array& a = cgs().rows_array();
for (int r = 0; r < a.items(); r++)
{
bill.get(a.row(r), 2, 0x1);
{
TToken_string& row = a.row(r);
bill.get(row, 2, 0x1);
if (bill.tipo() == tipocf && bill.codclifo() == codcf)
return TRUE;
return r;
}
bill.set(0, 0, codcf, tipocf);
return FALSE;
return -1;
}
void TPrimanota_application::write_scadenze(const TMask& m)
@ -761,8 +766,9 @@ void TPrimanota_application::write_scadenze(const TMask& m)
const TString agente (m.get(FS_AGENTE));
const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere
TBill clifo; cerca_conto_cf(clifo);
CHECK(clifo.ok(), "Impossibile generare la fattura senza gruppo/conto cliente");
TBill clifo;
const int riga_clifo = cerca_conto_cf(clifo);
CHECK(riga_clifo >= 0, "Impossibile generare la fattura senza gruppo/conto cliente");
newgame = new TPartita(clifo, anno, numpart);
const int row = newgame->prima_fattura(nreg); // Riga fattura di questo movimento
@ -781,7 +787,10 @@ void TPrimanota_application::write_scadenze(const TMask& m)
partita.put(PART_REG, causale().reg().name());
partita.put(PART_PROTIVA, m.get_long(F_PROTIVA));
partita.put(PART_SEZ, sezione);
partita.put(PART_IMPTOTDOC, m.get(F_TOTALE));
const TImporto totdoc = get_cgs_imp(riga_clifo);
partita.put(PART_IMPTOTDOC, totdoc.valore());
cambio.put(partita);
const bool in_valuta = cambio.in_valuta();

View File

@ -25,6 +25,7 @@ class TPay_mask : public TMask
protected:
static bool importo_handler(TMask_field& f, KEY k);
static bool importolire_handler(TMask_field& f, KEY k);
static bool saldo_handler(TMask_field& f, KEY k);
static bool cambio_handler(TMask_field& f, KEY k);
static bool datapag_handler(TMask_field& f, KEY k);
static bool conto_handler(TMask_field& f, KEY k);
@ -90,6 +91,7 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
}
else
set_handler(S_IMPORTO, importo_handler);
set_handler(S_SALDOACC, saldo_handler);
real oldimp = oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
if (!in_valuta)
@ -225,7 +227,7 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
if (m.field(S_RITENUTE).active())
i += real(m.get(S_RITENUTE));
if (i >= m._da_pagare && m.field(S_SALDOACC).active())
if (i >= m._da_pagare && m.mode() == NO_MODE && m.field(S_SALDOACC).active())
m.set(S_SALDOACC, "S");
if (m.get(S_SALDOACC)[0] != 'S')
@ -255,6 +257,21 @@ bool TPay_mask::importolire_handler(TMask_field& f, KEY k)
return TRUE;
}
bool TPay_mask::saldo_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
TMask& m = f.mask();
m.set_mode(MODE_QUERY);
TMask_field& imp = m.field(m.field(S_IMPORTOVAL).active() ? S_IMPORTOVAL : S_IMPORTO);
imp.set_dirty();
imp.on_hit();
m.set_mode(NO_MODE);
}
return TRUE;
}
bool TPay_mask::cambio_handler(TMask_field& f, KEY k)
{
if (k == K_TAB && f.focusdirty())
@ -607,7 +624,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
gm.set(P_NUMERO, num);
TValuta cambio;
bool in_valuta = FALSE;
bool prima_valuta = FALSE;
if (anno > 0)
{
@ -629,7 +646,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
continue;
cambio.get(riga);
in_valuta = cambio.in_valuta();
const bool in_valuta = cambio.in_valuta();
if (in_valuta)
prima_valuta = TRUE;
riga_fattura.cut(0);
riga_fattura.add(ri);
@ -799,15 +818,13 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
delete game;
}
if (in_valuta != gm._valfirst)
if (prima_valuta != gm._valfirst)
{
sheet.swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta
gm._valfirst = in_valuta;
gm._valfirst = prima_valuta;
}
sheet.force_update();
if (sheet.selected() > 0)
sheet.select(0);
}
if (k == K_INS)
{
@ -1049,9 +1066,17 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
#endif
}
if (cambiato)
{
gm.update_partita(game, gm._riga_partite);
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
{
if (game.ok())
{
gm.update_partita(game, gm._riga_partite);
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
}
else
{
app().partite().destroy(game);
gm.fill_partite();
}
gm._changed = TRUE;
}
}
@ -1137,7 +1162,7 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
gm._changed = TRUE;
}
else
app().partite().destroy(gm.conto(), anno, numero);
app().partite().destroy(game);
gm.fill_partite(); // Aggiorna sheet partite
}
}
@ -1364,7 +1389,7 @@ void TGame_mask::fill_partite()
if (a.items() > 1)
{
partite().select(r, TRUE);
partite().select(r, TRUE);
}
else
{
@ -1423,7 +1448,7 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
somma.put(PART_DATAPAG, m.get(S_DATAPAG)); // Aggiorna data pagamento (comune alla riga)
somma.put(PART_TIPOPAG, m.get(S_TIPOPAG)); // Aggiorna tipo pagamento (comune alla riga)
#ifndef __EXTRA__
aggiorna_sorelle(somma);
// aggiorna_sorelle(somma); // Tolta chiamata alla aggiorna sorelle lasciare la funzione perche potrebbe servire in futuro
#endif
}

View File

@ -1460,7 +1460,7 @@ void TPartita::sposta_riga(int r, TPartita& part)
int new_sca = i; // Nuovo numero rata (uguale a prima)
const int nrigp = address[j]; // Nuova riga somma (e pagamento)
if (!part.esiste(new_row, new_sca)) // Se la nuova partita non ha la rata
if (!part.esiste(new_row, new_sca)) // Se la nuova partita non ha la rata
new_row = new_sca = UNASSIGNED; // allora sposta sui non asseganti
TRectype npg(LF_PAGSCA); // Nuovo record di pagamento
@ -1468,7 +1468,6 @@ void TPartita::sposta_riga(int r, TPartita& part)
if (part.esiste(new_row, new_sca, nrigp)) // Se il pagamento esiste di gia'
{
npg = part.pagamento(new_row, new_sca, nrigp);
CHECK(npg.get_char(PAGSCA_ACCSAL) != 'S', "Can't add to soldered payment");
somma(pag, npg, PART_IMPORTO);
somma(pag, npg, PART_IMPORTOVAL);
somma(pag, npg, PART_RITENUTE);
@ -1616,6 +1615,12 @@ bool TPartite_array::destroy(const TBill& clifo, int anno, const char* num)
return remove(k);
}
bool TPartite_array::destroy(TPartita& game)
{
const TString& k = key(game.conto(), game.anno(), game.numero());
return remove(k);
}
bool TPartite_array::write(bool re)
{
bool ok = TRUE;

View File

@ -325,6 +325,7 @@ public:
{ return ((TPartite_array*)this)->find(part, FALSE); }
bool destroy(const TBill& clifo, int anno, const char* num);
bool destroy(TPartita& game);
bool write(bool re = FALSE);
bool rewrite() { return write(TRUE); }