Correzioni alla stampa estratti conto e solleciti

git-svn-id: svn://10.65.10.50/trunk@2666 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1996-03-05 17:34:14 +00:00
parent e91a2fc217
commit badcb05a70
4 changed files with 129 additions and 24 deletions

View File

@ -370,6 +370,7 @@ protected:
static TPartita* _sort_game;
static int ordina_pag(const void* pag1, const void* pag2);
void arrange_scaduto(const TPartita& game);
public:
TEC_row& row(int r) const { return (TEC_row&)operator[](r); }
@ -509,8 +510,7 @@ real TEC_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
delete arrpag;
scaduto_rata.normalize(sezione);
const bool total_payed = scaduto_rata.valore().sign() <= 0;
return total_payed ? ZERO : scaduto_rata.valore();
return scaduto_rata.valore();
}
TEC_row& TEC_array::new_row(const TRiga_partite& row, const TDate& data,
@ -636,12 +636,50 @@ void TEC_array::add_row(const TRiga_partite& row)
}
}
void TEC_array::arrange_scaduto(const TPartita& game)
{
const bool in_valuta = form().in_valuta() && row(0).in_valuta();
TImporto totpag(game.importo_pagato_unassigned(in_valuta));
const char sezione = game.conto().tipo() == 'C' ? 'A' : 'D';
totpag.normalize(sezione);
for (int r = items()-1; r >= 0; r--)
{
TEC_row& s = row(r);
real imp(s.scaduto());
if (imp.sign() < 0)
{
totpag += TImporto(sezione, -imp);
s.scaduto(ZERO);
}
}
for (r = 0; r < items() && totpag.valore() > ZERO; r++)
{
TEC_row& s = row(r);
real imp = s.scaduto();
if (imp.sign() > 0)
{
if (imp >= totpag.valore())
{
imp -= totpag.valore();
s.scaduto(imp);
totpag = TImporto(sezione, ZERO);
}
else
{
s.scaduto(ZERO);
totpag -= TImporto(sezione, imp);
}
}
}
}
TEC_array::TEC_array(const TPartita& game, const TEC_form* f)
: _form(f)
{
for (int r = game.last(); r > 0; r = game.pred(r))
add_row(game.riga(r));
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
for (r = items()-1; r >= 0; r--)
{
@ -656,8 +694,8 @@ TEC_array::TEC_array(const TPartita& game, const TEC_form* f)
}
}
}
sort();
arrange_scaduto(game);
}

View File

