Aggiornamento invio PayLine
Prima versione importazione Visual Gala git-svn-id: svn://10.65.10.50/branches/R_10_00@22780 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f0ab065f43
commit
b8a406bf7e
@ -7,8 +7,9 @@ int main(int argc, char** argv)
|
||||
const int op = argc < 2 ? 0 : argv[1][1]-'0';
|
||||
switch (op)
|
||||
{
|
||||
case 1: tc8200(argc,argv); break;
|
||||
default: tc8100(argc,argv); break; // importazione da Semetra
|
||||
case 1: tc8200(argc,argv); break; // esportazione PayLine
|
||||
case 2: tc8300(argc,argv); break; // importazione VisualGala
|
||||
default: tc8100(argc,argv); break; // importazione da Semetra
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
1
tc/tc8.h
1
tc/tc8.h
@ -3,6 +3,7 @@
|
||||
|
||||
int tc8100(int argc, char** argv);
|
||||
int tc8200(int argc, char** argv);
|
||||
int tc8300(int argc, char** argv);
|
||||
|
||||
#endif // __TC8_H
|
||||
|
||||
|
302
tc/tc8200.cpp
302
tc/tc8200.cpp
@ -11,6 +11,7 @@
|
||||
#include <utility.h>
|
||||
|
||||
#include "tc8.h"
|
||||
#include "../cg/cgsaldac.h"
|
||||
|
||||
#include <clifo.h>
|
||||
#include <partite.h>
|
||||
@ -54,15 +55,20 @@ class TPayLine_app : public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
virtual bool create();
|
||||
virtual const char* extra_modules() { return "cg"; }
|
||||
virtual const char* extra_modules() const { return "cg"; }
|
||||
virtual void main_loop();
|
||||
|
||||
public:
|
||||
bool find_clifo(long codcf, TPayLine_recset& clienti) const;
|
||||
long export_clifo(long codcf, TPayLine_recset& clienti, TLog_report& log) const;
|
||||
bool esporta_pagsca(const TRectype& pag, const TRectype& scad, bool unico,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti,
|
||||
bool esporta_pagsca(const TRiga_partite& part, const TRiga_scadenze* scad, const TRectype& pag,
|
||||
const TDate& dal, const TDate& al, TPayLine_recset& clienti, TPayLine_recset& movimenti,
|
||||
TLog_report& log) const;
|
||||
bool esporta_scad(const TRiga_scadenze& scad,
|
||||
const TDate& dal, const TDate& al,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti, TLog_report& log) const;
|
||||
void esporta_partita(long lastcf, int lastyear, const TString& lastpart, const TDate& dal, const TDate& al,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti, TLog_report& log) const;
|
||||
bool esporta(const TString& dir, const TString& ftp, const TDate& dt, TLog_report& log) const;
|
||||
bool ftp_send(const TFilename& filename, const TString& ftp) const;
|
||||
};
|
||||
@ -111,17 +117,18 @@ long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_repor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alleg >= 2 && alleg != 7)
|
||||
|
||||
bool good = false;
|
||||
switch (alleg)
|
||||
{
|
||||
case 2: msg << TR("OCCASIONALE"); break;
|
||||
case 5:
|
||||
case 6: msg << TR("PRIVATO"); break;
|
||||
case 9: msg << TR("ESTERO"); break;
|
||||
default: good = true; break;
|
||||
}
|
||||
if (!good)
|
||||
{
|
||||
switch (alleg)
|
||||
{
|
||||
case 2: msg << "OCCASIONALE"; break;
|
||||
case 5:
|
||||
case 9: msg << "ESTERO"; break;
|
||||
case 6: msg << "PRIVATO"; break;
|
||||
default: msg << "Codice allegato " << alleg; break;
|
||||
}
|
||||
log.log(1, msg);
|
||||
return -2;
|
||||
}
|
||||
@ -129,7 +136,7 @@ long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_repor
|
||||
if (find_clifo(codcf, clienti))
|
||||
return codcf; // Already saved
|
||||
|
||||
TToken_string row(256, ';');
|
||||
TToken_string row(128, ';');
|
||||
|
||||
row.format("%6ld", codcf);
|
||||
|
||||
@ -172,12 +179,18 @@ long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_repor
|
||||
row.add(rec.get(CLI_COFI), 8); // C.F.
|
||||
}
|
||||
|
||||
if (alleg == 8)
|
||||
{
|
||||
row.add(TR("Fallimento"), 9); // Status legale
|
||||
row.add(TR("Bloccato"), 10); // Status bloccato
|
||||
}
|
||||
|
||||
clienti.new_rec(row);
|
||||
return codcf;
|
||||
}
|
||||
|
||||
bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, bool unico,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti,
|
||||
bool TPayLine_app::esporta_pagsca(const TRiga_partite& part, const TRiga_scadenze* scad, const TRectype& pag,
|
||||
const TDate& dal, const TDate& al, TPayLine_recset& clienti, TPayLine_recset& movimenti,
|
||||
TLog_report& log) const
|
||||
{
|
||||
const long codcf = pag.get_long(PAGSCA_SOTTOCONTO);
|
||||
@ -185,36 +198,23 @@ bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, boo
|
||||
if (lastcf <= 0)
|
||||
return false;
|
||||
|
||||
TToken_string key;
|
||||
key.format("C|0|0|%ld|%d|%s|%d",
|
||||
codcf, pag.get_int(PART_ANNO), (const char*)pag.get(PART_NUMPART),
|
||||
pag.get_int(PAGSCA_NRIGP));
|
||||
const TRectype part = cache().get(LF_PARTITE, key);
|
||||
if (part.empty())
|
||||
return false; // Can't be empty: orphan record!
|
||||
TDate data = part.get(PART_DATADOC); // Data Documento
|
||||
if (!data.ok())
|
||||
data = part.get_date(PART_DATAREG);
|
||||
if (data > al || data < dal && part.partita().chiusa())
|
||||
return false;
|
||||
|
||||
if (!scad.empty())
|
||||
key.format("C|0|0|%ld|%d|%s|%d",
|
||||
codcf, pag.get_int(PART_ANNO), (const char*)pag.get(PART_NUMPART),
|
||||
pag.get_int(PAGSCA_NRIGA));
|
||||
else
|
||||
key.cut(0);
|
||||
const TRectype fatt = cache().get(LF_PARTITE, key); // Can be empty: unassigned
|
||||
|
||||
TToken_string row(128, ';');
|
||||
TString str;
|
||||
row.format("%6ld", lastcf);
|
||||
|
||||
TDate data = part.get(PART_DATADOC); // Data Documento
|
||||
if (!data.ok())
|
||||
data = part.get_date(PART_DATAREG);
|
||||
str = data.stringa(); str.left_just(10);
|
||||
row.add(str, 1);
|
||||
|
||||
str = part.get(PART_NUMDOC); str.left_just(8);
|
||||
row.add(str, 2); // Numero Documento
|
||||
|
||||
if (fatt.empty())
|
||||
if (scad == NULL)
|
||||
{
|
||||
row.add(row.get(1), 3); // Data riferimento
|
||||
str = part.get(PART_NUMPART); str.left_just(8);
|
||||
@ -222,6 +222,7 @@ bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, boo
|
||||
}
|
||||
else
|
||||
{
|
||||
const TRiga_partite& fatt = scad->riga();
|
||||
data = fatt.get(PART_DATADOC); // Data riferimento
|
||||
if (!data.ok())
|
||||
data = fatt.get_date(PART_DATAREG);
|
||||
@ -238,16 +239,22 @@ bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, boo
|
||||
str = part.get(PART_NREG); str.right_just(7);
|
||||
row.add(str, 6); // Numero registrazione
|
||||
|
||||
str = scad.get(SCAD_DATASCAD); str.left_just(10);
|
||||
if (scad != NULL)
|
||||
{
|
||||
str = scad->get(SCAD_DATASCAD);
|
||||
str.left_just(10);
|
||||
}
|
||||
else
|
||||
str.spaces(10);
|
||||
row.add(str, 7); // Data scadenza
|
||||
|
||||
const int tm = part.get_int(PART_TIPOMOV);
|
||||
|
||||
real imp;
|
||||
if (tm == 3 && unico && scad.get_bool(SCAD_PAGATA))
|
||||
if (tm == 3 && scad != NULL && scad->chiusa() && scad->rows() == 1) // Pagamento su unica rata chiusa
|
||||
{
|
||||
// Caso semplice: una rata pagata completamene con un solo pagamento
|
||||
imp = scad.get_real(SCAD_IMPORTO); // Importo pagato = importo da pagare
|
||||
imp = scad->get_real(SCAD_IMPORTO); // Importo pagato = importo da pagare
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -288,6 +295,108 @@ bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, boo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TPayLine_app::esporta_scad(const TRiga_scadenze& scad, const TDate& dal, const TDate& al,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti, TLog_report& log) const
|
||||
{
|
||||
const TDate datascad = scad.get(SCAD_DATASCAD);
|
||||
if (datascad > al)
|
||||
return false;
|
||||
|
||||
const TRiga_partite& part = scad.riga();
|
||||
if (scad.get_bool(SCAD_PAGATA) || part.get_bool(PART_CHIUSA))
|
||||
{
|
||||
if (datascad < dal)
|
||||
return false; // Ignora vecchia partita chiusa
|
||||
}
|
||||
|
||||
TToken_string row(255, ';');
|
||||
row.format("%6ld", scad.get_long(SCAD_SOTTOCONTO)); // Codice cliente
|
||||
|
||||
TString str;
|
||||
str = part.get(PART_DATADOC); // Data Documento
|
||||
if (str.blank())
|
||||
str = part.get(PART_DATAREG);
|
||||
row.add(str, 1);
|
||||
|
||||
str = part.get(PART_NUMDOC); str.left_just(8);
|
||||
row.add(str, 2); // Numero Documento
|
||||
|
||||
row.add(row.get(1), 3); // Data riferimento
|
||||
str = part.get(PART_NUMPART); str.left_just(8);
|
||||
row.add(str, 4); // Numero riferimento
|
||||
|
||||
row.add(part.get(PART_DATAREG), 5); // Data registrazione
|
||||
|
||||
str = part.get(PART_NREG); str.right_just(7);
|
||||
row.add(str, 6); // Numero registrazione
|
||||
|
||||
row.add(datascad, 7); // Data scadenza
|
||||
|
||||
real importo = scad.get_real(SCAD_IMPORTO);
|
||||
str = part.get(PART_SEZ);
|
||||
if (importo < ZERO)
|
||||
{
|
||||
importo = -importo;
|
||||
str = str == "D" ? "A" : "D";
|
||||
}
|
||||
row.add(importo.stringa(10,2), 8); // Importo
|
||||
row.add(str, 9); // Dare/Avere
|
||||
|
||||
row.add(str[0] == 'A' ? "EF7#" : "EF1#", 10); // Causale Fattura o Nota credito
|
||||
|
||||
movimenti.new_rec(row);
|
||||
|
||||
for (int r = scad.last(); r > 0; r = scad.pred(r))
|
||||
esporta_pagsca(part, &scad, scad.row(r), dal, al, clienti, movimenti, log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPayLine_app::esporta_partita(long cf, int year, const TString& numpart,
|
||||
const TDate& dal, const TDate& al,
|
||||
TPayLine_recset& clienti, TPayLine_recset& movimenti, TLog_report& log) const
|
||||
{
|
||||
const TBill bill(0, 0, cf, 'C');
|
||||
TPartita game(bill, year, numpart);
|
||||
|
||||
if (cf == 1211 && atoi(numpart) == 69)
|
||||
int cazzone = 1;
|
||||
|
||||
const TRiga_scadenze* last_scad = NULL;
|
||||
for (int r = game.prima_fattura(); game.esiste(r); r = game.succ(r))
|
||||
{
|
||||
const TRiga_partite& riga = game.riga(r);
|
||||
for (int s = 1; s <= riga.rate(); s++)
|
||||
{
|
||||
const TRiga_scadenze& rata = riga.rata(s);
|
||||
if (esporta_scad(rata, dal, al, clienti, movimenti, log))
|
||||
last_scad = &rata;
|
||||
}
|
||||
}
|
||||
|
||||
const TRecord_array& nonass = game.unassigned();
|
||||
if (nonass.rows() > 0)
|
||||
{
|
||||
const bool game_over = game.chiusa();
|
||||
if (last_scad != NULL)
|
||||
{
|
||||
if (game_over && last_scad->get_date(SCAD_DATASCAD) < dal)
|
||||
return; // Ignora vecchie partite chiuse
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game_over)
|
||||
return; // Ignora vecchie partite chiuse
|
||||
}
|
||||
|
||||
for (int u = nonass.last_row(); u > 0; u = nonass.pred_row(u))
|
||||
{
|
||||
const TRiga_partite& part = game.riga(u);
|
||||
esporta_pagsca(part, NULL, nonass.row(u), dal, al, clienti, movimenti, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int sort_mov(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
const TToken_string& r1 = *(const TToken_string*)*o1;
|
||||
@ -382,116 +491,33 @@ bool TPayLine_app::esporta(const TString& dir, const TString& ftp,
|
||||
TPayLine_recset movimenti;
|
||||
|
||||
TString query;
|
||||
query << "USE SCAD "
|
||||
<< "\nJOIN PART INTO TIPOC==TIPOC SOTTOCONTO==SOTTOCONTO ANNO==ANNO NUMPART==NUMPART NRIGA==NRIGA"
|
||||
<< "\nFROM TIPOC=C\nTO TIPOC=C";
|
||||
query << "USE PART SELECT NRIGA<=2\nFROM TIPOC=C\nTO TIPOC=C";
|
||||
|
||||
TISAM_recordset mov(query);
|
||||
if (mov.items() > 0)
|
||||
TISAM_recordset saldaconto(query);
|
||||
if (saldaconto.items() > 0)
|
||||
{
|
||||
const TRectype& scad = mov.cursor()->curr();
|
||||
const TRectype& part = mov.cursor()->curr(LF_PARTITE);
|
||||
long lastcf = 0;
|
||||
TToken_string row(256, ';');
|
||||
TString str;
|
||||
long last_cf = 0;
|
||||
int last_anno = 0;
|
||||
TString8 last_part;
|
||||
|
||||
str = log.title();
|
||||
str << '\n' << TR("Scadenze e pagamenti associati");
|
||||
const TRectype& part = saldaconto.cursor()->curr();
|
||||
|
||||
TProgind pi(mov.items(), str);
|
||||
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
||||
TProgind pi(saldaconto.items(), title());
|
||||
for (bool ok = saldaconto.move_first(); ok; ok = saldaconto.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
const TDate datascad = scad.get(SCAD_DATASCAD);
|
||||
if (datascad > al)
|
||||
continue;
|
||||
if (scad.get_bool(SCAD_PAGATA) || part.get_bool(PART_CHIUSA))
|
||||
const long codcf = part.get_long(SCAD_SOTTOCONTO);
|
||||
const int year = part.get_int(SCAD_ANNO);
|
||||
const TString8 numpart = part.get(SCAD_NUMPART);
|
||||
if (codcf != last_cf || year != last_anno || numpart != last_part)
|
||||
{
|
||||
if (datascad < dal)
|
||||
continue; // Ignora vecchia partita chiusa
|
||||
esporta_partita(codcf, year, numpart, dal, al, clienti, movimenti, log);
|
||||
last_cf = codcf;
|
||||
last_anno = year;
|
||||
last_part = numpart;
|
||||
}
|
||||
|
||||
const long codcf = scad.get_long(SCAD_SOTTOCONTO);
|
||||
if (codcf != lastcf)
|
||||
{
|
||||
lastcf = export_clifo(codcf, clienti, log);
|
||||
if (lastcf <= 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
row.format("%6d", lastcf); // Codice cliente
|
||||
|
||||
str = part.get(PART_DATADOC); // Data Documento
|
||||
if (str.blank())
|
||||
str = part.get(PART_DATAREG);
|
||||
row.add(str, 1);
|
||||
|
||||
str = part.get(PART_NUMDOC); str.left_just(8);
|
||||
row.add(str, 2); // Numero Documento
|
||||
|
||||
row.add(row.get(1), 3); // Data riferimento
|
||||
str = part.get(PART_NUMPART); str.left_just(8);
|
||||
row.add(str, 4); // Numero riferimento
|
||||
|
||||
row.add(part.get(PART_DATAREG), 5); // Data registrazione
|
||||
|
||||
str = part.get(PART_NREG); str.right_just(7);
|
||||
row.add(str, 6); // Numero registrazione
|
||||
|
||||
row.add(datascad, 7); // Data scadenza
|
||||
|
||||
real importo = scad.get_real(SCAD_IMPORTO);
|
||||
str = part.get(PART_SEZ);
|
||||
if (importo < ZERO)
|
||||
{
|
||||
importo = -importo;
|
||||
str = str == "D" ? "A" : "D";
|
||||
}
|
||||
row.add(importo.stringa(10,2), 8); // Importo
|
||||
row.add(str, 9); // Dare/Avere
|
||||
|
||||
row.add(str[0] == 'A' ? "EF7#" : "EF1#", 10); // Causale Fattura o Nota credito
|
||||
|
||||
movimenti.new_rec(row);
|
||||
|
||||
TToken_string key;
|
||||
key.format("C|0|0|%ld|%d|%s|%d|%d",
|
||||
lastcf, part.get_int(PART_ANNO), (const char*)part.get(PART_NUMPART),
|
||||
scad.get_int(SCAD_NRIGA), scad.get_int(SCAD_NRATA));
|
||||
TRecord_array pagsca(key, LF_PAGSCA);
|
||||
const bool unico = pagsca.rows() == 1;
|
||||
for (int r = pagsca.first_row(); r > 0 && r <= pagsca.last_row(); r = pagsca.succ_row(r))
|
||||
esporta_pagsca(pagsca.row(r), scad, unico, clienti, movimenti, log);
|
||||
}
|
||||
}
|
||||
|
||||
query.cut(0);
|
||||
query << "USE PAGSCA SELECT NRIGA=9999"
|
||||
<< "\nJOIN PART INTO TIPOC==TIPOC SOTTOCONTO==SOTTOCONTO ANNO==ANNO NUMPART==NUMPART"
|
||||
<< "\nFROM TIPOC=C\nTO TIPOC=C";
|
||||
TISAM_recordset nonass(query);
|
||||
if (nonass.items())
|
||||
{
|
||||
TString str;
|
||||
str = log.title();
|
||||
str << '\n' << TR("Pagamenti non associati a scadenze");
|
||||
TProgind pi(nonass.items(), str);
|
||||
const TRectype& pagsca = nonass.cursor()->curr();
|
||||
const TRectype& part = nonass.cursor()->curr(LF_PARTITE);
|
||||
const TRectype scad(LF_SCADENZE); // Scadenza nulla
|
||||
for (bool ok = nonass.move_first(); ok; ok = nonass.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
TDate data = part.get(PART_DATADOC);
|
||||
if (!data.ok())
|
||||
data = part.get_date(PART_DATAREG);
|
||||
if (data > al || (data < dal && part.get_bool(PART_CHIUSA))) // Ignora vecchia partita chiusa
|
||||
continue;
|
||||
esporta_pagsca(pagsca, scad, false, clienti, movimenti, log);
|
||||
}
|
||||
}
|
||||
|
||||
|
733
tc/tc8300.cpp
Normal file
733
tc/tc8300.cpp
Normal file
@ -0,0 +1,733 @@
|
||||
#include "tc8.h"
|
||||
#include "../cg/cg2101.h"
|
||||
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <progind.h>
|
||||
#include <reputils.h>
|
||||
#include <textset.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <causali.h>
|
||||
#include <clifo.h>
|
||||
#include <occas.h>
|
||||
|
||||
///////////////////////////////////////
|
||||
// TVisualGala_set
|
||||
///////////////////////////////////////
|
||||
|
||||
enum TVisualGala_type { Datetime, Numerico, Char };
|
||||
|
||||
class TVisualGala_set : public TAS400_recordset
|
||||
{
|
||||
protected:
|
||||
bool add_field(const char* name, TVisualGala_type t, int len, int integers = 0, int decimals = 0);
|
||||
|
||||
public:
|
||||
bool get_bill(const char* name, TBill& bill) const;
|
||||
TVisualGala_set(const char* asq) : TAS400_recordset(asq) {}
|
||||
};
|
||||
|
||||
bool TVisualGala_set::add_field(const char* name, TVisualGala_type t, int len, int integers, int decimals)
|
||||
{
|
||||
bool ok = false;
|
||||
switch (t)
|
||||
{
|
||||
case Datetime:
|
||||
ok = TAS400_recordset::create_field(name, -1, len = 10, _datefld);
|
||||
break;
|
||||
case Numerico:
|
||||
if (decimals > 0)
|
||||
{
|
||||
len = integers + decimals + 1;
|
||||
ok = TAS400_recordset::create_field(name, -1, len, _realfld);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = integers;
|
||||
if (len == 1)
|
||||
ok = TAS400_recordset::create_field(name, -1, len, _boolfld);
|
||||
else
|
||||
ok = TAS400_recordset::create_field(name, -1, len, _intfld);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ok = TAS400_recordset::create_field(name, -1, len, _alfafld);
|
||||
break;
|
||||
};
|
||||
CHECKS(ok, "Can't create field ", name);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TVisualGala_set::get_bill(const char* name, TBill& bill) const
|
||||
{
|
||||
const TString& str = get(name).as_string();
|
||||
const int g = atoi(str.left(2));
|
||||
const int c = atoi(str.mid(2,2));
|
||||
const long s = atoi(str.mid(4));
|
||||
bill.set(g, c, s);
|
||||
return s > 0;
|
||||
}
|
||||
|
||||
class TVisualGala_clifoset : public TVisualGala_set
|
||||
{
|
||||
public:
|
||||
TVisualGala_clifoset(const TFilename& n);
|
||||
};
|
||||
|
||||
TVisualGala_clifoset::TVisualGala_clifoset(const TFilename& n) : TVisualGala_set("AS400(680)")
|
||||
{
|
||||
}
|
||||
|
||||
class TVisualGala_movset : public TVisualGala_set
|
||||
{
|
||||
public:
|
||||
TVisualGala_movset(const TFilename& n);
|
||||
};
|
||||
|
||||
TVisualGala_movset::TVisualGala_movset(const TFilename& n) : TVisualGala_set("AS400(679)")
|
||||
{
|
||||
add_field(MOV_DATAREG, Datetime, 10);
|
||||
add_field(CLI_CODCF, Numerico, 0, 6);
|
||||
add_field(CLI_PAIV, Char, 12);
|
||||
add_field(CLI_COFI, Char, 20);
|
||||
add_field(CLI_RAGSOC, Char, 40); // 49
|
||||
add_field(CLI_INDCF, Char, 40); // 89
|
||||
add_field(CLI_CAPCF, Char, 8); // 129
|
||||
add_field(CLI_COMCF, Char, 4);
|
||||
add_field(CLI_STATOCF, Char, 4);
|
||||
add_field("PersFis", Numerico, 0, 1); // 145
|
||||
add_field(MOV_PROTIVA, Numerico, 0, 7);
|
||||
add_field("Sezionale", Char, 2);
|
||||
add_field("FlagDocBIS", Numerico, 0, 1);
|
||||
add_field(MOV_DATADOC, Datetime, 10); // 156
|
||||
add_field(MOV_CODCAUS, Char, 4);
|
||||
add_field("CauDescr", Char, 40);
|
||||
add_field(MOV_CODPAG, Char, 6); // 210
|
||||
add_field(MOV_CODVAL, Char, 4);
|
||||
add_field(MOV_DATACAM, Datetime, 10); // 220
|
||||
add_field(MOV_CAMBIO, Numerico, 0, 6, 6);
|
||||
add_field(MOV_DATACOMP, Datetime, 10); // 243
|
||||
add_field(RMV_NUMRIG, Numerico, 0, 5);
|
||||
//add_field("CodCauCont", Char, 4); // 258
|
||||
add_field(RMV_SOTTOCONTO,Char, 10);
|
||||
add_field(RMV_SEZIONE, Numerico, 0, 2);
|
||||
add_field(MOV_TOTDOC, Numerico, 0, 11, 2); // 270
|
||||
add_field(MOV_TOTDOCVAL, Numerico, 0, 11, 2);
|
||||
add_field(RMI_IMPONIBILE,Numerico, 0, 11, 2);
|
||||
add_field(RMI_CODIVA, Char, 4);
|
||||
add_field(RMI_IMPOSTA, Numerico, 0, 11, 2);
|
||||
add_field("NonDetr", Numerico, 0, 11, 2);
|
||||
add_field("ImponibVal", Numerico, 0, 11, 2);
|
||||
add_field("ImpostaVal", Numerico, 0, 11, 2);
|
||||
add_field("NonDetrVal", Numerico, 0, 11, 2);
|
||||
add_field(MOV_NUMDOC, Char, 10);
|
||||
add_field(CLI_LOCCF, Char, 40);
|
||||
add_field("Provincia", Char, 2);
|
||||
add_field(MOV_DESCR, Char, 198);
|
||||
add_field(CLI_IBAN, Char, 40);
|
||||
//add_field("Franchigia0", Char, 2);
|
||||
|
||||
load_file(n);
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// TVisualGala_mask
|
||||
///////////////////////////////////////
|
||||
|
||||
class TVisualGala_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
TVisualGala_mask() : TAutomask("tc8300a") {}
|
||||
};
|
||||
|
||||
bool TVisualGala_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
{
|
||||
case 102:
|
||||
case 103:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TFilename n = get(101);
|
||||
n.add("*.txt");
|
||||
if (input_filename(n))
|
||||
{
|
||||
if (o.dlg() == 103)
|
||||
set(101, n.path());
|
||||
o.set(n.name());
|
||||
}
|
||||
} else
|
||||
if (e == fe_close)
|
||||
{
|
||||
TFilename n = get(101);
|
||||
n.add(o.get());
|
||||
if (!n.exist())
|
||||
return cantread_box(n);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// TVisualGala_app
|
||||
///////////////////////////////////////
|
||||
|
||||
class TVisualGala_app : public TSkeleton_application
|
||||
{
|
||||
TArray _lf;
|
||||
long _occas_code; // Codice del cliente occasionale
|
||||
|
||||
protected:
|
||||
virtual bool create();
|
||||
virtual void main_loop();
|
||||
virtual bool destroy();
|
||||
|
||||
TIsamfile& file(int logicnum) const; // Open a "Fast" isam file
|
||||
void close_isamfiles(); // Close all isam files
|
||||
|
||||
long find_clifo(const TString& cf_pi) const;
|
||||
const TString& find_occas(const TString& cf_pi) const;
|
||||
long create_new_clifo() const;
|
||||
bool find_or_create_clifo(const TRecordset& mov, TLog_report& log) const;
|
||||
long find_mov(const TRecordset& movset) const;
|
||||
long find_or_create_mov(const TRecordset& movset, TLog_report& log) const;
|
||||
|
||||
bool fill_mov_head(const TRecordset& movset, TRectype& mov, TLog_report& log) const;
|
||||
bool fill_iva_row(const TVisualGala_movset& movset, TRectype& mov, TLog_report& log) const;
|
||||
bool fill_cg_row(const TVisualGala_movset& movset, TRectype& mov, TLog_report& log) const;
|
||||
|
||||
public:
|
||||
bool import_clifo(const TFilename& n, TLog_report& log) const;
|
||||
bool import_mov(const TFilename& n, TLog_report& log) const;
|
||||
};
|
||||
|
||||
TIsamfile& TVisualGala_app::file(int logicnum) const
|
||||
{
|
||||
CHECKD(logicnum >= LF_TABCOM && logicnum <= LF_RMOVIVA, "Invalid file number ", logicnum);
|
||||
TFast_isamfile* f = (TFast_isamfile*)_lf.objptr(logicnum);
|
||||
if (f == NULL)
|
||||
{
|
||||
f = new TFast_isamfile(logicnum);
|
||||
((TArray&)_lf).add(f, logicnum);
|
||||
}
|
||||
return *f;
|
||||
}
|
||||
|
||||
long TVisualGala_app::find_clifo(const TString& cf_pi) const
|
||||
{
|
||||
if (cf_pi.blank() || cf_pi.blank())
|
||||
return 0;
|
||||
|
||||
TIsamfile& clifo = file(LF_CLIFO);
|
||||
|
||||
TString cod = cf_pi;
|
||||
cod.trim(); cod.upper();
|
||||
|
||||
// Tento prima il codice fiscale o la partita IVA?
|
||||
const char* const cofi_paiv = cod.len() > 12 ? "CP" : "PC";
|
||||
|
||||
int err = 204;
|
||||
for (int tentativo = 0; tentativo < 2; tentativo++)
|
||||
{
|
||||
clifo.zero();
|
||||
clifo.put(CLI_TIPOCF, 'C');
|
||||
if (cofi_paiv[tentativo] == 'C')
|
||||
{
|
||||
clifo.setkey(4);
|
||||
clifo.put(CLI_COFI, cod);
|
||||
}
|
||||
else
|
||||
{
|
||||
clifo.setkey(5);
|
||||
clifo.put(CLI_PAIV, cod);
|
||||
}
|
||||
err = clifo.read();
|
||||
if (err == NOERR)
|
||||
break;
|
||||
}
|
||||
|
||||
return err == NOERR ? clifo.get_long(CLI_CODCF) : 0;
|
||||
}
|
||||
|
||||
const TString& TVisualGala_app::find_occas(const TString& cf_pi) const
|
||||
{
|
||||
if (cf_pi.full())
|
||||
{
|
||||
TString cod = cf_pi;
|
||||
cod.trim(); cod.upper();
|
||||
|
||||
TIsamfile& occas = file(LF_OCCAS);
|
||||
occas.zero();
|
||||
occas.put(OCC_CFPI, cf_pi);
|
||||
if (occas.read() == NOERR)
|
||||
return occas.get(OCC_CFPI);
|
||||
}
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
bool TVisualGala_app::find_or_create_clifo(const TRecordset& mov, TLog_report& log) const
|
||||
{
|
||||
TString paiv = mov.get(CLI_PAIV).as_string(); paiv.trim(); paiv.upper();
|
||||
TString cofi = mov.get(CLI_COFI).as_string(); cofi.trim(); cofi.upper();
|
||||
if (cofi.blank() && paiv.blank())
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Cliente privo di Codice Fiscale e Partita IVA alla riga ") << mov.current_row();
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
const long vg_codcf = mov.get(CLI_CODCF).as_int(); // Codice cliente VisualGala
|
||||
long ce_codcf = 0; // Codice cliente Campo Enterprise
|
||||
|
||||
if (vg_codcf <= 0) // Cliente OCCASIONALE
|
||||
{
|
||||
// Posiziona correttamente clifo
|
||||
TIsamfile& clifo = file(LF_CLIFO);
|
||||
if (clifo.get_long(CLI_CODCF) != _occas_code)
|
||||
{
|
||||
clifo.setkey(1);
|
||||
clifo.zero();
|
||||
clifo.put(CLI_TIPOCF, 'C');
|
||||
clifo.put(CLI_CODCF, _occas_code);
|
||||
clifo.read();
|
||||
}
|
||||
|
||||
// Posiziona occas
|
||||
const TString& found = cofi.full() ? find_occas(cofi) : find_occas(paiv);
|
||||
TIsamfile& occas = file(LF_OCCAS);
|
||||
if (found.blank())
|
||||
{
|
||||
occas.zero();
|
||||
occas.put(OCC_CFPI, cofi.full() ? cofi : paiv);
|
||||
occas.put(OCC_RAGSOC, mov.get(CLI_RAGSOC).as_string());
|
||||
const int err = occas.write();
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Impossibile creare l'anagrafica del cliente occasionale alla riga ") << mov.current_row();
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
ce_codcf = _occas_code;
|
||||
}
|
||||
|
||||
occas.put(OCC_RAGSOC, mov.get(CLI_RAGSOC).as_string());
|
||||
|
||||
TString80 indir = mov.get(CLI_INDCF).as_string();
|
||||
const int comma = indir.rfind(',');
|
||||
if (comma > 0)
|
||||
{
|
||||
TString80 civ = indir.mid(comma+1); civ.trim();
|
||||
if (civ.len() <= occas.curr().length(OCC_CIV))
|
||||
{
|
||||
occas.put(OCC_CIV, civ.trim());
|
||||
indir.cut(comma); indir.trim();
|
||||
}
|
||||
}
|
||||
occas.put(OCC_INDIR, indir);
|
||||
occas.put(OCC_LOCALITA, mov.get(CLI_LOCCF).as_string());
|
||||
occas.put(OCC_CAP, mov.get(CLI_CAPCF).as_string());
|
||||
occas.put(OCC_COM, mov.get(CLI_COMCF).as_string());
|
||||
occas.put(OCC_COFI, cofi);
|
||||
occas.put(OCC_PAIV, paiv);
|
||||
if (cofi.len() == 16)
|
||||
{
|
||||
const TFixed_string wm = "ABCDEHLMPRST";
|
||||
const TString& codcom = cofi.mid(11, 4);
|
||||
occas.put(OCC_COMNASC, codcom);
|
||||
occas.put("SESSO", cofi[9] >= '4' ? 'F' : 'M');
|
||||
int anno = atoi(cofi.mid(6, 2));
|
||||
anno += (anno < 10) ? 2000 : 1900;
|
||||
const int mese = wm.find(cofi[8]) + 1;
|
||||
const int giorno = atoi(cofi.mid(9, 2)) % 40;
|
||||
occas.put(OCC_DNASC, TDate(giorno, mese, anno));
|
||||
}
|
||||
|
||||
const int err = occas.rewrite();
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Impossibile aggiornare l'anagrafica del cliente occasionale ") << occas.get(OCC_CFPI);
|
||||
log.log(1, msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ce_codcf = cofi.full() && find_clifo(cofi);
|
||||
if (ce_codcf <= 0)
|
||||
ce_codcf = paiv.full() && find_clifo(paiv);
|
||||
if (ce_codcf <= 0)
|
||||
{
|
||||
ce_codcf = create_new_clifo();
|
||||
if (ce_codcf <= 0)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Impossibile creare l'anagrafica del cliente occasionale alla riga ") << mov.current_row();
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
TIsamfile& clifo = file(LF_CLIFO);
|
||||
clifo.put(CLI_RAGSOC, mov.get(4).as_string());
|
||||
|
||||
TString80 indir = mov.get(5).as_string();
|
||||
TString80 civ;
|
||||
const int comma = indir.rfind(',');
|
||||
if (comma > 0)
|
||||
{
|
||||
civ = indir.mid(comma+1); civ.trim();
|
||||
if (civ.len() <= clifo.curr().length(CLI_CIVCF))
|
||||
{
|
||||
indir.cut(comma);
|
||||
indir.trim();
|
||||
}
|
||||
else
|
||||
civ.cut(0);
|
||||
}
|
||||
clifo.put(CLI_INDCF, indir);
|
||||
clifo.put(CLI_CIVCF, civ);
|
||||
|
||||
clifo.put(CLI_CAPCF, mov.get(6).as_string());
|
||||
clifo.put(CLI_COMCF, mov.get(7).as_string());
|
||||
clifo.put(CLI_COFI, cofi);
|
||||
clifo.put(CLI_PAIV, paiv);
|
||||
const int err = clifo.rewrite();
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Impossibile aggiornare l'anagrafica del cliente ") << ce_codcf;
|
||||
log.log(1, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TVisualGala_app::import_clifo(const TFilename& n, TLog_report& log) const
|
||||
{
|
||||
TVisualGala_clifoset clifoset(n);
|
||||
const TRecnotype r = clifoset.items();
|
||||
TProgind pi(r, TR("Importazione movimenti"));
|
||||
TRecnotype num = 0;
|
||||
for (bool ok = clifoset.move_first(); ok; ok = clifoset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
TString msg;
|
||||
msg.format("%ld anagrafiche importate.", num);
|
||||
log.log(0, "");
|
||||
log.log(0, msg);
|
||||
log.log(0, "");
|
||||
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
long TVisualGala_app::find_mov(const TRecordset& movset) const
|
||||
{
|
||||
const TString& codcau = movset.get(MOV_CODCAUS).as_string().left(3);
|
||||
const TString4 codreg = cache().get(LF_CAUSALI, codcau, CAU_REG);
|
||||
const long protiva = movset.get(MOV_PROTIVA).as_int();
|
||||
const TDate datareg = movset.get(MOV_DATAREG).as_date();
|
||||
|
||||
TIsamfile& mov = file(LF_MOV);
|
||||
mov.setkey(4);
|
||||
mov.zero();
|
||||
|
||||
long numreg = 0L;
|
||||
if (codreg.full() && protiva > 0 && datareg.ok())
|
||||
{
|
||||
mov.put(MOV_DATAREG, datareg);
|
||||
mov.put(MOV_REG, codreg);
|
||||
mov.put(MOV_PROTIVA, protiva);
|
||||
if (mov.read(_isgteq) == NOERR && mov.get_int(MOV_PROTIVA) == protiva)
|
||||
numreg = mov.get_long(MOV_NUMREG);
|
||||
}
|
||||
|
||||
return numreg;
|
||||
}
|
||||
|
||||
bool TVisualGala_app::fill_mov_head(const TRecordset& movset, TRectype& mov, TLog_report& log) const
|
||||
{
|
||||
TIsamfile& clifo = file(LF_CLIFO);
|
||||
if (!find_or_create_clifo(movset, log))
|
||||
return false;
|
||||
|
||||
const TString4 codcau = movset.get(MOV_CODCAUS).as_string().left(3);
|
||||
const TRectype& caus = cache().get(LF_CAUSALI, codcau);
|
||||
const TString4 codreg = caus.get(CAU_REG);
|
||||
|
||||
if (codreg.blank())
|
||||
{
|
||||
TString msg;
|
||||
msg << "Impossibile determinare il registro del movimento con protocollo " << movset.get(MOV_PROTIVA);
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
TDate datareg = movset.get(MOV_DATAREG).as_date();
|
||||
TDate datacomp = movset.get(MOV_DATACOMP).as_date();
|
||||
if (!datacomp.ok())
|
||||
datacomp = datareg;
|
||||
TDate datadoc = movset.get(MOV_DATADOC).as_date();
|
||||
if (!datadoc.ok())
|
||||
datadoc = datacomp;
|
||||
|
||||
mov.put(MOV_DATAREG, datareg);
|
||||
mov.put(MOV_DATACOMP, datacomp);
|
||||
mov.put(MOV_ANNOES, datacomp.year());
|
||||
mov.put(MOV_DATADOC, datadoc);
|
||||
mov.put(MOV_NUMDOC, movset.get(MOV_PROTIVA).as_int());
|
||||
mov.put(MOV_PROTIVA, movset.get(MOV_PROTIVA).as_int());
|
||||
mov.put(MOV_CODCAUS, codcau);
|
||||
mov.put(MOV_TIPODOC, caus.get(CAU_TIPODOC));
|
||||
mov.put(MOV_REG, codreg);
|
||||
mov.put(MOV_TIPO, clifo.get(CLI_TIPOCF));
|
||||
mov.put(MOV_CODCF, clifo.get(CLI_CODCF));
|
||||
if (clifo.get_bool(CLI_OCCAS))
|
||||
mov.put(MOV_OCFPI, file(LF_OCCAS).get(OCC_CFPI));
|
||||
else
|
||||
mov.zero(MOV_OCFPI);
|
||||
|
||||
TString descr = movset.get(MOV_DESCR).as_string();
|
||||
if (descr.blank())
|
||||
descr = movset.get("CauDescr").as_string();
|
||||
mov.put(MOV_DESCR, descr);
|
||||
|
||||
mov.put(MOV_TOTDOC, movset.get(MOV_TOTDOC).as_real());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TVisualGala_app::fill_iva_row(const TVisualGala_movset& movset, TRectype& rmi, TLog_report& log) const
|
||||
{
|
||||
rmi.put(RMI_IMPONIBILE, movset.get(RMI_IMPONIBILE).as_real());
|
||||
rmi.put(RMI_CODIVA, movset.get(RMI_CODIVA).as_string());
|
||||
rmi.put(RMI_IMPOSTA, movset.get(RMI_IMPOSTA).as_real());
|
||||
|
||||
TBill bill;
|
||||
if (!movset.get_bill(RMV_SOTTOCONTO, bill))
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Conto non valido ") << '"' << movset.get(RMV_SOTTOCONTO) << '"'
|
||||
<< TR(" nella riga ") << rmi.get(RMI_NUMRIG)
|
||||
<< TR(" nel movimento con protocollo ") << movset.get(MOV_PROTIVA);
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
bill.put(rmi);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TVisualGala_app::fill_cg_row(const TVisualGala_movset& movset, TRectype& rmv, TLog_report& log) const
|
||||
{
|
||||
rmv.put(RMV_IMPORTO, movset.get(RMI_IMPONIBILE).as_real());
|
||||
rmv.put(RMV_SEZIONE, movset.get(RMV_SEZIONE).as_int() == 2 ? 'A' : 'D');
|
||||
|
||||
TBill bill;
|
||||
if (!movset.get_bill(RMV_SOTTOCONTO, bill))
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Conto non valido ") << '"' << movset.get(RMV_SOTTOCONTO) << '"'
|
||||
<< TR(" nella riga ") << rmv.get(RMV_NUMRIG)
|
||||
<< TR(" del movimento con protocollo ") << movset.get(MOV_PROTIVA);
|
||||
log.log(2, msg);
|
||||
return false;
|
||||
}
|
||||
bill.put(rmv);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
long TVisualGala_app::find_or_create_mov(const TRecordset& movset, TLog_report& log) const
|
||||
{
|
||||
long numreg = find_mov(movset);
|
||||
if (numreg <= 0)
|
||||
{
|
||||
TIsamfile& mov = file(LF_MOV);
|
||||
mov.setkey(1);
|
||||
mov.zero();
|
||||
numreg = 1;
|
||||
int err = mov.last();
|
||||
if (err == NOERR)
|
||||
{
|
||||
numreg += mov.get_long(MOV_NUMREG);
|
||||
|
||||
mov.zero();
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
if (fill_mov_head(movset, mov.curr(), log))
|
||||
err = mov.write();
|
||||
else
|
||||
err = _isnocurkey;
|
||||
}
|
||||
if (err != NOERR)
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Impossibile creare il movimento ") << numreg
|
||||
<< TR(" con protocollo ") << movset.get(MOV_PROTIVA);
|
||||
log.log(2, msg);
|
||||
numreg = 0;
|
||||
}
|
||||
}
|
||||
return numreg;
|
||||
}
|
||||
|
||||
bool TVisualGala_app::import_mov(const TFilename& n, TLog_report& log) const
|
||||
{
|
||||
TVisualGala_movset movset(n);
|
||||
const TRecnotype r = movset.items();
|
||||
TProgind pi(r, TR("Importazione movimenti"));
|
||||
TRecnotype num = 0;
|
||||
TString msg;
|
||||
|
||||
TMovimentoPN mov;
|
||||
|
||||
for (bool ok = movset.move_first(); ok; ok = movset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
const int nriga = movset.get(RMV_NUMRIG).as_int();
|
||||
if (nriga == 1)
|
||||
{
|
||||
if (mov.cg_items() >= 3)
|
||||
{
|
||||
if (mov.rewrite() == NOERR)
|
||||
num++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
const long numreg = find_or_create_mov(movset, log);
|
||||
if (numreg <= 0)
|
||||
break;
|
||||
mov.curr() = file(LF_MOV).curr();
|
||||
const int err = mov.read(_isequal, _lock);
|
||||
if (err != NOERR)
|
||||
{
|
||||
msg << TR("Impossibile leggere il movimento ") << numreg;
|
||||
log.log(2, msg);
|
||||
break;
|
||||
}
|
||||
fill_mov_head(movset, mov.curr(), log);
|
||||
mov.destroy_rows(numreg);
|
||||
fill_iva_row(movset, mov.iva(0), log);
|
||||
}
|
||||
fill_cg_row(movset, mov.cg(nriga-1), log);
|
||||
|
||||
}
|
||||
if (mov.cg_items() >= 3)
|
||||
{
|
||||
if (mov.rewrite() == NOERR)
|
||||
num++;
|
||||
}
|
||||
|
||||
|
||||
msg.format("%ld movimenti importati.", num);
|
||||
log.log(0, "");
|
||||
log.log(0, msg);
|
||||
log.log(0, "");
|
||||
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
long TVisualGala_app::create_new_clifo() const
|
||||
{
|
||||
TIsamfile& f = file(LF_CLIFO);
|
||||
|
||||
long code = 0;
|
||||
TISAM_recordset c("USE CLIFO\nTO TIPOCF=C");
|
||||
if (c.move_last())
|
||||
{
|
||||
code = c.get(CLI_CODCF).as_int() + 1;
|
||||
f.zero();
|
||||
f.put(CLI_TIPOCF, 'C');
|
||||
f.put(CLI_CODCF, code);
|
||||
f.put(CLI_RAGSOC, TR("Nuovo Cliente"));
|
||||
if (f.write() != NOERR)
|
||||
code = 0;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
bool TVisualGala_app::create()
|
||||
{
|
||||
// Determina o crea l'anagrafica del cliente occasionale tipico
|
||||
TISAM_recordset clifo("USE CLIFO SELECT OCCAS=\"X\"\nTO TIPOCF=C");
|
||||
if (clifo.move_first())
|
||||
_occas_code = clifo.get(CLI_CODCF).as_int();
|
||||
else
|
||||
{
|
||||
_occas_code = create_new_clifo();
|
||||
if (_occas_code > 0)
|
||||
{
|
||||
TIsamfile& f = file(LF_CLIFO);
|
||||
f.put(CLI_RAGSOC, TR("Cliente Occasionale"));
|
||||
f.put(CLI_OCCAS, true);
|
||||
if (f.rewrite() != NOERR)
|
||||
_occas_code = 0;
|
||||
}
|
||||
}
|
||||
if (_occas_code <= 0)
|
||||
return error_box(TR("Impossibile determinare il codice del cliente occasionale"));
|
||||
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
void TVisualGala_app::close_isamfiles()
|
||||
{
|
||||
_lf.destroy();
|
||||
prefix().close_closeable_isamfiles();
|
||||
}
|
||||
|
||||
void TVisualGala_app::main_loop()
|
||||
{
|
||||
open_files(LF_TAB, LF_TABCOM, LF_CLIFO, LF_MOV, LF_RMOV, 0);
|
||||
|
||||
TVisualGala_mask mask;
|
||||
while (mask.run() == K_ENTER)
|
||||
{
|
||||
const TFilename dir = mask.get(101);
|
||||
TLog_report log;
|
||||
if (!mask.field(102).empty())
|
||||
{
|
||||
TFilename f = dir; f.add(mask.get(102));
|
||||
import_clifo(f, log);
|
||||
}
|
||||
if (!mask.field(103).empty())
|
||||
{
|
||||
TFilename f = dir; f.add(mask.get(103));
|
||||
import_mov(f, log);
|
||||
}
|
||||
close_isamfiles();
|
||||
log.preview();
|
||||
}
|
||||
}
|
||||
|
||||
bool TVisualGala_app::destroy()
|
||||
{
|
||||
close_isamfiles();
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
int tc8300 (int argc, char* argv[])
|
||||
{
|
||||
TVisualGala_app main_app;
|
||||
main_app.run(argc, argv, TR("Importazione VisualGala"));
|
||||
return 0;
|
||||
}
|
38
tc/tc8300a.uml
Normal file
38
tc/tc8300a.uml
Normal file
@ -0,0 +1,38 @@
|
||||
PAGE "Importazione VisualGala" -1 -1 60 5
|
||||
|
||||
STRING 101 256 45
|
||||
BEGIN
|
||||
PROMPT 1 1 "Cartella "
|
||||
DSELECT
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING 102 256 45
|
||||
BEGIN
|
||||
PROMPT 1 2 "Clienti "
|
||||
FLAGS "B"
|
||||
END
|
||||
|
||||
STRING 103 256 45
|
||||
BEGIN
|
||||
PROMPT 1 3 "Movimenti "
|
||||
FLAGS "B"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING DLG_PROFILE 50
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Profilo "
|
||||
PSELECT
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
#include <elabar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user