Correzione errori gabri e controllo giorni scadenza fissa

git-svn-id: svn://10.65.10.50/trunk@2320 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-19 15:53:50 +00:00
parent f9ac1b045a
commit 60b57890ed
8 changed files with 68 additions and 28 deletions

View File

@ -924,7 +924,7 @@ int TPrimanota_application::write(const TMask& m)
if (salvaconto)
{
const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
partite().update_reg(_rel->lfile().curr(), old_nreg);
partite().update_reg(_rel->curr(), _rel->cg_rows(), old_nreg);
partite().write();
}
@ -962,7 +962,7 @@ int TPrimanota_application::rewrite(const TMask& m)
if (salvaconto)
{
partite().update_reg(_rel->curr());
partite().update_reg(_rel->curr(), _rel->cg_rows());
partite().rewrite();
}
}

View File

@ -37,7 +37,8 @@ public:
virtual int write (bool force = TRUE, TDate& atdate = (TDate&)botime);
virtual int rewrite(bool force = TRUE, TDate& atdate = (TDate&)botime);
virtual int remove (TDate& atdate = (TDate&)botime);
const TRecord_array& cg_rows() const { return _cg; }
TRectype& cg(int i);
TRectype& iva(int i);
int cg_items() const { return _cg.rows(); }

View File

