5ed8a6b90d
Corretto riutilizzo vecchi NUMREG in prima nota Correttra gestione floppy in trasferimento a PC git-svn-id: svn://10.65.10.50/branches/R_10_00@23068 c028cbd2-c16b-5b4b-a496-9718f37d4682
2057 lines
62 KiB
C++
Executable File
2057 lines
62 KiB
C++
Executable File
#include "cg6900.h"
|
|
#include "cg6900a.h"
|
|
|
|
#include "cglib03.h"
|
|
|
|
#include <progind.h>
|
|
#include <utility.h>
|
|
|
|
FILE* TInv_cont::chiedi_disco(const char* name, int disk, const TString& floppy, bool lettura)
|
|
{
|
|
FILE* f = NULL;
|
|
if (!xvt_fsys_is_floppy_drive(floppy))
|
|
return f;
|
|
|
|
message_box("Inserire il disco %d nel drive %c:", disk, floppy[0]);
|
|
|
|
// name.ext(format("%03d", disk));
|
|
|
|
bool retry = true;
|
|
while (retry)
|
|
{
|
|
fopen_s(&f, name, lettura ? "rb" : "wb");
|
|
if (f == NULL)
|
|
retry = yesno_box("Il file %s non e' accessibile: riprovare?", (const char*)name);
|
|
else
|
|
{
|
|
retry = false;
|
|
fclose(f);
|
|
}
|
|
}
|
|
|
|
return f;
|
|
}
|
|
|
|
bool TInv_cont::scrivi_disco(const TString& floppy, int disk, const char* work,
|
|
FILE* i, TProgind& w)
|
|
{
|
|
FILE* file = chiedi_disco(work, disk, floppy, FALSE);
|
|
|
|
const bool is_floppy = xvt_fsys_is_floppy_drive(floppy) != 0;
|
|
if (is_floppy)
|
|
{
|
|
if (file == NULL)
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
if (_dim_disk < _dim_tot)
|
|
{
|
|
warning_box(FR("Occorrono almeno %d Kb di spazio su disco"), int(_dim_tot/1024+1));
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
TString str;
|
|
str.format("%02d", disk);
|
|
if (_scelta == 'S')
|
|
aggiorna_marker(str,31); // Aggiorna il num. progr. disco su marker
|
|
else
|
|
aggiorna_marker(str,34);
|
|
|
|
TFilename path_m = floppy; path_m.add("marker");
|
|
TFilename path_t = floppy; path_t.add("trasfer");
|
|
|
|
if (!fcopy(_marker,path_m)) // Copia il marker su disco
|
|
return false;
|
|
|
|
FILE* o = NULL; fopen_s(&o, path_t, "wb");
|
|
if (o != NULL)
|
|
{
|
|
TString tmp(BUFSIZE);
|
|
char* buffer = tmp.get_buffer(BUFSIZE);
|
|
size_t tot_scritti = BUFSIZE;
|
|
while (tot_scritti <= _dim_disk)
|
|
{
|
|
const size_t letti = fread(buffer, 1, BUFSIZE, i);
|
|
fwrite(buffer, letti, 1, o);
|
|
tot_scritti += letti;
|
|
if (letti < BUFSIZE)
|
|
break;
|
|
|
|
w.addstatus(letti);
|
|
}
|
|
|
|
fclose(o);
|
|
}
|
|
|
|
return o != NULL;
|
|
}
|
|
|
|
int TInv_cont::calcola_numero_dischi(TMask& msk, const TString& floppy)
|
|
{
|
|
int numdisc = 1;
|
|
|
|
FILE* t = NULL; fopen_s(&t, _trasf, "rb");
|
|
if (t == NULL) return error_box("Impossibile aprire il file '%s'", _trasf);
|
|
|
|
long dim_t = _tras_file.determina_dimensione(t); //Determina la dimensione del trasfer
|
|
fclose(t);
|
|
|
|
// FILE* h = fopen(_header, "rb");
|
|
// if (h == NULL) return error_box("Impossibile aprire il file '%s'", _header);
|
|
|
|
// long dim_h = determina_dimensione(h); //Determina la dimensione del trasfer
|
|
// fclose(h);
|
|
|
|
FILE* m = NULL; fopen_s(&m, _marker, "rb");
|
|
if (m == NULL) return error_box("Impossibile aprire il file '%s'", _marker);
|
|
|
|
long dim_m = _tras_file.determina_dimensione(m); // Determina la dimensione del marker
|
|
fclose(m);
|
|
|
|
_dim_tot = dim_t + dim_m; //+dim_h; // Determina la dimensione totale
|
|
|
|
if (xvt_fsys_is_floppy_drive(floppy))
|
|
{
|
|
int item = msk.get_int(F_DIM);
|
|
switch (item)
|
|
{
|
|
case 1 :
|
|
_dim_disk = 1400000L;
|
|
break;
|
|
case 2 :
|
|
_dim_disk = 1200000L;
|
|
break;
|
|
case 3 :
|
|
_dim_disk = 720000L;
|
|
break;
|
|
case 4 :
|
|
_dim_disk = 360000L;
|
|
break;
|
|
default :
|
|
break;
|
|
};
|
|
|
|
if (_dim_tot < _dim_disk)
|
|
numdisc = 1;
|
|
else
|
|
{
|
|
numdisc = int(_dim_tot / _dim_disk);
|
|
if ( (_dim_tot % _dim_disk) != 0)
|
|
numdisc += 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_dim_disk = xvt_fsys_get_disk_free_space(floppy, 'b');
|
|
}
|
|
|
|
return numdisc;
|
|
}
|
|
|
|
// Invio a sistema
|
|
bool TInv_cont::invio_contabilita()
|
|
{
|
|
const int size = 256;
|
|
|
|
char sigla;
|
|
TString nrec,files;
|
|
bool header = TRUE;
|
|
|
|
_numrec_cau = 0;
|
|
_numrec_clifo = 0;
|
|
_numrec_pcon = 0;
|
|
_numrec_pn = 0;
|
|
_numrec_iva = 0;
|
|
_numrec_sc = 0;
|
|
|
|
_tras_file.open(_header);
|
|
|
|
leggi_record_controllo();
|
|
|
|
files = _tras_file.sigle_file();
|
|
nrec = _tras_file.nrec_file();
|
|
files.trim();
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
for (int i = 0; i < files.len();i++)
|
|
{
|
|
sigla = files[i];
|
|
//_numrec = atol(nrec.mid(i * 6,6));
|
|
|
|
if (header)
|
|
{
|
|
TString dittaAS = _control_rec.sub(301,305);
|
|
|
|
TString app1 = _control_rec.mid(0,15);
|
|
TString app2 = _control_rec.mid(60,10);
|
|
TString app3 = _control_rec.mid(71,7);
|
|
app3.overwrite(dittaAS,0); //Sostituisco l'eventuale ditta di 5 con quella di 4
|
|
TString app4 = _control_rec.mid(80,300);
|
|
TString app5 = app1 << app2 << app3 << app4;
|
|
app5.overwrite(" ",252); //Pulisco la ditta da inviare a sistema che non serve piu'
|
|
app5.cut(size);
|
|
_tras_file.write_control_rec(app5,size);
|
|
aggiorna_marker(dittaAS,10);
|
|
header = FALSE;
|
|
}
|
|
|
|
switch (sigla)
|
|
{
|
|
case 'W':
|
|
if (!invio_tab_cau())
|
|
return FALSE;
|
|
break;
|
|
|
|
case 'A':
|
|
if (!invio_clifo())
|
|
return FALSE;
|
|
break;
|
|
|
|
case 'P':
|
|
if (!invio_pcon())
|
|
return FALSE;
|
|
break;
|
|
|
|
case 'Z':
|
|
if (!invio_mov_PN())
|
|
return FALSE;
|
|
break;
|
|
|
|
case 'U':
|
|
if (!invio_mov_IVA())
|
|
return FALSE;
|
|
break;
|
|
|
|
case 'B':
|
|
if (!invio_mov_SC())
|
|
return FALSE;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
};
|
|
}
|
|
|
|
aggiorna_header(files);
|
|
aggiorna_trasfer(files);
|
|
|
|
TString str;
|
|
|
|
calcola_totale_record();
|
|
str.format("%06ld", _tot_rec);
|
|
aggiorna_marker(str,23);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TInv_cont::aggiorna_header(TString& files)
|
|
{
|
|
char sigla;
|
|
int size = 1024;
|
|
|
|
_tras_file.open(_header);
|
|
leggi_record_controllo();
|
|
|
|
for (int i = 0; i < files.len();i++)
|
|
{
|
|
sigla = files[i];
|
|
|
|
switch (sigla)
|
|
{
|
|
case 'W':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_cau);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
case 'A':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_clifo);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
case 'P':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_pcon);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
case 'Z':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_pn);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
case 'U':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_iva);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
case 'B':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_sc);
|
|
_control_rec.overwrite(app,((i * 6) + 95));
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
};
|
|
}
|
|
_tras_file.write_control_rec(_control_rec,size);
|
|
_tras_file.close();
|
|
}
|
|
|
|
void TInv_cont::aggiorna_trasfer(TString& files)
|
|
{
|
|
char sigla;
|
|
int size,pos;
|
|
|
|
if (_scelta == 'S')
|
|
{
|
|
size = 256;
|
|
pos = 47;
|
|
}
|
|
else
|
|
{
|
|
size = 1024;
|
|
pos = 95;
|
|
}
|
|
|
|
_tras_file.open(_trasf);
|
|
leggi_record_controllo();
|
|
|
|
for (int i = 0; i < files.len();i++)
|
|
{
|
|
sigla = files[i];
|
|
|
|
switch (sigla)
|
|
{
|
|
case 'W':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_cau);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
case 'A':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_clifo);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
case 'P':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_pcon);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
case 'Z':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_pn);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
case 'U':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_iva);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
case 'B':
|
|
{
|
|
TString app;
|
|
app.format("%06ld", _numrec_sc);
|
|
_control_rec.overwrite(app,((i * 6) + pos));
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
};
|
|
}
|
|
_tras_file.write_control_rec(_control_rec,size);
|
|
_tras_file.close();
|
|
}
|
|
|
|
bool TInv_cont::invio_tab_cau()
|
|
{
|
|
const int size = 256;
|
|
TString record(size);
|
|
TString cod;
|
|
|
|
long cicli = _tcaus->items();
|
|
_prog = new TProgind(cicli,"Tabella Causali: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
for (_tcaus->first(); !_tcaus->eof(); _tcaus->next())
|
|
{
|
|
TString str;
|
|
|
|
_prog->addstatus(1);
|
|
|
|
record.spaces();
|
|
|
|
const char* codcau = _tcaus->get(CAU_CODCAUS);
|
|
str.format("%03s", codcau);
|
|
record.overwrite("W1",0); //Tipo record
|
|
record.overwrite(str,2); //Codice causale
|
|
|
|
TString descr = _tcaus->get(CAU_DESCR);
|
|
descr.format("%-.20s", (const char*) descr);
|
|
record.overwrite(descr,15); //Descrizione
|
|
|
|
TString tipodoc = _tcaus->get(CAU_TIPODOC);
|
|
record.overwrite(tipodoc,35); //Tipo documento
|
|
|
|
TString reg = _tcaus->get(CAU_REG);
|
|
if (real::is_natural(reg))
|
|
{
|
|
int app = atoi(reg);
|
|
reg.format("%d", app);
|
|
}
|
|
record.overwrite(reg,37); //Registro IVA
|
|
|
|
bool alleg = _tcaus->get_bool(CAU_ALLEG);
|
|
if (alleg)
|
|
record.overwrite("X",38);
|
|
else //Flag esclusione tipo documento da allegato
|
|
record.overwrite(" ",38);
|
|
|
|
int m770 = atoi(_tcaus->get(CAU_M770));
|
|
str = format("%1d", m770);
|
|
record.overwrite(str,39); //Collegamento modello 770
|
|
|
|
TString cespiti = _tcaus->get(CAU_COLLCESP);
|
|
record.overwrite(cespiti,40); //Collegamento cespiti
|
|
|
|
bool numdoc = _tcaus->get_bool(CAU_NUMDOC);
|
|
if (numdoc)
|
|
record.overwrite("1",206);
|
|
else //Flag immissione numero documento
|
|
record.overwrite("0",206);
|
|
|
|
bool datadoc = _tcaus->get_bool(CAU_DATADOC);
|
|
if (datadoc)
|
|
record.overwrite("1",207);
|
|
else //Flag immissione data documento
|
|
record.overwrite("0",207);
|
|
|
|
const char* codcausim = _tcaus->get(CAU_CODCAUSIM);
|
|
str.format("%03s", codcausim);
|
|
record.overwrite(str,209); //Codice causale per incasso immediato
|
|
|
|
bool intracom = _tcaus->get_bool(CAU_INTRACOM);
|
|
if (intracom)
|
|
record.overwrite("X",246);
|
|
else //Flag per operazioni intracomunitarie
|
|
record.overwrite(" ",246);
|
|
|
|
bool valintra = _tcaus->get_bool(CAU_VALINTRA);
|
|
if (valintra)
|
|
record.overwrite("X",247);
|
|
else //Gestione valuta per oper. intracomunitarie
|
|
record.overwrite(" ",247);
|
|
|
|
bool ritfatt = _tcaus->get_bool(CAU_RITFATT);
|
|
if (ritfatt)
|
|
record.overwrite("X",248);
|
|
else //Flag causale per fattura ricevuta in ritardo
|
|
record.overwrite(" ",248);
|
|
|
|
bool autofatt = _tcaus->get_bool(CAU_AUTOFATT);
|
|
if (autofatt)
|
|
record.overwrite("X",249);
|
|
else //Autofattura art.34
|
|
record.overwrite(" ",249);
|
|
|
|
TString movap = _tcaus->get(CAU_MOVAP);
|
|
record.overwrite(movap,212); //Segnalino di causale apertura/chiusura
|
|
|
|
int tipomov = _tcaus->get_int(CAU_TIPOMOV);
|
|
str.format("%d", tipomov);
|
|
record.overwrite(str,208); //Tipo movimento del saldaconto
|
|
|
|
bool movval = _tcaus->get_bool(CAU_MOVVAL);
|
|
if (movval)
|
|
record.overwrite("X",214);
|
|
else //Flag movimento in valuta
|
|
record.overwrite(" ",214);
|
|
|
|
int num = 0;
|
|
int pos_gcs = 41;
|
|
int pos_sez = 191;
|
|
_codcaus = _tcaus->get(CAU_CODCAUS);
|
|
|
|
do
|
|
{
|
|
num++;
|
|
|
|
_trcaus->setkey(1);
|
|
_trcaus->zero();
|
|
_trcaus->put(RCA_CODCAUS, _codcaus);
|
|
_trcaus->put(RCA_NRIGA, num);
|
|
|
|
if (_trcaus->read() == NOERR)
|
|
{
|
|
int g = _trcaus->get_int (RCA_GRUPPO);
|
|
int c = _trcaus->get_int (RCA_CONTO);
|
|
long s = _trcaus->get_long(RCA_SOTTOCONTO);
|
|
TString sez = _trcaus->get (RCA_SEZIONE);
|
|
|
|
str = format("%02d", g);
|
|
record.overwrite(str,pos_gcs); //Gruppo
|
|
pos_gcs += 2;
|
|
str = format("%02d", c);
|
|
record.overwrite(str,pos_gcs); //Conto
|
|
pos_gcs += 2;
|
|
str = format("%06ld", s);
|
|
record.overwrite(str,pos_gcs); //Sottoconto
|
|
pos_gcs += 6;
|
|
|
|
record.overwrite(sez,pos_sez); //Sezione
|
|
pos_sez++;
|
|
}
|
|
else
|
|
{
|
|
int g = 0;
|
|
int c = 0;
|
|
long s = 0;
|
|
TString sez = " ";
|
|
|
|
str = format("%02d", g);
|
|
record.overwrite(str,pos_gcs); //Gruppo
|
|
pos_gcs += 2;
|
|
str = format("%02d", c);
|
|
record.overwrite(str,pos_gcs); //Conto
|
|
pos_gcs += 2;
|
|
str = format("%06ld", s);
|
|
record.overwrite(str,pos_gcs); //Sottoconto
|
|
pos_gcs += 6;
|
|
|
|
record.overwrite(sez,pos_sez); //Sezione
|
|
pos_sez++;
|
|
}
|
|
}
|
|
while (num < 15);
|
|
|
|
_numrec_cau++;
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
delete _prog;
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TInv_cont::scrivi_telefono(TString& appoggio)
|
|
{
|
|
TString ptel;
|
|
TString tel;
|
|
|
|
if (_tclifo->get(CLI_TEL).not_empty())
|
|
{
|
|
ptel = _tclifo->get(CLI_PTEL);
|
|
tel = _tclifo->get(CLI_TEL);
|
|
}
|
|
else
|
|
if (_tclifo->get(CLI_TEL2).not_empty())
|
|
{
|
|
ptel = _tclifo->get(CLI_PTEL2);
|
|
tel = _tclifo->get(CLI_TEL2);
|
|
}
|
|
else
|
|
if (_tclifo->get(CLI_TEL3).not_empty())
|
|
{
|
|
ptel = _tclifo->get(CLI_PTEL3);
|
|
tel = _tclifo->get(CLI_TEL3);
|
|
}
|
|
|
|
if (real::is_natural(ptel))
|
|
{
|
|
appoggio << ptel;
|
|
if (ptel.not_empty())
|
|
appoggio << "/" << tel;
|
|
else
|
|
appoggio << tel;
|
|
}
|
|
else
|
|
appoggio << tel;
|
|
}
|
|
|
|
void TInv_cont::cerca_dencom(const TString& comcf,TString& dencom) const
|
|
{
|
|
TString8 k; k << " |" << comcf;
|
|
dencom = cache().get(LF_COMUNI, k, COM_DENCOM);
|
|
}
|
|
|
|
bool TInv_cont::invio_clifo()
|
|
{
|
|
const int size = 256;
|
|
TString record(size);
|
|
|
|
long cicli = _tclifo->items();
|
|
_prog = new TProgind(cicli,"Anagrafica Clienti/Fornitori: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
for (_tclifo->first(); !_tclifo->eof(); _tclifo->next())
|
|
{
|
|
TString str;
|
|
|
|
_prog->addstatus(1);
|
|
|
|
record.spaces();
|
|
|
|
// Il tipocf su PC e' C = cliente F = fornitore.
|
|
// Il tipocf su AS400 e' 1 = cliente 2 = fornitore.
|
|
TString tipo_cod;
|
|
|
|
char tipo = _tclifo->get_char(CLI_TIPOCF);
|
|
if (tipo == 'C')
|
|
tipo_cod = "1";
|
|
else
|
|
if (tipo == 'F')
|
|
tipo_cod = "2";
|
|
|
|
record.overwrite("A1",0); //Tipo record
|
|
record.overwrite(tipo_cod,2); //Tipo cliente/fornitore
|
|
|
|
long codice = _tclifo->get_long(CLI_CODCF);
|
|
str.format("%06ld", codice);
|
|
record.overwrite(str,3); //Codice cliente/fornitore
|
|
|
|
//Il tipo persona su PC e' F = fisica G = giuridica
|
|
//Il tipo persona su AS400 e' 0 = giuridica 1 = fisica
|
|
char tipop = _tclifo->get_char(CLI_TIPOPERS);
|
|
TString tipopers;
|
|
|
|
if (tipop == 'F')
|
|
tipopers = "1";
|
|
else
|
|
if (tipop == 'G')
|
|
tipopers = "0";
|
|
|
|
record.overwrite(tipopers,15); //Tipo persona
|
|
|
|
TString ragsoc = _tclifo->get(CLI_RAGSOC);
|
|
TString cognome = ragsoc.mid(0,30);
|
|
TString nome = ragsoc.mid(30,20);
|
|
str.format("%-30s", (const char*) cognome); //Cognome o I ragione sociale
|
|
record.overwrite(str,16);
|
|
str.format("%-20s", (const char*) nome);
|
|
record.overwrite(str,46); //Nome o II ragione sociale
|
|
|
|
TString paiv = _tclifo->get(CLI_PAIV);
|
|
str.format("%011s", (const char*) paiv);
|
|
record.overwrite(str,66); //Partita IVA
|
|
|
|
TString cofi = _tclifo->get(CLI_COFI);
|
|
str.format("%-16s", (const char*) cofi);
|
|
record.overwrite(str,77); //Codice fiscale
|
|
|
|
TString indcf = _tclifo->get(CLI_INDCF);
|
|
TString civcf = _tclifo->get(CLI_CIVCF);
|
|
int lind = indcf.len();
|
|
int lciv = civcf.len();
|
|
int totlen = lind + lciv + 1;
|
|
if (totlen < 36)
|
|
indcf << " " << civcf;
|
|
|
|
str.format("%-35s", (const char*) indcf);
|
|
record.overwrite(str,93); //Indirizzo
|
|
|
|
const TString8 capcf = _tclifo->get(CLI_CAPCF);
|
|
str.format("%05s", (const char*) capcf);
|
|
record.overwrite(str,128); //Codice di avviamento postale
|
|
|
|
const TString4 comcf = _tclifo->get(CLI_COMCF);
|
|
TString localita;
|
|
if (comcf.not_empty())
|
|
cerca_dencom(comcf,localita);
|
|
else
|
|
localita = _tclifo->get(CLI_LOCCF);
|
|
str.format("%-.20s", (const char*) localita);
|
|
record.overwrite(str,133); //Localita'
|
|
|
|
TString4 provincia;
|
|
|
|
cerca_provincia(comcf, provincia);
|
|
str.format("%-2s", (const char*) provincia);
|
|
record.overwrite(str,153); //Provincia
|
|
|
|
/* TString ptel = _tclifo->get(CLI_PTEL);
|
|
TString tel = _tclifo->get(CLI_TEL);
|
|
TString appoggio;
|
|
appoggio << ptel << " " << tel;
|
|
record.overwrite(appoggio,155);
|
|
*/
|
|
TString appoggio = "";
|
|
scrivi_telefono(appoggio);
|
|
appoggio.format("%-12s", (const char*) appoggio);
|
|
appoggio.cut(12);
|
|
record.overwrite(appoggio,155);
|
|
|
|
TString alleg = _tclifo->get(CLI_ALLEG);
|
|
record.overwrite(alleg,167); //Flag gestione allegato
|
|
|
|
int gruppo = _tclifo->get_int(CLI_GRUPPORIC);
|
|
int conto = _tclifo->get_int(CLI_CONTORIC);
|
|
long sottoc = _tclifo->get_long(CLI_SOTTOCRIC);
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,168); //Gruppo di costo/ricavo
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,170); //Conto di costo/ricavo
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,172); //sottoconto di costo/ricavo
|
|
|
|
long codalleg = _tclifo->get_long(CLI_CODALLEG);
|
|
str.format("%06ld", codalleg);
|
|
record.overwrite(str,179);
|
|
|
|
TString codpag = _tclifo->get(CLI_CODPAG);
|
|
str.format("%-2s", (const char*) codpag);
|
|
record.overwrite(str,185);
|
|
|
|
_numrec_clifo++;
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
delete _prog;
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TInv_cont::invio_pcon()
|
|
{
|
|
const int size = 256;
|
|
TString record(size);
|
|
|
|
long cicli = _tpcon->items();
|
|
_prog = new TProgind(cicli,"Anagrafica Piano Conti: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
for (_tpcon->first(); !_tpcon->eof(); _tpcon->next())
|
|
{
|
|
TString str;
|
|
|
|
_prog->addstatus(1);
|
|
|
|
record.spaces();
|
|
|
|
int g = _tpcon->get_int (PCN_GRUPPO);
|
|
int c = _tpcon->get_int (PCN_CONTO);
|
|
long s = _tpcon->get_long(PCN_SOTTOCONTO);
|
|
|
|
// Se si tratta di un GRUPPO
|
|
|
|
if (g != 0 && c == 0 && s == 0)
|
|
{
|
|
record.overwrite("P1",0); //Tipo record
|
|
str.format("%02d", g);
|
|
record.overwrite(str,2); //Gruppo
|
|
|
|
TString descr (_tpcon->get(PCN_DESCR));
|
|
str.format("%-.30s", (const char*) descr);
|
|
record.overwrite(str,15); //Descrizione gruppo
|
|
}
|
|
|
|
// Se si tratta di un CONTO
|
|
|
|
if (g != 0 && c != 0 && s == 0)
|
|
{
|
|
record.overwrite("P2",0); //Tipo record
|
|
str.format("%02d", g);
|
|
record.overwrite(str,2); //Gruppo
|
|
|
|
str.format("%02d", c);
|
|
record.overwrite(str,4); //Conto
|
|
|
|
TString descr (_tpcon->get(PCN_DESCR));
|
|
str.format("%-.30s", (const char*) descr);
|
|
record.overwrite(str,15); //Descrizione conto
|
|
|
|
int indbil = _tpcon->get_int(PCN_INDBIL);
|
|
str.format("%d", indbil);
|
|
record.overwrite(str,45); //Indicatore di bilancio
|
|
|
|
TString tmcf = _tpcon->get(PCN_TMCF);
|
|
record.overwrite(tmcf,46); //Flag conto cliente/fornitore
|
|
|
|
bool stsottbil = _tpcon->get_bool(PCN_STSOTTBIL);
|
|
if (stsottbil)
|
|
str = "1";
|
|
else
|
|
str = "0";
|
|
record.overwrite(str,47); //Flag stampa dettaglio sottoconti su bilancio
|
|
|
|
// Classe IV direttiva CEE
|
|
|
|
TString sez = _tpcon->get(PCN_SEZIVD);
|
|
if (sez == "0")
|
|
sez = " ";
|
|
record.overwrite(sez,48); //Sezione IV dir
|
|
|
|
TString let = _tpcon->get(PCN_LETTIVD);
|
|
record.overwrite(let,49); //Lettera IV dir
|
|
|
|
int numrom = atoi(_tpcon->get(PCN_NUMRIVD));
|
|
str.format("%03d", numrom);
|
|
record.overwrite(str,60); //Numero arabo corrispondente al numero romano
|
|
TString numr = itor(numrom);
|
|
str.format("%-8s", (const char*) numr);
|
|
record.overwrite(str,50); //Numero romano IV dir
|
|
|
|
const TString num = _tpcon->get(PCN_NUMIVD).left(2);
|
|
record.overwrite(num,58); //Numero arabo IV dir
|
|
|
|
// Classe IV direttiva CEE di segno opposto
|
|
|
|
TString sezop = _tpcon->get(PCN_SEZIVDOPP);
|
|
if (sezop == "0")
|
|
sezop = " ";
|
|
record.overwrite(sezop,63); //Sezione IV dir
|
|
|
|
TString letop = _tpcon->get(PCN_LETTIVDOPP);
|
|
record.overwrite(letop,64); //Lettera IV dir
|
|
|
|
int numromop = atoi(_tpcon->get(PCN_NUMRIVDOPP));
|
|
str.format("%03d", numromop);
|
|
record.overwrite(str,75); //Numero arabo corrispondente al numero romano
|
|
TString numrop = itor(numromop);
|
|
str.format("%-8s", (const char*) numrop);
|
|
record.overwrite(str,65); //Numero romano IV dir
|
|
|
|
const TString16 numop = _tpcon->get(PCN_NUMIVDOPP).left(2);
|
|
record.overwrite(numop,73); //Numero arabo IV dir
|
|
}
|
|
|
|
// Se si tratta di un SOTTOCONTO
|
|
|
|
if (g != 0 && c != 0 && s != 0)
|
|
{
|
|
record.overwrite("P3",0); //Tipo record
|
|
str.format("%02d", g);
|
|
record.overwrite(str,2); //Gruppo
|
|
|
|
str.format("%02d", c);
|
|
record.overwrite(str,4); //Conto
|
|
|
|
str.format("%06ld", s);
|
|
record.overwrite(str,6); //Sottoconto
|
|
|
|
TString descr (_tpcon->get(PCN_DESCR));
|
|
str.format("%-.30s", (const char*) descr);
|
|
record.overwrite(str,15); //Descrizione sottoconto
|
|
|
|
int tipospric = _tpcon->get_int(PCN_TIPOSPRIC);
|
|
str.format("%d", tipospric);
|
|
record.overwrite(str,45); //Tipo costo/ricavo
|
|
|
|
int ricser = _tpcon->get_int(PCN_RICSER);
|
|
if (ricser == 0)
|
|
str = " ";
|
|
else
|
|
str.format("%d", ricser);
|
|
record.overwrite(str,46); //Tipo attivita'
|
|
|
|
// Classe IV direttiva CEE
|
|
|
|
TString sez = _tpcon->get(PCN_SEZIVD);
|
|
if (sez == "0")
|
|
sez = " ";
|
|
record.overwrite(sez,47); //Sezione IV dir
|
|
|
|
TString let = _tpcon->get(PCN_LETTIVD);
|
|
record.overwrite(let,48); //Lettera IV dir
|
|
|
|
int numrom = atoi(_tpcon->get(PCN_NUMRIVD));
|
|
str.format("%03d", numrom);
|
|
record.overwrite(str,59); //Numero arabo corrispondente al numero romano
|
|
TString numr = itor(numrom);
|
|
str.format("%-8s", (const char*) numr);
|
|
record.overwrite(str,49); //Numero romano IV dir
|
|
|
|
const TString num = _tpcon->get(PCN_NUMIVD).left(2);
|
|
record.overwrite(num, 57); //Numero arabo IV dir
|
|
|
|
// Classe IV direttiva CEE di segno opposto
|
|
|
|
TString sezop = _tpcon->get(PCN_SEZIVDOPP);
|
|
if (sezop == "0")
|
|
sezop = " ";
|
|
record.overwrite(sezop,62); //Sezione IV dir
|
|
|
|
TString letop = _tpcon->get(PCN_LETTIVDOPP);
|
|
record.overwrite(letop,63); //Lettera IV dir
|
|
|
|
int numromop = atoi(_tpcon->get(PCN_NUMRIVDOPP));
|
|
str.format("%03d", numromop);
|
|
record.overwrite(str,74); //Numero arabo corrispondente al numero romano
|
|
TString numrop = itor(numromop);
|
|
str.format("%-8s", (const char*) numrop);
|
|
record.overwrite(str,64); //Numero romano IV dir
|
|
|
|
const TString numop = _tpcon->get(PCN_NUMIVDOPP).left(2);
|
|
record.overwrite(numop, 72); //Numero arabo IV dir
|
|
|
|
int ivacomp = atoi(_tpcon->get(PCN_IVACOMP));
|
|
str.format("%02d",ivacomp);
|
|
record.overwrite(str,89); // Codice IVA di compensazione
|
|
}
|
|
|
|
_numrec_pcon++;
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
delete _prog;
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TInv_cont::testata_mov_PN()
|
|
{
|
|
_annoes = _tmov->get_int (MOV_ANNOES);
|
|
_datareg = _tmov->get_date(MOV_DATAREG);
|
|
_datadoc = _tmov->get_date(MOV_DATADOC);
|
|
_numdoc = _tmov->get (MOV_NUMDOC);
|
|
_reg = _tmov->get (MOV_REG);
|
|
_codcausm = _tmov->get (MOV_CODCAUS);
|
|
_codpag = _tmov->get (MOV_CODPAG);
|
|
// _tipodoc = _tmov->get (MOV_TIPODOC);
|
|
_protiva = _tmov->get_long(MOV_PROTIVA);
|
|
_uprotiva = _tmov->get_long(MOV_UPROTIVA);
|
|
_inviato = _tmov->get_bool(MOV_INVIATO);
|
|
_provvis = _tmov->get_char(MOV_PROVVIS);
|
|
}
|
|
|
|
void TInv_cont::testata_trasfer(long nreg, int nrig, TString& record)
|
|
{
|
|
TString str;
|
|
|
|
record.overwrite("Z1",0); //Tipo record
|
|
|
|
str.format("%06ld", nreg);
|
|
record.overwrite(str,2); //Numero di registrazione
|
|
|
|
str.format("%02d", nrig);
|
|
record.overwrite(str,8); //Numero di riga
|
|
|
|
TString datastr = _datareg.string();
|
|
str = riconverti_data(datastr,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,15); //Data di registrazione
|
|
|
|
//Determino il segnalino della competenza
|
|
int segnalino;
|
|
|
|
int anno = date2esc(_datareg);
|
|
if (_annoes == anno)
|
|
segnalino = 0;
|
|
else
|
|
segnalino = 1;
|
|
str.format("%d", segnalino);
|
|
record.overwrite(str,21); //Segnalino della competenza
|
|
|
|
TString datadocstr = _datadoc.string();
|
|
str = riconverti_data(datadocstr,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,22); //Data documento
|
|
|
|
str.format("%-7s", (const char*) _numdoc);
|
|
record.overwrite(str,28);
|
|
|
|
TString reg;
|
|
if (real::is_natural(_reg))
|
|
{
|
|
int app = atoi(_reg);
|
|
reg.format("%d", app);
|
|
}
|
|
else
|
|
reg = _reg.trim();
|
|
|
|
record.overwrite(reg,35); //Codice registro IVA
|
|
|
|
str.format("%05ld", _protiva);
|
|
record.overwrite(str,36); //Numero protocollo IVA
|
|
|
|
const char* cod_causm = (const char*)_codcausm;
|
|
str.format("%03s", (const char*)_codcausm);
|
|
record.overwrite(str,41); //Codice causale
|
|
|
|
str.format("%-2s", (const char*) _codpag);
|
|
record.overwrite(str,95); //Codice di pagamento
|
|
|
|
str.format("%05ld", _uprotiva);
|
|
record.overwrite(str,108); //Ultimo numero di protocollo IVA
|
|
|
|
record.overwrite("0",218); //Flag di solo sezionale
|
|
}
|
|
|
|
void TInv_cont::sola_iva(TString& record, long nreg)
|
|
{
|
|
int gruppo = 0;
|
|
int conto = 0;
|
|
long sottoc = 0;
|
|
|
|
const TString4 tipodoc = cache().get(LF_CAUSALI, _codcausm, CAU_TIPODOC);
|
|
|
|
const TRectype& tabtpd = cache().get("%TPD", tipodoc);
|
|
const bool cor = tabtpd.get_bool("B0");
|
|
|
|
if (!cor)
|
|
{
|
|
TLocalisamfile rcaus (LF_RCAUSALI);
|
|
rcaus.put(RCA_CODCAUS, _codcausm);
|
|
rcaus.read();
|
|
|
|
const TString& codcau = rcaus.get(RCA_CODCAUS);
|
|
if (codcau == _codcausm)
|
|
{
|
|
gruppo = rcaus.get_int (RCA_GRUPPO);
|
|
conto = rcaus.get_int (RCA_CONTO);
|
|
sottoc = _tmov->get_long(MOV_CODCF);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TLocalisamfile riva (LF_RMOVIVA);
|
|
riva.put(RMI_NUMREG, nreg);
|
|
riva.read();
|
|
long nr = riva.get_long(RMI_NUMREG);
|
|
if (nreg == nr)
|
|
{
|
|
gruppo = riva.get_int (RMI_GRUPPO);
|
|
conto = riva.get_int (RMI_CONTO);
|
|
sottoc = riva.get_long(RMI_SOTTOCONTO);
|
|
}
|
|
}
|
|
|
|
TString8 str;
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,74); //Gruppo di partita
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,76); //Conto di partita
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,78); //Sottoconto di partita
|
|
|
|
record.overwrite("0000000000",85); //Sottoconto di contropartita
|
|
|
|
record.overwrite("00000000000",97); //Importo
|
|
}
|
|
|
|
bool TInv_cont::invio_mov_PN()
|
|
{
|
|
const int size = 256;
|
|
TString record(size),head_descr;
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
long cicli = _tmov->items();
|
|
_prog = new TProgind(cicli,"Movimenti di Prima nota: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
TString80 str;
|
|
for (_tmov->first(); !_tmov->eof(); _tmov->next())
|
|
{
|
|
_prog->addstatus(1);
|
|
|
|
record.spaces();
|
|
|
|
long nreg = _tmov->get_long(RMV_NUMREG);
|
|
head_descr = _tmov->get(MOV_DESCR); // Descrizione di testata
|
|
|
|
testata_mov_PN();
|
|
|
|
_trmov->setkey(1);
|
|
_trmov->zero();
|
|
_trmov->put(RMV_NUMREG, nreg);
|
|
TRectype trmov(LF_RMOV);
|
|
trmov = _trmov->curr();
|
|
|
|
for (_trmov->read(); !_trmov->eof(); _trmov->next())
|
|
{
|
|
if (_trmov->curr() > trmov) break;
|
|
|
|
record = "";
|
|
record.spaces();
|
|
|
|
almeno_una_riga = TRUE;
|
|
|
|
int nrig = _trmov->get_int (RMV_NUMRIG);
|
|
|
|
testata_trasfer(nreg,nrig,record);
|
|
|
|
TString80 descr = _trmov->get(RMV_DESCR);
|
|
if (descr.empty())
|
|
descr = head_descr; // Se non esiste la descrizione della riga ci mette quella della testata
|
|
str.format("%-.30s", (const char*) descr);
|
|
record.overwrite(str,44); //Descrizione riga di movimento
|
|
|
|
int gruppo = _trmov->get_int(RMV_GRUPPO);
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,74); //Gruppo di partita
|
|
|
|
int conto = _trmov->get_int(RMV_CONTO);
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,76); //Conto di partita
|
|
|
|
long sottoc = _trmov->get_long(RMV_SOTTOCONTO);
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,78); //Sottoconto di partita
|
|
|
|
str = _trmov->get(RMV_SEZIONE);
|
|
record.overwrite(str,84); //Sezione importo
|
|
|
|
int gruppoc = _trmov->get_int(RMV_GRUPPOC);
|
|
str.format("%02d", gruppoc);
|
|
record.overwrite(str,85); //Gruppo di contropartita
|
|
|
|
int contoc = _trmov->get_int(RMV_CONTOC);
|
|
str.format("%02d", contoc);
|
|
record.overwrite(str,87); //Conto di contropartita
|
|
|
|
long sottocc = _trmov->get_long(RMV_SOTTOCONTOC);
|
|
str.format("%06ld", sottocc);
|
|
record.overwrite(str,89); //Sottoconto di contropartita
|
|
|
|
const real importo (_trmov->get_real(RMV_IMPORTO));
|
|
/*
|
|
TString numero = importo.string();
|
|
if (importo.sign() < 0)
|
|
negPC2negAS(numero);
|
|
str.format("%011s", (const char*) numero);
|
|
record.overwrite(str,97); //Importo riga di movimento
|
|
*/
|
|
write_AS_imp(importo, record, 97);
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
_numrec_pn++;
|
|
}
|
|
|
|
if (!almeno_una_riga)
|
|
{
|
|
int nrig = 1;
|
|
testata_trasfer(nreg,nrig,record);
|
|
sola_iva(record,nreg);
|
|
_numrec_pn++;
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
else
|
|
almeno_una_riga = FALSE;
|
|
}
|
|
delete _prog;
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TInv_cont::testata_mov_IVA(long numreg)
|
|
{
|
|
_tmov->setkey(1);
|
|
_tmov->zero();
|
|
_tmov->put(MOV_NUMREG, numreg);
|
|
const bool ok = _tmov->read() == NOERR;
|
|
if (ok)
|
|
{
|
|
_codcf = _tmov->get_long(MOV_CODCF);
|
|
_data74ter = _tmov->get_date(MOV_DATA74TER);
|
|
_corrlire = _tmov->get_real(MOV_CORRLIRE);
|
|
_codvali = _tmov->get (MOV_CODVALI);
|
|
_cambioi = _tmov->get_real(MOV_CAMBIOI);
|
|
_corrval = _tmov->get_real(MOV_CORRVALUTA);
|
|
_dataregiva = _tmov->get_date(MOV_DATAREG);
|
|
_inviato = _tmov->get_bool(MOV_INVIVA);
|
|
_tipodoc = _tmov->get (MOV_TIPODOC);
|
|
_provvis = _tmov->get_char(MOV_PROVVIS);
|
|
_ocfpi = _tmov->get (MOV_OCFPI);
|
|
if (_ocfpi.full())
|
|
cerca_occasionale();
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
void TInv_cont::cerca_occasionale()
|
|
{
|
|
_toccas->setkey(1);
|
|
_toccas->zero();
|
|
_toccas->put(OCC_CFPI, _ocfpi);
|
|
if (_toccas->read() == NOERR)
|
|
{
|
|
_ragsococc = _toccas->get(OCC_RAGSOC);
|
|
_indocc = _toccas->get(OCC_INDIR);
|
|
_capocc = _toccas->get(OCC_CAP);
|
|
const TString8 com = _toccas->get(OCC_COM);
|
|
cerca_comune_occas(com);
|
|
}
|
|
else
|
|
{
|
|
_ragsococc = "";
|
|
_indocc = "";
|
|
_capocc = "";
|
|
_localocc = "";
|
|
_provocc = "";
|
|
}
|
|
}
|
|
|
|
void TInv_cont::cerca_comune_occas(const TString& com)
|
|
{
|
|
/*
|
|
TLocalisamfile comuni (LF_COMUNI);
|
|
|
|
comuni.setkey(1);
|
|
comuni.zero();
|
|
comuni.put(COM_COM, com);
|
|
if (comuni.read() == NOERR)
|
|
{
|
|
_localocc = comuni.get(COM_DENCOM);
|
|
_provocc = comuni.get(COM_PROVCOM);
|
|
}
|
|
*/
|
|
TString8 comkey; comkey << " |" << com;
|
|
const TRectype& comrec = cache().get(LF_COMUNI, comkey);
|
|
_localocc = comrec.get(COM_DENCOM);
|
|
_provocc = comrec.get(COM_PROVCOM);
|
|
}
|
|
|
|
// Invia a sistema un movimento IVA
|
|
bool TInv_cont::invio_mov_IVA()
|
|
{
|
|
const int size = 256;
|
|
TString256 record;
|
|
long nreg_p;
|
|
int numero_righe = 0;
|
|
|
|
nreg_p = -1;
|
|
|
|
const long cicli = _triva->items();
|
|
_prog = new TProgind(cicli,TR("Movimenti Iva: generazione file TRASFER per Sistema\nPrego attendere."),FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
TString str;
|
|
for (int err = _triva->first(); err == NOERR; err = _triva->next())
|
|
{
|
|
_prog->addstatus(1);
|
|
record.spaces();
|
|
|
|
long nreg = _triva->get_long(RMI_NUMREG);
|
|
int nrig = _triva->get_int (RMI_NUMRIG);
|
|
|
|
if (nreg != nreg_p)
|
|
{
|
|
numero_righe = 0;
|
|
if (!testata_mov_IVA(nreg))
|
|
return error_box("Rilevata riga mancante di testata: impossibile proseguire. /n Registrazione %07d Riga %03d",nreg,nrig);
|
|
}
|
|
|
|
record.overwrite("U1",0); //Tipo record
|
|
|
|
str.format("%06ld", nreg);
|
|
record.overwrite(str,2); //Numero di registrazione
|
|
|
|
str.format("%02d", nrig);
|
|
record.overwrite(str,8); //Numero di riga
|
|
|
|
nreg_p = nreg;
|
|
|
|
str.format("%06ld", _codcf);
|
|
record.overwrite(str,15); //Codice cliente/fornitore
|
|
|
|
real imponibile (_triva->get_real(RMI_IMPONIBILE));
|
|
if (_tipodoc == "NC" || _tipodoc == "ST")
|
|
imponibile = -imponibile;
|
|
/*
|
|
TString numero = imponibile.string();
|
|
if (imponibile.sign() < 0)
|
|
negPC2negAS(numero);
|
|
str.format("%011s", (const char*) numero);
|
|
record.overwrite(str,21); //Imponibile
|
|
*/
|
|
write_AS_imp(imponibile, record, 21);
|
|
|
|
const TString4 codiva = _triva->get(RMI_CODIVA);
|
|
str.format("%02s", (const char*) codiva);
|
|
record.overwrite(str,32); //Codice iva
|
|
|
|
real imposta (_triva->get_real(RMI_IMPOSTA));
|
|
if (_tipodoc == "NC" || _tipodoc == "ST")
|
|
imposta = -imposta;
|
|
/*
|
|
numero = imposta.string();
|
|
if (imposta.sign() < 0)
|
|
negPC2negAS(numero);
|
|
str.format("%09s", (const char*) numero);
|
|
record.overwrite(str,34); //Imposta
|
|
*/
|
|
write_AS_imp(imposta, record, 34, 9);
|
|
|
|
int tipocr = _triva->get_int(RMI_TIPOCR);
|
|
str.format("%01d", tipocr);
|
|
record.overwrite(str,43); //Tipo costo/ricavo
|
|
|
|
real percind;
|
|
const TRectype & mov = cache().get(LF_MOV, nreg);
|
|
const int tipodet = get_tipodet_from_rmi(_triva->curr(), mov, percind);
|
|
|
|
str.format("%01d", tipodet);
|
|
record.overwrite(str,44); //Tipo detraibilita'
|
|
|
|
int gruppo = _triva->get_int(RMI_GRUPPO);
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,45); //Gruppo
|
|
|
|
int conto = _triva->get_int(RMI_CONTO);
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,47); //Conto
|
|
|
|
long sottoc = _triva->get_long(RMI_SOTTOCONTO);
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,49); //Sottoconto
|
|
|
|
TString16 data74terstr = _data74ter.string();
|
|
str = riconverti_data(data74terstr,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,55); //Data per registri 74 TER
|
|
|
|
if (_ocfpi.not_empty())
|
|
{
|
|
str.format("%-.25s", (const char*) _ragsococc);
|
|
record.overwrite(str,61); //Ragione sociale cliente occasionale
|
|
|
|
str.format("%-.22s", (const char*) _indocc);
|
|
record.overwrite(str,86); //indirizzo cliente occasionale
|
|
|
|
str.format("%-.18s", (const char*) _localocc);
|
|
record.overwrite(str,108); //Localita cliente occasionale
|
|
|
|
str.format("%05s", (const char*) _capocc);
|
|
record.overwrite(str,126); //Codice avviamento postale cliente occasionale
|
|
|
|
str.format("%-.2s", (const char*) _provocc);
|
|
record.overwrite(str,131); //Provincia cliente occasionale
|
|
|
|
record.overwrite(_ocfpi, 199); //Codice occasionale alla pos 200 (aggiunta AGA)
|
|
}
|
|
|
|
const int tipoatt = _triva->get_int(RMI_TIPOATT);
|
|
str.format("%01d", tipoatt);
|
|
record.overwrite(str,133); //Tipo attivita'
|
|
|
|
const bool intra = _triva->get_bool(RMI_INTRA);
|
|
record.overwrite(intra ? "X" : " ",134); //Flag causale x acquisti intracomunitari
|
|
|
|
/*
|
|
TString corrlire = _corrlire.string();
|
|
if (_corrlire.sign() < 0)
|
|
negPC2negAS(corrlire);
|
|
str.format("%011s", (const char*) corrlire);
|
|
record.overwrite(str,135); //Corrispettivo in lire
|
|
*/
|
|
write_AS_imp(_corrlire, record, 135);
|
|
|
|
record.overwrite(_codvali,146); //Codice valuta
|
|
|
|
/* Cambio intra con 5 decimali */
|
|
dec2integer(_cambioi,100000L);
|
|
TString16 cambioi = _cambioi.string();
|
|
if (_cambioi.sign() < 0)
|
|
negPC2negAS(cambioi);
|
|
str.format("%011s", (const char*) cambioi);
|
|
record.overwrite(str,149); //Cambio
|
|
|
|
dec2integer(_corrval,1000);
|
|
TString16 corrval = _corrval.string();
|
|
if (_corrval.sign() < 0)
|
|
negPC2negAS(corrval);
|
|
str.format("%014s", (const char*) corrval);
|
|
record.overwrite(str,160); //Corrispettivo in valuta
|
|
|
|
const bool nota = _triva->curr().exist(RMI_NAVP) && _triva->get_bool(RMI_NAVP);
|
|
record.overwrite(nota ? "1" : " ", 177); //Nota variazione relativa anni precedenti
|
|
|
|
_tmov->setkey(1);
|
|
_tmov->put(MOV_NUMREG, nreg);
|
|
if (_tmov->read() == NOERR)
|
|
{
|
|
const int meseliq = _tmov->get_int(MOV_MESELIQ);
|
|
if (meseliq > 0)
|
|
{
|
|
str.format("%02d", meseliq);
|
|
record.overwrite(str, 174);
|
|
}
|
|
}
|
|
|
|
_numrec_iva++;
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
|
|
//iva_inviata(nreg);
|
|
}
|
|
delete _prog;
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int TInv_cont::nprogre_interno(long numreg, int numrig)
|
|
{
|
|
int riga = 1;
|
|
|
|
TString8 key; key.format("%06ld%02d", numreg, numrig);
|
|
|
|
if (!_riga_interna.is_key(key))
|
|
{
|
|
TString8 nr; nr.format("%d", riga);
|
|
_riga_interna.add(key,nr);
|
|
}
|
|
else
|
|
{
|
|
TString& token = (TString&)_riga_interna.find(key);
|
|
riga = atoi(token);
|
|
riga++;
|
|
token.format("%d", riga);
|
|
}
|
|
return riga;
|
|
}
|
|
|
|
long TInv_cont::crea_record_riferimento_PN()
|
|
{
|
|
const int size = 256;
|
|
TString256 record;
|
|
TString8 str;
|
|
|
|
_ultima_nreg++;
|
|
|
|
record.spaces();
|
|
|
|
record.overwrite("Z1",0); //Tipo record
|
|
|
|
str.format("%06ld", _ultima_nreg);
|
|
record.overwrite(str,2); //Numero di registrazione
|
|
|
|
str.format("%02d", 1);
|
|
record.overwrite(str,8); //Numero di riga
|
|
|
|
TString16 datareg (_tpart->get_date(PART_DATAREG));
|
|
str = riconverti_data(datareg,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,15); //Data di registrazione
|
|
|
|
TString datadoc (_tpart->get_date(PART_DATADOC));
|
|
str = riconverti_data(datareg,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,22); //Data documento
|
|
|
|
long ndoc = _tpart->get_long(PART_NUMDOC);
|
|
str.format("%7d", ndoc);
|
|
record.overwrite(str,28); //numero documento
|
|
|
|
int gruppo = _tpart->get_int (PART_GRUPPOCL);
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,74); //Gruppo di partita
|
|
|
|
int conto = _tpart->get_int (PART_CONTOCL);
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,76); //Conto di partita
|
|
|
|
long sottoc = _tpart->get_long(PART_SOTTOCONTO);
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,78); //Sottoconto di partita
|
|
|
|
record.overwrite("0000000000",85); //Sottoconto di contropartita
|
|
|
|
record.overwrite("00000000000",97); //Importo
|
|
|
|
str.format("%d", 1);
|
|
record.overwrite(str,218); //Flag solo sezionale (Presente solo saldaconto)
|
|
|
|
char tipocf = _tpart->get_char(PART_TIPOCF);
|
|
str.format("%c", tipocf);
|
|
record.overwrite(str,219); //Flag Cliente / Fornitore
|
|
|
|
TString4 codcaus (_tpart->get(PART_CODCAUS));
|
|
if (tipocf != ' ' && codcaus.empty())
|
|
codcaus = (TString&)_tab_cau[_tpart->get_int(PART_TIPOMOV)-1]; // Causale
|
|
str.format("%03s",(const char*)codcaus);
|
|
record.overwrite(str,41);
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
|
|
_numrec_pn++;
|
|
|
|
return _ultima_nreg;
|
|
}
|
|
|
|
// Invia un record partita a sistema
|
|
void TInv_cont::partita2trasfer(TString& record, bool crea_record_riferimento)
|
|
{
|
|
TString str;
|
|
|
|
record.spaces();
|
|
|
|
record.overwrite("B1",0); //Tipo record
|
|
|
|
long nreg = _tpart->get_long(PART_NREG);
|
|
int nrig = _tpart->get_int (PART_NUMRIG);
|
|
const bool extra = nreg == 0 && nrig == 0;
|
|
|
|
if (extra) //Se si tratta di extracontabile nreg = 0 e nrig = 0
|
|
{ //prendo come nreg l'ultimo che trovo sugli archivi + 1.
|
|
if (crea_record_riferimento) //Creo anche un record di riferimento nei mov di PN (Z1).
|
|
nreg = crea_record_riferimento_PN(); //In caso di abbuoni o diff.cambio o ritenute non e'
|
|
else //necessario creare ogni volta un record di riferimento e reperire
|
|
nreg = _ultima_nreg; //una nuova nreg, in quanto si puo' usare l'ultima nreg creata in occasione
|
|
nrig = 1; //del pagamento esploso prima. Quindi mi basta assegnare _ultima_nreg.
|
|
}
|
|
|
|
str.format("%06ld", nreg);
|
|
record.overwrite(str,2); //Numero di registrazione
|
|
|
|
str.format("%02d", nrig);
|
|
record.overwrite(str,8); //Numero di riga
|
|
|
|
int nriga = nprogre_interno(nreg,nrig);
|
|
str.format("%03d", nriga);
|
|
record.overwrite(str,10); //Numero progressivo all'interno della riga
|
|
|
|
char tipo = _tpart->get_char(PART_TIPOCF);
|
|
int tipoAS;
|
|
if (tipo == 'C')
|
|
tipoAS = 1;
|
|
else
|
|
if (tipo == 'F')
|
|
tipoAS = 2;
|
|
else
|
|
tipoAS = 3;
|
|
str.format("%d", tipoAS);
|
|
record.overwrite(str,15); //Tipo anagrafica
|
|
|
|
int gruppo = _tpart->get_int (PART_GRUPPO);
|
|
str.format("%02d", gruppo);
|
|
record.overwrite(str,16); //Gruppo anagrafica
|
|
|
|
int conto = _tpart->get_int (PART_CONTO);
|
|
str.format("%02d", conto);
|
|
record.overwrite(str,18); //Conto anagrafica
|
|
|
|
long sottoc = _tpart->get_long(PART_SOTTOCONTO);
|
|
str.format("%06ld", sottoc);
|
|
record.overwrite(str,20); //Cliente o fornitore
|
|
|
|
TString anno (format("%4d", _tpart->get_int(PART_ANNO)));
|
|
record.overwrite(anno.mid(2,2),26); //Anno partita
|
|
|
|
str.format("%-7s", (const char*) _tpart->get(PART_NUMPART));
|
|
record.overwrite(str,28); //Numero partita
|
|
|
|
int tipomov = _tpart->get_int (PART_TIPOMOV);
|
|
str.format("%d", tipomov);
|
|
record.overwrite(str,37); //Tipo movimento
|
|
|
|
TString datareg (_tpart->get_date(PART_DATAREG));
|
|
str = riconverti_data(datareg,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,38); //Data di registrazione
|
|
|
|
TString datadoc (_tpart->get_date(PART_DATADOC));
|
|
str = riconverti_data(datadoc,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,44); //Data documento
|
|
|
|
TString numdoc (_tpart->get(PART_NUMDOC));
|
|
str.format("%-7s", (const char*) numdoc);
|
|
record.overwrite(str,50); //Numero documento
|
|
|
|
TString registro;
|
|
TString reg (_tpart->get(PART_REG));
|
|
if (real::is_natural(reg))
|
|
{
|
|
int app = atoi(reg);
|
|
registro.format("%d", app);
|
|
}
|
|
else
|
|
registro = reg.trim();
|
|
|
|
record.overwrite(registro,57); //Codice registro IVA
|
|
|
|
long protiva = _tpart->get_long(PART_PROTIVA);
|
|
str.format("%05ld", protiva);
|
|
record.overwrite(str,58); //Numero protocollo IVA
|
|
|
|
TString codcaus (_tpart->get(PART_CODCAUS));
|
|
if (extra && tipoAS < 3 && codcaus.empty())
|
|
codcaus = (TString&)_tab_cau[tipomov-1]; // Causale da tabella
|
|
str.format("%03s", (const char*)codcaus);
|
|
record.overwrite(str,63); //Codice causale
|
|
|
|
TString ws;
|
|
real importo (_tpart->get_real(PART_IMPTOTDOC));
|
|
/*
|
|
ws = importo.string();
|
|
if (importo.sign() < 0)
|
|
negPC2negAS(ws);
|
|
str.format("%011s", (const char*) ws);
|
|
record.overwrite(str,68); //Importo in lire tot documento
|
|
*/
|
|
write_AS_imp(importo, record, 68);
|
|
|
|
|
|
_codval = _tpart->get(PART_CODVAL);
|
|
str.format("%-3s", (const char*) _codval);
|
|
record.overwrite(str,79); //Codice valuta
|
|
|
|
real importoval (_tpart->get_real(PART_IMPTOTVAL));
|
|
if (importoval == ZERO && nreg != 0 && _codval.not_empty()) // se non lo trova lo cerca nei movimenti
|
|
{
|
|
_tmov->put(MOV_NUMREG,nreg);
|
|
if (_tmov->read() == NOERR) importoval = _tmov->get_real(MOV_TOTDOCVAL);
|
|
}
|
|
dec2integer(importoval,1000);
|
|
ws = importoval.string();
|
|
if (importoval.sign() < 0)
|
|
negPC2negAS(ws);
|
|
str.format("%013s", (const char*) ws);
|
|
record.overwrite(str,82); //Importo in valuta tot documento
|
|
|
|
/* Vecchio modo a 5 decimali
|
|
_cambio = _tpart->get_real(PART_CAMBIO);
|
|
dec2integer(_cambio,100000L);
|
|
TString80 cambioi = _cambio.string();
|
|
if (_cambio.sign() < 0)
|
|
negPC2negAS(cambioi);
|
|
str.format("%011s", (const char*) cambioi);
|
|
record.overwrite(str,95); //Cambio
|
|
*/
|
|
// Nuovo modo a 6 decimali
|
|
_cambio = _tpart->get_real(PART_CAMBIO);
|
|
dec2integer(_cambio,1000000L);
|
|
TString80 cambioi = _cambio.string();
|
|
if (_cambio.sign() < 0)
|
|
negPC2negAS(cambioi);
|
|
str.format("%011s", (const char*) cambioi);
|
|
record.overwrite(str,95); // Cambio
|
|
record.overwrite("6",160); // 6 decimali per cambio
|
|
|
|
TString16 datacam (_tpart->get_date(PART_DATACAM));
|
|
str = riconverti_data(datacam,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,106); //Data cambio
|
|
|
|
if (tipomov != 1)
|
|
{
|
|
if (tipomov == 2) // Note di credito sia contabili che extracontabili
|
|
{
|
|
str.format("%-2s", (const char*) _cpg_nc);
|
|
record.overwrite(str,112);
|
|
}
|
|
int tipopag = _tpart->get_int (PART_TIPOPAG);
|
|
str.format("%d", tipopag);
|
|
record.overwrite(str,114); //Tipo pagamento
|
|
|
|
TString datapag (_tpart->get_date(PART_DATAPAG));
|
|
str = riconverti_data(datapag,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,140); //Data pagamento
|
|
}
|
|
|
|
TString sez = _tpart->get(PART_SEZ);
|
|
str.format("%s", (const char*) sez);
|
|
record.overwrite(str,152); //Sezione partita
|
|
|
|
int gruppocl = _tpart->get_int (PART_GRUPPOCL);
|
|
str.format("%02d", gruppocl);
|
|
record.overwrite(str,168); //Gruppo cliente
|
|
|
|
int contocl = _tpart->get_int (PART_CONTOCL);
|
|
str.format("%02d", contocl);
|
|
record.overwrite(str,170); //Conto cliente
|
|
|
|
_numrec_sc++;
|
|
}
|
|
|
|
void TInv_cont::aggiorna_array_rate(char tipo,int g,int c,long s,int anno,
|
|
const TString& numpart, int rata)
|
|
{
|
|
TString key (format("%c%02d%02d%06ld%4d%-7s", tipo, g, c, s, anno, (const char*) numpart));
|
|
|
|
if (!_ultima_rata.is_key(key))
|
|
{
|
|
TString nr (format("%2d", rata));
|
|
_ultima_rata.add(key,nr);
|
|
}
|
|
else
|
|
{
|
|
TString& token = (TString&)_ultima_rata.find(key);
|
|
int nr = atoi(token);
|
|
if (rata > nr)
|
|
token.format("%2d", rata);
|
|
}
|
|
}
|
|
|
|
int TInv_cont::ultima_rata_partita(char tipo,int g,int c,long s,
|
|
int anno, const TString& numpart)
|
|
{
|
|
int rata = 1;
|
|
TString80 key;
|
|
key.format("%c%02d%02d%06ld%4d%-7s", tipo, g, c, s, anno, (const char*)numpart);
|
|
|
|
if (!_ultima_rata.is_key(key))
|
|
{
|
|
TString4 nr; nr.format("%2d", rata);
|
|
_ultima_rata.add(key,nr);
|
|
}
|
|
else
|
|
{
|
|
TString& token = (TString&)_ultima_rata.find(key);
|
|
rata = atoi(token);
|
|
rata++;
|
|
token.format("%2d", rata);
|
|
}
|
|
|
|
return rata;
|
|
}
|
|
|
|
void TInv_cont::pagsca2trasfer(TString& record,real& importo,real& importoval)
|
|
{
|
|
TString str;
|
|
int size = 256;
|
|
|
|
char tipo = _tpagsca->get_char(PAGSCA_TIPOC);
|
|
int g = _tpagsca->get_int (PAGSCA_GRUPPO);
|
|
int c = _tpagsca->get_int (PAGSCA_CONTO);
|
|
long s = _tpagsca->get_long(PAGSCA_SOTTOCONTO);
|
|
int anno = _tpagsca->get_int (PAGSCA_ANNO);
|
|
TString numpart = _tpagsca->get (PAGSCA_NUMPART);
|
|
int nriga = _tpagsca->get_int (PAGSCA_NRIGA);
|
|
int nrata = _tpagsca->get_int (PAGSCA_NRATA);
|
|
|
|
if (nriga == 9999 && nrata == 9999)
|
|
nrata = ultima_rata_partita(tipo,g,c,s,anno,numpart);
|
|
|
|
str.format("%02d", nrata);
|
|
record.overwrite(str,35); //Numero di rata
|
|
|
|
/*
|
|
TString numero = importo.string();
|
|
if (importo.sign() < 0)
|
|
negPC2negAS(numero);
|
|
str.format("%011s", (const char*) numero);
|
|
record.overwrite(str,116); //Importo in lire pagamento
|
|
*/
|
|
write_AS_imp(importo, record, 116);
|
|
|
|
dec2integer(importoval,1000);
|
|
/*
|
|
TString impvalstr = importoval.string();
|
|
if (importoval.sign() < 0)
|
|
negPC2negAS(impvalstr);
|
|
str.format("%013s", (const char*) impvalstr);
|
|
record.overwrite(str,127); //Importo in valuta pagamento
|
|
*/
|
|
write_AS_imp(importoval, record, 127, 13);
|
|
|
|
TString codag (_tpagsca->get(PAGSCA_CODAG));
|
|
str.format("%-6s", (const char*) codag);
|
|
record.overwrite(str,172); //Codice agente
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
|
|
bool TInv_cont::invio_mov_SC()
|
|
{
|
|
int size = 256;
|
|
TString record(size);
|
|
bool almeno_una_riga = FALSE;
|
|
|
|
_tmov->last();
|
|
_ultima_nreg = _tmov->get_long(MOV_NUMREG);
|
|
|
|
_riga_interna.restart(); // Azzero l'array dove tengo lo storico del numero progressivo all'interno della riga.
|
|
_ultima_rata.restart(); // Azzero l'array dove tengo lo storico delle rate di una partita (serve per
|
|
// assegnare un numero di rata ai pagamenti non assegnati).
|
|
long cicli = _tpart->items();
|
|
_prog = new TProgind(cicli,"Movimenti di Saldaconto: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
|
|
|
|
_tras_file.open(_trasf,TRUE);
|
|
|
|
for (_tpart->first(); !_tpart->eof(); _tpart->next())
|
|
{
|
|
TString str;
|
|
|
|
_prog->addstatus(1);
|
|
|
|
char tipo = _tpart->get_char(PART_TIPOCF);
|
|
int gruppo = _tpart->get_int (PART_GRUPPO);
|
|
int conto = _tpart->get_int (PART_CONTO);
|
|
long sottoc = _tpart->get_long(PART_SOTTOCONTO);
|
|
int anno = _tpart->get_int (PART_ANNO);
|
|
TString numpart = _tpart->get (PART_NUMPART);
|
|
int nriga = _tpart->get_int (PART_NRIGA);
|
|
int tipomov = _tpart->get_int (PART_TIPOMOV);
|
|
|
|
if (tipo == 'C' || tipo == 'F')
|
|
{
|
|
if (tipomov == 1)
|
|
{
|
|
_tscad->zero();
|
|
_tscad->put(SCAD_TIPOCF, tipo);
|
|
if (gruppo != 0)
|
|
_tscad->put(SCAD_GRUPPO, gruppo);
|
|
if (conto != 0)
|
|
_tscad->put(SCAD_CONTO, conto);
|
|
if (sottoc != 0)
|
|
_tscad->put(SCAD_SOTTOCONTO, sottoc);
|
|
_tscad->put(SCAD_ANNO, anno);
|
|
_tscad->put(SCAD_NUMPART, numpart);
|
|
_tscad->put(SCAD_NRIGA, nriga);
|
|
|
|
TRectype scad (_tscad->curr());
|
|
|
|
TString rec,file,str,codpag,ultclass,datascad,numero,codag,impvalstr,numpart;
|
|
|
|
for (_tscad->read(_isgteq); !_tscad->eof(); _tscad->next())
|
|
{
|
|
rec = scad.get(SCAD_NUMPART);
|
|
file = _tscad->get(SCAD_NUMPART);
|
|
|
|
if (_tscad->curr() != scad || file != rec) break;
|
|
|
|
partita2trasfer(record);
|
|
|
|
int nrata = _tscad->get_int(SCAD_NRATA);
|
|
str.format("%02d", nrata);
|
|
record.overwrite(str,35); //Numero di rata
|
|
|
|
char tipo = _tscad->get_char(SCAD_TIPOCF);
|
|
int g = _tscad->get_int (SCAD_GRUPPO);
|
|
int c = _tscad->get_int (SCAD_CONTO);
|
|
long s = _tscad->get_long(SCAD_SOTTOCONTO);
|
|
int anno = _tscad->get_int (SCAD_ANNO);
|
|
numpart = _tscad->get(SCAD_NUMPART);
|
|
aggiorna_array_rate(tipo,g,c,s,anno,numpart,nrata);
|
|
|
|
codpag = _tscad->get(SCAD_CODPAG);
|
|
str.format("%-2s", (const char*) codpag);
|
|
record.overwrite(str,112); //Codice di pagamento
|
|
|
|
int tipopag = _tscad->get_int(SCAD_TIPOPAG);
|
|
str.format("%d", tipopag);
|
|
record.overwrite(str,114); //Tipo pagamento
|
|
|
|
ultclass = _tscad->get(SCAD_ULTCLASS);
|
|
str.format("%s", (const char*) ultclass);
|
|
record.overwrite(str,115); //Ulteriore classificazione
|
|
|
|
real importo (_tscad->get_real(SCAD_IMPORTO));
|
|
/*
|
|
numero = importo.string();
|
|
if (importo.sign() < 0)
|
|
negPC2negAS(numero);
|
|
str.format("%011s", (const char*) numero);
|
|
record.overwrite(str,116); //Importo in lire rata partita
|
|
*/
|
|
write_AS_imp(importo, record, 116);
|
|
|
|
real importoval (_tscad->get_real(SCAD_IMPORTOVAL));
|
|
dec2integer(importoval,1000);
|
|
/*
|
|
impvalstr = importoval.string();
|
|
if (importoval.sign() < 0)
|
|
negPC2negAS(impvalstr);
|
|
str.format("%013s", (const char*) impvalstr);
|
|
record.overwrite(str,127); //Importo in valuta rata partita
|
|
*/
|
|
write_AS_imp(importoval, record, 127, 13);
|
|
|
|
|
|
datascad = _tscad->get_date(SCAD_DATASCAD);
|
|
str = riconverti_data(datascad,FALSE);
|
|
str.format("%06s", (const char*) str);
|
|
record.overwrite(str,140); //Data scadenza
|
|
|
|
codag = _tscad->get(SCAD_CODAG);
|
|
str.format("%-6s", (const char*) codag);
|
|
record.overwrite(str,172); //Codice agente
|
|
|
|
_tras_file.write_control_rec(record,size);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_tpagsca->zero();
|
|
_tpagsca->put(PAGSCA_TIPOC, tipo);
|
|
if (gruppo != 0)
|
|
_tpagsca->put(PAGSCA_GRUPPO, gruppo);
|
|
if (conto != 0)
|
|
_tpagsca->put(PAGSCA_CONTO, conto);
|
|
if (sottoc != 0)
|
|
_tpagsca->put(PAGSCA_SOTTOCONTO, sottoc);
|
|
_tpagsca->put(PAGSCA_ANNO, anno);
|
|
_tpagsca->put(PAGSCA_NUMPART, numpart);
|
|
|
|
TRectype pagsca (_tpagsca->curr());
|
|
|
|
TString str,rec,file;
|
|
|
|
for (_tpagsca->read(_isgteq); !_tpagsca->eof(); _tpagsca->next())
|
|
{
|
|
int nrigp = _tpagsca->get_int(PAGSCA_NRIGP);
|
|
|
|
rec = pagsca.get(PAGSCA_NUMPART);
|
|
file = _tpagsca->get(PAGSCA_NUMPART);
|
|
|
|
if (_tpagsca->curr() != pagsca || file != rec) break;
|
|
|
|
if (nriga != nrigp) continue;
|
|
|
|
partita2trasfer(record);
|
|
|
|
real importo (_tpagsca->get_real(PAGSCA_IMPORTO));
|
|
real importoval (_tpagsca->get_real(PAGSCA_IMPORTOVAL));
|
|
pagsca2trasfer(record,importo,importoval);
|
|
|
|
real abbuoni (_tpagsca->get_real(PAGSCA_ABBUONI));
|
|
if (abbuoni != ZERO)
|
|
{
|
|
char sezabb;
|
|
char passat = _tpagsca->get_char(PAGSCA_PASSATT);
|
|
char sez = _tpart->get_char(PART_SEZ);
|
|
if (passat == 'A')
|
|
sezabb = 'D';
|
|
else
|
|
if (passat == 'P')
|
|
sezabb = 'A';
|
|
if (sezabb != sez)
|
|
abbuoni = abbuoni * -1;
|
|
real abblire = ZERO;
|
|
partita2trasfer(record,FALSE);
|
|
if (_codval.not_empty())
|
|
{
|
|
abblire = abbuoni * _cambio;
|
|
abblire.round();
|
|
}
|
|
str.format("%d", 4);
|
|
record.overwrite(str,37);
|
|
str.format("%c", sezabb);
|
|
record.overwrite(str,152);
|
|
if (_codval.not_empty())
|
|
pagsca2trasfer(record,abblire,abbuoni);
|
|
else
|
|
pagsca2trasfer(record,abbuoni,abblire);
|
|
}
|
|
|
|
real diffcam (_tpagsca->get_real(PAGSCA_DIFFCAM));
|
|
if (diffcam != ZERO)
|
|
{
|
|
real imp = ZERO;
|
|
partita2trasfer(record,FALSE);
|
|
char sez = _tpart->get_char(PART_SEZ);
|
|
if (diffcam < ZERO)
|
|
{
|
|
diffcam = -diffcam;
|
|
sez = (sez == 'D') ? 'A' : 'D';
|
|
}
|
|
str.format("%d", 4);
|
|
record.overwrite(str,37);
|
|
str.format("%c", sez);
|
|
record.overwrite(str,152);
|
|
pagsca2trasfer(record,diffcam,imp);
|
|
}
|
|
|
|
real ritenute (_tpagsca->get_real(PAGSCA_RITENUTE));
|
|
if (ritenute != ZERO)
|
|
{
|
|
real imp = ZERO;
|
|
partita2trasfer(record,FALSE);
|
|
pagsca2trasfer(record,ritenute,imp);
|
|
}
|
|
real ritsoc (_tpagsca->get_real(PAGSCA_RITSOC));
|
|
if (ritsoc != ZERO)
|
|
{
|
|
real imp = ZERO;
|
|
partita2trasfer(record,FALSE);
|
|
pagsca2trasfer(record,ritsoc,imp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
delete _prog;
|
|
|
|
_riga_interna.destroy();
|
|
_ultima_rata.destroy();
|
|
|
|
_tras_file.close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TInv_cont::negPC2negAS(TString& numero)
|
|
{
|
|
numero.trim();
|
|
numero.ltrim(1); // Considero il numero senza il segno -
|
|
|
|
const int cifra = atoi(numero.right(1)); // Considero l'ultima cifra
|
|
|
|
char carattere = _tabella[cifra];
|
|
|
|
numero.rtrim(1); // Considero il numero senza l'ultima cifra
|
|
numero << carattere;
|
|
}
|
|
|
|
void TInv_cont::dec2integer(real& val, long dec)
|
|
{
|
|
val *= dec;
|
|
val.round();
|
|
}
|
|
|
|
void TInv_cont::write_AS_imp(const real& importo, TString& record, int pos, int len)
|
|
{
|
|
TString16 numero;
|
|
|
|
// const int dec = TCurrency::get_firm_dec();
|
|
// numero = importo.string(0, dec);
|
|
const TCurrency imp(importo); // Proviamo se e' meglio
|
|
numero = imp.string(true);
|
|
numero.strip(".,");
|
|
|
|
if (numero[0] == '-')
|
|
negPC2negAS(numero);
|
|
numero.right_just(len, '0');
|
|
record.overwrite(numero, pos);
|
|
} |