Patch level : 10.0 1152
Files correlati : fe0.exe fe0100a.msk Ricompilazione Demo : [ ] Commento : Migliorata gestione anagrafiche con Partita IVA duplicata Ridotto numero di segnalazioni poco importanti per facilitare controlli Ora è possibile eliminare le righe immesse manualmente git-svn-id: svn://10.65.10.50/branches/R_10_00@22491 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2d49557540
commit
a344994dc0
@ -274,12 +274,15 @@ public:
|
||||
|
||||
TExclusion_mode TDati_rilevanti_array::segnala_riga(const TRectype& alleg, TExclusion_mode motivo, TLog_report& log) const
|
||||
{
|
||||
const long numreg = alleg.get_long(ALL_PROGR);
|
||||
const char* tipocf = alleg.get_char(ALL_TIPOCF) == 'F' ? TR("Fornitore") : TR("Cliente");
|
||||
const long codcf = alleg.get_long(MOV_CODCF);
|
||||
TString msg; msg.format(FR("%s %6ld - Riga %7ld scartata: "), tipocf, codcf, numreg);
|
||||
msg << mode2string(motivo);
|
||||
log.log(1, msg);
|
||||
if (motivo > em_importo_limite)
|
||||
{
|
||||
const TAnagrafica a(alleg);
|
||||
TString msg;
|
||||
msg.format(FR("%s %s - Riga %7ld: "), alleg.get_char(ALL_TIPOCF) == 'F' ? TR("For.") : TR("Cli."),
|
||||
(const char*)a.ragione_sociale(), alleg.get_long(ALL_PROGR));
|
||||
msg << mode2string(motivo);
|
||||
log.log(1, msg);
|
||||
}
|
||||
return motivo;
|
||||
}
|
||||
|
||||
@ -295,6 +298,10 @@ TExclusion_mode TDati_rilevanti_array::add(const TRectype& alleg, bool send_all,
|
||||
if (importo.is_zero() && imposta.is_zero())
|
||||
return segnala_riga(alleg, em_importo_limite, log);
|
||||
|
||||
const TAnagrafica a(alleg);
|
||||
if (a.codice_fiscale().blank() && a.partita_IVA().blank())
|
||||
return segnala_riga(alleg, em_no_allegato, log);
|
||||
|
||||
const TString80 contratto = alleg.get(ALL_CONTRATTO);
|
||||
const TString8 numrett = alleg.get(ALL_NUMRETT);
|
||||
if (contratto.full() || numrett.full())
|
||||
@ -447,16 +454,21 @@ public:
|
||||
|
||||
TExclusion_mode TDati_rilevanti_msk::segnala_movimento(const TRectype& mov, TExclusion_mode motivo)
|
||||
{
|
||||
if (_why == em_incluso)
|
||||
if (_why <= em_importo_limite) // Aggiorna motivo esclusione se attualemte incluso o non rilevante
|
||||
{
|
||||
const long numreg = mov.get_long(MOV_NUMREG);
|
||||
const char* tipocf = mov.get_char(MOV_TIPO) == 'F' ? TR("Fornitore") : TR("Cliente");
|
||||
const long codcf = mov.get_long(MOV_CODCF);
|
||||
TString msg; msg.format(FR("%s %6ld - Registrazione %7ld scartata: "), tipocf, codcf, numreg);
|
||||
msg << mode2string(motivo);
|
||||
_why = motivo;
|
||||
if (motivo > em_importo_limite)
|
||||
if (motivo > em_importo_limite) // Non segnalare pippate
|
||||
{
|
||||
const long numreg = mov.get_long(MOV_NUMREG);
|
||||
const char tipocf = mov.get_char(MOV_TIPO); ;
|
||||
const long codcf = mov.get_long(MOV_CODCF);
|
||||
const TAnagrafica a(tipocf, codcf, mov.get(MOV_OCFPI));
|
||||
TString msg;
|
||||
msg.format(FR("Mov. %7ld %s %s: "), numreg,
|
||||
tipocf=='F' ? TR("For.") : TR("Cli."), (const char*)a.ragione_sociale());
|
||||
msg << mode2string(motivo);
|
||||
_log->log(1, msg);
|
||||
}
|
||||
}
|
||||
return motivo;
|
||||
}
|
||||
@ -479,7 +491,6 @@ TExclusion_mode TDati_rilevanti_msk::validate_clifo(const TRectype& mov)
|
||||
{
|
||||
TString8 key; key.format("%c|%ld", tipocf, codcf);
|
||||
const TRectype& rec_clifo = cache().get(LF_CLIFO, key);
|
||||
stato = rec_clifo.get(CLI_STATOCF);
|
||||
|
||||
const int alleg = rec_clifo.get_int(CLI_ALLEG);
|
||||
if (alleg == 1)
|
||||
@ -488,15 +499,17 @@ TExclusion_mode TDati_rilevanti_msk::validate_clifo(const TRectype& mov)
|
||||
if (tipocf == 'F' && alleg == 5)
|
||||
return segnala_movimento(mov, em_estero);
|
||||
|
||||
if (stato.full())
|
||||
{
|
||||
const TRectype& rec_sta = cache().get("%STA", stato);
|
||||
if (rec_sta.get_bool("B0"))
|
||||
return segnala_movimento(mov, em_fiscalita_agevolata);
|
||||
stato = rec_clifo.get(CLI_STATOCF);
|
||||
}
|
||||
|
||||
if (tipocf == 'F')
|
||||
return segnala_movimento(mov, em_estero);
|
||||
}
|
||||
if (stato.full())
|
||||
{
|
||||
const TRectype& rec_sta = cache().get("%STA", stato);
|
||||
if (rec_sta.get_bool("B0"))
|
||||
return segnala_movimento(mov, em_fiscalita_agevolata);
|
||||
|
||||
if (tipocf == 'F')
|
||||
return segnala_movimento(mov, em_estero);
|
||||
}
|
||||
|
||||
return em_incluso; //se arriva qui il clifo è da considerare
|
||||
@ -1020,8 +1033,6 @@ bool TDati_rilevanti_msk::send_fatt(const TRectype& alleg, TDati_rilevanti_set&
|
||||
if (!anag.ok())
|
||||
return false;
|
||||
|
||||
const TString& paiv = anag.partita_IVA();
|
||||
|
||||
if (anag.stato_estero() > 0)
|
||||
{
|
||||
operaz.new_rec("3"); // Operazioni con soggetti non residenti
|
||||
@ -1053,6 +1064,7 @@ bool TDati_rilevanti_msk::send_fatt(const TRectype& alleg, TDati_rilevanti_set&
|
||||
}
|
||||
else
|
||||
{
|
||||
const TString& paiv = anag.partita_IVA();
|
||||
if (paiv.blank())
|
||||
{
|
||||
operaz.new_rec("1"); // Operazioni con soggetti residenti non titolari di partita IVA
|
||||
@ -1563,11 +1575,29 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
|
||||
}
|
||||
break;
|
||||
case DLG_DELREC:
|
||||
if (e == fe_button && jolly == 0 && o.active())
|
||||
if (e == fe_button && o.active())
|
||||
{
|
||||
recall_alleg();
|
||||
enable_buttons(); // Disabilita bottone
|
||||
return false;
|
||||
if (jolly == 0) // Toolbar principale
|
||||
{
|
||||
recall_alleg();
|
||||
enable_buttons(); // Disabilita bottone
|
||||
return false;
|
||||
}
|
||||
else // Maschera di riga
|
||||
{
|
||||
const long progr = o.mask().get_long(A_RIGA);
|
||||
if (progr >= MANUAL_ROW)
|
||||
{
|
||||
TLocalisamfile alleg(LF_ALLEG);
|
||||
alleg.put(ALL_ANNO, get(F_ANNO));
|
||||
alleg.put(ALL_PROGR, progr);
|
||||
const int err = alleg.remove();
|
||||
if (err != NOERR)
|
||||
return error_box(FR("Errore di cancellazione: %d"), err);
|
||||
}
|
||||
else
|
||||
return error_box(TR("Riga non cancellabile"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DLG_PREVIEW:
|
||||
|
@ -109,6 +109,8 @@ BEGIN
|
||||
DISPLAY "Codice" CODCF
|
||||
DISPLAY "Ragione Sociale@50" RAGSOC
|
||||
DISPLAY "Occasionale@C" OCCAS
|
||||
DISPLAY "Codice Fiscale@16" COFI
|
||||
DISPLAY "Partita IVA@15" PAIV
|
||||
OUTPUT F_CODCF CODCF
|
||||
OUTPUT F_RAGSOC RAGSOC
|
||||
CHEKTYPE NORMAL
|
||||
@ -124,7 +126,10 @@ BEGIN
|
||||
INPUT RAGSOC F_RAGSOC
|
||||
DISPLAY "Ragione Sociale@50" RAGSOC
|
||||
DISPLAY "Codice" CODCF
|
||||
DISPLAY "Codice Fiscale@16" COFI
|
||||
DISPLAY "Partita IVA@15" PAIV
|
||||
COPY OUTPUT F_CODCF
|
||||
ADD RUN CG0 -1
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
@ -363,8 +368,6 @@ BEGIN
|
||||
FLAGS "U"
|
||||
COPY ALL A_DATAREG
|
||||
ADD RUN cg2 -0
|
||||
STR_EXPR IF(#A_TIPOCF=="C";#A_NUMDOC!="";1)
|
||||
WARNING "E' necessario inserire il numero della fattura di vendita"
|
||||
FIELD NUMDOC
|
||||
END
|
||||
|
||||
|
144
fe/felib.cpp
144
fe/felib.cpp
@ -130,6 +130,13 @@ bool TAnagrafica::init(const TRectype& rec)
|
||||
}
|
||||
break;
|
||||
case LF_CLIFO:
|
||||
_allegato = rec.get_int(CLI_ALLEG);
|
||||
if (_allegato == 4)
|
||||
{
|
||||
const long ca = rec.get_long(CLI_CODALLEG);
|
||||
if (ca > 0)
|
||||
return init(rec.get_char(CLI_TIPOCF), ca, EMPTY_STRING);
|
||||
}
|
||||
_tipo = rec.get_char(CLI_TIPOAPER);
|
||||
if (_tipo == 'F')
|
||||
{
|
||||
@ -155,7 +162,6 @@ bool TAnagrafica::init(const TRectype& rec)
|
||||
// Prevale sempre la ragione sociale del cliente: "Il cliente ha sempre ragione".
|
||||
_ragsoc = rec.get(CLI_RAGSOC); _ragsoc.upper();
|
||||
_stato_estero = rec.get_int(CLI_STATOCF);
|
||||
_allegato = rec.get_int(CLI_ALLEG);
|
||||
_loc_res = rec.get(CLI_LOCCF);
|
||||
break;
|
||||
case LF_MOV:
|
||||
@ -167,8 +173,7 @@ bool TAnagrafica::init(const TRectype& rec)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_tipo == 'G')
|
||||
_ragsoc.strip_double_spaces();
|
||||
_ragsoc.strip_double_spaces();
|
||||
|
||||
return _tipo == 'F' || _tipo == 'G';
|
||||
}
|
||||
@ -179,13 +184,17 @@ bool TAnagrafica::init(int num, char tipo, long codice)
|
||||
return init(cache().get(num, key));
|
||||
}
|
||||
|
||||
bool TAnagrafica::init(char tipo, long codice, const TString& ocfpi)
|
||||
bool TAnagrafica::init(char tipocf, long codice, const TString& ocfpi)
|
||||
{
|
||||
bool done = false;
|
||||
if (ocfpi.full())
|
||||
done = init(LF_OCCAS, ocfpi);
|
||||
if (!done)
|
||||
done = init(LF_CLIFO, tipo, codice);
|
||||
{
|
||||
CHECK(tipocf == 'C' || tipocf == 'F', "Tipo cli/for non valido");
|
||||
CHECKD(codice > 0, "Codice cli/for non valido", codice);
|
||||
done = init(LF_CLIFO, tipocf, codice);
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@ -546,23 +555,34 @@ TDati_rilevanti_set::TDati_rilevanti_set(int anno)
|
||||
// TCofi_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TObject* TCofi_cache::key2obj(const char* key)
|
||||
TObject* TCofi_cache::find_ragsoc(bool piva, char tipocf, const TString& code)
|
||||
{
|
||||
TToken_string chiave(key);
|
||||
const int fkey = chiave.get_char(0)=='C' ? 4 : 5;
|
||||
const TString4 tipocf = chiave.get();
|
||||
const TString16 code= chiave.get();
|
||||
|
||||
const int fkey = piva ? 5 : 4;
|
||||
const char* kfield = piva ? CLI_PAIV : CLI_COFI;
|
||||
_clifo.setkey(fkey);
|
||||
_clifo.zero();
|
||||
_clifo.put(CLI_TIPOCF, tipocf);
|
||||
if (fkey == 5)
|
||||
_clifo.put(CLI_PAIV, code);
|
||||
else
|
||||
_clifo.put(CLI_COFI, code);
|
||||
_clifo.put(kfield, code);
|
||||
|
||||
int err = _clifo.read();
|
||||
if (err != NOERR && fkey == 5 && pi_check("IT", code))
|
||||
|
||||
if (err == NOERR && _clifo.get_int(CLI_ALLEG) == 4) // Codice Fiscale o Partita IVA doppia
|
||||
{
|
||||
const long codall = _clifo.get_long(CLI_CODALLEG);
|
||||
if (codall > 0)
|
||||
{
|
||||
const TRecnotype recno = _clifo.recno();
|
||||
_clifo.setkey(1);
|
||||
_clifo.put(CLI_TIPOCF, tipocf);
|
||||
_clifo.put(CLI_CODCF, codall);
|
||||
err = _clifo.read();
|
||||
if (err != NOERR || _clifo.get(kfield) != code)
|
||||
err = _clifo.readat(recno);
|
||||
_clifo.setkey(fkey);
|
||||
}
|
||||
}
|
||||
|
||||
if (err != NOERR && piva && pi_check("IT", code))
|
||||
{
|
||||
_clifo.put(CLI_TIPOCF, tipocf);
|
||||
_clifo.put(CLI_STATOPAIV, "IT");
|
||||
@ -573,7 +593,7 @@ TObject* TCofi_cache::key2obj(const char* key)
|
||||
if (err == NOERR)
|
||||
return new TString80(_clifo.get(CLI_RAGSOC));
|
||||
|
||||
if (fkey == 5 && !pi_check("IT", code)) // cerco partite IVA estere
|
||||
if (piva && !pi_check("IT", code)) // cerco partite IVA estere
|
||||
{
|
||||
TString query;
|
||||
query << "USE CLIFO SELECT PAIV=\"" << code << '"'
|
||||
@ -587,38 +607,67 @@ TObject* TCofi_cache::key2obj(const char* key)
|
||||
_occas.put(OCC_CFPI, code);
|
||||
if (_occas.read() == NOERR)
|
||||
{
|
||||
const TString& cfpi = _occas.get(fkey == 4 ? OCC_COFI : OCC_PAIV);
|
||||
const TString& cfpi = _occas.get(piva ? OCC_PAIV : OCC_COFI);
|
||||
if (code == cfpi || cfpi.empty())
|
||||
return new TString80(_occas.get(OCC_RAGSOC));
|
||||
}
|
||||
|
||||
TString query;
|
||||
query << "USE OCCAS SELECT ";
|
||||
if (fkey == 4)
|
||||
query << "COFI=\"" << code << '"';
|
||||
else
|
||||
if (piva)
|
||||
query << "PAIV=\"" << code << '"';
|
||||
else
|
||||
query << "COFI=\"" << code << '"';
|
||||
TISAM_recordset occas(query);
|
||||
if (occas.move_first())
|
||||
return new TString80(occas.get(OCC_RAGSOC).as_string());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TObject* TCofi_cache::key2obj(const char* key)
|
||||
{
|
||||
TToken_string chiave(key);
|
||||
const bool paiv = chiave.get_char(0)=='P';
|
||||
const char tipocf = chiave.get_char(1);
|
||||
TString16 code; chiave.get(2, code);
|
||||
|
||||
TObject* ragsoc = NULL;
|
||||
if (code.full())
|
||||
{
|
||||
if (tipocf != 'C' && tipocf != 'F')
|
||||
{
|
||||
ragsoc = find_ragsoc(paiv, 'C', code);
|
||||
if (ragsoc == NULL)
|
||||
ragsoc = find_ragsoc(paiv, 'F', code);
|
||||
}
|
||||
else
|
||||
ragsoc = find_ragsoc(paiv, tipocf, code);
|
||||
}
|
||||
return ragsoc;
|
||||
}
|
||||
|
||||
const TString& TCofi_cache::cofi2ragsoc(char tipocf, const TString& cofi)
|
||||
{
|
||||
TString80 key;
|
||||
key.format("CF|%c|%s", tipocf, (const char*)cofi);
|
||||
const TString* ragsoc = (const TString*)objptr(key);
|
||||
return ragsoc != NULL ? *ragsoc : EMPTY_STRING;
|
||||
const TString* ragsoc = NULL;
|
||||
if (cofi.full())
|
||||
{
|
||||
TString80 key;
|
||||
key.format("CF|%c|%s", tipocf, (const char*)cofi);
|
||||
ragsoc = (const TString*)objptr(key);
|
||||
}
|
||||
return ragsoc ? *ragsoc : EMPTY_STRING;
|
||||
}
|
||||
|
||||
const TString& TCofi_cache::paiv2ragsoc(char tipocf, const TString& paiv)
|
||||
{
|
||||
TString80 key;
|
||||
key.format("PI|%c|%s", tipocf, (const char*)paiv);
|
||||
const TString* ragsoc = (const TString*)objptr(key);
|
||||
return ragsoc != NULL ? *ragsoc : EMPTY_STRING;
|
||||
const TString* ragsoc = NULL;
|
||||
if (paiv.full())
|
||||
{
|
||||
TString80 key;
|
||||
key.format("PI|%c|%s", tipocf, (const char*)paiv);
|
||||
ragsoc = (const TString*)objptr(key);
|
||||
}
|
||||
return ragsoc ? *ragsoc : EMPTY_STRING;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -662,19 +711,18 @@ bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
}
|
||||
if (name == "RAGSOC")
|
||||
{
|
||||
char tipocf = 'C';
|
||||
switch (tipo)
|
||||
{
|
||||
case 2: if (set.get("2.8").as_int() == 2) tipocf = 'F'; break;
|
||||
default: break;
|
||||
};
|
||||
switch (tipo)
|
||||
{
|
||||
case 1: var = cofi2ragsoc(tipocf, set.get("1.2").as_string()); break;
|
||||
case 2: var = paiv2ragsoc(tipocf, set.get("2.2").as_string()); break;
|
||||
case 1: var = cofi2ragsoc(' ', set.get("1.2").as_string()); break;
|
||||
case 2:
|
||||
{
|
||||
const char tipocf = set.get("2.8").as_int() == 2 ? 'F' : 'C';
|
||||
var = paiv2ragsoc(tipocf, set.get("2.2").as_string());
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
var = set.get("3.8");
|
||||
if (var.is_empty())
|
||||
if (var.as_string().blank())
|
||||
{
|
||||
TString80 rs;
|
||||
rs << set.get("3.2") << ' ' << set.get("3.3");
|
||||
@ -685,23 +733,17 @@ bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
const TString16 paiv = set.get("4.2").as_string();
|
||||
if (paiv.full())
|
||||
{
|
||||
var = paiv2ragsoc('C', paiv);
|
||||
if (var.is_empty())
|
||||
var = paiv2ragsoc('F', paiv);
|
||||
}
|
||||
var = paiv2ragsoc(' ', paiv);
|
||||
else
|
||||
{
|
||||
const TString16 cofi = set.get("4.3").as_string();
|
||||
var = cofi2ragsoc('C', cofi);
|
||||
if (var.is_empty())
|
||||
var = paiv2ragsoc('F', cofi);
|
||||
var = cofi2ragsoc(' ', cofi);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
var = set.get("5.8");
|
||||
if (var.is_empty())
|
||||
if (var.as_string().blank())
|
||||
{
|
||||
TString80 rs;
|
||||
rs << set.get("5.2") << ' ' << set.get("5.3");
|
||||
@ -786,7 +828,7 @@ bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
switch (tipo)
|
||||
{
|
||||
case 4: var = set.get("4.10"); break;
|
||||
case 4: var = set.get("4.10"); break;
|
||||
case 5: var = set.get("5.18"); break;
|
||||
default: var.set_null(); break;
|
||||
}
|
||||
@ -796,7 +838,7 @@ bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
switch (tipo)
|
||||
{
|
||||
case 4: var = set.get("4.11"); break;
|
||||
case 4: var = set.get("4.11"); break;
|
||||
case 5: var = set.get("5.19"); break;
|
||||
default: var.set_null(); break;
|
||||
}
|
||||
@ -808,7 +850,7 @@ bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
case 1: var = set.get("1.4"); break;
|
||||
case 2: var = set.get("2.5"); break;
|
||||
case 3: var = set.get("3.14"); break;
|
||||
case 3: var = set.get("3.14"); break;
|
||||
default: var.set_null(); break;
|
||||
}
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
bool init(int num, const TString& codice) { return init(cache().get(num, codice)); }
|
||||
bool init(int num, long codice) { return init(cache().get(num, codice)); }
|
||||
bool init(int num, char tipo, long codice);
|
||||
bool init(char tipo, long codice, const TString& ocfpi);
|
||||
bool init(char tipocf, long codice, const TString& ocfpi);
|
||||
|
||||
TAnagrafica() : _tipo('\0') {}
|
||||
TAnagrafica(int lognum, const TString& codice) { init(lognum, codice); }
|
||||
@ -102,6 +102,7 @@ class TCofi_cache : public TCache
|
||||
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key);
|
||||
TObject* find_ragsoc(bool piva, char tipocf, const TString& code);
|
||||
|
||||
public:
|
||||
const TString& cofi2ragsoc(char tipocf, const TString& cofi);
|
||||
|
Loading…
x
Reference in New Issue
Block a user