diff --git a/at/at8900.cpp b/at/at8900.cpp index 25d48119a..bf42a4b19 100755 --- a/at/at8900.cpp +++ b/at/at8900.cpp @@ -447,6 +447,7 @@ bool TCtpr2at::build_record(TAssoc_array& record, const TString& istruzione) bool TCtpr2at::soggetto(const TString& istruzione) { + const TDate oggi(TODAY); int error = NOERR; TAssoc_array record; if (build_record(record, istruzione)) @@ -503,24 +504,39 @@ bool TCtpr2at::soggetto(const TString& istruzione) } } if (error != NOERR) - { - recsog.zero(); - recsog.put(SOG_COGNOME, cognome); - recsog.put(SOG_NOME, nome); - recsog.put(SOG_DATANASC, datanasc); - recsog.put(SOG_NOTIZIARIO, 'X'); - recsog.put(SOG_BENEM, 'X'); - recsog.put(SOG_CODICE, get_next_key()); - error = recsog.write(_rel->lfile()); - stampa = "Inserito da CETRAPLUS"; - print_line(stampa); + { + bool inserisci = TRUE; + const long eta = oggi - datanasc; + if (eta > 71) + { + const TString16& stato = (TString16&) record["DT_NASCITA"]; + TRectype recpr1 = cache().get("PR1", stato); + TString16 catdon = recpr1.get("S6"); + if (catdon.not_empty()) + inserisci = cache().get("CTD", catdon).get_bool("B0"); + } + if (inserisci) + { + recsog.zero(); + recsog.put(SOG_COGNOME, cognome); + recsog.put(SOG_NOME, nome); + recsog.put(SOG_DATANASC, datanasc); + recsog.put(SOG_NOTIZIARIO, 'X'); + recsog.put(SOG_BENEM, 'X'); + recsog.put(SOG_CODICE, get_next_key()); + error = recsog.write(_rel->lfile()); + stampa = "Inserito da CETRAPLUS"; + print_line(stampa); + } } - if (update_record(recsog, record)) + if (error == NOERR) { - TDate oggi(TODAY); - recsog.put(SOG_DATAULTAGG, oggi); - recsog.put(SOG_UTENULTAGG, "CETRAPLUS"); - error = recsog.rewrite(_rel->lfile()); + if (update_record(recsog, record)) + { + recsog.put(SOG_DATAULTAGG, oggi); + recsog.put(SOG_UTENULTAGG, "CETRAPLUS"); + error = recsog.rewrite(_rel->lfile()); + } } return (error == NOERR); }