HttpServletRequest request,
HttpServletResponse response) throws Throwable {
InvoiceMaintActionForm form = (InvoiceMaintActionForm) actionForm;
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
InvoiceHeader invoiceHeader = (InvoiceHeader) em.find(InvoiceHeader.class, Format.getLong(form.getInvoiceHeaderId()));
OrderHeader orderHeader = invoiceHeader.getOrderHeader();
initOrder(form, orderHeader, invoiceHeader, null, null, request);
Iterator<?> iterator = form.getOrderItemDetails().iterator();
Vector<InvoiceDetailDisplayForm> invoiceDetailVector = new Vector<InvoiceDetailDisplayForm>();
while (iterator.hasNext()) {
OrderItemDetailDisplayForm itemDisplay = (OrderItemDetailDisplayForm) iterator.next();
InvoiceDetailDisplayForm invoiceDisplay = new InvoiceDetailDisplayForm();
invoiceDisplay.setOrderItemDetailId(itemDisplay.getOrderItemDetailId());
invoiceDisplay.setItemId(itemDisplay.getItemId());
invoiceDisplay.setItemSkuCd(itemDisplay.getItemSkuCd());
invoiceDisplay.setItemNum(itemDisplay.getItemNum());
invoiceDisplay.setItemShortDesc(itemDisplay.getItemShortDesc());
invoiceDisplay.setItemTierQty(itemDisplay.getItemTierQty());
invoiceDisplay.setItemTierPrice(itemDisplay.getItemTierPrice());
invoiceDisplay.setItemOrderQty(itemDisplay.getItemOrderQty());
invoiceDisplay.setItemCreditQty(itemDisplay.getItemCreditQty());
invoiceDisplay.setItemShipQty(itemDisplay.getItemShipQty());
invoiceDisplay.setInputInvoiceQty("");
invoiceDisplay.setItemInvoiceAmount(Format.getFloat(0));
invoiceDisplay.setItemInvoiceQty(itemDisplay.getItemInvoiceQty());
invoiceDisplay.setOrderItemAttributes(itemDisplay.getOrderItemAttributes());
Iterator<?> invoiceDetailIterator = invoiceHeader.getInvoiceDetails().iterator();
while (invoiceDetailIterator.hasNext()) {
InvoiceDetail invoiceDetail = (InvoiceDetail) invoiceDetailIterator.next();
if (itemDisplay.getOrderItemDetailId().equals(invoiceDetail.getOrderItemDetail().getOrderItemDetailId().toString())) {
invoiceDisplay.setInputInvoiceQty(Format.getInt(invoiceDetail.getItemInvoiceQty()));
invoiceDisplay.setItemInvoiceAmount(Format.getFloat(invoiceDetail.getItemInvoiceAmount()));
}
}
invoiceDetailVector.add(invoiceDisplay);
}
InvoiceDetailDisplayForm invoiceDetails[] = new InvoiceDetailDisplayForm[invoiceDetailVector.size()];
invoiceDetailVector.copyInto(invoiceDetails);
form.setInvoiceDetails(invoiceDetails);
form.setEditable(false);
form.setAllowCredit(false);
InvoiceEngine invoiceEngine = new InvoiceEngine(invoiceHeader, null);
//em.evict(invoiceHeader);
form.setInputShippingTotal(Format.getFloat(invoiceEngine.getInvoiceHeader().getShippingTotal()));
if (invoiceEngine.isOpen(invoiceHeader)) {
form.setEditable(true);
}
if (invoiceEngine.isCompleted(invoiceHeader)) {
form.setAllowCredit(true);
}
form.setNewInvoice(false);
if (orderHeader.getPaymentGatewayProvider() == null) {
if (invoiceHeader.getInvoiceStatus().equals(Constants.ORDERSTATUS_OPEN)) {
form.setAllowCapture(true);
}
if (invoiceHeader.getInvoiceStatus().equals(Constants.ORDERSTATUS_COMPLETED)) {
form.setAllowVoid(true);