Aggiunta esportazione per PayLine

git-svn-id: svn://10.65.10.50/branches/R_10_00@22767 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-12-04 16:47:36 +00:00
parent d993d1a9fa
commit 0a2d7f4399
10 changed files with 398 additions and 20 deletions

View File

@ -14,10 +14,9 @@ int main(int argc, char** argv)
case 5: tc0600(argc,argv); break; //importazione PCon, Cuas, CodIVA
case 6: tc0700(argc,argv); break; //esportazione contabilita' a TeamSystem
case 7: tc0800(argc,argv); break; // Riclassificazione conti TeamSystem
case 8: tc0900(argc,argv); break; // COnverione archivi CAMPO
default: ; tc0100(argc,argv); break;
case 8: tc0900(argc,argv); break; // Converione archivi CAMPO
default: tc0100(argc,argv); break;
}
exit(0);
return 0;
}

View File

@ -11,7 +11,7 @@ int main(int argc, char** argv)
case 4: tc2500(argc,argv); break; //gestore tabelle multirel
case 6: tc2700(argc,argv); break; //esportazione contabilita' a TeamSystem
case 7: tc2800(argc,argv); break; // Riclassificazione conti TeamSystem
default: ; tc2100(argc,argv); break;
default: tc2100(argc,argv); break;
}
return 0;
}

View File

@ -7,10 +7,9 @@ int main(int argc, char** argv)
const int op = argc < 2 ? 0 : argv[1][1]-'0';
switch (op)
{
case 0: tc8100(argc,argv); break; // importazione da Semetra
default: tc8100(argc,argv); break;
case 1: tc8200(argc,argv); break;
default: tc8100(argc,argv); break; // importazione da Semetra
}
exit(0);
return 0;
}

View File

@ -2,6 +2,7 @@
#define __TC8_H
int tc8100(int argc, char** argv);
int tc8200(int argc, char** argv);
#endif // __TC8_H

View File

