if (request.getParameter("buttonpress") != null)
typeOfSave = request.getParameter("buttonpress");
AccountFacade remote =(AccountFacade)accountFacadeHome.create();
remote.setDataSource(dataSource);
int jurisdictionID = 0;
int billingAddressID = 0;
if(invoiceForm.getJurisdictionID() != null && !((invoiceForm.getJurisdictionID()).equals(""))){
jurisdictionID = (invoiceForm.getJurisdictionID()).intValue();
}//end of if(invoiceForm.getJurisdictionID() != null && !((invoiceForm.getJurisdictionID()).equals("")))
if(invoiceForm.getBilltoID() != null && !((invoiceForm.getBilltoID()).equals(""))){
billingAddressID = Integer.parseInt(invoiceForm.getBilltoID());
}//end of if(invoiceForm.getBilltoID() != null && !((invoiceForm.getBilltoID()).equals("")))
if(billingAddressID != 0 && jurisdictionID != 0){
remote.setJurisdictionForAddress(billingAddressID,jurisdictionID);
}//end of if(billingAddressID != 0 && jurisdictionID != 0)
InvoiceVOX vox = new InvoiceVOX(invoiceForm);
InvoiceVO invoiceVO = vox.getVO();
if (typeOfSave.equals("save"))
{
InvoiceForm newinvoiceform = new InvoiceForm();
remote.updateInvoice(invoiceVO,userId);
invoiceVO = remote.getInvoiceVO(invoiceVO.getInvoiceId(),userId);
newinvoiceform.setInvoiceid(invoiceVO.getInvoiceId()+"");
newinvoiceform.setOrderid(invoiceVO.getOrderId()+"");
newinvoiceform.setCustomerId(invoiceVO.getCustomerId()+"");
newinvoiceform.setBillto(invoiceVO.getBillToAddress()+"");
newinvoiceform.setBilltoID(invoiceVO.getBillToId()+"");
newinvoiceform.setShiptoID(invoiceVO.getShipToId()+"");
newinvoiceform.setShipto(invoiceVO.getShipToAddress()+"");
newinvoiceform.setStatusid(invoiceVO.getStatusId()+"");
newinvoiceform.setInvoiceDate(invoiceVO.getInvoiceDate());
newinvoiceform.setPoid(invoiceVO.getPo());
newinvoiceform.setTermid(invoiceVO.getTermId()+"");
newinvoiceform.setAccountmanagerid(invoiceVO.getAccountManagerId()+"");
newinvoiceform.setProjectid(invoiceVO.getProjectId()+"");
newinvoiceform.setNotes(invoiceVO.getDescription()+"");
newinvoiceform.setProjectName(invoiceVO.getProjectName());
newinvoiceform.setAccountmanagerName(invoiceVO.getAccountManagerName());
newinvoiceform.setItemLines(invoiceVO.getItemLines());
newinvoiceform.setOrdername(invoiceVO.getCustomerName());
newinvoiceform.setExternalid(invoiceVO.getExternalId());
newinvoiceform.setJurisdictionID(invoiceVO.getJurisdictionID());
java.sql.Date invDate = invoiceVO.getInvoiceDate();
if (invDate != null)
{
int month = invDate.getMonth();
month=month+1;
newinvoiceform.setMonth(month+"");
int date = invDate.getDate();
newinvoiceform.setDate(date+"");
int year= invDate.getYear();
newinvoiceform.setYear(year+"");
}// end of if (invDate != null)
request.setAttribute("newinvoiceform",newinvoiceform);
form = invoiceForm;
FORWARD_final = FORWARD_save;
request.setAttribute(AccountConstantKeys.TYPEOFOPERATION, AccountConstantKeys.EDIT);
}// end of if (typeOfSave.equals("save"))
else if (typeOfSave.equals("savenew"))
{
remote.updateInvoice(invoiceVO,userId);
Vector taxJurisdiction = remote.getTaxJurisdiction();
invoiceForm.setJurisdictionVec(taxJurisdiction);
FORWARD_final = FORWARD_savenew;
request.setAttribute(AccountConstantKeys.TYPEOFOPERATION, AccountConstantKeys.ADD);
request.setAttribute("invoiceform",invoiceForm);
request.setAttribute("clearform","true");
}// end of else if (typeOfSave.equals("savenew"))
else if (typeOfSave.equals("saveclose"))
{
remote.updateInvoice(invoiceVO,userId);
FORWARD_final = FORWARD_saveclose;
request.setAttribute("body", "list");
}// end of else if (typeOfSave.equals("saveclose"))
else if (typeOfSave.equals("delete"))
{
remote.deleteInvoice(invoiceVO.getInvoiceId(),userId);
FORWARD_final = FORWARD_saveclose;
request.setAttribute("body", "list");
}// end of else if (typeOfSave.equals("delete"))
request.setAttribute(AccountConstantKeys.TYPEOFSUBMODULE, AccountConstantKeys.INVOICE);
} // end of try block