Aggiunto scadenzario (ancora incompleto, senza registrazione) alla primanota
git-svn-id: svn://10.65.10.50/trunk@317 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e1ec4c3f2b
commit
1009bd1f41
@ -14,5 +14,3 @@ int main(int argc,char** argv)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1
cg/cg2.h
1
cg/cg2.h
@ -5,4 +5,3 @@ int cg2100(int argc, char** argv);
|
|||||||
int cg2200(int argc, char** argv);
|
int cg2200(int argc, char** argv);
|
||||||
|
|
||||||
#endif // __CG2_H
|
#endif // __CG2_H
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <execp.h>
|
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
|
#include <execp.h>
|
||||||
|
|
||||||
#include "cg2100.h"
|
#include "cg2100.h"
|
||||||
#include "cg2102.h"
|
#include "cg2102.h"
|
||||||
@ -158,13 +158,6 @@ bool TPrimanota_application::user_destroy()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TPrimanota_application::print()
|
|
||||||
{
|
|
||||||
TExternal_app stampa("cg3 -0");
|
|
||||||
stampa.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Legge la causale di codice cod ed il relativo registro dell'anno year
|
// Legge la causale di codice cod ed il relativo registro dell'anno year
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
bool TPrimanota_application::read_caus(const char* cod, int year)
|
bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||||
@ -187,6 +180,12 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrimanota_application::print()
|
||||||
|
{
|
||||||
|
TExternal_app stampa("cg3 -0");
|
||||||
|
stampa.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TPrimanota_application::changing_mask(int mode)
|
bool TPrimanota_application::changing_mask(int mode)
|
||||||
{
|
{
|
||||||
@ -196,6 +195,7 @@ bool TPrimanota_application::changing_mask(int mode)
|
|||||||
_iva = nessuna_iva;
|
_iva = nessuna_iva;
|
||||||
|
|
||||||
TString16 causale;
|
TString16 causale;
|
||||||
|
// TString16 registro;
|
||||||
int annoes = 0, annoiva = 0;
|
int annoes = 0, annoiva = 0;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
@ -211,6 +211,9 @@ bool TPrimanota_application::changing_mask(int mode)
|
|||||||
annoiva = _rel->lfile().get_int("ANNOIVA");
|
annoiva = _rel->lfile().get_int("ANNOIVA");
|
||||||
causale = _rel->lfile().get("CODCAUS");
|
causale = _rel->lfile().get("CODCAUS");
|
||||||
giornale().read(annoes);
|
giornale().read(annoes);
|
||||||
|
// registro = _rel->lfile()->get("REG");
|
||||||
|
// _causale.read(causale, 0);
|
||||||
|
// _causale.reg().read(registro, annoiva);
|
||||||
read_caus(causale, annoiva);
|
read_caus(causale, annoiva);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -256,7 +259,7 @@ void TPrimanota_application::init_mask(TMask& m)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
forg = 'h';
|
forg = 'h';
|
||||||
clig = causale().corrispettivi() ? 'h' : 's';
|
clig = causale().reg().corrispettivi() ? 'h' : 's';
|
||||||
}
|
}
|
||||||
m.send_key(K_SHIFT+K_CTRL+clig, -1); // group 1 (clienti)
|
m.send_key(K_SHIFT+K_CTRL+clig, -1); // group 1 (clienti)
|
||||||
m.send_key(K_SHIFT+K_CTRL+forg, -2); // group 2 (fornitori)
|
m.send_key(K_SHIFT+K_CTRL+forg, -2); // group 2 (fornitori)
|
||||||
@ -282,7 +285,6 @@ void TPrimanota_application::init_mask(TMask& m)
|
|||||||
|
|
||||||
void TPrimanota_application::init_query_mode(TMask& m)
|
void TPrimanota_application::init_query_mode(TMask& m)
|
||||||
{
|
{
|
||||||
enable_menu_item(M_FILE_PRINT);
|
|
||||||
m.enable(DLG_NEWREC);
|
m.enable(DLG_NEWREC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,8 +327,7 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
|||||||
_saldi.set_movap(_causale.apertura());
|
_saldi.set_movap(_causale.apertura());
|
||||||
_saldi.set_anno_es(m.get_int(F_ANNOES));
|
_saldi.set_anno_es(m.get_int(F_ANNOES));
|
||||||
_saldi.set_num_ulmov(m.get_long(F_NUMREG));
|
_saldi.set_num_ulmov(m.get_long(F_NUMREG));
|
||||||
const TDate datareg(m.get(F_DATAREG));
|
_saldi.set_data_ulmov(TDate(m.get(F_DATAREG)));
|
||||||
_saldi.set_data_ulmov(datareg);
|
|
||||||
|
|
||||||
if (_iva != nessuna_iva)
|
if (_iva != nessuna_iva)
|
||||||
{
|
{
|
||||||
@ -366,8 +367,7 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
|||||||
|
|
||||||
if (iva() == nessuna_iva)
|
if (iva() == nessuna_iva)
|
||||||
{
|
{
|
||||||
const int n = set_cgs_row(-1,zero,tc,desc,' ');
|
set_cgs_row(-1,zero,tc,desc,' ');
|
||||||
cgs().disable_cell(n, sezione == 'D' ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -608,7 +608,7 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
|||||||
}
|
}
|
||||||
if (_iva == nessuna_iva) return;
|
if (_iva == nessuna_iva) return;
|
||||||
|
|
||||||
if (causale().corrispettivi())
|
if (causale().reg().corrispettivi())
|
||||||
{
|
{
|
||||||
TRectype& rec = _rel->lfile().curr();
|
TRectype& rec = _rel->lfile().curr();
|
||||||
rec.put("TIPO", "");
|
rec.put("TIPO", "");
|
||||||
@ -697,6 +697,8 @@ int TPrimanota_application::write(const TMask& m)
|
|||||||
const TString16 causimm(_causale.causale_inc_imm());
|
const TString16 causimm(_causale.causale_inc_imm());
|
||||||
if (causimm.not_empty())
|
if (causimm.not_empty())
|
||||||
genera_incasso(causimm);
|
genera_incasso(causimm);
|
||||||
|
if (TRUE) // TBI controlla pagamento da scadenzare
|
||||||
|
aggiorna_scadenzario(m);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -708,6 +710,9 @@ int TPrimanota_application::rewrite(const TMask& m)
|
|||||||
const int err = _rel->rewrite(TRUE);
|
const int err = _rel->rewrite(TRUE);
|
||||||
if (err == NOERR)
|
if (err == NOERR)
|
||||||
_saldi.registra();
|
_saldi.registra();
|
||||||
|
if (TRUE) // TBI controlla pagamento da scadenzare e/o variazione che ne implichi
|
||||||
|
// la modifica
|
||||||
|
aggiorna_scadenzario(m);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ class TPrimanota_application : public TRelation_application
|
|||||||
long _lastreg; // Numero ultima registrazione
|
long _lastreg; // Numero ultima registrazione
|
||||||
int _mode; // Modo maschera corrente
|
int _mode; // Modo maschera corrente
|
||||||
|
|
||||||
|
void* _app_data;
|
||||||
|
|
||||||
static bool suspended_handler(TMask_field& f, KEY k);
|
static bool suspended_handler(TMask_field& f, KEY k);
|
||||||
static bool num_handler(TMask_field& f, KEY key);
|
static bool num_handler(TMask_field& f, KEY key);
|
||||||
static bool caus_query_handler(TMask_field& f, KEY key);
|
static bool caus_query_handler(TMask_field& f, KEY key);
|
||||||
@ -76,6 +78,8 @@ class TPrimanota_application : public TRelation_application
|
|||||||
static bool iva_handler(TMask_field& f, KEY key);
|
static bool iva_handler(TMask_field& f, KEY key);
|
||||||
static bool cg_notify(int r, KEY key);
|
static bool cg_notify(int r, KEY key);
|
||||||
static bool cg_handler(TMask_field& f, KEY key);
|
static bool cg_handler(TMask_field& f, KEY key);
|
||||||
|
static bool pag_notify(int r, KEY key);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool user_create();
|
virtual bool user_create();
|
||||||
@ -94,6 +98,7 @@ protected:
|
|||||||
virtual bool remove();
|
virtual bool remove();
|
||||||
|
|
||||||
void genera_incasso(const char* causimm);
|
void genera_incasso(const char* causimm);
|
||||||
|
void aggiorna_scadenzario(const TMask& m);
|
||||||
|
|
||||||
TMask* load_mask(int n);
|
TMask* load_mask(int n);
|
||||||
TMask& occas_mask() { return *load_mask(3); }
|
TMask& occas_mask() { return *load_mask(3); }
|
||||||
@ -151,6 +156,9 @@ protected:
|
|||||||
void add_cgs_tot(TMask& m);
|
void add_cgs_tot(TMask& m);
|
||||||
void add_cgs_rit(bool fisc);
|
void add_cgs_rit(bool fisc);
|
||||||
|
|
||||||
|
void* get_app_data() { return _app_data; }
|
||||||
|
void set_app_data(void* v) { _app_data = v; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TPrimanota_application();
|
TPrimanota_application();
|
||||||
};
|
};
|
||||||
|
220
cg/cg2104.cpp
Executable file
220
cg/cg2104.cpp
Executable file
@ -0,0 +1,220 @@
|
|||||||
|
// --------------------------------------------------------------------------
|
||||||
|
// Scadenzario
|
||||||
|
// fv 24/8/94
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "cg2102.h"
|
||||||
|
#include "cg2100.h"
|
||||||
|
#include "cg2104a.h"
|
||||||
|
#include "pagament.h"
|
||||||
|
|
||||||
|
struct shuttle {
|
||||||
|
Pagamento* _pag; // pagamento
|
||||||
|
TSheet_field* _sheet; // sheet
|
||||||
|
TMask* _mask; // maschera
|
||||||
|
TArray* _rows; // righe spreadsheet nella versione originale
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||||
|
{
|
||||||
|
// questo e' il bello
|
||||||
|
|
||||||
|
shuttle* sh = (shuttle*)(((TPrimanota_application*)MainApp())->get_app_data());
|
||||||
|
|
||||||
|
Pagamento* pag = sh->_pag;
|
||||||
|
TSheet_field* ps = sh->_sheet;
|
||||||
|
TMask* msk = sh->_mask;
|
||||||
|
TArray* rws = sh->_rows;
|
||||||
|
|
||||||
|
int rdiff = atoi(msk->get(F_RDIFFER));
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
bool recalc = msk->get_bool(F_RECALC);
|
||||||
|
bool mcomm = msk->get_bool(F_MCOMM);
|
||||||
|
|
||||||
|
switch (k)
|
||||||
|
{
|
||||||
|
case K_SPACE:
|
||||||
|
break;
|
||||||
|
case K_ENTER:
|
||||||
|
ns = ps->row(r);
|
||||||
|
ts = (TToken_string&)(*rws)[r];
|
||||||
|
|
||||||
|
news = ns.get(0);
|
||||||
|
newp = ns.get(1);
|
||||||
|
newi = ns.get(2);
|
||||||
|
newt = ns.get(3);
|
||||||
|
|
||||||
|
// qui viene il bello, si fa per dire
|
||||||
|
if (strcmp(ts.get(0),news) != 0) // modificata data scadenza
|
||||||
|
{
|
||||||
|
mod = m_scad = TRUE;
|
||||||
|
}
|
||||||
|
if (strcmp(ts.get(1),newp) != 0) // modificata percentuale
|
||||||
|
{
|
||||||
|
mod = m_perc = TRUE;
|
||||||
|
}
|
||||||
|
if (strcmp(ts.get(2),newi) != 0) // modificato importo
|
||||||
|
{
|
||||||
|
if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato
|
||||||
|
{
|
||||||
|
mod = m_imp = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strcmp(ts.get(3),newt) != 0) // modificato tipo pagamento
|
||||||
|
{
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
// see if rdiff changed
|
||||||
|
msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
|
||||||
|
}
|
||||||
|
if (!recalc)
|
||||||
|
{
|
||||||
|
ahiahi = P_OK;
|
||||||
|
// put data as they are
|
||||||
|
TToken_string& trw = pag->rata(r);
|
||||||
|
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
|
||||||
|
if ((ahiahi = pag->validate()) != P_OK)
|
||||||
|
pag->rata(r) = srw;
|
||||||
|
}
|
||||||
|
if (ahiahi) // any error?
|
||||||
|
// rimetti le righe com'erano prima
|
||||||
|
{
|
||||||
|
beep();
|
||||||
|
|
||||||
|
// se gli errori sono voluti, spiegali
|
||||||
|
if (!recalc)
|
||||||
|
{
|
||||||
|
TString s(256);
|
||||||
|
pag->strerr(ahiahi,s);
|
||||||
|
warning_box(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
ps->row(r) = (TToken_string&)(*rws)[r];
|
||||||
|
ps->force_update(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (recalc && mod && need_recalc)
|
||||||
|
{
|
||||||
|
// ridefinisci lo sheet sulla base delle nuove rate
|
||||||
|
pag->set_sheet(*ps);
|
||||||
|
ps->force_update(-1);
|
||||||
|
rws->destroy();
|
||||||
|
(*rws) = ps->rows_array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return doit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||||
|
{
|
||||||
|
real imponibile(0.0);
|
||||||
|
real imposta(0.0);
|
||||||
|
real spese(0.0);
|
||||||
|
TString dt(m.get(F_DATAREG));
|
||||||
|
Pagamento pag(m.get(F_CODPAG), (const char*)dt);
|
||||||
|
|
||||||
|
if (pag.is_new()) return;
|
||||||
|
|
||||||
|
TMask ms("cg2104a");
|
||||||
|
TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET);
|
||||||
|
ps.set_notify(pag_notify);
|
||||||
|
|
||||||
|
ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2");
|
||||||
|
ms.field(F_NAMEPAG).set(pag.name());
|
||||||
|
ms.field(F_TIPOPR).set(pag.desc_tpr());
|
||||||
|
ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : "");
|
||||||
|
|
||||||
|
TSheet_field& iva_sh = ivas();
|
||||||
|
|
||||||
|
for (int i = 0; i < iva_sh.items(); i++)
|
||||||
|
{
|
||||||
|
TToken_string& tt = iva_sh.row(i);
|
||||||
|
real mpo(tt.get(0));
|
||||||
|
real imp(tt.get(3));
|
||||||
|
imponibile += mpo;
|
||||||
|
imposta += imp;
|
||||||
|
// TBI: le spese che cazzo sono?
|
||||||
|
// -----------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.field(F_IMPONIBILE).set(imponibile.string());
|
||||||
|
ms.field(F_IMPOSTA).set(imposta.string());
|
||||||
|
ms.field(F_SPESE).set(spese.string());
|
||||||
|
ms.field(F_RECALC).set("X");
|
||||||
|
|
||||||
|
pag.set_total(imponibile, imposta, spese);
|
||||||
|
|
||||||
|
// TBI TBI TBI TBI TBI TBI TBI TBI TBI
|
||||||
|
// controllare se c'e' una rateazione non standard gia' registrata
|
||||||
|
// in tal caso occorre zappare e settare le rate a mano
|
||||||
|
pag.set_rate_auto();
|
||||||
|
|
||||||
|
// se la prima rata e' fissa non si tocca
|
||||||
|
if (pag.tipo_prima_rata() > 0)
|
||||||
|
{
|
||||||
|
ps.disable_cell(0,0);
|
||||||
|
ps.disable_cell(0,1);
|
||||||
|
ps.disable_cell(0,2);
|
||||||
|
ps.disable_cell(0,3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepara lo sheet
|
||||||
|
pag.set_sheet(ps);
|
||||||
|
TArray rows(ps.rows_array());
|
||||||
|
|
||||||
|
shuttle sh;
|
||||||
|
|
||||||
|
sh._pag = &pag;
|
||||||
|
sh._sheet = &ps;
|
||||||
|
sh._mask = &ms;
|
||||||
|
sh._rows = &rows;
|
||||||
|
|
||||||
|
set_app_data(&sh);
|
||||||
|
ms.run();
|
||||||
|
|
||||||
|
// TBI se modificato riaggiustare i files
|
||||||
|
// chiamando la write del caso
|
||||||
|
// -------------------------------------------------
|
||||||
|
}
|
10
cg/cg2104a.h
Executable file
10
cg/cg2104a.h
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#define F_RATESHEET 101
|
||||||
|
#define F_TOTAL 102
|
||||||
|
#define F_RDIFFER 103
|
||||||
|
#define F_IMPONIBILE 104
|
||||||
|
#define F_IMPOSTA 105
|
||||||
|
#define F_SPESE 106
|
||||||
|
#define F_RECALC 107
|
||||||
|
#define F_NAMEPAG 108
|
||||||
|
#define F_TIPOPR 109
|
||||||
|
#define F_MCOMM 110
|
135
cg/cg2104a.uml
Executable file
135
cg/cg2104a.uml
Executable file
@ -0,0 +1,135 @@
|
|||||||
|
#include "cg2104a.h"
|
||||||
|
|
||||||
|
TOOLBAR "" 0 20 0 2
|
||||||
|
|
||||||
|
#include <toolbar.h>
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
PAGE "Registrazione Scadenze" -1 -1 77 20
|
||||||
|
|
||||||
|
GROUPBOX DLG_NULL 79 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 1 "@bScadenzario"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_IMPONIBILE 14
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 2 "Imponibile "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_IMPOSTA 14
|
||||||
|
BEGIN
|
||||||
|
PROMPT 29 2 "Imposta "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_SPESE 14
|
||||||
|
BEGIN
|
||||||
|
PROMPT 53 2 "Spese "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
RADIOBUTTON F_RDIFFER 31
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "Opzioni ricalcolo rate"
|
||||||
|
ITEM "1|Differenziate"
|
||||||
|
ITEM "2|Uguali"
|
||||||
|
ITEM "3|Uguali dall'ultima modificata"
|
||||||
|
ITEM "4|Uguali finche' possibile"
|
||||||
|
END
|
||||||
|
|
||||||
|
BOOLEAN F_RECALC
|
||||||
|
BEGIN
|
||||||
|
PROMPT 53 5 "Ricalcolo automatico"
|
||||||
|
MESSAGE TRUE ENABLE,F_RDIFFER|ENABLE,F_MCOMM
|
||||||
|
MESSAGE FALSE DISABLE,F_RDIFFER|DISABLE,F_MCOMM
|
||||||
|
END
|
||||||
|
|
||||||
|
BOOLEAN F_MCOMM
|
||||||
|
BEGIN
|
||||||
|
PROMPT 53 6 "Mese commerciale"
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
STRING F_NAMEPAG 27
|
||||||
|
BEGIN
|
||||||
|
PROMPT 36 7 "Pagamento "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_TIPOPR 27
|
||||||
|
BEGIN
|
||||||
|
PROMPT 36 8 "Tipo prima rata "
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
SPREADSHEET F_RATESHEET 80 8
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 10 "Rate"
|
||||||
|
ITEM "Scadenza@10"
|
||||||
|
ITEM "Percentuale@12"
|
||||||
|
ITEM "Importo@15"
|
||||||
|
ITEM "Tipo"
|
||||||
|
ITEM "Pagamento@32"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
ENDMASK
|
||||||
|
|
||||||
|
PAGE "Rata pagamento" -1 -1 50 7
|
||||||
|
|
||||||
|
DATE 101
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 2 "Scadenza "
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER 102 3 0
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 3 "Percentuale "
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER 103 15 0
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "Importo "
|
||||||
|
END
|
||||||
|
|
||||||
|
NUMBER 104 2 0
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 5 "Tipo pagamento "
|
||||||
|
HELP ""
|
||||||
|
SHEET "Codice|Tipo pagamento@32"
|
||||||
|
INPUT 104
|
||||||
|
OUTPUT 104
|
||||||
|
OUTPUT 105
|
||||||
|
ITEM "1|Rimessa diretta o contanti"
|
||||||
|
ITEM "2|Tratta"
|
||||||
|
ITEM "3|Ricevuta Bancaria"
|
||||||
|
ITEM "4|Cessione"
|
||||||
|
ITEM "5|Paghero'"
|
||||||
|
ITEM "6|Lettera di credito"
|
||||||
|
ITEM "7|Tratta accettata"
|
||||||
|
ITEM "8|Altro pagamento"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING 105 36
|
||||||
|
BEGIN
|
||||||
|
PROMPT 22 6 ""
|
||||||
|
FLAGS "D"
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_CANCEL 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -12 -1 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_OK 10 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT -22 -1 ""
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
ENDMASK
|
906
cg/pagament.cpp
Executable file
906
cg/pagament.cpp
Executable file
@ -0,0 +1,906 @@
|
|||||||
|
#include "pagament.h"
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
|
int Pagamento::_rata_ifield(int n, int f) const
|
||||||
|
{
|
||||||
|
TToken_string& t = (TToken_string&)_rate[n];
|
||||||
|
return t.get_int(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
real Pagamento::_rata_rfield(int n, int f) const
|
||||||
|
{
|
||||||
|
TToken_string& t = (TToken_string&)_rate[n];
|
||||||
|
return real(t.get(f));
|
||||||
|
}
|
||||||
|
|
||||||
|
TDate Pagamento::_rata_dfield(int n, int f) const
|
||||||
|
{
|
||||||
|
TToken_string& t = (TToken_string&)_rate[n];
|
||||||
|
return TDate(t.get(f));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Pagamento::_rata_sfield(int n, int f) const
|
||||||
|
{
|
||||||
|
static char kak[6];
|
||||||
|
TToken_string& t = (TToken_string&)_rate[n];
|
||||||
|
strcpy(kak,t.get(f));
|
||||||
|
return kak;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::set_intervallo_rate(int in)
|
||||||
|
{
|
||||||
|
_dirty = TRUE;
|
||||||
|
if (_mcomm && (in % 30) != 0)
|
||||||
|
_mcomm = FALSE;
|
||||||
|
for (int i = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
TToken_string& ts = rata(i);
|
||||||
|
ts.add(i == 0 ? "0" : format("%d",in), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_mese_commerciale(bool v, int& sscad)
|
||||||
|
{
|
||||||
|
_dirty = FALSE;
|
||||||
|
if (_mcomm == v) return;
|
||||||
|
if (sscad == -1) sscad = 30;
|
||||||
|
|
||||||
|
if ((sscad % 30) != 0) sscad = 30 * ((sscad/30)+1);
|
||||||
|
set_intervallo_rate(sscad);
|
||||||
|
|
||||||
|
_mcomm = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_rate_differenziate(int v)
|
||||||
|
{
|
||||||
|
_dirty = FALSE;
|
||||||
|
if (!_rdiff && v == 2) return;
|
||||||
|
|
||||||
|
if (v == 2 && (100 % n_rate()) == 0)
|
||||||
|
{
|
||||||
|
int p = 100 / n_rate();
|
||||||
|
for (int i = _tpr == 0 ? 0 : 1; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(i);
|
||||||
|
tt.add(p,1);
|
||||||
|
}
|
||||||
|
_rdiff = !(v == 2);
|
||||||
|
_dirty = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_tipo_prima_rata(int v, int sscad)
|
||||||
|
{
|
||||||
|
_dirty = FALSE;
|
||||||
|
if (_tpr == v) return;
|
||||||
|
|
||||||
|
if (v == 0 && _tpr > 0)
|
||||||
|
{
|
||||||
|
for (int i = n_rate() - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(i);
|
||||||
|
tt.add(scad_rata(i-1),0);
|
||||||
|
tt.add(tipo_rata(i-1),2);
|
||||||
|
tt.add(ulc_rata(i-1),5);
|
||||||
|
}
|
||||||
|
_rate.add(NULL,0);
|
||||||
|
_rate.pack();
|
||||||
|
}
|
||||||
|
else if ( _tpr == 0 && v > 0)
|
||||||
|
{
|
||||||
|
TToken_string* ttn = new TToken_string(32);
|
||||||
|
ttn->add(0,0);
|
||||||
|
ttn->add(0,1);
|
||||||
|
ttn->add(1,2);
|
||||||
|
ttn->add("",3);
|
||||||
|
ttn->add("",4);
|
||||||
|
ttn->add("",5);
|
||||||
|
_rate.insert(ttn,0);
|
||||||
|
for (int i = 0; i < (n_rate()-1); i++)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(i);
|
||||||
|
{
|
||||||
|
tt.add(scad_rata(i+1),0);
|
||||||
|
tt.add(tipo_rata(i+1),2);
|
||||||
|
tt.add(ulc_rata(i+1),5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tpr = v;
|
||||||
|
_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_numero_rate(int n, int sscad)
|
||||||
|
{
|
||||||
|
_dirty = FALSE;
|
||||||
|
if (n == 0 || n == n_rate()) return;
|
||||||
|
|
||||||
|
int p = 100 / n;
|
||||||
|
int nr = n_rate();
|
||||||
|
int first = _tpr == 0 ? 0 : 1;
|
||||||
|
|
||||||
|
for (int i = first, sum = 0; sum < 100; i++)
|
||||||
|
{
|
||||||
|
if ((100 - sum) < p) p = 100 - sum;
|
||||||
|
sum += p;
|
||||||
|
|
||||||
|
set_rata(i, real(p),
|
||||||
|
i == 0 ? 0 :
|
||||||
|
(sscad == -1 ? (i < nr ? scad_rata(i) : scad_rata(nr-1)) : sscad),
|
||||||
|
(i < nr ? tipo_rata(i) : tipo_rata(nr-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::next_scad(TDate& d, int scad, bool mcomm, int rata)
|
||||||
|
{
|
||||||
|
if (mcomm)
|
||||||
|
{
|
||||||
|
int nm = scad / 30;
|
||||||
|
int ny = nm / 12;
|
||||||
|
nm %= 12;
|
||||||
|
|
||||||
|
int newm = d.month() + nm;
|
||||||
|
if (newm > 12) { newm -= 12; ny++; }
|
||||||
|
|
||||||
|
bool last = d.is_end_month() && inizio_scadenza() == 'M';
|
||||||
|
|
||||||
|
int dy = d.day();
|
||||||
|
|
||||||
|
// la palla del febbraio & c.
|
||||||
|
if (rata > 1)
|
||||||
|
{
|
||||||
|
TDate oldd(data_rata(rata-2));
|
||||||
|
if (oldd.day() > dy) dy = oldd.day();
|
||||||
|
}
|
||||||
|
|
||||||
|
d.set_day(1); // il giorno 1 ce l'hanno tutti
|
||||||
|
d.set_month(newm);
|
||||||
|
d.set_year(d.year()+ny);
|
||||||
|
|
||||||
|
d.set_end_month();
|
||||||
|
if (!last && dy < d.day()) d.set_day(dy);
|
||||||
|
}
|
||||||
|
else d += scad;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::remove_rata(int i)
|
||||||
|
{
|
||||||
|
// non fa nessun ricalcolo, si limita ad impacchettare se
|
||||||
|
// necessario
|
||||||
|
_rate.add(NULL,i);
|
||||||
|
_rate.pack();
|
||||||
|
_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TToken_string& Pagamento::add_rata(real perc, int day, int type)
|
||||||
|
{
|
||||||
|
TToken_string* tt = new TToken_string(16);
|
||||||
|
tt->add(day); // scadenza
|
||||||
|
tt->add(perc.string()); // percentuale
|
||||||
|
tt->add(type); // tipo
|
||||||
|
|
||||||
|
_rate.add(tt);
|
||||||
|
_dirty = TRUE;
|
||||||
|
return *tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
TToken_string& Pagamento::set_rata (int index, real perc, int day, int type,
|
||||||
|
const char* ulc, const char* imp,
|
||||||
|
const char* data)
|
||||||
|
{
|
||||||
|
bool nwr = FALSE;
|
||||||
|
TToken_string* tt = (TToken_string*)_rate.objptr(index);
|
||||||
|
if (nwr = (tt == NULL)) tt = new TToken_string(16);
|
||||||
|
tt->add(day,0); // scadenza
|
||||||
|
tt->add(perc.string(),1); // percentuale
|
||||||
|
tt->add(type,2); // tipo
|
||||||
|
tt->add(data == NULL ? "" : data,3);
|
||||||
|
tt->add(imp == NULL ? "" : imp,4);
|
||||||
|
tt->add(ulc == NULL ? "" : ulc,5);
|
||||||
|
|
||||||
|
if (!nwr)
|
||||||
|
{
|
||||||
|
if (index > _rate.items())
|
||||||
|
{
|
||||||
|
error_box("Rate non contigue");
|
||||||
|
delete tt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_rate.add(tt,index);
|
||||||
|
_dirty = TRUE;
|
||||||
|
}
|
||||||
|
return *tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_imprata(int i, real r)
|
||||||
|
{
|
||||||
|
TToken_string& tt = (TToken_string&)_rate[i];
|
||||||
|
TDate d = _inizio;
|
||||||
|
|
||||||
|
for (int n = 0; n <= i; n++)
|
||||||
|
next_scad(d, scad_rata(n), _mcomm, n);
|
||||||
|
|
||||||
|
tt.add((const char*)d, 3);
|
||||||
|
tt.add(r.string(), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
word Pagamento::validate() const
|
||||||
|
{
|
||||||
|
word res = 0x0000;
|
||||||
|
real r(0.0);
|
||||||
|
|
||||||
|
int first = _tpr == 0 ? 0 : 1;
|
||||||
|
real toshare(_tpr == 0 ? _firstr : _secndr);
|
||||||
|
TDistrib ds(toshare,0);
|
||||||
|
|
||||||
|
// check percentages & prepare slicer
|
||||||
|
for (int i = first; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
real p(perc_rata(i));
|
||||||
|
ds.add(p);
|
||||||
|
r += p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r != real(100.0))
|
||||||
|
res |= P_RSUM;
|
||||||
|
|
||||||
|
|
||||||
|
if (_inited)
|
||||||
|
{
|
||||||
|
ds.init(toshare);
|
||||||
|
// check importi rate consistenti con la percentuale
|
||||||
|
for (int i = first; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
real r1(tpay_rata(i));
|
||||||
|
real r2(ds.get());
|
||||||
|
if (r1 != r2)
|
||||||
|
{ res |= P_IMPNC; break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// check errori date scadenze (se istanziate)
|
||||||
|
TDate d(data_rata(0));
|
||||||
|
if (d < _inizio)
|
||||||
|
res |= P_INIZIO;
|
||||||
|
for (i = 1; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
if (data_rata(i) <= d)
|
||||||
|
{ res |= P_SCAD; break; }
|
||||||
|
d = data_rata(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::strerr(word err, TString& s)
|
||||||
|
{
|
||||||
|
s = "Errore:";
|
||||||
|
if (err & P_RSUM)
|
||||||
|
s << "\n Le percentuali non sommano a 100";
|
||||||
|
if (err & P_IMPNC)
|
||||||
|
s << "\n Le percentuali sono inconsistenti con gli importi";
|
||||||
|
if (err & P_SCAD)
|
||||||
|
s << "\n Le scadenze non sono consecutive";
|
||||||
|
if (err & P_INIZIO)
|
||||||
|
s << "\n La prima rata e' antecedente alla data movimento";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Pagamento::desc_tpr() const
|
||||||
|
{
|
||||||
|
const char* o;
|
||||||
|
switch (_tpr)
|
||||||
|
{
|
||||||
|
case 0: o = "Totale su tutte le rate"; break;
|
||||||
|
case 1: o = "Tutte le imposte su 1a"; break;
|
||||||
|
case 2: o = "Tutte le spese su 1a"; break;
|
||||||
|
case 3: o = "Imposte + spese su 1a"; break;
|
||||||
|
case 4: o = "Spese + merce su 1a"; break;
|
||||||
|
case 5: o = "Merce + imposte su 1a"; break;
|
||||||
|
case 6: o = "Tutta la merce su 1a"; break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Pagamento::desc_tipo(int i) const
|
||||||
|
{
|
||||||
|
const char* o;
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 1: o = "Rimessa diretta / contanti"; break;
|
||||||
|
case 2: o = "Tratta"; break;
|
||||||
|
case 3: o = "Ricevuta bancaria"; break;
|
||||||
|
case 4: o = "Cessione"; break;
|
||||||
|
case 5: o = "Paghero'"; break;
|
||||||
|
case 6: o = "Lettera di credito"; break;
|
||||||
|
case 7: o = "Tratta accettata"; break;
|
||||||
|
case 8: o = "Altro pagamento"; break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
word Pagamento::recalc_rate(int row, bool is_perc_modified,
|
||||||
|
const char* new_value, const char* scad,
|
||||||
|
const char* typ, int rdiff, bool mcomm,
|
||||||
|
bool& need_recalc)
|
||||||
|
// ricalcola le rate sulla base di parametri modificati sulla riga row
|
||||||
|
// parametri: tutti i const char* possono essere NULL, il che vuol dire
|
||||||
|
// che i dati corrispondenti non sono stati modificati;
|
||||||
|
// se new_value non e' NULL puo' essere la percentuale (e
|
||||||
|
// allora is_perc_modified e' TRUE) o l'importo. Non e'
|
||||||
|
// possibile modificare entrambi; se succede viene data
|
||||||
|
// priorita' alla percentuale.
|
||||||
|
{
|
||||||
|
CHECK(!(!is_perc_modified && new_value != NULL && !_inited),
|
||||||
|
"A'stronzo! E famme 'na pippa! Me dai n'importo che nun ce sta? Ma Vaffanculo!");
|
||||||
|
|
||||||
|
if (_rate.items() == 0) return P_OK;
|
||||||
|
|
||||||
|
real rsum(0.0), newv(0.0), rmax(0.0);
|
||||||
|
int oldtype = tipo_rata(0);
|
||||||
|
int oldscad = scad_rata(0);
|
||||||
|
TDate lastdate = data_rata(0);
|
||||||
|
int first = _tpr == 0 ? 0 : 1;
|
||||||
|
TArray srate(_rate); // rate come erano
|
||||||
|
|
||||||
|
|
||||||
|
if (srate.items() > 1)
|
||||||
|
{
|
||||||
|
// calcola defaults per tipo pagamento e scadenza
|
||||||
|
// nel caso di rate nuove
|
||||||
|
oldscad = scad_rata(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldscad == 0) oldscad = 30;
|
||||||
|
if (oldtype == 0) oldtype = 1;
|
||||||
|
|
||||||
|
if (new_value != NULL)
|
||||||
|
{
|
||||||
|
newv = new_value;
|
||||||
|
rmax = is_perc_modified? real(100.0) : (_tpr == 0 ? _firstr : _secndr);
|
||||||
|
if (newv > rmax) return P_RSUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool exhausted = FALSE;
|
||||||
|
|
||||||
|
for (int i = first; i < srate.items(); i++)
|
||||||
|
{
|
||||||
|
if (i == row)
|
||||||
|
{
|
||||||
|
if (typ != NULL)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(row);
|
||||||
|
TToken_string& ss = (TToken_string&)srate[row];
|
||||||
|
tt.add(typ,2);
|
||||||
|
ss.add(typ,2);
|
||||||
|
// no error is possible
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scad != NULL)
|
||||||
|
{
|
||||||
|
// if !_inited scad e' il n. giorni, se no e' la rata
|
||||||
|
if (_inited)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(row);
|
||||||
|
TToken_string& ss = (TToken_string&)srate[row];
|
||||||
|
lastdate = scad;
|
||||||
|
// controlla errore sulla data scadenza
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
oldscad = (int)(lastdate - data_rata(i-1));
|
||||||
|
if (oldscad <= 0l) return P_SCAD;
|
||||||
|
}
|
||||||
|
else if (lastdate < _inizio) return P_INIZIO;
|
||||||
|
tt.add(scad,3);
|
||||||
|
ss.add(scad,3);
|
||||||
|
// ricalcola rate successive: se si vuole modificarne solo una
|
||||||
|
// ci si fotte e si disabilita il ricalcolo
|
||||||
|
TDate ddd (lastdate);
|
||||||
|
for (int j = row+1; j < srate.items(); j++)
|
||||||
|
{
|
||||||
|
TToken_string& tt = rata(j);
|
||||||
|
TToken_string& ss = (TToken_string&)srate[j];
|
||||||
|
next_scad(ddd,scad_rata(j),mcomm,j);
|
||||||
|
tt.add(ddd.string(),3);
|
||||||
|
ss.add(ddd.string(),3);
|
||||||
|
need_recalc = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// nulla di speciale visto che si memorizza la derivata
|
||||||
|
int sc = atoi(scad);
|
||||||
|
if (sc <= 0) return P_SCAD;
|
||||||
|
if (_mcomm && (sc % 30) != 0) _mcomm = FALSE;
|
||||||
|
TToken_string& tt = rata(row);
|
||||||
|
TToken_string& ss = (TToken_string&)srate[row];
|
||||||
|
tt.add(0,sc);
|
||||||
|
ss.add(1,sc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// here's the bell
|
||||||
|
if (new_value != NULL)
|
||||||
|
{
|
||||||
|
if (newv == ZERO || (rsum+newv) > rmax)
|
||||||
|
return P_RSUM;
|
||||||
|
// did not sforate
|
||||||
|
rsum += newv;
|
||||||
|
TToken_string& rt = rata(row);
|
||||||
|
// setta nuovo valore e ricalcola cio' che ne consegue
|
||||||
|
if (is_perc_modified) rt.add(new_value,1);
|
||||||
|
else rt.add(new_value,4);
|
||||||
|
// riaggiusta le rate rimanenti
|
||||||
|
real remainder(0.0); remainder = rmax - rsum;
|
||||||
|
if (!(exhausted = (remainder == real(0.0))))
|
||||||
|
{
|
||||||
|
// controlla se rdiff e' compatibile con
|
||||||
|
// i dati e se e' il caso riaggiusta
|
||||||
|
if (rdiff == 3 && !((remainder % newv.integer()) == ZERO))
|
||||||
|
rdiff = 2;
|
||||||
|
if (rdiff == 2 && !((rmax % newv.integer()) == ZERO))
|
||||||
|
rdiff = 1;
|
||||||
|
_rdiff = (rdiff == 1 || rdiff == 3 || rdiff == 4);
|
||||||
|
|
||||||
|
// procedi
|
||||||
|
if (rdiff == 1)
|
||||||
|
{
|
||||||
|
// cancella tutte le rate successive, aggiungi un'unica rata
|
||||||
|
// con il resto dell'importo
|
||||||
|
if (row < (srate.items()-1))
|
||||||
|
{
|
||||||
|
TToken_string& trt = rata(row+1);
|
||||||
|
trt.add(remainder.string(), is_perc_modified ? 1 : 4);
|
||||||
|
for(int j = row+2; j < srate.items(); j++)
|
||||||
|
_rate.add(NULL,j);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// l'importante e' esagerare
|
||||||
|
for(int j = row+1; j < srate.items(); j++)
|
||||||
|
_rate.add(NULL,j);
|
||||||
|
|
||||||
|
TToken_string& trt = add_rata(is_perc_modified? remainder : real(0.0),
|
||||||
|
oldscad, oldtype);
|
||||||
|
if (!is_perc_modified) trt.add(remainder.string(),4);
|
||||||
|
if (_inited)
|
||||||
|
{
|
||||||
|
TDate dd = data_rata(row);
|
||||||
|
next_scad(dd,oldscad,mcomm,row);
|
||||||
|
trt.add(dd.string(),3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // rate non differenziate (dall'inizio o da row)
|
||||||
|
{
|
||||||
|
// ripartisci l'importo nel numero necessario di rate per
|
||||||
|
// mantenere costante il valore
|
||||||
|
real sum(0.0);
|
||||||
|
if (_inited) lastdate = data_rata(rdiff == 2 ? first : row);
|
||||||
|
|
||||||
|
TDate dd(lastdate);
|
||||||
|
int type = oldtype;
|
||||||
|
int nscd = oldscad;
|
||||||
|
|
||||||
|
int frs = (rdiff == 3 || rdiff == 4) ? row+1 : first;
|
||||||
|
real mx = (rdiff == 3 || rdiff == 4) ? remainder : rmax;
|
||||||
|
|
||||||
|
// cancelliamo tutto, va'
|
||||||
|
for (int j = frs; j < srate.items(); j++)
|
||||||
|
_rate.add(NULL,j);
|
||||||
|
|
||||||
|
if (rdiff != 4)
|
||||||
|
for (j = frs; sum < mx; j++)
|
||||||
|
{
|
||||||
|
// se c'e' la vecchia rata si tengono i parametri
|
||||||
|
// altrimenti si calcolano
|
||||||
|
if (j < srate.items())
|
||||||
|
{
|
||||||
|
TToken_string& trt = (TToken_string&)srate[j];
|
||||||
|
if (_inited) dd = trt.get(3);
|
||||||
|
type = atoi(trt.get(2));
|
||||||
|
nscd = j == 0 ? 0 : atoi(trt.get(0));
|
||||||
|
if (type == 0) type = 1;
|
||||||
|
if (j > 0 && nscd == 0) nscd = oldscad;
|
||||||
|
if (_inited && dd == lastdate && j > 0)
|
||||||
|
next_scad(dd,nscd,mcomm,j);
|
||||||
|
}
|
||||||
|
else if (_inited)
|
||||||
|
{
|
||||||
|
if (dd <= botime) dd = lastdate;
|
||||||
|
next_scad(dd,nscd,mcomm,j);
|
||||||
|
}
|
||||||
|
|
||||||
|
TToken_string& ttr = set_rata(j, is_perc_modified ? newv : ZERO,
|
||||||
|
nscd, type);
|
||||||
|
if (_inited)
|
||||||
|
ttr.add(dd.string(), 3);
|
||||||
|
if (!is_perc_modified)
|
||||||
|
ttr.add(newv.string(),4);
|
||||||
|
sum += newv;
|
||||||
|
}
|
||||||
|
else // rdiff == 4; uguali finche' possibile
|
||||||
|
{
|
||||||
|
bool basta = FALSE;
|
||||||
|
for (j = frs; ; j++)
|
||||||
|
{
|
||||||
|
// ultima rata puo' differire dalle precedenti
|
||||||
|
if (mx - sum <= newv)
|
||||||
|
{
|
||||||
|
newv = mx - sum;
|
||||||
|
basta = TRUE;
|
||||||
|
}
|
||||||
|
// se c'e' la vecchia rata si tengono i parametri
|
||||||
|
// altrimenti si calcolano
|
||||||
|
if (j < srate.items())
|
||||||
|
{
|
||||||
|
TToken_string& trt = (TToken_string&)srate[j];
|
||||||
|
if (_inited) dd = trt.get(3);
|
||||||
|
type = atoi(trt.get(2));
|
||||||
|
nscd = j == 0 ? 0 : atoi(trt.get(0));
|
||||||
|
if (type == 0) type = 1;
|
||||||
|
if (j > 0 && nscd == 0) nscd = oldscad;
|
||||||
|
if (_inited && dd == lastdate && j > 0)
|
||||||
|
next_scad(dd,nscd,mcomm,j);
|
||||||
|
}
|
||||||
|
else if (_inited) next_scad(dd,nscd,mcomm,j);
|
||||||
|
|
||||||
|
TToken_string& ttr = set_rata(j, is_perc_modified ? newv : ZERO,
|
||||||
|
nscd, type);
|
||||||
|
if (_inited)
|
||||||
|
ttr.add(dd.string(), 3);
|
||||||
|
if (!is_perc_modified)
|
||||||
|
ttr.add(newv.string(),4);
|
||||||
|
if (basta) break;
|
||||||
|
sum += newv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else // exhausted
|
||||||
|
{
|
||||||
|
for(int j = row+1; j < srate.items(); j++)
|
||||||
|
_rate.add(NULL,j);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_inited)
|
||||||
|
{
|
||||||
|
// ricalcola il valore secondario (non modificato)
|
||||||
|
real toshare(100.0);
|
||||||
|
if (is_perc_modified)
|
||||||
|
toshare = (_tpr == 0 ? _firstr : _secndr);
|
||||||
|
TDistrib dt(toshare,0);
|
||||||
|
|
||||||
|
for (int j = first; j < _rate.items(); j++)
|
||||||
|
{
|
||||||
|
real rvl = is_perc_modified ? perc_rata(j) : tpay_rata(j);
|
||||||
|
real zpx = rvl/rmax; // percentuale
|
||||||
|
dt.add(zpx);
|
||||||
|
}
|
||||||
|
for (j = first; j < _rate.items(); j++)
|
||||||
|
{
|
||||||
|
TToken_string& tr = rata(j);
|
||||||
|
real rvl = dt.get();
|
||||||
|
tr.add(rvl.string(), is_perc_modified ? 4 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
need_recalc = TRUE;
|
||||||
|
return P_OK;
|
||||||
|
} // new_value != NULL
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else // i != row modified
|
||||||
|
{
|
||||||
|
if (i > 0 && !((perc_rata(i-1) == perc_rata(i))))
|
||||||
|
{
|
||||||
|
if (rdiff == 2) rdiff = 1;
|
||||||
|
_rdiff = FALSE;
|
||||||
|
}
|
||||||
|
rsum += is_perc_modified ? perc_rata(i) : tpay_rata(i);
|
||||||
|
|
||||||
|
lastdate = data_rata(i);
|
||||||
|
oldtype = tipo_rata(i);
|
||||||
|
oldscad = scad_rata(i);
|
||||||
|
if (_inited && i > 0)
|
||||||
|
{
|
||||||
|
if (data_rata(i) <= data_rata(i-1))
|
||||||
|
return P_SCAD;
|
||||||
|
}
|
||||||
|
else if (lastdate < _inizio)
|
||||||
|
return P_INIZIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return P_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Pagamento::read(TTable* t, TTable* r)
|
||||||
|
{
|
||||||
|
// puo' chiamarla chiunque
|
||||||
|
bool istnew = FALSE;
|
||||||
|
if (t == NULL)
|
||||||
|
{
|
||||||
|
t = new TTable("%CPG");
|
||||||
|
istnew = TRUE;
|
||||||
|
}
|
||||||
|
t->zero(); t->put("CODTAB",_code);
|
||||||
|
t->read(); if (t->eof()) return FALSE;
|
||||||
|
|
||||||
|
// set everything
|
||||||
|
_rdiff = t->get_bool("B1");
|
||||||
|
_mcomm = t->get_bool("B0");
|
||||||
|
_tpr = *((const char*)(t->get("S3")));
|
||||||
|
_inscad = *((const char*)(t->get("S1")));
|
||||||
|
_code = t->get("CODTAB");
|
||||||
|
_name = t->get("S0");
|
||||||
|
|
||||||
|
// TBI aggiusta _inizio secondo INSCAD; vedi mese commerciale etc.
|
||||||
|
if (_inscad == 'M')
|
||||||
|
{
|
||||||
|
if (_mcomm) _inizio.set_month(_inizio.month() == 2 ? 28 : 30);
|
||||||
|
else _inizio.set_end_month();
|
||||||
|
}
|
||||||
|
else if (_inscad == 'F' && _mcomm && _inizio.month() == 31)
|
||||||
|
_inizio.set_month(30);
|
||||||
|
|
||||||
|
// leggi rate e scadenze
|
||||||
|
bool isrnew = FALSE;
|
||||||
|
if (r == NULL)
|
||||||
|
{
|
||||||
|
r = new TTable("%RPG");
|
||||||
|
isrnew = TRUE;
|
||||||
|
}
|
||||||
|
TString s(16);
|
||||||
|
|
||||||
|
for (int i = 0; ;i++)
|
||||||
|
{
|
||||||
|
r->zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r->put("CODTAB", (const char*)s);
|
||||||
|
if (r->read() != NOERR) break;
|
||||||
|
TToken_string* tt = new TToken_string(16);
|
||||||
|
tt->add((const char*)(r->get("I0"))); // scadenza
|
||||||
|
tt->add((const char*)(r->get("R0"))); // percentuale
|
||||||
|
tt->add((const char*)(r->get("I1"))); // tipo
|
||||||
|
// data e importo
|
||||||
|
TDate d = _inizio;
|
||||||
|
next_scad(d,(int)(r->get_long("I0")),_mcomm,i);
|
||||||
|
tt->add((const char*)d);
|
||||||
|
tt->add("");
|
||||||
|
tt->add(r->get("S1"));
|
||||||
|
_slicer.add(real(r->get("R0")));
|
||||||
|
_rate.add(tt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (istnew) delete t;
|
||||||
|
if (isrnew) delete r;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Pagamento::write(TTable& r)
|
||||||
|
{
|
||||||
|
// Scrive soltanto le righe di pagamento; si assume sia stata chiamata da una
|
||||||
|
// relapp, che ha scritto il file principale
|
||||||
|
|
||||||
|
TString s(16); bool ok = TRUE;
|
||||||
|
for (int i = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r.put("CODTAB", (const char*)s);
|
||||||
|
r.put("I0", (long)scad_rata(i));
|
||||||
|
r.put("R0", perc_rata(i).string());
|
||||||
|
r.put("I1", (long)tipo_rata(i));
|
||||||
|
r.put("S1", ulc_rata(i));
|
||||||
|
ok &= (r.write() == NOERR);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Pagamento::rewrite(TTable& r)
|
||||||
|
{
|
||||||
|
TString s(16); bool ok = TRUE;
|
||||||
|
for (int i = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r.put("CODTAB", (const char*)s);
|
||||||
|
bool was = (r.read() == NOERR);
|
||||||
|
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r.put("CODTAB", (const char*)s);
|
||||||
|
r.put("I0", (long)scad_rata(i));
|
||||||
|
r.put("R0", perc_rata(i).string());
|
||||||
|
r.put("I1", (long)tipo_rata(i));
|
||||||
|
r.put("S1", ulc_rata(i));
|
||||||
|
ok &= ((was ? r.rewrite : r.write()) == NOERR);
|
||||||
|
}
|
||||||
|
// erase possible rates > current n. rates
|
||||||
|
for (;;i++)
|
||||||
|
{
|
||||||
|
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r.put("CODTAB", (const char*)s);
|
||||||
|
if (r.read() == NOERR) r.remove();
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::remove(TTable& r)
|
||||||
|
{
|
||||||
|
TString s(16);
|
||||||
|
for (int i = 0 ; ; i++)
|
||||||
|
{
|
||||||
|
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||||
|
r.put("CODTAB", (const char*)s);
|
||||||
|
if (r.read() == NOERR) r.remove();
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pagamento::set_rate_auto()
|
||||||
|
{
|
||||||
|
// vedi rate esistenti e tipo prima rata
|
||||||
|
// deve fare riferimento ad un tipo pagamento esistente
|
||||||
|
// e sensato
|
||||||
|
int first = 0;
|
||||||
|
|
||||||
|
real toslice = _firstr;
|
||||||
|
|
||||||
|
if (n_rate() == 0 || !_inited || (_tpr > 0 && n_rate() == 1)) return;
|
||||||
|
if (_tpr > 1) // ripartisci _firstr su tutte le rate
|
||||||
|
{
|
||||||
|
first = 1;
|
||||||
|
toslice = _secndr;
|
||||||
|
}
|
||||||
|
|
||||||
|
_slicer.init(toslice);
|
||||||
|
|
||||||
|
if (_tpr > 0)
|
||||||
|
// prima rata obbligatoria
|
||||||
|
set_imprata(0, _firstr);
|
||||||
|
|
||||||
|
for (int i = first; i < n_rate(); i++)
|
||||||
|
// setta le fette e le date di scadenza
|
||||||
|
set_imprata(i, _slicer.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::set_total(real& imponibile, real& imposta, real& spese)
|
||||||
|
{
|
||||||
|
_imponibile = imponibile;
|
||||||
|
_imposta = imposta;
|
||||||
|
_spese = spese;
|
||||||
|
_inited = TRUE;
|
||||||
|
|
||||||
|
// istanzia _firstr e _secndr a seconda di _tpr
|
||||||
|
switch(_tpr)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
_firstr = _imponibile + _imposta + _spese;
|
||||||
|
_secndr = 0.0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
_firstr = _imposta;
|
||||||
|
_secndr = _imponibile + _spese;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
_firstr = _spese;
|
||||||
|
_secndr = _imposta + _imponibile;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
_firstr = _imposta + _spese;
|
||||||
|
_secndr = _imponibile;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
_firstr = _spese + _imponibile;
|
||||||
|
_secndr = _imposta;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
_firstr = _imponibile + _imposta;
|
||||||
|
_secndr = _spese;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
_firstr = _imponibile;
|
||||||
|
_secndr = _imposta + _spese;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _rate.items(); i++)
|
||||||
|
{
|
||||||
|
TToken_string& t = (TToken_string&)_rate[i];
|
||||||
|
real rr(t.get(1));
|
||||||
|
_slicer.add(rr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pagamento::set_sheet(TSheet_field& sf, int sscad)
|
||||||
|
{
|
||||||
|
sf.reset();
|
||||||
|
if (_inited && _rate.items() > 0)
|
||||||
|
{
|
||||||
|
// si istanzia uno sheet di primanota
|
||||||
|
for (int i = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
TToken_string* ts = new TToken_string(36);
|
||||||
|
// istanzia, o stronzo
|
||||||
|
ts->add((const char*)data_rata(i));
|
||||||
|
ts->add(perc_rata(i).string());
|
||||||
|
ts->add(tpay_rata(i).string());
|
||||||
|
ts->add(tipo_rata(i));
|
||||||
|
ts->add(desc_tipo(tipo_rata(i)));
|
||||||
|
sf.row(-1) = (*ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_rate.items() > 0) // not inited: set edit sheet
|
||||||
|
{
|
||||||
|
for (int i = 0, scr = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
TToken_string* s = new TToken_string(32);
|
||||||
|
scr += scad_rata(i);
|
||||||
|
s->add(format("%d",scr));
|
||||||
|
s->add(perc_rata(i).string());
|
||||||
|
s->add(format("%d",tipo_rata(i)));
|
||||||
|
s->add(desc_tipo(tipo_rata(i)));
|
||||||
|
s->add(ulc_rata(i));
|
||||||
|
sf.row(-1) = *s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // new: set with 1 or 2 rates according to tpr
|
||||||
|
{
|
||||||
|
if (_tpr > 0)
|
||||||
|
set_rata(0, ZERO, sscad == -1 ? 0 : sscad, 1);
|
||||||
|
set_rata(_tpr == 0 ? 0 : 1, real(100.0), sscad == -1 ? (_tpr == 0 ? 0 :30)
|
||||||
|
: sscad, 1);
|
||||||
|
_dirty = TRUE;
|
||||||
|
|
||||||
|
for (int i = 0, scr = 0; i < n_rate(); i++)
|
||||||
|
{
|
||||||
|
TToken_string* s = new TToken_string(32);
|
||||||
|
scr += scad_rata(i);
|
||||||
|
s->add(format("%d",scr));
|
||||||
|
s->add(perc_rata(i).string());
|
||||||
|
s->add(format("%d",tipo_rata(i)));
|
||||||
|
s->add(desc_tipo(tipo_rata(i)));
|
||||||
|
s->add(ulc_rata(i));
|
||||||
|
sf.row(-1) = *s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_tpr > 0)
|
||||||
|
{
|
||||||
|
// disabilita campi da non toccare sulla prima rata
|
||||||
|
if (_inited)
|
||||||
|
{
|
||||||
|
sf.disable_cell(0,1); // percentuale
|
||||||
|
sf.disable_cell(0,2); // importo
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sf.disable_cell(0,1); // percentuale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sf.force_update();
|
||||||
|
}
|
||||||
|
|
||||||
|
Pagamento::Pagamento(const char* codtab, const char* data) :
|
||||||
|
_slicer(0.0,0), _new(FALSE), _imponibile(0.0), _imposta(0.0),
|
||||||
|
_spese(0.0), _code(codtab), _dirty(FALSE), _inited(FALSE)
|
||||||
|
{
|
||||||
|
if (data != NULL)
|
||||||
|
_inizio = data;
|
||||||
|
if (_code.empty() || !read())
|
||||||
|
_new = TRUE;
|
||||||
|
if (_new && data != NULL) error_box("Modalita' pagamento inesistente");
|
||||||
|
}
|
138
cg/pagament.h
Executable file
138
cg/pagament.h
Executable file
@ -0,0 +1,138 @@
|
|||||||
|
#ifndef __PAGAMENT_H
|
||||||
|
#define __PAGAMENT_H
|
||||||
|
|
||||||
|
#ifndef __REAL_H
|
||||||
|
#include <real.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __STRINGS_H
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DATE_H
|
||||||
|
#include <date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MSKSHEET_H
|
||||||
|
#include <msksheet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __TABUTIL_H
|
||||||
|
#include <tabutil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Error codes for pagation
|
||||||
|
const word P_OK = 0x0000; // ok
|
||||||
|
const word P_RSUM = 0x0001; // percentages do not sum up to 100
|
||||||
|
const word P_IMPNC = 0x0002; // inconsistenza percentuali / importi
|
||||||
|
const word P_SCAD = 0x0004; // scadenze non consecutive
|
||||||
|
const word P_INIZIO = 0x0008; // data 1a rata < data inizio pagamenti
|
||||||
|
|
||||||
|
class Pagamento : public TObject
|
||||||
|
{
|
||||||
|
TString _code; // codice
|
||||||
|
TString _name; // descrizione
|
||||||
|
real _imponibile; // imponibile da affettare
|
||||||
|
real _imposta; // imposta da affettare
|
||||||
|
real _spese; // spese da affettare
|
||||||
|
TDistrib _slicer; // affettatrice
|
||||||
|
bool _new; // non letto da database
|
||||||
|
TArray _rate; // rate medesime
|
||||||
|
char _inscad; // inizio scadenze: S1
|
||||||
|
bool _mcomm; // mese commerciale: B0
|
||||||
|
bool _rdiff; // rate differenziate: B1
|
||||||
|
int _tpr; // tipo prima rata: S3
|
||||||
|
bool _dirty; // modificato (strutturalmente!)
|
||||||
|
TDate _inizio; // data inizio pagamenti
|
||||||
|
bool _inited; // vero se c'e' un movimento di riferimento
|
||||||
|
real _firstr; // importo da pagare in prima rata (o distribuire se tpr == 0)
|
||||||
|
real _secndr; // importo da distribuire
|
||||||
|
|
||||||
|
int _rata_ifield(int n, int f) const;
|
||||||
|
real _rata_rfield(int n, int f) const;
|
||||||
|
TDate _rata_dfield(int n, int f) const;
|
||||||
|
const char* _rata_sfield(int n, int f) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
int n_rate() const { return _rate.items(); }
|
||||||
|
bool is_new() const { return _new; }
|
||||||
|
bool dirty() const { return _dirty; }
|
||||||
|
int tipo_rata(int n) const { return _rata_ifield(n,2);}
|
||||||
|
real perc_rata(int n) const { return _rata_rfield(n,1);}
|
||||||
|
int scad_rata(int n) const { return _rata_ifield(n,0);}
|
||||||
|
TDate data_rata(int n) const { return _rata_dfield(n,3);}
|
||||||
|
real tpay_rata(int n) const { return _rata_rfield(n,4);}
|
||||||
|
const char* ulc_rata(int n) const { return _rata_sfield(n,5);}
|
||||||
|
char inizio_scadenza() const { return _inscad; }
|
||||||
|
bool mese_commerciale() const { return _mcomm; }
|
||||||
|
bool rate_differenziate() const { return _rdiff; }
|
||||||
|
int tipo_prima_rata() const { return _tpr; }
|
||||||
|
|
||||||
|
const TString& name() const { return _name; }
|
||||||
|
const TString& code() const { return _code; }
|
||||||
|
const char* desc_tpr() const;
|
||||||
|
const char* desc_tipo(int) const;
|
||||||
|
|
||||||
|
// queste vengono usate solo per movimenti editabili nella struttura
|
||||||
|
// (da tabella pagamenti) e riaggiustano tutte le rate in accordo
|
||||||
|
// con il parametro modificato
|
||||||
|
void set_intervallo_rate(int i);
|
||||||
|
void set_mese_commerciale(bool v, int& sscad);
|
||||||
|
void set_rate_differenziate(int v);
|
||||||
|
void set_tipo_prima_rata(int v, int sscad = -1);
|
||||||
|
void set_numero_rate(int n, int sscad = -1);
|
||||||
|
|
||||||
|
void set_inizio_scadenza(char v) { _inscad = v; }
|
||||||
|
void set_code(const char* c) { _code = c; }
|
||||||
|
// check consistency: returns word with errors flagged, 0 if ok
|
||||||
|
word validate() const;
|
||||||
|
void strerr(word err, TString& s);
|
||||||
|
|
||||||
|
// read/write from database
|
||||||
|
// relapp passa i files, se no vengono aperti
|
||||||
|
bool read(TTable* cpg = NULL, TTable* rpg = NULL);
|
||||||
|
|
||||||
|
// chiamabili solo da relapp, agiscono solo su %RPG
|
||||||
|
bool write(TTable& rpg);
|
||||||
|
bool rewrite(TTable& rpg);
|
||||||
|
void remove(TTable& rpg);
|
||||||
|
|
||||||
|
// modifica rate manualmente o non
|
||||||
|
TToken_string& rata(int r) { return (TToken_string&)_rate[r]; }
|
||||||
|
TToken_string& add_rata (real perc, int day, int type);
|
||||||
|
TToken_string& set_rata (int index, real perc, int day, int type,
|
||||||
|
const char* ulc = NULL, const char* imp = NULL,
|
||||||
|
const char* data = NULL);
|
||||||
|
|
||||||
|
void remove_rata(int r);
|
||||||
|
void zap_rate () { _rate.destroy(); }
|
||||||
|
// calcola le rate automaticamente secondo quanto specificato
|
||||||
|
void set_rate_auto();
|
||||||
|
// data una rata esistente, riaggiusta gli importi usando lo slicer e
|
||||||
|
// le scadenze usando la data di inizio
|
||||||
|
void set_imprata(int i, real r);
|
||||||
|
|
||||||
|
// slicer interface
|
||||||
|
void set_total(real& ib, real& im, real& sp);
|
||||||
|
|
||||||
|
// istanzia uno sheet field come diobue comanda
|
||||||
|
void set_sheet(TSheet_field& sf, int sscad = -1);
|
||||||
|
// ricalcola automaticamente tutto il ricalcolabile
|
||||||
|
// alla modifica di una percentuale (o di un importo)
|
||||||
|
// ritorna TRUE se non si poteva; non occorre che sia inizializzato
|
||||||
|
// con un importo
|
||||||
|
word recalc_rate(int row, bool is_perc_modified, const char* new_value,
|
||||||
|
const char* scad, const char* typ, int rdiff,
|
||||||
|
bool mcomm, bool& need_recalc);
|
||||||
|
|
||||||
|
// determina la prossima scadenza
|
||||||
|
void next_scad(TDate& d, int scad, bool mcomm, int rata);
|
||||||
|
|
||||||
|
// se codtab non e' NULL legge da file (e da' errore se non c'e')
|
||||||
|
// se si vuole fare un pagamento nuovo si da' il codice con set_code
|
||||||
|
Pagamento(const char* codtab = NULL, const char* data = NULL);
|
||||||
|
virtual ~Pagamento() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -12,9 +12,15 @@ EdMask = cg5000a.msk
|
|||||||
#codice azienda banca
|
#codice azienda banca
|
||||||
CodCAB = 1
|
CodCAB = 1
|
||||||
#codice dipendenza
|
#codice dipendenza
|
||||||
|
<<<<<<< prassis.doc
|
||||||
|
CodABI = 1
|
||||||
|
# Somma imposte non detraibiili agli acquisti/importazioni in mod. IVA 11
|
||||||
|
Sind11 = X
|
||||||
|
=======
|
||||||
CodABI = 1
|
CodABI = 1
|
||||||
# Somma imposte non detraibili agli acquist/importazioni in mod. IVA 11
|
# Somma imposte non detraibili agli acquist/importazioni in mod. IVA 11
|
||||||
Sind11 = X
|
Sind11 = X
|
||||||
|
>>>>>>> 1.2
|
||||||
# Stampa intestazione su registri bollati
|
# Stampa intestazione su registri bollati
|
||||||
StiReg = X
|
StiReg = X
|
||||||
# Non stampa data registrazione su registi IVA
|
# Non stampa data registrazione su registi IVA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user