@ -1594,10 +1594,11 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
{
if (f.dlg() == F_DATADOC)
{
if (app().is_fattura() && m.get(F_ANNORIF).empty())
{
if (app().is_fattura())
{
const TDate dd(val);
m.set(F_ANNORIF, dd.year()); // copia anno documento
if (m.get(F_ANNORIF).empty())
m.set(F_ANNORIF, dd.year()); // copia anno documento
app().recalc_scadenze(dd);
}
}

View File

@ -165,13 +165,32 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
if (key == K_TAB && f.focusdirty() && m.is_running() &&
app().is_saldaconto() && !f.mask().edit_mode())
{
const TString16 dt(m.get(F_DATADOC));
app().set_pagamento(f.get(), dt);
app().set_scadenze(m);
}
if (m.insert_mode() && app().is_fattura())
{
if (key == K_TAB && f.focusdirty())
{
const TString16 dt(m.get(F_DATADOC));
app().set_pagamento(f.get(), dt);
app().set_scadenze(m);
}
if (key == K_ENTER && f.get().empty())
{
const char typ = app().clifo();
const long cod = m.get_long(typ == 'C' ? F_CLIENTE : F_FORNITORE);
TLocalisamfile clifo(LF_CLIFO);
clifo.put(CLI_TIPOCF, typ);
clifo.put(CLI_CODCF, cod);
if (clifo.read() == NOERR)
f.set(clifo.get(CLI_CODPAG));
return error_box("Il codice di pagamento e' obbligatorio!\n"
"Se possibile esso verra' proposto, ma potra'\n"
"essere modificato prima di registrare il movimento.");
}
}
return TRUE;
}

View File

@ -1329,10 +1329,11 @@ bool TPrimanota_application::edit_partite(const TMask& m, int riga)
const TBill b(gruppo, conto, sottoconto, tipo); // Legge il conto della riga selezionata
if (!b.ok())
return FALSE; // Esci se il conto della riga cliente non e' valido
curr_mask().autosave(get_relation()); // Aggiorna i dati della testata sulle partite
const TRectype& mov = get_relation()->curr();
partite().update_reg(mov);
TMovimentoPN* pn = (TMovimentoPN*)get_relation();
curr_mask().autosave(pn); // Aggiorna i dati della testata sulle partite
const TRectype& mov = pn->curr();
partite().update_reg(mov, pn->cg_rows());
// Esecuzione maschera di selezione partite
TGame_mask* mask = new TGame_mask(b, mov.get_long(MOV_NUMREG), riga+1);

View File

@ -271,7 +271,7 @@ void TPagamento::set_cambio(const real& cambio)
_cambio = 1.0;
else
_cambio = cambio;
set_round(_cambio == 1.0 ? 0 : 2);
set_round(_cambio == 1.0 ? 0 : 3);
const bool in_valuta = _cambio != 1.0;
real lit;
@ -1503,11 +1503,12 @@ void TPagamento::adjust_fixed_scad()
{
for (int i = 0; i < 3; i++)
{
if (_fixd[i] > d.day())
if (_fixd[i] >= d.day())
{
if (d.last_day(d.month(), d.year()) >= _fixd[i])
d.set_day(_fixd[i]);
else d.set_end_month();
else
d.set_end_month();
break;
}
}
@ -1517,8 +1518,8 @@ void TPagamento::adjust_fixed_scad()
if (_fixd[0] > 0 && _fixd[0] < d.day())
{
d.set_day(_fixd[0]);
bool chyear = d.month() == 12;
d.set_month(chyear? 1 : d.month() + 1);
const bool chyear = d.month() == 12;
d.set_month(chyear ? 1 : d.month() + 1);
if (chyear) d.set_year(d.year() + 1);
}
}

View File

@ -5,6 +5,7 @@
#include "saldacon.h"
#include <mov.h>
#include <rmov.h>
#include <scadenze.h>
#include <pagsca.h>
@ -262,6 +263,14 @@ const TString& TDecoder::decode(const char* code)
return s;
}
const TString& TDecoder::decode(long code)
{
TString16 c;
if (code > 0)
c << code;
return decode(c);
}
///////////////////////////////////////////////////////////
// TRiga_scadenze
///////////////////////////////////////////////////////////
@ -1051,7 +1060,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig) const
}
void TPartita::update_reg(long nreg, const TRectype& mov)
void TPartita::update_reg(long nreg, const TRectype& mov, const TRecord_array& cg)
{
for (int r = last(); r > 0; r = pred(r))
{
@ -1065,6 +1074,13 @@ void TPartita::update_reg(long nreg, const TRectype& mov)
rig.put(PART_REG, mov.get(MOV_REG));
rig.put(PART_PROTIVA, mov.get(MOV_PROTIVA));
rig.put(PART_CODCAUS, mov.get(MOV_CODCAUS));
const int numrig = rig.get_int(PART_NUMRIG);
if (numrig > 0 && numrig <= cg.rows())
{
const TRectype& cgrow = cg.row(numrig);
rig.put(PART_IMPTOTDOC, cgrow.get(RMV_IMPORTO));
}
}
}
}
@ -1577,12 +1593,12 @@ TImporto TPartite_array::importo_speso(long nreg, int numrig)
return imp;
}
void TPartite_array::update_reg(const TRectype& mov, long old_nreg)
void TPartite_array::update_reg(const TRectype& mov, const TRecord_array& cg, long old_nreg)
{
if (old_nreg <= 0)
old_nreg = mov.get_long(MOV_NUMREG);
add_numreg(old_nreg);
for (TPartita* game = first(); game; game = next())
game->update_reg(old_nreg, mov);
game->update_reg(old_nreg, mov, cg);
}

View File

@ -111,7 +111,8 @@ class TDecoder : private TAssoc_array
TString _if, _of;
public:
const TString& decode(const char* code);
const TString& decode(const char* code);
const TString& decode(long code);
TDecoder(int num, const char* inf, const char* outf);
TDecoder(const char* table);
@ -272,7 +273,7 @@ public:
const TString& descrizione() const;
TImporto importo_speso(long numreg, int numrig) const;
void update_reg(long nreg, const TRectype& mov);
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;
TImporto calcola_saldo_al(bool valuta, const TDate& al, const TDate& data_rischio = botime) const;
@ -321,7 +322,7 @@ public:
int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg
TImporto importo_speso(long numreg, int numrig);
void update_reg(const TRectype& mov, long old_reg = 0);
void update_reg(const TRectype& mov, const TRecord_array& cg, long old_reg = 0);
// Controlla se esistono righe di pagamento relative alla riga numrig
bool utilizzata(long numreg, int numrig);