Corretta gestione saldaconto in prima nota

git-svn-id: svn://10.65.10.50/trunk@1495 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-06-22 14:46:26 +00:00
parent a333ab9f04
commit 9e1604c531
6 changed files with 96 additions and 67 deletions

View File

@ -151,21 +151,21 @@ TMask* TPrimanota_application::load_mask(int n)
bool TPrimanota_application::user_create()
{
_tabcom = new TLocalisamfile(LF_TABCOM);
_tab = new TLocalisamfile(LF_TAB);
_caus = new TLocalisamfile(LF_CAUSALI);
_rcaus = new TLocalisamfile(LF_RCAUSALI);
_clifo = new TLocalisamfile(LF_CLIFO);
_pcon = new TLocalisamfile(LF_PCON);
_attiv = new TLocalisamfile(LF_ATTIV);
_saldo = new TLocalisamfile(LF_SALDI);
_comuni = new TLocalisamfile(LF_COMUNI);
_occas = new TLocalisamfile(LF_OCCAS);
_nditte = new TLocalisamfile(LF_NDITTE);
_tabcom = new TLocalisamfile(LF_TABCOM);
_tab = new TLocalisamfile(LF_TAB);
_caus = new TLocalisamfile(LF_CAUSALI);
_rcaus = new TLocalisamfile(LF_RCAUSALI);
_clifo = new TLocalisamfile(LF_CLIFO);
_pcon = new TLocalisamfile(LF_PCON);
_attiv = new TLocalisamfile(LF_ATTIV);
_saldo = new TLocalisamfile(LF_SALDI);
_comuni = new TLocalisamfile(LF_COMUNI);
_occas = new TLocalisamfile(LF_OCCAS);
_nditte = new TLocalisamfile(LF_NDITTE);
_scadenze = new TLocalisamfile(LF_SCADENZE);
_rel = new TMovimentoPN;
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
_rel->add(LF_PARTITE, "NREG=NUMREG", 3);
_causale = new TCausale();
_giornale = new TLibro_giornale();

View File

@ -14,6 +14,12 @@
// Funzioni di decodifica/calcolo
///////////////////////////////////////////////////////////
HIDDEN char row_type(const TToken_string& s)
{
const int l = s.len()-1;
return l > 0 ? s[l] : ' ';
}
// Determina il tipo IVA da causale+anno
// Certified 100%
TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva)
@ -107,7 +113,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
TSheet_field& s = app().cgs();
const int sel = s.selected();
TToken_string& row = app().cgs().row(sel);
if (row.get_char(2) > ' ')
if (row_type(row) <= ' ')
{
const int currig = sel+1;
@ -176,18 +182,12 @@ bool TPrimanota_application::detraibile(TToken_string& row)
// Funzioni di ricerca
///////////////////////////////////////////////////////////
HIDDEN char row_type(const TToken_string& s)
{
const int l = s.len()-1;
return l > 0 ? s[l] : ' ';
}
int TPrimanota_application::type2pos(char tipo)
{
TSheet_field& cg = app().cgs();
TString_array& cg = app().cgs().rows_array();
for (int i = 0; i < cg.items(); i++)
{
TToken_string& s = cg.row(i);
const TToken_string& s = cg.row(i);
const char t = row_type(s);
if (t == tipo)
return i;
@ -199,7 +199,7 @@ int TPrimanota_application::type2pos(char tipo)
// Trova nelle righe contabili un conto nelle righe di tipo prescelto
int TPrimanota_application::bill2pos(const TBill& conto, char tipo)
{
TSheet_field& cg = app().cgs();
TString_array& cg = app().cgs().rows_array();
for (int i = 0; i < cg.items(); i++)
{
TToken_string& s = cg.row(i);
@ -253,25 +253,28 @@ int TPrimanota_application::bill_used(const TBill& conto) const
return users;
}
/*
// Controlla se e' stato usata l'IVA detraibile o indetraibile nelle righe IVA
// Certified 90%
int TPrimanota_application::det_used(char det) const
{
int users = 0;
int TPrimanota_application::det_used(char det) const
{
int users = 0;
const bool detraib = det == 'D';
TString_array& arr = ivas().rows_array();
for (int i = 0; i < arr.items(); i++)
{
TToken_string& row = arr.row(i);
if (!row.empty_items())
{
const bool d = detraibile(row);
if (detraib == d) users++;
}
}
return users;
}
const bool detraib = det == 'D';
TString_array& arr = ivas().rows_array();
for (int i = 0; i < arr.items(); i++)
{
TToken_string& row = arr.row(i);
if (!row.empty_items())
{
const bool d = detraibile(row);
if (detraib == d) users++;
}
}
return users;
}
*/
///////////////////////////////////////////////////////////
// Gestione sheet CG
@ -284,16 +287,17 @@ TSheet_field& TPrimanota_application::cgs() const
}
// Certified 99%
// Scrive l'importo imp nella opportuna sezione della riga n
// Certified 100%
// Scrive l'importo imp nella opportuna colonna della riga n
void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp)
{
imp.add_to(cgs().row(n), 0);
cgs().force_update(n);
{
TSheet_field& s = cgs();
imp.add_to(s.row(n), 0);
s.force_update(n);
}
// Legge l'importo della riga n e lo ritorna col segno dovuto
// Certified 99%
// Certified 100%
TImporto TPrimanota_application::get_cgs_imp(int n)
{
TImporto importo;

View File

@ -331,6 +331,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
const TString16 numpart = m.get(F_NUMRIF);
const int anno = m.get_int(F_ANNORIF);
CHECK(anno > 1900, "Anno partita non valido");
char sezione = _rel->cg(0).get_char("SEZIONE"); // Dare/Avere
char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
@ -666,7 +667,7 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int rata, int rmo
bool TPrimanota_application::edit_scadenze(int anno, const char* num)
{
TString caption; caption.format("Pagamenti della partita %s dell'anno %d", num, anno);
TArray_sheet a(-1, -1, 0, 0, caption, "Rata|Data@10|Importo@15|Descrizione@50|Riga", 0x8);
TArray_sheet a(-1, -1, 0, 0, caption, "Rata|Data@10|Dare@15R|Avere@15R|Descrizione@50|Riga", 0x8);
TPartita& partita = _partite.partita(anno, num);
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione corrente
@ -685,14 +686,25 @@ bool TPrimanota_application::edit_scadenze(int anno, const char* num)
a.destroy();
long nr;
const char sez_par = partita.riga(1).get_char(PART_SEZ);
for (int s = 1; s <= partita.rate(); s++)
{
const TRectype& rata = partita.rata(s);
r.cut(0);
r.add(rata.get(SCAD_NRATA));
r.add(rata.get(SCAD_DATASCAD));
r.add(rata.get(SCAD_IMPORTO));
if (sez_par == 'A')
{
r.add(rata.get(SCAD_IMPORTO));
r.add("");
}
else
{
r.add("");
r.add(rata.get(SCAD_IMPORTO));
}
r.add(desc);
r.add("S");
nr = a.add(r);
@ -707,7 +719,17 @@ bool TPrimanota_application::edit_scadenze(int anno, const char* num)
r.cut(0);
r.add(s);
r.add(paga.get(PART_DATAREG));
r.add(paga.get(PART_IMPORTO));
const char sez = paga.get_char(PART_SEZ);
if (sez == 'D')
{
r.add(paga.get(PART_IMPORTO));
r.add("");
}
else
{
r.add(paga.get(PART_IMPORTO));
r.add("");
}
r.add(paga.get(PART_DESCR));
r.add(paga.get(PART_NRIGA));
nr = a.add(r);

View File

@ -7,7 +7,6 @@
// -------------------------------------------------------------------------
#include <signal.h>
#include <stdlib.h>
#include <applicat.h>
#include <isam.h>
@ -39,7 +38,7 @@ struct therec {
class CG4100_App : public TApplication
{
TString _year;
int _year;
char _optype;
TMask* _msk;
@ -56,7 +55,7 @@ public:
bool sort_mov();
bool sort_sal();
CG4100_App() : TApplication(), _year(4), _optype('S') {}
CG4100_App() : TApplication(), _optype('S') {}
virtual ~CG4100_App() {}
};
@ -102,7 +101,7 @@ bool CG4100_App::set_parms()
_msk->run();
if (_optype == 'S')
_year = _msk->get(FLD_CG41_YEAR);
_year = _msk->get_int(FLD_CG41_YEAR);
else
_year = 0;
@ -331,7 +330,6 @@ bool CG4100_App::sort_mov()
bool CG4100_App::sort_sal()
{
if (!set_parms())
return FALSE;
@ -345,7 +343,7 @@ bool CG4100_App::sort_sal()
fclose(fp);
int gruppo, conto;
const int year = atoi(_year);
const int year = _year;
long oldnumreg = 0L, sottoconto;
TProgind prnd(rmov.items(),
"Riordino archivio saldi in corso\nLettura archivio movimenti...",
@ -363,7 +361,7 @@ bool CG4100_App::sort_sal()
while (!rmov.eof())
{
if (_year == rmov.get(RMV_ANNOES))
if (_year == rmov.get_int(RMV_ANNOES))
{
numreg = rmov.get_long(RMV_NUMREG);
@ -398,7 +396,7 @@ bool CG4100_App::sort_sal()
datareg = mov.get_date(MOV_DATAREG);
sal.reset();
sal.set_anno_es(atoi(_year));
sal.set_anno_es(_year);
sal.set_movap(apertura);
sal.set_movprovv(provvis);
sal.set_data_ulmov(datareg);

View File

@ -86,7 +86,7 @@ TSaldo_agg::TSaldo_agg()
_num_ulmov = 0l;
_movap = FALSE;
_provv = FALSE;
// reset(); // INUTILE pulizia dell'array dei conti
// reset(); // INUTILE pulizia dell'array dei conti
}
void TSaldo_agg::aggiorna(const TBill& tc, const TImporto& imp, bool somma)
@ -163,7 +163,7 @@ void TSaldo_agg::registra()
{
THash_object* hobj = _tab_conti.get_hashobj();
TConto& tcon = (TConto &)hobj->obj();
CHECK(tcon.ok(), "Tentativo di saldare un conto incompleto");
CHECK(tcon.ok(), "Tentavi di saldare un conto incompleto, eh?");
saldi.zero();
saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)) );
@ -172,12 +172,11 @@ void TSaldo_agg::registra()
saldi.put(SLD_SOTTOCONTO, tcon.sottoconto());
bool update = TRUE;
if (saldi.read(_isequal, _lock) != NOERR)
{
saldi.zero();
// saldi.put(SLD_ANNOES, anno_es());
saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)) );
saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)));
saldi.put(SLD_GRUPPO, tcon.gruppo());
saldi.put(SLD_CONTO, tcon.conto());
saldi.put(SLD_SOTTOCONTO, tcon.sottoconto());
@ -238,7 +237,13 @@ void TSaldo_agg::registra()
r = saldi.get_real(SLD_PAVERE);
r += tcon.avere();
saldi.put(SLD_PAVERE, r);
saldi.rewrite();
const int err = saldi.rewrite();
if (err != NOERR)
{
yesnofatal_box("Errore %d nell'aggiornamento del saldo %d %d %ld",
err, tcon.gruppo(), tcon.conto(), tcon.sottoconto());
}
}
TImporto sf(flag_salini, si);

View File

@ -948,9 +948,9 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
{
TToken_string& s = sf.row(-1);
scr += scad_rata(i);
s.add(format("%d",scr));
s.add(scr);
s.add(perc_rata(i).string());
s.add(format("%d",tipo_rata(i)));
s.add(tipo_rata(i));
s.add(desc_tipo(tipo_rata(i)));
s.add(ulc_rata(i));
}
@ -1086,7 +1086,7 @@ int TPartita::ultimo_pagamento(int rata) const
const TRectype& paga = riga(p);
if (paga.get_int(PART_NRATA) == rata)
{
int u = paga.get_int(PART_NRIGA); // Non pretende che siano in ordine
const int u = paga.get_int(PART_NRIGA); // Non pretende che siano in ordine
if (u > ultimo) ultimo = u;
}
}