Patch level : Personalizzazione OMASA
Files correlati : cgp4100a.msk cgp4.exe Ricompilazione Demo : [ ] Commento : sistemata importazione stipendi con richieste Cinzia git-svn-id: svn://10.65.10.50/trunk@12114 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
aaf0b5ad9e
commit
9752ae07ed
293
cg/cgp4100.cpp
293
cg/cgp4100.cpp
@ -6,6 +6,7 @@
|
||||
#include <execp.h>
|
||||
#include <filetext.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <strings.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -14,7 +15,9 @@
|
||||
#include "cgp4100b.h"
|
||||
#include "cglib01.h"
|
||||
|
||||
#include <causali.h>
|
||||
#include <mov.h>
|
||||
#include <pconti.h>
|
||||
#include <rmov.h>
|
||||
|
||||
|
||||
@ -89,11 +92,6 @@ class TOmasa : public TSkeleton_application
|
||||
|
||||
long _numreg;
|
||||
|
||||
protected:
|
||||
long ultima_registrazione();
|
||||
void compila_testata(int anno,const TDate& datareg,const TString& codcaus,const TDate& datacomp);
|
||||
void registra_pn();
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
@ -130,26 +128,11 @@ bool TOmasa::destroy()
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
long TOmasa::ultima_registrazione()
|
||||
{
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
|
||||
// Leggo il numero di registrazione dell'ultimo record di mov, e lo
|
||||
// incremento di uno per ottenere un numero di registrazione sicuramente non esistente.
|
||||
if (_numreg == 0)
|
||||
{
|
||||
mov.last();
|
||||
_numreg = mov.get_long(MOV_NUMREG) + 1;
|
||||
}
|
||||
else
|
||||
_numreg++;
|
||||
return _numreg;
|
||||
}
|
||||
|
||||
void TOmasa::main_loop()
|
||||
{
|
||||
KEY tasto;
|
||||
_msk->set(F_PERCORSO, _configfile->get("PERCORSO", "MAIN"));
|
||||
_msk->set(F_CODCAUS, _configfile->get("CODCAUS", "MOVIMENTO"));
|
||||
tasto = _msk->run();
|
||||
if (tasto == K_ENTER)
|
||||
{
|
||||
@ -157,6 +140,7 @@ void TOmasa::main_loop()
|
||||
if (transfer())
|
||||
{
|
||||
_configfile->set("PERCORSO", _msk->get(F_PERCORSO), "MAIN");
|
||||
_configfile->set("CODCAUS", _msk->get(F_CODCAUS), "MOVIMENTO");
|
||||
message_box(TR("Importazione stipendi completata"));
|
||||
}
|
||||
}
|
||||
@ -164,96 +148,216 @@ void TOmasa::main_loop()
|
||||
|
||||
bool TOmasa::transfer()
|
||||
{
|
||||
TString_array transactions;
|
||||
list_files("omat*.ini", transactions);
|
||||
TString_array transactions;
|
||||
TFilename tempdir;
|
||||
tempdir.tempdir();
|
||||
|
||||
TString80 listfiles = tempdir;
|
||||
listfiles << "\\oo*.ini";
|
||||
list_files(listfiles, transactions);
|
||||
FOR_EACH_ARRAY_ROW(transactions, row, name)
|
||||
remove(*name);
|
||||
int ntransac=0; // contatore di transazione
|
||||
|
||||
|
||||
TConfig* movpn=NULL;
|
||||
|
||||
_trasfile = new TOmasa_file(_msk->get(F_PERCORSO));
|
||||
_trasfile->open(_msk->get(F_PERCORSO),'r');
|
||||
|
||||
// creazione file temporanei per commessa e conto dare e avere
|
||||
const long dimension = fsize(_msk->get(F_PERCORSO));
|
||||
TProgind pi(dimension,"Importazione in corso...");
|
||||
const TDate datareg = _msk->get_date(F_DATAREG);
|
||||
const int annoes = _esc->date2esc(datareg);
|
||||
|
||||
TString16 olddip = "**";
|
||||
int numrig = 0;
|
||||
|
||||
TRecord_text curr;
|
||||
while (_trasfile->read(curr) == NOERR)
|
||||
{
|
||||
pi.setstatus(_trasfile->read_file()->tellg());
|
||||
TString impstr = curr.get(F_IMPORTO);
|
||||
impstr.insert(",",11);
|
||||
impstr.insert(".",11);
|
||||
const real importo(impstr);
|
||||
TString16 contodare = curr.get(F_CONTODARE);
|
||||
TString16 contoavere = curr.get(F_CONTOAVERE);
|
||||
if ((!real::is_null(impstr)) && (!contodare.blank() || !contoavere.blank()))
|
||||
{
|
||||
|
||||
TString16 coddip = curr.get(F_CODDIP);
|
||||
if (coddip != olddip)
|
||||
{
|
||||
ntransac++;
|
||||
TFilename name;
|
||||
name.tempdir();
|
||||
name.add(format("omat%04d", ntransac));
|
||||
name.ext(".ini");
|
||||
movpn = new TConfig(name);
|
||||
movpn->set_paragraph("Transaction");
|
||||
movpn->set("Action","INSERT");
|
||||
movpn->set("Mode","AUTO");
|
||||
|
||||
movpn->set_paragraph(format("%d",LF_MOV));
|
||||
|
||||
movpn->set("ANNOES", annoes);
|
||||
movpn->set("DATACOMP", datareg);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("DESCR", "Importazione stipendi");
|
||||
//movpn->set("NUMREG", ultima_registrazione());
|
||||
movpn->set("CODCAUS", _configfile->get("CODCAUS","MOVIMENTO"));
|
||||
numrig = 0;
|
||||
}
|
||||
|
||||
TString16 codcms = curr.get(F_CENTROCOSTO);
|
||||
codcms.trim();
|
||||
TFilename name;
|
||||
name.tempdir();
|
||||
name.add(format("oo%s", (const char*) codcms));
|
||||
name.ext(".ini");
|
||||
movpn = new TConfig(name);
|
||||
movpn->set_paragraph("MAIN");
|
||||
movpn->set("CODCMS",codcms);
|
||||
if (!contodare.blank())
|
||||
{
|
||||
movpn->set_paragraph("DARE");
|
||||
contodare.trim();
|
||||
TToken_string conto = _configfile->get(contodare, "CONTI");
|
||||
if (conto.empty())
|
||||
impstr = movpn->get(contodare, "DARE");
|
||||
real importomem(impstr);
|
||||
importomem+=importo;
|
||||
movpn->set(contodare, importomem.string());
|
||||
}
|
||||
if (!contoavere.blank())
|
||||
{
|
||||
movpn->set_paragraph("AVERE");
|
||||
contoavere.trim();
|
||||
impstr = movpn->get(contoavere, "AVERE");
|
||||
real importomem(impstr);
|
||||
importomem+=importo;
|
||||
movpn->set(contoavere, importomem.string());
|
||||
}
|
||||
|
||||
delete movpn;
|
||||
if (pi.iscancelled())
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
_trasfile->close();
|
||||
delete _trasfile;
|
||||
|
||||
// creazione .ini per la prima nota
|
||||
const TDate datareg = _msk->get_date(F_DATAREG);
|
||||
const int annoes = _esc->date2esc(datareg);
|
||||
const TString8 codcaus = _msk->get(F_CODCAUS);
|
||||
|
||||
listfiles = tempdir;
|
||||
listfiles << "\\oo*.ini";
|
||||
list_files(listfiles, transactions);
|
||||
FOR_EACH_ARRAY_ROW(transactions, row_oo, name_oo)
|
||||
{
|
||||
TConfig* movpn=NULL;
|
||||
TConfig file_oo(*name_oo);
|
||||
TString16 codcms = file_oo.get("CODCMS", "MAIN");
|
||||
codcms.trim();
|
||||
TFilename name;
|
||||
name.tempdir();
|
||||
name.add(format("ooo%s", (const char*) codcms));
|
||||
name.ext(".ini");
|
||||
movpn = new TConfig(name);
|
||||
|
||||
movpn->set_paragraph("Transaction");
|
||||
movpn->set("Action","INSERT");
|
||||
movpn->set("Mode","AUTO");
|
||||
|
||||
movpn->set_paragraph(format("%d",LF_MOV));
|
||||
movpn->set("ANNOES", annoes);
|
||||
movpn->set("DATACOMP", datareg);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("DESCR", cache().get(LF_CAUSALI, codcaus, CAU_DESCR));
|
||||
movpn->set("CODCAUS", codcaus);
|
||||
|
||||
int numrig = 0;
|
||||
|
||||
TString_array vl;
|
||||
file_oo.list_variables(vl,TRUE, "DARE", TRUE);
|
||||
FOR_EACH_ARRAY_ROW(vl,rd,sd)
|
||||
{
|
||||
TString16 contodare = (*sd).get();
|
||||
TString16 importodare = (*sd).get();
|
||||
TToken_string conto = _configfile->get(contodare, "CONTI");
|
||||
if (conto.empty())
|
||||
{
|
||||
TMask mskconto("cgp4100b");
|
||||
mskconto.set(F_CONTOOMASA, contodare);
|
||||
if (mskconto.run() == K_ENTER)
|
||||
{
|
||||
TMask mskconto("cgp4100b");
|
||||
mskconto.set(F_CONTOOMASA, contodare);
|
||||
if (mskconto.run() == K_ENTER)
|
||||
{
|
||||
const int gr = mskconto.get_int(F_GRUPPO);
|
||||
const int co = mskconto.get_int(F_CONTO);
|
||||
const long so = mskconto.get_long(F_SOTTOCONTO);
|
||||
conto.format("%d|%d|%ld", gr, co, so);
|
||||
_configfile->set(contodare, conto, "CONTI");
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
const int gr = mskconto.get_int(F_GRUPPO);
|
||||
const int co = mskconto.get_int(F_CONTO);
|
||||
const long so = mskconto.get_long(F_SOTTOCONTO);
|
||||
conto.format("%d|%d|%ld", gr, co, so);
|
||||
_configfile->set(contodare, conto, "CONTI");
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
numrig++;
|
||||
movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig));
|
||||
movpn->set("ANNOES", annoes);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("NUMRIG", numrig);
|
||||
movpn->set("IMPORTO", importodare);
|
||||
movpn->set("SEZIONE", "D");
|
||||
const int indbil = cache().get(LF_PCON, conto, PCN_INDBIL)[0];
|
||||
if ((indbil != 1) && (indbil != 2))
|
||||
movpn->set("CODCMS", codcms);
|
||||
movpn->set("GRUPPO", conto.get(0));
|
||||
movpn->set("CONTO", conto.get(1));
|
||||
movpn->set("SOTTOCONTO", conto.get(2));
|
||||
}
|
||||
|
||||
file_oo.list_variables(vl,TRUE, "AVERE", TRUE);
|
||||
FOR_EACH_ARRAY_ROW(vl,ra,sa)
|
||||
{
|
||||
TString16 contoavere = (*sa).get();
|
||||
TString16 importoavere = (*sa).get();
|
||||
TToken_string conto = _configfile->get(contoavere, "CONTI");
|
||||
if (conto.empty())
|
||||
{
|
||||
TMask mskconto("cgp4100b");
|
||||
mskconto.set(F_CONTOOMASA, contoavere);
|
||||
if (mskconto.run() == K_ENTER)
|
||||
{
|
||||
const int gr = mskconto.get_int(F_GRUPPO);
|
||||
const int co = mskconto.get_int(F_CONTO);
|
||||
const long so = mskconto.get_long(F_SOTTOCONTO);
|
||||
conto.format("%d|%d|%ld", gr, co, so);
|
||||
_configfile->set(contoavere, conto, "CONTI");
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
numrig++;
|
||||
movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig));
|
||||
movpn->set("ANNOES", annoes);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("NUMRIG", numrig);
|
||||
movpn->set("IMPORTO", importoavere);
|
||||
movpn->set("SEZIONE", "A");
|
||||
const int indbil = cache().get(LF_PCON, conto, PCN_INDBIL)[0];
|
||||
if ((indbil != 1) && (indbil != 2))
|
||||
movpn->set("CODCMS", codcms);
|
||||
movpn->set("GRUPPO", conto.get(0));
|
||||
movpn->set("CONTO", conto.get(1));
|
||||
movpn->set("SOTTOCONTO", conto.get(2));
|
||||
}
|
||||
}
|
||||
|
||||
tempdir.tempdir();
|
||||
TString80 applicat = "cg2.exe -0 -i";
|
||||
applicat << tempdir;
|
||||
applicat << "\\ooo*.ini";
|
||||
TExternal_app primanota(applicat);
|
||||
primanota.run();
|
||||
|
||||
listfiles = tempdir;
|
||||
listfiles << "\\oo*.ini";
|
||||
list_files(listfiles, transactions);
|
||||
FOR_EACH_ARRAY_ROW(transactions, rowf, namef)
|
||||
remove(*namef);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int cgp4100 (int argc, char* argv[])
|
||||
{
|
||||
TOmasa main_app;
|
||||
main_app.run(argc, argv, TR("Importazione stipendi"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
numrig++;
|
||||
movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig));
|
||||
movpn->set("ANNOES", annoes);
|
||||
//movpn->set("NUMREG", _numreg);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("NUMRIG", numrig);
|
||||
movpn->set("IMPORTO", importo.string());
|
||||
movpn->set("SEZIONE", "D");
|
||||
movpn->set("CODCMS", F_CENTROCOSTO);
|
||||
movpn->set("CODCMS", codcms);
|
||||
movpn->set("GRUPPO", conto.get(0));
|
||||
movpn->set("CONTO", conto.get(1));
|
||||
movpn->set("SOTTOCONTO", conto.get(2));
|
||||
}
|
||||
if (!contoavere.blank())
|
||||
{
|
||||
contoavere.trim();
|
||||
TToken_string conto = _configfile->get(contoavere, "CONTI");
|
||||
if (conto.empty())
|
||||
{
|
||||
@ -273,7 +377,6 @@ bool TOmasa::transfer()
|
||||
numrig++;
|
||||
movpn->set_paragraph(format("%d,%d",LF_RMOV, numrig));
|
||||
movpn->set("ANNOES", annoes);
|
||||
//movpn->set("NUMREG", _numreg);
|
||||
movpn->set("DATAREG", datareg);
|
||||
movpn->set("NUMRIG", numrig);
|
||||
movpn->set("IMPORTO", importo.string());
|
||||
@ -282,42 +385,4 @@ bool TOmasa::transfer()
|
||||
movpn->set("GRUPPO", conto.get(0));
|
||||
movpn->set("CONTO", conto.get(1));
|
||||
movpn->set("SOTTOCONTO", conto.get(2));
|
||||
}
|
||||
|
||||
delete movpn;
|
||||
if (pi.iscancelled())
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
_trasfile->close();
|
||||
delete _trasfile;
|
||||
|
||||
TFilename tempdir;
|
||||
tempdir.tempdir();
|
||||
TString80 applicat = "cg2.exe -0 -i";
|
||||
applicat << tempdir;
|
||||
applicat << "\\omat*.ini";
|
||||
TExternal_app primanota(applicat);
|
||||
primanota.run();
|
||||
TString80 listfiles = tempdir;
|
||||
listfiles << "\\omat*.ini";
|
||||
list_files(listfiles, transactions);
|
||||
FOR_EACH_ARRAY_ROW(transactions, rowf, namef)
|
||||
remove(*namef);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int cgp4100 (int argc, char* argv[])
|
||||
{
|
||||
TOmasa main_app;
|
||||
main_app.run(argc, argv, TR("Importazione stipendi"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
@ -1,8 +1,12 @@
|
||||
// campi della maschera
|
||||
// campi della maschera principale
|
||||
|
||||
#define F_PERCORSO 101
|
||||
#define F_DATAREG 102
|
||||
#define F_CODCAUS 103
|
||||
#define F_DESCR 104
|
||||
|
||||
// campi della maschera di conversione conti
|
||||
|
||||
|
||||
// campi del tracciato record
|
||||
|
||||
|
@ -4,12 +4,12 @@ TOOLBAR "" 0 20 0 2
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 ""
|
||||
PROMPT -12 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -1 ""
|
||||
PROMPT -22 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
@ -18,7 +18,7 @@ PAGE "Importazione stipendi" 0 -1 0 19
|
||||
|
||||
STRING F_PERCORSO 50
|
||||
BEGIN
|
||||
PROMPT 2 2 "File da trasferire "
|
||||
PROMPT 2 2 "File da trasferire "
|
||||
CHECKTYPE REQUIRED
|
||||
VALIDATE FILENAME_FUNC
|
||||
FLAGS "A"
|
||||
@ -28,12 +28,41 @@ END
|
||||
|
||||
DATE F_DATAREG
|
||||
BEGIN
|
||||
PROMPT 2 3 "Data registrazione movimenti "
|
||||
CHECKTYPE REQUIRED
|
||||
HELP "Data di registrazione dei movimenti contabili"
|
||||
WARNING "E' necessario specificare la data di registrazione"
|
||||
PROMPT 2 3 "Data registrazione "
|
||||
CHECKTYPE REQUIRED
|
||||
HELP "Data di registrazione dei movimenti contabili"
|
||||
WARNING "E' necessario specificare la data di registrazione"
|
||||
END
|
||||
|
||||
STRING F_CODCAUS 4
|
||||
BEGIN
|
||||
PROMPT 2 4 "Causale "
|
||||
FLAGS "UZ"
|
||||
USE LF_CAUSALI
|
||||
INPUT CODCAUS F_CODCAUS
|
||||
DISPLAY "Codice" CODCAUS
|
||||
DISPLAY "Descrizione@60" DESCR
|
||||
OUTPUT F_CODCAUS CODCAUS
|
||||
OUTPUT F_DESCR DESCR
|
||||
CHECKTYPE SEARCH
|
||||
END
|
||||
|
||||
STRING F_DESCR 50
|
||||
BEGIN
|
||||
PROMPT 17 4 ""
|
||||
USE LF_CAUSALI KEY 2
|
||||
INPUT DESCR F_DESCR
|
||||
DISPLAY "Descrizione@60" DESCR
|
||||
DISPLAY "Codice" CODCAUS
|
||||
COPY OUTPUT F_CODCAUS
|
||||
CHECKTYPE SEARCH
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Tabella conversione conti" 0 -1 0 19
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user