1994-11-10 14:25:26 +00:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Scadenzario
|
|
|
|
// fv 24/8/94
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
#include <sheet.h>
|
1995-09-11 10:53:00 +00:00
|
|
|
#include <utility.h>
|
1995-08-09 09:52:08 +00:00
|
|
|
#include "pagament.h"
|
1995-09-01 10:13:36 +00:00
|
|
|
#include "saldacon.h"
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
#include "cg2102.h"
|
|
|
|
#include "cg2100.h"
|
1995-02-28 09:17:57 +00:00
|
|
|
#include "cg21sld.h"
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-03-23 17:17:13 +00:00
|
|
|
#include <clifo.h>
|
1995-03-22 09:04:45 +00:00
|
|
|
#include <partite.h>
|
1995-09-01 10:13:36 +00:00
|
|
|
#include <scadenze.h>
|
1995-09-29 16:21:08 +00:00
|
|
|
#include <pagsca.h>
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
1995-09-25 11:38:25 +00:00
|
|
|
{
|
|
|
|
TPagamento* pg = app().pagamento();
|
|
|
|
if (pg == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
TPagamento& pag = *pg;
|
1995-10-25 09:34:53 +00:00
|
|
|
TMask* msk = &(ps.mask());
|
1995-03-22 09:04:45 +00:00
|
|
|
TString_array& rws = app().pag_rows();
|
1995-09-25 11:38:25 +00:00
|
|
|
|
|
|
|
const int rdiff = atoi(msk->get(FS_RDIFFER));
|
|
|
|
const bool in_valuta = pag.in_valuta();
|
|
|
|
const int impos = in_valuta ? 2 : 1;
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
// ts contiene la vecchia riga, ns la nuova
|
1995-10-10 09:04:46 +00:00
|
|
|
TToken_string ts(128), ns(128);
|
1995-09-22 12:29:00 +00:00
|
|
|
TString16 banca;
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
|
1995-11-03 08:17:08 +00:00
|
|
|
bool m_scad = FALSE, m_tipo = FALSE, m_ulc = FALSE, mod = FALSE;
|
1994-11-10 14:25:26 +00:00
|
|
|
word ahiahi = P_OK;
|
|
|
|
|
1995-11-03 08:17:08 +00:00
|
|
|
TString news(10), newi(15), newp(15), newt(1), newu(1);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
bool recalc = msk->get_bool(FS_RECALC);
|
|
|
|
bool mcomm = msk->get_bool(FS_MCOMM);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
switch (k)
|
|
|
|
{
|
|
|
|
case K_ENTER:
|
1995-03-22 09:04:45 +00:00
|
|
|
ns = ps.row(r);
|
|
|
|
ts = rws.row(r);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-09-25 11:38:25 +00:00
|
|
|
news = ns.get(0); // Data scadenza
|
|
|
|
newi = ns.get(impos); // Imponibile (lire o valuta)
|
|
|
|
newp = ns.get(3); // Percentuale
|
|
|
|
newt = ns.get(4); // Tipo pagamento
|
1995-11-03 08:17:08 +00:00
|
|
|
newu = ns.get(5); // Ulteriore classificazione
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
// qui viene il bello, si fa per dire
|
1995-10-10 09:04:46 +00:00
|
|
|
if (news != ts.get(0)) // modificata data scadenza
|
1995-09-25 11:38:25 +00:00
|
|
|
mod = m_scad = TRUE;
|
1995-10-10 09:04:46 +00:00
|
|
|
if (newp != ts.get(3)) // modificata percentuale
|
1995-09-25 11:38:25 +00:00
|
|
|
mod = m_perc = TRUE;
|
1995-10-10 09:04:46 +00:00
|
|
|
if (newi != ts.get(impos)) // modificato importo
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1995-02-28 09:17:57 +00:00
|
|
|
// se si modifica la percentuale l'importo non viene cagato
|
|
|
|
if ((recalc && !m_perc) || (!recalc))
|
1995-09-25 11:38:25 +00:00
|
|
|
mod = m_imp = TRUE;
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
1995-10-10 09:04:46 +00:00
|
|
|
if (newt != ts.get(4)) // modificato tipo pagamento
|
1995-11-10 13:35:00 +00:00
|
|
|
mod = m_tipo = m_ulc = TRUE;
|
1995-11-03 08:17:08 +00:00
|
|
|
|
|
|
|
if (newu != ts.get(5)) // modificata ulteriore classificazione
|
|
|
|
mod = m_ulc = TRUE;
|
1994-11-10 14:25:26 +00:00
|
|
|
break;
|
|
|
|
case K_DEL:
|
|
|
|
case K_INS:
|
|
|
|
doit = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// settato da recalc_rate se occorre ridefinire lo sheet
|
|
|
|
// aggiungendo o togliendo righe
|
|
|
|
bool need_recalc = FALSE;
|
|
|
|
|
|
|
|
if (k == K_ENTER)
|
|
|
|
{
|
|
|
|
if (mod && recalc)
|
|
|
|
{
|
|
|
|
// ricalcola sheet come sai fare tu
|
1995-03-22 09:04:45 +00:00
|
|
|
ahiahi = pag.recalc_rate(r, m_perc,
|
|
|
|
((m_perc || m_imp) ?
|
|
|
|
(m_perc ? (const char*)newp : (const char*)newi) :
|
|
|
|
NULL),
|
|
|
|
(m_scad ? (const char*)news : NULL),
|
1995-11-03 08:17:08 +00:00
|
|
|
(m_tipo ? (const char*)newt : NULL),
|
|
|
|
(m_ulc ? (const char*)newu : NULL),
|
1995-03-22 09:04:45 +00:00
|
|
|
rdiff, mcomm, need_recalc);
|
1994-11-10 14:25:26 +00:00
|
|
|
// see if rdiff changed
|
1995-06-21 15:33:31 +00:00
|
|
|
msk->set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
1995-09-22 12:29:00 +00:00
|
|
|
msk->set(FS_NRATE, pag.n_rate());
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
if (!recalc)
|
|
|
|
{
|
|
|
|
ahiahi = P_OK;
|
|
|
|
// put data as they are
|
1995-03-22 09:04:45 +00:00
|
|
|
TToken_string& trw = pag.rata(r);
|
1994-11-10 14:25:26 +00:00
|
|
|
TToken_string srw = trw;
|
1995-09-25 11:38:25 +00:00
|
|
|
if (m_tipo) trw.add(newt,2);
|
|
|
|
if (m_scad) trw.add(news,3);
|
1995-10-25 09:34:53 +00:00
|
|
|
if (m_imp)
|
|
|
|
{
|
|
|
|
trw.add(newi,4);
|
|
|
|
const real p = pag.recalc_percrata(r);
|
|
|
|
ps.row(r).add(p.string(), 3);
|
|
|
|
rws.row(r) = ps.row(r);
|
|
|
|
ps.force_update(r);
|
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
1995-03-22 09:04:45 +00:00
|
|
|
if (ahiahi) // any error? Rimetti le righe com'erano prima
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
|
|
|
if (recalc)
|
|
|
|
{
|
|
|
|
beep();
|
|
|
|
ps.row(r) = rws.row(r);
|
|
|
|
ps.force_update(r);
|
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
1995-03-22 09:04:45 +00:00
|
|
|
else if (recalc && mod && need_recalc)
|
|
|
|
{
|
|
|
|
// ridefinisci lo sheet sulla base delle nuove rate
|
|
|
|
pag.set_sheet(ps);
|
|
|
|
rws = ps.rows_array();
|
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return doit;
|
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
bool ok = TRUE;
|
|
|
|
if (key == K_TAB || key == K_ENTER)
|
|
|
|
{
|
|
|
|
TPagamento* pag = app().pagamento();
|
|
|
|
if (pag != NULL)
|
|
|
|
{
|
|
|
|
const word err = pag->validate();
|
|
|
|
if (err != P_OK)
|
|
|
|
{
|
|
|
|
TString256 s;
|
|
|
|
pag->strerr(err, s);
|
|
|
|
error_box(s);
|
|
|
|
ok = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key)
|
1995-03-22 09:04:45 +00:00
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
1995-11-14 10:27:10 +00:00
|
|
|
if (key == K_TAB && f.focusdirty() && m.is_running() &&
|
|
|
|
app().is_saldaconto() && !f.mask().edit_mode())
|
1995-02-28 09:17:57 +00:00
|
|
|
{
|
1995-09-11 10:53:00 +00:00
|
|
|
const TString16 dt(m.get(F_DATADOC));
|
1995-03-22 09:04:45 +00:00
|
|
|
app().set_pagamento(f.get(), dt);
|
|
|
|
app().set_scadenze(m);
|
1995-02-28 09:17:57 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
1995-08-24 07:27:50 +00:00
|
|
|
|
1995-11-14 15:58:25 +00:00
|
|
|
bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
bool ok = TRUE;
|
|
|
|
if (f.to_check(key))
|
|
|
|
{
|
|
|
|
const TPartita* old = app().partite().first();
|
|
|
|
if (old && f.get().blank()) // Se esisteva una partita ma ora non piu'
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n"
|
|
|
|
"Premere SI per cancellarla, NO per ripristinarla, ANNULLA modificarla",
|
|
|
|
old->anno(), (const char*)old->numero());
|
|
|
|
switch (k)
|
|
|
|
{
|
|
|
|
case K_NO:
|
|
|
|
m.set(F_ANNORIF, old->anno());
|
|
|
|
m.set(F_NUMRIF, old->numero());
|
|
|
|
break;
|
|
|
|
case K_ESC:
|
|
|
|
ok = FALSE;
|
|
|
|
default:
|
|
|
|
f.reset();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1995-09-25 11:38:25 +00:00
|
|
|
bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
{
|
|
|
|
TPagamento* pag = app().pagamento();
|
|
|
|
if (pag != NULL)
|
|
|
|
{
|
|
|
|
const real ex(f.get());
|
|
|
|
pag->set_cambio(ex);
|
1995-10-12 15:02:46 +00:00
|
|
|
|
|
|
|
TSheet_field& ps = app().pags();
|
|
|
|
pag->set_sheet(ps);
|
|
|
|
ps.force_update();
|
1995-09-25 11:38:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-08-24 07:27:50 +00:00
|
|
|
bool TPrimanota_application::reset_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
if (key == K_SPACE && m.is_running() && app().is_saldaconto())
|
|
|
|
{
|
1995-11-14 10:27:10 +00:00
|
|
|
app().reset_pagamento(f.mask());
|
1995-08-24 07:27:50 +00:00
|
|
|
app().set_scadenze(m);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_SPACE)
|
|
|
|
{
|
|
|
|
const bool on = f.get().not_empty();
|
|
|
|
const TMask& m = f.mask();
|
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
ps.enable_column(3, on);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-09-11 10:53:00 +00:00
|
|
|
bool TPrimanota_application::nrate_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
1995-11-03 08:17:08 +00:00
|
|
|
if (key == K_TAB && f.focusdirty())
|
1995-09-11 10:53:00 +00:00
|
|
|
{
|
1995-09-25 11:38:25 +00:00
|
|
|
TPagamento* pag = app().pagamento();
|
1995-11-03 08:17:08 +00:00
|
|
|
CHECK(pag != NULL, "Null pagament");
|
|
|
|
pag->set_numero_rate(atoi(f.get()));
|
|
|
|
if (pag->dirty())
|
1995-09-11 10:53:00 +00:00
|
|
|
{
|
1995-11-03 08:17:08 +00:00
|
|
|
TMask& m = f.mask();
|
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
pag->set_sheet(ps);
|
|
|
|
app().pag_rows() = ps.rows_array();
|
|
|
|
}
|
1995-09-11 10:53:00 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-09-22 12:29:00 +00:00
|
|
|
bool TPrimanota_application::codcab_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
{
|
|
|
|
const TMask& m = f.mask();
|
|
|
|
const short id = f.dlg() == FS_NSCAB ? FS_NSABI : FS_VSABI;
|
1995-11-03 08:17:08 +00:00
|
|
|
const int pos = id == FS_NSABI ? 7 : 9; // Posizione codici ABI sullo sheet
|
1995-09-22 12:29:00 +00:00
|
|
|
const TString16 abi = m.get(id);
|
|
|
|
const TString16 cab = m.get(id+1);
|
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
1995-11-03 08:17:08 +00:00
|
|
|
for (int i = ps.items()-1; i >= 0; i--) // Setta la banca in tutte le righe
|
1995-09-22 12:29:00 +00:00
|
|
|
{
|
|
|
|
TToken_string& row = ps.row(i);
|
|
|
|
row.add(abi, pos);
|
|
|
|
row.add(cab, pos+1);
|
|
|
|
}
|
|
|
|
ps.force_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1995-08-24 07:27:50 +00:00
|
|
|
|
1995-11-14 10:27:10 +00:00
|
|
|
void TPrimanota_application::reset_pagamento(TMask& m)
|
|
|
|
{
|
|
|
|
// se in modifica, rilegge totali e date dalla maschera; altrimenti
|
|
|
|
// rilegge il pagamento da disco
|
1995-08-24 07:27:50 +00:00
|
|
|
if (_pag != NULL)
|
|
|
|
{
|
1995-11-14 10:27:10 +00:00
|
|
|
/* if (!m.edit_mode())*/ _pag->read();
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const real spese(0.0);
|
|
|
|
real imponibile, imposta;
|
|
|
|
const real cambio(m.get(S_CAMBIO));
|
|
|
|
if (cambio.is_zero())
|
|
|
|
{
|
|
|
|
imponibile = real(m.get(F_IMPONIBILI));
|
|
|
|
imposta = real(m.get(F_IMPOSTE));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_pag->set_cambio(cambio);
|
|
|
|
imponibile = real(m.get(S_TOTDOCVAL));
|
|
|
|
imposta = ZERO;
|
|
|
|
}
|
|
|
|
_pag->set_inizio(m.get_date(F_DATADOC));
|
|
|
|
_pag->set_total(imponibile, imposta, spese);
|
|
|
|
}
|
|
|
|
*/
|
1995-08-24 07:27:50 +00:00
|
|
|
_pag->set_rate_auto();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-31 11:37:09 +00:00
|
|
|
void TPrimanota_application::recalc_scadenze(const TDate& d)
|
|
|
|
{
|
|
|
|
if (_pag == NULL) return;
|
|
|
|
_pag->set_inizio(d);
|
|
|
|
// ridefinisci lo sheet sulla base delle nuove rate
|
|
|
|
TSheet_field& ps = pags();
|
|
|
|
TString_array& rws = pag_rows();
|
|
|
|
|
|
|
|
_pag->set_sheet(ps);
|
|
|
|
rws = ps.rows_array();
|
|
|
|
ps.force_update();
|
|
|
|
}
|
1995-02-28 09:17:57 +00:00
|
|
|
|
|
|
|
void TPrimanota_application::set_pagamento(const char* c, const char* d)
|
|
|
|
{
|
|
|
|
if (_pag != NULL) delete _pag;
|
1995-03-01 15:19:25 +00:00
|
|
|
_pag = new TPagamento(c,d);
|
1995-02-28 09:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TPrimanota_application::set_scadenze(TMask& m)
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1995-09-25 11:38:25 +00:00
|
|
|
real imponibile, imposta;
|
1995-06-21 15:33:31 +00:00
|
|
|
const real spese(0.0);
|
1995-09-25 11:38:25 +00:00
|
|
|
const real cambio(m.get(S_CAMBIO));
|
1995-09-01 10:13:36 +00:00
|
|
|
TPagamento& pag = *pagamento();
|
1995-09-25 11:38:25 +00:00
|
|
|
|
|
|
|
if (cambio.is_zero())
|
|
|
|
{
|
|
|
|
imponibile = real(m.get(F_IMPONIBILI));
|
|
|
|
imposta = real(m.get(F_IMPOSTE));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pag.set_cambio(cambio);
|
|
|
|
imponibile = real(m.get(S_TOTDOCVAL));
|
|
|
|
imposta = ZERO;
|
|
|
|
}
|
1995-02-28 09:17:57 +00:00
|
|
|
|
1995-09-25 11:38:25 +00:00
|
|
|
pag.set_total(imponibile, imposta, spese);
|
|
|
|
pag.set_rate_auto();
|
1995-10-25 09:34:53 +00:00
|
|
|
|
|
|
|
if (m.field(FS_RECALC).enabled())
|
|
|
|
{
|
|
|
|
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
|
|
|
m.set(FS_NAMEPAG, pag.name());
|
|
|
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
|
|
|
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
1995-11-14 10:27:10 +00:00
|
|
|
m.set(FS_RECALC, m.edit_mode() ? "" : "X", TRUE);
|
1995-10-25 09:34:53 +00:00
|
|
|
m.set(FS_NRATE, pag.n_rate());
|
|
|
|
}
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1995-09-25 11:38:25 +00:00
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
pag.set_sheet(ps); // prepara lo sheet
|
|
|
|
_pag_rows = ps.rows_array(); // copia sheet
|
1995-02-28 09:17:57 +00:00
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-06-21 15:33:31 +00:00
|
|
|
bool TPrimanota_application::read_scadenze(TMask& m)
|
1995-02-28 09:17:57 +00:00
|
|
|
{
|
1995-09-25 11:38:25 +00:00
|
|
|
const TRectype& testa = _rel->curr();
|
1995-06-28 16:33:53 +00:00
|
|
|
const long nreg = testa.get_long("NUMREG");
|
|
|
|
const TString16 ndoc(testa.get("NUMDOC"));
|
|
|
|
const int tmov = testa.get_int("TIPOMOV");
|
|
|
|
const TDate ddoc(testa.get_date("DATADOC"));
|
|
|
|
const TDate dreg(testa.get_date("DATAREG"));
|
|
|
|
const TString16 reg (testa.get("REG"));
|
|
|
|
const long protiva = testa.get_long("PROTIVA");
|
|
|
|
const TString16 codcaus(testa.get("CODCAUS"));
|
|
|
|
const TString16 codval (testa.get("CODVAL"));
|
|
|
|
const real cambio(testa.get("CAMBIO"));
|
1995-09-25 11:38:25 +00:00
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
|
|
|
|
real imponibile, imposta;
|
|
|
|
const real spese(0.0);
|
1995-06-28 16:33:53 +00:00
|
|
|
|
1995-09-25 11:38:25 +00:00
|
|
|
TPagamento& pag = *pagamento();
|
1995-10-12 15:02:46 +00:00
|
|
|
|
|
|
|
bool in_valuta = FALSE;
|
1995-09-25 11:38:25 +00:00
|
|
|
if (cambio.sign() > 0)
|
|
|
|
{
|
|
|
|
pag.set_cambio(cambio);
|
|
|
|
imponibile = real(m.get(S_TOTDOCVAL));
|
1995-10-12 15:02:46 +00:00
|
|
|
imposta = ZERO;
|
|
|
|
in_valuta = TRUE;
|
1995-09-25 11:38:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imponibile = real(m.get(F_IMPONIBILI));
|
|
|
|
imposta = real(m.get(F_IMPOSTE));
|
|
|
|
}
|
|
|
|
pag.set_total(imponibile, imposta, spese);
|
|
|
|
|
1995-06-28 16:33:53 +00:00
|
|
|
const TRectype& prima = _rel->cg(0);
|
|
|
|
const char sezione = prima.get_char("SEZIONE"); // Dare/Avere
|
|
|
|
const int nriga = 1;
|
|
|
|
const int numrig = 1;
|
1995-09-01 10:13:36 +00:00
|
|
|
|
1995-09-19 15:43:43 +00:00
|
|
|
TBill clifo; clifo.get(prima);
|
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
|
|
|
const TString16 numpart(m.get(F_NUMRIF));
|
|
|
|
partite().destroy();
|
|
|
|
const TPartita& part = partite().partita(clifo, anno, numpart);
|
1994-11-18 11:40:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
int npart = part.prima_fattura(nreg);
|
1994-11-21 11:47:08 +00:00
|
|
|
bool fromscratch = FALSE;
|
1995-09-25 11:38:25 +00:00
|
|
|
|
1995-09-22 12:29:00 +00:00
|
|
|
if (npart > 0) // la gh'e'
|
1994-11-21 11:47:08 +00:00
|
|
|
{
|
1995-09-19 15:43:43 +00:00
|
|
|
const TRiga_partite& partita = part.riga(npart);
|
|
|
|
const TRiga_scadenze& primarata = partita.rata(1);
|
1995-09-01 10:13:36 +00:00
|
|
|
|
|
|
|
// se si e' specificato un codice pagamento diverso si rifa' da capo
|
|
|
|
// la follia e' che e' sulle SCADENZE, non sulle partite, naturalmente
|
|
|
|
// uguale per tutte
|
|
|
|
if (pag.code() != primarata.get(SCAD_CODPAG))
|
|
|
|
fromscratch = TRUE;
|
|
|
|
|
1994-11-21 11:47:08 +00:00
|
|
|
// se invece la maschera contiene importi diversi da quelli
|
1995-09-01 10:13:36 +00:00
|
|
|
// registrati si passa la palla al culano/a
|
|
|
|
// TBC controllo se imponibile deve contenere le spese
|
1995-10-12 15:02:46 +00:00
|
|
|
else
|
1994-11-21 11:47:08 +00:00
|
|
|
{
|
1995-10-12 15:02:46 +00:00
|
|
|
if ((imponibile + imposta) != partita.get_real(in_valuta ? PART_IMPORTOVAL : PART_IMPORTO) ||
|
|
|
|
imposta != partita.get_real(PART_IMPOSTA) ||
|
|
|
|
spese != partita.get_real(PART_SPESE))
|
|
|
|
{
|
|
|
|
fromscratch = !yesno_box("Gli importi totali delle scadenze sono stati modificati rispetto"
|
|
|
|
" all'ultima registrazione. Si desidera mantenere"
|
|
|
|
" comunque la rateazione precedente");
|
|
|
|
// nel qual caso, of course, si disabilitano gli automatismi
|
1995-10-25 09:34:53 +00:00
|
|
|
if(!fromscratch) m.set(FS_RECALC, "", TRUE);
|
1995-10-12 15:02:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-11-21 11:47:08 +00:00
|
|
|
if (fromscratch)
|
1995-09-22 12:29:00 +00:00
|
|
|
{
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_rate_auto();
|
1995-09-22 12:29:00 +00:00
|
|
|
}
|
1994-11-18 11:40:45 +00:00
|
|
|
else
|
1995-10-12 15:02:46 +00:00
|
|
|
{
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.zap_rate();
|
1995-09-01 10:13:36 +00:00
|
|
|
for (int i = 1; i <= partita.rate(); i++)
|
1994-11-18 11:40:45 +00:00
|
|
|
{
|
1995-09-19 15:43:43 +00:00
|
|
|
const TRiga_scadenze& scadenza = partita.rata(i);
|
|
|
|
real importo = scadenza.get(SCAD_IMPORTO);
|
1995-09-01 10:13:36 +00:00
|
|
|
const TDate scad = scadenza.get(SCAD_DATASCAD);
|
|
|
|
const int tipop = scadenza.get_int(SCAD_TIPOPAG);
|
|
|
|
const bool paid = scadenza.get_bool(SCAD_PAGATA);
|
1995-09-22 12:29:00 +00:00
|
|
|
const TString16 ulc = scadenza.get(SCAD_ULTCLASS);
|
|
|
|
if (scadenza.in_valuta())
|
|
|
|
{
|
|
|
|
const real impval(scadenza.get(SCAD_IMPORTOVAL));
|
|
|
|
pag.set_rata(i-1, impval, importo, scad, tipop, ulc, paid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pag.set_rata(i-1, importo, ZERO, scad, tipop, ulc, paid);
|
|
|
|
|
|
|
|
TToken_string& str = ps.row(i-1);
|
1995-11-03 08:17:08 +00:00
|
|
|
str.add(scadenza.get(SCAD_CODABIPR), 7);
|
|
|
|
str.add(scadenza.get(SCAD_CODCABPR), 8);
|
|
|
|
str.add(scadenza.get(SCAD_CODABI), 9);
|
|
|
|
str.add(scadenza.get(SCAD_CODCAB), 10);
|
1995-09-22 12:29:00 +00:00
|
|
|
if (i == 1)
|
|
|
|
{
|
1995-11-03 08:17:08 +00:00
|
|
|
m.set(FS_NSABI, str.get(7));
|
|
|
|
m.set(FS_NSCAB, str.get(8));
|
|
|
|
m.set(FS_VSABI, str.get(9));
|
|
|
|
m.set(FS_VSCAB, str.get(10));
|
1995-09-22 12:29:00 +00:00
|
|
|
m.set(FS_AGENTE, scadenza.get(SCAD_CODAG));
|
|
|
|
}
|
1995-09-01 10:13:36 +00:00
|
|
|
}
|
1995-10-12 15:02:46 +00:00
|
|
|
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
|
|
|
m.set(FS_NAMEPAG, pag.name());
|
|
|
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
|
|
|
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
1995-11-14 10:27:10 +00:00
|
|
|
m.set(FS_RECALC, m.edit_mode() ? "" : "X", TRUE);
|
1995-10-12 15:02:46 +00:00
|
|
|
m.set(FS_NRATE, pag.n_rate());
|
1994-11-21 11:47:08 +00:00
|
|
|
} //else
|
1994-11-18 11:40:45 +00:00
|
|
|
}
|
|
|
|
else
|
1995-03-10 10:51:10 +00:00
|
|
|
return FALSE;
|
1995-02-28 09:17:57 +00:00
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_sheet(ps);
|
|
|
|
_pag_rows = ps.rows_array();
|
1994-11-18 11:40:45 +00:00
|
|
|
|
1994-11-10 14:25:26 +00:00
|
|
|
// se la prima rata e' fissa non si tocca
|
1995-09-01 10:13:36 +00:00
|
|
|
if (pag.tipo_prima_rata() > 3)
|
1995-03-22 09:04:45 +00:00
|
|
|
ps.disable_cell(0,-1);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPrimanota_application::write_scadenze(const TMask& m)
|
1995-09-19 15:43:43 +00:00
|
|
|
{
|
|
|
|
const long nreg = m.get_long(F_NUMREG);
|
1995-11-10 13:35:00 +00:00
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
|
|
|
const TString numpart(m.get(F_NUMRIF));
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-11-14 15:58:25 +00:00
|
|
|
TPartita* oldgame = partite().first();
|
1995-09-19 15:43:43 +00:00
|
|
|
TPartita* newgame = NULL;
|
1995-11-14 15:58:25 +00:00
|
|
|
|
|
|
|
if (anno > 0 && !numpart.blank())
|
1995-09-19 15:43:43 +00:00
|
|
|
{
|
|
|
|
real imponibile(0.0);
|
|
|
|
real imposta(0.0);
|
|
|
|
real spese(0.0);
|
|
|
|
|
1995-11-03 08:17:08 +00:00
|
|
|
const TString ndoc(m.get(F_NUMDOC));
|
1995-09-19 15:43:43 +00:00
|
|
|
const int tmov = causale().tipomov();
|
|
|
|
const TDate ddoc(m.get(F_DATADOC));
|
|
|
|
const TDate dreg(m.get(F_DATAREG));
|
1995-11-03 08:17:08 +00:00
|
|
|
const TString reg (causale().reg().name());
|
|
|
|
const TString desc(m.get(F_DESCR));
|
1995-09-19 15:43:43 +00:00
|
|
|
const long protiva = m.get_long(F_PROTIVA);
|
1995-11-03 08:17:08 +00:00
|
|
|
const TString codcaus(causale().codice());
|
|
|
|
const TString codval (m.get(S_VALUTA));
|
1995-09-19 15:43:43 +00:00
|
|
|
const real cambio (m.get(S_CAMBIO));
|
1995-11-03 08:17:08 +00:00
|
|
|
const TString agente (m.get(FS_AGENTE));
|
1995-09-19 15:43:43 +00:00
|
|
|
const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-09-22 12:29:00 +00:00
|
|
|
const TBill clifo(cgs().row(0), 2, 0x3);
|
1995-09-19 15:43:43 +00:00
|
|
|
newgame = new TPartita(clifo, anno, numpart);
|
|
|
|
|
|
|
|
const int row = newgame->prima_fattura(nreg);
|
|
|
|
TRiga_partite& partita = row <= 0 ? newgame->new_row() : newgame->riga(row);
|
|
|
|
TPagamento& pag = *pagamento();
|
|
|
|
|
|
|
|
// put data on partita
|
|
|
|
partita.put(PART_TIPOMOV, tmov);
|
|
|
|
partita.put(PART_NREG, nreg);
|
|
|
|
partita.put(PART_NUMRIG, 1);
|
|
|
|
partita.put(PART_DATAREG, dreg);
|
|
|
|
partita.put(PART_DATADOC, ddoc);
|
|
|
|
partita.put(PART_NUMDOC, ndoc);
|
|
|
|
partita.put(PART_DESCR, desc);
|
|
|
|
partita.put(PART_CODCAUS, codcaus);
|
1995-09-22 12:29:00 +00:00
|
|
|
partita.put(PART_REG, reg);
|
|
|
|
partita.put(PART_PROTIVA, protiva);
|
1995-09-19 15:43:43 +00:00
|
|
|
partita.put(PART_SEZ, sezione);
|
|
|
|
partita.put(PART_CODVAL, codval);
|
|
|
|
partita.put(PART_CAMBIO, cambio);
|
1995-09-25 17:30:36 +00:00
|
|
|
|
|
|
|
if (partita.in_valuta())
|
|
|
|
{
|
|
|
|
partita.put(PART_IMPORTO, m.get(F_IMPONIBILI));
|
|
|
|
partita.put(PART_IMPORTOVAL, pag.imponibile());
|
|
|
|
partita.zero(PART_IMPOSTA);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-10-30 10:17:14 +00:00
|
|
|
partita.put(PART_IMPORTO, real(pag.imponibile()+pag.imposta()));
|
1995-09-25 17:30:36 +00:00
|
|
|
partita.zero(PART_IMPORTOVAL);
|
|
|
|
partita.put(PART_IMPOSTA, pag.imposta());
|
|
|
|
}
|
1995-09-19 15:43:43 +00:00
|
|
|
partita.put(PART_SPESE, pag.spese());
|
|
|
|
|
1995-09-22 12:29:00 +00:00
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
1995-09-19 15:43:43 +00:00
|
|
|
partita.elimina_rate();
|
|
|
|
for (int i = 0; i < pag.n_rate(); i++)
|
1995-09-22 12:29:00 +00:00
|
|
|
{
|
|
|
|
TToken_string& row = ps.row(i);
|
|
|
|
|
1995-09-19 15:43:43 +00:00
|
|
|
TRiga_scadenze& scadenza = partita.new_row();
|
|
|
|
scadenza.put(SCAD_CODPAG, pag.code());
|
|
|
|
scadenza.put(SCAD_TIPOPAG, pag.tipo_rata(i));
|
|
|
|
scadenza.put(SCAD_ULTCLASS, pag.ulc_rata(i));
|
1995-09-22 12:29:00 +00:00
|
|
|
if (partita.in_valuta())
|
|
|
|
{
|
|
|
|
scadenza.put(SCAD_IMPORTO, pag.tlit_rata(i));
|
|
|
|
scadenza.put(SCAD_IMPORTOVAL, pag.tpay_rata(i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scadenza.put(SCAD_IMPORTO, pag.tpay_rata(i));
|
|
|
|
scadenza.zero(SCAD_IMPORTOVAL);
|
|
|
|
}
|
1995-09-19 15:43:43 +00:00
|
|
|
scadenza.put(SCAD_DATASCAD, pag.data_rata(i));
|
1995-11-03 08:17:08 +00:00
|
|
|
scadenza.put(SCAD_CODABIPR, row.get(7));
|
|
|
|
scadenza.put(SCAD_CODCABPR, row.get(8));
|
|
|
|
scadenza.put(SCAD_CODABI, row.get(9));
|
|
|
|
scadenza.put(SCAD_CODCAB, row.get(10));
|
1995-09-22 12:29:00 +00:00
|
|
|
scadenza.put(SCAD_CODAG, agente);
|
1995-11-03 08:17:08 +00:00
|
|
|
scadenza.put(SCAD_PAGATA, pag.ratapagata(i));
|
1995-09-19 15:43:43 +00:00
|
|
|
}
|
1995-03-22 09:04:45 +00:00
|
|
|
}
|
1995-09-19 15:43:43 +00:00
|
|
|
|
|
|
|
if (oldgame != NULL)
|
|
|
|
{
|
1995-11-14 15:58:25 +00:00
|
|
|
const int rigafatt = oldgame->prima_fattura(nreg);
|
|
|
|
if (rigafatt > 0)
|
1995-09-19 15:43:43 +00:00
|
|
|
{
|
1995-09-25 17:30:36 +00:00
|
|
|
if (newgame == NULL || *oldgame != *newgame)
|
1995-09-19 15:43:43 +00:00
|
|
|
{
|
|
|
|
bool sposta = newgame != NULL;
|
|
|
|
if (sposta)
|
1995-10-04 15:07:56 +00:00
|
|
|
{
|
|
|
|
sposta = (oldgame->conto().sottoconto() == newgame->conto().sottoconto());
|
1995-09-19 15:43:43 +00:00
|
|
|
if (sposta)
|
|
|
|
sposta = yesno_box("Spostare le righe nella nuova partita?");
|
|
|
|
}
|
|
|
|
if (sposta)
|
1995-11-14 15:58:25 +00:00
|
|
|
oldgame->sposta_riga(rigafatt, *newgame);
|
1995-09-19 15:43:43 +00:00
|
|
|
else
|
1995-09-25 17:30:36 +00:00
|
|
|
{
|
1995-11-14 15:58:25 +00:00
|
|
|
oldgame->scollega_pagamenti(rigafatt);
|
|
|
|
oldgame->rimuovi_riga(rigafatt);
|
1995-09-25 17:30:36 +00:00
|
|
|
}
|
1995-09-19 15:43:43 +00:00
|
|
|
oldgame->rewrite();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-11-14 15:58:25 +00:00
|
|
|
oldgame->sposta_riga(rigafatt, *newgame);
|
1995-09-19 15:43:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-09-01 10:13:36 +00:00
|
|
|
|
1995-11-14 15:58:25 +00:00
|
|
|
if (newgame != NULL) // Se ho cancellato il numero partita ...
|
|
|
|
newgame->write(); // Salva nuova partita
|
1995-03-22 09:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione pagamenti
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
bool ok = TRUE;
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
const char tipo = m.get(116)[0];
|
|
|
|
if (tipo == 'K' || (tipo == 'T' && app().causale().tipomov() == 2))
|
|
|
|
{
|
|
|
|
TSheet_field& s = *m.get_sheet();
|
|
|
|
const int riga = s.selected();
|
|
|
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
1995-10-11 11:39:50 +00:00
|
|
|
const bool ok = app().edit_partite(m, riga);
|
1995-10-25 09:34:53 +00:00
|
|
|
if (ok && riga < s.items())
|
1995-09-29 16:21:08 +00:00
|
|
|
k = K_ENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k == K_ENTER)
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
1995-09-29 16:21:08 +00:00
|
|
|
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
|
|
|
const TImporto importo(app().get_cgs_imp(riga));
|
|
|
|
const TImporto speso(app().partite().importo_speso(curreg, riga+1));
|
|
|
|
if (importo != speso)
|
|
|
|
{
|
|
|
|
const char* ss = speso.valore().string(".");
|
|
|
|
return f.error_box("L'importo deve essere %s %c", ss, speso.sezione());
|
|
|
|
}
|
|
|
|
if (tipo == 'K' && !speso.is_zero())
|
|
|
|
app().disable_cgs_cells(riga, 'K');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deleting significato
|
1995-10-11 11:39:50 +00:00
|
|
|
// -1 sto cancellando tutto
|
|
|
|
// 0 non sto cancellando nulla
|
1995-09-29 16:21:08 +00:00
|
|
|
// 1 sto cancellando la prima riga contabile
|
|
|
|
// n sto cancellando la ennesima riga contabile
|
|
|
|
bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag,
|
|
|
|
const TValuta& valuta, int deleting)
|
|
|
|
{
|
|
|
|
const int nriga = new_pag.get_int(PAGSCA_NRIGA); // Riga fattura
|
|
|
|
const int nrata = new_pag.get_int(PAGSCA_NRATA); // Numero rata
|
|
|
|
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); // Riga pagamento
|
|
|
|
const TRectype& old_pag = p.pagamento(nriga, nrata, nrigp);
|
|
|
|
const TRiga_partite& somma = p.riga(nrigp);
|
|
|
|
const int riga_contabile = somma.get_int(PART_NUMRIG); // Riga movimento
|
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
if (deleting >= 0)
|
1995-09-29 16:21:08 +00:00
|
|
|
{
|
|
|
|
const char sez = somma.sezione(); // Sezione importo e ritenute
|
|
|
|
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
|
|
|
|
|
|
|
|
// Aggiornamento contopartita
|
|
|
|
const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO));
|
|
|
|
TBill old_conto; old_conto.get(old_pag, TRUE);
|
|
|
|
|
|
|
|
const TImporto new_importo(controsez, new_pag.get_real(PAGSCA_IMPORTO));
|
|
|
|
TBill new_conto; new_conto.get(new_pag, TRUE);
|
|
|
|
|
|
|
|
if (old_importo != new_importo || old_conto != new_conto)
|
|
|
|
{
|
|
|
|
const int old_riga = bill2pos(old_conto, 'I');
|
|
|
|
if (old_riga >= 0)
|
|
|
|
{
|
|
|
|
const bool empty = sub_cgs_imp(old_riga, old_importo);
|
|
|
|
if (empty && (new_importo.is_zero() || new_conto != old_conto))
|
|
|
|
reset_cgs_row(old_riga);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Importo della contropartita
|
|
|
|
if (!new_importo.is_zero() && new_conto.ok())
|
|
|
|
{
|
|
|
|
const int new_riga = bill2pos(new_conto, 'I');
|
|
|
|
if (new_riga < 0)
|
|
|
|
set_cgs_row(new_riga, new_importo, new_conto, "", 'I');
|
|
|
|
else
|
|
|
|
add_cgs_imp(new_riga, new_importo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aggiornamento ritenute
|
|
|
|
const real old_ritenute(old_pag.get(PAGSCA_RITENUTE));
|
|
|
|
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
|
|
|
if (old_ritenute != new_ritenute)
|
|
|
|
{
|
|
|
|
const TImporto grow_ritenute(controsez, new_ritenute-old_ritenute);
|
|
|
|
const riga = type2pos('F');
|
|
|
|
if (riga < 0)
|
|
|
|
{
|
|
|
|
TBill conto_rit; causale().bill(11, conto_rit);
|
1995-10-06 13:24:49 +00:00
|
|
|
const TString desc(causale().desc_agg(11));
|
|
|
|
set_cgs_row(riga, grow_ritenute, conto_rit, desc, 'F');
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool empty = add_cgs_imp(riga, grow_ritenute);
|
|
|
|
if (empty) reset_cgs_row(riga);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if (deleting != 0)
|
|
|
|
|
|
|
|
char old_ap, new_ap;
|
|
|
|
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
|
|
|
const bool empty = p.modifica_pagamento(new_pag, valuta,
|
|
|
|
old_ap, old_abbuono, old_diffcam,
|
1995-10-25 09:34:53 +00:00
|
|
|
new_ap, new_abbuono, new_diffcam, TRUE);
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
if (deleting >= 0)
|
1995-09-29 16:21:08 +00:00
|
|
|
{
|
|
|
|
// Se c'e' differenza negli abbuoni
|
|
|
|
if (old_abbuono != new_abbuono || old_ap != new_ap)
|
|
|
|
{
|
|
|
|
if (old_ap != ' ') // Se c'era un abbuono ...
|
|
|
|
{
|
|
|
|
const int riga_abb = type2pos(old_ap);
|
|
|
|
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
1995-10-25 09:34:53 +00:00
|
|
|
const bool empty = add_cgs_imp(riga_abb, old_abbuono);
|
1995-09-29 16:21:08 +00:00
|
|
|
if (empty && new_ap != old_ap)
|
1995-10-25 09:34:53 +00:00
|
|
|
cgs().destroy(riga_abb);
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
if (deleting != riga_contabile)
|
|
|
|
{
|
|
|
|
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
1995-10-25 09:34:53 +00:00
|
|
|
sub_cgs_imp(riga_contabile-1, old_abbuono);
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new_ap != ' ') // Se ci sono abbuoni
|
|
|
|
{
|
|
|
|
const riga_abb = type2pos(new_ap);
|
1995-10-25 09:34:53 +00:00
|
|
|
|
|
|
|
new_abbuono.swap_section();
|
|
|
|
new_abbuono.normalize();
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
if (riga_abb < 0)
|
|
|
|
{
|
|
|
|
const int rc = new_ap == 'A' ? 9 : 8;
|
|
|
|
TBill conto_abb; causale().bill(rc, conto_abb);
|
1995-10-06 13:24:49 +00:00
|
|
|
const TString desc(causale().desc_agg(rc));
|
|
|
|
app().set_cgs_row(riga_abb, new_abbuono, conto_abb, desc, new_ap);
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
add_cgs_imp(riga_abb, new_abbuono);
|
|
|
|
|
|
|
|
if (deleting != riga_contabile)
|
|
|
|
{
|
|
|
|
// Aggiunge l'abbuono con la sezione invertita
|
1995-10-06 13:24:49 +00:00
|
|
|
sub_cgs_imp(riga_contabile-1, new_abbuono);
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Se c'e' variazione nella differenza cambi
|
|
|
|
if (old_diffcam != new_diffcam)
|
|
|
|
{
|
|
|
|
const int riga_diffcam = type2pos('C');
|
1995-10-25 09:34:53 +00:00
|
|
|
TImporto grow_diffcam(old_diffcam);
|
|
|
|
grow_diffcam -= new_diffcam;
|
1995-09-29 16:21:08 +00:00
|
|
|
grow_diffcam.normalize();
|
|
|
|
|
|
|
|
if (riga_diffcam < 0)
|
|
|
|
{
|
|
|
|
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
1995-10-06 13:24:49 +00:00
|
|
|
const TString desc(causale().desc_agg(12));
|
|
|
|
set_cgs_row(riga_diffcam, grow_diffcam, conto_diffcam, desc, 'C');
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool empty = add_cgs_imp(riga_diffcam, grow_diffcam);
|
1995-10-25 09:34:53 +00:00
|
|
|
if (empty) cgs().destroy(riga_diffcam);
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (deleting != riga_contabile)
|
|
|
|
{
|
|
|
|
// Aggiunge la differenza con la sezione invertita
|
|
|
|
sub_cgs_imp(riga_contabile-1, grow_diffcam);
|
|
|
|
}
|
|
|
|
}
|
1995-10-11 11:39:50 +00:00
|
|
|
} // if (deleting >= 0)
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
return empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scorre tutte le righe della partita ed azzera i pagamenti relativi a alla riga contabile
|
|
|
|
// cancellata e decrementa i numeri riga superiori a numrig
|
|
|
|
bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg, int numrig)
|
|
|
|
{
|
|
|
|
bool found = FALSE;
|
|
|
|
|
|
|
|
for (int p = partita.last(); p > 0; p = partita.pred(p))
|
|
|
|
{
|
|
|
|
TRiga_partite& part = partita.riga(p);
|
|
|
|
if (part.get_int(PART_TIPOMOV) == 1)
|
|
|
|
{
|
|
|
|
for (int r = part.rate(); r > 0; r--)
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& scad = part.rata(r);
|
|
|
|
for (int s = scad.last(); s > 0; s = scad.pred(s))
|
|
|
|
{
|
|
|
|
const TRiga_partite& sum = partita.riga(s);
|
|
|
|
if (sum.get_long(PART_NREG) == nreg &&
|
|
|
|
(numrig <= 0 || sum.get_int(PART_NUMRIG) == numrig))
|
|
|
|
{
|
|
|
|
TRectype nul_pag(scad.row(s));
|
|
|
|
nul_pag.zero(PAGSCA_IMPORTO);
|
|
|
|
nul_pag.zero(PAGSCA_IMPORTOVAL);
|
|
|
|
nul_pag.zero(PAGSCA_RITENUTE);
|
|
|
|
nul_pag.put(PAGSCA_ACCSAL, 'A');
|
|
|
|
const TValuta val; // Non cambiare valuta
|
|
|
|
notify_edit_pagamento(partita, nul_pag, val, numrig);
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (numrig > 0 && part.get_long(PART_NREG) == nreg && part.get_int(PART_NUMRIG) > numrig)
|
|
|
|
part.put(PART_NUMRIG, numrig-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TPrimanota_application::notify_cgline_deletion(int numrig)
|
|
|
|
{
|
|
|
|
bool found = FALSE;
|
|
|
|
const long nreg = curr_mask().get_long(F_NUMREG);
|
1995-10-11 11:39:50 +00:00
|
|
|
for (TPartita* game = partite().first(); game; game = partite().next())
|
1995-09-29 16:21:08 +00:00
|
|
|
found |= notify_cgline_deletion(*game, nreg, numrig);
|
|
|
|
return found;
|
|
|
|
}
|