@ -122,22 +122,21 @@ int TStampaSol_application::print_sol()
const bool sel_tot_saldo = f.get_sel_tot_saldo(); // selezione sul saldo totale cliente
const real sel_importo(f.get_sel_importo()); // importo di selezione
const TDate data_limite_soll(f.data_limite_operazione());
const TDate data_limite_scad(f.data_limite_scaduto());
if (sel_tot_saldo)
{
TImporto saldo;
real saldo;
for (int err = partite.read(_isgteq);
err == NOERR && partite.curr() == filter;
err = partite.read(_isgreat))
{
TPartita game(partite.curr());
saldo += game.calcola_saldo_al(FALSE, data_limite_soll);
saldo += game.calcola_scaduto_al(FALSE, data_limite_scad);
partite.put(PART_NRIGA, 9999);
}
saldo.normalize(f.sezione_normale());
if (saldo.valore() < sel_importo)
if (saldo < sel_importo)
return 0;
partite.curr() = filter;
}
@ -146,9 +145,7 @@ int TStampaSol_application::print_sol()
err = partite.read(_isgreat))
{
TPartita game(partite.curr());
TImporto saldo(game.calcola_saldo_al(FALSE, data_limite_soll));
saldo.normalize(f.sezione_normale());
real saldo(game.calcola_scaduto_al(FALSE, data_limite_scad));
TImporto unreferenced; //Totale non assegnati per questa partita.
{
@ -174,7 +171,7 @@ int TStampaSol_application::print_sol()
}
}
if (sel_tot_saldo || unreferenced.valore() > 0 || saldo.valore() >= sel_importo )
if (sel_tot_saldo || (saldo > ZERO && saldo >= sel_importo ))
{
const bool printed = form().print_game(game);
if (printed)

View File

@ -263,7 +263,9 @@ static int val_compare(const void* o1, const void* o2) {
///////////////////////////////////////////////////////////
// TESSL_array
///////////////////////////////////////////////////////////
TPartita* TESSL_array::_sort_game = NULL;
// Calcola l'importo su di una riga di pagamento
TImporto TESSL_array::importo(const TPartita& game, const TRectype& pag, bool valuta) const
{
@ -309,19 +311,41 @@ TImporto& TESSL_array::importo_riga_scaduto(int n)
return *imp;
}
// Ordina i pagamenti in ordine di DATAPAG
int TESSL_array::ordina_pag(const void* pag1, const void* pag2)
{
const int r1 = (*(TRectype**)pag1)->get_int(PAGSCA_NRIGP);
const TDate d1 = _sort_game->riga(r1).get(PART_DATAPAG);
const int r2 = (*(TRectype**)pag2)->get_int(PAGSCA_NRIGP);
const TDate d2 = _sort_game->riga(r2).get(PART_DATAPAG);
const int diff = d1 == d2 ? 0 : (d1 > d2 ? +1 : -1);
return diff;
}
real TESSL_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
{
const TPartita& game = rata.partita();
const char sezione = _form->sezione_normale();
const TPartita& game = rata.partita();
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
TImporto scaduto_rata = rata.importo(TRUE);
int riga_corrente_scaduto = 0;
const int lastp = rata.last(); // Ultimo pagamento sulla rata corrente
for (int p = rata.first(); p <= lastp; p = rata.succ(p)) // Qui bisogna andare in avanti!
const int numpag = rata.rows(); // Numero totale di pagamenti sulla rata
TRectype** arrpag = NULL; // Array di puntatori ai pagamenti
if (numpag > 0)
{
const TRectype& pag = rata.row(p);
arrpag = new TRectype*[numpag];
int i = 0;
for (int p = rata.last(); p > 0; p = rata.pred(p))
arrpag[i++] = (TRectype*)&rata.row(p); // Copia puntatori ai pagamenti nell'array
_sort_game = (TPartita*)&game; // Inizializza partita di appoggio al sort
qsort(arrpag, numpag, sizeof(TRectype*), ordina_pag);
}
for (int i = 0; i < numpag; i++)
{
const TRectype& pag = *arrpag[i];
const int nrigp = pag.get_int(PAGSCA_NRIGP);
const TRiga_partite& sum = game.riga(nrigp);
TImporto imp = importo(game, pag, valuta);
@ -358,7 +382,7 @@ real TESSL_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
if (tm == tm_insoluto)
riga_corrente_scaduto = nrigp;
else
CHECKD(riga_corrente_scaduto > 0, "Pagamento insoluto senza insoluto ", p);
CHECKD(riga_corrente_scaduto > 0, "Pagamento insoluto senza insoluto ", nrigp);
importo_riga_scaduto(riga_corrente_scaduto) += imp;
}
else
@ -366,9 +390,12 @@ real TESSL_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
scaduto_rata += imp;
}
}
if (arrpag != NULL)
delete arrpag;
scaduto_rata.normalize(sezione);
const bool total_payed = scaduto_rata.valore().sign() <= 0;
return total_payed ? ZERO : scaduto_rata.valore();
return scaduto_rata.valore();
}
TESSL_row& TESSL_array::new_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int n)
@ -499,6 +526,45 @@ void TESSL_array::add_row(const TRiga_partite& row)
}
}
void TESSL_array::arrange_scaduto(const TPartita& game)
{
const bool in_valuta = form().in_valuta() && row(0).in_valuta();
TImporto totpag(game.importo_pagato_unassigned(in_valuta));
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
totpag.normalize(sezione);
for (int r = items()-1; r >= 0; r--)
{
TESSL_row& s = row(r);
real imp(s.scaduto());
if (imp.sign() < 0)
{
totpag += TImporto(sezione, imp);
s.scaduto(ZERO);
}
}
for (r = 0; r < items() && totpag.valore() >= ZERO; r++)
{
TESSL_row& s = row(r);
real imp = s.scaduto();
if (imp.sign() > 0)
{
if (imp >= totpag.valore())
{
imp -= totpag.valore();
s.scaduto(imp);
totpag = TImporto(sezione, ZERO);
}
else
{
s.scaduto(ZERO);
totpag -= TImporto(sezione, imp);
}
}
}
}
TESSL_array::TESSL_array(const TPartita& game, const TESSL_form* f)
:_form(f)
{
@ -518,8 +584,8 @@ TESSL_array::TESSL_array(const TPartita& game, const TESSL_form* f)
}
}
}
sort();
arrange_scaduto(game);
}

View File

@ -193,7 +193,11 @@ protected:
TImporto& importo_riga_scaduto(int n);
TImporto importo(const TPartita& game, const TRectype& pag, bool valuta) const;
static TPartita* _sort_game;
static int ordina_pag(const void* pag1, const void* pag2);
void arrange_scaduto(const TPartita& game);
public:
TESSL_row& row(int r) const { return (TESSL_row&)operator[](r); }