Gestione valuta extracontabile

git-svn-id: svn://10.65.10.50/trunk@2202 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-11-23 14:21:04 +00:00
parent 4d2fb08b25
commit de5cace708
2 changed files with 56 additions and 37 deletions

View File

@ -4,12 +4,17 @@ TOOLBAR "" 0 20 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
PROMPT -13 -1 ""
END
BUTTON DLG_DELREC 10 2
BEGIN
PROMPT -23 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -22 -1 ""
PROMPT -33 -1 ""
END
ENDPAGE

View File

@ -1,3 +1,6 @@
#include <execp.h>
#include <mailbox.h>
#include "../cg/conto.h"
#include "../cg/pagament.h"
#include "../cg/saldacon.h"
@ -54,10 +57,12 @@ TFattura_mask::TFattura_mask(TRiga_partite& fattura, const TString& codpag)
hide(FS_IMPOSTE); // Elimina le imposte (non gestite in extra-contabile)
show(FS_TOTVAL); // Attiva il totale documento in valuta
set_handler(FS_IMPONIBILI, totdoc_handler);
set_handler(FS_TOTVAL, totval_handler);
set_handler(FS_CAMBIO, cambio_handler);
set_handler(FS_RESET, reset_handler);
set_handler(FS_RECALC, recalc_handler);
set_handler(FS_NRATE, nrate_handler);
@ -194,23 +199,25 @@ bool TFattura_mask::totdoc_handler(TMask_field& f, KEY k)
if (k == K_TAB && f.focusdirty())
{
TFattura_mask& fm = (TFattura_mask&)f.mask();
TPagamento& pag = fm.pagamento();
const bool valuta = fm.get(FS_VALUTA).not_empty();
TMask_field& totval = fm.field(FS_TOTVAL);
if (valuta && totval.get().empty())
{
const real cambio(fm.get(FS_CAMBIO));
if (!cambio.is_zero())
{
real tot(f.get());
tot /= cambio;
fm.set(FS_CAMBIO, tot.string(), TRUE);
}
}
if (!valuta)
if (valuta)
{
if (fm.get(FS_TOTVAL).empty())
{
const real cambio(fm.get(FS_CAMBIO));
if (!cambio.is_zero())
{
real tot(f.get());
tot /= cambio;
fm.set(FS_TOTVAL, tot, TRUE);
}
}
}
else
{
const real tot(valuta ? totval.get() : f.get());
TPagamento& pag = fm.pagamento();
const real tot(f.get());
pag.set_total(tot, ZERO, ZERO);
pag.set_rate_auto();
fm.pag2sheet();
@ -224,27 +231,28 @@ bool TFattura_mask::totval_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.focusdirty())
{
TFattura_mask& fm = (TFattura_mask&)f.mask();
real totval(f.get());
real cambio(fm.get(FS_CAMBIO));
real totale(fm.get(FS_IMPONIBILI));
if (totale.is_zero())
{
totale = totval * cambio;
fm.set(FS_IMPONIBILI, totale.string(), TRUE);
fm.set(FS_IMPONIBILI, totale, TRUE);
}
else
{
if (cambio.is_zero())
if (cambio.is_zero() && !totval.is_zero())
{
cambio = totale / totval;
fm.set(FS_CAMBIO, cambio.string(), TRUE);
fm.set(FS_CAMBIO, cambio, TRUE);
}
}
TPagamento& pag = fm.pagamento();
pag.set_total(totval, ZERO, ZERO);
pag.set_rate_auto();
fm.pag2sheet();
TPagamento& pag = fm.pagamento();
pag.set_total(totval, ZERO, ZERO);
pag.set_rate_auto();
fm.pag2sheet();
}
}
return TRUE;
}
@ -253,9 +261,9 @@ bool TFattura_mask::cambio_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
{
const real cambio(f.get());
TFattura_mask& fm = (TFattura_mask&)f.mask();
TPagamento& pag = fm.pagamento();
const real cambio(f.get());
pag.set_cambio(cambio);
}
return TRUE;
@ -423,22 +431,26 @@ void TFattura_mask::write_scadenze() const
{
CHECK(_pag, "Null pagament");
const TPagamento& pag = *_pag;
TRiga_partite& partita = _fattura;
TSheet_field& ps = pag_sheet();
_fattura.put(PART_IMPORTO, get(FS_IMPONIBILI));
_fattura.put(PART_CODVAL, get(FS_VALUTA));
_fattura.put(PART_DATACAM, get(FS_DATACAMBIO));
_fattura.put(PART_CAMBIO, get(FS_CAMBIO));
_fattura.put(PART_IMPORTOVAL, get(FS_TOTVAL));
const TString agente = get(FS_AGENTE);
const int old_rate = partita.rate();
const int old_rate = _fattura.rate();
for (int i = 0; i < pag.n_rate(); i++)
{
TToken_string& row = ps.row(i);
TRiga_scadenze& scadenza = i >= old_rate ? partita.new_row() : partita.rata(i+1);
TRiga_scadenze& scadenza = i >= old_rate ? _fattura.new_row() : _fattura.rata(i+1);
scadenza.put(SCAD_CODPAG, pag.code());
scadenza.put(SCAD_TIPOPAG, pag.tipo_rata(i));
scadenza.put(SCAD_ULTCLASS, pag.ulc_rata(i));
if (partita.in_valuta())
if (_fattura.in_valuta())
{
scadenza.put(SCAD_IMPORTO, pag.tlit_rata(i));
scadenza.put(SCAD_IMPORTOVAL, pag.tpay_rata(i));
@ -454,12 +466,12 @@ void TFattura_mask::write_scadenze() const
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));
scadenza.put(SCAD_PAGATA, scadenza.chiusa(TRUE));
}
TPartita& game = _fattura.partita();
if (i < old_rate)
{
TPartita& game = _fattura.partita();
const int riga = _fattura.get_int(PART_NRIGA);
for (int r = old_rate; r > i; r--)
{
@ -467,6 +479,8 @@ void TFattura_mask::write_scadenze() const
_fattura.elimina_rata(r);
}
}
game.chiusa(TRUE);
}
@ -485,19 +499,19 @@ bool TGame_mask::edit_fattura(TPartita& p, int nriga)
_codpag = f.rata(1).get(SCAD_CODPAG);
TFattura_mask fm(f, _codpag);
const bool ok = fm.run() == K_ENTER;
const KEY k = fm.run();
if (ok)
if (k == K_ENTER)
{
fm.write_scadenze();
}
else
{
if (nuova)
if (nuova || k == K_DEL)
p.rimuovi_riga(nriga);
}
return ok;
return k != K_ESC;
}
bool TGame_mask::prima_nota(const long nreg)