Patch level : 12.0 no-patch

Files correlati     : ps6215.exe
Commento            : Aggiunta esportazione per CO.MA.RI delle partite aperte
This commit is contained in:
Simone Palacino 2020-01-28 17:51:22 +01:00
parent d319980d15
commit e6f2db8c6c
3 changed files with 172 additions and 8 deletions

View File

@ -1,3 +1,4 @@
#include <string.h>
#include <applicat.h> #include <applicat.h>
#include <automask.h> #include <automask.h>
#include <tsdb.h> #include <tsdb.h>
@ -10,8 +11,108 @@
#include "clifo.h" #include "clifo.h"
#include "comuni.h" #include "comuni.h"
#include "cfven.h" #include "cfven.h"
#include "sqlset.h"
#include <vector>
#define CLIFO_RECLEN 730 #define CLIFO_RECLEN 730
#define D_ANNO 4
#define D_NUMPART 7
#define D_NRIGA 4
#define D_TIPOC 1 // ['C' | 'F'] (Cliente/Fornitore)
#define D_SOTTOCONTO 6
#define D_TIPOMOV 1
#define D_TIPOPAG 1
#define D_NREG 7
#define D_NUMRIG 3
#define D_DATAREG 8 // Formato data dd-MM-yyyy
#define D_DATADOC 8 // Formato data dd-MM-yyyy
#define D_DATAPAG 8 // Formato data dd-MM-yyyy
#define D_NUMDOC 7
#define D_REG 3
#define D_PROTIVA 5
#define D_CODCAUS 3
#define D_SEZ 1 // ['D' | 'A'] (Dare/Avere)
#define D_IMPORTO 18 // 18 con 3 decimali, segno, e virgola
#define D_IMPOSTA 18 // 18 con 3 decimali, segno, e virgola
#define D_SPESE 18 // 18 con 3 decimali, segno, e virgola
#define D_IMPTOTDOC 18 // 18 con 3 decimali, segno, e virgola
#define D_RITENUTE 18 // 18 con 3 decimali, segno, e virgola
#define D_RITSOC 18 // 18 con 3 decimali, segno, e virgola
#define D_SEZABB 1
#define D_ABBUONI 18 // 18 con 3 decimali, segno, e virgola
#define D_SEZDIFCAM 1
#define D_DIFFCAM 18 // 18 con 3 decimali, segno, e virgola
#define D_GRUPPOCL 3
#define D_CONTOCL 3
//const char* fields[] = { "ANNO", "NUMPART", "NRIGA", "TIPOC", "SOTTOCONTO", "TIPOMOV", "TIPOPAG", "NREG", "NUMRIG", "DATAREG", "DATADOC", "DATAPAG", "NUMDOC", "REG", "PROTIVA", "CODCAUS", "SEZ", "IMPORTO", "IMPOSTA", "SPESE", "IMPTOTDOC", "RITENUTE", "RITSOC", "SEZABB", "ABBUONI", "SEZDIFCAM", "DIFFCAM", "GRUPPOCL", "CONTOCL" };
const int dim_fields[] = { D_ANNO, D_NUMPART, D_NRIGA, D_TIPOC, D_SOTTOCONTO, D_TIPOMOV, D_TIPOPAG, D_NREG, D_NUMRIG, D_DATAREG, D_DATADOC, D_DATAPAG, D_NUMDOC, D_REG, D_PROTIVA, D_CODCAUS, D_SEZ, D_IMPORTO, D_IMPOSTA, D_SPESE, D_IMPTOTDOC, D_RITENUTE, D_RITSOC, D_SEZABB, D_ABBUONI, D_SEZDIFCAM, D_DIFFCAM, D_GRUPPOCL, D_CONTOCL };
class TFixed_record
{
int _items;
int* _dims;
int _tot_len;
char* _str;
int pos(int _Idx) const;
public:
void set_str(int _Idx, const char* _Str) const;
const char* const get_line() const { return static_cast<const char* const>(_str); }
TFixed_string operator[](int _Idx) const;
TFixed_record(int items = 0, const int dims[] = nullptr);
};
int TFixed_record::pos(int _Idx) const
{
int real_idx = 0;
if (_Idx >= 0 && _Idx <= _items)
{
for (int i = 0; i < _Idx; ++i)
real_idx += _dims[i];
}
return real_idx;
}
void TFixed_record::set_str(int _Idx, const char* _Str) const
{
const int p = pos(_Idx);
for (int i = p; i < p + _dims[_Idx] && i < (int)strlen(_Str) + p; ++i)
_str[i] = _Str[i - p];
}
TFixed_string TFixed_record::operator[](int _Idx) const
{
static TFixed_string* f_str = nullptr;
delete f_str;
if (_Idx >= 0 && _Idx < _items)
{
const int p = pos(_Idx);
TString appo(_str);
appo = appo.sub(p, p + _dims[_Idx]);
const TFixed_string str(appo, _dims[_Idx] + 1);
f_str = new TFixed_string(str);
}
else
f_str = new TFixed_string("");
return *f_str;
}
TFixed_record::TFixed_record(const int items, const int dims[]): _items(items), _tot_len(0)
{
_dims = new int[items];
for (int i = 0; i < items; ++i)
{
_dims[i] = dims[i];
_tot_len += dims[i];
}
_str = new char[_tot_len + 1];
memset(_str, ' ', _tot_len + 1);
_str[_tot_len] = '\0';
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utilities // Utilities
@ -103,10 +204,11 @@ class TComariExport_app : public TSkeleton_application
bool export_all() const; bool export_all() const;
static void add_to_record(char* record, TString& str, int len, int& index); static void add_to_record(char* record, TString& str, int len, int& index);
static void export_clifo(ofstream& fout); static void export_clifo(ofstream& fout);
static void export_parti(ofstream& fout);
bool export_table(short id) const; bool export_table(short id) const;
public: public:
bool create() override; bool create() override;
void main_loop() override; void main_loop() override;
TComariExport_app() = default; TComariExport_app() = default;
}; };
@ -114,6 +216,7 @@ bool TComariExport_app::export_all() const
{ {
return return
export_table(F_CLIFOR) && export_table(F_CLIFOR) &&
export_table(F_PARTOPEN) &&
export_table(F_PIANOCONTI) && export_table(F_PIANOCONTI) &&
export_table(F_MASTRI); export_table(F_MASTRI);
} }
@ -283,6 +386,49 @@ void TComariExport_app::export_clifo(ofstream& fout)
} }
} }
void TComariExport_app::export_parti(ofstream& fout)
{
TString4 last_game = ini_get_string(CONFIG_DITTA, "sc", "last_year_open_game", "2019");
const string year = (const char*)last_game;
const int y = stol(year);
if (y < 2000 || y > 2029)
last_game = "2019";
ini_set_string(CONFIG_DITTA, "sc", "last_game", last_game);
TString sql; sql << "SELECT ANNO, NUMPART, NRIGA, TIPOC, SOTTOCONTO, TIPOMOV, TIPOPAG, NREG, "\
"NUMRIG, DATAREG, DATADOC, DATAPAG, NUMDOC, REG, PROTIVA, CODCAUS, SEZ, IMPORTO, IMPOSTA, "\
"SPESE, IMPTOTDOC, RITENUTE, RITSOC, SEZABB, ABBUONI, SEZDIFCAM, DIFFCAM, GRUPPOCL, CONTOCL \n" <<
"FROM part WHERE CHIUSA<>'X' AND ANNO <=" << last_game << ";";
TSQL_recordset openpart(sql);
if (!openpart.items())
message_box("Non ci sono partite aperte al %s da esportare.", (const char*)last_game);
else if(openpart.move_first())
{
TProgress_monitor bar(openpart.items(), "Esportazione Partite Aperte");
for(bool ok = true; ok; ok = openpart.move_next())
{
if (!bar.add_status())
break;
TFixed_record rec((int)(sizeof dim_fields / sizeof *dim_fields), dim_fields);
for (int i = 0; i < (int)(sizeof dim_fields / sizeof *dim_fields); ++i)
{
if (openpart.column_info(i)._type == _datefld)
{
TString ansi; ansi << TDate(openpart.get(i).as_date()).date2ansi();
if(ansi != "0")
rec.set_str(i, ansi);
}
else if(i >= 17 && i <= 22 || i == 24 || i == 26) // reali (non so perche' ma becca come reali anche gli interi...)
rec.set_str(i, TString(openpart.get(i).as_real().string(18, 3, ' ')));
else
rec.set_str(i, openpart.get(i).as_string());
}
fout << rec.get_line() << endl;
}
}
else
warning_box(TR("Impossibile leggere file partite aperte."));
}
bool TComariExport_app::export_table(const short id) const bool TComariExport_app::export_table(const short id) const
{ {
bool ok = false; bool ok = false;
@ -303,6 +449,17 @@ bool TComariExport_app::export_table(const short id) const
} }
name = "Clienti Fornitori"; name = "Clienti Fornitori";
break; break;
case F_PARTOPEN:
name_file = "partiteaperte.txt";
path << "\\" << name_file;
fout.open(path, ios_base::out);
if ((ok = fout.is_open()))
{
export_parti(fout);
fout.close();
}
name = "Clienti Fornitori";
break;
case F_PIANOCONTI: case F_PIANOCONTI:
name_file = "pianoconti.txt"; name_file = "pianoconti.txt";
path << "\\" << name_file; path << "\\" << name_file;
@ -359,6 +516,6 @@ void TComariExport_app::main_loop()
int ps6215100(const int argc, char* argv[]) int ps6215100(const int argc, char* argv[])
{ {
TComariExport_app pe; TComariExport_app pe;
pe.run(argc, argv, TR("Configurazione Esportazione CO.MA.RI.")); pe.run(argc, argv, TR("Esportazione CO.MA.RI."));
return 0; return 0;
} }

View File

@ -1,4 +1,5 @@
#define F_FLDDEST 101 #define F_FLDDEST 101
#define F_CLIFOR 102 #define F_CLIFOR 102
#define F_PIANOCONTI 103 #define F_PARTOPEN 103
#define F_MASTRI 104 #define F_PIANOCONTI 104
#define F_MASTRI 105

View File

@ -20,15 +20,21 @@ BEGIN
FLAGS "" FLAGS ""
END END
BOOLEAN F_PARTOPEN
BEGIN
PROMPT 2 3 "Esporta Partite Aperte"
FLAGS ""
END
BOOLEAN F_PIANOCONTI BOOLEAN F_PIANOCONTI
BEGIN BEGIN
PROMPT 2 3 "Esporta Piano dei Conti" PROMPT 2 4 "Esporta Piano dei Conti"
FLAGS "D" FLAGS "D"
END END
BOOLEAN F_MASTRI BOOLEAN F_MASTRI
BEGIN BEGIN
PROMPT 2 4 "Esporta Mastri" PROMPT 2 5 "Esporta Mastri"
FLAGS "D" FLAGS "D"
END END