package com.gpc.client.pointofsale.invoice.line;
import java.awt.Component;
import java.awt.Container;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.FocusManager;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import org.apache.log4j.Logger;
import com.gpc.businessservice.factory.indago.TamsJmoIntegrationServiceFactory;
import com.gpc.businessservice.factory.ppseservice.PPSEServiceFactory;
import com.gpc.businessservice.factory.rads.RadsServiceFactory;
import com.gpc.businessservice.interfaces.indago.BuildInboundMessageService;
import com.gpc.businessservice.interfaces.ppseservice.PPSEService;
import com.gpc.client.common.ClientApplicationContext;
import com.gpc.client.common.ClientPropConstants;
import com.gpc.client.common.event.BuyoutEvent;
import com.gpc.client.common.event.BuyoutListener;
import com.gpc.client.common.event.CartEvent;
import com.gpc.client.common.event.CartListener;
import com.gpc.client.common.event.CatalogEvent;
import com.gpc.client.common.event.CatalogListener;
import com.gpc.client.common.event.CatalogPartsListEvent;
import com.gpc.client.common.event.CatalogTitleEvent;
import com.gpc.client.common.event.CheckoutEvent;
import com.gpc.client.common.event.CheckoutListener;
import com.gpc.client.common.event.CustomerEvent;
import com.gpc.client.common.event.CustomerListener;
import com.gpc.client.common.event.EmployeeEvent;
import com.gpc.client.common.event.EmployeeListener;
import com.gpc.client.common.event.InvoiceEvent;
import com.gpc.client.common.event.InvoiceLineEntryListener;
import com.gpc.client.common.event.InvoiceListListener;
import com.gpc.client.common.event.InvoiceListener;
import com.gpc.client.common.event.POSTAMSEvent;
import com.gpc.client.common.event.POSTAMSListener;
import com.gpc.client.common.event.PointOfSaleEvent;
import com.gpc.client.common.event.PointOfSaleEventDispatcher;
import com.gpc.client.common.event.PointOfSaleListEvent;
import com.gpc.client.common.event.PointOfSaleListListener;
import com.gpc.client.common.event.ProcessLineQueueListener;
import com.gpc.client.common.event.ProfileEvent;
import com.gpc.client.common.event.ProfileListener;
import com.gpc.client.common.event.StoreEvent;
import com.gpc.client.common.event.StoreListener;
import com.gpc.client.common.event.VehicleEvent;
import com.gpc.client.common.event.VehicleListener;
import com.gpc.client.common.focusmanager.FocusDecider;
import com.gpc.client.common.input.document.FwoValidatedDecimalNumberDocument;
import com.gpc.client.common.input.document.FwoValidatedWholeNumberDocument;
import com.gpc.client.common.input.document.TsoValidatedIMPartNumberDocument;
import com.gpc.client.common.input.document.TsoValidatedLineAbbrevDocument;
import com.gpc.client.common.input.verifier.FwoBaseInputVerifier;
import com.gpc.client.common.input.verifier.FwoNumberVerifier;
import com.gpc.client.common.input.verifier.TsoIMPartNumberVerifier;
import com.gpc.client.common.mvc.IView;
import com.gpc.client.common.util.BrowserLauncher;
import com.gpc.client.common.util.ClientUtil;
import com.gpc.client.pointofsale.cashier.CashierController;
import com.gpc.client.pointofsale.cashier.CashierPanel;
import com.gpc.client.pointofsale.catalog.CatalogButtonPanel;
import com.gpc.client.pointofsale.catalog.partinfo.AdditionalPartInfoController;
import com.gpc.client.pointofsale.customer.CustomerBL;
import com.gpc.client.pointofsale.giftcard.GiftCardBL;
import com.gpc.client.pointofsale.inventory.StockController;
import com.gpc.client.pointofsale.invoice.AaaMemberValidationController;
import com.gpc.client.pointofsale.invoice.AaaValidationController;
import com.gpc.client.pointofsale.invoice.AttentionTextEntryController;
import com.gpc.client.pointofsale.invoice.BannedPartListController;
import com.gpc.client.pointofsale.invoice.BannedPartListDialog;
import com.gpc.client.pointofsale.invoice.BopisCancelReasonController;
import com.gpc.client.pointofsale.invoice.BopisCancelReasonDialog;
import com.gpc.client.pointofsale.invoice.CustomerTaxInfoController;
import com.gpc.client.pointofsale.invoice.FinalizeInvoiceController;
import com.gpc.client.pointofsale.invoice.FinalizeNonPhoneRoomInvoiceController;
import com.gpc.client.pointofsale.invoice.FinalizeOptionalDeliveryInvoiceController;
import com.gpc.client.pointofsale.invoice.FinalizePhoneRoomInvoiceController;
import com.gpc.client.pointofsale.invoice.InvoiceBL;
import com.gpc.client.pointofsale.invoice.InvoiceController;
import com.gpc.client.pointofsale.invoice.InvoiceInitializerFunctions;
import com.gpc.client.pointofsale.invoice.InvoicePanel;
import com.gpc.client.pointofsale.invoice.InvoiceReturnApprovalController;
import com.gpc.client.pointofsale.invoice.InvoiceReturnCustomerInfoController;
import com.gpc.client.pointofsale.invoice.InvoiceReturnCustomerInfoDialog;
import com.gpc.client.pointofsale.invoice.PasswordController;
import com.gpc.client.pointofsale.invoice.PhoneRoomEjoeiController;
import com.gpc.client.pointofsale.invoice.PhoneRoomInterStoreController;
import com.gpc.client.pointofsale.invoice.PhoneRoomInvoiceBL;
import com.gpc.client.pointofsale.invoice.RadsDeliveryOptionController;
import com.gpc.client.pointofsale.invoice.RecallSavedInvPrintController;
import com.gpc.client.pointofsale.tax.PhoneRoomTax;
import com.gpc.client.pointofsale.tax.Tax;
import com.gpc.client.pointofsale.util.BaseController;
import com.gpc.client.pointofsale.util.DefaultDocument;
import com.gpc.client.pointofsale.util.SelectionField;
import com.gpc.client.pospricing.rmiclient.POSPricingClient;
import com.gpc.common.ApplicationContext;
import com.gpc.common.BOPISLogger;
import com.gpc.common.Constants;
import com.gpc.common.FwiConstant;
import com.gpc.common.Profile;
import com.gpc.common.ResourceBundleReader;
import com.gpc.common.SystemConfig;
import com.gpc.common.TsoConstant;
import com.gpc.common.constants.IndagoConstants;
import com.gpc.common.constants.PasswordConstants;
import com.gpc.common.constants.RadsConstants;
import com.gpc.common.constants.refvalues.RefCatalogDataVersion;
import com.gpc.common.constants.refvalues.RefCountry;
import com.gpc.common.constants.refvalues.RefInvoiceLineItemType;
import com.gpc.common.constants.refvalues.RefInvoiceNoteType;
import com.gpc.common.constants.refvalues.RefInvoiceSpecialFunction;
import com.gpc.common.constants.refvalues.RefNOLOrderStatus;
import com.gpc.common.constants.refvalues.RefNOLOrderType;
import com.gpc.common.constants.refvalues.RefOrderSubType;
import com.gpc.common.constants.refvalues.RefRadsDiscrepancyType;
import com.gpc.common.constants.refvalues.RefRadsResponse;
import com.gpc.common.constants.refvalues.RefRegulatoryType;
import com.gpc.common.constants.refvalues.RefState;
import com.gpc.common.exception.ApplicationException;
import com.gpc.common.exception.DisconnectedException;
import com.gpc.common.pattern.FwoNumberPattern;
import com.gpc.common.pattern.FwoPattern;
import com.gpc.common.pattern.NumberPatternFormatException;
import com.gpc.common.pattern.PatternParseException;
import com.gpc.common.pointofsale.invoice.CommonInvoiceBL;
import com.gpc.common.pointofsale.invoice.line.CommonInvoiceLineBL;
import com.gpc.common.pointofsale.invoice.line.PhoneRoomCommonInvoiceLineBL;
import com.gpc.common.session.SessionData;
import com.gpc.common.session.factory.SessionFactory;
import com.gpc.common.util.CommonUtil;
import com.gpc.common.util.FwoUtil;
import com.gpc.common.util.LockableBoolean;
import com.gpc.common.util.PartNumberFormatCertifier;
import com.gpc.common.util.RefStoreConfigurationUtil;
import com.gpc.common.util.StringUtils;
import com.gpc.server.dataaccess.customer.Customer;
import com.gpc.tams.comm.io.PhoneRoomTaapRouter;
import com.gpc.tams.comm.io.TaapRouter;
import com.gpc.valueobjects.PointOfSaleVO;
import com.gpc.valueobjects.catalog.PartVO;
import com.gpc.valueobjects.catalog.VehicleVO;
import com.gpc.valueobjects.common.IDValuePairVO;
import com.gpc.valueobjects.common.POSStateVO;
import com.gpc.valueobjects.customer.CustomerDeliveryVO;
import com.gpc.valueobjects.customer.CustomerVO;
import com.gpc.valueobjects.giftcard.GiftCardResponse;
import com.gpc.valueobjects.inventory.BaseInventoryVO;
import com.gpc.valueobjects.inventory.InventoryVO;
import com.gpc.valueobjects.inventory.KitDefinitionComponentVO;
import com.gpc.valueobjects.inventory.KitDefinitionVO;
import com.gpc.valueobjects.inventory.MiscChgVO;
import com.gpc.valueobjects.inventory.RegulationRuleMessageVO;
import com.gpc.valueobjects.inventory.RegulationRulePartVO;
import com.gpc.valueobjects.invoice.AttentionVO;
import com.gpc.valueobjects.invoice.InvoiceDeliveryVO;
import com.gpc.valueobjects.invoice.InvoiceVO;
import com.gpc.valueobjects.invoice.display.DisplayableInvoiceVO;
import com.gpc.valueobjects.invoice.line.BaseLineItemVO;
import com.gpc.valueobjects.invoice.line.FulfillmentItemVO;
import com.gpc.valueobjects.invoice.line.FulfillmentNoteVO;
import com.gpc.valueobjects.invoice.line.FulfillmentVO;
import com.gpc.valueobjects.invoice.line.InvoiceLineItemCertificationVO;
import com.gpc.valueobjects.invoice.line.InvoiceLineItemReturnVO;
import com.gpc.valueobjects.invoice.line.InvoiceLineItemVO;
import com.gpc.valueobjects.invoice.line.InvoiceNoteVO;
import com.gpc.valueobjects.invoice.line.KitLineItemVO;
import com.gpc.valueobjects.invoice.line.NAPAOnlineInfoVO;
import com.gpc.valueobjects.invoice.line.PhoneRoomStoreVO;
import com.gpc.valueobjects.invoice.rads.RadsDiscrepancyLog;
import com.gpc.valueobjects.ordering.notification.OrderNotificationStatus;
import com.gpc.valueobjects.ordering.salesorder.SalesOrderVO;
import com.gpc.valueobjects.profile.InvoicingProfileVO;
import com.gpc.valueobjects.profile.StoreProfileVO;
import com.gpc.valueobjects.reftables.RefTableVO;
import com.gpc.valueobjects.report.FwoPrinterSelectionSettings;
import com.gpc.valueobjects.services.RadsNewOrderOut;
import com.gpc.valueobjects.tax.TaxDecisionVO;
import com.gpc.valueobjects.tax.TaxTableVO;
/**
*
Title: InvoiceLineEntryController
* Description: CLASS DESCRIPTION GOES HERE
* @author Copyright © 1999-2003, Genuine Parts Company, All Rights Reserved
* @author Michelle McGovern
* @version 1.0
*/
public class InvoiceLineEntryController extends BaseController implements InvoiceListener,
InvoiceListListener, CustomerListener, EmployeeListener, VehicleListener,
ProcessLineQueueListener, CatalogListener, BuyoutListener,ProfileListener,
InvoiceLineEntryListener, PointOfSaleListListener, POSTAMSListener, StoreListener,
CheckoutListener, CartListener {
private static Logger logger = Logger.getLogger(InvoiceLineEntryController.class);
private InvoiceVO invoiceVO = null;
private InvoiceLineEntryPanel invoiceLineEntryPanel;
private InvoicePanel invoicePanel;
private CatalogButtonPanel catalogButtonPanel;
private CashierPanel cashierPanel;
private FinalizeInvoiceController finalizeInvoiceController;
private RadsDeliveryOptionController radsDeliveryOptionController;
private StockController stockController;
private CustomerVO customerVO;
private InvoiceLineItemVO invoiceLineItemVO;
private BaseLineItemVO baseLineItemVO;
private InvoiceNoteVO invoiceNoteVO;
private NAPAOnlineInfoVO napaOnlineInfoVO;
private AbstractLineItemHandler lineItemHandler;
private LineItemHandlerFactory lineItemHandlerFactory = LineItemHandlerFactory.getInstance();
private VehicleVO vehicleVO;
private PartVO partVO;
private AdditionalPartInfoController additionalPartInfoController;
private FinalizePhoneRoomInvoiceController finalizePhoneRoomInvoiceController;
private InvoiceReturnApprovalController invoiceReturnApprovalController;
private PasswordController passwordController;
private InvoiceReturnCustomerInfoController invoiceReturnCustomerInfoController;
private PhoneRoomEjoeiController phoneRoomEjoeiController;
private PhoneRoomInterStoreController phoneRoomInterStoreController;
private FinalizeNonPhoneRoomInvoiceController finalizeNonPhoneRoomInvoiceController;
private InvoiceController invoiceController;
private InvoiceReturnCustomerInfoDialog invoiceReturnCustomerInfoDialog;
private CheckoutLaterController checkoutLaterController;
private CustomerTaxInfoController customerTaxInfoController;
private WorkOrderController workOrderController;
private BopisCancelReasonDialog bopisCancelReasonDialog;
private BopisCancelReasonController bopisCancelReasonController;
private BannedPartListDialog bannedPartListDialog;
private BannedPartListController bannedPartListController;
private boolean focusMovingForward = true;
private boolean buttonClicked = false;
private boolean zeroPriceOK = false;
private boolean buyoutOpened = false;
/**Variable used to check whether a invoice line list panel is enabled or not*/
private boolean isLineListPanelEnabled = true ;
private Frame parentView;
private PartVO tempPartVO;
private DisplayableInvoiceVO dispInvVO;
private POSPricingClient posPricingClient;
//Bug No 28515, added a boolean variable
public static boolean priceDecision = false;
private boolean autoCheckDCQuantity = false;
private static boolean defectiveKitSelectedForRgn = false;
private boolean isFromDeleteBtn = false;
RecallSavedInvPrintController recallSavedInvPrintController;
TaapRouter taapRouter = new TaapRouter();
PhoneRoomTaapRouter phoneRoomTaapRouter = new PhoneRoomTaapRouter();
private FinalizeOptionalDeliveryInvoiceController finalizeOptionalDeliveryInvoiceController;
private CustomerDeliveryVO customerDeliveryVO;
private boolean isOptionalDeliveryFlag = false;
private int defaultCustomerTaxId = 0;
public static boolean isPartAddedFromPPSE2 = false;
boolean isPartCertified = false;
boolean isPartBlockSaleEnable = false;
public Vector directShipLines = new Vector();
private boolean reservedLineItem = false;
private boolean isReservedLineItem = false;
private boolean isDefectiveLine = false;
private boolean isNXPPunchedOut = false;
boolean isMessageSet = false;
public Vector vlineItems = null;
public boolean isBopisRADSOrderFailed = false;
public InvoiceLineEntryController(Container parentView) {
invoiceLineEntryPanel = new InvoiceLineEntryPanel();
additionalPartInfoController = new AdditionalPartInfoController(parentView);
finalizeInvoiceController = new FinalizeInvoiceController(parentView);
finalizePhoneRoomInvoiceController = new FinalizePhoneRoomInvoiceController(parentView);
finalizeNonPhoneRoomInvoiceController = new FinalizeNonPhoneRoomInvoiceController(parentView);
radsDeliveryOptionController = new RadsDeliveryOptionController(parentView);
invoiceReturnApprovalController = new InvoiceReturnApprovalController(parentView);
invoiceReturnCustomerInfoController = new InvoiceReturnCustomerInfoController(parentView);
phoneRoomEjoeiController = new PhoneRoomEjoeiController(parentView);
phoneRoomInterStoreController = new PhoneRoomInterStoreController(parentView);
bopisCancelReasonDialog = new BopisCancelReasonDialog((Frame) parentView);
recallSavedInvPrintController = new RecallSavedInvPrintController(parentView);
this.parentView = (Frame) parentView;
passwordController = new PasswordController(this.parentView);
Profile profile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation());
boolean loggedInAsPhoneRoom = clientApplicationContext.isLoggedInAsPhoneRoom();
invoiceLineEntryPanel.lblDC.setVisible(!loggedInAsPhoneRoom && profile.getStoreProfile().getDcStore().booleanValue()
&& profile.getStoreProfile().getDcStoreHasInventory().booleanValue());
invoiceLineEntryPanel.fldDC.setVisible(!loggedInAsPhoneRoom && profile.getStoreProfile().getDcStore().booleanValue()
&& profile.getStoreProfile().getDcStoreHasInventory().booleanValue());
finalizeOptionalDeliveryInvoiceController = new FinalizeOptionalDeliveryInvoiceController(parentView);
customerTaxInfoController = new CustomerTaxInfoController(parentView);
workOrderController = new WorkOrderController(parentView);
checkoutLaterController = new CheckoutLaterController(parentView);
install();
localizeView();
}
public void invoiceLoaded (InvoiceEvent ie) {
if (ie == null) {
return;
}
//Set the Cashierpanel if the invoice loaded from Cashier's function.
Object o = ie.getSource();
if (o instanceof CashierController) {
CashierController c = (CashierController) o;
this.setCashierPanel((CashierPanel)c.getView());
}
invoiceVO = (InvoiceVO) ie.getModel();
if (customerVO == null) {
try {
customerVO = clientApplicationContext.getCustomerDAO().getCustomerDetailInfoByID(
invoiceVO.getCustomerID(), invoiceVO.getCustomerTypeCD());
} catch (ApplicationException e) {
logger.error(e.toString(), e);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, e.getUserMessageID(), e.getUserMessageParameters());
return;
}
if (invoiceVO.getManualTransaction().booleanValue()) {
invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(false);
} else {
invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(
customerVO.getAlternateCoreCustomerID() != null);
}
}
}
public void invoicePrinted (InvoiceEvent ie) {
customerVO = null;
invoiceVO = (InvoiceVO) ie.getModel();
if (getInvoicePanel().getManualInvPanel().isVisible()) {
invoiceVO.setManualTransaction(Boolean.TRUE);
}
resetEntryArea(null, null);
resetLineItem(null);
resetSpecialFunctions(0, false);
setPartNumberEnabled(false);
}
public void invoiceSaved (InvoiceEvent ie) {
customerVO = null;
invoiceVO = (InvoiceVO) ie.getModel();
resetEntryArea(null, null);
resetLineItem(null);
resetSpecialFunctions(0, false);
byte posState = clientApplicationContext.getPOSState().getState();
if (clientApplicationContext.isLoggedInAsSales()
|| posState == POSStateVO.INVOICING_AS_CASHIER) {
this.getInvoicePanel().getEmployeeField().requestFocus();
} else if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
this.getInvoicePanel().getStoreComboBox().requestFocus();
} else {
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
this.getCashierPanel().getFldID().requestFocus();
} else {
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
this.getInvoicePanel().getStoreComboBox().requestFocus();
} else {
if (!this.getInvoicePanel().getCustomerComboBox().isEnabled()) {
this.getInvoicePanel().getCustomerComboBox().setEnabled(true);
}
this.getInvoicePanel().getCustomerComboBox().requestFocus();
}
}
}
setPartNumberEnabled(false);
if (invoiceVO != null && invoiceVO.getLineItems()!=null && invoiceVO.getPONumber()!=null) {
logger.error("InvoiceLineEntryController.invoiceSaved: for custID:" + invoiceVO.getCustomerID() + " /Number of line items:"
+ invoiceVO.getLineItems().size() + " /PONum:" + invoiceVO.getPONumber()+" /SessionId= "+invoiceVO.getSessionID());
}
}
public void invoiceCancelled(InvoiceEvent ie) {
customerVO = null;
invoiceVO = (InvoiceVO) ie.getModel();
if (getInvoicePanel().getManualInvPanel().isVisible()) {
invoiceVO.setManualTransaction(Boolean.TRUE);
}
if (invoiceVO.getPpseCartNumber() != null) {
PPSEService ppseService = PPSEServiceFactory.getServiceInstance();
ppseService.endPPSECartSession(invoiceVO.getPpseCartNumber(), "");
}
resetEntryArea(null, null);
resetLineItem(null);
setPartNumberEnabled(false);
resetSpecialFunctions(0, false);
}
public void invoiceSplitted(InvoiceEvent ie){
invoiceVO = (InvoiceVO) ie.getModel();
resetLineItem(null);
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
public void invoiceTotalChanged(InvoiceEvent ie) {
// placing the code to update the subtotal labels in a invokeLater call to allow
// the original event can finish, otherwise,
// the line item has not yet been added to the invoiceVO?
SwingUtilities.invokeLater(new Runnable() {
public void run() {
FwoNumberPattern fwoNumberPattern = (FwoNumberPattern)
FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL,
clientApplicationContext.getCurrentLocale(), true);
boolean displayPriceWithTax = getStoreProfile().getIncludeTaxInPrice().booleanValue();
BigDecimal subTotal = invoiceVO.getSubTotal();
BigDecimal bdSubtotal = subTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
logger.debug("InvoiceLineEntryController.invoiceTotalChanged - SubTotal = " + bdSubtotal);
try {
final StringBuffer subTotalValue = new StringBuffer(150);
if (displayPriceWithTax) {
final BigDecimal taxAmount = Tax.getInvoiceTaxAmount(invoiceVO, customerVO);
if (taxAmount != null && taxAmount.compareTo(new BigDecimal("0.00")) != 0) {
bdSubtotal = bdSubtotal.add(taxAmount).setScale(2,
BigDecimal.ROUND_HALF_UP);
}
subTotalValue.append(fwoNumberPattern.format(bdSubtotal));
} else {
subTotalValue.append(fwoNumberPattern.format(bdSubtotal));
}
invoiceLineEntryPanel.dlblSubtotal.setText(subTotalValue.toString());
if (invoiceVO.getManualTransaction().booleanValue()) {
invoiceLineEntryPanel.dlblAlternateCoreSubtotal.setText("");
} else {
if (invoiceVO.getAlternateCoreSubTotal() == null) {
invoiceLineEntryPanel.dlblAlternateCoreSubtotal.setText("0.00");
}else {
if (displayPriceWithTax
&& invoiceVO.getAlternateCoreDisplaySubTotal() != null) {
invoiceLineEntryPanel.dlblAlternateCoreSubtotal
.setText(fwoNumberPattern
.format(invoiceVO.getAlternateCoreDisplaySubTotal())
.toString());
} else {
invoiceLineEntryPanel.dlblAlternateCoreSubtotal
.setText(fwoNumberPattern
.format(invoiceVO.getAlternateCoreSubTotal())
.toString());
}
}
}
} catch (NumberPatternFormatException npfe) {
}
}
});
}
/**
*
* @param partNumber
* @param lineAbbr
* @param partDesc
* @param partMap
* @param isKitPart
* @param customerVO
* @return
*/
private boolean isEligibleForPartSale(String partNumber, String lineAbbr, String partDesc,
Map> partMap, boolean isKitPart, CustomerVO customerVO, boolean blockSaleEnabled) {
ArrayList ruleList = new ArrayList ();
boolean isEligibleForPartSale= InvoiceLineBL.isPartEligibleForSaleWithoutMessage(baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(),
baseLineItemVO.getPartDescription(), ruleList, baseLineItemVO.isKitPart(), customerVO, blockSaleEnabled);
if(!isEligibleForPartSale) {
String key = partDesc + " (" + lineAbbr + " - "+ partDesc + ")";
if (partMap.get(key) != null) {
ArrayList list = partMap.get(key);
list.addAll(ruleList);
partMap.put(key, list);
} else {
partMap.put(key, ruleList);
}
}
return isEligibleForPartSale;
}
/**
*
* @param invoiceLineItemVO
* @param partMap
* @return
*/
public boolean validateBlockSale(InvoiceLineItemVO invoiceLineItemVO,
Map> partMap) {
boolean blockSaleEnabled = false;
blockSaleEnabled = InvoiceLineBL.getBlockSaleFlag(InvoiceBL.isRemoteStore());
// Return if block sale validation is not required
// Or Customer and Part has required certificates for sale.
if (!blockSaleEnabled) {
return true;
}
if (invoiceLineItemVO != null) {
if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
}
if (invoiceLineItemVO instanceof InvoiceNoteVO) {
invoiceNoteVO = (InvoiceNoteVO) invoiceLineItemVO;
}
}
// Remove only the Invoices notes if its a child.
if (baseLineItemVO == null && (invoiceNoteVO != null && invoiceNoteVO.getGeneratedByLineItem() != null)
&& isPartBlockSaleEnable) {
return false;
}
/*
isPartBlockSaleEnable - true Remove child items from invoice if parent item is blocked for sale
false keep all child items part of the invoce
*/
if (baseLineItemVO != null && (baseLineItemVO.getGeneratedByLineItem() != null)
&& isPartBlockSaleEnable) {
return false;
}
int invoiceLineItemType = RefInvoiceLineItemType.NORMAL_ITEM;
if(baseLineItemVO != null && baseLineItemVO.getRefInvoiceLineItemTypeID() != null) {
invoiceLineItemType = baseLineItemVO.getRefInvoiceLineItemTypeID().intValue();
}
if (blockSaleEnabled
&& baseLineItemVO != null
&& baseLineItemVO.getQuantityBilled().doubleValue() > 0
&& (baseLineItemVO.getGeneratedByLineItem() == null || InvoiceLineBL.isDefectiveReplacementLineItem(baseLineItemVO)) ) {
boolean isEligibleForPartSale = isEligibleForPartSale(baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(),
baseLineItemVO.getPartDescription(), partMap, baseLineItemVO.isKitPart(),customerVO, InvoiceBL.isRemoteStore());
if (!isEligibleForPartSale) {
// make isPartBlockSaleEnable to true to remove child items from invoice
isPartBlockSaleEnable = true;
return false;
}
isPartBlockSaleEnable = false;
} else {
isPartBlockSaleEnable = false;
}
return true;
}
/**
*
* @param partMap
* @return
*/
private String getBlockSaleMessage(Map> partMap) {
final String methodSpec = " InvoiceController.getBlockSaleMessage() - ";
final StringBuffer regulationRuleTitle = new StringBuffer();
// Iterating HashMap through for loop
for (Map.Entry> set : partMap.entrySet()) {
String key = set.getKey();
ArrayList regulationPartList = partMap.get(key);
regulationRuleTitle.append(key).append(")\n");
for (RegulationRuleMessageVO regulationMessageVO : regulationPartList) {
RegulationRulePartVO regulationPart = regulationMessageVO.getRegulationRulePartVO();
regulationRuleTitle.append(regulationPart.getRegulationRuleVO().getRegTitle()).append(" ")
.append(regulationPart.getRegulationRuleVO().getRegulatoryType()).append("-")
.append(regulationPart.getRegulationRuleVO().getJurisdictionLevel()).append("\n");
if (null != regulationPart.getAlternatePartNumber()
&& !regulationPart.getAlternatePartNumber().trim().isEmpty()
&& null != regulationPart.getAlternateLineAbbrev()
&& !regulationPart.getAlternateLineAbbrev().trim().isEmpty()) {
regulationRuleTitle.append("Alternate Part: " + regulationPart.getAlternateLineAbbrev().trim()).append(" - ") ;
regulationRuleTitle.append(regulationPart.getAlternatePartNumber().trim()).append("\n");
}
}
regulationRuleTitle.append("\n");
}
logger.debug(methodSpec + " Block sale error message " + regulationRuleTitle.toString());
return regulationRuleTitle.toString();
}
public void processLineQueue(PointOfSaleEvent pe) {
resetLineItem(null);
logInvoiceDetails();
int lineItemsProcessed = 0;
Map> partMap= new HashMap>();
List certErrors = new ArrayList();
boolean blockSaleEnable= InvoiceLineBL.getBlockSaleFlag(InvoiceBL.isRemoteStore());
while (!LineGenerationQueue.getInstance().isEmpty()) {
resetLineItemVOs(
(InvoiceLineItemVO) LineGenerationQueue.getInstance().getNextLineItem());
boolean doInvoiceLineItem = validateCertPart(invoiceLineItemVO, certErrors);
if(blockSaleEnable) {
doInvoiceLineItem = validateBlockSale(invoiceLineItemVO, partMap);
}
if (doInvoiceLineItem) {
if (invoiceLineItemVO.isCompletedLine()) {
lineItemsProcessed++;
clientApplicationContext.getPointOfSaleEventDispatcher().
fireInvoiceLineItemAdded(new PointOfSaleListEvent(this, invoiceLineItemVO));
} else {
lineItemHandler =
lineItemHandlerFactory.getHandlerFromLineItemVO(invoiceLineEntryPanel,
invoiceLineItemVO, customerVO, invoiceVO, null);
resetLineItem(lineItemHandler);
break;
}
}
}
if ((blockSaleEnable && lineItemsProcessed <= 0 && partMap != null && !partMap.isEmpty())
||(InvoiceBL.isCertificationEnabled() && lineItemsProcessed <= 0 && certErrors != null
&& !certErrors.isEmpty())) {
invoiceVO.getLineItems().clear();
}
handleBlockSaleMsg(partMap, blockSaleEnable);
if (invoiceVO != null && invoiceVO.getLineItems() != null && invoiceVO.getSavedInvoiceIdForDeletion() != null
&& invoiceVO.getPONumber() != null) {
logger.error("InvoiceLineEntryController:processLineQueue2: for custID:" + invoiceVO.getCustomerID()
+ " /Number of line items:" + invoiceVO.getLineItems().size() + " /PONum:" + invoiceVO.getPONumber()
+ " /SessionId= " + invoiceVO.getSessionID() + " /SavedInvoiceID= "
+ invoiceVO.getSavedInvoiceIdForDeletion());
}
if (baseLineItemVO != null) {
if (baseLineItemVO.getPartNum().startsWith("@")) {
if (baseLineItemVO.getPartNum().equals("@B/DEND")
|| baseLineItemVO.getPartNum().equals("@B$END")) {
resetEntryArea(null, null);
invoiceLineEntryPanel.btnFinalize.doClick();
return;
}
}
}
if (validLineItemHandler()) {
/**
* Code added to set zero price return line item as completed line
* in order to update the line entry area.
*/
if(baseLineItemVO != null && baseLineItemVO.getReturnItems() != null
&& baseLineItemVO.getUnitPrice().signum() == 0) {
((InvoiceLineItemVO)lineItemHandler.getLineItemVO()).setCompletedLine(true);
clientApplicationContext.getPointOfSaleEventDispatcher()
.fireListSetEnabledInvoked(new PointOfSaleListEvent(this, baseLineItemVO,
false));
}
lineItemHandler.displayLineItem();
if(baseLineItemVO != null && baseLineItemVO.getReturnItems() != null
&& baseLineItemVO.getUnitPrice().signum() == 0) {
invoiceLineEntryPanel.btnDelete.setEnabled(false);
lineItemHandler.setQuantityEnabled(false);
// Code added to set the focus on PD field for zero price return line item.
lineItemHandler.setPDEnabled(true,baseLineItemVO);
}
if (baseLineItemVO != null) {
if (baseLineItemVO.getPartNum().startsWith("@")) {
invoiceLineEntryPanel.fldPartNumber.setText(baseLineItemVO.getPartNum());
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(
new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
return;
}
}
JComponent nextFocus = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldOK);
if(nextFocus != null) {
nextFocus.requestFocus();
}
if (nextFocus instanceof JTextField) {
((JTextField) nextFocus).selectAll();
}
} else {
String source = pe.getSource().toString();
if (source.indexOf("InvoiceController") < 0) {
resetEntryArea(null, null);
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
if (customerVO != null && !customerVO.isAuthorizedBuyersOnly()
|| (customerVO != null && customerVO.isAuthorizedBuyersOnly()
&& invoiceVO.getCustomerContactID() != null
&& customerVO.getAuthorizedBuyers() != null
&& !customerVO.getAuthorizedBuyers().isEmpty())) {
setPartNumberEnabled(true);
resetFunctionsArea(null, null);
resetSpecialFunctions(0, true);
invoiceLineEntryPanel.btnBarcode.setEnabled(true);
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
invoiceLineEntryPanel.btnBarcode.setVisible(true);
invoiceLineEntryPanel.btnOtherStores.setVisible(false);
}
/**
removing this code and putting it in the specific place it needed to be called from
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
**/
}
}
if (partVO != null) {
partVO.setInvoiced(Boolean.TRUE);
}
}
/**
* Added for capturing invoice details while recalling saved invoice for factory orders TNSS-6633
*
* @param
* @return
*/
private void logInvoiceDetails() {
if (invoiceVO.getPONumber() != null && invoiceVO.getSavedInvoiceIdForDeletion() != null) {
logger.error("InvoiceLineEntryController:processLineQueue:logInvoiceDetails: for custID:" + invoiceVO.getCustomerID()
+ " /Number of line items:" + invoiceVO.getLineItems().size() + " /PONum:" + invoiceVO.getPONumber()
+ " LineGenerationQueue.Size()=" + LineGenerationQueue.getInstance().size() + " /SessionId= "
+ invoiceVO.getSessionID() + " /SavedInvoiceID= " + invoiceVO.getSavedInvoiceIdForDeletion());
try {
int lineCount = clientApplicationContext.getInvoiceDAO()
.getSavedInvItemCount(invoiceVO.getSavedInvoiceIdForDeletion().intValue());
logger.error("InvoiceLineEntryController:logInvoiceDetails:lineCount from Saved invoice for custId:"
+ invoiceVO.getCustomerID() + " LineCount =" + lineCount);
if (invoiceVO.getLineItems().size() != lineCount) {
logger.error(
"InvoiceLineEntryController:Mismatch occured in saved invoice lineCount and invoiced lines for custId:"
+ invoiceVO.getCustomerID() + " /PONum:" + invoiceVO.getPONumber()
+ " SavedInvoiceLineCount = " + lineCount + " invoiceLineItemCount="
+ invoiceVO.getLineItems().size() + " /SessionId= " + invoiceVO.getSessionID()
+ " /SavedInvoiceID= " + invoiceVO.getSavedInvoiceIdForDeletion());
}
} catch (RemoteException re) {
logger.error("RemoteException occurred while getting the count for Saved Invoice items.."+re);
re.printStackTrace();
} catch (ApplicationException ae) {
logger.error("ApplicationException occurred while getting the count for Saved Invoice items.."+ae);
ae.printStackTrace();
}
}
}
/**
* Diplay dialog about the blocked parts and available Alternate parts
* Cancel an invoice if no invoiceable items left on an invoice after messaging.
* @param partMap
* @return
*/
private void handleBlockSaleMsg(Map> partMap, boolean isBlockSaleEnable) {
if (isBlockSaleEnable && partMap != null && !partMap.isEmpty()) {
String message = getBlockSaleMessage(partMap);
ArrayList list= new ArrayList();
for (Map.Entry> set : partMap.entrySet()) {
String key = set.getKey();
ArrayList value= partMap.get(key);
for(int i=0; i certErrors) {
boolean validateCertificate = false;
if (invoiceLineItemVO != null) {
if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
}
if (invoiceLineItemVO instanceof InvoiceNoteVO) {
invoiceNoteVO = (InvoiceNoteVO) invoiceLineItemVO;
}
}
if (baseLineItemVO == null && invoiceNoteVO != null && isPartCertified) {
return false;
}
if (baseLineItemVO != null && (baseLineItemVO.getGeneratedByLineItem() != null)
&& isPartCertified) {
return false;
}
int invoiceLineItemType = RefInvoiceLineItemType.NORMAL_ITEM;
if(baseLineItemVO != null && baseLineItemVO.getRefInvoiceLineItemTypeID() != null) {
invoiceLineItemType = baseLineItemVO.getRefInvoiceLineItemTypeID().intValue();
}
InvoicingProfileVO invoicingProfileVO = getInvoicingProfile();
validateCertificate = (invoicingProfileVO != null
&& invoicingProfileVO.getEnableValidateCertificate() != null
&& invoicingProfileVO.getEnableValidateCertificate().booleanValue());
if (validateCertificate
&& baseLineItemVO != null
&& baseLineItemVO.getQuantityBilled().doubleValue() > 0
&& !baseLineItemVO.isCoreItem()
&& !baseLineItemVO.isWarrantyLaborClaim().booleanValue()
&& (baseLineItemVO.getGeneratedByLineItem() == null
|| InvoiceLineBL.isDefectiveReplacementLineItem(baseLineItemVO))
&& (invoiceLineItemType == RefInvoiceLineItemType.NORMAL_ITEM
|| invoiceLineItemType == RefInvoiceLineItemType.DC_ITEM
|| invoiceLineItemType == RefInvoiceLineItemType.TRANSFER_ITEM
|| invoiceLineItemType == RefInvoiceLineItemType.DC_ITEM_TRANSFER)) {
InventoryVO inventoryVo = clientApplicationContext.getInventoryDAO().getPartDetailInfo(
customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), false);
boolean isEligibleForPartSale= true;
isEligibleForPartSale= InvoiceLineBL.checkForPartSaleAndPopulateCertInfo(
loc, invoiceVO.getCustomerID(), inventoryVo, baseLineItemVO, baseLineItemVO.getQuantityBilled());
if (!isEligibleForPartSale) {
ClientApplicationContext.getClientApplicationContext().getMessageMgr()
.showMessage(invoiceLineEntryPanel, "9940");
certErrors.add(new String(inventoryVo.getPartNumber()));
isPartCertified = true;
return false;
}
isPartCertified = false;
} else {
isPartCertified = false;
}
return true;
}
public void listModelChanged(InvoiceEvent ie) {
/**
* Code added to avoid executing the listModalChanged event code when quantity is being
* edited in the line entry area.
*/
String remoteStoreIp = null;
if(invoiceVO.isPhoneRoomMessagesFlag()){
try {
remoteStoreIp = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber()) ;
} catch (ApplicationException e) {
e.printStackTrace();
}
}
if (baseLineItemVO != null && baseLineItemVO.isQuantityEdited()) {
return;
}
if (ie.getModel() instanceof InvoiceLineItemVO) {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
getInvoicePanel().getCatalogButton().setEnabled(false);
invoiceLineItemVO = (InvoiceLineItemVO) ie.getModel();
if (invoiceLineItemVO == null) {
invoiceLineEntryPanel.fldQuantity.putClientProperty(FocusDecider.NAME, null);
resetLineItem(null);
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetEntryArea(invoiceLineEntryPanel.fldNote, invoiceLineEntryPanel.fldNote);
// Added for RGN:Invoicing
resetEntryArea(invoiceLineEntryPanel.lblClaimFormNumber,
invoiceLineEntryPanel.fldClaimFormNumber);
// =======================================
invoiceLineEntryPanel.fldQuantity.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_ENTER, '\n'));
} else {
boolean gpcOwned ;
if(!invoiceVO.isPhoneRoomMessagesFlag()){
gpcOwned = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()
).getStoreProfile().getGpcOwned().booleanValue();
}else{
gpcOwned = (new PhoneRoomTaapRouter().getStoreProfile(remoteStoreIp).getGpcOwned().booleanValue());
}
if (invoiceLineItemVO instanceof NAPAOnlineInfoVO) {
napaOnlineInfoVO =
(NAPAOnlineInfoVO) ((NAPAOnlineInfoVO) invoiceLineItemVO).clone();
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(
invoiceLineEntryPanel, napaOnlineInfoVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
} else if (invoiceLineItemVO instanceof InvoiceNoteVO) {
invoiceNoteVO = (InvoiceNoteVO) ((InvoiceNoteVO) invoiceLineItemVO).clone();
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(
invoiceLineEntryPanel, invoiceNoteVO, customerVO, invoiceVO, null);
if (invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
!= RefInvoiceNoteType.WARRANTY_MESSAGE) {
lineItemHandler.displayLineItem();
}
/* Checks if invoiceLineItemVO is an instance of KitLineItemVO.
* If true, displays warning message "Component line item cannot be edited".
*/
} else if (invoiceLineItemVO instanceof KitLineItemVO
&& (gpcOwned || !(invoiceLineItemVO.isWarrantyItem().booleanValue()
|| (invoiceLineItemVO.getGeneratedByLineItem() != null
&& ((BaseLineItemVO)invoiceLineItemVO).getQuantityBilled().equals(
((BaseLineItemVO)invoiceLineItemVO.getGeneratedByLineItem())
.getQuantityBilled().negate()))))) {
invoiceLineEntryPanel.btnDelete.setEnabled(false);
invoiceLineEntryPanel.btnBarcode.setEnabled(false);
invoiceLineEntryPanel.fldPartNumber.setEnabled(true);
invoiceLineEntryPanel.fldDescription.setEnabled(false);
invoiceLineEntryPanel.fldList.setEnabled(false);
invoiceLineEntryPanel.fldQuantity.setEnabled(false);
invoiceLineEntryPanel.fldPD.setEnabled(false);
invoiceLineEntryPanel.fldPrice.setEnabled(false);
invoiceLineEntryPanel.fldUnit.setEnabled(false);
invoiceLineEntryPanel.fldDC.setEnabled(false);
invoiceLineEntryPanel.fldTax.setEnabled(false);
invoiceLineEntryPanel.fldSecondaryTax.setEnabled(false);
invoiceLineEntryPanel.fldOK.setEnabled(false);
invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(false);
final boolean useNxp = (!invoiceVO.isPhoneRoomMessagesFlag())
? getStoreProfile().getUseNapaXpress().booleanValue()
: (new PhoneRoomTaapRouter().getStoreProfile(remoteStoreIp)
.getUseNapaXpress().booleanValue());
if (useNxp) {
loadKitLineItemToLineEntryArea(remoteStoreIp);
} else {
resetLineItem(null);
resetEntryArea(null, null);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"1224");
}
} else if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) ((BaseLineItemVO) invoiceLineItemVO).clone();
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(
invoiceLineEntryPanel, baseLineItemVO, customerVO, invoiceVO, null);
if (baseLineItemVO.getPartNum() != null
&& baseLineItemVO.getPartNum().trim().length() > 0
&& baseLineItemVO.getLineAbbr() != null
&& baseLineItemVO.getLineAbbr().trim().length() > 0) {
if (!baseLineItemVO.getAutoGeneratedMiscChg().booleanValue()
&& !baseLineItemVO.isPickupItem().booleanValue()) {
if(!invoiceVO.isPhoneRoomMessagesFlag())
{
lineItemHandler.setInventoryVO(
clientApplicationContext.getInventoryDAO().getPartDetailInfo(
customerVO, baseLineItemVO.getPartNum(),
baseLineItemVO.getLineAbbr(), false));
}else{
lineItemHandler.setInventoryVO(
new PhoneRoomTaapRouter().getPartDetailInfo(
customerVO, baseLineItemVO.getPartNum(),
baseLineItemVO.getLineAbbr(), false, remoteStoreIp,clientApplicationContext.getCurrentLocale().getLanguage(),false));
}
if(!invoiceVO.isPhoneRoomMessagesFlag()){
lineItemHandler.setPrices(
InvoiceLineBL.getPrices(customerVO.getID(),
customerVO.getCustomerTypeCD(),
baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(),
baseLineItemVO.getQuantityBilled()));
}else{
lineItemHandler.setPrices(
PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO,
customerVO.getCustomerTypeCD(),
baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(),
baseLineItemVO.getQuantityBilled(),remoteStoreIp,null));
}
}
}
lineItemHandler.displayLineItem();
// if(InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)){
// invoiceLineEntryPanel.btnSourceOption.setVisible(false);
// invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
// } else {
final boolean useNxp = (!invoiceVO.isPhoneRoomMessagesFlag())?getStoreProfile().getUseNapaXpress().booleanValue():
(new PhoneRoomTaapRouter().getStoreProfile(remoteStoreIp).getUseNapaXpress().booleanValue());
// It has been decided not to have NXP feature for Kit since other groups are not ready
// hence restricting NXP feature for kits
if (useNxp && TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
invoiceLineEntryPanel.btnSourceOption.setVisible(true);
invoiceLineEntryPanel.btnSourceOption.setEnabled(true);
invoiceLineEntryPanel.btnSourceOption.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnSourceOption.SourceLocally",
clientApplicationContext.getCurrentLocale()));
} else if (useNxp && TsoConstant.LOCAL.equals(baseLineItemVO.getSpecialOrder())) {
invoiceLineEntryPanel.btnSourceOption.setVisible(true);
invoiceLineEntryPanel.btnSourceOption.setEnabled(true);
invoiceLineEntryPanel.btnSourceOption
.setText(clientApplicationContext
.getResourceBundleReader()
.getLocalizedText(
ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnSourceOption.SourceFromNXP",
clientApplicationContext.getCurrentLocale()));
isReservedLineItem = isReservedLine();
if(isReservedLineItem){
invoiceLineEntryPanel.btnSourceOption.setVisible(false);
invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
}
else if (invoiceLineEntryPanel.fldQuantity.getText().startsWith("-")) {
invoiceLineEntryPanel.btnSourceOption.setVisible(false);
invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
}
// }
}
}
/**
* Code added for Return Authorization to
* enable edit of "Tax" flags for miscellaneous charge
* line items for GPC Owned stores
*/
if (!invoiceLineEntryPanel.btnDelete.isEnabled()
&& ((baseLineItemVO != null
&& (((baseLineItemVO.getAutoGeneratedMiscChg().booleanValue()
&& baseLineItemVO.getQuantityBilled().doubleValue() > 0)
&& clientApplicationContext.getSystemDAO().allowDeleteOfMiscCharges(
).booleanValue())
|| (clientApplicationContext.getApplicationType() == ClientApplicationContext.TAMS_II
&& baseLineItemVO.isWarrantyItem().booleanValue())
|| (clientApplicationContext.getApplicationType()
== ClientApplicationContext.TAMS_II
&& InvoiceLineBL.isReplacementCoreLineItem(baseLineItemVO))
|| (clientApplicationContext.getApplicationType() == ClientApplicationContext.TAMS_II
&& baseLineItemVO.getGeneratedByLineItem() != null
&& baseLineItemVO.getQuantityBilled().equals(
((BaseLineItemVO)baseLineItemVO.getGeneratedByLineItem()
).getQuantityBilled().negate()))))
|| (!isCoreLineItem(invoiceLineItemVO)
&& !InvoiceLineBL.isWlcNoteLine(invoiceLineItemVO)
&& ((invoiceNoteVO != null) &&
(invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.WARRANTY_MESSAGE
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.CATALOGING_VEHICLE_INFORMATION_MESSAGE
|| (invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.INVENTORY_NOTE && gpcOwned)
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.HAZARDOUS_MATERIAL_MESSAGE
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.PICKUP_REFERENCE_NUMBER
|| (invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.SALE_MESSAGE && gpcOwned)
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.RETURN_MESSAGE
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.PHONE_ROOM_MESSAGE
// Code added for Tender Types.
// Make NAPA Gift Card line Item's invoice note non-editable.
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.NAPA_GIFT_CARD_MESSAGE
|| invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.NEW_NAPA_GIFT_CARD_MESSAGE))
||invoiceLineItemVO instanceof NAPAOnlineInfoVO))) {
resetEntryArea(null, null);
if(invoiceLineItemVO instanceof NAPAOnlineInfoVO){
invoiceLineEntryPanel.btnDelete.setVisible(false);
}
resetLineItem(null);
//1224 = 1,N,This generated line cannot be edited or deleted.
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "1224");
}
else {
if(invoiceLineItemVO instanceof InvoiceNoteVO && invoiceNoteVO != null){
if(!gpcOwned && ((invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.INVENTORY_NOTE )
|| (invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.SALE_MESSAGE ))){
invoiceLineEntryPanel.btnDelete.setEnabled(true);
invoiceLineEntryPanel.btnBarcode.setEnabled(false);
invoiceLineEntryPanel.lblNote.setEnabled(true);
invoiceLineEntryPanel.fldNote.setEnabled(true);
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(false);
invoiceLineEntryPanel.lblNote.setVisible(true);
invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(true);
resetLineItem(lineItemHandler);
}
if(invoiceNoteVO.getRefInvoiceNoteTyepID().intValue()
== RefInvoiceNoteType.WLC_AUTHORIZATION_NUMBER ){
invoiceLineEntryPanel.btnDelete.setEnabled(false);
invoiceLineEntryPanel.btnBarcode.setEnabled(false);
invoiceLineEntryPanel.fldNote.setEnabled(true);
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(false);
invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(true);
resetLineItem(lineItemHandler);
}
}
}
}
} else if (ie.getModel() instanceof PartVO) {
partVO = (PartVO) ie.getModel();
baseLineItemVO = new BaseLineItemVO();
baseLineItemVO.setPartNum(partVO.getPart());
baseLineItemVO.setExpandedPartNum(partVO.getExpandedPart());
baseLineItemVO.setPartDescription(partVO.getPartDesc());
baseLineItemVO.setLineAbbr(partVO.getTamsLine());
boolean printCatalogNotesOnInvoice ;
if(!invoiceVO.isPhoneRoomMessagesFlag()){
printCatalogNotesOnInvoice = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getInvoicingProfile(
).getPrintCatalogNotesOnInvoice().booleanValue();
}else{
printCatalogNotesOnInvoice = new TaapRouter().getInvoicingProfile(remoteStoreIp
).getPrintCatalogNotesOnInvoice().booleanValue();
}
if (printCatalogNotesOnInvoice && customerVO.doPrintCatalogNotesOnInvoice().booleanValue()){
if (vehicleVO != null) {
baseLineItemVO.setVehicleMake(vehicleVO.getMake().getValue().toString());
baseLineItemVO.setVehicleModel(vehicleVO.getModel().getValue().toString());
baseLineItemVO.setVehicleYear(new Short((short) vehicleVO.getYear()));
baseLineItemVO.setVehicleVO(vehicleVO);
}
baseLineItemVO.setPartNote(formatPartVONoteText(partVO));
}
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
invoiceLineEntryPanel.fldPartNumber.setText(baseLineItemVO.getExpandedPartNum());
invoiceLineEntryPanel.slfLine.setText(partVO.getTamsLine());
lineItemHandler.handle(InvoiceLineEntryPanel.SLF_LINE_NAME);
lineItemHandler.setPartNumberEnabled(false);
String source = ie.getSource().toString();
if (source.indexOf("PartsListController") > 0) {
logger.debug("***** catalogPartSelected: Set REF_CATALOG_DATA_VERSION HERE *****");
baseLineItemVO.setRefCatalogDataVersionID(new Integer(RefCatalogDataVersion.PARTSPRO));
}
}
// commented out because PaintWizard is no longer accessible from Catalog.
/*else if (ie.getModel() instanceof PaintWizardPartVO) {
PaintWizardPartVO paintWizardPartVO = (PaintWizardPartVO) ie.getModel();
baseLineItemVO = new BaseLineItemVO();
baseLineItemVO.setPartNum(paintWizardPartVO.getPart());
baseLineItemVO.setExpandedPartNum(paintWizardPartVO.getExpandedPart());
if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getInvoicingProfile().
getPrintCatalogNotesOnInvoice().booleanValue()
&& customerVO.doPrintCatalogNotesOnInvoice().booleanValue()){
String[] strPaintWizardNoteArray = new String[3];
strPaintWizardNoteArray[0] = paintWizardPartVO.getVOCLeadInfo();
strPaintWizardNoteArray[1] = paintWizardPartVO.getFormulaMSDSInfo();
strPaintWizardNoteArray[2] = paintWizardPartVO.getVehicleInfo();
baseLineItemVO.setPartNote(strPaintWizardNoteArray);
} else {
String[] strPaintWizardNoteArray = {paintWizardPartVO.getVOCLeadInfo()};
baseLineItemVO.setPartNote(strPaintWizardNoteArray);
}
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
invoiceLineEntryPanel.fldPartNumber.setText(baseLineItemVO.getExpandedPartNum());
invoiceLineEntryPanel.slfLine.setText(paintWizardPartVO.getLine());
lineItemHandler.handle(InvoiceLineEntryPanel.SLF_LINE_NAME);
} */else {
resetLineItem(null);
resetEntryArea(null, null);
}
resetSpecialFunctions(0, false);
if(invoiceVO.isReturnInvoice()) {
invoiceLineEntryPanel.fldQuantity.requestFocus();
}
}
private void loadKitLineItemToLineEntryArea(String remoteStoreIp) {
final String methodSpec = "InvoiceLineEntryController.loadKitLineItemToLineEntryArea()";
logger.debug(methodSpec);
baseLineItemVO = (BaseLineItemVO) ((BaseLineItemVO) invoiceLineItemVO).clone();
lineItemHandler = lineItemHandlerFactory.getHandlerFromLineItemVO(invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0
&& baseLineItemVO.getLineAbbr() != null
&& baseLineItemVO.getLineAbbr().trim().length() > 0) {
if (!baseLineItemVO.getAutoGeneratedMiscChg().booleanValue()
&& !baseLineItemVO.isPickupItem().booleanValue()) {
if (!invoiceVO.isPhoneRoomMessagesFlag()) {
lineItemHandler.setInventoryVO(clientApplicationContext.getInventoryDAO()
.getPartDetailInfo(customerVO, baseLineItemVO.getPartNum(),
baseLineItemVO.getLineAbbr(), false));
} else {
lineItemHandler.setInventoryVO(new PhoneRoomTaapRouter().getPartDetailInfo(
customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(),
false, remoteStoreIp,
clientApplicationContext.getCurrentLocale().getLanguage(), false));
}
}
}
lineItemHandler.displayLineItem();
final boolean useNxp = (!invoiceVO.isPhoneRoomMessagesFlag())
? getStoreProfile().getUseNapaXpress().booleanValue() : (new PhoneRoomTaapRouter()
.getStoreProfile(remoteStoreIp).getUseNapaXpress().booleanValue());
// It has been decided not to have NXP feature for Kit since other groups are not ready
// hence restricting NXP feature for kits
if (useNxp && TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
invoiceLineEntryPanel.btnSourceOption.setVisible(true);
invoiceLineEntryPanel.btnSourceOption.setEnabled(true);
invoiceLineEntryPanel.btnSourceOption.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnSourceOption.SourceLocally",
clientApplicationContext.getCurrentLocale()));
} else if (useNxp && TsoConstant.LOCAL.equals(baseLineItemVO.getSpecialOrder())) {
invoiceLineEntryPanel.btnSourceOption.setVisible(true);
invoiceLineEntryPanel.btnSourceOption.setEnabled(true);
invoiceLineEntryPanel.btnSourceOption.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnSourceOption.SourceFromNXP",
clientApplicationContext.getCurrentLocale()));
isReservedLineItem = isReservedLine();
if (isReservedLineItem) {
invoiceLineEntryPanel.btnSourceOption.setVisible(false);
invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
} else if (invoiceLineEntryPanel.fldQuantity.getText().startsWith("-")) {
invoiceLineEntryPanel.btnSourceOption.setVisible(false);
invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
}
}
invoiceLineEntryPanel.btnDelete.setEnabled(false);
invoiceLineEntryPanel.btnSupersede.setEnabled(false);
}
// Checking the line Abbr for reserved line items
private boolean isReservedLine(){
boolean isReserveLineItem = false;
String lineAbbr = baseLineItemVO.getLineAbbr();
if((lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.DELIVERY)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.FREIGHT)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.BAGFEE)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.MISCELLANEOUS)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.OTHER)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.POLICY_ADJUSTMENT)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.SERVICE_CHARGE)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.TELEPHONE)
|| lineAbbr.equalsIgnoreCase(RefInvoiceSpecialFunction.COLORADO_DELIVERY_FEE))
|| (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.LABOR)
|| (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.ENVIRONMENTAL_CHARGE)
|| (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.NAPA_GIFT_CARD)
|| (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.NAPA_REWARDS)
|| (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)
|| baseLineItemVO.isSpecialFnCorSelected()
|| baseLineItemVO.isWarrantyLaborClaim().booleanValue()
|| baseLineItemVO.isCoreTransaction().booleanValue()){
isReserveLineItem = true;
}
return isReserveLineItem;
}
private String[] formatPartVONoteText(PartVO partVO) {
StringBuffer strBuffer = new StringBuffer();
if (validNoteText(partVO.getTextLine1())) {
strBuffer.append(partVO.getTextLine1().trim());
}
if (validNoteText(partVO.getTextLine2())) {
strBuffer.append(" " + partVO.getTextLine2().trim());
}
if (validNoteText(partVO.getTextLine3())) {
strBuffer.append(" " + partVO.getTextLine3().trim());
}
if (validNoteText(partVO.getTextLine4())) {
strBuffer.append(" " + partVO.getTextLine4().trim());
}
if (validNoteText(partVO.getTextLine5())) {
strBuffer.append(" " + partVO.getTextLine5().trim());
}
String strCatalogNote = parseCatalogNote(strBuffer.toString());
return createCatalogNoteStringArray(strCatalogNote);
}
private boolean validNoteText(String strNoteText) {
return ((strNoteText != null) && (strNoteText.trim().length() > 0));
}
private String parseCatalogNote(String strCatalogNoteText) {
if ((strCatalogNoteText == null) || (strCatalogNoteText.trim().length() == 0)) {
return "";
}
int noteStartIndex = strCatalogNoteText.indexOf("@");
int noteEndIndex = strCatalogNoteText.lastIndexOf("@");
if (noteStartIndex == -1) {
return "";
} else if (noteStartIndex >= noteEndIndex) {
return "";
}
return strCatalogNoteText.substring(noteStartIndex + 1, noteEndIndex);
}
private String[] createCatalogNoteStringArray(String strCatalogNote) {
if (!clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()
).getInvoicingProfile().getPrintCatalogNotesOnInvoice().booleanValue()
&& customerVO.doPrintCatalogNotesOnInvoice().booleanValue()){
return new String[0];
}
if ((strCatalogNote == null) || (strCatalogNote.trim().length() == 0)) {
return new String[0];
}
// int maxStringLength = clientApplicationContext.getSystemDAO().
// getCharactersInInvoiceLineMessage().intValue();
int maxStringLength = 50; //length of text returned from PPII service.
if (strCatalogNote.length() <= maxStringLength) {
String[] catalogNoteArray = {strCatalogNote};
return catalogNoteArray;
}
String strTempHolder = strCatalogNote;
String strTestHolder = strCatalogNote;
Vector vCommentLines = new Vector();
int nextSpaceIndex = 0;
int nextCommaIndex = 0;
int nextIndex = 0;
while (strTestHolder.length() > maxStringLength) {
nextSpaceIndex = strTestHolder.lastIndexOf(" ");
if (nextSpaceIndex > 0) {
strTestHolder = strTempHolder.substring(0, nextSpaceIndex);
if (nextSpaceIndex <= maxStringLength) {
vCommentLines.add(strTempHolder.substring(0, nextSpaceIndex));
strTestHolder = strTempHolder.substring(nextSpaceIndex + 1,
strTempHolder.length());
strTempHolder = strTestHolder;
}
} else if (strTestHolder != null && nextSpaceIndex == -1
&& strTestHolder.length() > maxStringLength) {
nextCommaIndex = strTestHolder.lastIndexOf(",");
if (nextCommaIndex > 0) {
strTestHolder = strTempHolder.substring(0, nextCommaIndex);
if (nextCommaIndex <= maxStringLength) {
vCommentLines.add(strTempHolder.substring(0, nextCommaIndex));
strTestHolder = strTempHolder.substring(nextCommaIndex + 1,
strTempHolder.length());
strTempHolder = strTestHolder;
}
} else if (strTestHolder != null && nextCommaIndex == -1
&& strTestHolder.length() > maxStringLength) {
strTestHolder = strTempHolder.substring(0, 49);
nextIndex = 50;
if (nextSpaceIndex <= maxStringLength) {
vCommentLines.add(strTempHolder.substring(0, nextIndex));
strTestHolder = strTempHolder.substring(nextIndex,
strTempHolder.length());
strTempHolder = strTestHolder;
}
}
}
}
if (strTempHolder.trim().length() > 0) {
vCommentLines.add(strTempHolder.trim());
}
int vectorSize = vCommentLines.size();
String[] catalogNoteArray = new String[vectorSize];
for (int i = 0; i < vectorSize; i++) {
catalogNoteArray[i] = (String) vCommentLines.elementAt(i);
}
return catalogNoteArray;
}
public void maxLinesInvoiced(PointOfSaleListEvent posle) {
resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber);
resetLineEntryArea(invoiceLineEntryPanel.lblQuantity, invoiceLineEntryPanel.fldQuantity);
resetLineItem(null);
resetSpecialFunctions(0, true);
}
private boolean isCoreLineItem (InvoiceLineItemVO line) {
if (line == null) {
return false;
}
if (!(line instanceof BaseLineItemVO)) {
return false;
}
if (((BaseLineItemVO) line).isCoreTransaction() == null) {
return false;
}
return ((BaseLineItemVO) line).isCoreTransaction().booleanValue();
}
public void switchLineItemHandler(InvoiceEvent ie) {
baseLineItemVO = (BaseLineItemVO) ie.getModel();
if (baseLineItemVO.isCoreTransaction().booleanValue()) {
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_CORE_LINE_ITEM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
lineItemHandler = lineItemHandlerFactory.getHandler(LineItemHandlerFactory.CORE,
invoiceLineEntryPanel, baseLineItemVO, customerVO, invoiceVO, null);
}
} else if (baseLineItemVO.isDefective().booleanValue()) {
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_DEFECTIVE_LINE_ITEM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.DEFECTIVE, invoiceLineEntryPanel, baseLineItemVO,
customerVO, invoiceVO, null);
}
} else {
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_LINE_ITEM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
lineItemHandler = lineItemHandlerFactory.getHandler(LineItemHandlerFactory.DEFAULT,
invoiceLineEntryPanel, baseLineItemVO, customerVO, invoiceVO, null);
}
}
lineItemHandler.handle(InvoiceLineEntryPanel.SLF_LINE_NAME);
if(!invoiceVO.isReturnInvoice()) {
invoiceLineEntryPanel.fldQuantity.dispatchEvent(
new KeyEvent(invoiceLineEntryPanel.fldQuantity, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
}
public void customerChanged(CustomerEvent ce) {
lineItemHandler = null;
customerVO = (CustomerVO) ce.getModel();
if (invoiceVO.getManualTransaction().booleanValue()) {
invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(false);
} else {
invoiceLineEntryPanel.pnlAlternateCoreSubtotal
.setVisible(customerVO.getAlternateCoreCustomerID() != null);
invoiceVO.setAlternateCoreSubTotal(new BigDecimal("0.00"));
invoiceVO.setAlternateCoreDisplaySubTotal(new BigDecimal("0.00"));
}
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
setSpecialFunctions(clientApplicationContext.getCurrentUser().getRefLanguageCd());
if ((lineItemHandler == null || napaOnlineInfoVO == null)) {
napaOnlineInfoVO = new NAPAOnlineInfoVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_INFO, invoiceLineEntryPanel,
napaOnlineInfoVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
}
}
}
public void customerFieldFocusGained(CustomerEvent ce) {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
invoiceLineEntryPanel.btnBarcode.setEnabled(false);
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
invoiceLineEntryPanel.btnBarcode.setVisible(true);
invoiceLineEntryPanel.btnOtherStores.setVisible(false);
}
}
public void customerFieldValidated(CustomerEvent ce) {
}
public void actionPerformed(ActionEvent ae) {
fireStartTimer();
String strComponentName = ((Component) ae.getSource()).getName();
boolean isNxpInterstoreInvoice = InvoiceBL.doesInvoiceContainNXPInterStoreOrder(invoiceVO);
boolean isCancelInvoice = false;
StoreProfileVO remoteStoreProfileVO = null;
String remoteIpAddress = null;
if (strComponentName.equals(InvoiceLineEntryPanel.BTN_DELETE_NAME)) {
buttonClicked = true;
deleteInvoiceLineItem(false);
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_FINALIZE_NAME)) {
boolean npxApprovalRequired = checkForNxpApproval();
boolean mainCounterFlag = false;
if(null!=invoiceVO && invoiceVO.isPhoneRoomMessagesFlag()) {
try {
remoteIpAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
remoteStoreProfileVO = phoneRoomTaapRouter.getStoreProfile(remoteIpAddress);
mainCounterFlag = PhoneRoomInvoiceBL.isMainCounter(remoteStoreProfileVO);
} catch (ApplicationException e) {
//throw new RuntimeException(e);
logger.error("Unable to fetch Ip address for the remote store number :");
}
} else {
mainCounterFlag = InvoiceBL.isMainCounter();
}
if (invoiceLineEntryPanel.btnFinalize.getText() != null
&& invoiceLineEntryPanel.btnFinalize.getText().equals(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnFinalize.ReadyForPickup",
clientApplicationContext.getCurrentLocale())) && !npxApprovalRequired && !mainCounterFlag) {
boolean isReadyForPickup = readyForPickupAndSave();
if (isReadyForPickup) {
return;
}
}
if(isNxpInterstoreInvoice){
try {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
sendNXPInterstoreUpdateSalesOrderRequest(invoiceVO, isCancelInvoice);
} else {
phoneRoomTaapRouter.sendNXPInterstoreUpdateSalesOrderRequestForPhoneRoom(invoiceVO,
remoteIpAddress,isCancelInvoice);
}
} catch(Throwable e) {
logger.error("Error in sending interstore update sales order..");
}
}
if (customerVO.isAuthorizedBuyersOnly()
&& invoiceVO.getCustomerContactID() == null) {
getInvoicePanel().getAuthorizedBuyerBox().requestFocus();
return;
}
logger.warn("****Check performance**start fetching available quantity************");
if(clientApplicationContext.isLoggedInAsPhoneRoom()
&& InvoiceBL.checkAvailableQuantity(invoiceVO, customerVO,true,
((invoiceVO.isPhoneRoomMessagesFlag() && remoteIpAddress!=null)?remoteIpAddress:null))) {
logger.warn("****after fetching available quantity, triggering fireInvoiceLineItemsChanged event************");
clientApplicationContext.getPointOfSaleEventDispatcher()
.fireInvoiceLineItemsChanged(new PointOfSaleListEvent(this, invoiceVO));
logger.warn("****after triggering fireInvoiceLineItemsChanged event************");
if(!clientApplicationContext.getMessageMgr().showMessageYesNo(invoiceLineEntryPanel, "9544")){
return;
}
}
InvoicingProfileVO invoicingProfileVO = null;
//Stel-751
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
invoicingProfileVO = getInvoicingProfile();
} else {
invoicingProfileVO = taapRouter.getInvoicingProfile(remoteIpAddress);
}
if (invoicingProfileVO != null
&& invoicingProfileVO.getRefElectronicInvoiceVendorId() != null
&& invoicingProfileVO.getRefElectronicInvoiceVendorId().intValue() == 1) {
// User is restricted from finalizing an invoice if the customer is
// not registered with R.F.C number.
if (!CustomerBL.isTransferCustomer(customerVO)
&& !CustomerBL.isRegisteredCustomer(customerVO)) {
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "10109");
return;
}
// User is restricted from finalising an invoice containing non core
// items,if Customer
// is authorised to sell only core items
if (CustomerBL.isRaisaCustomer(customerVO)
&& !InvoiceBL.doesInvoiceContainsOnlyCoreItems(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "10114");
return;
}
}
// Added for ASWA project - START
final BuildInboundMessageService buildInboundMessageService
= (BuildInboundMessageService) TamsJmoIntegrationServiceFactory
.getServiceInstance(IndagoConstants.INBOUND_ACTIVITY,
IndagoConstants.TAMS_MESSAGE_INITIATOR, null);
try {
StoreProfileVO storeProfile = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
storeProfile = ApplicationContext.getInstance().getProfile(
Profile.SERVER, buildInboundMessageService.getStoreLocation())
.getStoreProfile();
} else {
storeProfile = remoteStoreProfileVO;
}
if ((storeProfile != null
&& storeProfile.getIndagoInUse().booleanValue()
&& invoiceVO.getWmsTransactionIdentifier() != null
&& invoiceVO.getWmsTransactionStatus() != null
&& (invoiceVO.getWmsTransactionStatus().intValue() == 1
|| invoiceVO.getWmsTransactionStatus().intValue() == 0
|| invoiceVO.getWmsTransactionStatus().intValue() == 2))
&& hasMainPart(invoiceVO)) {
if (!(clientApplicationContext.getMessageMgr().showMessageNoYes(invoiceLineEntryPanel, "9601"))){
return;
}
}
} catch (ApplicationException applicationException) {
logger.error(applicationException.toString(), applicationException);
}
// Added for ASWA project - END
if (!CustomerBL.isNapaOnlineCustomer(customerVO)) {
for (int i = 0; i < invoiceVO.getLineItems().size(); i++) {
InvoiceLineItemVO iliVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(i);
/*
* Checks whether the entered part is a kit component or
* not.
*/
if(iliVO instanceof KitLineItemVO) {
continue;
}
if (iliVO instanceof BaseLineItemVO) {
BaseLineItemVO bliVO = (BaseLineItemVO) iliVO;
if (bliVO.getUnitPrice().signum() == 0 && !zeroPriceOK) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "1367");
zeroPriceOK = true;
return;
}
}
}
}
// Added for RADS-Main Counter Project
// Check if RADS is in use
boolean useRads = false;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
int loc = ClientApplicationContext.getClientApplicationContext()
.getLocation();
Profile profile = ClientApplicationContext
.getClientApplicationContext().getProfile(
Profile.POINT_OF_SALE_CLIENT, loc);
useRads = profile.getInvoicingProfile().getUseRads()
.booleanValue();
logger.debug("useRads-->" + useRads);
// If RADS is in use, send new order request to the RADS System
if (useRads && invoiceVO.getManualTransaction() != null
&& !(invoiceVO.getManualTransaction().booleanValue())) {
if (sendRadsNewOrderAndSaveInvoice(invoiceVO, customerVO, invoiceLineEntryPanel)) {
return;
} else if (InvoiceBL.isMainCounter() && InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)
&& invoiceLineEntryPanel.btnFinalize.getText() != null) {
if(invoiceLineEntryPanel.btnFinalize.getText().equals(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.btnFinalize.ReadyForPickup",
clientApplicationContext.getCurrentLocale())) && !npxApprovalRequired) {
boolean isReadyForPickup = readyForPickupAndSave();
if (isReadyForPickup) {
return;
}
} else if(invoiceLineEntryPanel.btnFinalize.getText().equals(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.btnFinalize.ContinueToNXP",
clientApplicationContext.getCurrentLocale())) && npxApprovalRequired) {
isBopisRADSOrderFailed = true;
}
}
}
} else {
useRads = invoicingProfileVO.getUseRads().booleanValue();
logger.debug("useRads inside else part -->" + useRads);
// If RADS is in use, send new order request to the RADS System
if (useRads && invoiceVO.getManualTransaction() != null
&& !(invoiceVO.getManualTransaction().booleanValue())) {
if (sendRadsNewOrderAndSaveInvoice(invoiceVO, customerVO, invoiceLineEntryPanel)) {
return;
} else if (PhoneRoomInvoiceBL.isMainCounter(remoteStoreProfileVO) && InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)
&& invoiceLineEntryPanel.btnFinalize.getText() != null) {
if(invoiceLineEntryPanel.btnFinalize.getText() != null
&& invoiceLineEntryPanel.btnFinalize.getText().equals(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.btnFinalize.ReadyForPickup",
clientApplicationContext.getCurrentLocale())) && !npxApprovalRequired) {
boolean isReadyForPickup = readyForPickupAndSave();
if (isReadyForPickup) {
return;
}
} else if(invoiceLineEntryPanel.btnFinalize.getText() != null
&& invoiceLineEntryPanel.btnFinalize.getText().equals(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.btnFinalize.ContinueToNXP",
clientApplicationContext.getCurrentLocale())) && npxApprovalRequired) {
isBopisRADSOrderFailed = true;
}
}
}
}
// ======================================
FwoPrinterSelectionSettings printerSelectionSettings = new FwoPrinterSelectionSettings();
printerSelectionSettings.setPrinterType("I");
printerSelectionSettings.setPrinterUse("Invoices");
printerSelectionSettings.setClientIPAddress(clientApplicationContext.getClientIPAddress());
Vector vPrinterList = clientApplicationContext.getHardwareDAO().getPrinterList(
printerSelectionSettings);
if (vPrinterList == null || vPrinterList.isEmpty()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2216");
return;
}
try {
if (invoiceVO.doDisplayPricing()
&& getRMIClient() != null && !getRMIClient ().canCheckout(dispInvVO).booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2237");
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(
new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
return;
}
} catch(RemoteException re) {
// do nothing. we have already displayed a warning. let them keep invoicing
}
// Set Line Items - Retail Price & Usual Price
if (!CustomerBL.isTransferCustomer(customerVO)) {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
InvoiceLineBL.setLineItemsRetailPrice(invoiceVO, customerVO);
} else {
PhoneRoomInvoiceLineBL.setLineItemsRetailPrice(invoiceVO,customerVO, remoteIpAddress, clientApplicationContext.getLocation());
}
}
if (doesAAAMembershipValidationRequired() && !validateNapaAAAMembership()) {
return;
}
if (askForCustomerInformation()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (isReturnApprovalChecked()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
finalizeInvoice();
}
});
}
}
});
}
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_SUPERSEDE_NAME)) {
lineItemHandler.handle(InvoiceLineEntryPanel.BTN_SUPERSEDE_NAME);
invoiceLineEntryPanel.btnSupersede.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.btnSupersede, KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_TAB, '\t'));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (invoiceLineEntryPanel.fldQuantity.isFocusable()) {
invoiceLineEntryPanel.fldQuantity.selectAll();
}
}
});
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_BARCODE_NAME)) {
baseLineItemVO = new BaseLineItemVO();
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_LINE_ITEM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.PHONE_ROOM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.DEFAULT, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
}
}
lineItemHandler.handle(InvoiceLineEntryPanel.BTN_BARCODE_NAME);
SwingUtilities.invokeLater(new Runnable(){
public void run() {
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnBarcode,new KeyEvent(
invoiceLineEntryPanel.btnBarcode, KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_TAB, '\t'));
}
});
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_OTHER_STORES)) {
if(lineItemHandler != null) {
lineItemHandler.handle(InvoiceLineEntryPanel.BTN_OTHER_STORES);
}
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_STOCK_CHECK)) {
stockController.otherStoreStockCheck(Boolean.FALSE);
int loc = ClientApplicationContext.getClientApplicationContext().getLocation();
Profile profile = ClientApplicationContext.getClientApplicationContext()
.getProfile(Profile.POINT_OF_SALE_CLIENT, loc);
boolean dcStore = profile.getStoreProfile().getDcStore().booleanValue();
boolean usStore = RefCountry.UNITED_STATES.equalsIgnoreCase(profile.getStoreProfile().getRefCountryCd());
boolean isQuickStockType = isQuickStockItemHandler();
if (!dcStore || !autoCheckDCQuantity || !isQuickStockType || !usStore) {
autoCheckDCQuantity = false;
String partNumber= FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText(),
new char[] {PartNumberFormatCertifier.DASH,
PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE});
if (clientApplicationContext.getSystemDAO().askForPassword(
PasswordConstants.STOCK_CHECK_PWD).booleanValue()) {
PasswordController passwordController = new PasswordController(parentView);
passwordController.setInitialData(PasswordConstants.STOCK_CHECK_PWD);
passwordController.setViewVisible(true);
if (passwordController.getPasswordValid()) {
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
String storeNumber = InvoiceBL.formatStoreNumber(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getStoreProfile().getStoreNum());
String[] parms = new String[]{storeNumber};
clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9530", parms);
}
BaseInventoryVO baseInventoryVO = new BaseInventoryVO();
baseInventoryVO.setPartNumber(partNumber);
baseInventoryVO.setLineAbbrev(invoiceLineEntryPanel.slfLine.getText());
baseInventoryVO.setDescription(invoiceLineEntryPanel.fldDescription.getText());
stockController.setInitialData(customerVO, baseInventoryVO);
stockController.setViewVisible(true);
}
} else {
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
String storeNumber = InvoiceBL.formatStoreNumber(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getStoreProfile().getStoreNum());
String[] parms = new String[]{storeNumber};
clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9530", parms);
}
BaseInventoryVO baseInventoryVO = new BaseInventoryVO();
baseInventoryVO.setPartNumber(partNumber);
baseInventoryVO.setLineAbbrev(invoiceLineEntryPanel.slfLine.getText());
baseInventoryVO.setDescription(invoiceLineEntryPanel.fldDescription.getText());
stockController.setInitialData(customerVO, baseInventoryVO);
stockController.setViewVisible(true);
}
} else if (dcStore && autoCheckDCQuantity && usStore) {
setWaitCursor(true);
autoCheckDCQuantity = false;
String dcQuantity = null;
String dcName = null;
try {
Vector list = clientApplicationContext.getEJOEIDAO().getDistributionCenterList(
invoiceLineEntryPanel.fldPartNumber.getText(),
invoiceLineEntryPanel.slfLine.getText(),
clientApplicationContext.getCurrentLocale().getLanguage(),
clientApplicationContext.getCurrentUser().getEmployeeId().intValue(),loc,clientApplicationContext.getCurrentUser());
//The serving DC should be the first one in the vector.
IDValuePairVO valuePairVO = (IDValuePairVO)list.elementAt(0);
int index = 0;
while (valuePairVO != null && valuePairVO.validVO()
&& valuePairVO.getID() instanceof Integer && index < list.size()+1) {
index = index+1;
valuePairVO = (IDValuePairVO) list.elementAt(index);
}
if ((valuePairVO != null) && valuePairVO.validVO()) {
try {
dcName = (String)valuePairVO.getID();
if (valuePairVO.getValue() instanceof String) {
dcQuantity = (String)valuePairVO.getValue();
if (dcQuantity.indexOf(",") > 0) {
dcQuantity = dcQuantity.substring(0, dcQuantity.indexOf(","));
}
dcQuantity = Integer.valueOf(dcQuantity).toString();
} else {
dcQuantity = ((Integer)valuePairVO.getValue()).toString();
}
} catch (Exception e){
//there was an exception when casting the above values...no error to report
}
}
if (dcName == null) {
dcName = "N/A";
}
if (dcQuantity == null) {
dcQuantity = "N/A";
}
lineItemHandler.setDCStockInfo(dcName, dcQuantity);
lineItemHandler.handleLineAnnotations();
} catch(DisconnectedException e) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, e.getUserMessageID());
} catch(ApplicationException e) {
logger.error(e, e);
if ("2010".equals(e.getUserMessageID())) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, e.getUserMessageID());
} else if("2477".equals(e.getUserMessageID())){
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, e.getUserMessageID());
}else {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2009");
}
} finally {
setWaitCursor(false);
}
}
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_PART_INFO_NAME)) {
PPSEService ppseService = PPSEServiceFactory.getServiceInstance();
if (ppseService.isPPSE2Active()) {
try {
SessionData sessionData = SessionFactory.createSession(invoiceVO, customerVO,
SessionFactory.PPSE2_PART_INFO);
StringBuffer partInfoUrl = new StringBuffer();
StringBuffer key = new StringBuffer();
String keyString = "";
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");
final TimeZone utc = TimeZone.getTimeZone("UTC");
sdf.setTimeZone(utc);
String partNumber = FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText(),
new char[] { PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE });
partInfoUrl.append(clientApplicationContext.getSystemDAO().getPPSE2PartInfoURL());
partInfoUrl.append(sessionData.toUrlParams());
key.append("TAMS|");
key.append(invoiceLineEntryPanel.slfLine.getText());
key.append("|");
key.append(partNumber);
key.append("|");
key.append(sdf.format(new Date()));
keyString = key.toString();
MessageDigest messageDigest = MessageDigest.getInstance("SHA");
messageDigest.reset();
messageDigest.update(keyString.getBytes("UTF-8"));
String encryptedKey = new BigInteger(1, messageDigest.digest()).abs().toString(16);
while (encryptedKey.length() < 40) {
encryptedKey = "0" + encryptedKey;
}
partInfoUrl.append("&key=").append(encryptedKey.toUpperCase());
partInfoUrl.append("&line=").append(invoiceLineEntryPanel.slfLine.getText());
partInfoUrl.append("&part=").append(partNumber);
logger.debug("****PPSE Part Info URL****" + partInfoUrl.toString());
BrowserLauncher.launch(CommonUtil.getSunURL(partInfoUrl.toString()));
} catch (Exception exception) {
logger.error(exception.getMessage(), exception);
openNoAdditionalInfoMsg();
return;
}
invoiceLineEntryPanel.btnPartInfo.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.btnPartInfo, KeyEvent.KEY_PRESSED, new Date().getTime(), 0,
KeyEvent.VK_TAB, '\t'));
} else {
openNoAdditionalInfoMsg();
}
} else if (strComponentName.equals(InvoiceLineEntryPanel.BTN_CANCEL)) {
if (invoiceVO.getLineItems().size() < 2) {
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
int modifiers = clientApplicationContext.isLoggedInAsSales()
? KeyEvent.SHIFT_MASK : 0;
getInvoicePanel().getEmployeePswdField().dispatchEvent(new KeyEvent(
getInvoicePanel().getEmployeePswdField(), KeyEvent.KEY_PRESSED,
new Date().getTime(), modifiers, KeyEvent.VK_TAB, '\t'));
} else {
InvoiceBL.closePpseSession(invoiceVO);
resetEntryArea(null, null);
resetLineItem(null);
resetSpecialFunctions(0, false);
clientApplicationContext.getPointOfSaleEventDispatcher().fireListItemCleared(
new PointOfSaleListEvent(this, null));
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(
new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
} else if(strComponentName.equals(InvoiceLineEntryPanel.BTN_CHECK_OTHER_STORES)){
String partNumber= FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber
.getText(),
new char[] {PartNumberFormatCertifier.DASH,
PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE});
BaseInventoryVO baseInventoryVO = new BaseInventoryVO();
baseInventoryVO.setPartNumber(partNumber);
baseInventoryVO.setLineAbbrev(invoiceLineEntryPanel.slfLine.getText());
baseInventoryVO.setDescription(invoiceLineEntryPanel.fldDescription.getText());
stockController.setInitialData(customerVO, baseInventoryVO);
stockController.otherStoreStockCheck(Boolean.TRUE);
stockController.setViewVisible(true);
} else if(strComponentName.equals(InvoiceLineEntryPanel.BTN_SOURCE_OPTION)) {
if (TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
baseLineItemVO.setSourceOptionSelected(true);
baseLineItemVO.setSpecialOrder(TsoConstant.LOCAL);
addLineItemToLineList();
} else if (TsoConstant.LOCAL.equals(baseLineItemVO.getSpecialOrder())) {
baseLineItemVO.setSourceOptionSelected(true);
baseLineItemVO.setSpecialOrder(TsoConstant.NAPA_XPRESS);
addLineItemToLineList();
}
}
}
private void openNoAdditionalInfoMsg() {
setWaitCursor(true);
if (getInvoicePanel().isVisible()) {
additionalPartInfoController.setPartInfo(FwoUtil.stripChars(
invoiceLineEntryPanel.fldPartNumber.getText(),
new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}),
invoiceLineEntryPanel.slfLine.getText());
} else {
additionalPartInfoController.setPartInfo(tempPartVO);
}
setWaitCursor(false);
invoiceLineEntryPanel.btnPartInfo.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.btnPartInfo, KeyEvent.KEY_PRESSED, new Date().getTime(), 0,
KeyEvent.VK_TAB, '\t'));
}
private boolean sendNXPInterstoreUpdateSalesOrderRequest(
InvoiceVO invoiceVO, boolean isCancelInvoice) {
boolean orderNotificationStatusValue = false;
try {
OrderNotificationStatus orderNotificationStatus = clientApplicationContext
.getInvoiceDAO().sendNXPInterstoreUpdateNotification(
invoiceVO, isCancelInvoice);
if (orderNotificationStatus != null) {
orderNotificationStatusValue = orderNotificationStatus
.isSuccess();
return orderNotificationStatusValue;
}
} catch (ApplicationException e) {
logger.error(e.toString(), e);
}
return orderNotificationStatusValue;
}
private boolean isSpecialChargeItemHandler() {
return lineItemHandler instanceof DeliveryLineItemHandler ||
lineItemHandler instanceof FreightLineItemHandler ||
lineItemHandler instanceof BagFeeLineItemHandler ||
lineItemHandler instanceof TelephoneLineItemHandler ||
lineItemHandler instanceof MiscLineItemHandler ||
lineItemHandler instanceof OtherLineItemHandler ||
lineItemHandler instanceof PALineItemHandler ||
lineItemHandler instanceof ServiceLineItemHandler ||
lineItemHandler instanceof ColoradoDeliveryFeeLineItemHandler;
}
private boolean isQuickStockItemHandler() {
if (lineItemHandler instanceof EnvLineItemHandler ||
lineItemHandler instanceof WLCLineItemHandler ||
lineItemHandler instanceof CoreLineItemHandler ||
lineItemHandler instanceof AGCoreLineItemHandler ||
lineItemHandler instanceof DefectiveLineItemHandler ||
lineItemHandler instanceof NAPAOnlineDefectiveLineItemHandler) {
return false;
} else {
return true;
}
}
public void focusGained(FocusEvent fe) {
if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_PART_NUMBER_NAME)
&& invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
if (customerVO == null) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getInvoicePanel().getCustomerComboBox().dispatchEvent(
new KeyEvent(getInvoicePanel().getCustomerComboBox(),
KeyEvent.KEY_PRESSED, new Date().getTime(), 0,
KeyEvent.VK_TAB, '\t'));
}
});
}
if (!invoiceLineEntryPanel.fldPartNumber.getText().equals("")
|| lineItemHandler == null
|| (baseLineItemVO != null && (
baseLineItemVO.getLineAbbr().startsWith("DEL")
|| baseLineItemVO.getLineAbbr().startsWith("FRT")
|| baseLineItemVO.getLineAbbr().startsWith("OTH")
|| baseLineItemVO.getLineAbbr().startsWith("PA")
|| baseLineItemVO.getLineAbbr().startsWith("TEL")
|| baseLineItemVO.getLineAbbr().startsWith("SVC")
|| baseLineItemVO.getLineAbbr().startsWith("MIS")
|| baseLineItemVO.getLineAbbr().startsWith("ENV")))) {
if(baseLineItemVO != null && baseLineItemVO.isPartAddedFromPPSE2()){
clientApplicationContext.getPointOfSaleEventDispatcher().fireLineItemRemovedInTAMS(new CartEvent(this, baseLineItemVO));
}
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
clientApplicationContext.getPointOfSaleEventDispatcher().fireListItemCleared(
new PointOfSaleListEvent(this, null));
}
invoiceLineEntryPanel.fldPartNumber.setText("");
invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(true);
invoiceLineEntryPanel.btnBarcode.setEnabled(true);
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
invoiceLineEntryPanel.btnBarcode.setVisible(true);
invoiceLineEntryPanel.btnOtherStores.setVisible(false);
}
if (!invoiceLineEntryPanel.slfSpecialFunctions.isVisible()) {
focusLost(new FocusEvent(invoiceLineEntryPanel.fldPartNumber, 0));
}
if (!invoiceLineEntryPanel.fldPartNumber.getCaret().isVisible()) {
invoiceLineEntryPanel.fldPartNumber.getCaret().setVisible(true);
}
if ((invoiceVO.getLineItems() != null) && (invoiceVO.getLineItems().size() > 0)) {
invoiceLineEntryPanel.btnFinalize.setEnabled(true);
} else {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
}
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.SLF_LINE_NAME)) {
//Other Balances and PartInfo are not an option when the focus is not line field
if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){
invoiceLineEntryPanel.btnCheckOtherStores.setVisible(false);
invoiceLineEntryPanel.btnBarcode.setVisible(true);
}
invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(false);
invoiceLineEntryPanel.btnPartInfo.setEnabled(false);
invoiceLineEntryPanel.btnSupersede.setEnabled(false);
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
invoiceLineEntryPanel.fldPD.setText("");
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_NAPA_RETURN_AUTH_NUM)
&& (lineItemHandler == null || napaOnlineInfoVO == null)) {
napaOnlineInfoVO = new NAPAOnlineInfoVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_INFO, invoiceLineEntryPanel,
napaOnlineInfoVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
} else if (fe.getComponent().getName().equals(
InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
RefTableVO refTableVO = (RefTableVO)
invoiceLineEntryPanel.slfSpecialFunctions.getTableModel().getData().get(0);
refTableVO.setDescription(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.slfSpecialFunctions.Part",
clientApplicationContext.getCurrentLocale()));
if (invoiceLineEntryPanel.slfSpecialFunctions.getSelectedRow() == 0) {
invoiceLineEntryPanel.slfSpecialFunctions.setText(refTableVO.getDescription());
invoiceLineEntryPanel.slfSpecialFunctions.selectAll();
}
//We only want to display Sequence # to edit/delete if there are lines in the list.
if (invoiceVO.getLineItems() != null && !invoiceVO.getLineItems().isEmpty()) {
invoiceLineEntryPanel.lblLine5.setEnabled(true);
invoiceLineEntryPanel.lblLine5.setText(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.slfSpecialFunctions.Edit",
clientApplicationContext.getCurrentLocale()));
}
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
if (baseLineItemVO != null) {
if (invoiceLineEntryPanel.fldPartNumber.getSelectedText() != null) {
invoiceLineEntryPanel.fldPartNumber.select(0, 0);
}
pointOfSaleEventDispatcher.fireListItemSelected(new PointOfSaleListEvent(this,
invoiceLineItemVO, false));
if (getDefectiveKitSelectedForRgn()) {
setDefectiveKitSelectedForRgn(false);
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldQuantity, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
// Disable 'Other Stores' button on editing the quantity of
// recalled saved invoice return line item
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
if (invoiceLineEntryPanel.fldQuantity.getText().startsWith("-")) {
invoiceLineEntryPanel.btnOtherStores.setEnabled(false);
} else {
invoiceLineEntryPanel.btnOtherStores.setEnabled(true);
}
}
}
autoCheckDCQuantity = true;
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
hidePercentField();
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_DC_NAME)) {
hidePercentField();
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_TAX_NAME)) {
hidePercentField();
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_SECONDARY_TAX_NAME)) {
hidePercentField();
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_PERCENT_NAME)) {
invoiceLineEntryPanel.fldPD.setVisible(false);
} else if (fe.getComponent().getName().equals(
InvoiceLineEntryPanel.FLD_CLAIM_FORM_NUMBER_NAME)) {
this.resetSpecialFunctions(0, true);
}
else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_OK_NAME)) {
hidePercentField();
if (clientApplicationContext.isLoggedInAsPhoneRoom()
&& baseLineItemVO != null && baseLineItemVO.getQuantityBilled() !=null &&
baseLineItemVO.getQuantityBilled().signum() != 0) {
invoiceLineEntryPanel.btnOtherStores.setEnabled(false);
}
if (invoiceLineEntryPanel.fldOK.getText().equals("")
&& (baseLineItemVO != null && baseLineItemVO.isCompletedLine())) {
invoiceLineEntryPanel.fldOK.setText("Y");
invoiceLineEntryPanel.fldOK.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldOK,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
} else {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
invoiceLineEntryPanel.slfLine.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldDescription.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldQuantity.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldList.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldPD.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldPrice.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldUnit.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldDC.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldTax.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldSecondaryTax.setVerifyInputWhenFocusTarget(false);
// Added for RGN:Invoicing
if (invoiceLineEntryPanel.fldClaimFormNumber.isVisible()) {
invoiceLineEntryPanel.fldNote.setVerifyInputWhenFocusTarget(false);
invoiceLineEntryPanel.fldClaimFormNumber
.setVerifyInputWhenFocusTarget(false);
}
// ===========================
invoicePanel.getEmployeeField().setVerifyInputWhenFocusTarget(false);
}
});
}
}
}
private void hidePercentField() {
if (invoiceLineEntryPanel.fldPercent.isVisible()) {
invoiceLineEntryPanel.lblPercent.setVisible(false);
invoiceLineEntryPanel.lblPercent.setEnabled(false);
invoiceLineEntryPanel.fldPercent.setVisible(false);
invoiceLineEntryPanel.fldPercent.setEnabled(false);
invoiceLineEntryPanel.fldPD.setVisible(true);
}
}
void setVerifyInputforComponents() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
invoiceLineEntryPanel.slfLine.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldDescription.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldQuantity.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldList.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldPD.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldPrice.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldUnit.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldDC.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldTax.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldSecondaryTax.setVerifyInputWhenFocusTarget(true);
// Added for RGN:Invoicing
if (invoiceLineEntryPanel.fldClaimFormNumber.isVisible()) {
invoiceLineEntryPanel.fldClaimFormNumber
.setVerifyInputWhenFocusTarget(true);
}
// ===========================
invoicePanel.getEmployeeField().setVerifyInputWhenFocusTarget(true);
}
});
}
public void focusLost(FocusEvent fe) {
if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_OK_NAME)) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
invoiceLineEntryPanel.slfLine.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldDescription.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldQuantity.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldList.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldPD.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldPrice.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldUnit.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldDC.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldTax.setVerifyInputWhenFocusTarget(true);
invoiceLineEntryPanel.fldSecondaryTax.setVerifyInputWhenFocusTarget(true);
// Added for RGN:Invoicing
if (invoiceLineEntryPanel.fldClaimFormNumber.isVisible()) {
invoiceLineEntryPanel.fldClaimFormNumber
.setVerifyInputWhenFocusTarget(true);
}
// ===========================
invoicePanel.getEmployeeField().setVerifyInputWhenFocusTarget(true);
}
});
if (invoiceLineEntryPanel.fldOK.getText().equalsIgnoreCase("Y")
|| invoiceLineEntryPanel.fldOK.getText().equalsIgnoreCase(
"T")) {
if ((baseLineItemVO == null || baseLineItemVO.isCompletedLine())
&& !LineGenerationQueue.getInstance().isEmpty()) {
boolean itemReturnDetailInfoRequired = getInvoicingProfile()
.getAskForItemReturnInfo().booleanValue();
/**
* Code added to avoid calling the processLineQueue() method
* when the return line item is not added to list.
*/
if (baseLineItemVO != null && baseLineItemVO.getReturnItems() != null
&& !baseLineItemVO.isLineAddedToList()
&& itemReturnDetailInfoRequired) {
return;
}
PointOfSaleEventDispatcher.getInstance()
.fireProcessLineQueue(
new PointOfSaleEvent(this, baseLineItemVO));
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
}
}
if (clientApplicationContext.isLoggedInAsPhoneRoom()
&& baseLineItemVO != null
&& baseLineItemVO.getQuantityBilled().signum() >= 0) {
invoiceLineEntryPanel.btnOtherStores.setEnabled(true);
}
} else if (fe.getComponent().getName().equals(
InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
RefTableVO refTableVO = (RefTableVO)
invoiceLineEntryPanel.slfSpecialFunctions.getTableModel().getData().get(0);
refTableVO.setDescription(
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.slfSpecialFunctions.Default",
clientApplicationContext.getCurrentLocale()));
if (invoiceLineEntryPanel.slfSpecialFunctions.getSelectedRow() == 0) {
invoiceLineEntryPanel.slfSpecialFunctions.setText(refTableVO.getDescription());
}
invoiceLineEntryPanel.lblLine5.setText("");
invoiceLineEntryPanel.lblLine5.setEnabled(false);
} else if (fe.getComponent().getName().equals(
InvoiceLineEntryPanel.FLD_NAPA_TOTAL_CREDIT)) {
if (napaOnlineInfoVO != null && napaOnlineInfoVO.isCompletedLine()) {
PointOfSaleEventDispatcher.getInstance().fireProcessLineQueue(
new PointOfSaleEvent(this, napaOnlineInfoVO));
}
} else if (fe.getComponent().getName().equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
autoCheckDCQuantity = false;
}
}
public void mousePressed(MouseEvent me) {
}
public IView getView() {
return invoiceLineEntryPanel;
}
public PointOfSaleVO getModel() {
return invoiceVO;
}
public void installViewListeners() {
invoiceLineEntryPanel.fldNote.addFocusListener(this);
invoiceLineEntryPanel.fldNote.addKeyListener(this);
invoiceLineEntryPanel.fldPartNumber.addFocusListener(this);
invoiceLineEntryPanel.slfLine.addFocusListener(this);
invoiceLineEntryPanel.fldOK.addFocusListener(this);
invoiceLineEntryPanel.fldQuantity.addFocusListener(this);
invoiceLineEntryPanel.btnDelete.addActionListener(this);
invoiceLineEntryPanel.btnSupersede.addActionListener(this);
invoiceLineEntryPanel.btnSourceOption.addActionListener(this);
invoiceLineEntryPanel.slfSpecialFunctions.addFocusListener(this);
invoiceLineEntryPanel.btnBarcode.addActionListener(this);
invoiceLineEntryPanel.btnOtherStores.addActionListener(this);
invoiceLineEntryPanel.btnCheckOtherBalances.addActionListener(this);
invoiceLineEntryPanel.btnCheckOtherStores.addActionListener(this);
invoiceLineEntryPanel.btnPartInfo.addActionListener(this);
invoiceLineEntryPanel.btnFinalize.addActionListener(this);
invoiceLineEntryPanel.btnCancel.addActionListener(this);
invoiceLineEntryPanel.fldNapaReturnAuthNum.addFocusListener(this);
invoiceLineEntryPanel.fldNapaTotalCredit.addFocusListener(this);
invoiceLineEntryPanel.fldPD.addFocusListener(this);
invoiceLineEntryPanel.fldPercent.addFocusListener(this);
invoiceLineEntryPanel.fldTax.addFocusListener(this);
invoiceLineEntryPanel.fldSecondaryTax.addFocusListener(this);
invoiceLineEntryPanel.fldDC.addFocusListener(this);
// Added for RGN:Invoicing
invoiceLineEntryPanel.fldClaimFormNumber.addFocusListener(this);
// =====================================
invoiceLineEntryPanel.fldPartNumber.addMouseListener(this);
}
public void installBusinessListeners() {
pointOfSaleEventDispatcher.addListener(InvoiceListener.class, this);
pointOfSaleEventDispatcher.addListener(InvoiceListListener.class, this);
pointOfSaleEventDispatcher.addListener(CustomerListener.class, this);
pointOfSaleEventDispatcher.addListener(EmployeeListener.class, this);
pointOfSaleEventDispatcher.addListener(VehicleListener.class, this);
pointOfSaleEventDispatcher.addListener(ProcessLineQueueListener.class, this);
pointOfSaleEventDispatcher.addListener(CatalogListener.class, this);
pointOfSaleEventDispatcher.addListener(BuyoutListener.class, this);
pointOfSaleEventDispatcher.addListener(ProfileListener.class, this);
pointOfSaleEventDispatcher.addListener(InvoiceLineEntryListener.class, this);
pointOfSaleEventDispatcher.addListener(PointOfSaleListListener.class, this);
pointOfSaleEventDispatcher.addListener(POSTAMSListener.class, this);
pointOfSaleEventDispatcher.addListener(StoreListener.class, this);
pointOfSaleEventDispatcher.addListener(CheckoutListener.class, this);
pointOfSaleEventDispatcher.addListener(CartListener.class, this);
}
public void installVerifiers() {
FwoBaseInputVerifier baseVerifier = new FwoBaseInputVerifier(this);
baseVerifier.setAdditionalValidationOnClient(true);
TsoIMPartNumberVerifier partNumberVerifier = new TsoIMPartNumberVerifier(this);
partNumberVerifier.setAdditionalValidationOnClient(true);
invoiceLineEntryPanel.fldPartNumber.setDocument
(new TsoValidatedIMPartNumberDocument(invoiceLineEntryPanel.fldPartNumber, 26, true));
invoiceLineEntryPanel.fldPartNumber.setInputVerifier(partNumberVerifier);
invoiceLineEntryPanel.slfLine.setDocument(
new TsoValidatedLineAbbrevDocument(invoiceLineEntryPanel.slfLine));
invoiceLineEntryPanel.slfLine.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldDescription.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldQuantity.setDocument(new QuantityDocument());
invoiceLineEntryPanel.fldQuantity.setInputVerifier(new QuantityVerifier(this, true));
FwoValidatedDecimalNumberDocument fvdnd = new FwoValidatedDecimalNumberDocument(
invoiceLineEntryPanel.fldList, FwiConstant.DOUBLE_MIN_VALUE,
FwiConstant.DOUBLE_MAX_VALUE, 4, 4);
String validInputChars = String.valueOf(fvdnd.getPattern().getValidInputChars()) + "@";
fvdnd.setValidInputChars(validInputChars.toCharArray());
invoiceLineEntryPanel.fldList.setDocument(fvdnd);
invoiceLineEntryPanel.fldList.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldPD.setDocument(new PDDocument());
invoiceLineEntryPanel.fldPD.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldPercent.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldDC.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldDC,
1, null, new char [] {'y', 'n'}, DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldDC.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldTax.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldTax,
1, null, new char [] {'y', 'n'}, DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldTax.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldSecondaryTax.setDocument(new DefaultDocument(
invoiceLineEntryPanel.fldSecondaryTax, 1, null, new char [] {'y', 'n'},
DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldSecondaryTax.setInputVerifier(baseVerifier);
// invoiceLineEntryPanel.fldOK.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldOK,
// 1, null, new char [] {'y', 'n', 't'}, DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldOK.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldOK,
1, null, new char [] {'y', 'n'}, DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldOK.setInputVerifier(baseVerifier);
int chars = clientApplicationContext.getSystemDAO().getCharactersInInvoiceLineMessage().
intValue();
invoiceLineEntryPanel.fldNote.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldNote,
chars, DefaultDocument.ANY));
invoiceLineEntryPanel.fldNote.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.slfSpecialFunctions.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldNapaReturnAuthNum.setDocument(new DefaultDocument(
invoiceLineEntryPanel.fldNapaReturnAuthNum, 7, DefaultDocument.NUMERIC));
invoiceLineEntryPanel.fldNapaReturnAuthNum.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldNapaTotalCredit.setDocument(new DefaultDocument(
invoiceLineEntryPanel.fldNapaTotalCredit, 10, DefaultDocument.NUMERIC,
new char [] {'.','-',','}));
invoiceLineEntryPanel.fldNapaTotalCredit.setInputVerifier(baseVerifier);
invoiceLineEntryPanel.fldYN.setDocument(new DefaultDocument(invoiceLineEntryPanel.fldYN,
1, null, new char [] {'y', 'n'}, DefaultDocument.UPPER_CASE));
invoiceLineEntryPanel.fldYN.setInputVerifier(baseVerifier);
// Added for RGN:Invoicing
invoiceLineEntryPanel.fldClaimFormNumber.setDocument(new FwoValidatedWholeNumberDocument(
invoiceLineEntryPanel.fldClaimFormNumber, new Integer(0), FwiConstant.INTEGER_MAX_VALUE, false));
FwoNumberVerifier numberVerifier = new FwoNumberVerifier(this, true);
invoiceLineEntryPanel.fldClaimFormNumber.setInputVerifier(numberVerifier);
// =======================
}
public void installFocusDeciders() {
invoiceLineEntryPanel.fldPartNumber.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.slfLine.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldDescription.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldQuantity.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldList.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldPD.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldPercent.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldDC.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldTax.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldSecondaryTax.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldOK.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldNote.putClientProperty(FocusDecider.NAME, this);
// Added for RGN:Invoicing
invoiceLineEntryPanel.fldClaimFormNumber.putClientProperty(FocusDecider.NAME, this);
// ==================================================
invoiceLineEntryPanel.slfSpecialFunctions.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnDelete.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnSupersede.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnSourceOption.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnFinalize.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnCheckOtherBalances.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnCheckOtherStores.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldNapaReturnAuthNum.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldNapaTotalCredit.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnBarcode.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnOtherStores.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.btnPartInfo.putClientProperty(FocusDecider.NAME, this);
invoiceLineEntryPanel.fldYN.putClientProperty(FocusDecider.NAME, this);
}
public boolean validateComponent(JComponent currentComponent) {
if (focusMovingForward == false) {
focusMovingForward = true;
return true;
}
String componentName = currentComponent.getName();
if (componentName.equals(InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
processSpecialFunctionSelection();
} else {
if ((lineItemHandler == null || baseLineItemVO == null)
&& componentName.equals(InvoiceLineEntryPanel.FLD_PART_NUMBER_NAME)
&& invoiceLineEntryPanel.fldPartNumber.getText() != null
&& !invoiceLineEntryPanel.fldPartNumber.getText().equals(
TsoConstant.EMPTY_STRING)) {
baseLineItemVO = new BaseLineItemVO();
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.NAPA_ONLINE_LINE_ITEM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
} else {
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.PHONE_ROOM, invoiceLineEntryPanel, baseLineItemVO,
customerVO, invoiceVO, null);
} else {
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.DEFAULT, invoiceLineEntryPanel, baseLineItemVO,
customerVO, invoiceVO, null);
}
}
lineItemHandler.displayLineItem();
}
if (componentName.equals(InvoiceLineEntryPanel.FLD_DESCRIPTION_NAME)) {
if (invoiceLineEntryPanel.fldDescription.getText() == null
|| invoiceLineEntryPanel.fldDescription.getText().equals("")) {
return false;
}
}
if (componentName.equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
if (isPDOverMaxPrice()) {
invoiceLineEntryPanel.fldPD.setText("");
return false;
}
BigDecimal price = null;
FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern
.getNumberPatternInstance(FwoNumberPattern.DECIMAL,
clientApplicationContext.getCurrentLocale(), true);
try {
price = (BigDecimal) fwoNumberPattern.parse(invoiceLineEntryPanel.fldPrice
.getText());
} catch (PatternParseException ppe) {
logger.error("Error occured in validateComponent() method" + ppe.getMessage());
}
String pd = invoiceLineEntryPanel.fldPD.getText();
if (baseLineItemVO != null && baseLineItemVO.isCasePrice().booleanValue()
&& price != null && price.doubleValue() != 0.0 && pd.trim().equals("")) {
invoiceLineEntryPanel.fldPD.setText("C");
}
}
if (lineItemHandler != null) {
lineItemHandler.handle(componentName);
// if (componentName.equals(invoiceLineEntryPanel.FLD_OK_NAME)
// && (invoiceLineEntryPanel.fldOK.getText().equals("Y")
// || invoiceLineEntryPanel.fldOK.getText().equals("T"))) {
// resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
// invoiceLineEntryPanel.fldPartNumber);
// }
if (componentName.equals(InvoiceLineEntryPanel.FLD_OK_NAME)
&& (invoiceLineEntryPanel.fldOK.getText().equals("Y"))) {
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
}
}
}
if (lineItemHandler != null) {
if (componentName.equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
if (invoiceLineEntryPanel.fldQuantity.getText().equals("")) {
return false;
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DC_NAME)) {
return validDCText();
}
}
return true;
}
private boolean isPDOverMaxPrice () {
BigDecimal price = null;
FwoNumberPattern fwoNumberPattern = (FwoNumberPattern)
FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL,
clientApplicationContext.getCurrentLocale(), true);
try {
price = (BigDecimal) fwoNumberPattern.parse(invoiceLineEntryPanel.fldPD.getText());
} catch (PatternParseException ppe) {
//do nothing
}
if (price == null) {
return false;
}
return InvoiceBL.isPriceExceedsMaxUnitPrice(price);
}
public JComponent getFocusableComponent() {
JComponent returnComponent = null;
if (invoiceLineEntryPanel.fldOK.isVisible() && invoiceLineEntryPanel.fldOK.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldOK;
} else if (invoiceLineEntryPanel.fldSecondaryTax.isVisible()
&& invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else if (invoiceLineEntryPanel.fldTax.isVisible()
&& invoiceLineEntryPanel.fldTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else if (invoiceLineEntryPanel.fldDC.isVisible()
&& invoiceLineEntryPanel.fldDC.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (invoiceLineEntryPanel.fldUnit.isVisible()
&& invoiceLineEntryPanel.fldUnit.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldUnit;
} else if (invoiceLineEntryPanel.fldPrice.isVisible()
&& invoiceLineEntryPanel.fldPrice.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPrice;
} else if (invoiceLineEntryPanel.fldPD.isVisible()
&& invoiceLineEntryPanel.fldPD.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else if (invoiceLineEntryPanel.fldList.isVisible()
&& invoiceLineEntryPanel.fldList.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldList;
} else if (invoiceLineEntryPanel.fldQuantity.isVisible()
&& invoiceLineEntryPanel.fldQuantity.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (invoiceLineEntryPanel.fldDescription.isVisible()
&& invoiceLineEntryPanel.fldDescription.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else if (invoiceLineEntryPanel.slfLine.isVisible()
&& invoiceLineEntryPanel.slfLine.isEnabled()) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (invoiceLineEntryPanel.fldPartNumber.isVisible()
&& invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
return returnComponent;
}
public JComponent getDefaultFocusableComponent(JComponent currentComponent,
boolean transferFocusForward) {
JComponent returnComponent = null;
String componentName = currentComponent.getName();
focusMovingForward = transferFocusForward;
if (transferFocusForward) {
if (componentName.equals(InvoiceLineEntryPanel.FLD_PART_NUMBER_NAME)) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (componentName.equals(InvoiceLineEntryPanel.SLF_LINE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DESCRIPTION_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_LIST_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PERCENT_NAME)) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DC_NAME)) {
if (validDCText()) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else {
returnComponent = invoiceLineEntryPanel.fldDC;
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_TAX_NAME)) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_SECONDARY_TAX_NAME)) {
returnComponent = invoiceLineEntryPanel.fldOK;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_OK_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_INVOICE_NOTE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SUPERSEDE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_DELETE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
resetLineItem(null);
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SOURCE_OPTION)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
resetLineItem(null);
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_FINALIZE_NAME)) {
if (invoiceVO.getManualTransaction().booleanValue()) {
returnComponent = getInvoicePanel().getInvoiceDateField();
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_STOCK_CHECK)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_CHECK_OTHER_STORES)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_RETURN_AUTH_NUM)) {
returnComponent = invoiceLineEntryPanel.fldNapaTotalCredit;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_TOTAL_CREDIT)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_YN_NAME)) {
if (validYNText()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}else {
returnComponent = invoiceLineEntryPanel.fldYN;
}
}
} else {
if (componentName.equals(InvoiceLineEntryPanel.FLD_PART_NUMBER_NAME)) {
invoiceLineEntryPanel.fldPartNumber.setText("");
returnComponent = invoiceLineEntryPanel.slfSpecialFunctions;
} else if (componentName.equals(InvoiceLineEntryPanel.SLF_LINE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
invoiceController.stopPpse2LinesProcessing();
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DESCRIPTION_NAME)) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_LIST_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PERCENT_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DC_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_TAX_NAME)) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_SECONDARY_TAX_NAME)) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_OK_NAME)) {
invoiceLineEntryPanel.fldOK.setText("");
returnComponent = invoiceLineEntryPanel.fldTax;
}
// Added/Modified for RGN:Invoicing
else if (componentName.equals(InvoiceLineEntryPanel.FLD_INVOICE_NOTE_NAME)) {
invoiceLineEntryPanel.fldNote.setText("");
returnComponent = invoiceLineEntryPanel.fldClaimFormNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_CLAIM_FORM_NUMBER_NAME)) {
invoiceLineEntryPanel.fldClaimFormNumber.setText("");
returnComponent = invoiceLineEntryPanel.slfSpecialFunctions;
}
// ==================================================
else if (componentName.equals(InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SUPERSEDE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_DELETE_NAME)) {
resetLineItem(null);
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SOURCE_OPTION)) {
resetLineItem(null);
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_FINALIZE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_RETURN_AUTH_NUM)) {
returnComponent = invoiceLineEntryPanel.btnCancel;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_TOTAL_CREDIT)) {
returnComponent = invoiceLineEntryPanel.fldNapaReturnAuthNum;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_YN_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
}
return returnComponent;
}
public JComponent getFocusableComponentAfterVerification(JComponent currentComponent,
boolean transferFocusForward) {
JComponent returnComponent = null;
String componentName = currentComponent.getName();
if (componentName.equals(InvoiceLineEntryPanel.FLD_PART_NUMBER_NAME)) {
if (transferFocusForward) {
if (getInvoicePanel().isVisible()) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
if (invoiceLineEntryPanel.fldPartNumber.getText().equals("")) {
// Code added for Tender Types.
// Disable line field when part number field is empty.
if (invoiceLineEntryPanel.slfLine.getText().trim().equals("")) {
invoiceLineEntryPanel.lblLine.setEnabled(false);
invoiceLineEntryPanel.slfLine.setEnabled(false);
}
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (invoiceLineEntryPanel.slfLine.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else {
if (invoiceLineEntryPanel.fldDescription.getText() == null
|| invoiceLineEntryPanel.fldDescription.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
}
if (invoiceLineEntryPanel.fldYN.isVisible()
&& invoiceLineEntryPanel.fldYN.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldYN;
}
} else {
returnComponent = getCatalogButtonPanel().getSQFSequenceNum();
}
} else {
invoiceLineEntryPanel.fldPartNumber.setText("");
if (invoiceLineEntryPanel.slfSpecialFunctions.isVisible()) {
returnComponent = invoiceLineEntryPanel.slfSpecialFunctions;
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.SLF_LINE_NAME)) {
if (transferFocusForward) {
if (getInvoicePanel().isVisible()) {
if (lineItemHandler == null) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (invoiceLineEntryPanel.slfLine.getText() == null
|| invoiceLineEntryPanel.slfLine.getText().trim().equals("")
|| invoiceLineEntryPanel.slfLine.getText().length() < 2) {
/**
* Code added to set focus on Part Number field, when user accepts the alert
* message, on attempting to invoice a Kit Part against the special function
* COR.
*/
if (invoiceLineEntryPanel.fldPartNumber.getText() == null
|| invoiceLineEntryPanel.fldPartNumber.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = invoiceLineEntryPanel.slfLine;
}
} else if (invoiceLineEntryPanel.fldDescription.getText() == null
|| invoiceLineEntryPanel.fldDescription.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else {
// Code added for Tender Types.
// Sets the PD field document based on the entered line items and set the PD
// field text value with previous PD field value
setPdFieldDocument();
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
} else {
if (invoiceLineEntryPanel.slfLine.getText() == null
|| invoiceLineEntryPanel.slfLine.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (invoiceLineEntryPanel.fldDescription.getText() == null
|| invoiceLineEntryPanel.fldDescription.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
}
} else {
if (getInvoicePanel().isVisible()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = getCatalogButtonPanel().getSQFSequenceNum();
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DESCRIPTION_NAME)) {
if (transferFocusForward) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else {
if (getInvoicePanel().isVisible()) {
if (invoiceLineEntryPanel.slfLine.isEnabled()) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
} else {
returnComponent = getCatalogButtonPanel().getSQFSequenceNum();
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_QUANTITY_NAME)) {
//Bug No 28515, added if-else, checking for the case price, if yes then make the boolean variable to true
if (invoiceLineEntryPanel.fldPD.getText().equalsIgnoreCase("C")
|| (baseLineItemVO != null && baseLineItemVO.isCasePrice().booleanValue())) {
priceDecision = true;
} else {
priceDecision = false;
}
if (transferFocusForward) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.isMainCounter()){
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.lblOK.setEnabled(true);
returnComponent = invoiceLineEntryPanel.fldOK;
}
if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)
|| InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
if (invoiceLineEntryPanel.fldTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else {
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.lblOK.setEnabled(true);
returnComponent = invoiceLineEntryPanel.fldOK;
}
}
String remoteStoreIp = null;
if (invoiceVO.isPhoneRoomMessagesFlag()) {
try {
remoteStoreIp = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
} catch (ApplicationException e) {
logger.error("Exception occured while getting remote store IP");
e.getMessage();
}
}
if (InvoiceBL.doesKitComponentEligibleToLoadLineEntryArea(baseLineItemVO,
remoteStoreIp, invoiceVO)) {
invoiceLineEntryPanel.fldPD.setEnabled(false);
invoiceLineEntryPanel.fldDC.setEnabled(false);
invoiceLineEntryPanel.fldTax.setEnabled(false);
invoiceLineEntryPanel.fldSecondaryTax.setEnabled(false);
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.lblOK.setEnabled(true);
returnComponent = invoiceLineEntryPanel.fldOK;
}
if (InvoiceBL.useNapaGCv2() && baseLineItemVO.isCompletedLine()
&& baseLineItemVO.isNewGiftCard()
&& baseLineItemVO.getQuantityBilled().signum() < 0) {
invoiceLineEntryPanel.fldPD.setEnabled(false);
invoiceLineEntryPanel.fldDC.setEnabled(false);
invoiceLineEntryPanel.fldTax.setEnabled(false);
invoiceLineEntryPanel.fldSecondaryTax.setEnabled(false);
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.lblOK.setEnabled(true);
returnComponent = invoiceLineEntryPanel.fldOK;
}
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
String quantity = invoiceLineEntryPanel.fldQuantity.getText();
if (quantity.trim().length() == 0) {
invoiceLineEntryPanel.fldQuantity.setEnabled(false);
} else if (baseLineItemVO != null && baseLineItemVO.getQuantityBilled() != null) {
FwoNumberPattern fwoNumberPattern = (FwoNumberPattern)
FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL,
clientApplicationContext.getCurrentLocale(), true);
BigDecimal bdQty = null;
try {
bdQty = (BigDecimal) fwoNumberPattern.parse(quantity);
}catch (PatternParseException ppe) {
}
if (bdQty == null || baseLineItemVO.getQuantityBilled().compareTo(bdQty) != 0
|| quantity.equals("0.00")) {
if (bdQty != null && !quantity.equals("0.00")
&& !baseLineItemVO.isCasePrice().booleanValue()) {
baseLineItemVO.setQuantityBilled(new BigDecimal(quantity));
}
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
}
if (invoiceLineEntryPanel.fldPrice.getText().equals("0.0000")
&& baseLineItemVO != null && !baseLineItemVO.isCasePrice().booleanValue()) {
invoiceLineEntryPanel.fldPD.setText("");
}
} else {
if (getInvoicePanel().isVisible()) {
if (invoiceLineEntryPanel.slfLine.isEnabled()) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
} else {
return getCatalogButtonPanel().getSQFSequenceNum();
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_LIST_NAME)) {
if (invoiceLineEntryPanel.fldList.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldList;
} else if (transferFocusForward) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PD_NAME)) {
if (transferFocusForward) {
if (invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.A.toString())) {
if (baseLineItemVO != null) {
if (baseLineItemVO.getPriceDecision() == null){
invoiceLineEntryPanel.fldPD.setText("");
} else {
invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision());
}
}
returnComponent = invoiceLineEntryPanel.fldList;
} //else if (invoiceLineEntryPanel.fldPrice.getText().equals("0.00000") &&
// invoiceLineEntryPanel.fldPD.getText().equals("")) {
// returnComponent = invoiceLineEntryPanel.fldPD;
//}
else if (invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.PERCENT.toString())
|| invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.R.toString())
|| invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.T.toString())
|| invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.B.toString())) {
if (invoiceLineEntryPanel.fldPercent.isVisible()) {
returnComponent = invoiceLineEntryPanel.fldPercent;
} else {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
}
} else {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
}
// Place focus back to PD field - if line item price value is
// zero &
// invoicing profile - 'Item Price Value Required' flag is ON.
if (isLineItemPriceZero()) {
returnComponent = invoiceLineEntryPanel.fldPD;
}
} else {
if (invoiceLineEntryPanel.fldQuantity.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else {
returnComponent = invoiceLineEntryPanel.fldPD;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_PERCENT_NAME)) {
invoiceLineEntryPanel.fldPD.setVisible(true);
if (transferFocusForward) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
} else {
if (invoiceLineEntryPanel.fldQuantity.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else {
returnComponent = invoiceLineEntryPanel.fldPD;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_DC_NAME)) {
if (transferFocusForward) {
if (validDCText()) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
} else {
returnComponent = invoiceLineEntryPanel.fldDC;
}
} else {
if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()
).getInvoicingProfile().getAllowCtrmanOverridePrice().booleanValue()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_TAX_NAME)) {
if (transferFocusForward) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
} else {
if (invoiceLineEntryPanel.fldDC.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (invoiceLineEntryPanel.fldPD.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
if (!returnComponent.isEnabled()) {
returnComponent = currentComponent;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_SECONDARY_TAX_NAME)) {
if (transferFocusForward) {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
} else {
if (invoiceLineEntryPanel.fldTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else if (invoiceLineEntryPanel.fldDC.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (invoiceLineEntryPanel.fldPD.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
if (!returnComponent.isEnabled()) {
returnComponent = currentComponent;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_OK_NAME)) {
if (transferFocusForward) {
if (invoiceLineEntryPanel.fldOK.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldOK;
} else if (invoiceLineEntryPanel.fldOK.getText().equals("N")) {
if (baseLineItemVO != null) {
if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else if (invoiceLineEntryPanel.fldTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldTax;
} else if (invoiceLineEntryPanel.fldDC.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (invoiceLineEntryPanel.fldPD.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
if (!returnComponent.isEnabled()) {
returnComponent = currentComponent;
}
}
} else {
if (getInvoicePanel().isVisible()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
if (getCatalogButtonPanel().getSQFSequenceNum().isEnabled()) {
returnComponent = getCatalogButtonPanel().getSQFSequenceNum();
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
}
}
} else {
if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else if (invoiceLineEntryPanel.fldTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldTax;
}else if (invoiceLineEntryPanel.fldDC.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDC;
} else if (invoiceLineEntryPanel.fldPD.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPD;
} else {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
if (!returnComponent.isEnabled()) {
returnComponent = currentComponent;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.SLF_SPECIAL_FUNCTIONS_NAME)) {
if (invoiceLineEntryPanel.slfSpecialFunctions.getText().startsWith(TsoConstant.MESSAGE)) {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
returnComponent = invoiceLineEntryPanel.fldNote;
} else if (invoiceLineEntryPanel.slfSpecialFunctions.getText().startsWith(TsoConstant.CHANGE_CUSTOMER)) {
if ((CustomerBL.isNapaOnlineCustomer(customerVO)
&& invoiceVO.getLineItems() != null && !invoiceVO.getLineItems().isEmpty())) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = (JComponent)
getInvoicePanel().getCustomerComboBox().getEditor().getEditorComponent();
}
} else if (invoiceLineEntryPanel.slfSpecialFunctions.getText().startsWith(TsoConstant.PICK_UP)) {
//if it is phone room not considering buyout setting value
if(clientApplicationContext.isLoggedInAsPhoneRoom()){
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
} else {
if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getStoreProfile()
.getBuyoutPickupPOInUse().booleanValue()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
if (lineItemHandler != null) {
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
}
}
} else if (getInvoicePanel().getEmployeeField().getText().equals("")) {
if (invoiceVO.getManualTransaction().booleanValue()) {
returnComponent = getInvoicePanel().getInvoiceDateField();
} else {
returnComponent = getInvoicePanel().getEmployeeField();
}
} else if (((JTextField) getInvoicePanel().getCustomerComboBox().getEditor().
getEditorComponent()).getText().equals("")) {
if (invoiceVO.getManualTransaction().booleanValue()) {
returnComponent = getInvoicePanel().getInvoiceDateField();
} else {
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
if (getCashierPanel() == null) {
return null;
} else {
returnComponent = getCashierPanel().getFldID();
}
} else if (clientApplicationContext.getPOSState().getState()
== POSStateVO.INVOICING_AS_CASHIER) {
returnComponent = getInvoicePanel().getEmployeeField();
} else if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
returnComponent = getInvoicePanel().getStoreComboBox();
} else {
returnComponent = (JComponent) getInvoicePanel().getCustomerComboBox().
getEditor().getEditorComponent();
}
}
} else {
if (lineItemHandler == null) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
returnComponent = lineItemHandler.getNextFocus(currentComponent);
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_FINALIZE_NAME)) {
if (invoiceVO.getManualTransaction().booleanValue()) {
if (invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
returnComponent = (JComponent) getInvoicePanel().getInvoiceDateField();
}
} else if ((clientApplicationContext.isLoggedInAsSales()
|| clientApplicationContext.getPOSState().getState()
== POSStateVO.INVOICING_AS_CASHIER)
&& getInvoicePanel().getEmployeeField().isEnabled()) {
if (getInvoicePanel().getResizePanel().getHidden()) {
getInvoicePanel().getResizePanel().togglePanel();
}
returnComponent = (JComponent) getInvoicePanel().getEmployeeField();
} else {
if (invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else {
if (getInvoicePanel().getResizePanel().getHidden()) {
getInvoicePanel().getResizePanel().togglePanel();
}
if (invoiceVO.getManualTransaction().booleanValue()) {
returnComponent = (JComponent)
getInvoicePanel().getInvoiceDateField();
} else {
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
returnComponent = getCashierPanel().getFldID();
} else if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
getInvoicePanel().getStoreComboBox().setEnabled(true);
returnComponent = (JComponent) getInvoicePanel().getStoreComboBox();
} else {
returnComponent = (JComponent) getInvoicePanel().getCustomerComboBox(
).getEditor().getEditorComponent();
}
}
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_DELETE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_STOCK_CHECK)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SOURCE_OPTION)) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_CHECK_OTHER_STORES)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_RETURN_AUTH_NUM)) {
if (invoiceLineEntryPanel.fldNapaTotalCredit.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldNapaTotalCredit;
} else {
returnComponent = invoiceLineEntryPanel.fldNapaReturnAuthNum;
}
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_INVOICE_NOTE_NAME)) {
if (transferFocusForward) {
if (invoiceLineEntryPanel.fldNote.getText() == null
|| invoiceLineEntryPanel.fldNote.getText().trim().equals("")) {
returnComponent = invoiceLineEntryPanel.fldNote;
} else { // Modified for RGN:Invoicing
if (invoiceLineEntryPanel.lblClaimFormNumber.isVisible()) {
returnComponent = invoiceLineEntryPanel.fldClaimFormNumber;
} else {
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true);
invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(false);
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
this.resetSpecialFunctions(0, true);
}
} else {
invoiceLineEntryPanel.fldNote.setText("");
this.resetSpecialFunctions(0, true);
returnComponent = invoiceLineEntryPanel.slfSpecialFunctions;
clientApplicationContext.getPointOfSaleEventDispatcher().fireListItemCleared(new PointOfSaleListEvent(this, invoiceLineItemVO));
}
}
// Added for RGN:Invoicing
else if (componentName.equals(InvoiceLineEntryPanel.FLD_CLAIM_FORM_NUMBER_NAME)) {
if (transferFocusForward) {
if (invoiceLineEntryPanel.fldClaimFormNumber.getText() == null
|| invoiceLineEntryPanel.fldClaimFormNumber.getText().trim().equals("")) {
returnComponent = invoiceLineEntryPanel.fldClaimFormNumber;
} else {
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true);
invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(false);
returnComponent = invoiceLineEntryPanel.fldPartNumber;
this.resetSpecialFunctions(0, true);
}
} else {
invoiceLineEntryPanel.fldClaimFormNumber.setText("");
this.resetSpecialFunctions(0, true);
returnComponent = invoiceLineEntryPanel.fldNote;
clientApplicationContext.getPointOfSaleEventDispatcher().fireListItemCleared(new PointOfSaleListEvent(this, invoiceLineItemVO));
}
}
// ==============================
else if (componentName.equals(InvoiceLineEntryPanel.FLD_NAPA_TOTAL_CREDIT)) {
if (invoiceLineEntryPanel.fldNapaTotalCredit.getText() != null
&& !invoiceLineEntryPanel.fldNapaTotalCredit.getText().equals("")) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true);
invoiceLineEntryPanel.pnlFunctions.setVisible(true);
invoiceLineEntryPanel.pnlNapaOnline.setVisible(false);
} else {
returnComponent = invoiceLineEntryPanel.fldNapaTotalCredit;
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_SUPERSEDE_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_BARCODE_NAME)) {
if (invoiceLineEntryPanel.fldQuantity.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (invoiceLineEntryPanel.fldDescription.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldDescription;
} else if (invoiceLineEntryPanel.slfLine.isEnabled()) {
returnComponent = invoiceLineEntryPanel.slfLine;
} else if (invoiceLineEntryPanel.fldYN.isVisible()
&& invoiceLineEntryPanel.fldYN.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldYN;
} else {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_PART_INFO_NAME)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else if (componentName.equals(InvoiceLineEntryPanel.FLD_YN_NAME)) {
//add if transfer focus is forward or backward
if (invoiceLineEntryPanel.fldYN.getText().equals("N")
|| invoiceLineEntryPanel.fldYN.getText().trim().equals("")) {
returnComponent = invoiceLineEntryPanel.fldPartNumber;
} else if (invoiceLineEntryPanel.fldYN.getText().equals("Y")) {
if (invoiceLineEntryPanel.fldQuantity.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
} else {
returnComponent = invoiceLineEntryPanel.fldDescription;
}
}
} else if (componentName.equals(InvoiceLineEntryPanel.BTN_OTHER_STORES)) {
returnComponent = invoiceLineEntryPanel.fldQuantity;
}
if (returnComponent != null &&
(returnComponent == invoiceLineEntryPanel.slfSpecialFunctions
|| returnComponent.getName().equals(InvoicePanel.FLD_EMPLOYEE_NUM)
|| returnComponent.getName().equals(InvoicePanel.FLD_INVOICE_DATE)
|| returnComponent == invoiceLineEntryPanel.fldPartNumber
|| returnComponent == invoiceLineEntryPanel.fldNapaTotalCredit
|| returnComponent.getName().equals(InvoicePanel.CB_CUSTOMER_NAME)
|| returnComponent.getName().equals(InvoicePanel.CB_STORE))) {
pointOfSaleEventDispatcher.fireListSetEnabledInvoked(
new PointOfSaleListEvent(this, invoiceLineItemVO, true));
} else {
if (clientApplicationContext.getPOSState().getState() != POSStateVO.CASHIER) {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
pointOfSaleEventDispatcher.fireListSetEnabledInvoked(
new PointOfSaleListEvent(this, invoiceLineItemVO, false));
}
}
if (transferFocusForward
&& (!currentComponent.equals(invoiceLineEntryPanel.fldOK)
&& !invoiceLineEntryPanel.fldOK.getText().equals(""))){
if (returnComponent.equals(invoiceLineEntryPanel.fldTax)) {
if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldSecondaryTax;
} else if (invoiceLineEntryPanel.fldOK.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldOK;
}
}
if (returnComponent.equals(invoiceLineEntryPanel.fldSecondaryTax)) {
if (invoiceLineEntryPanel.fldOK.isEnabled()) {
returnComponent = invoiceLineEntryPanel.fldOK;
}
}
}
if(!transferFocusForward && returnComponent == invoiceLineEntryPanel.fldPartNumber){
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
return returnComponent;
}
private JComponent determineFirstEnabledField() {
int componentCount = invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponentCount() - 8;
for (int i = 1; i < componentCount; i = i + 2) {
Component component = invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponent(i);
if (component.isEnabled()) {
return (JComponent) component;
}
}
return null;
}
public JComponent getNextFocus(JComponent currentComponent) {
return lineItemHandler.getNextFocus(currentComponent);
}
public void setPartNumberEnabled(boolean partNumberEnabled) {
changeBtnFinalizeName();
logger.debug("===> partNumberEnabled = " +partNumberEnabled);
invoiceLineEntryPanel.lblPartNumber.setEnabled(partNumberEnabled);
invoiceLineEntryPanel.fldPartNumber.setEnabled(partNumberEnabled);
}
private void deleteInvoiceLineItem(final boolean deletedOutsideTAMS) {
boolean response = true;
boolean isNOL = false;
boolean isCDF = false;
if(!deletedOutsideTAMS){
String message = "1218";
if (baseLineItemVO != null) {
//Added for CDF line
if(baseLineItemVO.getRefInvoiceLineItemTypeID() != null
&& baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue() == RefInvoiceLineItemType.COLORADO_DELIVERY_FEE) {
isCDF = true;
}
if(baseLineItemVO.getSpecialOrder() != null && baseLineItemVO.getSpecialOrder().equals(
TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED)
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10080");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,new KeyEvent(
invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
}
});
return;
}
if (baseLineItemVO.isUsedForReturn()) {
if (!baseLineItemVO.isCoreTransaction().booleanValue()) {
message = "2255";
} else if (baseLineItemVO.isCoreTransaction().booleanValue()
&& baseLineItemVO.getQuantityBilled().signum() > 0) {
message = "8012";
}
}
if (InvoiceBL.isBarcodedNAPAGiftCardReturnItem(baseLineItemVO)) {
// Release Barcoded Gift Card Return Item Hold Amount
final GiftCardResponse giftCardResponse = GiftCardBL.giftCardCashPayoutHoldReversal(
baseLineItemVO.getGiftCardTransactionReferenceId());
logger.debug("Gift Card Cash Payout Hold Reversal Service Response = "
+ giftCardResponse);
}
}
response = clientApplicationContext.getMessageMgr().showMessageYesNo(invoiceLineEntryPanel, message);
}
if (response) {
// Added for RADS - Main Counter
// Create Discrepancy Report with discrepancy type as PICKED_BY_RADS_ITEM_DELETED
int locationId = (invoiceVO.getLOC() != null) ? invoiceVO.getLOC().intValue() : 1;
int lineItemSize = (invoiceVO.getLineItems() != null) ? invoiceVO
.getLineItems().size() : 0;
SalesOrderVO salesOrderVo = null;
if(isCDF) {
invoiceVO.setCoroladoFeeLineAdded(false);
}
try{
if (invoiceVO != null && invoiceVO.getSalesOrderVO() != null) {
salesOrderVo = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
if (salesOrderVo != null && salesOrderVo.getRefOrderSubTypeId() != null) {
if (salesOrderVo.getRefOrderSubTypeId().intValue() == RefNOLOrderType.ROL|| salesOrderVo.getRefOrderSubTypeId().intValue() == RefNOLOrderType.BOPIS) {
isNOL = true;
}
}
}
}catch(ApplicationException ae){
logger.error(ae.toString(), ae);
}
List radsDiscrepancyLogList = new ArrayList();
logger.debug("Building Rads Discrepancy Log");
if (baseLineItemVO != null) {
if (baseLineItemVO.isKitPart()
&& baseLineItemVO.getGeneratedByLineItem() == null
&& InvoiceBL.isKitPartPickedByRads(invoiceVO, baseLineItemVO)) {
for (int i = 0; i < lineItemSize; i++) {
Object object = invoiceVO.getLineItems().get(i);
if (object instanceof KitLineItemVO) {
KitLineItemVO kitLineItem = (KitLineItemVO) object;
if (kitLineItem.getPickedByRads() != null
&& kitLineItem.getPickedByRads().booleanValue()
&& baseLineItemVO.getSequence() != null
&& kitLineItem.getGeneratedBySequence().intValue() == baseLineItemVO
.getSequence().intValue()) {
InvoiceBL.createRadsDiscrepancyLogList(locationId, kitLineItem,
radsDiscrepancyLogList,
RefRadsDiscrepancyType.PICKED_BY_RADS_ITEM_DELETED);
}
}
}
} else if (!baseLineItemVO.isKitPart()) {
InvoiceBL.createRadsDiscrepancyLogList(locationId, baseLineItemVO,
radsDiscrepancyLogList,
RefRadsDiscrepancyType.PICKED_BY_RADS_ITEM_DELETED);
}
}
// =========Parts of Bopis order not deleted outside from tams
if(isNOL && !deletedOutsideTAMS){
if(lineItemSize ==1){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (baseLineItemVO != null && baseLineItemVO.isUsedForReturn()
&& baseLineItemVO.isCoreTransaction().booleanValue()
&& baseLineItemVO.getQuantityBilled().doubleValue() < 0) {
PointOfSaleEventDispatcher.getInstance()
.fireDetachCoreLineItemFromPart(new PointOfSaleListEvent(this, invoiceVO));
}
PointOfSaleEventDispatcher.getInstance()
.fireInvoiceLineItemDeleteInvoked(new PointOfSaleListEvent(this, invoiceVO));
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions.sequenceLines(invoiceVO.getLineItems());
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel,
"10143");
return;
}
}
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,new KeyEvent(
invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
invoiceLineEntryPanel.fldPartNumber.grabFocus();
isFromDeleteBtn = true;
invoiceLineEntryPanel.slfSpecialFunctions.setText(TsoConstant.CANCEL_INVOICE);
processSpecialFunctionSelection();
isFromDeleteBtn = false;
}
}
});
}else {
if(checkIfLastLine(lineItemSize)){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (baseLineItemVO != null && baseLineItemVO.isUsedForReturn()
&& baseLineItemVO.isCoreTransaction().booleanValue()
&& baseLineItemVO.getQuantityBilled().doubleValue() < 0) {
PointOfSaleEventDispatcher.getInstance()
.fireDetachCoreLineItemFromPart(new PointOfSaleListEvent(this, invoiceVO));
}
PointOfSaleEventDispatcher.getInstance()
.fireInvoiceLineItemDeleteInvoked(new PointOfSaleListEvent(this, invoiceVO));
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions.sequenceLines(invoiceVO.getLineItems());
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel,
"10143");
return;
}
}
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,new KeyEvent(
invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
invoiceLineEntryPanel.fldPartNumber.grabFocus();
isFromDeleteBtn = true;
invoiceLineEntryPanel.slfSpecialFunctions.setText(TsoConstant.CANCEL_INVOICE);
processSpecialFunctionSelection();
isFromDeleteBtn = false;
}
}
});
}
else{
if (baseLineItemVO != null && baseLineItemVO.isUsedForReturn()
&& baseLineItemVO.isCoreTransaction().booleanValue()
&& baseLineItemVO.getQuantityBilled().doubleValue() < 0) {
PointOfSaleEventDispatcher.getInstance()
.fireDetachCoreLineItemFromPart(new PointOfSaleListEvent(this, invoiceVO));
}
PointOfSaleEventDispatcher.getInstance()
.fireInvoiceLineItemDeleteInvoked(new PointOfSaleListEvent(this, invoiceVO));
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,new KeyEvent(
invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
}
}
}else if(invoiceVO.isReturnInvoice() && !invoiceVO.isReturnInvoiceLoaded()) {
if(null != lineItemHandler && lineItemHandler instanceof DefaultLineItemHandler) {
lineItemHandler.skipDeletedPartReturn(baseLineItemVO, invoiceVO);
}
}else{
if (baseLineItemVO != null && baseLineItemVO.isUsedForReturn()
&& baseLineItemVO.isCoreTransaction().booleanValue()
&& baseLineItemVO.getQuantityBilled().doubleValue() < 0) {
PointOfSaleEventDispatcher.getInstance()
.fireDetachCoreLineItemFromPart(new PointOfSaleListEvent(this, invoiceVO));
}
PointOfSaleEventDispatcher.getInstance()
.fireInvoiceLineItemDeleteInvoked(new PointOfSaleListEvent(this, invoiceVO));
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,
new KeyEvent(invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED, new Date().getTime(), 0,
KeyEvent.VK_TAB, '\t'));
}
// Added for RADS - Main Counter
/*
* Add the rads discrepancy for deleted items to InvoiceVo. Do not create the
* discrepancy in database until Invoice is saved or finalized.
*/
if (radsDiscrepancyLogList != null && radsDiscrepancyLogList.size() > 0) {
logger
.debug("Create discrepancy log and add it to Invoice Vo for Deleted Line items");
if (invoiceVO != null) {
if (invoiceVO.getRadsDiscrepancyLogList() != null) {
invoiceVO.getRadsDiscrepancyLogList().addAll(radsDiscrepancyLogList);
} else {
invoiceVO.setRadsDiscrepancyLogList(radsDiscrepancyLogList);
}
}
}
// ====================================
}
pointOfSaleEventDispatcher.getInstance().fireTamsIsReady(new CartEvent(this));
}
private boolean checkIfLastLine(int lineCount){
boolean isLastLine = false;
int baseLineitemCount =0;
int genByLineItm =0;
boolean checkMessageFld = invoiceLineEntryPanel.fldNote.isEnabled();
for(int j=0; j phoneRoomStoreVOlist = stores;
String ipAddress = null;
for(int i=0;i"
+ clientApplicationContext.isLoggedInAsPhoneRoom());
verifyTaxDecision();
final boolean npxApprovalRequired = checkForNxpApproval();
final Boolean[] responseApproveNoCancel = new Boolean[1];
if (npxApprovalRequired) {
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
isMessageSet = false;
responseApproveNoCancel[0] = ClientApplicationContext.getClientApplicationContext()
.getMessageMgr()
.showMessageApproveSaveCancel(invoiceLineEntryPanel, "9972");
invoiceLineEntryPanel.fldPartNumber.requestFocus();
} else {
responseApproveNoCancel[0] = ClientApplicationContext.getClientApplicationContext()
.getMessageMgr().showMessageApproveNoCancel(invoiceLineEntryPanel, "9972");
}
//handle Bopis-RADS failure
if(isBopisRADSOrderFailed && responseApproveNoCancel[0].booleanValue() == true) {
makeInvoiceLinesNXPEligible(invoiceVO);
}
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (processNxpApprovalResponse(npxApprovalRequired, responseApproveNoCancel[0])) {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
if(continueWithUnfulfilledItemsThroughNAPAXpress()){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (checkForManuallyEnteredTaxNumber()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (enterWorkOrderInformation()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (checkForEJOEI()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (checkInterStoreOrders()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if(saveDirectShipItems(false)) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
openCheckoutScreen();
}
});
}
}
});
}
}
});
}
}
});
}
}
});
}
}
});
} else {
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
}
});
}
}
});
}
/**
* This method checks if any items could not be fulfilled through NAPA Xpress.
* If yes, we give counter person option, he can choose to go ahead with unfulfilled item(s) or
* he can go back to POS line entry and review those item(s).
* @return
*/
private boolean continueWithUnfulfilledItemsThroughNAPAXpress(){
for (int lineIndex = 0; lineIndex < invoiceVO.getLineItems().size(); lineIndex++) {
final InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(lineIndex);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
final BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if (TsoConstant.MANUAL.equals(baseLineItemVO.getSpecialOrder())) {
return ClientApplicationContext.getClientApplicationContext().getMessageMgr().showMessageYesNo(invoiceLineEntryPanel, "1179");
}
}
}
return true;
}
/**
* This method is used to check whether the special order items are approved or not.
* @return boolean
*/
private boolean checkForNxpApproval() {
if(invoiceVO.getManualTransaction().booleanValue()) {
return false;
}
final int noOfLines = invoiceVO.getLineItems().size();
boolean npxApprovalRequired = false;
StoreProfileVO storeProfile = null;
String remoteStoreIP = null;
PhoneRoomTaapRouter phoneRoomTaapRouter = new PhoneRoomTaapRouter();
//Stel -751
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
storeProfile = ApplicationContext.getInstance().getProfile(
Profile.SERVER, invoiceVO.getLOC().intValue()).getStoreProfile();
} else {
String storeNum = invoiceVO.getRemoteStoreNumber();
try {
remoteStoreIP = getRemoteIpAddress(storeNum);
} catch (ApplicationException e) {
//throw new RuntimeException(e);
logger.error("Unable to fetch the ip Address for the store :"+storeNum);
}
if(remoteStoreIP != null) {
storeProfile = phoneRoomTaapRouter.getStoreProfile(remoteStoreIP);
}
}
try {
if(invoiceVO.getSavedDate() != null && invoiceVO.getSalesOrderVO() != null) {
String poNumber = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
poNumber = clientApplicationContext.getOrderingDAO()
.getFulFillmentPoNumberBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
loc.intValue());
} else {
poNumber = phoneRoomTaapRouter.getFulfillmentBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),remoteStoreIP,loc.intValue());
}
if (storeProfile.getUseNapaXpress().booleanValue() && poNumber == null) {
for (int i = 0; i < noOfLines; i++) {
final InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(i);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if(TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
npxApprovalRequired = true;
break;
}
}
}
}
} else {
for (int i = 0; i < noOfLines; i++) {
final InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(i);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if (TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
npxApprovalRequired = true;
break;
}
}
}
}
} catch (ApplicationException applicationException) {
logger.error(applicationException.toString(), applicationException);
npxApprovalRequired = false;
}
return npxApprovalRequired;
}
/**
* This method processes the NXP item approval response from user as per below.
* 1)Approve
* a. Punch out to NAPA Xpress and display "Approve special order" page.
* b. After approval navigate user back to line item entry screen
* c. If user clicks "Checkout" proceed to "Checkout" screen without displaying any modal.
* 2)No, Split invoice
* a. Launch split invoice screen , with local and special order items are separated in default view.
* 3)Cancel
* a. Navigate user back to line item entry screen.
*
* @param boolean
* @param Boolean
* @return boolean
*/
private boolean processNxpApprovalResponse(final boolean npxApprovalRequired,
final Boolean responseApproveNoCancel) {
if(!npxApprovalRequired) {
return true;
}
if(responseApproveNoCancel == null) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
return false;
} else if(responseApproveNoCancel.booleanValue() == true) {
final SessionData sessionData = SessionFactory.createSession(invoiceVO, customerVO, SessionFactory.NAPA_XPRESS);
final StringBuffer sb = new StringBuffer();
final Properties properties = ClientApplicationContext.getInstance().getSystemConfig().getSystemConfiguration(SystemConfig.APPLICATION);
final String nxpPunchoutUrn = properties.getProperty(ClientPropConstants.NXP_PUNCHOUT_URN);
try {
sb.append(clientApplicationContext.getSystemDAO().getNapaXpressPunchoutURL());
sb.append(nxpPunchoutUrn);
sb.append(sessionData.toUrlParams());
BrowserLauncher.launch(CommonUtil.getSunURL(sb.toString()));
} catch (MalformedURLException me) {
logger.error(me.getMessage(), me);
} catch (ApplicationException ae) {
logger.error(ae.getMessage(), ae);
}
return false;
} else if(responseApproveNoCancel.booleanValue() == false) {
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
invoiceLineEntryPanel.slfSpecialFunctions.setText(TsoConstant.SAVE_INVOICE);
processSpecialFunctionSelection();
return false;
} else {
checkoutLaterController.setInitialData(separateNxpItems((InvoiceVO)invoiceVO.clone()));
if ((invoiceVO.getLineItems() != null && invoiceVO.getLineItems().isEmpty())
|| checkoutLaterController.getModel() == null || InvoiceBL.hasSpecialOrderItem(invoiceVO)) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
return false;
}
}
}
return true;
}
/**
* This method separates the special order items and normal items to be displayed in
* checkout later screen.
*
* @param InvoiceVO
* @return InvoiceVO
*/
private InvoiceVO separateNxpItems(final InvoiceVO invoiceVO) {
final Vector lineItems = invoiceVO.getLineItems();
final Vector nxpLineItems = new Vector();
final Vector localLineItems = new Vector();
final int noOfLines = lineItems.size();
for (int i = 0; i < noOfLines; i++) {
final InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.get(i);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if (TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) {
nxpLineItems.add(invoiceLineItemVO);
} else if (baseLineItemVO.getGeneratedByLineItem() != null
&& baseLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO
&& TsoConstant.NAPA_XPRESS.equals(((BaseLineItemVO) baseLineItemVO
.getGeneratedByLineItem()).getSpecialOrder())) {
nxpLineItems.add(invoiceLineItemVO);
} else {
localLineItems.add(invoiceLineItemVO);
}
} else if(invoiceLineItemVO instanceof InvoiceNoteVO){
if(invoiceLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO &&
TsoConstant.NAPA_XPRESS.equals(((BaseLineItemVO) invoiceLineItemVO.getGeneratedByLineItem()).getSpecialOrder())){
nxpLineItems.add(invoiceLineItemVO);
} else {
localLineItems.add(invoiceLineItemVO);
}
}
}
invoiceVO.setLineItems(localLineItems);
final InvoiceVO savedInvoiceVO = (InvoiceVO)invoiceVO.clone();
if(savedInvoiceVO.getSavedCart() != null) {
final Vector currentSavedCartItems = savedInvoiceVO.getSavedCart().getLineItems();
currentSavedCartItems.addAll(nxpLineItems);
savedInvoiceVO.setLineItems(currentSavedCartItems);
} else {
savedInvoiceVO.setLineItems(nxpLineItems);
}
savedInvoiceVO.setAttention(getAttentionFromPOSAttentionField());
invoiceVO.setSavedCart(savedInvoiceVO);
return invoiceVO;
}
/**
* Opens Work Order Information pop up to enter work order number and unit number.
*
* @return boolean
*/
private boolean enterWorkOrderInformation() {
String remoteStoreIp = null;
if(clientApplicationContext.isLoggedInAsPhoneRoom()){
try {
remoteStoreIp = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
} catch (ApplicationException e) {
//throw new RuntimeException(e);
logger.error("Unable to fetch store ip in enterWorkOrderInformation method :");
}
}
if (CustomerBL.isIbsAccount(customerVO,remoteStoreIp)) {
workOrderController.setInitialData(invoiceVO);
workOrderController.setViewVisible(true);
if (workOrderController.isCancelled()) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
return false;
}
}
return true;
}
private boolean checkForManuallyEnteredTaxNumber() {
InvoicingProfileVO invoicingProfileVO = null;
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) {
String remoteIpAddress = null;
try {
remoteIpAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
} catch (ApplicationException e) {
logger.error("Unable to fetch store ip address " + e.getMessage());
}
invoicingProfileVO = remoteIpAddress != null ? taapRouter.getInvoicingProfile(remoteIpAddress) : null;
} else {
invoicingProfileVO = getInvoicingProfile();
}
if (invoicingProfileVO!=null && invoicingProfileVO.getEnableCoreReturnLaw().booleanValue()) {
boolean taxNumberEnteredManually = false;
String primaryTaxNumber = invoicePanel.getPrimaryTaxNum().getText();
if(StringUtils.isNotEmpty(primaryTaxNumber)) {
taxNumberEnteredManually = true;
}
String secondaryTaxNumber = invoicePanel.getSecondaryTaxNum().getText();
if(!taxNumberEnteredManually && StringUtils.isNotEmpty(secondaryTaxNumber)) {
taxNumberEnteredManually = true;
}
if(!taxNumberEnteredManually) {
if(invoiceVO.getSavedInvoiceIdForDeletion() != null
&& invoiceVO.getCustomerTaxVO() != null
&& (StringUtils.isNotEmpty(primaryTaxNumber)
|| StringUtils.isNotEmpty(secondaryTaxNumber))) {
taxNumberEnteredManually = true;
}
}
//Tax Number entered manually.
if (!taxNumberEnteredManually) {
invoiceVO.setCustomerTaxVO(null);
}
if (taxNumberEnteredManually && InvoiceBL.doReturnCoreExist(invoiceVO)) {
customerTaxInfoController.setInitialData(invoiceVO);
customerTaxInfoController.setViewVisible(true);
} else {
invoiceVO.setCustomerTaxVO(null);
}
logger.debug("Cancelled>>>" + customerTaxInfoController.isProcessCancelled());
if (customerTaxInfoController.isProcessCancelled()) {
//Resetting isProcessCancelled variable
customerTaxInfoController.setProcessCancelled(false);
return false;
}
}
return true;
}
/**
* Checks if any EJOEI orders exists or not. If EJOEI order exists, then EJOEI order
* screen will be displayed.
*
* @return true, if successful
*/
private boolean checkForEJOEI() {
// If logged in as Phone room then only check for Ejoei initial data
if (phoneRoomEjoeiController.setInitialData(invoiceVO, customerVO)) {
phoneRoomEjoeiController.setViewVisible(true);
}
// Check whether ESC clicked without ordering part on Ejoei screen
if (phoneRoomEjoeiController.isProcessCancelled) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
return false;
}
return true;
}
/**
* Checks if any interstore orders exists or not. If interstore order exists, then interstore
* order screen will be displayed.
*
* @return true, if successful
*/
private boolean checkInterStoreOrders() {
// If logged in as Phone room then only check for inter-store initial data
if (phoneRoomInterStoreController.setInitialData(invoiceVO, customerVO)) {
fireStopTimer();
phoneRoomInterStoreController.setViewVisible(true);
fireStartTimer();
}
// Check whether ESC clicked without ordering part on inter-store screen
if (phoneRoomInterStoreController.isProcessCancelled) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
return false;
}
return true;
}
/**
* Displays old or new version of checkout screen based on system settings. If employee logged
* in as phone room user or INVOICE_CHECKOUT_VERSION setting is enabled, then new checkout
* screen is displayed else old checkout screen is displayed.
*
*/
private void openCheckoutScreen() {
final String methodSpec = "InvoiceLineEntryController.openCheckoutScreen - ";
logger.debug(methodSpec);
//set attention from POS
invoiceVO.setAttention(getAttentionFromPOSAttentionField());
if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
setCSGRestrictedReturnInvoicePONumber();
}
if (invoiceController != null) {
final SessionData sessionData = SessionFactory.createSession(invoiceVO, customerVO, SessionFactory.PPSE2);
if (sessionData.getVersion() == SessionData.PPSE2_REGULAR){
invoiceController.stopPartsProSe2Timer();
}
}
String remoteIpAddress = null;
try {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
customerDeliveryVO = clientApplicationContext.getCustomerDAO().getCustomerDelivery(loc, customerVO.getID(), customerVO.getCustomerTypeCD());
} else {
remoteIpAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
customerDeliveryVO = phoneRoomTaapRouter.getCustomerDeliveryVOPR(loc, customerVO.getCustomerTypeCD(), customerVO.getID().toString(),remoteIpAddress); }
} catch (ApplicationException ae) {
logger.error( ae.toString(), ae );
//clientApplicationContext.getMessageMgr().showMessage( finalizeDialog, ae.getUserMessageID(), ae.getUserMessageParameters() );
logger.error( "Error from TAMS Service programs. Operation did not complete. Please Contact TAMS Support. Service Error = " + ae.getUserMessageID() );
}
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
isOptionalDeliveryFlag = clientApplicationContext.getProfile(
Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).
getInvoicingProfile().getRequireDeliverySelection().booleanValue();
} else {
isOptionalDeliveryFlag = taapRouter.getInvoicingProfile(remoteIpAddress).getRequireDeliverySelection().booleanValue();
}
logger.debug("isOptionalDeliveryFlag in Line entry panel --- > "+isOptionalDeliveryFlag);
if (!ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()
&& invoiceVO.getRemoteStoreNumber() == null) {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
invoiceVO.setRemoteStoreNumber(clientApplicationContext.getProfile(
Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation())
.getStoreProfile().getStoreNum());
} else {
invoiceVO.setRemoteStoreNumber(phoneRoomTaapRouter.getStoreProfile(remoteIpAddress).getStoreNum());
}
}
if (showCheckoutScreenForRemoteInvoicing()) {
finalizeInvoiceController.removeBusinessListeners();
finalizeNonPhoneRoomInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.removeBusinessListeners();
finalizePhoneRoomInvoiceController.installBusinessListeners();
if (!finalizePhoneRoomInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
fireStopTimer();
finalizePhoneRoomInvoiceController.setViewVisible(true);
fireStartTimer();
} else if(showInvoiceCheckoutVersionScreen()) {
finalizeInvoiceController.removeBusinessListeners();
finalizePhoneRoomInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.removeBusinessListeners();
finalizeNonPhoneRoomInvoiceController.installBusinessListeners();
if (!finalizeNonPhoneRoomInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
fireStopTimer();
finalizeNonPhoneRoomInvoiceController.setViewVisible(true);
fireStartTimer();
} else if (customerDeliveryVO != null &&
customerDeliveryVO.getDeliveryRefOptionCD().equalsIgnoreCase("O")
&& isOptionalDeliveryFlag) {
logger.debug("else in optional delivery controller normal invoice =======> ");
finalizeInvoiceController.removeBusinessListeners();
finalizePhoneRoomInvoiceController.removeBusinessListeners();
finalizeNonPhoneRoomInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.installBusinessListeners();
if (!finalizeOptionalDeliveryInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
fireStopTimer();
finalizeOptionalDeliveryInvoiceController.setViewVisible(true);
fireStartTimer();
} else {
finalizePhoneRoomInvoiceController.removeBusinessListeners();
finalizeNonPhoneRoomInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.removeBusinessListeners();
finalizeInvoiceController.removeBusinessListeners();
finalizeInvoiceController.installBusinessListeners();
if (!finalizeInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
fireStopTimer();
finalizeInvoiceController.setViewVisible(true);
fireStartTimer();
}
SwingUtilities.invokeLater(new Runnable(){
public void run() {
invoiceLineEntryPanel.btnFinalize.grabFocus();
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnFinalize,new KeyEvent(
invoiceLineEntryPanel.btnFinalize, KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_TAB, '\t'));
setInitialFocus();
}
});
}
private void setInitialFocus() {
logger.debug(" ENTER setInitialFocus () !" );
if (getInvoicePanel().getManualInvPanel().isVisible()) {
if (invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
} else {
getInvoicePanel().getInvoiceDateField().requestFocus();
}
} else {
if (getInvoicePanel().getEmployeeField().isEnabled()) {
getInvoicePanel().getEmployeeField().requestFocus();
} else {
if (!getInvoicePanel().getCustomerComboBox().isEnabled()) {
getInvoicePanel().getCustomerComboBox().setEnabled(true);
getInvoicePanel().getCustomerComboBox().setEditable(true);
getInvoicePanel().getSearchButton().setEnabled(true);
}
if (clientApplicationContext.isLoggedInAsPhoneRoom()
&& getInvoicePanel().getStoreComboBox().isEnabled()) {
getInvoicePanel().getStoreComboBox().requestFocus();
}
}
}
}
/**
* Show remote checkout screen if logged in as phone room user.
*
* @return true, if successful
*/
private boolean showCheckoutScreenForRemoteInvoicing() {
boolean displayRemoteCheckoutScreen = false;
// If logged in as phone room: show new checkout screen
if (ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()) {
displayRemoteCheckoutScreen = true;
}
return displayRemoteCheckoutScreen;
}
/**
* Show remote checkout screen.
*
* @param invoiceVO the invoice vo
* @return true, if successful
*/
private boolean showInvoiceCheckoutVersionScreen() {
boolean displayCheckoutVersionScreen = false;
// If invoice checkout screen is set: show new checkout screen
final Profile profile = ClientApplicationContext.getClientApplicationContext().getProfile(
Profile.POINT_OF_SALE_CLIENT,
ClientApplicationContext.getClientApplicationContext().getLocation());
final LockableBoolean invoiceCheckoutVersion =
profile.getInvoicingProfile().getInvoiceCheckoutVersion();
if (invoiceCheckoutVersion != null && invoiceCheckoutVersion.booleanValue()) {
displayCheckoutVersionScreen = true;
}
return displayCheckoutVersionScreen;
}
private void processSpecialFunctionSelection() {
final String methodSpec = "InvoiceLineEntryController.processSpecialFunctionSelection - ";
logger.debug(methodSpec);
String selectedItem = invoiceLineEntryPanel.slfSpecialFunctions.getText();
if (invoiceLineEntryPanel.slfSpecialFunctions.getSelectedRow() == 0) {
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
if (invoiceLineEntryPanel.slfSpecialFunctions.getSelectedRow() == -1) {
try {
int sequence = Integer.parseInt(selectedItem) - 1;
if ((sequence > -1) && (sequence < invoiceVO.getLineItems().size())) {
PointOfSaleEventDispatcher.getInstance().fireListItemSelected(
new PointOfSaleListEvent(this, null, sequence));
} else {
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
} catch (NumberFormatException nfe) {
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
} else {
if (selectedItem.startsWith(TsoConstant.CANCEL_INVOICE)) {
boolean isNxpInterstoreInvoice = InvoiceBL.doesInvoiceContainNXPInterStoreOrder(invoiceVO);
if(isNxpInterstoreInvoice){
try{
boolean isCancelInvoice = true;
if(invoiceVO != null && invoiceVO.isPhoneRoomMessagesFlag()) {
String remoteIpAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
phoneRoomTaapRouter.sendNXPInterstoreUpdateSalesOrderRequestForPhoneRoom(invoiceVO,
remoteIpAddress,isCancelInvoice);
}else {
sendNXPInterstoreUpdateSalesOrderRequest(invoiceVO, isCancelInvoice);
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
} catch(Throwable e) {
logger.error("Error in sending interstore update sales order..");
}
}
if (GiftCardBL.doesInvoiceContainBarcodedNAPAGiftCardReturnItem(invoiceVO)) {
logger.debug(methodSpec + " Cash Payout HOLD amount reversal ");
GiftCardBL.releaseBarcodedNAPAGiftCardReturnItemHoldAmount(invoiceVO);
}
boolean isNOL = false;
SalesOrderVO salesOrderVo = null;
String remoteStoreIP = null;
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
try{
remoteStoreIP = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());}
catch (ApplicationException e) {
logger.error("Error in getting remote store ip" ,e);
}
}
int lineItemCount = (invoiceVO.getLineItems() != null) ? invoiceVO
.getLineItems().size() : 0;
try{
if (invoiceVO != null && invoiceVO.getSalesOrderVO() != null) {
if(invoiceVO.isPhoneRoomMessagesFlag()){
salesOrderVo = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(),remoteStoreIP);
}else{
salesOrderVo = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
if (salesOrderVo != null && salesOrderVo.getRefOrderSubTypeId() != null) {
if (salesOrderVo.getRefOrderSubTypeId().intValue() == RefNOLOrderType.ROL|| salesOrderVo.getRefOrderSubTypeId().intValue() == RefNOLOrderType.BOPIS) {
isNOL = true;
}
}
}
}catch(ApplicationException ae){
logger.error(ae.toString(), ae);
} catch (IOException e) {
logger.error(e.toString(), e);
}
if(isNOL && !isFromDeleteBtn){
if(lineItemCount==1){
String remoteIP = remoteStoreIP;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
salesVO = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(), remoteIP);
}else{
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
logger.error(e.toString(), e);
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions
.sequenceLines(invoiceVO.getLineItems());
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
new TaapRouter().saveInvoice(invoiceVO, remoteIP);
}else{
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10143");
return;
}
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
}
}
});
}else if (isNOL && checkIfLastLine(lineItemCount)){
String finalRemoteStoreIP = remoteStoreIP;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
salesVO = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(), finalRemoteStoreIP);
}else{
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions
.sequenceLines(invoiceVO.getLineItems());
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
new TaapRouter().saveInvoice(invoiceVO,finalRemoteStoreIP);
}else
{
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10143");
return;
}
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
}
}
});
}else{
String remoteIP = remoteStoreIP;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
salesVO = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(), remoteIP);
}else{
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions
.sequenceLines(invoiceVO.getLineItems());
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
new TaapRouter().saveInvoice(invoiceVO,remoteIP);
}else
{
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10143");
return;
}
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
}
}
});
}
}else{
if((InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO)
|| (invoiceVO.getDirectShippedInvoice() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0))
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10080");
return;
}
/*
* Added for RADS: Retrieve the discrepancy list from Invoice VO this list contain
* the discrepancy added when user deletes a line item
*/
List radsDiscrepancyLogsFromInvoice = invoiceVO.getRadsDiscrepancyLogList();
boolean messageItemsExist = InvoiceLineBL.doMessageItemsExist(
invoiceVO.getLineItems());
boolean response = false;
if (messageItemsExist) {
response = clientApplicationContext.getMessageMgr().showMessageYesNo(
invoiceLineEntryPanel, "2217");
}
// Added for RADS - Main Counter
// Create Discrepancy Log for Canceled Invoice, if line items
// were picked by RADS.
Vector lineItems = invoiceVO.getLineItems();
int lineItemSize = 0;
int locationId = (invoiceVO.getLOC() != null) ? (invoiceVO.getLOC().intValue()) : 1;
List radsDiscrepancyLogList = new ArrayList();
if (lineItems != null) {
lineItemSize = lineItems.size();
}
for (int index = 0; index < lineItemSize; index++) {
Object object = lineItems.elementAt(index);
if (object instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItem = (BaseLineItemVO) object;
InvoiceBL.createRadsDiscrepancyLogList(locationId, baseLineItem,
radsDiscrepancyLogList, RefRadsDiscrepancyType.INVOICE_CANCELLED);
}
}
/*
* The discrepancy list from Invoice VO contain discrepancy for the deleted line items.
* Since the invoice is canceled the discrepancy should be of discrepancy type
* "Invoice Canceled" instead of "picked by line items deleted"
*/
int radsDiscrepancyLogsSize = (radsDiscrepancyLogsFromInvoice != null)
? radsDiscrepancyLogsFromInvoice.size() : 0;
for (int index = 0; index < radsDiscrepancyLogsSize; index++) {
Object object = radsDiscrepancyLogsFromInvoice.get(index);
if (object instanceof RadsDiscrepancyLog) {
RadsDiscrepancyLog radsDiscrepancyLog = (RadsDiscrepancyLog) object;
radsDiscrepancyLog
.setDiscrepancyType(RefRadsDiscrepancyType.INVOICE_CANCELLED);
}
}
// ================================================
if (!messageItemsExist || (messageItemsExist && !response)) {
if (invoiceVO.getSavedInvoiceIdForDeletion() != null) {
try {
if ((invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag())) {
new TaapRouter().deleteSavedInvoice(invoiceVO, Boolean.FALSE, remoteStoreIP);
} else {
clientApplicationContext.getInvoiceDAO().deleteSavedInvoice(invoiceVO, Boolean.FALSE);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
//delete error
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2228");
return;
}
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
} else {
if ((customerVO != null) && (customerVO.getCustomerNumber() != null)
&& (customerVO.getCustomerNumber().intValue() == 0)) {
String s = getAttention();
invoiceVO.setAttention(s);
}
InvoiceBL.closePpseSession((InvoiceVO) getModel());
SwingUtilities.invokeLater(new Runnable(){
public void run() {
try {
if (((InvoiceVO) getModel()).isPhoneRoomMessagesFlag()
?PhoneRoomInvoiceBL.saveInvoiceInServingStore((InvoiceVO) getModel(), customerVO,
invoiceLineEntryPanel)
:InvoiceBL.saveInvoice((InvoiceVO) getModel(), customerVO,
invoiceLineEntryPanel)) {
pointOfSaleEventDispatcher.fireInvoiceSaved(new InvoiceEvent(this,
new InvoiceVO()));
invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new
KeyEvent(invoiceLineEntryPanel.slfSpecialFunctions,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER,
'\n'));
setPartNumberEnabled(false);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2204");
return;
}
}
});
}
// ==================================
// Added for RADS - Main Counter
// Calling service method to create discrepancy log
if ((radsDiscrepancyLogsFromInvoice != null && radsDiscrepancyLogsFromInvoice
.size() > 0)
|| (radsDiscrepancyLogList != null && radsDiscrepancyLogList.size() > 0)) {
logger.debug("Call of service method to create discrepancy log");
try {
if (radsDiscrepancyLogsFromInvoice != null) {
if (radsDiscrepancyLogList == null) {
radsDiscrepancyLogList = new ArrayList();
}
radsDiscrepancyLogList.addAll(radsDiscrepancyLogsFromInvoice);
}
RadsServiceFactory.getServiceInstance().createRadsDiscrepancyLog(
radsDiscrepancyLogList);
} catch (ApplicationException e) {
logger
.error(
"Exception occurred while creating discrepancy log for cancelled invoice line item",
e);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"9039");
}
}
}
// ====================================
} else if (selectedItem.startsWith(TsoConstant.CHANGE_CUSTOMER)) {
pointOfSaleEventDispatcher.fireTamsIsBusy(new CartEvent(this));
if (CustomerBL.isNapaOnlineCustomer(customerVO)
&& (invoiceVO.getLineItems() != null) && !invoiceVO.getLineItems().isEmpty()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"439");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
} else if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10127");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
} else if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10201");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
} else if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, //if buyout po pu in use and required and is a pu item
clientApplicationContext.getLocation()).getStoreProfile()
.getBuyoutPickupPOInUse().booleanValue() &&
InvoiceBL.hasPickupItem(invoiceVO.getLineItems())) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"438");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
} else if((InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO)
|| (invoiceVO.getDirectShippedInvoice() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0))
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10082");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
} else if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getInvoicingProfile()
.getAskForItemReturnInfo().booleanValue()) {
Vector lineItems = invoiceVO.getLineItems();
for (int i = 0; i < lineItems.size(); i++) {
Object itemVO = lineItems.elementAt(i);
if (itemVO != null && itemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO)itemVO;
if ((baseLineItemVO.getReturnItems() != null && baseLineItemVO.getReturnItems().size() > 0)
|| (baseLineItemVO.getReturnCoreItems() != null
&& baseLineItemVO.getReturnCoreItems().size() > 0)) {
/*
* Coded added for Return Authorization to
* check if return core line item is associated with
* purchase part on the same invoice
*/
Iterator itemsIterator = baseLineItemVO
.getReturnItems().iterator();
while (itemsIterator.hasNext()) {
InvoiceLineItemReturnVO ilirVO = (InvoiceLineItemReturnVO) itemsIterator
.next();
if (ilirVO.getOriginalInvoiceNumber() != null
&& !baseLineItemVO
.isUsedForReturn()) {
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "2251");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
}
}
}
}
}
} else if (selectedItem.startsWith(TsoConstant.MESSAGE)) {
if (checkMaxInvoiceLinesReached(1)) {
return;
}
invoiceNoteVO = new InvoiceNoteVO();
lineItemHandler =
lineItemHandlerFactory.getHandlerFromSpecialFunctionCD(selectedItem,
invoiceLineEntryPanel, invoiceNoteVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
} else if(selectedItem.startsWith(TsoConstant.SPLIT_INVOICE)){
if(InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)){
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10126");
resetSpecialFunctions(0, true);
return;
}
if (invoiceVO.getSavedInvoiceIdForDeletion() != null
&& InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO)
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(
invoicePanel, "10084");
return;
}
InvoiceVO cloneInvoice = (InvoiceVO)invoiceVO.clone();
if (cloneInvoice.getSavedCart() != null) {
cloneInvoice.getSavedCart().setAttention(getAttentionFromPOSAttentionField());
} else {
cloneInvoice.setAttention(getAttentionFromPOSAttentionField());
}
checkoutLaterController.setInitialData(cloneInvoice);
} else if (selectedItem.startsWith(TsoConstant.POLICY_ADJUSTMENT)) {
clientApplicationContext.getPointOfSaleEventDispatcher().fireTamsIsBusy(new CartEvent(this));
// Counter person is restricted from adding any additional line items to invoice containing
// NOL Order
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10124");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
// Counter person is restricted from adding any additional line items to return invoice
if (invoiceVO.isReturnInvoice()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10308");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10202");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10212", originalInvoiceNumber);
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (clientApplicationContext.getSystemDAO().askForPassword(
PasswordConstants.POLICY_ADJ_PWD).booleanValue()) {
passwordController.setInitialData(PasswordConstants.POLICY_ADJ_PWD);
// To localize Policy Adjustment password dialog.
passwordController.localizeView();
passwordController.setViewVisible(true);
if (passwordController.getPasswordValid()) {
baseLineItemVO = new BaseLineItemVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.POLICY_ADJUSTMENT, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
} else {
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
clientApplicationContext.getPointOfSaleEventDispatcher().fireTamsIsReady(new CartEvent(this));
}
} else { //password not required
baseLineItemVO = new BaseLineItemVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.POLICY_ADJUSTMENT, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
}
} else if (selectedItem.startsWith(TsoConstant.PICK_UP)) {
boolean isCallCenterEnable = false;
boolean isBuyoutApplicable = false;
try {
if(invoiceVO!=null && invoiceVO.getRemoteStoreNumber()!=null && InvoiceBL.isRemoteStore(invoiceVO.getRemoteStoreNumber())) {
String ipAddress = PhoneRoomInvoiceBL.getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
StoreProfileVO storeProfileVO = new PhoneRoomTaapRouter().getStoreProfile(ipAddress);
isBuyoutApplicable = storeProfileVO.getBuyoutPickupPOInUse().booleanValue();
} else {
isBuyoutApplicable = clientApplicationContext.getProfile(
Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).
getStoreProfile().getBuyoutPickupPOInUse().booleanValue();
}
if(clientApplicationContext.isLoggedInAsPhoneRoom()){
isCallCenterEnable = clientApplicationContext.getMessageDAO().checkServingStoreMSGFlag();
}
} catch (ApplicationException e) {
logger.error("Exception occured while fetching the call center flag" + e);
}
if(isBuyoutApplicable && (!clientApplicationContext.isLoggedInAsPhoneRoom() || isCallCenterEnable)){
// Counter person is restricted from adding any additional line items to invoice containing
// NOL Order
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10124");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
// Counter person is restricted from adding any additional line items to return invoice
if (invoiceVO.isReturnInvoice()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10308");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10202");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10212", originalInvoiceNumber);
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (!buyoutOpened && clientApplicationContext.getSystemDAO().allowBuyouts().booleanValue()) {
baseLineItemVO = new BaseLineItemVO();
lineItemHandler =
lineItemHandlerFactory.getHandlerFromSpecialFunctionCD(selectedItem,
invoiceLineEntryPanel, baseLineItemVO, customerVO, invoiceVO, null);
buyoutOpened = true;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pointOfSaleEventDispatcher.fireBuyoutOpened(new BuyoutEvent(this,
invoiceVO));
buyoutOpened = false;
}
});
}
}
} else if (selectedItem.startsWith(TsoConstant.SAVE_INVOICE)) {
if ((invoiceVO.getLineItems() == null) || invoiceVO.getLineItems().isEmpty()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"1219");
} else if (invoiceVO.getSavedInvoiceIdForDeletion() != null
&& InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO)
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(
invoicePanel, "10084");
return;
} else if (GiftCardBL.doesInvoiceContainBarcodedNAPAGiftCardReturnItem(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoicePanel,
"10742");
return;
} else {
// Added for ASWA project - START
final BuildInboundMessageService buildInboundMessageService =
(BuildInboundMessageService) TamsJmoIntegrationServiceFactory
.getServiceInstance(IndagoConstants.INBOUND_ACTIVITY,
IndagoConstants.TAMS_MESSAGE_INITIATOR, null);
try {
StoreProfileVO storeProfile = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag())
?(new PhoneRoomTaapRouter().getStoreProfile(
getRemoteIpAddress(invoiceVO.getRemoteStoreNumber())))
:ApplicationContext.getInstance().getProfile(
Profile.SERVER, buildInboundMessageService.getStoreLocation())
.getStoreProfile();
if (storeProfile != null && storeProfile.getIndagoInUse().booleanValue()
&& invoiceVO.getWmsTransactionStatus() != null
&& invoiceVO.getWmsTransactionStatus().intValue() == 3) {
ClientApplicationContext.getClientApplicationContext().getMessageMgr()
.showMessage(invoiceLineEntryPanel, "9602");
return;
}
boolean attentionEntryRequired = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag())
?(new TaapRouter().getInvoicingProfile(getRemoteIpAddress(invoiceVO.getRemoteStoreNumber()))
.getAttentionEntryRequired().booleanValue())
:clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getInvoicingProfile()
.getAttentionEntryRequired().booleanValue();
if (((customerVO != null)
&& (customerVO.getCustomerNumber() != null) && (customerVO
.getCustomerNumber().intValue() == 0))
|| ((storeProfile != null && storeProfile
.getPhoneRoomInUse().booleanValue())
&& attentionEntryRequired)) {
String s = getAttention();
invoiceVO.setAttention(s);
} else {
invoiceVO.setAttention(getAttentionFromPOSAttentionField());
}
} catch (ApplicationException applicationException) {
logger.error(applicationException.toString(), applicationException);
}
// Added for ASWA project - END
if(saveDirectShipItems(true)){
return;
}
if(!showCheckoutScreenForRemoteInvoicing()) {
try {
invoiceVO.setCalcOnSpecialFunction(true);
if (!finalizeInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
} catch (Exception e) {
logger.error("Save Invocie throws exception while doing invoiceCalculation", e);
} finally {
invoiceVO.setCalcOnSpecialFunction(false);
}
}
SwingUtilities.invokeLater(new Runnable(){
public void run() {
try {
boolean isNOLInv = false;
SalesOrderVO salesOrdVO = null;
InvoiceVO invoice = (InvoiceVO) getModel();
if (invoice != null) {
if (invoice.getSalesOrderVO() != null) {
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
salesOrdVO = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(),getRemoteIpAddress(invoiceVO.getRemoteStoreNumber()));
}else{
salesOrdVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
if (salesOrdVO != null && salesOrdVO.getRefOrderSubTypeId() != null) {
if (salesOrdVO.getRefOrderSubTypeId().intValue() == RefNOLOrderType.ROL || salesOrdVO.getRefOrderSubTypeId().intValue() ==RefNOLOrderType.BOPIS) {
isNOLInv = true;
invoice.setWorkInProgressUpdated(new Boolean(true));
}
}
}
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
if(!isNOLInv) {
if ((invoice != null && invoice.isPhoneRoomMessagesFlag())) {
invoice.setSavedInvoiceType(TsoConstant.CALL_CENTER_SAVED_INVOICE);
} else {
invoice.setSavedInvoiceType(TsoConstant.PHONE_ROOM_SAVED_INVOICE);
}
}else {
if ((invoice != null && invoice.isPhoneRoomMessagesFlag())) {
invoice.setSavedInvoiceType(TsoConstant.CALL_CENTER_SAVED_INVOICE);
} else {
invoice.setSavedInvoiceType(TsoConstant.NORMAL_SAVED_INVOICE);
}
}
} else {
invoice.setSavedInvoiceType(TsoConstant.NORMAL_SAVED_INVOICE);
}
invoice.setTransactionNumber(null);
if ((invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag())
?PhoneRoomInvoiceBL.saveInvoice(invoice,customerVO,invoiceLineEntryPanel
,getRemoteIpAddress(invoiceVO.getRemoteStoreNumber()))
:InvoiceBL.saveInvoice(invoice, customerVO, invoiceLineEntryPanel)) {
pointOfSaleEventDispatcher
.fireInvoiceSaved(new InvoiceEvent(this,
new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
// Release Barcoded NAPA Gift Card Return Item HOLD amount
if(GiftCardBL.doesInvoiceContainBarcodedNAPAGiftCardReturnItem(invoiceVO)) {
GiftCardBL.releaseBarcodedNAPAGiftCardReturnItemHoldAmount(invoiceVO);
}
invoiceLineEntryPanel.slfSpecialFunctions
.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.slfSpecialFunctions,
KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_ENTER, '\n'));
setPartNumberEnabled(false);
}
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "2204");
return;
} catch (IOException ae) {
logger.error(ae.toString(), ae);
}
}
});
}
} else if(selectedItem.startsWith(TsoConstant.PRINT_QUOTE_AND_SAVE_INVOICE)) {
logger.debug("handle print quote and save invoice");
if ((invoiceVO.getLineItems() == null) || invoiceVO.getLineItems().isEmpty()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"1219");
} else if (invoiceVO.getSavedInvoiceIdForDeletion() != null
&& InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO)
&& customerVO.getDirectShipEligible().booleanValue()) {
clientApplicationContext.getMessageMgr().showMessage(
invoicePanel, "10084");
return;
} else {
if ((customerVO != null) && (customerVO.getCustomerNumber() != null)
&& (customerVO.getCustomerNumber().intValue() == 0)) {
String s = getAttention();
invoiceVO.setAttention(s);
} else {
invoiceVO.setAttention(getAttentionFromPOSAttentionField());
}
if(saveDirectShipItems(true)){
return;
}
if(!showCheckoutScreenForRemoteInvoicing()) {
try {
invoiceVO.setCalcOnSpecialFunction(true);
if (!finalizeInvoiceController.setInitialData(invoiceVO, dispInvVO)) {
return;
}
} catch (Exception e) {
logger.error("Quote and Save throws exception while doing invoiceCalculation", e);
} finally {
invoiceVO.setCalcOnSpecialFunction(false);
}
}
SwingUtilities.invokeLater(new Runnable(){
public void run() {
try {
InvoiceVO invoice = (InvoiceVO) getModel();
if (invoice != null) {
if (invoice.isPhoneRoomMessagesFlag()) {
invoice.setSavedInvoiceType(TsoConstant.CALL_CENTER_SAVED_INVOICE);
} else {
invoice.setSavedInvoiceType(TsoConstant.NORMAL_SAVED_INVOICE);
}
invoice.setTransactionNumber(null);
if ((invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag())
?PhoneRoomInvoiceBL.saveInvoice(invoice,customerVO,invoiceLineEntryPanel
,getRemoteIpAddress(invoiceVO.getRemoteStoreNumber()))
:InvoiceBL.saveInvoice(invoice, customerVO, invoiceLineEntryPanel)) {
logger.debug("saved invoice: " + invoice.getID());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
printInvoiceQuoteAfterSave(invoiceVO);
logger.info("return from printInvoiceQuoteAfterSave()");
pointOfSaleEventDispatcher.fireInvoiceSaved(new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.slfSpecialFunctions,
KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_ENTER, '\n'));
setPartNumberEnabled(false);
}
}); // end invoke later here
}
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "2204");
return;
}
}
});
}
} else if (selectedItem.startsWith(TsoConstant.WARRANTY_LABOR_CLAIM)) {
// Counter person is restricted from adding any additional line items to invoice containing
// NOL Order
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10124");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
// Counter person is restricted from adding any additional line items to return invoice
if (invoiceVO.isReturnInvoice()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10308");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10202");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10212", originalInvoiceNumber);
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (clientApplicationContext.getSystemDAO().askForPassword(
PasswordConstants.WLC_PWD).booleanValue()) {
passwordController.setInitialData(PasswordConstants.WLC_PWD);
// To localize Warranty Labor Claim Password dialog.
passwordController.localizeView();
passwordController.setViewVisible(true);
if (passwordController.getPasswordValid()) {
baseLineItemVO = new BaseLineItemVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.WARRANTY_LABOR_CLAIM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
} else {
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
}
} else {
baseLineItemVO = new BaseLineItemVO();
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.WARRANTY_LABOR_CLAIM, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
}
} else {
baseLineItemVO = new BaseLineItemVO();
if(selectedItem.startsWith(TsoConstant.CORE)) { //Setting the flag when Special Function COR is selected
baseLineItemVO.setSpecialFnCorSelected(true);
} else if(selectedItem.startsWith(TsoConstant.DEFECTIVE)){
baseLineItemVO.setSpecialFnDefSelected(true);
} else if(selectedItem.startsWith(TsoConstant.COLORADO_DELIVERY_FEE)) {
if(invoiceVO != null && invoiceVO.isCoroladoFeeLineExists()) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10605");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
}
// Counter person is restricted from adding any additional line items to invoice containing
// NOL Order
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !(selectedItem.startsWith(TsoConstant.BACK_TO_PART_NUMBER))) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10124");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
// Counter person is restricted from adding any additional line items to return invoice
if (invoiceVO.isReturnInvoice() && !(selectedItem.equalsIgnoreCase(TsoConstant.BACK_TO_PART_NUMBER))) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10308");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10202");
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) {
final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10212", originalInvoiceNumber);
resetSpecialFunctions(0, true);
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this, null));
return;
}
lineItemHandler =
lineItemHandlerFactory.getHandlerFromSpecialFunctionCD(selectedItem,
invoiceLineEntryPanel, baseLineItemVO, customerVO, invoiceVO, null);
lineItemHandler.displayLineItem();
if(isSpecialChargeItemHandler()){
pointOfSaleEventDispatcher.fireTamsIsBusy(new CartEvent(this));
}
}
}
}
private void printInvoiceQuoteAfterSave(InvoiceVO invoiceVO) {
logger.debug("printInvoiceQuoteAfterSave(" + (invoiceVO != null ? invoiceVO.getID().toString() : "NULL") + ")");
invoiceVO.setInvoiceQuote(new Boolean(true));
recallSavedInvPrintController.populateData(invoiceVO);
recallSavedInvPrintController.setPrintQuoteData(invoiceVO);
((JDialog) recallSavedInvPrintController.getView()).setVisible(true);
}
private String getAttention () {
AttentionTextEntryController attentionTextEntryController =
new AttentionTextEntryController (parentView);
attentionTextEntryController.setAttention(getAttentionFromPOSAttentionField());
attentionTextEntryController.setViewVisible(true);
AttentionVO attentionVO = (AttentionVO) attentionTextEntryController.getModel();
return attentionVO.getAttnetion();
}
private boolean checkMaxInvoiceLinesReached(int linesToAdd) {
boolean maxLinesReached =
InvoiceLineBL.isMaximumLinesExceeded(invoiceVO.getLineItems().size(), linesToAdd);
if (maxLinesReached) {
JOptionPane.showMessageDialog(invoiceLineEntryPanel,
"Reached maximum number of lines to invoice",
"Maximum Lines Invoiced", JOptionPane.INFORMATION_MESSAGE);
clientApplicationContext.getPointOfSaleEventDispatcher().
fireMaxLinesInvoiced(new PointOfSaleListEvent(this, invoiceVO));
return true;
}
return false;
}
private void resetEntryArea(Component exceptionLabelComponent,
Component exceptionFieldComponent) {
resetLineEntryArea(exceptionLabelComponent, exceptionFieldComponent);
resetNoteEntryArea(exceptionLabelComponent, exceptionFieldComponent);
resetNAPAOnlineArea(exceptionLabelComponent, exceptionFieldComponent);
resetFunctionsArea(exceptionLabelComponent, exceptionFieldComponent);
invoiceLineEntryPanel.btnDelete.setVisible(true);
invoiceLineEntryPanel.btnDelete.setEnabled(false);
invoiceLineEntryPanel.btnSourceOption.setVisible(false);
invoiceLineEntryPanel.btnSourceOption.setEnabled(false);
invoiceLineEntryPanel.fldYN.setVisible(false);
invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(false);
invoiceLineEntryPanel.pnlNapaOnline.setVisible(false);
invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true);
directShipLines = new Vector();
}
private void resetLineEntryArea(Component exceptionLabelComponent,
Component exceptionFieldComponent) {
Component components[] = invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponents();
Component component = null;
for (int i = 0; i < components.length; i++) {
component = components[i];
if (!component.equals(exceptionLabelComponent)
&& !component.equals(exceptionFieldComponent) && !component.hasFocus()) {
component.setEnabled(false);
}
if (component instanceof JTextField && !component.hasFocus()) {
((JTextField) component).setText("");
}
if (component.getName().startsWith(InvoiceLineEntryPanel.LBL_LINE1_NAME.substring(0, 6))
&& component.getName().length() > 7) {
((JLabel) component).setText("");
}
}
invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows();
setPartNumberEnabled(true);
}
private void resetNoteEntryArea(Component exceptionLabelComponent,
Component exceptionFieldComponent) {
Component components[] = invoiceLineEntryPanel.pnlInvoiceNoteEntry.getComponents();
Component component = null;
for (int i = 0; i < components.length; i++) {
component = components[i];
if (!component.equals(exceptionLabelComponent)
&& !component.equals(exceptionFieldComponent) && !component.hasFocus()) {
component.setEnabled(false);
}
if (component instanceof JTextField && !component.hasFocus()) {
((JTextField) component).setText("");
}
}
}
private void resetNAPAOnlineArea(Component exceptionLabelComponent,
Component exceptionFieldComponent) {
Component components[] = invoiceLineEntryPanel.pnlNapaReturnAuthNum.getComponents();
Component component = null;
for (int i = 0; i < components.length; i++) {
component = components[i];
if (component instanceof JTextField && !component.hasFocus()) {
((JTextField) component).setText("");
}
}
}
private void resetFunctionsArea(Component exceptionLabelComponent,
Component exceptionFieldComponent) {
invoiceLineEntryPanel.pnlFunctions.setVisible(true);
if (!invoiceLineEntryPanel.slfSpecialFunctions.equals(exceptionFieldComponent)
&& !invoiceLineEntryPanel.slfSpecialFunctions.hasFocus()) {
invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(true);
}
if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){
invoiceLineEntryPanel.btnCheckOtherStores.setVisible(false);
invoiceLineEntryPanel.btnBarcode.setVisible(true);
}
invoiceLineEntryPanel.btnBarcode.setEnabled(false);
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
invoiceLineEntryPanel.btnBarcode.setVisible(true);
invoiceLineEntryPanel.btnOtherStores.setVisible(false);
}
invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(false);
invoiceLineEntryPanel.btnPartInfo.setEnabled(false);
if (invoiceVO.getLineItems() != null && !invoiceVO.getLineItems().isEmpty()
&& LineGenerationQueue.getInstance().isEmpty()) {
invoiceLineEntryPanel.btnFinalize.setEnabled(true);
} else {
invoiceLineEntryPanel.btnFinalize.setEnabled(false);
if (invoiceVO.getLineItems() == null || invoiceVO.getLineItems().isEmpty()) {
FwoNumberPattern fwoNumberPattern = (FwoNumberPattern)
FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL,
clientApplicationContext.getCurrentLocale(), true);
try {
invoiceLineEntryPanel.dlblSubtotal.setText(fwoNumberPattern.format(
"0.00").toString());
invoiceLineEntryPanel.dlblAlternateCoreSubtotal.setText(fwoNumberPattern.format(
"000,000.00").toString());
} catch (NumberPatternFormatException npfe) {
}
}
if (customerVO == null) {
invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(false);
}
zeroPriceOK = false;
}
invoiceLineEntryPanel.lblSubtotal.setEnabled(true);
invoiceLineEntryPanel.dlblSubtotal.setEnabled(true);
}
private void removeSaveOption (Vector v) {
if ((v == null) || (v.size() == 0)) {
return;
}
Object o = null;
RefTableVO item = null;
int itemCount = v.size();
for (int i = itemCount -1; i >= 0; i--) {
o = v.elementAt(i) ;
if (!(o instanceof RefTableVO)) {
continue;
}
item = (RefTableVO) o;
if (item.getCD().equals(RefInvoiceSpecialFunction.SAVE_INVOICE) ||
item.getCD().equals(RefInvoiceSpecialFunction.PRINT_QUOTE_AND_SAVE_INVOICE)) {
v.remove(i);
}
}
}
private void removeMiscellaneousOption (Vector v) {
if ((v == null) || (v.size() == 0)) {
return;
}
Object o = null;
RefTableVO item = null;
int index = 0, itemCount = v.size();
for (int i = 0; i < itemCount; i++) {
o = v.elementAt(i) ;
if (!(o instanceof RefTableVO)) {
continue;
}
item = (RefTableVO) o;
if (item.getCD().equals(RefInvoiceSpecialFunction.MISCELLANEOUS)) {
v.remove(i);
break;
}
}
}
private void removePolicyAdjustments (Vector v) {
if ((v == null) || (v.size() == 0)) {
return;
}
Object o = null;
RefTableVO item = null;
int index = 0, itemCount = v.size();
for (int i = 0; i < itemCount; i++) {
o = v.elementAt(i) ;
if (!(o instanceof RefTableVO)) {
continue;
}
item = (RefTableVO) o;
if (item.getCD().equals(RefInvoiceSpecialFunction.POLICY_ADJUSTMENT)) {
v.remove(i);
break;
}
}
}
private void removeMoveOption (Vector v) {
if ((v == null) || (v.size() == 0)) {
return;
}
Object o = null;
RefTableVO item = null;
int index = 0, itemCount = v.size();
for (int i = 0; i < itemCount; i++) {
o = v.elementAt(i) ;
if (!(o instanceof RefTableVO)) {
continue;
}
item = (RefTableVO) o;
if (item.getCD().equals(RefInvoiceSpecialFunction.MOVE_TO_SAVED_INVOICE)) {
v.remove(i);
break;
}
}
}
private void removeOptionsForNAPA(Vector v) {
for (int i = 0; i < v.size(); i++) {
Object o = v.elementAt(i);
if (!(o instanceof RefTableVO)) {
continue;
} else {
String code = ((RefTableVO) o).getCD();
if (code.equals(RefInvoiceSpecialFunction.CHANGE_CUSTOMER)
|| code.equals(RefInvoiceSpecialFunction.DELIVERY)
|| code.equals(RefInvoiceSpecialFunction.DOES_NOT_AFFECT_SALES)
|| code.equals(RefInvoiceSpecialFunction.ENVIRONMENTAL_CHARGE)
|| code.equals(RefInvoiceSpecialFunction.FREIGHT)
|| code.equals(RefInvoiceSpecialFunction.BAGFEE)
|| code.equals(RefInvoiceSpecialFunction.MISCELLANEOUS)
|| code.equals(RefInvoiceSpecialFunction.OTHER)
|| code.equals(RefInvoiceSpecialFunction.PICK_UP)
|| code.equals(RefInvoiceSpecialFunction.POLICY_ADJUSTMENT)
|| code.equals(RefInvoiceSpecialFunction.SAVE_INVOICE)
|| code.equals(RefInvoiceSpecialFunction.PRINT_QUOTE_AND_SAVE_INVOICE)
|| code.equals(RefInvoiceSpecialFunction.SERVICE_CHARGE)
|| code.equals(RefInvoiceSpecialFunction.TELEPHONE)
|| code.equals(RefInvoiceSpecialFunction.WARRANTY_LABOR_CLAIM)
|| code.equals(RefInvoiceSpecialFunction.COLORADO_DELIVERY_FEE)) {
v.remove(i);
i--;
}
}
}
}
private void setSpecialFunctions(String languageCD) {
Vector specialFunctions = new Vector();
specialFunctions =
clientApplicationContext.getRefTableDAO().getInvoiceSpecialFunctions(languageCD);
if(!getStoreProfile().getUseNapaXpress().booleanValue()) {
removeMoveOption(specialFunctions);
}
if (!clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()
).getInvoicingProfile().getUseSaveInvoice().booleanValue()) {
removeSaveOption (specialFunctions);
}
if (CustomerBL.isNapaOnlineCustomer(customerVO)) {
removeOptionsForNAPA(specialFunctions);
}
Profile profile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation());
boolean allowMISfunction = profile.getInvoicingProfile().getAllowMisFunction().booleanValue();
boolean allowPolicyAdjustment = profile.getInvoicingProfile().getAllowPolicyAdjustment().booleanValue();
boolean gpcOwned = profile.getStoreProfile().getGpcOwned().booleanValue();
if (gpcOwned || !allowMISfunction) {
removeMiscellaneousOption(specialFunctions);
}
if (gpcOwned || !allowPolicyAdjustment) {
removePolicyAdjustments(specialFunctions);
}
if(getStoreProfile().getRetailDeliveryFee() != null
&& !getStoreProfile().getRetailDeliveryFee().equalsIgnoreCase(
RefState.COLORADO)) {
removeRetailDeliveryFee(specialFunctions, RefInvoiceSpecialFunction.COLORADO_DELIVERY_FEE);
}
if(getStoreProfile().getRetailDeliveryFee() != null
&& !getStoreProfile().getRetailDeliveryFee().equalsIgnoreCase(
RefState.MINNESOTA)) {
removeRetailDeliveryFee(specialFunctions, RefInvoiceSpecialFunction.MN_DELIVERY_FEE);
}
specialFunctions.add(0, new RefTableVO("",
clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.slfSpecialFunctions.Default",
clientApplicationContext.getCurrentLocale())));
invoiceLineEntryPanel.slfSpecialFunctions.setData(specialFunctions);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
}
public boolean validLineItemHandler() {
return (lineItemHandler != null);
}
public JTextField getPartNumberComponent() {
return invoiceLineEntryPanel.fldPartNumber;
}
public JTextField getQuantityComponent() {
return invoiceLineEntryPanel.fldQuantity;
}
public JTextField getNAPAReturnAuthNumComponent() {
return invoiceLineEntryPanel.fldNapaReturnAuthNum;
}
public JTextField getOKComponent() {
return invoiceLineEntryPanel.fldOK;
}
private void resetLineItem(AbstractLineItemHandler lineItemHandler) {
this.lineItemHandler = lineItemHandler;
if (lineItemHandler == null) {
resetLineItemVOs(null);
} else {
resetLineItemVOs(lineItemHandler.getLineItemVO());
}
}
private void resetLineItemVOs(InvoiceLineItemVO invoiceLineItemVO) {
this.invoiceLineItemVO = invoiceLineItemVO;
if (invoiceLineItemVO != null) {
if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
invoiceNoteVO = null;
napaOnlineInfoVO = null;
} else if (invoiceLineItemVO instanceof InvoiceNoteVO) {
invoiceNoteVO = (InvoiceNoteVO) invoiceLineItemVO;
baseLineItemVO = null;
napaOnlineInfoVO = null;
} else if (invoiceLineItemVO instanceof NAPAOnlineInfoVO) {
invoiceNoteVO = null;
baseLineItemVO = null;
napaOnlineInfoVO = (NAPAOnlineInfoVO) invoiceLineItemVO;
}
} else {
baseLineItemVO = null;
invoiceNoteVO = null;
napaOnlineInfoVO = null;
}
}
public void setCatlogButtonPanel(CatalogButtonPanel catalogButtonPanel) {
this.catalogButtonPanel = catalogButtonPanel;
}
public CatalogButtonPanel getCatalogButtonPanel() {
return this.catalogButtonPanel;
}
public void setInvoicePanel(InvoicePanel invoicePanel) {
this.invoicePanel = invoicePanel;
}
private InvoicePanel getInvoicePanel() {
return invoicePanel;
}
public void setCashierPanel(CashierPanel cashierPanel) {
this.cashierPanel = cashierPanel;
}
private CashierPanel getCashierPanel() {
return cashierPanel;
}
public Frame getParentView() {
return parentView;
}
public void resetSpecialFunctions(int index, boolean enabled) {
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(index);
invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(enabled);
}
public JButton getDeleteButton() {
return invoiceLineEntryPanel.btnDelete;
}
public JButton getFinalizeButton() {
return invoiceLineEntryPanel.btnFinalize;
}
public JButton getSupersedeButton() {
return invoiceLineEntryPanel.btnSupersede;
}
public JButton getCOBButton() {
return invoiceLineEntryPanel.btnCheckOtherBalances;
}
public JButton getBarcodeButton() {
return invoiceLineEntryPanel.btnBarcode;
}
public JButton getOtherStoresButton() {
return invoiceLineEntryPanel.btnOtherStores;
}
public JPanel getNAPAPanel() {
return invoiceLineEntryPanel.pnlNapaOnline;
}
public JButton getCancelButton() {
return invoiceLineEntryPanel.btnCancel;
}
public JButton getPartInfoButton() {
return invoiceLineEntryPanel.btnPartInfo;
}
public JButton getCheckOtherStoreButton(){
return invoiceLineEntryPanel.btnCheckOtherStores;
}
public SelectionField getSpecialFunctions() {
return invoiceLineEntryPanel.slfSpecialFunctions;
}
public void invoicingVisible(boolean boolState) {
invoiceLineEntryPanel.slfSpecialFunctions.setVisible(boolState);
invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(boolState);
invoiceLineEntryPanel.btnBarcode.setVisible(boolState);
invoiceLineEntryPanel.btnBarcode.setEnabled(boolState);
if (clientApplicationContext.isLoggedInAsPhoneRoom()) {
invoiceLineEntryPanel.btnBarcode.setVisible(true);
invoiceLineEntryPanel.btnOtherStores.setVisible(false);
}
}
public void employeeLoggedOut(EmployeeEvent ee) {
resetEntryArea(null, null);
setPartNumberEnabled(false);
resetSpecialFunctions(0, false);
}
public void employeeLoggedIn(EmployeeEvent ee) {
Profile profile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation());
invoiceLineEntryPanel.lblSecondaryTax.setVisible(
profile.getStoreProfile().getRefCountryCd().equals("CA"));
invoiceLineEntryPanel.fldSecondaryTax.setVisible(
profile.getStoreProfile().getRefCountryCd().equals("CA"));
invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(false);
}
public void catalogingOpened(CatalogEvent ce) {
resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
}
public void catalogPartSelected(CatalogEvent ce) {
tempPartVO = (PartVO) ce.getModel();
}
public void setInvoiceVO(InvoiceVO invoiceVO) {
this.invoiceVO = invoiceVO;
}
public void setStockController(StockController stockController) {
this.stockController = stockController;
}
public void vehicleChanged(VehicleEvent ve) {
vehicleVO = (VehicleVO) ve.getModel();
}
public String getSubtotalText() {
return invoiceLineEntryPanel.dlblSubtotal.getText();
}
public void buyoutClosed(BuyoutEvent be) {
if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation()).getBuyoutProfile(
).getRequirePOForPickupItems().booleanValue()
&& be.isBuyoutCancelled()) {
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
if (baseLineItemVO != null){
baseLineItemVO.setPickupItem(Boolean.FALSE) ;
}
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.DEFAULT, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
}
if (invoiceLineEntryPanel.fldPartNumber.isEnabled()
&& (be.isBuyoutCancelled() || !be.doesContainZeroItem())) {
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
}
public void profileChanged(ProfileEvent pe) {
setProfileDependentSettings();
}
protected void setProfileDependentSettings() {
if (!invoiceVO.getManualTransaction().booleanValue()) {
Locale locale = clientApplicationContext.getCurrentLocale();
if(locale == null){
locale = Locale.getDefault();
}
setSpecialFunctions(locale.getLanguage());
}
}
public void manualInvoiceOpened(InvoiceEvent ie) {
Vector specialFunctions = invoiceLineEntryPanel.slfSpecialFunctions.getData();
removeSaveOption (specialFunctions);
invoiceLineEntryPanel.slfSpecialFunctions.setData(specialFunctions);
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
invoiceVO.setManualTransaction(Boolean.TRUE);
}
public void manualInvoiceClosed(InvoiceEvent ie) {
setSpecialFunctions(clientApplicationContext.getCurrentLocale().getLanguage());
invoiceVO.setManualTransaction(Boolean.FALSE);
}
public void recallSavedInvoiceDialogueClosed(InvoiceEvent ie){}
public void keyPressed(KeyEvent ke) { }
public void keyReleased(KeyEvent ke) {
if (ke.getModifiers() == 0) {
switch (ke.getKeyCode()) {
case KeyEvent.VK_F5:
if (invoiceLineEntryPanel.btnDelete.isEnabled()) {
invoiceLineEntryPanel.btnDelete.doClick();
}
break;
}
}
}
private boolean validDCText() {
String strText = invoiceLineEntryPanel.fldDC.getText();
return (strText.equals("N") || strText.equals("Y"));
}
private boolean validYNText() {
String strText = invoiceLineEntryPanel.fldYN.getText();
return (strText.equals("N") || strText.equals("Y"));
}
public void keyTyped(KeyEvent ke) { }
public void mouseReleased(MouseEvent me) {
if (me.getSource() == invoiceLineEntryPanel.fldPartNumber) {
clientApplicationContext.getPointOfSaleEventDispatcher().fireTamsIsReady(new CartEvent(this));
}
}
public void mouseEntered(MouseEvent me) { }
public void mouseExited(MouseEvent me) { }
public void mouseClicked(MouseEvent me) {
if (me.getSource() == invoiceLineEntryPanel.fldPartNumber) {
invoiceController.stopPpse2LinesProcessing();
}
}
public void catalogingClosed(CatalogEvent ce) { }
public void catalogTitleChanged(CatalogTitleEvent cte) { }
public void catalogPartsListChanged(CatalogPartsListEvent cte) { }
public void invalidCatalogLookupPerformed(CatalogEvent ce) { }
public void buyoutRefreshed(BuyoutEvent be) { }
public void buyoutChosen(BuyoutEvent be) { }
public void salespersonChanged(EmployeeEvent ee) { }
public void buyoutOpened(BuyoutEvent be) { }
public void ppseCatalogSessionOpen(CatalogEvent ce) { }
public void ppseCatalogSessionClosed(CatalogEvent ce) { }
public void ppseInUse(CatalogEvent ce) {}
public void localizeView() {
// Sets the property key to the panel title border before the FwoLocalizationMgr framework
// class methods are called to localize the panel title border.
setTitleBorderPropertyKey();
localizationMgr.localize(invoiceLineEntryPanel.pnlInvoiceLineEntry,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlInvoiceNoteEntry,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlAlternateCoreSubtotal,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlSubtotal,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlFunctions,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlNapaOnline,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
localizationMgr.localize(invoiceLineEntryPanel.pnlNapaReturnAuthNum,
InvoiceLineEntryPanel.INVOICE_LINE_ENTRY_PANEL);
setSpecialFunctions(clientApplicationContext.getCurrentLocale().getLanguage());
}
/**
* This method sets the panel title border property key.
*
*/
private void setTitleBorderPropertyKey() {
Border border = invoiceLineEntryPanel.pnlNapaReturnAuthNum.getBorder();
if (border instanceof TitledBorder) {
((TitledBorder) border)
.setTitle(InvoiceLineEntryPanel.NAPA_RETURN_AUTH_NUM_PANEL_TITLE);
}
}
public void invoiceLineItemDeleted(PointOfSaleListEvent posle) {}
public void invoiceLineItemAdded(PointOfSaleListEvent posle) {
resetLineItem(null);
}
public void invoiceLineItemDeleteInvoked (PointOfSaleListEvent pose) { }
public void invoiceAssociatedCoreLineItemDeleteInvoked(
PointOfSaleListEvent pose) { }
public void detachCoreLineItemFromPart(PointOfSaleListEvent pose) { }
public void setDispInvVO(DisplayableInvoiceVO dispInvVO) {
this.dispInvVO = dispInvVO;
}
private POSPricingClient getRMIClient () throws RemoteException{
if (posPricingClient == null) {
posPricingClient = new POSPricingClient(FwoUtil.getIPAddress());
}
return posPricingClient;
}
/**
* This method sends a new order request to the RADS system and saves the
* corresponding invoice.
* @param invoice contains the invoice information
* @param customer contains the customer details
* @param invoiceLineEntryPanel InvoiceLineEntryPanel object
* @return If RADS request is successfully sent to RADS System and
* corresponding invoice is saved returns true, else returns false
*/
private boolean sendRadsNewOrderAndSaveInvoice(InvoiceVO invoice,
final CustomerVO customer,
final InvoiceLineEntryPanel invoiceLineEntryPanel) {
logger.debug("sendRadsNewOrderAndSaveInvoice()");
boolean transactionStatus = false;
int radsTransactionNumber = -1;
int radsTransactionSequence = -1;
int radsRequestReturnCode = -1;
List radsNewOrderOutList = null;
try {
// Call the method to send the new order request to RADS System
// and get the return status for each request
radsNewOrderOutList = InvoiceBL.sendRadsNewOrder(invoiceVO, customerVO);
// If RadsNewOrderOutList does not contain the status of any RADS
// request returns false to the calling method.
if (radsNewOrderOutList == null || radsNewOrderOutList.size() == 0) {
return transactionStatus;
}
int noOfRadsNewOrder = radsNewOrderOutList.size();
logger.debug("noOfRadsNewOrder-->" + noOfRadsNewOrder);
int noOfLineItems = (invoice != null && invoice.getLineItems() != null) ? invoice
.getLineItems().size() : 0;
// For each line item of a Transaction, get the Return Code.
// if Return Code is equal MESSAGE_RECEIVED set the RADS request
// information in the BaseLineItemVO object
for (int i = 0; i < noOfRadsNewOrder; i++) {
Object radsNewOrderOutObject = radsNewOrderOutList.get(i);
if (radsNewOrderOutObject instanceof RadsNewOrderOut) {
RadsNewOrderOut radsNewOrderOut = (RadsNewOrderOut) radsNewOrderOutObject;
radsRequestReturnCode = radsNewOrderOut.getReturnCode();
logger.debug("radsReuestReturnCode-->" + radsRequestReturnCode);
if (radsRequestReturnCode == RefRadsResponse.MESSAGE_RECEIVED
|| radsRequestReturnCode == RefRadsResponse.DC_IS_CLOSED
|| radsRequestReturnCode == RefRadsResponse.NOT_ACCEPTING_REQUESTS
|| radsRequestReturnCode == RefRadsResponse.MISCELLANEOUS) {
radsTransactionNumber = radsNewOrderOut.getTransactionId();
radsTransactionSequence = radsNewOrderOut.getTransactionSeq();
// Get the BaseLineItemVO object from the invoice object
// and set the Transaction Number, Transaction Sequence and
// Returns Code for the RADS Request sent to the RADS system.
for (int j = 0; j < noOfLineItems; j++) {
Object object = invoice.getLineItems().get(j);
if (object instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItem = (BaseLineItemVO) object;
if (baseLineItem.getSequence().intValue() == radsNewOrderOut
.getInvoiceLineNumber()) {
baseLineItem.setRadsTransactionNumber(radsTransactionNumber);
baseLineItem
.setRadsTransactionSequence(radsTransactionSequence);
baseLineItem.setRadsRequestReturnCode(radsRequestReturnCode);
if (radsRequestReturnCode == RefRadsResponse.MESSAGE_RECEIVED) {
transactionStatus = true;
baseLineItem.setRadsRequestSent(true);
} else if (radsRequestReturnCode == RefRadsResponse.DC_IS_CLOSED
|| radsRequestReturnCode == RefRadsResponse.MISCELLANEOUS
|| radsRequestReturnCode
== RefRadsResponse.NOT_ACCEPTING_REQUESTS) {
baseLineItem.setRefInvoiceLineItemTypeID(InvoiceLineBL
.getLineItemType(baseLineItem, customerVO));
baseLineItem.setRadsDiscrepancyType(
RefRadsDiscrepancyType.RADS_NOT_ACCEPTING_REQUEST);
}
}
}
}
}
}
}
// If Return Code is MESSAGE_RECEIVED, for all new order request of
// a Transaction call method to save the corresponding invoice.
if (transactionStatus) {
invoiceVO.setSavedInvoiceType(new Byte(RadsConstants.RADS_SAVED_INVOICE_TYPE));
logger.debug("Calling Save Invoice");
if (InvoiceBL.saveInvoice(invoiceVO, customerVO, invoiceLineEntryPanel)) {
if (!radsDeliveryOptionController.setInitialData(invoiceVO,
radsTransactionNumber)) {
return false;
}
fireStopTimer();
radsDeliveryOptionController.setViewVisible(true);
fireStartTimer();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pointOfSaleEventDispatcher.fireInvoiceSaved(new InvoiceEvent(this,
new InvoiceVO()));
byte posState = clientApplicationContext.getPOSState().getState();
if (clientApplicationContext.isLoggedInAsSales()
|| posState == POSStateVO.INVOICING_AS_CASHIER) {
getInvoicePanel().getEmployeeField().dispatchEvent(
new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_TAB, '\t'));
} else {
if (clientApplicationContext.getPOSState().getState()
== POSStateVO.CASHIER) {getCashierPanel().getFldID()
.dispatchEvent(
new KeyEvent(invoicePanel,
KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_TAB,
'\t'));
} else {
getInvoicePanel().getCustomerComboBox()
.dispatchEvent(
new KeyEvent(invoicePanel,
KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_TAB,
'\t'));
}
}
}
});
}
}
// If RADS request status is DC_IS_CLOSED, NOT_ACCEPTING_REQUESTS or
// MISCELLANEOUS displays a message "DC is not accepting requests
// for parts. All parts must be manually pulled." to the user.
else if (radsRequestReturnCode == RefRadsResponse.DC_IS_CLOSED
|| radsRequestReturnCode == RefRadsResponse.MISCELLANEOUS) {
logger.debug("RADS Request Status is either of DC_IS_CLOSED or MISCELLANEOUS");
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9043");
} else if (radsRequestReturnCode == RefRadsResponse.NOT_ACCEPTING_REQUESTS) {
logger.debug("RADS Request Status is NOT_ACCEPTING_REQUESTS");
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9024");
}
// If RADS request status is none of MESSAGE_RECEIVED, DC_IS_CLOSED,
// NOT_ACCEPTING_REQUESTS or MISCELLANEOUS displays a message as
// Invalid RADS Request Status for a new order request to the user.
else {
logger.error("Invalid RADS Request Status for a new order request");
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9038");
}
} catch (ApplicationException applicationException) {
logger.error("Exception occurred while sending the RADS Order to the RADS System",
applicationException);
// Display the message
// "No RADS Transaction Number is available. Please contact TAMS Support."
if (applicationException.getUserMessageID() != null
&& applicationException.getUserMessageID().equals(
RadsConstants.NO_RADS_TRANSACTION_NUMBER_AVAILABLE_MESSAGE_ID)) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
RadsConstants.NO_RADS_TRANSACTION_NUMBER_AVAILABLE_MESSAGE_ID);
} else {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9042");
}
}
return transactionStatus;
}
/**
* This method checks whether to display 'Customer Return Information' screen or not.
* @return boolean
*/
private boolean askForCustomerInformation() {
boolean askForItemReturnCustInfo = false;
TaapRouter taapRouter = new TaapRouter();
//Stel-751
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
askForItemReturnCustInfo = getInvoicingProfile()
.getAskForItemReturnCustomerInfo().booleanValue();
} else {
String ipAddress = null;
try {
ipAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
} catch (ApplicationException e) {
logger.error("Unable to fetch the ip address :");
}
InvoicingProfileVO invoicingProfileVO = taapRouter.getInvoicingProfile(ipAddress);
if(invoicingProfileVO.getAskForItemReturnCustomerInfo()!=null)
askForItemReturnCustInfo = invoicingProfileVO.getAskForItemReturnCustomerInfo().booleanValue();
}
if (customerVO.getCustomerNumber().intValue() == 0
&& InvoiceBL.doReturnsExist(invoiceVO)
&& askForItemReturnCustInfo) {
invoiceReturnCustomerInfoController.setInitialData(invoiceVO,
baseLineItemVO);
invoiceReturnCustomerInfoController.setViewVisible(true);
if (!isCustomerInfoEntered(askForItemReturnCustInfo)) {
invoiceLineEntryPanel.fldPartNumber.requestFocus();
return false;
}
}
return true;
}
/**
* This method checks whether customer information is entered or not for return items.
* @return boolean
* @param askForItemReturnCustInfo
*/
private boolean isCustomerInfoEntered(boolean askForItemReturnCustInfo) {
if (invoiceVO.getInvoiceReturnVO() == null
|| (!CustomerBL.isNapaOnlineCustomer(customerVO)
&& askForItemReturnCustInfo && (invoiceVO
.getInvoiceReturnVO().getName() == null || invoiceVO
.getInvoiceReturnVO().getName().equals("")))) {
return false;
}
return true;
}
/**
* This method is used to get invoicing profile information
*
* @return InvoiceProfileVO
*/
private InvoicingProfileVO getInvoicingProfile() {
Profile profile = clientApplicationContext.getProfile(
Profile.POINT_OF_SALE_CLIENT, clientApplicationContext
.getLocation());
return profile.getInvoicingProfile();
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.PointOfSaleListListener#listItemCleared(com.gpc.client.common
* .event.PointOfSaleListEvent)
*/
public void listItemCleared(PointOfSaleListEvent posle) {
}
/*
* (non-Javadoc)
*
* @see com.gpc.client.common.event.PointOfSaleListListener#listItemSelected(com.gpc.client
* .common.event.PointOfSaleListEvent)
*/
public void listItemSelected(PointOfSaleListEvent posle) {
}
/*
* (non-Javadoc)
*
* @see com.gpc.client.common.event.PointOfSaleListListener#listSetEnabledInvoked(com.gpc
* .client.common.event.PointOfSaleListEvent)
*/
public void listSetEnabledInvoked(PointOfSaleListEvent posle) {
isLineListPanelEnabled = posle.getEnabled();
}
/*
* (non-Javadoc)
*
* @see com.gpc.client.common.event.POSTAMSListener#posAboutInvoked(com.gpc.client.common.event.
* POSTAMSEvent)
*/
public void posAboutInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see com.gpc.client.common.event.POSTAMSListener#posAddPOInvoked(com.gpc.client.common.event.
* POSTAMSEvent)
*/
public void posAddPOInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.POSTAMSListener#posLogoutInvoked(com.gpc.client.common.event.
* POSTAMSEvent)
*/
public void posLogoutInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.POSTAMSListener#posOtherTAMSFunctionsInvoked(com.gpc.client.
* common.event.POSTAMSEvent)
*/
public void posOtherTAMSFunctionsInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see com.gpc.client.common.event.POSTAMSListener#posROAInvoked(com.gpc.client.common.event.
* POSTAMSEvent)
*/
public void posROAInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.POSTAMSListener#posScreenLockInvoked(com.gpc.client.common.event
* .POSTAMSEvent)
*/
public void posScreenLockInvoked(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.POSTAMSListener#posWindowClosing(com.gpc.client.common.event.
* POSTAMSEvent)
*/
public void posWindowClosing(POSTAMSEvent e) {
}
/*
* (non-Javadoc)
*
* @see
* com.gpc.client.common.event.POSTAMSListener#tamsInvoicingInvoked(com.gpc.client.common.event
* .POSTAMSEvent)
*/
public void tamsInvoicingInvoked(POSTAMSEvent poste) {
if (validLineItemHandler() && !isLineListPanelEnabled) {
JComponent nextFocusableComponent = lineItemHandler
.getNextFocus(invoiceLineEntryPanel.fldPartNumber);
if (nextFocusableComponent != null) {
nextFocusableComponent.requestFocus();
}
}
// Added code to check to see if there are items in the
// LineGenerationQueue when the TAMSII client receives a
// "tamsInvoicingInvoked" event, and generating a new event to process
// items that are in the queue to make sure that the current invoice
// processes these line items, instead of incorrectly leaving them in
// the queue for a future invoice to receive
if(!LineGenerationQueue.getInstance().isEmpty()) {
PointOfSaleEventDispatcher.getInstance().fireProcessLineQueue(
new PointOfSaleEvent(this, baseLineItemVO));
}
}
/**
* Sets the PD field document based on the entered line items and set the PD field text value
* with previous PD field value.
*/
private void setPdFieldDocument() {
if (lineItemHandler instanceof DefaultLineItemHandler) {
((DefaultLineItemHandler) lineItemHandler).setPDFieldDocument();
invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision());
}
}
/**
* This method sets the value of defectiveKitSelectedForRgn
*/
public static void setDefectiveKitSelectedForRgn(boolean defectiveKitSelectedForRgn) {
InvoiceLineEntryController.defectiveKitSelectedForRgn = defectiveKitSelectedForRgn;
}
/**
* This method returns the true if defective kit selected for RGN
*/
public static boolean getDefectiveKitSelectedForRgn() {
return defectiveKitSelectedForRgn;
}
public void storeChanged(StoreEvent se) {
setSpecialFunctions(clientApplicationContext.getCurrentUser().getRefLanguageCd());
}
public void invoiceLineItemsChanged(PointOfSaleListEvent posle) { }
/**
* Checks for main part.
*
* @param invoiceVo the invoice vo
* @return true, if at least one invoice line item is having a normal part
* false, if all the invoice line items are generated through special functions.
*/
private boolean hasMainPart(InvoiceVO invoiceVo) {
logger.debug("In hasMainPart() method...");
boolean isMainPart = false;
Vector items = (Vector) invoiceVo.getLineItems();
if (items != null && !items.isEmpty()) {
Iterator itemsIterator = items.iterator();
while (itemsIterator.hasNext()) {
Object invoiceLineItemVO = itemsIterator.next();
if (invoiceLineItemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
Integer generatedBySequence = baseLineItemVO.getGeneratedBySequence();
if ((generatedBySequence == null || (generatedBySequence != null
&& baseLineItemVO.isKitPart())) && !(generatedBySequence == null
&& baseLineItemVO.isKitPart())
&& !baseLineItemVO.getPickupItem().booleanValue()
&& !baseLineItemVO.getPolicyAdjustment().booleanValue()
&& !baseLineItemVO.getCoreTransaction().booleanValue()
&& !baseLineItemVO.getDefective().booleanValue()
&& !baseLineItemVO.getWarrantyItem().booleanValue()
&& !baseLineItemVO.getWarrantyLaborClaim().booleanValue()
&& !baseLineItemVO.getAutoGeneratedMiscChg().booleanValue()
&& (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.NORMAL_ITEM
|| baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.DC_ITEM
|| baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.TRANSFER_ITEM
|| baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue()
== RefInvoiceLineItemType.DC_ITEM_TRANSFER)) {
isMainPart = true;
break;
}
}
}
}
return isMainPart;
}
public final void setInvoiceController( InvoiceController invoiceController ) {
this.invoiceController = invoiceController;
}
/*
* Overridden method of CheckoutListener
*/
public void checkoutClosed(CheckoutEvent checkoutEvent) {
if (checkoutEvent.getCheckoutType() == CheckoutEvent.NORMAL_CHECKOUT_CONTROLLER) {
finalizeOptionalDeliveryInvoiceController.installBusinessListeners();
finalizeNonPhoneRoomInvoiceController.installBusinessListeners();
} else if (checkoutEvent.getCheckoutType() == CheckoutEvent.OPTIONAL_CHECKOUT_CONTROLLER) {
finalizeInvoiceController.installBusinessListeners();
finalizeNonPhoneRoomInvoiceController.installBusinessListeners();
} else {
finalizeInvoiceController.installBusinessListeners();
finalizeOptionalDeliveryInvoiceController.installBusinessListeners();
}
}
public void addPartFromPpse(PointOfSaleListEvent pose) {
final BaseLineItemVO cartItem = (BaseLineItemVO)pose.getModel();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dispatchPartLineQty(cartItem, true);
}
});
}
public final static boolean isPartAddedFromPPSE2() {
return isPartAddedFromPPSE2;
}
private void dispatchPartLineQty(final BaseLineItemVO cartItem, final boolean isFirstVersionOfPPSE2) {
final String partNumber = cartItem.getPartNum();
final String lineAbbrev = cartItem.getLineAbbr();
final String quantity = cartItem.getQuantityBilled().toString();
logger.debug("partNumber===> " + partNumber);
logger.debug("lineAbbrev===> " + lineAbbrev);
setVerifyInputforComponents();
if (partNumber != null && !partNumber.equals("") && lineAbbrev != null
&& !lineAbbrev.equals("")) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
synchronized(this) {
if(!isFirstVersionOfPPSE2){
baseLineItemVO = new BaseLineItemVO();
baseLineItemVO.setVirtualKit(cartItem.isVirtualKit());
baseLineItemVO.setComponents(cartItem.getComponents());
lineItemHandler =
lineItemHandlerFactory.getHandlerFromLineItemVO(invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
}
if (!invoiceLineEntryPanel.fldPartNumber.isEnabled()) {
setPartNumberEnabled(true);
}
invoiceLineEntryPanel.fldPartNumber.setText(partNumber);
isPartAddedFromPPSE2 = true;
invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
isPartAddedFromPPSE2 = false;
invoiceLineEntryPanel.slfLine.setText(lineAbbrev);
if(invoiceLineEntryPanel.slfLine.getData() != null
&& invoiceLineEntryPanel.slfLine.getData().size() > 1) {
invoiceLineEntryPanel.slfLine.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.slfLine, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
invoiceLineEntryPanel.fldDescription.setText(cartItem.getPartDescription());
if (baseLineItemVO != null) {
StringBuffer noteBuffer = new StringBuffer();
String[] catalogNoteArray = cartItem.getPartNoteArray();
if(catalogNoteArray != null) {
for(int i = 0 ; i < catalogNoteArray.length; i++){
noteBuffer.append(catalogNoteArray[i]);
}
}
String catalogNote = parseCatalogNote(noteBuffer.toString());
baseLineItemVO.setVehicleMake(cartItem.getVehicleMake());
baseLineItemVO.setVehicleModel(cartItem.getVehicleModel());
baseLineItemVO.setVehicleYear(cartItem.getVehicleYear());
baseLineItemVO.setVehicleVO(cartItem.getVehicleVO());
baseLineItemVO.setPartNote(createCatalogNoteStringArray(catalogNote));
baseLineItemVO.setPhoneRoomItems(cartItem.getPhoneRoomItems());
baseLineItemVO.setId(cartItem.getId());
baseLineItemVO.setVersion(cartItem.getVersion());
baseLineItemVO.setExternalIdentifier(cartItem.getExternalIdentifier());
baseLineItemVO.setPartAddedFromPPSE2(true);
baseLineItemVO.setSpecialOrder(cartItem.getSpecialOrder());
baseLineItemVO.setTokenId(cartItem.getTokenId());
}
invoiceLineEntryPanel.fldQuantity.setText(quantity);
if (!(lineItemHandler instanceof DefaultLineItemHandler
&& ((DefaultLineItemHandler) lineItemHandler).hasInventoryNote())) {
if(getStoreProfile().getUseNapaXpress().booleanValue() && !baseLineItemVO.isPartAddedFromPPSE2()) {
addLineItemToLineList();
} else {
invoiceLineEntryPanel.fldQuantity.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldQuantity, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
if ((lineItemHandler instanceof DefaultLineItemHandler)) {
((DefaultLineItemHandler) lineItemHandler).setTaxTableDependentDisplay();
}
if (invoiceLineEntryPanel.fldOK.isEnabled()) {
invoiceLineEntryPanel.fldOK.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldOK, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
/*
* Processing the line queue. Before this fix, line queue process was dependent on
* focusGained and focusLost from 'OK' text field. This was causing lot of user experience
* issues. This fix will make sure that user does not need to come back to TAMS for parts
* to get added to list.
*/
if ((baseLineItemVO == null || baseLineItemVO.isCompletedLine())
&& !LineGenerationQueue.getInstance().isEmpty()) {
PointOfSaleEventDispatcher.getInstance()
.fireProcessLineQueue(
new PointOfSaleEvent(this, baseLineItemVO));
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
}
}
}
}
}
}
});
} else if((partNumber == null || partNumber.equals("")) && lineAbbrev != null
&& lineAbbrev.equals("FRT")){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
baseLineItemVO = cartItem;
lineItemHandler = lineItemHandlerFactory.getHandler(
LineItemHandlerFactory.FREIGHT, invoiceLineEntryPanel,
baseLineItemVO, customerVO, invoiceVO, null);
invoiceLineEntryPanel.fldPartNumber.setText(baseLineItemVO.getPartNum());
invoiceLineEntryPanel.slfLine.setText(baseLineItemVO.getLineAbbr());
if(invoiceLineEntryPanel.slfLine.getData() != null
&& invoiceLineEntryPanel.slfLine.getData().size() > 1) {
invoiceLineEntryPanel.slfLine.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.slfLine, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
invoiceLineEntryPanel.fldDescription.setText(baseLineItemVO.getPartDescription());
invoiceLineEntryPanel.fldQuantity.setText(quantity);
invoiceLineEntryPanel.fldQuantity.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldQuantity,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
invoiceLineEntryPanel.fldPD
.setDocument(new FwoValidatedDecimalNumberDocument(invoiceLineEntryPanel.fldPD));
invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getUnitPrice().toString());
invoiceLineEntryPanel.fldPrice.setText(baseLineItemVO.getUnitPrice().toString());
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.fldOK.setText("Y");
JComponent fldOk = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldOK);
if (fldOk != null) {
fldOk.requestFocusInWindow();
}
invoiceLineEntryPanel.fldOK.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldOK,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
/*
* Processing the line queue. Before this fix, line queue process was dependent on
* focusGained and focusLost from 'OK' text field. This was causing lot of user experience
* issues. This fix will make sure that user does not need to come back to TAMS for parts
* to get added to list.
*/
if ((baseLineItemVO == null || baseLineItemVO.isCompletedLine())
&& !LineGenerationQueue.getInstance().isEmpty()) {
PointOfSaleEventDispatcher.getInstance()
.fireProcessLineQueue(new PointOfSaleEvent(this, baseLineItemVO));
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
setPartNumberEnabled(true);
}
invoiceLineEntryPanel.fldPartNumber.requestFocusInWindow();
}
});
}
}
/**
* This method removes all Checkout business listeners.
*/
public void removeCheckoutScreenBusinessListeners() {
finalizeInvoiceController.removeBusinessListeners();
finalizeNonPhoneRoomInvoiceController.removeBusinessListeners();
finalizeOptionalDeliveryInvoiceController.removeBusinessListeners();
finalizePhoneRoomInvoiceController.removeBusinessListeners();
}
/**
* This method installs all Checkout business listeners.
*/
public void installCheckoutScreenBusinessListeners() {
finalizeInvoiceController.installBusinessListeners();
finalizeNonPhoneRoomInvoiceController.installBusinessListeners();
finalizeOptionalDeliveryInvoiceController.installBusinessListeners();
finalizePhoneRoomInvoiceController.installBusinessListeners();
}
/**
* This method will verify tax decisions for the part and automatically correct it if any
* mismatch in tax decision found
*/
private void verifyTaxDecision() {
String remoteIpAddress = null;
if(clientApplicationContext.isLoggedInAsPhoneRoom()){
try {
remoteIpAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
} catch (ApplicationException e) {
//throw new RuntimeException(e);
logger.error("Unable to fetch store ip address "+e.getMessage());
}
}
boolean displayMsg = false;
InvoicingProfileVO invoicingProfile = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
invoicingProfile = getInvoicingProfile();
} else {
invoicingProfile = taapRouter.getInvoicingProfile(remoteIpAddress);
}
boolean enableCoreReturnLaw = false;
if(invoicingProfile != null) {
enableCoreReturnLaw = invoicingProfile.getEnableCoreReturnLaw().booleanValue();
}
boolean misMatchFound = false;
boolean msgDisplayed = false;
// Get value from property file to display message for tax mismatch
Properties properties = ApplicationContext.getInstance().getSystemConfig()
.getSystemConfiguration(SystemConfig.APPLICATION);
String displayTaxMisMatchMsg = (String) properties.get("DISPLAY_TAX_MISMATCH_MESSAGE");
if(TsoConstant.GENERIC_Y.equals(displayTaxMisMatchMsg)) {
displayMsg = true;
}
Vector lineItems = invoiceVO.getLineItems();
Vector partTaxMisMatchList = null;
if (lineItems != null) {
int listSize = lineItems.size();
// Re-evaluate invoice line item tax
StringBuffer partInfo = null;
for (int index = 0; index < listSize; index++) {
partInfo = null;
InvoiceLineItemVO invoiceLineItem = (InvoiceLineItemVO) lineItems.get(index);
if (invoiceLineItem instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItem = (BaseLineItemVO) invoiceLineItem;
// tax decision verification not required for return items which are associated
// with the original invoice line items STel-751
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
if(baseLineItem.getQuantityBilled().signum() < 0
&& InvoiceLineBL.isPartAssociatedWithOrigInvoiceFromList(baseLineItem)) {
continue;
}
} else {
if (baseLineItem.getQuantityBilled().signum() < 0
&& PhoneRoomInvoiceLineBL.isPartAssociatedWithOrigInvoiceFromList(baseLineItem,remoteIpAddress)) {
continue;
}
}
// Ignore core return line items if 'Enable Core Return Law' setting is 'ON'
if(enableCoreReturnLaw
&& baseLineItem.isCoreItem()
&& baseLineItem.getQuantityBilled().signum() < 0) {
continue;
}
InventoryVO inventoryVo = null;
MiscChgVO miscChgVO = null;
TaxDecisionVO taxDecision = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
// Get inventory information for the part
inventoryVo = clientApplicationContext.getInventoryDAO()
.getPartDetailInfo(customerVO, baseLineItem.getPartNum(),
baseLineItem.getLineAbbr(), false);
// Get miscellaneous charge information
miscChgVO = clientApplicationContext.getInventoryDAO().
getMiscChargeStateDetail(baseLineItem.getLineAbbr(),
baseLineItem.getPartNum(), customerVO.getState(),
customerVO.getCountryCD());
// Get tax decision
taxDecision = Tax.getTaxDecision(customerVO, inventoryVo,
miscChgVO, baseLineItem, invoiceVO.getPrimaryTaxTableVO(), invoiceVO
.getSecondaryTaxTableVO(), Profile.POINT_OF_SALE_CLIENT);
} else {
inventoryVo = phoneRoomTaapRouter.getPartDetailInfo(customerVO,baseLineItem.getLineAbbr(),baseLineItem.getPartNum(),false,
remoteIpAddress,clientApplicationContext.getCurrentLocale().getLanguage(),false);
miscChgVO = phoneRoomTaapRouter.getMiscChargeStateDetail(baseLineItem.getLineAbbr(),baseLineItem.getPartNum(),
customerVO.getState(),customerVO.getCountryCD(),remoteIpAddress,clientApplicationContext.getLocation());
taxDecision = PhoneRoomTax.getTaxDecision(customerVO,inventoryVo,miscChgVO,baseLineItem,invoiceVO.getPrimaryTaxTableVO(),
invoiceVO.getSecondaryTaxTableVO(),Profile.POINT_OF_SALE_CLIENT,remoteIpAddress,clientApplicationContext.getCurrentLocale().getLanguage());
}
// If primary tax decision mismatch found, auto correct tax decision and collect
// part information for logging
String primaryTax = taxDecision.getPrimaryTax();
if(!InvoiceLineBL.isPrimaryTaxEnabledForCustomer(customerVO, baseLineItem)) {
if (primaryTax.equals(Tax.ALWAYS)
&& !baseLineItem.getTaxable1().booleanValue()) {
misMatchFound = true;
if(partInfo == null) {
partInfo = new StringBuffer();
partInfo.append("Part Number : ").append(baseLineItem.getPartNum());
partInfo.append(", ");
partInfo.append("Line Abbrev : ").append(baseLineItem.getLineAbbr());
}
partInfo.append(", Primary Tax before fix : ")
.append(baseLineItem.getTaxable1().booleanValue());
baseLineItem.setTaxable1(Boolean.TRUE);
partInfo.append(", Primary Tax after fix : ")
.append(baseLineItem.getTaxable1().booleanValue());
} else if (primaryTax.equals(Tax.NEVER)
&& baseLineItem.getTaxable1().booleanValue()) {
misMatchFound = true;
if(partInfo == null) {
partInfo = new StringBuffer();
partInfo.append("Part Number : ").append(baseLineItem.getPartNum());
partInfo.append(", ");
partInfo.append("Line Abbrev : ").append(baseLineItem.getLineAbbr());
}
partInfo.append(", Primary Tax before fix : ")
.append(baseLineItem.getTaxable1().booleanValue());
baseLineItem.setTaxable1(Boolean.FALSE);
partInfo.append(", Primary Tax after fix : ")
.append(baseLineItem.getTaxable1().booleanValue());
}
}
// If secondary tax decision mismatch found, auto correct tax decision and
// collect part information for logging
String secondaryTax = taxDecision.getSecondaryTax();
if(!InvoiceLineBL.isSecondaryTaxEnabledForCustomer(customerVO, baseLineItem)) {
if (secondaryTax.equals(Tax.ALWAYS)
&& !baseLineItem.getTaxable2().booleanValue()) {
misMatchFound = true;
if(partInfo == null) {
partInfo = new StringBuffer();
partInfo.append("Part Number : ").append(baseLineItem.getPartNum());
partInfo.append(", ");
partInfo.append("Line Abbrev : ").append(baseLineItem.getLineAbbr());
}
partInfo.append(", Secondary Tax before fix : ")
.append(baseLineItem.getTaxable2().booleanValue());
baseLineItem.setTaxable2(Boolean.TRUE);
partInfo.append(", Secondary Tax after fix : ")
.append(baseLineItem.getTaxable2().booleanValue());
} else if (secondaryTax.equals(Tax.NEVER)
&& baseLineItem.getTaxable2().booleanValue()) {
misMatchFound = true;
if(partInfo == null) {
partInfo = new StringBuffer();
partInfo.append("Part Number : ").append(baseLineItem.getPartNum());
partInfo.append(", ");
partInfo.append("Line Abbrev : ").append(baseLineItem.getLineAbbr());
}
partInfo.append(", Secondary Tax before fix : ")
.append(baseLineItem.getTaxable2().booleanValue());
baseLineItem.setTaxable2(Boolean.FALSE);
partInfo.append(", Secondary Tax after fix : ")
.append(baseLineItem.getTaxable2().booleanValue());
}
}
}
// This condition is added to display the message only once
if (displayMsg && misMatchFound && !msgDisplayed) {
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"9912");
msgDisplayed = true;
}
if(partInfo != null) {
if(partTaxMisMatchList == null) {
partTaxMisMatchList = new Vector();
}
partTaxMisMatchList.add(partInfo.toString());
}
}
}
// If tax decision mismatch found, log information
if(misMatchFound) {
ClientUtil.generateTaxDecisionMismatchLog(partTaxMisMatchList, invoiceVO, customerVO);
}
}
public void lineItemAddedOutsideTAMS(final CartEvent ce) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if(ce.getModel() instanceof BaseLineItemVO){
final BaseLineItemVO line = (BaseLineItemVO)ce.getModel();
if(line.getExternalIdentifier() != null){
if(TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED.equals(line.getSpecialOrder())){
InvoiceVO directShippedInvoiceVO = invoiceVO.getDirectShippedInvoice();
if(directShippedInvoiceVO == null){
directShippedInvoiceVO = (InvoiceVO)invoiceVO.clone();
directShipLines = new Vector();
directShipLines.add(line);
directShippedInvoiceVO.setLineItems(directShipLines);
invoiceVO.setDirectShippedInvoice(directShippedInvoiceVO);
} else {
directShipLines = directShippedInvoiceVO.getLineItems();
directShipLines.add(line);
}
final List fulfillments = line.getFulfillments();
if(fulfillments != null && fulfillments.size() > 0){
for(int index = 0; index < fulfillments.size(); index++){
final FulfillmentVO fulfillmentVO = (FulfillmentVO)fulfillments.get(index);
final List fulfillmentItems = fulfillmentVO.getFulfillmentItems();
if(fulfillmentItems != null && fulfillmentItems.size() > 0){
for(int itemIndex = 0; itemIndex < fulfillmentItems.size(); itemIndex++){
if(fulfillmentItems.get(itemIndex) instanceof FulfillmentNoteVO){
final FulfillmentNoteVO fulfillmentNote = (FulfillmentNoteVO)fulfillmentItems.get(itemIndex);
final InvoiceNoteVO note = new InvoiceNoteVO();
note.setLOC(loc);
note.setExternalIdentifier(""+System.currentTimeMillis());
note.setGeneratedBySequence(line.getGeneratedBySequence());
note.setText(fulfillmentNote.getText());
note.setCompletedLine(true);
directShipLines.add(note);
}
}
}
}
}
directShippedInvoiceVO.setLineItems(directShipLines);
invoiceVO.setDirectShippedInvoice(directShippedInvoiceVO);
final InvoiceNoteVO note = new InvoiceNoteVO();
note.setLOC(loc);
note.setRefInvoiceNoteTyepID(new Integer(RefInvoiceNoteType.PHONE_ROOM_MESSAGE));
note.setExternalIdentifier(""+System.currentTimeMillis());
note.setText("DTC Shipment saved invoice for Qty: "+line.getQuantityBilled()+ " of "+line.getPartNum()+"/"+line.getLineAbbr() + " created.");
note.setCompletedLine(true);
pointOfSaleEventDispatcher.fireInvoiceLineItemAdded(new PointOfSaleListEvent(this, note));
} else {
dispatchPartLineQty(line, false);
}
} else {
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
} else if(ce.getModel() instanceof InvoiceNoteVO){
//TODO Fulfillment check needs to be done server side.
final InvoiceNoteVO note = (InvoiceNoteVO) ce.getModel();
if (getInvoicingProfile().getPrintFulFillmentNoteOnInvoice().booleanValue()) {
note.setLOC(loc);
note.setCompletedLine(true);
pointOfSaleEventDispatcher.fireInvoiceLineItemAdded(new PointOfSaleListEvent(this, note));
}
}
}
});
}
public void lineItemEditedOutsideTAMS(final CartEvent cartEvent) {
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
pointOfSaleEventDispatcher.fireSetIsNXPPunchedOut(true);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (cartEvent.getModel() instanceof BaseLineItemVO) {
final BaseLineItemVO editedCartLineItemVO = (BaseLineItemVO) cartEvent
.getModel();
final Vector lines = invoiceVO.getLineItems();
if (lines != null) {
for (int index = 0; index < lines.size(); index++) {
if(lines.get(index) instanceof BaseLineItemVO){
final BaseLineItemVO existingLine = (BaseLineItemVO) lines.get(index);
if (existingLine != null && editedCartLineItemVO.getId() != null
&& editedCartLineItemVO.getId().equals(existingLine.getId())) {
if(TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED.equals(
editedCartLineItemVO.getSpecialOrder()) || (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO))){
if (!InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
existingLine.setSpecialOrder(
TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED);
} else {
existingLine.setSpecialOrder(TsoConstant.NXP_ORDERED);
}
existingLine.setGeneratedBySequence(null);
InvoiceVO directShippedInvoiceVO = invoiceVO.getDirectShippedInvoice();
if(directShippedInvoiceVO == null){
directShippedInvoiceVO = (InvoiceVO)invoiceVO.clone();
directShipLines = new Vector();
directShipLines.add(existingLine);
directShippedInvoiceVO.setLineItems(directShipLines);
invoiceVO.setDirectShippedInvoice(directShippedInvoiceVO);
} else {
directShipLines = directShippedInvoiceVO.getLineItems();
directShipLines.add(existingLine);
}
for(int nextIndex = index + 1; nextIndex < lines.size(); nextIndex++){
InvoiceLineItemVO nextLine = (InvoiceLineItemVO)lines.get(nextIndex);
final InvoiceLineItemVO parentLineItem = (InvoiceLineItemVO) nextLine.getGeneratedByLineItem();
if(parentLineItem == null) {
continue;
}
if(parentLineItem == existingLine || parentLineItem.getGeneratedByLineItem() == existingLine){
if(nextLine!= null && nextLine instanceof KitLineItemVO) {
final KitLineItemVO subKitPart = (KitLineItemVO)nextLine;
if (!InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
subKitPart.setSpecialOrder(
TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED);
} else {
subKitPart.setSpecialOrder(TsoConstant.NXP_ORDERED);
}
nextLine = (InvoiceLineItemVO)subKitPart;
}
nextLine.setGeneratedBySequence(null);
nextLine.setGeneratedByLineItem(
(InvoiceLineItemVO) existingLine);
directShipLines.add(nextLine);
}
}
invoiceVO.setDirectShippedInvoice(directShippedInvoiceVO);
existingLine.setItemEditedOutsideTams(true);
if (!InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)) {
PointOfSaleEventDispatcher.getInstance().fireListItemSelected(
new PointOfSaleListEvent(this, null, index));
deleteInvoiceLineItem(true);
}
if(baseLineItemVO != null){
baseLineItemVO.setItemEditedOutsideTams(false);
}
if (!InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
final InvoiceNoteVO note = new InvoiceNoteVO();
note.setLOC(loc);
note.setExternalIdentifier(
"" + System.currentTimeMillis());
note.setRefInvoiceNoteTyepID(new Integer(
RefInvoiceNoteType.PHONE_ROOM_MESSAGE));
note.setText("DTC Shipment saved invoice for Qty: "
+ editedCartLineItemVO.getQuantityBilled()
+ " of " + editedCartLineItemVO.getPartNum()
+ "/" + editedCartLineItemVO.getLineAbbr()
+ " created.");
note.setCompletedLine(true);
pointOfSaleEventDispatcher.fireInvoiceLineItemAdded(
new PointOfSaleListEvent(this, note));
} else {
if (!isMessageSet) {
try {
InvoiceVO savedInvVO = InvoiceBL.recallSavedInvoice(invoiceVO.getID());
if(savedInvVO != null) {
boolean noteFound = false;
for(int j = 0; j< savedInvVO.getLineItems().size(); j++) {
if(savedInvVO.getLineItems().get(j) instanceof InvoiceNoteVO) {
InvoiceNoteVO savedVONote = (InvoiceNoteVO)savedInvVO.getLineItems().get(j);
String noteText = savedVONote.getText();
if (noteText.length() > 9) {
String subNote = noteText.substring(0,9);
noteFound = subNote.equalsIgnoreCase("NOL Order") ? true:false;
}
}
}
if (!noteFound) {
final InvoiceNoteVO nolNote = new InvoiceNoteVO();
nolNote.setLOC(loc);
nolNote.setExternalIdentifier(""
+ System.currentTimeMillis());
nolNote.setRefInvoiceNoteTyepID(
new Integer(
RefInvoiceNoteType.PHONE_ROOM_MESSAGE));
nolNote.setText(
"NOL order is saved, NOL Order Number : "
+ invoiceVO
.getSalesOrderVO()
.getNolOrderNumber());
nolNote.setCompletedLine(true);
isMessageSet = true;
pointOfSaleEventDispatcher
.fireInvoiceLineItemAdded(
new PointOfSaleListEvent(
this, nolNote));
}
}
} catch (ApplicationException e) {
final InvoiceNoteVO nolNote = new InvoiceNoteVO();
nolNote.setLOC(loc);
nolNote.setExternalIdentifier("" + System.currentTimeMillis());
nolNote.setRefInvoiceNoteTyepID(new Integer(RefInvoiceNoteType.PHONE_ROOM_MESSAGE));
nolNote.setText("NOL order is saved, NOL Order Number : " + invoiceVO.getSalesOrderVO().getNolOrderNumber());
nolNote.setCompletedLine(true);
isMessageSet = true;
pointOfSaleEventDispatcher.fireInvoiceLineItemAdded(new PointOfSaleListEvent(this, nolNote));
logger.error(e);
}
}
}
} else {
// In case sequence of NOL orders reaches here, restrict showing on
// Invoice line entry rows.
if(!InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)){
existingLine.setVersion(editedCartLineItemVO.getVersion());
existingLine.setSpecialOrder(editedCartLineItemVO.getSpecialOrder());
existingLine.setItemEditedOutsideTams(true);
PointOfSaleEventDispatcher.getInstance().fireListItemSelected(
new PointOfSaleListEvent(this, null, index));
if (lineItemHandler != null
&& lineItemHandler.getLineItemVO() != null) {
lineItemHandler.getLineItemVO().setQuantityBilled(
editedCartLineItemVO.getQuantityBilled());
invoiceLineEntryPanel.fldQuantity.setText(editedCartLineItemVO
.getQuantityBilled().toString());
addLineItemToLineList();
}
if(baseLineItemVO != null){
baseLineItemVO.setItemEditedOutsideTams(false);
}
}
}
if (TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED.equals(
editedCartLineItemVO.getSpecialOrder()) || TsoConstant.NXP_ORDERED.equals(
editedCartLineItemVO.getSpecialOrder()) || (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO))){
if (invoiceVO.getDirectShippedInvoice() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0) {
Vector invoiceLines = invoiceVO.getLineItems();
if (invoiceLines != null){
for(int lineIndex = 0; lineIndex < invoiceVO.getLineItems().size(); lineIndex++){
if(invoiceLines.get(lineIndex) instanceof BaseLineItemVO){
final BaseLineItemVO nextLine = (BaseLineItemVO) invoiceLines.get(lineIndex);
if (nextLine.getLineAbbr() != null && nextLine.getLineAbbr().equalsIgnoreCase("FRT")){
invoiceVO.getDirectShippedInvoice().getLineItems().add(nextLine);
PointOfSaleEventDispatcher.getInstance().fireListItemSelected(
new PointOfSaleListEvent(this, null, lineIndex));
PointOfSaleEventDispatcher
.getInstance()
.fireInvoiceLineItemDeleteInvoked(
new PointOfSaleListEvent(
this,
invoiceVO));
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
FocusManager.getCurrentManager().processKeyEvent(invoiceLineEntryPanel.btnDelete,new KeyEvent(
invoiceLineEntryPanel.btnDelete, KeyEvent.KEY_PRESSED,
new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
lineIndex --;
}
}
}
}
}
}
break;
}
}
}
}
}
}
});
}
private void addLineItemToLineList() {
JComponent fldQuantity = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldQuantity);
if (fldQuantity != null) {
fldQuantity.requestFocus();
}
invoiceLineEntryPanel.fldQuantity.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldQuantity, KeyEvent.KEY_PRESSED, new Date().getTime(), 0,
KeyEvent.VK_ENTER, '\n'));
if (invoiceLineEntryPanel.fldPD.isEnabled()) {
JComponent fldPD = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldPD);
if (fldPD != null) {
fldPD.requestFocus();
}
if(baseLineItemVO.getUnitPrice().doubleValue() == 0) {
return;
}
invoiceLineEntryPanel.fldPD.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldPD,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
if (invoiceLineEntryPanel.fldDC.isEnabled()) {
JComponent fldDC = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldDC);
if (fldDC != null) {
fldDC.requestFocus();
}
invoiceLineEntryPanel.fldDC.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldDC,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
if (invoiceLineEntryPanel.fldTax.isEnabled()) {
JComponent fldTax = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldTax);
if (fldTax != null) {
fldTax.requestFocus();
}
invoiceLineEntryPanel.fldTax.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldTax,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) {
JComponent fldSecondaryTax = lineItemHandler
.getNextFocus(invoiceLineEntryPanel.fldSecondaryTax);
if (fldSecondaryTax != null) {
fldSecondaryTax.requestFocus();
}
invoiceLineEntryPanel.fldSecondaryTax.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.fldSecondaryTax, KeyEvent.KEY_PRESSED, new Date()
.getTime(), 0, KeyEvent.VK_ENTER, '\n'));
}
invoiceLineEntryPanel.fldOK.setEnabled(true);
invoiceLineEntryPanel.fldOK.setText("Y");
JComponent fldOk = lineItemHandler.getNextFocus(invoiceLineEntryPanel.fldOK);
if (fldOk != null) {
fldOk.requestFocus();
}
invoiceLineEntryPanel.fldOK.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldOK,
KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n'));
invoiceLineEntryPanel.fldPartNumber.setEnabled(true);
invoiceLineEntryPanel.fldPartNumber.requestFocusInWindow();
/*
* Processing the line queue. Before this fix, line queue process was dependent on
* focusGained and focusLost from 'OK' text field. This was causing lot of user experience
* issues. This fix will make sure that user does not need to come back to TAMS for parts
* to get added to list.
*/
if ((baseLineItemVO == null || baseLineItemVO.isCompletedLine())
&& !LineGenerationQueue.getInstance().isEmpty()) {
PointOfSaleEventDispatcher.getInstance()
.fireProcessLineQueue(
new PointOfSaleEvent(this, baseLineItemVO));
invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0);
resetEntryArea(invoiceLineEntryPanel.lblPartNumber,
invoiceLineEntryPanel.fldPartNumber);
resetLineItem(null);
setPartNumberEnabled(true);
}
invoiceLineEntryPanel.fldPartNumber.requestFocusInWindow();
}
public void lineItemRemovedOutsideTAMS(final CartEvent ce) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if(ce.getModel() instanceof BaseLineItemVO){
final BaseLineItemVO line = (BaseLineItemVO)ce.getModel();
final Vector lines = invoiceVO.getLineItems();
if(lines != null){
for(int index = 0; index < lines.size(); index++){
final InvoiceLineItemVO existingLine = (InvoiceLineItemVO)lines.get(index);
if (line.getId() != null && existingLine.getId() != null
&& line.getId().equals(existingLine.getId())) {
existingLine.setItemEditedOutsideTams(true);
PointOfSaleEventDispatcher.getInstance().fireListItemSelected(
new PointOfSaleListEvent(this, null, index));
deleteInvoiceLineItem(true);
if(baseLineItemVO != null){
baseLineItemVO.setItemEditedOutsideTams(false);
}
break;
}
}
/*
* Making TAMS ready may not be entirely right. We will take a detail look
* at it after first project build.
*/
pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this));
}
}
}
});
}
public void tamsIsReady(CartEvent ce) {}
public void tamsIsBusy(CartEvent ce) {}
public void lineItemAddedInTAMS(CartEvent ce) {}
public void lineItemEditedInTAMS(CartEvent ce) {}
public void lineItemRemovedInTAMS(CartEvent ce) {}
public void invoiceLineItemSpeciallyOrdered(PointOfSaleListEvent pose) {
if(baseLineItemVO == null || baseLineItemVO.getExpandedPartNum() == null || baseLineItemVO.getLineAbbr() == null){
return;
}
if(baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NORMAL_ITEM){
return;
}
if(pose.getModel() instanceof FulfillmentVO){
final FulfillmentVO fulfillmentVO = (FulfillmentVO) pose.getModel();
final FulfillmentItemVO fulfillmentItemVO = (FulfillmentItemVO)fulfillmentVO.getFulfillmentItems().get(0);
if(fulfillmentItemVO.getLineAbbrev().equals(baseLineItemVO.getLineAbbr())
&& FwoUtil.stripChars(fulfillmentItemVO.getPartNumber(),
new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}).equals(FwoUtil.stripChars(baseLineItemVO.getExpandedPartNum(),
new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH,
PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}))){
if(baseLineItemVO.getFulfillments() == null){
baseLineItemVO.setFulfillments(new ArrayList());
}
baseLineItemVO.getFulfillments().add(fulfillmentVO);
baseLineItemVO.setSpecialOrderedQuantity(baseLineItemVO.getSpecialOrderedQuantity().add(fulfillmentItemVO.getOrderPartCount()));
if(invoiceVO.getSalesOrderVO() != null){
invoiceVO.getSalesOrderVO().addFulfillments(fulfillmentVO);
}
}
}
}
/** This method creates Direct Consumer saved invoice with fulfillment code "S"
* @param isSpecialFunctionSave
* @return True/False
*/
public boolean saveDirectShipItems(boolean isSpecialFunctionSave) {
BaseLineItemVO directToConsumerLine = null;
InvoiceVO cloneInvoiceVO = (InvoiceVO) invoiceVO.clone();
Vector itemList = cloneInvoiceVO.getLineItems();
Vector newDirectLines = new Vector();
directShipLines = new Vector();
if (invoiceVO.getDirectShippedInvoice() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems() != null
&& invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0) {
directShipLines.addAll(invoiceVO.getDirectShippedInvoice().getLineItems());
newDirectLines.addAll(directShipLines);
int directSize = directShipLines.size();
for (int index = 0; index < directSize; index++) {
if (directShipLines.get(index) instanceof BaseLineItemVO) {
directToConsumerLine = (BaseLineItemVO) directShipLines.get(index);
if (directToConsumerLine.getGeneratedBySequence() != null && itemList != null) {
for (int parentIndex = 0; parentIndex < itemList.size(); parentIndex++) {
if(itemList.get(parentIndex) instanceof BaseLineItemVO) {
final BaseLineItemVO mainLineItemVO = (BaseLineItemVO) itemList.get(parentIndex);
if (mainLineItemVO != null && directToConsumerLine.getGeneratedBySequence().equals(mainLineItemVO.getId())) {
directToConsumerLine.setCountermanEmployeeID(mainLineItemVO.getCountermanEmployeeID());
for (int childIndex = parentIndex + 1; childIndex < cloneInvoiceVO.getLineItems().size(); childIndex++) {
final InvoiceLineItemVO nextLineItem = (InvoiceLineItemVO) cloneInvoiceVO.getLineItems().get(childIndex);
final InvoiceLineItemVO parentLineItem = (InvoiceLineItemVO) nextLineItem.getGeneratedByLineItem();
if (parentLineItem == null) {
if (nextLineItem instanceof InvoiceNoteVO) {
if (InvoiceBL.doesInvoiceContainNOLOrder(
invoiceVO)) {
logger.debug(
"**************** bopis customer message");
newDirectLines.add(nextLineItem);
}
}
continue;
}
if (parentLineItem == mainLineItemVO
|| parentLineItem.getGeneratedByLineItem() == mainLineItemVO) {
if (nextLineItem instanceof InvoiceNoteVO) {
// TODO Ignoring parent item Fulfillment Notes
if (nextLineItem != null
&& ((InvoiceNoteVO) nextLineItem).getText().indexOf("Qty:") > 0
|| ((InvoiceNoteVO) nextLineItem).getText().indexOf("(transfer)") > 0) {
logger.debug("Ignoring this note: "+((InvoiceNoteVO) nextLineItem).getText());
continue;
}
} else if(nextLineItem instanceof BaseLineItemVO) {
nextLineItem.setQuantityBilled(directToConsumerLine.getQuantityBilled());
}
nextLineItem.setGeneratedByLineItem((InvoiceLineItemVO) directToConsumerLine);
newDirectLines.add(nextLineItem);
}
}
}
}
}
}
} else if (directShipLines.get(index) instanceof InvoiceNoteVO) {
InvoiceNoteVO noteItem = (InvoiceNoteVO) directShipLines.get(index);
if (noteItem.getGeneratedByLineItem() == null) {
noteItem.setGeneratedByLineItem(directToConsumerLine);
}
}
}
//Consolidating Freight Lines
InvoiceLineItemVO freightlineItemVO = consolidateFreightCharges(newDirectLines);
if(freightlineItemVO != null && freightlineItemVO.getUnitPrice().compareTo(new BigDecimal("0.00")) == 1){
newDirectLines.add(freightlineItemVO);
}
// Auto Save direct consumer items
InvoiceVO savedInvoiceVO = (InvoiceVO) invoiceVO.clone();
savedInvoiceVO.setLineItems(newDirectLines);
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
savedInvoiceVO.setDirectShipInvoice(new Boolean(false));
for (int i = 0; i < invoiceVO.getLineItems().size(); i++) {
if (invoiceVO.getLineItems().get(i) instanceof InvoiceNoteVO) {
InvoiceNoteVO noteVO = (InvoiceNoteVO) invoiceVO.getLineItems().get(i);
if (!noteVO.getText().startsWith("NOL Order") && !newDirectLines.contains(noteVO)) {
newDirectLines.add(noteVO);
}
}
if (invoiceVO.getLineItems().get(i) instanceof BaseLineItemVO && !newDirectLines.contains(invoiceVO.getLineItems().get(i))) {
BaseLineItemVO baseVO = (BaseLineItemVO) invoiceVO.getLineItems()
.get(i);
newDirectLines.add(baseVO);
}
}
} else {
savedInvoiceVO.setDirectShipInvoice(new Boolean(true));
}
savedInvoiceVO.setLineItems(newDirectLines);
//added for Direct ship invoice attention
savedInvoiceVO.setAttention(getAttentionFromPOSAttentionField());
try {
savedInvoiceVO.setSavedCart(null);
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
InvoiceBL.saveInvoice(savedInvoiceVO, customerVO, invoiceLineEntryPanel);
} else {
String ipAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
PhoneRoomInvoiceBL.saveInvoice(savedInvoiceVO,customerVO,invoiceLineEntryPanel,ipAddress);
}
} catch (ApplicationException exception) {
logger.error("ApplicationException occured while creating auto save invoice for direct ship items"
+ exception.getMessage());
}
boolean proceedToCheckout = false;
if(invoiceVO != null && invoiceVO.getLineItems().size() == 1) {
for(int lineItem = 0; lineItem < invoiceVO.getLineItems().size(); lineItem++){
InvoiceLineItemVO lineItemVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(lineItem);
if(lineItemVO instanceof BaseLineItemVO) {
proceedToCheckout = true;
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
proceedToCheckout = false;
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10137");
return false;
}
}
}
} else {
if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) {
isNXPPunchedOut = false;
proceedToCheckout = false;
pointOfSaleEventDispatcher
.fireInvoiceSaved(new InvoiceEvent(this, new InvoiceVO()));
invoiceVO.setDirectShippedInvoice(null);
clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,
"10137");
return false;
}
}
removeCDFIfOnlyNotesLeft(invoiceVO);
//Return False if invoice left with only direct consumer notes.
if(!proceedToCheckout
&& invoiceVO.getSubTotal().compareTo(new BigDecimal("0.00")) == 0) {
pointOfSaleEventDispatcher.fireInvoiceSaved(new InvoiceEvent(this, new InvoiceVO()));
invoiceVO.setDirectShippedInvoice(null);
if(isSpecialFunctionSave) {
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
invoiceLineEntryPanel.slfSpecialFunctions
.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.slfSpecialFunctions,
KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_ENTER, '\n'));
setPartNumberEnabled(false);
return true;
}
return false;
}
}
//Returning False if it is special function save to continue remaining save functionalities.
if(isSpecialFunctionSave) {
invoiceVO.setDirectShippedInvoice(null);
return false;
}
invoiceVO.setDirectShippedInvoice(null);
return true;
}
private void removeCDFIfOnlyNotesLeft(InvoiceVO invoiceVO) {
int baseLineitemCounter = 0;
int noteLineItemCounter = 0;
int cdfLineIndex = -1;
boolean isOnlyCDFLineLeft = false;
if (invoiceVO != null && invoiceVO.getLineItems() != null) {
for (int index = 0; index < invoiceVO.getLineItems().size(); index++) {
InvoiceLineItemVO lineItemVO = (InvoiceLineItemVO) invoiceVO.getLineItems()
.get(index);
if (lineItemVO instanceof BaseLineItemVO) {
if (lineItemVO.getLineAbbr()
.equalsIgnoreCase(TsoConstant.COLORADO_DELIVERY_FEE_LINE_ABBREV)) {
cdfLineIndex = index;
}
baseLineitemCounter++;
} else if (lineItemVO instanceof InvoiceNoteVO) {
noteLineItemCounter++;
}
}
if (baseLineitemCounter == 1 && noteLineItemCounter > 0 && cdfLineIndex != -1) {
invoiceVO.getLineItems().remove(cdfLineIndex);
}
}
}
//Freight charges
private InvoiceLineItemVO consolidateFreightCharges(Vector invoiceLineItems) {
logger.debug("Inside consolidateFreightLines()");
BigDecimal combineFrieghtprice = new BigDecimal("0.00");
InvoiceLineItemVO freightlineItemVO = new InvoiceLineItemVO();
if (invoiceLineItems != null) {
int listSize = invoiceLineItems.size();
for (int index = 0; index < listSize; index++) {
if (invoiceLineItems.get(index) instanceof BaseLineItemVO) {
InvoiceLineItemVO lineItemVO = (InvoiceLineItemVO) invoiceLineItems.get(index);
if (lineItemVO.getLineAbbr().equalsIgnoreCase("FRT")) {
freightlineItemVO = (InvoiceLineItemVO) lineItemVO.clone();
combineFrieghtprice = lineItemVO.getUnitPrice().add(combineFrieghtprice);
freightlineItemVO.setUnitPrice(combineFrieghtprice);
invoiceLineItems.remove(index);
listSize = invoiceLineItems.size();
index--;
}
}
}
}
return freightlineItemVO;
}
/**
* Method to check whether line item unit price value is zero or not.
*
* @return a boolean value to indicate whether line item price value is zero
* or not.
*/
private boolean isLineItemPriceZero() {
boolean isLineItemPriceZero = false;
final Integer refElectronicInvoiceId = clientApplicationContext
.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation())
.getInvoicingProfile().getRefElectronicInvoiceVendorId();
final boolean itemPriceValueRequired = clientApplicationContext
.getProfile(Profile.POINT_OF_SALE_CLIENT,
clientApplicationContext.getLocation())
.getInvoicingProfile().getItemPriceValueRequired()
.booleanValue();
if (refElectronicInvoiceId != null
&& refElectronicInvoiceId.intValue() == 1
&& itemPriceValueRequired) {
if (baseLineItemVO != null
&& (baseLineItemVO.getGeneratedByLineItem() == null || baseLineItemVO
.getCoreTransaction().booleanValue())
&& baseLineItemVO.getUnitPrice() != null
&& baseLineItemVO.getUnitPrice().compareTo(
new BigDecimal("0.00")) == 0) {
isLineItemPriceZero = true;
}
}
return isLineItemPriceZero;
}
private String getAttentionFromPOSAttentionField() {
return invoicePanel.getFldAttentionInfo().getText();
}
/**
* This method sets the CSG restricted Return Invoice PO number to current invoice PO Number
*
*/
private void setCSGRestrictedReturnInvoicePONumber() {
if (invoiceVO.getLineItems() != null) {
Object invoiceLineItem = null;
BaseLineItemVO baseLineItemVO = null;
Object invoiceReturnLineItem = null;
InvoiceLineItemReturnVO invoiceLineItemReturnVO = null;
Integer orderSubType = null;
final Vector invoiceLineItems = invoiceVO.getLineItems();
final int invoiceLineItemsSize = invoiceLineItems.size();
for (int index = 0; index < invoiceLineItemsSize; index++) {
invoiceLineItem = (Object) invoiceLineItems.get(index);
if (invoiceLineItem instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItem;
if (baseLineItemVO != null && baseLineItemVO.getQuantityBilled() != null
&& baseLineItemVO.getGeneratedByLineItem() == null
&& baseLineItemVO.getQuantityBilled().signum() == -1
&& baseLineItemVO.getReturnItems() != null
&& baseLineItemVO.getReturnItems().size() > 0) {
final Vector invoiceReturnLineItems = baseLineItemVO.getReturnItems();
if (invoiceReturnLineItems != null) {
final int invoiceReturnLineItemsSize = invoiceReturnLineItems.size();
for (int returnItemIndex = 0; returnItemIndex < invoiceReturnLineItemsSize; returnItemIndex++) {
invoiceReturnLineItem = (Object) invoiceReturnLineItems
.get(returnItemIndex);
if (invoiceReturnLineItem instanceof InvoiceLineItemReturnVO) {
invoiceLineItemReturnVO = (InvoiceLineItemReturnVO) invoiceReturnLineItem;
orderSubType = invoiceLineItemReturnVO
.getOriginalInvoiceRefOrderSubTypeId();
if (orderSubType != null && orderSubType
.intValue() == RefOrderSubType.PROLINK_CSG_RESTRICTED) {
invoiceVO.setPONumber(invoiceLineItemReturnVO
.getOriginalInvoicePONumber());
return;
}
}
}
}
}
}
}
}
}
private void readyForPickup() {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"readyForPickup() starts");
Integer customerNum = null;
CustomerVO customerVO = null;
InvoiceVO newInvoiceVO = null;
String remoteStoreIp = null;
if (invoiceVO != null) {
try {
//Stel 751
if(clientApplicationContext.isLoggedInAsPhoneRoom()) {
remoteStoreIp = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
}
if (isOnHandLowInInventory(invoiceVO,remoteStoreIp)) {
if (!clientApplicationContext.getMessageMgr().showMessageYesNo(invoiceLineEntryPanel,
"10145")) {
return;
}
}
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
customerNum = clientApplicationContext.getCustomerDAO()
.getCustomerNumberByID(invoiceVO.getCustomerID());
customerVO = clientApplicationContext.getCustomerDAO()
.getCustomerDetailInfo(customerNum);
newInvoiceVO = addTotalsToBopisInvoice(invoiceVO, customerVO);
} else {
Map customerParams = new HashMap();
customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + remoteStoreIp);
customerParams.put(TaapRouter.CUSTID, "" + invoiceVO.getCustomerID());
customerParams.put(TaapRouter.LOC, "" + loc);
customerNum = phoneRoomTaapRouter.getCustomerNumByID(customerParams);
customerParams.put(TaapRouter.TYPE, "" + "RS");
customerParams.put(TaapRouter.LANG, "" + clientApplicationContext.getCurrentLocale().getLanguage());
customerParams.put(TaapRouter.CUSTOMERNUM,""+customerNum);
customerVO = taapRouter.getCustomerDetailInfoByID(customerParams);
newInvoiceVO = addTotalsToBopisInvoicePR(invoiceVO, customerVO, remoteStoreIp);
}
logger.debug("invoiceVO.getSubTotal() = " + newInvoiceVO.getSubTotal());
logger.debug("invoiceVO.getInvoiceTotal() = " + newInvoiceVO.getInvoiceTotal());
logger.debug("invoiceVO.getTaxAmount1() = " + newInvoiceVO.getTaxAmount1());
logger.debug("invoiceVO.getTaxAmount2() = " + newInvoiceVO.getTaxAmount2());
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.INFO,
"invoiceVO.getSubTotal() = " + newInvoiceVO.getSubTotal() + "invoiceVO.getInvoiceTotal() = "
+ newInvoiceVO.getInvoiceTotal() + "invoiceVO.getTaxAmount1() = "
+ newInvoiceVO.getTaxAmount1() + "invoiceVO.getTaxAmount2() = "
+ newInvoiceVO.getTaxAmount2());
OrderNotificationStatus orderNotificationStatus = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
orderNotificationStatus = InvoiceBL
.sendOrderUpdateNotification(newInvoiceVO);
} else {
orderNotificationStatus = PhoneRoomInvoiceBL.sendOrderUpdateNotification(newInvoiceVO,remoteStoreIp);
}
if (orderNotificationStatus != null) {
boolean orderNotificationStatusValue = orderNotificationStatus.isSuccess();
if (orderNotificationStatusValue) {
boolean nofifySuccess = false;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
nofifySuccess = clientApplicationContext.getInvoiceDAO()
.notifyNolOrderPickup(invoiceVO.getSalesOrderVO());
} else {
nofifySuccess = phoneRoomTaapRouter.sendNOLOrderUpdateForPhoneRoom(invoiceVO.getSalesOrderVO(),remoteStoreIp);
}
if (!nofifySuccess) {
// Posting Unsuccessful
ClientApplicationContext.getClientApplicationContext()
.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10128");
} else {
// Posting Successful
ClientApplicationContext.getClientApplicationContext()
.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10129");
}
} else {
logger.debug("Update Order UNSUCCESSFUL !!!!!!!!!");
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"Update Order UNSUCCESSFUL !!!!!!!!!");
// Posting of Update Sales Order Unsuccessful
ClientApplicationContext.getClientApplicationContext().getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10128");
}
} else {
logger.debug("Update Order UNSUCCESSFUL !!!!!!!!!");
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"Update Order UNSUCCESSFUL !!!!!!!!!");
// Posting of Update Sales Order Unsuccessful
ClientApplicationContext.getClientApplicationContext().getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10128");
}
} catch (RemoteException e) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC())
.errorBOPISLog("Remote Exception occured during ready for pickup call " , e);
logger.debug("Remote Exception occured during ready for pickup call " + e);
} catch (ApplicationException e) {
logger.debug("Application Exception occurred during ready for pickup call " + e);
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC())
.errorBOPISLog("Application Exception occurred during ready for pickup call " , e);
}
}
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"readyForPickup() ends");
}
private InvoiceVO addTotalsToBopisInvoice(InvoiceVO invoiceVO, CustomerVO customerVO) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"addTotalsToBopisInvoice() starts");
InvoiceVO invoiceVoClone = (InvoiceVO) invoiceVO.clone();
if (invoiceVoClone != null && customerVO != null) {
try {
// set tax table infor
if (deliveryRequired(customerVO) && customerVO.getDeliveredTaxTableID() != null
&& customerVO.getDeliveredTaxTableID().intValue() > 0) {
invoiceVoClone.setPrimaryTaxTableID(customerVO.getDeliveredTaxTableID());
Vector vector = new Customer().getCustomerDeliveryTaxTables(
invoiceVoClone.getLOC(), customerVO.getDeliveredTaxTableID());
if (vector != null && !vector.isEmpty()) {
invoiceVoClone.setPrimaryTaxTableVO((TaxTableVO) vector.get(0));
if (vector.size() == 2) {
invoiceVoClone.setSecondaryTaxTableVO((TaxTableVO) vector.get(1));
invoiceVoClone.setSecondaryTaxTableID(invoiceVoClone
.getSecondaryTaxTableVO().getID());
}
}
} else {
invoiceVoClone.setPrimaryTaxTableVO(customerVO.getPrimaryTaxTable());
invoiceVoClone.setSecondaryTaxTableVO(customerVO.getSecondaryTaxTable());
invoiceVoClone.setPrimaryTaxTableID(customerVO.getDefaultTaxTableID());
invoiceVoClone.setSecondaryTaxTableID(customerVO.getSecondaryTaxTableID());
}
updateExtendedPriceToBaseLineItem(invoiceVoClone,"NA");
if (deliveryRequired(customerVO) && invoiceVO.getInvoiceDeliveryVO() == null
&& invoiceVO.getSubTotal().signum() != -1) {
invoiceVO.setDeliveryFlag(Boolean.TRUE);
invoiceVO.setInvoiceDeliveryVO(createInvoiceDeliveryVO(invoiceVO, customerVO));
}
calculateMiscAdjustments(invoiceVoClone, customerVO,"NA");
calculateTaxAmounts(invoiceVoClone, customerVO, "NA");
if (customerVO.getAlternateCoreCustomerID() != null) {
calculateAltCoreSubTotal(invoiceVoClone);
}
// Calculate invoice total
BigDecimal invoiceTotal = new BigDecimal("0.00");
invoiceTotal = invoiceTotal.add(invoiceVoClone.getSubTotal());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getDeliveryCharge());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getMiscAdjustments());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getTaxAmount1());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getTaxAmount2());
invoiceTotal = invoiceTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
invoiceVoClone.setInvoiceTotal(invoiceTotal);
CommonInvoiceBL.setTransferInvoiceTax(invoiceVO, customerVO);
} catch (ApplicationException e) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).errorBOPISLog(e.toString(), e);
logger.error(e.toString(), e);
}
}
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"addTotalsToBopisInvoice() ends");
return invoiceVoClone;
}
private boolean deliveryRequired(CustomerVO customerVO) {
boolean deliveryRequired = false;
final String customerDeliveryOption = (customerVO.getCustomerDeliveryVO() != null)
? customerVO.getCustomerDeliveryVO().getDeliveryRefOptionCD() : null;
if (customerDeliveryOption != null && customerDeliveryOption.equals("A")) {
deliveryRequired = true;
}
return deliveryRequired;
}
private void updateExtendedPriceToBaseLineItem(InvoiceVO invoiceVO,String remoteIpAddress) {
Vector lineItems = invoiceVO.getLineItems();
final int listSize = lineItems.size();
BaseLineItemVO baseLineItemVO = null;
for (int index = 0; index < listSize; index++) {
InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.elementAt(index);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
baseLineItemVO.setExtendedPrice(CommonInvoiceLineBL
.getExtendedPrice(baseLineItemVO));
} else {
baseLineItemVO.setExtendedPrice(PhoneRoomCommonInvoiceLineBL
.getExtendedPrice(baseLineItemVO,remoteIpAddress,phoneRoomTaapRouter.getStoreProfile(remoteIpAddress)));
}
}
}
}
private void calculateMiscAdjustments(InvoiceVO invoiceVO, CustomerVO customerVO,String remoteIpAddress) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"calculateMiscAdjustments() starts");
InvoicingProfileVO invoicingProfileVO = null;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
invoicingProfileVO = clientApplicationContext.getProfile(
Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation())
.getInvoicingProfile();
} else {
invoicingProfileVO = taapRouter.getInvoicingProfile(remoteIpAddress);
}
boolean isCustomerWithAlternateCoreCustomerID = (customerVO.getAlternateCoreCustomerID() != null);
if (invoicingProfileVO.getAllowMiscAdjustment().booleanValue()
&& !customerVO.getMiscInvDiscountRefOptionCD().equalsIgnoreCase("N")) {
if (customerVO.getMiscInvDiscPercent() != null) {
BigDecimal bdTempMiscAdjust = (new BigDecimal(customerVO.getMiscInvDiscPercent()
.toString()).setScale(2, BigDecimal.ROUND_HALF_UP));
BigDecimal tmpMiscAdjust = bdTempMiscAdjust.divide(new BigDecimal((double) 100), 2,
BigDecimal.ROUND_HALF_UP);
BigDecimal totalMiscAdjust = new BigDecimal("0.00");
BigDecimal lineTotal = null;
BigDecimal lineAdjust = null;
Vector vInvoiceLines = invoiceVO.getLineItems();
for (int i = 0; i < vInvoiceLines.size(); i++) {
InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) vInvoiceLines
.elementAt(i);
// if LineItem, cast to a baseLineItemVO
if (invoiceLineItemVO instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
lineTotal = CommonInvoiceLineBL.getExtendedPrice(baseLineItemVO);
} else {
lineTotal = PhoneRoomCommonInvoiceLineBL.getExtendedPrice(baseLineItemVO,remoteIpAddress,
phoneRoomTaapRouter.getStoreProfile(remoteIpAddress));
}
lineAdjust = lineTotal.multiply(tmpMiscAdjust);
lineAdjust = lineAdjust.setScale(2, BigDecimal.ROUND_HALF_UP);
// Store the Misc Adjustment Amount in the Line Item
baseLineItemVO.setMiscAdjustments(lineAdjust);
if ((!isCustomerWithAlternateCoreCustomerID)
|| (!baseLineItemVO.isCoreItem())) { // include items that goes only
// into main invoice
lineAdjust = lineAdjust.negate();
totalMiscAdjust = totalMiscAdjust.add(lineAdjust);
}
}
}
invoiceVO.setMiscAdjustments(totalMiscAdjust);
invoiceVO.setMiscAdjustmentsPercent(new Short(bdTempMiscAdjust.shortValue()));
}
}
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"calculateMiscAdjustments() ends");
}
private void calculateAltCoreSubTotal(InvoiceVO invoiceVO) {
BigDecimal alternateCoreSubTotal = new BigDecimal("0.00");
Vector lineItems = invoiceVO.getLineItems();
int listSize = lineItems.size();
for (int index = 0; index < listSize; index++) {
InvoiceLineItemVO lineItem = (InvoiceLineItemVO) lineItems.elementAt(index);
if (lineItem instanceof BaseLineItemVO) {
BaseLineItemVO baseLineItem = (BaseLineItemVO) lineItem;
if (baseLineItem.isCoreItem()) {
alternateCoreSubTotal = alternateCoreSubTotal.add(((BaseLineItemVO) lineItem)
.getExtendedPrice());
}
}
}
invoiceVO.setAlternateCoreSubTotal(alternateCoreSubTotal);
}
/**
* Calculate tax amounts.
*
* @param invoiceVo the invoice vo
*/
private void calculateTaxAmounts(InvoiceVO invoiceVo, CustomerVO customerVO, String ip) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"calculateTaxAmounts() starts");
// recalculateTaxableSales must always be called before calculate Tax amounts
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
Tax.recalculateTaxableSales(invoiceVo, false,
(customerVO.getAlternateCoreCustomerID() == null), true, Profile.SERVER, customerVO);
} else {
PhoneRoomTax.recalculateTaxableSales(invoiceVo, false,
(customerVO.getAlternateCoreCustomerID() == null), true, Profile.SERVER, customerVO, ip);
}
logger.debug("calculateTaxAmounts, calling Tax.calculateTaxAmounts");
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
Tax.calculateTaxAmounts(invoiceVo, customerVO, true);
} else {
PhoneRoomTax.calculateTaxAmounts(invoiceVo,customerVO,true,ip);
}
// setTaxPercentAndAmountValues(invoiceVo);
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"calculateTaxAmounts() ends");
}
private InvoiceDeliveryVO createInvoiceDeliveryVO(InvoiceVO invoiceVO, CustomerVO customerVO) {
final String methodSpec = " RecallSavedInvoice.createInvoiceDeliveryVO() - ";
logger.debug(methodSpec + " Invoice number =" + invoiceVO.getId());
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.INFO,
methodSpec + " Invoice number =" + invoiceVO.getId());
final InvoiceDeliveryVO invoiceDeliveryVO = new InvoiceDeliveryVO();
final CustomerDeliveryVO customerDeliveryVO = customerVO.getCustomerDeliveryVO();
final BigDecimal minimumSalesForFreeDelivery = customerDeliveryVO.getMinAmtFreeDelivery();
if (minimumSalesForFreeDelivery.signum() == 0
|| invoiceVO.getSubTotal().compareTo(minimumSalesForFreeDelivery) == -1) {
invoiceVO.setDeliveryCharge(customerDeliveryVO.getDeliveryCharge().setScale(2,
BigDecimal.ROUND_HALF_UP));
}
invoiceDeliveryVO.setInvoiceID(invoiceVO.getID());
invoiceDeliveryVO.setLOC(invoiceVO.getLOC());
invoiceDeliveryVO.setDeliveryPriorityID(customerDeliveryVO.getDeliveryPriorityID());
invoiceDeliveryVO.setTravelMinutes(customerDeliveryVO.getTravelTimeCustomer());
invoiceDeliveryVO.setDeliveryDescription("Our Truck");
invoiceDeliveryVO.setDeliveryRouteCD(customerDeliveryVO.getDeliveryRouteCD());
return invoiceDeliveryVO;
}
private boolean isOnHandLowInInventory(InvoiceVO invoiceVO, String remoteIpAddress) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"isOnHandLowInInventory() starts");
boolean isOnHandLow = false;
int inventory = -2;
InventoryVO inventoryVo = null;
CustomerVO customerVo = null;
String lang = clientApplicationContext.getCurrentLocale().getLanguage();
if (invoiceVO != null) {
try {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
customerVo = clientApplicationContext.getCustomerDAO().getCustomerDetailInfoByID(
invoiceVO.getCustomerID(), null);
} else {
Map customerParams = new HashMap();
customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + remoteIpAddress);
customerParams.put(TaapRouter.CUSTOMERNUM, "" + "1");
customerParams.put(TaapRouter.TYPE, "" + "RS");
customerParams.put(TaapRouter.CUSTID, "" + invoiceVO.getCustomerID());
customerParams.put(TaapRouter.LANG, "" + lang);
customerParams.put(TaapRouter.LOC, "" + loc);
customerVo = taapRouter.getCustomerDetailInfoByID(customerParams);
}
if (invoiceVO.getLineItems() != null) {
for (int i = 0; i < invoiceVO.getLineItems().size(); i++) {
if (invoiceVO.getLineItems().get(i) instanceof KitLineItemVO) {
KitLineItemVO compLine = (KitLineItemVO) invoiceVO.getLineItems()
.get(i);
if (customerVo != null && compLine.getPartNum() != null
&& compLine.getLineAbbr() != null) {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
inventoryVo = clientApplicationContext.getInventoryDAO()
.getPartDetailInfo(customerVo, compLine.getPartNum(),
compLine.getLineAbbr(), false);
} else {
inventoryVo = phoneRoomTaapRouter.getPartDetailInfo(customerVo,compLine.getLineAbbr(),compLine.getPartNum(),
false,remoteIpAddress,lang,false);
}
// Call Inventory
if (inventoryVo != null
&& inventoryVo.getInventoryStockVO() != null) {
if (inventoryVo.getInventoryStockVO().getOnHand() != null
&& compLine.getQuantityBilled() != null) {
BigDecimal onHandQty = inventoryVo.getInventoryStockVO()
.getOnHand();
inventory = onHandQty.compareTo(compLine
.getQuantityBilled());
if (inventory == -1) {
isOnHandLow = true;
break;
}
}
}
}
} else if (invoiceVO.getLineItems().get(i) instanceof BaseLineItemVO) {
// BaseLineItemVO selectedVO = (BaseLineItemVO)
// recallSavedInvoiceDialog.lstSavedItems.getSelectedValue();
BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceVO
.getLineItems().get(i);
if (customerVo != null && baseLineItemVO.getPartNum() != null
&& baseLineItemVO.getLineAbbr() != null) {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
inventoryVo = clientApplicationContext.getInventoryDAO()
.getPartDetailInfo(customerVo, baseLineItemVO.getPartNum(),
baseLineItemVO.getLineAbbr(), false);
} else {
inventoryVo = phoneRoomTaapRouter.getPartDetailInfo(customerVo,baseLineItemVO.getLineAbbr(),baseLineItemVO.getPartNum(),
false,remoteIpAddress,lang,false);
}
if (inventoryVo != null
&& inventoryVo.getInventoryStockVO() != null) {
if (inventoryVo.getInventoryStockVO().getOnHand() != null
&& baseLineItemVO.getQuantityBilled() != null) {
BigDecimal onHandQty = inventoryVo.getInventoryStockVO()
.getOnHand();
inventory = onHandQty.compareTo(baseLineItemVO
.getQuantityBilled());
if (inventory == -1) {
isOnHandLow = true;
break;
}
}
}
}
}
}
}
} catch (ApplicationException ae) {
ae.printStackTrace();
}
}
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"isOnHandLowInInventory() ends");
return isOnHandLow;
}
private void changeBtnFinalizeName() {
if (isNXPPunchedOut) {
pointOfSaleEventDispatcher.fireSetIsNXPPunchedOut(true);
return;
}
SalesOrderVO salesOrderVO = null;
String remoteIpAddress = null;
invoiceLineEntryPanel.btnFinalize.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnFinalize",
clientApplicationContext.getCurrentLocale()));
if (invoiceVO != null) {
boolean isBopis = InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO);
if (invoiceVO.getSalesOrderVO() != null && invoiceVO.getSalesOrderVO().getId() != null) {
try {
if(!invoiceVO.isPhoneRoomMessagesFlag()) {
salesOrderVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(
invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
} else {
remoteIpAddress = PhoneRoomInvoiceBL.getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
salesOrderVO = new TaapRouter().getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(), remoteIpAddress);
}
} catch (ApplicationException e) {
logger.debug("Error occured while fetching sales order details");
} catch (IOException e) {
logger.debug("Error occured while fetching sales order details");
}
}
if (isBopis && salesOrderVO != null && salesOrderVO.getRefOrderStatusId() != null
&& (salesOrderVO.getRefOrderStatusId().intValue() != RefNOLOrderStatus.READY_FOR_PICKUP && salesOrderVO.getRefOrderStatusId().intValue() != RefNOLOrderStatus.DELIVERED)) {
invoiceLineEntryPanel.btnFinalize.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnFinalize.ReadyForPickup",
clientApplicationContext.getCurrentLocale()));
logger.debug("Checkout Button Name = "
+ invoiceLineEntryPanel.btnFinalize.getText());
boolean npxApprovalRequired = checkForNxpApproval();
if (npxApprovalRequired) {
invoiceLineEntryPanel.btnFinalize.setText(clientApplicationContext
.getResourceBundleReader().getLocalizedText(ResourceBundleReader.UI,
"InvoiceLineEntryPanel.btnFinalize.ContinueToNXP",
clientApplicationContext.getCurrentLocale()));
logger.debug("NXP Checkout Button Name = "
+ invoiceLineEntryPanel.btnFinalize.getText());
}
}
}
}
public void setIsNXPPunchedOut(boolean isPunchedOut) {
if (isPunchedOut) {
invoiceLineEntryPanel.btnFinalize
.setText(clientApplicationContext.getResourceBundleReader().getLocalizedText(
ResourceBundleReader.UI, "InvoiceLineEntryPanel.btnFinalize",
clientApplicationContext.getCurrentLocale()));
}
isNXPPunchedOut = isPunchedOut;
}
private boolean readyForPickupAndSave(){
BOPISLogger.getInstance().setStoreProfile(loc).addBOPISLog(Constants.DEBUG, "readyForPickupAndSave() starts");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
boolean saveInvoiceFlag = false;
String ipAddress = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());
invoiceVO.setWorkInProgressUpdated(new Boolean(true));
if(!invoiceVO.isPhoneRoomMessagesFlag()){
saveInvoiceFlag = InvoiceBL.saveInvoice(invoiceVO, customerVO,
invoiceLineEntryPanel);
} else {
invoiceVO.setSavedInvoiceType(TsoConstant.CALL_CENTER_SAVED_INVOICE);
saveInvoiceFlag = PhoneRoomInvoiceBL.saveInvoice(invoiceVO,customerVO,invoiceLineEntryPanel,ipAddress);
}
if (saveInvoiceFlag) {
readyForPickup();
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.INFO,
"saved invoice: " + invoiceVO.getID());
logger.debug("saved invoice: " + invoiceVO.getID());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pointOfSaleEventDispatcher.fireInvoiceSaved(new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
invoiceLineEntryPanel.btnFinalize.dispatchEvent(new KeyEvent(
invoiceLineEntryPanel.btnFinalize,
KeyEvent.KEY_PRESSED, new Date().getTime(),
0, KeyEvent.VK_ENTER, '\n'));
setPartNumberEnabled(false);
}
}); // end invoke later here
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
BOPISLogger.getInstance().setStoreProfile(loc).errorBOPISLog(ae.toString(), ae);
clientApplicationContext.getMessageMgr().showMessage(
invoiceLineEntryPanel, "2204");
return;
}
}
});
BOPISLogger.getInstance().setStoreProfile(loc).addBOPISLog(Constants.DEBUG, "readyForPickupAndSave() ends");
return true;
}
private void removeRetailDeliveryFee(Vector specialFunctionItems, String retailDeliveryFee) {
if (specialFunctionItems == null || specialFunctionItems.size() == 0) {
return;
}
RefTableVO item = null;
for (Object x : specialFunctionItems) {
if (!(x instanceof RefTableVO)) {
continue;
}
item = (RefTableVO) x;
if (item.getCD().equals(retailDeliveryFee)) {
specialFunctionItems.remove(x);
break;
}
}
}
private InvoiceVO addTotalsToBopisInvoicePR(InvoiceVO invoiceVO, CustomerVO customerVO, String remoteIpAddress) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"addTotalsToBopisInvoice() starts");
InvoiceVO invoiceVoClone = (InvoiceVO) invoiceVO.clone();
if (invoiceVoClone != null && customerVO != null) {
try {
// set tax table infor
if (deliveryRequired(customerVO) && customerVO.getDeliveredTaxTableID() != null
&& customerVO.getDeliveredTaxTableID().intValue() > 0) {
invoiceVoClone.setPrimaryTaxTableID(customerVO.getDeliveredTaxTableID());
Vector vector = phoneRoomTaapRouter.getCustomerDeliveryTaxTables(
invoiceVoClone.getLOC(), customerVO.getDeliveredTaxTableID(),remoteIpAddress);
if (vector != null && !vector.isEmpty()) {
invoiceVoClone.setPrimaryTaxTableVO((TaxTableVO) vector.get(0));
if (vector.size() == 2) {
invoiceVoClone.setSecondaryTaxTableVO((TaxTableVO) vector.get(1));
invoiceVoClone.setSecondaryTaxTableID(invoiceVoClone
.getSecondaryTaxTableVO().getID());
}
}
} else {
invoiceVoClone.setPrimaryTaxTableVO(customerVO.getPrimaryTaxTable());
invoiceVoClone.setSecondaryTaxTableVO(customerVO.getSecondaryTaxTable());
invoiceVoClone.setPrimaryTaxTableID(customerVO.getDefaultTaxTableID());
invoiceVoClone.setSecondaryTaxTableID(customerVO.getSecondaryTaxTableID());
}
updateExtendedPriceToBaseLineItem(invoiceVoClone,remoteIpAddress);
if (deliveryRequired(customerVO) && invoiceVO.getInvoiceDeliveryVO() == null
&& invoiceVO.getSubTotal().signum() != -1) {
invoiceVO.setDeliveryFlag(Boolean.TRUE);
invoiceVO.setInvoiceDeliveryVO(createInvoiceDeliveryVO(invoiceVO, customerVO));
}
calculateMiscAdjustments(invoiceVoClone, customerVO, remoteIpAddress);
calculateTaxAmounts(invoiceVoClone, customerVO,remoteIpAddress);
if (customerVO.getAlternateCoreCustomerID() != null) {
calculateAltCoreSubTotal(invoiceVoClone);
}
// Calculate invoice total
BigDecimal invoiceTotal = new BigDecimal("0.00");
invoiceTotal = invoiceTotal.add(invoiceVoClone.getSubTotal());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getDeliveryCharge());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getMiscAdjustments());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getTaxAmount1());
invoiceTotal = invoiceTotal.add(invoiceVoClone.getTaxAmount2());
invoiceTotal = invoiceTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
invoiceVoClone.setInvoiceTotal(invoiceTotal);
CommonInvoiceBL.setTransferInvoiceTax(invoiceVO, customerVO);
} catch (Exception e) {
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).errorBOPISLog(e.toString(), e);
logger.error(e.toString(), e);
}
}
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG,
"addTotalsToBopisInvoice() ends");
return invoiceVoClone;
}
/**
* When RADS order fails, this method makes invoice line NXP-compatible.
*
* @param invoiceVO
*/
public void makeInvoiceLinesNXPEligible(InvoiceVO invoiceVO) {
if(invoiceVO != null && invoiceVO.getLineItems() != null) {
Vector lineItems = invoiceVO.getLineItems();
final int listSize = lineItems.size();
BaseLineItemVO baseLineItemVO = null;
for (int index = 0; index < listSize; index++) {
InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.elementAt(index);
if (invoiceLineItemVO instanceof BaseLineItemVO) {
baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO;
if(baseLineItemVO != null && baseLineItemVO.getSpecialOrder().equals(TsoConstant.NAPA_XPRESS)
&& baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.DC_ITEM) {
baseLineItemVO.setRefInvoiceLineItemTypeID(new Byte((byte) RefInvoiceLineItemType.NORMAL_ITEM));
clientApplicationContext.getPointOfSaleEventDispatcher().fireLineItemEditedInTAMS(
new CartEvent(this, baseLineItemVO));
BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.ERROR,
"An error occurred during the creation of the RADS order! Making the invoice line NXP-compatible");
}
}
}
}
}
public boolean validateNapaAAAMembership() {
final String methodSpec = "InvoiceLineEntryController.validateNapaAAAMembership - ";
logger.debug(methodSpec);
if (CustomerBL.isAAACustomer(customerVO)
&& InvoiceBL.doesInvoiceContainPurchaseItem(invoiceVO)
&& StringUtils.isNotEmpty(getStoreProfile().getPostalCode())
&& getStoreProfile().getRefCountryCd().equalsIgnoreCase(RefCountry.UNITED_STATES)
&& !RefStoreConfigurationUtil.isAAALookupByNameEnabled()) {
AaaValidationController validationController = new AaaValidationController(
this.parentView);
validationController.setInitialData(invoiceVO);
int validationStatus = validationController.show();
if (validationStatus == -1) {
return false;
}
}else if(CustomerBL.isAAACustomer(customerVO)
&& InvoiceBL.doesInvoiceContainPurchaseItem(invoiceVO)
&& getStoreProfile().getRefCountryCd().equalsIgnoreCase(RefCountry.UNITED_STATES)
&& RefStoreConfigurationUtil.isAAALookupByNameEnabled()) {
AaaMemberValidationController validationController = new AaaMemberValidationController(
this.parentView);
validationController.setInitialData(invoiceVO);
int validationStatus = validationController.show();
if (validationStatus == -1) {
return false;
}
}
return true;
}
public boolean doesAAAMembershipValidationRequired() {
final String methodSpec = "CustomerBL.doesAAAMembershipValidationRequired - ";
logger.debug(methodSpec);
final ClientApplicationContext clientApplicationContext = ClientApplicationContext
.getClientApplicationContext();
final StoreProfileVO storeProfile = clientApplicationContext
.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation())
.getStoreProfile();
final String validateAAACardNumber = storeProfile.getValidateAAAcardnumber();
logger.debug(methodSpec + "validateAAACardNumber = " + validateAAACardNumber);
return TsoConstant.GENERIC_Y.equalsIgnoreCase(validateAAACardNumber);
}
private void processCancelOrder(InvoiceVO invoiceVO) {
String remoteStoreIP = null;
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
try{
remoteStoreIP = getRemoteIpAddress(invoiceVO.getRemoteStoreNumber());}
catch (ApplicationException e) {
logger.error("Error in getting remote store ip" ,e);
}
}
String finalRemoteStoreIP = remoteStoreIP;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SalesOrderVO salesVO = null;
try {
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
salesVO = new TaapRouter()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue(), finalRemoteStoreIP);
}else{
salesVO = clientApplicationContext.getOrderingDAO()
.getSalesOrderDetailsBySalesOrderId(invoiceVO.getSalesOrderVO().getId(),
invoiceVO.getLOC().intValue());
}
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
bopisCancelReasonController = new BopisCancelReasonController(bopisCancelReasonDialog, salesVO, baseLineItemVO);
bopisCancelReasonController.setSource("InvoiceLineEntryController");
bopisCancelReasonController.setViewVisible(true);
if(!bopisCancelReasonController.isCancelled()){
if (invoiceVO.getSavedInvoiceIdForDeletion() == null) {
try {
InvoiceInitializerFunctions
.sequenceLines(invoiceVO.getLineItems());
if(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()){
new TaapRouter().saveInvoice(invoiceVO,finalRemoteStoreIP);
}else
{
clientApplicationContext.getInvoiceDAO()
.saveInvoice(invoiceVO, customerVO);
}
} catch (ApplicationException ae) {
logger.error(ae.toString(), ae);
// save error
clientApplicationContext.getMessageMgr()
.showMessage(invoiceLineEntryPanel, "10143");
return;
}
}
clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled(
new InvoiceEvent(this, new InvoiceVO()));
if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) {
pointOfSaleEventDispatcher.fireChangedToCashier(null);
}
}
}
});
}
}