package com.gpc.client.pointofsale.invoice; 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.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.net.MalformedURLException; import java.net.URL; import java.rmi.RemoteException; import java.util.*; import javax.swing.FocusManager; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.border.TitledBorder; import org.apache.commons.httpclient.HttpException; import org.apache.log4j.Logger; import com.gpc.backofficecommon.report.TsoReportHelper; import com.gpc.backofficecommon.report.criteria.TsiQuestionConstants; import com.gpc.backofficecommon.util.Encryptor; import com.gpc.backofficecommon.util.TamsMisc; import com.gpc.businessservice.factory.corebank.CoreBankServiceFactory; import com.gpc.businessservice.factory.loyalty.LoyaltyProgramServiceFactory; import com.gpc.businessservice.factory.ppseservice.PPSEServiceFactory; import com.gpc.businessservice.factory.rads.RadsServiceFactory; import com.gpc.businessservice.factory.security.SecurityServiceFactory; import com.gpc.businessservice.interfaces.corebank.CoreBankService; import com.gpc.businessservice.interfaces.loyalty.LoyaltyProgramService; import com.gpc.businessservice.interfaces.ppseservice.PPSEService; import com.gpc.businessservice.valueobject.ppseservice.PPSECartVO; import com.gpc.client.common.ClientApplicationContext; import com.gpc.client.common.ClientPropConstants; import com.gpc.client.common.ClientResourceUsage; 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.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.InvoiceListener; import com.gpc.client.common.event.LocaleEvent; import com.gpc.client.common.event.POSStateEvent; import com.gpc.client.common.event.POSStateListener; import com.gpc.client.common.event.POSTAMSEvent; 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.ProfileEvent; import com.gpc.client.common.event.ProfileListener; import com.gpc.client.common.event.StoreEvent; import com.gpc.client.common.focusmanager.FocusDecider; import com.gpc.client.common.input.document.FwoValidatedWholeNumberDocument; import com.gpc.client.common.input.document.TsoTextPersistedDateDocument; import com.gpc.client.common.input.verifier.FwoBaseInputVerifier; import com.gpc.client.common.input.verifier.FwoDateVerifier; import com.gpc.client.common.input.verifier.FwoNumberVerifier; import com.gpc.client.common.mvc.IView; import com.gpc.client.common.ppse.PPSE2Helper; import com.gpc.client.common.util.Browser; import com.gpc.client.common.util.BrowserLauncher; import com.gpc.client.pointofsale.PointOfSaleConstants; import com.gpc.client.pointofsale.PointOfSaleFrame; import com.gpc.client.pointofsale.cashier.CashierController; import com.gpc.client.pointofsale.catalog.CatalogBL; import com.gpc.client.pointofsale.customer.CustomerBL; import com.gpc.client.pointofsale.customer.CustomerInfoController; import com.gpc.client.pointofsale.customer.CustomerPhoneController; import com.gpc.client.pointofsale.customer.CustomerPhoneDialog; import com.gpc.client.pointofsale.customer.CustomerSearchController; import com.gpc.client.pointofsale.giftcard.NewNapaGiftCardController; import com.gpc.client.pointofsale.inventory.StockController; import com.gpc.client.pointofsale.invoice.line.ChooseStoreController; import com.gpc.client.pointofsale.invoice.line.InvoiceLineBL; import com.gpc.client.pointofsale.invoice.line.InvoiceLineCodeParser; import com.gpc.client.pointofsale.invoice.line.InvoiceLineEntryController; import com.gpc.client.pointofsale.invoice.line.InvoiceLineEntryPanel; import com.gpc.client.pointofsale.invoice.line.InvoiceLineListController; import com.gpc.client.pointofsale.invoice.line.InvoiceLineListPanel; import com.gpc.client.pointofsale.invoice.line.LineGenerationQueue; import com.gpc.client.pointofsale.message.ReviewMessagesController; 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.ResizablePanel; 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.TsoCurrentUser; import com.gpc.common.constants.PasswordConstants; import com.gpc.common.constants.loyalty.LoyaltyConstants; import com.gpc.common.constants.refvalues.RefCatalogDataVersion; import com.gpc.common.constants.refvalues.RefState; import com.gpc.common.constants.refvalues.RefCatalogPreference; import com.gpc.common.constants.refvalues.RefCustomerType; import com.gpc.common.constants.refvalues.RefLanguage; import com.gpc.common.constants.refvalues.RefLoyaltyCustomerStatus; import com.gpc.common.constants.refvalues.RefNAPACustomerCategory; import com.gpc.common.constants.refvalues.RefPasswordStatus; import com.gpc.common.constants.refvalues.RefPhoneRoomInvoiceSetting; import com.gpc.common.constants.refvalues.RefRegulatoryType; import com.gpc.common.constants.refvalues.RefInvoiceLineItemType; import com.gpc.common.empservice.EmployeeServiceUtil; import com.gpc.common.exception.ApplicationException; import com.gpc.common.exception.ApplicationRuntimeException; import com.gpc.common.pattern.DatePatternFormatException; import com.gpc.common.pattern.FwoDatePattern; import com.gpc.common.pattern.FwoPattern; import com.gpc.common.pattern.FwoPhonePattern; import com.gpc.common.pattern.FwoZipPattern; import com.gpc.common.pattern.PatternFormatException; import com.gpc.common.pattern.PhonePatternFormatException; import com.gpc.common.pattern.ZipPatternFormatException; import com.gpc.common.security.util.EmployeeAccessValidator; import com.gpc.common.session.PPSESessionData; 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.ParameterizedStringParser; import com.gpc.common.util.RefStoreConfigurationUtil; import com.gpc.common.util.StringUtils; import com.gpc.server.servlet.GetBarCodeDetailsServlet; import com.gpc.valueobjects.PointOfSaleVO; import com.gpc.valueobjects.catalog.VehicleVO; import com.gpc.valueobjects.common.IDValuePairVO; import com.gpc.valueobjects.common.POSStateVO; import com.gpc.valueobjects.common.ServerInfoVO; import com.gpc.valueobjects.customer.CustomerContactVO; import com.gpc.valueobjects.customer.CustomerVO; import com.gpc.valueobjects.employee.EmployeeVO; import com.gpc.valueobjects.inventory.InventoryVO; import com.gpc.valueobjects.inventory.KitInventoryVO; import com.gpc.valueobjects.inventory.RegulationRulePartVO; 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.InvoiceLineItemReturnVO; import com.gpc.valueobjects.invoice.line.InvoiceLineItemVO; import com.gpc.valueobjects.invoice.line.InvoiceNoteVO; import com.gpc.valueobjects.invoice.line.PhoneRoomStoreVO; import com.gpc.valueobjects.ppse.PPSEStatusVO; import com.gpc.valueobjects.price.PricesInVO; import com.gpc.valueobjects.price.PricesOutVO; import com.gpc.valueobjects.profile.InventoryProfileVO; import com.gpc.valueobjects.profile.InvoicingProfileVO; import com.gpc.valueobjects.profile.StoreProfileVO; import com.gpc.valueobjects.report.FwoPrintSettings; import com.gpc.valueobjects.report.FwoPrinterSelectionSettings; import com.gpc.valueobjects.report.FwoRefReportRequest; import com.gpc.valueobjects.report.FwoReportResponse; import com.gpc.valueobjects.report.criteria.FwoQuestionAnswer; import com.gpc.valueobjects.report.criteria.FwoQuestionAnswerMap; import com.gpc.valueobjects.report.criteria.FwoRefReportCriteria; import com.gpc.valueobjects.system.ResourceUsageVO; import com.gpc.valueobjects.tax.TaxDecisionVO; import com.gpc.valueobjects.tax.TaxTableVO; import com.gpc.valueobjects.loyalty.LoyaltyRequest; import com.gpc.valueobjects.loyalty.LoyaltyResponse; import com.gpc.valueobjects.message.MessagePartVO; import com.gpc.client.pointofsale.invoice.line.DefaultLineItemHandler; import com.gpc.client.pointofsale.phoneRoomMessages.PhoneRoomMessageController; import com.gpc.client.pointofsale.customer.*; import com.gpc.client.pointofsale.customer.CustomerInfoController; import com.gpc.client.pointofsale.invoice.line.*; import com.gpc.client.pointofsale.tax.PhoneRoomTax; import com.gpc.tams.comm.io.PhoneRoomTaapRouter; import com.gpc.tams.comm.io.TaapRouter; /** * *

Title:

*

Description:

*

Copyright: Copyright © 2003

*

Company: Genuine Parts Company

* @author Copyright © 2003 Genuine Parts Company * @version 1.0 */ public class InvoiceController extends BaseController implements Runnable, InvoiceListener, WindowListener, CatalogListener, PropertyChangeListener, InvoiceLineEntryListener, CustomerListener, BuyoutListener, ProfileListener, EmployeeListener, PointOfSaleListListener, POSStateListener, CartListener { private static final Logger logger = Logger.getLogger(InvoiceController.class); private InvoicePanel invoicePanel; private InvoiceVO invoiceVO; private DisplayableInvoiceVO displayableInvVO; private InvoiceLineListController invoiceLineListController; private InvoiceLineEntryController invoiceLineEntryController; private ReviewMessagesController reviewMessagesController; private CustomerInfoController customerInfoController; private NewNapaGiftCardController newNapaGiftCardController; private StockController stockController; private CustomerPhoneController customerPhoneController; private PhoneNumberController phoneNumberController; private InvitationController invitationController; private PhoneNumberDialog phoneNumberDialog; private CustomerVO customerVO; private String oldCustomerNum; private Vector vSalespersonList = new Vector(); private String initialItem; private String notAssigned; private EmployeeVO employeeVO; private JTextField fldCustomer; private JTextField fldSalesperson; private Integer counterManID; private CashierController cashierController; private Container parentContainer; private Byte refLoyaltyCustomerStatusId; private String loyaltyCustomerLookup; private String loyaltyCustomerExternalIdentifier; private List phoneRoomStoresList; private InvoicingProfileVO invoicingProfileVO = null; private boolean buyoutOpenedFromTAMS = false; private LoyaltyProgramService loyaltyProgramService = null; //Added for core bank FwoReportResponse m_rptResponse = null; FwoRefReportCriteria rptCriteria = null; private boolean useSaveInvoice = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getUseSaveInvoice().booleanValue(); private boolean skipCustomerPresent = false; private boolean loadedFromRecallSavedInvoice = false; private int noOfFailedLoginAttempts; private boolean encryptionRequired = false; private String encryptedPassword; private boolean changePassword = false; private int tempEmpNum = -1; private final String PROGRAM_SOURCE_NAME = "PointOfSale"; private static int REFRESH_TIME = 20 * 1000; private final PPSEService ppseService = PPSEServiceFactory.getServiceInstance(); private final boolean ppse2Active; private BaseLineItemVO partsProSe2StockCheckInventoryVO = null; private static final Object timerLock = new Object(); private static final java.util.Timer partsProSe2Timer = new java.util.Timer( true ); private static volatile TimerTask partsProSe2CheckForItemsTask = null; private static volatile String ppse2GuiInstanceId = null; private static List ppse2Lines = new ArrayList(); private static boolean ppse2LinesProcessing = false; private static boolean listItemSelected = false; private ChooseStoreController chooseStoreController; private BigDecimal alternateCoreSubTotal = new BigDecimal("0.00"); private boolean certificatePartExist = false; private boolean ableToAcceptROAPayments = false; private StoreProfileVO storeProfile = null; private boolean gpcOwned = false; private boolean isNapaRewardProgramOn = false; private int empNum=0; private String partVal; private static void setPPSE2TimerTask( TimerTask task ) { synchronized( timerLock ) { partsProSe2CheckForItemsTask = task; } } private static boolean isPPSE2TimerTaskCancelled() { synchronized( timerLock ) { return (partsProSe2CheckForItemsTask == null); } } private static void cancelPPSE2TimerTask() { synchronized( timerLock ) { if (partsProSe2CheckForItemsTask != null) { final TimerTask tmpTask = partsProSe2CheckForItemsTask; partsProSe2CheckForItemsTask = null; tmpTask.cancel(); } } } public InvoiceController(Container parentContainer, InvoiceLineEntryController invoiceLineEntryController) { ppse2Active = ppseService.isPPSE2Active(); invoicingProfileVO = getInvoicingProfileVO (); invoiceVO = new InvoiceVO(); displayableInvVO = new DisplayableInvoiceVO(); invoicePanel = new InvoicePanel( ppse2Active ,clientApplicationContext.isLoggedInAsPhoneRoom()); this.invoiceLineEntryController = invoiceLineEntryController; invoiceLineEntryController.setInvoiceController( this ); this.parentContainer = parentContainer; stockController = new StockController(parentContainer); invoiceLineEntryController.setInvoiceVO(invoiceVO); invoiceLineEntryController.setStockController(stockController); invoiceLineEntryController.setDispInvVO(displayableInvVO); invoiceLineListController = new InvoiceLineListController(parentContainer, invoiceVO, displayableInvVO); reviewMessagesController = new ReviewMessagesController(parentContainer); invoicePanel.add((InvoiceLineListPanel) invoiceLineListController.getView()); invoicePanel.add((InvoiceLineEntryPanel) invoiceLineEntryController.getView()); customerPhoneController = new CustomerPhoneController(parentContainer); if (!clientApplicationContext.getSystemDAO().enableROA().booleanValue()) { invoicePanel.btnROA.setEnabled(false); } storeProfile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile(); gpcOwned = storeProfile.getGpcOwned().booleanValue(); boolean printROAReceipts = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getARProfile().getPrintROAReceipts().booleanValue(); loyaltyProgramService = LoyaltyProgramServiceFactory.getLoyaltyProgramService(); if (gpcOwned) { ableToAcceptROAPayments = clientApplicationContext.getSystemDAO().ableToAcceptROAPayments( loc, clientApplicationContext.getCurrentUser().getEmployeeId()); invoicePanel.btnROA.setEnabled(ableToAcceptROAPayments && printROAReceipts); } if (!clientApplicationContext.getSystemDAO().enableMessageButton().booleanValue() || clientApplicationContext.isLoggedInAsSales()) { invoicePanel.btnMessage.setEnabled(false); } if (!clientApplicationContext.getSystemDAO().askEmployeePassword().booleanValue()) { invoicePanel.pswdEmployee.setVisible(false); } if (invoicingProfileVO.getEnableCoreReturnLaw().booleanValue()) { invoicePanel.lblPrimaryTaxNumber.setVisible(true); invoicePanel.lblSecondaryTaxNumber.setVisible(true); invoicePanel.pnlCustomerTaxNumber.setVisible(true); } phoneNumberController = new PhoneNumberController((Frame)parentContainer); invitationController = new InvitationController((Frame)parentContainer); phoneNumberDialog = (PhoneNumberDialog) phoneNumberController.getView(); initializeDisplayPricing(); install(invoicePanel); localizeView(); invoicePanel.setVisible(true); } /** * Stel-473 * @param vo * @return */ public boolean checkNXPLineItems(InvoiceVO vo){ Vector itemList = invoiceVO.getLineItems(); if (itemList != null) { int listSize = itemList.size(); InvoiceLineItemVO lineItem = null; for (int index = 0; index < listSize; index++) { lineItem = (InvoiceLineItemVO) itemList.elementAt(index); if (lineItem instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) lineItem; if(TsoConstant.NXP_ORDERED.equalsIgnoreCase(baseLineItemVO.getSpecialOrder())){ partVal = baseLineItemVO.getPartNum(); return true; } } } } return false; } /** * To remove phone room line items when the store changed. */ private void storeChanged() { if (loadedFromRecallSavedInvoice && invoiceVO != null && invoicePanel.cbStore.getSelectedItem() != null) { invoiceVO.setRemoteStoreNumber(((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem()).getStoreNumber()); invoiceVO.setPhoneRoomStoreId(((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem()).getId()); clientApplicationContext.setRemoteStoreNumber(((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem()).getStoreNumber()); StoreEvent event = new StoreEvent(this, ((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem())); pointOfSaleEventDispatcher.fireStoreChanged(event); } else if (invoiceVO != null && invoicePanel.cbStore.getSelectedItem() != null) { PhoneRoomStoreVO phoneRoomStoreVO = ((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem()); String newStoreNumber = phoneRoomStoreVO.getStoreNumber(); String storeNumberAndName = newStoreNumber.substring(newStoreNumber.length() - 3) + " " + phoneRoomStoreVO.getStoreName(); String oldStoreNumber = invoiceVO.getRemoteStoreNumber(); if (oldStoreNumber != null && !oldStoreNumber.equals(newStoreNumber)) { boolean allowChangeStore = true; boolean lineItemExist = invoiceVO.getLineItems() != null && !invoiceVO.getLineItems().isEmpty(); if (lineItemExist) { if(InvoiceBL.isRemoteStore(newStoreNumber) && InvoiceBL.invoiceHasReturnItems(invoiceVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9546"); allowChangeStore = false; } else { if(!checkNXPLineItems(invoiceVO)) { allowChangeStore = clientApplicationContext.getMessageMgr().showMessageNoYes( invoicePanel, "9545", storeNumberAndName); } else { clientApplicationContext.getMessageMgr().showMessage( invoicePanel, "9553", partVal); allowChangeStore = false; } } } if (allowChangeStore) { invoiceVO.setRemoteStoreNumber((newStoreNumber)); clientApplicationContext.setRemoteStoreNumber(newStoreNumber); invoiceVO.setPhoneRoomStoreId(((PhoneRoomStoreVO) invoicePanel.cbStore .getSelectedItem()).getId()); //T2CAN-411 adding condition to update call center flag( if enabled) when remote store is selected if(invoiceVO!=null){ try { invoiceVO.setPhoneRoomMessagesFlag((ClientApplicationContext.getClientApplicationContext() .isLoggedInAsPhoneRoom() && invoiceVO.getRemoteStoreNumber()!=null && InvoiceBL.isRemoteStore() && ClientApplicationContext.getClientApplicationContext().getMessageDAO(). checkServingStoreMSGFlag()) ?true:false); } catch (ApplicationException e) { logger.error("Exception while checking Call center flag**"+e); } } StoreEvent event = new StoreEvent(this, ((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem())); pointOfSaleEventDispatcher.fireStoreChanged(event); if (lineItemExist) { InvoiceLineBL.removeInterStoreAndEjoeiOrderInformation(invoiceVO); clientApplicationContext.getPointOfSaleEventDispatcher() .fireInvoiceLineItemDeleted( new PointOfSaleListEvent(this, invoiceVO)); checkAvailableQuantity(); } } else { selectStoreByNumber(oldStoreNumber); } } else { clientApplicationContext.setRemoteStoreNumber(newStoreNumber); } } } /** * Checks the available quantity in the serving store. */ private void checkAvailableQuantity() { Vector itemList = invoiceVO.getLineItems(); if (itemList != null) { int listSize = itemList.size(); InvoiceLineItemVO lineItem = null; for (int index = 0; index < listSize; index++) { lineItem = (InvoiceLineItemVO) itemList.elementAt(index); if (lineItem instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) lineItem; if (baseLineItemVO.isQuantityNotDistributed()) { InventoryVO inventoryVo = clientApplicationContext.getInventoryDAO() .getPartDetailInfo(customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), false); String availableString = InvoiceLineBL.getAvailableQuantityByStore(loc, invoiceVO, inventoryVo, customerVO,false); BigDecimal availableQuantity = new BigDecimal("0.00"); try { availableQuantity = new BigDecimal(availableString); } catch (NumberFormatException nfe) { availableQuantity = new BigDecimal("0.00"); } BigDecimal quantityBilled = baseLineItemVO.getQuantityBilled(); if (quantityBilled != null && availableQuantity.compareTo(quantityBilled) >= 0) { baseLineItemVO.setQuantityNotDistributed(false); } } } } clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemsChanged( new PointOfSaleListEvent(this, invoiceVO)); } } private void populateStore() { try { invoicePanel.cbStore.removeAllItems(); List stores = InvoiceBL.getPhoneRoomStoreList(); phoneRoomStoresList = stores; logger.warn("inside invoice controller populate store() phoneroom stores size"+phoneRoomStoresList.size()); if (stores.size() > 0) { for (int i=0; i < stores.size(); i++) { PhoneRoomStoreVO dto = (PhoneRoomStoreVO)stores.get(i); if (!dto.getServingDC().booleanValue()) { if (dto.getDefaultServing().booleanValue()) { invoicePanel.cbStore.insertItemAt(dto, 0); } else { invoicePanel.cbStore.addItem(dto); } } } invoicePanel.cbStore.setSelectedIndex(0); invoiceVO.setRemoteStoreNumber(((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem()).getStoreNumber()); invoiceVO.setPhoneRoomStoreId(((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem()).getId()); } } catch (ApplicationException ex) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, ex.getUserMessageID(), ex.getUserMessageParameters()); return; } } private void initializeDisplayPricing() { if (!clientApplicationContext.isPOSPricingDeviceEnabled().booleanValue()) { invoiceVO.setDisplayPricing(false); } else if (clientApplicationContext.isLoggedInAsCashier()) { invoiceVO.setDisplayPricing(true); } else { String dispPricing = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getDisplayPOSPricingToCustomer(); if (dispPricing.equalsIgnoreCase("A")) { invoiceVO.setDisplayPricing(true); } else { invoiceVO.setDisplayPricing(false); } } } private void displayMessage() { /*if we don't execute popupVisible false, we have double focus issues with COD customers / and when items have price of 0. This happens when using the keyboard and not mouse.*/ invoicePanel.cbCustomer.setPopupVisible(false); boolean allMultipleUsersForMessages = false; String resource = "ReviewMessagesController"; ResourceUsageVO resourceUsageVO = new ResourceUsageVO(); EmployeeVO o = new EmployeeVO(); o.setID(clientApplicationContext.getCurrentUser().getEmployeeId()); resourceUsageVO.setEmployee(o); resourceUsageVO.setLocation(loc); resourceUsageVO.setResource(resource); resourceUsageVO.setSession(clientApplicationContext.getSessionId()); resourceUsageVO.setTerminal(clientApplicationContext.getSystemDAO( ).getTerminalFromIPAddress(clientApplicationContext.getClientIPAddress(), loc)); clientApplicationContext.getProfile(Profile.SERVER,clientApplicationContext.getLocation()).invalidateInvoicingProfile(); if(clientApplicationContext.isLoggedInAsPhoneRoom()){ allMultipleUsersForMessages = true; logger.warn("User Logged in as Phone Room user "); } else { logger.warn("User Logged in as non Phone Room user "); allMultipleUsersForMessages = clientApplicationContext.getProfile(Profile.SERVER, clientApplicationContext.getLocation()). getInvoicingProfile().getAllowMultipleUsersForMessage().booleanValue(); } logger.warn("Value for the allMultipleUsersForMessages boolean is "+allMultipleUsersForMessages); if(!allMultipleUsersForMessages){ if (!(clientApplicationContext.getResourceUsageDAO().setMessagesInUse(resourceUsageVO).booleanValue())) { invoicePanel.cbCustomer.setPopupVisible(true); //1393 = Messages are being reviewed elsewhere. Please try again later. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1393"); return; } 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); } reviewMessagesController.setResourceUsageVO(resourceUsageVO); reviewMessagesController.setViewVisible(true); if (reviewMessagesController.getModel() != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (customerVO == null) { InvoiceController.this.fldCustomer.requestFocus(); } else if (invoicePanel.cbSalesperson.isEnabled()) { invoicePanel.cbAuthorizedBuyer.dispatchEvent(new KeyEvent(invoicePanel.cbAuthorizedBuyer, KeyEvent.KEY_PRESSED, new Date().getTime(), KeyEvent.SHIFT_MASK, KeyEvent.VK_TAB, '\t')); } else if (invoicePanel.cbAuthorizedBuyer.isEnabled()) { invoicePanel.cbBuyerPhone.dispatchEvent(new KeyEvent(invoicePanel.cbBuyerPhone, KeyEvent.KEY_PRESSED, new Date().getTime(), KeyEvent.SHIFT_MASK, KeyEvent.VK_TAB, '\t')); } else { invoicePanel.btnPartsPro.setEnabled(true); invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoicePanel.btnMessage.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoicePanel.btnStoresMessages!=null) { invoicePanel.btnStoresMessages.setEnabled(false); } invoiceLineEntryController.setPartNumberEnabled(true); invoicePanel.btnRecallSavedInvoice.dispatchEvent( new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } } }); } } } 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); } else { logger.warn("Inside phone Room else condition check in InvoiceController :: "); boolean flag = clientApplicationContext.getResourceUsageDAO().setMessagesInUse(resourceUsageVO); if (flag) { reviewMessagesController.setResourceUsageVO(resourceUsageVO); } } reviewMessagesController.setViewVisible(true); if (reviewMessagesController.getModel() != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (customerVO == null) { InvoiceController.this.fldCustomer.requestFocus(); } else if (invoicePanel.cbSalesperson.isEnabled()) { invoicePanel.cbAuthorizedBuyer.dispatchEvent(new KeyEvent(invoicePanel.cbAuthorizedBuyer, KeyEvent.KEY_PRESSED, new Date().getTime(), KeyEvent.SHIFT_MASK, KeyEvent.VK_TAB, '\t')); } else if (invoicePanel.cbAuthorizedBuyer.isEnabled()) { invoicePanel.cbBuyerPhone.dispatchEvent(new KeyEvent(invoicePanel.cbBuyerPhone, KeyEvent.KEY_PRESSED, new Date().getTime(), KeyEvent.SHIFT_MASK, KeyEvent.VK_TAB, '\t')); } else { invoicePanel.btnPartsPro.setEnabled(true); invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoicePanel.btnMessage.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(false); } invoiceLineEntryController.setPartNumberEnabled(true); invoicePanel.btnRecallSavedInvoice.dispatchEvent( new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } } }); } } } public void actionPerformed(ActionEvent ae) { fireStartTimer(); Component source = (Component) ae.getSource(); if (source.getName().equals(InvoicePanel.BTN_SEARCH)) { displayCustomerSearch (); } else if (source.getName().equals(InvoicePanel.BTN_ROA)) { triggerROAInvoked(); } else if (source.getName().equals(InvoicePanel.BTN_MESSAGE)) { displayMessage(); } else if (source.getName().equals(InvoicePanel.BTN_STOCK_CHECK)) { 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); } if (clientApplicationContext.getSystemDAO().askForPassword( PasswordConstants.STOCK_CHECK_PWD).booleanValue()) { PasswordController passwordController = new PasswordController((Frame) parentContainer); passwordController.setInitialData(PasswordConstants.STOCK_CHECK_PWD); passwordController.setViewVisible(true); if (passwordController.getPasswordValid()) { SwingUtilities.invokeLater(new Runnable() { public void run() { final BaseLineItemVO tmp = partsProSe2StockCheckInventoryVO; partsProSe2StockCheckInventoryVO = null; stockController.setInitialData(customerVO, tmp); stockController.setViewVisible(true); } }); } } else { SwingUtilities.invokeLater(new Runnable() { public void run() { final BaseLineItemVO tmp = partsProSe2StockCheckInventoryVO; partsProSe2StockCheckInventoryVO = null; stockController.setInitialData(customerVO, tmp); stockController.setViewVisible(true); } }); } } else if (source.getName().equals(InvoicePanel.BTN_RECALL_SAVED_INVOICE)) { recallSavedInvoice(null, null, null); } else if (source.getName().equals(InvoicePanel.CB_STORE)) { storeChanged(); } else if (source.getName().equals(InvoicePanel.BTN_STORES_MESSAGES)) { displayProvisionedStoresMessages(); }else if (source.getName().equals(InvoicePanel.CB_AUTHORIZED_BUYER)) { authorizedBuyerChanged(); } else if (source.getName().equals(InvoicePanel.BTN_PARTS_PRO)) { if(InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)){ clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10124"); return; } if(invoiceVO.isReturnInvoice()){ clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10308"); return; } if(InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)){ clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10202"); return; } if(InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)){ final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10212", originalInvoiceNumber); return; } if (isPreferencePPSE()) { logger.debug("actionPerformed: CatalogButton Pushed: isPreferencePPSE/calling openPPSE"); openPPSE(); } else { logger.debug("actionPerformed: CatalogButton: preference is NOT PPSE"); if (!CatalogBL.verifyDVDServices()) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2208"); return; } // code added to avoid display network connectivity issue message // when user preferences is other than Parts pro SE. clientApplicationContext.setDisplayPpse2MaxOutageMsg(false); invoicePanel.setVisible(false); clientApplicationContext.getPointOfSaleEventDispatcher() .fireCatalogingOpened(new CatalogEvent(this, null)); } } else if (source.getName().equals(InvoicePanel.CK_CUSTOMER_PRESENT)) { invoiceVO.setDisplayPricing(invoicePanel.ckCustomerPresent.isSelected()); } else if (source.getName().equals(InvoicePanel.BTN_VIEW_OPEN_CORES)) { viewOpenCores(); } else if (source.getName().equals(InvoicePanel.BTN_IMPORT_CART)) { importCartContents(); } } private Boolean preferencePPSE = null; private boolean isPreferencePPSE() { if (preferencePPSE != null) { return preferencePPSE.booleanValue(); } boolean retFlag = false; TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); if(currentUser != null) { EmployeeVO employeeVO = null; try { employeeVO = clientApplicationContext.getEmployeeDAO().getEmployeeDetailInfo(currentUser.getEmployeeNum()); } catch (ApplicationException ae) { logger.error(ae); setWaitCursor(false); } if (employeeVO == null) { logger.warn( "No employee information found for logged-in user (user likely logged in as Sales)" ); } int catalogPreference = RefCatalogPreference.PARTSPRO_CATEGORY; if ((employeeVO != null) && (employeeVO.getRefCatalogPreference() != null)) { catalogPreference = employeeVO.getRefCatalogPreference().intValue(); } else { // get the default value from the system if there is one. int loc = clientApplicationContext.getLocation(); Integer cp = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, loc).getInvoicingProfile().getRefCatalogPreferenceID(); if(cp != null) { catalogPreference = cp.intValue(); } } if (ppse2Active) { if ((employeeVO != null && isPreferenceLocked( employeeVO.getRefCatalogPreference(), employeeVO.getAllowChangeCatalogPreference()))) { retFlag = true; } else if (isPreferenceLocked( invoicingProfileVO.getRefCatalogPreferenceID(), invoicingProfileVO.getAllowChangeCatalogPreference())) { retFlag = true; } } if (retFlag || catalogPreference == RefCatalogPreference.PARTSPRO_SE) { retFlag = true; } else { retFlag = false; } } else { retFlag = false; } preferencePPSE = new Boolean( retFlag ); return retFlag; } private boolean isPreferenceLocked(Integer preference, String allowChange) { return preference != null && preference.intValue() == RefCatalogPreference.PARTSPRO_SE && allowChange.equalsIgnoreCase("N"); } private void triggerROAInvoked () { if (clientApplicationContext.isLoggedInAsSales()) { clientApplicationContext.getPointOfSaleEventDispatcher().fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); } 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); } invoicePanel.btnROA.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); EmployeeVO o = null; TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); if (currentUser != null) { o = new EmployeeVO(); o.setID(currentUser.getEmployeeId()); o.setEmployeeNum(currentUser.getEmployeeNum()); o.setFirstName(currentUser.getFirstName()); o.setLastName(currentUser.getLastName()); } //This line of code needs to come after dispatching TAB key event if (clientApplicationContext.isLoggedInAsSales()) { this.parentContainer.setVisible(false); } pointOfSaleEventDispatcher.firePOSROAInvoked (new POSTAMSEvent (this, o)); } public InvoicingProfileVO getInvoicingProfileVO() { return clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile(); } public void catalogingOpened(CatalogEvent ce) { } public void catalogingClosed(CatalogEvent ce) { invoicePanel.add((InvoiceLineEntryPanel) invoiceLineEntryController.getView()); ((InvoiceLineEntryPanel) invoiceLineEntryController.getView()).setBounds(1, 521, 1014, 152); invoicePanel.setVisible(true); invoicePanel.btnPartsPro.dispatchEvent(new KeyEvent(invoicePanel.btnPartsPro, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); invoiceLineEntryController.invoicingVisible(true); ClientApplicationContext.getClientApplicationContext().setCatalogInUse(false); } public void catalogTitleChanged(CatalogTitleEvent cte) { } public void invalidCatalogLookupPerformed(CatalogEvent ce) { } public void catalogPartsListChanged(CatalogPartsListEvent cple) { } public void catalogPartSelected(CatalogEvent ce) { } public void windowClosing(WindowEvent we) { } public void windowActivated(WindowEvent we) { } public void windowClosed(WindowEvent we) { } public void windowDeactivated(WindowEvent we) { } public void windowDeiconified(WindowEvent we) { } public void windowIconified(WindowEvent we) { } public void windowOpened(WindowEvent we) { } public void verifyEmployee() { TsoCurrentUser tsoCurrentUser = (TsoCurrentUser) clientApplicationContext.getCurrentUser(); if (tsoCurrentUser != null && tsoCurrentUser.getEmployeeNum() != null && tsoCurrentUser.getEmployeeNum().intValue() > 0) { invoicePanel.fldEmployee.setText(tsoCurrentUser.getEmployeeNum().toString()); if (!clientApplicationContext.isLoggedInAsSales() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() != POSStateVO.INVOICING_AS_CASHIER)) { invoicePanel.fldEmployee.setEnabled(false); } invoicePanel.dlblEmployee.setText(tsoCurrentUser.getFirstName() + " " + tsoCurrentUser.getLastName()); invoicePanel.pswdEmployee.setVisible(false); counterManID = tsoCurrentUser.getEmployeeId(); if (customerInfoController == null) { customerInfoController = new CustomerInfoController(invoicePanel); } pointOfSaleEventDispatcher.fireEmployeeLoggedIn(new EmployeeEvent(this, employeeVO)); } else { pointOfSaleEventDispatcher.fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); } } public void displayCustomerInfo(CustomerVO customerVO) { Integer verifyCustNum = null; if (customerVO != null) { verifyCustNum = customerVO.getCustomerNumber(); } try { customerVO = clientApplicationContext.getCustomerDAO().getCustomerDetailInfo(new Integer(0)); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } if (verifyCustNum == null) { customerVO.setCustomerTypeCD(RefCustomerType.RETAIL_ACCOUNT); customerVO.setCustomerNumber( clientApplicationContext.getCustomerDAO().getNextRetailCustomerNum()); } else { customerVO.setCustomerNumber(verifyCustNum); customerVO.setCustomerTypeCD(RefCustomerType.VERIFY_ACCOUNT); } if (customerInfoController == null) { customerInfoController = new CustomerInfoController (invoicePanel); } customerInfoController.setModel(customerVO); customerInfoController.setViewVisible(true); //Bug #31446, "If" condition is changed for the button "Ok" //and else is made for button"Cancel and "frame "X" close button /*if (customerInfoController.isCancelled()) { customerVO = null; oldCustomerNum = null; ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()).setText(""); invoicePanel.cbCustomer.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } else { this.customerVO = (CustomerVO) customerInfoController.getModel(); enableSalesperson(); displayCustomerDetails(); setInvoiceVOCustomerAttributes(); SwingUtilities.invokeLater(new Runnable() { public void run() { invoicePanel.cbAuthorizedBuyer.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); }*/ if(customerInfoController.isOk()) { this.customerVO = (CustomerVO) customerInfoController.getModel(); enableSalesperson(); displayCustomerDetails(); setInvoiceVOCustomerAttributes(); SwingUtilities.invokeLater(new Runnable() { public void run() { invoicePanel.cbAuthorizedBuyer.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); // Added for add retail customer functionality delegateToESBRegistration(); }else{ customerVO = null; oldCustomerNum = null; ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()).setText(""); invoicePanel.cbCustomer.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); }//Bug #31446 end } private void enableSalesperson() { if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getAllowChangeSalesman().booleanValue()) { invoicePanel.cbSalesperson.setEnabled(true); invoicePanel.cbSalesperson.setEditable(true); } else { invoicePanel.cbSalesperson.setEditable(false); invoicePanel.cbSalesperson.setEnabled(false); if (invoicePanel.ckCustomerPresent.isVisible() && customerVO != null) { invoicePanel.ckCustomerPresent.setEnabled(true); } if (invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { invoicePanel.cbAuthorizedBuyer.setEnabled(true); invoicePanel.lblAuthorizedBuyer.setEnabled(true); invoiceLineEntryController.setPartNumberEnabled(true); } else { if ((customerVO != null) && (!customerVO.isAuthorizedBuyersOnly() || (customerVO.isAuthorizedBuyersOnly() && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() > 0))) { invoicePanel.btnPartsPro.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (!invoiceLineEntryController.getPartNumberComponent().isEnabled()) { invoiceLineEntryController.setPartNumberEnabled(true); invoiceLineEntryController.getPartNumberComponent().requestFocus(); } } }); } } } } private void disableBeforeCustomerButtons() { invoicePanel.btnROA.setEnabled(false); invoicePanel.btnMessage.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(false); } } private void getAndDisplayCustomerInfo(int customerID, String customerTypeCD) { try { if(!invoiceVO.isPhoneRoomMessagesFlag()){ customerVO = clientApplicationContext.getCustomerDAO().getCustomerDetailInfoByID( new Integer(customerID), customerTypeCD); }else{ Map customerParams = new HashMap(); customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + PhoneRoomInvoiceBL.getRemoteIpAddress(invoiceVO.getRemoteStoreNumber())); customerParams.put(TaapRouter.CUSTOMERNUM, "" + invoiceVO.getCustomerID()); customerParams.put(TaapRouter.TYPE, "" + "RS"); customerParams.put(TaapRouter.CUSTID, "" + invoiceVO.getCustomerID()); customerParams.put(TaapRouter.LANG, "" + clientApplicationContext.getCurrentLocale().getLanguage()); customerParams.put(TaapRouter.LOC, "" + loc); customerVO = new TaapRouter().getCustomerDetailInfoByID(customerParams); } } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } if (customerVO != null) { oldCustomerNum = customerVO.getCustomerNumber().toString(); } if(loadedFromRecallSavedInvoice){ setInvoiceDetails(); } else { invoiceVO.setPrimaryTaxTableVO(customerVO.getPrimaryTaxTable()); invoiceVO.setSecondaryTaxTableVO(customerVO.getSecondaryTaxTable()); } displayCustomerDetails(); } private void setInvoiceDetails() { TaxTableVO primaryTaxTableVO = null; TaxTableVO secondaryTaxTableVO = null; primaryTaxTableVO = clientApplicationContext.getSystemDAO().getTaxTable( loc, invoiceVO.getPrimaryTaxTableID()); if ((invoiceVO.getSecondaryTaxTableID() != null && invoiceVO.getSecondaryTaxTableID().shortValue() > 0)){ secondaryTaxTableVO = clientApplicationContext.getSystemDAO().getTaxTable( loc, invoiceVO.getSecondaryTaxTableID()); } invoiceVO.setPrimaryTaxTableVO(primaryTaxTableVO); invoiceVO.setSecondaryTaxTableVO(secondaryTaxTableVO); invoiceVO.setLoadedFromRecallSavedInvoice(true); } public void displayCustomerSearch () { boolean allowDisplay = canChangeCustomer(); if (allowDisplay) { logger.debug("CUSTOMER_SEARCH DISPLAY - SHOW"); //DISPLAY CustomerSearchController customerSearchController = new CustomerSearchController(parentContainer); customerSearchController.show(); logger.debug("CUSTOMER_SEARCH DISPLAY - DONE"); //UPDATE if (customerSearchController.getModel() != null) { customerVO = (CustomerVO) customerSearchController.getModel(); //added to help with 27395 - please remove final CustomerVO fromSearchVO = customerVO; //added to help with 27395 - please remove try { customerVO = clientApplicationContext.getCustomerDAO().getCustomerDetailInfoByID( customerVO.getID(), customerVO.getCustomerTypeCD()); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } logger.debug("CUSTOMER_SEARCH UPDATE"); SwingUtilities.invokeLater(new Runnable() { public void run() { /** * This try/catch surround is not a bug fix it is code added for bug 27395 to * understand it better. Please see bugzilla for discussion. Please remove this * try catch when this issue is resolved. */ try { if (verifyCustomerVO(customerVO.getCustomerNumber() .toString())) { updateCustomerIdForRadsItems(); if (clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile() .getAllowChangeSalesman() .booleanValue()) { invoicePanel.cbSalesperson.setEnabled(true); invoicePanel.cbSalesperson.getEditor() .getEditorComponent() .requestFocus(); } else if (invoicePanel.cbAuthorizedBuyer .isEnabled()) { invoicePanel.cbAuthorizedBuyer .requestFocus(); } else if (invoiceLineEntryController .getPartNumberComponent().isEnabled()) { invoiceLineEntryController .getPartNumberComponent() .requestFocus(); } } else { customerVO = null; } } catch (NullPointerException npe) { StringBuffer strb = new StringBuffer(); strb.append("CustomerVO from search dialog: ").append(voInfo(fromSearchVO)). append(",CustomerDetail VO: ").append(voInfo(customerVO)); //this should give us some more detail logger.fatal(strb.toString(),npe); //allow to return like the t/c above } //end of bug code for this method } }); } } logger.debug("CUSTOMER_SEARCH EXIT"); } /*** * For bug 27395 - please remove when this is resolved. * */ private String voInfo(CustomerVO customer) { if (customer == null) { return "null"; } StringBuffer sb = new StringBuffer(). append("{CustomerID= ").append(customer.getID()). append(",CustomerName= ").append(customer.getName()). append(",AccountActive= ").append(customer.isAccountActive()).append("}"); return sb.toString(); } public void retrieveAvailableAndLimit() { Thread processingThread = new Thread(this); try { processingThread.start(); } catch (IllegalThreadStateException itse) { throw new ApplicationRuntimeException(itse, ApplicationRuntimeException.GENERIC_SHORT_MESSAGE_ID); } } public void refreshSavedInvoice () { Thread refreshSavedInvoiceThread = new Thread(new Runnable() { public void run() { while(invoiceVO != null && invoiceVO.getSavedInvoiceIdForDeletion() != null) { try { clientApplicationContext.getInvoiceDAO().refreshSavedInvoice(invoiceVO.getSavedInvoiceIdForDeletion(), loc, clientApplicationContext.getSystemDAO().getServerDate()); Thread.sleep(REFRESH_TIME); } catch(ApplicationException ae) { logger.error(ae.getMessage(), ae); //Update error clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2229"); } catch(InterruptedException e) { logger.error(e.getMessage(), e); //Update error clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2229"); } } } }); refreshSavedInvoiceThread.start(); } public void run() { Object[] availCreditAndLim = CustomerBL.getAvailableCreditAndLimit(customerVO); invoicePanel.dlblAvailable.setText((String) availCreditAndLim[1]); invoicePanel.dlblLimit.setText((String) availCreditAndLim[0]); } private void populateBillTypeAndTax() { // populate BillingType panel invoicePanel.dlblAvailable.setText(""); invoicePanel.dlblLimit.setText(""); retrieveAvailableAndLimit(); invoicePanel.dlblBillingType.setText(customerVO.getBillType()); //populate tax fields invoicePanel.dlblPrimaryTax.setText(customerVO.getTaxStatusPrimaryCodeDescription()); invoicePanel.dlblPrimaryTaxState.setText(customerVO.getState()); invoicePanel.dlblTaxExemptNum.setText(customerVO.getTaxExemptNumberPrimary()); boolean showSecondary = false; showSecondary = CustomerBL.hasSecondaryTax(customerVO); FwoDatePattern fwoDatePattern = (FwoDatePattern) FwoPattern.getDatePatternInstance( clientApplicationContext.getCurrentLocale(), new Integer( clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getStoreProfile().getRefDateFormatId().intValue())); try { invoicePanel.dlblTaxExpDate.setText(fwoDatePattern.format( customerVO.getTaxExemptPrimaryExpDate())); } catch (DatePatternFormatException dpfe) { invoicePanel.dlblTaxExpDate.setText(""); } try { if (showSecondary) { invoicePanel.dlblSecondaryTaxExpDate.setText(fwoDatePattern.format( customerVO.getTaxExemptNumberSecondary())); } } catch (DatePatternFormatException dpfe) { if (showSecondary) { invoicePanel.dlblSecondaryTaxExpDate.setText(""); } } if (showSecondary) { invoicePanel.dlblSecondaryTax.setText( customerVO.getTaxStatusSecondaryCodeDescription()); invoicePanel.dlblSecondaryTaxState.setText(customerVO.getState()); invoicePanel.dlblSecondaryTaxExemptNum.setText( customerVO.getTaxExemptNumberSecondary()); invoicePanel.lblSecondaryTax.setVisible(true); } else { invoicePanel.dlblSecondaryTax.setText(""); invoicePanel.dlblSecondaryTaxState.setText(""); invoicePanel.dlblSecondaryTaxExemptNum.setText(""); invoicePanel.lblSecondaryTax.setVisible(false); } } private void populatePhoneFax() { Locale recordLocale = clientApplicationContext.getCurrentLocale(); if (customerVO != null && customerVO.getRefLanguageCD() != null && customerVO.getCountryCD() != null) { recordLocale = new Locale(customerVO.getRefLanguageCD(), customerVO.getCountryCD()); } FwoPhonePattern fwoPhonePattern = (FwoPhonePattern) FwoPattern .getPhonePatternInstance(recordLocale); if(customerVO.getPhone() == null){ invoicePanel.dlblPhone.setText(TsoConstant.EMPTY_STRING); } else { try { invoicePanel.dlblPhone.setText(fwoPhonePattern.format(customerVO.getPhone())); } catch (PhonePatternFormatException phonePatternFormatException) { invoicePanel.dlblPhone.setText(customerVO.getPhone()); } } if (customerVO.getFaxNumber() == null) { invoicePanel.dlblFax.setText(TsoConstant.EMPTY_STRING); } else { try { invoicePanel.dlblFax.setText(fwoPhonePattern.format(customerVO.getFaxNumber())); } catch (PhonePatternFormatException phonePatternFormatException) { invoicePanel.dlblFax.setText(customerVO.getFaxNumber()); } } } public void displayProvisionedStoresMessages(){ PhoneRoomMessageController phoneRoomMessageController = new PhoneRoomMessageController(parentContainer,phoneRoomStoresList); phoneRoomMessageController.show(); } public void recallSavedInvoice(Integer customerID, String customerTypeCD, Integer customerNumber) { if (clientApplicationContext.getSystemDAO().askForPassword( PasswordConstants.RECALL_SAVED_PWD).booleanValue()) { PasswordController passwordController = new PasswordController((Frame) parentContainer); passwordController.setInitialData(PasswordConstants.RECALL_SAVED_PWD); passwordController.setViewVisible(true); if (!passwordController.getPasswordValid()) { return; } } RecallSavedInvoiceController recallSavedInvoiceController = new RecallSavedInvoiceController(parentContainer); recallSavedInvoiceController.setCustomerID (customerID); recallSavedInvoiceController.setCustomerNumber(customerNumber); recallSavedInvoiceController.setCustomerTypeCD(customerTypeCD); final String napaRewardsPromptOption = invoicingProfileVO.getRewardsProgramPrompt(); isNapaRewardProgramOn = (invoicingProfileVO.getUseNAPARewards().booleanValue() && !invoiceVO.getManualTransaction().booleanValue() && customerVO != null && customerVO.getREFNAPACustomerCategoryID() != null && customerVO.getREFNAPACustomerCategoryID() .intValue() == (RefNAPACustomerCategory.RETAIL_DIY) && !(clientApplicationContext.isLoggedInAsPhoneRoom() && (isPhoneRoomMessageCheckout() || isRemoteStore()))); if (isNapaRewardProgramOn && (napaRewardsPromptOption.equals(LoyaltyConstants.CUSTOMER_ONLY) || napaRewardsPromptOption.equals(LoyaltyConstants.CUSTOMER_AND_TENDER))) { recallSavedInvoiceController.setDosePhoneNumberDialogueRequire(true); } recallSavedInvoiceController.show(); SwingUtilities.invokeLater(new Runnable() { public void run() { if (customerVO == null) { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); } InvoiceController.this.fldCustomer.requestFocus(); } else if (customerVO != null && customerVO.isAuthorizedBuyersOnly() && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) { invoicePanel.cbAuthorizedBuyer.requestFocus(); } else { invoicePanel.btnPartsPro.setEnabled(true); invoicePanel.btnMessage.setEnabled(false); invoicePanel.btnRecallSavedInvoice.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbStore.setEnabled(false); invoicePanel.btnStoresMessages.setEnabled(false); } invoiceLineEntryController.setPartNumberEnabled(true); invoicePanel.btnRecallSavedInvoice.dispatchEvent( new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } } }); } /** * This method to display the RadsRequestActivity dialog and set the focus on POS screen on * close of RADS Request Activity screen. * * @param radsRequestActivityController Contains RadsRequestActivityController object */ public void displayRadsRequestActivity( RadsRequestActivityController radsRequestActivityController) { radsRequestActivityController.showRadsRequestActivity(); SwingUtilities.invokeLater(new Runnable() { public void run() { if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) { ((PointOfSaleFrame) parentContainer).setOtherTAMSFunctionsMenuItem(false); } else if (customerVO == null) { InvoiceController.this.fldCustomer.requestFocus(); } else if (customerVO != null && customerVO.isAuthorizedBuyersOnly() && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) { invoicePanel.cbAuthorizedBuyer.requestFocus(); } else { invoicePanel.btnPartsPro.setEnabled(true); invoicePanel.btnMessage.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(false); } invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoiceLineEntryController.setPartNumberEnabled(true); FocusManager.getCurrentManager().processKeyEvent(invoicePanel.btnRecallSavedInvoice,new KeyEvent( invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } } }); } private void message() { } public void focusGained(FocusEvent fe) { preferencePPSE = null; if (fe.getComponent().getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { //Disable Catlog button invoicePanel.btnPartsPro.setEnabled(false); if (invoiceVO == null && invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(false); } //Notify PointOfSalecontroller to enable Add Retail Customer clientApplicationContext.getPointOfSaleEventDispatcher().fireCustomerFieldFocusGained(new CustomerEvent(this, null)); } if (fe.getComponent().getName().equals(InvoicePanel.FLD_EMPLOYEE_NUM)) { //if focus is coming from customer, we want all change customer events to run first SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher().fireEmployeeLoggedOut( new EmployeeEvent(this, employeeVO)); } }); } else if (fe.getComponent().getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { invoicePanel.btnRecallSavedInvoice.setEnabled( (this.useSaveInvoice) && (invoiceVO.getLineItems() == null || invoiceVO.getLineItems().isEmpty())); if (invoicePanel.pswdEmployee.isVisible()) { invoicePanel.pswdEmployee.setEnabled(false); } if (!clientApplicationContext.isLoggedInAsSales() && clientApplicationContext.getPOSState().getState() != POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.fldEmployee.setEnabled(false); } invoicePanel.fldEmployee.setVerifyInputWhenFocusTarget(false); invoiceLineEntryController.resetSpecialFunctions(0, false); } } public void focusLost(FocusEvent fe) { if (fe.getComponent().getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { invoicePanel.fldEmployee.setVerifyInputWhenFocusTarget(true); } else if (fe.getComponent().getName().equals(InvoicePanel.FLD_PRIMARY_TAX_NUMBER) && getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { SwingUtilities.invokeLater(new Runnable() { public void run() { /* When focus is on Primary tax number and checkout button is clicked reset core Tax decision*/ validatePrimaryTaxNumber(); } }); } else if (fe.getComponent().getName().equals(InvoicePanel.FLD_SECONDARY_TAX_NUMBER) && getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { SwingUtilities.invokeLater(new Runnable() { public void run() { /* When focus is on Secondary tax number and checkout button is clicked reset core Tax decision*/ validateSecondaryTaxNumber(); } }); } } public void keyPressed(KeyEvent ke) { } public void keyReleased(KeyEvent ke) { fireStartTimer(); if(ke.getSource() == invoicePanel.pswdEmployee){ if(invoicePanel.pswdEmployee.getPassword() == null || invoicePanel.pswdEmployee.getPassword().length == 0){ encryptedPassword = null; encryptionRequired = false; }else if (ke.getKeyCode() != KeyEvent.VK_TAB && ke.getKeyCode() != KeyEvent.VK_ENTER && invoicePanel.pswdEmployee.getPassword() != null && invoicePanel.pswdEmployee.getPassword().length > 0) { encryptionRequired = true; } } if (invoicePanel.isVisible() && ke.getModifiers() == 0) { if (invoiceLineEntryController.getNAPAPanel().isVisible()) { if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) { invoiceLineEntryController.getCancelButton().grabFocus(); invoiceLineEntryController.getCancelButton().doClick(); } } else if (invoiceVO.getManualTransaction().booleanValue() && ke.getKeyCode() == KeyEvent.VK_ESCAPE) { TsoCurrentUser tsoCurrentUser = clientApplicationContext.getCurrentUser(); if (tsoCurrentUser != null && tsoCurrentUser.getEmployeeNum() != null && tsoCurrentUser.getEmployeeNum().intValue() > 0) { invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); } invoiceVO = new InvoiceVO(); pointOfSaleEventDispatcher.fireInvoiceCancelled(new InvoiceEvent(this, invoiceVO)); pointOfSaleEventDispatcher.fireManualInvoiceClosed(new InvoiceEvent(this, invoiceVO)); setInitialFocus(); } else { switch (ke.getKeyCode()) { case KeyEvent.VK_F5: if (invoiceLineEntryController.getDeleteButton().isEnabled()) { invoiceLineEntryController.getDeleteButton().grabFocus(); invoiceLineEntryController.getDeleteButton().doClick(); } break; case KeyEvent.VK_F2: if (invoiceLineEntryController.getFinalizeButton().isEnabled()) { invoiceLineEntryController.getFinalizeButton().doClick(); } break; case KeyEvent.VK_F11: if (invoiceLineEntryController.getBarcodeButton().isVisible() && invoiceLineEntryController.getBarcodeButton().isEnabled()) { invoiceLineEntryController.getBarcodeButton().grabFocus(); invoiceLineEntryController.getBarcodeButton().doClick(); } else if (invoiceLineEntryController.getOtherStoresButton().isEnabled() && invoiceLineEntryController.getOtherStoresButton().isVisible()) { invoiceLineEntryController.getOtherStoresButton().grabFocus(); invoiceLineEntryController.getOtherStoresButton().doClick(); } if (invoiceLineEntryController.getCheckOtherStoreButton().isVisible() && invoiceLineEntryController.getCheckOtherStoreButton().isEnabled()) { invoiceLineEntryController.getCheckOtherStoreButton().doClick(); } break; } } switch (ke.getKeyCode()) { case KeyEvent.VK_F6: if (!invoiceVO.getManualTransaction().booleanValue() && invoicePanel.btnROA.isEnabled()) { invoicePanel.btnROA.doClick(); } break; case KeyEvent.VK_F7: if (!invoiceVO.getManualTransaction().booleanValue() && invoicePanel.btnRecallSavedInvoice.isEnabled()) { invoicePanel.btnRecallSavedInvoice.doClick(); } break; case KeyEvent.VK_F9: if (invoicePanel.btnPartsPro.isEnabled()) { invoicePanel.btnPartsPro.doClick(); } break; case KeyEvent.VK_F3: if (invoicePanel.btnSearch.isEnabled()) { invoicePanel.btnSearch.doClick(); } break; case KeyEvent.VK_F4: if (!invoiceVO.getManualTransaction().booleanValue() && invoicePanel.btnMessage.isEnabled()) { invoicePanel.btnMessage.doClick(); } else if (invoiceLineEntryController.getSupersedeButton().isEnabled()) { invoiceLineEntryController.getSupersedeButton().doClick(); } break; case KeyEvent.VK_F12: if (invoiceLineEntryController.getCOBButton().isEnabled()) { invoiceLineEntryController.getCOBButton().doClick(); } else if (!invoiceVO.getManualTransaction().booleanValue() && invoicePanel.btnStockCheck.isEnabled()) { invoicePanel.btnStockCheck.doClick(); } break; case KeyEvent.VK_F8: if (clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { if (this.lineCount() > 0) { if (clientApplicationContext.getMessageMgr().showMessageYesNo( invoicePanel, "1374")) { clientApplicationContext.getPOSState().setState(POSStateVO.CASHIER); pointOfSaleEventDispatcher.fireChangedToCashier(null); } } else { if (cashierController != null) { clientApplicationContext.getPOSState().setState(POSStateVO.CASHIER); cashierController.setInputVerifyFocus(false); pointOfSaleEventDispatcher.fireChangedToCashier(null); cashierController.setInputVerifyFocus(true); } } } break; } } else if (invoicePanel.isVisible() && ke.getModifiers() == KeyEvent.SHIFT_MASK) { switch (ke.getKeyCode()) { case KeyEvent.VK_F2: if (invoiceLineEntryController.getPartInfoButton().isEnabled()) { invoiceLineEntryController.getPartInfoButton().doClick(); } break; case KeyEvent.VK_F8: if (invoicePanel.btnImportCart != null && invoicePanel.btnImportCart.isEnabled()) { invoicePanel.btnImportCart.doClick(); } else if (invoicePanel.btnStoresMessages != null && invoicePanel.btnStoresMessages.isEnabled()) { invoicePanel.btnStoresMessages.doClick(); } break; // Added for "Open Core [Shift + F9]" button. case KeyEvent.VK_F9: if (invoicePanel.btnViewOpenCores.isEnabled()) { invoicePanel.btnViewOpenCores.doClick(); } break; case KeyEvent.VK_F12: invoicePanel.pnlResize.togglePanel(); break; } } } public void keyTyped(KeyEvent ke) { } public void mouseClicked(MouseEvent me) { } public void mouseEntered(MouseEvent me) { } public void mouseExited(MouseEvent me) { } public void mousePressed(MouseEvent me) { } public void mouseReleased(MouseEvent me) { } public IView getView() { return invoicePanel; } public PointOfSaleVO getModel() { return invoiceVO; } private void populateSalesperson() { if (vSalespersonList.isEmpty()) { try { vSalespersonList = clientApplicationContext.getEmployeeDAO().getEmployeeList( PointOfSaleConstants.ACTIVE_SALES_MAN); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } } if (invoicePanel.cbSalesperson.getItemCount() > 0) { invoicePanel.cbSalesperson.removeAllItems(); } for (int i = 0; i < vSalespersonList.size(); i++) { invoicePanel.cbSalesperson.addItem(vSalespersonList.elementAt(i)); } if (clientApplicationContext.getSystemDAO().isNotAssignedSalesmanAllowed()) { EmployeeVO notAssignedSalesperson = new EmployeeVO(); notAssignedSalesperson.setEmployeeNum(new Integer(0)); notAssignedSalesperson.setFirstName(notAssigned); invoicePanel.cbSalesperson.insertItemAt(notAssignedSalesperson, 0); } invoicePanel.cbSalesperson.setSelectedIndex(0); } private int getExistingIndex(int customerNum) { int existingIndex = -1; for (int i = 0; i < invoicePanel.cbCustomer.getItemCount(); i++) { CustomerVO currentCustomer = (CustomerVO) invoicePanel.cbCustomer.getItemAt(i); if (customerNum == currentCustomer.getCustomerNumber().intValue()) { existingIndex = i; break; } } return existingIndex; } private int getExistingIndex(CustomerVO customer) { if ((customer == null) || (customer.getCustomerTypeCD() == null) || (customer.getCustomerTypeCD().equals(""))) { return -1; } boolean retailCust = customer.getCustomerTypeCD().equals(RefCustomerType.RETAIL_ACCOUNT); int customerNum = (customer.getCustomerNumber() == null ? 0 : customer.getCustomerNumber().intValue()); String customerPhone = (customer.getPhone() == null ? "" : customer.getPhone()); int existingIndex = -1; String s = null; for (int i = 0; i < invoicePanel.cbCustomer.getItemCount(); i++) { CustomerVO currentCustomer = (CustomerVO) invoicePanel.cbCustomer.getItemAt(i); if (retailCust) { s = currentCustomer.getPhone(); if (s == null) { continue; } if (s.equals(customerPhone)) { existingIndex = i; break; } } else { //Since we are wroking on non-retail account, skip all retail customers in the combo box if ((currentCustomer.getCustomerTypeCD() != null) && (currentCustomer.getCustomerTypeCD().equals(RefCustomerType.RETAIL_ACCOUNT))) { continue; } if (customerNum == currentCustomer.getCustomerNumber().intValue()) { //replace the item with new information entered. invoicePanel.cbCustomer.removeItemAt(i); invoicePanel.cbCustomer.insertItemAt(customer, i); existingIndex = i; break; } } } return existingIndex; } private void populateTACustInfo() { invoicePanel.taCustomerInfo.setText(customerVO.getCustomerNumber() + "\n" + customerVO.getName()); String[] address = {customerVO.getAddrLine1(), customerVO.getAddress2(), customerVO.getAddress3(), customerVO.getAddress4()}; String zipcode = customerVO.getPostalCode(); for (int i = 0; i < address.length; i++) { if (address[i] != null && address[i].length() > 0) { invoicePanel.taCustomerInfo.append("\n" + address[i]); } } if (zipcode != null && zipcode.length() > 0 && !zipcode.equals("0")) { Locale recordLocale = null; String languageCd = customerVO.getRefLanguageCD() == null ? RefLanguage.ENGLISH : customerVO.getRefLanguageCD(); if (languageCd != null && customerVO.getCountryCD() != null) { recordLocale = new Locale(languageCd, customerVO.getCountryCD()); } recordLocale = recordLocale == null ? clientApplicationContext.getCurrentLocale() : recordLocale; FwoZipPattern fwoZipPattern = (FwoZipPattern) FwoPattern .getZipPatternInstance(recordLocale); try { zipcode = fwoZipPattern.format(zipcode); } catch (ZipPatternFormatException zpfe) { logger.debug(zipcode + " is not matched with defined pattern "); } } if (customerVO.getCity() != null && customerVO.getCity().length() > 0) { if (zipcode != null) { invoicePanel.taCustomerInfo.append("\n" + customerVO.getCity() + ", " + customerVO.getState() + " " + zipcode); } else { invoicePanel.taCustomerInfo.append("\n" + customerVO.getCity() + ", " + customerVO.getState()); } } else { if (zipcode != null) { invoicePanel.taCustomerInfo.append("\n" + customerVO.getState() + " " + zipcode); } else { invoicePanel.taCustomerInfo.append("\n" + customerVO.getState()); } } invoicePanel.taCustomerInfo.setCaretPosition(0); } public void authorizedBuyerChanged() { String emptyString = ""; CustomerContactVO customerContactVO = null; if (customerVO != null && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() > 0) { invoicePanel.cbBuyerPhone.removeAllItems(); String buyerName = emptyString; buyerName = (String) ((IDValuePairVO) invoicePanel.cbAuthorizedBuyer.getSelectedItem()).getValue(); invoicePanel.dlblAuthorizedBuyer.setText(buyerName); customerContactVO = clientApplicationContext.getCustomerDAO().verifyBuyerInfo( customerVO.getID(), buyerName); boolean phoneExists = false; if (customerContactVO != null) { String phone = emptyString; String cell = emptyString; String pager = emptyString; String home = emptyString; String fax = emptyString; String ext = emptyString; String languageCd = RefLanguage.ENGLISH; Locale recordLocale = null; if (clientApplicationContext.getCurrentUser() != null && clientApplicationContext.getCurrentUser().getRefLanguageCd() != null) { languageCd = clientApplicationContext.getCurrentUser().getRefLanguageCd(); } if (customerContactVO.getCountryCd() != null && languageCd != null) { recordLocale = new Locale(languageCd, customerContactVO.getCountryCd()); } recordLocale = recordLocale == null ? clientApplicationContext.getCurrentLocale() : recordLocale; FwoPhonePattern fwoPhonePattern = (FwoPhonePattern) FwoPattern .getPhonePatternInstance(recordLocale); if(customerContactVO.getPhone() != null){ try { phone = fwoPhonePattern.format(customerContactVO.getPhone()); } catch (PhonePatternFormatException phonePatternFormatException) { phone = customerContactVO.getPhone(); } } if(customerContactVO.getCellPhone() != null){ try { cell = fwoPhonePattern.format(customerContactVO.getCellPhone()); } catch (PhonePatternFormatException phonePatternFormatException) { cell = customerContactVO.getCellPhone(); } } if(customerContactVO.getPager() != null){ try { pager = fwoPhonePattern.format(customerContactVO.getPager()); } catch (PhonePatternFormatException phonePatternFormatException) { pager = customerContactVO.getPager(); } } if(customerContactVO.getHomePhone() != null){ try { home = fwoPhonePattern.format(customerContactVO.getHomePhone()); } catch (PhonePatternFormatException phonePatternFormatException) { home = customerContactVO.getHomePhone(); } } if(customerContactVO.getFaxNumber() != null){ try { fax = fwoPhonePattern.format(customerContactVO.getFaxNumber()); } catch (PhonePatternFormatException phonePatternFormatException) { fax = customerContactVO.getFaxNumber(); } } ext = customerContactVO.getExtension(); if ((phone != null) && !(phone.equals(emptyString))) { phoneExists = true; if ((ext != null) && !ext.equals(emptyString)) { invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "PHONE", clientApplicationContext.getCurrentLocale()) + " " + phone + " Ext " + ext); } else { invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "PHONE", clientApplicationContext.getCurrentLocale()) + " " + phone); } } if ((cell != null) && !(cell.equals(emptyString))) { phoneExists = true; invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "CELL", clientApplicationContext.getCurrentLocale()) + " " + cell); } if ((pager != null) && !(pager.equals(emptyString))) { phoneExists = true; invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "PAGER", clientApplicationContext.getCurrentLocale()) + " " + pager); } if ((home != null) && !(home.equals(emptyString))) { phoneExists = true; invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "HOME", clientApplicationContext.getCurrentLocale()) + " " + home); } if ((fax != null) && !(fax.equals(emptyString))) { phoneExists = true; invoicePanel.cbBuyerPhone.addItem( clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "FAX", clientApplicationContext.getCurrentLocale()) + " " + fax); } invoiceVO.setCustomerContactID(new Integer(customerContactVO.getID())); invoiceVO.setAuthorizedBuyerName(buyerName); } invoicePanel.cbBuyerPhone.setEnabled(phoneExists); invoicePanel.btnPartsPro.setEnabled(true); invoiceLineEntryController.setPartNumberEnabled(true); } else { invoicePanel.dlblAuthorizedBuyer.setText(emptyString); invoiceVO.setCustomerContactID(null); invoiceVO.setAuthorizedBuyerName(null); if (customerVO != null && customerVO.isAuthorizedBuyersOnly()) { invoicePanel.cbBuyerPhone.setEnabled(false); invoicePanel.btnPartsPro.setEnabled(false); invoiceLineEntryController.setPartNumberEnabled(false); invoiceLineEntryController.resetSpecialFunctions(0, false); } } } public void installBusinessListeners() { pointOfSaleEventDispatcher.addListener(InvoiceListener.class, this); pointOfSaleEventDispatcher.addListener(InvoiceLineEntryListener.class, this); pointOfSaleEventDispatcher.addListener(CatalogListener.class, this); pointOfSaleEventDispatcher.addListener(CustomerListener.class, this); pointOfSaleEventDispatcher.addListener(BuyoutListener.class, this); pointOfSaleEventDispatcher.addListener(ProfileListener.class, this); pointOfSaleEventDispatcher.addListener(EmployeeListener.class, this); pointOfSaleEventDispatcher.addListener(PointOfSaleListListener.class, this); pointOfSaleEventDispatcher.addListener(POSStateListener.class, this); pointOfSaleEventDispatcher.addListener(CartListener.class, this); } public void installViewListeners() { invoicePanel.fldEmployee.addFocusListener(this); invoicePanel.pswdEmployee.addKeyListener(this); invoicePanel.btnSearch.addActionListener(this); invoicePanel.cbAuthorizedBuyer.addActionListener(this); invoicePanel.cbStore.addActionListener(this); invoicePanel.btnRecallSavedInvoice.addActionListener(this); invoicePanel.btnStockCheck.addActionListener(this); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.addActionListener(this); } invoicePanel.btnMessage.addActionListener(this); if (invoicePanel.btnStoresMessages != null) { invoicePanel.btnStoresMessages.addActionListener(this); } invoicePanel.cbCustomer.addFocusListener(this); invoicePanel.cbCustomer.getEditor().getEditorComponent().addFocusListener(this); invoicePanel.btnPartsPro.addActionListener(this); invoicePanel.btnROA.addActionListener (this); invoicePanel.pnlResize.addPropertyChangeListener(this); invoiceLineEntryController.getPartNumberComponent().addKeyListener( invoiceLineListController); invoicePanel.ckCustomerPresent.addActionListener(this); invoicePanel.btnViewOpenCores.addActionListener(this); invoicePanel.fldPrimaryTaxNumber.addFocusListener(this); invoicePanel.fldSecondaryTaxNum.addFocusListener(this); invoicePanel.cbCustomer.getEditor().getEditorComponent().addKeyListener(this); invoiceLineEntryController.getQuantityComponent().addKeyListener(this); invoicePanel.fldInvoiceNumber.addKeyListener(this); invoicePanel.fldInvoiceDate.addKeyListener(this); invoicePanel.cbStore.addKeyListener(this); } private boolean displayEmployeeName(Integer empNum) { try { employeeVO = clientApplicationContext.getEmployeeDAO().getEmployeeDetailInfo(empNum); } catch (ApplicationException ae) { logger.error(ae.toString(), ae); String[] parms = new String[]{ae.getUserMessageID()}; //2312 = Error from TAMS Service programs. \nOperation did not complete. \n //Please Contact TAMS Support. Service Error = $1 ClientApplicationContext.getClientApplicationContext().getMessageMgr(). showMessage(invoicePanel, "2312", parms); return false; } if (employeeVO != null) { String name = employeeVO.getFirstName() + " " + employeeVO.getLastName(); invoicePanel.dlblEmployee.setText(name); if(employeeVO.getRefPasswordStatus().intValue() == RefPasswordStatus.LOCKED){ clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9005"); invoicePanel.fldEmployee.setEnabled(true); invoicePanel.fldEmployee.setEditable(true); return false; } else if (!InvoiceBL.isEmployeeClockedIn(employeeVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "128"); invoicePanel.fldEmployee.setEnabled(true); invoicePanel.fldEmployee.setEditable(true); return false; } else if (!InvoiceBL.isEmployeeAllowedToInvoice(employeeVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "137"); invoicePanel.fldEmployee.setEnabled(true); invoicePanel.fldEmployee.setEditable(true); return false; } else { if (!(clientApplicationContext.getSystemDAO().askEmployeePassword().booleanValue() && getInvoicingProfileVO().getRequireEmployeePasswordOnInvoice() .booleanValue())&&clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL) { resetCurrentUser (employeeVO); verifyEmployee(); } this.counterManID = employeeVO.getID(); if (tempEmpNum == -1) { tempEmpNum = employeeVO.getEmployeeNum().intValue(); } else { if (tempEmpNum != employeeVO.getEmployeeNum().intValue()) { noOfFailedLoginAttempts = 0; tempEmpNum = employeeVO.getEmployeeNum().intValue(); } } return true; } } else { invoicePanel.dlblEmployee.setText(""); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "116"); return false; } } /** * This method validates whether the password entered matches with the * database. * * @return boolean - true if the password matches with the database. */ private boolean validateEmpPwd() throws IOException { boolean pwdFlag = false; if (encryptionRequired) { try { if (invoicePanel.pswdEmployee.getPassword() != null && invoicePanel.pswdEmployee.getPassword().length > 0) { encryptedPassword = Encryptor.oneWayEncrypt(new String( invoicePanel.pswdEmployee.getPassword()) .toLowerCase()); encryptionRequired = false; } } catch (ApplicationException ae) { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "9008"); return false; } } if (encryptedPassword != null) { EmployeeServiceUtil employeeServiceUtil= new EmployeeServiceUtil(); try { pwdFlag = employeeServiceUtil.validateEmpPswd(Integer.parseInt(invoicePanel.fldEmployee.getText()), 1, encryptedPassword); logger.debug("Service response is :" + pwdFlag); if (!pwdFlag) { logger.error(" employee password pwdFlag noOfFailedLoginAttempts: " + noOfFailedLoginAttempts); noOfFailedLoginAttempts++; encryptedPassword = null; } } catch (NumberFormatException e) { logger.error("Invalid employee number" + invoicePanel.fldEmployee.getText()); ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "109"); } } return pwdFlag; } /** * This method updates the status of the employee as 'LOCKED'. * * @return boolean - true if the status of the employee is updated as * 'LOCKED'. */ private boolean setEmployeeStatusLocked(Integer empID){ String ipAddress = TamsMisc.getIPAddress(); try { (SecurityServiceFactory.getServiceInstance()).lockEmployee( empID, PROGRAM_SOURCE_NAME, new Integer(clientApplicationContext.getLocation()), ipAddress); employeeVO.setRefPasswordStatus(new Integer( RefPasswordStatus.LOCKED)); } catch (ApplicationException e) { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "9007"); return false; } return true; } /** * This method displays the Change Password dialog. * * @return - None. */ private void openChangePwdDialog() { ChangePasswordController changePasswordController = new ChangePasswordController( parentContainer); changePasswordController.show(); changePassword = changePasswordController.isChangePasswordSuccessful(); if (changePassword) { // show message stating change password was successful invoicePanel.pswdEmployee.setText(TsoConstant.PASSWORD_DISPLAY); SwingUtilities.invokeLater(new Runnable() { public void run() { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "304"); } }); pointOfSaleEventDispatcher.fireEmployeeLoggedIn(new EmployeeEvent( this, employeeVO)); this.employeeVO = (EmployeeVO) changePasswordController.getModel(); encryptedPassword = employeeVO.getPassword(); } } /** * This method validates whether the password expires in 3 days or expired. * * @return boolean - true if the password is not expired. */ private boolean validatePasswordExpDate(Date expirationDate,Integer empId) { logger.debug("The expiration date is: " + expirationDate); logger.debug("Today's date is: " + new Date()); boolean expirationReturnValue = true; if (expirationDate != null) { int expDate = Integer.parseInt(EmployeeAccessValidator .calculateExpirationDateDays(expirationDate)); if (expDate > 0 && expDate < TsoConstant.PASSWORD_EXPIRY_REMINDER_DAYS) { if (ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessageYesNo(invoicePanel, "9002", String.valueOf(expDate))) { SwingUtilities.invokeLater(new Runnable() { public void run() { openChangePwdDialog(); } }); expirationReturnValue = changePassword; } } else if (expDate <= 0) { if (setEmployeeStatusLocked(empId)) { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "9003"); expirationReturnValue = false; } else { return false; } } } return expirationReturnValue; } /** * This method validates the password entered. * * @param password - * Password entered. * @return boolean - true if the password is valid. */ private boolean verifyPassword(String password) { boolean loginStatus = true; EmployeeVO employeeAccountInfoVO = null; try { employeeAccountInfoVO = clientApplicationContext.getEmployeeDAO().getEmployeeAccountInfo(new Integer(empNum)); } catch (ApplicationException e) { logger.error("Exception in verifyPassword" +e); } if(employeeAccountInfoVO == null){ loginStatus = false; }else if (employeeAccountInfoVO.getRefPasswordStatus().intValue() == RefPasswordStatus.LOCKED) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9005"); loginStatus = false; } else { try{ if (validateEmpPwd()) { if ((clientApplicationContext.getCurrentUser() == null) || (clientApplicationContext.isLoggedInAsSales())) { displayEmployeeName(new Integer(empNum)); resetCurrentUser (employeeVO); } if (employeeAccountInfoVO.getRefPasswordStatus().intValue() == RefPasswordStatus.RESET) { clientApplicationContext.getMessageMgr().showMessage( invoicePanel, "9004"); SwingUtilities.invokeLater(new Runnable() { public void run() { openChangePwdDialog(); } }); loginStatus = changePassword; } else if (!validatePasswordExpDate((java.util.Date) employeeAccountInfoVO .getPasswordExpDate(),employeeAccountInfoVO.getID())) { loginStatus = false; } } else if (noOfFailedLoginAttempts == TsoConstant.MAX_FAILED_LOGIN_ATTEMPTS) { clientApplicationContext.getMessageMgr().showMessage( invoicePanel, "9000"); if (setEmployeeStatusLocked((Integer)employeeAccountInfoVO.getID())) { loginStatus = false; } else { return false; } } else { clientApplicationContext.getMessageMgr().showMessage( invoicePanel, "110"); loginStatus = false; } }catch(HttpException e) { logger.error("HttpException occured in validateEmpPwd: "+e); ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "8400"); loginStatus = false; } catch(IOException e) { logger.error("IOException occured in validateEmpPwd: "+e); ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoicePanel, "8400"); loginStatus = false; } } return loginStatus; } private boolean isCurrentUserSales () { String sLocalizedSalesLoginNumber = clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, PointOfSaleConstants.SALESLOGINNUMBER, clientApplicationContext.getCurrentLocale()); TsoCurrentUser currUser = clientApplicationContext.getCurrentUser(); logger.debug("currUser.getFirstName() = " + currUser.getFirstName() + " sLocalizedSalesLoginNumber = " + sLocalizedSalesLoginNumber); //if current user name is SALES in localized text if (currUser.getFirstName().equals(sLocalizedSalesLoginNumber)) { logger.debug("Current user is SALES, needs to be reset."); return true; } else { logger.debug("Current user is NOT SALES, need not be reset."); return false; } } private void resetCurrentUser (EmployeeVO o) { logger.debug("new resetting the current user....."); TsoCurrentUser currUser = clientApplicationContext.getCurrentUser(); //first name currUser.setFirstName(o.getFirstName()); //last name currUser.setLastName(o.getLastName()); //emp num currUser.setEmployeeNum(o.getEmployeeNum()); //emp id currUser.setEmployeeId(o.getID()); //loc currUser.setEmployeeLoc(new Integer(clientApplicationContext.getLocation())); //invoicing currUser.setInvoicingAllowed(o.getInvoicingAllowed()); //ref langauge currUser.setRefLanguageCd(o.getRefLanguageCD()); //password currUser.setPassword(o.getPassword()); //password status currUser.setRefPasswordStatus(o.getRefPasswordStatus()); currUser.setEmployeeLdapId(o.getEmployeeLdapId()); clientApplicationContext.setCurrentUser(currUser); logger.debug("Current user is now set."); } private boolean verifyCustomerText(String value) { /*if we don't execute popupVisible false, we have double focus issues with COD customers / and when items have price of 0. This happens when using the keyboard and not mouse.*/ invoicePanel.cbCustomer.setPopupVisible(false); int customerNum = -1; if (value != null && value.length() > 0 && !value.equals("")) { value = (value.indexOf(" ") > 0) ? value.substring(0, value.indexOf(" ")) : value.trim(); if (value.equals(oldCustomerNum)) { invoicePanel.cbCustomer.setSelectedItem(customerVO); return true; } else { if (!canChangeCustomer()) { return false; } } if (value.indexOf("-") >= 0) { //#1067 = Invalid customer number. Please try again. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1067"); return false; } try { customerNum = Integer.parseInt(value); } catch (NumberFormatException nfe) { //#1067 = Invalid customer number. Please try again. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1067"); ////clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "404"); return false; } } else { if (clientApplicationContext.getSystemDAO().promptCustomerPhone().booleanValue()) { customerPhoneController.resetValues(); ((CustomerPhoneDialog) customerPhoneController.getView()).setVisible(true); if (customerPhoneController.getModel() == null) { if (customerPhoneController.isPhoneCanceled()) { return false; } else { SwingUtilities.invokeLater(new Runnable() { public void run() { displayCustomerInfo(null); } }); return true; } } else { this.customerVO = (CustomerVO) customerPhoneController.getModel(); if (!CustomerBL.ableToInvoice(customerVO, invoicePanel)) { return false; } if (invoicePanel.lblCustomerPresent.isVisible()) { invoicePanel.ckCustomerPresent.setSelected(customerVO.isTypicallyPresentDuringInvoicing().booleanValue()); invoiceVO.setDisplayPricing(invoicePanel.ckCustomerPresent.isSelected()); } invoicePanel.dlblPUPending.setVisible(customerVO.hasPendingPO()); populateAuthorizedBuyer(); displayCustomerDetails(); disableBeforeCustomerButtons(); enableSalesperson(); processCustomerMessages(); setInvoiceVOCustomerAttributes(); if (getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { populateCustomerTaxNumber(); } int authCount = invoicePanel.cbAuthorizedBuyer.getItemCount(); invoicePanel.cbAuthorizedBuyer.setEnabled(authCount > 0); invoicePanel.lblAuthorizedBuyer.setEnabled(authCount > 0); invoicePanel.cbBuyerPhone.setEnabled(false); logger.debug("---verifyCustomerText, setting oldCustomerNum = " + customerVO.getCustomerNumber().toString()); oldCustomerNum = customerVO.getCustomerNumber().toString(); invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoicePanel.btnSearch.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return true; } } else { if (customerVO == null) { return true; } int existingIndex = -1; //existingIndex = getExistingIndex(customerVO.getCustomerNumber().intValue()); if (clientApplicationContext.getApplicationType() == ClientApplicationContext.PARTS_PRO_II) { existingIndex = getExistingIndex(customerVO); } else { existingIndex = getExistingIndex(customerVO.getCustomerNumber().intValue()); } if (existingIndex >= 0) { logger.debug("---- verifyCustomerText, setting cbCustomer to existingIndex= " + existingIndex); invoicePanel.cbCustomer.setSelectedItem(customerVO); } else { invoicePanel.cbCustomer.insertItemAt(customerVO, 0); invoicePanel.cbCustomer.setSelectedIndex(0); } return true; } } CustomerVO customer = null; Object o = invoicePanel.cbCustomer.getSelectedItem(); if (clientApplicationContext.getApplicationType() == ClientApplicationContext.PARTS_PRO_II) { if ((o == null) || (!(o instanceof CustomerVO))){ try { customer = clientApplicationContext.getCustomerDAO().getCustomerDetailInfo( new Integer(customerNum)); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return false; } } else { try { customer = (CustomerVO) o; if ((customer.getCustomerNumber() == null) || (customer.getCustomerNumber().intValue() != customerNum)){ customer = clientApplicationContext.getCustomerDAO().getCustomerDetailInfo( new Integer(customerNum)); } } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return false; } } } else { //ApplicationType is not PARTS_PRO_II try { customer = clientApplicationContext.getCustomerDAO().getCustomerDetailInfo( new Integer(customerNum)); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return false; } } if (CustomerBL.isNapaOnlineCustomer(customer) && invoiceVO.getLineItems() != null && invoiceVO.getLineItems().size() > 0 && !value.equals(oldCustomerNum)) { //439 = Cannot change NAPAonline.com customer. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "439"); invoicePanel.cbCustomer.setSelectedItem(customerVO); return false; } else { customerVO = customer; return verifyCustomerVO(value); } } private boolean verifyCustomerVO(String customerNumber) { if (customerVO == null) { customerVO = null; //408 = The customer does not exist. logger.debug("--- msg408 - ccustomer " + customerNumber + " does not exist."); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "408"); ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()).setText(""); oldCustomerNum = ""; return false; } int customerNum = -1; try { customerNum = Integer.parseInt(customerNumber); } catch (NumberFormatException nfe) { //1067 = ,Invalid customer number. Please try again. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1067"); return false; } if (customerVO.getCustomerNumber().intValue() != customerNum) { customerVO = null; // 408 = The customer does not exist. logger.debug("--- msg408 - ccustomer " + customerNumber + " does not exist."); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "408"); ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()).setText(""); oldCustomerNum = " "; return false; } else { if (!CustomerBL.ableToInvoice(customerVO, invoicePanel)) { invoicePanel.lblCoreNotification.setVisible(false); invoicePanel.btnViewOpenCores.setEnabled(false); return false; } invoicePanel.dlblPUPending.setVisible(customerVO.hasPendingPO()); invoiceVO.setCustomerContactID(null); populateAuthorizedBuyer(); displayCustomerDetails(); disableBeforeCustomerButtons(); enableSalesperson(); processCustomerMessages(); setInvoiceVOCustomerAttributes(); if (getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { populateCustomerTaxNumber(); } if (invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { invoicePanel.lblAuthorizedBuyer.setEnabled(true); invoicePanel.cbAuthorizedBuyer.setEnabled(true); } else { invoicePanel.lblAuthorizedBuyer.setEnabled(false); invoicePanel.cbAuthorizedBuyer.setEnabled(false); invoicePanel.cbBuyerPhone.setEnabled(false); } } logger.debug("---- verifyCustomerVO: setting oldCustomerNum = " + customerVO.getCustomerNumber().toString() ); oldCustomerNum = customerVO.getCustomerNumber().toString(); invoicePanel.btnRecallSavedInvoice.setEnabled(false); enableViewOpenCoresButton(); setResourceInUse(); return true; } private void processCustomerMessages() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (displayTaxExemptMessage()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (displayCustomerNote()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (!isBuyoutOpenedFromTAMS() && displaySavedInvoiceMessage()) { SwingUtilities.invokeLater(new Runnable() { public void run() { delegateToESBRegistration(); } }); } } }); } } }); } } }); } private boolean displayTaxExemptMessage() { if (CustomerBL.checkTaxExpiration(customerVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1241"); invoicePanel.dlblPrimaryTax.setText(customerVO.getTaxStatusPrimaryCodeDescription()); if (CustomerBL.hasSecondaryTax(customerVO)) { invoicePanel.dlblSecondaryTax.setText( customerVO.getTaxStatusSecondaryCodeDescription()); } } CustomerBL.checkTaxExpiration(customerVO.getAlternateCoreCustomerTax()); return true; } private boolean displaySavedInvoiceMessage() { if ((invoiceVO.getLineItems() == null || invoiceVO.getLineItems().isEmpty()) && !invoiceVO.getManualTransaction().booleanValue() && clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getDisplaySavedInvoicesAlert().booleanValue() && customerVO.hasSavedInvoice() && clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getUseSaveInvoice().booleanValue()) { if (clientApplicationContext.getMessageMgr().showMessageNoYes( invoicePanel, "447")) { recallSavedInvoice(customerVO.getID(), customerVO.getCustomerTypeCD(), customerVO.getCustomerNumber()); return false; } } return true; } private boolean displayCustomerNote() { if (CustomerBL.hasARNote(customerVO)) { String message = customerVO.getCustomerNote(); if (message.length() > 85) { message = message.substring(0, 84); } final String finalMsg = message; clientApplicationContext.getMessageMgr().showMessage( invoicePanel, "449", finalMsg); } return true; } private void setInvoiceVOCustomerAttributes() { setInvoiceVOCustomerAttributes(true); } private void setInvoiceVOCustomerAttributes(boolean shouldRegenerateLines) { invoiceVO.setCustomerID(customerVO.getID()); invoiceVO.setCustomerTypeCD(customerVO.getCustomerTypeCD()); invoiceVO.setCustomerName(customerVO.getName()); invoiceVO.setLOC(loc); invoiceVO.setTaxExemptNumPrimary(customerVO.getTaxExemptNumberPrimary()); invoiceVO.setTaxExemptNumberSecondary(customerVO.getTaxExemptNumberSecondary()); if (counterManID == null) { TsoCurrentUser tsoCurrentUser = (TsoCurrentUser) clientApplicationContext.getCurrentUser(); if (tsoCurrentUser != null && tsoCurrentUser.getEmployeeNum() != null && tsoCurrentUser.getEmployeeNum().intValue() > 0) { invoicePanel.dlblEmployee.setText(tsoCurrentUser.getFirstName() + " " + tsoCurrentUser.getLastName()); counterManID = tsoCurrentUser.getEmployeeId(); } } invoiceVO.setCountermanEmployeeID(counterManID); //we don't want to set the salesmanEmployeeID when recalling a saved invoice if (shouldRegenerateLines) { invoiceVO.setSalesmanEmployeeID(((EmployeeVO) invoicePanel.cbSalesperson.getSelectedItem() ).getID()); } if (!loadedFromRecallSavedInvoice) { if (customerVO.getPrimaryTaxTable() != null && customerVO.getPrimaryTaxTable().getID().shortValue() > 0) { invoiceVO.setTaxPercent1(customerVO.getPrimaryTaxTable().getSalesTaxPercent()); invoiceVO.setPrimaryTaxTableID(customerVO.getDefaultTaxTableID()); invoiceVO.setSecondaryTaxTableID(customerVO.getSecondaryTaxTableID()); } else { invoiceVO.setTaxPercent1(null); invoiceVO.setPrimaryTaxTableID(null); invoiceVO.setSecondaryTaxTableID(null); } invoiceVO.setPrimaryTaxTableVO(customerVO.getPrimaryTaxTable()); invoiceVO.setSecondaryTaxTableVO(customerVO.getSecondaryTaxTable()); if (customerVO.getSecondaryTaxTable() == null || customerVO.getSecondaryTaxTable().getID().shortValue() > 0) { invoiceVO.setTaxPercent2(new BigDecimal("0.00")); } else { invoiceVO.setTaxPercent2(customerVO.getSecondaryTaxTable() .getSalesTaxPercent()); } final StoreProfileVO storeProfile = clientApplicationContext.getProfile(Profile .POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile(); boolean includeTaxInPrice = storeProfile.getIncludeTaxInPrice().booleanValue(); // If Customer has delivery tax table then use it has primary tax table if (includeTaxInPrice) { Short deliveryTaxTableId = customerVO.getDeliveredTaxTableID(); String deliveryFlag = deliveryTaxTableId == null ? "" : customerVO.getCustomerDeliveryVO().getDeliveryRefOptionCD(); if (deliveryFlag != null && deliveryFlag.equals("A") && deliveryTaxTableId != null && deliveryTaxTableId.intValue() > 0) { TaxTableVO deliveryTaxTable = clientApplicationContext.getSystemDAO() .getTaxTable(loc, deliveryTaxTableId); if (deliveryTaxTable != null) { invoiceVO.setPrimaryTaxTableVO(deliveryTaxTable); invoiceVO.setPrimaryTaxTableID(deliveryTaxTableId); invoiceVO.setTaxPercent1(deliveryTaxTable.getSalesTaxPercent()); Short secondaryTaxTableId = deliveryTaxTable.getSecondaryTaxTableID(); if (secondaryTaxTableId != null && secondaryTaxTableId.intValue() > 0) { TaxTableVO secondaryTaxTable = clientApplicationContext.getSystemDAO() .getTaxTable(loc, secondaryTaxTableId); invoiceVO.setSecondaryTaxTableID(secondaryTaxTableId); invoiceVO.setSecondaryTaxTableVO(secondaryTaxTable); invoiceVO.setTaxPercent2(secondaryTaxTable.getSalesTaxPercent()); } else { invoiceVO.setSecondaryTaxTableID(null); invoiceVO.setTaxPercent2(null); invoiceVO.setSecondaryTaxTableVO(null); } } } } } invoiceVO.setCustomerPhone(customerVO.getPhone()); final InvoiceVO savedCart = invoiceVO.getSavedCart(); if(savedCart != null){ if(invoiceVO.getLineItems() != null && savedCart.getLineItems() != null){ invoiceVO.getLineItems().addAll((Vector)savedCart.getLineItems().clone()); } } invoiceVO.setSavedCart(null); invoiceVO.setRecalledDate(null); pointOfSaleEventDispatcher.fireCustomerChanged(new CustomerEvent( this, customerVO, shouldRegenerateLines)); } private boolean canChangeCustomer() { if (invoiceVO != null && invoiceVO.getLineItems() != null && invoiceVO.getLineItems().size() > 0) { if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile() .getBuyoutPickupPOInUse().booleanValue() && InvoiceBL.hasPickupItem(invoiceVO.getLineItems())) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "438"); return false; } if (CustomerBL.isNapaOnlineCustomer(customerVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "439"); invoicePanel.cbCustomer.setSelectedItem(customerVO); return false; } JTextField textFieldComp = (JTextField) invoicePanel.cbCustomer.getEditor() .getEditorComponent(); if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10127"); textFieldComp.setText(customerVO.toString()); return false; } if (InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10201"); textFieldComp.setText(customerVO.toString()); return false; } if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile() .getAskForItemReturnInfo().booleanValue() && hasReturnItemMappedToOriginalInvoice(invoiceVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2251"); textFieldComp.setText(customerVO!=null?customerVO.toString():TsoConstant.EMPTY_STRING); return false; } if (doCertificationPartsExist()) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9943"); certificatePartExist = true; return false; } if (InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO) || (invoiceVO.getDirectShippedInvoice() != null && invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10082"); return false; } } return true; } private void populateAuthorizedBuyer() { invoicePanel.cbAuthorizedBuyer.removeAllItems(); invoicePanel.cbBuyerPhone.removeAllItems(); Vector authBuyerVector = customerVO.getAuthorizedBuyers(); if (authBuyerVector != null && authBuyerVector.size() > 0) { if (customerVO.isAuthorizedBuyersOnly()) { invoicePanel.cbAuthorizedBuyer.insertItemAt( new IDValuePairVO (new Integer(0), initialItem), 0); } else { invoicePanel.cbAuthorizedBuyer.insertItemAt( new IDValuePairVO (new Integer(0), notAssigned), 0); } for (int i = 0; i < authBuyerVector.size(); i++) { invoicePanel.cbAuthorizedBuyer.addItem(authBuyerVector.elementAt(i)); } if (invoiceVO.getCustomerContactID() == null) { invoicePanel.cbAuthorizedBuyer.setSelectedIndex(0); } } } private void selectStore(Integer storeId) { int iStoresCount = invoicePanel.cbStore.getItemCount(); for (int i = 0; i < iStoresCount; i++) { int id = ((PhoneRoomStoreVO) invoicePanel.cbStore.getItemAt(i)).getId().intValue(); if (id == storeId.intValue()) { invoicePanel.cbStore.setSelectedIndex(i); return; } } } private void selectStoreAsSame() { int iStoresCount = invoicePanel.cbStore.getItemCount(); String sameStoreNum = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile().getStoreNum(); for (int i = 0; i < iStoresCount; i++) { String storeNum = ((PhoneRoomStoreVO) invoicePanel.cbStore.getItemAt(i)).getStoreNumber(); if (sameStoreNum.equals(storeNum)) { invoicePanel.cbStore.setSelectedIndex(i); return; } } } private void selectStoreByNumber(String storeNumber) { if (storeNumber != null && invoicePanel.cbStore.isVisible()) { int iStoresCount = invoicePanel.cbStore.getItemCount(); for (int i = 0; i < iStoresCount; i++) { String storeInCombo = ((PhoneRoomStoreVO) invoicePanel.cbStore.getItemAt(i)).getStoreNumber(); if (storeInCombo.equals(storeNumber)) { invoicePanel.cbStore.setSelectedIndex(i); return; } } } } private void selectSalesPerson (int salesmanEmpID) { int iItemsCount = invoicePanel.cbSalesperson.getItemCount(); boolean salesFound = false; for (int index = 0; index < iItemsCount; index++) { int id = ((Integer) ((EmployeeVO) invoicePanel.cbSalesperson.getItemAt(index)).getID()).intValue(); if (id == salesmanEmpID) { if ((salesmanEmpID < 0) && (clientApplicationContext.getApplicationType() == ClientApplicationContext.PARTS_PRO_II)) { // invoicePanel.cbSalesperson.setEditable(true); String salesmanEmpNumber = new String(customerVO.getSalesmanEmployeeNumber().toString()); EmployeeVO notAssignedSalesperson = new EmployeeVO(); notAssignedSalesperson.setID(new Integer(salesmanEmpID)); notAssignedSalesperson.setEmployeeNum(new Integer(salesmanEmpNumber)); notAssignedSalesperson.setFirstName(" "+salesmanEmpNumber); invoicePanel.cbSalesperson.insertItemAt(notAssignedSalesperson, 0); invoicePanel.cbSalesperson.setSelectedItem(notAssignedSalesperson); } else { invoicePanel.cbSalesperson.setSelectedIndex(index); } return; } } EmployeeVO employeeVO = new EmployeeVO(); try { employeeVO = clientApplicationContext.getEmployeeDAO().getSalesPersonInfo( new Integer(salesmanEmpID)); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } //if salesperson is not in the employee table then set salesperson to 0 if (employeeVO == null) { for (int index = 0; index < iItemsCount; index++) { int empNum = ((Integer) ((EmployeeVO) invoicePanel.cbSalesperson.getItemAt(index)).getEmployeeNum()).intValue(); if (empNum == 0) { invoicePanel.cbSalesperson.setSelectedIndex(index); return; } } } else { invoicePanel.cbSalesperson.insertItemAt(employeeVO, 0); invoicePanel.cbSalesperson.setSelectedIndex(0); } } private void displayCustomerDetails() { populateSalesperson(); int salesEmpId = 0; if (customerVO.getSalesmanEmployeeID() != null) { salesEmpId = customerVO.getSalesmanEmployeeID().intValue(); } selectSalesPerson(salesEmpId); if (!(loadedFromRecallSavedInvoice && invoiceVO.getPhoneRoomStoreId() != null)) { selectStoreByNumber(customerVO.getServingStore()); } int existingIndex = -1; //existingIndex = getExistingIndex(customerVO.getCustomerNumber().intValue()); if (clientApplicationContext.getApplicationType() == ClientApplicationContext.PARTS_PRO_II) { existingIndex = getExistingIndex(customerVO); } else { existingIndex = getExistingIndex(customerVO.getCustomerNumber().intValue()); } if (existingIndex >= 0) { invoicePanel.cbCustomer.setSelectedIndex(existingIndex); } else { invoicePanel.cbCustomer.insertItemAt(customerVO, 0); invoicePanel.cbCustomer.setSelectedIndex(0); } invoicePanel.dlblCustomerHeader.setText(customerVO.getCustomerNumber().toString()); populateTACustInfo(); populatePhoneFax(); populateBillTypeAndTax(); invoicePanel.taNote.setText(customerVO.getCustomerNote()); invoicePanel.lblPriorityPlusLabel.setVisible(customerVO.getPriorityPlus().booleanValue()); if (invoicePanel.lblCustomerPresent.isVisible()) { invoicePanel.ckCustomerPresent.setSelected(customerVO.isTypicallyPresentDuringInvoicing().booleanValue()); invoiceVO.setDisplayPricing(invoicePanel.ckCustomerPresent.isSelected()); } pointOfSaleEventDispatcher.fireLocaleLocked(new LocaleEvent(this, clientApplicationContext.getCurrentLocale(), clientApplicationContext.getCurrentLocale())); } private boolean displaySalespersonName(String salespersonNumString) { boolean salesFound = false; if (!salespersonNumString.equals("0 " + notAssigned) && salespersonNumString.length() > 0) { int truncate = -1; truncate = salespersonNumString.indexOf(" "); salespersonNumString = truncate > 0 ? salespersonNumString.substring(0, truncate) : salespersonNumString; int salesNum = -1; try { salesNum = Integer.parseInt(salespersonNumString); } catch (NumberFormatException nfe) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "404"); return false; } for (int i = 0; i < invoicePanel.cbSalesperson.getItemCount(); i++) { EmployeeVO salesperson = (EmployeeVO) invoicePanel.cbSalesperson.getItemAt(i); if (salesperson.getEmployeeNum().intValue() == salesNum) { invoicePanel.cbSalesperson.setSelectedIndex(i); ((JTextField)invoicePanel.cbSalesperson.getEditor().getEditorComponent()) .setText(invoicePanel.cbSalesperson.getSelectedItem().toString()); salesFound = true; break; } } if (!salesFound) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "116"); return false; } } Integer salesID = null; if (invoicePanel.cbSalesperson.getSelectedIndex() > -1) { salesID = ((EmployeeVO) invoicePanel.cbSalesperson.getSelectedItem()).getID(); } invoiceVO.setSalesmanEmployeeID(salesID); if (invoicePanel.ckCustomerPresent.isVisible()) { invoicePanel.ckCustomerPresent.setEnabled(true); } if (invoicePanel.cbAuthorizedBuyer.getItemCount() <= 0) { invoicePanel.btnPartsPro.setEnabled(true); invoiceLineEntryController.setPartNumberEnabled(true); } else { invoicePanel.cbAuthorizedBuyer.setEnabled(true); invoicePanel.lblAuthorizedBuyer.setEnabled(true); } return true; } public void installVerifiers() { FwoBaseInputVerifier baseInputVerifier = new FwoBaseInputVerifier(this); baseInputVerifier.setAdditionalValidationOnClient(true); FwoDateVerifier dateVerifier = new FwoDateVerifier(this); dateVerifier.setAdditionalValidationOnClient(true); invoicePanel.fldEmployee.setInputVerifier(baseInputVerifier); invoicePanel.fldEmployee.setDocument(new FwoValidatedWholeNumberDocument( invoicePanel.fldEmployee)); invoicePanel.pswdEmployee.setInputVerifier(baseInputVerifier); fldCustomer = ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()); fldCustomer.setInputVerifier(baseInputVerifier); fldCustomer.setName(InvoicePanel.CB_CUSTOMER_NAME); fldSalesperson = ((JTextField) invoicePanel.cbSalesperson.getEditor().getEditorComponent()); fldSalesperson.setInputVerifier(baseInputVerifier); fldSalesperson.setName(InvoicePanel.CB_SALESPERSON); Profile profile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()); invoicePanel.fldInvoiceDate.setDocument(new TsoTextPersistedDateDocument( invoicePanel.fldInvoiceDate, profile.getStoreProfile().getRefDateFormatId().intValue())); invoicePanel.fldInvoiceDate.setInputVerifier(dateVerifier); invoicePanel.fldInvoiceNumber.setDocument(new FwoValidatedWholeNumberDocument( invoicePanel.fldInvoiceNumber, new Integer(1), new Integer(999999), false)); FwoNumberVerifier numberVerifier = new FwoNumberVerifier(this, true); invoicePanel.fldInvoiceNumber.setInputVerifier(numberVerifier); invoicePanel.fldPrimaryTaxNumber.setDocument(new DefaultDocument( invoicePanel.fldPrimaryTaxNumber,30,FwiConstant.ALPHANUMERIC)); invoicePanel.fldSecondaryTaxNum.setDocument(new DefaultDocument( invoicePanel.fldSecondaryTaxNum,30,FwiConstant.ALPHANUMERIC)); invoicePanel.fldPrimaryTaxNumber.setInputVerifier(baseInputVerifier); invoicePanel.fldSecondaryTaxNum.setInputVerifier(baseInputVerifier); } public void installFocusDeciders() { invoicePanel.fldEmployee.putClientProperty(FocusDecider.NAME, this); invoicePanel.pswdEmployee.putClientProperty(FocusDecider.NAME, this); ((JTextField) invoicePanel.cbCustomer.getEditor().getEditorComponent()).putClientProperty( FocusDecider.NAME, this); ((JTextField) invoicePanel.cbSalesperson.getEditor().getEditorComponent()).putClientProperty( FocusDecider.NAME, this); invoicePanel.cbAuthorizedBuyer.putClientProperty(FocusDecider.NAME, this); invoicePanel.cbBuyerPhone.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnSearch.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnROA.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnRecallSavedInvoice.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnStockCheck.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnPartsPro.putClientProperty(FocusDecider.NAME, this); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.putClientProperty(FocusDecider.NAME, this); } invoicePanel.fldInvoiceDate.putClientProperty(FocusDecider.NAME, this); invoicePanel.fldInvoiceNumber.putClientProperty(FocusDecider.NAME, this); invoicePanel.ckCustomerPresent.putClientProperty(FocusDecider.NAME, this); invoicePanel.btnMessage.putClientProperty(FocusDecider.NAME, this); if (invoicePanel.btnStoresMessages != null) { invoicePanel.btnStoresMessages.putClientProperty(FocusDecider.NAME, this); } invoicePanel.btnViewOpenCores.putClientProperty(FocusDecider.NAME, this); invoicePanel.cbStore.putClientProperty(FocusDecider.NAME, this); invoicePanel.fldPrimaryTaxNumber.putClientProperty(FocusDecider.NAME, this); invoicePanel.fldSecondaryTaxNum.putClientProperty(FocusDecider.NAME, this); } public JComponent getDefaultFocusableComponent(JComponent currentComponent, boolean transferFocusForward) { JComponent returnComponent = null; if (transferFocusForward) { if (currentComponent.getName().equals(InvoicePanel.FLD_EMPLOYEE_NUM)) { if (invoicePanel.pswdEmployee.isVisible()) { returnComponent = invoicePanel.pswdEmployee; } else { if (invoiceVO.getManualTransaction().booleanValue()) { if (invoicePanel.fldInvoiceDate.getText() == null || invoicePanel.fldInvoiceDate.getText().equals("")) { returnComponent = invoicePanel.fldInvoiceDate; } else if (invoicePanel.fldInvoiceNumber.getText() == null || invoicePanel.fldInvoiceNumber.getText().equals("")) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { if(!invoicePanel.cbCustomer.isEnabled()){ invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); } returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } } else if (currentComponent.getName().equals(InvoicePanel.CB_STORE)) { invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.PSWD_EMPLOYEE)) { if (invoiceVO.getManualTransaction().booleanValue()) { if (invoicePanel.fldInvoiceDate.getText() == null || invoicePanel.fldInvoiceDate.getText().equals("")) { returnComponent = invoicePanel.fldInvoiceDate; } else if (invoicePanel.fldInvoiceNumber.getText() == null || invoicePanel.fldInvoiceNumber.getText().equals("")) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.CB_SALESPERSON)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else if (currentComponent.getName().equals(InvoicePanel.BTN_SEARCH)) { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.BTN_RECALL_SAVED_INVOICE)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else if (currentComponent.getName().equals(InvoicePanel.BTN_STORES_MESSAGES)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); }else if (currentComponent.getName().equals(InvoicePanel.BTN_PARTS_PRO)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else if (currentComponent.getName().equals(InvoicePanel.BTN_STOCK_CHECK)) { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.BTN_ROA)) { if (invoicePanel.fldEmployee.isEnabled()) { returnComponent = invoicePanel.fldEmployee; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_DATE)) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_NUMBER)) { String strNum = invoicePanel.fldInvoiceNumber.getText(); if ((strNum.equals("") || strNum == null) && !transferFocusForward) { logger.debug("getDefaultFocusableComponent, returning fldInvoiceNumber"); returnComponent = invoicePanel.fldInvoiceNumber; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.CK_CUSTOMER_PRESENT)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else if (currentComponent.getName().equals(InvoicePanel.FLD_PRIMARY_TAX_NUMBER)) { if (invoicePanel.fldSecondaryTaxNum.isEnabled()) { returnComponent = invoicePanel.fldSecondaryTaxNum; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.FLD_SECONDARY_TAX_NUMBER)) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } else { if (currentComponent.getName().equals(InvoicePanel.CB_STORE)) { returnComponent = invoicePanel.cbStore; } else if (currentComponent.getName().equals(InvoicePanel.FLD_EMPLOYEE_NUM)) { returnComponent = invoicePanel.fldEmployee; } else if (currentComponent.getName().equals(InvoicePanel.PSWD_EMPLOYEE)) { StringBuffer pswdBuffer = new StringBuffer(); char[] pswdArray = ((JPasswordField) currentComponent).getPassword(); pswdBuffer.append(pswdArray); if (pswdBuffer.toString().equals("") && !transferFocusForward) { logger.debug("getDefaultFocusableComponent, returning fldEmployee"); return invoicePanel.fldEmployee; } } else if (currentComponent.getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { if (invoiceVO.getManualTransaction().booleanValue()) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else if (invoicePanel.fldEmployee.isEnabled()) { returnComponent = invoicePanel.fldEmployee; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.CB_SALESPERSON)) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.CB_AUTHORIZED_BUYER)) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.BTN_SEARCH)) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_DATE)) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_NUMBER)) { returnComponent = invoicePanel.fldInvoiceDate; } else if (currentComponent.getName().equals(InvoicePanel.CK_CUSTOMER_PRESENT)) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else if (currentComponent.getName().equals(InvoicePanel.FLD_PRIMARY_TAX_NUMBER)) { if (invoicePanel.cbBuyerPhone.isEnabled() && invoicePanel.cbBuyerPhone.getItemCount() > 0) { returnComponent = invoicePanel.cbBuyerPhone; } else if (invoicePanel.cbAuthorizedBuyer.isEnabled() && invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson .getEditor().getEditorComponent(); } else { returnComponent = (JComponent) invoicePanel.cbCustomer .getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.FLD_SECONDARY_TAX_NUMBER)) { if (invoicePanel.fldPrimaryTaxNumber.isEnabled()) { returnComponent = invoicePanel.fldPrimaryTaxNumber; } else if (invoicePanel.cbBuyerPhone.isEnabled() && invoicePanel.cbBuyerPhone.getItemCount() > 0) { returnComponent = invoicePanel.cbBuyerPhone; } else if (invoicePanel.cbAuthorizedBuyer.isEnabled() && invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson .getEditor().getEditorComponent(); } else { returnComponent = (JComponent) invoicePanel.cbCustomer .getEditor().getEditorComponent(); } } } return returnComponent; } public JComponent getFocusableComponentAfterVerification(JComponent currentComponent, boolean transferFocusForward) { JComponent returnComponent = null; logger.debug("--- inside getFocusableCompAfterVerification"); if (currentComponent.getName().equals(InvoicePanel.CB_STORE)) { if (transferFocusForward) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else { returnComponent = invoicePanel.cbStore; } } else if (currentComponent.getName().equals(InvoicePanel.CB_CUSTOMER_NAME) || currentComponent.getName().equals(InvoicePanel.BTN_SEARCH)) { if (transferFocusForward) { if (((JTextField) (invoicePanel.cbCustomer.getEditor().getEditorComponent())).getText().equals("")) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if (customerVO != null) { if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { if (CustomerBL.isNapaOnlineCustomer(customerVO)) { returnComponent = invoiceLineEntryController.getNAPAReturnAuthNumComponent(); } else if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } } else { logger.debug("--- getFocusableCompAfterVerification, returning cbCustomer"); returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else { if (invoiceVO.getManualTransaction().booleanValue()) { returnComponent = invoicePanel.fldInvoiceNumber; } else if (invoicePanel.fldEmployee.isEnabled()) { returnComponent = invoicePanel.fldEmployee; } else if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.CB_SALESPERSON)) { if (transferFocusForward) { if (CustomerBL.isNapaOnlineCustomer(customerVO)) { returnComponent = invoiceLineEntryController.getNAPAReturnAuthNumComponent(); } else { if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else if (currentComponent.getName().equals(InvoicePanel.CB_AUTHORIZED_BUYER)) { if (transferFocusForward) { if (customerVO == null) { //#1067 = Invalid customer number. Please try again. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1067"); returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if ((customerVO.isAuthorizedBuyersOnly() && (customerVO.getAuthorizedBuyers() == null || customerVO.getAuthorizedBuyers().isEmpty()))) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else if (customerVO.isAuthorizedBuyersOnly() && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else if (invoicePanel.cbBuyerPhone.getItemCount() > 0) { returnComponent = invoicePanel.cbBuyerPhone; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } else { if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.CB_BUYER_PHONE)) { if (transferFocusForward) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else { returnComponent = invoicePanel.cbAuthorizedBuyer; } } else if (currentComponent.getName().equals(InvoicePanel.BTN_RECALL_SAVED_INVOICE)) { if (transferFocusForward) { if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_DATE)) { if (transferFocusForward) { returnComponent = invoicePanel.fldInvoiceNumber; } else { pointOfSaleEventDispatcher.fireManualInvoiceClosed(new InvoiceEvent(this, invoiceVO)); if (invoicePanel.cbCustomer.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else { returnComponent = invoicePanel.fldEmployee; } } } else if (currentComponent.getName().equals(InvoicePanel.FLD_INVOICE_NUMBER)) { if (transferFocusForward) { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } else { returnComponent = invoicePanel.fldInvoiceDate; } } else if (currentComponent.getName().equals(InvoicePanel.PSWD_EMPLOYEE)) { if (transferFocusForward) { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { returnComponent = invoicePanel.cbStore; } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } else { returnComponent = invoicePanel.fldEmployee; } } else if (currentComponent.getName().equals(InvoicePanel.CK_CUSTOMER_PRESENT)) { if (transferFocusForward) { if (CustomerBL.isNapaOnlineCustomer(customerVO)) { returnComponent = invoiceLineEntryController.getNAPAReturnAuthNumComponent(); } else if (invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } else { if (invoicePanel.cbSalesperson.isEnabled()) { invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.FLD_PRIMARY_TAX_NUMBER)) { if (transferFocusForward) { if (invoicePanel.fldSecondaryTaxNum.isEnabled()) { returnComponent = invoicePanel.fldSecondaryTaxNum; } else { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } } else { if (invoicePanel.cbBuyerPhone.isEnabled() && invoicePanel.cbBuyerPhone.getItemCount() > 0) { returnComponent = invoicePanel.cbBuyerPhone; } else if (invoicePanel.cbAuthorizedBuyer.isEnabled() && invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } else if (currentComponent.getName().equals(InvoicePanel.FLD_SECONDARY_TAX_NUMBER)) { if (transferFocusForward) { returnComponent = invoiceLineEntryController.getPartNumberComponent(); } else { if (invoicePanel.fldPrimaryTaxNumber.isEnabled()) { returnComponent = invoicePanel.fldPrimaryTaxNumber; } else if (invoicePanel.cbBuyerPhone.isEnabled() && invoicePanel.cbBuyerPhone.getItemCount() > 0) { returnComponent = invoicePanel.cbBuyerPhone; } else if (invoicePanel.cbAuthorizedBuyer.isEnabled() && invoicePanel.cbAuthorizedBuyer.getItemCount() > 0) { returnComponent = invoicePanel.cbAuthorizedBuyer; } else if (invoicePanel.ckCustomerPresent.isVisible() && !skipCustomerPresent) { returnComponent = invoicePanel.ckCustomerPresent; } else if (invoicePanel.cbSalesperson.isEnabled()) { returnComponent = (JComponent) invoicePanel.cbSalesperson.getEditor().getEditorComponent(); } else { returnComponent = (JComponent) invoicePanel.cbCustomer.getEditor().getEditorComponent(); } } } return returnComponent; } public boolean validateComponent(JComponent component) { if (component.getName().equals(InvoicePanel.FLD_EMPLOYEE_NUM)) { if (((JTextField) component).getText() == null || ((JTextField) component).getText().equals("")) { return false; } else { try { empNum = Integer.parseInt(((JTextField) component).getText()); if (clientApplicationContext.getSystemDAO().askEmployeePassword().booleanValue() && getInvoicingProfileVO().getRequireEmployeePasswordOnInvoice() .booleanValue()) { invoicePanel.pswdEmployee.setEnabled(true); return true; } else { return displayEmployeeName(empNum); } } catch (NumberFormatException e) { logger.info("Employee Number Invalid", e); invoicePanel.dlblEmployee.setText(""); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "116"); return false; } } } else if (component.getName().equals(InvoicePanel.PSWD_EMPLOYEE)) { StringBuffer pswdBuffer = new StringBuffer(); char[] pswdArray = ((JPasswordField) component).getPassword(); pswdBuffer.append(pswdArray); boolean retFlag = verifyPassword(pswdBuffer.toString()); changePassword = false; if (!retFlag && pswdBuffer.toString().equals("")) { retFlag = true; // this will cause focus to go back to employee // field. } if (!changePassword && retFlag && !pswdBuffer.toString().equals("")) { pointOfSaleEventDispatcher .fireEmployeeLoggedIn(new EmployeeEvent(this, employeeVO)); } return retFlag; } else if (component.getName().equals(InvoicePanel.CB_CUSTOMER_NAME)) { String customerNumString = ((JTextField) component).getText().trim(); if (verifyCustomerText(customerNumString)){ enableViewOpenCoresButton(); setResourceInUse(); customerNumString = ((JTextField) component).getText().trim(); if (customerNumString.length() > 0) { //Enable Parts Pro Button if (ppse2Active) { setPartsPro2LaunchEnabled( true ); } else { invoicePanel.btnPartsPro.setEnabled(true); } //Notify PointOfSalecontroller to disable Add Retail Customer clientApplicationContext.getPointOfSaleEventDispatcher().fireCustomerFieldValidated(new CustomerEvent(this, null)); // Added for RADS-Main Counter updateCustomerIdForRadsItems(); // ========================================== return true; } else { fldCustomer.setText(""); oldCustomerNum = ""; customerVO = null; invoiceLineEntryController.setPartNumberEnabled(false); invoiceLineEntryController.getBarcodeButton().setEnabled(false); invoicePanel.cbSalesperson.setEnabled(false); return false; } } else { if (!CustomerBL.isNapaOnlineCustomer(customerVO) && !InvoiceBL.hasPickupItem(invoiceVO.getLineItems()) && !hasReturnItemMappedToOriginalInvoice(invoiceVO) && !certificatePartExist && !InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO) && invoiceVO.getDirectShippedInvoice() == null && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) { fldCustomer.setText(""); oldCustomerNum = ""; customerVO = null; invoiceLineEntryController.setPartNumberEnabled(false); invoiceLineEntryController.getBarcodeButton().setEnabled(false); invoicePanel.cbSalesperson.setEnabled(false); } return false; } } else if (component.getName().equals(InvoicePanel.CB_SALESPERSON)) { String salespersonNumString = ((JTextField) component).getText(); if ((salespersonNumString == null) || (salespersonNumString.trim().equals(""))) { return false; } else { return displaySalespersonName(salespersonNumString); } } else if (component.getName().equals(InvoicePanel.FLD_INVOICE_DATE)) { return validateInvoiceDate(); } else if (component.getName().equals(InvoicePanel.FLD_INVOICE_NUMBER)) { String strNum = invoicePanel.fldInvoiceNumber.getText(); if (strNum.equals("") || strNum == null) { return true; //so we can go backwards to invoice Date } return validateInvoiceNumber(); } else if (component.getName().equals(InvoicePanel.FLD_PRIMARY_TAX_NUMBER)) { validatePrimaryTaxNumber(); } else if (component.getName().equals(InvoicePanel.FLD_SECONDARY_TAX_NUMBER)) { validateSecondaryTaxNumber(); } return true; } private boolean validateInvoiceNumber() { if (invoiceVO.getManualTransaction().booleanValue()) { String invoiceNumber = invoicePanel.fldInvoiceNumber.getText().trim(); if (invoiceNumber == null || invoiceNumber.length() < 1) { return false; } else { invoiceVO.setInvoiceNumber(new Integer(invoiceNumber)); try { if (clientApplicationContext.getInvoiceDAO().doesInvoiceExist( invoiceVO).booleanValue()) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1363"); clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled( new InvoiceEvent(this, invoiceVO)); return false; } } catch(ApplicationException e) { logger.error(e.toString(), e); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2227"); return false; } invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); invoicePanel.btnSearch.setEnabled(true); return true; } } else { return true; } } private boolean validateInvoiceDate() { String invoiceDate = invoicePanel.fldInvoiceDate.getText(); if (invoiceDate == null || invoiceDate.length() < 1) { try { FwoPattern datePattern = FwoPattern.getDatePatternInstance( clientApplicationContext.getCurrentLocale(), new Integer( clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getStoreProfile().getRefDateFormatId().intValue())); invoicePanel.fldInvoiceDate.setText(datePattern.format(new Date())); } catch (PatternFormatException pfe) { logger.error(pfe.toString(), pfe); } } Date today = new Date(); Date d = InvoiceLineBL.parseDate(invoicePanel.fldInvoiceDate.getText()); if (d.after(today)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1372"); return false; } invoiceVO.setInvoiceDate(d); invoiceVO.setInvoiceDateInString(d.toString()); return true; } public void invoiceLoaded (final InvoiceEvent ie) { if (!(ie.getModel() instanceof InvoiceVO)) { return; } if(ie.getSource() instanceof RecallSavedInvoiceController) { loadedFromRecallSavedInvoice = true; } else { loadedFromRecallSavedInvoice = false; } logger.debug("old InvoiceVO: " + this.invoiceVO.getPpseCartNumber()); // should send endPPSE message here... // if the old invoice vo has a PPSE number, then this invoice was abandoned // after starting a PPSE session, and an endPpseSession call should be made if(this.invoiceVO != null && this.invoiceVO.getPpseCartNumber() != null && !this.invoiceVO.getPpseCartNumber().equals("")) { logger.debug("closing abandonded PPSE session"); InvoiceBL.closePpseSession(this.invoiceVO); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(false); } } this.invoiceVO = (InvoiceVO) ie.getModel(); logger.debug("new InvoiceVO: " + invoiceVO.getPpseCartNumber()); if (this.invoiceVO.getCustomerID() == null) { return; } if (ie.getDisplayCustomerPresent()) { initializeDisplayPricing(); } if (clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER) { try { employeeVO = clientApplicationContext.getEmployeeDAO().getEmployeeInfo( invoiceVO.getCountermanEmployeeID()); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } invoicePanel.fldEmployee.setText(employeeVO.getEmployeeNum().toString()); invoicePanel.dlblEmployee.setText(employeeVO.getFirstName() + " " + employeeVO.getLastName()); invoicePanel.pswdEmployee.setVisible(false); invoicePanel.fldEmployee.setEnabled(false); counterManID = invoiceVO.getCountermanEmployeeID(); } if (clientApplicationContext.isLoggedInAsPhoneRoom()) { if (loadedFromRecallSavedInvoice && invoiceVO.getPhoneRoomStoreId() != null) { selectStore(invoiceVO.getPhoneRoomStoreId()); } //STEL-195 else if(invoiceVO.getRemoteStoreNumber()!=null && invoiceVO.getPhoneRoomStoreId()!=null) { selectStore(invoiceVO.getPhoneRoomStoreId()); }else { selectStoreAsSame(); } if(invoiceVO.getRemoteStoreNumber() == null && invoicePanel.cbStore.isVisible() && invoicePanel.cbStore.getSelectedItem() != null && invoicePanel.cbStore.getSelectedItem() instanceof PhoneRoomStoreVO) { invoiceVO.setRemoteStoreNumber( ((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem()) .getStoreNumber()); } } if (ie.getDisplayCustomerPresent()) { getAndDisplayCustomerInfo (this.invoiceVO.getCustomerID().intValue(), this.invoiceVO.getCustomerTypeCD()); setInvoiceVOCustomerAttributes(false); if (this.invoiceVO.getSalesmanEmployeeID() == null) { selectSalesPerson(-1); } else { selectSalesPerson(this.invoiceVO.getSalesmanEmployeeID().intValue()); } if (InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)) { invoicePanel.fldAttentionInfo .setDocument(new DefaultDocument( invoicePanel.fldAttentionInfo, clientApplicationContext .getSystemDAO().getAttentionCharLength().intValue(), DefaultDocument.ANY)); } invoicePanel.fldAttentionInfo.setText(((this.invoiceVO.getAttention()) != null ? (this.invoiceVO.getAttention()) : TsoConstant.EMPTY_STRING)); populateAuthorizedBuyer(); enableSalesperson(); if (this.invoiceVO.getCustomerContactID() != null) { selectAuthorizedBuyer (this.invoiceVO.getCustomerContactID()); } } skipCustomerPresent = true; SwingUtilities.invokeLater(new Runnable() { public void run() { if(ie.getSource() instanceof ReviewMessagesController) { loadLines(ie.getGenerateLines(), true, false, ie.getDisplayCustomerPresent(), false); }else if(ie.getSource() instanceof PhoneRoomMessageController) { loadLinesPhoneRoom(ie.getGenerateLines(), true, false, ie.getDisplayCustomerPresent(), false); }else { if (loadedFromRecallSavedInvoice) { setInvoiceDetails(); } loadLines(ie.getGenerateLines(), false, false, ie.getDisplayCustomerPresent(), false); invoiceVO.setLoadedFromRecallSavedInvoice(false); } } }); if (invoiceVO != null && invoiceVO.getSavedInvoiceIdForDeletion() != null) { refreshSavedInvoice(); } if (clientApplicationContext.getPOSState().getState() != POSStateVO.NORMAL) { invoicePanel.setVisible(true); } if (getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { invoicePanel.lblPrimaryTaxNumber.setEnabled(true); invoicePanel.lblSecondaryTaxNumber.setEnabled(true); // RecallSaved Invoice if (invoiceVO.getSavedInvoiceIdForDeletion() != null) { String invPrimaryTaxNumber = invoiceVO.getPrimaryTaxNumber(); String custPrimaryTaxNumber = customerVO.getPrimaryTaxNumber(); invPrimaryTaxNumber = (invPrimaryTaxNumber == null) ? null : invPrimaryTaxNumber.trim(); custPrimaryTaxNumber = (custPrimaryTaxNumber == null) ? null : custPrimaryTaxNumber.trim(); if(StringUtils.isNotEmpty(invPrimaryTaxNumber) && invPrimaryTaxNumber.equals(custPrimaryTaxNumber)) { invoicePanel.lblPrimaryTaxNumberValue.setVisible(true); invoicePanel.fldPrimaryTaxNumber.setVisible(false); invoicePanel.lblPrimaryTaxNumberValue.setText(invPrimaryTaxNumber); } else { invoicePanel.lblPrimaryTaxNumberValue.setVisible(false); invoicePanel.fldPrimaryTaxNumber.setVisible(true); invoicePanel.fldPrimaryTaxNumber.setEnabled(true); if(StringUtils.isNotEmpty(invPrimaryTaxNumber)) { invoicePanel.fldPrimaryTaxNumber.setText(invPrimaryTaxNumber); } } String invSecondaryTaxNumber = invoiceVO.getSecondaryTaxNumber(); String custSecondaryTaxNumber = customerVO.getSecondaryTaxNumber(); invSecondaryTaxNumber = (invSecondaryTaxNumber == null) ? null : invSecondaryTaxNumber.trim(); custSecondaryTaxNumber = (custSecondaryTaxNumber == null) ? null : custSecondaryTaxNumber.trim(); if (StringUtils.isNotEmpty(invSecondaryTaxNumber) && invSecondaryTaxNumber.equals(custSecondaryTaxNumber)) { invoicePanel.lblSecondaryTaxNumberValue.setVisible(true); invoicePanel.fldSecondaryTaxNum.setVisible(false); invoicePanel.lblSecondaryTaxNumberValue.setText(invSecondaryTaxNumber); } else { invoicePanel.lblSecondaryTaxNumberValue.setVisible(false); invoicePanel.fldSecondaryTaxNum.setVisible(true); invoicePanel.fldSecondaryTaxNum.setEnabled(true); if(StringUtils.isNotEmpty(invSecondaryTaxNumber)) { invoicePanel.fldSecondaryTaxNum.setText(invSecondaryTaxNumber); } } } } enableViewOpenCoresButton(); setResourceInUse(); SwingUtilities.invokeLater(new Runnable() { public void run() { delegateToESBRegistration(); } }); } public void invoicePrinted (InvoiceEvent ie) { InvoiceVO invoiceVO = (InvoiceVO) ie.getModel(); if (invoicePanel.pnlManualInvoice.isVisible()) { invoiceVO.setManualTransaction(Boolean.TRUE); } resetVOs(invoiceVO); resetInvoicePanel(); if (invoicePanel.pnlManualInvoice.isVisible()) { invoicePanel.cbCustomer.setEditable(false); invoicePanel.cbCustomer.setEnabled(false); invoicePanel.btnSearch.setEnabled(false); } if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.fldEmployee.setEnabled(true); clientApplicationContext.getPointOfSaleEventDispatcher().fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); if (clientApplicationContext.isLoggedInAsSales()) { setCurrentUserAsSales(); } } selectDefaultServingStore(); ClientResourceUsage.finishTask(PointOfSaleConstants.POS_PROGRAM_SOURCE); } public void invoiceSaved (InvoiceEvent ie) { stopPartsProSe2Timer(); resetVOs((InvoiceVO) ie.getModel()); resetInvoicePanel(); if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState( ).getState() == POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.fldEmployee.setEnabled(true); clientApplicationContext.getPointOfSaleEventDispatcher().fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); if (clientApplicationContext.isLoggedInAsSales()) { setCurrentUserAsSales(); } } selectDefaultServingStore(); ClientResourceUsage.finishTask(PointOfSaleConstants.POS_PROGRAM_SOURCE); if (invoiceVO != null && invoiceVO.getLineItems()!=null) { logger.error("InvoiceController.invoiceSaved: for custID:" + invoiceVO.getCustomerID() + " /Number of line items:" + invoiceVO.getLineItems().size() + " /PONum:" + invoiceVO.getPONumber()+" /SessionId= "+invoiceVO.getSessionID()); } } public void setInitialFocus() { if (invoicePanel.pnlManualInvoice.isVisible()) { invoicePanel.fldInvoiceDate.requestFocus(); } else { if (invoicePanel.fldEmployee.isEnabled()) { SwingUtilities.invokeLater(new Runnable() { public void run() { invoicePanel.fldEmployee.requestFocusInWindow(); } }); } else { if (!invoicePanel.cbCustomer.isEnabled()) { invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); invoicePanel.btnSearch.setEnabled(true); } if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoicePanel.cbStore.isEnabled()) { invoicePanel.cbStore.requestFocus(); } else { invoicePanel.cbCustomer.getEditor().getEditorComponent().requestFocus(); } } } } private void selectAuthorizedBuyer(Integer customerContact) { if (customerContact == null) { return; } int iCount = invoicePanel.cbAuthorizedBuyer.getItemCount(); for (int i = 0; i < iCount; i++) { IDValuePairVO idValuePair = (IDValuePairVO) invoicePanel.cbAuthorizedBuyer.getItemAt(i); if (idValuePair == null) { continue; } if (idValuePair.getValue() == null) { continue; } if (((Integer) idValuePair.getID()).intValue() != customerContact.intValue()) { if ((i + 1) == iCount) { invoiceVO.setCustomerContactID(null); invoicePanel.cbAuthorizedBuyer.setSelectedIndex(0); break; } else { continue; } } invoicePanel.cbAuthorizedBuyer.setSelectedIndex(i); break; } } public void invoiceCancelled(InvoiceEvent ie) { InvoiceVO invoiceVO = (InvoiceVO) ie.getModel(); if (invoicePanel.pnlManualInvoice.isVisible()) { invoiceVO.setManualTransaction(Boolean.TRUE); } if(this.invoiceVO != null) { stopPartsProSe2Timer(); InvoiceBL.closePpseSession(this.invoiceVO); } resetVOs(invoiceVO); resetInvoicePanel(); if (invoicePanel.pnlManualInvoice.isVisible()) { invoicePanel.cbCustomer.setEditable(false); invoicePanel.cbCustomer.setEnabled(false); invoicePanel.btnSearch.setEnabled(false); } if (ie.getSource() instanceof DefaultLineItemHandler) { invoicePanel.cbCustomer.setEditable(true); invoicePanel.cbCustomer.setEnabled(true); invoicePanel.btnSearch.setEnabled(true); invoicePanel.btnSearch.setEnabled(true); InvoiceController.this.fldCustomer.requestFocus(); } if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.fldEmployee.setEnabled(true); clientApplicationContext.getPointOfSaleEventDispatcher().fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); if (clientApplicationContext.isLoggedInAsSales()) { setCurrentUserAsSales(); } } loyaltyCustomerLookup = null; selectDefaultServingStore(); ClientResourceUsage.finishTask(PointOfSaleConstants.POS_PROGRAM_SOURCE); } public void invoiceSplitted(InvoiceEvent ie){ this.invoiceVO = (InvoiceVO) ie.getModel(); } public void invoiceTotalChanged(InvoiceEvent ie) { } public void recallSavedInvoiceDialogueClosed(InvoiceEvent ie){ SwingUtilities.invokeLater(new Runnable() { public void run() { delegateToESBRegistration(); } }); } public void invoiceLineItemAdded(PointOfSaleListEvent posle) { logger.debug("QUEUE SIZE ===" + LineGenerationQueue.getInstance().size()); invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoicePanel.btnMessage.setEnabled(false); invoicePanel.btnROA.setEnabled(false); if(clientApplicationContext.isLoggedInAsPhoneRoom() && invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setEnabled(false); if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { //disable the employee field invoicePanel.fldEmployee.setEnabled(false); //get handle to "Other TAMS Functions", and enable it. ((PointOfSaleFrame) parentContainer).setOtherTAMSFunctionsMenuItem(false); } if(LineGenerationQueue.getInstance().size() != 0) { listItemSelected = true; } else if (LineGenerationQueue.getInstance().size() == 0) { listItemSelected = false; } if(ppse2Lines.size() == 0){ ppse2LinesProcessing = false; } else { if(LineGenerationQueue.getInstance().size() == 0) { processPpse2Lines(); } } } public void invoiceLineItemDeleted(PointOfSaleListEvent posle) { Vector lineItems = ((InvoiceVO) posle.getModel()).getLineItems(); if(gpcOwned){ if (ableToAcceptROAPayments && clientApplicationContext.getSystemDAO().enableROA().booleanValue() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL)) { invoicePanel.btnROA.setEnabled((lineItems == null || lineItems.isEmpty())); } } else { if (clientApplicationContext.getSystemDAO().enableROA().booleanValue() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL)) { invoicePanel.btnROA.setEnabled((lineItems == null || lineItems.isEmpty())); } } if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.fldEmployee.setEnabled(lineItems == null || lineItems.isEmpty()); //get handle to "Other TAMS Functions", and enable it. ((PointOfSaleFrame) parentContainer).setOtherTAMSFunctionsMenuItem( (lineItems == null || lineItems.isEmpty())); } } public void invoiceLineItemDeleteInvoked (PointOfSaleListEvent posle) { } public void invoiceAssociatedCoreLineItemDeleteInvoked( PointOfSaleListEvent posle) { } public void detachCoreLineItemFromPart(PointOfSaleListEvent posle) { } public void clearButtonsOnHidePanel() { invoicePanel.btnStockCheck.setBounds(260, 50, 170, 20); invoicePanel.pnlButtons.add(invoicePanel.btnStockCheck); invoicePanel.btnPartsPro.setBounds(260, 4, 170, 20); invoicePanel.pnlButtons.add(invoicePanel.btnPartsPro); //commented out awaiting answer on if we need this included // invoicePanel.btnRecallSavedInvoice.setBounds(10, 50, 170, 20); // invoicePanel.pnlButtons.add(invoicePanel.btnRecallSavedInvoice); // invoicePanel.btnSearch.setBounds(402, 28, 100, 20); // invoicePanel.pnlEmployee.add(invoicePanel.btnSearch); // invoicePanel.btnROA.setBounds(10, 27, 170, 20); // invoicePanel.pnlButtons.add(invoicePanel.btnROA); // invoicePanel.btnMessage.setBounds(10, 4, 170, 20); // invoicePanel.pnlButtons.add(invoicePanel.btnMessage); } public void setButtonsOnHidePanel() { invoicePanel.btnPartsPro.setBounds(828, 1, 170, 20); //(840, 1, 170, 20); invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnPartsPro); invoicePanel.btnStockCheck.setBounds(683, 1, 140, 20); //(660, 1, 170, 20); invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnStockCheck); //commented out awaiting answer on if we need this included // invoicePanel.btnRecallSavedInvoice.setBounds(524, 1, 154, 20); // invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnRecallSavedInvoice); // invoicePanel.btnSearch.setBounds(419, 1, 100, 20); // invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnSearch); // invoicePanel.btnROA.setBounds(329, 1, 85, 20); // invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnROA); // invoicePanel.btnMessage.setBounds(229, 1, 94, 20); // invoicePanel.pnlResize.addToMaximizer(invoicePanel.btnMessage); } public void propertyChange(PropertyChangeEvent pce) { if (invoicePanel.pnlResize == pce.getSource()) { if (pce.getPropertyName().equals(ResizablePanel.RESIZED)) { if (pce.getNewValue().equals(Boolean.FALSE)) { invoicePanel.pnlResize.setBounds(0, 0, invoicePanel.screenSize.width, InvoicePanel.RESIZABLE_PANEL_HEIGHT); clearButtonsOnHidePanel(); } else { invoicePanel.pnlResize.setBounds(0, 0, invoicePanel.screenSize.width, 22); setButtonsOnHidePanel(); } boolean boolPCE = ((Boolean) pce.getNewValue()).booleanValue(); invoiceLineListController.enlargeInvoiceLineEntryArea(boolPCE); invoicePanel.dlblCustomerHeader.setVisible(!boolPCE); repaintView(); } } } private void resetInvoicePanel() { preferencePPSE = null; String emptyString = ""; invoicePanel.dlblCustomerHeader.setText(emptyString); invoicePanel.dlblAuthorizedBuyer.setText(emptyString); fldCustomer.setText(emptyString); pointOfSaleEventDispatcher.fireLocaleUnlocked(new LocaleEvent(this, clientApplicationContext.getCurrentLocale(), clientApplicationContext.getCurrentLocale())); populateSalesperson(); invoicePanel.cbSalesperson.setEnabled(false); invoicePanel.taCustomerInfo.setText(emptyString); invoicePanel.dlblPhone.setText(emptyString); invoicePanel.dlblFax.setText(emptyString); invoicePanel.dlblBillingType.setText(emptyString); invoicePanel.dlblAvailable.setText(emptyString); invoicePanel.dlblLimit.setText(emptyString); invoicePanel.dlblPrimaryTax.setText(emptyString); invoicePanel.dlblPrimaryTaxState.setText(emptyString); invoicePanel.dlblTaxExemptNum.setText(emptyString); invoicePanel.dlblTaxExpDate.setText(emptyString); invoicePanel.dlblSecondaryTax.setText(emptyString); invoicePanel.dlblSecondaryTaxState.setText(emptyString); invoicePanel.dlblSecondaryTaxExemptNum.setText(emptyString); invoicePanel.dlblSecondaryTaxExpDate.setText(emptyString); invoicePanel.taNote.setText(emptyString); invoicePanel.dlblPUPending.setVisible(false); invoicePanel.lblAuthorizedBuyer.setEnabled(false); invoicePanel.cbAuthorizedBuyer.removeAllItems(); invoicePanel.cbAuthorizedBuyer.setEnabled(false); invoicePanel.cbBuyerPhone.removeAllItems(); invoicePanel.cbBuyerPhone.setEnabled(false); invoicePanel.fldAttentionInfo.setText(emptyString); invoiceLineEntryController.setPartNumberEnabled(false); invoicePanel.btnRecallSavedInvoice.setEnabled(this.useSaveInvoice); if(gpcOwned){ if (ableToAcceptROAPayments && clientApplicationContext.getSystemDAO().enableROA().booleanValue() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL || clientApplicationContext.getPOSState().getState() == POSStateVO.PHONE_ROOM)) { invoicePanel.btnROA.setEnabled(true); } } else { if (clientApplicationContext.getSystemDAO().enableROA().booleanValue() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL || clientApplicationContext.getPOSState().getState() == POSStateVO.PHONE_ROOM)) { invoicePanel.btnROA.setEnabled(true); } } if (clientApplicationContext.isLoggedInAsSales() || clientApplicationContext.getPOSState().getState() == POSStateVO.CASHIER || clientApplicationContext.getPOSState().getState() == POSStateVO.INVOICING_AS_CASHIER) { ((PointOfSaleFrame) parentContainer).setOtherTAMSFunctionsMenuItem(false); } else { ((PointOfSaleFrame) parentContainer).setOtherTAMSFunctionsMenuItem(true); } ((PointOfSaleFrame) parentContainer).setPartsPROMenuEnabled(false); invoicePanel.btnPartsPro.setEnabled(false); setPartsPro2LaunchEnabled( false ); //fire event to disable PPSE Menu option. clientApplicationContext.getPointOfSaleEventDispatcher().firePpseCatalogSessionClosed( new CatalogEvent(this, null)); if (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() != POSStateVO.INVOICING_AS_CASHIER) { invoicePanel.btnMessage.setEnabled( clientApplicationContext.getSystemDAO().enableMessageButton().booleanValue()); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(clientApplicationContext.getSystemDAO().enableMessageButton().booleanValue()); } } invoicePanel.fldInvoiceNumber.setText(""); invoicePanel.ckCustomerPresent.setSelected(false); invoicePanel.ckCustomerPresent.setEnabled(false); skipCustomerPresent = false; if (invoicePanel.pnlResize.getHidden()) { invoicePanel.pnlResize.togglePanel(); } // Code Added for Core Bank - start invoicePanel.lblCoreNotification.setVisible(false); invoicePanel.btnViewOpenCores.setEnabled(false); // Code Added for Core Bank if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbStore.setEnabled(true); if(invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setEnabled(true); } invoicePanel.lblPriorityPlusLabel.setVisible(false); invoicePanel.lblPrimaryTaxNumber.setEnabled(false); invoicePanel.fldPrimaryTaxNumber.setEnabled(false); invoicePanel.fldPrimaryTaxNumber.setText(""); invoicePanel.lblSecondaryTaxNumber.setEnabled(false); invoicePanel.fldSecondaryTaxNum.setText(""); invoicePanel.fldSecondaryTaxNum.setEnabled(false); invoicePanel.lblSecondaryTaxNumberValue.setText(""); invoicePanel.lblPrimaryTaxNumberValue.setText(""); invoicePanel.fldPrimaryTaxNumber.setVisible(false); invoicePanel.fldSecondaryTaxNum.setVisible(false); } public void resetVOs(InvoiceVO invoiceVO) { this.invoiceVO = invoiceVO; if (invoiceVO != null && clientApplicationContext.isLoggedInAsPhoneRoom()) { invoiceVO.setRemoteStoreNumber(((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem()).getStoreNumber()); invoiceVO.setPhoneRoomStoreId(((PhoneRoomStoreVO) invoicePanel.cbStore.getSelectedItem()).getId()); } if(this.invoiceVO != null){ this.invoiceVO.setSavedCart(null); } invoicingProfileVO = getInvoicingProfileVO(); this.customerVO = null; oldCustomerNum = null; displayableInvVO = new DisplayableInvoiceVO(); initializeDisplayPricing(); } public JButton getPartsProButton() { return invoicePanel.btnPartsPro; } public JButton getImportCartButton() { return invoicePanel.btnImportCart; // Can be null! } public void customerChanged(CustomerEvent ce) { logger.debug("oldCustomerNum: " + oldCustomerNum); logger.debug("customerVO.getCustomerNumber(): " + customerVO.getCustomerNumber()); logger.debug("invoiceVO.getPpseCartNumber(): " + invoiceVO.getPpseCartNumber()); logger.debug("loadedFromRecallSavedInvoice: " + loadedFromRecallSavedInvoice); final String newCustomerNum = customerVO.getCustomerNumber().toString(); final SessionData sessionData = SessionFactory.createSession(invoiceVO, customerVO, SessionFactory.PPSE2); setPartsPro2LaunchEnabled( true ); if (sessionData.getVersion() == SessionData.PPSE2_REGULAR){ stopPartsProSe2Timer(); if (ppse2GuiInstanceId != null && (oldCustomerNum != null && !oldCustomerNum.equals( newCustomerNum ))) { SwingUtilities.invokeLater(new Runnable() { public void run() { //2,N,You have changed the customer while invoicing. //Please close the browser and restart your PartsProSE session. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "6203"); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(false); } } }); } else if (!loadedFromRecallSavedInvoice && (oldCustomerNum != null && !oldCustomerNum.equals( newCustomerNum )) && (invoiceVO.getPpseCartNumber() != null && !invoiceVO.getPpseCartNumber().equals(""))) { InvoiceBL.closePpseSession(invoiceVO); invoiceVO.setPpseCartNumber(null); invoiceVO.setPpseTicketNumber(null); // put this in a swing utilities invoke later because it was causing // weird focus on the customer drop down when customer was changed by selecting // the drop down and choosing a different customer in the list. SwingUtilities.invokeLater(new Runnable() { public void run() { //2,N,You have changed the customer while invoicing. //Please close the browser and restart your PartsProSE session. clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "6203"); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(false); } } }); } } if (!loadedFromRecallSavedInvoice && (oldCustomerNum != null && !oldCustomerNum.equals( newCustomerNum ))) { InvoiceBL.removeCustomerInformationLines(invoiceVO.getLineItems()); } loadedFromRecallSavedInvoice = false; if (ce.getRegenerateLines()) { deleteAutoGeneratedMiscCharges(); if (!CustomerBL.isNapaOnlineCustomer(customerVO)) { if (invoicePanel.ckCustomerPresent.isVisible() && invoiceVO != null && !invoiceVO.getLineItems().isEmpty()) { skipCustomerPresent = true; } SwingUtilities.invokeLater(new Runnable() { public void run() { loadLines(false, true, true, true, true); } }); } else { invoiceVO.setSavedCart(null); } } displayableInvVO = new DisplayableInvoiceVO(); //we only want it to display on a change customer, not if it's a recalled invoice. loyaltyCustomerLookup = null; } public void customerFieldFocusGained(CustomerEvent ce) {} public void customerFieldValidated(CustomerEvent ce) {} private void loadLines(boolean generateLines, boolean redoTaxes, boolean miscChgOnly, boolean displayCustomerPresent, boolean changeCustomer) { boolean invoiceContainsZeroPriceLineItem = false; BigDecimal zero = new BigDecimal("0.00"); if (invoiceVO.getAlternateCoreSubTotal() == null) { invoiceVO.setAlternateCoreSubTotal(zero); invoiceVO.setAlternateCoreDisplaySubTotal(zero); } if (invoiceVO.isReturnInvoice() && invoiceVO.getLineItems().size() > 0) { Vector lineItems = (Vector) invoiceVO.getLineItems().clone(); invoiceVO.getLineItems().removeAllElements(); int lineitemindex = 0; // Logic to process the notes here first for (int i = 0; i < lineItems.size(); i++) { InvoiceLineItemVO invoiceLineItemVOtemp1 = (InvoiceLineItemVO)lineItems.get(i); if(invoiceLineItemVOtemp1 instanceof InvoiceNoteVO){ final InvoiceNoteVO invoiceNoteVO = (InvoiceNoteVO)invoiceLineItemVOtemp1; ((InvoiceNoteVO)lineItems.get(i)).setLineAddedToList(true); lineitemindex++; invoiceNoteVO.setCompletedLine(true); invoiceNoteVO.setLineAddedToList(true); SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemAdded( new PointOfSaleListEvent(this, invoiceNoteVO)); } }); } else { break; } } InvoiceLineItemVO invoiceLineItemVOtemp = (InvoiceLineItemVO)lineItems.get(lineitemindex); if (invoiceLineItemVOtemp instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVOtemp = (BaseLineItemVO) invoiceLineItemVOtemp; ((BaseLineItemVO)lineItems.get(lineitemindex)).setLineAddedToList(true); //baseLineItemVOtemp.setLineAddedToList(true); } invoiceVO.setReturnLineItems(lineItems); invoiceVO.getLineItems().removeAllElements(); final BaseLineItemVO currentLineItmVO = (BaseLineItemVO) invoiceLineItemVOtemp; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher() .fireListModelChanged(new InvoiceEvent(this, currentLineItmVO)); } }); return; } InvoiceLineBL.removeCODeliveryLineItem(invoiceVO); Vector lineItems = (Vector) invoiceVO.getLineItems().clone(); if (lineItems != null && invoiceVO.getPONumber()!=null && invoiceVO.getSavedInvoiceIdForDeletion() !=null ) { logger.error("InvoiceController.loadLines1: Invoice recalled for custID:" + invoiceVO.getCustomerID() + " /Number of line items:" + lineItems + " /PONum:" + invoiceVO.getPONumber()+" /SessionId= "+invoiceVO.getSessionID()+" /SavedInvoiceID= "+invoiceVO.getSavedInvoiceIdForDeletion()); } invoiceVO.getLineItems().removeAllElements(); if (redoTaxes) { invoiceVO.setNonTaxableSales1(zero); invoiceVO.setTaxableSales1(zero); invoiceVO.setNonTaxableSales2(zero); invoiceVO.setTaxableSales2(zero); } if (lineItems.size() > 0 && CustomerBL.doDisplayCustPresentQuestion()&& displayCustomerPresent) { int focus = customerVO.isTypicallyPresentDuringInvoicing().booleanValue() ? 0 : 1; boolean dispToPricingPole = clientApplicationContext.getMessageMgr().showMessageFocusPrompt(invoicePanel, "2235", focus); invoiceVO.setDisplayPricing(dispToPricingPole); invoicePanel.ckCustomerPresent.setSelected(dispToPricingPole); } TaxTableVO deliveryTaxTableVO = clientApplicationContext.getSystemDAO().getTaxTable( loc, customerVO.getDeliveredTaxTableID()); final Vector linesAlredayInQueue = new Vector(); final Vector invoiceLineItems = new Vector(); boolean isCODeliveryFeeRequired = false; for (int i = 0; i < lineItems.size(); i++) { InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.get(i); /* * TODO Saved invoice check along with setting null to id and version should be removed in next release. * * I have kept this check to minimize the impact to other flows. The cart would have got * synced through createCart/editCart process for a saved invoice by now. Once we remove the * check of saved invoice while creating cart, we don't want need this check anymore. */ if(invoiceVO.getSavedInvoiceIdForDeletion() == null){ invoiceLineItemVO.setId(null); invoiceLineItemVO.setVersion(null); } if (invoiceLineItemVO instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO; if (invoiceVO.getSavedInvoiceIdForDeletion() != null && !changeCustomer) { baseLineItemVO.setDisplayTaxable2((invoiceVO.getSecondaryTaxTableID() != null && invoiceVO.getSecondaryTaxTableID().shortValue() > 0)); } else { baseLineItemVO.setDisplayTaxable2((customerVO.getPrimaryTaxTable() != null) && ((customerVO.getPrimaryTaxTable().getSecondaryTaxTableID() != null && customerVO.getPrimaryTaxTable().getSecondaryTaxTableID().shortValue() > 0) ||(deliveryTaxTableVO != null && deliveryTaxTableVO.getSecondaryTaxTableID() != null && deliveryTaxTableVO.getSecondaryTaxTableID().shortValue() > 0))); } InventoryVO inventoryVO = null; if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { if(baseLineItemVO.isVirtualKit() && baseLineItemVO.getComponents() != null && baseLineItemVO.getComponents().size() > 0){ inventoryVO = InvoiceLineBL.getVirtualKitDetailInfo(customerVO, baseLineItemVO); } else { inventoryVO = clientApplicationContext.getInventoryDAO().getPartDetailInfo( customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), false); } InvoiceLineBL.checkDC(customerVO, baseLineItemVO, false, inventoryVO); } logger.debug(" InvoiceController.loadLines - redoTaxes = " + redoTaxes); if (getStoreProfile().getUseNapaXpress().booleanValue() && baseLineItemVO.getGeneratedByLineItem() == null && !CustomerBL.isNapaOnlineCustomer(customerVO) && !CustomerBL.isTransferCustomer(customerVO) && baseLineItemVO.getQuantityBilled().signum() == 1 && !changeCustomer && !baseLineItemVO.isPickupItem().booleanValue()) { String dcStockQuantity = ""; if(InvoiceBL.isDCInUSUsingRadsAndNAPAXpress()){ try{ dcStockQuantity = baseLineItemVO.isVirtualKit() ? InvoiceLineBL.getVirtualKitOnHandInServingDC(baseLineItemVO).toString() : (String)InvoiceLineBL.getServingDC(inventoryVO).getValue(); } catch(Exception exception){ logger.error(exception, exception); } } if(!baseLineItemVO.isKitPart() || !invoicingProfileVO.getAllowKitSourcingOptimization().booleanValue()) { baseLineItemVO.setQuantityBilled(InvoiceLineBL.splitQuantity(customerVO, invoiceVO, baseLineItemVO, inventoryVO, baseLineItemVO.getQuantityBilled(), dcStockQuantity)); baseLineItemVO.setExtendedPrice(InvoiceLineBL.getExtendedPrice(baseLineItemVO)); baseLineItemVO.setExtendedSaved(InvoiceLineBL.getExtendedSaved(baseLineItemVO)); } } if (redoTaxes) { /*if we are redoing the Taxes then we have changed the customer and we should /check if the customer is a transfer customer. If it is then we need to reset /the ref invoice line item type*/ //Fix for bug #21855, InvoiceLineBL.changeBillingType() needs to be called before //Tax.evaluateInvoiceLineItemTax() because the evaluation of taxes needs //the up to date ref invoice line item type InvoiceLineBL.changeBillingType(customerVO, baseLineItemVO); if(changeCustomer){ baseLineItemVO.setTaxable1(null); baseLineItemVO.setTaxable2(null); } Tax.evaluateInvoiceLineItemTax(baseLineItemVO, customerVO, customerVO.getPrimaryTaxTable(), customerVO.getSecondaryTaxTable(), Profile.POINT_OF_SALE_CLIENT, true); if(getInvoicingProfileVO().getEnableCoreReturnLaw().booleanValue()) { if (baseLineItemVO.isCoreItem() && baseLineItemVO.getQuantityBilled().signum() < 0 && (baseLineItemVO.getGeneratedByLineItem() == null || baseLineItemVO.isUsedForReturn())) { InvoiceLineBL.resetCoreTaxDecisionBasedOnCustTaxNumbers( invoiceVO, baseLineItemVO); } } } // Set display prices for line item InvoiceLineBL.setDisplayPricesForLineItem(baseLineItemVO, customerVO, invoiceVO); logger.debug(" InvoiceController.loadLines - Set Display Prices "); logger.debug(" InvoiceController.loadLines - Unit Price = " + baseLineItemVO.getUnitPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice()); logger.debug(" InvoiceController.loadLines - Unit List Price = " + baseLineItemVO.getUnitListPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitListPrice()); logger.debug(" InvoiceController.loadLines - generateLines = " + generateLines + ", miscChgOnly = " + miscChgOnly); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.INFO, " InvoiceController.loadLines - Set Display Prices " + " InvoiceController.loadLines - Unit Price = " + baseLineItemVO.getUnitPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice() + " InvoiceController.loadLines - Unit List Price = " + baseLineItemVO.getUnitListPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitListPrice() + " InvoiceController.loadLines - generateLines = " + generateLines + ", miscChgOnly = " + miscChgOnly); if (generateLines || miscChgOnly) { PricesOutVO prices = null; if (baseLineItemVO.isPickupItem().booleanValue()) { PricesInVO pricesInVO = new PricesInVO(); if (baseLineItemVO.getBuyoutItemVO() == null) { //special PU function used pricesInVO.setCost(baseLineItemVO.getUnitCost()); } else { //buyout po used pricesInVO.setCost(baseLineItemVO.getBuyoutItemVO().getUnitCost()); pricesInVO.setCoreCost(baseLineItemVO.getBuyoutItemVO().getCoreCost()); } pricesInVO.setCustomerId(customerVO.getID()); pricesInVO.setCustomerTypeCD(customerVO.getCustomerTypeCD()); pricesInVO.setLocation(loc); prices = clientApplicationContext.getOrderingDAO().getPickupPrice( pricesInVO ); if (baseLineItemVO.isCoreTransaction().booleanValue()) { baseLineItemVO.setUnitCost(prices.getCoreCost()); baseLineItemVO.setUnitPrice(prices.getCorePrice()); baseLineItemVO.setUnitListPrice(prices.getCorePrice()); } else { baseLineItemVO.setUnitCost(prices.getUnitCost()); baseLineItemVO.setUnitPrice(prices.getUnitPrice()); baseLineItemVO.setUnitListPrice(prices.getUnitPrice()); } baseLineItemVO.setDisplayUnitPrice(InvoiceLineBL .getDisplayPriceFromUnitPrice(baseLineItemVO.getUnitPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null)); baseLineItemVO.setDisplayUnitListPrice(InvoiceLineBL .getDisplayPriceFromUnitPrice(baseLineItemVO.getUnitListPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null)); } else { /* There are some BaseLineItemVOs that have a line but do not have a / part number(FRT, OTH, DEL, etc.). In these cases we don't want to call / get price. */ if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && !(baseLineItemVO.getRefInvoiceLineItemTypeID() != null && (baseLineItemVO.getRefInvoiceLineItemTypeID() .intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)) && !baseLineItemVO.isAutoGeneratedMiscChg().booleanValue() && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { logger.debug(" InvoiceController.loadLines - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - "); prices = InvoiceLineBL.getPrices(customerVO.getID(), customerVO.getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO.getQuantityBilled()); if (baseLineItemVO.isCoreTransaction().booleanValue()) { logger.debug(" InvoiceController.loadLines - core item - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - core item - "); baseLineItemVO.setUnitListPrice(prices.getCorePrice()); baseLineItemVO.setUnitPrice(prices.getCorePrice()); baseLineItemVO.setUnitCost(prices.getCoreCost()); baseLineItemVO.setPriceDecision(prices.getCorePriceDecision()); baseLineItemVO.setDisplayUnitListPrice(prices.getDisplayCorePrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayCorePrice()); } else if (baseLineItemVO.isWarrantyItem().booleanValue()) { logger.debug(" InvoiceController.loadLines - warranty item - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - warranty item - "); baseLineItemVO.setUnitListPrice(InvoiceLineBL.getWarrantyAdjustment( (BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem(), customerVO, null, null)); baseLineItemVO.setUnitPrice(baseLineItemVO.getUnitListPrice()); baseLineItemVO.setPriceDecision(((BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem()).getPriceDecision()); baseLineItemVO.setDisplayUnitListPrice( InvoiceLineBL.getDisplayPriceFromUnitPrice( baseLineItemVO.getUnitListPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null)); baseLineItemVO.setDisplayUnitPrice( baseLineItemVO.getDisplayUnitListPrice()); } else if ((!baseLineItemVO.isKitPart() || (baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null))) { logger.debug(" InvoiceController.loadLines - set display price - "); if(!InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)) { baseLineItemVO.setUnitPrice(prices.getUnitPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayUnitPrice()); } if (InvoiceLineBL.checkListPrice(baseLineItemVO, prices.getCalculatedList())) { baseLineItemVO.setUnitListPrice(new BigDecimal("0.00")); } else { baseLineItemVO.setUnitListPrice(prices.getCalculatedList()); baseLineItemVO.setDisplayUnitListPrice(prices.getDisplayListPrice()); } if (baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null) { // Gets the sum of kit part unit cost as the sum of // unit cost of components associated with a kit part by // calling the getPrice() functionality on each component. BigDecimal kitPartCost = InvoiceLineBL.getKitPartCost( inventoryVO, customerVO); if (kitPartCost != null) { // Sets the kit part unit cost value to value object // which is later used to the set line item unit cost // by calling InvoiceLineBL.changeUnitCost() method. prices.setUnitCost(kitPartCost); } } baseLineItemVO.setUnitCost(prices.getUnitCost()); baseLineItemVO.setPriceDecision(prices.getPriceDecision()); } InvoiceLineBL.setRebateItem(baseLineItemVO, prices.getUnitRebate(),invoiceVO); InvoiceLineBL.setPricingProfile(baseLineItemVO, prices); } } if (baseLineItemVO.getPartNum() != null && !baseLineItemVO.getPartNum().trim().equals("") && !(baseLineItemVO.getRefInvoiceLineItemTypeID() != null && (baseLineItemVO .getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)) && !baseLineItemVO.isAutoGeneratedMiscChg().booleanValue() && prices.getUnitPrice().signum() == 0 && !invoiceContainsZeroPriceLineItem) { invoiceContainsZeroPriceLineItem = true; } InvoiceLineBL.changeUnitCost(baseLineItemVO, customerVO, prices); baseLineItemVO.setExtendedPrice(InvoiceLineBL.getExtendedPrice(baseLineItemVO)); baseLineItemVO.setExtendedSaved( InvoiceLineBL.getExtendedSaved(baseLineItemVO)); InvoiceLineBL.setDoesnotAffectSalesHistory(baseLineItemVO, customerVO); // Set display prices for line item InvoiceLineBL.setDisplayPricesForLineItem(baseLineItemVO, customerVO, invoiceVO); if (miscChgOnly) { if (baseLineItemVO.getGeneratedByLineItem() == null && baseLineItemVO.getQuantityBilled().intValue() > 0) { //logger.error( "lg 1" ); LineGenerationQueue.getInstance().addLineAndMiscChgOnly(invoiceVO, baseLineItemVO, customerVO, prices, null, true); } else { //logger.error( "lg 2" ); LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } else { //logger.error( "lg 3 -- the 'right' one?" ); LineGenerationQueue.getInstance().addLineItem(invoiceVO, baseLineItemVO, customerVO, prices, null, true); } //end if generateLines || miscChg } else { PricesOutVO prices = null; if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { prices = InvoiceLineBL.getPrices(customerVO.getID(), customerVO.getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO.getQuantityBilled()); } if(baseLineItemVO.isKitPart()) { if ((baseLineItemVO.getGeneratedByLineItem() == null && baseLineItemVO.getSpecialOrder().equals(TsoConstant.NXP_ORDERED)) || ((baseLineItemVO.getGeneratedByLineItem() != null && ((BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem()).getSpecialOrder() .equals(TsoConstant.NXP_ORDERED)))) { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } else if(baseLineItemVO.getGeneratedByLineItem() == null){ LineGenerationQueue.getInstance().addLineItem(invoiceVO, baseLineItemVO, customerVO, prices, null, true); } } else { if (baseLineItemVO.getGeneratedByLineItem() == null) { if(baseLineItemVO.getNonAvailableQty() != null && baseLineItemVO.getNonAvailableQty().signum() == 1) { LineGenerationQueue.getInstance().addLineItem(invoiceVO, baseLineItemVO, customerVO, prices, null, true); } else { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } else if(baseLineItemVO.getGeneratedByLineItem() != null && baseLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO) { BaseLineItemVO parentLine = (BaseLineItemVO)baseLineItemVO.getGeneratedByLineItem(); if(!parentLine.isSplittedForSpecialOrder()) { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } } } //end if BaseLineItemVO //Setting price decision to blank for NOL orders so that price will not be overridden //with inventory price when it is recalled and edited in invoicing screen. if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) { baseLineItemVO.setPriceDecision(""); } if(baseLineItemVO != null && baseLineItemVO.getRefInvoiceLineItemTypeID() != null && baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue() == RefInvoiceLineItemType.COLORADO_DELIVERY_FEE) { baseLineItemVO.setTaxable1(Boolean.FALSE); baseLineItemVO.setTaxable2(Boolean.FALSE); } if(!isCODeliveryFeeRequired && ((invoiceVO.getSavedInvoiceIdForDeletion() != null && invoiceVO.getDeliveryFlag()) || invoiceVO.getSavedInvoiceIdForDeletion() == null) && baseLineItemVO != null && (baseLineItemVO.getTaxable1().booleanValue() || baseLineItemVO.getTaxable2().booleanValue())) { isCODeliveryFeeRequired = true; } invoiceLineItems.add(baseLineItemVO); } else { //logger.error( "lg 5" ); BaseLineItemVO parenLineItemVO = null; if(invoiceLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO) { parenLineItemVO = (BaseLineItemVO) invoiceLineItemVO.getGeneratedByLineItem(); } if (parenLineItemVO == null || (parenLineItemVO != null && !parenLineItemVO.isKitPart() && !parenLineItemVO.isSplittedForSpecialOrder()) || (parenLineItemVO != null && parenLineItemVO.isKitPart() && (parenLineItemVO.getSpecialOrder().equals(TsoConstant.NXP_ORDERED) || parenLineItemVO.getSpecialOrder().equals(TsoConstant.LOCAL)))) { invoiceLineItems.add(invoiceLineItemVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(invoiceLineItemVO); } } invoiceVO.setLineItems(invoiceLineItems); linesAlredayInQueue.add(invoiceLineItemVO); } // end FOR loop if (invoiceVO.getSavedInvoiceIdForDeletion() !=null && invoiceLineItems !=null && invoiceVO.getPONumber() != null) { logger.error("InvoiceController.loadLines2:loadedFromRecallSavedInvoice for custID:" + invoiceVO.getCustomerID() + " /Number of line items:" + invoiceLineItems.size() + " /PONum:" + invoiceVO.getPONumber()+" /SessionId= "+invoiceVO.getSessionID()+" /SavedInvoiceID= "+invoiceVO.getSavedInvoiceIdForDeletion()); } if(!invoiceVO.isCoroladoFeeLineExists() && isCODeliveryFeeRequired && InvoiceLineBL.isEligibleForColoradoDeliveryLaw(customerVO, getStoreProfile())) { final BaseLineItemVO coloradoRetailDeliveryLineItem = InvoiceLineBL.createCODeliveryFeeLineItem(invoiceVO, customerVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(coloradoRetailDeliveryLineItem); } else if(!invoiceVO.isCoroladoFeeLineExists() && isCODeliveryFeeRequired && invoiceVO.getSavedInvoiceIdForDeletion() != null && invoiceVO.getDeliveryFlag() && getStoreProfile() != null && customerVO != null && customerVO.getState().equalsIgnoreCase(RefState.COLORADO) && getStoreProfile().getRetailDeliveryFee().equalsIgnoreCase(customerVO.getState()) && customerVO.getCustomerDeliveryVO() != null && customerVO.getCustomerDeliveryVO().getDeliveryRefOptionCD().equalsIgnoreCase( TsoConstant.DELIVERY_OPTION_OPTIONAL)){ //This is quick fix !! Later this will be made has one if condition. final BaseLineItemVO coloradoRetailDeliveryLineItem = InvoiceLineBL.createCODeliveryFeeLineItem(invoiceVO, customerVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(coloradoRetailDeliveryLineItem); } final boolean finalInvoiceContainsZero = invoiceContainsZeroPriceLineItem; final boolean chgCustomer = changeCustomer; //invokeLater because we want to make sure all of the customerChanged events run first SwingUtilities.invokeLater(new Runnable() { public void run() { if (finalInvoiceContainsZero && chgCustomer) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1362"); } if (invoiceVO.getSavedInvoiceIdForDeletion() !=null && invoiceVO.getLineItems() !=null && invoiceVO.getPONumber() != null) { logger.error("InvoiceController.loadLines3:loadedFromRecallSavedInvoice for custID:" + invoiceVO.getCustomerID() + " /Number of line items:" + invoiceVO.getLineItems().size() + " /PONum:" + invoiceVO.getPONumber()+" /SessionId= "+invoiceVO.getSessionID()+" /SavedInvoiceID= "+invoiceVO.getSavedInvoiceIdForDeletion()); } clientApplicationContext.getPointOfSaleEventDispatcher().fireProcessLineQueue( new InvoiceEvent(this, invoiceVO)); if ((invoiceVO.getLineItems() == null) || (invoiceVO.getLineItems().size() == 0)) { invoiceLineEntryController.getFinalizeButton().setEnabled(false); /* * TODO * Remove it in next release when we move this code outside if-else * * When We have line items to be loaded, explicit call to make tamsIsReady * isn't required as InvoiceLineListController - > ListDataListener will do * that for us. */ pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this)); } else { /* * TODO * Move this code outside if-else in next release without the saved invoice check. * * Check for saved invoice is kept right now to avoid any possible impact. */ if(invoiceVO.getSavedInvoiceIdForDeletion() != null){ pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this)); } invoiceLineEntryController.getFinalizeButton().setEnabled(true); } // To display message about quantity billed greater than available quantity for // recalled saved invoice line items if(clientApplicationContext.isLoggedInAsPhoneRoom() && invoiceVO.getSavedInvoiceIdForDeletion() != null && InvoiceBL.checkAvailableQuantity(invoiceVO, customerVO,false)) { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemsChanged(new PointOfSaleListEvent(this, invoiceVO)); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9551"); } /* * This signifies invoice is done doing all the work of loading invoice. */ invoiceVO.setRecalledDate(new Date()); } }); } private void loadLinesPhoneRoom(boolean generateLines, boolean redoTaxes, boolean miscChgOnly, boolean displayCustomerPresent, boolean changeCustomer) { boolean invoiceContainsZeroPriceLineItem = false; BigDecimal zero = new BigDecimal("0.00"); String storeNum = invoiceVO.getRemoteStoreNumber(); List phoneRoomStoreVOlist = phoneRoomStoresList; String remoteIpAddress = null; for(int i=0;i 0) { Vector lineItems = (Vector) invoiceVO.getLineItems().clone(); invoiceVO.getLineItems().removeAllElements(); int lineitemindex = 0; // Logic to process the notes here first for (int i = 0; i < lineItems.size(); i++) { InvoiceLineItemVO invoiceLineItemVOtemp1 = (InvoiceLineItemVO)lineItems.get(i); if(invoiceLineItemVOtemp1 instanceof InvoiceNoteVO){ final InvoiceNoteVO invoiceNoteVO = (InvoiceNoteVO)invoiceLineItemVOtemp1; ((InvoiceNoteVO)lineItems.get(i)).setLineAddedToList(true); lineitemindex++; invoiceNoteVO.setCompletedLine(true); invoiceNoteVO.setLineAddedToList(true); SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemAdded( new PointOfSaleListEvent(this, invoiceNoteVO)); } }); } else { break; } } InvoiceLineItemVO invoiceLineItemVOtemp = (InvoiceLineItemVO)lineItems.get(lineitemindex); if (invoiceLineItemVOtemp instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVOtemp = (BaseLineItemVO) invoiceLineItemVOtemp; ((BaseLineItemVO)lineItems.get(lineitemindex)).setLineAddedToList(true); //baseLineItemVOtemp.setLineAddedToList(true); } invoiceVO.setReturnLineItems(lineItems); invoiceVO.getLineItems().removeAllElements(); final BaseLineItemVO currentLineItmVO = (BaseLineItemVO) invoiceLineItemVOtemp; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher() .fireListModelChanged(new InvoiceEvent(this, currentLineItmVO)); } }); return; } //can use existing code InvoiceLineBL.removeCODeliveryLineItem(invoiceVO); Vector lineItems = (Vector) invoiceVO.getLineItems().clone(); invoiceVO.getLineItems().removeAllElements(); if (redoTaxes) { invoiceVO.setNonTaxableSales1(zero); invoiceVO.setTaxableSales1(zero); invoiceVO.setNonTaxableSales2(zero); invoiceVO.setTaxableSales2(zero); } TaapRouter taapRouter = new TaapRouter(); PhoneRoomTaapRouter prTaapRouter = new PhoneRoomTaapRouter(); Map customerParams = new HashMap(); customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + remoteIpAddress); customerParams.put(TaapRouter.CUSTOMERNUM, "" + invoiceVO.getCustomerID()); customerParams.put(TaapRouter.TYPE, "" + "RS"); customerParams.put(TaapRouter.CUSTID, "" + invoiceVO.getCustomerID()); customerParams.put(TaapRouter.LANG, "" + clientApplicationContext.getCurrentLocale().getLanguage()); customerParams.put(TaapRouter.LOC, "" + loc); customerVO = taapRouter.getCustomerDetailInfoByID(customerParams); if (lineItems.size() > 0 && PhoneRoomCustomerBL.doDisplayCustPresentQuestion(remoteIpAddress)&& displayCustomerPresent) { int focus = customerVO.isTypicallyPresentDuringInvoicing().booleanValue() ? 0 : 1; boolean dispToPricingPole = clientApplicationContext.getMessageMgr().showMessageFocusPrompt(invoicePanel, "2235", focus); invoiceVO.setDisplayPricing(dispToPricingPole); invoicePanel.ckCustomerPresent.setSelected(dispToPricingPole); } TaxTableVO deliveryTaxTableVO = null; if(customerVO.getDeliveredTaxTableID()!=null)deliveryTaxTableVO=prTaapRouter.getTaxTable(loc,customerVO.getDeliveredTaxTableID(),remoteIpAddress); final Vector linesAlredayInQueue = new Vector(); final Vector invoiceLineItems = new Vector(); boolean isCODeliveryFeeRequired = false; StoreProfileVO storeProfileVO = prTaapRouter.getStoreProfile(remoteIpAddress); InvoicingProfileVO invoicingProfileVO = taapRouter.getInvoicingProfile(remoteIpAddress); for (int i = 0; i < lineItems.size(); i++) { InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.get(i); /* * TODO Saved invoice check along with setting null to id and version should be removed in next release. * * I have kept this check to minimize the impact to other flows. The cart would have got * synced through createCart/editCart process for a saved invoice by now. Once we remove the * check of saved invoice while creating cart, we don't want need this check anymore. */ if(invoiceVO.getSavedInvoiceIdForDeletion() == null){ invoiceLineItemVO.setId(null); invoiceLineItemVO.setVersion(null); } if (invoiceLineItemVO instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO; if (invoiceVO.getSavedInvoiceIdForDeletion() != null && !changeCustomer) { baseLineItemVO.setDisplayTaxable2((invoiceVO.getSecondaryTaxTableID() != null && invoiceVO.getSecondaryTaxTableID().shortValue() > 0)); } else { baseLineItemVO.setDisplayTaxable2((customerVO.getPrimaryTaxTable() != null) && ((customerVO.getPrimaryTaxTable().getSecondaryTaxTableID() != null && customerVO.getPrimaryTaxTable().getSecondaryTaxTableID().shortValue() > 0) ||(deliveryTaxTableVO != null && deliveryTaxTableVO.getSecondaryTaxTableID() != null && deliveryTaxTableVO.getSecondaryTaxTableID().shortValue() > 0))); } InventoryVO inventoryVO = null; if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { if(baseLineItemVO.isVirtualKit() && baseLineItemVO.getComponents() != null && baseLineItemVO.getComponents().size() > 0){ inventoryVO = PhoneRoomInvoiceLineBL.getVirtualKitDetailInfo(customerVO, baseLineItemVO,remoteIpAddress); } else { inventoryVO = prTaapRouter.getPartDetailInfo( customerVO, baseLineItemVO.getLineAbbr(),baseLineItemVO.getPartNum(), false,remoteIpAddress,clientApplicationContext.getCurrentLocale().getLanguage(),false); } PhoneRoomInvoiceLineBL.checkDC(customerVO, baseLineItemVO, false, inventoryVO,remoteIpAddress); } logger.debug(" InvoiceController.loadLines - redoTaxes = " + redoTaxes); if (storeProfileVO.getUseNapaXpress().booleanValue() && baseLineItemVO.getGeneratedByLineItem() == null && !CustomerBL.isNapaOnlineCustomer(customerVO) && !CustomerBL.isTransferCustomer(customerVO) && baseLineItemVO.getQuantityBilled().signum() == 1 && !changeCustomer && !baseLineItemVO.isPickupItem().booleanValue()) { String dcStockQuantity = ""; if(PhoneRoomInvoiceBL.isDCInUSUsingRadsAndNAPAXpress(storeProfileVO,invoicingProfileVO)){ try{ dcStockQuantity = baseLineItemVO.isVirtualKit() ? PhoneRoomInvoiceLineBL.getVirtualKitOnHandInServingDC(baseLineItemVO,invoicingProfileVO,storeProfileVO,remoteIpAddress).toString() : (String)PhoneRoomInvoiceLineBL.getServingDC(inventoryVO,remoteIpAddress).getValue(); } catch(Exception exception){ logger.error(exception, exception); } } if(!baseLineItemVO.isKitPart() || !invoicingProfileVO.getAllowKitSourcingOptimization().booleanValue()) { baseLineItemVO.setQuantityBilled(PhoneRoomInvoiceLineBL.splitQuantity(customerVO, invoiceVO, baseLineItemVO, inventoryVO, baseLineItemVO.getQuantityBilled(), dcStockQuantity,remoteIpAddress,storeProfileVO)); baseLineItemVO.setExtendedPrice(InvoiceLineBL.getExtendedPrice(baseLineItemVO)); baseLineItemVO.setExtendedSaved(InvoiceLineBL.getExtendedSaved(baseLineItemVO)); } } if (redoTaxes) { /*if we are redoing the Taxes then we have changed the customer and we should /check if the customer is a transfer customer. If it is then we need to reset /the ref invoice line item type*/ //Fix for bug #21855, InvoiceLineBL.changeBillingType() needs to be called before //Tax.evaluateInvoiceLineItemTax() because the evaluation of taxes needs //the up to date ref invoice line item type InvoiceLineBL.changeBillingType(customerVO, baseLineItemVO); if(changeCustomer){ baseLineItemVO.setTaxable1(null); baseLineItemVO.setTaxable2(null); } PhoneRoomTax.evaluateInvoiceLineItemTax(baseLineItemVO, customerVO, customerVO.getPrimaryTaxTable(), customerVO.getSecondaryTaxTable(), Profile.POINT_OF_SALE_CLIENT, true,remoteIpAddress,storeProfileVO.getRefLanguageCd()); if(invoicingProfileVO.getEnableCoreReturnLaw().booleanValue()) { if (baseLineItemVO.isCoreItem() && baseLineItemVO.getQuantityBilled().signum() < 0 && (baseLineItemVO.getGeneratedByLineItem() == null || baseLineItemVO.isUsedForReturn())) { PhoneRoomInvoiceLineBL.resetCoreTaxDecisionBasedOnCustTaxNumbers( invoiceVO, baseLineItemVO); } } } // Set display prices for line item PhoneRoomInvoiceLineBL.setDisplayPricesForLineItem(baseLineItemVO, customerVO, invoiceVO,remoteIpAddress,storeProfileVO.getIncludeTaxInPrice().booleanValue()); logger.debug(" InvoiceController.loadLines - Set Display Prices "); logger.debug(" InvoiceController.loadLines - Unit Price = " + baseLineItemVO.getUnitPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice()); logger.debug(" InvoiceController.loadLines - Unit List Price = " + baseLineItemVO.getUnitListPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitListPrice()); logger.debug(" InvoiceController.loadLines - generateLines = " + generateLines + ", miscChgOnly = " + miscChgOnly); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.INFO, " InvoiceController.loadLines - Set Display Prices " + " InvoiceController.loadLines - Unit Price = " + baseLineItemVO.getUnitPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice() + " InvoiceController.loadLines - Unit List Price = " + baseLineItemVO.getUnitListPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitListPrice() + " InvoiceController.loadLines - generateLines = " + generateLines + ", miscChgOnly = " + miscChgOnly); if (generateLines || miscChgOnly) { PricesOutVO prices = null; if (baseLineItemVO.isPickupItem().booleanValue()) { PricesInVO pricesInVO = new PricesInVO(); if (baseLineItemVO.getBuyoutItemVO() == null) { //special PU function used pricesInVO.setCost(baseLineItemVO.getUnitCost()); } else { //buyout po used pricesInVO.setCost(baseLineItemVO.getBuyoutItemVO().getUnitCost()); pricesInVO.setCoreCost(baseLineItemVO.getBuyoutItemVO().getCoreCost()); } pricesInVO.setCustomerId(customerVO.getID()); pricesInVO.setCustomerTypeCD(customerVO.getCustomerTypeCD()); pricesInVO.setLocation(loc); prices = prTaapRouter.getPickUpPrice(pricesInVO,remoteIpAddress,loc); if (baseLineItemVO.isCoreTransaction().booleanValue()) { baseLineItemVO.setUnitCost(prices.getCoreCost()); baseLineItemVO.setUnitPrice(prices.getCorePrice()); baseLineItemVO.setUnitListPrice(prices.getCorePrice()); } else { baseLineItemVO.setUnitCost(prices.getUnitCost()); baseLineItemVO.setUnitPrice(prices.getUnitPrice()); baseLineItemVO.setUnitListPrice(prices.getUnitPrice()); } baseLineItemVO.setDisplayUnitPrice(PhoneRoomInvoiceLineBL .getDisplayPriceFromUnitPrice(baseLineItemVO.getUnitPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null,remoteIpAddress,storeProfileVO.getIncludeTaxInPrice().booleanValue())); baseLineItemVO.setDisplayUnitListPrice(PhoneRoomInvoiceLineBL .getDisplayPriceFromUnitPrice(baseLineItemVO.getUnitListPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null,remoteIpAddress,storeProfileVO.getIncludeTaxInPrice().booleanValue())); } else { /* There are some BaseLineItemVOs that have a line but do not have a / part number(FRT, OTH, DEL, etc.). In these cases we don't want to call / get price. */ if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && !(baseLineItemVO.getRefInvoiceLineItemTypeID() != null && (baseLineItemVO.getRefInvoiceLineItemTypeID() .intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)) && !baseLineItemVO.isAutoGeneratedMiscChg().booleanValue() && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { logger.debug(" InvoiceController.loadLines - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - "); prices = PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO, customerVO.getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO.getQuantityBilled(),remoteIpAddress,storeProfileVO); if (baseLineItemVO.isCoreTransaction().booleanValue()) { logger.debug(" InvoiceController.loadLines - core item - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - core item - "); baseLineItemVO.setUnitListPrice(prices.getCorePrice()); baseLineItemVO.setUnitPrice(prices.getCorePrice()); baseLineItemVO.setUnitCost(prices.getCoreCost()); baseLineItemVO.setPriceDecision(prices.getCorePriceDecision()); baseLineItemVO.setDisplayUnitListPrice(prices.getDisplayCorePrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayCorePrice()); } else if (baseLineItemVO.isWarrantyItem().booleanValue()) { logger.debug(" InvoiceController.loadLines - warranty item - "); BOPISLogger.getInstance().setStoreProfile(invoiceVO.getLOC()).addBOPISLog(Constants.DEBUG, " InvoiceController.loadLines - warranty item - "); baseLineItemVO.setUnitListPrice(PhoneRoomInvoiceLineBL.getWarrantyAdjustment( (BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem(), customerVO, null, null,remoteIpAddress,storeProfileVO)); baseLineItemVO.setUnitPrice(baseLineItemVO.getUnitListPrice()); baseLineItemVO.setPriceDecision(((BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem()).getPriceDecision()); baseLineItemVO.setDisplayUnitListPrice( PhoneRoomInvoiceLineBL.getDisplayPriceFromUnitPrice( baseLineItemVO.getUnitListPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO, null,remoteIpAddress,storeProfileVO.getIncludeTaxInPrice().booleanValue())); baseLineItemVO.setDisplayUnitPrice( baseLineItemVO.getDisplayUnitListPrice()); } else if ((!baseLineItemVO.isKitPart() || (baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null))) { logger.debug(" InvoiceController.loadLines - set display price - "); if(!InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)) { baseLineItemVO.setUnitPrice(prices.getUnitPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayUnitPrice()); } if (InvoiceLineBL.checkListPrice(baseLineItemVO, prices.getCalculatedList())) { baseLineItemVO.setUnitListPrice(new BigDecimal("0.00")); } else { baseLineItemVO.setUnitListPrice(prices.getCalculatedList()); baseLineItemVO.setDisplayUnitListPrice(prices.getDisplayListPrice()); } if (baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null) { // Gets the sum of kit part unit cost as the sum of // unit cost of components associated with a kit part by // calling the getPrice() functionality on each component. BigDecimal kitPartCost = PhoneRoomInvoiceLineBL.getKitPartCost( inventoryVO, customerVO,remoteIpAddress,storeProfileVO); if (kitPartCost != null) { // Sets the kit part unit cost value to value object // which is later used to the set line item unit cost // by calling InvoiceLineBL.changeUnitCost() method. prices.setUnitCost(kitPartCost); } } baseLineItemVO.setUnitCost(prices.getUnitCost()); baseLineItemVO.setPriceDecision(prices.getPriceDecision()); } InvoiceLineBL.setRebateItem(baseLineItemVO, prices.getUnitRebate(),invoiceVO); InvoiceLineBL.setPricingProfile(baseLineItemVO, prices); } } if (baseLineItemVO.getPartNum() != null && !baseLineItemVO.getPartNum().trim().equals("") && !(baseLineItemVO.getRefInvoiceLineItemTypeID() != null && (baseLineItemVO .getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)) && !baseLineItemVO.isAutoGeneratedMiscChg().booleanValue() && prices.getUnitPrice().signum() == 0 && !invoiceContainsZeroPriceLineItem) { invoiceContainsZeroPriceLineItem = true; } InvoiceLineBL.changeUnitCost(baseLineItemVO, customerVO, prices); baseLineItemVO.setExtendedPrice(InvoiceLineBL.getExtendedPrice(baseLineItemVO)); baseLineItemVO.setExtendedSaved( InvoiceLineBL.getExtendedSaved(baseLineItemVO)); PhoneRoomInvoiceLineBL.setDoesnotAffectSalesHistory(baseLineItemVO, customerVO,remoteIpAddress); // Set display prices for line item PhoneRoomInvoiceLineBL.setDisplayPricesForLineItem(baseLineItemVO, customerVO, invoiceVO,remoteIpAddress,storeProfileVO.getIncludeTaxInPrice().booleanValue()); if (miscChgOnly) { if (baseLineItemVO.getGeneratedByLineItem() == null && baseLineItemVO.getQuantityBilled().intValue() > 0) { //logger.error( "lg 1" ); LineGenerationQueue.getInstance().addLineAndMiscChgOnlyPhoneRoom(invoiceVO, baseLineItemVO, customerVO, prices, null, true,inventoryVO,remoteIpAddress); } else { //logger.error( "lg 2" ); LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } else { //logger.error( "lg 3 -- the 'right' one?" ); LineGenerationQueue.getInstance().addLineItemPhoneRoom(invoiceVO, baseLineItemVO, customerVO, prices, null, true,inventoryVO,remoteIpAddress); } //end if generateLines || miscChg } else { PricesOutVO prices = null; if (baseLineItemVO.getPartNum() != null && baseLineItemVO.getPartNum().trim().length() > 0 && baseLineItemVO.getLineAbbr() != null && baseLineItemVO.getLineAbbr().trim().length() > 0) { prices = PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO, customerVO.getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO.getQuantityBilled(),remoteIpAddress,storeProfileVO); } if(baseLineItemVO.isKitPart()) { if ((baseLineItemVO.getGeneratedByLineItem() == null && baseLineItemVO.getSpecialOrder().equals(TsoConstant.NXP_ORDERED)) || ((baseLineItemVO.getGeneratedByLineItem() != null && ((BaseLineItemVO) baseLineItemVO.getGeneratedByLineItem()).getSpecialOrder() .equals(TsoConstant.NXP_ORDERED)))) { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } else if(baseLineItemVO.getGeneratedByLineItem() == null){ LineGenerationQueue.getInstance().addLineItemPhoneRoom(invoiceVO, baseLineItemVO, customerVO, prices, null, true,inventoryVO,remoteIpAddress); } } else { if (baseLineItemVO.getGeneratedByLineItem() == null) { if(baseLineItemVO.getNonAvailableQty() != null && baseLineItemVO.getNonAvailableQty().signum() == 1) { LineGenerationQueue.getInstance().addLineItemPhoneRoom(invoiceVO, baseLineItemVO, customerVO, prices, null, true,inventoryVO,remoteIpAddress); } else { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } else if(baseLineItemVO.getGeneratedByLineItem() != null && baseLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO) { BaseLineItemVO parentLine = (BaseLineItemVO)baseLineItemVO.getGeneratedByLineItem(); if(!parentLine.isSplittedForSpecialOrder()) { LineGenerationQueue.getInstance().addLineItemNoGenerate(baseLineItemVO); } } } } //end if BaseLineItemVO //Setting price decision to blank for NOL orders so that price will not be overridden //with inventory price when it is recalled and edited in invoicing screen. if (InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) { baseLineItemVO.setPriceDecision(""); } if(baseLineItemVO != null && baseLineItemVO.getRefInvoiceLineItemTypeID() != null && baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue() == RefInvoiceLineItemType.COLORADO_DELIVERY_FEE) { baseLineItemVO.setTaxable1(Boolean.FALSE); baseLineItemVO.setTaxable2(Boolean.FALSE); } if(!isCODeliveryFeeRequired && ((invoiceVO.getSavedInvoiceIdForDeletion() != null && invoiceVO.getDeliveryFlag()) || invoiceVO.getSavedInvoiceIdForDeletion() == null) && baseLineItemVO != null && (baseLineItemVO.getTaxable1().booleanValue() || baseLineItemVO.getTaxable2().booleanValue())) { isCODeliveryFeeRequired = true; } invoiceLineItems.add(baseLineItemVO); } else { //logger.error( "lg 5" ); BaseLineItemVO parenLineItemVO = null; if(invoiceLineItemVO.getGeneratedByLineItem() instanceof BaseLineItemVO) { parenLineItemVO = (BaseLineItemVO) invoiceLineItemVO.getGeneratedByLineItem(); } if (parenLineItemVO == null || (parenLineItemVO != null && !parenLineItemVO.isKitPart() && !parenLineItemVO.isSplittedForSpecialOrder()) || (parenLineItemVO != null && parenLineItemVO.isKitPart() && (parenLineItemVO.getSpecialOrder().equals(TsoConstant.NXP_ORDERED) || parenLineItemVO.getSpecialOrder().equals(TsoConstant.LOCAL)))) { invoiceLineItems.add(invoiceLineItemVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(invoiceLineItemVO); } } invoiceVO.setLineItems(invoiceLineItems); linesAlredayInQueue.add(invoiceLineItemVO); } // end FOR loop if(!invoiceVO.isCoroladoFeeLineExists() && isCODeliveryFeeRequired && PhoneRoomInvoiceLineBL.isEligibleForColoradoDeliveryLaw(customerVO, storeProfileVO)) { final BaseLineItemVO coloradoRetailDeliveryLineItem = PhoneRoomInvoiceLineBL.createCODeliveryFeeLineItem(invoiceVO, customerVO,remoteIpAddress,storeProfileVO, invoicingProfileVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(coloradoRetailDeliveryLineItem); } else if(!invoiceVO.isCoroladoFeeLineExists() && isCODeliveryFeeRequired && invoiceVO.getSavedInvoiceIdForDeletion() != null && invoiceVO.getDeliveryFlag() && getStoreProfile() != null && customerVO != null && customerVO.getState().equalsIgnoreCase(RefState.COLORADO) && getStoreProfile().getRetailDeliveryFee().equalsIgnoreCase(customerVO.getState()) && customerVO.getCustomerDeliveryVO() != null && customerVO.getCustomerDeliveryVO().getDeliveryRefOptionCD().equalsIgnoreCase( TsoConstant.DELIVERY_OPTION_OPTIONAL)){ //This is quick fix !! Later this will be made has one if condition. final BaseLineItemVO coloradoRetailDeliveryLineItem = PhoneRoomInvoiceLineBL.createCODeliveryFeeLineItem(invoiceVO, customerVO,remoteIpAddress,storeProfileVO, invoicingProfileVO); LineGenerationQueue.getInstance().addLineItemNoGenerate(coloradoRetailDeliveryLineItem); } final boolean finalInvoiceContainsZero = invoiceContainsZeroPriceLineItem; final boolean chgCustomer = changeCustomer; //invokeLater because we want to make sure all of the customerChanged events run first String finalRemoteIpAddress = remoteIpAddress; SwingUtilities.invokeLater(new Runnable() { public void run() { if (finalInvoiceContainsZero && chgCustomer) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "1362"); } clientApplicationContext.getPointOfSaleEventDispatcher().fireProcessLineQueue( new InvoiceEvent(this, invoiceVO)); if ((invoiceVO.getLineItems() == null) || (invoiceVO.getLineItems().size() == 0)) { invoiceLineEntryController.getFinalizeButton().setEnabled(false); /* * TODO * Remove it in next release when we move this code outside if-else * * When We have line items to be loaded, explicit call to make tamsIsReady * isn't required as InvoiceLineListController - > ListDataListener will do * that for us. */ pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this)); } else { /* * TODO * Move this code outside if-else in next release without the saved invoice check. * * Check for saved invoice is kept right now to avoid any possible impact. */ if(invoiceVO.getSavedInvoiceIdForDeletion() != null){ pointOfSaleEventDispatcher.fireTamsIsReady(new CartEvent(this)); } invoiceLineEntryController.getFinalizeButton().setEnabled(true); } // To display message about quantity billed greater than available quantity for // recalled saved invoice line items if(clientApplicationContext.isLoggedInAsPhoneRoom() && invoiceVO.getSavedInvoiceIdForDeletion() != null && PhoneRoomInvoiceBL.checkAvailableQuantity(invoiceVO, customerVO,storeProfileVO, finalRemoteIpAddress)) { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemsChanged(new PointOfSaleListEvent(this, invoiceVO)); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "9551"); } /* * This signifies invoice is done doing all the work of loading invoice. */ invoiceVO.setRecalledDate(new Date()); } }); } private void deleteAutoGeneratedMiscCharges() { for (int i = 0; i < invoiceVO.getLineItems().size(); i++) { InvoiceLineItemVO iliVO = (InvoiceLineItemVO) invoiceVO.getLineItems().get(i); if ((iliVO).getGeneratedByLineItem() != null) { if (iliVO instanceof BaseLineItemVO && ((BaseLineItemVO) iliVO).isAutoGeneratedMiscChg().booleanValue()) { invoiceVO.getLineItems().remove(i); i--; } } } final InvoiceVO savedCart = invoiceVO.getSavedCart(); if(savedCart != null){ for (int i = 0; i < savedCart.getLineItems().size(); i++) { InvoiceLineItemVO iliVO = (InvoiceLineItemVO) savedCart.getLineItems().get(i); if ((iliVO).getGeneratedByLineItem() != null) { if (iliVO instanceof BaseLineItemVO && ((BaseLineItemVO) iliVO).isAutoGeneratedMiscChg().booleanValue()) { savedCart.getLineItems().remove(i); i--; } } } } } public void localizeView() { // Initialize the localized text values to be set to Authorized Buyer drop down list. initialItem = clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "ComboBoxInitialItem", clientApplicationContext.getCurrentLocale()); notAssigned = clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, "ComboBoxNotAssigned", clientApplicationContext.getCurrentLocale()); // Sets the property key to the panel title border before FwoLocalizationMgr class methods // are called to localize the panel title border. setTitleBorderPropertyKey(); localizationMgr.localize(invoicePanel, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlInvoiceHeader, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlEmployee, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlButtons, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlManualInvoice, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlCustomerInfo, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlPhone, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlBillingType, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlTax, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlNote, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlAttentionInfo, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlBuyer, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlCustomerTaxNumber, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlResize, InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlResize.getMaximizerPanel(), InvoicePanel.PNL_INVOICE_NAME); localizationMgr.localize(invoicePanel.pnlResize.getMinimizerPanel(), InvoicePanel.PNL_INVOICE_NAME); // Changing Panel name from pnlViewOpenCores to pnlCustomerPresent. localizationMgr.localize(invoicePanel.pnlCustomerPresent, InvoicePanel.PNL_INVOICE_NAME); if (invoiceLineListController != null) { invoiceLineListController.localizeView(); } } /** * This method sets the property key to the panel title border. * */ private void setTitleBorderPropertyKey() { Border border = invoicePanel.pnlCustomerInfo.getBorder(); if (border instanceof TitledBorder) { ((TitledBorder) border).setTitle(InvoicePanel.CUSTOMER_INFO_PANEL_TITLE); } border = invoicePanel.pnlBillingType.getBorder(); if (border instanceof TitledBorder) { ((TitledBorder) border).setTitle(InvoicePanel.BILLING_TYPE_PANEL_TITLE); } border = invoicePanel.pnlTax.getBorder(); if (border instanceof TitledBorder) { ((TitledBorder) border).setTitle(InvoicePanel.TAX_PANEL_TITLE); } border = invoicePanel.pnlNote.getBorder(); if (border instanceof TitledBorder) { ((TitledBorder) border).setTitle(InvoicePanel.NOTE_PANEL_TITLE); } } public boolean isInvoiceInProgress(PointOfSaleVO invVO) { InvoiceVO currentInvoice = (InvoiceVO) this .getModel(); if (currentInvoice == null) { return false; } Integer currentCustomerID = currentInvoice.getCustomerID(); if ((currentCustomerID == null) || (currentCustomerID.intValue() < 0)) { return false; } return true; } public void buyoutOpened(BuyoutEvent be) { invoicePanel.setVisible(false); } private boolean isBuyoutOpenedFromTAMS() { return buyoutOpenedFromTAMS; } public void buyoutClosed(BuyoutEvent be) { invoicePanel.setVisible(true); if ((invoiceVO.getLineItems() == null) || (invoiceVO.getLineItems().size() == 0)) { if (isBuyoutOpenedFromTAMS() && be.isBuyoutCancelled()) { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled( new InvoiceEvent(this, new InvoiceVO())); invoicePanel.btnSearch.dispatchEvent(new KeyEvent(invoicePanel, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } else { if (be.isBuyoutCancelled()) { invoicePanel.cbBuyerPhone.dispatchEvent(new KeyEvent(invoicePanel.cbBuyerPhone, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } } } if(isBuyoutOpenedFromTAMS()) { invoiceVO.setAlternateCoreSubTotal(alternateCoreSubTotal); } alternateCoreSubTotal = new BigDecimal("0.00"); buyoutOpenedFromTAMS = false; } public void buyoutRefreshed(BuyoutEvent be) { } public void buyoutChosen(BuyoutEvent be) { } public void buyoutChosen(InvoiceVO inVO, Integer buyoutID) { logger.debug("buyoutChosen, buyoutOpenedFromTAMS = TRUE"); buyoutOpenedFromTAMS = true; try { employeeVO = clientApplicationContext.getEmployeeDAO().getEmployeeInfo( inVO.getCountermanEmployeeID()); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } if (clientApplicationContext.getPOSState().getState() != POSStateVO.CASHIER) { resetCurrentUser(employeeVO); } verifyEmployee(); try { customerVO = clientApplicationContext.getCustomerDAO().getCustomerDetailInfoByID( inVO.getCustomerID(), inVO.getCustomerTypeCD()); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); return; } alternateCoreSubTotal = new BigDecimal("0.00"); if (oldCustomerNum != null && customerVO != null && customerVO.getCustomerNumber() != null && oldCustomerNum.equals(customerVO.getCustomerNumber().toString())) { alternateCoreSubTotal = invoiceVO.getAlternateCoreSubTotal(); } else { // If customer is changed, set alternate core sub total to zero. invoiceVO.setAlternateCoreSubTotal(alternateCoreSubTotal); invoiceVO.setAlternateCoreDisplaySubTotal(alternateCoreSubTotal); } verifyCustomerVO(customerVO.getCustomerNumber().toString()); if (inVO.getCustomerContactID() != null) { for (int i = 0; i < invoicePanel.cbAuthorizedBuyer.getModel().getSize() ; i++) { IDValuePairVO pair = (IDValuePairVO) invoicePanel.cbAuthorizedBuyer.getModel().getElementAt(i); if (pair.getID().equals(inVO.getCustomerContactID())) { invoicePanel.cbAuthorizedBuyer.setSelectedIndex(i); break; } } } pointOfSaleEventDispatcher.fireBuyoutOpened(new BuyoutEvent(this, invoiceVO, buyoutID)); } public void profileChanged(ProfileEvent pe) { setProfileDependentSettings(); } protected void setProfileDependentSettings() { useSaveInvoice = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getUseSaveInvoice().booleanValue(); invoicePanel.btnRecallSavedInvoice.setEnabled(useSaveInvoice); } public void employeeLoggedIn(EmployeeEvent ee) { if (!invoiceVO.getManualTransaction().booleanValue() || (invoiceVO.getManualTransaction().booleanValue() && invoicePanel.fldInvoiceDate.getText() != null && !invoicePanel.fldInvoiceDate.getText().equals("") && invoicePanel.fldInvoiceNumber.getText() != null || !invoicePanel.fldInvoiceNumber.getText().equals(""))) { if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbStore.setEnabled(true); if(invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setEnabled(true); } invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); invoicePanel.btnSearch.setEnabled(true); if( invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setEnabled(true); } boolean doDisplayCustPresent = CustomerBL.doDisplayCustPresentQuestion(); invoicePanel.lblCustomerPresent.setVisible(doDisplayCustPresent); invoicePanel.ckCustomerPresent.setVisible(doDisplayCustPresent); populateSalesperson(); if (!invoiceVO.getManualTransaction().booleanValue() && (clientApplicationContext.getPOSState() == null || clientApplicationContext.getPOSState().getState() == POSStateVO.NORMAL)) { invoicePanel.btnMessage.setEnabled( clientApplicationContext.getSystemDAO().enableMessageButton().booleanValue()); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(clientApplicationContext.getSystemDAO().enableMessageButton().booleanValue()); } invoicePanel.btnRecallSavedInvoice.setEnabled(this.useSaveInvoice); invoicePanel.btnStockCheck.setEnabled(true); } if(storeProfile == null) { storeProfile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile(); } boolean printROAReceipts = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getARProfile().getPrintROAReceipts().booleanValue(); gpcOwned = storeProfile.getGpcOwned().booleanValue(); if (gpcOwned) { ableToAcceptROAPayments = clientApplicationContext.getSystemDAO().ableToAcceptROAPayments( loc, clientApplicationContext.getCurrentUser().getEmployeeId()); invoicePanel.btnROA.setEnabled(ableToAcceptROAPayments && printROAReceipts); } if (clientApplicationContext.isPOSPricingDeviceEnabled().booleanValue() && !invoicingProfileVO.getDisplayPOSPricingToCustomer().equals("N")) { isPricingDisplayWorking(); } } public void employeeLoggedOut(EmployeeEvent ee) { resetInvoicePanel(); if(this.invoiceVO != null) { stopPartsProSe2Timer(); InvoiceBL.closePpseSession(this.invoiceVO); } customerVO = null; oldCustomerNum = null; invoicePanel.fldEmployee.setText(""); invoicePanel.dlblEmployee.setText(""); invoicePanel.pswdEmployee.setText(""); invoicePanel.cbCustomer.setSelectedIndex(-1); invoicePanel.cbCustomer.setEditable(false); invoicePanel.cbCustomer.setEnabled(false); invoicePanel.cbSalesperson.setEnabled(false); invoicePanel.btnSearch.setEnabled(false); invoicePanel.btnRecallSavedInvoice.setEnabled(false); invoicePanel.btnStockCheck.setEnabled(false); invoicePanel.fldEmployee.setEnabled(true); invoicePanel.pswdEmployee.setVisible(clientApplicationContext. getSystemDAO().askEmployeePassword().booleanValue() && getInvoicingProfileVO().getRequireEmployeePasswordOnInvoice().booleanValue()); invoicePanel.btnMessage.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.btnStoresMessages.setEnabled(false); } encryptedPassword = null; noOfFailedLoginAttempts = 0; tempEmpNum = -1; encryptionRequired = false; // code added for core bank start invoicePanel.lblCoreNotification.setVisible(false); invoicePanel.btnViewOpenCores.setEnabled(false); // code added for core bank end } public void salespersonChanged(EmployeeEvent ee) { invoicePanel.pnlManualInvoice.setVisible(false); invoicePanel.pnlButtons.setVisible(true); } public void manualInvoiceOpened(InvoiceEvent ie) { invoicePanel.pnlButtons.setVisible(false); invoicePanel.pnlManualInvoice.setVisible(true); invoicePanel.cbCustomer.setEnabled(false); invoicePanel.cbCustomer.setEditable(false); invoicePanel.cbSalesperson.setEnabled(false); invoicePanel.cbSalesperson.setEditable(false); invoicePanel.btnSearch.setEnabled(false); invoicePanel.fldInvoiceDate.setText(""); invoiceVO.setManualTransaction(Boolean.TRUE); } public void manualInvoiceClosed(InvoiceEvent ie) { invoicePanel.pnlButtons.setVisible(true); invoicePanel.pnlManualInvoice.setVisible(false); if (invoicePanel.fldEmployee.getText() != null && !invoicePanel.fldEmployee.getText().trim().equals("")) { invoicePanel.cbCustomer.setEnabled(true); invoicePanel.cbCustomer.setEditable(true); invoicePanel.btnSearch.setEnabled(true); } invoiceVO.setManualTransaction(Boolean.FALSE); } public void listItemSelected(PointOfSaleListEvent posle){ } public void listItemCleared(PointOfSaleListEvent posle){ logger.debug("LIST ITEM CLEARED=========>"); listItemSelected = false; invoicePanel.btnPartsPro.setEnabled(this.customerVO != null); invoicePanel.btnStockCheck.setEnabled(true); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbStore.setEnabled(true); } } public void listSetEnabledInvoked(PointOfSaleListEvent posle){ if ((!invoiceVO.getManualTransaction().booleanValue() || (invoiceVO.getManualTransaction().booleanValue() && invoicePanel.fldInvoiceDate.getText().length() > 0 && invoicePanel.fldInvoiceNumber.getText().length() > 0)) && posle.getEnabled()) { enableSalesperson(); } else { invoicePanel.cbSalesperson.setEnabled(false); } invoicePanel.cbCustomer.setEnabled((!invoiceVO.getManualTransaction().booleanValue() || (invoiceVO.getManualTransaction().booleanValue() && invoicePanel.fldInvoiceDate.getText().length() > 0 && invoicePanel.fldInvoiceNumber.getText().length() > 0)) && posle.getEnabled()); invoicePanel.btnSearch.setEnabled((!invoiceVO.getManualTransaction().booleanValue() || (invoiceVO.getManualTransaction().booleanValue() && invoicePanel.fldInvoiceDate.getText().length() > 0 && invoicePanel.fldInvoiceNumber.getText().length() > 0)) && posle.getEnabled()); invoicePanel.btnPartsPro.setEnabled(this.customerVO != null && posle.getEnabled()); invoicePanel.btnStockCheck.setEnabled(posle.getEnabled()); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoicePanel.cbStore.setEnabled(posle.getEnabled()); } invoicePanel.getResizePanel().setEnabled(posle.getEnabled()); BaseLineItemVO baseLineItemVO = null; if(posle.getModel() instanceof BaseLineItemVO){ baseLineItemVO = (BaseLineItemVO)posle.getModel(); } logger.debug("LIST SET ENABLED INVOKDED " + baseLineItemVO); if (baseLineItemVO != null && baseLineItemVO.isCompletedLine()){ listItemSelected = true; } } public void changedToCashier(POSStateEvent posStateEvent) { //if we're going back to the cashier screen, cancel the current invoice in progree clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceCancelled( new InvoiceEvent(this, new InvoiceVO())); invoicePanel.setVisible(false); } public void changedToNormal(POSStateEvent posStateEvent) { invoicePanel.lblEmployee.setVisible(true); invoicePanel.fldEmployee.setVisible(true); invoicePanel.dlblEmployee.setVisible(true); invoicePanel.lblStore.setVisible(false); invoicePanel.cbStore.setVisible(false); //if(invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setVisible(false); invoicePanel.setVisible(true); } public void changedToInvoicingAsCashier(POSStateEvent posStateEvent) { invoicePanel.lblEmployee.setVisible(true); invoicePanel.fldEmployee.setVisible(true); invoicePanel.dlblEmployee.setVisible(true); invoicePanel.pswdEmployee.setVisible(clientApplicationContext.getSystemDAO( ).askEmployeePassword().booleanValue() && getInvoicingProfileVO().getRequireEmployeePasswordOnInvoice().booleanValue()); invoicePanel.lblStore.setVisible(false); //if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoicePanel.btnStoresMessages!=null) invoicePanel.btnStoresMessages.setVisible(false); invoicePanel.cbStore.setVisible(false); resetInvoicePanel(); invoicePanel.fldEmployee.setEnabled(true); pointOfSaleEventDispatcher.fireEmployeeLoggedOut(new EmployeeEvent(this, employeeVO)); if (!clientApplicationContext.getSystemDAO().askEmployeePassword().booleanValue()) { invoicePanel.pswdEmployee.setVisible(false); } invoicePanel.btnMessage.setEnabled(false); setInitialFocus(); invoicePanel.setVisible(true); invoicePanel.btnROA.setEnabled(false); } public void changedToPhoneRoom(POSStateEvent posStateEvent) { invoicePanel.lblEmployee.setVisible(false); invoicePanel.fldEmployee.setVisible(false); invoicePanel.dlblEmployee.setVisible(false); invoicePanel.pswdEmployee.setVisible(false); invoicePanel.lblStore.setVisible(true); invoicePanel.cbStore.setVisible(true); try { if(clientApplicationContext.getMessageDAO().checkServingStoreMSGFlag()){ invoicePanel.btnStoresMessages.setVisible(true); }else{ invoicePanel.btnStoresMessages.setVisible(false); } } catch (ApplicationException e) { invoicePanel.btnStoresMessages.setVisible(false); e.printStackTrace(); } populateStore(); } private void setCurrentUserAsSales() { String sLocalizedSalesLoginNumber = clientApplicationContext.getResourceBundleReader(). getLocalizedText(ResourceBundleReader.UI, PointOfSaleConstants.SALESLOGINNUMBER, clientApplicationContext.getCurrentLocale()); TsoCurrentUser currUser = new TsoCurrentUser(); currUser.setFirstName(sLocalizedSalesLoginNumber); currUser.setLastName(sLocalizedSalesLoginNumber); currUser.setRefLanguageCd("EN"); clientApplicationContext.setCurrentUser(currUser); } private void isPricingDisplayWorking() { try { new POSPricingClient(FwoUtil.getIPAddress()); } catch (RemoteException re) { SwingUtilities.invokeLater(new Runnable(){ public void run() { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2236"); } }); } } /** * Open the regular version of PPSE2 which does not have the capability to sync cart with * TAMSII. * * @param sessionData */ private void openPPSE2Regular(final SessionData sessionData) { final String OVERRIDDEN_CART_VERSION = ApplicationContext.getInstance().getSystemConfig().getSystemConfiguration( SystemConfig.APPLICATION).getProperty(ClientPropConstants.OVERRIDDEN_CART_VERSION, "0"); URL catalogURL = null; if (!OVERRIDDEN_CART_VERSION.equals("1") && !storeProfile.getUseNapaXpress().booleanValue()){ final StringBuffer sb = new StringBuffer(); sb.append(ppseService.getPPSE2SessionURL(sessionData.getRemoteStoreNumber(),invoiceVO.getSessionID())); sb.append(sessionData.toUrlParams()); try { catalogURL = CommonUtil.getSunURL(sb.toString()); } catch (MalformedURLException exception) { logger.error(exception.getMessage(), exception); } } else { catalogURL = ppseService.getPPSE2CatalogURL((PPSESessionData)sessionData); } logger.debug("catalogURL: " + catalogURL); // Extract the guiInstanceId from the query string of the pre-built URL final String urlQuery = catalogURL.getQuery(); final String instanceKey = "tamsInstance="; final int instancePos = urlQuery.indexOf( instanceKey ); final int endInstancePos = urlQuery.indexOf( '&', instancePos + 1 ); final String guiInstanceId = urlQuery.substring( instancePos+instanceKey.length(), endInstancePos ); BrowserLauncher.launch(catalogURL); setupPartsProSe2Timer( guiInstanceId, true, "version1" ); setPartsPro2LaunchEnabled( false ); // deactivate the menu item (and the catalog button, if applicable) SwingUtilities.invokeLater( new Runnable() { public void run() { if (invoiceLineEntryController.getPartNumberComponent().isEnabled()) { invoiceLineEntryController.getPartNumberComponent().requestFocus(); } } } ); } /** * Open the advanced version of PPSE2 which has the capability to sync cart with TAMSII. * @param sessionData */ private void openPPSE2Advanced(final SessionData sessionData) { final StringBuffer sb = new StringBuffer(); try { ppseService.getPPSE2SessionURL(sessionData.getRemoteStoreNumber(),invoiceVO.getSessionID()); sb.append(clientApplicationContext.getSystemDAO().getPPSE2URL()); sb.append(sessionData.toUrlParams()); BrowserLauncher.launch(CommonUtil.getSunURL(sb.toString())); setupPartsProSe2Timer( invoiceVO.getSessionID(), false, "version2" ); setPartsPro2LaunchEnabled( false ); // deactivate the menu item (and the catalog button, if applicable) SwingUtilities.invokeLater( new Runnable() { public void run() { if (invoiceLineEntryController.getPartNumberComponent().isEnabled()) { invoiceLineEntryController.getPartNumberComponent().requestFocus(); } } }); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } if (clientApplicationContext.isLoggedInAsPhoneRoom()) { clientApplicationContext.getPointOfSaleEventDispatcher().firePpseCatalogSessionOpen( new CatalogEvent(this, invoiceVO)); } } private void setupPartsProSe2Timer( final String guiInstanceId, final boolean importCartContents, final String tamsVersion ) { stopPartsProSe2Timer(); ppse2GuiInstanceId = guiInstanceId; // Get any available items in a background thread but, once the items are acquired, // handle them in the Swing thread. Do not check for available items if the screen is locked. final TimerTask task = new TimerTask() { public void run() { if (clientApplicationContext.isScreenLockShowing()) { return; } final Vector cartItems = ppseService.getPPSE2ItemsForInvoice( guiInstanceId, tamsVersion ); SwingUtilities.invokeLater( new Runnable() { public void run() { if (isPPSE2TimerTaskCancelled()) { return; } if (cartItems == null) { // Assume the browser has gone away setPartsPro2LaunchEnabled( true ); } else { if (importCartContents) { importCartContents( cartItems ); } setPartsPro2LaunchEnabled( false ); } } }); } }; setPPSE2TimerTask( task ); partsProSe2Timer.schedule( partsProSe2CheckForItemsTask, 250, 250 ); } public void stopPartsProSe2Timer() { cancelPPSE2TimerTask(); if (ppse2GuiInstanceId != null) { ppseService.disposePPSE2Catalog( ppse2GuiInstanceId ); ppse2GuiInstanceId = null; } setPartsPro2LaunchEnabled( true ); ppse2Lines = new ArrayList(); ppse2LinesProcessing = false; } private void setPartsPro2LaunchEnabled( boolean flag ) { ((PointOfSaleFrame) parentContainer).setPartsProSE_MenuItemEnabled( flag ); if (isPreferencePPSE()) { invoicePanel.btnPartsPro.setEnabled( flag ); } } public void openPPSE() { if(InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO)) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10202"); return; } if(InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) { final String originalInvoiceNumber = InvoiceBL.retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "10212", originalInvoiceNumber); return; } PPSEStatusVO ppseStatusVO =null; if (ppse2Active) { if (ClientApplicationContext.getClientApplicationContext() .isCatalogInUse()) { PointOfSaleEventDispatcher.getInstance().fireCatalogingClosed( new CatalogEvent(this, null)); } try { String url = clientApplicationContext.getSystemDAO().getPPSE2HealthCheckURL(); ppseStatusVO = PPSE2Helper.getPPSE2AvailableInformation(loc, url); } catch (ApplicationException ae) { logger.error("Unable to get PPSE2 available information due to some reasons ... "+ae); openInStoreCatalog(); return; } if (ppseStatusVO != null && Boolean.valueOf(ppseStatusVO.getIsAuthorized()).booleanValue()) { final boolean isControlsEnabled = ((PointOfSaleFrame) parentContainer).isPartsProSE_MenuItemEnabled(); if (!isControlsEnabled) { logger.debug( "PPSE2 controls disabled" ); return; } if (customerVO == null || customerVO.getCustomerNumber() == null) { SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "6204"); } }); return; } final SessionData sessionData = SessionFactory.createSession(invoiceVO, customerVO, SessionFactory.PPSE2); if ((sessionData.getVersion() == SessionData.PPSE2_ADVANCED)) { openPPSE2Advanced(sessionData); } else if(sessionData.getVersion() == SessionData.PPSE2_REGULAR){ openPPSE2Regular(sessionData); } else { openInStoreCatalog(); return; } clientApplicationContext.setUnableToReachPPSE2(false); return; } if (ppseStatusVO == null || (ppseStatusVO != null && !(Boolean.valueOf(ppseStatusVO.getIsAuthorized()) .booleanValue()))) { openInStoreCatalog(); return; } } logger.debug("openPPSE()"); PPSECartVO ppseCartVO = null; if (invoiceVO.getPpseCartNumber() == null) { String storeNumber = clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()) .getStoreProfile().getStoreNum(); Short dcId = clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()) .getStoreProfile().getNapaAcctDcCode(); ppseCartVO = ppseService.getPPSECartVO( customerVO.getCustomerNumber(), customerVO.getName(), storeNumber, dcId, clientApplicationContext.getCurrentLocale()); if (ppseCartVO != null) { invoiceVO.setPpseCartNumber(ppseCartVO.getCartID()); invoiceVO.setPpseTicketNumber(ppseCartVO.getTicketID()); if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(true); } } } else { // we already have a PPSE Cart, need to get a new ticket logger.debug("openPPSE: get a new PPSE Ticket ID, CartNumber= " + invoiceVO.getPpseCartNumber()); ppseCartVO = ppseService.getNewPPSETicketID(invoiceVO .getPpseCartNumber()); if (ppseCartVO != null) { logger.debug("get a new PPSE Ticket ID, CartNumber= " + invoiceVO.getPpseCartNumber()); invoiceVO.setPpseTicketNumber(ppseCartVO.getTicketID()); } } logger.debug("ppseCartVO: " + ppseCartVO); if (ppseCartVO != null) { if (invoicePanel.btnImportCart != null) { invoicePanel.btnImportCart.setEnabled(true); } URL catalogURL = ppseService.getPPSECatalogURL(ppseCartVO .getTicketID()); logger.debug("catalogURL: " + catalogURL); BrowserLauncher.launch(catalogURL); } else { logger.error("unable to contact PPSE site"); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "6201"); return; } } private void openInStoreCatalog() { ((PointOfSaleFrame) parentContainer).enableMenuItems(true); int ppse2OutageMsgCount = clientApplicationContext.getPpse2OutageMsgCount(); clientApplicationContext.setPpse2OutageMsgCount(++ppse2OutageMsgCount); clientApplicationContext.setDisplayPpse2MaxOutageMsg(true); clientApplicationContext.setUnableToReachPPSE2(true); if (!CatalogBL.verifyDVDServices()) { clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2208"); return; } invoicePanel.setVisible(false); clientApplicationContext.getPointOfSaleEventDispatcher().fireCatalogingOpened( new CatalogEvent(this, null)); } public void importCartContents() { importCartContents( null ); } public void importCartContents( List cartItems ) { if (cartItems == null) { if(invoiceVO.getPpseCartNumber() == null || invoiceVO.getPpseCartNumber().equals("")) { logger.info("no current cart number"); return; } cartItems = ppseService.getPPSECartContents(invoiceVO.getPpseCartNumber()); } if(cartItems != null && cartItems.size() > 0) { ppse2Lines.addAll(cartItems); } if(!ppse2LinesProcessing) { processPpse2Lines(); } } private void processPpse2Lines() { String splFunText = invoiceLineEntryController.getSpecialFunctions().getText(); boolean isSplFunSelected = (invoiceLineEntryController.getSpecialFunctions() .getSelectedRow() != 0 && invoiceLineEntryController.getSpecialFunctions() .getSelectedRow() != -1 && splFunText != null && !splFunText.startsWith("Back")); logger.debug("listItemSelected " + listItemSelected); logger.debug("isSplFunSelected " + isSplFunSelected); if (ppse2Lines != null && ppse2Lines.size() > 0 && !listItemSelected && !isSplFunSelected) { ppse2LinesProcessing = true; final BaseLineItemVO cartItemVO = (BaseLineItemVO) ppse2Lines.remove(0); final boolean processed = processPpse2Lines(cartItemVO); if (processed) { pointOfSaleEventDispatcher.fireAddPartFromPpse(new PointOfSaleListEvent(this, cartItemVO)); } } } /** * This is an extension of processPpse2Lines() method. * This is getting called from lineItemAddedOutsideTAMS method as well. * * @param cartItemVO * @return */ private boolean processPpse2Lines(final BaseLineItemVO cartItemVO) { boolean processed = true; final InvoicingProfileVO invoicingProfileVO = getInvoicingProfileVO(); final InventoryVO inventoryVO = clientApplicationContext.getInventoryDAO().getPartDetailInfo( customerVO, cartItemVO.getPartNum(), cartItemVO.getLineAbbr(), false); InvoiceLineEntryPanel invoiceLineEntryPanel = (InvoiceLineEntryPanel) invoiceLineEntryController.getView(); // Check for block sale parts and any waivers through certificate. if (InvoiceLineBL.getBlockSaleFlag(InvoiceBL.isRemoteStore()) && customerVO != null && cartItemVO != null && !cartItemVO.isStockCheck()) { //From PPSE, we don't know if part is Kit or not, so Assume all parts are Kit items boolean isPartEligibleForSale = InvoiceLineBL.isPartEligibleForSale(cartItemVO.getPartNum(), cartItemVO.getLineAbbr(), cartItemVO.getPartDescription(), (InvoiceLineEntryPanel) invoiceLineEntryController.getView(), customerVO, true, InvoiceBL.isRemoteStore()); if (!isPartEligibleForSale) { processed = false; // focus at part number invoiceLineEntryPanel.getFldPartNumber().requestFocus(); return processed; } } else if (customerVO != null && cartItemVO != null && !cartItemVO.isStockCheck() && invoicingProfileVO.getEnableValidateCertificate().booleanValue()) { boolean isCertifiedPart = InvoiceLineBL.checkForPartSaleAndPopulateCertInfo(loc, customerVO.getID(), inventoryVO, cartItemVO, cartItemVO.getQuantityBilled()); if (!isCertifiedPart) { clientApplicationContext.getMessageMgr() .showMessage((InvoiceLineEntryPanel) invoiceLineEntryController.getView(), "9940"); processed = false; ppse2LinesProcessing = false; return processed; } } /* * Validate product line of part. */ if (!InvoiceLineBL.isValidLine(cartItemVO.getLineAbbr()).booleanValue()) { final TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); final String lineAbbrev = cartItemVO.getLineAbbr(); final String clientIPAddress = clientApplicationContext.getClientIPAddress(); try { clientApplicationContext.getInventoryDAO().createProductLine(loc, currentUser, lineAbbrev, clientIPAddress); } catch (ApplicationException applicationException) { clientApplicationContext.getMessageMgr().showMessage(applicationException.getUserMessageID(), applicationException.getUserMessageParameters()); processed = false; ppse2LinesProcessing = false; return processed; } } if(cartItemVO.getLineAbbr() != null && !cartItemVO.getLineAbbr().equals("") && cartItemVO.getPartNum() != null && !cartItemVO.getPartNum().equals("")) { /* * Execute the stock check flow. */ if (cartItemVO.isStockCheck()) { if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoicingProfileVO.getUseChooseStoreDialog().booleanValue()) { openChooseStoreModal(cartItemVO); } else { partsProSe2StockCheckInventoryVO = cartItemVO; SwingUtilities.invokeLater( new Runnable() { public void run() { final JFrame frame = (JFrame) SwingUtilities.getWindowAncestor( invoicePanel ); frame.toFront(); SwingUtilities.invokeLater( new Runnable() { public void run() { invoicePanel.btnStockCheck.doClick(); } } ); } } ); } SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryController.getPartNumberComponent().requestFocusInWindow(); } }); processed = false; ppse2LinesProcessing = false; return processed; } /* * Check for part not being in TAMSII. */ if (!InvoiceBL.doesPartExistInInvOrDVD(cartItemVO.getPartNum(), cartItemVO.getLineAbbr(), customerVO)) { String partInfo [] = {cartItemVO.getLineAbbr(), cartItemVO.getPartNum()}; //check if line abbrev is valid. if not, display message if (!InvoiceLineBL.isValidLine(cartItemVO.getLineAbbr()).booleanValue()) { //display message "Part= Line= Is an invalid Line Abbreviation. Part Not Added." clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2252", partInfo); processed = false; ppse2LinesProcessing = false; return processed; } //1250 = $1 $2 not found in inventory. Do you wish to add it to inventory ? if (clientApplicationContext.getMessageMgr().showMessageYesNo(invoicePanel, "1250", partInfo)) { final InventoryProfileVO inventoryProfileVO = ApplicationContext .getInstance().getProfile(Profile.POINT_OF_SALE_CLIENT, ClientApplicationContext .getClientApplicationContext().getLocation()) .getInventoryProfile(); Integer partNumberLength = inventoryProfileVO.getPartNumberLength(); if (cartItemVO.getPartNum().length() > partNumberLength.intValue()) { final String[] partNumLength = {partNumberLength.toString()}; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getMessageMgr() .showMessage(invoicePanel, "9561",partNumLength); } }); processed = false; ppse2LinesProcessing = false; return processed; } else { processed = addPart(cartItemVO, customerVO); } } else { processed = false; ppse2LinesProcessing = false; return processed; } } else if(cartItemVO.isVirtualKit()){ /* * For virtual kit, kit header should be in inventory to fall back to * existing design of TAMSII for kit. */ if(!clientApplicationContext.getInventoryDAO().doesPartExist( cartItemVO.getPartNum(), cartItemVO.getLineAbbr(), new Integer(clientApplicationContext.getLocation())).booleanValue()){ final String partInfo [] = {cartItemVO.getLineAbbr(), cartItemVO.getPartNum()}; //1250 = $1 $2 not found in inventory. Do you wish to add it to inventory ? if (clientApplicationContext.getMessageMgr().showMessageYesNo(invoicePanel, "1250", partInfo)) { final InventoryProfileVO inventoryProfileVO = ApplicationContext .getInstance().getProfile(Profile.POINT_OF_SALE_CLIENT, ClientApplicationContext .getClientApplicationContext().getLocation()) .getInventoryProfile(); Integer partNumberLength = inventoryProfileVO.getPartNumberLength(); if (cartItemVO.getPartNum().length() > partNumberLength.intValue()) { final String[] partNumLength = {partNumberLength.toString()}; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getMessageMgr() .showMessage(invoicePanel, "9561",partNumLength); } }); processed = false; ppse2LinesProcessing = false; return processed; } else { processed = addPart(cartItemVO, customerVO); } } else { processed = false; ppse2LinesProcessing = false; return processed; } } } } return processed; } private boolean addPart(BaseLineItemVO cartItemVO, CustomerVO customerVO) { BaseLineItemVO newItemVO = createLineItem(cartItemVO); InventoryVO inventoryVO = new InventoryVO(); inventoryVO.setPartNumber(newItemVO.getPartNum()); inventoryVO.setLineAbbrev(newItemVO.getLineAbbr()); inventoryVO.setLOC(newItemVO.getLOC()); inventoryVO.setCoreCost(new BigDecimal("0.00")); inventoryVO.setCost(new BigDecimal("0.00")); try { if (clientApplicationContext.getInventoryDAO().getProductLineVO(cartItemVO.getLineAbbr()) != null && clientApplicationContext.getInventoryDAO().quickAddPart(inventoryVO, clientApplicationContext.getCurrentUser().getEmployeeId(), "PointOfSale")) { } else { final String strArray [] = {inventoryVO.getPartNumber(), inventoryVO.getLineAbbrev()}; SwingUtilities.invokeLater(new Runnable() { public void run() { // 2233 = 2,N,Add failed for part: $1 line $2 clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2233", strArray); } }); return false; } } catch (ApplicationException ae) { clientApplicationContext.getMessageMgr().showMessage(ae.getUserMessageID(), ae.getUserMessageParameters()); return false; } return true; } private BaseLineItemVO createLineItem(BaseLineItemVO item) { logger.debug("createLineItem()"); BaseLineItemVO lineItemVO = new BaseLineItemVO(); lineItemVO.setPartNum(item.getPartNum()); lineItemVO.setExpandedPartNum(item.getExpandedPartNum()); lineItemVO.setLineAbbr(item.getLineAbbr()); lineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType(item, this.customerVO)); lineItemVO.setRefInvoiceLineItemOriginID(new Byte((byte) 1)); lineItemVO.setQuantityBilled(item.getQuantityBilled()); lineItemVO.setPartDescription(item.getPartDescription()); lineItemVO.setCountermanEmployeeID(clientApplicationContext.getCurrentUser().getEmployeeId()); lineItemVO.setPartNote( item.getPartNoteArray() ); InventoryVO inventoryVO = clientApplicationContext.getInventoryDAO().getPartDetailInfo( customerVO, item.getPartNum(), item.getLineAbbr(), false); if(inventoryVO != null) { lineItemVO.setGroupCode(inventoryVO.getGroupCode()); lineItemVO.setInventoryStockLocations(inventoryVO.getInventoryStockLocations()); } //TAX SETTINGS TaxDecisionVO taxDecision = Tax.getTaxDecision(customerVO, inventoryVO, null, item, customerVO.getPrimaryTaxTable(), customerVO.getSecondaryTaxTable(), Profile.POINT_OF_SALE_CLIENT); if (!taxDecision.getPrimaryTax().equals(Tax.OPTIONAL)) { if (taxDecision.getPrimaryTax().equals(Tax.ALWAYS)) { lineItemVO.setTaxable1(Boolean.TRUE); } else { lineItemVO.setTaxable1(Boolean.FALSE); } } else { lineItemVO.setTaxable1(Boolean.TRUE); } if (!taxDecision.getSecondaryTax().equals(Tax.OPTIONAL)) { if (taxDecision.getSecondaryTax().equals(Tax.ALWAYS)) { lineItemVO.setTaxable2(Boolean.TRUE); } else { lineItemVO.setTaxable2(Boolean.FALSE); } } else { lineItemVO.setTaxable2(Boolean.TRUE); } lineItemVO.setCodes(InvoiceLineCodeParser.parse(item)); //Vehicle Information VehicleVO vehicleVO = new VehicleVO(); vehicleVO.setEngine(null); if (item.getVehicleMake() != null) { lineItemVO.setVehicleMake(item.getVehicleMake()); IDValuePairVO vehicleMake = new IDValuePairVO(); vehicleMake.setID(new Integer("0")); vehicleMake.setValue((Object) item.getVehicleMake()); vehicleVO.setMake(vehicleMake); } if (item.getVehicleModel() != null) { lineItemVO.setVehicleModel(item.getVehicleModel()); IDValuePairVO vehicleModel = new IDValuePairVO(); vehicleModel.setID(new Integer(0)); vehicleModel.setValue((Object) item.getVehicleModel()); vehicleVO.setModel(vehicleModel); } if (item.getVehicleYear() != null) { lineItemVO.setVehicleYear(item.getVehicleYear()); vehicleVO.setYear(item.getVehicleYear().intValue()); } if (item.getVehicleAdditionalInfo() != null) { lineItemVO.setVehicleAdditionalInfo( item.getVehicleAdditionalInfo() ); vehicleVO.setVehicleAdditionalInfo( item.getVehicleAdditionalInfo() ); } if (vehicleVO != null) { lineItemVO.setVehicleVO(vehicleVO); } lineItemVO.setRefCatalogDataVersionID(new Integer(RefCatalogDataVersion.PARTSPRO_SE)); lineItemVO.setCompletedLine(true); return lineItemVO; } // Added for RADS-Main Counter /* * This method updates the RADS_ITEM and RADS_DISCREPANCY_LOG table with the changed value of * customer number. */ private void updateCustomerIdForRadsItems() { logger.debug("updateCustomerIdForRadsItems()"); try { if (invoiceVO != null && invoiceVO.getRadsTransactionNumbers() != null) { List radsTransactionNumbers = invoiceVO.getRadsTransactionNumbers(); logger.debug("invoiceVO.getCustomerID()--" + invoiceVO.getCustomerID()); logger.debug("invoiceVO.getLOC()--" + invoiceVO.getLOC()); RadsServiceFactory.getServiceInstance().updateRadsCustomer(radsTransactionNumbers, invoiceVO.getCustomerID().intValue(), invoiceVO.getLOC().intValue()); } } catch (ApplicationException ae) { clientApplicationContext.getMessageMgr().showMessage("9053"); } } // ========================================== public void ppseCatalogSessionOpen(CatalogEvent ce) { } public void ppseCatalogSessionClosed(CatalogEvent ce) { } /** * This method enables 'Open Cores' button and displays outstanding core * notification label only if core bank in use and customer has outstanding cores. */ private void enableViewOpenCoresButton() { invoicingProfileVO = getInvoicingProfileVO(); if (invoicingProfileVO.getCoreBankInUse().booleanValue() && customerVO != null && customerVO.getAlternateCoreCustomerID() != null) { checkForOutstandingCoreBalance(); } else { invoicePanel.lblCoreNotification.setVisible(false); invoicePanel.btnViewOpenCores.setEnabled(false); } } /** * This method checks whether the customer has outstanding cores or not. * If customer has outstanding cores, this method displays outstanding core * notification label and enables "View Cores Report" button. */ private void checkForOutstandingCoreBalance() { CoreBankService coreBankService = CoreBankServiceFactory .getServiceInstance(); try { if (coreBankService.isCustomerHasOutstandingCores(customerVO.getID(), customerVO.getAlternateCoreCustomerID(), customerVO.getLOC()).booleanValue()) { invoicePanel.lblCoreNotification.setVisible(true); invoicePanel.lblCoreNotification .setText(clientApplicationContext.getMessageMgr() .getMessage("7101").getText()); invoicePanel.btnViewOpenCores.setEnabled(true); } else { invoicePanel.lblCoreNotification.setVisible(false); invoicePanel.btnViewOpenCores.setEnabled(false); } } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); } } /** * This method will open cores pending report showing outstanding cores for * the selected customer. */ private void viewOpenCores() { try { 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); } runReport(); viewAndPrintReport(true); } catch (ApplicationException aerr) { logger.error(aerr.toString(), aerr); clientApplicationContext.getMessageMgr().showMessage(invoicePanel, aerr.getUserMessageID(), aerr.getUserMessageParameters()); } } /** * This method will generate cores pending report. * @throws ApplicationException */ private void runReport() throws ApplicationException { Integer altCoreCustomerNumber = clientApplicationContext .getCustomerDAO().getCustomerNumberByID( customerVO.getAlternateCoreCustomerID()); FwoQuestionAnswerMap qaMap = new FwoQuestionAnswerMap(); FwoQuestionAnswer altCoreAcctQnAnswer = new FwoQuestionAnswer(); altCoreAcctQnAnswer.setQuestionKey(new Integer( TsiQuestionConstants.QUESTION_ALTERNATE_CORE_ACCOUNT)); altCoreAcctQnAnswer.setDataType(FwoQuestionAnswer.DATA_TYPE_NUM); altCoreAcctQnAnswer.setAnswerType(FwoQuestionAnswer.ANSWER_TYPE_SINGLE); altCoreAcctQnAnswer.setAnswerValues(altCoreCustomerNumber.toString()); qaMap.replaceQuestionAnswer(altCoreAcctQnAnswer); FwoQuestionAnswer mainAcctQnAnswer = new FwoQuestionAnswer(); mainAcctQnAnswer.setQuestionKey(new Integer(TsiQuestionConstants.QUESTION_CUSTOMER)); mainAcctQnAnswer.setDataType(FwoQuestionAnswer.DATA_TYPE_NUM); mainAcctQnAnswer.setAnswerType(FwoQuestionAnswer.ANSWER_TYPE_SINGLE); mainAcctQnAnswer.setAnswerValues(customerVO.getID().toString()); qaMap.replaceQuestionAnswer(mainAcctQnAnswer); rptCriteria = new FwoRefReportCriteria(); rptCriteria.setLOC(new Integer(1)); rptCriteria.setRefTimeFrameID(new Integer(3)); rptCriteria.setRefReportID(new Integer(198)); rptCriteria.setQuestionAnswerMap(qaMap); FwoRefReportRequest rptRequest = new FwoRefReportRequest(); rptRequest.setRefTimeFrameID(new Integer(3)); rptRequest.setRefReportID(new Integer(198)); rptRequest.setLOC(new Integer(1)); rptRequest.setReportCriteria(rptCriteria); rptRequest.setCreateArchive(false); rptRequest.setLocale(clientApplicationContext.getCurrentLocale()); // only build the report for viewing rptRequest.setDoBuild(true); rptRequest.setDoArchive(false); rptRequest.setDoPrint(false); rptRequest.setDoDelete(false); m_rptResponse = TsoReportHelper.runReport(rptRequest); } /** * This method will preview or print cores pending report. * @param previewRpt * @throws ApplicationException */ private void viewAndPrintReport(boolean previewRpt) throws ApplicationException { if (m_rptResponse != null && m_rptResponse.buildCompleted() && !m_rptResponse.fileDeleted()) { String previewAction = null; if (previewRpt) { previewAction = TsoReportHelper.preview(m_rptResponse .getServerPfFileParent(), m_rptResponse .getServerPfFileName(), invoicePanel, null); logger.debug("tds:previewAction = " + previewAction); } if (TsoReportHelper.PREVIEW_ACTION_PRINT.equals(previewAction) || !previewRpt) { logger .debug("tds:// print the report just viewed, but use the file return and don't rebuild"); FwoRefReportRequest rptRequest = null; logger.debug("tds:m_schedule is null"); rptRequest = new FwoRefReportRequest(); rptRequest.setRefTimeFrameID(rptCriteria.getRefTimeFrameID()); rptRequest.setRefReportID(new Integer(198)); rptRequest.setLOC(rptCriteria.getLOC()); rptRequest.setReportCriteria(rptCriteria); rptRequest.setCreateArchive(false); rptRequest.setLocale(ClientApplicationContext .getClientApplicationContext().getCurrentLocale()); rptRequest.setServerPfFilePath(m_rptResponse .getServerPfFileParent(), m_rptResponse .getServerPfFileName()); rptRequest.setDoBuild(false); rptRequest.setDoArchive(true); rptRequest.setDoPrint(true); rptRequest.setDoDelete(true); if (previewRpt) { logger .debug("tds:// print passing in the print settings and requiring the select printer to come up to display those settings"); FwoPrintSettings pSettings = rptRequest.getPrintSettings(); FwoPrinterSelectionSettings psSettings = new FwoPrinterSelectionSettings(); psSettings.setPrinterUse("Reports"); psSettings.setPrintSettings(pSettings); psSettings = TsoReportHelper.selectPrinterSettings( invoicePanel, psSettings); if (psSettings != null && psSettings.getPrintSettings() != null) { rptRequest.setPrintSettings(psSettings .getPrintSettings()); m_rptResponse = TsoReportHelper.print(rptRequest, false, invoicePanel, false); } } else { m_rptResponse = TsoReportHelper.print(rptRequest, false, invoicePanel, false); } } } } /** * This method is used to check whether invoice has return item mapped to original invoice * * @param invoiceVO value object containing invoice information * @return boolean value indicating invoice has a return item mapped to original invoice */ private boolean hasReturnItemMappedToOriginalInvoice(InvoiceVO invoiceVO){ Vector lineItems = invoiceVO.getLineItems(); if (lineItems != null) { int lineItemsSize = lineItems.size(); for (int index = 0; index < lineItemsSize; index++) { Object itemVO = lineItems.elementAt(index); if (itemVO instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) itemVO; if (baseLineItemVO.getReturnItems() != null && baseLineItemVO.getReturnItems().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()) { return true; } } } } } } return false; } /** * Launches web dash board. */ public void launchDashboard() { String userContextId = null; try { userContextId = getUserContextIdForTamsWeb(); } catch (ApplicationException applicationException) { logger.error(applicationException.toString(), applicationException); } logger.debug("userContextId===>" + userContextId); if (userContextId != null) { final String webDashboardUrl = createTamsWebUrl(userContextId, TsoConstant.WEBDASHBOARD); logger.debug("webDashboardUrl===>" + webDashboardUrl); try { Browser.openBrowser(new URL(webDashboardUrl).toString()); } catch (MalformedURLException e) { logger.error(e.toString(), e); } catch (IOException e) { logger.error(e.toString(), e); } } } /** * Retrieve the context id by invoking web service * * @return user context id * @throws ApplicationException if application exception occurs */ private String getUserContextIdForTamsWeb() throws ApplicationException { String userContextId = null; final ClientApplicationContext clientApplicationContext = ClientApplicationContext.getClientApplicationContext(); if (clientApplicationContext != null) { final TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); final ServerInfoVO serverInfoVo = clientApplicationContext.getServerInfo(); if (currentUser != null && currentUser.getEmployeeNum() != null && serverInfoVo != null) { userContextId = SecurityServiceFactory.getServiceInstance() .loginToTamsWeb(currentUser.getEmployeeNum().intValue(), currentUser.getPassword(), serverInfoVo.getHost(), currentUser.getRefLanguageCd()); } } return userContextId; } /** * Creates TAMS web URL * * @param userContextId user context id * @param function function name * @return TAMS web URL */ private String createTamsWebUrl(final String userContextId, final String function) { final ClientApplicationContext clientApplicationContext = ClientApplicationContext.getClientApplicationContext(); final String serverAndPort = clientApplicationContext.getServerInfo() .getHost() + ":" + clientApplicationContext.getServerInfo().getPort(); final StringBuffer urlBuffer = new StringBuffer(100); urlBuffer.append("http://"); urlBuffer.append(serverAndPort); urlBuffer.append("/"); urlBuffer.append(TsoConstant.TII_CLIENT_URL ); urlBuffer.append("?"); urlBuffer.append(TsoConstant.FUNCTION); urlBuffer.append("="); urlBuffer.append(function); urlBuffer.append("&"); urlBuffer.append(TsoConstant.CONTEXT_ID); urlBuffer.append("="); urlBuffer.append(userContextId); return urlBuffer.toString(); } public void invoiceLineItemsChanged(PointOfSaleListEvent posle) { } /** * Select default serving store. */ private void selectDefaultServingStore() { if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoicePanel.cbStore.isVisible()) { int storesCount = invoicePanel.cbStore.getItemCount(); for (int index = 0; index < storesCount; index++) { PhoneRoomStoreVO phoneRoomStoreVO = (PhoneRoomStoreVO) invoicePanel.cbStore .getItemAt(index); if (phoneRoomStoreVO.getDefaultServing() != null && phoneRoomStoreVO.getDefaultServing().booleanValue()) { invoicePanel.cbStore.setSelectedIndex(index); break; } } } } public void addPartFromPpse(PointOfSaleListEvent pose) { } public void stopPpse2LinesProcessing() { ppse2LinesProcessing = false; } public int lineCount() { return invoiceLineListController.getSize(); } /** * Sets the cashier Controller. * * @param cashier controller the {@link CashierController} object */ public void setCashierController(CashierController cashierController) { this.cashierController = cashierController; } /** * Disposes PPSE2 browser */ public void disposePpseBrowser() { if (ppse2Active) { stopPartsProSe2Timer(); } } /** * This method opens choose store modal * @param cartItemVO {@link BaseLineItemVO} object containing PPSE cart information */ private void openChooseStoreModal(BaseLineItemVO cartItemVO) { chooseStoreController = new ChooseStoreController(invoicePanel); InventoryVO inventoryVO = clientApplicationContext.getInventoryDAO() .getPartDetailInfo(customerVO, cartItemVO.getPartNum(), cartItemVO.getLineAbbr(), false); // check if the entered part is a kit part. if (inventoryVO != null && inventoryVO instanceof KitInventoryVO) { cartItemVO.setKitPart(true); } cartItemVO.setQuantityBilled(new BigDecimal("0.00")); chooseStoreController.setInitialData(inventoryVO, cartItemVO, customerVO, invoiceVO, true); SwingUtilities.invokeLater(new Runnable() { public void run() { final JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(invoicePanel); frame.toFront(); SwingUtilities.invokeLater(new Runnable() { public void run() { chooseStoreController.setViewVisible(true); } }); } }); } private void populateCustomerTaxNumber() { logger.debug("populateCustomerTaxId >>>>"); String primaryTaxNumber; String secondaryTaxNumber; primaryTaxNumber = customerVO.getPrimaryTaxNumber(); primaryTaxNumber = (primaryTaxNumber == null) ? null : primaryTaxNumber.trim(); secondaryTaxNumber = customerVO.getSecondaryTaxNumber(); secondaryTaxNumber = (secondaryTaxNumber == null) ? null : secondaryTaxNumber.trim(); invoicePanel.lblPrimaryTaxNumber.setEnabled(true); invoicePanel.lblSecondaryTaxNumber.setEnabled(true); invoicePanel.fldPrimaryTaxNumber.setText(""); invoicePanel.fldSecondaryTaxNum.setText(""); if (StringUtils.isNotEmpty(primaryTaxNumber)) { invoicePanel.fldPrimaryTaxNumber.setVisible(false); invoicePanel.lblPrimaryTaxNumberValue.setVisible(true); invoicePanel.lblPrimaryTaxNumberValue.setText(primaryTaxNumber); invoiceVO.setPrimaryTaxNumber(primaryTaxNumber); } else { invoicePanel.lblPrimaryTaxNumberValue.setVisible(false); invoicePanel.fldPrimaryTaxNumber.setVisible(true); invoicePanel.fldPrimaryTaxNumber.setEnabled(true); invoicePanel.lblPrimaryTaxNumber.setEnabled(true); invoiceVO.setPrimaryTaxNumber(null); } if (StringUtils.isNotEmpty(secondaryTaxNumber)) { invoicePanel.lblSecondaryTaxNumberValue.setVisible(true); invoicePanel.fldSecondaryTaxNum.setVisible(false); invoicePanel.lblSecondaryTaxNumberValue.setText(secondaryTaxNumber); invoiceVO.setSecondaryTaxNumber(secondaryTaxNumber); } else { invoicePanel.lblSecondaryTaxNumberValue.setVisible(false); invoicePanel.fldSecondaryTaxNum.setVisible(true); invoicePanel.fldSecondaryTaxNum.setEnabled(true); invoicePanel.lblSecondaryTaxNumber.setEnabled(true); invoiceVO.setSecondaryTaxNumber(null); } invoiceVO.setCustomerTaxVO(null); } private void setResourceInUse() { if(!ClientResourceUsage.isResourceInUse(PointOfSaleConstants.POS_PROGRAM_SOURCE)) { ClientResourceUsage.startTask(PointOfSaleConstants.POS_PROGRAM_SOURCE); } } /** * Method : doCertificationPartsExist * Description : This method checks the any certification part exist in invoice. * @param lineItems * return : boolean */ private boolean doCertificationPartsExist() { Vector lineItems = invoiceVO.getLineItems(); int size = lineItems.size(); boolean certPartExists = false; if (getInvoicingProfileVO().getEnableValidateCertificate().booleanValue()) { for (int index = 0; index < size; index++) { InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) lineItems.get(index); if (invoiceLineItemVO instanceof BaseLineItemVO) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO; if (baseLineItemVO.getInvoiceLineItemCertification() != null) { certPartExists = true; break; } } } } return certPartExists; } public void lineItemAddedOutsideTAMS(CartEvent ce) { if(ce.getModel() instanceof BaseLineItemVO){ final BaseLineItemVO line = (BaseLineItemVO)ce.getModel(); final boolean processed = processPpse2Lines(line); if(!processed){ clientApplicationContext.getPointOfSaleEventDispatcher().fireLineItemRemovedInTAMS(new CartEvent(this, line)); line.setExternalIdentifier(null); } } } public void lineItemEditedOutsideTAMS(CartEvent event) {} public void lineItemRemovedOutsideTAMS(CartEvent event) {} public void tamsIsReady(CartEvent event) {} public void tamsIsBusy(CartEvent event) {} public void lineItemAddedInTAMS(CartEvent event) {} public void lineItemEditedInTAMS(CartEvent event) {} public void lineItemRemovedInTAMS(CartEvent event) {} public void setIsNXPPunchedOut(boolean isPunchedOut) {} public void invoiceLineItemSpeciallyOrdered(PointOfSaleListEvent pose) {} private void delegateToESBRegistration() { final String napaRewardsPromptOption = invoicingProfileVO.getRewardsProgramPrompt(); isNapaRewardProgramOn = (invoicingProfileVO.getUseNAPARewards().booleanValue() && !invoiceVO.getManualTransaction().booleanValue() && customerVO.getREFNAPACustomerCategoryID() .intValue() == (RefNAPACustomerCategory.RETAIL_DIY) && !(clientApplicationContext.isLoggedInAsPhoneRoom() && (isPhoneRoomMessageCheckout() || isRemoteStore()))) && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO); if (isNapaRewardProgramOn && (napaRewardsPromptOption.equals(LoyaltyConstants.CUSTOMER_ONLY) || napaRewardsPromptOption.equals(LoyaltyConstants.CUSTOMER_AND_TENDER))) { ((PhoneNumberDialog) phoneNumberController.getView()).fldPhoneNumber.setText(""); new Thread() { public void run() { /* * This is an existing design used by TAMSII code to use join when showing * dialog on top of dialog. This will provide enough time for swing to redirect * focus to top window. */ try { join(100); } catch (InterruptedException ee) { logger.debug(ee.getMessage(), ee); } try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { /* * Call is embedded into a Thread as this call will display dialog * on top of 'Checkout' screen. There is always a possibility of * focus problem when multiple screen overlap each other. Call * inside thread will almost kill that possibility. */ handleNAPARewardsProgram(); } }); } catch (InterruptedException interruptedException) { logger.error(interruptedException.getMessage(), interruptedException); } catch (InvocationTargetException invocationException) { logger.error(invocationException.getMessage(), invocationException); } } }.start(); } } /** * This method handle the total NAPA reward program functionality. */ private void handleNAPARewardsProgram() { logger.debug("handleNAPARewardsProgram()"); String phoneNumber = ""; BigDecimal loyaltyEligibleAmount = new BigDecimal("0.00"); final TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); String employeeId = currentUser.getEmployeeLdapId(); String correlationId = getCorrelationID(); final LoyaltyRequest loyaltyRequest = new LoyaltyRequest(); loyaltyRequest.setCountryCode(storeProfile.getRefCountryCd()); loyaltyRequest.setCustomerType(LoyaltyConstants.CUSTOMER_TYPE); loyaltyRequest.setInvoiceDate(invoiceVO.getInvoiceDate().toString()); loyaltyRequest.setLanguageCode(storeProfile.getRefLanguageCd()); loyaltyRequest.setPhoneNumber(phoneNumber); loyaltyRequest.setStoreNumber(storeProfile.getStoreNum()); if (isNotEmpty(employeeId)) { loyaltyRequest.setEmployeeUniqueId(employeeId); } else { loyaltyRequest.setEmployeeUniqueId(currentUser.getEmployeeNum().toString()); } loyaltyRequest.setLoyaltyEligibleAmount(loyaltyEligibleAmount); loyaltyRequest.setCorrelationId(correlationId); String savedPhoneNumber = getCustLookupOrVendorIdentifier(LoyaltyConstants.CUSTOMER_LOOKUP); final boolean isNapaRewardsProgramVersion2Active = loyaltyProgramService .doesNapaRewardProgramVersion2Active(); int phoneNumberDialogAction = displayPhoneNumberDialog(savedPhoneNumber); if ((phoneNumberDialogAction == PhoneNumberController.DECLINE)) { handleLoyaltyDecline(loyaltyRequest); } else if ((phoneNumberDialogAction == PhoneNumberController.CONTINUE) || (invoiceVO.getLoyaltyCustomerLookup() != null) || (savedPhoneNumber != null) || isNotEmpty(loyaltyCustomerLookup)) { if (isNotEmpty(invoiceVO.getLoyaltyCustomerLookup())) { phoneNumber = invoiceVO.getLoyaltyCustomerLookup(); } else if (isNotEmpty(savedPhoneNumber)) { phoneNumber = savedPhoneNumber; } else if (isNotEmpty(loyaltyCustomerLookup)) { phoneNumber = loyaltyCustomerLookup; } else { phoneNumber = ((PhoneNumberDialog) phoneNumberController.getView()).fldPhoneNumber .getText(); } final String finalPhoneNumber = phoneNumber; loyaltyCustomerLookup = phoneNumber; if (finalPhoneNumber != null) { loyaltyRequest.setPhoneNumber(finalPhoneNumber); final LoyaltyResponse memberStatusResponse = loyaltyProgramService .checkMemberStatus(loyaltyRequest); if (memberStatusResponse.isSuccess()) { final String firstName = memberStatusResponse.getFirstName(); final String lastName = memberStatusResponse.getLastName(); final String emailAddress = memberStatusResponse.getEmailAddress(); final boolean isCustomerEligibleToUpdateDetails = ((isNullOrEmpty(lastName) || isNullOrEmpty(firstName) || isNullOrEmpty(emailAddress)) && memberStatusResponse.getStatus().equalsIgnoreCase( LoyaltyConstants.ACTIVE) && isNapaRewardsProgramVersion2Active); if (memberStatusResponse.getStatus().equalsIgnoreCase(LoyaltyConstants.INACTIVE) || isCustomerEligibleToUpdateDetails) { // New customer new Thread() { public void run() { /* * This is an existing design used by TAMSII code to use join when * showing dialog on top of dialog. This will provide enough time * for swing to redirect focus to top window. */ try { join(100); } catch (InterruptedException ee) { logger.debug(ee.getMessage(), ee); } try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { /* * Call is embedded into a Thread as this call will * display dialog on top of 'Checkout' screen. There is * always a possibility of focus problem when multiple * screen overlap each other. Call inside thread will * almost kill that possibility. */ InvitationDialog invitationDialog = (InvitationDialog) invitationController .getView(); String[] messageParams = new String[] { finalPhoneNumber }; String labelText1 = ParameterizedStringParser .parseString(getLocalizedText( InvitationDialog.DLG_INVITATION + "." + (isCustomerEligibleToUpdateDetails ? InvitationDialog.LBL_INVITATION_UPDATE_MSG1 : InvitationDialog.LBL_INVITATION_MSG1)), messageParams); String labelText2 = ParameterizedStringParser .parseString(getLocalizedText( InvitationDialog.DLG_INVITATION + "." + (isCustomerEligibleToUpdateDetails ? InvitationDialog.LBL_INVITATION_UPDATE_MSG2 : InvitationDialog.LBL_INVITATION_MSG2)), messageParams); invitationDialog.lblInvitationMsg1.setText(labelText1); invitationDialog.lblInvitationMsg2.setText(labelText2); if (isNapaRewardsProgramVersion2Active) { invitationDialog.fldPhoneNumber .setText(finalPhoneNumber); invitationDialog.fldLastName.setText(lastName); invitationDialog.fldFirstName.setText(firstName); invitationDialog.fldEmailAddress .setText(emailAddress); invitationController .setDoseRewardVersion2Active(true); if (isCustomerEligibleToUpdateDetails) { invitationDialog.btnUpdate.setVisible(true); invitationDialog.btnContinue.setVisible(true); invitationDialog.btnEnroll.setVisible(false); invitationDialog.btnDecline.setVisible(false); } else { invitationDialog.btnUpdate.setVisible(false); invitationDialog.btnContinue.setVisible(false); invitationDialog.btnEnroll.setVisible(true); invitationDialog.btnDecline.setVisible(true); } } if (!isNapaRewardsProgramVersion2Active) { invitationController.invitationDialog .resizeDailogue(); } //Setting this for registration service. invitationController.setLoyaltyRequest(loyaltyRequest); invitationController.setNapaRewardsProgramVersion2Active(isNapaRewardsProgramVersion2Active); int invitationDialogAction = invitationController .show(); if (invitationDialogAction == InvitationController.ENROLL) { final LoyaltyResponse registrationResponse = invitationController.getRegistrationResponse(); if (registrationResponse != null && registrationResponse.isSuccess()) { refLoyaltyCustomerStatusId = new Byte( RefLoyaltyCustomerStatus.ENROLLED); loyaltyCustomerExternalIdentifier = registrationResponse .getVendorRewardMemberIdentifier(); } else { refLoyaltyCustomerStatusId = new Byte( RefLoyaltyCustomerStatus.UNKNOWN); } setNAPARewardsInfoToInvoiceVO(); } else if (invitationDialogAction == InvitationController.DECLINE) { handleLoyaltyDecline(loyaltyRequest); } else if (invitationDialogAction == InvitationController.TRY_AGAIN) { invoiceVO.setLoyaltyCustomerLookup(null); loyaltyCustomerLookup = ""; /* * A recursive call to delegateToESBRegistration. * Once user click on 'Try Again', system should * behave as if screen is loaded for the first time. * This call will take care of all focus related * issues. Since this call display 'NAPA Rewards * Program' dialog, there is no chance of system * going into infinite loop as system will wait for * user input. */ // Thread esbThread = delegateToESBRegistration(); return; } else if (invitationDialogAction == InvitationController.CONTINUE) { refLoyaltyCustomerStatusId = new Byte( RefLoyaltyCustomerStatus.MEMBER); loyaltyCustomerExternalIdentifier = memberStatusResponse .getVendorRewardMemberIdentifier(); setNAPARewardsInfoToInvoiceVO(); } else if (invitationDialogAction == InvitationController.UPDATE) { if (isNapaRewardsProgramVersion2Active) { loyaltyRequest.setLastName( invitationDialog.fldLastName.getText()); loyaltyRequest.setFirstName( invitationDialog.fldFirstName .getText()); loyaltyRequest.setEmailAddress( invitationDialog.fldEmailAddress .getText()); } final LoyaltyResponse memberUpdateResponse = loyaltyProgramService .updateMemberDetails(loyaltyRequest); if (memberUpdateResponse.isSuccess()) { refLoyaltyCustomerStatusId = new Byte( RefLoyaltyCustomerStatus.MEMBER); loyaltyCustomerExternalIdentifier = memberUpdateResponse .getVendorRewardMemberIdentifier(); } else { refLoyaltyCustomerStatusId = new Byte( RefLoyaltyCustomerStatus.UNKNOWN); } setNAPARewardsInfoToInvoiceVO(); } } }); } catch (InterruptedException interruptedException) { logger.error(interruptedException.getMessage(), interruptedException); } catch (InvocationTargetException invocationTargetException) { logger.error(invocationTargetException.getMessage(), invocationTargetException); } } }.start(); } else { setNAPARewardsInfoToInvoiceVO(); } } } } } /** * This method sets the NAPA rewards information to InvoiceVO. */ private void setNAPARewardsInfoToInvoiceVO() { invoiceVO.setLoyaltyCustomerLookup(loyaltyCustomerLookup); invoiceVO.setLoyaltyCustomerExternalIdentifier(loyaltyCustomerExternalIdentifier); invoiceVO.setRefLoyaltyCustomerStatusId(refLoyaltyCustomerStatusId); ((PhoneNumberDialog) phoneNumberController.getView()).fldPhoneNumber.setText(""); loyaltyCustomerLookup = null; } /** * This method displays the phone number dialog * @param loyaltyCustomerLookup */ private int displayPhoneNumberDialog(String phoneNumber) { int phoneNumberDialogAction = 0; if ((isNullOrEmpty(invoiceVO.getLoyaltyCustomerLookup())) && (isNullOrEmpty(phoneNumber))) { phoneNumberDialogAction = phoneNumberController.show(); } return phoneNumberDialogAction; } /** * This method returns true if the string value is null or empty * @param String value */ private boolean isNullOrEmpty(String value){ return (value == null || value.trim().equals("")); } /** * This method checks if the logged in store is not a current store. * @return true if logged in store is remote store. */ private boolean isRemoteStore(){ String currentStoreNumber = clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getStoreProfile().getStoreNum(); boolean isRemoteStore = true; if (invoiceVO.getRemoteStoreNumber() != null && invoiceVO.getRemoteStoreNumber().equals( currentStoreNumber)) { isRemoteStore = false; } return isRemoteStore; } /** * This method checks if the PhoneRoom checkout screen is Message or not * @return true if PhoneRoom message checkout screen. */ private boolean isPhoneRoomMessageCheckout(){ boolean phoneRoomMessage = false; try { boolean isRemoteStore = isRemoteStore(); final PhoneRoomStoreVO phoneRoomStoreVO = clientApplicationContext .getRemoteInvoiceDAO().getPhoneRoomInvoiceSetting( invoiceVO.getRemoteStoreNumber(), isRemoteStore); if (phoneRoomStoreVO != null) { if (phoneRoomStoreVO.getPhoneRoomInvoiceSettingId() == RefPhoneRoomInvoiceSetting.MESSAGE) { phoneRoomMessage = true; } } } catch (ApplicationException ae) { logger.error(ae.toString(), ae); } return phoneRoomMessage; } /** * This method returns the unique correlation id every time. * * @return String */ private String getCorrelationID() { String correlationID = null; logger.debug("invoiceVO.getCorrelationID()>>>"+invoiceVO.getCorrelationID()); if (invoiceVO.getCorrelationID() == null) { StoreProfileVO storeProfile = ApplicationContext.getInstance() .getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()).getStoreProfile(); final TsoCurrentUser currentUser = clientApplicationContext.getCurrentUser(); correlationID = storeProfile.getStoreNum() + currentUser.getEmployeeNum() + System.currentTimeMillis(); invoiceVO.setCorrelationID(correlationID); } else { correlationID = invoiceVO.getCorrelationID(); } return correlationID; } /** * This method returns LoyaltyCustomerLookup of a returned line item */ private String getCustLookupOrVendorIdentifier(String parameter) { Vector lineItems = invoiceVO.getLineItems(); if (lineItems != null && lineItems.size() > 0) { for (int i = 0; i < lineItems.size(); i++) { if ((lineItems.get(i) instanceof BaseLineItemVO)) { BaseLineItemVO baseLineItemVO = (BaseLineItemVO) lineItems .get(i); if (baseLineItemVO.getReturnItems() != null) { for (Iterator iterReturnItems = baseLineItemVO .getReturnItems().iterator(); iterReturnItems .hasNext();) { InvoiceLineItemReturnVO vo = (InvoiceLineItemReturnVO) iterReturnItems .next(); if (parameter .equalsIgnoreCase(LoyaltyConstants.CUSTOMER_LOOKUP)) { if (vo.getLoyaltyCustomerLookup() != null){ return vo.getLoyaltyCustomerLookup(); } } else if (parameter .equalsIgnoreCase(LoyaltyConstants.VENDOR_IDENTIFIER)) { return vo.getLoyaltyInvoiceExternalIdentifier(); } } } } } } return null; } /** * This method is used to handle loyalty decline. */ private void handleLoyaltyDecline(final LoyaltyRequest loyaltyRequest ){ loyaltyCustomerLookup = null; setNAPARewardsInfoToInvoiceVO(); } /** * This method returns true if the string value is not an empty string * @param String value */ private boolean isNotEmpty(String value){ return (value != null && !value.trim().equals("")); } /** * This method return the localized text for the label. * * @param labelName * @return String */ private String getLocalizedText(final String labelName) { return clientApplicationContext.getResourceBundleReader().getLocalizedText( ResourceBundleReader.UI, labelName, clientApplicationContext.getCurrentLocale()); } public void displayNewNapaGiftCardDialog() { if (newNapaGiftCardController == null) { newNapaGiftCardController = new NewNapaGiftCardController (invoicePanel); } newNapaGiftCardController.setViewVisible(true); invoiceLineEntryController.getPartNumberComponent().requestFocus(); } public void validatePrimaryTaxNumber() { boolean resetCoreTaxDecision = false; int oldPrimaryTaxNumberLength = (invoiceVO.getPrimaryTaxNumber() == null) ? 0 : invoiceVO.getPrimaryTaxNumber().length(); String primaryTaxNumber = invoicePanel.getPrimaryTaxNum().getText(); primaryTaxNumber = (primaryTaxNumber == null) ? null : primaryTaxNumber.trim(); invoiceVO.setPrimaryTaxNumber(primaryTaxNumber); int newPrimaryTaxNumberLength = (invoiceVO.getPrimaryTaxNumber() == null) ? 0 : invoiceVO.getPrimaryTaxNumber().length(); if((oldPrimaryTaxNumberLength == 0 && newPrimaryTaxNumberLength != 0) ||(oldPrimaryTaxNumberLength != 0 && newPrimaryTaxNumberLength == 0)) { if(invoicingProfileVO.getEnableCoreReturnLaw().booleanValue() && invoiceVO.getPrimaryTaxTableVO().isValidateCoreReturnTaxNumber() && InvoiceBL.doReturnCoreExist(invoiceVO)) { resetCoreTaxDecision = true; } } if(resetCoreTaxDecision) { InvoiceBL.resetTaxDecisionBasedOnCustTaxNumbers(invoiceVO, customerVO, true, false); clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemsChanged( new PointOfSaleListEvent(this, invoiceVO)); } } public void validateSecondaryTaxNumber() { boolean resetCoreTaxDecision = false; int oldSecondaryTaxNumberLength = (invoiceVO.getSecondaryTaxNumber() == null) ? 0 : invoiceVO.getSecondaryTaxNumber().length(); String secondaryTaxNumber = invoicePanel.getSecondaryTaxNum().getText(); secondaryTaxNumber = (secondaryTaxNumber == null) ? null : secondaryTaxNumber.trim(); invoiceVO.setSecondaryTaxNumber(secondaryTaxNumber); int newSecondaryTaxNumberLength = (invoiceVO.getSecondaryTaxNumber() == null) ? 0 : invoiceVO.getSecondaryTaxNumber().length(); if((oldSecondaryTaxNumberLength == 0 && newSecondaryTaxNumberLength != 0) ||(oldSecondaryTaxNumberLength != 0 && newSecondaryTaxNumberLength == 0)) { if(invoicingProfileVO.getEnableCoreReturnLaw().booleanValue() && invoiceVO.getSecondaryTaxTableVO() != null && invoiceVO.getSecondaryTaxTableVO().isValidateCoreReturnTaxNumber() && InvoiceBL.doReturnCoreExist(invoiceVO)) { resetCoreTaxDecision = true; } } if(resetCoreTaxDecision) { InvoiceBL.resetTaxDecisionBasedOnCustTaxNumbers(invoiceVO, customerVO, false, true); clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemsChanged( new PointOfSaleListEvent(this, invoiceVO)); } } }