Corretti vari errori prima nota e pagamenti

git-svn-id: svn://10.65.10.50/trunk@2327 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-20 16:16:14 +00:00
parent 9617c37aa2
commit 609afe9ac3
10 changed files with 119 additions and 77 deletions

View File

@ -98,6 +98,7 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(F_SOLAIVA, solaiva_handler);
m->set_handler(F_SHEETIVA, iva_handler);
m->set_handler(F_CODPAG, codpag_handler);
m->set_handler(SK_VALUTA, valuta_handler);
m->set_handler(SK_CAMBIO, cambio_handler);
TSheet_field& is = (TSheet_field&)m->field(F_SHEETIVA);
@ -124,6 +125,10 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(FS_RECALC, recalc_handler);
m->set_handler(FS_NSCAB, codcab_handler);
m->set_handler(FS_VSCAB, codcab_handler);
TMask& sm = ps.sheet_mask();
sm.set_handler(105, tipopag_handler);
sm.set_handler(106, tipopag_handler);
}
}
case 1:

View File

@ -176,8 +176,6 @@ BEGIN
DISPLAY "Descrizione@50" S0
OUTPUT F_DESCAGG CODTAB
OUTPUT F_DESCR S0
CHECKTYPE NORMAL
WARNING "Descrizione assente"
END
STRING F_DESCR 50
@ -424,7 +422,7 @@ BEGIN
OUTPUT SK_DATACAMBIO D0
OUTPUT SK_CAMBIO R10
GROUP 3
CHECKTYPE NORMAL
CHECKTYPE SEARCH
END
NUMBER SK_CAMBIO 15 5

View File

@ -125,8 +125,10 @@ RADIOBUTTON S_SALDOACC 1 24
BEGIN
PROMPT 1 9 ""
FLAGS "Z"
ITEM "A|Acconto"
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

@ -105,12 +105,15 @@ class TPrimanota_application : public TRelation_application
static bool imposta_handler(TMask_field& f, KEY key);
static bool dareavere_handler(TMask_field& f, KEY k);
static bool cg_conto_handler(TMask_field& f, KEY key);
static bool codpag_handler(TMask_field& f, KEY key);
static bool valuta_handler(TMask_field& f, KEY key);
static bool cambio_handler(TMask_field& f, KEY key);
static bool reset_handler(TMask_field& f, KEY key);
static bool nrate_handler(TMask_field& f, KEY key);
static bool recalc_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key);
static bool tipopag_handler(TMask_field& f, KEY key);
static bool iva_notify(TSheet_field& s, int r, KEY key);
static bool iva_handler(TMask_field& f, KEY key);

View File

@ -161,6 +161,20 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
return ok;
}
bool TPrimanota_application::tipopag_handler(TMask_field& f, KEY key)
{
if ((key == K_TAB || key == K_ENTER) && f.dirty())
{
TMask& m = f.mask();
const int t = m.get_int(105);
const char u = m.get(106)[0];
const TPagamento& pag = app().pagamento();
const char* s = pag.desc_tipo(t, u);
m.set(107, s);
}
return TRUE;
}
bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
{
@ -254,6 +268,24 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
return ok;
}
bool TPrimanota_application::valuta_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
{
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 TDate datacam(dc.get());
const TRectype& rec = dc.browse()->cursor()->curr();
const TDate curcam(rec.get("CODTAB"));
if (datacam != curcam) // Se non esiste cambio per la nuova valuta
m.set(SK_CAMBIO, "", TRUE);
}
return TRUE;
}
bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
@ -765,7 +797,12 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
{
const int new_riga = bill2pos(new_conto, 'I');
if (new_riga < 0)
set_cgs_row(new_riga, new_importo, new_conto, "", 'I');
{
const int tp = somma.get_int(PART_TIPOPAG);
const int da = p.tipopag2causale(tp);
const TString descagg(causale().desc_agg(da));
set_cgs_row(new_riga, new_importo, new_conto, descagg, 'I');
}
else
add_cgs_imp(new_riga, new_importo);
}

View File

