Stampa EC
git-svn-id: svn://10.65.10.50/trunk@2213 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b967f84c85
commit
b0f462dc9e
471
sc/sc0100.cpp
471
sc/sc0100.cpp
@ -1,53 +1,448 @@
|
||||
#include <stdarg.h>
|
||||
#include <applicat.h>
|
||||
#include <config.h>
|
||||
#include <form.h>
|
||||
#include <printer.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include <mask.h>
|
||||
#include <urldefid.h>
|
||||
#include "saldacon.h"
|
||||
#include "sc2.h"
|
||||
#include "sc2101.h"
|
||||
|
||||
#include "sc0100.h"
|
||||
#include <clifo.h>
|
||||
|
||||
bool TSaldaconto_app::create()
|
||||
{
|
||||
open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
|
||||
_msk = new TMask("sc0100a");
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TDecoder : private TAssoc_array
|
||||
{
|
||||
TLocalisamfile* _file;
|
||||
const TString _ifield;
|
||||
const TString _ofield;
|
||||
|
||||
public:
|
||||
const TString& decode(const char* code);
|
||||
|
||||
TDecoder(int logicnum, const char* ifield, const char* ofield);
|
||||
TDecoder(const char* table);
|
||||
virtual ~TDecoder();
|
||||
};
|
||||
|
||||
TDecoder::TDecoder(int logicnum, const char* ifield, const char* ofield)
|
||||
: _file(new TLocalisamfile(logicnum)), _ifield(ifield), _ofield(ofield)
|
||||
{
|
||||
}
|
||||
|
||||
TDecoder::TDecoder(const char* table)
|
||||
: _file(new TTable(table)), _ifield("CODTAB") , _ofield("S0")
|
||||
{
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(const char* code)
|
||||
{
|
||||
const TObject* obj = objptr(code);
|
||||
if (obj == NULL)
|
||||
{
|
||||
_file->set_key(1);
|
||||
_file->put(_ifield, code);
|
||||
const int err = _file->read();
|
||||
CHECKS(err == NOERR, "Can't decode ", code);
|
||||
obj = new TString(_file->get(_ofield));
|
||||
add(code, obj);
|
||||
}
|
||||
|
||||
const TString& s = (const TString&)*obj;
|
||||
return s;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TEC_row
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TEC_row : public TSortable
|
||||
{
|
||||
friend TEC_array;
|
||||
|
||||
TDate _data;
|
||||
int _riga;
|
||||
|
||||
TString _causale;
|
||||
TDate _data_doc;
|
||||
TString _num_doc;
|
||||
long _num_prot;
|
||||
TImporto _totale_doc;
|
||||
TImporto _importo;
|
||||
TValuta _valuta;
|
||||
|
||||
protected: // TSortable
|
||||
virtual int compare(const TSortable& s) const;
|
||||
|
||||
public:
|
||||
TEC_row(int r, const TRiga_partite& row, TDecoder& causali);
|
||||
virtual ~TEC_row() {}
|
||||
};
|
||||
|
||||
int TEC_row::compare(const TSortable& s) const
|
||||
{
|
||||
const TEC_row& r = (const TEC_row&)s;
|
||||
int c = 0;
|
||||
if (_data = r._data)
|
||||
c = _riga - r._riga;
|
||||
else
|
||||
c = _data > r._data ? +1 : -1;
|
||||
return c;
|
||||
}
|
||||
|
||||
TEC_row::TEC_row(int r, const TRiga_partite& row) : _riga(r)
|
||||
{
|
||||
ecr->_causale = row.get(PART_CODCAUS);
|
||||
ecr->_data_doc = row.get_date(PART_DATADOC);
|
||||
ecr->_num_doc = row.get(PART_NUMDOC);
|
||||
ecr->_num_prot = row.get_long(PART_NUMPROT);
|
||||
ecr->_valuta.get(row);
|
||||
// ecr->_totale = ???
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Totalizzatore
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTotal : TAssoc_array
|
||||
{
|
||||
public:
|
||||
void add(const char* val, const TImporto& imp);
|
||||
|
||||
TTotal();
|
||||
virtual ~TTotal() { }
|
||||
};
|
||||
|
||||
void TTotal::add(const char* val, const TImporto& imp)
|
||||
{
|
||||
TObject* obj = objptr(val);
|
||||
if (obj)
|
||||
{
|
||||
TImporto& tot = (TImporto&)*obj;
|
||||
tot += imp;
|
||||
}
|
||||
else
|
||||
{
|
||||
add(val, imp);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Form speciale per estratti conto
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TEC_form : public TForm
|
||||
{
|
||||
static TEC_form* _form;
|
||||
|
||||
TCursor* _cursore;
|
||||
|
||||
TDecoder _causali;
|
||||
TTotal _totali;
|
||||
TArray _righe;
|
||||
|
||||
protected:
|
||||
static TEC_form& form() { return *_form; }
|
||||
static void ec_header_handler(TPrinter& p);
|
||||
static void ec_footer_handler(TPrinter& p);
|
||||
|
||||
TTotal& totali() const { return _totali; }
|
||||
void add_row(const TRiga_partite& r);
|
||||
|
||||
public:
|
||||
long move_cursor(const TRectype& rec);
|
||||
|
||||
void print_game(const TPartita& game);
|
||||
|
||||
TEC_form(const char* codice, TCursor* cursor);
|
||||
virtual ~TEC_form();
|
||||
};
|
||||
|
||||
TEC_form* TEC_form::_form = NULL;
|
||||
|
||||
void TEC_form::ec_header_handler(TPrinter& pr)
|
||||
{
|
||||
TPrint_section& head = form().section('H', 1);
|
||||
|
||||
form().totali().destroy();
|
||||
|
||||
head.reset();
|
||||
pr.resetheader();
|
||||
|
||||
head.update();
|
||||
for (word j = 0; j < head.height(); j++)
|
||||
pr.setheaderline(j, head.row(j));
|
||||
}
|
||||
|
||||
|
||||
void TEC_form::ec_footer_handler(TPrinter& p)
|
||||
{
|
||||
TRACE("Stamperei un footer");
|
||||
}
|
||||
|
||||
long TEC_form::move_cursor(const TRectype& rec)
|
||||
{
|
||||
cursor()->file().curr() = rec;
|
||||
const long r = cursor()->read();
|
||||
return r;
|
||||
}
|
||||
|
||||
void TEC_form::add_row(const TRiga_partite& row)
|
||||
{
|
||||
if (row.is_fattura())
|
||||
{
|
||||
for (int r = row.rate(); r > 0; r--)
|
||||
{
|
||||
const TRiga_scadenze& rata = row.rata(r);
|
||||
TEC_row* ecr = new TEC_row(_righe.items(), row);
|
||||
ecr->_data = rata.get_date(SCAD_DATASCAD);
|
||||
ecr->_importo.set(row.sezione(), rata.get_real(SCAD_IMPORTO));
|
||||
_righe.add(ecr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const TImporto importo(row.sezione(), row.get_real(PART_IMPORTO))
|
||||
TEC_row* ecr = new TEC_row(_righe.items(), row);
|
||||
ecr->_data = ecr->_data_doc; // ???
|
||||
ecr->_importo = importo;
|
||||
_righe.add(ecr);
|
||||
|
||||
const TImporto abbuoni(row.get_char(PART_SEZABB), row.get_real(PART_ABBUONI));
|
||||
if (!abbuoni.is_zero())
|
||||
{
|
||||
ecr = new TEC_row(_righe.items(), row);
|
||||
ecr->_data = ecr->_data_doc; // ???
|
||||
ecr->_importo = abbuoni;
|
||||
_righe.add(ecr);
|
||||
}
|
||||
|
||||
const TImporto diffcam(row.get_char(PART_SEZDIFCAM), row.get_real(PART_DIFFCAM));
|
||||
if (!diffcam.is_zero())
|
||||
{
|
||||
ecr = new TEC_row(_righe.items(), row);
|
||||
ecr->_data = ecr->_data_doc; // ???
|
||||
ecr->_importo = diffcam;
|
||||
_righe.add(ecr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TEC_form::print_game(const TPartita& game)
|
||||
{
|
||||
_righe.destroy();
|
||||
for (int r = game.last(); r > 0; r = game.pred(r))
|
||||
add_row(game.riga(r));
|
||||
_righe.sort();
|
||||
|
||||
TPrinter& pr = printer();
|
||||
|
||||
TPrintrow r;
|
||||
|
||||
for (int i = 0; i < _righe.items(); i++)
|
||||
{
|
||||
if (pr.rows_left() < 2)
|
||||
pr.formfeed();
|
||||
|
||||
TEC_row& r = (TEC_row&)_righe[i];
|
||||
const TValuta& valuta = r.valuta();
|
||||
const TImporto& imp = r.importo();
|
||||
totali().add(valuta.codice(), imp);
|
||||
r.zero();
|
||||
r.put("Importo riga ")
|
||||
r.put(imp.valore.string());
|
||||
pr.print(r)
|
||||
}
|
||||
|
||||
r.zero();
|
||||
r.put("Saldo partita");
|
||||
pr.print(r);
|
||||
pr.print(NULL);
|
||||
}
|
||||
|
||||
TEC_form::TEC_form(const char* codice, TCursor* cur)
|
||||
: TForm(BASE_EC_PROFILE, codice),
|
||||
_causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR)
|
||||
{
|
||||
_form = this;
|
||||
_cursore = cur;
|
||||
|
||||
TPrinter& pr = printer();
|
||||
|
||||
pr.setheaderhandler(ec_header_handler);
|
||||
pr.headerlen(section('H', 1).height());
|
||||
|
||||
pr.setfooterhandler(ec_footer_handler);
|
||||
pr.footerlen(section('F', 1).height());
|
||||
}
|
||||
|
||||
TEC_form::~TEC_form()
|
||||
{
|
||||
TPrinter& pr = printer();
|
||||
pr.setheaderhandler(NULL);
|
||||
pr.setfooterhandler(NULL);
|
||||
_form = NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Stampa estratti conto
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TStampaEC_application : public TApplication
|
||||
{
|
||||
TEC_mask* _msk;
|
||||
TEC_form* _form;
|
||||
|
||||
TString _lingua;
|
||||
TString _linprof;
|
||||
bool _gesval;
|
||||
|
||||
protected: // TApplication
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
virtual bool menu(MENU_TAG m);
|
||||
virtual void on_firm_change();
|
||||
|
||||
public:
|
||||
static TStampaEC_application& app() { return (TStampaEC_application&)main_app(); }
|
||||
|
||||
public:
|
||||
TEC_mask& mask() { return *_msk; }
|
||||
TCursor_sheet& sheet() { return _msk->cur_sheet(); }
|
||||
TEC_form& form() { return *_form; }
|
||||
|
||||
bool select_ec(); // starting point
|
||||
bool print_selected(); // print selected items
|
||||
bool print_ec(); // print one item
|
||||
|
||||
TStampaEC_application();
|
||||
virtual ~TStampaEC_application() {}
|
||||
};
|
||||
|
||||
bool TStampaEC_application::select_ec()
|
||||
{
|
||||
TEC_mask& m = mask();
|
||||
while (m.run() != K_ESC)
|
||||
{
|
||||
_linprof = m.get_prof_lang();
|
||||
_form = new TEC_form(m.get_prof_code(), sheet().cursor());
|
||||
_form->cursor().set_key(m.get_key());
|
||||
|
||||
print_selected();
|
||||
|
||||
delete _form;
|
||||
_form = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TStampaEC_application::print_selected()
|
||||
{
|
||||
TCursor_sheet& s = sheet();
|
||||
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
|
||||
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
|
||||
|
||||
printer().open();
|
||||
|
||||
TCursor& c = *s.cursor();
|
||||
const long items = c.items();
|
||||
for (long i = 0; i < items; i++) if (print_all || s.checked(i))
|
||||
{
|
||||
c = i;
|
||||
form().move_cursor(c.file().curr());
|
||||
|
||||
const bool ok = print_ec();
|
||||
if (!ok) analfabeti++;
|
||||
}
|
||||
|
||||
printer().close();
|
||||
|
||||
if (analfabeti > 0)
|
||||
warning_box("%ld clienti/fornitori non sono stati stmapati in quanto "
|
||||
"il codice lingua non corrispondeva al profilo di stampa", analfabeti);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TStampaEC_application::print_ec()
|
||||
{
|
||||
TEC_form& f = form();
|
||||
|
||||
const TRectype& clf = f.cursor()->file().curr();
|
||||
const TString lincf(clf.get(CLI_CODLIN));
|
||||
|
||||
bool ok = TRUE;
|
||||
|
||||
// make controllations per lingua profilo/CF
|
||||
if ((_linprof == _lingua && !lincf.empty()) || _linprof != _lingua)
|
||||
ok = lincf == _linprof;
|
||||
|
||||
if (!ok) // Cliente analfabeta
|
||||
return FALSE;
|
||||
|
||||
TRectype filter(LF_PARTITE);
|
||||
filter.put(PART_TIPOCF, clf.get(CLI_TIPOCF));
|
||||
filter.put(PART_SOTTOCONTO, clf.get(CLI_CODCF));
|
||||
|
||||
TLocalisamfile& partite = f.cursor()->file(LF_PARTITE);
|
||||
for (int err = partite.read();
|
||||
err == NOERR && partite.curr() == filter;
|
||||
err = partite.read(_isgreat))
|
||||
{
|
||||
TPartita game(partite.curr());
|
||||
form().print_partita(game);
|
||||
partite.put(PART_NUMRIG, 9999);
|
||||
}
|
||||
|
||||
printer().formfeed();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Generic TApplication methods
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TStampaEC_application::create()
|
||||
{
|
||||
TApplication::create();
|
||||
|
||||
_msk = new TEC_mask("sc2100a");
|
||||
|
||||
dispatch_e_menu(MENU_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TSaldaconto_app::destroy()
|
||||
{
|
||||
bool TStampaEC_application::destroy()
|
||||
{
|
||||
delete _msk;
|
||||
close_files();
|
||||
return TRUE;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
void TSaldaconto_app::open_files(int logicnum, ...)
|
||||
{
|
||||
va_list marker;
|
||||
va_start(marker, logicnum);
|
||||
while (logicnum > 0)
|
||||
{
|
||||
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
|
||||
_file.add(new TLocalisamfile(logicnum), logicnum);
|
||||
logicnum = va_arg(marker, int);
|
||||
}
|
||||
}
|
||||
void TStampaEC_application::on_firm_change()
|
||||
{
|
||||
TApplication::on_firm_change();
|
||||
TConfig c(CONFIG_DITTA, "cg");
|
||||
_lingua = c.get("CodLin");
|
||||
_gesval = c.get_bool("GesVal");
|
||||
}
|
||||
|
||||
void TSaldaconto_app::on_config_change()
|
||||
bool TStampaEC_application::menu(MENU_TAG m)
|
||||
{
|
||||
TPartita::carica_allineamento();
|
||||
}
|
||||
select_ec();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TSaldaconto_app::menu(MENU_TAG)
|
||||
{
|
||||
TMask& m = curr_mask();
|
||||
while (m.run() == K_ENTER)
|
||||
edit_partite(m);
|
||||
TStampaEC_application::TStampaEC_application()
|
||||
: _lingua(1), _linprof(1), _msk(NULL), _form(NULL)
|
||||
{}
|
||||
|
||||
int sc2100(int argc, char** argv)
|
||||
{
|
||||
TStampaEC_application app;
|
||||
app.run(argc, argv, "Stampa Estratti Conto");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sc0100(int argc, char* argv[])
|
||||
{
|
||||
TSaldaconto_app app;
|
||||
app.run(argc, argv, "Gestione Saldaconto");
|
||||
return 0;
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#include <printer.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "../cg/saldacon.h"
|
||||
#include "sc2.h"
|
||||
#include "sc2101.h"
|
||||
|
||||
@ -35,7 +36,7 @@ public:
|
||||
|
||||
TEC_row::TEC_row(const TRectype& rec)
|
||||
{
|
||||
if (rec.logicnum() == LF_SCAD)
|
||||
if (rec.num() == LF_SCADENZE)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
13
sc/sc2200.h
13
sc/sc2200.h
@ -1,9 +1,10 @@
|
||||
|
||||
#define F_DATASTAMPA 101
|
||||
#define F_DATASTAMPA 101
|
||||
#define F_DATASCADENZAI 102
|
||||
#define F_DATASCADENZAF 103
|
||||
#define F_RATESALDATE 104
|
||||
#define F_TIPO 105
|
||||
#define F_ORDDATA 106
|
||||
#define F_ORDINE 107
|
||||
#define SC21_BUT_SEL 108
|
||||
#define F_RATESALDATE 104
|
||||
#define F_ORDDATA 105
|
||||
#define F_VALUTA 106
|
||||
|
||||
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
#ifndef __SCSELMSK_H
|
||||
#define __SCSELMSK_H
|
||||
|
||||
#define SC_CFCODFR 301
|
||||
#define SC_CFCODTO 302
|
||||
#define SC_CFBUTFR 303
|
||||
#define SC_CFBUTTO 304
|
||||
#define SC_CFDESFR 305
|
||||
#define SC_CFDESTO 306
|
||||
#define SC_SELECT 307
|
||||
#define SC_RESET 308
|
||||
#define SC_CLIFO 309
|
||||
#define SC_SORTCF 310
|
||||
#define SC_NSEL 311
|
||||
|
||||
#define BASE_EC_PROFILE "PEC"
|
||||
|
||||
#endif
|
||||
#ifndef __SCSELMSK_H
|
||||
#define __SCSELMSK_H
|
||||
|
||||
#define SC_CFCODFR 301
|
||||
#define SC_CFCODTO 302
|
||||
#define SC_CFBUTFR 303
|
||||
#define SC_CFBUTTO 304
|
||||
#define SC_CFDESFR 305
|
||||
#define SC_CFDESTO 306
|
||||
#define SC_SELECT 307
|
||||
#define SC_RESET 308
|
||||
#define SC_CLIFO 309
|
||||
#define SC_SORTCF 310
|
||||
#define SC_NSEL 311
|
||||
|
||||
#define BASE_EC_PROFILE "PEC"
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user