Velocizzata e corretta stampa delloo scadenzario e dei solleciti

git-svn-id: svn://10.65.10.50/trunk@3741 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-10-09 14:19:27 +00:00
parent 51236253f8
commit 0c33db8d25
6 changed files with 198 additions and 150 deletions

View File

@ -15,11 +15,11 @@ int main(int argc,char** argv)
case 0:
sc2100(argc,argv); break;
case 1:
sc2200(argc,argv); break;
sc2200(argc,argv); break;
case 2:
sc2300(argc,argv); break;
sc2300(argc,argv); break;
case 3:
sc2400(argc,argv); break;
sc2400(argc,argv); break;
default:
error_box(usage);
}

View File

@ -1,4 +1,3 @@
#include "sc2102.h"
///////////////////////////////////////////////////////////

View File

@ -129,7 +129,7 @@ class TStampaScadenzario : public TPrintapp
// chiave per tali TAssoc_array e': TIPO+GRUPPO+CONTO+SOTTOCONTO+ANNO+NUMPART.
// prima di ricalcolare i non assegnati e' necessario guardare in questa cache, se esiste la
// chiave relativa alla partita, ed eventualmente utilizzare tale valore in memoria.
friend bool filter_func(const TRelation *); // Funzione di filtro [_datai.._dataf]
static bool filter_func(const TRelation *); // Funzione di filtro [_datai.._dataf]
public:
// print functions
@ -169,17 +169,23 @@ public:
inline TStampaScadenzario& app() {return (TStampaScadenzario&)main_app();}
bool filter_func(const TRelation *r)
{ // Filtro per rate saldate: se e' saldata e' ok solo quando
bool rt = FALSE; // e' abilitato il flag; se non e' saldata va sempre bene.
TLocalisamfile* scad = &(r->lfile(LF_SCADENZE));
bool saldata = scad->get_bool(SCAD_PAGATA);
if (!saldata || (saldata && app()._ratesald))
bool TStampaScadenzario::filter_func(const TRelation *r)
{
// Filtro per rate saldate: se e' saldata e' ok solo quando
// e' abilitato il flag; se non e' saldata va sempre bene.
/*
const TRectype& scad = r->curr(LF_SCADENZE);
const bool saldata = scad.get_bool(SCAD_PAGATA);
const bool ok = !saldata || (saldata && app()._ratesald);
*/
bool ok = app()._ratesald;
if (!ok)
{
rt=TRUE;
const TRectype& scad = r->curr();
ok = !scad.get_bool(SCAD_PAGATA);
}
return rt;
return ok;
}
void TStampaScadenzario::check_add_key_to_tl(tipo_pe p, int t)
@ -379,7 +385,7 @@ void TStampaScadenzario::calcola_pagamenti(real& imp_scad, int riga, int rata)
bool TStampaScadenzario::preprocess_page(int file, int counter)
// Se ritorna FALSE salta questa scadenza e va alla prossima.
{
TRectype &rc = current_cursor()->curr(LF_SCADENZE);
const TRectype &rc = current_cursor()->curr(LF_SCADENZE);
char tipoc = rc.get_char(SCAD_TIPOCF); // Tipo
int gruppo = rc.get_int(SCAD_GRUPPO); // Gruppo
int conto = rc.get_int(SCAD_CONTO); // Conto
@ -406,7 +412,8 @@ bool TStampaScadenzario::preprocess_page(int file, int counter)
if (tp.items() == 0) return FALSE;
}
if (file == LF_SCADENZE && !_end_printed)
{
{
/*
TCursor_sheet& cs = _m->cur_sheet(); // Sheet di selezione (CLI/FO/PCON)
TCursor* c = cs.cursor();
TRectype& rec = c->curr();
@ -415,8 +422,14 @@ bool TStampaScadenzario::preprocess_page(int file, int counter)
else
if (_tipost == altri)
rec = current_cursor()->curr(LF_PCON);
if (!cs.checked(c->read(_isequal))) // Se non e' stato selezionato salta alla prossima scdz
return FALSE;
*/
const TBill bill(rc);
if (!_m->selected(bill))
return FALSE;
_descrizione->restart();
if (scad_changed(tipoc,gruppo,conto,codcf,annop,nump))
{
@ -744,24 +757,9 @@ bool TStampaScadenzario::user_destroy()
bool TStampaScadenzario::set_print(int)
{
bool rt=FALSE,ok=FALSE;
KEY t;
while (!ok)
{
if ((t=_m->run())==K_ENTER)
{
if ( !_m->cur_sheet().checked())
error_box("Non e' stata effettuata alcuna selezione.");
else
ok=TRUE;
}
else ok=TRUE;
}
switch (t)
const bool ok = _m->run() == K_ENTER;
if (ok)
{
case K_ENTER:
{
_end_printed = FALSE;
reset_files();
reset_print();
@ -817,8 +815,7 @@ bool TStampaScadenzario::set_print(int)
// Setta l'intervallo di data. Si puo' fare per tutti i cursori, poiche'
// il file principale e' sempre LF_SCADENZE.
TRectype da_data(LF_SCADENZE), a_data(LF_SCADENZE);
da_data.zero();
a_data.zero();
da_data.put(SCAD_DATASCAD,_datai);
a_data.put(SCAD_DATASCAD,_dataf);
get_cursor(_cur1)->setregion(da_data,a_data);
@ -912,18 +909,16 @@ bool TStampaScadenzario::set_print(int)
default:
break;
}
rt=TRUE;
break;
}
default:
break;
}
if (_p) delete _p; // Questo deve essere cancellato, altrimenti rimane in memoria,
if (_p) delete _p; // Questo deve essere cancellato, altrimenti rimane in memoria,
_p = NULL; // provocando casini al prossimo "giro"
TAssoc_array& a =(TAssoc_array&) _uns_cache[0];
TAssoc_array& b =(TAssoc_array&) _uns_cache[1];
a.destroy(); b.destroy(); // Libera i TAssoc_array impiegati.
return rt;
return ok;
}
void TStampaScadenzario::print_header()

View File

@ -1,53 +1,27 @@
#ifndef __PRINTAPP_H
#include <printapp.h>
#endif
#ifndef __CONFIG_H
#include <config.h>
#endif
#include <printapp.h>
#ifndef __ASSOC_H
#include <assoc.h>
#endif
#ifndef __SALDACON_H
#include "../cg/saldacon.h"
#endif
#ifndef __DITTE_H
#include <nditte.h>
#endif
#ifndef __CLIFO_H
#include <clifo.h>
#endif
#ifndef __PCONTI_H
#include <pconti.h>
#endif
#ifndef __PARTITE_H
#include <partite.h>
#endif
#ifndef __SCADENZE_H
#include <scadenze.h>
#endif
#include <nditte.h>
#include <pagsca.h>
#include <pconti.h>
#include <scadenze.h>
#include "sc2.h"
#include "sc2201.h"
#include "sc2300.h"
///////////////////////////////////////////////////////////
// Stampa scaduto
///////////////////////////////////////////////////////////
enum tipo_st {nessuno=0, tutti=1, clienti=2, fornitori=3, altri=4};
const char * scaglioni[9] =
{"0 gg","+15 gg","+30 gg","+45 gg","+60 gg","+30 gg","+60 gg","+90 gg","+120 gg"};
bool fil_function(const TRelation *);
struct _LineTotal : public TObject //Oggetto di base per i TAssoc_array dei totali
{
real _rd, // Residuo documento
@ -71,6 +45,7 @@ class TStampaScaduto : public TPrintapp
_cur3, _cur4;
TSelection_ext_mask *_m;
TLocalisamfile *_scad,*_pagsca;
tipo_st _tipost; // Tipo di stampa impostato
bool _end_printed,
@ -85,8 +60,9 @@ class TStampaScaduto : public TPrintapp
real _unsnc,_uns; // Unassigned per partita.
TArray _t, // Array per i totali
_s_date; // Date per lo scaduto
friend bool fil_function(const TRelation *);
static TString _last_game;
static bool fil_function(const TRelation *);
public:
virtual bool preprocess_page(int file, int counter);
@ -109,17 +85,24 @@ public:
void compute_all(TPartita& p);
TStampaScaduto();
};
TString TStampaScaduto::_last_game;
inline TStampaScaduto& app() {return (TStampaScaduto&)main_app();}
bool fil_function(const TRelation *r)
bool TStampaScaduto::fil_function(const TRelation *r)
{
TLocalisamfile* part = &(r->lfile(LF_PARTITE));
int nriga = part->get_int(PART_NRIGA);
bool rt = FALSE;
TRectype& part = r->curr(LF_PARTITE);
if (nriga == 1)
rt=TRUE;
TString80 key;
key.format("%03d%03d%06ld%4d",
part.get_int(PART_GRUPPO), part.get_int(PART_CONTO),
part.get_long(PART_SOTTOCONTO), part.get_int(PART_ANNO));
key << part.get(PART_NUMPART);
const bool rt = key != _last_game;
if (rt)
_last_game = key;
return rt;
}
@ -344,36 +327,30 @@ void TStampaScaduto::compute_all(TPartita& p)
bool TStampaScaduto::preprocess_page(int file, int counter)
{
TRectype rc(current_cursor()->curr(file));
if (file == LF_PARTITE)
{
TCursor_sheet& cs = _m->cur_sheet(); // Sheet di selezione (CLI/FO/PCON)
TCursor* c = cs.cursor();
TRectype& rec = c->curr();
if (_tipost == clienti || _tipost == fornitori)
rec = current_cursor()->curr(LF_CLIFO);
else
if (_tipost == altri)
rec = current_cursor()->curr(LF_PCON);
int nriga = 1;
bool checked = cs.checked(c->read(_isequal));
{
const TRectype& curr = current_cursor()->curr(file);
const TBill bill(curr);
const bool checked = _m->selected(bill);
if (!checked && !_end_printed) // Se non e' stato selezionato salta al prossimo record
return FALSE;
int nriga = 1;
if (_tipost == clienti || _tipost == fornitori)
{
_des = current_cursor()->curr(LF_CLIFO).get(CLI_RAGSOC);
_cod = current_cursor()->curr(LF_CLIFO).get(CLI_CODCF);
{
const TRectype& clifo = current_cursor()->curr(LF_CLIFO);
_des = clifo.get(CLI_RAGSOC);
_cod = clifo.get(CLI_CODCF);
}
else
{
_des = current_cursor()->curr(LF_PCON).get(PCN_DESCR);
_cod = current_cursor()->curr(LF_PCON).get(PCN_GRUPPO);
_cod << " " << current_cursor()->curr(LF_PCON).get(PCN_CONTO);
_cod << " " << current_cursor()->curr(LF_PCON).get(PCN_SOTTOCONTO);
const TRectype& pcon = current_cursor()->curr(LF_PCON);
_des = pcon.get(PCN_DESCR);
_cod = pcon.get(PCN_GRUPPO);
_cod << " " << pcon.get(PCN_CONTO);
_cod << " " << pcon.get(PCN_SOTTOCONTO);
}
if (_cod != _cod_pre || _end_printed) // Controlla se e' cambiato il codice cli/fo/conto
@ -400,12 +377,14 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
_pending_clifo = TRUE;
}
TPartita p(rc);
if (curr.empty()) // Attenzione: Possono succedere anche queste cose!
return FALSE;
TPartita p(curr);
//Pesca gli estremi dalla prima riga di fattura, che non e' necessariamente la riga #1
int r = p.prima_fattura();
if (r < 1) return TRUE; // se non ci sono fatture ... salta al prossimo
const int r = p.prima_fattura();
if (r <= 0)
return TRUE; // se non ci sono fatture ... salta al prossimo
_residuo = "";
_nonscad = "";
@ -438,7 +417,7 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
!_sc_3.empty() || !_sc_4.empty() || !_sc_5.empty() || !_sc_6.empty() || (_tipost == clienti && !_buonfin.empty());
if (to_print)
{
if (rc.get_int(PART_NRIGA) == 1)
if (curr.get_int(PART_NRIGA) == 1)
{
if (_pending_clifo)
{
@ -480,12 +459,14 @@ bool TStampaScaduto::user_create()
{
_rel1 = new TRelation(LF_PARTITE);
_rel1->add(LF_CLIFO,"TIPOCF=TIPOC|CODCF=SOTTOCONTO",1);
_cur1 = add_cursor(new TSorted_cursor(_rel1,"SOTTOCONTO|ANNO|NUMPART","",1));
// _cur1 = add_cursor(new TSorted_cursor(_rel1,"SOTTOCONTO|ANNO|NUMPART","",1));
_cur1 = add_cursor(new TCursor(_rel1));
_cur2 = add_cursor(new TSorted_cursor(_rel1,"UPPER(20->RAGSOC)|ANNO|NUMPART","",1));
_rel2 = new TRelation(LF_PARTITE);
_rel2->add(LF_PCON,"GRUPPO=GRUPPO|CONTO=CONTO|SOTTOCONTO=SOTTOCONTO",1);
_cur3 = add_cursor(new TSorted_cursor(_rel2,"GRUPPO|CONTO|SOTTOCONTO|ANNO|NUMPART","",1));
// _cur3 = add_cursor(new TSorted_cursor(_rel2,"GRUPPO|CONTO|SOTTOCONTO|ANNO|NUMPART","",1));
_cur3 = add_cursor(new TCursor(_rel2));
_cur4 = add_cursor(new TSorted_cursor(_rel2,"UPPER(19->DESCR)|ANNO|NUMPART","",1));
_scad = new TLocalisamfile(LF_SCADENZE);
@ -493,9 +474,11 @@ bool TStampaScaduto::user_create()
_t.add(new TAssoc_array);_t.add(new TAssoc_array);
for (int i = 0; i < 5; i++)
_s_date.add(new TDate);
TConfig conf (CONFIG_DITTA,"cg");
_m = new TSelection_ext_mask("sc2300a");
_m->enable(F_VALUTA,conf.get_bool("GesVal"));
enable_print_menu();
return TRUE;
}
@ -514,30 +497,21 @@ bool TStampaScaduto::user_destroy()
bool TStampaScaduto::set_print(int)
{
bool rt=FALSE,ok=FALSE;
KEY t;
while (!ok)
const bool rt = _m->run() == K_ENTER;
if (rt)
{
if ((t=_m->run())==K_ENTER)
{
if ( !_m->cur_sheet().checked())
error_box("Non e' stato effettuata alcuna selezione.");
else
ok=TRUE;
}
else ok=TRUE;
}
// Here set some filters...
switch (t)
{
case K_ENTER:
{
reset_files();
reset_print();
if (_m->get_who() == 'P') _tipost = altri;
if (_m->get_who() == 'P')
{
_tipost = altri;
}
else
if (_m->get_who() == 'C') _tipost = clienti;
else _tipost = fornitori;
{
if (_m->get_who() == 'C') _tipost = clienti;
else _tipost = fornitori;
}
if (_m->get_key() == 1) _ordcod = TRUE;
else _ordcod = FALSE;
_end_printed = _pending_clifo = FALSE;
@ -556,43 +530,45 @@ bool TStampaScaduto::set_print(int)
TAssoc_array& aa = (TAssoc_array&) _t[it];
aa.destroy(); // Totali lineari (singolo e generale)
}
get_cursor(_cur1)->set_filterfunction(fil_function,TRUE);
get_cursor(_cur2)->set_filterfunction(fil_function,TRUE);
get_cursor(_cur3)->set_filterfunction(fil_function,TRUE);
get_cursor(_cur4)->set_filterfunction(fil_function,TRUE);
_last_game.cut(0);
TRectype filter_from(LF_PARTITE), filter_to(LF_PARTITE);
switch (_tipost)
{
case clienti:
case fornitori:
filter_from.put("TIPOC", _tipost == clienti ? "C" : "F");
filter_to = filter_from;
if (_ordcod) // Per codice...
{
select_cursor(_cur1);
if (_tipost==clienti)
get_cursor(_cur1)->setfilter("(TIPOC=\"C\")");
else
get_cursor(_cur1)->setfilter("(TIPOC=\"F\")");
select_cursor(_cur1);
get_cursor(_cur1)->setregion(filter_from, filter_to);
}
else // ... e ragione sociale
{
select_cursor(_cur2);
if (_tipost==clienti)
get_cursor(_cur2)->setfilter("(TIPOC=\"C\")");
else
get_cursor(_cur2)->setfilter("(TIPOC=\"F\")");
get_cursor(_cur2)->setregion(filter_from, filter_to);
}
add_file(LF_PARTITE);
add_file(LF_CLIFO,LF_PARTITE);
break;
case altri:
filter_to.put("TIPOC", "A"); // Sporco trucco per selezionare solo i conti
if (_ordcod) // Per codice...
{
select_cursor(_cur3);
get_cursor(_cur3)->setfilter("(TIPOC=\"\")"); // Filtro per i conti normali!
get_cursor(_cur3)->setregion(filter_from, filter_to); // Filtro per i conti normali!
}
else // ... e descrizione
{
select_cursor(_cur4);
get_cursor(_cur4)->setfilter("(TIPOC=\"\")"); // Filtro per i conti normali!
get_cursor(_cur4)->setregion(filter_from, filter_to); // Filtro per i conti normali!
}
add_file(LF_PARTITE);
add_file(LF_PCON,LF_PARTITE);
@ -612,12 +588,7 @@ bool TStampaScaduto::set_print(int)
*d = _limscad - nday;
nday += inc;
}
rt = TRUE;
break;
}
default:
break;
} // End of outer switch
} // End if
return rt;
}

View File

@ -1,5 +1,7 @@
#include "../cg/conto.h"
#include "scselect.h"
#include <defmask.h>
TSelection_mask::TSelection_mask(const char* name)
@ -65,6 +67,14 @@ TSelection_mask::~TSelection_mask()
delete _clifo_rel;
}
bool TSelection_mask::stop_run(KEY k)
{
const bool ok = TMask::stop_run(k);
if (ok && k == K_ENTER)
update_assoc();
return ok;
}
void TSelection_mask::set_handler(short fld_id, CONTROL_HANDLER handler)
{
const int pos = id2pos(fld_id);
@ -465,3 +475,60 @@ bool TSelection_mask::rsortcf_handler(TMask_field& f, KEY k)
return TRUE;
}
void TSelection_mask::update_assoc()
{
_assoc.destroy();
_all_selected = FALSE;
TCursor_sheet& cs = cur_sheet(); // Sheet di selezione (CLI/FO/PCON)
const long checked = cs.checked();
if (checked == 0L || checked == cs.items())
_all_selected =TRUE;
else
{
const int first = get_key();
const char who = get_who();
TString16 key;
for (long i = cs.items()-1; i >= 0; i--) if (cs.checked(i))
{
TToken_string& row = cs.row(i);
if (who == 'C' || who == 'F')
{
key.format("000000%06ld", row.get_long(first));
}
else
{
const TBill b(row, first, 0x0);
key.format("%03d%03d%06ld",
b.gruppo(), b.conto(), b.sottoconto());
}
_assoc.add(key, NULL);
}
}
}
bool TSelection_mask::selected(const TBill& b) const
{
bool ok = _all_selected;
if (!ok)
{
TString16 key;
key.format("%03d%03d%06ld",
b.gruppo(), b.conto(), b.sottoconto());
ok = _assoc.is_key(key);
}
return ok;
}
bool TSelection_mask::selected(int g, int c, long s) const
{
bool ok = _all_selected;
if (!ok)
{
TString16 key;
key.format("%03d%03d%06ld", g, c, s);
ok = _assoc.is_key(key);
}
return ok;
}

View File

@ -1,6 +1,14 @@
#ifndef __SCSELECT_H
#define __SCSELECT_H
#ifndef __ASSOC_H
#include <assoc.h>
#endif
#ifndef __CONTO_H
class TBill;
#endif
#ifndef __MASK_H
#include <mask.h>
#endif
@ -34,11 +42,15 @@ class TSelection_mask : public TMask
TCursor_sheet* _for_sh_k1;
TCursor_sheet* _for_sh_k2;
char _who;
int _key;
char _who; // Clienti, fornitori, conti
int _key; // 1 = per codice, 2 = per descrizione
TAssoc_array _assoc;
bool _all_selected;
protected: // TMask
virtual void set_handler(short fld_id, CONTROL_HANDLER handler);
virtual bool stop_run(KEY k);
protected:
void select_clifo_range(long from, long to);
@ -50,6 +62,7 @@ protected:
void set_key (int k) { _key = k; }
void reset_sheets();
void update_assoc();
// handlers
static bool bfrom_handler(TMask_field& f, KEY k);
@ -71,6 +84,9 @@ public:
char get_who() const { return _who; }
int get_key() const { return _key; }
bool selected(const TBill& c) const;
bool selected(int g, int c, long s) const;
TSelection_mask(const char* name);
virtual ~TSelection_mask();
};