2005-02-17 18:13:12 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <assoc.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <currency.h>
|
|
|
|
|
#include <filetext.h>
|
|
|
|
|
#include <msksheet.h>
|
|
|
|
|
#include <printer.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <sort.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "cg7.h"
|
|
|
|
|
#include "cg7200a.h"
|
|
|
|
|
|
|
|
|
|
#include <mov.h>
|
|
|
|
|
#include <rmov.h>
|
|
|
|
|
#include <rmoviva.h>
|
2005-05-16 23:44:23 +00:00
|
|
|
|
#include <pagsca.h>
|
|
|
|
|
#include <partite.h>
|
2005-02-17 18:13:12 +00:00
|
|
|
|
|
2005-03-03 15:42:04 +00:00
|
|
|
|
#define ALIAS_PCON1 100
|
|
|
|
|
#define ALIAS_PCON2 200
|
2005-05-16 23:44:23 +00:00
|
|
|
|
#define ALIAS_ABPCON1 300
|
|
|
|
|
#define ALIAS_ABPCON2 400
|
2005-02-17 18:13:12 +00:00
|
|
|
|
|
|
|
|
|
class TInvioP_file: public TFile_text
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TInvioP_file(const TString& file_name, const TString& config_name);
|
|
|
|
|
virtual ~TInvioP_file() { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TInvioP_file::TInvioP_file(const TString& file_name, const TString& config_name)
|
|
|
|
|
: TFile_text(file_name, config_name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TInvioP_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
TInvioP_mask();
|
|
|
|
|
|
|
|
|
|
virtual ~TInvioP_mask(){};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TInvioP_mask::TInvioP_mask() :TAutomask ("cg7200a")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInvioP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_CODDITTA:
|
|
|
|
|
if (e==fe_init && o.empty())
|
|
|
|
|
{
|
|
|
|
|
set(F_CODDITTA, main_app().get_firm());
|
|
|
|
|
((TEdit_field&) o).check();
|
|
|
|
|
disable(F_CODDITTA);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TInvioP : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
TCursor* _cur;
|
|
|
|
|
TInvioP_mask* _msk;
|
|
|
|
|
TInvioP_file* _trasfile;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
TInvioP_file* _trasfilepag;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TDate _dataini, _datafin;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
long _nregcosto, _nregpag;
|
|
|
|
|
real _importo;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create(void);
|
|
|
|
|
virtual bool destroy(void);
|
|
|
|
|
virtual void main_loop() ;
|
|
|
|
|
void invio_proforma();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
bool i_proforma_movimenti(const bool pagamenti);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
bool i_proforma_righe();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
bool i_proforma_pagamenti(const TCursor& cur);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
bool i_proforma_clifor(char tipocf = 'C');
|
|
|
|
|
bool i_proforma_conti();
|
|
|
|
|
public:
|
2005-05-16 23:44:23 +00:00
|
|
|
|
const real get_importo() {return _importo;};
|
2005-09-19 12:45:16 +00:00
|
|
|
|
const char* get_nregcosto() {return format("%d", _nregcosto);};
|
|
|
|
|
const char* get_nregpag() {return format("%d", _nregpag);};
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TInvioP() {};
|
|
|
|
|
virtual ~TInvioP() {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// restituisce un riferimento all' applicazione
|
|
|
|
|
inline TInvioP& app() { return (TInvioP&) main_app();}
|
|
|
|
|
|
|
|
|
|
// gestione dei messaggi estesi nei campi
|
|
|
|
|
void TInvioP_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str)
|
|
|
|
|
{
|
|
|
|
|
const TString code(s.get(0));
|
|
|
|
|
TString valore;
|
|
|
|
|
if (code == "_FISSO")
|
|
|
|
|
{
|
|
|
|
|
// gestione dei campi fissi per i record delle riba
|
|
|
|
|
// sintassi: _FISSO,!<valore>
|
|
|
|
|
// dove: <valore> <20> la stringa fissa da emettere
|
|
|
|
|
TString in(s.get());
|
|
|
|
|
CHECK(in[0]=='!',"Macro _FISSO senza carattere '!'");
|
|
|
|
|
in.ltrim(1);
|
|
|
|
|
in.trim();
|
|
|
|
|
valore = in;
|
|
|
|
|
}
|
2005-03-03 15:42:04 +00:00
|
|
|
|
else if (code == "_TELEFONO")
|
2005-02-17 18:13:12 +00:00
|
|
|
|
{
|
|
|
|
|
valore = str;
|
2005-03-03 15:42:04 +00:00
|
|
|
|
valore.trim();
|
|
|
|
|
str = cur.curr().get("PTEL");
|
|
|
|
|
valore << str;
|
|
|
|
|
valore.trim();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
|
else if (code == "_CODCBL")
|
|
|
|
|
{
|
|
|
|
|
valore = str;
|
|
|
|
|
int i = valore.find("$");
|
|
|
|
|
valore = valore.left(i);
|
|
|
|
|
}
|
|
|
|
|
else if (code == "_RAGSOC")
|
|
|
|
|
{
|
|
|
|
|
valore = str;
|
|
|
|
|
valore = valore.strip_d_spaces();
|
|
|
|
|
}
|
|
|
|
|
else if (code == "_FLAG")
|
|
|
|
|
{
|
|
|
|
|
const char chiusa = str[0];
|
|
|
|
|
valore = (chiusa=='X') ? "S" : "A";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (code == "_NREGCOSTO")
|
|
|
|
|
{
|
|
|
|
|
valore = app().get_nregcosto();
|
|
|
|
|
}
|
|
|
|
|
else if (code == "_NREGPAG")
|
|
|
|
|
{
|
|
|
|
|
valore = app().get_nregpag();
|
|
|
|
|
}
|
|
|
|
|
else if (code == "_IMPORTO")
|
|
|
|
|
{
|
|
|
|
|
valore = app().get_importo().string();
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-17 18:13:12 +00:00
|
|
|
|
else NFCHECK("Macro non definita: %s", (const char *)code);
|
|
|
|
|
str = valore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInvioP::create()
|
|
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
|
open_files(LF_CAUSALI, LF_CLIFO, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA, LF_ABPCON, LF_PARTITE, 0);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
_msk = new TInvioP_mask();
|
|
|
|
|
_trasfile = NULL;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
_trasfilepag = NULL;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInvioP::destroy()
|
|
|
|
|
{
|
|
|
|
|
if (_trasfile)
|
|
|
|
|
delete _trasfile;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (_trasfilepag)
|
|
|
|
|
delete _trasfilepag;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
delete _msk;
|
|
|
|
|
|
|
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TInvioP::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TFilename configname = "cg7200a.ini";
|
|
|
|
|
TConfig configfile(configname);
|
|
|
|
|
_msk->set(F_DATAINI, configfile.get("DATA","OPZIONI"));
|
|
|
|
|
_msk->set(F_DESTINAZIONE, configfile.get("PERCORSO","OPZIONI"));
|
|
|
|
|
|
|
|
|
|
while (_msk->run()!=K_QUIT)
|
|
|
|
|
{
|
|
|
|
|
configfile.set("DATA", _msk->get_date(F_DATAFIN),"OPZIONI");
|
|
|
|
|
configfile.set("PERCORSO", _msk->get(F_DESTINAZIONE),"OPZIONI");
|
|
|
|
|
_dataini = _msk->get_date(F_DATAINI);
|
|
|
|
|
_datafin = _msk->get_date(F_DATAFIN);
|
|
|
|
|
const char tipoinvio = _msk->get(F_TIPOINVIO)[0];
|
|
|
|
|
if (tipoinvio == 'P')
|
|
|
|
|
invio_proforma();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TInvioP::invio_proforma()
|
|
|
|
|
{
|
|
|
|
|
if (_msk->get_bool(F_MOVIMENTI))
|
|
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
|
i_proforma_movimenti(_msk->get_bool(F_PAGAMENTI));
|
2005-02-17 18:13:12 +00:00
|
|
|
|
i_proforma_righe();
|
|
|
|
|
}
|
|
|
|
|
if (_msk->get_bool(F_CLIENTI))
|
|
|
|
|
i_proforma_clifor();
|
|
|
|
|
if (_msk->get_bool(F_FORNITORI))
|
|
|
|
|
i_proforma_clifor('F');
|
|
|
|
|
if (_msk->get_bool(F_CONTI))
|
|
|
|
|
i_proforma_conti();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInvioP::i_proforma_conti()
|
|
|
|
|
{
|
|
|
|
|
TFilename configname = "proforma.ini";
|
|
|
|
|
TConfig configfile(configname);
|
|
|
|
|
TFilename filename = _msk->get(F_DESTINAZIONE);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
filename.add("pianocon.txt");
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (fexist(filename))
|
|
|
|
|
remove(filename);
|
|
|
|
|
_trasfile = new TInvioP_file(filename, configname);
|
|
|
|
|
_trasfile->open(filename,'w');
|
2005-03-03 15:42:04 +00:00
|
|
|
|
_trasfile->force_record_separator();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TRelation rel(LF_PCON);
|
|
|
|
|
TCursor cur(&rel);
|
|
|
|
|
const long cur_items = cur.items();
|
|
|
|
|
if (cur_items != 0)
|
|
|
|
|
{
|
|
|
|
|
cur.freeze();
|
|
|
|
|
TRectype& cur_rec = cur.curr();
|
|
|
|
|
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
|
|
|
|
{
|
|
|
|
|
TRecord_text rec;
|
|
|
|
|
rec.set_type("P");
|
|
|
|
|
_trasfile->autoload(rec, cur);
|
|
|
|
|
_trasfile->write(rec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
|
|
|
|
delete _trasfile;
|
|
|
|
|
_trasfile = NULL;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
|
bool TInvioP::i_proforma_movimenti(const bool pagamenti)
|
2005-02-17 18:13:12 +00:00
|
|
|
|
{
|
|
|
|
|
TFilename configname = "proforma.ini";
|
|
|
|
|
TConfig configfile(configname);
|
|
|
|
|
TFilename filename = _msk->get(F_DESTINAZIONE);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
filename.add("registra.txt");
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (fexist(filename))
|
|
|
|
|
remove(filename);
|
|
|
|
|
_trasfile = new TInvioP_file(filename, configname);
|
|
|
|
|
_trasfile->open(filename,'w');
|
2005-03-03 15:42:04 +00:00
|
|
|
|
_trasfile->force_record_separator();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (pagamenti)
|
|
|
|
|
{
|
|
|
|
|
TFilename filenamepag = _msk->get(F_DESTINAZIONE);
|
|
|
|
|
filenamepag.add("pagament.txt");
|
|
|
|
|
if (fexist(filenamepag))
|
|
|
|
|
remove(filenamepag);
|
|
|
|
|
_trasfilepag = new TInvioP_file(filenamepag, configname);
|
|
|
|
|
_trasfilepag->open(filenamepag,'w');
|
|
|
|
|
_trasfilepag->force_record_separator();
|
|
|
|
|
}
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TRectype da(LF_MOV);
|
|
|
|
|
TRectype a(LF_MOV);
|
|
|
|
|
da.put(MOV_DATAREG, _dataini);
|
|
|
|
|
a.put(MOV_DATAREG, _datafin);
|
|
|
|
|
TRelation rel(LF_MOV);
|
|
|
|
|
rel.add(LF_CAUSALI, "CODCAUS==CODCAUS", 1);
|
|
|
|
|
TCursor cur(&rel, "", 2, &da, &a);
|
|
|
|
|
|
|
|
|
|
const long cur_items = cur.items();
|
|
|
|
|
if (cur_items != 0)
|
|
|
|
|
{
|
|
|
|
|
cur.freeze();
|
|
|
|
|
TRectype& cur_rec = cur.curr();
|
|
|
|
|
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
|
|
|
|
{
|
|
|
|
|
TRecord_text rec;
|
|
|
|
|
rec.set_type("T");
|
|
|
|
|
_trasfile->autoload(rec, cur);
|
|
|
|
|
_trasfile->write(rec);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (pagamenti)
|
|
|
|
|
i_proforma_pagamenti(cur);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
|
|
|
|
delete _trasfile;
|
|
|
|
|
_trasfile = NULL;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
if (pagamenti)
|
|
|
|
|
{
|
|
|
|
|
_trasfilepag->close();
|
|
|
|
|
delete _trasfilepag;
|
|
|
|
|
_trasfilepag = NULL;
|
|
|
|
|
}
|
2005-02-17 18:13:12 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TInvioP::i_proforma_righe()
|
|
|
|
|
{
|
|
|
|
|
TFilename configname = "proforma.ini";
|
|
|
|
|
TConfig configfile(configname);
|
|
|
|
|
TFilename filename = _msk->get(F_DESTINAZIONE);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
filename.add("righe.txt");
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (fexist(filename))
|
|
|
|
|
remove(filename);
|
|
|
|
|
_trasfile = new TInvioP_file(filename, configname);
|
|
|
|
|
_trasfile->open(filename,'w');
|
2005-03-03 15:42:04 +00:00
|
|
|
|
_trasfile->force_record_separator();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TRectype da(LF_MOV);
|
|
|
|
|
TRectype a(LF_MOV);
|
|
|
|
|
da.put(MOV_DATAREG, _dataini);
|
|
|
|
|
a.put(MOV_DATAREG, _datafin);
|
|
|
|
|
TRelation rel(LF_MOV);
|
|
|
|
|
rel.add(LF_RMOVIVA, "NUMREG==NUMREG", 1);
|
|
|
|
|
rel.add(LF_RMOV, "NUMREG==NUMREG", 1);
|
2005-03-03 15:42:04 +00:00
|
|
|
|
rel.add(LF_PCON, "GRUPPO==GRUPPO|CONTO==CONTO|SOTTOCONTO==SOTTOCONTO", 1, LF_RMOV, ALIAS_PCON1);
|
|
|
|
|
rel.add(LF_PCON, "GRUPPO==GRUPPO|CONTO==CONTO|SOTTOCONTO==SOTTOCONTO", 1, LF_RMOVIVA, ALIAS_PCON2);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
rel.add(LF_ABPCON, "CODCBL==CODCBL", 1, -ALIAS_PCON1, ALIAS_ABPCON1);
|
|
|
|
|
rel.add(LF_ABPCON, "CODCBL==CODCBL", 1, -ALIAS_PCON2, ALIAS_ABPCON2);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TCursor cur(&rel, "", 2, &da, &a);
|
|
|
|
|
const long cur_items = cur.items();
|
|
|
|
|
if (cur_items != 0)
|
|
|
|
|
{
|
|
|
|
|
cur.freeze();
|
|
|
|
|
TRectype& cur_rec = cur.curr();
|
|
|
|
|
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
|
|
|
|
{
|
|
|
|
|
const long numreg = cur.curr().get_long(MOV_NUMREG);
|
|
|
|
|
bool continua = TRUE;
|
|
|
|
|
while (continua)
|
|
|
|
|
{
|
|
|
|
|
const long numregrig = cur.curr(LF_RMOVIVA).get_long(RMI_NUMREG);
|
|
|
|
|
if (numreg == numregrig)
|
|
|
|
|
{
|
|
|
|
|
TRectype& cur_rec_righe = cur.curr(LF_RMOVIVA);
|
|
|
|
|
TRecord_text recrighe;
|
|
|
|
|
recrighe.set_type("I");
|
|
|
|
|
_trasfile->autoload(recrighe, cur);
|
|
|
|
|
_trasfile->write(recrighe);
|
|
|
|
|
}
|
|
|
|
|
continua = cur.next_match(LF_RMOVIVA, "NUMREG");
|
|
|
|
|
}
|
|
|
|
|
continua = TRUE;
|
|
|
|
|
while (continua)
|
|
|
|
|
{
|
|
|
|
|
const long numregrig = cur.curr(LF_RMOV).get_long(RMV_NUMREG);
|
|
|
|
|
if (numreg == numregrig)
|
|
|
|
|
{
|
|
|
|
|
TRectype& cur_rec_righe = cur.curr(LF_RMOV);
|
|
|
|
|
TRecord_text recrighe;
|
|
|
|
|
recrighe.set_type("R");
|
|
|
|
|
_trasfile->autoload(recrighe, cur);
|
|
|
|
|
_trasfile->write(recrighe);
|
|
|
|
|
}
|
|
|
|
|
continua = cur.next_match(LF_RMOV, "NUMREG");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
|
|
|
|
delete _trasfile;
|
|
|
|
|
_trasfile = NULL;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
|
bool TInvioP::i_proforma_pagamenti(const TCursor& cur)
|
|
|
|
|
{
|
|
|
|
|
const char tipomov = cur.curr().get(MOV_TIPOMOV)[0];
|
|
|
|
|
if (tipomov == '3' || tipomov == '2' || tipomov == '6')
|
|
|
|
|
{
|
|
|
|
|
TRelation relpart(LF_PARTITE);
|
|
|
|
|
TRectype da(LF_PARTITE);
|
|
|
|
|
da.put(PART_NREG, cur.curr().get(MOV_NUMREG));
|
|
|
|
|
TCursor curpart(&relpart, "", 2, &da, &da);
|
|
|
|
|
const long curpart_items = curpart.items();
|
|
|
|
|
if (curpart_items != 0)
|
|
|
|
|
{
|
|
|
|
|
curpart.freeze();
|
|
|
|
|
TRectype& curpart_rec = curpart.curr();
|
|
|
|
|
for (curpart = 0; curpart.pos() < curpart_items; ++(curpart))
|
|
|
|
|
{
|
|
|
|
|
TRelation relpag(LF_PAGSCA);
|
|
|
|
|
TRectype da(LF_PAGSCA);
|
|
|
|
|
da.put(PAGSCA_TIPOC, curpart_rec.get(PART_TIPOCF));
|
|
|
|
|
da.put(PAGSCA_GRUPPO, curpart_rec.get(PART_GRUPPO));
|
|
|
|
|
da.put(PAGSCA_CONTO, curpart_rec.get(PART_CONTO));
|
|
|
|
|
da.put(PAGSCA_SOTTOCONTO, curpart_rec.get(PART_SOTTOCONTO));
|
|
|
|
|
da.put(PAGSCA_ANNO, curpart_rec.get(PART_ANNO));
|
|
|
|
|
da.put(PAGSCA_NUMPART, curpart_rec.get(PART_NUMPART));
|
|
|
|
|
const int nrigapart = curpart_rec.get_int(PART_NRIGA);
|
|
|
|
|
TString80 filtro;
|
|
|
|
|
filtro.format("NRIGP == %d", nrigapart);
|
2005-09-19 12:45:16 +00:00
|
|
|
|
TCursor curpag(&relpag, filtro, 1, &da, &da);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
const long curpag_items = curpag.items();
|
|
|
|
|
if (curpag_items != 0)
|
|
|
|
|
{
|
|
|
|
|
TAssoc_array pagame;
|
|
|
|
|
pagame.destroy();
|
|
|
|
|
curpag.freeze();
|
|
|
|
|
TRectype& curpag_rec = curpag.curr();
|
|
|
|
|
for (curpag = 0; curpag.pos() < curpag_items; ++(curpag))
|
|
|
|
|
{
|
|
|
|
|
TString80 indice = curpag_rec.get(PAGSCA_ANNO);
|
|
|
|
|
indice << '|' << curpag_rec.get(PAGSCA_NUMPART);
|
|
|
|
|
indice << '|' << curpag_rec.get(PAGSCA_NRIGA);
|
|
|
|
|
real importo = ZERO;
|
|
|
|
|
bool is_key = pagame.is_key(indice);
|
|
|
|
|
real& somma = is_key ? (real&) pagame[indice] : importo;
|
|
|
|
|
somma += curpag_rec.get_real(PAGSCA_IMPORTO);
|
|
|
|
|
if (!is_key)
|
|
|
|
|
pagame.add(indice, somma);
|
|
|
|
|
}
|
|
|
|
|
// scrivo i record risultanti
|
|
|
|
|
real* cp;
|
|
|
|
|
for (cp = (real*) pagame.first_item(); cp != NULL; cp = (real*) pagame.succ_item())
|
|
|
|
|
{
|
|
|
|
|
TToken_string keypart;
|
2005-09-19 12:45:16 +00:00
|
|
|
|
keypart.add(curpart_rec.get(PART_TIPOCF));
|
|
|
|
|
keypart.add(curpart_rec.get(PART_GRUPPO));
|
|
|
|
|
keypart.add(curpart_rec.get(PART_CONTO));
|
|
|
|
|
keypart.add(curpart_rec.get(PART_SOTTOCONTO));
|
|
|
|
|
keypart.add(pagame.get_hashobj()->key());
|
2005-05-16 23:44:23 +00:00
|
|
|
|
const TRectype& partita = cache().get(LF_PARTITE, keypart);
|
|
|
|
|
_nregpag = cur.curr().get_long(MOV_NUMREG);
|
|
|
|
|
_nregcosto = partita.get_long(PART_NREG);
|
|
|
|
|
_importo = *cp;
|
|
|
|
|
TRecord_text recpag;
|
|
|
|
|
recpag.set_type("G");
|
|
|
|
|
_trasfilepag->autoload(recpag, curpag);
|
|
|
|
|
_trasfilepag->write(recpag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-17 18:13:12 +00:00
|
|
|
|
bool TInvioP::i_proforma_clifor(char tipocf)
|
|
|
|
|
{
|
|
|
|
|
TFilename configname = "proforma.ini";
|
|
|
|
|
TConfig configfile(configname);
|
|
|
|
|
TFilename filename = _msk->get(F_DESTINAZIONE);
|
|
|
|
|
if (tipocf == 'C')
|
2005-05-16 23:44:23 +00:00
|
|
|
|
filename.add("clienti.txt");
|
2005-02-17 18:13:12 +00:00
|
|
|
|
else
|
2005-05-16 23:44:23 +00:00
|
|
|
|
filename.add("fornit.txt");
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (fexist(filename))
|
|
|
|
|
remove(filename);
|
|
|
|
|
_trasfile = new TInvioP_file(filename, configname);
|
|
|
|
|
_trasfile->open(filename,'w');
|
2005-03-03 15:42:04 +00:00
|
|
|
|
_trasfile->force_record_separator();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TString80 filtro = "";
|
|
|
|
|
filtro.format("TIPOCF == \"%c\"", tipocf);
|
|
|
|
|
TRelation rel(LF_CLIFO);
|
2005-03-03 15:42:04 +00:00
|
|
|
|
rel.add(LF_COMUNI, "STATO==STATOCF|COM==COMCF", 1);
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TCursor cur(&rel, filtro);
|
|
|
|
|
const long cur_items = cur.items();
|
|
|
|
|
if (cur_items != 0)
|
|
|
|
|
{
|
|
|
|
|
cur.freeze();
|
|
|
|
|
TRectype& cur_rec = cur.curr();
|
|
|
|
|
for (cur = 0; cur.pos() < cur_items; ++(cur))
|
|
|
|
|
{
|
|
|
|
|
TRecord_text rec;
|
|
|
|
|
|
|
|
|
|
rec.set_type("C");
|
|
|
|
|
_trasfile->autoload(rec, cur);
|
|
|
|
|
_trasfile->write(rec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
|
|
|
|
delete _trasfile;
|
|
|
|
|
_trasfile = NULL;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cg7200(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
TInvioP a;
|
|
|
|
|
a.run(argc, argv, "Invio dati contabilit<69>");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|