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 _tabcom;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -241,6 +240,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
TMask& cgm = cgs().sheet_mask();
|
||||
cgm.set_handler(100, _is_saldaconto ? showpartite_handler : NULL); // bottoncino riga
|
||||
cgm.enable(100, _is_saldaconto);
|
||||
m->show(S_TIPORIGA, _is_saldaconto);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -282,8 +282,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
if (tc.tipo() > ' ' && tc.ok())
|
||||
{
|
||||
const TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
|
||||
if (clifo.conto() != 0)
|
||||
TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
|
||||
if (clifo.find() && clifo.conto() != 0) // Legge gruppo e conto
|
||||
tc = clifo;
|
||||
}
|
||||
|
||||
@ -308,10 +308,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
{
|
||||
char tipr = ' ';
|
||||
if (_is_saldaconto)
|
||||
{
|
||||
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);
|
||||
if (sezione > ' ' && tipr != ' ')
|
||||
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
|
||||
{
|
||||
if (_iva != nessuna_iva || !_is_saldaconto)
|
||||
if (_iva != nessuna_iva || !is_saldaconto())
|
||||
{
|
||||
TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG);
|
||||
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_STAMPATO 143
|
||||
#define F_REGST 144
|
||||
#define F_SHEETCG 300
|
||||
#define F_SHEETIVA 301
|
||||
#define F_SHEETCG 190
|
||||
#define F_SHEETIVA 191
|
||||
|
||||
// Campi ripetuti sulla seconda pagina
|
||||
#define H_DATAREG 201
|
||||
@ -102,27 +102,28 @@
|
||||
#define I_SOTTOCONTO4 234
|
||||
|
||||
// Saldaconto
|
||||
#define S_TOTDOC 401
|
||||
#define S_TOTDOCVAL 402
|
||||
#define S_VALUTA 403
|
||||
#define S_DATACAMBIO 404
|
||||
#define S_CAMBIO 405
|
||||
#define S_TOTDOC 301
|
||||
#define S_TOTDOCVAL 302
|
||||
#define S_VALUTA 303
|
||||
#define S_DATACAMBIO 304
|
||||
#define S_CAMBIO 305
|
||||
#define S_TIPORIGA 306
|
||||
|
||||
// copie 2a pag.
|
||||
#define K_CODDITTA 501
|
||||
#define K_RAGSOC 502
|
||||
#define K_DATAREG 503
|
||||
#define K_NUMREG 504
|
||||
#define K_CODCAUS 505
|
||||
#define K_DESCRCAUS 506
|
||||
#define K_DOCUMENTO 507
|
||||
#define K_TIPODOC 508
|
||||
#define K_PROTIVA 509
|
||||
#define K_PROVVISORIO 510
|
||||
#define K_DESCR 511
|
||||
#define K_DATADOC 512
|
||||
#define K_NUMDOC 513
|
||||
#define K_ANNOES 514
|
||||
#define K_DATACOMP 515
|
||||
#define K_CODDITTA 401
|
||||
#define K_RAGSOC 402
|
||||
#define K_DATAREG 403
|
||||
#define K_NUMREG 404
|
||||
#define K_CODCAUS 405
|
||||
#define K_DESCRCAUS 406
|
||||
#define K_DOCUMENTO 407
|
||||
#define K_TIPODOC 408
|
||||
#define K_PROTIVA 409
|
||||
#define K_PROVVISORIO 410
|
||||
#define K_DESCR 411
|
||||
#define K_DATADOC 412
|
||||
#define K_NUMDOC 413
|
||||
#define K_ANNOES 414
|
||||
#define K_DATACOMP 415
|
||||
|
||||
#endif
|
||||
|
@ -320,10 +320,17 @@ END
|
||||
|
||||
STRING K_NUMDOC 7
|
||||
BEGIN
|
||||
PROMPT 56 7 "Documento n. "
|
||||
PROMPT 38 7 "Num. "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
LIST S_TIPORIGA 1 13
|
||||
BEGIN
|
||||
PROMPT 60 7 "Riga "
|
||||
ITEM "K|Saldaconto"
|
||||
ITEM "S|Spese"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEETCG
|
||||
BEGIN
|
||||
PROMPT 0 8 ""
|
||||
|
130
cg/cg2102.cpp
130
cg/cg2102.cpp
@ -99,36 +99,46 @@ real TPrimanota_application::totale_documento()
|
||||
bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (k == K_SPACE)
|
||||
if (m.get(116) == "K")
|
||||
{
|
||||
TSheet_field& s = app().cgs();
|
||||
TSheet_field& s = *m.get_sheet();
|
||||
const int riga = s.selected();
|
||||
const bool dirty = app().edit_partite(riga);
|
||||
if (dirty) k = K_ENTER;
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
TSheet_field& s = app().cgs();
|
||||
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);
|
||||
TImporto importo; importo = row;
|
||||
TImporto speso = app()._partite.importo_speso(curreg, currig);
|
||||
|
||||
if (importo != speso)
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
ok = yesno_box("L'importo dei pagamenti %c %s\ne' diverso dall'importo sulla riga %d.\n"
|
||||
"Si desidera correggerlo?", speso.sezione(), speso.valore().string("."), currig);
|
||||
if (ok)
|
||||
const bool dirty = app().edit_partite(riga);
|
||||
if (dirty)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const bool dare = speso.sezione() == 'D';
|
||||
m.set(101, dare ? speso.valore().string() : "");
|
||||
m.set(102, dare ? "" : speso.valore().string());
|
||||
if (m.field(103).enabled())
|
||||
app().disable_cgs_cells(riga, 'K');
|
||||
k = K_ENTER;
|
||||
}
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
const int currig = riga+1;
|
||||
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
||||
TImporto importo;
|
||||
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)
|
||||
{
|
||||
ok = yesno_box("L'importo dei pagamenti %c %s\ne' diverso dall'importo sulla riga %d.\n"
|
||||
"Si desidera correggerlo?", speso.sezione(), speso.valore().string("."), currig);
|
||||
if (ok)
|
||||
{
|
||||
const bool dare = speso.sezione() == 'D';
|
||||
m.set(101, dare ? speso.valore().string() : "");
|
||||
m.set(102, dare ? "" : speso.valore().string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -468,7 +478,7 @@ void TPrimanota_application::cgs_pack()
|
||||
TToken_string& r = rows.row(i);
|
||||
if (can_remove(r))
|
||||
{
|
||||
if (salda && row_type(r) == ' ')
|
||||
if (salda && row_type(r) == 'K')
|
||||
cg_notify(cgs(), i, K_DEL);
|
||||
rows.destroy(i, salda);
|
||||
}
|
||||
@ -558,7 +568,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
||||
empty = FALSE;
|
||||
|
||||
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 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);
|
||||
else return FALSE;
|
||||
}
|
||||
if (tipo != 'K' && !speso.is_zero())
|
||||
{
|
||||
r.add("K", -2);
|
||||
app().disable_cgs_cells(i, 'K');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -700,26 +705,45 @@ void TPrimanota_application::generazione_righe_cg(int r)
|
||||
|
||||
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)
|
||||
{
|
||||
case K_SPACE:
|
||||
{
|
||||
const char tipo = row_type(cg.row(r));
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ');
|
||||
case K_TAB:
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K');
|
||||
cg.sheet_mask().show(100, tipo == 'K');
|
||||
break;
|
||||
case K_ENTER:
|
||||
if (app().iva() == nessuna_iva)
|
||||
app().generazione_righe_cg(r);
|
||||
app().calcola_saldo();
|
||||
break;
|
||||
case K_DEL:
|
||||
if (tipo == 'K')
|
||||
app().notify_cgline_deletion(r+1);
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case K_ENTER:
|
||||
if (app().iva() == nessuna_iva)
|
||||
app().generazione_righe_cg(r);
|
||||
app().calcola_saldo();
|
||||
break;
|
||||
case K_DEL:
|
||||
if (app().is_saldaconto() && app().iva() == nessuna_iva)
|
||||
app().notify_cgline_deletion(r+1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1739,8 +1763,6 @@ bool TPrimanota_application::totale_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
app().add_cgs_tot(m);
|
||||
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())
|
||||
@ -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 ok = TRUE;
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
// app().add_cgs_tot_noiva(f.mask());
|
||||
}
|
||||
if (key == K_ENTER && f.get().empty())
|
||||
ok = f.yesno_box("Totale documento nullo: continuare ugualmente?");
|
||||
return ok;
|
||||
@ -1850,7 +1868,7 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key)
|
||||
const real cambio = m.get(F_CAMBIOINTRA);
|
||||
if (cambio != ZERO && m.get(F_CORRVALUTA).empty())
|
||||
{
|
||||
real c = f.get();
|
||||
real c(f.get());
|
||||
c /= cambio;
|
||||
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(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);
|
||||
bool link_m770();
|
||||
|
||||
|
348
cg/cg2105.cpp
348
cg/cg2105.cpp
@ -15,6 +15,7 @@
|
||||
class TGame_mask : public TMask
|
||||
{
|
||||
const TBill _conto; // Conto fisso
|
||||
int _riga_partite;
|
||||
|
||||
protected:
|
||||
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);
|
||||
n.set_dirty();
|
||||
numpart_handler(f, k);
|
||||
numpart_handler(n, k);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -123,6 +124,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
if (k == K_TAB)
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)partite.mask();
|
||||
gm._riga_partite = r;
|
||||
|
||||
TSheet_field& scadenze = gm.scadenze();
|
||||
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 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 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(rigp.get(PART_DESCR));
|
||||
row.add(rigp.get(PART_NUMDOC));
|
||||
row.add(rigp.get(PART_PROTIVA));
|
||||
row.add("");
|
||||
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);
|
||||
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;
|
||||
}
|
||||
@ -259,59 +265,52 @@ void TGame_mask::fill_partite(bool all) const
|
||||
|
||||
const TRectype filter(partita.curr()); // Record campione
|
||||
|
||||
int ultimo_anno = 0, anno; // Anno ultima partita
|
||||
TString16 ultimo_num, num; // Ultimo numero partita
|
||||
TToken_string r(80);
|
||||
|
||||
for (int err = partita.read(_isgteq); err == NOERR && partita.curr() == filter; err = partita.next())
|
||||
for (int err = partita.read(_isgteq);
|
||||
err == NOERR && partita.curr() == filter;
|
||||
err = partita.read(_isgreat))
|
||||
{
|
||||
anno = partita.get_int(PART_ANNO);
|
||||
num = partita.get(PART_NUMPART);
|
||||
const int anno = partita.get_int(PART_ANNO);
|
||||
const TString16 num(partita.get(PART_NUMPART));
|
||||
|
||||
if (ultimo_anno != anno && ultimo_num != num)
|
||||
TPartita* game = NULL;
|
||||
bool should_delete_game = FALSE;
|
||||
if (app().partite().exist(conto(), anno, num))
|
||||
game = &app().partite().partita(conto(), anno, num);
|
||||
else
|
||||
{
|
||||
TPartita* game = NULL;
|
||||
bool should_delete_game = FALSE;
|
||||
if (app().partite().exist(conto(), anno, num))
|
||||
game = &app().partite().partita(conto(), anno, num);
|
||||
else
|
||||
{
|
||||
game = new TPartita(conto(), anno, num);
|
||||
should_delete_game = TRUE;
|
||||
}
|
||||
|
||||
TImporto saldo, doc, pag, imp;
|
||||
game->calcola_saldo(saldo, doc, pag, imp);
|
||||
|
||||
if (all || !saldo.is_zero())
|
||||
{
|
||||
int riga_fatt = game->prima_fattura();
|
||||
if (riga_fatt < 1) riga_fatt = 1; // E' un anticipo
|
||||
|
||||
const TRiga_partite& riga = game->riga(riga_fatt);
|
||||
const TString16 data_doc = riga.get(PART_DATADOC);
|
||||
const TString16 num_doc = riga.get(PART_NUMDOC);
|
||||
const char*descr = riga.get(PART_DESCR);
|
||||
|
||||
r.cut(0);
|
||||
r.add(anno);
|
||||
r.add(num);
|
||||
r.add(data_doc);
|
||||
r.add(num_doc);
|
||||
add_importo(r, saldo);
|
||||
add_importo(r, doc);
|
||||
add_importo(r, pag);
|
||||
add_importo(r, imp);
|
||||
r.add(descr);
|
||||
a.add(r); // Aggiunge partita alla lista
|
||||
}
|
||||
|
||||
if (should_delete_game)
|
||||
delete game;
|
||||
|
||||
ultimo_anno = anno;
|
||||
ultimo_num = num;
|
||||
game = new TPartita(conto(), anno, num);
|
||||
should_delete_game = TRUE;
|
||||
}
|
||||
|
||||
TImporto saldo, doc, pag, imp;
|
||||
game->calcola_saldo(saldo, doc, pag, imp);
|
||||
|
||||
if (all || !saldo.is_zero())
|
||||
{
|
||||
int riga_fatt = game->prima_fattura();
|
||||
if (riga_fatt < 1) riga_fatt = game->first(); // E' un anticipo
|
||||
|
||||
const TRiga_partite& riga = game->riga(riga_fatt);
|
||||
const TString16 data_doc = riga.get(PART_DATADOC);
|
||||
const TString16 num_doc = riga.get(PART_NUMDOC);
|
||||
const char*descr = riga.get(PART_DESCR);
|
||||
|
||||
TToken_string &r = partite().row(-1); // Stringa di lavoro per lo sheet
|
||||
r.add(anno);
|
||||
r.add(num);
|
||||
r.add(data_doc);
|
||||
r.add(num_doc);
|
||||
add_importo(r, saldo);
|
||||
add_importo(r, doc);
|
||||
add_importo(r, pag);
|
||||
add_importo(r, imp);
|
||||
r.add(descr);
|
||||
}
|
||||
|
||||
if (should_delete_game)
|
||||
delete game;
|
||||
|
||||
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
|
||||
}
|
||||
|
||||
partite().force_update();
|
||||
@ -449,42 +448,150 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
||||
|
||||
HIDDEN bool importo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (k == K_F8)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
f.set(m.get(S_IMPORTO));
|
||||
f.set(m.get(S_RESIDUO));
|
||||
k = K_TAB;
|
||||
}
|
||||
|
||||
if (f.to_check(k))
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
real i(f.get());
|
||||
const real tot(m.get(S_IMPORTO));
|
||||
if (i > tot)
|
||||
{
|
||||
warning_box("Non e' possibile inserire un importo superiore a ", tot.string("."));
|
||||
i = tot;
|
||||
f.set(i.string());
|
||||
}
|
||||
if (i == tot)
|
||||
const real i(f.get());
|
||||
const real tot(m.get(S_RESIDUO));
|
||||
if (i >= tot)
|
||||
m.set(S_SALDOACC, "S");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag)
|
||||
{
|
||||
const int nriga = new_pag.get_int(PAGSCA_NRIGA); // Riga fattura
|
||||
const TRiga_partite& parbas = p.riga(nriga);
|
||||
|
||||
const int nrata = new_pag.get_int(PAGSCA_NRATA); // Numero rata
|
||||
TRiga_scadenze& scaden = parbas.rata(nrata);
|
||||
|
||||
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); // Riga pagamento
|
||||
const TRectype& old_pag = scaden.row(nrigp);
|
||||
const TRiga_partite& somma = p.riga(nrigp);
|
||||
|
||||
const char sez = somma.sezione(); // Sezione importo e ritenute
|
||||
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
|
||||
|
||||
// Aggiornamento contopartita
|
||||
const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO));
|
||||
TBill old_conto; old_conto.get(old_pag, TRUE);
|
||||
|
||||
const TImporto new_importo(controsez, new_pag.get_real(PAGSCA_IMPORTO));
|
||||
TBill new_conto; new_conto.get(new_pag, TRUE);
|
||||
|
||||
if (old_importo != new_importo || old_conto != new_conto)
|
||||
{
|
||||
const int old_riga = bill2pos(old_conto, 'I');
|
||||
if (old_riga >= 0)
|
||||
sub_cgs_imp(old_riga, old_importo);
|
||||
|
||||
// Importo della contropartita
|
||||
if (!new_importo.is_zero())
|
||||
{
|
||||
const int new_riga = bill2pos(new_conto, 'I');
|
||||
if (new_riga < 0)
|
||||
set_cgs_row(new_riga, new_importo, new_conto, "", 'I');
|
||||
else
|
||||
add_cgs_imp(new_riga, new_importo);
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiornamento ritenute
|
||||
const real old_ritenute(old_pag.get(PAGSCA_RITENUTE));
|
||||
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
||||
const TImporto grow_ritenute(controsez, new_ritenute-old_ritenute);
|
||||
if (!grow_ritenute.is_zero())
|
||||
{
|
||||
const riga = type2pos('F');
|
||||
if (riga < 0)
|
||||
{
|
||||
TBill conto_rit; causale().bill(11, conto_rit);
|
||||
set_cgs_row(riga, grow_ritenute, conto_rit, "", 'F');
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga, grow_ritenute);
|
||||
}
|
||||
|
||||
char old_ap, new_ap;
|
||||
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
||||
const bool empty = p.modifica_pagamento(new_pag,
|
||||
old_ap, old_abbuono, new_abbuono,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
|
||||
// Se c'e' differenza negli abbuoni
|
||||
if (old_abbuono != new_abbuono || old_ap != new_ap)
|
||||
{
|
||||
const int riga_contabile = app().cgs().selected();
|
||||
if (old_ap != ' ') // Se c'era un abbuono ...
|
||||
{
|
||||
const int riga_abb = type2pos(old_ap);
|
||||
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
||||
sub_cgs_imp(riga_abb, old_abbuono);
|
||||
|
||||
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
||||
add_cgs_imp(riga_contabile, old_abbuono);
|
||||
}
|
||||
if (new_ap != ' ') // Se ci sono abbuoni
|
||||
{
|
||||
const riga_abb = type2pos(new_ap);
|
||||
if (riga_abb < 0)
|
||||
{
|
||||
TBill conto_abb; causale().bill(new_ap == 'A' ? 9 : 8, conto_abb);
|
||||
app().set_cgs_row(riga_abb, new_abbuono, conto_abb, "", new_ap);
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga_abb, new_abbuono);
|
||||
sub_cgs_imp(riga_contabile, new_abbuono); // Aggiunge l'abbuono con la sezione invertita
|
||||
}
|
||||
}
|
||||
|
||||
// Se c'e' variazione nella differenza cambi
|
||||
if (old_diffcam != new_diffcam)
|
||||
{
|
||||
const int riga_diffcam = type2pos('C');
|
||||
if (!old_diffcam.is_zero()) // Se c'era una differenza cambi
|
||||
{
|
||||
CHECK(riga_diffcam >= 0, "Chiss'e' fregato la differenza cambi?");
|
||||
sub_cgs_imp(riga_diffcam, old_diffcam);
|
||||
}
|
||||
if (!new_diffcam.is_zero())
|
||||
{
|
||||
if (riga_diffcam < 0)
|
||||
{
|
||||
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
||||
set_cgs_row(riga_diffcam, new_diffcam, conto_diffcam, "", 'C');
|
||||
}
|
||||
else
|
||||
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);
|
||||
TRiga_scadenze& scaden = parbas.rata(nrata);
|
||||
const TRectype& oldpag = scaden.row(nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
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.get(SCAD_CODVAL).not_empty();
|
||||
const bool in_valuta = scaden.in_valuta();
|
||||
m.show(S_IMPORTOVAL_SCAD, in_valuta);
|
||||
m.show(S_IMPORTOVAL, in_valuta);
|
||||
|
||||
@ -510,16 +617,6 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
||||
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)
|
||||
{
|
||||
@ -535,93 +632,8 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
||||
}
|
||||
|
||||
m.autosave(&rel);
|
||||
const TRectype& paga = rel.lfile().curr();
|
||||
|
||||
const TImporto new_importo(controsez, paga.get_real(PART_IMPORTO));
|
||||
if (old_importo != new_importo)
|
||||
{
|
||||
if (old_riga >= 0)
|
||||
sub_cgs_imp(old_riga, old_importo);
|
||||
|
||||
// Importo della contropartita
|
||||
if (!new_importo.is_zero())
|
||||
{
|
||||
TBill new_conto; new_conto.get(paga, TRUE);
|
||||
const int riga = bill2pos(new_conto, 'I');
|
||||
if (riga < 0)
|
||||
set_cgs_row(riga, new_importo, new_conto, m.get(S_DESCAGG), 'I');
|
||||
else
|
||||
add_cgs_imp(riga, new_importo);
|
||||
}
|
||||
}
|
||||
|
||||
const real rit(m.get(S_RITENUTE)); // Valore ritenute fiscali
|
||||
const TImporto grow_ritenute(controsez, rit-old_ritenute.valore());
|
||||
if (!grow_ritenute.is_zero())
|
||||
{
|
||||
const riga = type2pos('F');
|
||||
if (riga < 0)
|
||||
{
|
||||
TBill conto_rit; causale().bill(11, conto_rit);
|
||||
set_cgs_row(riga, grow_ritenute, conto_rit, "", 'F');
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga, grow_ritenute);
|
||||
}
|
||||
|
||||
char old_ap, new_ap;
|
||||
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
||||
const bool empty = p.modifica_pagamento(paga,
|
||||
old_ap, old_abbuono, new_abbuono,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
|
||||
// Se c'e' differenza negli abbuoni
|
||||
if (old_abbuono != new_abbuono || old_ap != new_ap)
|
||||
{
|
||||
const int riga_contabile = app().cgs().selected();
|
||||
if (old_ap != ' ') // Se c'era un abbuono ...
|
||||
{
|
||||
const int riga_abb = type2pos(old_ap);
|
||||
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
||||
sub_cgs_imp(riga_abb, old_abbuono);
|
||||
|
||||
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
||||
add_cgs_imp(riga_contabile, old_abbuono);
|
||||
}
|
||||
if (new_ap != ' ') // Se ci sono abbuoni
|
||||
{
|
||||
const riga_abb = type2pos(new_ap);
|
||||
if (riga_abb < 0)
|
||||
{
|
||||
TBill conto_abb; causale().bill(new_ap == 'A' ? 9 : 8, conto_abb);
|
||||
app().set_cgs_row(riga_abb, new_abbuono, conto_abb, "", new_ap);
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga_abb, new_abbuono);
|
||||
sub_cgs_imp(riga_contabile, new_abbuono); // Aggiunge l'abbuono con la sezione invertita
|
||||
}
|
||||
}
|
||||
|
||||
// Se c'e' variazione nella differenza cambi
|
||||
if (old_diffcam != new_diffcam)
|
||||
{
|
||||
const int riga_diffcam = type2pos('C');
|
||||
if (!old_diffcam.is_zero()) // Se c'era una differenza cambi
|
||||
{
|
||||
CHECK(riga_diffcam >= 0, "Chiss'e' fregato la differenza cambi?");
|
||||
sub_cgs_imp(riga_diffcam, old_diffcam);
|
||||
}
|
||||
if (!new_diffcam.is_zero())
|
||||
{
|
||||
if (riga_diffcam < 0)
|
||||
{
|
||||
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
||||
set_cgs_row(riga_diffcam, new_diffcam, conto_diffcam, "", 'C');
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga_diffcam, new_diffcam);
|
||||
}
|
||||
}
|
||||
TRectype& new_pag = rel.lfile().curr();
|
||||
notify_edit_pagamento(p, new_pag);
|
||||
}
|
||||
|
||||
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 found = FALSE;
|
||||
const int riga_ritenute = type2pos('F');
|
||||
|
||||
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);
|
||||
if (numrig > 0)
|
||||
{
|
||||
|
||||
}
|
||||
else // numrig == 0
|
||||
{
|
||||
|
@ -351,6 +351,7 @@ BEGIN
|
||||
ITEM "D|IVA detraibile"
|
||||
ITEM "F|Ritenute fiscali"
|
||||
ITEM "I|Riga di IVA"
|
||||
ITEM "K|Riga Cliente/Fornitore"
|
||||
ITEM "N|IVA non detraibile"
|
||||
ITEM "S|Ritenute sociali"
|
||||
ITEM "T|Totale documento"
|
||||
|
@ -1205,16 +1205,17 @@ int TTree_rectype::remove(TBaseisamfile& f)
|
||||
// TRiga_scadenze
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TRiga_scadenze::TRiga_scadenze(TRiga_partite* riga)
|
||||
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(riga)
|
||||
TRiga_scadenze::TRiga_scadenze(TRiga_partite* r)
|
||||
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(r)
|
||||
{
|
||||
zero();
|
||||
CHECK(_riga, "Riga nulla");
|
||||
}
|
||||
|
||||
TRiga_scadenze::TRiga_scadenze(const TRiga_scadenze& s)
|
||||
: TTree_rectype(s), _riga(s._riga)
|
||||
|
||||
{
|
||||
zero();
|
||||
CHECK(_riga, "Riga nulla");
|
||||
}
|
||||
|
||||
TPartita& TRiga_scadenze::partita() const
|
||||
@ -1423,12 +1424,14 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
|
||||
TRiga_partite::TRiga_partite(TPartita* game)
|
||||
: TTree_rectype(LF_PARTITE, LF_SCADENZE, "NRATA"), _partita(game)
|
||||
{
|
||||
zero();
|
||||
CHECK(_partita, "Partita nulla");
|
||||
}
|
||||
|
||||
TRiga_partite::TRiga_partite(const TRiga_partite& r)
|
||||
: TTree_rectype(r), _partita(r._partita)
|
||||
{}
|
||||
{
|
||||
CHECK(_partita, "Partita nulla");
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
err = _recarr.read(s); // Deve esistere almento una scadenza
|
||||
#ifdef DBG
|
||||
if (err != NOERR)
|
||||
if (_recarr.rows() == 0)
|
||||
yesnofatal_box("Riga di fattura senza nessuna scadenza");
|
||||
#endif
|
||||
}
|
||||
@ -1494,6 +1497,11 @@ bool TPartita::read(const TBill& clifo, int anno, const char* num)
|
||||
partita->put(PART_NUMPART, num); // Numero 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
|
||||
unas.zero();
|
||||
unas.put(PART_TIPOCF, partita->get(PART_TIPOCF)); // Copia chiave partite
|
||||
|
@ -226,7 +226,7 @@ public:
|
||||
bool in_valuta() 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_da_pagare(bool val) const;
|
||||
@ -256,7 +256,7 @@ public:
|
||||
int ultimo_pagamento(int rata) const;
|
||||
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(const TRiga_partite& r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user