Corretta gestione campo DATAPAG e continuata stampa Estratti conto

git-svn-id: svn://10.65.10.50/trunk@2222 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-01 11:49:57 +00:00
parent dd53428762
commit 754fcfa868
8 changed files with 826 additions and 876 deletions

View File

@ -1,448 +1,53 @@
#include <applicat.h> #include <stdarg.h>
#include <config.h>
#include <form.h> #include <mask.h>
#include <printer.h>
#include <urldefid.h> #include <urldefid.h>
#include "saldacon.h" #include "sc0100.h"
#include "sc2.h"
#include "sc2101.h"
#include <clifo.h> bool TSaldaconto_app::create()
///////////////////////////////////////////////////////////
// TDecoder
///////////////////////////////////////////////////////////
class TDecoder : private TAssoc_array
{ {
TLocalisamfile* _file; open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
const TString _ifield; _msk = new TMask("sc0100a");
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)); dispatch_e_menu(MENU_ITEM(1));
return TRUE; return TRUE;
} }
bool TStampaEC_application::destroy() bool TSaldaconto_app::destroy()
{ {
delete _msk; delete _msk;
return TApplication::destroy(); close_files();
return TRUE;
} }
void TStampaEC_application::on_firm_change() void TSaldaconto_app::open_files(int logicnum, ...)
{ {
TApplication::on_firm_change(); va_list marker;
TConfig c(CONFIG_DITTA, "cg"); va_start(marker, logicnum);
_lingua = c.get("CodLin"); while (logicnum > 0)
_gesval = c.get_bool("GesVal"); {
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
_file.add(new TLocalisamfile(logicnum), logicnum);
logicnum = va_arg(marker, int);
}
} }
bool TStampaEC_application::menu(MENU_TAG m) void TSaldaconto_app::on_config_change()
{ {
select_ec(); TPartita::carica_allineamento();
return FALSE;
} }
TStampaEC_application::TStampaEC_application() bool TSaldaconto_app::menu(MENU_TAG)
: _lingua(1), _linprof(1), _msk(NULL), _form(NULL)
{}
int sc2100(int argc, char** argv)
{ {
TStampaEC_application app; TMask& m = curr_mask();
app.run(argc, argv, "Stampa Estratti Conto"); while (m.run() == K_ENTER)
edit_partite(m);
return 0;
}
int sc0100(int argc, char* argv[])
{
TSaldaconto_app app;
app.run(argc, argv, "Gestione Saldaconto");
return 0; return 0;
} }

View File

@ -202,6 +202,7 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check)
TRiga_partite& riga = game.new_row(); TRiga_partite& riga = game.new_row();
riga.put(PART_DATAREG, _today); riga.put(PART_DATAREG, _today);
riga.put(PART_DATADOC, _today); riga.put(PART_DATADOC, _today);
riga.put(PART_DATAPAG, _today);
riga.put(PART_SEZ, saldo.sezione()); riga.put(PART_SEZ, saldo.sezione());
riga.put(PART_IMPORTO, saldo.valore()); riga.put(PART_IMPORTO, saldo.valore());
riga.put(PART_DESCR, cf == 'C' ? _desccl : _descfo); riga.put(PART_DESCR, cf == 'C' ? _desccl : _descfo);
@ -224,7 +225,6 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check)
const int r = riga.get_int(PART_NRIGA); const int r = riga.get_int(PART_NRIGA);
TRectype& unas = game.unassigned().row(r, TRUE); TRectype& unas = game.unassigned().row(r, TRUE);
unas.put(PAGSCA_IMPORTO, saldo.valore()); unas.put(PAGSCA_IMPORTO, saldo.valore());
unas.put(PAGSCA_DATAPAG, _today);
unas.put(PAGSCA_ACCSAL, 'A'); unas.put(PAGSCA_ACCSAL, 'A');
} }
@ -232,7 +232,8 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check)
n_part++; n_part++;
else else
{ {
error_box("Impossibile scrivere la partita %d *", anno_rif); error_box("Impossibile scrivere la partita %d %s",
anno_rif, (const char *)numero);
break; break;
} }
} }

