Patch level : 12.00 1278

Files correlati     : cg2.exe
Commento            :

Correzione saldacontot per AGS
This commit is contained in:
Alessandro Bonazzi 2023-08-10 02:02:58 +02:00
parent 08be98bc92
commit a70e0bcdea
2 changed files with 50 additions and 5 deletions

View File

@ -1410,6 +1410,9 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
_num.trim();
_align = allineamento_corrente();
real dare;
real avere;
TRiga_partite* partita = new TRiga_partite(this); // Record campione della partita
TString16 str;
str << clifo.tipo();
@ -1428,10 +1431,29 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
partita->renum_key(PART_NUMPART, _num); // Numero partita
_part.read(partita);
TBit_array regs;
int firstrow =first();
bool changed = false;
for (int r = last(); r >= firstrow; r = pred(r))
{
TRiga_partite & row = riga(r);
long nreg = row.get_long(PART_NREG);
int rate = row.rate();
if (regs[nreg])
{
_part.destroy_row(r);
changed = true;
}
else
regs.set(nreg);
}
if (_part.exist(UNASSIGNED))
_part.destroy_row(UNASSIGNED); // Elimina riga saldo;
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati
partita->copy_key_to_row(*unas);
unas->put(PART_NRIGA, (int)UNASSIGNED);
unas->put(SCAD_NRATA, (int)UNASSIGNED);
@ -1439,6 +1461,29 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
if (_unassigned.rows() > 0 &&_part.rows() <= 0) // non assegnati orfani!
_unassigned.destroy_rows();
/*
TImporto saldo;
TImporto doc;
TImporto pag;
TImporto imp;
calcola_saldo(saldo, doc, pag, imp);
TImporto oldsaldo;
TImporto olddoc;
TImporto oldpag;
TImporto oldimp;
TRectype riga_saldo(LF_PARTITE);
read_saldo(riga_saldo,oldsaldo, olddoc, oldpag, oldimp, true);
if (saldo != oldsaldo || doc != olddoc || pag != oldpag || imp != oldimp)
write_saldo(true);
*/
if (changed)
rewrite();
return ok();
}
@ -1492,7 +1537,7 @@ int TPartita::write_saldo(bool re, TRectype* rec) const
}
int TPartita::read_saldo(TRectype& riga,
TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp)
TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp, bool low_level)
{
int err = NOERR;
@ -1504,7 +1549,7 @@ int TPartita::read_saldo(TRectype& riga,
sld.put(PART_NRIGA, (int)UNASSIGNED);
err = part.read();
if (err != NOERR)
if (err != NOERR && !low_level)
{
const TPartita p(riga);
err = p.write_saldo(false, &sld);

View File

@ -322,7 +322,7 @@ public:
static void carica_allineamento();
static char allineamento_richiesto(char tipocf);
static int read_saldo(TRectype& riga, TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp);
static int read_saldo(TRectype& riga, TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp, bool low_level = false);
static bool rileva_sempre_differenze_cambi();
int tipopag2causale(int tipo) const;