Patch level : 10.0 patch ???
Files correlati : ps0713 Ricompilazione Demo : [ ] Commento : Modificati i programmi in modo che utilizzino ps0713lib e le tabelle di ripartizione per recuperare i dati di gruppo conto e sottoconto relativi a un dato codice commessa git-svn-id: svn://10.65.10.50/trunk@20468 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
82a27843a6
commit
533186853e
@ -237,7 +237,7 @@ void TEsporta_dativa_app::set_inviva(TISAM_recordset& rmoviva) const
|
||||
//controllo che la partita sia chiusa
|
||||
if (partita_chiusa)
|
||||
{
|
||||
//leggo dal file LF_MOV quello che ha il numero di registrazione selezioante
|
||||
//leggo dal file LF_MOV quello che ha il numero di registrazione selezionato
|
||||
mov.put(MOV_NUMREG, curr_numreg);
|
||||
int err = mov.read();
|
||||
|
||||
|
142
ps/ps0713200.cpp
142
ps/ps0713200.cpp
@ -6,7 +6,12 @@
|
||||
#include <relation.h>
|
||||
#include <reprint.h>
|
||||
|
||||
#include "tabutil.h"
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/calib02.h"
|
||||
#include "../ca/movana.h"
|
||||
#include "../ca/rmovana.h"
|
||||
|
||||
#include "ps0713lib.h"
|
||||
|
||||
#include "ps0713200a.h"
|
||||
|
||||
@ -32,7 +37,8 @@ bool TImporta_comm_msk::on_field_event(TOperable_field& f, TField_event e, long
|
||||
}
|
||||
|
||||
//metodo costruttore
|
||||
TImporta_comm_msk::TImporta_comm_msk() : TAutomask("ps0713200a"){}
|
||||
TImporta_comm_msk::TImporta_comm_msk()
|
||||
: TAutomask("ps0713200a"){}
|
||||
|
||||
/////////////////////////////////
|
||||
//// TIMPORTA_COMM_APP ////
|
||||
@ -51,28 +57,22 @@ public:
|
||||
virtual bool destroy();
|
||||
virtual void main_loop();
|
||||
|
||||
void scan_file(const TFilename& file, TAssoc_array& righe);
|
||||
void importa_cms(TAssoc_array& righe);
|
||||
|
||||
bool transfer(const TFilename& file);
|
||||
|
||||
TImporta_comm_app() {};
|
||||
};
|
||||
|
||||
TImporta_comm_app& app() { return (TImporta_comm_app&) main_app(); }
|
||||
|
||||
//TRASNFER: metodo che effettivamente svolge l'elaborazione di importazione
|
||||
bool TImporta_comm_app::transfer(const TFilename& file)
|
||||
//SCAN_FILE: metodo che scandisce il file ed evita i duplicati
|
||||
void TImporta_comm_app::scan_file(const TFilename& file, TAssoc_array& righe)
|
||||
{
|
||||
TLog_report log("Importazione Commesse");
|
||||
|
||||
//Instazio lo scanner con cui leggerò il file di testo
|
||||
//che contiene codcms|gr|co|stco
|
||||
TScanner s(file);
|
||||
TToken_string rec(50, ',');
|
||||
rec = s.line();
|
||||
|
||||
//Instanzio la tabella che devo riempire
|
||||
TTable comm("CMS");
|
||||
|
||||
TProgind pi(fsize(file), "Importazione Commesse in corso...", true, true);
|
||||
TProgind pi(fsize(file), "Scansione file in corso...", true, true);
|
||||
|
||||
//scorro tutto il file (per ogni riga devo riportare l'esito dell'importazione nel log)
|
||||
while (s.ok())
|
||||
@ -80,47 +80,111 @@ bool TImporta_comm_app::transfer(const TFilename& file)
|
||||
if (!pi.addstatus(s.tellg()))
|
||||
break;
|
||||
|
||||
TString codtab = rec.get(0); codtab.strip("\"");
|
||||
TString idlavoro = rec.get(0); idlavoro.strip("\"");
|
||||
|
||||
//salto le righe vuote del file
|
||||
if (codtab.empty())
|
||||
if (idlavoro.empty())
|
||||
continue;
|
||||
|
||||
//recupero i dati di interesse dal file
|
||||
TString descr = "IDLAVORO "; descr << codtab;
|
||||
//recupero i dati di interesse dal file;
|
||||
//gruppo conto e sottoconto devono avere dei valori sensati
|
||||
TString gr = rec.get(1); gr.strip("\""); (gr == "" || gr == "?") ? gr ="0" : gr = gr;
|
||||
TString co = rec.get(2); co.strip("\""); (co == "" || co == "?") ? co ="0" : co = co;
|
||||
TString sc = rec.get(3); sc.strip("\""); (sc == "" || sc == "?") ? sc ="0" : sc = gr;
|
||||
|
||||
comm.zero();
|
||||
comm.put("CODTAB", codtab); //setto il campo CODTAB
|
||||
comm.put("S0", descr); //setto il campo descrizione (S0)
|
||||
comm.put("I1", gr); //setto il campo gruppo (I1)
|
||||
comm.put("I2", co); //setto il campo conto (I2)
|
||||
comm.put("I3", sc); //setto il campo sottoconto (I3)
|
||||
|
||||
//salvo ciò che ho appena importato
|
||||
int err = comm.write();
|
||||
|
||||
//preparo il log con tutti i risultati delle operazioni svolte
|
||||
TString str = "La commessa ";
|
||||
switch(err)
|
||||
{
|
||||
case NOERR: str << codtab << " è stata inserita"; log.log(0, str); break;
|
||||
case 224: str << codtab << " NON è stata inserita perchè esiste già"; log.log(2, str); break;
|
||||
default: str << codtab << " NON è stata inserita. Errore = " << err; log.log(2, str); break;
|
||||
}
|
||||
|
||||
//leggo la riga successiva
|
||||
rec = s.line();
|
||||
TCommessa_string str(atol(idlavoro), atoi(gr), atoi(co), atol(sc));
|
||||
if(!righe.is_key(str))
|
||||
righe.add(str, str);
|
||||
}
|
||||
}
|
||||
|
||||
void TImporta_comm_app::importa_cms(TAssoc_array& righe)
|
||||
{
|
||||
TProgind pi(righe.items(), "Scansione file in corso...", true, true);
|
||||
TLog_report log("Importazione Commesse");
|
||||
|
||||
TLocalisamfile rip(LF_RIP);
|
||||
TLocalisamfile rrip(LF_RRIP);
|
||||
const TRectype& r = rip.last();
|
||||
long codice = r.get_long("CODICE");
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(righe, obj, key, itm)
|
||||
{
|
||||
TCommessa_string cms(key);
|
||||
TString80 codcms; codcms << cms.idlavoro();
|
||||
|
||||
TString str;
|
||||
str << "La commessa " << codcms;
|
||||
|
||||
TString query;
|
||||
query << "USE RIP KEY 4\n"
|
||||
<< "FROM TIPO=\"B\" CODCOSTO=\"\" CODCMS=\"" << codcms << "\"\n"
|
||||
<< "TO TIPO=\"B\" CODCOSTO=\"\" CODCMS=\"" << codcms << "\"\n";
|
||||
const TISAM_recordset riprec(query);
|
||||
|
||||
if(riprec.empty())
|
||||
{
|
||||
const int gruppo = cms.gruppo(); TString4 grup; grup.format("%03d", gruppo);
|
||||
const int conto = cms.conto(); TString4 cont; cont.format("%03d", conto);
|
||||
const long sotco = cms.sotco(); TString8 sotc; sotc.format("%06ld", sotco);
|
||||
TString80 codconto; codconto << grup << cont << sotc;
|
||||
|
||||
TString8 cod;
|
||||
cod.format("%08ld", ++codice);
|
||||
TString80 descr; descr << "Comessa " << codice;
|
||||
|
||||
TBill bill(gruppo, conto, sotco);
|
||||
|
||||
const real percentuale(CENTO);
|
||||
|
||||
rip.put("TIPO", 'B');
|
||||
rip.put("CODICE", cod);
|
||||
rip.put("CODCMS", codcms);
|
||||
rip.put("INDBIL", bill.indicatore_bilancio());
|
||||
rip.put("DESCRIZ", descr);
|
||||
|
||||
rrip.put("TIPO", 'B');
|
||||
rrip.put("CODICE", codice);
|
||||
rrip.put("NRIGA", 1);
|
||||
rrip.put("CODCMS", codcms);
|
||||
rrip.put("CODCONTO", codconto);
|
||||
rrip.put("RIPARTO", percentuale);
|
||||
|
||||
int err = rip.write();
|
||||
if(err == NOERR)
|
||||
err = rrip.write();
|
||||
|
||||
if(err == NOERR)
|
||||
{
|
||||
str << codcms << " è stata inserita";
|
||||
log.log(0, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
str << " NON è stata inserita. Errore = " << err;
|
||||
log.log(2, str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
str << codcms << " NON è stata inserita perchè esiste già";
|
||||
log.log(2, str);
|
||||
}
|
||||
}
|
||||
//stampo a video il log
|
||||
TReport_book buc;
|
||||
buc.add(log);
|
||||
buc.preview();
|
||||
}
|
||||
|
||||
TImporta_comm_app& app() { return (TImporta_comm_app&) main_app(); }
|
||||
|
||||
//TRASNFER: metodo che effettivamente svolge l'elaborazione di importazione
|
||||
bool TImporta_comm_app::transfer(const TFilename& file)
|
||||
{
|
||||
TAssoc_array righe;
|
||||
scan_file(file, righe);
|
||||
importa_cms(righe);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <tabutil.h>
|
||||
#include <textset.h>
|
||||
|
||||
#include <causali.h>
|
||||
#include <clifo.h>
|
||||
#include <mov.h>
|
||||
#include <rmoviva.h>
|
||||
|
||||
#include "ps0713lib.h"
|
||||
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/calib02.h"
|
||||
#include "../ca/movana.h"
|
||||
@ -17,61 +18,6 @@
|
||||
|
||||
#include "ps0713300a.h"
|
||||
|
||||
//////////////////////////////////////
|
||||
//// TIMPORTA_FATACQ_ANROW ////
|
||||
//////////////////////////////////////
|
||||
|
||||
//classe TImporta_fatacq_anrow
|
||||
class TImporta_fatacq_anrow: public TToken_string
|
||||
{
|
||||
public:
|
||||
const long idlavoro();
|
||||
const int gruppo();
|
||||
const int conto();
|
||||
const int sotco();
|
||||
|
||||
TImporta_fatacq_anrow& operator= (const char* key){ set(key); return *this; }
|
||||
|
||||
TImporta_fatacq_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco);
|
||||
TImporta_fatacq_anrow(const char* key):TToken_string(key){}
|
||||
TImporta_fatacq_anrow(const TToken_string& key):TToken_string(key){}
|
||||
TImporta_fatacq_anrow(const TImporta_fatacq_anrow& key):TToken_string(key){}
|
||||
TImporta_fatacq_anrow():TToken_string(){}
|
||||
};
|
||||
|
||||
//IDLAVORO: metodo che restituisce l'Idlavoro
|
||||
const long TImporta_fatacq_anrow::idlavoro()
|
||||
{
|
||||
return get_long(0);
|
||||
}
|
||||
|
||||
//GRUPPO: metodo che restituisce il gruppo
|
||||
const int TImporta_fatacq_anrow::gruppo()
|
||||
{
|
||||
return get_int(1);
|
||||
}
|
||||
|
||||
//CONTO: metodo che restituisce il conto
|
||||
const int TImporta_fatacq_anrow::conto()
|
||||
{
|
||||
return get_int(2);
|
||||
}
|
||||
|
||||
//SOTCO: metodo che restituisce il sottoconto
|
||||
const int TImporta_fatacq_anrow::sotco()
|
||||
{
|
||||
return get_int(3);
|
||||
}
|
||||
|
||||
//metodo costruttore
|
||||
TImporta_fatacq_anrow::TImporta_fatacq_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco)
|
||||
{
|
||||
add(idlavoro);
|
||||
add(gruppo);
|
||||
add(conto);
|
||||
add(sotco);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATACQ_MSK ////
|
||||
///////////////////////////////////
|
||||
@ -96,24 +42,6 @@ bool TImporta_fatacq_msk::on_field_event(TOperable_field& f, TField_event e, lon
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATACQ_REC ////
|
||||
///////////////////////////////////
|
||||
|
||||
//Classe TImporta_fatacq_rec
|
||||
class TImporta_fatacq_rec : public TCSV_recordset
|
||||
{
|
||||
public:
|
||||
TImporta_fatacq_rec(const char * fileName);
|
||||
};
|
||||
|
||||
TImporta_fatacq_rec::TImporta_fatacq_rec(const char * fileName)
|
||||
: TCSV_recordset("CSV(\",\")")
|
||||
{
|
||||
load_file(fileName);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATACQ_APP ////
|
||||
///////////////////////////////////
|
||||
@ -179,7 +107,7 @@ void TImporta_fatacq_app::genera_analitica(const long numreg, TAssoc_array& righ
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
TImporta_fatacq_anrow& row = (TImporta_fatacq_anrow)keyar;
|
||||
TCommessa_string& row = (TCommessa_string)keyar;
|
||||
const long idlav = row.idlavoro();
|
||||
const int gruppo = row.gruppo(); TString8 grup; grup.format("%03d", gruppo);
|
||||
const int conto = row.conto(); TString8 cont; cont.format("%03d", conto);
|
||||
@ -202,7 +130,7 @@ void TImporta_fatacq_app::genera_analitica(const long numreg, TAssoc_array& righ
|
||||
|
||||
bool TImporta_fatacq_app::transfer(const TFilename& file, const long numreg, TAssoc_array& righean)
|
||||
{
|
||||
TImporta_fatacq_rec s(file);
|
||||
TVB_recset s(file, '\t');
|
||||
|
||||
TProgind pi(s.items(),"Importazione fatture in corso ...",true,true);
|
||||
|
||||
@ -230,14 +158,8 @@ bool TImporta_fatacq_app::transfer(const TFilename& file, const long numreg, TAs
|
||||
TString16 codcom = s.get(0).as_string();
|
||||
real imp = s.get(1).as_real();
|
||||
|
||||
TTable cms("CMS");
|
||||
cms.put("CODTAB", codcom);
|
||||
int err = cms.read();
|
||||
const int gruppo = err == NOERR ? cms.get_int("I1") : 0;
|
||||
const int conto = err == NOERR ? cms.get_int("I2") : 0;
|
||||
const long sotco = err == NOERR ? cms.get_int("I3") : 0;
|
||||
|
||||
TImporta_fatacq_anrow ankey(atol(codcom), gruppo, conto, sotco);
|
||||
TCommessa cms(codcom);
|
||||
TCommessa_string ankey = cms.cmsstr();
|
||||
|
||||
if(righean.is_key(ankey))
|
||||
{
|
||||
@ -248,8 +170,7 @@ bool TImporta_fatacq_app::transfer(const TFilename& file, const long numreg, TAs
|
||||
righean.add(ankey, imp);
|
||||
|
||||
_configfile->set(RMI_IMPONIBILE, imp.string());
|
||||
_configfile->set(RMI_CODIVA, _msk->get(F_CODIVA));
|
||||
_configfile->set(RMI_CODCMS, codcom);
|
||||
_configfile->set(RMI_CODIVA, _msk->get(F_CODIVA));
|
||||
}
|
||||
|
||||
_configfile->set_paragraph("Transaction");
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <progind.h>
|
||||
#include <textset.h>
|
||||
|
||||
#include "../ve/velib.h"
|
||||
|
||||
#include "ps0713400a.h"
|
||||
|
||||
#include "ps0713lib.h"
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATVEN_MSK ////
|
||||
///////////////////////////////////
|
||||
@ -32,67 +33,6 @@ bool TImporta_fatven_msk::on_field_event(TOperable_field& f, TField_event e, lon
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATVEN_REC ////
|
||||
///////////////////////////////////
|
||||
|
||||
//Classe TImporta_fatven_rec
|
||||
class TImporta_fatven_rec : public TCSV_recordset
|
||||
{
|
||||
protected:
|
||||
virtual TRecnotype new_rec(const char* buf = NULL);
|
||||
|
||||
public:
|
||||
TImporta_fatven_rec(const char * fileName);
|
||||
};
|
||||
|
||||
//NEW_REC: metodo che crea una nuova riga del recordset, cambiando il separatore col carattere TAB
|
||||
//e eliminando eventuali doppi apici agli estremi del campo
|
||||
TRecnotype TImporta_fatven_rec::new_rec(const char* buf)
|
||||
{
|
||||
TToken_string str(256,'\t'); //nuovo record tab separator
|
||||
|
||||
if(buf && *buf)
|
||||
{
|
||||
bool apici=false;
|
||||
|
||||
for (const char* c = buf; *c ; c++)
|
||||
{
|
||||
if (*c == '"')
|
||||
{
|
||||
apici = !apici;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*c == ',')
|
||||
{
|
||||
if (!apici)
|
||||
str << str.separator();
|
||||
else
|
||||
str << *c;
|
||||
}
|
||||
else
|
||||
str << *c;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const TRecnotype n = TText_recordset::new_rec(str);
|
||||
|
||||
if (n >= 0)
|
||||
row(n).separator(str.separator());
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
//metodo contruttre
|
||||
TImporta_fatven_rec::TImporta_fatven_rec(const char * fileName)
|
||||
: TCSV_recordset("CSV(,)")
|
||||
{
|
||||
load_file(fileName);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//// TIMPORTA_FATVEN_APP ////
|
||||
///////////////////////////////////
|
||||
@ -106,8 +46,8 @@ protected:
|
||||
virtual bool check_autorization() const {return false;}
|
||||
virtual const char * extra_modules() const {return "ve";}
|
||||
|
||||
long togli_apici_numero(TImporta_fatven_rec& s, int i);
|
||||
const TString& togli_apici(TImporta_fatven_rec& s, int i);
|
||||
long togli_apici_numero(TVB_recset& s, int i);
|
||||
const TString& togli_apici(TVB_recset& s, int i);
|
||||
bool find_clifo(long& codcf, TString& paiv, long& abi, long& cab, TString& codpag);
|
||||
|
||||
public:
|
||||
@ -121,7 +61,7 @@ public:
|
||||
|
||||
//TOGLI_APICI_NUMERO: metodo che restituisce un campo del recordset come numero
|
||||
//preoccupandosi prima di eliminare eventuali doppi apici
|
||||
long TImporta_fatven_app::togli_apici_numero(TImporta_fatven_rec& s, int i)
|
||||
long TImporta_fatven_app::togli_apici_numero(TVB_recset& s, int i)
|
||||
{
|
||||
TString80 tmp = s.get(i).as_string();
|
||||
tmp.strip("\"");
|
||||
@ -130,7 +70,7 @@ long TImporta_fatven_app::togli_apici_numero(TImporta_fatven_rec& s, int i)
|
||||
|
||||
//TOGLI_APICI: metodo che restituisce un campo del recordset come stringa
|
||||
//preoccupandosi prima di eliminare eventuali doppi apici
|
||||
const TString& TImporta_fatven_app::togli_apici(TImporta_fatven_rec & s, int i)
|
||||
const TString& TImporta_fatven_app::togli_apici(TVB_recset & s, int i)
|
||||
{
|
||||
TString& tmp = get_tmp_string();
|
||||
tmp = s.get(i).as_string();
|
||||
@ -167,7 +107,7 @@ bool TImporta_fatven_app::transfer(const TFilename& file)
|
||||
const TString4 codnum = "F01"; //Da analisi
|
||||
const TString4 tpdoc = "F01"; //Da analisi
|
||||
|
||||
TImporta_fatven_rec s(file);
|
||||
TVB_recset s(file, ',');
|
||||
|
||||
TProgind pi(s.items(),"Importazione fatture in corso ...",true,true);
|
||||
|
||||
|
140
ps/ps0713500.cpp
140
ps/ps0713500.cpp
@ -2,7 +2,6 @@
|
||||
#include <automask.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <textset.h>
|
||||
#include <recarray.h>
|
||||
|
||||
#include <rcausali.h>
|
||||
@ -10,7 +9,7 @@
|
||||
#include <mov.h>
|
||||
#include <rmov.h>
|
||||
|
||||
#include "tabutil.h"
|
||||
#include "ps0713lib.h"
|
||||
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/calib02.h"
|
||||
@ -20,63 +19,6 @@
|
||||
#include "ps0713500a.h"
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
//// TIMPORTA_SPESE_ANROW ////
|
||||
//////////////////////////////////////
|
||||
|
||||
//classe TImporta_spese_anrow
|
||||
class TImporta_spese_anrow: public TToken_string
|
||||
{
|
||||
public:
|
||||
const long idlavoro();
|
||||
const int gruppo();
|
||||
const int conto();
|
||||
const int sotco();
|
||||
|
||||
TImporta_spese_anrow& operator= (const char* key){ set(key); return *this; }
|
||||
|
||||
TImporta_spese_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco);
|
||||
TImporta_spese_anrow(const char* key):TToken_string(key){}
|
||||
TImporta_spese_anrow(const TToken_string& key):TToken_string(key){}
|
||||
TImporta_spese_anrow(const TImporta_spese_anrow& key):TToken_string(key){}
|
||||
TImporta_spese_anrow():TToken_string(){}
|
||||
};
|
||||
|
||||
//IDLAVORO: metodo che restituisce l'Idlavoro
|
||||
const long TImporta_spese_anrow::idlavoro()
|
||||
{
|
||||
return get_long(0);
|
||||
}
|
||||
|
||||
//GRUPPO: metodo che restituisce il gruppo
|
||||
const int TImporta_spese_anrow::gruppo()
|
||||
{
|
||||
return get_int(1);
|
||||
}
|
||||
|
||||
//CONTO: metodo che restituisce il conto
|
||||
const int TImporta_spese_anrow::conto()
|
||||
{
|
||||
return get_int(2);
|
||||
}
|
||||
|
||||
//SOTCO: metodo che restituisce il sottoconto
|
||||
const int TImporta_spese_anrow::sotco()
|
||||
{
|
||||
return get_int(3);
|
||||
}
|
||||
|
||||
//metodo costruttore
|
||||
TImporta_spese_anrow::TImporta_spese_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco)
|
||||
{
|
||||
add(idlavoro);
|
||||
add(gruppo);
|
||||
add(conto);
|
||||
add(sotco);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
//// TIMPORTA_SPESE_MSK ////
|
||||
//////////////////////////////////
|
||||
@ -101,65 +43,6 @@ bool TImporta_spese_msk::on_field_event(TOperable_field& f, TField_event e, long
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
//// TIMPORTA_SPESE_REC ////
|
||||
//////////////////////////////////
|
||||
|
||||
//Clase TImporta_spese_rec
|
||||
class TImporta_spese_rec : public TCSV_recordset
|
||||
{
|
||||
protected:
|
||||
virtual TRecnotype new_rec(const char* buf = NULL);
|
||||
|
||||
public:
|
||||
TImporta_spese_rec(const char * fileName);
|
||||
};
|
||||
|
||||
TRecnotype TImporta_spese_rec::new_rec(const char* buf)
|
||||
{
|
||||
TToken_string str(256,'\t'); //nuovo record tab separator
|
||||
|
||||
if(buf && *buf)
|
||||
{
|
||||
bool apici=false;
|
||||
|
||||
for (const char* c = buf; *c ; c++)
|
||||
{
|
||||
if (*c == '"')
|
||||
{
|
||||
apici = !apici;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*c == ',')
|
||||
{
|
||||
if (!apici)
|
||||
str << str.separator();
|
||||
else
|
||||
str << *c;
|
||||
}
|
||||
else
|
||||
str << *c;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const TRecnotype n = TText_recordset::new_rec(str);
|
||||
|
||||
if (n >= 0)
|
||||
row(n).separator(str.separator());
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
TImporta_spese_rec::TImporta_spese_rec(const char * fileName)
|
||||
: TCSV_recordset("CSV(,)")
|
||||
{
|
||||
load_file(fileName);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
//// TIMPORTA_SPESE_APP ////
|
||||
//////////////////////////////////
|
||||
@ -251,7 +134,7 @@ void TImporta_spese_app::genera_movana(const long numreg, TAssoc_array& righean)
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
TImporta_spese_anrow& row = (TImporta_spese_anrow)keyar;
|
||||
TCommessa_string& row = (TCommessa_string)keyar;
|
||||
const long idlav = row.idlavoro();
|
||||
const int gruppo = row.gruppo(); TString8 grup; grup.format("%03d", gruppo);
|
||||
const int conto = row.conto(); TString8 cont; cont.format("%03d", conto);
|
||||
@ -281,7 +164,7 @@ bool TImporta_spese_app::transfer()
|
||||
//genero il nome del file da caricare
|
||||
TFilename name = _msk->get(F_PATH);
|
||||
name.add(_msk->get(F_NAME));
|
||||
TImporta_spese_rec s(name);
|
||||
TVB_recset s(name, ',');
|
||||
|
||||
TProgind pi(s.items(),"Importazione spese in corso ...",true,true);
|
||||
|
||||
@ -322,7 +205,7 @@ bool TImporta_spese_app::transfer()
|
||||
tmp = s.get(0).as_string();
|
||||
tmp.strip("\"");
|
||||
const TString80 codcms = tmp;
|
||||
const TRectype& commessa = cache().get("CMS", tmp);
|
||||
const TCommessa cms(codcms);
|
||||
|
||||
//data
|
||||
tmp = s.get(1).as_string();
|
||||
@ -333,7 +216,7 @@ bool TImporta_spese_app::transfer()
|
||||
data.set_year(atoi(tmp.mid(6,4)));
|
||||
|
||||
//descrizione
|
||||
tmp = s.get(3).as_string();
|
||||
tmp = s.get(3).as_string();
|
||||
tmp.strip("\"");
|
||||
|
||||
if(data != dataold)
|
||||
@ -356,10 +239,7 @@ bool TImporta_spese_app::transfer()
|
||||
|
||||
configfile.set_paragraph("24,1");
|
||||
configfile.set(RMV_NUMRIG,1);
|
||||
configfile.set(RMV_GRUPPO, causale.get(RCA_GRUPPO));
|
||||
configfile.set(RMV_CONTO, causale.get(RCA_CONTO));
|
||||
configfile.set(RMV_SOTTOCONTO, causale.get(RCA_SOTTOCONTO));
|
||||
|
||||
|
||||
righean.destroy();
|
||||
tot_doc.reset();
|
||||
nriga = 2;
|
||||
@ -376,13 +256,9 @@ bool TImporta_spese_app::transfer()
|
||||
|
||||
configfile.set(RMV_IMPORTO, importo.valore().string());
|
||||
configfile.set(RMV_SEZIONE, importo.sezione());
|
||||
configfile.set(RMV_CODCMS, commessa.get("CODTAB"));
|
||||
configfile.set(RMV_DATAREG, data);
|
||||
configfile.set(RMV_GRUPPO, commessa.get("I1"));
|
||||
configfile.set(RMV_CONTO, commessa.get("I2"));
|
||||
configfile.set(RMV_SOTTOCONTO, commessa.get("I3"));
|
||||
configfile.set(RMV_DATAREG, data);
|
||||
|
||||
TImporta_spese_anrow ankey(commessa.get_long("CODTAB"), commessa.get_int("I1"), commessa.get_int("I2"), commessa.get_int("I3"));
|
||||
TCommessa_string ankey(cms.cmsstr());
|
||||
if(righean.is_key(ankey))
|
||||
{
|
||||
real& imponibile = *(real*)righean.objptr(ankey);
|
||||
|
159
ps/ps0713600.cpp
159
ps/ps0713600.cpp
@ -2,7 +2,6 @@
|
||||
#include <automask.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <textset.h>
|
||||
|
||||
#include "ps0713600a.h"
|
||||
|
||||
@ -10,6 +9,8 @@
|
||||
#include <rmov.h>
|
||||
#include <rmoviva.h>
|
||||
|
||||
#include "ps0713lib.h"
|
||||
|
||||
#include "../ca/calib01.h"
|
||||
#include "../ca/calib02.h"
|
||||
#include "../ca/movana.h"
|
||||
@ -40,119 +41,6 @@ bool TImporta_fat_for_msk::on_field_event(TOperable_field& f, TField_event e, lo
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
//// TIMPORTA_FAT_FOR_REC ////
|
||||
////////////////////////////////////
|
||||
|
||||
//Classe TImporta_fat_for_rec
|
||||
class TImporta_fat_for_rec : public TCSV_recordset
|
||||
{
|
||||
protected:
|
||||
virtual TRecnotype new_rec(const char* buf = NULL);
|
||||
|
||||
public:
|
||||
TImporta_fat_for_rec(const char * fileName);
|
||||
};
|
||||
|
||||
TRecnotype TImporta_fat_for_rec::new_rec(const char* buf)
|
||||
{
|
||||
TToken_string str(256,'\t'); //nuovo record tab separator
|
||||
|
||||
if(buf && *buf)
|
||||
{
|
||||
bool apici=false;
|
||||
|
||||
for (const char* c = buf; *c ; c++)
|
||||
{
|
||||
if (*c == '"')
|
||||
{
|
||||
apici = !apici;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*c == ',')
|
||||
{
|
||||
if (!apici)
|
||||
str << str.separator();
|
||||
else
|
||||
str << *c;
|
||||
}
|
||||
else
|
||||
str << *c;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const TRecnotype n = TText_recordset::new_rec(str);
|
||||
|
||||
if (n >= 0)
|
||||
row(n).separator(str.separator());
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
TImporta_fat_for_rec::TImporta_fat_for_rec(const char * fileName)
|
||||
: TCSV_recordset("CSV(,)")
|
||||
{
|
||||
load_file(fileName);
|
||||
}
|
||||
//////////////////////////////////////
|
||||
//// TIMPORTA_FAT_FOR_ANROW ////
|
||||
//////////////////////////////////////
|
||||
|
||||
//classe TImporta_fat_for_anrow
|
||||
class TImporta_fat_for_anrow: public TToken_string
|
||||
{
|
||||
public:
|
||||
const long idlavoro();
|
||||
const int gruppo();
|
||||
const int conto();
|
||||
const int sotco();
|
||||
|
||||
TImporta_fat_for_anrow& operator= (const char* key){ set(key); return *this; }
|
||||
|
||||
TImporta_fat_for_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco);
|
||||
TImporta_fat_for_anrow(const char* key):TToken_string(key){}
|
||||
TImporta_fat_for_anrow(const TToken_string& key):TToken_string(key){}
|
||||
TImporta_fat_for_anrow(const TImporta_fat_for_anrow& key):TToken_string(key){}
|
||||
TImporta_fat_for_anrow():TToken_string(){}
|
||||
};
|
||||
|
||||
//IDLAVORO: metodo che restituisce l'Idlavoro
|
||||
const long TImporta_fat_for_anrow::idlavoro()
|
||||
{
|
||||
return get_long(0);
|
||||
}
|
||||
|
||||
//GRUPPO: metodo che restituisce il gruppo
|
||||
const int TImporta_fat_for_anrow::gruppo()
|
||||
{
|
||||
return get_int(1);
|
||||
}
|
||||
|
||||
//CONTO: metodo che restituisce il conto
|
||||
const int TImporta_fat_for_anrow::conto()
|
||||
{
|
||||
return get_int(2);
|
||||
}
|
||||
|
||||
//SOTCO: metodo che restituisce il sottoconto
|
||||
const int TImporta_fat_for_anrow::sotco()
|
||||
{
|
||||
return get_int(3);
|
||||
}
|
||||
|
||||
//metodo costruttore
|
||||
TImporta_fat_for_anrow::TImporta_fat_for_anrow(const long idlavoro, const int gruppo, const int conto, const int sotco)
|
||||
{
|
||||
add(idlavoro);
|
||||
add(gruppo);
|
||||
add(conto);
|
||||
add(sotco);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
//// TIMPORTA_FAT_FOR_APP ////
|
||||
////////////////////////////////////
|
||||
@ -169,19 +57,19 @@ protected:
|
||||
|
||||
public:
|
||||
//metodi per l'acquisizione dei dati da file e i calcoli da effettura eprima dell'importazione
|
||||
void scan_file(TImporta_fat_for_rec& file, TAssoc_array& righean, TAssoc_array& righecg) const;
|
||||
bool calcola_quadratura(TAssoc_array& righean, TImporta_fat_for_anrow& kmax, real& quad);
|
||||
void scan_file(TVB_recset& file, TAssoc_array& righean, TAssoc_array& righecg) const;
|
||||
bool calcola_quadratura(TAssoc_array& righean, TCommessa_string& kmax, real& quad);
|
||||
bool importa(const TFilename& name, TAssoc_array& righean, TAssoc_array& righecg);
|
||||
//metodi per l'importazione vera e propria
|
||||
long genera_movcg();
|
||||
void genera_analitica(TAssoc_array& righean, TImporta_fat_for_anrow& kmax, const real& quad, const long numregcg);
|
||||
void importa_fat(TAssoc_array& righecg, TImporta_fat_for_anrow& kmax, const real& quad, TConfig* configfile, const long numregcg);
|
||||
void importa_fat_ric(TAssoc_array& righecg, TImporta_fat_for_anrow& kmax, const real& quad, TConfig* configfile, const long numregcg);
|
||||
void gestione_ini(TAssoc_array& righecg, TImporta_fat_for_anrow& kmax, const real& quad, const long numregcg);
|
||||
void genera_analitica(TAssoc_array& righean, TCommessa_string& kmax, const real& quad, const long numregcg);
|
||||
void importa_fat(TAssoc_array& righecg, TCommessa_string& kmax, const real& quad, TConfig* configfile, const long numregcg);
|
||||
void importa_fat_ric(TAssoc_array& righecg, TCommessa_string& kmax, const real& quad, TConfig* configfile, const long numregcg);
|
||||
void gestione_ini(TAssoc_array& righecg, TCommessa_string& kmax, const real& quad, const long numregcg);
|
||||
bool transfer();
|
||||
};
|
||||
|
||||
void TImporta_fat_for_app::scan_file(TImporta_fat_for_rec& file, TAssoc_array& righean, TAssoc_array& righecg) const
|
||||
void TImporta_fat_for_app::scan_file(TVB_recset& file, TAssoc_array& righean, TAssoc_array& righecg) const
|
||||
{
|
||||
TProgind pi(file.items(), "Scansione file in corso ...", true, true);
|
||||
|
||||
@ -217,7 +105,7 @@ void TImporta_fat_for_app::scan_file(TImporta_fat_for_rec& file, TAssoc_array& r
|
||||
const int sotco = file.get(4).as_int();
|
||||
|
||||
//chiave del TAssoc_array dell'analatica
|
||||
TImporta_fat_for_anrow keyan(idlavoro, gruppo, conto, sotco);
|
||||
TCommessa_string keyan(idlavoro, gruppo, conto, sotco);
|
||||
|
||||
//riempio l'array dell'analitica
|
||||
if(righean.is_key(keyan))
|
||||
@ -240,7 +128,7 @@ void TImporta_fat_for_app::scan_file(TImporta_fat_for_rec& file, TAssoc_array& r
|
||||
}
|
||||
|
||||
//CALCOLA_QUADRATURA: metodo che calcola l'ammontare dell'evetuale riga di quadratura del documento
|
||||
bool TImporta_fat_for_app::calcola_quadratura(TAssoc_array& righean, TImporta_fat_for_anrow& kmax, real& quad)
|
||||
bool TImporta_fat_for_app::calcola_quadratura(TAssoc_array& righean, TCommessa_string& kmax, real& quad)
|
||||
{
|
||||
//calcolo qaul'è la massima tolleranza consentita
|
||||
//(da analisi la tolleranza è un centesimo per riga)
|
||||
@ -296,7 +184,7 @@ bool TImporta_fat_for_app::calcola_quadratura(TAssoc_array& righean, TImporta_fa
|
||||
//IMPORTA: metodo che popola l'assoc_array delle righe e calcola la quadratura
|
||||
bool TImporta_fat_for_app::importa(const TFilename& name, TAssoc_array& righean, TAssoc_array& righecg)
|
||||
{
|
||||
TImporta_fat_for_rec file(name);
|
||||
TVB_recset file(name, ',');
|
||||
|
||||
scan_file(file, righean, righecg);
|
||||
|
||||
@ -318,7 +206,7 @@ long TImporta_fat_for_app::genera_movcg()
|
||||
}
|
||||
|
||||
//GENERA_ANALITICA: metodo che genera il movimento di contabilità analitica
|
||||
void TImporta_fat_for_app::genera_analitica(TAssoc_array& righean, TImporta_fat_for_anrow& kmax, const real& quad, const long numregcg)
|
||||
void TImporta_fat_for_app::genera_analitica(TAssoc_array& righean, TCommessa_string& kmax, const real& quad, const long numregcg)
|
||||
{
|
||||
TProgind pi(righean.items(), "Importazione analitica in corso...", true, true);
|
||||
|
||||
@ -372,7 +260,7 @@ void TImporta_fat_for_app::genera_analitica(TAssoc_array& righean, TImporta_fat_
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
TImporta_fat_for_anrow& row = (TImporta_fat_for_anrow)keyar;
|
||||
TCommessa_string& row = (TCommessa_string)keyar;
|
||||
const long idlav = row.idlavoro();
|
||||
const int gruppo = row.gruppo(); TString8 grup; grup.format("%03d", gruppo);
|
||||
const int conto = row.conto(); TString8 cont; cont.format("%03d", conto);
|
||||
@ -410,7 +298,7 @@ void TImporta_fat_for_app::genera_analitica(TAssoc_array& righean, TImporta_fat_
|
||||
}
|
||||
|
||||
//IMPORTA_FAT: metodo che genera l'ini per l'importazione delle fatture a fornitore
|
||||
void TImporta_fat_for_app::importa_fat(TAssoc_array& righecg, TImporta_fat_for_anrow& kmax, const real& quad, TConfig* configfile, const long numregcg)
|
||||
void TImporta_fat_for_app::importa_fat(TAssoc_array& righecg, TCommessa_string& kmax, const real& quad, TConfig* configfile, const long numregcg)
|
||||
{
|
||||
const TDate datareg = _msk->get_date(F_DATAREG);
|
||||
const TDate datadoc = _msk->get_date(F_DATADOC);
|
||||
@ -485,8 +373,7 @@ void TImporta_fat_for_app::importa_fat(TAssoc_array& righecg, TImporta_fat_for_a
|
||||
configfile->set(RMI_ANNOES, anno);
|
||||
configfile->set(RMI_IMPONIBILE, importo.valore().string());
|
||||
configfile->set(RMI_CODIVA, codiva);
|
||||
configfile->set(RMI_IMPOSTA, rimposta.string());
|
||||
configfile->set(RMI_CODCMS, idlav);
|
||||
configfile->set(RMI_IMPOSTA, rimposta.string());
|
||||
configfile->set(RMI_TIPOATT, 1);
|
||||
}
|
||||
}
|
||||
@ -507,7 +394,6 @@ void TImporta_fat_for_app::importa_fat(TAssoc_array& righecg, TImporta_fat_for_a
|
||||
configfile->set(RMI_IMPONIBILE, importo.valore().string());
|
||||
configfile->set(RMI_CODIVA, codiva);
|
||||
configfile->set(RMI_IMPOSTA, rimposta.string());
|
||||
configfile->set(RMI_CODCMS, kmax.idlavoro());
|
||||
configfile->set(RMI_TIPOATT, 1);
|
||||
}
|
||||
|
||||
@ -518,7 +404,7 @@ void TImporta_fat_for_app::importa_fat(TAssoc_array& righecg, TImporta_fat_for_a
|
||||
|
||||
//IMPORTA_FAT_RIC: metodo che genera l'ini per l'importazione delle fatture da ricevere
|
||||
//(attenzione: genero righe IVA)
|
||||
void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TImporta_fat_for_anrow& kmax, const real& quad, TConfig* configfile, const long numregcg)
|
||||
void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TCommessa_string& kmax, const real& quad, TConfig* configfile, const long numregcg)
|
||||
{
|
||||
const TDate datareg = _msk->get_date(F_DATAREG);
|
||||
const TDate datadoc = _msk->get_date(F_DATADOC);
|
||||
@ -557,7 +443,6 @@ void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TImporta_fat_f
|
||||
configfile->set(RMV_ANNOES, anno);
|
||||
configfile->set(RMV_SEZIONE, causale.get("SEZIONE"));
|
||||
configfile->set(RMV_IMPORTO, importo.valore().string());
|
||||
configfile->set(RMV_CODCMS, causale.get("CODCMS"));
|
||||
configfile->set(RMV_TIPOC, causale.get("TIPOCF"));
|
||||
|
||||
key.add(2,1);
|
||||
@ -586,7 +471,6 @@ void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TImporta_fat_f
|
||||
configfile->set(RMV_ANNOES, anno);
|
||||
configfile->set(RMV_SEZIONE, causale2.get("SEZIONE"));
|
||||
configfile->set(RMV_IMPORTO, importo.valore().string());
|
||||
configfile->set(RMV_CODCMS, idlav);
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,8 +486,7 @@ void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TImporta_fat_f
|
||||
|
||||
configfile->set(RMV_ANNOES, anno);
|
||||
configfile->set(RMV_SEZIONE, causale2.get("SEZIONE"));
|
||||
configfile->set(RMV_IMPORTO, importo.valore().string());
|
||||
configfile->set(RMV_CODCMS, kmax.idlavoro());
|
||||
configfile->set(RMV_IMPORTO, importo.valore().string());
|
||||
}
|
||||
|
||||
paragraph.format("%d,%d", LF_RMOVIVA, ++nrigaco);
|
||||
@ -611,7 +494,7 @@ void TImporta_fat_for_app::importa_fat_ric(TAssoc_array& righecg, TImporta_fat_f
|
||||
}
|
||||
|
||||
//GESTIONE_INI: metodo che si occupa di generare il file ini e di importarlo effettivamente
|
||||
void TImporta_fat_for_app::gestione_ini(TAssoc_array& righe, TImporta_fat_for_anrow& kmax, const real& quad, const long numregcg)
|
||||
void TImporta_fat_for_app::gestione_ini(TAssoc_array& righe, TCommessa_string& kmax, const real& quad, const long numregcg)
|
||||
{
|
||||
TConfig* configfile = NULL;
|
||||
TFilename tmpdir; tmpdir.tempdir();
|
||||
@ -653,7 +536,7 @@ bool TImporta_fat_for_app::transfer()
|
||||
|
||||
TAssoc_array righean;
|
||||
TAssoc_array righecg;
|
||||
TImporta_fat_for_anrow kmax;
|
||||
TCommessa_string kmax;
|
||||
|
||||
for(int i = F_NAME1; i <= F_NAME2; i++)
|
||||
{
|
||||
@ -675,7 +558,7 @@ bool TImporta_fat_for_app::transfer()
|
||||
if(importato)
|
||||
{
|
||||
real quad;
|
||||
TImporta_fat_for_anrow kmax;
|
||||
TCommessa_string kmax;
|
||||
calcola_quadratura(righean, kmax, quad);
|
||||
long numregcg = genera_movcg();
|
||||
genera_analitica(righean, kmax, quad, numregcg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user