Patch level : 2.1 verticalizzazionbe OMASA

Files correlati     : cgp4.exe cgp4100a.msk cgp4100a.ini omasa.ini
Ricompilazione Demo : [ ]
Commento            : Importazione stipendi OMASA


git-svn-id: svn://10.65.10.50/trunk@12010 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2004-04-28 10:28:52 +00:00
parent 48ecff053c
commit 29bdec473c
7 changed files with 526 additions and 0 deletions

20
cg/cgp4.cpp Executable file
View File

@ -0,0 +1,20 @@
#include <xvt.h>
#include "cgp4.h"
int main(int argc,char** argv)
{
const int s = (argc > 1) ? argv[1][1] - '0' : 0;
switch (s)
{
case 0 :
default: cgp4100(argc,argv) ; break; // Importa stipendi in prima nota (OMASA)
}
exit(0);
return 0;
}

7
cg/cgp4.h Executable file
View File

@ -0,0 +1,7 @@
#ifndef __CGP4_H
#define __CGP4_H
int cgp4100(int argc, char* argv[]);
#endif // __CGP4_H

283
cg/cgp4100.cpp Executable file
View File

@ -0,0 +1,283 @@
// OMASA
#include <applicat.h>
#include <automask.h>
#include <config.h>
#include <execp.h>
#include <filetext.h>
#include <progind.h>
#include <utility.h>
#include "cgp4.h"
#include "cgp4100a.h"
#include "cglib01.h"
#include <mov.h>
#include <rmov.h>
#define MAX_CG_ROWS 98
// TAutomask
class TOmasa_mask : public TAutomask
{
protected:
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TOmasa_mask();
virtual ~TOmasa_mask(){};
};
TOmasa_mask::TOmasa_mask() :TAutomask ("cgp4100a")
{
}
bool TOmasa_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
return TRUE;
}
// TFile_text
class TOmasa_file: public TFile_text
{
protected:
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
public:
TOmasa_file(const TString& file_name);
virtual ~TOmasa_file() { }
};
TOmasa_file::TOmasa_file(const TString& file_name)
: TFile_text(file_name, "omasa.ini")
{
}
void TOmasa_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str)
{
const TString code(s.get(0));
TString valore;
if (code == "_UPPERCASE")
{
valore.upper();
}
else NFCHECK("Macro non definita: %s", (const char *)code);
str = valore;
}
// TSkeleton_application
class TOmasa : public TSkeleton_application
{
TOmasa_mask* _msk;
TOmasa_file* _trasfile;
TConfig* _configfile;
TRelation* _rel;
TCursor* _cur;
TProgind* _prog;
TEsercizi_contabili* _esc;
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();
virtual void main_loop();
bool transfer();
TOmasa() {}
};
TOmasa& app() { return (TOmasa&) main_app(); }
bool TOmasa::create()
{
open_files(LF_TABCOM, LF_TAB, LF_SALDI, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA,
LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
_configfile = new TConfig("cgp4100a.ini");
_msk = new TOmasa_mask();
_rel = new TRelation (LF_PCON);
_cur = new TCursor(_rel,"((GRUPPO!=\"\")&&(CONTO!=\"\")&&(SOTTOCONTO==\"\"))",1);
_esc = new TEsercizi_contabili;
return TSkeleton_application::create();
}
bool TOmasa::destroy()
{
delete _esc;
delete _cur;
delete _rel;
delete _msk;
delete _configfile;
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"));
tasto = _msk->run();
if (tasto == K_ENTER)
{
_numreg = 0;
if (transfer())
{
_configfile->set("PERCORSO", _msk->get(F_PERCORSO), "MAIN");
message_box(TR("Importazione stipendi completata"));
}
}
}
bool TOmasa::transfer()
{
TString_array transactions;
list_files("omat*.ini", 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');
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);
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++;
movpn = new TConfig(format("omat%04d.ini",ntransac));
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());
numrig = 0;
}
if (!contodare.blank())
{
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);
contodare.trim();
TToken_string conto = _configfile->get(contodare, "CONTI");
if (conto.not_empty())
{
movpn->set("GRUPPO", conto.get(0));
movpn->set("CONTO", conto.get(1));
movpn->set("SOTTOCONTO", conto.get(2));
}
}
if (!contoavere.blank())
{
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", 'A');
movpn->set("CODCMS", F_CENTROCOSTO);
contoavere.trim();
TToken_string conto = _configfile->get(contoavere, "CONTI");
if (!conto.blank())
{
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;
//TExternal_app primanota("cg2.exe -0 -iosam*.ini ");
//primanota.run();
return TRUE;
}
int cgp4100 (int argc, char* argv[])
{
TOmasa main_app;
main_app.run(argc, argv, TR("Importazione stipendi"));
return TRUE;
}

25
cg/cgp4100a.h Executable file
View File

@ -0,0 +1,25 @@
// campi della maschera
#define F_PERCORSO 101
#define F_DATAREG 102
#define F_CODCAUS 103
// campi del tracciato record
#define F_CODAZIENDA 0
#define F_CODDIP 1
#define F_VOCE 2
#define F_TIPOVOCE 3
#define F_QUOTAVOCE 4
#define F_VALOREVOCE 5
#define F_IMPORTO 6
#define F_CONTODARE 7
#define F_CONTOAVERE 8
#define F_CENTROCOSTO 9
#define F_SEDELAVORO 10
#define F_SEDEINPS 11
#define F_QUALIFICA 12
#define F_POSINAIL 13
#define F_VARIABILE 14
#define F_CONTRATTO 15
#define F_FILLER 16

14
cg/cgp4100a.ini Executable file
View File

@ -0,0 +1,14 @@
[MAIN]
PERCORSO = c:\temp\outretr.seq
[CONTI]
420010=15|70|1
421000=15|70|1
421100=15|70|1
424000=15|70|1
601000=15|70|1
601050=15|70|1
601010=15|70|1
601300=15|70|1
601385=15|70|1

38
cg/cgp4100a.uml Executable file
View File

@ -0,0 +1,38 @@
#include "cgp4100a.h"
TOOLBAR "" 0 20 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
PAGE "Importazione stipendi" 0 -1 0 19
STRING F_PERCORSO 50
BEGIN
PROMPT 2 2 "File da trasferire "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
FLAGS "A"
HELP "Percorso e nome file da trasferire"
WARNING "E' necessario specificare il nome del file da trasferire"
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"
END
ENDPAGE
ENDMASK

139
cg/omasa.ini Executable file
View File

@ -0,0 +1,139 @@
[MAIN]
DECSEP =
FIELDSEP =
RECORDSEP = \n
RECORDSIZE = 0
SKIPLINES = 0
TYPEFIELD = -1
TYPELEN = -1
TYPEPOS = -1
[TYPE FISSO]
ALIGN =
DATA =
DECIMAL = 0
FILLER = ' '
LENGTH = 0
PICTURE =
[TYPE DATA]
ALIGN =
DATA = D
DECIMAL = 0
FILLER =
LENGTH = 8
PICTURE =
[TYPE NUMERO]
ALIGN = R
DATA =
DECIMAL = 0
FILLER = '0'
LENGTH = 0
PICTURE =
[TYPE IMPORTO]
ALIGN = R
DATA =
DECIMAL = 2
FILLER = '0'
LENGTH = 13
PICTURE =
[TYPE STRINGA]
ALIGN = L
DATA = S
DECIMAL = 0
FILLER = ' '
LENGTH = 0
PICTURE =
[RECORD]
NAME(0) = CODICE AZIENDA
TYPE(0) = NUMERO
POSITION(0) = 0
LENGTH(0) = 4
NAME(1) = CODICE DIPENDENTE
TYPE(1) = NUMERO
POSITION(1) = 4
LENGTH(1) = 6
NAME(2) = VOCE
TYPE(2) = NUMERO
POSITION(2) = 10
LENGTH(2) = 4
NAME(3) = TIPO VOCE
TYPE(3) = STRINGA
POSITION(3) = 14
LENGTH(3) = 1
NAME(4) = QUOTA VOCE
TYPE(4) = NUMERO
POSITION(4) = 15
LENGTH(4) = 6
DECIMAL(4) = 2
NAME(5) = VALORE VOCE
TYPE(5) = NUMERO
POSITION(5) = 21
LENGTH(5) = 13
DECIMAL(5) = 2
NAME(6) = IMPORTO UNITARIO
TYPE(6) = IMPORTO
POSITION(6) = 34
LENGTH(6) = 13
DECIMAL(6) = 2
NAME(7) = CONTO DARE
TYPE(7) = STRINGA
POSITION(7) = 47
LENGTH(7) = 14
NAME(8) = CONTO AVERE
TYPE(8) = STRINGA
POSITION(8) = 61
LENGTH(8) = 14
NAME(9) = CENTRO DI COSTO
TYPE(9) = STRINGA
POSITION(9) = 75
LENGTH(9) = 12
NAME(10) = SEDE DI LAVORO
TYPE(10) = STRINGA
POSITION(10) = 87
LENGTH(10) = 2
NAME(11) = SEDE INPS
TYPE(11) = STRINGA
POSITION(11) = 89
LENGTH(11) = 2
NAME(12) = QUALIFICA
TYPE(12) = STRINGA
POSITION(12) = 91
LENGTH(12) = 1
NAME(13) = POSIZIONE INAIL
TYPE(13) = STRINGA
POSITION(13) = 92
LENGTH(13) = 2
NAME(14) = VARIABILE
TYPE(14) = STRINGA
POSITION(14) = 94
LENGTH(14) = 40
NAME(15) = CONTRATTO
TYPE(15) = STRINGA
POSITION(15) = 134
LENGTH(15) = 2
NAME(16) = FILLER
TYPE(16) = STRINGA
POSITION(16) = 136
LENGTH(16) = 6