Patch level : 2.0 638

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Prima implementazione della gestione del codice IBAN in generazione effetti


git-svn-id: svn://10.65.10.50/trunk@11581 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-11-10 15:01:49 +00:00
parent 4aa6525ae2
commit 27990792f3
10 changed files with 134 additions and 70 deletions

View File

@ -41,6 +41,7 @@
#define CLI_CODSTAT "CODSTAT"
#define CLI_CODABI "CODABI"
#define CLI_CODCAB "CODCAB"
#define CLI_IBAN "IBAN"
#define CLI_SCONTO "SCONTO"
#define CLI_CODVAL "CODVAL"
#define CLI_RAGGRB "RAGGRB"

View File

@ -410,7 +410,7 @@ void TExchange::set(const char* val, const real& chg, exchange_type et)
void TExchange::set(const TRectype& rec)
{
const TString16 codval = rec.get("CODVAL");
const TString4 codval = rec.get("CODVAL");
const real chg = rec.get_real("CAMBIO");
exchange_type et = _exchange_undefined;
if (rec.exist("CONTROEURO"))

View File

@ -94,9 +94,8 @@
#define NOT_EMPTY_CHECK_FIELD 21 0
#define ORA_FUNC 22 0
#define SCONTO_FUNC 23 0
#define CHECK_FIRM_FUNC 24 0
#define CHECK_IBAN_FUNC 25
#define CHECK_BBAN_FUNC 26
#define CHECK_IBAN_FUNC 24 8
#define CHECK_BBAN_FUNC 25 5
#define VALEXPR VALIDATE EXPR_FUNC
#define NUM_EXPR VALEXPR 0

View File

@ -23,6 +23,7 @@
#define DOC_DATAINSC "DATAINSC"
#define DOC_CODABIA "CODABIA"
#define DOC_CODCABA "CODCABA"
#define DOC_IBAN "IBAN"
#define DOC_CODABIP "CODABIP"
#define DOC_CODCABP "CODCABP"
#define DOC_CATVEN "CATVEN"

View File

@ -15,6 +15,7 @@
#define EFF_CONTROEURO "CONTROEURO"
#define EFF_CODABI "CODABI"
#define EFF_CODCAB "CODCAB"
#define EFF_IBAN "IBAN"
#define EFF_ULTRATA "ULTRATA"
#define EFF_TIPODIST "TIPODIST"
#define EFF_NDIST "NDIST"

View File

@ -7,6 +7,8 @@
#include <controls.h>
#include <urldefid.h>
int TIndwin::_indwin_count = 0;
word TIndwin::measure_text(TToken_string& s, word& maxlen) const
{
word lines = 0;
@ -34,7 +36,9 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
const int hor = min(maxlen+3, 78);
const int ver = lines+1 + (bar ? 2 : 0) + (cancel ? 2: 0);
set_win(create_interface(TASK_WIN, -1, -1, hor, ver, TR("Elaborazione in corso"), this, FALSE));
const int y = _indwin_count == 0 ? 4 : 12;
set_win(create_interface(TASK_WIN, -1, y, hor, ver, TR("Elaborazione in corso"), this, FALSE));
_text = new TMultiline_control(win(), DLG_NULL, 1, 0, hor-2, lines+1, 512, "CD", "");
_text->set_read_only();
@ -52,6 +56,7 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
open_modal();
do_events();
_indwin_count++;
_start_time = clock();
}
@ -88,6 +93,7 @@ TIndwin::~TIndwin()
if (_cancel) delete _cancel;
if (_text) delete _text;
_indwin_count--;
}
bool TIndwin::can_be_closed() const

View File

@ -44,6 +44,8 @@ class TIndwin : public TWindow
// @cmember:(INTERNAL) Flag che indica quali operazioni sono state effettuate
byte _flags;
static int _indwin_count;
// @access Protected Member
protected:
// @cmember Massimo valore da ricercare

View File

@ -458,8 +458,7 @@ const TString& TString::mid(
if (from > l) from = l;
if (count < 0 || from+count>l)
count = l-from;
spark = &_str[from];
spark.cut(count);
spark.strncpy(&_str[from], count);
return spark;
}

View File