View File

@ -26,6 +26,7 @@ END
NUMBER F_ANNO 4 NUMBER F_ANNO 4
BEGIN BEGIN
PROMPT 1 7 "Anno esercizio " PROMPT 1 7 "Anno esercizio "
FLAGS "Z"
USE ESC USE ESC
INPUT CODTAB F_ANNO INPUT CODTAB F_ANNO
DISPLAY "Anno Esercizio" CODTAB DISPLAY "Anno Esercizio" CODTAB

View File

@ -2,74 +2,52 @@
#include <config.h> #include <config.h>
#include <form.h> #include <form.h>
#include <printer.h> #include <printer.h>
#include <tabutil.h>
#include <urldefid.h> #include <urldefid.h>
#include "../cg/saldacon.h" #include "../cg/saldacon.h"
#include "sc2.h" #include "sc2.h"
#include "sc2101.h" #include "sc2101.h"
#include "sc2100a.h"
#include <clifo.h> #include <clifo.h>
#include <causali.h>
/////////////////////////////////////////////////////////// #include <scadenze.h>
// TEC_row
///////////////////////////////////////////////////////////
class TEC_row : public TSortable
{
TString _causale;
TString _desc_causale;
TDate _data_doc;
TString _num_doc;
long _num_prot;
TImporto _totale_doc;
TDate _data_scad;
TImporto _importo;
TValuta _valuta;
protected: // TSortable
virtual int compare(const TSortable& s) const;
public:
TEC_row(const TRectype& rec);
virtual ~TEC_row() {}
};
TEC_row::TEC_row(const TRectype& rec)
{
if (rec.num() == LF_SCADENZE)
{
}
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Totalizzatore // Totalizzatore
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TTotal : TAssoc_array class TTotalizer : public TAssoc_array
{ {
public: public:
void add(const char* val, const TImporto& imp); void add(const TImporto& imp, const char* val);
TTotal(); TTotalizer() { }
virtual ~TTotal() { } virtual ~TTotalizer() { }
}; };
void TTotal::add(const char* val, const TImporto& imp) void TTotalizer::add(const TImporto& imp, const char* val)
{ {
TObject* obj = objptr(val); TString16 codice(val);
if (obj) if (codice == "LIT")
codice.cut(0);
TObject* obj = objptr(codice);
if (obj != NULL)
{ {
TImporto& tot = (TImporto&)*obj; TImporto& tot = (TImporto&)*obj;
tot += imp; tot += imp;
} }
else else
{ {
add(val, imp); TAssoc_array::add(codice, new TImporto(imp));
} }
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Form speciale per estratti conto // TEC_form
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TEC_form : public TForm class TEC_form : public TForm
@ -77,15 +55,18 @@ class TEC_form : public TForm
static TEC_form* _form; static TEC_form* _form;
TCursor* _cursore; TCursor* _cursore;
TTotal _totali; TTotalizer _totali;
TDecoder _causali;
protected: protected:
static TEC_form& form() { return *_form; }
static void ec_header_handler(TPrinter& p); static void ec_header_handler(TPrinter& p);
static void ec_footer_handler(TPrinter& p); static void ec_footer_handler(TPrinter& p);
public: public:
long move_cursor(const TRectype& rec); TTotalizer& totali() { return _totali; }
TDecoder& causali() { return _causali; }
bool print_game(const TPartita& game);
TEC_form(const char* codice, TCursor* cursor); TEC_form(const char* codice, TCursor* cursor);
virtual ~TEC_form(); virtual ~TEC_form();
@ -93,9 +74,238 @@ public:
TEC_form* TEC_form::_form = NULL; TEC_form* TEC_form::_form = NULL;
///////////////////////////////////////////////////////////
// TEC_row
///////////////////////////////////////////////////////////
class TEC_row : public TSortable
{
TDate _data;
int _riga;
TString _causale;
TString _descrizione;
TDate _data_doc;
TString _num_doc;
long _num_prot;
TImporto _importo;
TValuta _valuta;
TImporto _totale_doc;
protected: // TSortable
virtual int compare(const TSortable& s) const;
public:
void descrizione(const char* s) { _descrizione = s; }
const TValuta& valuta() const { return _valuta; }
const TImporto& importo() const { return _importo; }
void print_on(TPrint_section& body);
TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int riga);
TEC_row(const char* desc, const TImporto& imp);
virtual ~TEC_row() {}
};
TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int riga)
: _riga(riga), _num_prot(0)
{
_data = data;
_causale = row.get(PART_CODCAUS);
_data_doc = row.get(PART_DATADOC);
_num_prot = row.get_long(PART_PROTIVA);
_valuta.get(row);
_importo = imp;
// _totale = row.get_long(???);
}
TEC_row::TEC_row(const char* desc, const TImporto& imp)
: _riga(0), _num_prot(0)
{
_descrizione = desc;
_importo = imp;
}
int TEC_row::compare(const TSortable& s) const
{
const TEC_row& r = (const TEC_row&)s;
int c = 0;
if (_data == r._data)
c = r._riga - _riga;
else
c = _data < r._data ? +1 : -1;
return c;
}
void TEC_row::print_on(TPrint_section& body)
{
TEC_form& form = (TEC_form&)body.form();
body.reset();
if (_causale.not_empty())
{
TForm_item& causale = body.find_field(201);
causale.set(_causale);
if (_descrizione.empty())
{
TDecoder& causali = form.causali();
_descrizione = causali.decode(_causale);
}
}
if (_descrizione.not_empty())
{
TForm_item& descr = body.find_field(202);
descr.set(_descrizione);
}
if (_data_doc.ok())
{
TForm_item& datadoc = body.find_field(203);
datadoc.set(_data_doc.string());
}
if (_num_doc.not_empty())
{
TForm_item& numdoc = body.find_field(204);
numdoc.set(_num_doc);
}
if (_num_prot != 0)
{
TForm_item& numprot = body.find_field(205);
TString16 protiva; protiva << _num_prot;
numprot.set(protiva);
}
if (_data.ok())
{
TForm_item& datapag = body.find_field(207);
datapag.set(_data.string());
}
const real& imp = _importo.valore();
if (!imp.is_zero())
{
TForm_item& dare = body.find_field(208);
TForm_item& avere = body.find_field(209);
if (_importo.sezione() == 'D')
{
dare.set(imp.string());
avere.set("");
}
else
{
avere.set(imp.string());
dare.set("");
}
}
if (!_valuta.in_lire())
{
TForm_item& cambio = body.find_field(212);
cambio.set(_valuta.cambio().string());
if (_valuta.data().ok())
{
TForm_item& datacambio = body.find_field(213);
datacambio.set(_valuta.data().string());
}
}
body.update();
TPrinter& pr = printer();
for (word j = 0; j < body.height(); j++)
pr.print(body.row(j));
}
///////////////////////////////////////////////////////////
// TEC_array
///////////////////////////////////////////////////////////
class TEC_array : public TArray
{
const TEC_form* _form;
protected:
TEC_row& new_row(const TRiga_partite& row, const TDate& data, const TImporto& imp);
void add_row(const TRiga_partite& row);
public:
TEC_row& row(int r) { return (TEC_row&)operator[](r); }
const TEC_form& form() const { return *_form; }
TEC_array(const TPartita& game, const TEC_form* f);
virtual ~TEC_array() {}
};
TEC_row& TEC_array::new_row(const TRiga_partite& row, const TDate& data, const TImporto& imp)
{
const int n = items();
TEC_row* riga = new TEC_row(row, data, imp, n);
add(riga, n);
return *riga;
}
void TEC_array::add_row(const TRiga_partite& row)
{
if (row.is_fattura())
{
for (int r = 1; r <= row.rate(); r++)
{
const TRiga_scadenze& rata = row.rata(r);
const TImporto imp(row.sezione(), rata.get_real(PART_IMPORTO));
const TDate data(rata.get(SCAD_DATASCAD));
new_row(row, data, imp);
}
}
else
{
const TImporto imp(row.sezione(), row.get_real(PART_IMPORTO));
const TDate data(row.get(PART_DATAPAG));
new_row(row, data, imp);
const TImporto abbuoni(row.get_char(PART_SEZABB), row.get_real(PART_ABBUONI));
if (!abbuoni.is_zero())
{
TEC_row& r = new_row(row, data, abbuoni);
const TForm_item& desc_abb = form().find_field('B', odd_page, 302);
r.descrizione(desc_abb.prompt());
}
const TImporto diffcam(row.get_char(PART_SEZDIFCAM), row.get_real(PART_DIFFCAM));
if (!diffcam.is_zero())
{
TEC_row& r = new_row(row, data, diffcam);
const TForm_item& desc_dif = form().find_field('B', odd_page, 303);
r.descrizione(desc_dif.prompt());
}
}
}
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));
sort();
}
///////////////////////////////////////////////////////////
// Form speciale per estratti conto
///////////////////////////////////////////////////////////
void TEC_form::ec_header_handler(TPrinter& pr) void TEC_form::ec_header_handler(TPrinter& pr)
{ {
TPrint_section& head = form().section('H', 1); TPrint_section& head = _form->section('H');
head.reset(); head.reset();
pr.resetheader(); pr.resetheader();
@ -111,15 +321,52 @@ void TEC_form::ec_footer_handler(TPrinter& p)
TRACE("Stamperei un footer"); TRACE("Stamperei un footer");
} }
long TEC_form::move_cursor(const TRectype& rec) bool TEC_form::print_game(const TPartita& game)
{ {
cursor()->file().curr() = rec; bool ok = FALSE;
const long r = cursor()->read();
return r; TEC_array righe(game, this);
TPrinter& pr = printer();
TPrintrow prow;
TPrint_section& body = section('B');
TImporto saldo;
// Stampa le righe di partita
for (int r = 0; r < righe.items(); r++)
{
if (pr.rows_left() < body.height())
pr.formfeed();
TEC_row& riga = righe.row(r);
riga.print_on(body);
totali().add(riga.importo(), riga.valuta().codice());
saldo += riga.importo();
ok = TRUE;
}
if (ok)
{
saldo.normalize();
const TForm_item& desc_sld = body.find_field(301);
TEC_row sld(desc_sld.prompt(), saldo);
sld.print_on(body);
// Salta una riga vuota
TPrintrow vuota;
pr.print(vuota);
}
return ok;
} }
TEC_form::TEC_form(const char* codice, TCursor* cur) TEC_form::TEC_form(const char* codice, TCursor* cur)
: TForm(BASE_EC_PROFILE, codice) : TForm(BASE_EC_PROFILE, codice),
_causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR)
{ {
_form = this; _form = this;
_cursore = cur; _cursore = cur;
@ -127,10 +374,10 @@ TEC_form::TEC_form(const char* codice, TCursor* cur)
TPrinter& pr = printer(); TPrinter& pr = printer();
pr.setheaderhandler(ec_header_handler); pr.setheaderhandler(ec_header_handler);
pr.headerlen(section('H', 1).height()); pr.headerlen(section('H').height());
pr.setfooterhandler(ec_footer_handler); pr.setfooterhandler(ec_footer_handler);
pr.footerlen(section('F', 1).height()); pr.footerlen(section('F').height());
} }
TEC_form::~TEC_form() TEC_form::~TEC_form()
@ -141,6 +388,37 @@ TEC_form::~TEC_form()
_form = NULL; _form = NULL;
} }
///////////////////////////////////////////////////////////
// TFilearray
///////////////////////////////////////////////////////////
class TFile_array
{
TArray _file;
public:
void open(int num, ...);
TLocalisamfile& file(int num) const { return (TLocalisamfile&)_file[num]; }
TLocalisamfile& operator[](int num) const { return file(num); }
TFile_array() {}
virtual ~TFile_array() {}
};
void TFile_array::open(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);
}
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Stampa estratti conto // Stampa estratti conto
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -150,6 +428,8 @@ class TStampaEC_application : public TApplication
TEC_mask* _msk; TEC_mask* _msk;
TEC_form* _form; TEC_form* _form;
TFile_array _file;
TString _lingua; TString _lingua;
TString _linprof; TString _linprof;
bool _gesval; bool _gesval;
@ -195,18 +475,28 @@ bool TStampaEC_application::select_ec()
bool TStampaEC_application::print_selected() bool TStampaEC_application::print_selected()
{ {
TCursor_sheet& s = sheet(); TCursor_sheet& s = sheet();
TCursor& c = *s.cursor();
const char who = mask().get_who();
const int key = mask().get_key();
// Filtra il cursore del form in mode che diventi uguale al cursor_sheet corrente
// Qui sarebbe bello copiarsi l'indice dell'altro cursore
TCursor& fc = *form().cursor();
fc.setkey(key);
TRectype filter(LF_CLIFO);
filter.put(CLI_TIPOCF, who);
fc.setregion(filter, filter);
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti 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 long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
printer().open(); printer().open();
TCursor& c = *s.cursor();
const long items = c.items(); const long items = c.items();
for (long i = 0; i < items; i++) if (print_all || s.checked(i)) for (long i = 0; i < items; i++) if (print_all || s.checked(i))
{ {
c = i; fc = i; // Muove il cursore alla posizione corrente
form().move_cursor(c.file().curr());
const bool ok = print_ec(); const bool ok = print_ec();
if (!ok) analfabeti++; if (!ok) analfabeti++;
} }
@ -214,7 +504,7 @@ bool TStampaEC_application::print_selected()
printer().close(); printer().close();
if (analfabeti > 0) if (analfabeti > 0)
warning_box("%ld clienti/fornitori non sono stati stmapati in quanto " warning_box("%ld clienti/fornitori non sono stati stampati in quanto "
"il codice lingua non corrispondeva al profilo di stampa", analfabeti); "il codice lingua non corrispondeva al profilo di stampa", analfabeti);
return TRUE; return TRUE;
@ -236,23 +526,58 @@ bool TStampaEC_application::print_ec()
if (!ok) // Cliente analfabeta if (!ok) // Cliente analfabeta
return FALSE; return FALSE;
TRectype filter(LF_PARTITE); // Filtra solo le partite del cliente selezionato
filter.put(PART_TIPOCF, clf.get(CLI_TIPOCF)); TLocalisamfile& partite = _file[LF_PARTITE];
filter.put(PART_SOTTOCONTO, clf.get(CLI_CODCF)); partite.zero();
partite.put(PART_TIPOCF, clf.get(CLI_TIPOCF));
partite.put(PART_SOTTOCONTO, clf.get(CLI_CODCF));
const TRectype filter(partite.curr());
TLocalisamfile& partite = f.cursor()->file(LF_PARTITE); const bool stampa_chiuse = mask().get_bool(F_STAMPCHIU);
for (int err = partite.read(); const TDate data_chiuse = mask().get(F_DATACHIU);
const TDate data_scaduto = mask().get(F_DATALIMSC);
const int giorni_rischio = mask().get_int(F_GIORISCH);
bool one_printed = FALSE;
for (int err = partite.read(_isgteq);
err == NOERR && partite.curr() == filter; err == NOERR && partite.curr() == filter;
err = partite.read(_isgreat)) err = partite.read(_isgreat))
{ {
TPartita game(partite.curr()); TPartita game(partite.curr());
for (int r = game.last(); r > 0; r = game.pred(r))
if (game.chiusa())
{ {
TDate data_rischio = data_scaduto; data_rischio -= giorni_rischio;
const TImporto saldo = game.calcola_saldo_al(data_rischio, TRUE);
if (saldo.is_zero())
{
int r = 0;
if (stampa_chiuse)
{
for (r = game.last(); r > 0 ; r = game.pred(r))
{
const TRiga_partite& riga = game.riga(r);
if (riga.is_fattura())
{
const TDate dd(riga.get(PART_DATADOC));
if (dd > data_rischio)
break;
}
}
}
if (r == 0)
continue;
}
} }
partite.put(PART_NUMRIG, 9999); const bool printed = form().print_game(game);
if (printed)
one_printed = TRUE;
partite.put(PART_NRIGA, 9999);
} }
if (one_printed)
printer().formfeed(); printer().formfeed();
return TRUE; return TRUE;
@ -266,6 +591,10 @@ bool TStampaEC_application::create()
{ {
TApplication::create(); TApplication::create();
_file.open(LF_TABCOM, LF_TAB, LF_CAUSALI, LF_MOV, LF_RMOV, 0);
_file.open(LF_NDITTE, LF_ANAG, LF_COMUNI, 0);
_file.open(LF_CLIFO, LF_PARTITE, LF_SCADENZE, LF_PAGSCA ,0);
_msk = new TEC_mask("sc2100a"); _msk = new TEC_mask("sc2100a");
dispatch_e_menu(MENU_ITEM(1)); dispatch_e_menu(MENU_ITEM(1));
@ -302,3 +631,4 @@ int sc2100(int argc, char** argv)
app.run(argc, argv, "Stampa Estratti Conto"); app.run(argc, argv, "Stampa Estratti Conto");
return 0; return 0;
} }

View File

@ -75,6 +75,7 @@ END
NUMBER F_GIORISCH 3 NUMBER F_GIORISCH 3
BEGIN BEGIN
PROMPT 1 11 "Giorni calcolo rischio " PROMPT 1 11 "Giorni calcolo rischio "
GROUP 1
END END
BOOLEAN F_STAMPCHIU BOOLEAN F_STAMPCHIU
@ -87,6 +88,7 @@ END
DATE F_DATACHIU DATE F_DATACHIU
BEGIN BEGIN
PROMPT 25 12 "dal " PROMPT 25 12 "dal "
FLAGS "D"
END END
STRING F_LUOGOSEND 50 32 STRING F_LUOGOSEND 50 32
@ -102,6 +104,20 @@ BEGIN
END END
RADIOBUTTON SC_CLIFO 20
BEGIN
PROMPT 1 2 "Selezione"
ITEM "C|Clienti" MESSAGE ENABLE,1@
ITEM "F|Fornitori" MESSAGE CLEAR,1@
END
RADIOBUTTON SC_SORTCF 20
BEGIN
PROMPT 25 2 "Ordinamento"
ITEM "1|Per codice"
ITEM "2|Per ragione sociale"
END
BUTTON SC_SELECT 10 1 BUTTON SC_SELECT 10 1
BEGIN BEGIN
PROMPT 51 3 "~Selezione" PROMPT 51 3 "~Selezione"
@ -112,20 +128,6 @@ BEGIN
PROMPT 51 4 "~Azzera" PROMPT 51 4 "~Azzera"
END END
RADIOBUTTON SC_CLIFO 20
BEGIN
PROMPT 1 2 "Selezione"
ITEM "C|Clienti"
ITEM "F|Fornitori"
END
RADIOBUTTON SC_SORTCF 20
BEGIN
PROMPT 25 2 "Ordinamento"
ITEM "1|Per codice"
ITEM "2|Per ragione sociale"
END
NUMBER SC_CFCODFR 5 NUMBER SC_CFCODFR 5
BEGIN BEGIN
PROMPT 1 6 "Da codice " PROMPT 1 6 "Da codice "

View File

@ -3,10 +3,13 @@
#include "sc2101.h" #include "sc2101.h"
#include "sc2100a.h" #include "sc2100a.h"
#include <comuni.h>
TEC_mask::TEC_mask(const char* name) : TSelection_mask(name), _ditta(LF_NDITTE) TEC_mask::TEC_mask(const char* name) : TSelection_mask(name), _ditta(LF_NDITTE)
{ {
_ditta.add(LF_ANAG, "TIPOA==TIPOA|CODANAGR==CODANAGR"); _ditta.add(LF_ANAG, "TIPOA==TIPOA|CODANAGR==CODANAGR");
_ditta.add(LF_COMUNI, "COM==COMRF(COMRES)", 1, LF_ANAG); _ditta.add(LF_COMUNI, "COM==COMRF(COMRES)", 1, LF_ANAG, 101);
_ditta.add(LF_COMUNI, "COM==COMRES", 1, LF_ANAG, 102);
} }
TEC_mask::~TEC_mask() TEC_mask::~TEC_mask()
@ -19,7 +22,10 @@ void TEC_mask::on_firm_change()
_ditta[0].put("CODDITTA", prefix().get_codditta()); _ditta[0].put("CODDITTA", prefix().get_codditta());
if (_ditta.read() == NOERR) if (_ditta.read() == NOERR)
set(F_LUOGOSEND, _ditta[LF_COMUNI].get("DENCOM")); {
const int alias = _ditta[LF_ANAG].get_char("TIPOA") == 'F' ? -101 : -102;
set(F_LUOGOSEND, _ditta.lfile(alias).get("DENCOM"));
}
} }
void TEC_mask::start_run() void TEC_mask::start_run()

