final String sBusinessName = getParam("taxPayer.businessName");
final String sTaxId = getParam("taxPayer.taxId");
final String sFormerId = getParam("taxPayer.id");
Log.out.debug("Validating TaxPayer with business name "+sBusinessName+" and tax id. "+sTaxId+" for former id "+sFormerId);
if (sBusinessName==null) {
addError(new LocalizableError("com.zesped.action.SaveClient.businessName.valueNotPresent"));
} else if (sBusinessName.length()==0) {
addError(new LocalizableError("com.zesped.action.SaveClient.businessName.valueNotPresent"));
} else {
try {
connect();
CustomerAccount oAcc = new CustomerAccount(getSession().getDms(), getSessionAttribute("customer_account_docid"));
TaxPayer oFoundTaxPayer = oAcc.taxpayers(getSession()).seek(getSession(), sBusinessName);
if (!oFoundTaxPayer.id().equals(sFormerId))
addError(new LocalizableError("com.zesped.action.SaveClient.businessNameAlreadyExists"));
oFoundTaxPayer = oAcc.taxpayers(getSession()).seek(getSession(), sTaxId);
if (!oFoundTaxPayer.id().equals(sFormerId))
addError(new LocalizableError("com.zesped.action.SaveClient.taxIdAlreadyExists"));
} catch (ElementNotFoundException clientnotfound) {
} catch (Exception e) {
Log.out.error("SaveTaxPayer.validateBusinessName("+sBusinessName+") "+e.getClass().getName()+" "+e.getMessage(), e);
} finally {
close();