Corretta gestione saldaconto con valuta
git-svn-id: svn://10.65.10.50/trunk@2653 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f2770ff0cb
commit
6fd645a927
@ -5,6 +5,32 @@
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "sc0100.h"
|
||||
#include "sc0100a.h"
|
||||
|
||||
HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
static bool ignore = FALSE;
|
||||
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
if (!ignore)
|
||||
{
|
||||
TMask_field& c = f.mask().field(F_CONTO);
|
||||
if (c.get().not_empty())
|
||||
{
|
||||
ignore = TRUE;
|
||||
c.set_dirty();
|
||||
c.on_key(K_TAB);
|
||||
ignore = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione saldaconto extra-contabile
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TSaldaconto_app::TSaldaconto_app()
|
||||
: _file(32), _allow_firm(TRUE)
|
||||
@ -13,7 +39,10 @@ TSaldaconto_app::TSaldaconto_app()
|
||||
bool TSaldaconto_app::create()
|
||||
{
|
||||
open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
|
||||
|
||||
_msk = new TMask("sc0100a");
|
||||
_msk->set_handler(F_GRUPPO, gruppo_handler);
|
||||
|
||||
dispatch_e_menu(MENU_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
@ -99,7 +128,7 @@ void TSaldaconto_app::gioca_cambi(TMask& m, int force)
|
||||
|
||||
int sc0100(int argc, char* argv[])
|
||||
{
|
||||
TSaldaconto_app app;
|
||||
app.run(argc, argv, "Gestione Saldaconto");
|
||||
TSaldaconto_app salda;
|
||||
salda.run(argc, argv, "Gestione Saldaconto");
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ END
|
||||
BUTTON DLG_DELREC 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 ""
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
@ -55,7 +56,6 @@ DATE E_DATADOC
|
||||
BEGIN
|
||||
PROMPT 1 4 "Data documento "
|
||||
FIELD LF_PARTITE->DATADOC
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Inserire una data documento non superiore alla data dell'operazione"
|
||||
VALIDATE DATE_CMP_FUNC <= E_DATAREG
|
||||
END
|
||||
@ -104,11 +104,12 @@ BEGIN
|
||||
VALIDATE NOT_EMPTY_FUNC
|
||||
END
|
||||
|
||||
LIST DLG_NULL 1
|
||||
LIST E_CLIFO 1 16
|
||||
BEGIN
|
||||
ITEM "C" MESSAGE SHOW,1@¦HIDE,2@
|
||||
ITEM "F" MESSAGE SHOW,2@¦HIDE,1@
|
||||
ITEM "C|Cliente" MESSAGE SHOW,1@|HIDE,2@
|
||||
ITEM "F|Fornitore" MESSAGE SHOW,2@|HIDE,1@
|
||||
FIELD LF_PARTITE->TIPOC
|
||||
FLAGS "HG"
|
||||
END
|
||||
|
||||
NUMBER E_CLIENTE 6
|
||||
|
130
sc/sc0101.cpp
130
sc/sc0101.cpp
@ -393,6 +393,10 @@ bool TFattura_mask::datadoc_handler(TMask_field& f, KEY key)
|
||||
else
|
||||
pag.set_datadoc(dd);
|
||||
}
|
||||
|
||||
if (key == K_ENTER && f.get().empty())
|
||||
return error_box("La data del documento e' obbligatoria.");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -679,12 +683,12 @@ bool TFattura_mask::tipopag_handler(TMask_field& f, KEY key)
|
||||
|
||||
|
||||
void TFattura_mask::write_scadenze() const
|
||||
{
|
||||
const TBill conto(_fattura); // Conto cliente/fornitore della partita
|
||||
{
|
||||
TPartita* oldgame = &_fattura.partita();
|
||||
const TBill conto(oldgame->conto()); // Conto cliente/fornitore della partita
|
||||
const int anno = get_int(E_ANNORIF); // Anno di riferimento
|
||||
const TString numpart(get(E_NUMRIF)); // Numero di riferimento
|
||||
|
||||
TPartita* oldgame = &_fattura.partita();;
|
||||
int vecchia_riga = _fattura.get_int(PART_NRIGA);
|
||||
if (insert_mode())
|
||||
{
|
||||
@ -822,24 +826,24 @@ bool TGame_mask::edit_fattura(TPartita& p, int nriga)
|
||||
TRiga_partite& f = p.riga(nriga);
|
||||
TFattura_mask fm(f);
|
||||
const KEY k = fm.run();
|
||||
|
||||
bool update = FALSE;
|
||||
bool updated = FALSE;
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
update = TRUE;
|
||||
fm.write_scadenze();
|
||||
updated = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nuova || k == K_DEL)
|
||||
{
|
||||
p.rimuovi_riga(nriga);
|
||||
update = !nuova;
|
||||
updated = !nuova;
|
||||
if (updated)
|
||||
p.rewrite();
|
||||
}
|
||||
}
|
||||
if (update)
|
||||
fm.write_scadenze();
|
||||
|
||||
return update;
|
||||
return updated;
|
||||
}
|
||||
|
||||
bool TGame_mask::prima_nota(const long nreg)
|
||||
@ -913,18 +917,32 @@ bool TSaldaconto_app::totale_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
|
||||
if (k == K_TAB)
|
||||
{
|
||||
{
|
||||
const bool dirty = f.focusdirty();
|
||||
if (dirty) app().gioca_cambi(m);
|
||||
if (is_fatt)
|
||||
{
|
||||
if (f.focusdirty())
|
||||
{
|
||||
app().gioca_cambi(m);
|
||||
if (dirty)
|
||||
update_rate(m);
|
||||
}
|
||||
real tot(f.get());
|
||||
tot -= m.get_real(E_IMPOSTE);
|
||||
m.set(FS_IMPONIBILI, tot);
|
||||
const real tot(f.get());
|
||||
const real imp(m.get(E_IMPOSTE));
|
||||
m.set(FS_IMPONIBILI, real(tot-imp));
|
||||
m.set(FS_IMPOSTE, imp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dirty)
|
||||
{
|
||||
if (m.insert_mode() && m.get(S_IMPORTO).empty())
|
||||
m.set(S_IMPORTO, f.get(), TRUE);
|
||||
}
|
||||
if (dirty || !m.is_running())
|
||||
{
|
||||
TPay_mask& pm = (TPay_mask&)m;
|
||||
if (pm.unassigned())
|
||||
pm.set(S_IMPORTO_SCAD, f.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
@ -949,19 +967,13 @@ bool TSaldaconto_app::totale_handler(TMask_field& f, KEY k)
|
||||
if (ok && !is_fatt)
|
||||
{
|
||||
const real totdoc(f.get());
|
||||
const real imppag(m.get(S_IMPORTO));
|
||||
if (totdoc < imppag)
|
||||
const real imppag(m.get_real(S_IMPORTO) + m.get_real(S_RITENUTE));
|
||||
if (totdoc != imppag)
|
||||
{
|
||||
TString msg(80);
|
||||
msg << "Il totale del documento deve essere maggiore dell'importo pagato "
|
||||
<< imppag.string(".");
|
||||
if (m.edit_mode())
|
||||
{
|
||||
msg << "\nSi desidera continuare ugualmente?";
|
||||
ok = f.yesno_box(msg);
|
||||
}
|
||||
else
|
||||
ok = f.error_box(msg);
|
||||
msg << "Il totale del documento e' diverso dall'importo pagato "
|
||||
<< imppag.string(".") << "\nSi desidera continuare ugualmente?";
|
||||
ok = f.yesno_box(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -971,15 +983,11 @@ bool TSaldaconto_app::totale_handler(TMask_field& f, KEY k)
|
||||
|
||||
bool TSaldaconto_app::imposte_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB)
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
if (is_fattura(m))
|
||||
{
|
||||
if (f.focusdirty())
|
||||
update_rate(m);
|
||||
m.set(FS_IMPOSTE, f.get());
|
||||
}
|
||||
TMask_field& tot = f.mask().field(E_TOTALE);
|
||||
tot.set_dirty();
|
||||
tot.on_hit();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -999,31 +1007,44 @@ bool TSaldaconto_app::totval_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
else
|
||||
f.set(m.get(S_IMPORTOVAL));
|
||||
key = K_TAB;
|
||||
}
|
||||
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
app().gioca_cambi(m, m.insert_mode() ? 0x1 : 0x0);
|
||||
if (key == K_TAB)
|
||||
{
|
||||
const bool dirty = f.focusdirty();
|
||||
if (dirty)
|
||||
app().gioca_cambi(m);
|
||||
|
||||
if (is_fatt)
|
||||
update_rate(m);
|
||||
{
|
||||
if (dirty)
|
||||
update_rate(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dirty && m.insert_mode() && m.get(S_IMPORTOVAL).empty())
|
||||
m.set(S_IMPORTOVAL, f.get(), TRUE);
|
||||
if (dirty || !m.is_running())
|
||||
{
|
||||
TPay_mask& pm = (TPay_mask&)m;
|
||||
if (pm.unassigned())
|
||||
pm.set(S_IMPORTOVAL_SCAD, f.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key == K_ENTER && !is_fatt)
|
||||
{
|
||||
const real totdoc(f.get());
|
||||
const real imppag(m.get(S_IMPORTOVAL));
|
||||
if (totdoc < imppag)
|
||||
if (totdoc != imppag)
|
||||
{
|
||||
TString msg(80);
|
||||
msg << "Il totale del documento in valuta " << m.get(E_VALUTA)
|
||||
<< " deve essere maggiore dell'importo pagato " << imppag.string(".3");
|
||||
if (m.edit_mode())
|
||||
{
|
||||
msg << "\nSi desidera continuare ugualmente?";
|
||||
ok = f.yesno_box(msg);
|
||||
}
|
||||
else
|
||||
ok = f.error_box(msg);
|
||||
msg << "Il totale del documento in valuta e' diverso dall'importo pagato "
|
||||
<< imppag.string(".3")
|
||||
<< "\nSi desidera continuare ugualmente?";
|
||||
ok = f.yesno_box(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1059,7 +1080,14 @@ bool TSaldaconto_app::valuta_handler(TMask_field& f, KEY k)
|
||||
m.enable(E_TOTDOCVAL, full);
|
||||
|
||||
if (is_fattura(m))
|
||||
{
|
||||
m.set(FS_VALUTA, val); // Copia a pagina 2
|
||||
}
|
||||
else
|
||||
{
|
||||
TPay_mask& pm = (TPay_mask&)m;
|
||||
pm.attiva_valuta(full);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user