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:
parent
a333ab9f04
commit
9e1604c531
@ -165,7 +165,7 @@ bool TPrimanota_application::user_create()
|
|||||||
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
_scadenze = new TLocalisamfile(LF_SCADENZE);
|
||||||
|
|
||||||
_rel = new TMovimentoPN;
|
_rel = new TMovimentoPN;
|
||||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
|
_rel->add(LF_PARTITE, "NREG=NUMREG", 3);
|
||||||
|
|
||||||
_causale = new TCausale();
|
_causale = new TCausale();
|
||||||
_giornale = new TLibro_giornale();
|
_giornale = new TLibro_giornale();
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
// Funzioni di decodifica/calcolo
|
// 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
|
// Determina il tipo IVA da causale+anno
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva)
|
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();
|
TSheet_field& s = app().cgs();
|
||||||
const int sel = s.selected();
|
const int sel = s.selected();
|
||||||
TToken_string& row = app().cgs().row(sel);
|
TToken_string& row = app().cgs().row(sel);
|
||||||
if (row.get_char(2) > ' ')
|
if (row_type(row) <= ' ')
|
||||||
{
|
{
|
||||||
const int currig = sel+1;
|
const int currig = sel+1;
|
||||||
|
|
||||||
@ -176,18 +182,12 @@ bool TPrimanota_application::detraibile(TToken_string& row)
|
|||||||
// Funzioni di ricerca
|
// 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)
|
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++)
|
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);
|
const char t = row_type(s);
|
||||||
if (t == tipo)
|
if (t == tipo)
|
||||||
return i;
|
return i;
|
||||||
@ -199,7 +199,7 @@ int TPrimanota_application::type2pos(char tipo)
|
|||||||
// Trova nelle righe contabili un conto nelle righe di tipo prescelto
|
// Trova nelle righe contabili un conto nelle righe di tipo prescelto
|
||||||
int TPrimanota_application::bill2pos(const TBill& conto, char tipo)
|
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++)
|
for (int i = 0; i < cg.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string& s = cg.row(i);
|
TToken_string& s = cg.row(i);
|
||||||
@ -253,7 +253,9 @@ int TPrimanota_application::bill_used(const TBill& conto) const
|
|||||||
return users;
|
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 TPrimanota_application::det_used(char det) const
|
||||||
{
|
{
|
||||||
int users = 0;
|
int users = 0;
|
||||||
@ -272,6 +274,7 @@ int TPrimanota_application::det_used(char det) const
|
|||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Gestione sheet CG
|
// Gestione sheet CG
|
||||||
@ -284,16 +287,17 @@ TSheet_field& TPrimanota_application::cgs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Certified 99%
|
// Certified 100%
|
||||||
// Scrive l'importo imp nella opportuna sezione della riga n
|
// Scrive l'importo imp nella opportuna colonna della riga n
|
||||||
void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp)
|
void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp)
|
||||||
{
|
{
|
||||||
imp.add_to(cgs().row(n), 0);
|
TSheet_field& s = cgs();
|
||||||
cgs().force_update(n);
|
imp.add_to(s.row(n), 0);
|
||||||
|
s.force_update(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legge l'importo della riga n e lo ritorna col segno dovuto
|
// 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 TPrimanota_application::get_cgs_imp(int n)
|
||||||
{
|
{
|
||||||
TImporto importo;
|
TImporto importo;
|
||||||
|
@ -331,6 +331,7 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
|||||||
|
|
||||||
const TString16 numpart = m.get(F_NUMRIF);
|
const TString16 numpart = m.get(F_NUMRIF);
|
||||||
const int anno = m.get_int(F_ANNORIF);
|
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 sezione = _rel->cg(0).get_char("SEZIONE"); // Dare/Avere
|
||||||
char tipocf = _rel->cg(0).get_char("TIPOC"); // Cliente || Fornitore || Uncazzo
|
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)
|
bool TPrimanota_application::edit_scadenze(int anno, const char* num)
|
||||||
{
|
{
|
||||||
TString caption; caption.format("Pagamenti della partita %s dell'anno %d", num, anno);
|
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);
|
TPartita& partita = _partite.partita(anno, num);
|
||||||
|
|
||||||
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione corrente
|
const long curreg = curr_mask().get_long(F_NUMREG); // Numero registrazione corrente
|
||||||
@ -686,13 +687,24 @@ bool TPrimanota_application::edit_scadenze(int anno, const char* num)
|
|||||||
a.destroy();
|
a.destroy();
|
||||||
long nr;
|
long nr;
|
||||||
|
|
||||||
|
const char sez_par = partita.riga(1).get_char(PART_SEZ);
|
||||||
|
|
||||||
for (int s = 1; s <= partita.rate(); s++)
|
for (int s = 1; s <= partita.rate(); s++)
|
||||||
{
|
{
|
||||||
const TRectype& rata = partita.rata(s);
|
const TRectype& rata = partita.rata(s);
|
||||||
r.cut(0);
|
r.cut(0);
|
||||||
r.add(rata.get(SCAD_NRATA));
|
r.add(rata.get(SCAD_NRATA));
|
||||||
r.add(rata.get(SCAD_DATASCAD));
|
r.add(rata.get(SCAD_DATASCAD));
|
||||||
|
if (sez_par == 'A')
|
||||||
|
{
|
||||||
r.add(rata.get(SCAD_IMPORTO));
|
r.add(rata.get(SCAD_IMPORTO));
|
||||||
|
r.add("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r.add("");
|
||||||
|
r.add(rata.get(SCAD_IMPORTO));
|
||||||
|
}
|
||||||
r.add(desc);
|
r.add(desc);
|
||||||
r.add("S");
|
r.add("S");
|
||||||
nr = a.add(r);
|
nr = a.add(r);
|
||||||
@ -707,7 +719,17 @@ bool TPrimanota_application::edit_scadenze(int anno, const char* num)
|
|||||||
r.cut(0);
|
r.cut(0);
|
||||||
r.add(s);
|
r.add(s);
|
||||||
r.add(paga.get(PART_DATAREG));
|
r.add(paga.get(PART_DATAREG));
|
||||||
|
const char sez = paga.get_char(PART_SEZ);
|
||||||
|
if (sez == 'D')
|
||||||
|
{
|
||||||
r.add(paga.get(PART_IMPORTO));
|
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_DESCR));
|
||||||
r.add(paga.get(PART_NRIGA));
|
r.add(paga.get(PART_NRIGA));
|
||||||
nr = a.add(r);
|
nr = a.add(r);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <isam.h>
|
#include <isam.h>
|
||||||
@ -39,7 +38,7 @@ struct therec {
|
|||||||
|
|
||||||
class CG4100_App : public TApplication
|
class CG4100_App : public TApplication
|
||||||
{
|
{
|
||||||
TString _year;
|
int _year;
|
||||||
char _optype;
|
char _optype;
|
||||||
TMask* _msk;
|
TMask* _msk;
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ public:
|
|||||||
bool sort_mov();
|
bool sort_mov();
|
||||||
bool sort_sal();
|
bool sort_sal();
|
||||||
|
|
||||||
CG4100_App() : TApplication(), _year(4), _optype('S') {}
|
CG4100_App() : TApplication(), _optype('S') {}
|
||||||
virtual ~CG4100_App() {}
|
virtual ~CG4100_App() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ bool CG4100_App::set_parms()
|
|||||||
_msk->run();
|
_msk->run();
|
||||||
|
|
||||||
if (_optype == 'S')
|
if (_optype == 'S')
|
||||||
_year = _msk->get(FLD_CG41_YEAR);
|
_year = _msk->get_int(FLD_CG41_YEAR);
|
||||||
else
|
else
|
||||||
_year = 0;
|
_year = 0;
|
||||||
|
|
||||||
@ -331,7 +330,6 @@ bool CG4100_App::sort_mov()
|
|||||||
|
|
||||||
bool CG4100_App::sort_sal()
|
bool CG4100_App::sort_sal()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!set_parms())
|
if (!set_parms())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -345,7 +343,7 @@ bool CG4100_App::sort_sal()
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
int gruppo, conto;
|
int gruppo, conto;
|
||||||
const int year = atoi(_year);
|
const int year = _year;
|
||||||
long oldnumreg = 0L, sottoconto;
|
long oldnumreg = 0L, sottoconto;
|
||||||
TProgind prnd(rmov.items(),
|
TProgind prnd(rmov.items(),
|
||||||
"Riordino archivio saldi in corso\nLettura archivio movimenti...",
|
"Riordino archivio saldi in corso\nLettura archivio movimenti...",
|
||||||
@ -363,7 +361,7 @@ bool CG4100_App::sort_sal()
|
|||||||
|
|
||||||
while (!rmov.eof())
|
while (!rmov.eof())
|
||||||
{
|
{
|
||||||
if (_year == rmov.get(RMV_ANNOES))
|
if (_year == rmov.get_int(RMV_ANNOES))
|
||||||
{
|
{
|
||||||
numreg = rmov.get_long(RMV_NUMREG);
|
numreg = rmov.get_long(RMV_NUMREG);
|
||||||
|
|
||||||
@ -398,7 +396,7 @@ bool CG4100_App::sort_sal()
|
|||||||
datareg = mov.get_date(MOV_DATAREG);
|
datareg = mov.get_date(MOV_DATAREG);
|
||||||
|
|
||||||
sal.reset();
|
sal.reset();
|
||||||
sal.set_anno_es(atoi(_year));
|
sal.set_anno_es(_year);
|
||||||
sal.set_movap(apertura);
|
sal.set_movap(apertura);
|
||||||
sal.set_movprovv(provvis);
|
sal.set_movprovv(provvis);
|
||||||
sal.set_data_ulmov(datareg);
|
sal.set_data_ulmov(datareg);
|
||||||
|
@ -163,7 +163,7 @@ void TSaldo_agg::registra()
|
|||||||
{
|
{
|
||||||
THash_object* hobj = _tab_conti.get_hashobj();
|
THash_object* hobj = _tab_conti.get_hashobj();
|
||||||
TConto& tcon = (TConto &)hobj->obj();
|
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.zero();
|
||||||
saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)) );
|
saldi.put(SLD_ANNOES, atoi(hobj->key().left(4)) );
|
||||||
@ -176,7 +176,6 @@ void TSaldo_agg::registra()
|
|||||||
if (saldi.read(_isequal, _lock) != NOERR)
|
if (saldi.read(_isequal, _lock) != NOERR)
|
||||||
{
|
{
|
||||||
saldi.zero();
|
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_GRUPPO, tcon.gruppo());
|
||||||
saldi.put(SLD_CONTO, tcon.conto());
|
saldi.put(SLD_CONTO, tcon.conto());
|
||||||
@ -238,7 +237,13 @@ void TSaldo_agg::registra()
|
|||||||
r = saldi.get_real(SLD_PAVERE);
|
r = saldi.get_real(SLD_PAVERE);
|
||||||
r += tcon.avere();
|
r += tcon.avere();
|
||||||
saldi.put(SLD_PAVERE, r);
|
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);
|
TImporto sf(flag_salini, si);
|
||||||
|
@ -948,9 +948,9 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
|||||||
{
|
{
|
||||||
TToken_string& s = sf.row(-1);
|
TToken_string& s = sf.row(-1);
|
||||||
scr += scad_rata(i);
|
scr += scad_rata(i);
|
||||||
s.add(format("%d",scr));
|
s.add(scr);
|
||||||
s.add(perc_rata(i).string());
|
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(desc_tipo(tipo_rata(i)));
|
||||||
s.add(ulc_rata(i));
|
s.add(ulc_rata(i));
|
||||||
}
|
}
|
||||||
@ -1086,7 +1086,7 @@ int TPartita::ultimo_pagamento(int rata) const
|
|||||||
const TRectype& paga = riga(p);
|
const TRectype& paga = riga(p);
|
||||||
if (paga.get_int(PART_NRATA) == rata)
|
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;
|
if (u > ultimo) ultimo = u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user