@ -563,14 +563,14 @@ HIDDEN bool _numcalc_val(TMask_field& f, KEY k)
const char* s = e.varname(i);
if (s[0] != '#')
{
TString80 err; err << "Cannot load variable " << s << " in " << e;
TString err; err << "Cannot load variable " << s << " in " << e;
return f.error_box((const char*)err);
}
s++;
const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
}
const TFixed_string s(e.as_string());
const TString& s = e.as_string();
f.set(s);
return TRUE;
}
@ -579,21 +579,21 @@ HIDDEN bool _numcalc_val(TMask_field& f, KEY k)
HIDDEN bool _strcalc_val(TMask_field& f, KEY k)
{
if (k != K_TAB) return TRUE;
TExpression e(get_val_param(0), _strexpr);
TExpression e(get_val_param(0), _strexpr);
for (int i = 0 ; i < e.numvar(); i++)
{
const char* s = e.varname(i);
if (s[0] != '#')
{
TString80 err; err << "Cannot load variable " << s << " in " << e;
TString err; err << "Cannot load variable " << s << " in " << e;
return f.error_box((const char*)err);
}
s++;
const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
}
TFixed_string s( e.as_string());
const TString& s = e.as_string();
f.set(s);
return TRUE;
}
@ -797,22 +797,22 @@ HIDDEN bool _ora_val(TMask_field& f, KEY key)
return TRUE;
}
bool iban_check(const TString& b, TString& msg)
int iban_check(const TString& b, TString& msg)
{
if (b.len() < 5)
{
msg = TR("Lunghezza inferiore a 5 caratteri");
return false;
return 2;
}
if (!isalpha(b[0]) || !isalpha(b[1]))
{
msg.format(FR("I primi due caratteri (%s) devono essere alfabetici"), (const char*)b.left(2));
return false;
return 3;
}
if (!isdigit(b[2]) || !isdigit(b[1]))
if (!isdigit(b[2]) || !isdigit(b[3]))
{
msg.format(FR("I caratteri 3 e 4 (%s) devono essere numerici"), (const char*)b.mid(2,2));
return false;
return 4;
}
TString80 s;
@ -835,39 +835,39 @@ bool iban_check(const TString& b, TString& msg)
else
{
msg.format(FR("Carattere non ammesso: '%c'"), c);
return false;
return 5;
}
}
if (r != 1)
{
msg = TR("Codice di controllo errato");
return false;
return 1;
}
return true;
return 0;
}
bool bban_check(const TString& b, TString& msg)
int bban_check(const TString& b, TString& msg)
{
const unsigned char dispari[26] = { 1, 0, 5, 7, 9, 13, 15, 17, 19, 21, 2, 4, 18,
20, 11, 3, 6, 8, 12, 14, 16, 10, 22, 25, 24, 23 };
if (b.len() != 23)
{
msg = TR("Lunghezza diversa da 23 caratteri");
return false;
return 2;
}
if (b[0] < 'A' || b[0] > 'Z')
{
msg.format(FR("Il CIN deve essere una lettera maiuscola: '%c'"), b[0]);
return false;
return 2;
}
for (int a = 1; a <= 10; a++)
{
if (!isdigit(b[a]))
{
msg = TR("ABI e CAB devono essere numerici");
return false;
return 3;
}
}
@ -887,7 +887,7 @@ bool bban_check(const TString& b, TString& msg)
else
{
msg.format(FR("Carattere non ammesso: '%c'"), c);
return false;
return 4;
}
if (i == 0)
kcin = k;
@ -902,67 +902,122 @@ bool bban_check(const TString& b, TString& msg)
if (s % 26 != kcin)
{
msg = TR("Codice di controllo (CIN) errato");
return false;
msg.format(TR("Codice di controlo (CIN) errato"));
return 1;
}
return true;
return 0;
}
HIDDEN bool _iban_val(TMask_field& f, KEY key)
{
TMask& m = f.mask();
const int nparms = get_val_param_num();
CHECKD(nparms == 8, "IBAN_CHECK deve avere 8 parametri: ", nparms);
int id[8];
for (int i = 0; i < 8; i++)
id[i] = atoi(get_val_param(i));
bool ok = true;
if (f.to_check(key))
if (f.dlg() == id[1]) // Campo Stato IBAN
{
const TMask& m = f.mask();
TString80 iban;
const int nparms = get_val_param_num();
for (int i = 0; i < nparms; i++)
if (key == K_TAB && !m.is_running())
{
const int id = atoi(get_val_param(i));
iban << m.get(id);
}
TString msg;
ok = iban_check(iban, msg);
if (!ok)
{
msg.insert(TR("Codice IBAN errato:\n"));
error_box(msg);
}
else
{
ok = bban_check(iban.mid(5), msg);
if (!ok)
const TString& iban = m.get(id[0]);
if (iban.not_empty())
{
msg.insert(TR("Codice BBAN errato:\n"));
error_box(msg);
m.set(id[1], iban.left(2));
m.set(id[2], iban.mid(2,2));
m.set(id[3], iban.mid(4));
m.set(id[4], iban.mid(4,1));
m.set(id[5], iban.mid(5,5));
m.set(id[6], iban.mid(10,5));
m.set(id[7], iban.mid(15));
}
}
const bool italy = f.empty() || f.get() == "IT";
m.show(id[3], !italy);
m.show(id[4], italy);
m.show(id[5], italy);
m.show(id[6], italy);
m.show(id[7], italy);
}
if (f.dlg() == id[2] && !f.empty() && key == K_ENTER)
{
const TString& stato = m.get(id[1]);
const bool italy = stato.empty() || stato == "IT";
const bool do_test = !m.field(id[italy ? 7 : 3]).empty(); // Faccio il test solo in presenza di conto corrente
TString80 iban;
if (do_test)
{
iban << m.get(id[1]) << m.get(id[2]);
if (italy)
iban << m.get(id[4]) << m.get(id[5]) << m.get(id[6]) << m.get(id[7]);
else
iban << m.get(id[3]);
TString msg;
const int err = iban_check(iban, msg);
if (err != 0)
{
msg.insert(TR("Codice IBAN errato:\n"));
if (err > 1) // Errore grave
ok = error_box(msg);
else
{
msg << '\n' << TR("Si desidera continuare ugualmente?");
ok = yesno_box(msg);
}
}
}
if (key == K_ENTER)
{
if (!ok) iban.cut(0);
m.set(id[0], iban);
}
}
return ok;
}
HIDDEN bool _bban_val(TMask_field& f, KEY key)
{
bool ok = true;
if (f.to_check(key))
if (key == K_ENTER && !f.empty())
{
const TMask& m = f.mask();
TString80 bban;
TMask& m = f.mask();
const int nparms = get_val_param_num();
for (int i = 0; i < nparms; i++)
CHECKD(nparms == 5, "BBAN_CHECK deve avere 5 parametri: ", nparms);
int id[5];
for (int i = 0; i < 5; i++)
id[i] = atoi(get_val_param(i));
if (f.dlg() == id[1])
{
const int id = atoi(get_val_param(i));
bban << m.get(id);
}
TString msg;
ok = bban_check(bban, msg);
if (!ok)
{
msg.insert(TR("Codice BBAN errato:\n"));
error_box(msg);
TString80 bban;
for (int i = 1; i < 5; i++)
bban << m.get(id[i]);
if (bban.len() > 11)
{
TString msg;
const int err = bban_check(bban, msg);
if (err != 0)
{
msg.insert(TR("Codice BBAN errato:\n"));
if (err > 1) // Errore grave
ok = error_box(msg);
else
{
msg << '\n' << TR("Si desidera continuare ugualmente?");
ok = yesno_box(msg);
}
}
}
}
}
return ok;
}
@ -970,32 +1025,32 @@ HIDDEN bool _bban_val(TMask_field& f, KEY key)
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{
_expr_val,
_expr_val, // 0
_emptycopy_val,
_pi_val,
_cf_val,
_notempty_val,
_date_cmp,
_date_cmp, // 5
_xt_pi_val,
_xt_cf_val,
_xtz_pi_val,
_xtz_cf_val,
_fixlen_val,
_fixlen_val, // 10
_mtcheck_val,
_reqif_val,
_autoexit_val,
_numcalc_val,
_strcalc_val,
_strcalc_val, // 15
_onereq_val,
_chkfld_val,
_filename_val,
_zerofill_val,
_alpha_val,
_alpha_val, // 20
_not_empty_chkfld_val,
_ora_val,
_sconto_val,
_iban_val,
_bban_val,
_bban_val, // 25
};
// @doc INTERNAL

View File

@ -9,7 +9,7 @@ bool validate(int fn, TMask_field& f, KEY k, const TArray& parms);
bool pi_check (const char* stato, const char* pi);
bool cf_check (const char* stato, const char* cf);
bool iban_check(const TString& b, TString& msg);
bool bban_check(const TString& b, TString& msg);
int iban_check(const TString& b, TString& msg);
int bban_check(const TString& b, TString& msg);
#endif // __VALIDATE_H