Files correlati : Ricompilazione Demo : [ ] Commento : Rportata la versione 3.2 patch 1314 git-svn-id: svn://10.65.10.50/trunk@18269 c028cbd2-c16b-5b4b-a496-9718f37d4682
1595 lines
47 KiB
C++
Executable File
1595 lines
47 KiB
C++
Executable File
#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 <comuni.h>
|
|
#include <mov.h>
|
|
#include <pconti.h>
|
|
#include <saldi.h>
|
|
|
|
|
|
#include "../cg/cg2101.h"
|
|
#include "../cg/cglib02.h"
|
|
#include "../cg/cgpagame.h"
|
|
#include "../cg/cgsaldac.h"
|
|
|
|
#include "ps0001.h"
|
|
#include "ps0001100.h"
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDettaglio_mask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TTrasf_mask : public TAutomask
|
|
{
|
|
private:
|
|
void serialize(bool bSave);
|
|
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
TTrasf_mask();
|
|
~TTrasf_mask();
|
|
};
|
|
|
|
bool TTrasf_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
bool ok = true;
|
|
switch (o.dlg())
|
|
{
|
|
case F_PATH:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
void TTrasf_mask::serialize(bool bSave)
|
|
{
|
|
const char* defpar = "tc";
|
|
TConfig ini(CONFIG_DITTA, defpar);
|
|
for (int i = fields()-1; i >= 0; i--)
|
|
{
|
|
TMask_field& f = fld(i);
|
|
const TFieldref* fr = f.field();
|
|
if (fr != NULL)
|
|
{
|
|
if (bSave)
|
|
fr->write(ini, defpar, f.get());
|
|
else
|
|
f.set(fr->read(ini, defpar));
|
|
}
|
|
}
|
|
}
|
|
|
|
TTrasf_mask::TTrasf_mask()
|
|
: TAutomask("ps0001100")
|
|
{
|
|
serialize(false);
|
|
}
|
|
|
|
TTrasf_mask::~TTrasf_mask()
|
|
{
|
|
serialize(true);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TClienti_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TClienti_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TClienti_textset();
|
|
};
|
|
|
|
TClienti_textset::TClienti_textset()
|
|
: TAS400_recordset(TString("AS400(2865,0,0)\n"))
|
|
{
|
|
create_field("SUPPLIER CODE", 0, 15);
|
|
create_field("NAME", 15, 50);
|
|
create_field("LOOKUP CODE", 65, 15);
|
|
create_field("SHORT HEADING", 65, 15);
|
|
create_field("DESCRIPTION", 80, 50);
|
|
create_field("LONG DESCRIPTION", 130, 255);
|
|
create_field("ANALYSIS 1 - COA_UK", 385, 10);
|
|
create_field("ANALYSIS 2", 395, 10);
|
|
create_field("ANALYSIS 3", 405, 10);
|
|
create_field("ANALYSIS 4 - CUST_SUPP_GROUP", 415, 3);
|
|
create_field("ANALYSIS 5 - WITHHOLD_TAX", 418, 10);
|
|
create_field("E-MAIL ADDRESS", 428, 124);
|
|
create_field("WEB PAGE ADDRESS", 552, 124);
|
|
create_field("BANK SUB CODE", 676, 5);
|
|
create_field("COMPANY ADDRESS", 681, 15);
|
|
create_field("PAY ADDRESS", 696, 15);
|
|
create_field("ACCOUNT CODE", 711, 15);
|
|
create_field("CURRENCY CODE", 726, 3);
|
|
create_field("CREDIT LIMIT", 729, 18, _realfld);
|
|
create_field("PAYMENT METHOD", 747, 4); // ??
|
|
create_field("PAYMENT TERMS GROUP", 751, 15);
|
|
create_field("Name/Address 1", 766, 50);
|
|
create_field("Name/Address 2", 816, 50);
|
|
create_field("Name/Address 3", 866, 50);
|
|
create_field("Name/Address 4", 916, 50);
|
|
create_field("Name/Address 5", 966, 50);
|
|
create_field("Town/City", 1016, 50);
|
|
create_field("State", 1066, 50);
|
|
create_field("Postal Code", 1116, 20);
|
|
create_field("Country", 1136, 50);
|
|
create_field("Telephone Number", 1186, 50);
|
|
create_field("Telex/Fax Number", 1236, 50);
|
|
create_field("Web Page Address", 1866, 124);
|
|
create_field("Long Description", 1990, 255);
|
|
create_field("Short Heading", 2245, 15);
|
|
create_field("Lookup Code", 2260, 15);
|
|
create_field("Bank Sub Code", 2275, 5);
|
|
create_field("Bank Lookup Code", 2280, 15);
|
|
create_field("Bank Address Code", 2295, 15);
|
|
create_field("Bank Account Name", 2310, 50);
|
|
create_field("Bank Account Number", 2360, 34);
|
|
create_field("Filler", 2394, 3);
|
|
create_field("Filler", 2397, 3);
|
|
create_field("Bank Name", 2400, 50);
|
|
create_field("Bank Branch", 2450, 50);
|
|
create_field("Bank Sorting Code", 2500, 15);
|
|
create_field("Comment", 2515, 255);
|
|
create_field("Vat Code", 2770, 20);
|
|
create_field("Fiscal Code", 2790, 20);
|
|
create_field("Birth Date", 2810, 20);
|
|
create_field("Sex", 2830, 2);
|
|
create_field("Birth Town", 2832, 30);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFornitori_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TFornitori_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TFornitori_textset();
|
|
};
|
|
|
|
TFornitori_textset::TFornitori_textset()
|
|
: TAS400_recordset(TString("AS400(2865,0,0)\n"))
|
|
{
|
|
create_field("SUPPLIER CODE", 0, 15);
|
|
create_field("NAME", 15, 50);
|
|
create_field("LOOKUP CODE", 65, 15);
|
|
create_field("SHORT HEADING", 65, 15);
|
|
create_field("DESCRIPTION", 80, 50);
|
|
create_field("LONG DESCRIPTION", 130, 255);
|
|
create_field("ANALYSIS 1 - COA_UK", 385, 20);
|
|
create_field("ANALYSIS 2", 405, 10);
|
|
create_field("ANALYSIS 3", 415, 10);
|
|
create_field("ANALYSIS 4 - CUST_SUPP_GROUP", 425, 3);
|
|
create_field("ANALYSIS 5 - WITHHOLD_TAX", 428, 10);
|
|
create_field("E-MAIL ADDRESS", 438, 124);
|
|
create_field("WEB PAGE ADDRESS", 562, 124);
|
|
create_field("BANK SUB CODE", 686, 5);
|
|
create_field("COMPANY ADDRESS", 691, 15);
|
|
create_field("PAY ADDRESS", 706, 15);
|
|
create_field("ACCOUNT CODE", 721, 15);
|
|
create_field("CURRENCY CODE", 736, 3);
|
|
create_field("CREDIT LIMIT", 739, 18, _realfld);
|
|
create_field("PAYMENT METHOD", 757, 4); // ??
|
|
create_field("PAYMENT TERMS GROUP", 761, 15);
|
|
create_field("Name/Address 1", 776, 50);
|
|
create_field("Name/Address 2", 826, 50);
|
|
create_field("Name/Address 3", 876, 50);
|
|
create_field("Name/Address 4", 926, 50);
|
|
create_field("Name/Address 5", 976, 50);
|
|
create_field("Town/City", 1026, 50);
|
|
create_field("State", 1076, 50);
|
|
create_field("Postal Code", 1126, 20);
|
|
create_field("Country", 1146, 50);
|
|
create_field("Telephone Number", 1196, 50);
|
|
create_field("Telex/Fax Number", 1246, 50);
|
|
create_field("Web Page Address", 1866, 124);
|
|
create_field("Long Description", 1990, 255);
|
|
create_field("Short Heading", 2245, 15);
|
|
create_field("Lookup Code", 2260, 15);
|
|
create_field("Bank Sub Code", 2275, 5);
|
|
create_field("Bank Lookup Code", 2280, 15);
|
|
create_field("Bank Address Code", 2295, 15);
|
|
create_field("Bank Account Name", 2310, 50);
|
|
create_field("Bank Account Number", 2360, 34);
|
|
create_field("Filler", 2394, 3);
|
|
create_field("Filler", 2397, 3);
|
|
create_field("Bank Name", 2400, 50);
|
|
create_field("Bank Branch", 2450, 50);
|
|
create_field("Bank Sorting Code", 2500, 15);
|
|
create_field("Comment", 2515, 255);
|
|
create_field("Vat Code", 2770, 20);
|
|
create_field("Fiscal Code", 2790, 20);
|
|
create_field("Birth Date", 2810, 20);
|
|
create_field("Sex", 2830, 2);
|
|
create_field("Birth Town", 2832, 30);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TPartCliFo_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TPartCliFo_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TPartCliFo_textset();
|
|
};
|
|
|
|
TPartCliFo_textset::TPartCliFo_textset()
|
|
: TAS400_recordset(TString("AS400(293,0,0)\n"))
|
|
{
|
|
create_field("Filler", 0, 5, _intfld);
|
|
create_field("Line No", 5, 5, _intfld);
|
|
create_field("Codice Conto", 10, 12);
|
|
create_field("Descrizione Conto", 22, 50);
|
|
create_field("Periodo", 72, 50, _longfld);
|
|
create_field("Data Fattura / NC", 122, 10, _datefld);
|
|
create_field("Numero Fattura / NC", 132, 20);
|
|
create_field("Descrizione", 152, 50);
|
|
create_field("Importo Euro (Avere = negativo)", 202, 18, _realfld);
|
|
create_field("Cod Valuta", 220, 3);
|
|
create_field("Importo in Valuta", 223, 18, _realfld);
|
|
create_field("Data Scadenza", 241, 10, _datefld);
|
|
create_field("Non Utilizzare", 251, 1);
|
|
create_field("Non Utilizzare", 242, 1);
|
|
create_field("Non Utilizzare", 253, 1);
|
|
create_field("T1 - Non utilizzare", 254, 1);
|
|
create_field("T2 - Non utilizzare", 255, 1);
|
|
create_field("T3 - Non utilizzare", 256, 1);
|
|
create_field("T4 - Non utilizzare (Cod Iva)", 257, 10);
|
|
create_field("T5 - Non utilizzare", 267, 1);
|
|
create_field("T6 - Non utilizzare", 268, 1);
|
|
create_field("T7 - Prot Iva", 269, 10);
|
|
create_field("T8 - Cod Riten", 279, 1);
|
|
create_field("T9 - Divisione", 280, 10);
|
|
create_field("T10 - Non utilizzare", 290, 1);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TPartForPer_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TPartForPer_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TPartForPer_textset();
|
|
};
|
|
|
|
TPartForPer_textset::TPartForPer_textset()
|
|
: TAS400_recordset(TString("AS400(279,0,0)\n"))
|
|
{
|
|
create_field("Data Reg ne", 0, 10);
|
|
create_field("Conto", 10, 12);
|
|
create_field("Descrizione conto", 22, 50);
|
|
create_field("Periodo", 72, 7);
|
|
create_field("Imp. Euro", 79, 18, _realfld);
|
|
create_field("Causale", 97, 5, _alfafld, false, TVariant("PMFRE")); // fissi
|
|
create_field("Ledger", 102, 1, _alfafld, false, TVariant("A")); // fissi
|
|
create_field("Data Doc to", 103, 10, _datefld);
|
|
create_field("Rif. Doc to", 113, 10);
|
|
create_field("N Giornale", 123, 5, _intfld); // num.reg.
|
|
create_field("N Riga Giorn.", 128, 5, _intfld); // num.rig
|
|
|
|
create_field("Cod Valuta", 133, 3);
|
|
create_field("Imp Valuta", 136, 18, _realfld);
|
|
create_field("Region", 154, 6); // vuoto
|
|
create_field("Centro di Costo", 160, 20);
|
|
create_field("Cod Iva", 180, 10);
|
|
create_field("Misc Code", 190, 6); // vuoto
|
|
create_field("Prot Iva", 196, 10);
|
|
create_field("Rit Acc", 206, 10, _alfafld, false, TVariant("11401"));
|
|
create_field("IndicatoreAlloc", 216, 6); // vuoto
|
|
create_field("Rif to Alloc", 222, 6); // vuoto
|
|
create_field("Data Allocazione", 228, 10); // vuoto
|
|
create_field("Tipo Oper Cespite", 238, 10); // vuoto
|
|
create_field("Codice Cespite", 248, 10); // vuoto
|
|
create_field("Descrizione Cespite", 258, 10); // vuoto
|
|
create_field("Divisione", 268, 10);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TSaldi_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TSaldi_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TSaldi_textset();
|
|
};
|
|
|
|
TSaldi_textset::TSaldi_textset()
|
|
: TAS400_recordset(TString("AS400(302,0,0)\n"))
|
|
{
|
|
create_field("Filler", 0, 5, _intfld);
|
|
create_field("Line No", 5, 5, _intfld);
|
|
create_field("Codice Conto", 10, 12);
|
|
create_field("Descrizione Conto", 22, 50);
|
|
create_field("Periodo", 72, 50, _longfld);
|
|
create_field("Data Documento", 122, 10, _datefld);
|
|
create_field("Riferimento Doc to", 132, 20);
|
|
create_field("Descrizione", 152, 50);
|
|
create_field("Importo Euro (Avere = negativo)", 202, 18, _realfld);
|
|
create_field("Cod Valuta", 220, 3);
|
|
create_field("Importo in Valuta", 223, 18, _realfld);
|
|
create_field("Data Scadenza", 241, 10, _datefld);
|
|
create_field("Non Utilizzare", 251, 1);
|
|
create_field("Non Utilizzare", 242, 1);
|
|
create_field("Non Utilizzare", 253, 1);
|
|
create_field("T1 - Non utilizzare", 254, 1);
|
|
create_field("T2 - Non utilizzare", 255, 1);
|
|
create_field("T3 - Non utilizzare", 256, 1);
|
|
create_field("T4 - Non utilizzare (Cod Iva)", 257, 10);
|
|
create_field("T5 - Non utilizzare", 267, 1);
|
|
create_field("T6 - Non utilizzare", 268, 1);
|
|
create_field("T7 - Prot Iva", 269, 10);
|
|
create_field("T8 - Cod Riten", 279, 10);
|
|
create_field("T9 - Divisione", 289, 10);
|
|
create_field("T10 - Non utilizzare", 299, 1);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TMovim_textset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMovim_textset : public TAS400_recordset
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
TMovim_textset();
|
|
};
|
|
|
|
TMovim_textset::TMovim_textset()
|
|
: TAS400_recordset(TString("AS400(385,0,0)\n"))
|
|
{
|
|
create_field("Mov No", 0, 5, _intfld);
|
|
create_field("Line No", 5, 5, _intfld);
|
|
create_field("Codice Conto", 10, 12);
|
|
create_field("Descrizione Conto", 22, 50);
|
|
create_field("Periodo", 72, 50, _longfld);
|
|
create_field("Data Documento", 122, 10, _datefld);
|
|
create_field("Riferimento Doc to", 132, 20);
|
|
create_field("Descrizione", 152, 50);
|
|
create_field("Importo Euro (Avere = negativo)", 202, 18, _realfld);
|
|
create_field("Cod Valuta", 220, 3);
|
|
create_field("Importo in Valuta", 223, 18, _realfld);
|
|
create_field("Data Scadenza", 241, 10, _datefld);
|
|
create_field("Non Utilizzare", 251, 1);
|
|
create_field("Non Utilizzare", 252, 1);
|
|
create_field("Non Utilizzare", 253, 1);
|
|
create_field("T1 - Non utilizzare", 254, 1);
|
|
create_field("T2 - Non utilizzare", 255, 1);
|
|
create_field("T3 - Non utilizzare: Centro di Costo", 256, 20);
|
|
create_field("T4 - Non utilizzare (Cod Iva)", 276, 10);
|
|
create_field("T5 - Non utilizzare", 286, 1);
|
|
create_field("T6 - Non utilizzare", 287, 1);
|
|
create_field("T7 - Prot Iva", 288, 10);
|
|
create_field("T8 - Cod Riten", 298, 10);
|
|
create_field("T9 - Divisione", 308, 10);
|
|
create_field("x", 318, 1);
|
|
create_field("T10 - Codice Causale originale", 319, 10);
|
|
create_field("Descrizione Causale originale", 329, 50);
|
|
create_field("Numero operazione originale", 379, 5, _intfld);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TTrasf_app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TTrasf_app : public TSkeleton_application
|
|
{
|
|
|
|
protected:
|
|
void export_clienti(const TTrasf_mask & m);
|
|
void export_fornitori(const TTrasf_mask & m);
|
|
void load_partite_aperte(const TTrasf_mask & m, const char * tipocf, TPartite_array &part);
|
|
void export_partite_clienti(const TTrasf_mask & m);
|
|
void export_partite_fornitori(const TTrasf_mask & m);
|
|
void export_saldi(const TTrasf_mask & m);
|
|
void export_movimenti(const TTrasf_mask & m);
|
|
virtual const char * extra_modules() const {return "ba";}
|
|
|
|
public:
|
|
virtual bool create();
|
|
virtual void main_loop();
|
|
virtual bool destroy();
|
|
TTrasf_app() {}
|
|
};
|
|
|
|
TTrasf_app& app() { return (TTrasf_app&)main_app(); }
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Utility functions
|
|
///////////////////////////////////////////////////////////
|
|
|
|
static void pag2pag(TVariant & p)
|
|
{
|
|
TString16 s = p.as_string();
|
|
while (s.len() < 3)
|
|
s.insert("0");
|
|
|
|
if (s == "027" || s == "011" || s == "014")
|
|
p = "120T";
|
|
else
|
|
if (s == "034")
|
|
p = "14T";
|
|
else
|
|
if (s == "028")
|
|
p = "150T";
|
|
else
|
|
if (s == "004" || s == "005" || s == "015" || s == "024")
|
|
p = "30T";
|
|
else
|
|
if (s == "038")
|
|
p = "45T";
|
|
else
|
|
if (s == "006" || s == "021" || s == "25")
|
|
p = "60T";
|
|
else
|
|
if (s == "002" || s == "010" || s == "033")
|
|
p = "90T";
|
|
else
|
|
if (s == "001" || s == "003")
|
|
p = "NOW";
|
|
else
|
|
if (s == "017" || s == "019" || s == "026" || s == "032")
|
|
p = "30M";
|
|
else
|
|
if (s == "029")
|
|
p = "40T";
|
|
else
|
|
if (s == "002" || s == "008" || s == "009" || s == "016" || s == "022" || s == "023")
|
|
p = "60M";
|
|
else
|
|
if (s == "007" || s == "031" || s == "036")
|
|
p = "90M";
|
|
else
|
|
if (s == "035" || s == "037")
|
|
p = "120M";
|
|
else
|
|
if (s == "012" || s == "013")
|
|
p = "150M";
|
|
else
|
|
p = "";
|
|
}
|
|
|
|
static bool cli2code(const TRectype & clifo, const TString & div, TVariant & code, TString & descr)
|
|
{
|
|
if (clifo.get(CLI_TIPOCF) == "C")
|
|
code = "D";
|
|
else
|
|
code = "C";
|
|
|
|
|
|
const TString & pi = clifo.get(CLI_PAIV);
|
|
const int gruppo = clifo.get_int(CLI_GRUPPORIC);
|
|
const int conto = clifo.get_int(CLI_CONTORIC);
|
|
const long sottoconto = clifo.get_long(CLI_SOTTOCRIC);
|
|
TString key("CL|");
|
|
|
|
key << div << "|" << format("%03d%03d%06ld", gruppo, conto, sottoconto);
|
|
|
|
const TRectype & maprec = cache().get(LF_MULTIREL, key);
|
|
bool grouped = !maprec.empty();
|
|
|
|
if (grouped)
|
|
{
|
|
TToken_string data(maprec.get("DATA"), ',');
|
|
descr = data.get();
|
|
code = data.get();
|
|
}
|
|
else
|
|
{
|
|
TString sl(clifo.get(CLI_RAGSOC));
|
|
|
|
if (sl.len() > 30 && sl[29] == ' ')
|
|
{
|
|
TString sr(sl.mid(30));
|
|
|
|
sl = sl.left(30);
|
|
sl.trim();
|
|
sl << " " << sr;
|
|
}
|
|
|
|
descr = sl;
|
|
if (pi.full())
|
|
code += (const char *) pi;
|
|
else
|
|
code += (const char *) clifo.get(CLI_COFI);
|
|
}
|
|
|
|
return grouped;
|
|
}
|
|
|
|
static void count2code(TBill & c, const TString& div, TVariant & code)
|
|
{
|
|
TString key(40);
|
|
if (c.tipo() > ' ')
|
|
{
|
|
TString descr;
|
|
|
|
key << c.tipo() << "|" << c.sottoconto();
|
|
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
cli2code(clifo, div, code, descr);
|
|
}
|
|
else
|
|
{
|
|
code = format("%03d%03d%06ld", c.gruppo(), c.conto(), c.sottoconto());
|
|
key << "DV|" << div << "|" << code.as_string();
|
|
|
|
const TRectype & map = cache().get(LF_MULTIREL, key);
|
|
|
|
if (!map.empty())
|
|
code = map.get("DATA");
|
|
}
|
|
}
|
|
|
|
static void iva2iva(TString & codiva, TString & div)
|
|
{
|
|
TString key;
|
|
|
|
key << "IV|" << div << "|" << codiva;
|
|
const TRectype & map = cache().get(LF_MULTIREL, key);
|
|
|
|
if (!map.empty())
|
|
codiva = map.get("DATA");
|
|
}
|
|
|
|
static void ditta2div(long codditta, TString & div)
|
|
{
|
|
switch (codditta)
|
|
{
|
|
case 1:
|
|
case 3:
|
|
break;
|
|
case 5:
|
|
div = "246";
|
|
return;
|
|
break;
|
|
case 7:
|
|
break;
|
|
case 10:
|
|
div = "245";
|
|
return;
|
|
break;
|
|
case 25:
|
|
div ="247";
|
|
return;
|
|
break;
|
|
default :
|
|
break;
|
|
}
|
|
div = "241";
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TTrasf_app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TTrasf_app::create()
|
|
{
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TTrasf_app::destroy()
|
|
{
|
|
return TSkeleton_application::destroy();
|
|
}
|
|
|
|
void TTrasf_app::export_clienti(const TTrasf_mask & m)
|
|
{
|
|
TClienti_textset outputfile;
|
|
TFilename name = m.get(F_PATH);
|
|
TString div;
|
|
TString descr;
|
|
TVariant v;
|
|
|
|
ditta2div(prefix().get_codditta(), div);
|
|
name.add("clienti.slk");
|
|
|
|
TISAM_recordset clienti("USE CLIFO SELECT TIPOCF==\"C\"");
|
|
TProgind pin(clienti.items(), TR("Esportazione Clienti"), true, true);
|
|
|
|
for (bool ok = clienti.move_first(); ok; ok = clienti.move_next())
|
|
{
|
|
TVariant code;
|
|
TString sl(clienti.get(CLI_RAGSOC).as_string());
|
|
|
|
if (sl.len() > 30 && sl[29] == ' ')
|
|
{
|
|
TString sr(sl.mid(30));
|
|
|
|
sl = sl.left(30);
|
|
sl.trim();
|
|
sl << " " << sr;
|
|
}
|
|
|
|
const TVariant ragsoc(sl);
|
|
const TVariant shortragsoc(sl.left(15));
|
|
TString pi(clienti.get(CLI_PAIV).as_string());
|
|
TString cofi(clienti.get(CLI_COFI).as_string());
|
|
|
|
if (pi.blank() || cofi.blank())
|
|
continue;
|
|
if (cli2code(clienti.cursor()->curr(), div, code, descr))
|
|
continue;
|
|
|
|
outputfile.new_rec();
|
|
outputfile.set("SUPPLIER CODE", code);
|
|
outputfile.set("NAME", ragsoc);
|
|
outputfile.set("LOOKUP CODE", shortragsoc);
|
|
outputfile.set("SHORT HEADING", shortragsoc);
|
|
outputfile.set("DESCRIPTION", ragsoc);
|
|
outputfile.set("LONG DESCRIPTION", ragsoc);
|
|
outputfile.set("ANALYSIS 1 - COA_UK", "DEBTOR");
|
|
outputfile.set("ANALYSIS 2", "SOUTH");
|
|
outputfile.set("ANALYSIS 3", "Y");
|
|
outputfile.set("ANALYSIS 4 - CUST_SUPP_GROUP", "501");
|
|
outputfile.set("E-MAIL ADDRESS", clienti.get(CLI_MAIL));
|
|
outputfile.set("BANK SUB CODE", "00000");
|
|
outputfile.set("Bank Sub Code", "00000");
|
|
outputfile.set("WEB PAGE ADDRESS", "");
|
|
outputfile.set("ACCOUNT CODE", code);
|
|
v = clienti.get(CLI_CODVAL);
|
|
if (v.as_string().blank())
|
|
v = "EUR";
|
|
outputfile.set("CURRENCY CODE", v);
|
|
outputfile.set("CREDIT LIMIT", clienti.get(CLI_FIDO));
|
|
|
|
v = clienti.get(CLI_CODPAG);
|
|
pag2pag(v);
|
|
outputfile.set("PAYMENT TERMS GROUP", v);
|
|
|
|
outputfile.set("Name/Address 1", ragsoc);
|
|
TString s(clienti.get(CLI_INDCF).as_string());
|
|
s << " " << clienti.get(CLI_CIVCF).as_string();;
|
|
outputfile.set("Name/Address 2", s);
|
|
outputfile.set("Name/Address 3", clienti.get(CLI_LOCCF));
|
|
|
|
TString key; key << "|" << clienti.get(CLI_COMCF).as_string();
|
|
const TRectype & rec = cache().get(LF_COMUNI, key);
|
|
|
|
outputfile.set("Town/City", rec.get(COM_DENCOM));
|
|
outputfile.set("State", rec.get(COM_PROVCOM));
|
|
outputfile.set("Postal Code", rec.get(COM_CAPCOM));
|
|
descr = clienti.get(CLI_STATOPAIV).as_string();
|
|
if (descr.blank())
|
|
descr = "IT";
|
|
outputfile.set("Country", descr);
|
|
s = clienti.get(CLI_PTEL).as_string();
|
|
if (s.full())
|
|
s << "/" ;
|
|
s << clienti.get(CLI_TEL).as_string() << " " << clienti.get(CLI_PTEL2).as_string();
|
|
if (clienti.get(CLI_PTEL2).as_string().full())
|
|
s << "/" ;
|
|
s << clienti.get(CLI_TEL2).as_string() << " "<< clienti.get(CLI_PTEL3).as_string();
|
|
if (clienti.get(CLI_PTEL3).as_string().full())
|
|
s << "/" ;
|
|
s << clienti.get(CLI_TEL3).as_string();
|
|
outputfile.set("Telephone Number", s);
|
|
s = clienti.get(CLI_PFAX).as_string();
|
|
if (s.full())
|
|
s << "/" ;
|
|
s << clienti.get(CLI_FAX).as_string();
|
|
v = s;
|
|
outputfile.set("Telex/Fax Number", s);
|
|
outputfile.set("Long Description", ragsoc);
|
|
outputfile.set("Short Heading", shortragsoc);
|
|
outputfile.set("Lookup Code", shortragsoc);
|
|
outputfile.set("Comment", clienti.get(CLI_REFERENTE));
|
|
if (pi.blank())
|
|
{
|
|
pi = cofi;
|
|
cofi = "";
|
|
}
|
|
outputfile.set("Vat Code", pi);
|
|
pin.addstatus(1L);;
|
|
if (pin.iscancelled())
|
|
break;
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::export_fornitori(const TTrasf_mask & m)
|
|
{
|
|
TFornitori_textset outputfile;
|
|
TFilename name = m.get(F_PATH);
|
|
TString div;
|
|
TString descr;
|
|
TVariant v;
|
|
const TString16 wm("ABCDEHLMPRST");
|
|
|
|
ditta2div(prefix().get_codditta(), div);
|
|
name.add("fornitori.slk");
|
|
|
|
TISAM_recordset fornitori("USE CLIFO SELECT TIPOCF==\"F\"");
|
|
TProgind pin(fornitori.items(), TR("Esportazione Fornitori"), true, true);
|
|
|
|
for (bool ok = fornitori.move_first(); ok; ok = fornitori.move_next())
|
|
{
|
|
TVariant code;
|
|
TString sl(fornitori.get(CLI_RAGSOC).as_string());
|
|
|
|
if (sl.len() > 30 && sl[29] == ' ')
|
|
{
|
|
TString sr(sl.mid(30));
|
|
|
|
sl = sl.left(30);
|
|
sl.trim();
|
|
sl << " " << sr;
|
|
}
|
|
|
|
TVariant ragsoc(sl);
|
|
TVariant shortragsoc(sl.left(15));
|
|
TString pi(fornitori.get(CLI_PAIV).as_string());
|
|
TString cofi(fornitori.get(CLI_COFI).as_string());
|
|
|
|
if (pi.blank() || cofi.blank())
|
|
continue;
|
|
cli2code(fornitori.cursor()->curr(), div, code, descr);
|
|
outputfile.new_rec();
|
|
outputfile.set("SUPPLIER CODE", code);
|
|
outputfile.set("NAME", ragsoc);
|
|
outputfile.set("LOOKUP CODE", shortragsoc);
|
|
outputfile.set("SHORT HEADING", shortragsoc);
|
|
outputfile.set("DESCRIPTION", ragsoc);
|
|
outputfile.set("LONG DESCRIPTION", ragsoc);
|
|
outputfile.set("E-MAIL ADDRESS", fornitori.get(CLI_MAIL));
|
|
outputfile.set("WEB PAGE ADDRESS", "");
|
|
outputfile.set("ACCOUNT CODE", code);
|
|
v = fornitori.get(CLI_CODVAL);
|
|
if (v.as_string().blank())
|
|
v = "EUR";
|
|
outputfile.set("CURRENCY CODE", v);
|
|
outputfile.set("CREDIT LIMIT", fornitori.get(CLI_FIDO));
|
|
|
|
v = fornitori.get(CLI_CODPAG);
|
|
pag2pag(v);
|
|
outputfile.set("PAYMENT TERMS GROUP", v);
|
|
|
|
outputfile.set("Name/Address 1", ragsoc);
|
|
TString s(fornitori.get(CLI_INDCF).as_string());
|
|
s << " " << fornitori.get(CLI_CIVCF).as_string();;
|
|
outputfile.set("Name/Address 2", s);
|
|
outputfile.set("Name/Address 3", fornitori.get(CLI_LOCCF));
|
|
|
|
TString key; key << "|" << fornitori.get(CLI_COMCF).as_string();
|
|
const TRectype & rec = cache().get(LF_COMUNI, key);
|
|
|
|
outputfile.set("Town/City", rec.get(COM_DENCOM));
|
|
outputfile.set("State", rec.get(COM_PROVCOM));
|
|
outputfile.set("Postal Code", rec.get(COM_CAPCOM));
|
|
v = fornitori.get(CLI_STATOPAIV);
|
|
if (v.as_string().blank())
|
|
v = "IT";
|
|
outputfile.set("Country", v);
|
|
s = fornitori.get(CLI_PTEL).as_string();
|
|
if (s.full())
|
|
s << "/" ;
|
|
s << fornitori.get(CLI_TEL).as_string() << " " << fornitori.get(CLI_PTEL2).as_string();
|
|
if (fornitori.get(CLI_PTEL2).as_string().full())
|
|
s << "/";
|
|
s << fornitori.get(CLI_TEL2).as_string() << " " << fornitori.get(CLI_PTEL3).as_string();
|
|
if (fornitori.get(CLI_PTEL3).as_string().full())
|
|
s << "/";
|
|
s << fornitori.get(CLI_TEL3).as_string();
|
|
outputfile.set("Telephone Number", s);
|
|
s = fornitori.get(CLI_PFAX).as_string();
|
|
if (s.full())
|
|
s << "/" ;
|
|
s << fornitori.get(CLI_FAX).as_string();
|
|
outputfile.set("Telex/Fax Number", s);
|
|
outputfile.set("Long Description", ragsoc);
|
|
outputfile.set("Short Heading", shortragsoc);
|
|
outputfile.set("Lookup Code", shortragsoc);
|
|
const TString8 abi(fornitori.get(CLI_CODABI).as_string());
|
|
TString16 cab(abi) ;
|
|
|
|
cab << fornitori.get(CLI_CODCAB).as_string();
|
|
|
|
const TRectype & abirec = cache().get("%BAN", abi);
|
|
const TRectype & cabrec = cache().get("%BAN", cab);
|
|
|
|
v = abirec.get("S0");
|
|
outputfile.set("Bank Lookup Code", v);
|
|
outputfile.set("Bank Account Name", v);
|
|
outputfile.set("Bank Name", v);
|
|
outputfile.set("Bank Address Code", cab);
|
|
outputfile.set("Bank Account Number", fornitori.get(CLI_NUMCC));
|
|
outputfile.set("Bank Branch", cabrec.get("S0"));
|
|
v = fornitori.get(CLI_IBAN).as_string();
|
|
if (v.as_string().len() > 5)
|
|
{
|
|
v = v.as_string().left(5);
|
|
outputfile.set("Bank Sorting Code", v);
|
|
}
|
|
outputfile.set("Comment", fornitori.get(CLI_REFERENTE));
|
|
v = "";
|
|
const bool persona = cofi.len() > 11;
|
|
if (persona)
|
|
v = atoi(cofi.mid(9,2)) > 31 ? "F" :"M";
|
|
if (pi.blank())
|
|
{
|
|
pi = cofi;
|
|
cofi = "";
|
|
}
|
|
outputfile.set("Vat Code", pi);
|
|
outputfile.set("Fiscal Code", cofi);
|
|
outputfile.set("Fiscal Code", cofi);
|
|
outputfile.set("Sex", v);
|
|
|
|
outputfile.set("ANALYSIS 1 - COA_UK", "CREDITORS<1YR");
|
|
outputfile.set("ANALYSIS 2", "SOUTH");
|
|
outputfile.set("ANALYSIS 3", "Y");
|
|
outputfile.set("BANK SUB CODE", "00000");
|
|
outputfile.set("Bank Sub Code", "00000");
|
|
if (!persona)
|
|
{
|
|
outputfile.set("ANALYSIS 4 - CUST_SUPP_GROUP", "001");
|
|
outputfile.set("ANALYSIS 5 - WITHHOLD_TAX", "");
|
|
}
|
|
else
|
|
{
|
|
outputfile.set("ANALYSIS 4 - CUST_SUPP_GROUP", "201");
|
|
outputfile.set("ANALYSIS 5 - WITHHOLD_TAX", "10401");
|
|
const int year = 1900 + atoi(cofi.mid(6, 2));
|
|
int month = wm.find(cofi[8]) + 1;
|
|
int day = atoi(cofi.mid(9, 2));
|
|
|
|
if (month < 1)
|
|
month = 1;
|
|
if (day > 40)
|
|
day -= 40;
|
|
|
|
const TDate datanasc(day, month, year);
|
|
|
|
v = datanasc.string(full, '/');
|
|
outputfile.set("Birth Date", v);
|
|
key = "|"; key << cofi.mid(11, 4);
|
|
|
|
const TRectype & recnasc = cache().get(LF_COMUNI, key);
|
|
|
|
v = recnasc.get(COM_DENCOM);
|
|
const TString & prov = recnasc.get(COM_PROVCOM);
|
|
if (prov.full())
|
|
{
|
|
v += " (";
|
|
v += (const char *) prov;
|
|
v += ")";
|
|
}
|
|
outputfile.set("Birth Town", v);
|
|
}
|
|
pin.addstatus(1L);;
|
|
if (pin.iscancelled())
|
|
break;
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::load_partite_aperte(const TTrasf_mask & m, const char * tipocf, TPartite_array &part)
|
|
{
|
|
TString query;
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
|
|
query << "USE PART SELECT (NRIGA==1)&&(TIPOC==\"" << tipocf << "\")";
|
|
|
|
TISAM_recordset partite(query);
|
|
TProgind pin(partite.items(), TR("Caricamento Partite Aperte"), true, true);
|
|
|
|
for (bool ok = partite.move_first(); ok; ok = partite.move_next())
|
|
{
|
|
TPartita * p = new TPartita(partite.cursor()->curr());
|
|
TImporto saldo = p->calcola_saldo_al(false, datalim, datalim, datalim);
|
|
|
|
saldo.normalize('D');
|
|
if (saldo.valore() != ZERO)
|
|
part.insert(p);
|
|
else
|
|
delete p;
|
|
pin.addstatus(1L);;
|
|
if (pin.iscancelled())
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
void TTrasf_app::export_partite_clienti(const TTrasf_mask & m)
|
|
{
|
|
TPartCliFo_textset outputfile;
|
|
TFilename name = m.get(F_PATH);
|
|
TPartite_array part;
|
|
TString descr;
|
|
long line = 0L;
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
TString div;
|
|
TVariant v;
|
|
|
|
ditta2div(prefix().get_codditta(), div);
|
|
name.add("partcli.slk");
|
|
|
|
load_partite_aperte(m, "C", part);
|
|
TProgind pi(part.items(), TR("Esportazione Partite Clienti"), true, true);
|
|
|
|
for (const TPartita * p = part.first(); p != NULL; p = part.next())
|
|
{
|
|
TImporto saldo = p->calcola_saldo_al(false, datalim, datalim, datalim);
|
|
TImporto saldoval = p->calcola_saldo_al(true, datalim, datalim, datalim);
|
|
TVariant code;
|
|
TVariant grouped_code;
|
|
TString key("C|");
|
|
int row = p->prima_fattura();
|
|
|
|
if (row < 0)
|
|
row = 1;
|
|
|
|
const TRiga_partite & rigafatt = p->riga(row);
|
|
|
|
key << rigafatt.get(PART_SOTTOCONTO);
|
|
|
|
const TRectype & rec = cache().get(LF_CLIFO, key);
|
|
const bool grouped = cli2code(rec, div, code, descr);
|
|
|
|
outputfile.new_rec();
|
|
outputfile.set("Line No", ++line);
|
|
outputfile.set("Codice Conto", code);
|
|
outputfile.set("Descrizione Conto", descr);
|
|
outputfile.set("Data Fattura / NC", rigafatt.get_date(PART_DATADOC));
|
|
outputfile.set("Numero Fattura / NC", rigafatt.get(PART_NUMDOC));
|
|
if (!grouped)
|
|
v = rigafatt.get(PART_DESCR);
|
|
else
|
|
{
|
|
const TRectype & reccli = cache().get(LF_CLIFO, key);
|
|
|
|
descr = reccli.get(CLI_COFI);
|
|
descr << " " << reccli.get(CLI_RAGSOC);
|
|
v = descr;
|
|
}
|
|
outputfile.set("Descrizione", v);
|
|
saldo.normalize('D');
|
|
outputfile.set("Importo Euro (Avere = negativo)", saldo.valore());
|
|
if (rigafatt.get(PART_CODVAL).full())
|
|
v = rigafatt.get(PART_CODVAL);
|
|
else
|
|
v = "EUR";
|
|
outputfile.set("Cod Valuta", v);
|
|
saldoval.normalize('D');
|
|
outputfile.set("Importo in Valuta", saldoval.valore());
|
|
|
|
const int nrate = rigafatt.rate();
|
|
|
|
if (nrate > 0)
|
|
outputfile.set("Data Scadenza", rigafatt.rata(rigafatt.rate()).get_date(SCAD_DATASCAD));
|
|
outputfile.set("T7 - Prot Iva", rigafatt.get(PART_PROTIVA));
|
|
outputfile.set("T9 - Divisione", div);
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::export_partite_fornitori(const TTrasf_mask & m)
|
|
{
|
|
TPartCliFo_textset outputfile;
|
|
TPartForPer_textset outputfileper;
|
|
TFilename name = m.get(F_PATH);
|
|
TFilename nameper = m.get(F_PATH);
|
|
TPartite_array part;
|
|
TString descr;
|
|
long line = 0L;
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
TString div;
|
|
TVariant v;
|
|
long nummov = 0L;
|
|
|
|
ditta2div(prefix().get_codditta(), div);
|
|
|
|
name.add("partfor.slk");
|
|
nameper.add("partforper.slk");
|
|
|
|
load_partite_aperte(m, "F", part);
|
|
TProgind pin(part.items(), TR("Esportazione Partite Fornitori"), true, true);
|
|
|
|
for (const TPartita * p = part.first(); p != NULL; p = part.next())
|
|
{
|
|
TImporto saldo = p->calcola_saldo_al(false, datalim, datalim, datalim);
|
|
TImporto saldoval = p->calcola_saldo_al(true, datalim, datalim, datalim);
|
|
TVariant code;
|
|
TString key("F|");
|
|
int row = p->prima_fattura();
|
|
|
|
if (row < 0)
|
|
row = 1;
|
|
|
|
const TRiga_partite & rigafatt = p->riga(row);
|
|
|
|
key << rigafatt.get(PART_SOTTOCONTO);
|
|
|
|
const TRectype & rec = cache().get(LF_CLIFO, key);
|
|
const bool percipiente = rec.get_char(CLI_TIPOAPER) == 'F' && rec.get_char(CLI_CODANAGPER);
|
|
|
|
if (percipiente)
|
|
{
|
|
const long numreg = rigafatt.get_long(PART_NREG);
|
|
|
|
if (numreg > 0L)
|
|
{
|
|
TMovimentoPN movim;
|
|
|
|
movim.lfile().put(MOV_NUMREG, numreg);
|
|
movim.read();
|
|
|
|
const TDate datareg = movim.lfile().get_date(MOV_DATAREG);
|
|
TDate datadoc = movim.lfile().get_date(MOV_DATADOC);
|
|
const TString d = movim.lfile().get(MOV_DESCR);
|
|
const TString rifdoc(movim.lfile().get(MOV_NUMDOC));
|
|
const real ritfis(movim.lfile().get_real(MOV_RITFIS));
|
|
const real totdoc = movim.lfile().get_real(MOV_TOTDOC) + ritfis;
|
|
TString protiva(movim.lfile().get(MOV_PROTIVA));
|
|
|
|
protiva << movim.lfile().get(MOV_REG);
|
|
if (!datadoc.ok())
|
|
datadoc = datareg;
|
|
nummov++;
|
|
long rowno = 0;
|
|
const int rowscg = movim.cg_items();
|
|
const int rowsiva = movim.iva_items();
|
|
for (int i = 0; i < rowscg; i++)
|
|
{
|
|
const TRectype & row = movim.cg(i);
|
|
|
|
if (row.get_char(RMV_ROWTYPE) == 'T')
|
|
{
|
|
outputfileper.new_rec();
|
|
|
|
outputfileper.set("Data Reg ne", datareg);
|
|
|
|
TBill c(row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO), row.get_char(RMV_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfileper.set("Conto", v);
|
|
outputfileper.set("Descrizione conto", c.descrizione());
|
|
|
|
TImporto val( row.get_char(RMV_SEZIONE), totdoc);
|
|
|
|
val.normalize('D');
|
|
v = row.get(RMV_DESCR);
|
|
if (v.as_string().blank())
|
|
v = d;
|
|
outputfileper.set("Descrizione", v);
|
|
outputfileper.set("Imp. Euro", val.valore());
|
|
outputfileper.set("Data Doc to", datadoc);
|
|
outputfileper.set("Rif. Doc to", rifdoc);
|
|
outputfileper.set("N Giornale", nummov); // num.reg.
|
|
rowno++;
|
|
outputfileper.set("N Riga Giorn.", rowno); // num.rig
|
|
outputfileper.set("Cod Valuta", "EUR");
|
|
outputfileper.set("Imp Valuta", val.valore());
|
|
outputfileper.set("Centro di Costo", row.get(RMV_CODCMS));
|
|
outputfileper.set("Prot Iva", protiva);
|
|
outputfileper.set("Divisione", div);
|
|
if (ritfis != ZERO)
|
|
{
|
|
outputfileper.new_rec();
|
|
|
|
outputfileper.set("Data Reg ne", datareg);
|
|
|
|
TBill c(row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO), row.get_char(RMV_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfileper.set("Conto", v);
|
|
outputfileper.set("Descrizione conto", c.descrizione());
|
|
|
|
TImporto val( row.get_char(RMV_SEZIONE), ritfis);
|
|
|
|
val.normalize('D');
|
|
v = row.get(RMV_DESCR);
|
|
if (v.as_string().blank())
|
|
v = d;
|
|
outputfileper.set("Descrizione", v);
|
|
outputfileper.set("Imp. Euro", val.valore());
|
|
outputfileper.set("Data Doc to", datadoc);
|
|
outputfileper.set("Rif. Doc to", rifdoc);
|
|
outputfileper.set("N Giornale", nummov); // num.reg.
|
|
rowno++;
|
|
outputfileper.set("N Riga Giorn.", rowno); // num.rig
|
|
outputfileper.set("Cod Valuta", "EUR");
|
|
outputfileper.set("Imp Valuta", val.valore());
|
|
outputfileper.set("Centro di Costo", row.get(RMV_CODCMS));
|
|
outputfileper.set("Prot Iva", protiva);
|
|
outputfileper.set("Divisione", div);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (row.get(RMV_ROWTYPE) != "I" || rowsiva == 0)
|
|
{
|
|
outputfileper.new_rec();
|
|
|
|
outputfileper.set("Data Reg ne", datareg);
|
|
|
|
TBill c(row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO), row.get_char(RMV_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfileper.set("Conto", v);
|
|
outputfileper.set("Descrizione conto", c.descrizione());
|
|
|
|
TImporto val( row.get_char(RMV_SEZIONE), row.get_real(RMV_IMPORTO));
|
|
|
|
val.normalize('D');
|
|
v = row.get(RMV_DESCR);
|
|
if (v.as_string().blank())
|
|
v = d;
|
|
outputfileper.set("Descrizione", v);
|
|
outputfileper.set("Imp. Euro", val.valore());
|
|
outputfileper.set("Data Doc to", datadoc);
|
|
outputfileper.set("Rif. Doc to", rifdoc);
|
|
outputfileper.set("N Giornale", nummov); // num.reg.
|
|
rowno++;
|
|
outputfileper.set("N Riga Giorn.", rowno); // num.rig
|
|
outputfileper.set("Cod Valuta", "EUR");
|
|
outputfileper.set("Imp Valuta", val.valore());
|
|
outputfileper.set("Centro di Costo", row.get(RMV_CODCMS));
|
|
outputfileper.set("Prot Iva", protiva);
|
|
outputfileper.set("Divisione", div);
|
|
}
|
|
}
|
|
}
|
|
for (int j = 0; j < rowsiva; j++)
|
|
{
|
|
const TRectype & row = movim.iva(j);
|
|
|
|
outputfileper.new_rec();
|
|
|
|
outputfileper.set("Data Reg ne", datareg);
|
|
|
|
TBill c(row.get_int(RMI_GRUPPO), row.get_int(RMI_CONTO), row.get_long(RMI_SOTTOCONTO), row.get_char(RMI_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfileper.set("Conto", v);
|
|
outputfileper.set("Descrizione conto", c.descrizione());
|
|
|
|
const int nrowcg = row.get_int(RMI_RIGAIMP) - 1;
|
|
|
|
if (nrowcg >= 0)
|
|
{
|
|
TImporto val( movim.cg(nrowcg).get_char(RMV_SEZIONE), row.get_real(RMI_IMPONIBILE));
|
|
val.normalize('D');
|
|
outputfileper.set("Imp. Euro", val.valore());
|
|
outputfileper.set("Cod Valuta", "EUR");
|
|
outputfileper.set("Imp Valuta", val.valore());
|
|
}
|
|
else
|
|
message_box("Riga IVA senza sezione mov. %ld riga %d", numreg, i + 1);
|
|
|
|
|
|
v = "";
|
|
if (nrowcg >= 0)
|
|
v = movim.cg(nrowcg).get(RMV_DESCR);
|
|
if (v.as_string().blank())
|
|
v = d;
|
|
outputfileper.set("Descrizione", v);
|
|
outputfileper.set("Data Doc to", datadoc);
|
|
outputfileper.set("Rif. Doc to", rifdoc);
|
|
outputfileper.set("N Giornale", nummov); // num.reg.
|
|
rowno++;
|
|
outputfileper.set("N Riga Giorn.", rowno); // num.rig
|
|
outputfileper.set("Centro di Costo", row.get(RMI_CODCMS));
|
|
|
|
TString codiva(row.get(RMI_CODIVA));
|
|
|
|
iva2iva(codiva, div);
|
|
outputfileper.set("Cod Iva", codiva);
|
|
outputfileper.set("Prot Iva", protiva);
|
|
outputfileper.set("Divisione", div);
|
|
}
|
|
}
|
|
}
|
|
const bool grouped = cli2code(rec, div, code, descr);
|
|
|
|
outputfile.new_rec();
|
|
outputfile.set("Line No", ++line);
|
|
outputfile.set("Codice Conto", code);
|
|
outputfile.set("Descrizione Conto", descr);
|
|
outputfile.set("Data Fattura / NC", rigafatt.get_date(PART_DATADOC));
|
|
outputfile.set("Numero Fattura / NC", rigafatt.get(PART_NUMDOC));
|
|
outputfile.set("Descrizione", rigafatt.get(PART_DESCR));
|
|
saldo.normalize('D');
|
|
outputfile.set("Importo Euro (Avere = negativo)", saldo.valore());
|
|
if (rigafatt.get(PART_CODVAL).full())
|
|
v = rigafatt.get(PART_CODVAL);
|
|
else
|
|
v = "EUR";
|
|
outputfile.set("Cod Valuta", v);
|
|
saldoval.normalize('D');
|
|
outputfile.set("Importo in Valuta", saldoval.valore());
|
|
|
|
const int nrate = rigafatt.rate();
|
|
|
|
if (nrate > 0)
|
|
outputfile.set("Data Scadenza", rigafatt.rata(nrate).get_date(SCAD_DATASCAD));
|
|
descr = rigafatt.get(PART_PROTIVA);
|
|
descr << rigafatt.get(PART_REG);
|
|
outputfile.set("T7 - Prot Iva", descr);
|
|
outputfile.set("T9 - Divisione", div);
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
outputfileper.save_as(nameper, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::export_saldi(const TTrasf_mask & m)
|
|
{
|
|
TArray saldi_ragg;
|
|
TString_array ragg_codes;
|
|
TString_array ragg_descrs;
|
|
TSaldi_textset outputfile;
|
|
TFilename name = m.get(F_PATH);
|
|
long line = 0L;
|
|
TString div;
|
|
TString80 rifdoc("SALDI AP.DIV ");
|
|
TString80 key;
|
|
TVariant v;
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
TDate dataap = datalim;
|
|
TSaldo sld;
|
|
TEsercizi_contabili esc;
|
|
const int codes = esc.date2esc(datalim);
|
|
const TDate dataini = esc.esercizio(codes).inizio();
|
|
|
|
++dataap;
|
|
ditta2div(prefix().get_codditta(), div);
|
|
rifdoc << div;
|
|
|
|
|
|
name.add("saldi.slk");
|
|
|
|
TISAM_recordset saldi("USE SALDI\nFROM ANNOES=#ANNO\nTO ANNOES=#ANNO");
|
|
|
|
saldi.set_var("#ANNO", (long) codes);
|
|
TProgind pin(saldi.items(), TR("Esportazione Saldi"), true, true);
|
|
|
|
for (bool ok = saldi.move_first(); ok; ok = saldi.move_next())
|
|
{
|
|
const TRectype & sal = saldi.cursor()->curr();
|
|
int gruppo = sal.get_int(SLD_GRUPPO);
|
|
int conto = sal.get_int(SLD_CONTO);
|
|
|
|
key.format("%03d|%03d|0", gruppo, conto);
|
|
|
|
const TRectype & contorec = cache().get(LF_PCON, key);
|
|
char tipoconto = contorec.get_char(PCN_TMCF);
|
|
TBill c(gruppo, conto, sal.get_long(SLD_SOTTOCONTO), tipoconto);
|
|
TString descr;
|
|
TVariant code;
|
|
bool grouped = false;
|
|
|
|
if (tipoconto > ' ')
|
|
{
|
|
key.cut(0);
|
|
key << tipoconto << "|" << c.sottoconto();
|
|
const TRectype & rec = cache().get(LF_CLIFO, key);
|
|
|
|
grouped = cli2code(rec, div, code, descr);
|
|
TString c = code.as_string();
|
|
}
|
|
|
|
const int sottoconto = c.sottoconto();
|
|
|
|
const real& saldo = sld.saldo_periodo(gruppo, conto, sottoconto, dataini, datalim, c.indicatore_bilancio(), false);
|
|
|
|
if (saldo != ZERO)
|
|
{
|
|
if (grouped)
|
|
{
|
|
int index = ragg_codes.find(code.as_string());
|
|
|
|
if (index < 0)
|
|
{
|
|
index = ragg_codes.add(code.as_string());
|
|
ragg_descrs.add(descr, index);
|
|
}
|
|
real * imp = (real *) saldi_ragg.objptr(index);
|
|
|
|
if (imp == NULL)
|
|
{
|
|
imp = new real;
|
|
saldi_ragg.add(imp, index);
|
|
}
|
|
(*imp) += saldo;
|
|
}
|
|
else
|
|
{
|
|
outputfile.new_rec();
|
|
outputfile.set("Line No", ++line);
|
|
count2code(c, div, v);
|
|
outputfile.set("Codice Conto", v);
|
|
v = c.descrizione();
|
|
outputfile.set("Descrizione Conto", v);
|
|
outputfile.set("Descrizione", v);
|
|
outputfile.set("Data Documento", dataap);
|
|
v = rifdoc;
|
|
outputfile.set("Riferimento Doc to", v);
|
|
|
|
outputfile.set("Importo Euro (Avere = negativo)", saldo);
|
|
outputfile.set("Cod Valuta", "EUR");
|
|
outputfile.set("Importo in Valuta", saldo);
|
|
outputfile.set("T9 - Divisione", div);
|
|
}
|
|
}
|
|
pin.addstatus(1L);;
|
|
if (pin.iscancelled())
|
|
break;
|
|
}
|
|
for (int i = 0 ; i < saldi_ragg.items(); i++)
|
|
{
|
|
real * imp = (real *) saldi_ragg.objptr(i);
|
|
|
|
if (imp != NULL && *imp != ZERO)
|
|
{
|
|
const TString & code = ragg_codes.row(i);
|
|
const TString & descr = ragg_descrs.row(i);
|
|
outputfile.new_rec();
|
|
outputfile.set("Line No", ++line);
|
|
v = code;
|
|
outputfile.set("Codice Conto", v);
|
|
v = descr;
|
|
outputfile.set("Descrizione Conto", v);
|
|
outputfile.set("Descrizione", v);
|
|
outputfile.set("Data Documento", dataap);
|
|
v = rifdoc;
|
|
outputfile.set("Riferimento Doc to", v);
|
|
|
|
outputfile.set("Importo Euro (Avere = negativo)", *imp);
|
|
outputfile.set("Cod Valuta", "EUR");
|
|
outputfile.set("Importo in Valuta", *imp);
|
|
outputfile.set("T9 - Divisione", div);
|
|
}
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::export_movimenti(const TTrasf_mask & m)
|
|
{
|
|
TMovim_textset outputfile;
|
|
TFilename name = m.get(F_PATH);
|
|
TString div;
|
|
TString80 rifdoc;
|
|
TVariant v;
|
|
TString descr;
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
const TDate datamov = m.get_date(F_DATAMOV);
|
|
TPartite_array p;
|
|
long nummov = 0L;
|
|
|
|
ditta2div(prefix().get_codditta(), div);
|
|
name.add("movim.slk");
|
|
|
|
TISAM_recordset mov("USE MOV");
|
|
TProgind pi(mov.items(), TR("Esportazione Movimenti"), true, true);
|
|
|
|
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
|
{
|
|
const TDate datacomp = mov.get(MOV_DATACOMP).as_date();
|
|
|
|
if (datacomp > datalim && datacomp <= datamov)
|
|
{
|
|
TMovimentoPN movim;
|
|
const long numreg = mov.get(MOV_NUMREG).as_int();
|
|
TDate datadoc = mov.get(MOV_DATADOC).as_date();
|
|
const TString d = mov.get(MOV_DESCR).as_string();
|
|
const TString8 codcaus(mov.get(MOV_CODCAUS).as_string());
|
|
const TString80 descrcau(cache().get(LF_CAUSALI, codcaus, CAU_DESCR));
|
|
TString16 protiva(mov.get(MOV_PROTIVA).as_string());
|
|
|
|
protiva << mov.get(MOV_REG).as_string();
|
|
rifdoc = mov.get(MOV_NUMDOC).as_string();
|
|
if (!datadoc.ok())
|
|
datadoc = mov.get(MOV_DATAREG).as_date();
|
|
|
|
movim.lfile().put(MOV_NUMREG, numreg);
|
|
movim.read();
|
|
p.destroy();
|
|
p.add_numreg(numreg);
|
|
TPartita * par;
|
|
int rowpart = -1;
|
|
if (mov.get(MOV_REG).as_string().full())
|
|
for (par = p.first(); rowpart < 0 && par != NULL; par = p.next())
|
|
rowpart = par->prima_fattura(numreg);
|
|
|
|
nummov++;
|
|
long rowno = 0;
|
|
const int rowscg = movim.cg_items();
|
|
const int rowsiva = movim.iva_items();
|
|
for (int i = 0; i < rowscg; i++)
|
|
{
|
|
const TRectype & row = movim.cg(i);
|
|
|
|
if (row.get_char(RMV_ROWTYPE) == 'T' && rowpart >= 0)
|
|
{
|
|
const TRiga_partite & rp = p.first()->riga(rowpart);
|
|
const int rate = rp.rate();
|
|
TVariant v;
|
|
TString descr;
|
|
|
|
for (int j = 0; j < rate; j++)
|
|
{
|
|
const TRiga_scadenze & sc = rp.rata(j + 1);
|
|
|
|
outputfile.new_rec();
|
|
|
|
outputfile.set("Mov No", nummov);
|
|
rowno++;
|
|
outputfile.set("Line No", rowno);
|
|
|
|
TBill c(row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO), row.get_char(RMV_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfile.set("Codice Conto", v);
|
|
outputfile.set("Descrizione Conto", c.descrizione());
|
|
outputfile.set("Data Documento", datadoc);
|
|
outputfile.set("Riferimento Doc to", rifdoc);
|
|
descr = row.get(RMV_DESCR);
|
|
if (descr.blank())
|
|
descr = d;
|
|
outputfile.set("Descrizione", descr);
|
|
TImporto val = sc.importo(false);
|
|
|
|
val.normalize('D');
|
|
outputfile.set("Importo Euro (Avere = negativo)", val.valore());
|
|
outputfile.set("Cod Valuta", "EUR");
|
|
outputfile.set("Importo in Valuta", val.valore());
|
|
outputfile.set("Data Scadenza", sc.get_date(SCAD_DATASCAD));
|
|
outputfile.set("T3 - Non utilizzare: Centro di Costo", row.get(RMV_CODCMS));
|
|
outputfile.set("T7 - Prot Iva", protiva);
|
|
outputfile.set("T9 - Divisione", div);
|
|
outputfile.set("T10 - Codice Causale originale", codcaus);
|
|
outputfile.set("Descrizione Causale originale", descrcau);
|
|
outputfile.set("Numero operazione originale", numreg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (row.get(RMV_ROWTYPE) != "I" || rowsiva == 0)
|
|
{
|
|
outputfile.new_rec();
|
|
outputfile.set("Mov No", nummov);
|
|
rowno++;
|
|
outputfile.set("Line No", rowno);
|
|
|
|
TBill c(row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO), row.get_char(RMV_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfile.set("Codice Conto", v);
|
|
outputfile.set("Descrizione Conto", c.descrizione());
|
|
outputfile.set("Data Documento", datadoc);
|
|
outputfile.set("Riferimento Doc to", rifdoc);
|
|
descr = row.get(RMV_DESCR);
|
|
if (descr.blank())
|
|
descr = d;
|
|
outputfile.set("Descrizione", descr);
|
|
TImporto val( row.get_char(RMV_SEZIONE), row.get_real(RMV_IMPORTO));
|
|
|
|
val.normalize('D');
|
|
outputfile.set("Importo Euro (Avere = negativo)", val.valore());
|
|
outputfile.set("Cod Valuta", "EUR");
|
|
outputfile.set("Importo in Valuta", val.valore());
|
|
outputfile.set("T3 - Non utilizzare: Centro di Costo", row.get(RMV_CODCMS));
|
|
outputfile.set("T7 - Prot Iva", protiva);
|
|
outputfile.set("T9 - Divisione", div);
|
|
outputfile.set("T10 - Codice Causale originale", codcaus);
|
|
outputfile.set("Descrizione Causale originale", descrcau);
|
|
outputfile.set("Numero operazione originale", numreg);
|
|
|
|
}
|
|
}
|
|
}
|
|
for (int j = 0; j < rowsiva; j++)
|
|
{
|
|
const TRectype & row = movim.iva(j);
|
|
|
|
outputfile.new_rec();
|
|
outputfile.set("Mov No", nummov);
|
|
rowno++;
|
|
outputfile.set("Line No", rowno);
|
|
|
|
TBill c(row.get_int(RMI_GRUPPO), row.get_int(RMI_CONTO), row.get_long(RMI_SOTTOCONTO), row.get_char(RMI_TIPOC));
|
|
|
|
count2code(c, div, v);
|
|
outputfile.set("Codice Conto", v);
|
|
outputfile.set("Descrizione Conto", c.descrizione());
|
|
outputfile.set("Data Documento", datadoc);
|
|
outputfile.set("Riferimento Doc to", rifdoc);
|
|
const int nrowcg = row.get_int(RMI_RIGAIMP) - 1;
|
|
descr.cut(0);
|
|
if (nrowcg >= 0)
|
|
descr = movim.cg(nrowcg).get(RMV_DESCR);
|
|
if (descr.blank())
|
|
descr = d;
|
|
outputfile.set("Descrizione", descr);
|
|
if (nrowcg >= 0)
|
|
{
|
|
TImporto val( movim.cg(nrowcg).get_char(RMV_SEZIONE), row.get_real(RMI_IMPONIBILE));
|
|
val.normalize('D');
|
|
outputfile.set("Importo Euro (Avere = negativo)", val.valore());
|
|
outputfile.set("Cod Valuta", "EUR");
|
|
outputfile.set("Importo in Valuta", val.valore());
|
|
}
|
|
else
|
|
message_box("Riga IVA senza sezione mov. %ld riga %d", numreg, i + 1);
|
|
|
|
outputfile.set("Data Scadenza", datalim); // ??????
|
|
outputfile.set("T3 - Non utilizzare: Centro di Costo", row.get(RMV_CODCMS));
|
|
|
|
TString codiva = row.get(RMI_CODIVA);
|
|
|
|
iva2iva(codiva, div);
|
|
outputfile.set("T4 - Non utilizzare (Cod Iva)", codiva);
|
|
outputfile.set("T7 - Prot Iva", protiva);
|
|
outputfile.set("T9 - Divisione", div);
|
|
outputfile.set("T10 - Codice Causale originale", codcaus);
|
|
outputfile.set("Descrizione Causale originale", descrcau);
|
|
outputfile.set("Numero operazione originale", numreg);
|
|
}
|
|
|
|
}
|
|
pi.addstatus(1L);;
|
|
if (pi.iscancelled())
|
|
break;
|
|
}
|
|
outputfile.save_as(name, fmt_silk);
|
|
}
|
|
|
|
void TTrasf_app::main_loop()
|
|
{
|
|
TTrasf_mask m;
|
|
while (m.run() != K_QUIT)
|
|
{
|
|
if (m.get_bool(F_CL))
|
|
export_clienti(m);
|
|
if (m.get_bool(F_FO))
|
|
export_fornitori(m);
|
|
if (m.get_bool(F_PC))
|
|
export_partite_clienti(m);
|
|
if (m.get_bool(F_PF))
|
|
export_partite_fornitori(m);
|
|
if (m.get_bool(F_SA))
|
|
export_saldi(m);
|
|
if (m.get_bool(F_MO))
|
|
export_movimenti(m);
|
|
}
|
|
}
|
|
|
|
int ps0001100(int argc, char* argv[])
|
|
{
|
|
TTrasf_app a;
|
|
a.run(argc, argv, TR("Esportazione Salus"));
|
|
return 0;
|
|
}
|