}
if(hasErrors()){
return INPUT;
}
PurchaseOrder purchaseOrder;
if(getPurchaseOrder().getId() == null || "".equalsIgnoreCase(getPurchaseOrder().getId())){
purchaseOrder = new PurchaseOrder();
logInfo = new LogInformation();
logInfo.setCreateBy(sessionCredentials.getCurrentUser().getId());
logInfo.setCreateDate(new Timestamp(System.currentTimeMillis()));
} else {
purchaseOrder = (PurchaseOrder) manager.getById(PurchaseOrder.class, getPurchaseOrder().getId());
logInfo = purchaseOrder.getLogInformation();
}
logInfo.setActiveFlag(getActive());
logInfo.setLastUpdateBy(sessionCredentials.getCurrentUser().getId());
logInfo.setLastUpdateDate(new Timestamp(System.currentTimeMillis()));
purchaseOrder.setLogInformation(logInfo);
purchaseOrder.setDocumentNo(getPurchaseOrder().getDocumentNo());
purchaseOrder.setDescription(getPurchaseOrder().getDescription());
purchaseOrder.setDateOrdered(getPurchaseOrder().getDateOrdered());
purchaseOrder.setDatePromised(getPurchaseOrder().getDatePromised());
purchaseOrder.setBusinessPartner(getBusinessPartner());
purchaseOrder.setInvoiceLocation(getInvoiceLocation());
purchaseOrder.setPartnerLocation(getPartnerLocation());
purchaseOrder.setInvoicePartner(getInvoicePartner());
purchaseOrder.setContact(getContact());
purchaseOrder.setInvoiceContact(getInvoiceContact());
purchaseOrder.setWarehouse(getWarehouse());
purchaseOrder.setPriority(getPurchaseOrder().getPriority());
purchaseOrder.setPriceList(getPriceList());
purchaseOrder.setCompanyAgent(getCompanyAgent());
purchaseOrder.setCurrency(getCurrency());
purchaseOrder.setDiscountPrinted(getPurchaseOrder().getDiscountPrinted());
purchaseOrder.setPaymentTerm(getPaymentTerm());
manager.save(purchaseOrder);
setPurchaseOrder(purchaseOrder);
return SUCCESS;
}