Bonifici e RID SEPA
git-svn-id: svn://10.65.10.50/branches/R_10_00@23183 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3ce424af76
commit
bbc06b1603
175
ef/ef1100.cpp
175
ef/ef1100.cpp
@ -1,5 +1,6 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <dongle.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
@ -8,6 +9,7 @@
|
||||
#include <reputils.h>
|
||||
#include <tabutil.h>
|
||||
#include <utility.h>
|
||||
#include <validate.h>
|
||||
|
||||
#include "../fe/felib.h"
|
||||
|
||||
@ -164,7 +166,7 @@ public:
|
||||
void set(const char* fld, const real& var);
|
||||
void set(const char* fld, const TString& var);
|
||||
void set(const char* fld, const TDate& var);
|
||||
void set(const char* fld, bool var);
|
||||
void set(const char* fld, bool var);
|
||||
const TVariant& get(const char* fld) const;
|
||||
|
||||
bool insert();
|
||||
@ -446,6 +448,9 @@ void TSEPA_mask::fill_sheet()
|
||||
TString query;
|
||||
query << "USE EFFETTI KEY 3"
|
||||
<< "\nSELECT (TIPOCF=#TIPOCF)&&(TIPOPAG=#TIPOPAG)&&(NRIGADIST=1)";
|
||||
if (!get_bool(F_SHOWALL))
|
||||
query << "&&(EFFCOMP!=\"X\")";
|
||||
|
||||
if (!field(F_ABI).empty())
|
||||
{
|
||||
query << "&&(STR(";
|
||||
@ -487,6 +492,9 @@ void TSEPA_mask::fill_sheet()
|
||||
const TString& desc = banca(curr.get(EFF_CODABIP), curr.get(EFF_CODCABP));
|
||||
row.add(desc, s.cid2index(S_BANCA));
|
||||
|
||||
row.add(curr.get(EFF_EFFCONT));
|
||||
row.add(curr.get(EFF_EFFCOMP));
|
||||
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
}
|
||||
@ -508,6 +516,7 @@ bool TSEPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
case F_TIPO:
|
||||
case F_TIPOCF:
|
||||
case F_CAB:
|
||||
case F_SHOWALL:
|
||||
if (e == fe_modify && is_running())
|
||||
fill_sheet();
|
||||
break;
|
||||
@ -546,6 +555,7 @@ protected:
|
||||
bool genera_SEPA_RID(const TMask& m, TLog_report& log);
|
||||
|
||||
bool genera_xml(int tipo);
|
||||
void completa(TDistinta& dist) const;
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
@ -648,6 +658,9 @@ bool TSEPA_app::create_table(TScanner& paf, const TString& table)
|
||||
|
||||
bool TSEPA_app::create()
|
||||
{
|
||||
if (!has_module(SEAUT))
|
||||
return error_box(TR("Si richiede l'attivazione del modulo SEPA"));
|
||||
|
||||
const long cd = prefix().get_codditta();
|
||||
if (cd <= 0 || !prefix().is_firm())
|
||||
return cantread_box(TR("Ditta corrente"));
|
||||
@ -718,7 +731,7 @@ static bool SEPA_MsgId(const TRectype& dist, TString& id)
|
||||
const long num = dist.get_long(EFF_NDIST);
|
||||
const int abi = dist.get_int(EFF_CODABIP);
|
||||
const int cab = dist.get_int(EFF_CODCABP);
|
||||
id.format("%05ld_%c%05d_%05d%05d", firm, tipo, num, abi, cab);
|
||||
id.format("%05ld-%c%05d-%05d%05d", firm, tipo, num, abi, cab);
|
||||
CHECKS(id.len() <= 26, "MsgId più lungo di 26 caratteri ", id);
|
||||
return abi > 0 && cab > 0;
|
||||
}
|
||||
@ -729,7 +742,7 @@ static bool SEPA_InstrId(const TRectype& eff, TString& id)
|
||||
const char tipo = eff.get_char(EFF_TIPODIST);
|
||||
const long num = eff.get_long(EFF_NDIST);
|
||||
const int nriga = eff.get_int(EFF_NRIGADIST);
|
||||
id.format("%c%05d-%05d", tipo, num, nriga);
|
||||
id.format("%c%05ld-%05d", tipo, num, nriga);
|
||||
return nriga > 0;
|
||||
}
|
||||
|
||||
@ -752,11 +765,6 @@ static const char* tipo_sequenza(const TRectype& eff)
|
||||
return "RCUR";
|
||||
}
|
||||
|
||||
static TDate data_mandato(const TRectype& eff)
|
||||
{
|
||||
const TDate dm = cache().get("&MAN", eff.get(EFF_MANDATO), "D0");
|
||||
return dm;
|
||||
}
|
||||
|
||||
TDate TSEPA_app::data_scadenza(const TRectype& eff) const
|
||||
{
|
||||
@ -863,6 +871,17 @@ real TSEPA_app::genera_BON(const TString& PmtInfId, const TEffetto& eff)
|
||||
return imp;
|
||||
}
|
||||
|
||||
void TSEPA_app::completa(TDistinta& dist) const
|
||||
{
|
||||
TLocalisamfile eff(LF_EFFETTI);
|
||||
for (int i = 0; i < dist.items(); i++)
|
||||
{
|
||||
TEffetto& r = dist[i];
|
||||
r.put(EFF_EFFCOMP, true);
|
||||
r.rewrite(eff);
|
||||
}
|
||||
}
|
||||
|
||||
bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
{
|
||||
TDistinta dist(td, nd);
|
||||
@ -873,17 +892,25 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
{
|
||||
const TEffetto& eff = dist[i];
|
||||
const char* ts = tipo_sequenza(eff);
|
||||
CHECKS(ts && *ts, "Tipo sequenza non valido:", ts);
|
||||
|
||||
const TDate data = data_scadenza(eff);
|
||||
TString16 key; key.format("%s_%ld", ts, data.date2ansi());
|
||||
TArray* list = (TArray*)subdist.objptr(key);
|
||||
if (list == NULL)
|
||||
if (ts && *ts)
|
||||
{
|
||||
list = new TArray;
|
||||
subdist.add(key, list);
|
||||
const TDate data = data_scadenza(eff);
|
||||
TString16 key; key.format("%s_%ld", ts, data.date2ansi());
|
||||
TArray* list = (TArray*)subdist.objptr(key);
|
||||
if (list == NULL)
|
||||
{
|
||||
list = new TArray;
|
||||
subdist.add(key, list);
|
||||
}
|
||||
list->add(eff);
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Tipo sequenza non valido alla riga ")
|
||||
<< eff.get(EFF_NRIGADIST) << TR(" della distinta ") << nd;
|
||||
log.log(2, msg);
|
||||
}
|
||||
list->add(eff);
|
||||
}
|
||||
|
||||
if (subdist.empty())
|
||||
@ -898,10 +925,12 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
// In AS400 non si gestiscono le sottodistinte, per cui creo una distinta per ogni sottodisitinta
|
||||
FOR_EACH_ASSOC_OBJECT(subdist, hobj, key, itm)
|
||||
{
|
||||
const TArray& trans = objptr2array(itm);
|
||||
|
||||
TSEPA_record head("SEBOT00F");
|
||||
|
||||
// Il codice univoco diventa MsgId + Id
|
||||
TString PmtInfId; PmtInfId << msg_id << '_' << msg_date.left(8);
|
||||
TString PmtInfId; PmtInfId << msg_id << '-' << msg_date.left(8);
|
||||
log.log(0, PmtInfId);
|
||||
|
||||
head.set("SET001", PmtInfId); // MsgId
|
||||
@ -910,18 +939,25 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
head.set("SET002", msg_date); // CreDtTm data
|
||||
head.set("SET0021", msg_time); // CreDtTm ora
|
||||
|
||||
head.set("SET003", long(dist.items())); // NbOfTxs
|
||||
head.set("SET003", long(trans.items())); // NbOfTxs
|
||||
head.set("SET004", ZERO); // totale
|
||||
head.set("SET005", _ditta.ragione_sociale()); // Nm
|
||||
|
||||
head.set("SET006", _cuc); // Id
|
||||
const TEffetto& e0 = dist[0];
|
||||
TString16 codtab = e0.get(EFF_CODABIP); codtab << e0.get(EFF_CODCABP);
|
||||
TString4 prog = e0.get(EFF_PROGBNP);
|
||||
if (prog.full()) codtab << prog;
|
||||
const TRectype& bnp = cache().get("BNP", codtab);
|
||||
|
||||
TString8 cuc = bnp.get("S5"); // CUC specifico per banca di presentazione
|
||||
if (cuc.blank()) cuc = _cuc; // CUC generale della ditta corrente
|
||||
|
||||
head.set("SET006", cuc); // Id
|
||||
head.set("SET007", "CBI"); // Issr
|
||||
|
||||
head.set("SET008", "TRF"); // TRF,CHK,TRA
|
||||
head.set("SET009", "NORM"); // Priority2Code: NORM o HIGH
|
||||
|
||||
const TEffetto& e0 = dist[0];
|
||||
|
||||
const TDate ReqdExctnDt = data_scadenza(e0);
|
||||
head.set("SET010", ReqdExctnDt); // Data richiesta dal mittente YYYY-MM-DD
|
||||
|
||||
@ -941,20 +977,14 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
head.set("SET022", "ADE");
|
||||
head.set("SET023", _ditta.stato_partita_IVA());
|
||||
|
||||
TString16 codtab = e0.get(EFF_CODABIP); codtab << e0.get(EFF_CODCABP);
|
||||
TString4 prog = e0.get(EFF_PROGBNP);
|
||||
if (prog.full()) codtab << prog;
|
||||
|
||||
const TRectype& bnp = cache().get("BNP", codtab);
|
||||
head.set("SET024", bnp.get("S3"));
|
||||
//head.set("SET025", BIC); ???
|
||||
head.set("SET026", codtab.left(5));
|
||||
head.set("SET027", "SLEV");
|
||||
|
||||
const TArray& list = *(TArray*)itm;
|
||||
real totale;
|
||||
|
||||
FOR_EACH_ARRAY_ITEM(list, r, peff)
|
||||
FOR_EACH_ARRAY_ITEM(trans, r, peff)
|
||||
{
|
||||
const TEffetto& e = *(TEffetto*)peff;
|
||||
totale += genera_BON(PmtInfId, e);
|
||||
@ -964,6 +994,9 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
|
||||
head.insert();
|
||||
}
|
||||
|
||||
completa(dist);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1013,9 +1046,19 @@ real TSEPA_app::genera_RID(const TString& PmtInfId, const TEffetto& eff, TLog_re
|
||||
body.set("SERD05", imp);
|
||||
body.set("SERD06", "SLEV");
|
||||
|
||||
body.set("SERD07", eff.get(EFF_MANDATO));
|
||||
body.set("SERD08", data_mandato(eff));
|
||||
body.set("SERD09", "FALSE");
|
||||
TString80 cmndt = eff.get(EFF_MANDATO);
|
||||
TDate dmndt = cache().get("&MAN", cmndt, "D0");
|
||||
if (cmndt.blank())
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("Codice mandato assente in ") << instr_id;
|
||||
log.log(1, msg);
|
||||
cmndt = instr_id;
|
||||
dmndt = eff.get_date(EFF_DATADIST);
|
||||
}
|
||||
body.set("SERD07", cmndt); // Codice mandato
|
||||
body.set("SERD08", dmndt); // Data mandato
|
||||
body.set("SERD09", "0"); // era FALSE e non funzionava
|
||||
|
||||
const TAnagrafica debitor(eff);
|
||||
body.set("SERD11", debitor.ragione_sociale());
|
||||
@ -1041,8 +1084,7 @@ real TSEPA_app::genera_RID(const TString& PmtInfId, const TEffetto& eff, TLog_re
|
||||
|
||||
TString16 codbnp; codbnp << eff.get(EFF_CODABIP) << eff.get(EFF_CODCABP) << eff.get(EFF_PROGBNP);
|
||||
const TRectype& bnp = cache().get("BNP", codbnp);
|
||||
const bool sepa_dett = bnp.get_bool("B3");
|
||||
|
||||
|
||||
// Dettagli fatture pagate
|
||||
const TRecord_array reff(eff.get(EFF_NPROGTR), LF_REFFETTI);
|
||||
for (int r = reff.first_row(); r > 0 && r <= reff.last_row(); r = reff.succ_row(r))
|
||||
@ -1054,21 +1096,14 @@ real TSEPA_app::genera_RID(const TString& PmtInfId, const TEffetto& eff, TLog_re
|
||||
rata.set("SERF02", instr_id);
|
||||
rata.set("SERF03", (long)r);
|
||||
TString doc_id;
|
||||
doc_id << riga.get(REFF_ANNO) << '/' << riga.get(REFF_NFATT);
|
||||
doc_id << riga.get_date(REFF_DATAFATT).year() << '-' << riga.get(REFF_NFATT);
|
||||
doc_id.strip_spaces();
|
||||
rata.set("SERF07", doc_id);
|
||||
rata.set("SERF08", riga.get_date(REFF_DATAFATT));
|
||||
rata.set("SERF09", riga.get_real(REFF_IMPFATT));
|
||||
rata.set("SERF11", riga.get_real(REFF_IMPORTO));
|
||||
|
||||
const TString& mndt = eff.get(EFF_MANDATO);
|
||||
if (mndt.full())
|
||||
{
|
||||
rata.set("SERF12", mndt);
|
||||
rata.set("SERF13", data_mandato(eff));
|
||||
}
|
||||
else
|
||||
log.log(2, TR("Codice mandato assente"));
|
||||
rata.set("SERF12", cmndt); // Codice mandato
|
||||
rata.set("SERF13", dmndt); // Data mandato
|
||||
|
||||
rata.insert();
|
||||
}
|
||||
@ -1084,7 +1119,7 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
{
|
||||
const TEffetto& eff = dist[i];
|
||||
const TDate data = data_scadenza(eff);
|
||||
TString16 key; key.format("FRST_%ld", data.date2ansi());
|
||||
TString8 key; key << data.date2ansi();
|
||||
TArray* list = (TArray*)subdist.objptr(key);
|
||||
if (list == NULL)
|
||||
{
|
||||
@ -1106,10 +1141,12 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
// In AS400 non si gestiscono le sottodistinte, per cui creo una distinta per ogni sottodisitinta
|
||||
FOR_EACH_ASSOC_OBJECT(subdist, hobj, key, itm)
|
||||
{
|
||||
const TArray& trans = objptr2array(itm);
|
||||
|
||||
TSEPA_record head("SERIT00F");
|
||||
|
||||
// Il codice univoco diventa MsgId + Id
|
||||
TString PmtInfId; PmtInfId << msg_id << '_' << key;
|
||||
TString PmtInfId; PmtInfId << msg_id << '-' << key;
|
||||
log.log(0, PmtInfId);
|
||||
|
||||
head.set("SERT01", PmtInfId); // MsgId
|
||||
@ -1118,18 +1155,26 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
head.set("SERT02", msg_date); // CreDtTm data
|
||||
head.set("SERT021", msg_time); // CreDtTm ora
|
||||
|
||||
head.set("SERT03", long(dist.items())); // NbOfTxs
|
||||
head.set("SERT03", long(trans.items())); // NbOfTxs
|
||||
head.set("SERT04", ZERO); // totale
|
||||
head.set("SERT05", _ditta.ragione_sociale()); // Nm
|
||||
|
||||
head.set("SERT06", _cuc); // Id
|
||||
const TEffetto& e0 = dist[0];
|
||||
TString16 codtab = e0.get(EFF_CODABIP); codtab << e0.get(EFF_CODCABP);
|
||||
TString4 prog = e0.get(EFF_PROGBNP);
|
||||
if (prog.full()) codtab << prog;
|
||||
const TRectype& bnp = cache().get("BNP", codtab);
|
||||
|
||||
TString8 cuc = bnp.get("S5");
|
||||
if (cuc.blank()) cuc = _cuc;
|
||||
|
||||
head.set("SERT06", cuc); // Id
|
||||
head.set("SERT07", "CBI"); // Issr
|
||||
|
||||
head.set("SERT08", PmtInfId); // Progressivo
|
||||
head.set("SERT09", "DD");
|
||||
head.set("SERT10", "SEPA");
|
||||
|
||||
const TEffetto& e0 = dist[0];
|
||||
|
||||
head.set("SERT11", "CORE"); // Codice strumento (CORE, COR1, B2B)
|
||||
head.set("SERT12", "FRST"); // Tipo sequenza incasso
|
||||
@ -1150,15 +1195,18 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
head.set("SERT24", _ditta.stato_partita_IVA()); // Alpha-2 code
|
||||
head.set("SERT25", _ditta.fisica() ? 1L : 0L);
|
||||
|
||||
head.set("SERT27", _cuc); // Id
|
||||
head.set("SERT27", cuc); // Id
|
||||
head.set("SERT28", "CBI"); // Issr
|
||||
|
||||
TString16 codtab = e0.get(EFF_CODABIP); codtab << e0.get(EFF_CODCABP);
|
||||
TString4 prog = e0.get(EFF_PROGBNP);
|
||||
if (prog.full()) codtab << prog;
|
||||
|
||||
const TRectype& bnp = cache().get("BNP", codtab);
|
||||
head.set("SERT29", bnp.get("S3")); // IBAN
|
||||
const TString& iban = bnp.get("S3");
|
||||
TString msg;
|
||||
if (iban.blank() || iban_check(iban, msg) != 0)
|
||||
{
|
||||
msg.insert(TR("IBAN errato: "));
|
||||
log.log(2, msg);
|
||||
}
|
||||
|
||||
head.set("SERT29", iban); // IBAN
|
||||
head.set("SERT30", codtab.left(5));
|
||||
|
||||
head.set("SERT31", _ditta.ragione_sociale());
|
||||
@ -1172,14 +1220,19 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
head.set("SERT39", _ditta.provincia_residenza());
|
||||
head.set("SERT40", _ditta.stato_partita_IVA()); // Alpha-2 code
|
||||
|
||||
head.set("SERT41", _ditta.partita_IVA());
|
||||
const TString& cid = bnp.get("S4");
|
||||
if (cid.blank())
|
||||
{
|
||||
msg = TR("Creditor ID mancante sulla banca di presentazione");
|
||||
log.log(2, msg);
|
||||
}
|
||||
head.set("SERT41", cid);
|
||||
head.set("SERT42", "SEPA");
|
||||
head.set("SERT43", "ADE");
|
||||
head.set("SERT44", _ditta.stato_partita_IVA()); // Alpha-2 code
|
||||
head.set("SERT44", cid.left(2)); // Alpha-2 code
|
||||
|
||||
real totale;
|
||||
const TArray& list = *(TArray*)itm;
|
||||
FOR_EACH_ARRAY_ITEM(list, r, peff)
|
||||
FOR_EACH_ARRAY_ITEM(trans, r, peff)
|
||||
{
|
||||
const TEffetto& e = *(TEffetto*)peff;
|
||||
totale += genera_RID(PmtInfId, e, log);
|
||||
@ -1188,7 +1241,7 @@ bool TSEPA_app::genera_dist_RID(char td, long nd, TLog_report& log)
|
||||
|
||||
head.insert();
|
||||
}
|
||||
|
||||
completa(dist);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#define F_CAB 206
|
||||
#define F_PRO 207
|
||||
#define F_BANCA 208
|
||||
#define F_SHOWALL 209
|
||||
#define F_SHEET 300
|
||||
|
||||
#define S_SELECT 101
|
||||
@ -16,3 +17,5 @@
|
||||
#define S_CAB 107
|
||||
#define S_PRO 108
|
||||
#define S_BANCA 109
|
||||
#define S_EFFCONT 110
|
||||
#define S_EFFCOMP 111
|
||||
|
@ -6,7 +6,7 @@ ENDPAGE
|
||||
|
||||
PAGE "Emissione Bonifici e RID SEPA" 0 2 0 0
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
GROUPBOX DLG_NULL 78 5
|
||||
BEGIN
|
||||
PROMPT 1 0 "@bSelezione"
|
||||
END
|
||||
@ -77,9 +77,14 @@ BEGIN
|
||||
CHECTYPE NORMAL
|
||||
END
|
||||
|
||||
BOOLEAN F_SHOWALL
|
||||
BEGIN
|
||||
PROMPT 2 3 "Mostra anche le distinte già elaborate"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEET 0 -1
|
||||
BEGIN
|
||||
PROMPT 1 4 ""
|
||||
PROMPT 1 5 ""
|
||||
ITEM "@1"
|
||||
ITEM "Tipo"
|
||||
ITEM "Distinta@R"
|
||||
@ -89,13 +94,15 @@ BEGIN
|
||||
ITEM "CAB@5"
|
||||
ITEM "Prg."
|
||||
ITEM "Banca di presentazione@50"
|
||||
ITEM "Contab.@5C"
|
||||
ITEM "XML@5C"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
PAGE "Distinta" -1 -1 37 6
|
||||
PAGE "Distinta" -1 -1 37 7
|
||||
|
||||
BOOLEAN S_SELECT
|
||||
BEGIN
|
||||
@ -157,6 +164,18 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_EFFCONT
|
||||
BEGIN
|
||||
PROMPT 1 6 "Contabilizzato"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_EFFCOMP
|
||||
BEGIN
|
||||
PROMPT 40 6 "Generato XML SEPA"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "Topbar" 0 0 0 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user