Gestione saldaconto
git-svn-id: svn://10.65.10.50/trunk@1726 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d1bd75399e
commit
cdea07e1d9
@ -203,7 +203,6 @@ bool TPrimanota_application::user_destroy()
|
|||||||
delete _tab;
|
delete _tab;
|
||||||
delete _tabcom;
|
delete _tabcom;
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +240,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
|||||||
TMask& cgm = cgs().sheet_mask();
|
TMask& cgm = cgs().sheet_mask();
|
||||||
cgm.set_handler(100, _is_saldaconto ? showpartite_handler : NULL); // bottoncino riga
|
cgm.set_handler(100, _is_saldaconto ? showpartite_handler : NULL); // bottoncino riga
|
||||||
cgm.enable(100, _is_saldaconto);
|
cgm.enable(100, _is_saldaconto);
|
||||||
|
m->show(S_TIPORIGA, _is_saldaconto);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -282,8 +282,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
|||||||
|
|
||||||
if (tc.tipo() > ' ' && tc.ok())
|
if (tc.tipo() > ' ' && tc.ok())
|
||||||
{
|
{
|
||||||
const TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
|
TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
|
||||||
if (clifo.conto() != 0)
|
if (clifo.find() && clifo.conto() != 0) // Legge gruppo e conto
|
||||||
tc = clifo;
|
tc = clifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,10 +308,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
|||||||
{
|
{
|
||||||
char tipr = ' ';
|
char tipr = ' ';
|
||||||
if (_is_saldaconto)
|
if (_is_saldaconto)
|
||||||
{
|
|
||||||
if (nriga < 12 && nriga != 10) continue; // Si considerano solo le spese
|
if (nriga < 12 && nriga != 10) continue; // Si considerano solo le spese
|
||||||
tipr = nriga == 10 ? 'G' : 'L';
|
|
||||||
}
|
|
||||||
const int pos = set_cgs_row(-1, zero, tc, desc, tipr);
|
const int pos = set_cgs_row(-1, zero, tc, desc, tipr);
|
||||||
if (sezione > ' ' && tipr != ' ')
|
if (sezione > ' ' && tipr != ' ')
|
||||||
cgs().disable_cell(pos, sezione == 'A' ? 0 : 1);
|
cgs().disable_cell(pos, sezione == 'A' ? 0 : 1);
|
||||||
@ -479,7 +477,7 @@ void TPrimanota_application::init_query_mode(TMask& m)
|
|||||||
|
|
||||||
void TPrimanota_application::fill_sheet(TMask& m) const
|
void TPrimanota_application::fill_sheet(TMask& m) const
|
||||||
{
|
{
|
||||||
if (_iva != nessuna_iva || !_is_saldaconto)
|
if (_iva != nessuna_iva || !is_saldaconto())
|
||||||
{
|
{
|
||||||
TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG);
|
TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG);
|
||||||
for (int r = cgs.items(); r < 16; r++) cgs.row(r);
|
for (int r = cgs.items(); r < 16; r++) cgs.row(r);
|
||||||
|
45
cg/cg2100.h
45
cg/cg2100.h
@ -53,8 +53,8 @@
|
|||||||
#define F_CAMBIOINTRA 142
|
#define F_CAMBIOINTRA 142
|
||||||
#define F_STAMPATO 143
|
#define F_STAMPATO 143
|
||||||
#define F_REGST 144
|
#define F_REGST 144
|
||||||
#define F_SHEETCG 300
|
#define F_SHEETCG 190
|
||||||
#define F_SHEETIVA 301
|
#define F_SHEETIVA 191
|
||||||
|
|
||||||
// Campi ripetuti sulla seconda pagina
|
// Campi ripetuti sulla seconda pagina
|
||||||
#define H_DATAREG 201
|
#define H_DATAREG 201
|
||||||
@ -102,27 +102,28 @@
|
|||||||
#define I_SOTTOCONTO4 234
|
#define I_SOTTOCONTO4 234
|
||||||
|
|
||||||
// Saldaconto
|
// Saldaconto
|
||||||
#define S_TOTDOC 401
|
#define S_TOTDOC 301
|
||||||
#define S_TOTDOCVAL 402
|
#define S_TOTDOCVAL 302
|
||||||
#define S_VALUTA 403
|
#define S_VALUTA 303
|
||||||
#define S_DATACAMBIO 404
|
#define S_DATACAMBIO 304
|
||||||
#define S_CAMBIO 405
|
#define S_CAMBIO 305
|
||||||
|
#define S_TIPORIGA 306
|
||||||
|
|
||||||
// copie 2a pag.
|
// copie 2a pag.
|
||||||
#define K_CODDITTA 501
|
#define K_CODDITTA 401
|
||||||
#define K_RAGSOC 502
|
#define K_RAGSOC 402
|
||||||
#define K_DATAREG 503
|
#define K_DATAREG 403
|
||||||
#define K_NUMREG 504
|
#define K_NUMREG 404
|
||||||
#define K_CODCAUS 505
|
#define K_CODCAUS 405
|
||||||
#define K_DESCRCAUS 506
|
#define K_DESCRCAUS 406
|
||||||
#define K_DOCUMENTO 507
|
#define K_DOCUMENTO 407
|
||||||
#define K_TIPODOC 508
|
#define K_TIPODOC 408
|
||||||
#define K_PROTIVA 509
|
#define K_PROTIVA 409
|
||||||
#define K_PROVVISORIO 510
|
#define K_PROVVISORIO 410
|
||||||
#define K_DESCR 511
|
#define K_DESCR 411
|
||||||
#define K_DATADOC 512
|
#define K_DATADOC 412
|
||||||
#define K_NUMDOC 513
|
#define K_NUMDOC 413
|
||||||
#define K_ANNOES 514
|
#define K_ANNOES 414
|
||||||
#define K_DATACOMP 515
|
#define K_DATACOMP 415
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -320,10 +320,17 @@ END
|
|||||||
|
|
||||||
STRING K_NUMDOC 7
|
STRING K_NUMDOC 7
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 56 7 "Documento n. "
|
PROMPT 38 7 "Num. "
|
||||||
FLAGS "D"
|
FLAGS "D"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
LIST S_TIPORIGA 1 13
|
||||||
|
BEGIN
|
||||||
|
PROMPT 60 7 "Riga "
|
||||||
|
ITEM "K|Saldaconto"
|
||||||
|
ITEM "S|Spese"
|
||||||
|
END
|
||||||
|
|
||||||
SPREADSHEET F_SHEETCG
|
SPREADSHEET F_SHEETCG
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 0 8 ""
|
PROMPT 0 8 ""
|
||||||
|
@ -99,25 +99,35 @@ real TPrimanota_application::totale_documento()
|
|||||||
bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
||||||
{
|
{
|
||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
|
TMask& m = f.mask();
|
||||||
|
|
||||||
|
if (m.get(116) == "K")
|
||||||
|
{
|
||||||
|
TSheet_field& s = *m.get_sheet();
|
||||||
|
const int riga = s.selected();
|
||||||
if (k == K_SPACE)
|
if (k == K_SPACE)
|
||||||
{
|
{
|
||||||
TSheet_field& s = app().cgs();
|
|
||||||
const int riga = s.selected();
|
|
||||||
const bool dirty = app().edit_partite(riga);
|
const bool dirty = app().edit_partite(riga);
|
||||||
if (dirty) k = K_ENTER;
|
if (dirty)
|
||||||
|
{
|
||||||
|
if (m.field(103).enabled())
|
||||||
|
app().disable_cgs_cells(riga, 'K');
|
||||||
|
k = K_ENTER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
TSheet_field& s = app().cgs();
|
const int currig = riga+1;
|
||||||
const int sel = s.selected();
|
|
||||||
TToken_string& row = app().cgs().row(sel);
|
|
||||||
const int currig = sel+1;
|
|
||||||
|
|
||||||
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
||||||
TImporto importo; importo = row;
|
TImporto importo;
|
||||||
TImporto speso = app()._partite.importo_speso(curreg, currig);
|
const TString& imp = m.get(101);
|
||||||
|
if (imp.not_empty())
|
||||||
|
importo.set('D', real(imp));
|
||||||
|
else
|
||||||
|
importo.set('A', real(m.get(102)));
|
||||||
|
|
||||||
|
const TImporto speso(app()._partite.importo_speso(curreg, currig));
|
||||||
|
|
||||||
if (importo != speso)
|
if (importo != speso)
|
||||||
{
|
{
|
||||||
@ -125,13 +135,13 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
|||||||
"Si desidera correggerlo?", speso.sezione(), speso.valore().string("."), currig);
|
"Si desidera correggerlo?", speso.sezione(), speso.valore().string("."), currig);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
|
||||||
const bool dare = speso.sezione() == 'D';
|
const bool dare = speso.sezione() == 'D';
|
||||||
m.set(101, dare ? speso.valore().string() : "");
|
m.set(101, dare ? speso.valore().string() : "");
|
||||||
m.set(102, dare ? "" : speso.valore().string());
|
m.set(102, dare ? "" : speso.valore().string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,7 +478,7 @@ void TPrimanota_application::cgs_pack()
|
|||||||
TToken_string& r = rows.row(i);
|
TToken_string& r = rows.row(i);
|
||||||
if (can_remove(r))
|
if (can_remove(r))
|
||||||
{
|
{
|
||||||
if (salda && row_type(r) == ' ')
|
if (salda && row_type(r) == 'K')
|
||||||
cg_notify(cgs(), i, K_DEL);
|
cg_notify(cgs(), i, K_DEL);
|
||||||
rows.destroy(i, salda);
|
rows.destroy(i, salda);
|
||||||
}
|
}
|
||||||
@ -558,7 +568,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
|||||||
empty = FALSE;
|
empty = FALSE;
|
||||||
|
|
||||||
const char tipo = row_type(r);
|
const char tipo = row_type(r);
|
||||||
if ((tipo <= ' ' || tipo == 'K') && app().iva() == nessuna_iva && app().is_saldaconto())
|
if (tipo == 'K' && app().iva() == nessuna_iva && app().is_saldaconto())
|
||||||
{
|
{
|
||||||
const long numreg = f.mask().get_long(F_NUMREG);
|
const long numreg = f.mask().get_long(F_NUMREG);
|
||||||
const int currig = i+1;
|
const int currig = i+1;
|
||||||
@ -570,11 +580,6 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
|||||||
if (ok) app().set_cgs_imp(i, speso);
|
if (ok) app().set_cgs_imp(i, speso);
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
}
|
}
|
||||||
if (tipo != 'K' && !speso.is_zero())
|
|
||||||
{
|
|
||||||
r.add("K", -2);
|
|
||||||
app().disable_cgs_cells(i, 'K');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,13 +705,13 @@ void TPrimanota_application::generazione_righe_cg(int r)
|
|||||||
|
|
||||||
bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||||
{
|
{
|
||||||
|
const char tipo = row_type(cg.row(r)); // Tipo della riga in esame
|
||||||
|
|
||||||
switch(k)
|
switch(k)
|
||||||
{
|
{
|
||||||
case K_SPACE:
|
case K_TAB:
|
||||||
{
|
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K');
|
||||||
const char tipo = row_type(cg.row(r));
|
cg.sheet_mask().show(100, tipo == 'K');
|
||||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ');
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
if (app().iva() == nessuna_iva)
|
if (app().iva() == nessuna_iva)
|
||||||
@ -714,12 +719,31 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
|||||||
app().calcola_saldo();
|
app().calcola_saldo();
|
||||||
break;
|
break;
|
||||||
case K_DEL:
|
case K_DEL:
|
||||||
if (app().is_saldaconto() && app().iva() == nessuna_iva)
|
if (tipo == 'K')
|
||||||
app().notify_cgline_deletion(r+1);
|
app().notify_cgline_deletion(r+1);
|
||||||
break;
|
break;
|
||||||
default:
|
case K_INS:
|
||||||
|
if (app().iva() == nessuna_iva && app().is_saldaconto())
|
||||||
|
{
|
||||||
|
const char tipo = app().curr_mask().get(S_TIPORIGA)[0];
|
||||||
|
if (tipo == 'K')
|
||||||
|
{
|
||||||
|
cg.row(r).add("K", 15);
|
||||||
|
for (int i = 0; i < r; i++)
|
||||||
|
{
|
||||||
|
const TToken_string& row = cg.row(i);
|
||||||
|
if (row_type(row) != 'K')
|
||||||
|
{
|
||||||
|
cg.swap_rows(r, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1739,8 +1763,6 @@ bool TPrimanota_application::totale_handler(TMask_field& f, KEY key)
|
|||||||
{
|
{
|
||||||
app().add_cgs_tot(m);
|
app().add_cgs_tot(m);
|
||||||
m.field(F_CODIVA).on_hit();
|
m.field(F_CODIVA).on_hit();
|
||||||
// if (app().is_saldaconto() && m.get(F_CODPAG).not_empty())
|
|
||||||
// app().set_scadenze(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == K_ENTER && f.get().empty())
|
if (key == K_ENTER && f.get().empty())
|
||||||
@ -1751,10 +1773,6 @@ bool TPrimanota_application::totale_handler(TMask_field& f, KEY key)
|
|||||||
bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key)
|
bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key)
|
||||||
{
|
{
|
||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
if (key == K_TAB && f.focusdirty())
|
|
||||||
{
|
|
||||||
// app().add_cgs_tot_noiva(f.mask());
|
|
||||||
}
|
|
||||||
if (key == K_ENTER && f.get().empty())
|
if (key == K_ENTER && f.get().empty())
|
||||||
ok = f.yesno_box("Totale documento nullo: continuare ugualmente?");
|
ok = f.yesno_box("Totale documento nullo: continuare ugualmente?");
|
||||||
return ok;
|
return ok;
|
||||||
@ -1850,7 +1868,7 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key)
|
|||||||
const real cambio = m.get(F_CAMBIOINTRA);
|
const real cambio = m.get(F_CAMBIOINTRA);
|
||||||
if (cambio != ZERO && m.get(F_CORRVALUTA).empty())
|
if (cambio != ZERO && m.get(F_CORRVALUTA).empty())
|
||||||
{
|
{
|
||||||
real c = f.get();
|
real c(f.get());
|
||||||
c /= cambio;
|
c /= cambio;
|
||||||
m.set(F_CORRVALUTA, c.string());
|
m.set(F_CORRVALUTA, c.string());
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,8 @@ protected:
|
|||||||
bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig);
|
bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig);
|
||||||
bool notify_cgline_deletion(int numrig);
|
bool notify_cgline_deletion(int numrig);
|
||||||
|
|
||||||
|
bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag);
|
||||||
|
|
||||||
long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis);
|
long calcola_m770(int tipo_coll, real& spese, real& compenso, real& iva, real& ritfis);
|
||||||
bool link_m770();
|
bool link_m770();
|
||||||
|
|
||||||
|
206
cg/cg2105.cpp
206
cg/cg2105.cpp
@ -15,6 +15,7 @@
|
|||||||
class TGame_mask : public TMask
|
class TGame_mask : public TMask
|
||||||
{
|
{
|
||||||
const TBill _conto; // Conto fisso
|
const TBill _conto; // Conto fisso
|
||||||
|
int _riga_partite;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool annopart_handler(TMask_field& f, KEY k);
|
static bool annopart_handler(TMask_field& f, KEY k);
|
||||||
@ -61,7 +62,7 @@ bool TGame_mask::annopart_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
TMask_field& n = f.mask().field(P_NUMERO);
|
TMask_field& n = f.mask().field(P_NUMERO);
|
||||||
n.set_dirty();
|
n.set_dirty();
|
||||||
numpart_handler(f, k);
|
numpart_handler(n, k);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -123,6 +124,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
|||||||
if (k == K_TAB)
|
if (k == K_TAB)
|
||||||
{
|
{
|
||||||
TGame_mask& gm = (TGame_mask&)partite.mask();
|
TGame_mask& gm = (TGame_mask&)partite.mask();
|
||||||
|
gm._riga_partite = r;
|
||||||
|
|
||||||
TSheet_field& scadenze = gm.scadenze();
|
TSheet_field& scadenze = gm.scadenze();
|
||||||
scadenze.destroy();
|
scadenze.destroy();
|
||||||
|
|
||||||
@ -160,7 +163,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
|||||||
|
|
||||||
const TRecord_array& ap = scad.rows_array();
|
const TRecord_array& ap = scad.rows_array();
|
||||||
const int lastp = ap.last_row();
|
const int lastp = ap.last_row();
|
||||||
for (int pa = ap.first_row(); pa < lastp; pa++) if (ap.exist(pa))
|
for (int pa = ap.first_row(); pa <= lastp; pa = ap.succ_row(pa))
|
||||||
{
|
{
|
||||||
const TRiga_partite& rigp = game->riga(pa);
|
const TRiga_partite& rigp = game->riga(pa);
|
||||||
const TRectype& pag = ap.row(pa);
|
const TRectype& pag = ap.row(pa);
|
||||||
@ -176,7 +179,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
|||||||
row.add(pag.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
row.add(pag.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
||||||
row.add(rigp.get(PART_DESCR));
|
row.add(rigp.get(PART_DESCR));
|
||||||
row.add(rigp.get(PART_NUMDOC));
|
row.add(rigp.get(PART_NUMDOC));
|
||||||
row.add(rigp.get(PART_PROTIVA));
|
row.add("");
|
||||||
row.add(pa);
|
row.add(pa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +227,10 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TPartita& game = app().partite().partita(bill, anno, numero);
|
TPartita& game = app().partite().partita(bill, anno, numero);
|
||||||
app().edit_pagamento(game, nriga, nrata, nrigp);
|
const bool dirty = app().edit_pagamento(game, nriga, nrata, nrigp);
|
||||||
|
|
||||||
|
if (dirty)
|
||||||
|
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -259,17 +265,13 @@ void TGame_mask::fill_partite(bool all) const
|
|||||||
|
|
||||||
const TRectype filter(partita.curr()); // Record campione
|
const TRectype filter(partita.curr()); // Record campione
|
||||||
|
|
||||||
int ultimo_anno = 0, anno; // Anno ultima partita
|
for (int err = partita.read(_isgteq);
|
||||||
TString16 ultimo_num, num; // Ultimo numero partita
|
err == NOERR && partita.curr() == filter;
|
||||||
TToken_string r(80);
|
err = partita.read(_isgreat))
|
||||||
|
|
||||||
for (int err = partita.read(_isgteq); err == NOERR && partita.curr() == filter; err = partita.next())
|
|
||||||
{
|
{
|
||||||
anno = partita.get_int(PART_ANNO);
|
const int anno = partita.get_int(PART_ANNO);
|
||||||
num = partita.get(PART_NUMPART);
|
const TString16 num(partita.get(PART_NUMPART));
|
||||||
|
|
||||||
if (ultimo_anno != anno && ultimo_num != num)
|
|
||||||
{
|
|
||||||
TPartita* game = NULL;
|
TPartita* game = NULL;
|
||||||
bool should_delete_game = FALSE;
|
bool should_delete_game = FALSE;
|
||||||
if (app().partite().exist(conto(), anno, num))
|
if (app().partite().exist(conto(), anno, num))
|
||||||
@ -286,14 +288,14 @@ void TGame_mask::fill_partite(bool all) const
|
|||||||
if (all || !saldo.is_zero())
|
if (all || !saldo.is_zero())
|
||||||
{
|
{
|
||||||
int riga_fatt = game->prima_fattura();
|
int riga_fatt = game->prima_fattura();
|
||||||
if (riga_fatt < 1) riga_fatt = 1; // E' un anticipo
|
if (riga_fatt < 1) riga_fatt = game->first(); // E' un anticipo
|
||||||
|
|
||||||
const TRiga_partite& riga = game->riga(riga_fatt);
|
const TRiga_partite& riga = game->riga(riga_fatt);
|
||||||
const TString16 data_doc = riga.get(PART_DATADOC);
|
const TString16 data_doc = riga.get(PART_DATADOC);
|
||||||
const TString16 num_doc = riga.get(PART_NUMDOC);
|
const TString16 num_doc = riga.get(PART_NUMDOC);
|
||||||
const char*descr = riga.get(PART_DESCR);
|
const char*descr = riga.get(PART_DESCR);
|
||||||
|
|
||||||
r.cut(0);
|
TToken_string &r = partite().row(-1); // Stringa di lavoro per lo sheet
|
||||||
r.add(anno);
|
r.add(anno);
|
||||||
r.add(num);
|
r.add(num);
|
||||||
r.add(data_doc);
|
r.add(data_doc);
|
||||||
@ -303,15 +305,12 @@ void TGame_mask::fill_partite(bool all) const
|
|||||||
add_importo(r, pag);
|
add_importo(r, pag);
|
||||||
add_importo(r, imp);
|
add_importo(r, imp);
|
||||||
r.add(descr);
|
r.add(descr);
|
||||||
a.add(r); // Aggiunge partita alla lista
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_delete_game)
|
if (should_delete_game)
|
||||||
delete game;
|
delete game;
|
||||||
|
|
||||||
ultimo_anno = anno;
|
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
|
||||||
ultimo_num = num;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partite().force_update();
|
partite().force_update();
|
||||||
@ -449,114 +448,69 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
|||||||
|
|
||||||
HIDDEN bool importo_handler(TMask_field& f, KEY k)
|
HIDDEN bool importo_handler(TMask_field& f, KEY k)
|
||||||
{
|
{
|
||||||
|
TMask& m = f.mask();
|
||||||
|
|
||||||
if (k == K_F8)
|
if (k == K_F8)
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
f.set(m.get(S_RESIDUO));
|
||||||
f.set(m.get(S_IMPORTO));
|
|
||||||
k = K_TAB;
|
k = K_TAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f.to_check(k))
|
if (f.to_check(k))
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
const real i(f.get());
|
||||||
real i(f.get());
|
const real tot(m.get(S_RESIDUO));
|
||||||
const real tot(m.get(S_IMPORTO));
|
if (i >= tot)
|
||||||
if (i > tot)
|
|
||||||
{
|
|
||||||
warning_box("Non e' possibile inserire un importo superiore a ", tot.string("."));
|
|
||||||
i = tot;
|
|
||||||
f.set(i.string());
|
|
||||||
}
|
|
||||||
if (i == tot)
|
|
||||||
m.set(S_SALDOACC, "S");
|
m.set(S_SALDOACC, "S");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp)
|
bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag)
|
||||||
{
|
{
|
||||||
TMask m("cg2100s");
|
const int nriga = new_pag.get_int(PAGSCA_NRIGA); // Riga fattura
|
||||||
m.set_handler(S_IMPORTO, importo_handler);
|
|
||||||
|
|
||||||
const TRiga_partite& parbas = p.riga(nriga);
|
const TRiga_partite& parbas = p.riga(nriga);
|
||||||
|
|
||||||
|
const int nrata = new_pag.get_int(PAGSCA_NRATA); // Numero rata
|
||||||
TRiga_scadenze& scaden = parbas.rata(nrata);
|
TRiga_scadenze& scaden = parbas.rata(nrata);
|
||||||
const TRectype& oldpag = scaden.row(nrigp);
|
|
||||||
TRiga_partite& somma = p.riga(nrigp);
|
|
||||||
|
|
||||||
const bool in_valuta = scaden.get(SCAD_CODVAL).not_empty();
|
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); // Riga pagamento
|
||||||
m.show(S_IMPORTOVAL_SCAD, in_valuta);
|
const TRectype& old_pag = scaden.row(nrigp);
|
||||||
m.show(S_IMPORTOVAL, in_valuta);
|
const TRiga_partite& somma = p.riga(nrigp);
|
||||||
|
|
||||||
TRelation rel(LF_PAGSCA); // Working relation
|
const char sez = somma.sezione(); // Sezione importo e ritenute
|
||||||
rel.lfile().curr() = oldpag;
|
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
|
||||||
m.autoload(&rel); // Load current record on mask
|
|
||||||
|
|
||||||
m.set(S_DESCAGG, somma.get(PART_DESCR));
|
// Aggiornamento contopartita
|
||||||
|
const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO));
|
||||||
|
TBill old_conto; old_conto.get(old_pag, TRUE);
|
||||||
|
|
||||||
// Dati del documento (fattura) che ha generato la scadenza
|
const TImporto new_importo(controsez, new_pag.get_real(PAGSCA_IMPORTO));
|
||||||
m.set(S_NUMDOC, parbas.get(PART_NUMDOC)); // Numero documento
|
TBill new_conto; new_conto.get(new_pag, TRUE);
|
||||||
m.set(S_DATADOC, parbas.get(PART_DATADOC)); // Data documento
|
|
||||||
m.set(S_NUMPROT, parbas.get(PART_PROTIVA)); // Protocollo IVA
|
|
||||||
m.set(S_DESCR, parbas.get(PART_DESCR)); // Descrizione documento
|
|
||||||
|
|
||||||
// Dati della scadenza che ha generato la partita
|
if (old_importo != new_importo || old_conto != new_conto)
|
||||||
TReal_field& residuo = (TReal_field&)m.field(S_RESIDUO);
|
|
||||||
residuo.set_decimals(in_valuta ? 2 : 0);
|
|
||||||
residuo.set(scaden.residuo().string()); // Residuo da pagare
|
|
||||||
m.set(S_DATASCAD, scaden.get(SCAD_DATASCAD)); // Data della scadenza
|
|
||||||
m.set(S_SEZIONE_SCAD, parbas.get(PART_SEZ)); // Sezione della rata
|
|
||||||
m.set(S_RATA, scaden.get(SCAD_NRATA));
|
|
||||||
m.set(S_IMPORTO_SCAD, scaden.get(SCAD_IMPORTO)); // Importo della rata
|
|
||||||
m.set(S_IMPORTOVAL_SCAD, scaden.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
|
||||||
|
|
||||||
const char sez = parbas.get_char(PART_SEZ); // Sezione importo e rituenute
|
|
||||||
const char controsez = sez == 'D' ? 'A' : 'D'; // Sezione opposta (contropartita)
|
|
||||||
|
|
||||||
// Memorizza importi prima di eventuali variazioni
|
|
||||||
const TImporto old_importo(controsez, real(m.get(S_IMPORTO)));
|
|
||||||
const TImporto old_ritenute(controsez, real(m.get(S_RITENUTE)));
|
|
||||||
|
|
||||||
const TBill old_conto(m.get_int(S_GRUPPO), m.get_int(S_CONTO), m.get_long(S_SOTTOCONTO));
|
|
||||||
const int old_riga = old_conto.ok() ? bill2pos(old_conto, 'I') : -1;
|
|
||||||
|
|
||||||
const KEY key = m.run();
|
|
||||||
if (key == K_ENTER || key == K_DEL)
|
|
||||||
{
|
|
||||||
if (key == K_DEL)
|
|
||||||
{
|
|
||||||
m.reset(S_IMPORTO);
|
|
||||||
m.reset(S_IMPORTOVAL);
|
|
||||||
m.reset(S_RITENUTE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
|
|
||||||
}
|
|
||||||
|
|
||||||
m.autosave(&rel);
|
|
||||||
const TRectype& paga = rel.lfile().curr();
|
|
||||||
|
|
||||||
const TImporto new_importo(controsez, paga.get_real(PART_IMPORTO));
|
|
||||||
if (old_importo != new_importo)
|
|
||||||
{
|
{
|
||||||
|
const int old_riga = bill2pos(old_conto, 'I');
|
||||||
if (old_riga >= 0)
|
if (old_riga >= 0)
|
||||||
sub_cgs_imp(old_riga, old_importo);
|
sub_cgs_imp(old_riga, old_importo);
|
||||||
|
|
||||||
// Importo della contropartita
|
// Importo della contropartita
|
||||||
if (!new_importo.is_zero())
|
if (!new_importo.is_zero())
|
||||||
{
|
{
|
||||||
TBill new_conto; new_conto.get(paga, TRUE);
|
const int new_riga = bill2pos(new_conto, 'I');
|
||||||
const int riga = bill2pos(new_conto, 'I');
|
if (new_riga < 0)
|
||||||
if (riga < 0)
|
set_cgs_row(new_riga, new_importo, new_conto, "", 'I');
|
||||||
set_cgs_row(riga, new_importo, new_conto, m.get(S_DESCAGG), 'I');
|
|
||||||
else
|
else
|
||||||
add_cgs_imp(riga, new_importo);
|
add_cgs_imp(new_riga, new_importo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const real rit(m.get(S_RITENUTE)); // Valore ritenute fiscali
|
// Aggiornamento ritenute
|
||||||
const TImporto grow_ritenute(controsez, rit-old_ritenute.valore());
|
const real old_ritenute(old_pag.get(PAGSCA_RITENUTE));
|
||||||
|
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
||||||
|
const TImporto grow_ritenute(controsez, new_ritenute-old_ritenute);
|
||||||
if (!grow_ritenute.is_zero())
|
if (!grow_ritenute.is_zero())
|
||||||
{
|
{
|
||||||
const riga = type2pos('F');
|
const riga = type2pos('F');
|
||||||
@ -571,7 +525,7 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
|||||||
|
|
||||||
char old_ap, new_ap;
|
char old_ap, new_ap;
|
||||||
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
||||||
const bool empty = p.modifica_pagamento(paga,
|
const bool empty = p.modifica_pagamento(new_pag,
|
||||||
old_ap, old_abbuono, new_abbuono,
|
old_ap, old_abbuono, new_abbuono,
|
||||||
new_ap, new_abbuono, new_diffcam);
|
new_ap, new_abbuono, new_diffcam);
|
||||||
|
|
||||||
@ -622,6 +576,64 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
|||||||
add_cgs_imp(riga_diffcam, new_diffcam);
|
add_cgs_imp(riga_diffcam, new_diffcam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp)
|
||||||
|
{
|
||||||
|
TMask m("cg2100s");
|
||||||
|
m.set_handler(S_IMPORTO, importo_handler);
|
||||||
|
|
||||||
|
const TRiga_partite& parbas = p.riga(nriga);
|
||||||
|
const TRiga_scadenze& scaden = parbas.rata(nrata);
|
||||||
|
const TRectype& oldpag = scaden.row(nrigp);
|
||||||
|
TRiga_partite& somma = p.riga(nrigp);
|
||||||
|
|
||||||
|
const bool in_valuta = scaden.in_valuta();
|
||||||
|
m.show(S_IMPORTOVAL_SCAD, in_valuta);
|
||||||
|
m.show(S_IMPORTOVAL, in_valuta);
|
||||||
|
|
||||||
|
TRelation rel(LF_PAGSCA); // Working relation
|
||||||
|
rel.lfile().curr() = oldpag;
|
||||||
|
m.autoload(&rel); // Load current record on mask
|
||||||
|
|
||||||
|
m.set(S_DESCAGG, somma.get(PART_DESCR));
|
||||||
|
|
||||||
|
// Dati del documento (fattura) che ha generato la scadenza
|
||||||
|
m.set(S_NUMDOC, parbas.get(PART_NUMDOC)); // Numero documento
|
||||||
|
m.set(S_DATADOC, parbas.get(PART_DATADOC)); // Data documento
|
||||||
|
m.set(S_NUMPROT, parbas.get(PART_PROTIVA)); // Protocollo IVA
|
||||||
|
m.set(S_DESCR, parbas.get(PART_DESCR)); // Descrizione documento
|
||||||
|
|
||||||
|
// Dati della scadenza che ha generato la partita
|
||||||
|
TReal_field& residuo = (TReal_field&)m.field(S_RESIDUO);
|
||||||
|
residuo.set_decimals(in_valuta ? 2 : 0);
|
||||||
|
residuo.set(scaden.residuo().string()); // Residuo da pagare
|
||||||
|
m.set(S_DATASCAD, scaden.get(SCAD_DATASCAD)); // Data della scadenza
|
||||||
|
m.set(S_SEZIONE_SCAD, parbas.get(PART_SEZ)); // Sezione della rata
|
||||||
|
m.set(S_RATA, scaden.get(SCAD_NRATA));
|
||||||
|
m.set(S_IMPORTO_SCAD, scaden.get(SCAD_IMPORTO)); // Importo della rata
|
||||||
|
m.set(S_IMPORTOVAL_SCAD, scaden.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
||||||
|
|
||||||
|
const KEY key = m.run();
|
||||||
|
if (key == K_ENTER || key == K_DEL)
|
||||||
|
{
|
||||||
|
if (key == K_DEL)
|
||||||
|
{
|
||||||
|
m.reset(S_IMPORTO);
|
||||||
|
m.reset(S_IMPORTOVAL);
|
||||||
|
m.reset(S_RITENUTE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.autosave(&rel);
|
||||||
|
TRectype& new_pag = rel.lfile().curr();
|
||||||
|
notify_edit_pagamento(p, new_pag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return key != K_ESC;
|
return key != K_ESC;
|
||||||
@ -630,7 +642,6 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
|||||||
bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg, int numrig)
|
bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg, int numrig)
|
||||||
{
|
{
|
||||||
bool found = FALSE;
|
bool found = FALSE;
|
||||||
const int riga_ritenute = type2pos('F');
|
|
||||||
|
|
||||||
for (int r = partita.last(); r > 0; r = partita.pred(r))
|
for (int r = partita.last(); r > 0; r = partita.pred(r))
|
||||||
{
|
{
|
||||||
@ -641,6 +652,7 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
|||||||
const int num = part.get_int(PART_NUMRIG);
|
const int num = part.get_int(PART_NUMRIG);
|
||||||
if (numrig > 0)
|
if (numrig > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else // numrig == 0
|
else // numrig == 0
|
||||||
{
|
{
|
||||||
|
@ -351,6 +351,7 @@ BEGIN
|
|||||||
ITEM "D|IVA detraibile"
|
ITEM "D|IVA detraibile"
|
||||||
ITEM "F|Ritenute fiscali"
|
ITEM "F|Ritenute fiscali"
|
||||||
ITEM "I|Riga di IVA"
|
ITEM "I|Riga di IVA"
|
||||||
|
ITEM "K|Riga Cliente/Fornitore"
|
||||||
ITEM "N|IVA non detraibile"
|
ITEM "N|IVA non detraibile"
|
||||||
ITEM "S|Ritenute sociali"
|
ITEM "S|Ritenute sociali"
|
||||||
ITEM "T|Totale documento"
|
ITEM "T|Totale documento"
|
||||||
|
@ -1205,16 +1205,17 @@ int TTree_rectype::remove(TBaseisamfile& f)
|
|||||||
// TRiga_scadenze
|
// TRiga_scadenze
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TRiga_scadenze::TRiga_scadenze(TRiga_partite* riga)
|
TRiga_scadenze::TRiga_scadenze(TRiga_partite* r)
|
||||||
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(riga)
|
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(r)
|
||||||
{
|
{
|
||||||
zero();
|
CHECK(_riga, "Riga nulla");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRiga_scadenze::TRiga_scadenze(const TRiga_scadenze& s)
|
TRiga_scadenze::TRiga_scadenze(const TRiga_scadenze& s)
|
||||||
: TTree_rectype(s), _riga(s._riga)
|
: TTree_rectype(s), _riga(s._riga)
|
||||||
|
|
||||||
{
|
{
|
||||||
zero();
|
CHECK(_riga, "Riga nulla");
|
||||||
}
|
}
|
||||||
|
|
||||||
TPartita& TRiga_scadenze::partita() const
|
TPartita& TRiga_scadenze::partita() const
|
||||||
@ -1423,12 +1424,14 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
|
|||||||
TRiga_partite::TRiga_partite(TPartita* game)
|
TRiga_partite::TRiga_partite(TPartita* game)
|
||||||
: TTree_rectype(LF_PARTITE, LF_SCADENZE, "NRATA"), _partita(game)
|
: TTree_rectype(LF_PARTITE, LF_SCADENZE, "NRATA"), _partita(game)
|
||||||
{
|
{
|
||||||
zero();
|
CHECK(_partita, "Partita nulla");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRiga_partite::TRiga_partite(const TRiga_partite& r)
|
TRiga_partite::TRiga_partite(const TRiga_partite& r)
|
||||||
: TTree_rectype(r), _partita(r._partita)
|
: TTree_rectype(r), _partita(r._partita)
|
||||||
{}
|
{
|
||||||
|
CHECK(_partita, "Partita nulla");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int TRiga_partite::read(TBaseisamfile& f, word op)
|
int TRiga_partite::read(TBaseisamfile& f, word op)
|
||||||
@ -1440,7 +1443,7 @@ int TRiga_partite::read(TBaseisamfile& f, word op)
|
|||||||
copy_key_to_row(*s);
|
copy_key_to_row(*s);
|
||||||
err = _recarr.read(s); // Deve esistere almento una scadenza
|
err = _recarr.read(s); // Deve esistere almento una scadenza
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
if (err != NOERR)
|
if (_recarr.rows() == 0)
|
||||||
yesnofatal_box("Riga di fattura senza nessuna scadenza");
|
yesnofatal_box("Riga di fattura senza nessuna scadenza");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1494,6 +1497,11 @@ bool TPartita::read(const TBill& clifo, int anno, const char* num)
|
|||||||
partita->put(PART_NUMPART, num); // Numero partita
|
partita->put(PART_NUMPART, num); // Numero partita
|
||||||
_part.read(partita);
|
_part.read(partita);
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
for (int p = last(); p > 0; p = pred(p))
|
||||||
|
CHECKD(riga(p)._partita == this, "Riga partite inconsistente", p);
|
||||||
|
#endif
|
||||||
|
|
||||||
TRectype unas(LF_PAGSCA); // Record campione pagamenti non assegnati
|
TRectype unas(LF_PAGSCA); // Record campione pagamenti non assegnati
|
||||||
unas.zero();
|
unas.zero();
|
||||||
unas.put(PART_TIPOCF, partita->get(PART_TIPOCF)); // Copia chiave partite
|
unas.put(PART_TIPOCF, partita->get(PART_TIPOCF)); // Copia chiave partite
|
||||||
|
@ -226,7 +226,7 @@ public:
|
|||||||
bool in_valuta() const;
|
bool in_valuta() const;
|
||||||
|
|
||||||
TPartita& partita() const;
|
TPartita& partita() const;
|
||||||
TRiga_partite& riga() const { return *_riga; } // Riga partite generante (fattura)
|
TRiga_partite& riga() const { CHECK(_riga, "Riga nulla"); return *_riga; } // Riga partite
|
||||||
|
|
||||||
TImporto importo_pagato(bool val) const;
|
TImporto importo_pagato(bool val) const;
|
||||||
TImporto importo_da_pagare(bool val) const;
|
TImporto importo_da_pagare(bool val) const;
|
||||||
@ -256,7 +256,7 @@ public:
|
|||||||
int ultimo_pagamento(int rata) const;
|
int ultimo_pagamento(int rata) const;
|
||||||
char sezione() const { return get_char("SEZ"); }
|
char sezione() const { return get_char("SEZ"); }
|
||||||
|
|
||||||
TPartita& partita() const { return *_partita; } // Partita di appartenenza
|
TPartita& partita() const { CHECK(_partita, "Partita nulla"); return *_partita; }
|
||||||
|
|
||||||
TRiga_partite(TPartita* game);
|
TRiga_partite(TPartita* game);
|
||||||
TRiga_partite(const TRiga_partite& r);
|
TRiga_partite(const TRiga_partite& r);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user