Client representative = null;
if (sr.getPolis().getNumber().equals(Polis.FICTIVE_POLIS_NUMBER)) {
representative = client.getRepresentative();
}
ClientDocument doc;
Polis polis;
if (representative != null) {
rd.p_status = client.getRepresentativeStatus().getId();
rd.p_fam = representative.getSurname() == null ? 0 : representative.getSurname().getId();
rd.p_nam = representative.getName() == null ? 0 : representative.getName().getId();
rd.p_fnam = representative.getPathronymic() == null ? 0 : representative.getPathronymic().getId();
rd.pred = 1;
doc = representative.getClientDocument();
polis = ClientBean.findPolisOMI(representative, manager);
} else {
rd.p_status = 0;
rd.p_fam = 0;
rd.p_nam = 0;
rd.p_fnam = 0;
rd.pred = 0;
doc = client.getClientDocument();
polis = sr.getPolis();
}
rd.pol_ser = polis.getSeries();
rd.pol_num = polis.getNumber();
if (rd.pol_num.equals(Polis.FICTIVE_POLIS_NUMBER)) {
rd.pol_num = "";
rd.pol_ser = "";
}
if (address != null) {
AddressObject country = address.getAddressObject();
while (country.getParent() != null) {
country = country.getParent();
}
rd.c_oksm = country.getKladrCode();
} else {
//Если указан российский пасспорт считаем что гражданство российское
if (doc != null && doc.getDoctype().getId() == ClientDocumentType.TYPE_PASSPORT_RF) {
rd.c_oksm = "643";
} else {
rd.c_oksm = "";
}
}
rd.type_doc = doc != null ? doc.getDoctype().getId() : 0;
rd.doc_ser = doc != null ? doc.getSeries() : "";
rd.doc_num = doc != null ? doc.getNumber() : "";
//Обрезание до 20 символов
if (rd.doc_num.length() > 20) {
rd.doc_num = rd.doc_num.substring(0, 20);
}