Aggiunto trasferimendo a PayLine per Straccia Packaging
git-svn-id: svn://10.65.10.50/branches/R_10_00@22779 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0bfd0af032
commit
f0ab065f43
@ -200,7 +200,7 @@ void TDocTS::upload_causali(const TFilename& file, TLog_report& log) const
|
|||||||
|
|
||||||
while (s.ok())
|
while (s.ok())
|
||||||
{
|
{
|
||||||
if (!pi.addstatus(s.tellg()))
|
if (!pi.addstatus((long)s.tellg()))
|
||||||
break;
|
break;
|
||||||
causa.zero();
|
causa.zero();
|
||||||
curr = s.line();
|
curr = s.line();
|
||||||
@ -252,7 +252,7 @@ void TDocTS::upload_codiva(const TFilename& file, TLog_report& log) const
|
|||||||
|
|
||||||
while(s.ok())
|
while(s.ok())
|
||||||
{
|
{
|
||||||
if (!pi.addstatus(s.tellg()))
|
if (!pi.addstatus((long)s.tellg()))
|
||||||
break;
|
break;
|
||||||
//salto le righe di testata del file
|
//salto le righe di testata del file
|
||||||
iva.zero();
|
iva.zero();
|
||||||
|
439
tc/tc8200.cpp
439
tc/tc8200.cpp
@ -1,11 +1,14 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <automask.h>
|
#include <automask.h>
|
||||||
|
#include <dongle.h>
|
||||||
|
#include <netsock.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <reputils.h>
|
#include <reputils.h>
|
||||||
#include <textset.h>
|
#include <textset.h>
|
||||||
#include <validate.h>
|
#include <validate.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
#include "tc8.h"
|
#include "tc8.h"
|
||||||
|
|
||||||
@ -40,11 +43,6 @@ public:
|
|||||||
|
|
||||||
bool TPayLine_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
bool TPayLine_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
||||||
{
|
{
|
||||||
switch (f.dlg())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +53,18 @@ bool TPayLine_mask::on_field_event(TOperable_field& f, TField_event e, long joll
|
|||||||
class TPayLine_app : public TSkeleton_application
|
class TPayLine_app : public TSkeleton_application
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool find_clifo(long codcf, TPayLine_recset& clienti) const;
|
virtual bool create();
|
||||||
long export_clifo(long codcf, TPayLine_recset& clienti, TLog_report& log) const;
|
virtual const char* extra_modules() { return "cg"; }
|
||||||
bool esporta(const TString& dir, const TDate& dt, TLog_report& log) const;
|
virtual void main_loop();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void main_loop();
|
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,
|
||||||
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool TPayLine_app::find_clifo(long codcf, TPayLine_recset& clienti) const
|
bool TPayLine_app::find_clifo(long codcf, TPayLine_recset& clienti) const
|
||||||
@ -127,10 +131,11 @@ long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_repor
|
|||||||
|
|
||||||
TToken_string row(256, ';');
|
TToken_string row(256, ';');
|
||||||
|
|
||||||
row << codcf;
|
row.format("%6ld", codcf);
|
||||||
|
|
||||||
str = rec.get(CLI_RAGSOC);
|
str = rec.get(CLI_RAGSOC);
|
||||||
str.strip_double_spaces(); str.strip(";");
|
str.strip_double_spaces(); str.strip(";");
|
||||||
|
str.left_just(50);
|
||||||
row.add(str);
|
row.add(str);
|
||||||
|
|
||||||
str = rec.get(CLI_INDCF);
|
str = rec.get(CLI_INDCF);
|
||||||
@ -171,7 +176,203 @@ long TPayLine_app::export_clifo(long codcf, TPayLine_recset& clienti, TLog_repor
|
|||||||
return codcf;
|
return codcf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPayLine_app::esporta(const TString& dir, const TDate& al, TLog_report& log) const
|
bool TPayLine_app::esporta_pagsca(const TRectype& pag, const TRectype& scad, bool unico,
|
||||||
|
TPayLine_recset& clienti, TPayLine_recset& movimenti,
|
||||||
|
TLog_report& log) const
|
||||||
|
{
|
||||||
|
const long codcf = pag.get_long(PAGSCA_SOTTOCONTO);
|
||||||
|
const long lastcf = export_clifo(codcf, clienti, log);
|
||||||
|
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!
|
||||||
|
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
row.add(row.get(1), 3); // Data riferimento
|
||||||
|
str = part.get(PART_NUMPART); str.left_just(8);
|
||||||
|
row.add(str, 4); // Numero Riferimento
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = fatt.get(PART_DATADOC); // Data riferimento
|
||||||
|
if (!data.ok())
|
||||||
|
data = fatt.get_date(PART_DATAREG);
|
||||||
|
str = data.stringa(); str.left_just(10);
|
||||||
|
row.add(str, 3);
|
||||||
|
str = fatt.get(PART_NUMPART); str.left_just(8);
|
||||||
|
row.add(str, 4); // Numero Riferimento
|
||||||
|
}
|
||||||
|
|
||||||
|
str = part.get(PART_DATAREG);
|
||||||
|
str.left_just(10);
|
||||||
|
row.add(str, 5); // Data registrazione
|
||||||
|
|
||||||
|
str = part.get(PART_NREG); str.right_just(7);
|
||||||
|
row.add(str, 6); // Numero registrazione
|
||||||
|
|
||||||
|
str = scad.get(SCAD_DATASCAD); str.left_just(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))
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
str = part.get(PART_SEZ);
|
||||||
|
if (imp < ZERO)
|
||||||
|
{
|
||||||
|
imp = -imp;
|
||||||
|
str = str == "D" ? "A" : "D";
|
||||||
|
}
|
||||||
|
row.add(imp.stringa(10,2), 8); // Importo
|
||||||
|
row.add(str, 9); // Dare/Avere
|
||||||
|
|
||||||
|
switch (tm)
|
||||||
|
{
|
||||||
|
case 2: row.add("EF7#", 10); break; // Nota di credito
|
||||||
|
case 5: row.add("EF5#", 10); break; // Insoluto
|
||||||
|
default:
|
||||||
|
switch (part.get_int(PART_TIPOPAG))
|
||||||
|
{
|
||||||
|
case 3: row.add("EF3#", 10); break;// Causale pagamento con RIBA
|
||||||
|
default: row.add("EF6#", 10); break;// Causale pagamento normale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row.add(" ", 11); // Condizioni di pagamento
|
||||||
|
row.add(part.get(PART_DATAPAG), 12); // Data pagamento
|
||||||
|
movimenti.new_rec(row);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sort_mov(const TObject** o1, const TObject** o2)
|
||||||
|
{
|
||||||
|
const TToken_string& r1 = *(const TToken_string*)*o1;
|
||||||
|
const TToken_string& r2 = *(const TToken_string*)*o2;
|
||||||
|
|
||||||
|
long c1 = 0, c2 = 0;
|
||||||
|
r1.get(0, c1);
|
||||||
|
r2.get(0, c2);
|
||||||
|
|
||||||
|
int ret = c1 - c2;
|
||||||
|
|
||||||
|
for (int i = 3; i > 0 && ret == 0; i -= 2)
|
||||||
|
{
|
||||||
|
TDate d1, d2;
|
||||||
|
r1.get(i, d1);
|
||||||
|
r2.get(i, d2);
|
||||||
|
ret = d1 - d2;
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
TString16 p1, p2;
|
||||||
|
r1.get(i+1, p1); p1.trim();
|
||||||
|
r2.get(i+1, p2); p2.trim();
|
||||||
|
ret = p1.compare(p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPayLine_app::ftp_send(const TFilename& filename, const TString& ftp) const
|
||||||
|
{
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
TString srv, pat, usr, pwd;
|
||||||
|
const int at = ftp.find('@');
|
||||||
|
if (at > 0)
|
||||||
|
{
|
||||||
|
srv = ftp.mid(at+1);
|
||||||
|
usr = ftp.left(at);
|
||||||
|
if (usr.starts_with("ftp://"))
|
||||||
|
usr.ltrim(6);
|
||||||
|
const int colon = usr.find(':');
|
||||||
|
if (colon > 0)
|
||||||
|
{
|
||||||
|
pwd = usr.mid(colon+1);
|
||||||
|
usr.cut(colon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
srv = ftp;
|
||||||
|
if (srv.starts_with("ftp://"))
|
||||||
|
srv.ltrim(6);
|
||||||
|
}
|
||||||
|
const int slash = srv.find('/');
|
||||||
|
if (slash > 0)
|
||||||
|
{
|
||||||
|
pat = srv.mid(slash);
|
||||||
|
srv.cut(slash);
|
||||||
|
if (pat.full() && !pat.ends_with("/"))
|
||||||
|
pat << '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
TSocketClient ftpserver;
|
||||||
|
CONNID id = ftpserver.QueryConnection("21", srv);
|
||||||
|
if (id > 0)
|
||||||
|
{
|
||||||
|
TString remote = pat;
|
||||||
|
remote << filename.name();
|
||||||
|
done = ftpserver.FtpSendFile(id, remote, filename, usr, pwd);
|
||||||
|
if (!done)
|
||||||
|
done = error_box(FR("Impossibile inviare il file %s"), (const char*)filename);
|
||||||
|
|
||||||
|
ftpserver.RemoveConnection(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
done = error_box(FR("Impossibile connettersi al server %s"), (const char*)srv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPayLine_app::esporta(const TString& dir, const TString& ftp,
|
||||||
|
const TDate& al, TLog_report& log) const
|
||||||
{
|
{
|
||||||
TDate dal(al);
|
TDate dal(al);
|
||||||
dal.set_day(1); // A scanso equivoci bisestili
|
dal.set_day(1); // A scanso equivoci bisestili
|
||||||
@ -184,71 +385,43 @@ bool TPayLine_app::esporta(const TString& dir, const TDate& al, TLog_report& log
|
|||||||
query << "USE SCAD "
|
query << "USE SCAD "
|
||||||
<< "\nJOIN PART INTO TIPOC==TIPOC SOTTOCONTO==SOTTOCONTO ANNO==ANNO NUMPART==NUMPART NRIGA==NRIGA"
|
<< "\nJOIN PART INTO TIPOC==TIPOC SOTTOCONTO==SOTTOCONTO ANNO==ANNO NUMPART==NUMPART NRIGA==NRIGA"
|
||||||
<< "\nFROM TIPOC=C\nTO TIPOC=C";
|
<< "\nFROM TIPOC=C\nTO TIPOC=C";
|
||||||
|
|
||||||
TISAM_recordset mov(query);
|
TISAM_recordset mov(query);
|
||||||
const TRectype& scad = mov.cursor()->curr();
|
if (mov.items() > 0)
|
||||||
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))
|
const TRectype& scad = mov.cursor()->curr();
|
||||||
break;
|
const TRectype& part = mov.cursor()->curr(LF_PARTITE);
|
||||||
|
long lastcf = 0;
|
||||||
|
TToken_string row(256, ';');
|
||||||
|
TString str;
|
||||||
|
|
||||||
const TDate datascad = scad.get(SCAD_DATASCAD);
|
str = log.title();
|
||||||
if (scad.get_bool(SCAD_PAGATA) || part.get_bool(PART_CHIUSA))
|
str << '\n' << TR("Scadenze e pagamenti associati");
|
||||||
{
|
|
||||||
if (datascad < dal)
|
|
||||||
continue; // Ignora vecchia partita chiusa
|
|
||||||
}
|
|
||||||
|
|
||||||
const long codcf = scad.get_long(SCAD_SOTTOCONTO);
|
TProgind pi(mov.items(), str);
|
||||||
if (codcf != lastcf)
|
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
||||||
{
|
{
|
||||||
lastcf = export_clifo(codcf, clienti, log);
|
if (!pi.addstatus(1))
|
||||||
if (lastcf <= 0)
|
break;
|
||||||
|
|
||||||
|
const TDate datascad = scad.get(SCAD_DATASCAD);
|
||||||
|
if (datascad > al)
|
||||||
continue;
|
continue;
|
||||||
}
|
if (scad.get_bool(SCAD_PAGATA) || part.get_bool(PART_CHIUSA))
|
||||||
|
{
|
||||||
|
if (datascad < dal)
|
||||||
|
continue; // Ignora vecchia partita chiusa
|
||||||
|
}
|
||||||
|
|
||||||
str.cut(0) << lastcf; str.right_just(6);
|
const long codcf = scad.get_long(SCAD_SOTTOCONTO);
|
||||||
row.add(str, 0); // Codice cliente
|
if (codcf != lastcf)
|
||||||
|
{
|
||||||
|
lastcf = export_clifo(codcf, clienti, log);
|
||||||
|
if (lastcf <= 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
str = part.get(PART_DATADOC); // Data Documento
|
row.format("%6d", lastcf); // Codice cliente
|
||||||
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
|
str = part.get(PART_DATADOC); // Data Documento
|
||||||
if (str.blank())
|
if (str.blank())
|
||||||
@ -256,45 +429,73 @@ bool TPayLine_app::esporta(const TString& dir, const TDate& al, TLog_report& log
|
|||||||
row.add(str, 1);
|
row.add(str, 1);
|
||||||
|
|
||||||
str = part.get(PART_NUMDOC); str.left_just(8);
|
str = part.get(PART_NUMDOC); str.left_just(8);
|
||||||
row.add(str, 2); // Numero Documento
|
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
|
row.add(part.get(PART_DATAREG), 5); // Data registrazione
|
||||||
|
|
||||||
str = part.get(PART_NREG); str.right_just(7);
|
str = part.get(PART_NREG); str.right_just(7);
|
||||||
row.add(str, 6); // Numero registrazione
|
row.add(str, 6); // Numero registrazione
|
||||||
|
|
||||||
const int tm = part.get_int(PART_TIPOMOV);
|
row.add(datascad, 7); // Data scadenza
|
||||||
|
|
||||||
real imp;
|
real importo = scad.get_real(SCAD_IMPORTO);
|
||||||
if (tm == 3 && pagsca.rows() == 1 && scad.get_bool(SCAD_PAGATA))
|
str = part.get(PART_SEZ);
|
||||||
|
if (importo < ZERO)
|
||||||
{
|
{
|
||||||
// Caso semplice: una rata pagata completamene con un solo pagamento
|
importo = -importo;
|
||||||
imp = scad.get_real(SCAD_IMPORTO); // Importo pagato = importo da pagare
|
str = str == "D" ? "A" : "D";
|
||||||
}
|
}
|
||||||
else
|
row.add(importo.stringa(10,2), 8); // Importo
|
||||||
{
|
row.add(str, 9); // Dare/Avere
|
||||||
imp = pag.get_real(PAGSCA_IMPORTO);
|
|
||||||
if (tm == 3)
|
row.add(str[0] == 'A' ? "EF7#" : "EF1#", 10); // Causale Fattura o Nota credito
|
||||||
{
|
|
||||||
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);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TString msg;
|
TString msg;
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
|
|
||||||
@ -304,11 +505,46 @@ bool TPayLine_app::esporta(const TString& dir, const TDate& al, TLog_report& log
|
|||||||
<< TR(" al ") << al;
|
<< TR(" al ") << al;
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
|
|
||||||
TFilename fname = dir; fname.add("PLclienti.txt");
|
TFilename fname_cli = dir; fname_cli.add("PLclienti.txt");
|
||||||
clienti.save_as(fname);
|
clienti.sort();
|
||||||
|
clienti.save_as(fname_cli);
|
||||||
|
|
||||||
fname = dir; fname.add("PLmovimenti.txt");
|
TFilename fname_mov = dir; fname_mov.add("PLmovimenti.txt");
|
||||||
return movimenti.save_as(fname);
|
movimenti.sort(sort_mov);
|
||||||
|
bool done = movimenti.save_as(fname_mov);
|
||||||
|
|
||||||
|
if (done && ftp.full())
|
||||||
|
{
|
||||||
|
msg.cut(0);
|
||||||
|
log.log(0, msg);
|
||||||
|
msg << TR("Invio a ") << ftp;
|
||||||
|
log.log(0, msg);
|
||||||
|
|
||||||
|
TProgind pi(2, msg);
|
||||||
|
|
||||||
|
for (int i = 0; done && i < 2; i++)
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
const TFilename& fname = i == 0 ? fname_cli : fname_mov;
|
||||||
|
done = ftp_send(fname, ftp);
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
msg.cut(0) << TR("Impossibile inviare il file ") << fname;
|
||||||
|
log.log_error(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPayLine_app::create()
|
||||||
|
{
|
||||||
|
Tdninst dn;
|
||||||
|
if (!dn.can_I_run(true))
|
||||||
|
return error_box(FR("Postazione non abilitata per %s"), (const char*)title());
|
||||||
|
return TSkeleton_application::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPayLine_app::main_loop()
|
void TPayLine_app::main_loop()
|
||||||
@ -317,14 +553,15 @@ void TPayLine_app::main_loop()
|
|||||||
while (m.run() == K_ENTER)
|
while (m.run() == K_ENTER)
|
||||||
{
|
{
|
||||||
const TString& dir = m.get(101);
|
const TString& dir = m.get(101);
|
||||||
const TDate limit = m.get(102);
|
const TDate limit = m.get(102);
|
||||||
|
const TString& ftp = m.get(103);
|
||||||
|
|
||||||
TString tit;
|
TString tit;
|
||||||
tit << title() << " al " << limit;
|
tit << title() << " al " << limit;
|
||||||
TLog_report log(tit);
|
TLog_report log(tit);
|
||||||
log.kill_duplicates();
|
log.kill_duplicates();
|
||||||
|
|
||||||
esporta(dir, limit, log);
|
esporta(dir, ftp, limit, log);
|
||||||
log.preview();
|
log.preview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
PAGE "Esportazione PayLine" -1 -1 60 4
|
PAGE "Esportazione PayLine" -1 -1 60 8
|
||||||
|
|
||||||
GROUPBOX DLG_NULL 58 4
|
GROUPBOX DLG_NULL 58 4
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -19,6 +19,15 @@ BEGIN
|
|||||||
FLAGS "A"
|
FLAGS "A"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
GROUPBOX DLG_NULL 58 3
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 4 "@bSito FTP di destinazione"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING 103 256 53
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 5 ""
|
||||||
|
END
|
||||||
|
|
||||||
STRING DLG_PROFILE 50
|
STRING DLG_PROFILE 50
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -155,4 +155,4 @@ Picture = <cg01>
|
|||||||
Module = 27
|
Module = 27
|
||||||
Item_01 = "Proforma", "tc9 -0", ""
|
Item_01 = "Proforma", "tc9 -0", ""
|
||||||
Item_02 = "Semetra", "tc8 -0", ""
|
Item_02 = "Semetra", "tc8 -0", ""
|
||||||
Item_03 = "PayLine", "tc8 -1", "F"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user