Patch level :2.1 nopatch per ora
Files correlati : Ricompilazione Demo : [ ] Commento :programma proforma in corso d'opera git-svn-id: svn://10.65.10.50/trunk@13469 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ba935d2176
commit
ba7cfa9079
586
cg/cg7200.cpp
586
cg/cg7200.cpp
@ -12,6 +12,7 @@
|
||||
|
||||
#include "cg7.h"
|
||||
#include "cg7200a.h"
|
||||
#include "cglib01.h"
|
||||
|
||||
#include <mov.h>
|
||||
#include <rmov.h>
|
||||
@ -19,6 +20,10 @@
|
||||
#include <pagsca.h>
|
||||
#include <partite.h>
|
||||
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/movana.h"
|
||||
#include "../ca/rmovana.h"
|
||||
|
||||
#define ALIAS_PCON1 100
|
||||
#define ALIAS_PCON2 200
|
||||
#define ALIAS_ABPCON1 300
|
||||
@ -30,12 +35,12 @@ 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);
|
||||
TInvioP_file(const TString& file_name);
|
||||
virtual ~TInvioP_file() { }
|
||||
};
|
||||
|
||||
TInvioP_file::TInvioP_file(const TString& file_name, const TString& config_name)
|
||||
: TFile_text(file_name, config_name)
|
||||
TInvioP_file::TInvioP_file(const TString& file_name)
|
||||
: TFile_text(file_name, "proforma.ini")
|
||||
{
|
||||
}
|
||||
|
||||
@ -74,28 +79,31 @@ bool TInvioP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
|
||||
class TInvioP : public TSkeleton_application
|
||||
{
|
||||
TCursor* _cur;
|
||||
TInvioP_mask* _msk;
|
||||
TInvioP_file* _trasfile;
|
||||
TInvioP_file* _trasfilepag;
|
||||
TDate _dataini, _datafin;
|
||||
long _nregcosto, _nregpag;
|
||||
real _importo;
|
||||
|
||||
TCursor* _cur;
|
||||
TInvioP_mask* _msk;
|
||||
TDate _dataini, _datafin;
|
||||
long _nregcosto, _nregpag;
|
||||
real _importo;
|
||||
TConfig* _configfile;
|
||||
|
||||
protected:
|
||||
virtual bool create(void);
|
||||
virtual bool destroy(void);
|
||||
virtual void main_loop() ;
|
||||
void invio_proforma();
|
||||
bool i_proforma_movimenti(const bool pagamenti);
|
||||
bool i_proforma_righe();
|
||||
bool i_proforma_pagamenti(const TCursor& cur);
|
||||
bool i_proforma_movimenti();
|
||||
bool i_proforma_righe(TCursor& cur, TInvioP_file* trasfile);
|
||||
bool i_proforma_pagamenti();
|
||||
bool i_proforma_clifor(char tipocf = 'C');
|
||||
bool i_proforma_conti();
|
||||
|
||||
public:
|
||||
const real get_importo() {return _importo;};
|
||||
const char* get_nregcosto() {return format("%d", _nregcosto);};
|
||||
const char* get_nregpag() {return format("%d", _nregpag);};
|
||||
TInvioP_file* apri_file(const char* nome);
|
||||
void chiudi_file(TInvioP_file* trasfile);
|
||||
|
||||
TInvioP() {};
|
||||
virtual ~TInvioP() {};
|
||||
};
|
||||
@ -161,71 +169,30 @@ void TInvioP_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS
|
||||
str = valore;
|
||||
}
|
||||
|
||||
bool TInvioP::create()
|
||||
{
|
||||
open_files(LF_CAUSALI, LF_CLIFO, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA, LF_ABPCON, LF_PARTITE, 0);
|
||||
_msk = new TInvioP_mask();
|
||||
_trasfile = NULL;
|
||||
_trasfilepag = NULL;
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
bool TInvioP::destroy()
|
||||
{
|
||||
if (_trasfile)
|
||||
delete _trasfile;
|
||||
if (_trasfilepag)
|
||||
delete _trasfilepag;
|
||||
delete _msk;
|
||||
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
void TInvioP::main_loop()
|
||||
TInvioP_file* TInvioP::apri_file(const char* nome)
|
||||
{
|
||||
TFilename configname = "cg7200a.ini";
|
||||
TConfig configfile(configname);
|
||||
_msk->set(F_DATAINI, configfile.get("DATA","OPZIONI"));
|
||||
_msk->set(F_DESTINAZIONE, configfile.get("PERCORSO","OPZIONI"));
|
||||
TFilename filename = _msk->get(F_DESTINAZIONE);
|
||||
filename.add(nome);
|
||||
filename.ext("txt");
|
||||
if (filename.exist())
|
||||
remove(filename);
|
||||
|
||||
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();
|
||||
}
|
||||
TInvioP_file* trasfile = new TInvioP_file(filename);
|
||||
trasfile->open(filename,'w');
|
||||
trasfile->force_record_separator();
|
||||
return trasfile;
|
||||
}
|
||||
|
||||
void TInvioP::invio_proforma()
|
||||
void TInvioP::chiudi_file(TInvioP_file* trasfile)
|
||||
{
|
||||
if (_msk->get_bool(F_MOVIMENTI))
|
||||
{
|
||||
i_proforma_movimenti(_msk->get_bool(F_PAGAMENTI));
|
||||
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();
|
||||
trasfile->close();
|
||||
delete trasfile;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_conti()
|
||||
{
|
||||
TFilename configname = "proforma.ini";
|
||||
TConfig configfile(configname);
|
||||
TFilename filename = _msk->get(F_DESTINAZIONE);
|
||||
filename.add("pianocon.txt");
|
||||
if (fexist(filename))
|
||||
remove(filename);
|
||||
_trasfile = new TInvioP_file(filename, configname);
|
||||
_trasfile->open(filename,'w');
|
||||
_trasfile->force_record_separator();
|
||||
TInvioP_file* trasfile = apri_file("pianocon");
|
||||
|
||||
TRelation rel(LF_PCON);
|
||||
TCursor cur(&rel);
|
||||
const long cur_items = cur.items();
|
||||
@ -237,226 +204,244 @@ bool TInvioP::i_proforma_conti()
|
||||
{
|
||||
TRecord_text rec;
|
||||
rec.set_type("P");
|
||||
_trasfile->autoload(rec, cur);
|
||||
_trasfile->write(rec);
|
||||
trasfile->autoload(rec, cur);
|
||||
trasfile->write(rec);
|
||||
}
|
||||
}
|
||||
_trasfile->close();
|
||||
delete _trasfile;
|
||||
_trasfile = NULL;
|
||||
return TRUE;
|
||||
chiudi_file(trasfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_movimenti(const bool pagamenti)
|
||||
bool TInvioP::i_proforma_movimenti()
|
||||
{
|
||||
TFilename configname = "proforma.ini";
|
||||
TConfig configfile(configname);
|
||||
TFilename filename = _msk->get(F_DESTINAZIONE);
|
||||
filename.add("registra.txt");
|
||||
if (fexist(filename))
|
||||
remove(filename);
|
||||
_trasfile = new TInvioP_file(filename, configname);
|
||||
_trasfile->open(filename,'w');
|
||||
_trasfile->force_record_separator();
|
||||
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();
|
||||
}
|
||||
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);
|
||||
TInvioP_file* trasfile = apri_file("registra"); //file testate
|
||||
TInvioP_file* trasfilerighe = apri_file("righe"); //file righe movimenti
|
||||
|
||||
//trasferimento testate movimenti (cerca direttamente sui movimenti analitici in chiave 2..
|
||||
//..,cioè per DATACOMP e con NUMREGCG!=0
|
||||
TRectype da(LF_MOVANA);
|
||||
TRectype a(LF_MOVANA);
|
||||
da.put(MOVANA_DATACOMP, _dataini);
|
||||
a.put(MOV_DATACOMP, _datafin);
|
||||
TRelation rel(LF_MOVANA);
|
||||
rel.add(LF_MOV, "NUMREG==NUMREGCG");
|
||||
rel.add(LF_CAUSALI, "CODCAUS==CODCAUS");
|
||||
TCursor cur(&rel, "NUMREGCG!=0", 2, &da, &a);
|
||||
|
||||
const long cur_items = cur.items();
|
||||
if (cur_items != 0)
|
||||
{
|
||||
{
|
||||
//prepara i record di tipo testata da scrivere
|
||||
TRecord_text rec;
|
||||
rec.set_type("T");
|
||||
|
||||
cur.freeze();
|
||||
TRectype& cur_rec = cur.curr();
|
||||
const 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);
|
||||
if (pagamenti)
|
||||
i_proforma_pagamenti(cur);
|
||||
{
|
||||
//carica e scrive il record di testata in base alle informazioni contenute nel proforma.ini
|
||||
trasfile->autoload(rec, cur);
|
||||
trasfile->write(rec);
|
||||
//trasferisce le righe del movimento analitico corrente solo
|
||||
i_proforma_righe(cur, trasfilerighe);
|
||||
}
|
||||
}
|
||||
_trasfile->close();
|
||||
delete _trasfile;
|
||||
_trasfile = NULL;
|
||||
if (pagamenti)
|
||||
}
|
||||
chiudi_file(trasfilerighe);
|
||||
chiudi_file(trasfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_righe(TCursor& cur, TInvioP_file* trasfilerighe)
|
||||
{
|
||||
//---- righe movimenti analitica ----
|
||||
//necessita del numreg del corrente movimento analitico per poterlo istanziare e prenderne le righe
|
||||
const long numreg = cur.curr().get_long(MOVANA_NUMREG);
|
||||
TAnal_mov analmov(numreg); //..istanzia il movimento analitico cercato..
|
||||
int i;
|
||||
for (i = 1; i <= analmov.body().rows(); i++)
|
||||
{
|
||||
_trasfilepag->close();
|
||||
delete _trasfilepag;
|
||||
_trasfilepag = NULL;
|
||||
//..e scandisce le righe alla ricerca di quelle con conto = gruppo/conto/sottoconto del movimento contabile
|
||||
const TRectype& riga = analmov.body().row(i);
|
||||
//inganno il cursore passandogli la riga analitica in esame
|
||||
cur.curr(LF_RMOVANA) = riga;
|
||||
|
||||
TRecord_text recrighe;
|
||||
recrighe.set_type("R");
|
||||
trasfilerighe->autoload(recrighe, cur);
|
||||
trasfilerighe->write(recrighe);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_righe()
|
||||
{
|
||||
TFilename configname = "proforma.ini";
|
||||
TConfig configfile(configname);
|
||||
TFilename filename = _msk->get(F_DESTINAZIONE);
|
||||
filename.add("righe.txt");
|
||||
if (fexist(filename))
|
||||
remove(filename);
|
||||
_trasfile = new TInvioP_file(filename, configname);
|
||||
_trasfile->open(filename,'w');
|
||||
_trasfile->force_record_separator();
|
||||
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);
|
||||
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);
|
||||
rel.add(LF_ABPCON, "CODCBL==CODCBL", 1, -ALIAS_PCON1, ALIAS_ABPCON1);
|
||||
rel.add(LF_ABPCON, "CODCBL==CODCBL", 1, -ALIAS_PCON2, ALIAS_ABPCON2);
|
||||
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;
|
||||
}
|
||||
//---- righe iva ----
|
||||
//adesso tocca alle righe iva...e sara' un casino indicibile!
|
||||
const char* numregcg = analmov.get(MOVANA_NUMREGCG);
|
||||
//record_array con le righe iva aventi il numreg = numregcg analitico
|
||||
TRecord_array righeiva(numregcg, LF_RMOVIVA);
|
||||
//assoc array contenente tutti i diversi conti che incontrera' nello scanning delle righe iva
|
||||
TAssoc_array conti;
|
||||
|
||||
bool TInvioP::i_proforma_pagamenti(const TCursor& cur)
|
||||
{
|
||||
const char tipomov = cur.curr().get(MOV_TIPOMOV)[0];
|
||||
if (tipomov == '3' || tipomov == '2' || tipomov == '6')
|
||||
//scanning delle righe iva alla ricerca dei conti che compaiono
|
||||
for (int j = 1; j <= righeiva.rows(); j++)
|
||||
{
|
||||
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);
|
||||
TCursor curpag(&relpag, filtro, 1, &da, &da);
|
||||
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;
|
||||
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());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
//prende il conto e lo mette nell'assoc_array dei conti (notare che, essendo un assoc_array,..
|
||||
//..non vengono inseriti doppioni! mitico!!)
|
||||
TBill conto;
|
||||
conto.get(righeiva[j]);
|
||||
const char* codconto = conto.string(8);
|
||||
|
||||
//ad ogni conto lega un assoc_array (codivae) che conterra' tutti i codici iva legati a quel..
|
||||
//..conto nelle righe iva con i relativi importi
|
||||
TAssoc_array* codivae = (TAssoc_array*) conti.objptr(codconto);
|
||||
if (codivae == NULL) //se non esiste l'assoc_array legato al conto lo crea
|
||||
{
|
||||
codivae = new TAssoc_array;
|
||||
//aggiunge all'assoc_array conti il suo elemento assoc_array codivae..ho un assoc_array..
|
||||
//..di assoc_array!
|
||||
conti.add(codconto, codivae);
|
||||
}
|
||||
|
||||
TString16 codiva = righeiva[j].get(RMI_CODIVA); //prende il codice iva dalla riga iva
|
||||
//aggiungere qui eventuale numero di indetraibile
|
||||
|
||||
//ad ogni codiva presente in codivae lega un importo che risultera' la somma di tutti gli..
|
||||
//..importi con lo stesso conto e codice iva
|
||||
real* tot_imp = (real*) codivae->objptr(codiva);
|
||||
if (tot_imp == NULL) //se non esiste l'importo legato al codice iva lo crea
|
||||
{
|
||||
tot_imp = new real;
|
||||
//aggiunge all'assoc_array codivae il suo elemento real tot_imp
|
||||
codivae->add(codiva, tot_imp);
|
||||
}
|
||||
|
||||
//accresce l'importo tot_imp relativo alla coppia codiva+codconto corrente
|
||||
*tot_imp += righeiva[j].get_real(RMI_IMPONIBILE);
|
||||
//aggiungere qui eventuale imposta
|
||||
}
|
||||
|
||||
for (i = 1; i <= analmov.body().rows(); i++)
|
||||
{
|
||||
//scanning delle righe analitiche per estrarne i conti e controllare se compaiono nell'assoc_array..
|
||||
//..dei conti riempito con i conti trovati nelle righe iva
|
||||
const TRectype& riga = analmov.body().row(i);
|
||||
const TString& codconto = riga.get(RMOVANA_CODCONTO);
|
||||
TAssoc_array* codivae = (TAssoc_array*) conti.objptr(codconto); //assoc_array codivae del codconto
|
||||
|
||||
//se ho almeno un codice iva assocoato a questo conto nell'assoc_array dei conti
|
||||
if (codivae != NULL)
|
||||
{
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_pagamenti()
|
||||
{
|
||||
TInvioP_file* trasfilepag = apri_file("pagament");
|
||||
|
||||
TRectype da(LF_MOVANA);
|
||||
TRectype a(LF_MOVANA);
|
||||
da.put(MOVANA_DATACOMP, _dataini);
|
||||
a.put(MOV_DATACOMP, _datafin);
|
||||
TRelation rel(LF_MOVANA);
|
||||
rel.add(LF_MOV, "NUMREG==NUMREGCG");
|
||||
rel.add(LF_CAUSALI, "CODCAUS==CODCAUS");
|
||||
TCursor cur(&rel, "NUMREGCG!=0", 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 char tipomov = cur_rec.get(MOVANA_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);
|
||||
TCursor curpag(&relpag, filtro, 1, &da, &da);
|
||||
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;
|
||||
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());
|
||||
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);
|
||||
}
|
||||
|
||||
}//if curpag_items..
|
||||
}//for curpart =..
|
||||
}//if curpart_items..
|
||||
|
||||
// }//if tipomov..
|
||||
|
||||
}//for cur =..
|
||||
}//if cur_items..
|
||||
|
||||
chiudi_file(trasfilepag);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TInvioP::i_proforma_clifor(char tipocf)
|
||||
{
|
||||
TFilename configname = "proforma.ini";
|
||||
TConfig configfile(configname);
|
||||
TFilename filename = _msk->get(F_DESTINAZIONE);
|
||||
TInvioP_file* trasfile = NULL;
|
||||
if (tipocf == 'C')
|
||||
filename.add("clienti.txt");
|
||||
TInvioP_file* trasfile = apri_file("clienti");
|
||||
else
|
||||
filename.add("fornit.txt");
|
||||
if (fexist(filename))
|
||||
remove(filename);
|
||||
_trasfile = new TInvioP_file(filename, configname);
|
||||
_trasfile->open(filename,'w');
|
||||
_trasfile->force_record_separator();
|
||||
TInvioP_file* trasfile = apri_file("fornit");
|
||||
|
||||
TString80 filtro = "";
|
||||
filtro.format("TIPOCF == \"%c\"", tipocf);
|
||||
TRelation rel(LF_CLIFO);
|
||||
@ -472,19 +457,74 @@ bool TInvioP::i_proforma_clifor(char tipocf)
|
||||
TRecord_text rec;
|
||||
|
||||
rec.set_type("C");
|
||||
_trasfile->autoload(rec, cur);
|
||||
_trasfile->write(rec);
|
||||
trasfile->autoload(rec, cur);
|
||||
trasfile->write(rec);
|
||||
}
|
||||
}
|
||||
_trasfile->close();
|
||||
delete _trasfile;
|
||||
_trasfile = NULL;
|
||||
return TRUE;
|
||||
chiudi_file(trasfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
//"metodo dei metodi":in base ai parametri della maschera esegue la procedura indicata
|
||||
void TInvioP::invio_proforma()
|
||||
{
|
||||
if (_msk->get_bool(F_MOVIMENTI))
|
||||
i_proforma_movimenti();
|
||||
if (_msk->get_bool(F_PAGAMENTI))
|
||||
i_proforma_pagamenti();
|
||||
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::create()
|
||||
{
|
||||
_msk = new TInvioP_mask();
|
||||
_configfile = new TConfig("proforma.ini");
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
bool TInvioP::destroy()
|
||||
{
|
||||
if (_configfile != NULL)
|
||||
delete _configfile;
|
||||
delete _msk;
|
||||
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
void TInvioP::main_loop()
|
||||
{
|
||||
//il programma si puo' usare SOLO se in contabilita' analitica si usa il pianodeiconti contabile
|
||||
TConfig& cfg = ca_config();
|
||||
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
||||
if (!use_pdcc)
|
||||
return;
|
||||
|
||||
TFilename configname = "cg7200a.ini"; //file configurazione della maschera
|
||||
configname.custom_path();
|
||||
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(); //dopo aver preso i parametri dalla maschera chiama il "metodo dei metodi"
|
||||
}
|
||||
}
|
||||
|
||||
int cg7200(int argc, char **argv)
|
||||
{
|
||||
TInvioP a;
|
||||
a.run(argc, argv, "Invio dati contabilità");
|
||||
a.run(argc, argv, "Invio dati contabilità a Proforma");
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,66 +25,67 @@ END
|
||||
|
||||
GROUPBOX DLG_NULL 76 6
|
||||
BEGIN
|
||||
PROMPT 2 4 "Dati da inviare"
|
||||
PROMPT 2 4 "Dati da inviare"
|
||||
END
|
||||
|
||||
BOOLEAN F_MOVIMENTI
|
||||
BEGIN
|
||||
PROMPT 3 5 "Movimenti contabili"
|
||||
MESSAGE TRUE,ENABLE F_DATAFIN
|
||||
PROMPT 3 5 "Movimenti contabili"
|
||||
MESSAGE FALSE CLEAR,F_PAGAMENTI|DISABLE,F_DATAFIN
|
||||
MESSAGE TRUE ENABLE,F_PAGAMENTI|ENABLE,F_DATAFIN
|
||||
END
|
||||
|
||||
BOOLEAN F_CLIENTI
|
||||
BEGIN
|
||||
PROMPT 3 6 "Clienti"
|
||||
PROMPT 3 6 "Clienti"
|
||||
END
|
||||
|
||||
BOOLEAN F_FORNITORI
|
||||
BEGIN
|
||||
PROMPT 3 7 "Fornitori"
|
||||
PROMPT 3 7 "Fornitori"
|
||||
END
|
||||
|
||||
BOOLEAN F_CONTI
|
||||
BEGIN
|
||||
PROMPT 3 8 "Piano dei conti"
|
||||
PROMPT 3 8 "Piano dei conti"
|
||||
END
|
||||
|
||||
BOOLEAN F_PAGAMENTI
|
||||
BEGIN
|
||||
PROMPT 40 5 "Pagamenti"
|
||||
PROMPT 40 5 "Pagamenti"
|
||||
END
|
||||
|
||||
LISTBOX F_TIPOINVIO 20
|
||||
BEGIN
|
||||
PROMPT 2 10 "Invio a "
|
||||
ITEM "P|Proforma"
|
||||
PROMPT 2 10 "Invio a "
|
||||
ITEM "P|Proforma"
|
||||
END
|
||||
|
||||
STRING F_DESTINAZIONE 20
|
||||
BEGIN
|
||||
PROMPT 2 11 "Destinazione "
|
||||
PROMPT 2 11 "Destinazione "
|
||||
END
|
||||
|
||||
DATE F_DATAINI
|
||||
BEGIN
|
||||
PROMPT 2 12 "Data iniziale "
|
||||
PROMPT 2 12 "Data iniziale "
|
||||
END
|
||||
|
||||
DATE F_DATAFIN
|
||||
BEGIN
|
||||
PROMPT 40 12 "Data finale "
|
||||
PROMPT 40 12 "Data finale "
|
||||
END
|
||||
|
||||
BUTTON F_RIPRISTINA 20
|
||||
BEGIN
|
||||
PROMPT 2 14 "Annulla invio"
|
||||
MESSAGE SHOW,F_DATARIPRISTINO|ENABLE,F_DATARIPRISTINO
|
||||
PROMPT 2 14 "Annulla invio"
|
||||
MESSAGE SHOW,F_DATARIPRISTINO|ENABLE,F_DATARIPRISTINO
|
||||
END
|
||||
|
||||
DATE F_DATARIPRISTINO
|
||||
BEGIN
|
||||
PROMPT 25 14 "Annulla invio fino al "
|
||||
FLAGS "HD"
|
||||
PROMPT 25 14 "Annulla invio fino al "
|
||||
FLAGS "HD"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 9 2
|
||||
|
@ -142,7 +142,7 @@ NAME(0) = ID REGISTRAZIONE
|
||||
TYPE(0) = NUMERO
|
||||
POSITION(0) = 0
|
||||
LENGTH(0) = 10
|
||||
FIELD(0) = 24->NUMREG
|
||||
FIELD(0) = 108->NUMREG
|
||||
|
||||
NAME(1) = FLAG RIGA IVA
|
||||
TYPE(1) = STRINGA
|
||||
@ -154,25 +154,25 @@ NAME(2) = FLAG DARE/AVERE
|
||||
TYPE(2) = STRINGA
|
||||
POSITION(2) = 11
|
||||
LENGTH(2) = 1
|
||||
FIELD(2) = 24->SEZIONE
|
||||
FIELD(2) = 108->SEZIONE
|
||||
|
||||
NAME(3) = CODICE MASTRO
|
||||
TYPE(3) = STRINGA
|
||||
POSITION(3) = 12
|
||||
LENGTH(3) = 5
|
||||
FIELD(3) = 24->GRUPPO
|
||||
FIELD(3) = 108->CODCONTO[1,3]
|
||||
|
||||
NAME(4) = CODICE CONTO
|
||||
TYPE(4) = STRINGA
|
||||
POSITION(4) = 17
|
||||
LENGTH(4) = 5
|
||||
FIELD(4) = 24->CONTO
|
||||
FIELD(4) = 108->CODCONTO[4,6]
|
||||
|
||||
NAME(5) = CODICE SOTTOCONTO
|
||||
TYPE(5) = STRINGA
|
||||
POSITION(5) = 22
|
||||
LENGTH(5) = 5
|
||||
FIELD(5) = 24->SOTTOCONTO
|
||||
FIELD(5) = 108->CODCONTO[7,12]
|
||||
|
||||
NAME(6) = FLAG CLIFOR
|
||||
TYPE(6) = STRINGA
|
||||
@ -190,12 +190,12 @@ NAME(8) = DESCRIZIONE RIGA
|
||||
TYPE(8) = STRINGA
|
||||
POSITION(8) = 38
|
||||
LENGTH(8) = 40
|
||||
FIELD(8) = 24->DESCR[1,40]
|
||||
FIELD(8) = 108->DESCR[1,40]
|
||||
|
||||
NAME(9) = IMPORTO SOTTOCONTO
|
||||
TYPE(9) = IMPORTO
|
||||
POSITION(9) = 78
|
||||
FIELD(9) = 24->IMPORTO
|
||||
FIELD(9) = 108->IMPORTO
|
||||
|
||||
NAME(10) = IMPONIBILE
|
||||
TYPE(10) = IMPORTO
|
||||
@ -215,7 +215,7 @@ NAME(13) = COMMESSA
|
||||
TYPE(13) = STRINGA
|
||||
POSITION(13) = 125
|
||||
LENGTH(13) = 20
|
||||
FIELD(13) = 24->CODCMS
|
||||
FIELD(13) = 108->CODCMS
|
||||
|
||||
NAME(14) = VOCE DI SPESA
|
||||
TYPE(14) = STRINGA
|
||||
|
Loading…
x
Reference in New Issue
Block a user