View File

@ -7,4 +7,7 @@
#define F_VALUTA 106 #define F_VALUTA 106
#define F_TIPO 107
#define F_ORDINE 108
#define SC21_BUT_SEL 109

View File

@ -7,9 +7,10 @@ TSelection_mask::TSelection_mask(const char* name)
// crea relazioni, cursori e cursor_sheets // crea relazioni, cursori e cursor_sheets
_clifo_rel = new TRelation(LF_CLIFO); _clifo_rel = new TRelation(LF_CLIFO);
_cli_cur_k1 = new TCursor(_clifo_rel, "TIPOCF=\"C\"", 1); TRectype filter(LF_CLIFO);
_cli_cur_k2 = new TCursor(_clifo_rel, "TIPOCF=\"C\"", 2); filter.put("TIPOCF", "C");
_cli_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter);
_cli_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter);
_cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice", _cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice",
"@1|Codice|Ragione Sociale@50"); "@1|Codice|Ragione Sociale@50");
@ -18,8 +19,9 @@ TSelection_mask::TSelection_mask(const char* name)
if (id2pos(SC_CLIFO) >= 0) if (id2pos(SC_CLIFO) >= 0)
{ {
_for_cur_k1 = new TCursor(_clifo_rel, "TIPOCF=\"F\"", 1); filter.put("TIPOCF", "F");
_for_cur_k2 = new TCursor(_clifo_rel, "TIPOCF=\"F\"", 2); _for_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter);
_for_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter);
_for_sh_k1 = new TCursor_sheet(_for_cur_k1, " |CODCF|RAGSOC", "Selezione fornitori per codice", _for_sh_k1 = new TCursor_sheet(_for_cur_k1, " |CODCF|RAGSOC", "Selezione fornitori per codice",
"@1|Codice|Ragione Sociale@50"); "@1|Codice|Ragione Sociale@50");
_for_sh_k2 = new TCursor_sheet(_for_cur_k2, " |RAGSOC|CODCF", "Selezione fornitori per ragione sociale", _for_sh_k2 = new TCursor_sheet(_for_cur_k2, " |RAGSOC|CODCF", "Selezione fornitori per ragione sociale",