Gestione saldaconto
git-svn-id: svn://10.65.10.50/trunk@1748 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5a41ac1e94
commit
4d0047fe74
@ -310,8 +310,10 @@ 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 = 'G';
|
||||
}
|
||||
const int pos = set_cgs_row(-1, zero, tc, desc, tipr);
|
||||
if (sezione > ' ' && tipr != ' ')
|
||||
cgs().disable_cell(pos, sezione == 'A' ? 0 : 1);
|
||||
|
@ -179,19 +179,18 @@ BEGIN
|
||||
PROMPT 1 10 "Voci per saldaconto"
|
||||
END
|
||||
|
||||
NUMBER S_TOTDOC 15 0
|
||||
NUMBER S_TOTDOC 15
|
||||
BEGIN
|
||||
PROMPT 2 11 "Totale documento "
|
||||
FLAGS "R"
|
||||
PICTURE "."
|
||||
GROUP 5
|
||||
FIELD TOTDOC
|
||||
END
|
||||
|
||||
NUMBER S_TOTDOCVAL 15 2
|
||||
BEGIN
|
||||
PROMPT 44 11 "Totale in valuta "
|
||||
HELP ""
|
||||
FLAGS "R"
|
||||
PICTURE ".2"
|
||||
GROUP 3
|
||||
END
|
||||
@ -328,7 +327,8 @@ LIST S_TIPORIGA 1 13
|
||||
BEGIN
|
||||
PROMPT 60 7 "Riga "
|
||||
ITEM "K|Saldaconto"
|
||||
ITEM "S|Spese"
|
||||
ITEM "G|Spese"
|
||||
ITEM "A|Altro"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEETCG
|
||||
|
@ -54,6 +54,7 @@ NUMBER P_RESIDUO 15
|
||||
BEGIN
|
||||
PROMPT 1 3 "Residuo "
|
||||
FLAGS "D"
|
||||
PICTURE "."
|
||||
END
|
||||
|
||||
NUMBER P_ANNO 4
|
||||
|
@ -14,7 +14,7 @@
|
||||
// Funzioni di decodifica/calcolo
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HIDDEN char row_type(const TToken_string& s)
|
||||
char TPrimanota_application::row_type(const TToken_string& s)
|
||||
{
|
||||
const int l = s.len()-1;
|
||||
return l > 0 ? s[l] : ' ';
|
||||
@ -380,46 +380,41 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
|
||||
row.add(""); // Codice decrizione
|
||||
row.add(desc); // Descrizione aggiuntiva
|
||||
|
||||
switch(tipo) // Calcolo contropartita
|
||||
{
|
||||
case 'T':
|
||||
if (tipo == 'T') // Calcolo contropartita
|
||||
{
|
||||
TToken_string& irow = ivas().row(0);
|
||||
for (int i = 5; i < 10; i++)
|
||||
row.add(irow.get(i == 5 ? 5 : -1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const int pos = type2pos('T');
|
||||
if (pos >= 0)
|
||||
{
|
||||
TBill contro(cg.row(pos), 2, 0x3);
|
||||
row.add(contro.string(0x3));
|
||||
else
|
||||
{
|
||||
const int pos = type2pos('T');
|
||||
if (pos >= 0)
|
||||
{
|
||||
TBill contro(cg.row(pos), 2, 0x3);
|
||||
row.add(contro.string(0x3));
|
||||
}
|
||||
else row.add(" | | | | ");
|
||||
}
|
||||
else row.add(" | | | | ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
row << "| |" << tipo;
|
||||
row << "| |" << tipo;
|
||||
|
||||
disable_cgs_cells(n, tipo);
|
||||
cg.force_update(n);
|
||||
disable_cgs_cells(n, tipo);
|
||||
cg.force_update(n);
|
||||
|
||||
return n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
// Totale, Rit.Fisc., Rit.Soc., da riga IVA, riga contabile, IVA detr., IVA non detr.
|
||||
const char* const sort_order = "TFSI DNGAPRLC";
|
||||
const char* const sort_order = "TFSI DNAPRC";
|
||||
|
||||
const TToken_string* r1 = (const TToken_string*)*o1;
|
||||
const TToken_string* r2 = (const TToken_string*)*o2;
|
||||
const char c1 = row_type(*r1);
|
||||
const char c2 = row_type(*r2);
|
||||
const char c1 = app().row_type(*r1);
|
||||
const char c2 = app().row_type(*r2);
|
||||
return int(strchr(sort_order, c1) - strchr(sort_order, c2));
|
||||
}
|
||||
|
||||
@ -442,19 +437,19 @@ HIDDEN bool can_remove(TToken_string& s)
|
||||
void TPrimanota_application::cgs_pack()
|
||||
{
|
||||
TString_array& rows = cgs().rows_array();
|
||||
const bool salda = is_saldaconto() && iva() == nessuna_iva;
|
||||
const bool pagamento = is_saldaconto() && iva() == nessuna_iva;
|
||||
|
||||
for (int i = rows.items()-1; i >= 0; i--)
|
||||
{
|
||||
TToken_string& r = rows.row(i);
|
||||
if (can_remove(r))
|
||||
{
|
||||
if (salda && row_type(r) == 'K')
|
||||
if (pagamento && row_type(r) == 'K')
|
||||
cg_notify(cgs(), i, K_DEL);
|
||||
rows.destroy(i, salda);
|
||||
rows.destroy(i, TRUE);
|
||||
}
|
||||
}
|
||||
if (!salda)
|
||||
if (!pagamento) // Il pagamento e' gia' ordinato
|
||||
rows.sort(compare_rows); // Pack and sort array
|
||||
}
|
||||
|
||||
@ -676,13 +671,14 @@ void TPrimanota_application::generazione_righe_cg(int r)
|
||||
|
||||
bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
{
|
||||
int i; // Contatore nello switch
|
||||
const char tipo = row_type(cg.row(r)); // Tipo della riga in esame
|
||||
|
||||
switch(k)
|
||||
{
|
||||
case K_TAB:
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K');
|
||||
cg.sheet_mask().show(100, tipo == 'K');
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K' || tipo == 'G');
|
||||
cg.sheet_mask().enable(100, tipo == 'K');
|
||||
break;
|
||||
case K_ENTER:
|
||||
if (app().iva() == nessuna_iva)
|
||||
@ -697,10 +693,11 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
if (app().iva() == nessuna_iva && app().is_saldaconto())
|
||||
{
|
||||
const char tipo = app().curr_mask().get(S_TIPORIGA)[0];
|
||||
if (tipo == 'K')
|
||||
{
|
||||
switch (tipo)
|
||||
{
|
||||
case 'K':
|
||||
cg.row(r).add("K", 15);
|
||||
for (int i = 0; i < r; i++)
|
||||
for (i = 0; i < r; i++)
|
||||
{
|
||||
const TToken_string& row = cg.row(i);
|
||||
if (row_type(row) != 'K')
|
||||
@ -709,6 +706,12 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'G':
|
||||
cg.row(r).add("G", 15);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -226,6 +226,8 @@ protected:
|
||||
bool link_m770();
|
||||
|
||||
public:
|
||||
static char row_type(const TToken_string& s);
|
||||
|
||||
TPartite_array& partite() { return _partite; } // Partite editate
|
||||
int nuovo_pagamento(TPartita& p, int nriga, int rata, int rmov);
|
||||
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
|
||||
|
@ -167,6 +167,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri))
|
||||
{
|
||||
const TRiga_partite& riga = game->riga(ri);
|
||||
const bool in_valuta = riga.in_valuta();
|
||||
for (int ra = 1; ra <= riga.rate(); ra++)
|
||||
{
|
||||
const TRiga_scadenze& scad = riga.rata(ra);
|
||||
@ -179,13 +180,12 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
row.add(riga.get(PART_DATAREG));
|
||||
row.add(scad.get(SCAD_DATASCAD));
|
||||
row.add(scad.get(SCAD_IMPORTO));
|
||||
row.add(scad.get_real(SCAD_IMPORTOVAL).string(0, 2));
|
||||
row.add(in_valuta ? scad.get_real(SCAD_IMPORTOVAL).string(0, 2) : "");
|
||||
row.add(riga.get(PART_DESCR));
|
||||
row.add(riga.get(PART_NUMDOC));
|
||||
row.add(riga.get(PART_PROTIVA));
|
||||
|
||||
const int lastp = scad.last();
|
||||
const bool in_valuta = scad.in_valuta();
|
||||
for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa))
|
||||
{
|
||||
const TRiga_partite& rigp = game->riga(pa);
|
||||
@ -209,15 +209,17 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
TToken_string& sal = scadenze.row(scadenze.add(""));
|
||||
sal.add(ri);
|
||||
sal.add(ra);
|
||||
sal.add("");
|
||||
sal.add("");
|
||||
sal.add("");
|
||||
sal.add("");
|
||||
sal.add(scad.residuo(FALSE).string());
|
||||
sal.add(in_valuta ? scad.residuo(TRUE).string(0, 2) : "");
|
||||
if (scad.pagata())
|
||||
{
|
||||
sal.add("", 6);
|
||||
sal.add("");
|
||||
}
|
||||
else
|
||||
{
|
||||
sal.add(scad.residuo(FALSE).string(), 6);
|
||||
sal.add(in_valuta ? scad.residuo(TRUE).string(0, 2) : "");
|
||||
}
|
||||
sal.add("Saldo della rata "); sal << ra;
|
||||
sal.add("");
|
||||
sal.add("");
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,10 +247,11 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
|
||||
CHECK(nriga && nrata, "La riga della scadenza sembra vuota, ma tutti sanno che e' una balla!");
|
||||
|
||||
TPartita& game = app().partite().partita(bill, anno, numero);
|
||||
|
||||
int nrigp = m.get_int(112);
|
||||
if (nrigp == 0)
|
||||
{
|
||||
TPartita& game = app().partite().partita(bill, anno, numero);
|
||||
nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov);
|
||||
if (nrigp < 1)
|
||||
return f.error_box("La rata %d e' gia' stata pagata", nrata);
|
||||
@ -259,11 +262,14 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
const long cur_reg = cm.get_long(F_NUMREG);
|
||||
const long nreg = m.get_long(104);
|
||||
if (cur_reg != nreg)
|
||||
return f.error_box("Non si possono modificare pagamenti di movimenti diversi dal %ld",
|
||||
cur_reg);
|
||||
return f.error_box("Il movimento corrente e' il %ld", cur_reg);
|
||||
|
||||
const TRiga_scadenze& scad = game.rata(nriga, nrata);
|
||||
const int paga = scad.pagata();
|
||||
if (paga != 0 && paga != nrigp)
|
||||
return f.error_box("Pagamento non modificabile");
|
||||
}
|
||||
|
||||
TPartita& game = app().partite().partita(bill, anno, numero);
|
||||
const bool dirty = app().edit_pagamento(game, nriga, nrata, nrigp);
|
||||
|
||||
if (dirty)
|
||||
@ -319,7 +325,12 @@ void TGame_mask::update_partita(const TPartita& game, int prow) const
|
||||
r.add(riga.get(PART_DESCR));
|
||||
|
||||
if (prow >= 0)
|
||||
{
|
||||
TSheet_field& games = partite();
|
||||
games.force_update(prow);
|
||||
update_saldo_clifo();
|
||||
games.force_update(games.items()-1);
|
||||
}
|
||||
}
|
||||
|
||||
void TGame_mask::update_saldo_clifo() const
|
||||
@ -359,7 +370,7 @@ void TGame_mask::update_saldo_clifo() const
|
||||
}
|
||||
|
||||
void TGame_mask::fill_partite(bool all) const
|
||||
{
|
||||
{
|
||||
TString_array& a = partite().rows_array();
|
||||
a.destroy();
|
||||
|
||||
@ -403,8 +414,8 @@ void TGame_mask::fill_partite(bool all) const
|
||||
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
|
||||
}
|
||||
update_saldo_clifo();
|
||||
|
||||
partite().force_update();
|
||||
|
||||
if (a.items() > 0)
|
||||
partite_notify(partite(), 0, K_TAB);
|
||||
else
|
||||
@ -461,10 +472,12 @@ bool TPrimanota_application::edit_partite(int riga)
|
||||
{
|
||||
TToken_string& cgr = cgs().row(riga);
|
||||
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata
|
||||
if (!b.ok()) return FALSE;
|
||||
if (row_type(cgr) != 'K' || !b.ok())
|
||||
return FALSE;
|
||||
|
||||
TGame_mask mask(b); // Inizializzazione maschera di selezione partite
|
||||
mask.run();
|
||||
cgs().force_update();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -591,16 +604,16 @@ HIDDEN bool importo_handler(TMask_field& f, KEY k)
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (k == K_F8)
|
||||
{
|
||||
{
|
||||
f.set(m.get(S_RESIDUO));
|
||||
k = K_TAB;
|
||||
}
|
||||
|
||||
if (f.to_check(k))
|
||||
if (k == K_TAB && f.focusdirty())
|
||||
{
|
||||
const real i(f.get());
|
||||
const real tot(m.get(S_RESIDUO));
|
||||
if (i >= tot)
|
||||
const real res(m.get(S_RESIDUO));
|
||||
if (i >= res)
|
||||
m.set(S_SALDOACC, "S");
|
||||
}
|
||||
|
||||
@ -653,7 +666,6 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Aggiornamento ritenute
|
||||
const real old_ritenute(old_pag.get(PAGSCA_RITENUTE));
|
||||
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
||||
@ -778,7 +790,13 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
||||
// 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(TRUE).string()); // Residuo da pagare
|
||||
real res = scaden.residuo(TRUE);
|
||||
if (parbas.in_valuta())
|
||||
res += oldpag.get_real(PAGSCA_IMPORTOVAL);
|
||||
else
|
||||
res += oldpag.get_real(PAGSCA_IMPORTO);
|
||||
residuo.set(res.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));
|
||||
@ -826,7 +844,7 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
||||
{
|
||||
const TRiga_partite& sum = partita.riga(s);
|
||||
if (sum.get_long(PART_NREG) == nreg &&
|
||||
(numrig == 0 || sum.get_int(PART_NUMRIG) == numrig))
|
||||
(numrig <= 0 || sum.get_int(PART_NUMRIG) == numrig))
|
||||
{
|
||||
TRectype pag(scad.row(s));
|
||||
pag.zero(PAGSCA_IMPORTO);
|
||||
|
102
cg/saldacon.cpp
102
cg/saldacon.cpp
@ -10,17 +10,17 @@
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TTree_rectype::TTree_rectype(const TRectype& testa, const TRectype& riga, const char* num)
|
||||
: TRectype(testa), _recarr(riga, num)
|
||||
: TRectype(testa), _recarr(riga, num)
|
||||
{
|
||||
}
|
||||
|
||||
TTree_rectype::TTree_rectype(int testa, int riga, const char* num)
|
||||
: TRectype(testa), _recarr(riga, num)
|
||||
: TRectype(testa), _recarr(riga, num)
|
||||
{
|
||||
}
|
||||
|
||||
TTree_rectype::TTree_rectype(const TTree_rectype& t)
|
||||
: TRectype(t), _recarr(t._recarr)
|
||||
: TRectype(t), _recarr(t._recarr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ void TTree_rectype::copy_key_to_row(TRectype& row) const
|
||||
{
|
||||
const int numkey = 0; // Memento! Gli indici delle chiavi partono da zero!
|
||||
RecDes* recd = rec_des(); // Descrizione del record della testata
|
||||
|
||||
|
||||
row.zero();
|
||||
const KeyDes& kd = recd->Ky[numkey];
|
||||
for (int i = recd->Ky[numkey].NkFields-1; i >= 0; i--)
|
||||
@ -107,13 +107,13 @@ int TTree_rectype::remove(TBaseisamfile& f)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TRiga_scadenze::TRiga_scadenze(TRiga_partite* r)
|
||||
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(r)
|
||||
: TTree_rectype(LF_SCADENZE, LF_PAGSCA, "NRIGP"), _riga(r)
|
||||
{
|
||||
CHECK(_riga, "Riga nulla");
|
||||
}
|
||||
|
||||
TRiga_scadenze::TRiga_scadenze(const TRiga_scadenze& s)
|
||||
: TTree_rectype(s), _riga(s._riga)
|
||||
: TTree_rectype(s), _riga(s._riga)
|
||||
|
||||
{
|
||||
CHECK(_riga, "Riga nulla");
|
||||
@ -213,19 +213,19 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(bool update)
|
||||
TRectype& pag = row(riga_saldo);
|
||||
const TRiga_partite& sum = partita().riga(riga_saldo);
|
||||
const char sez = sum.sezione();
|
||||
|
||||
|
||||
if (update)
|
||||
{
|
||||
diffcam = importo_da_pagare(FALSE);
|
||||
diffcam += importo_pagato(FALSE);
|
||||
|
||||
|
||||
real a = pag.get_real(PAGSCA_ABBUONI);
|
||||
if (in_valuta())
|
||||
{
|
||||
a *= riga().get_real(PART_CAMBIO);
|
||||
a.round();
|
||||
}
|
||||
|
||||
|
||||
const TImporto abb_lit(sez, a);
|
||||
diffcam += abb_lit;
|
||||
diffcam.normalize(sez);
|
||||
@ -284,7 +284,7 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
|
||||
rows_array().destroy_row(nrigp);
|
||||
else
|
||||
row(nrigp) = new_pag;
|
||||
|
||||
|
||||
TImporto new_abbuono;
|
||||
new_ap = calcola_abbuono(new_abbuono, TRUE); // Calcolo abbuono in valuta
|
||||
|
||||
@ -320,22 +320,31 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
|
||||
return empty;
|
||||
}
|
||||
|
||||
bool TPartita::modifica_pagamento(const TRectype& new_pag)
|
||||
{
|
||||
char old_ap, new_ap;
|
||||
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
|
||||
return modifica_pagamento(new_pag,
|
||||
old_ap, old_abbuono, old_diffcam,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRiga_partite
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
TRiga_partite::TRiga_partite(TPartita* game)
|
||||
: TTree_rectype(LF_PARTITE, LF_SCADENZE, "NRATA"), _partita(game)
|
||||
: TTree_rectype(LF_PARTITE, LF_SCADENZE, SCAD_NRATA), _partita(game)
|
||||
{
|
||||
CHECK(_partita, "Partita nulla");
|
||||
}
|
||||
|
||||
TRiga_partite::TRiga_partite(const TRiga_partite& r)
|
||||
: TTree_rectype(r), _partita(r._partita)
|
||||
: TTree_rectype(r), _partita(r._partita)
|
||||
{
|
||||
CHECK(_partita, "Partita nulla");
|
||||
}
|
||||
|
||||
|
||||
TRiga_scadenze& TRiga_partite::new_row(int r)
|
||||
{
|
||||
if (r <= 0) r = last()+1;
|
||||
@ -383,18 +392,12 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
const char* sez, const char* val)
|
||||
{
|
||||
bool zero = FALSE;
|
||||
TImporto grow(nuo); grow -= vec; // Variazione al totale
|
||||
TImporto growth(nuo); growth -= vec; // Variazione al totale
|
||||
|
||||
if (!grow.is_zero())
|
||||
if (!growth.is_zero())
|
||||
{
|
||||
const char sezione = get_char(sez); // Sezione del totale
|
||||
TImporto totale;
|
||||
if (sezione > ' ') // Se c'era una sezione (e quindi un importo) ...
|
||||
totale.set(sezione, get_real(val)); // ... inizializza il totale
|
||||
else
|
||||
CHECKS(vec.is_zero(), "Sezione errata per l'importo ", val);
|
||||
|
||||
totale += grow; // incrementa il totale
|
||||
TImporto totale(get_char(sez), get_real(val));
|
||||
totale += growth; // incrementa il totale
|
||||
totale.normalize();
|
||||
put(sez, totale.sezione()); // Aggiorna il totale sul record
|
||||
put(val, totale.valore());
|
||||
@ -413,13 +416,13 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TPartita::TPartita(const TBill& clifo, int anno, const char* num)
|
||||
: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP")
|
||||
: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP")
|
||||
{
|
||||
read(clifo, anno, num);
|
||||
}
|
||||
|
||||
TPartita::TPartita()
|
||||
: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP")
|
||||
: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP")
|
||||
{}
|
||||
|
||||
// Costruisce le righe della partita
|
||||
@ -484,6 +487,12 @@ TRiga_partite& TPartita::nuova_riga()
|
||||
return nuova;
|
||||
}
|
||||
|
||||
TRiga_scadenze& TPartita::rata(int nriga, int nrata) const
|
||||
{
|
||||
if (nriga < 1) nriga = prima_fattura();
|
||||
const TRiga_partite& r = riga(nriga);
|
||||
return r.rata(nrata);
|
||||
}
|
||||
|
||||
TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const
|
||||
{
|
||||
@ -491,7 +500,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const
|
||||
|
||||
for (int r = last(); r > 0; r = pred(r))
|
||||
{
|
||||
const TRectype& part = riga(r);
|
||||
const TRiga_partite& part = riga(r);
|
||||
const long reg = part.get_long(PART_NREG);
|
||||
if (reg == nreg)
|
||||
{
|
||||
@ -504,7 +513,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const
|
||||
if (extra)
|
||||
{
|
||||
TImporto abbuoni(part.get_char(PART_SEZABB), part.get_real(PART_ABBUONI));
|
||||
if (part.get(PART_CODVAL).not_empty()) // Se e' in valuta
|
||||
if (part.in_valuta()) // Se e' in valuta
|
||||
{
|
||||
abbuoni.valore() *= part.get_real(PART_CAMBIO);
|
||||
abbuoni.valore().round();
|
||||
@ -569,7 +578,7 @@ int TPartita::prima_fattura(long nreg) const
|
||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||
if (tipomov == 1 || tipomov == 2)
|
||||
if (nreg == -1 || nreg == row.get_long(PART_NREG))
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -584,7 +593,7 @@ int TPartita::primo_pagamento(long nreg) const
|
||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||
if (tipomov == 3) // TBI controllare per insoluti (tipomov == 6)
|
||||
if (nreg == -1 || nreg == row.get_long(PART_NREG))
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -599,18 +608,18 @@ void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImp
|
||||
TImporto i(row.get_char(PART_SEZ), row.get_real(PART_IMPORTO));
|
||||
switch (row.get_int(PART_TIPOMOV))
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
doc += i; // documenti
|
||||
break;
|
||||
case 3:
|
||||
pag += i; // pagamenti
|
||||
break;
|
||||
default:
|
||||
imp += i; // altri importi
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
doc += i; // documenti
|
||||
break;
|
||||
case 3:
|
||||
pag += i; // pagamenti
|
||||
break;
|
||||
default:
|
||||
imp += i; // altri importi
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
TImporto abbuoni(row.get_char(PART_SEZABB), row.get_real(PART_ABBUONI));
|
||||
if (row.get(PART_CODVAL).not_empty())
|
||||
{
|
||||
@ -690,7 +699,7 @@ bool TPartita::modifica_pagamento(const TRectype& new_pag,
|
||||
|
||||
if (empty && !utilizzata(nrigp))
|
||||
_part.destroy_row(nrigp);
|
||||
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
@ -718,7 +727,7 @@ bool TPartita::chiusa(bool update)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (chiusa != forse_chiusa)
|
||||
{
|
||||
chiusa = forse_chiusa;
|
||||
@ -747,7 +756,7 @@ const TString& TPartite_array::key(const TBill& clifo, int anno, const char* num
|
||||
clifo.tipo(), clifo.gruppo(), clifo.conto(), clifo.sottoconto(), anno, num);
|
||||
return _key;
|
||||
}
|
||||
|
||||
|
||||
// Certified 99%
|
||||
TPartita* TPartite_array::find(const TBill& clifo, int anno, const char* num, bool create)
|
||||
{
|
||||
@ -820,7 +829,7 @@ int TPartite_array::add_reg_num(long nreg, int numrig)
|
||||
const TRectype filter(part);
|
||||
|
||||
TCursor cur(&rel, "", 2, &filter, &filter);
|
||||
|
||||
|
||||
for (cur = 0; cur.ok(); ++cur)
|
||||
{
|
||||
TPartita& p = partita(part); // Aggiungi partita se non esiste gia'
|
||||
@ -845,5 +854,4 @@ void TPartite_array::update_reg_num(long nreg, const TRectype& mov)
|
||||
for (TPartita* game = first(); game; game = next())
|
||||
game->update_reg_num(nreg, mov);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -74,12 +74,11 @@ protected: // TRecord_tree
|
||||
|
||||
public:
|
||||
int pagata() const; // Riga che chiude la rata o 0 se non pagata completamente
|
||||
|
||||
|
||||
bool in_valuta() const;
|
||||
|
||||
TPartita& partita() const;
|
||||
TRiga_partite& riga() const { CHECK(_riga, "Riga nulla"); return *_riga; } // Riga partite
|
||||
TRiga_partite& riga() const { return *_riga; } // Riga partite
|
||||
|
||||
TImporto importo_pagato(bool val) const;
|
||||
TImporto importo_da_pagare(bool val) const;
|
||||
@ -110,7 +109,8 @@ public:
|
||||
TRiga_scadenze& new_row(int r = -1);
|
||||
|
||||
int ultimo_pagamento(int rata) const;
|
||||
char sezione() const { return get_char("SEZ"); }
|
||||
char sezione() const { return get_char(PART_SEZ); }
|
||||
bool in_valuta() const { return get(PART_CODVAL).not_empty(); }
|
||||
|
||||
TPartita& partita() const { CHECK(_partita, "Partita nulla"); return *_partita; }
|
||||
|
||||
@ -132,6 +132,7 @@ public: // TObject
|
||||
public:
|
||||
TRiga_partite& riga(int r) const { return (TRiga_partite&)_part.row(r); }
|
||||
TRiga_partite& nuova_riga();
|
||||
TRiga_scadenze& rata(int nriga, int nrata) const;
|
||||
|
||||
int succ(int r) const { return _part.succ_row(r); }
|
||||
int pred(int r) const { return _part.pred_row(r); }
|
||||
@ -166,6 +167,7 @@ public:
|
||||
bool modifica_pagamento(const TRectype& new_pag,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam);
|
||||
bool modifica_pagamento(const TRectype& new_pag);
|
||||
|
||||
TPartita(const TBill& clifo, int anno, const char* num);
|
||||
TPartita();
|
||||
|
Loading…
x
Reference in New Issue
Block a user