@ -75,7 +75,8 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
TReal_field& res = (TReal_field&)field(S_RESIDUORATA);
res.set_decimals(in_valuta ? 2 : 0);
res.set(_da_pagare.string());
if (get(S_SALDOACC)[0] != 'S')
res.set(_da_pagare.string());
set_handler(in_valuta ? S_IMPORTOVAL : S_IMPORTO, importo_handler);
@ -176,10 +177,15 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
if (i >= m._da_pagare && m.field(S_SALDOACC).active())
m.set(S_SALDOACC, "S");
const real residuo(m._da_pagare - i);
m.set(S_RESIDUORATA, residuo);
if (m.get(S_SALDOACC)[0] != 'S')
{
const real residuo(m._da_pagare - i);
m.set(S_RESIDUORATA, residuo);
}
else
m.reset(S_RESIDUORATA);
const real residuopag(m._pagabile - i);
m.set(S_RESIDUOPAG, residuopag);
@ -818,31 +824,14 @@ int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
nrigp = nuova_riga(partita);
#endif
TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo pagamento
int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento
// Calcola riga causale per la contropartita in base al tipo pagamento
int caus = 2;
if (rata != TPartita::UNASSIGNED)
{
const TRiga_scadenze& scad = partita.rata(nriga, rata);
const int tp = scad.get_int(SCAD_TIPOPAG);
switch (tp)
{
case 2: // Tratta
case 7: // Tratta accettata
caus = 3; break;
case 3: // Ricevuta bancaria
caus = 4; break;
case 4: // Cessione
caus = 5; break;
case 5: // Paghero'
caus = 6; break;
case 6: // Fattura di credito
caus = 7; break;
case 1: // Rimessa
case 8: // Rapporti interbancari diretti
case 9: // Bonifico
default:
caus = 2; break;
}
caus = partita.tipopag2causale(tp);
TRiga_partite& somma = partita.riga(nrigp);
somma.put(PART_TIPOPAG, tp);

View File

@ -32,7 +32,7 @@ BEGIN
PICTURE ".2"
END
NUMBER 105 2 0
NUMBER 105 1
BEGIN
PROMPT 1 5 "Tipo pagamento "
SHEET "Codice|Tipo pagamento@32"
@ -47,8 +47,6 @@ BEGIN
ITEM "8|Rapporti interban. diretti"
ITEM "9|Bonifici"
OUTPUT 105
OUTPUT 107
MESSAGE DIRTY,106|K_TAB,106
END
STRING 106 1
@ -61,7 +59,6 @@ BEGIN
DISPLAY "Classificazione" CODTAB[2,2]
DISPLAY "Descrizione@50" S0
OUTPUT 106 CODTAB[2,2]
OUTPUT 107 S0
CHECKTYPE NORMAL
END

View File

@ -591,24 +591,22 @@ const char* TPagamento::desc_tpr() const
const char* TPagamento::desc_tipo(int tipo, char ulc) const
{
int err = ~NOERR;
const char* o;
const char* o = "";
if (ulc > ' ')
{
const char key[] = { tipo+'0', ulc, '\0' };
TTable clr("%CLR");
clr.put("CODTAB", key);
err = clr.read();
const int err = clr.read();
if (err == NOERR)
o = clr.get("S0");
}
if (err != NOERR)
else
{
switch (tipo)
{
{
case 0: o = "Altro pagamento"; break;
case 1: o = "Rimessa diretta o contanti"; break;
case 2: o = "Tratta"; break;
case 3: o = "Ricevuta Bancaria"; break;
@ -618,7 +616,7 @@ const char* TPagamento::desc_tipo(int tipo, char ulc) const
case 7: o = "Tratta accettata"; break;
case 8: o = "Rapporti interban. diretti"; break;
case 9: o = "Bonifici"; break;
default: o = "Altro pagamento"; break;
default: o = ""; break;
}
}
return o;
@ -1392,15 +1390,23 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
{
main_app().begin_wait();
if (_inited && _rate.items() > 0)
{
if (_rate.items() == 0)
{
if (_tpr > 3)
add_rata(ZERO, sscad <= 0 ? 0 : sscad, _def_tpr, _def_ulc);
add_rata(real(100.0), sscad <= 0 ? (_tpr < 4 ? 0 : 30) : sscad, _def_tpr, _def_ulc);
_dirty = TRUE;
}
if (_inited)
{
const bool in_valuta = _cambio != 1.0;
// si istanzia uno sheet di primanota
for (int i = 0; i < n_rate(); i++)
{
TToken_string& ts = sf.row(i);
ts.add((const char*)data_rata(i), 0); // 0 - Data scadenza
if (in_valuta)
{
@ -1413,7 +1419,7 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
ts.add("", 2);
}
ts.add(perc_rata(i).string(), 3); // 3 - Percentuale
const int tr = tipo_rata(i);
const char uc = ulc_rata(i)[0];
ts.add(tr, 4); // 4 - Tipo rata
@ -1423,24 +1429,22 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
const bool paid = ratapagata(i);
ts.add(paid ? "X" : "", 11); // 11 - Pagaya
}
for (int d = sf.items()-1; d >= i; d--)
sf.destroy(d);
sf.enable_column(2, in_valuta);
}
else
if (_rate.items() > 0) // not inited: set edit sheet
{
sf.destroy();
for (int i = 0, scr = 0; i < n_rate(); i++)
{
TToken_string& s = sf.row(-1);
scr += scad_rata(i);
s.add(scr);
s.add(perc_rata(i).string());
const int tr = tipo_rata(i);
const char uc = ulc_rata(i)[0];
s.add(tr);
@ -1448,28 +1452,6 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
s.add(desc_tipo(tr, uc));
}
}
else // new: set with 1 or 2 rates according to tpr
{
if (_tpr > 3)
add_rata(ZERO, sscad == -1 ? 0 : sscad, _def_tpr, _def_ulc);
add_rata(real(100.0), sscad == -1 ? (_tpr < 4 ? 0 : 30) : sscad, _def_tpr, _def_ulc);
_dirty = TRUE;
for (int i = 0, scr = 0; i < n_rate(); i++)
{
TToken_string& s = sf.row(-1);
scr += scad_rata(i);
s.add(scr);
s.add(perc_rata(i).string());
const int tr = tipo_rata(i);
const char uc = ulc_rata(i)[0];
s.add(tr);
s.add(uc);
s.add(desc_tipo(tr, uc));
}
}
const bool abilita = _tpr <= 3;
// disabilita campi da non toccare sulla prima rata
@ -1531,7 +1513,7 @@ void TPagamento::adjust_fixed_scad()
TPagamento::TPagamento(const char* codtab, const char* data) :
_slicer(0.0,0), _new(FALSE), _mcomm(FALSE), _imponibile(0.0), _imposta(0.0),
_spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE),
_def_tpr(1), _def_ulc(""), _round(0), _int_rate(30), _tpr(0)
_def_tpr(1), _def_ulc(""), _round(0), _int_rate(30), _tpr(0), _rdiff(FALSE)
{
_fixd[0] = _fixd[1] = _fixd[2] = 0;
if (data != NULL && *data)

View File

@ -1079,7 +1079,10 @@ void TPartita::update_reg(long nreg, const TRectype& mov, const TRecord_array& c
if (numrig > 0 && numrig <= cg.rows())
{
const TRectype& cgrow = cg.row(numrig);
rig.put(PART_IMPTOTDOC, cgrow.get(RMV_IMPORTO));
const char sez = cgrow.get_char(RMV_SEZIONE);
const real imp = cgrow.get(RMV_IMPORTO);
TImporto importo(sez, imp); importo.normalize(rig.sezione());
rig.put(PART_IMPTOTDOC, importo.valore());
}
}
}
@ -1462,6 +1465,31 @@ void TPartita::scollega_pagamenti(int r, int s)
}
}
// Trova la riga di causale corrispondente ad un tipo di pagamento
int TPartita::tipopag2causale(int tipo) const
{
int caus = 2;
switch (tipo)
{
case 2: // Tratta
case 7: // Tratta accettata
caus = 3; break;
case 3: // Ricevuta bancaria
caus = 4; break;
case 4: // Cessione
caus = 5; break;
case 5: // Paghero'
caus = 6; break;
case 6: // Fattura di credito
caus = 7; break;
case 1: // Rimessa
case 8: // Rapporti interbancari diretti
case 9: // Bonifico
default:
caus = 2; break;
}
return caus;
}
///////////////////////////////////////////////////////////
// TPartite_array

View File

@ -286,6 +286,7 @@ public:
static void carica_allineamento();
char allineamento_richiesto() const;
int tipopag2causale(int tipo) const;
TPartita(const TBill& clifo, int anno, const char* num);
TPartita(const TRectype& part);