@ -716,7 +716,7 @@ void TClifoCSV::add_riga_spese(TDocumento& doc, const TClifo_recset& s, int spes
}
//inserisco l'ammontare della fattura
const TCurrency tmp = s.get(colonna).as_real() / CENTO;
const real tmp = s.get(colonna).as_real() / CENTO;
if (!tmp.is_zero())
{
const TRectype& rec_spp = cache().get("SPP", tiposp); //leggi il record della tabella SPP corrispondente al codice spesa inserito
@ -846,8 +846,8 @@ void TClifoCSV::upload_fattEric(const TFilename& file, TLog_report& log, const i
rdoc.put(RDOC_QTA,1);
//inserisco l'ammontare dell'Imponibile
const TCurrency imp = s.get(23).as_real() / CENTO;
rdoc.put(RDOC_PREZZO,imp);
const real imp = s.get(23).as_real() / CENTO;
rdoc.put(RDOC_PREZZO, imp);
const TString& perivfile = s.get(16).as_string(); //prendo dal file la percentuale IVA sull'imponibile
const TString* pcodimp = (TString*)codiva.objptr(perivfile);

337
tc/tc8200.cpp Normal file
View File

@ -0,0 +1,337 @@
#include <applicat.h>
#include <automask.h>
#include <progind.h>
#include <recarray.h>
#include <relation.h>
#include <reputils.h>
#include <textset.h>
#include <validate.h>
#include "tc8.h"
#include <clifo.h>
#include <partite.h>
#include <scadenze.h>
#include <pagsca.h>
///////////////////////////////////////////////////////////
// TPayLine_recset
///////////////////////////////////////////////////////////
class TPayLine_recset : public TCSV_recordset
{
public:
TPayLine_recset() : TCSV_recordset("CSV(;)") {}
};
///////////////////////////////////////////////////////////
// TAutomask
///////////////////////////////////////////////////////////
class TPayLine_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TPayLine_mask() :TAutomask ("tc8200a") {}
};
bool TPayLine_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
switch (f.dlg())
{
default:
break;
}
return true;
}
///////////////////////////////////////
// TSkeleton_application
///////////////////////////////////////
class TPayLine_app : public TSkeleton_application
{
protected:
bool find_clifo(long codcf, TPayLine_recset& clienti) const;
long export_clifo(long codcf, TPayLine_recset& clienti, TLog_report& log) const;
bool esporta(const TString& dir, const TDate& dt, TLog_report& log) const;
public:
virtual void main_loop();
};
bool TPayLine_app::find_clifo(long codcf, TPayLine_recset& clienti) const
{
for (bool ok = clienti.move_first(); ok; ok = clienti.move_next())
{
if (clienti.get(0L).as_int() == codcf)
return true;
}
return false;
}
long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_report& log) const
{
TString8 key; key.format("C|%ld", codcf);
TRectype rec = cache().get(LF_CLIFO, key);
TString msg, str;
str = rec.get(CLI_RAGSOC);
str.strip_double_spaces();
msg << codcf << ' ' << str << ": ";
if (rec.get_bool(CLI_OCCAS))
{
msg << TR("OCCASIONALE");
log.log(1, msg);
return -1;
}
int alleg = rec.get_int(CLI_ALLEG);
while (alleg == 4)
{
alleg = 0;
const long altcf = rec.get_long(CLI_CODALLEG);
if (altcf > 0)
{
key.format("C|%ld", codcf);
rec = cache().get(LF_CLIFO, key);
if (!rec.empty())
{
codcf = altcf;
alleg = rec.get_int(CLI_ALLEG); // Ok, go on with new code
}
}
}
if (alleg >= 2 && alleg != 7)
{
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;
}
if (find_clifo(codcf, clienti))
return codcf; // Already saved
TToken_string row(256, ';');
row << codcf;
str = rec.get(CLI_RAGSOC);
str.strip_double_spaces(); str.strip(";");
row.add(str);
str = rec.get(CLI_INDCF);
str << ' ' << rec.get(CLI_CIVCF);
row.add(str);
row.add(rec.get(CLI_CAPCF), 3);
row.add(rec.get(CLI_LOCCF), 4);
TString4 stato = rec.get(CLI_STATOPAIV); // ""=Italia; "SM"=San Marino
str = rec.get(CLI_PAIV);
if (str.blank())
str = rec.get(CLI_COFI);
if (str.starts_with("SM"))
{
stato = "SM";
str = str.right(5);
}
if (stato != "SM")
stato = "IT";
row.add(stato, 6); // Stato partita IVA
if (!pi_check(stato, str))
{
msg << TR("Partita IVA non valida ") << str;
log.log(2, msg);
return -3; // Partita IVA non italiana?
}
if (stato != "SM") // No San Marino!
{
row.add(str, 7); // P.I.
row.add(rec.get(CLI_COFI), 8); // C.F.
}
clienti.new_rec(row);
return codcf;
}
bool TPayLine_app::esporta(const TString& dir, const TDate& al, TLog_report& log) const
{
TDate dal(al);
dal.set_day(1); // A scanso equivoci bisestili
dal.addyear(-1);
TPayLine_recset clienti;
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";
TISAM_recordset mov(query);
const TRectype& scad = mov.cursor()->curr();
const TRectype& part = mov.cursor()->curr(LF_PARTITE);
long lastcf = 0;
TProgind pi(mov.items(), log.title());
TToken_string row(256, ';');
TString str;
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
{
if (!pi.addstatus(1))
break;
const TDate datascad = scad.get(SCAD_DATASCAD);
if (scad.get_bool(SCAD_PAGATA) || part.get_bool(PART_CHIUSA))
{
if (datascad < dal)
continue; // Ignora vecchia partita chiusa
}
const long codcf = scad.get_long(SCAD_SOTTOCONTO);
if (codcf != lastcf)
{
lastcf = export_clifo(codcf, clienti, log);
if (lastcf <= 0)
continue;
}
str.cut(0) << lastcf; str.right_just(6);
row.add(str, 0); // 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
row.add(row.get(2), 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
row.add(scad.get_real(SCAD_IMPORTO).stringa(10,2), 8); // Importo
row.add(part.get(PART_SEZ), 9); // Dare/Avere
row.add("EF1#", 10); // Causale Fattura
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);
for (int r = pagsca.first_row(); r > 0 && r <= pagsca.last_row(); r = pagsca.succ_row(r))
{
const TRectype& pag = pagsca.row(r);
key.add(r, 6);
const TRectype& part = cache().get(LF_PARTITE, key);
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(part.get(PART_DATAREG), 5); // Data registrazione
str = part.get(PART_NREG); str.right_just(7);
row.add(str, 6); // Numero registrazione
const int tm = part.get_int(PART_TIPOMOV);
real imp;
if (tm == 3 && pagsca.rows() == 1 && scad.get_bool(SCAD_PAGATA))
{
// Caso semplice: una rata pagata completamene con un solo pagamento
imp = scad.get_real(SCAD_IMPORTO); // Importo pagato = importo da pagare
}
else
{
imp = pag.get_real(PAGSCA_IMPORTO);
if (tm == 3)
{
if (pag.get_char(PAGSCA_PASSATT) == 'P')
imp += pag.get_real(PAGSCA_ABBUONI);
imp += pag.get_real(PAGSCA_RITENUTE);
imp += pag.get_real(PAGSCA_RITSOC);
}
}
row.add(imp.stringa(10,2), 8); // Importo
row.add(part.get(PART_SEZ), 9); // Dare/Avere
switch (tm)
{
case 2: row.add("EF7#", 10); // Nota di credito
case 5: row.add("EF5#", 10); // Insoluto
default: row.add("EF6#", 10); // Causale pagamento
}
row.add(part.get(PART_DATAPAG), 12); // Data pagamento
movimenti.new_rec(row);
}
}
TString msg;
log.log(0, msg);
msg << TR("Esportati ")
<< movimenti.items() << TR(" movimenti di ")
<< clienti.items() << TR(" clienti")
<< TR(" al ") << al;
log.log(0, msg);
TFilename fname = dir; fname.add("PLclienti.txt");
clienti.save_as(fname);
fname = dir; fname.add("PLmovimenti.txt");
return movimenti.save_as(fname);
}
void TPayLine_app::main_loop()
{
TPayLine_mask m;
while (m.run() == K_ENTER)
{
const TString& dir = m.get(101);
const TDate limit = m.get(102);
TString tit;
tit << title() << " al " << limit;
TLog_report log(tit);
log.kill_duplicates();
esporta(dir, limit, log);
log.preview();
}
}
int tc8200 (int argc, char* argv[])
{
TPayLine_app main_app;
main_app.run(argc, argv, TR("Esportazione PayLine"));
return 0;
}

