Prima versione funzionante (CRPA e Dinamica) dei bonifici SEPA
git-svn-id: svn://10.65.10.50/branches/R_10_00@23174 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
df62fe8828
commit
6bd580c2b5
@ -318,7 +318,7 @@ bool TSEPA_record::remove()
|
||||
}
|
||||
|
||||
// Callback per la sottostante funzione search()
|
||||
static int paf_search_record(void* jolly, int cols, char** values, char** names)
|
||||
static int db_search_record(void* jolly, int cols, char** values, char** names)
|
||||
{
|
||||
TSEPA_record& rec = *(TSEPA_record*)jolly;
|
||||
for (int i = 0; i < cols; i++)
|
||||
@ -340,7 +340,7 @@ bool TSEPA_record::search()
|
||||
}
|
||||
query.rtrim(5);
|
||||
query << ';';
|
||||
return xvt_sql_execute(_db, query, paf_search_record, this) == 1;
|
||||
return xvt_sql_execute(_db, query, db_search_record, this) == 1;
|
||||
}
|
||||
|
||||
// Carica un record in base ad un massimo di 3 campi chiave
|
||||
@ -713,11 +713,13 @@ bool TSEPA_app::destroy()
|
||||
// Id univoco distinta
|
||||
static bool SEPA_MsgId(const TRectype& dist, TString& id)
|
||||
{
|
||||
const long firm = prefix().get_codditta();
|
||||
const char tipo = dist.get_char(EFF_TIPODIST);
|
||||
const long num = dist.get_char(EFF_NDIST);
|
||||
const int abi = dist.get_long(EFF_CODABI);
|
||||
const int cab = dist.get_long(EFF_CODCAB);
|
||||
id.format("%c%05d_%05d%05d", tipo, num, abi, cab);
|
||||
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);
|
||||
CHECKS(id.len() <= 26, "MsgId più lungo di 26 caratteri ", id);
|
||||
return abi > 0 && cab > 0;
|
||||
}
|
||||
|
||||
@ -725,9 +727,9 @@ static bool SEPA_MsgId(const TRectype& dist, TString& id)
|
||||
static bool SEPA_InstrId(const TRectype& eff, TString& id)
|
||||
{
|
||||
const char tipo = eff.get_char(EFF_TIPODIST);
|
||||
const long num = eff.get_char(EFF_NDIST);
|
||||
const int nriga = eff.get_char(EFF_NRIGADIST);
|
||||
id.format("%c%05d_%05d", tipo, num, nriga);
|
||||
const long num = eff.get_long(EFF_NDIST);
|
||||
const int nriga = eff.get_int(EFF_NRIGADIST);
|
||||
id.format("%c%05d-%05d", tipo, num, nriga);
|
||||
return nriga > 0;
|
||||
}
|
||||
|
||||
@ -738,19 +740,6 @@ static void AS400_date_time(TString& d, TString& t)
|
||||
t.format("%02d%02d%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
|
||||
}
|
||||
|
||||
static char tipo_incasso(const TRectype& eff)
|
||||
{
|
||||
const char tipopag = eff.get_char(EFF_TIPOPAG);
|
||||
const char tipocf = eff.get_char(EFF_TIPOCF);
|
||||
const long codcf = eff.get_long(EFF_CODCF);
|
||||
|
||||
if (tipopag != '8' || tipocf != 'C' || codcf <= 0L) // 8 = Rapporti Interbancari Diretti (alias RID)
|
||||
return ' '; // RID ONLY
|
||||
TString8 key; key.format("C|%ld", codcf);
|
||||
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
||||
return clifo.get_char(CLI_TIPOAPER) == 'G' ? 'V' : 'U';
|
||||
}
|
||||
|
||||
static const char* tipo_sequenza(const TRectype& eff)
|
||||
{
|
||||
const TRectype& mandato = cache().get("&MAN", eff.get(EFF_MANDATO));
|
||||
@ -771,14 +760,14 @@ static TDate data_mandato(const TRectype& eff)
|
||||
|
||||
TDate TSEPA_app::data_scadenza(const TRectype& eff) const
|
||||
{
|
||||
const TDate oggi(TODAY);
|
||||
TDate dt = eff.get(EFF_DSCVAL);
|
||||
if (!dt.ok())
|
||||
if (!dt.ok() || dt < oggi)
|
||||
dt = eff.get_date(EFF_DATASCAD);
|
||||
if (!dt.ok())
|
||||
if (!dt.ok() || dt < oggi)
|
||||
{
|
||||
NFCHECK("Data scadenza non valida");
|
||||
dt = TODAY;
|
||||
dt.set_end_month();
|
||||
dt = oggi;
|
||||
// dt.set_end_month(); // Forse per RID
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
@ -832,16 +821,39 @@ real TSEPA_app::genera_BON(const TString& PmtInfId, const TEffetto& eff)
|
||||
TString doc_id;
|
||||
doc_id << riga.get(REFF_ANNO) << '/' << riga.get(REFF_NFATT);
|
||||
doc_id.strip_spaces();
|
||||
|
||||
const TString& cup = eff.get(EFF_CUP);
|
||||
if (cup.full())
|
||||
doc_id << " CUP-" << cup;
|
||||
else
|
||||
{
|
||||
const TString& cig = eff.get(EFF_CIG);
|
||||
if (cig.full())
|
||||
doc_id << " CIG-" << cig;
|
||||
}
|
||||
rata.set("SEF007", doc_id);
|
||||
rata.set("SEF008", riga.get_date(REFF_DATAFATT));
|
||||
rata.set("SEF009", riga.get_real(REFF_IMPFATT));
|
||||
rata.set("SEF011", riga.get_real(REFF_IMPORTO));
|
||||
if (!sepa_dett)
|
||||
if (!sepa_dett) // NON STRUTTURATO
|
||||
{
|
||||
TString desc;
|
||||
desc.format(FR("Fattura %s del %s - Totale=%s - Importo=%s"),
|
||||
(const char*)doc_id, (const char*)riga.get(REFF_DATAFATT),
|
||||
(const char*)riga.get(REFF_IMPFATT), (const char*)riga.get(REFF_IMPORTO));
|
||||
const TCurrency tot = riga.get_real(REFF_IMPFATT);
|
||||
const TCurrency pag = riga.get_real(REFF_IMPORTO);
|
||||
if (tot > pag)
|
||||
{
|
||||
desc.format(FR("Fatt:%s Data %s Tot:%s Pag:%s"),
|
||||
(const char*)doc_id, (const char*)riga.get(REFF_DATAFATT),
|
||||
tot.string(), pag.string());
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.format(FR("Fatt:%s Data:%s Imp:%s"),
|
||||
(const char*)doc_id, (const char*)riga.get(REFF_DATAFATT),
|
||||
pag.string());
|
||||
}
|
||||
if (r > 1)
|
||||
desc.insert(" - ");
|
||||
rata.set("SEF012", desc);
|
||||
}
|
||||
|
||||
@ -889,7 +901,7 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
TSEPA_record head("SEBOT00F");
|
||||
|
||||
// Il codice univoco diventa MsgId + Id
|
||||
TString PmtInfId; PmtInfId << msg_id << '_' << key;
|
||||
TString PmtInfId; PmtInfId << msg_id << '_' << msg_date.left(8);
|
||||
log.log(0, PmtInfId);
|
||||
|
||||
head.set("SET001", PmtInfId); // MsgId
|
||||
@ -905,7 +917,7 @@ bool TSEPA_app::genera_dist_BON(char td, long nd, TLog_report& log)
|
||||
head.set("SET006", _cuc); // Id
|
||||
head.set("SET007", "CBI"); // Issr
|
||||
|
||||
head.set("SET008", "CHK"); // TRF,CHK,TRA
|
||||
head.set("SET008", "TRF"); // TRF,CHK,TRA
|
||||
head.set("SET009", "NORM"); // Priority2Code: NORM o HIGH
|
||||
|
||||
const TEffetto& e0 = dist[0];
|
||||
@ -1284,7 +1296,10 @@ void TSEPA_app::main_loop()
|
||||
TLog_report log(tipo == 8 ? "RID SEPA" : "Bonifici SEPA");
|
||||
|
||||
if (_cuc.blank())
|
||||
{
|
||||
log.log(2, TR("E' necessario inserire il codice CUC nei parametri degli effetti"));
|
||||
_cuc = "GEB00000";
|
||||
}
|
||||
|
||||
if (tipo == 9)
|
||||
genera_SEPA_BON(m, log);
|
||||
|
Loading…
x
Reference in New Issue
Block a user