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-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>
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-08-09 09:52:08 +00:00
|
|
|
bool TPrimanota_application::pag_notify(TSheet_field&, int r, KEY k)
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
1995-09-01 10:13:36 +00:00
|
|
|
TPagamento& pag = *(app().pagamento());
|
1995-03-22 09:04:45 +00:00
|
|
|
TSheet_field& ps = app().pags();
|
|
|
|
TMask* msk = &(app().curr_mask());
|
|
|
|
TString_array& rws = app().pag_rows();
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
int rdiff = atoi(msk->get(FS_RDIFFER));
|
1994-11-10 14:25:26 +00:00
|
|
|
|
|
|
|
// ts contiene la vecchia riga, ns la nuova
|
|
|
|
TToken_string ts(36), ns(36);
|
|
|
|
|
|
|
|
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
|
|
|
|
bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE;
|
|
|
|
word ahiahi = P_OK;
|
|
|
|
|
|
|
|
TString news(15), newi(15), newp(15), newt(2);
|
|
|
|
|
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_SPACE:
|
|
|
|
break;
|
|
|
|
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
|
|
|
|
|
|
|
news = ns.get(0);
|
1995-08-24 07:27:50 +00:00
|
|
|
newp = ns.get(2);
|
|
|
|
newi = ns.get(1);
|
1994-11-10 14:25:26 +00:00
|
|
|
newt = ns.get(3);
|
|
|
|
|
|
|
|
// qui viene il bello, si fa per dire
|
1995-03-22 09:04:45 +00:00
|
|
|
if (news != ts.get(0)) // modificata data scadenza
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
mod = m_scad = TRUE;
|
|
|
|
}
|
1995-08-24 07:27:50 +00:00
|
|
|
if (newp != ts.get(2)) // modificata percentuale
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
mod = m_perc = TRUE;
|
|
|
|
}
|
1995-08-24 07:27:50 +00:00
|
|
|
if (newi != ts.get(1)) // 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))
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
mod = m_imp = TRUE;
|
|
|
|
}
|
|
|
|
}
|
1995-03-22 09:04:45 +00:00
|
|
|
if (newt != ts.get(3)) // modificato tipo pagamento
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
mod = m_tipo = TRUE;
|
|
|
|
}
|
|
|
|
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),
|
|
|
|
(m_tipo ? (const char*)newt : NULL),
|
|
|
|
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");
|
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;
|
|
|
|
if (m_scad) trw.add(news,3);
|
|
|
|
if (m_perc) trw.add(newp,1);
|
|
|
|
if (m_imp) trw.add(newi,4);
|
|
|
|
if (m_tipo) trw.add(newt,2);
|
|
|
|
// validate the payment
|
1995-03-22 09:04:45 +00:00
|
|
|
if ((ahiahi = pag.validate()) != P_OK)
|
|
|
|
pag.rata(r) = srw;
|
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
|
1994-11-10 14:25:26 +00:00
|
|
|
{
|
|
|
|
beep();
|
|
|
|
|
|
|
|
// se gli errori sono voluti, spiegali
|
|
|
|
if (!recalc)
|
|
|
|
{
|
1995-03-22 09:04:45 +00:00
|
|
|
TString256 s;
|
|
|
|
pag.strerr(ahiahi,s);
|
1994-11-10 14:25:26 +00:00
|
|
|
warning_box(s);
|
|
|
|
}
|
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
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);
|
|
|
|
ps.force_update();
|
|
|
|
rws = ps.rows_array();
|
|
|
|
}
|
1994-11-10 14:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return doit;
|
|
|
|
}
|
|
|
|
|
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-09-01 10:13:36 +00:00
|
|
|
if (key == K_TAB && f.focusdirty() && m.is_running() && app().is_saldaconto())
|
1995-02-28 09:17:57 +00:00
|
|
|
{
|
1995-03-22 09:04:45 +00:00
|
|
|
const TString16 dt(m.get(F_DATAREG));
|
|
|
|
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
|
|
|
|
|
|
|
bool TPrimanota_application::reset_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
if (key == K_SPACE && m.is_running() && app().is_saldaconto())
|
|
|
|
{
|
|
|
|
app().reset_pagamento();
|
|
|
|
app().set_scadenze(m);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_TAB && f.mask().is_running() && f.focusdirty())
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
const TString& val = f.get();
|
|
|
|
|
|
|
|
// questo evita due handlerate visto che e' in fondo alla pagina
|
|
|
|
if (val == app().get_numrif()) return TRUE;
|
|
|
|
|
|
|
|
// se cambiato chiedo conferma:
|
|
|
|
// se svuotato, azzero il cazzoconto
|
|
|
|
if (val.empty())
|
|
|
|
{
|
|
|
|
if (yesno_box("Si desidera l'azzeramento delle scadenze?"))
|
|
|
|
{
|
|
|
|
// sbraga giu' il saldaconto: andra' tutto kancellato
|
|
|
|
// se c'era
|
|
|
|
app().remove_scadenze(f.mask(), app().get_numrif());
|
|
|
|
f.set(""); // non dovrebbe servire, ma...
|
|
|
|
f.mask().disable_page(2);
|
|
|
|
}
|
|
|
|
else { f.set(app().get_numrif()); }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TString16 oldnr = app().get_numrif();
|
|
|
|
|
|
|
|
if (oldnr.empty())
|
|
|
|
{
|
|
|
|
// se numrif era vuoto, mi limito a costruire il nuovo saldaminchia
|
|
|
|
// con questo numrif
|
|
|
|
if (yesno_box("Si desidera la ridefinizione delle scadenze?"))
|
|
|
|
{
|
|
|
|
// deve esserci la data rif.
|
|
|
|
if (f.mask().get(F_ANNORIF).empty())
|
|
|
|
{
|
|
|
|
error_box("Non e' indicato l'anno riferimento partita");
|
|
|
|
f.set("");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// lo ridefinisco da capo
|
|
|
|
// con il nuovo porcodio, riabilitando se
|
|
|
|
// non c'era
|
|
|
|
// deve essere indicato il pagamento, se no guai
|
|
|
|
if (app().pagamento() == NULL)
|
|
|
|
{
|
|
|
|
TString16 codpag = f.mask().get(F_CODPAG);
|
|
|
|
if (codpag.empty())
|
|
|
|
{
|
|
|
|
error_box("Deve essere specificato il codice pagamento");
|
|
|
|
f.set("");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
f.mask().enable_page(2);
|
|
|
|
app().set_pagamento(codpag, f.mask().get(F_DATAREG));
|
|
|
|
app().set_scadenze(f.mask());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
app().reset_pagamento();
|
|
|
|
app().set_scadenze(m);
|
|
|
|
f.mask().enable_page(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { f.set(""); }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// trattasi di variazione: devo chiedere se vuole spostare i
|
|
|
|
// pagamenti, e se non vuole li lascio con codice 9999 (??? TBC)
|
|
|
|
if (yesno_box("Confermare la modifica numero riferimento partita"))
|
|
|
|
app().renumber_partita(f.mask(), oldnr, f.get());
|
|
|
|
else f.set(app().get_numrif());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app().set_numrif(f.get());
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-08-24 07:27:50 +00:00
|
|
|
void TPrimanota_application::reset_pagamento()
|
|
|
|
{
|
|
|
|
if (_pag != NULL)
|
|
|
|
{
|
|
|
|
_pag->read();
|
|
|
|
_pag->set_rate_auto();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
void TPrimanota_application::renumber_partita(TMask& m, const char* oldp, const char* newp)
|
|
|
|
{
|
|
|
|
bool movep = FALSE;
|
|
|
|
|
|
|
|
const TRectype& testa = _rel->lfile().curr();
|
|
|
|
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"));
|
|
|
|
|
|
|
|
const TString16 numpart(m.get(F_NUMRIF));
|
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
|
|
|
|
|
|
|
const TRectype& prima = _rel->cg(0);
|
|
|
|
const char sezione = prima.get_char("SEZIONE"); // Dare/Avere
|
|
|
|
const char tipocf = prima.get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
|
|
|
const int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : prima.get_int("GRUPPO");
|
|
|
|
const int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : prima.get_int("CONTO");
|
|
|
|
const long sottoconto = prima.get_long("SOTTOCONTO");
|
|
|
|
const int nriga = 1;
|
|
|
|
const int numrig = 1;
|
|
|
|
|
|
|
|
TBill clifo(gruppo, conto, sottoconto, tipocf);
|
|
|
|
TPartita part(clifo, anno, numpart);
|
|
|
|
|
|
|
|
if (part.primo_pagamento() != -1)
|
|
|
|
movep = yesno_box("Si desidera spostare i pagamenti sulla nuova partita?");
|
|
|
|
|
|
|
|
// TBI
|
|
|
|
warning_box("Funzione non implementata");
|
|
|
|
}
|
|
|
|
|
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-06-21 15:33:31 +00:00
|
|
|
const real imponibile(m.get(F_IMPONIBILI));
|
|
|
|
const real imposta(m.get(F_IMPOSTE));
|
|
|
|
const real spese(0.0);
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TPagamento& pag = *pagamento();
|
1995-03-22 09:04:45 +00:00
|
|
|
if (pag.is_new())
|
1995-02-28 09:17:57 +00:00
|
|
|
{
|
1995-09-01 10:13:36 +00:00
|
|
|
// m.disable_page(2);
|
1995-02-28 09:17:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else m.enable_page(2);
|
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
|
|
|
m.set(FS_NAMEPAG, pag.name());
|
1995-06-21 15:33:31 +00:00
|
|
|
m.set(FS_TIPOPR, pag.desc_tpr());
|
|
|
|
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
|
|
|
m.set(FS_RECALC, "X", TRUE);
|
1995-02-28 09:17:57 +00:00
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_total(imponibile, imposta, spese);
|
|
|
|
pag.set_rate_auto();
|
1995-02-28 09:17:57 +00:00
|
|
|
bool new_part = TRUE;
|
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
// prepara lo sheet
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_sheet(ps);
|
|
|
|
_pag_rows = ps.rows_array();
|
1995-02-28 09:17:57 +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-02-28 09:17:57 +00:00
|
|
|
{
|
|
|
|
ps.disable_cell(0,0);
|
|
|
|
ps.disable_cell(0,1);
|
|
|
|
ps.disable_cell(0,2);
|
|
|
|
ps.disable_cell(0,3);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
1994-11-18 11:40:45 +00:00
|
|
|
// should never happen but it doesn't hurt
|
1995-02-28 09:17:57 +00:00
|
|
|
if (_rel->cg(0).empty()) return FALSE;
|
|
|
|
|
1995-06-28 16:33:53 +00:00
|
|
|
const real imponibile(m.get(F_IMPONIBILI));
|
|
|
|
const real imposta(m.get(F_IMPOSTE));
|
|
|
|
const real spese(0.0);
|
|
|
|
|
|
|
|
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
|
|
|
|
1995-06-21 15:33:31 +00:00
|
|
|
m.set(FS_RECALC, "X");
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TPagamento& pag = *pagamento();
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_total(imponibile, imposta, spese);
|
1994-11-18 11:40:45 +00:00
|
|
|
|
1995-06-28 16:33:53 +00:00
|
|
|
const TRectype& testa = _rel->lfile().curr();
|
|
|
|
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"));
|
|
|
|
|
|
|
|
const TString16 numpart(m.get(F_NUMRIF));
|
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
|
|
|
|
|
|
|
const TRectype& prima = _rel->cg(0);
|
|
|
|
const char sezione = prima.get_char("SEZIONE"); // Dare/Avere
|
|
|
|
const char tipocf = prima.get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
|
|
|
const int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : prima.get_int("GRUPPO");
|
|
|
|
const int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : prima.get_int("CONTO");
|
|
|
|
const long sottoconto = prima.get_long("SOTTOCONTO");
|
|
|
|
const int nriga = 1;
|
|
|
|
const int numrig = 1;
|
1995-09-01 10:13:36 +00:00
|
|
|
|
|
|
|
TBill clifo(gruppo, conto, sottoconto, tipocf);
|
|
|
|
TPartita part(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-01 10:13:36 +00:00
|
|
|
if (npart != -1) // la gh'e'
|
1994-11-21 11:47:08 +00:00
|
|
|
{
|
1995-09-01 10:13:36 +00:00
|
|
|
|
|
|
|
TRiga_partite& partita = part.riga(npart);
|
|
|
|
TRiga_scadenze& primarata = partita.rata(1);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
else if ((imponibile + imposta) != partita.get_real(PART_IMPORTO) ||
|
|
|
|
imposta != partita.get_real(PART_IMPOSTA) ||
|
|
|
|
spese != partita.get_real(PART_SPESE))
|
1994-11-21 11:47:08 +00:00
|
|
|
{
|
1995-02-28 09:17:57 +00:00
|
|
|
fromscratch = !yesno_box("Gli importi totali delle scadenze sono stati modificati rispetto"
|
1994-11-21 11:47:08 +00:00
|
|
|
" all'ultima registrazione. Si desidera mantenere"
|
|
|
|
" comunque la rateazione precedente");
|
1995-08-24 07:27:50 +00:00
|
|
|
// nel qual caso, of course, si disabilitano gli automatismi
|
1995-02-28 09:17:57 +00:00
|
|
|
if(!fromscratch) m.field(FS_RECALC).set("");
|
1994-11-21 11:47:08 +00:00
|
|
|
}
|
|
|
|
if (fromscratch)
|
1995-03-22 09:04:45 +00:00
|
|
|
pag.set_rate_auto();
|
1994-11-18 11:40:45 +00:00
|
|
|
else
|
|
|
|
{
|
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-01 10:13:36 +00:00
|
|
|
TRiga_scadenze& scadenza = partita.rata(i);
|
|
|
|
|
|
|
|
const real importo = scadenza.get(SCAD_IMPORTO);
|
|
|
|
const TDate scad = scadenza.get(SCAD_DATASCAD);
|
|
|
|
const int tipop = scadenza.get_int(SCAD_TIPOPAG);
|
|
|
|
const bool paid = scadenza.get_bool(SCAD_PAGATA);
|
|
|
|
const TString16 ulc = scadenza.get(SCAD_ULTCLASS);
|
1994-11-18 11:40:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
pag.set_rata(i-1, importo, scad, tipop, ulc, paid);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
1995-08-24 07:27:50 +00:00
|
|
|
void TPrimanota_application::remove_scadenze(const TMask& m, const char* nr)
|
|
|
|
{
|
|
|
|
TString numrif(nr);
|
|
|
|
if (numrif.empty()) return;
|
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TRectype& r = _rel->lfile().curr();
|
|
|
|
|
|
|
|
const long nreg = r.get_long("NUMREG");
|
|
|
|
|
|
|
|
// rimuovi se ci sono
|
|
|
|
const char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
|
|
|
const int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("GRUPPO");
|
|
|
|
const int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("CONTO");
|
|
|
|
const long sottoconto = _rel->cg(0).get_long("SOTTOCONTO");
|
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
|
|
|
|
|
|
|
TBill clifo(gruppo, conto, sottoconto, tipocf);
|
|
|
|
TPartita part(clifo, anno, numrif);
|
|
|
|
|
|
|
|
if (part.ok())
|
|
|
|
{
|
|
|
|
// check pagamenti effettuati
|
|
|
|
bool nopag = part.primo_pagamento(nreg) == -1;
|
|
|
|
|
|
|
|
if (nopag)
|
|
|
|
{
|
|
|
|
int npart = part.prima_fattura(nreg);
|
|
|
|
part.rimuovi_riga(npart);
|
|
|
|
part.rewrite();
|
|
|
|
_skip_write_scadenze = TRUE;
|
|
|
|
}
|
|
|
|
else warning_box("Esistono pagamenti gia' effettuati: rimozione impossibile");
|
|
|
|
}
|
1995-08-24 07:27:50 +00:00
|
|
|
}
|
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
void TPrimanota_application::write_scadenze(const TMask& m)
|
|
|
|
{
|
1995-03-22 09:04:45 +00:00
|
|
|
real imponibile(0.0);
|
|
|
|
real imposta(0.0);
|
1995-08-24 07:27:50 +00:00
|
|
|
real spese(0.0);
|
1995-09-01 10:13:36 +00:00
|
|
|
|
|
|
|
if (_skip_write_scadenze)
|
|
|
|
{
|
|
|
|
_skip_write_scadenze = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1995-02-28 09:17:57 +00:00
|
|
|
// should never happen but it doesn't hurt
|
1995-03-22 09:04:45 +00:00
|
|
|
CHECK(!_rel->cg(0).empty(), "Missing first line");
|
1995-02-28 09:17:57 +00:00
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
TRectype& r = _rel->lfile().curr();
|
|
|
|
|
1995-03-27 14:35:06 +00:00
|
|
|
const long nreg = r.get_long("NUMREG");
|
|
|
|
const TString16 ndoc(r.get("NUMDOC"));
|
|
|
|
const int tmov = r.get_int("TIPOMOV");
|
|
|
|
const TDate ddoc(r.get_date("DATADOC"));
|
|
|
|
const TDate dreg(r.get_date("DATAREG"));
|
|
|
|
const TString16 reg (r.get("REG"));
|
|
|
|
const TString80 desc(r.get("DESCR"));
|
1995-04-21 15:41:11 +00:00
|
|
|
const long protiva = r.get_long("PROTIVA");
|
1995-03-27 14:35:06 +00:00
|
|
|
const TString16 codcaus(r.get("CODCAUS"));
|
|
|
|
const TString16 codval (r.get("CODVAL"));
|
|
|
|
const real cambio (r.get("CAMBIO"));
|
|
|
|
|
|
|
|
const TString16 numpart = m.get(F_NUMRIF);
|
1995-03-22 09:04:45 +00:00
|
|
|
const int anno = m.get_int(F_ANNORIF);
|
1995-09-01 10:13:36 +00:00
|
|
|
|
1995-06-22 14:46:26 +00:00
|
|
|
CHECK(anno > 1900, "Anno partita non valido");
|
1995-02-28 09:17:57 +00:00
|
|
|
|
|
|
|
char sezione = _rel->cg(0).get_char("SEZIONE"); // Dare/Avere
|
|
|
|
char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
1995-03-22 09:04:45 +00:00
|
|
|
int gruppo = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("GRUPPO");
|
|
|
|
int conto = (tipocf == 'C' || tipocf == 'F') ? 0 : _rel->cg(0).get_char("CONTO");
|
1995-02-28 09:17:57 +00:00
|
|
|
long sottoconto = _rel->cg(0).get_long("SOTTOCONTO");
|
1995-08-24 07:27:50 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TBill clifo(gruppo, conto, sottoconto, tipocf);
|
|
|
|
TPartita part(clifo, anno, numpart);
|
|
|
|
|
|
|
|
int numrig = 1; // TBC
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
int row = part.prima_fattura(nreg);
|
|
|
|
TRiga_partite& partita = row == -1 ? part.nuova_riga() : part.riga(row);
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TPagamento& pag = *pagamento();
|
|
|
|
|
|
|
|
// put data on partita
|
|
|
|
partita.put(PART_TIPOMOV, tmov);
|
|
|
|
partita.put(PART_NREG, nreg);
|
|
|
|
partita.put(PART_DATAREG, dreg);
|
|
|
|
partita.put(PART_DATADOC, ddoc);
|
|
|
|
partita.put(PART_NUMDOC, ndoc);
|
|
|
|
partita.put(PART_REG, reg);
|
|
|
|
partita.put(PART_DESCR, desc);
|
|
|
|
partita.put(PART_PROTIVA, protiva);
|
|
|
|
partita.put(PART_CODCAUS, codcaus);
|
|
|
|
partita.put(PART_SEZ, sezione);
|
|
|
|
// partita.put(PART_CODPAG, pag.code());
|
|
|
|
partita.put(PART_CODVAL, codval);
|
|
|
|
partita.put(PART_CAMBIO, cambio);
|
|
|
|
partita.put(PART_IMPORTO, pag.imponibile()+pag.imposta()); // TBC sommare le spese?
|
|
|
|
partita.put(PART_IMPOSTA, pag.imposta());
|
|
|
|
partita.put(PART_SPESE, pag.spese());
|
|
|
|
partita.put(PART_NUMRIG, numrig);
|
1994-11-10 14:25:26 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
// TBC se devono cominciare da n != 1, si riveda questo
|
|
|
|
// appropriatamente
|
|
|
|
partita.elimina_rate();
|
1995-03-22 09:04:45 +00:00
|
|
|
|
1995-09-01 10:13:36 +00:00
|
|
|
TString16 np = partita.get(PART_NUMPART);
|
|
|
|
TString16 nr = partita.get(PART_NRIGA);
|
1994-11-18 11:40:45 +00:00
|
|
|
|
1995-03-22 09:04:45 +00:00
|
|
|
for (int i = 0; i < pag.n_rate(); i++)
|
|
|
|
{
|
1995-09-01 10:13:36 +00:00
|
|
|
TRiga_scadenze& scadenza = (TRiga_scadenze&)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));
|
|
|
|
scadenza.put(SCAD_IMPORTO, pag.tpay_rata(i));
|
|
|
|
scadenza.put(SCAD_DATASCAD, pag.data_rata(i));
|
|
|
|
scadenza.put(SCAD_PAGATA, pag.ratapagata(i));
|
|
|
|
// scadenza.put(SCAD_CODABIPR, pag.codabipr(i)); // TBI
|
|
|
|
// scadenza.put(SCAD_CODCABPR, pag.codcabpr(i)); // TBI
|
1995-03-22 09:04:45 +00:00
|
|
|
}
|
1995-09-01 10:13:36 +00:00
|
|
|
|
|
|
|
part.write();
|
1995-03-22 09:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|