38
tc/tc8200a.uml Normal file
View File

@ -0,0 +1,38 @@
PAGE "Esportazione PayLine" -1 -1 60 4
GROUPBOX DLG_NULL 58 4
BEGIN
PROMPT 1 0 "@bCartella di destinazione"
END
STRING 101 256 53
BEGIN
PROMPT 2 1 ""
DSELECT
CHECKTYPE REQUIRED
END
DATE 102
BEGIN
PROMPT 2 2 "Elaborazione a partire da un anno prima del "
CHECKTYPE REQUIRED
FLAGS "A"
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

View File

@ -7,11 +7,10 @@ int main(int argc, char** argv)
const int op = argc < 2 ? 0 : argv[1][1]-'0';
switch (op)
{
case 0: tc9100(argc,argv); break; // esiste sulla 4.0 Invio a Proforma
case 1: tc9200(argc,argv); break; // esiste dalla 4.0 Invio a ???
case 2: tc9300(argc,argv); break; // esiste dalla 4.0 Invio a Sispac/Cosmo
case 3: tc9400(argc,argv); break; // esiste dalla 4.0 Tabelle Sispac/Cosmo
default: tc9100(argc,argv); break;
case 1: tc9200(argc,argv); break; // Invio a WHATIS
case 2: tc9300(argc,argv); break; // Invio a Sispac/Cosmo
case 3: tc9400(argc,argv); break; // Tabelle Sispac/Cosmo
default: tc9100(argc,argv); break; // Invio a Proforma
}
return 0;
}

View File

@ -80,9 +80,7 @@ protected:
public:
TInvioW_file* apri_file(const char* nome);
void chiudi_file(TInvioW_file* trasfile);
TConfig& config() {return *_configfile;};
TInvioW() {} ;
virtual ~TInvioW() {} ;
TConfig& config() { return *_configfile; };
};
// restituisce un riferimento all' applicazione

View File

@ -7,8 +7,7 @@ Item_01 = "TeamSystem", [TCMENU_002]
Item_02 = "Zucchetti", [TCMENU_006]
Item_03 = "IPSOA", [TCMENU_010]
Item_04 = "Sispac", [TCMENU_014]
Item_05 = "Proforma", "tc9 -0", ""
Item_06 = "Semetra", "tc8 -0", ""
Item_05 = "Altri", [TCMENU_015]
[TCMENU_002]
Caption = "TeamSystem"
@ -149,3 +148,11 @@ Flags = ""
Item_01 = "Trasferimento", "tc9 -2", ""
Item_02 = "Tabella IVA Sispac", "tc9 -3 IVA", ""
Item_03 = "Tabella causali Sispac", "tc9 -3 CAU", ""
[TCMENU_015]
Caption = "Altri"
Picture = <cg01>
Module = 27
Item_01 = "Proforma", "tc9 -0", ""
Item_02 = "Semetra", "tc8 -0", ""
Item_03 = "PayLine", "tc8 -1", "F"