@DefaultHandler
public Resolution save() {
if (getErrorsCount()==0) {
final String sFormerId = getParam("accountingAccount.id");
try {
AccountingAccount oAacc;
connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
if (sFormerId.length()>0) {
oAacc = new AccountingAccount();
oAacc.load(getSession(), sFormerId);
oAacc.setCode(getParam("accountingAccount.code"));
oAacc.setDescription(getParam("accountingAccount.description"));
oAacc.setActive(getParam("accountingAccount.active","1").equals("1"));
} else {
Dms oDms = getSession().getDms();
TaxPayer oTxpr = new TaxPayer(getSession().getDms(), getParam("taxPayer"));
Document oDoca = oDms.newDocument(oDms.getDocumentType("AccountingAccount"), oTxpr.accounts(getSession()).getDocument());
oDoca.save("");
oAacc = new AccountingAccount(oDoca);
oAacc.setCode(getParam("accountingAccount.code"));
oAacc.setDescription(getParam("accountingAccount.description"));
oAacc.setActive(getParam("accountingAccount.active","1").equals("1"));
}
oAacc.save(getSession());
disconnect();
addDataLine("taxpayer",getParam("taxPayer"));
addDataLine("id",oAacc.id());
addDataLine("uuid",oAacc.getUuid());
addDataLine("code",oAacc.getCode());
addDataLine("description",oAacc.getDescription());
} catch (Exception xcpt) {
Log.out.error(xcpt.getMessage(), xcpt);
addError(new SimpleError(xcpt.getMessage()));
} finally {
close();