package com.gpc.client.pointofsale.invoice.line; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; import java.awt.Frame; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.math.BigDecimal; import java.math.RoundingMode; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; import java.util.Vector; import java.util.*; import com.gpc.client.pointofsale.invoice.ManagerPasswordController; import com.gpc.valueobjects.invoice.line.PhoneRoomStoreVO; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.text.Document; import org.apache.log4j.Logger; import com.gpc.businessservice.factory.rgn.RGNControlFileServiceFactory; import com.gpc.client.common.ClientApplicationContext; import com.gpc.client.common.FwoMessageMgr; import com.gpc.client.common.event.CartEvent; import com.gpc.client.common.event.InvoiceEvent; import com.gpc.client.common.event.PointOfSaleEvent; import com.gpc.client.common.event.PointOfSaleEventDispatcher; import com.gpc.client.common.event.PointOfSaleListEvent; import com.gpc.client.common.input.document.BarcodeFormatCertifier; import com.gpc.client.common.input.document.TsoValidatedIMPartNumberDocument; import com.gpc.client.pointofsale.customer.CustomerBL; import com.gpc.client.pointofsale.giftcard.GiftCardBL; import com.gpc.client.pointofsale.giftcard.NapaGiftCardController; import com.gpc.client.pointofsale.giftcard.NewNapaGiftCardController; import com.gpc.client.pointofsale.invoice.InvoiceBL; import com.gpc.client.pointofsale.invoice.PasswordController; import com.gpc.client.pointofsale.tax.Tax; import com.gpc.client.pointofsale.util.DefaultDocument; import com.gpc.client.pointofsale.util.MathUtil; import com.gpc.common.ApplicationContext; import com.gpc.common.FwiConstant; import com.gpc.common.PointOfSaleException; import com.gpc.common.Profile; import com.gpc.common.TsoConstant; import com.gpc.common.constants.PasswordConstants; import com.gpc.common.constants.RadsConstants; import com.gpc.common.constants.loyalty.LoyaltyConstants; import com.gpc.common.constants.refvalues.RefInvoiceLineItemDescription; import com.gpc.common.constants.refvalues.RefInvoiceLineItemType; import com.gpc.common.constants.refvalues.RefNAPACustomerCategory; import com.gpc.common.constants.refvalues.RefPriceSheet; import com.gpc.common.constants.refvalues.RefSupersedeType; import com.gpc.common.constants.refvalues.RefTenderType; import com.gpc.common.exception.ApplicationException; import com.gpc.common.exception.ApplicationRuntimeException; import com.gpc.common.pattern.FwoNumberPattern; import com.gpc.common.pattern.FwoPattern; import com.gpc.common.pattern.NumberPatternFormatException; import com.gpc.common.pattern.PatternParseException; import com.gpc.common.paymentcard.IntegratedPaymentCardHelper; import com.gpc.common.pointofsale.invoice.line.CommonInvoiceLineBL; import com.gpc.common.util.BooleanParser; import com.gpc.common.util.FwoUtil; import com.gpc.common.util.PartNumberFormatCertifier; import com.gpc.common.util.RefStoreConfigurationUtil; import com.gpc.valueobjects.common.IDValuePairVO; import com.gpc.valueobjects.customer.CustomerVO; import com.gpc.valueobjects.giftcard.GiftCardResponse; import com.gpc.valueobjects.inventory.BarcodeVO; import com.gpc.valueobjects.inventory.BaseInventoryVO; import com.gpc.valueobjects.inventory.InventoryNoteVO; import com.gpc.valueobjects.inventory.InventoryStockLocationVO; import com.gpc.valueobjects.inventory.InventoryVO; import com.gpc.valueobjects.inventory.KitDefinitionComponentVO; import com.gpc.valueobjects.inventory.KitDefinitionVO; import com.gpc.valueobjects.inventory.KitInventoryVO; import com.gpc.valueobjects.inventory.MiscChgVO; import com.gpc.valueobjects.inventory.SupersedePartVO; import com.gpc.valueobjects.invoice.InvoiceVO; import com.gpc.valueobjects.ordering.salesorder.SalesOrderVO; import com.gpc.valueobjects.invoice.line.BaseLineItemVO; import com.gpc.valueobjects.invoice.line.InvoiceLineItemVO; 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.rgn.RGNTypeVO; import com.gpc.valueobjects.tax.TaxDecisionVO; import com.gpc.valueobjects.tax.TaxTableVO; import com.gpc.valueobjects.invoice.line.InvoiceNoteVO; import com.gpc.valueobjects.message.MessageHeaderVO; import com.gpc.common.constants.refvalues.RefInvoiceNoteType; import com.gpc.valueobjects.inventory.BinRangeProfileVO; import com.gpc.client.pointofsale.invoice.PhoneRoomInvoiceBL; import com.gpc.client.pointofsale.tax.PhoneRoomTax; import com.gpc.common.pointofsale.invoice.line.PhoneRoomCommonInvoiceLineBL; import com.gpc.common.util.LockableBoolean; import com.gpc.server.storeprofile.dataaccess.StoreProfile; import com.gpc.tams.comm.io.PhoneRoomTaapRouter; import com.gpc.tams.comm.io.TaapRouter; /** *

Description: CLASS DESCRIPTION GOES HERE

* @author Copyright © 1999-2003, Genuine Parts Company, All Rights Reserved * @version 1.0 */ public class DefaultLineItemHandler extends AbstractLineItemHandler { private static final Logger logger = Logger.getLogger(DefaultLineItemHandler.class); protected static final String CASE = "CASE"; protected static final String PART_NUMBER_FILLER = ""; protected static final String CDF = "CDF"; protected FwoMessageMgr messageManager = clientApplicationContext.getMessageMgr(); protected InvoiceLineItemVO invoiceLineItemVO; protected BaseLineItemVO baseLineItemVO; protected InventoryVO inventoryVO; protected PricesOutVO prices; protected TaxDecisionVO taxDecision; protected MiscChgVO miscChgVO; protected boolean firstTimeThroughTax; protected AddPartLineController addPartLineController; protected AddBarcodeController addBarcodeController; protected BarcodeVO barcodeVO = null; private String pdAfterQtyChange = null; protected boolean pdChanged = false; //used to check when price is less than cost protected boolean listChanged = false; protected String expandedPartNumber = null; protected boolean partNumberFieldScanned = false; private boolean isSupersedingPart = false; private boolean waitForSecondInput = false; private boolean isZRPricing = false; protected boolean isRegularToCase = false; protected boolean hideLowSuggPriceLbl = false; protected final BigDecimal BD_ZERO = new BigDecimal("0.00"); protected String unitValue = null; protected boolean sameItemScanned = false; // Added class variables for Tender Types. private boolean isNapaGiftCardReload = false; /** Default quantity for NAPA Gift Card */ protected static final String QUNATITY_FOR_GIFT_CARDS = "1.00"; /** Case Quantity */ protected static final String CASE_QUANTITY = "C"; /** The Constant ZERO_MARKUP_PERCENT. */ private static final String ZERO_MARKUP_PERCENT = "0"; /** No of Gift Cards those can be activated in one invoice */ public static final int ACTIVATION_GIFT_CARD_LIMIT=10; /** Business approved minimum initial sale price for NAPA Gift Card */ private final int SELL_MIN_VALUE = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getTenderTypeProfile(RefTenderType.NAPA_GIFT_CARD).getSellMinValue().intValue(); /** Business approved maximum initial sale price for NAPA Gift Card */ private final int SELL_MAX_VALUE = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getTenderTypeProfile(RefTenderType.NAPA_GIFT_CARD).getSellMaxValue().intValue(); /** Business approved minimum reload price for NAPA Gift Card */ private final int RELOAD_MIN_VALUE = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getTenderTypeProfile(RefTenderType.NAPA_GIFT_CARD).getReloadMinValue().intValue(); /** Business approved maximum reload price for NAPA Gift Card */ private final int RELOAD_MAX_VALUE = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getTenderTypeProfile(RefTenderType.NAPA_GIFT_CARD).getReloadMaxValue().intValue(); /** Store Controls Currency Conversion Factor value. */ private final double CURRENCY_CONVERSION_FACTOR = getStoreProfile() .getCurrencyConversionFactor().doubleValue(); /** Holds Landed Price Factor type. */ private final Byte LANDED_PRICE_FACTOR_TYPE = new Byte((byte) TsoConstant.PRICE); /** Landed Cost Factor Type. */ private final Byte LANDED_COST_FACTOR_TYPE = new Byte((byte) TsoConstant.COST); private NewNapaGiftCardController newNapaGiftCardController; protected DefaultLineItemHandler() { } protected DefaultLineItemHandler(InvoiceLineEntryPanel invoiceLineEntryPanel, InvoiceLineItemVO invoiceLineItemVO, CustomerVO customerVO, InvoiceVO invoiceVO, BarcodeVO barcodeVO) { init(invoiceLineEntryPanel, invoiceLineItemVO, customerVO, invoiceVO, barcodeVO); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); } protected DefaultLineItemHandler(InvoiceLineEntryPanel invoiceLineEntryPanel, InvoiceLineItemVO invoiceLineItemVO, CustomerVO customerVO, InvoiceVO invoiceVO) { init(invoiceLineEntryPanel, invoiceLineItemVO, customerVO, invoiceVO); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); } public void init(InvoiceLineEntryPanel invoiceLineEntryPanel, InvoiceLineItemVO invoiceLineItemVO, CustomerVO customerVO, InvoiceVO invoiceVO, BarcodeVO barcodeVO) { this.barcodeVO = barcodeVO; init(invoiceLineEntryPanel, invoiceLineItemVO, customerVO, invoiceVO); } public void init(InvoiceLineEntryPanel invoiceLineEntryPanel, InvoiceLineItemVO invoiceLineItemVO, CustomerVO customerVO, InvoiceVO invoiceVO) { this.invoiceLineEntryPanel = invoiceLineEntryPanel; if (invoiceLineItemVO == null) { baseLineItemVO = new BaseLineItemVO(); } else { baseLineItemVO = (BaseLineItemVO) invoiceLineItemVO; } setInvoiceVO(invoiceVO); this.remoteStoreIP = getRemoteStoreIP(); this.customerVO = customerVO; if (invoiceVO.getSavedInvoiceIdForDeletion() != null) { baseLineItemVO.setDisplayTaxable2((invoiceVO.getSecondaryTaxTableID() != null && invoiceVO.getSecondaryTaxTableID().shortValue() > 0)); } else { boolean isDeliverySecTaxExist = (!invoiceVO.isPhoneRoomMessagesFlag())?CommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO):PhoneRoomCommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO,remoteStoreIP); baseLineItemVO.setDisplayTaxable2(((invoiceVO.getPrimaryTaxTableVO() != null && invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() != null && invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() .shortValue() > 0) || isDeliverySecTaxExist)); if (invoiceVO.getSecondaryTaxTableVO() == null && customerVO != null && customerVO.getDeliveredTaxTableID() != null) { TaxTableVO deliveryTaxTableVO = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ deliveryTaxTableVO= clientApplicationContext .getSystemDAO().getTaxTable(loc,customerVO.getDeliveredTaxTableID()); }else{ deliveryTaxTableVO= new PhoneRoomTaapRouter().getTaxTable(loc,customerVO.getDeliveredTaxTableID(),remoteStoreIP); } if(deliveryTaxTableVO!=null){ if(!invoiceVO.isPhoneRoomMessagesFlag()) invoiceVO.setSecondaryTaxTableVO(Tax.getSecondaryTaxTableVO(deliveryTaxTableVO)); else invoiceVO.setSecondaryTaxTableVO(PhoneRoomTax.getSecondaryTaxTableVO(deliveryTaxTableVO,remoteStoreIP)); invoiceVO.setSecondaryTaxTableID(deliveryTaxTableVO.getSecondaryTaxTableID()); }else{ invoiceVO.setSecondaryTaxTableVO(null); invoiceVO.setSecondaryTaxTableID(null); } } } inventoryVO = null; prices = null; miscChgVO = null; // To re-initialize the variable when line changes. pdAfterQtyChange = null; setPDFieldDocument(); String temp = invoiceLineEntryPanel.fldQuantity.getText(); invoiceLineEntryPanel.fldQuantity.setDocument(new QuantityDocument()); invoiceLineEntryPanel.fldQuantity.setText(temp); firstTimeThroughTax = true; isRegularToCase = false; unitValue = null; addPartLineController = new AddPartLineController(invoiceLineEntryPanel); this.dcName = ""; this.dcStockQuantity = ""; this.addDCStock = false; } /** * * @return true if invoice line items for New Gift card > No of Gift Cards those can be activated in one invoice */ private boolean giftCardMaxLimitExceed() { boolean maxLimitExceed=false; int noGiftCard = ACTIVATION_GIFT_CARD_LIMIT; // Maximum 10 line items can be part of one invoice else throw error message long totalRecord = invoiceVO.getLineItems().stream() .filter(invoiceLineItemVO -> ((InvoiceLineItemVO) invoiceLineItemVO).getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) .count(); String noGiftCardStr = clientApplicationContext.getRefTableDAO().getStoreConfigValue("ACTIVATION_GIFT_CARD_LIMIT"); if(noGiftCardStr !=null) { try { noGiftCard = Integer.parseInt(noGiftCardStr); }catch(NumberFormatException ex) { logger.error(ex.getMessage()); } } if(totalRecord == noGiftCard) maxLimitExceed=true; return maxLimitExceed; } protected void handlePartNumber() { partNumberFieldScanned = false; /*getting the text from the document is a terrible hack I had to put in to make 3 of 9 barcode work. * I entered a new bug so that we will rewrite TsoValidatedIMPartNumberDocument and TsoIMPartNumberVerifier */ Document doc = ((JTextField) invoiceLineEntryPanel.fldPartNumber).getDocument(); Object obj = ((TsoValidatedIMPartNumberDocument) doc).getDisplayValue(); String text = (obj != null ? obj.toString() : ((JTextField) invoiceLineEntryPanel.fldPartNumber).getText()); String tempText=null; String binRange = null; BinRangeProfileVO binRangeProfileVO = null; boolean isNewGiftCardPartNumber = isNewGiftCardPartNumberExists(text); if (!text.equals("") && text != null ) { Vector inventoryLines = null; /* Block the sale of existing gift cards via configuration*/ String allowGiftCardResale = clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getStoreProfile().getAllowLegacyGiftCardsSaleReload(); if (TsoConstant.GENERIC_N.equalsIgnoreCase(allowGiftCardResale) && "GFT1".equalsIgnoreCase(text)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10903"); } //strip preamble from scanned Gift card#. text = removeBarcodePrefixForGiftCards(text); if (text.startsWith("@")) { if (text.length() > 1 && (text.charAt(1) == BarcodeFormatCertifier.C || text.charAt(1) == BarcodeFormatCertifier.E || text.charAt(1) == BarcodeFormatCertifier.F || (text.charAt(1) == BarcodeFormatCertifier.B // Added to support NAPA Mexico barcodes && text.indexOf(".") == -1))) { if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { barcodeVO = PhoneRoomInvoiceLineBL.getBarcodeVO(text,this.remoteStoreIP); }else{ barcodeVO = InvoiceLineBL.getBarcodeVO(text); } if(barcodeVO == null){ if (text.length() == 14) { tempText = text.substring(0, 2) + "00" + text.substring(2, text.length()); } if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { barcodeVO = PhoneRoomInvoiceLineBL.getBarcodeVO(tempText!=null?tempText:text,this.remoteStoreIP); }else{ barcodeVO = InvoiceLineBL.getBarcodeVO(tempText != null ? tempText : text); } } if (barcodeVO == null) { //1214 = 3,N,Barcode not on file. Do you wish to add? appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1214, null, true); invoiceLineEntryPanel.fldYN.setVisible(true); invoiceLineEntryPanel.fldYN.setEnabled(true); } else { invoiceLineEntryPanel.fldPartNumber.setText(barcodeVO.getPartNumber()); if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { inventoryLines = new PhoneRoomTaapRouter().getPartLines( barcodeVO.getPartNumber(), barcodeVO.getLineAbbrev(),loc, true,this.remoteStoreIP); }else{ inventoryLines = clientApplicationContext.getInventoryDAO().getPartLines( barcodeVO.getPartNumber(), barcodeVO.getLineAbbrev(), true); } } partNumberFieldScanned = true; } else if (text.length() > 1 && text.charAt(1) == BarcodeFormatCertifier.B && text.indexOf(".") != -1) { String partLine = text.substring(2); String line = partLine.substring(0, partLine.indexOf( PartNumberFormatCertifier.PERIOD)); String part = partLine.substring(partLine.indexOf( PartNumberFormatCertifier.PERIOD) + 1); part = FwoUtil.stripChars(part, new char[] { PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(part); baseInventoryVO.setLineAbbrev(line); barcodeVO = new BarcodeVO(); barcodeVO.setPartNumber(part); barcodeVO.setLineAbbrev(line); inventoryLines = new Vector(); inventoryLines.add(baseInventoryVO); invoiceLineEntryPanel.fldPartNumber.setText(part); invoiceLineEntryPanel.fldQuantity.setDocument(new QuantityDocument(true)); partNumberFieldScanned = true; } else { //1361 = 1,N,Invalid Barcode appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1361, null, true); invoiceLineEntryPanel.fldPartNumber.setText(""); } } else if(text.length() == 18){ // This might be new gift card. // Check for the first 8 characters in the BIN_RANGE_PROFILE table. binRange = text.substring(0, 8); binRangeProfileVO = getBinRangeProfile(binRange); if(null != binRangeProfileVO) { if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { inventoryLines = new PhoneRoomTaapRouter().getPartLines( binRangeProfileVO.getPartNumber(), binRangeProfileVO.getLineAbbrev(), loc,true,this.remoteStoreIP); }else{ inventoryLines = clientApplicationContext.getInventoryDAO().getPartLines( binRangeProfileVO.getPartNumber(), binRangeProfileVO.getLineAbbrev(), true); } // Check no of Gift card in the invoice if(giftCardMaxLimitExceed()) { clientApplicationContext.getMessageMgr().showMessage( invoiceLineEntryPanel, "5064"); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.fldPartNumber.requestFocus(); } else { baseLineItemVO.setNewGiftCardNumber(text); baseLineItemVO.setNewGiftCard(true); } }else { try { expandedPartNumber = text; text = FwoUtil.stripChars(text, new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); invoiceLineEntryPanel.fldPartNumber.setText(text); boolean inventoryOnly = !InvoiceLineEntryController.isPartAddedFromPPSE2(); if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { inventoryLines = PhoneRoomInvoiceLineBL.getPartLines(text, inventoryOnly,this.remoteStoreIP); }else{ inventoryLines = InvoiceLineBL.getPartLines(text, inventoryOnly); } setComponents(); } catch (PointOfSaleException pose) { throw new ApplicationRuntimeException(pose, ApplicationRuntimeException.GENERIC_SHORT_MESSAGE_ID); } } } else if (isNewGiftCardPartNumber) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10900", ""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.fldPartNumber.requestFocus(); } else { try { expandedPartNumber = text; text = FwoUtil.stripChars(text, new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); invoiceLineEntryPanel.fldPartNumber.setText(text); boolean inventoryOnly = !InvoiceLineEntryController.isPartAddedFromPPSE2(); if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { inventoryLines = PhoneRoomInvoiceLineBL.getPartLines(text, inventoryOnly,this.remoteStoreIP); }else{ inventoryLines = InvoiceLineBL.getPartLines(text, inventoryOnly); } setComponents(); } catch (PointOfSaleException pose) { throw new ApplicationRuntimeException(pose, ApplicationRuntimeException.GENERIC_SHORT_MESSAGE_ID); } } if (inventoryLines != null) { invoiceLineEntryPanel.slfLine.setData(inventoryLines); if (inventoryLines != null && inventoryLines.size() == 1) { BaseInventoryVO baseInventoryVO = (BaseInventoryVO) inventoryLines.get(0); invoiceLineEntryPanel.slfLine.setText(baseInventoryVO.getLineAbbrev()); handleLine(); } /** * To disable Line field when Product Kit part was entered on selecting special * function COR. */ if(!(baseLineItemVO.isSpecialFnCorSelected() && invoiceLineEntryPanel.fldPartNumber.getText().equals(""))){ setLineEnabled(true); } invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(false); invoiceLineEntryPanel.btnBarcode.setEnabled(false); } clientApplicationContext.getPointOfSaleEventDispatcher().fireTamsIsBusy(new CartEvent(this)); } } private boolean isNewGiftCardPartNumberExists(String text) { Boolean isNewGiftCardPartNumber = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?(new PhoneRoomTaapRouter().isGiftCardPartNumber(text,this.remoteStoreIP)) :(InvoiceLineBL.getPartNumberDetails(text)); return isNewGiftCardPartNumber!=null?isNewGiftCardPartNumber:false; } // Find the bin range profile entry for a given gift card number BinRangeProfileVO getBinRangeProfile(String binRange) { BinRangeProfileVO binRangeProfilevo = null; boolean useNapaGCv2 ; if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { useNapaGCv2 = PhoneRoomInvoiceBL.useNapaGCv2(this.remoteStoreIP); logger.info("Checking For BinRange Number: " +binRange + " in database"); binRangeProfilevo = new PhoneRoomTaapRouter().getBinRangeDetails(binRange,this.remoteStoreIP); }else{ useNapaGCv2 = InvoiceBL.useNapaGCv2(); logger.info("Checking For BinRange Number: " +binRange + " in database"); binRangeProfilevo = InvoiceLineBL.getBinRangeDetails(binRange); } if (binRangeProfilevo != null) { if(!useNapaGCv2) { logger.info("Entered BinRange Number " +binRange + "is Valid"); logger.info("GFT Part Number: "+binRangeProfilevo.getPartNumber()); logger.info("GFT Line Abbrev: "+binRangeProfilevo.getLineAbbrev()); logger.info("Description: " +binRangeProfilevo.getDescription()); binRangeProfilevo = null; clientApplicationContext.getMessageMgr().showMessage( invoiceLineEntryPanel, "10701"); } } return binRangeProfilevo; } protected void handleLine() { clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE7_NAME); String text = invoiceLineEntryPanel.slfLine.getText(); BaseInventoryVO baseInventoryVO = null; //if (!baseLineItemVO.getLineAbbr().equals(invoiceLineEntryPanel.slfLine.getText())) { if (baseLineItemVO.getQuantityBilled().signum() == -1 && !baseLineItemVO.getLineAbbr().equals("")) { baseLineItemVO.setCoreTransaction(Boolean.FALSE); baseLineItemVO.setDefective(Boolean.FALSE); baseLineItemVO.setQuantityBilled(new BigDecimal("0.00")); invoiceLineEntryPanel.fldQuantity.setText("0.00"); clientApplicationContext.getPointOfSaleEventDispatcher().fireSwitchLineItemHandler( new InvoiceEvent(this, baseLineItemVO)); return; } if (!isManualNAPARewardsTransaction() && text.equalsIgnoreCase(LoyaltyConstants.REWARD_LINE) && invoiceLineEntryPanel.fldPartNumber.getText() .equalsIgnoreCase(LoyaltyConstants.REWARD_PART)) { if (!baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); displayLineItem(); return; } } Vector inventoryLines = invoiceLineEntryPanel.slfLine.getTableModel().getData(); for (int i = 0; i < inventoryLines.size(); i++) { baseInventoryVO = (BaseInventoryVO) inventoryLines.get(i); if (text.equals(baseInventoryVO.getLineAbbrev())) { break; } if (text.equals(new Integer(i + 1).toString())) { invoiceLineEntryPanel.slfLine.setText(baseInventoryVO.getLineAbbrev()); break; } baseInventoryVO = null; } if (baseInventoryVO == null) { baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(FwoUtil.stripChars( invoiceLineEntryPanel.fldPartNumber.getText(), new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE})); baseInventoryVO.setLineAbbrev(text); } int lineCount = LineGeneratorFactory.getInstance().getLineGenerator(this). countLinesToBeGenerated(true); if (!checkMaxInvoiceLinesReached(lineCount)) { displayPartDetail(baseInventoryVO); } /* } else { if (!invoiceLineEntryPanel.lblLine3.getText().equals("")) { clearLine(invoiceLineEntryPanel.LBL_LINE4_NAME); } } */ if (invoiceLineEntryPanel.slfLine.getText().trim().equals("") && invoiceLineEntryPanel.fldQuantity.isEnabled()) { setDescriptionEnabled(false); setQuantityEnabled(false); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setPriceEnabled(false); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); invoiceLineEntryPanel.btnSupersede.setEnabled(false); baseLineItemVO.setLineAbbr(""); } } /** * This method will check if it's a manual transaction which is eligible for NAPA Rewards */ private boolean isManualNAPARewardsTransaction() { InvoicingProfileVO invoicingProfileVO = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?(new TaapRouter().getInvoicingProfile(this.remoteStoreIP)) :(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile()); return invoicingProfileVO.getUseNAPARewards().booleanValue() && invoiceVO.getManualTransaction().booleanValue() && customerVO.getREFNAPACustomerCategoryID().intValue() == (RefNAPACustomerCategory.RETAIL_DIY); } protected void handleLineAnnotations() { InvoicingProfileVO invoicingProfileVO = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ invoicingProfileVO = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile(); }else{ invoicingProfileVO = new TaapRouter().getInvoicingProfile(remoteStoreIP); } boolean gpcOwned = (!invoiceVO.isPhoneRoomMessagesFlag())?getStoreProfile().getGpcOwned().booleanValue():new PhoneRoomTaapRouter().getStoreProfile(remoteStoreIP).getGpcOwned().booleanValue(); boolean displayCustomPricing = invoicingProfileVO.getDisplayCustomPricing().booleanValue(); boolean displayLowSuggPrice = invoicingProfileVO.getDisplayLowSuggPrice().booleanValue(); hideLowSuggPriceLbl = (gpcOwned || !displayLowSuggPrice); logger.debug("++++++ hideLowSuggPriceLbl = " + hideLowSuggPriceLbl); clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); if (inventoryVO.getInventoryStockVO() != null) { //1205 = 1,N,Avail: $1 String availString = inventoryVO.getInventoryStockVO().getInventoryAvailable(); appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1205, new String[] {availString}, false); } else { String availString = "0.00"; appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1205, new String[] {availString}, false); } if (addDCStock){ addHtmlTagToJLabel(InvoiceLineEntryPanel.LBL_LINE1_NAME, "", false); addHtmlTagToJLabel(InvoiceLineEntryPanel.LBL_LINE1_NAME, "", true); appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1283, new String[]{dcName, dcStockQuantity}, false); addHtmlTagToJLabel(InvoiceLineEntryPanel.LBL_LINE1_NAME, "", true); } String cls = ""; if (inventoryVO.getCurrentYearRefClassCD() == null) { cls = ""; } else { cls = inventoryVO.getCurrentYearRefClassCD(); } //1206 = 1,N,Cls: $1 this.appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1206, new String[] {cls}, false); handleLocLineAnnotations(); boolean ctrmanOverridePrice ; if(!invoiceVO.isPhoneRoomMessagesFlag()){ ctrmanOverridePrice=clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile( ).getAllowCtrmanOverridePrice().booleanValue(); }else{ ctrmanOverridePrice = new TaapRouter().getInvoicingProfile(remoteStoreIP).getAllowCtrmanOverridePrice().booleanValue(); } if (ctrmanOverridePrice) { // logger.debug(">>>> prices.getPriceDecision() = " + prices.getPriceDecision()); if (prices.getPriceDecision().equals("!")) { //1222 = 1,N,Sale Item appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1222, null, false); } else { String calcString = prices.getCalcString(); if(displayPriceWithTax()){ final String taxLabel = messageManager.getMessage(String.valueOf(9951), new String[] {}).getText(); calcString = calcString.concat(" + ").concat(taxLabel); } if (prices.getPriceDecision().equals("*")) { if (gpcOwned || !displayCustomPricing) { appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, new String(""), false); }else { if (!displayCustomPricing) { appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, new String(""), false); }else { appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, calcString, false); } } }else { if (displayCustomPricing) { appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, calcString, false); } else { appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, new String(""), false); } } } } clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); BigDecimal lowSuggestedPrice = (!invoiceVO.isPhoneRoomMessagesFlag())?clientApplicationContext.getInventoryDAO().getLowSuggestedPrice(inventoryVO): (new PhoneRoomTaapRouter().getLowSuggestedPrice(remoteStoreIP,inventoryVO)); if (InvoiceBL.compareLowSuggested(lowSuggestedPrice, baseLineItemVO)) { if (gpcOwned || !displayLowSuggPrice) { appendToLine(InvoiceLineEntryPanel.LBL_LINE3_NAME, new String(""), false); }else { String lowSuggestedPriceString = lowSuggestedPrice.toString(); if(displayPriceWithTax()){ final String taxLabel = messageManager.getMessage(String.valueOf(9951), new String[] {}).getText(); lowSuggestedPriceString = lowSuggestedPriceString.concat(" + ").concat(taxLabel); } //1208 = 1,N,Low Suggested Price $1 appendToLine(InvoiceLineEntryPanel.LBL_LINE3_NAME, 1208, new String [] {lowSuggestedPriceString}, false); Toolkit.getDefaultToolkit().beep(); } } clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); boolean supersedeExist; if(!invoiceVO.isPhoneRoomMessagesFlag()) supersedeExist = clientApplicationContext.getInventoryDAO().doSupersedesExist(inventoryVO); else supersedeExist = new PhoneRoomTaapRouter().doSupersedesExist(remoteStoreIP,inventoryVO.getLineAbbrev(),inventoryVO.getPartNumber(),loc); if (supersedeExist) { SupersedePartVO supersedePartVO =null; if(!invoiceVO.isPhoneRoomMessagesFlag()) { supersedePartVO= InvoiceLineBL.getSupersedePartVO(inventoryVO, customerVO); }else{ supersedePartVO = new PhoneRoomTaapRouter().getSupersede(inventoryVO,remoteStoreIP,customerVO,clientApplicationContext.getCurrentLocale().getLanguage()); } if (supersedePartVO.getRefSupersedeTypeID().intValue() == RefSupersedeType.SUPERSEDED_BY) { appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1368, new String[] {supersedePartVO.getSupersedingLineAbbrev(), supersedePartVO.getSupersedingPartNumber()}, false); } else if (supersedePartVO.getRefSupersedeTypeID().intValue() == RefSupersedeType.REORDER) { appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1369, new String[] {supersedePartVO.getSupersedingLineAbbrev(), supersedePartVO.getSupersedingPartNumber()}, false); } else if (supersedePartVO.getRefSupersedeTypeID().intValue() == RefSupersedeType.RENUMBERED) { appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1381, new String[] {supersedePartVO.getSupersedingLineAbbrev(), supersedePartVO.getSupersedingPartNumber()}, false); } else if (supersedePartVO.getRefSupersedeTypeID().intValue() == RefSupersedeType.SUBSTITUTE) { appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1382, new String[] {supersedePartVO.getSupersedingLineAbbrev(), supersedePartVO.getSupersedingPartNumber()}, false); } } else { if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 0 && !inventoryVO.isReportable().booleanValue()) { //1209 = 1,N,Non-reportable item appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1209, null, false); } } clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); if (inventoryVO.getInventoryStockVO() != null && inventoryVO.getInventoryStockVO().getInventoryNoteVO() != null) { InventoryNoteVO inventoryNote = inventoryVO.getInventoryStockVO().getInventoryNoteVO(); appendToLine(InvoiceLineEntryPanel.LBL_LINE6_NAME, inventoryNote.getText(), false); } } protected void handleLocLineAnnotations() { Vector inventoryStockLocations = inventoryVO.getInventoryStockLocations(); if (inventoryStockLocations != null && !inventoryStockLocations.isEmpty()) { StringBuffer inventoryStock = new StringBuffer(""); int maxDisplayedLocations = 3; if (inventoryStockLocations.size() < maxDisplayedLocations) { maxDisplayedLocations = inventoryStockLocations.size(); } for (int i = 0; i < maxDisplayedLocations ; i++) { String temp = ((InventoryStockLocationVO) inventoryStockLocations.get(i)). getStockLocation(); String planogramReference = ((InventoryStockLocationVO) inventoryStockLocations.get(i)) .getPlanogramReference(); if ((temp != null) && (temp.length() > 0)) { if (planogramReference != null && !planogramReference.isEmpty()) { temp = temp + "-" + planogramReference; } if ((inventoryStock.length() > 0) && !inventoryStock.toString().endsWith("|")) { inventoryStock.append("|"); } inventoryStock.append(temp); } } //1207 = 1,N,LOC: $1 appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1207, new String[] {inventoryStock.toString()}, false); } } protected void handleDescription() { setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); setQuantityEnabled(true); } private boolean isItemScannedAndCurrentItemSame (String scannedString) { if ((scannedString == null) || (scannedString.equals(""))) { return false; } if (!scannedString.startsWith("@")) { return false; } if (scannedString.length() > 1 && (scannedString.charAt(1) == BarcodeFormatCertifier.C || scannedString.charAt(1) == BarcodeFormatCertifier.E || scannedString.charAt(1) == BarcodeFormatCertifier.F || (scannedString.charAt(1) == BarcodeFormatCertifier.B && scannedString.indexOf(".") == -1))) { if (scannedString.length() < 10) { return false; } else { barcodeVO = InvoiceLineBL.getBarcodeVO(scannedString); if (barcodeVO == null) { return false; } else if ((barcodeVO.getPartNumber() == null) ||(!inventoryVO.getPartNumber().equals(barcodeVO.getPartNumber()))){ return false; } else if ((barcodeVO.getLineAbbrev() == null) || (!inventoryVO.getLineAbbrev().equals(barcodeVO.getLineAbbrev()))) { return false; } else { return true; } } } else if (scannedString.charAt(1) == BarcodeFormatCertifier.B && scannedString.indexOf(".") != -1) { String partLine = scannedString.substring(2); String line = partLine.substring(0, partLine.indexOf( PartNumberFormatCertifier.PERIOD)); String part = partLine.substring(partLine.indexOf( PartNumberFormatCertifier.PERIOD) + 1); part = FwoUtil.stripChars(part, new char[] { PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); if ((part == null) || (!part.equals(inventoryVO.getPartNumber()))) { return false; } if ((line == null) || (!line.equals(inventoryVO.getLineAbbrev()))) { return false; } return true; } return false; } protected void handleQuantityScanned() { sameItemScanned = false; String quantity = invoiceLineEntryPanel.fldQuantity.getText(); String originalQuantityEntry = invoiceLineEntryPanel.fldQuantity.getText(); BigDecimal barcodeQuantity = new BigDecimal("0.00"); if (originalQuantityEntry.startsWith("@B/") && !originalQuantityEntry.endsWith("END")) { try { barcodeQuantity = new BigDecimal(originalQuantityEntry.substring(3)); } catch (NumberFormatException nfe) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "176", quantity); invoiceLineEntryPanel.fldQuantity.setText(""); return; } catch (StringIndexOutOfBoundsException sioobe) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "1361"); invoiceLineEntryPanel.fldQuantity.setText(""); return; } barcodeQuantity = barcodeQuantity.setScale(2, BigDecimal.ROUND_HALF_UP); } else { if (baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().doubleValue() != 0) { barcodeQuantity = baseLineItemVO.getQuantityBilled(); } sameItemScanned = isItemScannedAndCurrentItemSame(originalQuantityEntry); // Code Added for Tender Types. // For a barcode scanned NAPA Gift Card part in Invoice Line Entry area, if the user // scans the same part again in the quantity field, restrict the quantity being // increased by 1. if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9302"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .toString()); return; } if (sameItemScanned) { if (barcodeVO == null) { if(!invoiceVO.isPhoneRoomMessagesFlag()) barcodeVO = InvoiceLineBL.getBarcodeVO(originalQuantityEntry); else barcodeVO = PhoneRoomInvoiceLineBL.getBarcodeVO(originalQuantityEntry,getRemoteStoreIP()); } if (barcodeVO == null) { if (inventoryVO == null || inventoryVO.getStandardPkg().intValue() == 0) { barcodeQuantity = barcodeQuantity.add(new BigDecimal("1.00")); } else { barcodeQuantity = barcodeQuantity.add(new BigDecimal(inventoryVO.getStandardPkg().toString())); } } else { if (barcodeVO.getPkgQty().intValue() == 0) { if (inventoryVO == null || inventoryVO.getStandardPkg().intValue() == 0) { barcodeQuantity = barcodeQuantity.add(new BigDecimal("1.00")); } else { barcodeQuantity = barcodeQuantity.add(new BigDecimal(inventoryVO.getStandardPkg().toString())); } } else { barcodeQuantity = barcodeQuantity.add(new BigDecimal(barcodeVO.getPkgQty( ).doubleValue())); } } } else { if(InvoiceLineBL.getBlockSaleFlag(InvoiceBL.isRemoteStore())) { if (!isPartElegibleForSale(barcodeQuantity, InvoiceBL.isRemoteStore())) { return; } }else if (!validatePartCertificate(barcodeQuantity)) { return; } } } invoiceLineEntryPanel.fldQuantity.setText(barcodeQuantity.toString()); baseLineItemVO.setQuantityBilled(barcodeQuantity); quantity = barcodeQuantity.toString(); checkPriceChangeDueToQuantity(); if (sameItemScanned) { return; } populateTaxDecision(); handlePD(); checkTax(); setLineFields(); baseLineItemVO.setCompletedLine(true); LineGenerationQueue.getInstance().addAutoCompletedLineItem(this); if (!originalQuantityEntry.equals("@B$END") && !originalQuantityEntry.equals("@B/DEND")) { BaseLineItemVO nextLine = new BaseLineItemVO(); nextLine.setPartNum(originalQuantityEntry); LineGenerationQueue.getInstance().addLineItemNoGenerate(nextLine); } else { BaseLineItemVO nextLine = new BaseLineItemVO(); nextLine.setPartNum(originalQuantityEntry); LineGenerationQueue.getInstance().addLineItemNoGenerate(nextLine); setLineEnabled(false); setQuantityEnabled(false); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setTaxEnabled(false); } clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE7_NAME); SwingUtilities.invokeLater(new Runnable() { public void run() { PointOfSaleEventDispatcher.getInstance().fireProcessLineQueue(null); } }); } protected void handleReturnDialog(boolean isItemReturnDetailInfoRequired) { String partNumber = FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText(), new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); if (partNumber == null || partNumber.length() == 0) { return; } baseLineItemVO.setPartNum(partNumber); baseLineItemVO.setPartDescription(invoiceLineEntryPanel.fldDescription.getText()); invoiceReturnController.setInitialData(invoiceVO, customerVO, baseLineItemVO, inventoryVO, prices.getPriceSheetCd()); invoiceReturnController.setViewVisible(true); // Skip the current line item if (invoiceVO.isReturnInvoice() && !invoiceReturnController.isReturnInfoEntered()) { return; } if ( !invoiceReturnController.isReturnInfoEntered()) { baseLineItemVO.setQuantityBilled(new BigDecimal("0.00")); String storeLanguageCd = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getStoreProfile().getRefLanguageCd(); String coreDescription = null; String warrantyDescription = null; try { coreDescription = clientApplicationContext.getRefTableDAO() .getInvoiceLineDescription(new Integer( RefInvoiceLineItemDescription.CORE_DEPOSIT), storeLanguageCd); warrantyDescription = clientApplicationContext.getRefTableDAO() .getInvoiceLineDescription(new Integer( RefInvoiceLineItemDescription.WARRANTY), storeLanguageCd); } catch (ApplicationException applicationException) { logger.error("Error occured while retreiving invoice line description" + applicationException.toString(), applicationException); } if(baseLineItemVO.getPartDescription().equals(coreDescription)){ baseLineItemVO.setCoreTransaction(Boolean.TRUE); } else { baseLineItemVO.setCoreTransaction(Boolean.FALSE); } if(baseLineItemVO.getPartDescription().equals(warrantyDescription)){ baseLineItemVO.setDefective(Boolean.TRUE); } else { baseLineItemVO.setDefective(Boolean.FALSE); } invoiceLineEntryPanel.fldQuantity.setText(""); invoiceLineEntryPanel.fldQuantity.requestFocus(); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setTaxEnabled(false); } else { resetAttributesOfReturnItem(baseLineItemVO); baseLineItemVO.setLineAbbr(""); if(invoiceVO.isReturnInvoice()) { baseLineItemVO.setCompletedLine(true); } clientApplicationContext.getPointOfSaleEventDispatcher().fireSwitchLineItemHandler( new InvoiceEvent(this, (BaseLineItemVO) invoiceReturnController.getModel())); if (isItemReturnDetailInfoRequired && baseLineItemVO.getReturnItems() != null && LineGenerationQueue.getInstance().isEmpty()) { // Added for RGN:Invoicing // Display special instruction if line is not present in the warranty file if(InvoiceBL.isRgnInUse()) { displayRgnSpeicialInstruction(); } // ========================================== setLineFields(true); baseLineItemVO.setCompletedLine(true); /** * Code added to update the queue with return detail entries created for each * return item. */ LineGenerationQueue.getInstance().addLineItem(invoiceVO, baseLineItemVO, customerVO, prices, invoiceReturnController, true); // Code added to process the queue containing return line item PointOfSaleEventDispatcher.getInstance().fireProcessLineQueue( new PointOfSaleEvent(this, baseLineItemVO)); } } } protected void handleQuantity() { //logger.debug("________>>> handleQuantity "); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); String quantity = invoiceLineEntryPanel.fldQuantity.getText(); FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits( clientApplicationContext.getSystemDAO().getPriceScale().intValue()); fwoNumberPattern.setMaxFractionDigits( clientApplicationContext.getSystemDAO().getPriceScale().intValue()); FwoNumberPattern fwoEPNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoEPNumberPattern.setMinFractionDigits(2); fwoEPNumberPattern.setMaxFractionDigits(2); // Setting NAPA Gift Card reload flag to false. isNapaGiftCardReload = false; if (CASE_QUANTITY.equalsIgnoreCase(quantity)) { //logger.debug("________>>> in case of CASE_QUANTITY, check for GFT qty C next ... "); // Code added for Tender Types to avoid entering quantity 'C' for NAPA Gift Card. if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9302"); invoiceLineEntryPanel.fldQuantity.setText(QUNATITY_FOR_GIFT_CARDS); return; } //logger.debug("________>>> in case of CASE_QUANTITY, go on ... "); invoiceLineEntryPanel.fldPD.setDocument(new PDDocument(new Character[] {PDDocument.C})); invoiceLineEntryPanel.fldPD.setText("C"); // variable used to check whether quantity of a regular part is changed to case quantity // or not. isRegularToCase = baseLineItemVO.isCasePrice().booleanValue() ? false : true; baseLineItemVO.setCasePrice(Boolean.TRUE); baseLineItemVO.setCaseQuantity(true); try { invoiceLineEntryPanel.fldPrice.setText(fwoNumberPattern.format(new BigDecimal( 0).setScale(clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP)).toString()); } catch (NumberPatternFormatException npfe) { //do nothing } unitValue = invoiceLineEntryPanel.fldUnit.getText(); invoiceLineEntryPanel.fldUnit.setText(CASE); if (inventoryVO != null) { if (inventoryVO.getCaseQty().intValue() != 0) { messageManager.showMessage(invoiceLineEntryPanel, "1200" , new String[] {inventoryVO.getCaseQty().toString()}); } BigDecimal caseQty = new BigDecimal (inventoryVO.getCaseQty().doubleValue()); caseQty = caseQty.setScale(2, BigDecimal.ROUND_HALF_UP); this.setQuantityToDisplay(caseQty.toString()); } else { this.setQuantityToDisplay("0.00"); } //logger.debug("________>>> in case of CASE_QUANTITY, return"); return; } else if (InvoiceLineBL.isScanned(quantity)) { if (!partNumberFieldScanned) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "1394"); return; } handleQuantityScanned(); //logger.debug("________>>> the method, scanned, return "); return; } //logger.debug("________>>> done with case quantity."); BigDecimal bdQuantity = null; if (!quantity.trim().equals("") && !quantity.equals("-")) { //logger.debug("________>>> the method, quantity is valid ..."); if (quantity.indexOf("/") != -1) { bdQuantity = MathUtil.convertToDecimal(quantity, 2); } else { if (!quantity.trim().equals("")) { try { bdQuantity = new BigDecimal(quantity); bdQuantity = bdQuantity.setScale(2, BigDecimal.ROUND_HALF_UP); invoiceLineEntryPanel.btnSupersede .setEnabled(canEnableSupersedeButton(bdQuantity)); if(InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO) && bdQuantity.doubleValue() < 0) { invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled().toString()); appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 9204, null, false); Toolkit.getDefaultToolkit().beep(); return; } if(invoiceVO.isReturnInvoice() && bdQuantity.doubleValue() > 0) { invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled().toString()); appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 10309, null, false); Toolkit.getDefaultToolkit().beep(); return; } if (bdQuantity.signum() == 0) { bdQuantity = handleDefaultQuantityOf1(new BigDecimal(0.00)); if (bdQuantity.signum() == 0) { this.setQuantityToDisplay("0.00"); } else { this.setQuantityToDisplay(bdQuantity.toString()); } } } catch (NumberFormatException nfe){ clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "176", quantity); invoiceLineEntryPanel.fldQuantity.setText(""); return; } } } //logger.debug("________>>> done with quantity is valid."); } else if (baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().doubleValue() != 0.0) { /* The above is done to handle reprompting in quantity */ bdQuantity = baseLineItemVO.getQuantityBilled(); invoiceLineEntryPanel.fldQuantity.setText(bdQuantity.toString()); } else { bdQuantity = new BigDecimal("0.00"); } if(baseLineItemVO.isCasePrice() != null && baseLineItemVO.isCasePrice().booleanValue()){ final BigDecimal availableQty = InvoiceLineBL.getAvailableQty(inventoryVO, dcStockQuantity); /* * Don't need to check for returns separately here. Least possible value for * 'availableQty' is 0. Hence in case of returns, this condition will always * fail. */ if(availableQty.compareTo(bdQuantity) == -1){ resetRegularPriceValues(); } } //logger.debug("________>>> before check DefaultQty"); bdQuantity = handleDefaultQuantityOf1(bdQuantity); // Check for block sale parts and any waivers through certificate. if(InvoiceLineBL.getBlockSaleFlag(InvoiceBL.isRemoteStore())) { if (!isPartElegibleForSale(bdQuantity, InvoiceBL.isRemoteStore())) { return; } }else if (!validatePartCertificate(bdQuantity)) { return; } if (baseLineItemVO.getGeneratedByLineItem() == null && bdQuantity.doubleValue() > 0 && !baseLineItemVO.isCompletedLine()) { String partNumber = FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText(), new char[] { PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE }); baseLineItemVO.setPartNum(partNumber); InventoryVO inventoryVo = clientApplicationContext.getInventoryDAO().getPartDetailInfo( customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), false); boolean supersedesExist = clientApplicationContext.getInventoryDAO().doSupersedesExist( inventoryVo); invoiceLineEntryPanel.btnSupersede.setEnabled(supersedesExist && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)); } else { invoiceLineEntryPanel.btnSupersede.setEnabled(false); } //logger.debug("________>>> before handing rads "); // Added for RADS - Main Counter // If line item is picked by RADS, display a information message for the // following cases // 1. If user tries to increase the invoiced quantity greater // than the sent quantity by the RADS // 2. If user tries to set negative quantity for the line item try { int messageToDisplay = InvoiceBL.handleRadsSentQuantityChanged(invoiceVO, baseLineItemVO, bdQuantity); logger.debug("messageToDisplay-->" + messageToDisplay); if (messageToDisplay == RadsConstants.CANNOT_INCREASE_QTY_ITEMS_PICKED_BY_RADS || messageToDisplay == RadsConstants.ITEMS_PICKED_BY_RADS_NO_NEGATIVE_QTY) { if (messageToDisplay == RadsConstants.CANNOT_INCREASE_QTY_ITEMS_PICKED_BY_RADS) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9021"); } else if (messageToDisplay == RadsConstants.ITEMS_PICKED_BY_RADS_NO_NEGATIVE_QTY) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9022"); } this.setQuantityToDisplay(baseLineItemVO.getQuantityBilled().setScale(2, BigDecimal.ROUND_HALF_UP).toString()); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setTaxEnabled(false); return; } } catch (ApplicationException e) { logger.error("Exception occurred while adjusting the quantity for RADS Item.", e); if (e.getUserMessageID() != null) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, e.getUserMessageID()); } else { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9039"); } } // Line Item invoice Quantity cannot be modified if the selected line item is KIT component if (InvoiceBL.doesKitComponentEligibleToLoadLineEntryArea(baseLineItemVO, getRemoteStoreIP(), invoiceVO) && bdQuantity != null && baseLineItemVO.getQuantityBilled() != null && bdQuantity.compareTo(baseLineItemVO.getQuantityBilled()) != 0) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2286"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); return; } // Line Item invoice Quantity cannot be increased more than NOL Order Quantity for NOL Order if (baseLineItemVO.isCompletedLine() && InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && bdQuantity != null && baseLineItemVO.getNolOrderQuantity() != null && bdQuantity.compareTo(baseLineItemVO.getNolOrderQuantity()) == 1) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "2283"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); return; } // Line Item invoice Quantity cannot be increased more than CSG Order Quantity for CSG Order if (baseLineItemVO.isCompletedLine() && InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && bdQuantity != null && baseLineItemVO.getOrderQuantity() != null && baseLineItemVO.getOrderQuantity().compareTo(BD_ZERO) != 0 && bdQuantity.compareTo(baseLineItemVO.getOrderQuantity()) == 1) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10203"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); return; } // Line item quantity can not be negative for CSG orders if (baseLineItemVO.isCompletedLine() && InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && bdQuantity != null && bdQuantity.signum() == -1) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10204"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); return; } if (InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)) { // CSG Restricted Return Item Quantity cannot be changed to positive quantity if (baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().signum() == -1 && bdQuantity != null && bdQuantity.signum() != -1) { clientApplicationContext.getMessageMgr() .showMessage(invoiceLineEntryPanel, "10211"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled() .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); return; } // Additional Sale items cannnot be added to CSG-Restricted return invoice if (!baseLineItemVO.isCompletedLine() && bdQuantity != null && bdQuantity.signum() != -1) { final String originalInvoiceNumber = InvoiceBL .retrieveCSGRestrictedReturnItemInvoiceNumber(invoiceVO); clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10212", originalInvoiceNumber); resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); return; } } // =========================== if (baseLineItemVO.isReqdProcessingLineMsg()) { processLine5Messages(bdQuantity.add(baseLineItemVO.getNonAvailableQty()), baseLineItemVO.getNonAvailableQty()); baseLineItemVO.setReqdProcessingLineMsg(false); } if (ipcInUse() && !baseLineItemVO.isCompletedLine() && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD && invoiceVO.getLineItems() != null && bdQuantity.doubleValue() > 0.00) { for (int i = 0; i < invoiceVO.getLineItems().size(); i++) { InvoiceLineItemVO invoiceLineItemVO = (InvoiceLineItemVO) invoiceVO .getLineItems().get(i); if (invoiceLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD && invoiceLineItemVO.getQuantityBilled().doubleValue() > 0.00) { clientApplicationContext.getMessageMgr().showMessage( invoiceLineEntryPanel, "5061"); return; } } } //logger.debug("________>>> before the rest ... "); final boolean isItemReturnDetailInfoRequired = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?(new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getAskForItemReturnInfo().booleanValue()) :(clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getAskForItemReturnInfo().booleanValue()); StoreProfileVO storeprofileVO = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?new PhoneRoomTaapRouter().getStoreProfile(this.remoteStoreIP) :getStoreProfile(); //logger.debug("________>>> isItemReturnDetailInfoRequired = " + isItemReturnDetailInfoRequired + // ", baseLineItemVO.getQuantityBilled() = "+ baseLineItemVO.getQuantityBilled()); if ((baseLineItemVO.getQuantityBilled().compareTo(bdQuantity) != 0 && bdQuantity.doubleValue() != 0.0) || invoiceVO.isReturnInvoice() && !invoiceVO.isReturnInvoiceLoaded() || isRegularToCase || (storeprofileVO.getUseNapaXpress().booleanValue() && isSupersedingPart)) { if(storeprofileVO.getUseNapaXpress().booleanValue()){ //logger.debug("________>>> getting here ..."); //logger.debug("________>>> getting here ..."); if(baseLineItemVO.isCompletedLine()){ if(TsoConstant.NXP_ORDERED.equals(baseLineItemVO.getSpecialOrder()) || TsoConstant.NXP_DIRECT_SHIP_APPROVED_ORDERED.equals(baseLineItemVO.getSpecialOrder())){ clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9974"); setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); return; } else { final BigDecimal qtyEligibleForSpecialOrder = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?PhoneRoomInvoiceLineBL.getQtyEligibleForSpecialOrder(invoiceVO, baseLineItemVO, inventoryVO, bdQuantity, dcStockQuantity,remoteStoreIP,null) :InvoiceLineBL.getQtyEligibleForSpecialOrder(invoiceVO, baseLineItemVO, inventoryVO, bdQuantity, dcStockQuantity); if (qtyEligibleForSpecialOrder.signum() == 1 && (InvoiceBL.hasNxpApprovedItem(invoiceVO) || InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO) || (invoiceVO != null && invoiceVO.getDirectShippedInvoice() != null && invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0))) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9975"); setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); return; } } } else { final BigDecimal qtyEligibleForSpecialOrder = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?PhoneRoomInvoiceLineBL.getQtyEligibleForSpecialOrder(invoiceVO, baseLineItemVO, inventoryVO, bdQuantity, dcStockQuantity,remoteStoreIP,null) :InvoiceLineBL.getQtyEligibleForSpecialOrder(invoiceVO, baseLineItemVO, inventoryVO, bdQuantity, dcStockQuantity); if (qtyEligibleForSpecialOrder.signum() == 1 && (InvoiceBL.hasNxpApprovedItem(invoiceVO) || InvoiceBL.hasNxpDirectShipApprovedItem(invoiceVO) || (invoiceVO != null && invoiceVO.getDirectShippedInvoice() != null && invoiceVO.getDirectShippedInvoice().getLineItems().size() > 0))) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9975"); resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); return; } } bdQuantity = handleSpecialOrder(bdQuantity); } processLine5Messages(bdQuantity.add(baseLineItemVO.getNonAvailableQty()), baseLineItemVO.getNonAvailableQty()); // Code added for Tender Types. // Prevent entering any quantity other than 1 or -1 for NAPA Gift Card. if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && bdQuantity.abs().doubleValue() != 1.00) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9302"); if (!baseLineItemVO.isCompletedLine()) { baseLineItemVO.setQuantityBilled(BD_ZERO); setQuantityToDisplay(QUNATITY_FOR_GIFT_CARDS); } else { setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); } return; } if ((CustomerBL.isNapaOnlineCustomer(customerVO) || bdQuantity.doubleValue() < 0) && quantity.indexOf("-") != 0 && !baseLineItemVO.isDefective().booleanValue()) { // To avoid appending of "-" to an empty string. if(!quantity.equals("")){ this.setQuantityToDisplay("-" + quantity); quantity = "-" + quantity; bdQuantity = new BigDecimal(quantity); } else { bdQuantity = handleDefaultQuantityOf1(new BigDecimal("0.00")); } } if (!baseLineItemVO.isWarrantyLaborClaim().booleanValue()) { /** * Code added to check when user changes the quantity of a return item * when store setting item return detail info required is activated . */ if (isItemReturnDetailInfoRequired && baseLineItemVO.isCompletedLine() && baseLineItemVO.getReturnItems() != null && baseLineItemVO.getQuantityBilled().doubleValue() < 0 && bdQuantity.doubleValue() < 0 && ((baseLineItemVO.getQuantityBilled().doubleValue() != bdQuantity.doubleValue()) || isRegularToCase)) { /** * Code to ask for confirmation before changing the quantity * of invoice line items. */ if (clientApplicationContext.getMessageMgr().showMessageNoYes( invoiceLineEntryPanel, "2257")) { deleteInvoiceLineItem(bdQuantity); // To set the variable with line item price decision value // after quantity change. pdAfterQtyChange = baseLineItemVO.getPriceDecision(); if (!baseLineItemVO.isSpecialFnCorSelected()) { baseLineItemVO.setCoreTransaction(Boolean.FALSE); } } else { invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO .getQuantityBilled().toString()); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setTaxEnabled(false); if (isRegularToCase) { resetRegularPriceValues(); } return; } } /** * Code added to check when user changes the quantity of a return item to positive. */ if (baseLineItemVO.getQuantityBilled().doubleValue() < 0 && bdQuantity.signum() > 0) { if (InvoiceBL.isBarcodedNAPAGiftCardReturnItem(baseLineItemVO)) { GiftCardResponse giftCardResponse = GiftCardBL .giftCardCashPayoutHoldReversal( baseLineItemVO.getGiftCardTransactionReferenceId()); logger.debug("GiftCardCashPayoutHoldReversal Service Response = " + giftCardResponse); } deleteInvoiceLineItem(bdQuantity); baseLineItemVO.setQuantityBilled(bdQuantity); this.setQuantityToDisplay(bdQuantity.toString()); invoiceLineEntryPanel.btnSupersede .setEnabled(canEnableSupersedeButton(bdQuantity)); if (!baseLineItemVO.isCoreTransaction().booleanValue()) { baseLineItemVO.setPartDescription(null); baseLineItemVO.setReqdProcessingLineMsg(true); BigDecimal bdUnitPrice = baseLineItemVO.getUnitPrice(); // Assigning 'isRegularToCase' value to variable '' as switching // of the line item handler will reset the 'isRegularToCase' value. boolean isRegularToCaseLineItem = isRegularToCase; clientApplicationContext.getPointOfSaleEventDispatcher() .fireSwitchLineItemHandler(new InvoiceEvent(this, baseLineItemVO)); if (baseLineItemVO.isCasePrice().booleanValue()) { // Code added to display the old price in the price field, when user // enters quantity as "C" while changing the quantity of a return item // which is a case transaction to a positive value with // "Item Return Info Required" flag off. if (!isItemReturnDetailInfoRequired && !isRegularToCaseLineItem && baseLineItemVO.isCaseQuantity()) { baseLineItemVO.setUnitPrice(bdUnitPrice); try { String strUnitPrice = fwoNumberPattern.format(bdUnitPrice); invoiceLineEntryPanel.fldPrice.setText(strUnitPrice); } catch (NumberPatternFormatException npfe) { logger.error("Error occured while formatting the price" + npfe.getMessage()); } } else { int priceScale = clientApplicationContext.getSystemDAO() .getPriceScale().intValue(); try { invoiceLineEntryPanel.fldPrice.setText(fwoNumberPattern .format(new BigDecimal(0).setScale(priceScale, BigDecimal.ROUND_HALF_UP))); } catch (NumberPatternFormatException nfe) { logger.error("Error occured while formatting the price" + nfe.getMessage()); } } invoiceLineEntryPanel.fldUnit.setText(CASE); setPDEnabled(true, baseLineItemVO); } return; } } /** * Code added to check when user changes the quantity of a * purchase item to negative. */ if(baseLineItemVO.getQuantityBilled().doubleValue() > 0 && bdQuantity.doubleValue() < 0 && !baseLineItemVO.isUsedForReturn() && baseLineItemVO.isCompletedLine()) { deleteInvoiceLineItem(bdQuantity); // Added code to remove grey color background for invoice line item // when quantity is changed from positive to negative. baseLineItemVO.setQuantityNotDistributed(false); // To set the variable with line item price decision value // after quantity change. pdAfterQtyChange = baseLineItemVO.getPriceDecision(); if (!baseLineItemVO.isSpecialFnCorSelected()) { baseLineItemVO.setCoreTransaction(Boolean.FALSE); } } /** * Code added to check when user changes the quantity of a return item * and store setting item return detail info required is not activated . */ if (!isItemReturnDetailInfoRequired && baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled().doubleValue() < 0 && bdQuantity.doubleValue() < 0 && ((baseLineItemVO.getQuantityBilled().doubleValue() != bdQuantity.doubleValue()) || isRegularToCase)) { deleteInvoiceLineItem(bdQuantity); // To set the variable with line item price decision value // after quantity change. pdAfterQtyChange = baseLineItemVO.getPriceDecision(); if(!baseLineItemVO.isSpecialFnCorSelected()){ baseLineItemVO.setCoreTransaction(Boolean.FALSE); } } } // Code added to display the old price in the unit price field, when user changes the // quantity of a purchase line item which is a case transaction to different // positive value. if(baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled().doubleValue() > 0.0 && bdQuantity.doubleValue() > 0.0 && !isRegularToCase && baseLineItemVO.isCasePrice().booleanValue()){ setPriceAttributes(false); invoiceLineEntryPanel.fldPD.setText(""); } if (baseLineItemVO.isUsedForReturn()) { if (clientApplicationContext.getMessageMgr().showMessageNoYes( invoiceLineEntryPanel, "2254")) { /** * Coded added for Return Authorization to delete associated * core line item when user changes the quantity of the * purchased part. */ PointOfSaleEventDispatcher.getInstance() .fireInvoiceAssociatedCoreLineItemDeleteInvoked( new PointOfSaleListEvent(this, invoiceVO)); baseLineItemVO.setUsedForReturn(false); // To set the variable with line item price decision value // after quantity change. pdAfterQtyChange = baseLineItemVO.getPriceDecision(); invoiceLineEntryPanel.btnSupersede .setEnabled(canEnableSupersedeButton(bdQuantity)); if (bdQuantity.doubleValue() < 0) { deleteInvoiceLineItem(bdQuantity); } } else { invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO .getQuantityBilled().toString()); if (!baseLineItemVO.isCompletedLine()) { InventoryVO inventoryVo = clientApplicationContext.getInventoryDAO() .getPartDetailInfo(customerVO, baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), false); boolean supersedesExist = clientApplicationContext.getInventoryDAO() .doSupersedesExist(inventoryVo); invoiceLineEntryPanel.btnSupersede.setEnabled(supersedesExist && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)); } else { invoiceLineEntryPanel.btnSupersede.setEnabled(false); } setListEnabled(false); setPDEnabled(false, baseLineItemVO); setTaxEnabled(false); if (isRegularToCase) { resetRegularPriceValues(); } return; } } if(InvoiceBL.useNapaGCv2() && baseLineItemVO.isNewGiftCard() && bdQuantity.signum()<0) { baseLineItemVO.setQuantityBilled(bdQuantity); SwingUtilities.invokeLater(new Runnable() { public void run() { handleGiftCardCashPayout(fwoNumberPattern); } }); return; } //when ipc is in use, don't let NAPA gift card item return go to Return Dialog... //Don't let NAPA Rewards line item return go to Return Dialog... baseLineItemVO.setQuantityBilled(bdQuantity); final String qty = quantity; if (!baseLineItemVO.isCashPayoutEligible() && !baseLineItemVO.isWarrantyLaborClaim().booleanValue() && baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue() != (byte) RefInvoiceLineItemType.ENVIRONMENTAL_CHARGE && !((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && ipcInUse()) && (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NAPA_REWARDS ) && (bdQuantity.doubleValue() < 0) || (invoiceVO.isReturnInvoice() && (bdQuantity.doubleValue() == 0))) { baseLineItemVO.setQuantityBilled(bdQuantity); SwingUtilities.invokeLater(new Runnable() { public void run() { if(invoiceVO.isReturnInvoice() && Double.parseDouble(qty) == 0 ) { skipDeletedPartReturn(baseLineItemVO, invoiceVO); }else { handleReturnDialog(isItemReturnDetailInfoRequired); if(invoiceVO.isReturnInvoice() && !invoiceVO.isReturnInvoiceLoaded()) { processNextReturnItem(invoiceVO); } } } // end of run }); // end of invoke later return; } //check gift card return here //logger.debug("__________ >>> check if the line item is gft return next ..."); if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && (bdQuantity.doubleValue() < 0)) { if (ipcInUse()) { //logger.debug("__________ >>> ipc is in use, check password ..."); final FwoNumberPattern tmpFwoNumberPattern = fwoNumberPattern; final BigDecimal tmpBdQuantity = bdQuantity; try { BigDecimal cardBal = callNAPAGiftCardBalanceInquiryDialog(); if (cardBal == null) { //reset quantityBilled is 0 baseLineItemVO.setQuantityBilled(new BigDecimal (0.0)); //allow user go back to qty field //logger.debug("__________ >>> IN GFT1 return:"); invoiceLineEntryPanel.fldQuantity.setText(""); invoiceLineEntryPanel.fldQuantity.requestFocus(); return; } invoiceLineEntryPanel.fldPrice.setText(tmpFwoNumberPattern.format(cardBal)); invoiceLineEntryPanel.fldQuantity.setText(tmpBdQuantity.toString()); if (baseLineItemVO.getUnitPrice() != null) { logger.debug("__________ >>> IN GFT1 return: baseLineItemVO.getUnitPrice() = " + baseLineItemVO.getUnitPrice()); } else { logger.debug("__________ >>> IN GFT1 return: baseLineItemVO.getUnitPrice() is NULL " ); baseLineItemVO.setUnitPrice(cardBal); } baseLineItemVO.setUnitPrice(cardBal); String pd = invoiceLineEntryPanel.fldPD.getText(); logger.debug("__________ >>> IN GFT1 return: pd = " + pd); } catch (NumberPatternFormatException npfe) { logger.error("Error occured while formatting the price" + npfe.getMessage()); } SwingUtilities.invokeLater(new Runnable() { public void run() { setListEnabled(false); setPDEnabled(false, baseLineItemVO); logger.debug("__________ >>> call checkTax() next ..."); checkTax(); invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); invoiceLineEntryPanel.fldOK.requestFocus(); } }); return; } } } isRegularToCase = false; //logger.debug("________>>> ... bdQuantity = " + bdQuantity); if (baseLineItemVO.getQuantityBilled().compareTo(bdQuantity) == 0 && bdQuantity.compareTo(new BigDecimal("0.00")) != 0) { baseLineItemVO.setQuantityBilled(bdQuantity); //This is necessary to keep focus in quantity. if (!invoiceLineEntryPanel.fldQuantity.getText().equals("")) { invoiceLineEntryPanel.fldQuantity.setText(bdQuantity.toString()); //logger.debug("________>>> the method MIDDLE late, ... WATCH OUT IF gft1 items get here ???"); } if (inventoryVO == null) { return; } // Code added for Tender Types. // Identify whether the NAPA Gift Card purchase transaction is initial sale or reload // when the business approved price range is different for sale and reload. // This is to bring in respective price validations. if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && (SELL_MAX_VALUE != RELOAD_MAX_VALUE || SELL_MIN_VALUE != RELOAD_MIN_VALUE)) { if (bdQuantity.doubleValue() > 0 && baseLineItemVO.getQuantityBilled().doubleValue() > 0 && baseLineItemVO.getReturnItems() == null) { if (!clientApplicationContext.getMessageMgr().showMessageYesNo( invoiceLineEntryPanel, "9303")) { isNapaGiftCardReload = true; } } } checkPriceChangeDueToQuantity(); if (!baseLineItemVO.isCasePrice().booleanValue()) { BigDecimal extPrice = InvoiceLineBL.getExtendedPrice(baseLineItemVO); final BigDecimal displayExtendedPrice = InvoiceLineBL.getDisplayExtendedPrice(baseLineItemVO); try { invoiceLineEntryPanel.fldUnit.setText(fwoEPNumberPattern.format( displayPriceWithTax() ? displayExtendedPrice : extPrice)); } catch (NumberPatternFormatException npfe) { // do nothing } } if (firstTimeThroughTax && !baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.fldTax.setText(""); invoiceLineEntryPanel.fldSecondaryTax.setText(""); } populateTaxDecision(); handleQuantityAnnotations(); // Code modified for Tender Types. // Disable List field for a NAPA Gift Card. if (isEqualToBigDecimalZero(invoiceLineEntryPanel.fldPrice.getText())) { setListEnabled(baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NAPA_GIFT_CARD && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD); setPDEnabled(true, baseLineItemVO); } else { final boolean allowCtrmanToOverridePrice = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?(new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getAllowCtrmanOverridePrice().booleanValue()) :( clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getAllowCtrmanOverridePrice().booleanValue()); // Code to enable PD field during following scenarios : // i) When the user selects return part that is not associated with original invoice // list. // ii)When the user selects the return part that is not associated with original // invoice and it is a case transaction with "Item Return Info Required" flag // on. // iii)When the user selects the return part which is a case transaction with // "Item Return Info Required" flag off. // iii)When the user selects the purchase line item which is a case transaction. // iv)When the user enters negative value in the quantity field and clicks on // "OK" button on the "Invoice Return Type" screen with "Item Return Info // Required" flag off and when it is a case transaction. if ((allowCtrmanToOverridePrice && (!InvoiceLineBL.isPartAssociatedWithOrigInvoiceFromList(baseLineItemVO) || baseLineItemVO.isUsedForReturn())) || (baseLineItemVO.isCompletedLine() && baseLineItemVO.isCasePrice().booleanValue() && ((baseLineItemVO.getQuantityBilled().doubleValue() < 0.0 && (isItemReturnDetailInfoRequired && !InvoiceLineBL .isPartAssociatedWithOrigInvoice(baseLineItemVO)) || !isItemReturnDetailInfoRequired) || baseLineItemVO.getQuantityBilled() .doubleValue() > 0.0)) || (!isItemReturnDetailInfoRequired && !baseLineItemVO.isCompletedLine() && baseLineItemVO.isCasePrice().booleanValue() && baseLineItemVO.getQuantityBilled().doubleValue() < 0.0)) { setListEnabled(true); setPDEnabled(true, baseLineItemVO); } // Code added for Tender Types. // Disable List field and enable PD field for NAPA Gift Card for all transactions // except if it is returned against an original invoice from same store logger.debug("__________ >>> check for gft1 next when ipc is not in use ..."); if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && baseLineItemVO.getReturnItems() == null) { if (!ipcInUse()) { logger.debug("__________ >>> IPC is not in use ..."); setListEnabled(false); setPDEnabled(true, baseLineItemVO); } } // Code modified for Tender Types. // Set focus on PD field on editing a NAPA Gift Card purchase line item. if (invoiceLineEntryPanel.fldQuantity.getText().length() > 0 && (!((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled().doubleValue() > 0.0))) { handlePD(); } } } else { if (quantity.equals("") || quantity.equals("0") || quantity.equals("0.00")) { //logger.debug("________>>> ... setting fldQuantity to 0.00 "); invoiceLineEntryPanel.fldQuantity.setText("0.00"); } invoiceLineEntryPanel.fldQuantity.selectAll(); } // Code added for Tender Types. // Set numeric document to PD field to restrict entry of fractional value or any price // sheet for NAPA Gift Card. // Added by IPC: skip gft1 returns because BA told that IPC GFT1 return doesn't limit the return value to whole number if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && (bdQuantity.doubleValue() > 0)) { //logger.debug("________>>> setting PD filed to numeric next for GFT1 ... "); invoiceLineEntryPanel.fldPD.setDocument(new DefaultDocument( invoiceLineEntryPanel.fldPD, FwiConstant.NUMERIC)); } if (baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().doubleValue() != 0.0) { String st = baseLineItemVO.getQuantityBilled().toString(); this.setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); } checkMaxInvoiceLinesReached( LineGeneratorFactory.getInstance().getLineGenerator(this).countLinesToBeGenerated(true)); //logger.debug("________>>> END OF handleQuantity "); } /** * Method to handle SPECIAL_ORDER flag. Current implementation does not set this flag * for KIT. Other than NORMAL_ITEM, parts can not be marked as special. * * @param quantity * @return */ protected BigDecimal handleSpecialOrder(final BigDecimal quantity){ StoreProfileVO storeprofileVO = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?new PhoneRoomTaapRouter().getStoreProfile(this.remoteStoreIP) :getStoreProfile(); if(!storeprofileVO.getUseNapaXpress().booleanValue()){ return quantity; } final InvoicingProfileVO invoicingProfileVO = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?new TaapRouter().getInvoicingProfile(this.remoteStoreIP) :clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile(); if(baseLineItemVO.isKitPart() && invoicingProfileVO.getAllowKitSourcingOptimization().booleanValue()) { if(baseLineItemVO.isCompletedLine()){ deleteInvoiceLineItem(quantity); setQuantityToDisplay(quantity.toString()); } return quantity; } final BigDecimal newQuantity = (invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?PhoneRoomInvoiceLineBL.splitQuantity(customerVO, invoiceVO, baseLineItemVO, inventoryVO, quantity, dcStockQuantity,this.remoteStoreIP,storeprofileVO) :InvoiceLineBL.splitQuantity(customerVO, invoiceVO, baseLineItemVO, inventoryVO, quantity, dcStockQuantity); if(baseLineItemVO.getNonAvailableQty().signum() > 0){ if(baseLineItemVO.isCompletedLine()){ deleteInvoiceLineItem(quantity); } setQuantityToDisplay(newQuantity.toString()); } return newQuantity; } private boolean validatePriceOverridePassword() { logger.debug("__________ >>> enter validatePriceOverridePassword "); Container parentView = invoiceLineEntryPanel; while (!(parentView instanceof Frame) && (parentView != null)) { parentView = parentView.getParent(); } PasswordController passwordController = new PasswordController((Frame) parentView); passwordController.setInitialData(PasswordConstants.PRICE_OVERRIDE_PASSWORD); ((JDialog) passwordController.getView()).setLocation(300,300); passwordController.setViewVisible(true); return passwordController.getPasswordValid(); } private BigDecimal callNAPAGiftCardBalanceInquiryDialog () { BigDecimal cardBal = null; if (ipcInUse()) { logger.debug("__________ >>> in ipc is in use ..."); //prompt for password for manager approval Container parentView = invoiceLineEntryPanel; while (!(parentView instanceof Frame) && (parentView != null)) { parentView = parentView.getParent(); } PasswordController passwordController = new PasswordController((Frame) parentView); passwordController.setInitialData(PasswordConstants.PRICE_OVERRIDE_PASSWORD); ((JDialog) passwordController.getView()).setLocation(300,300); passwordController.setViewVisible(true); if (passwordController.getPasswordValid()) { logger.debug("__________ >>> launch napa gift card dialog ..."); NapaGiftCardController napaGiftCardController = new NapaGiftCardController(); napaGiftCardController.launch((Dialog)passwordController.getView(), false); cardBal = napaGiftCardController.getCardBalance(); if (cardBal != null) { logger.debug("__________ >>> cardBal = "+ cardBal); } } } return cardBal; } protected BigDecimal handleDefaultQuantityOf1(BigDecimal bdQuantity) { if (!invoiceVO.isReturnInvoice() && bdQuantity != null && baseLineItemVO.getQuantityBilled() != null && bdQuantity.doubleValue() == 0.0) { // Code modified for Tender Types. // Avoid setting default quantity 1 based on system setting // "Use Default Quantity of 1". boolean useDefaultQty1; if(!invoiceVO.isPhoneRoomMessagesFlag()){ useDefaultQty1= clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()). getInvoicingProfile().getUseDefaultQtyOf1().booleanValue(); }else{ useDefaultQty1 = new TaapRouter().getInvoicingProfile(remoteStoreIP).getUseDefaultQtyOf1().booleanValue(); } if (useDefaultQty1 && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NAPA_GIFT_CARD && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) { bdQuantity = new BigDecimal("1.00"); invoiceLineEntryPanel.fldQuantity.setText("1.00"); } } return bdQuantity; } private void displayQtyExceedsStockMsg(String strQuantity, String strOnHand) { //1202 = Quantity entered ($1) exceeds stock on hand ($2). this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1202, new String[] { strQuantity, strOnHand}, false); Toolkit.getDefaultToolkit().beep(); this.setQuantityToDisplay(""); } protected void processLine5Messages(BigDecimal bdQuantity, BigDecimal qtyEligibleForSpecialOrder) { processLine5Messages(bdQuantity); if(qtyEligibleForSpecialOrder.signum() == 1){ this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1175, new String[] {qtyEligibleForSpecialOrder.toString()}, false); Toolkit.getDefaultToolkit().beep(); } else if(qtyEligibleForSpecialOrder.signum() != 1 && TsoConstant.NAPA_XPRESS.equals(baseLineItemVO.getSpecialOrder())) { this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1175, new String[] {bdQuantity.toString()}, false); Toolkit.getDefaultToolkit().beep(); } } protected void processLine5Messages(BigDecimal bdQuantity) { InvoicingProfileVO invoicingProfileVO = null; if(!invoiceVO.isPhoneRoomMessagesFlag()) { invoicingProfileVO = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile(); }else{ invoicingProfileVO = new TaapRouter().getInvoicingProfile(this.remoteStoreIP); } if (!CustomerBL.isNapaOnlineCustomer(customerVO) && bdQuantity.doubleValue() > 0) { clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); logger.debug("+++++ getDisplayInsfOnHandWarning= " + invoicingProfileVO.getDisplayInsfOnHandWarning().booleanValue()); // bug #23938 //if OnHand == 0 or doesn't exist, display Qty entered exceeds stock message. // Code modified for Tender Types. // Avoid display of Insufficient On-hand quantity message for NAPA Gift Card. if (invoicingProfileVO.getDisplayInsfOnHandWarning().booleanValue() && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NAPA_GIFT_CARD && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) { // If logged in as phone room employee, get available quantity from the // selected serving store. if (ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()) { String availableString = null; availableString = (invoiceVO.isPhoneRoomMessagesFlag() && remoteStoreIP!=null) ?InvoiceLineBL.getAvailableQuantityByStore(loc, invoiceVO, inventoryVO, customerVO,false,remoteStoreIP) :InvoiceLineBL.getAvailableQuantityByStore(loc, invoiceVO, inventoryVO, customerVO,false,null); BigDecimal availableQuantity = new BigDecimal("0.00"); try { availableQuantity = new BigDecimal(availableString); } catch (NumberFormatException nfe) { availableQuantity = new BigDecimal("0.00"); } if (bdQuantity.compareTo(availableQuantity) == 1) { displayQtyExceedsStockMsg(bdQuantity.toString(), availableString); return; } } else if ((inventoryVO != null) && (inventoryVO.getInventoryStockVO() != null)) { if (bdQuantity.compareTo(inventoryVO.getInventoryStockVO().getOnHand()) == 1) { displayQtyExceedsStockMsg(bdQuantity.toString(), inventoryVO.getInventoryStockVO().getOnHand().toString()); return; } } else { //inventoryVO or inventoryStockVO was null, so display exceeds mesg. displayQtyExceedsStockMsg(bdQuantity.toString(), "0"); return; } } if (inventoryVO != null && inventoryVO.getInventoryStockVO() != null && inventoryVO.getInventoryStockVO().getMinSaleQty() != null && inventoryVO.getInventoryStockVO().getMinSaleQty().compareTo( bdQuantity) == 1 && bdQuantity.doubleValue() > 0) { //1204 = Minimum Sale Quantity ($1) is greater than quantity entered ($2). this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1204, new String[] { inventoryVO.getInventoryStockVO().getMinSaleQty().toString(), bdQuantity.toString()}, false); Toolkit.getDefaultToolkit().beep(); this.setQuantityToDisplay(""); return; } if (MathUtil.isFraction(bdQuantity) && invoicingProfileVO.getDisplayFractionalQtyWarning().booleanValue() && checkFractionalQty()) { //1201 = The quantity entered ($1) is a fractional quantity. this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1201, new String[] {bdQuantity.toString()}, false); Toolkit.getDefaultToolkit().beep(); this.setQuantityToDisplay(""); return; } if (invoicingProfileVO.getDisplayNonStrdPkgWarning().booleanValue() && inventoryVO != null && (bdQuantity.compareTo(new BigDecimal( inventoryVO.getStandardPkg().doubleValue())) == -1) && !inventoryVO.getRefUnitDesignatorCD().equals("1")) { //1203 = Quantity entered ($1) is less than standard package ($2). this.appendToLine(InvoiceLineEntryPanel.LBL_LINE5_NAME, 1203, new String [] {bdQuantity.toString(), inventoryVO.getStandardPkg().toString()}, false); Toolkit.getDefaultToolkit().beep(); this.setQuantityToDisplay(""); } } } private boolean checkFractionalQty() { boolean retFlag = false; if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 0) { retFlag = true; } // this is a business rule from Legacy that has not been implemented in TAMSII yet. // if (part NOT next item read with a barcode) { // retFlag = true; // } return retFlag; } protected boolean isEqualToBigDecimalZero (String s) { if ((s == null) || (s.equals(""))) { return true; } BigDecimal bd = null; FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); try { bd = (BigDecimal) fwoNumberPattern.parse(s); } catch (PatternParseException ppe) { logger.debug(ppe.toString(), ppe); } if ((bd == null) || (bd.compareTo(new BigDecimal(0)) == 0)) { return true; } return false; } protected void handleQuantityAnnotations() { } protected void handleList() { final String methodSpec = "DefaultLineItemHandler.handleList() - "; String strList = invoiceLineEntryPanel.fldList.getText(); if (strList.startsWith("@")) { invoiceLineEntryPanel.fldList.setText(""); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); if (strList.trim().length() == 0) { try { invoiceLineEntryPanel.fldList.setText(fwoNumberPattern .format(displayPriceWithTax() ? baseLineItemVO.getDisplayUnitListPrice() : baseLineItemVO.getUnitListPrice())); } catch (NumberPatternFormatException npfe) { // do nothing } return; } int index = 0; int count = 0; int newIndex = 0; for (int i = 0; i < strList.length(); i++) { newIndex = strList.indexOf("-", i); if (newIndex >= 0) { if (index != newIndex || (strList.charAt(0) == '-')) { index = newIndex; count++; } } if (count > 0) { invoiceLineEntryPanel.fldList.setText(""); return; } } index = 0; count = 0; newIndex = 0; for (int i = 0; i < strList.length(); i++) { newIndex = strList.indexOf('.', i); if (newIndex >= 0) { if (index != newIndex) { index = newIndex; count++; } } if (count > 1) { invoiceLineEntryPanel.fldList.setText(""); return; } } try { listChanged = true; BigDecimal bdFormat = new BigDecimal(strList); //This could throw NumberFormatException, we need to handle it. bdFormat = bdFormat.setScale( clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP); bdFormat = new BigDecimal(fwoNumberPattern.format(bdFormat)); //this could throw NumberPatternFormatException logger.debug(methodSpec + "Display List Price = " + bdFormat); baseLineItemVO.setDisplayListPriceEntered( bdFormat.signum() > 0 ? Boolean.TRUE : Boolean.FALSE); if (displayPriceWithTax()) { BigDecimal listPrice = BD_ZERO; if (bdFormat.compareTo(new BigDecimal("0.00")) != 0) { listPrice = InvoiceLineBL.getActualPriceFromDisplayPrice(bdFormat, baseLineItemVO, invoiceVO, customerVO, inventoryVO, miscChgVO); } logger.debug(methodSpec + "List Price = " + listPrice); baseLineItemVO.setDisplayUnitListPrice(bdFormat); baseLineItemVO.setDisplayActualListPrice(bdFormat); baseLineItemVO.setUnitListPrice(listPrice); } invoiceLineEntryPanel.fldList.setText(bdFormat.toString()); } catch (NumberPatternFormatException e) { logger.debug("Error while doing fwoNumberPattern.format(bdFormat)", e); } catch (NumberFormatException e) { logger.debug("Error while doing new BigDecimal(strList)", e); } } /** If the user inputs 'Z' or 'R' in the PD field, and INVOICING_PROFILE.COST_PASSWORD (Z/R Pricing Password) has a value, * the system prompts the user to enter the password before proceeding. * Note: If gpcOwned, a password is required. */ protected boolean zrPricingPasswordValid(String remoteStoreIP) { String costPswd = null; if(!invoiceVO.isPhoneRoomMessagesFlag() && remoteStoreIP==null){ costPswd = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile().getCostPassword(); }else{ costPswd = new TaapRouter().getInvoicingProfile(remoteStoreIP).getCostPassword(); } if (costPswd == null || costPswd.trim().equals("")) { return true; } Container parentView = invoiceLineEntryPanel; while (!(parentView instanceof Frame) && (parentView != null)) { parentView = parentView.getParent(); } PasswordController passwordController = new PasswordController((Frame) parentView); passwordController.setInitialData(PasswordConstants.ZR_PRICING_PASSWORD); ((JDialog) passwordController.getView()).setLocation(300,300); passwordController.setViewVisible(true); return passwordController.getPasswordValid(); } protected boolean pricePasswordIsValid() { boolean result = false; boolean noPricingPswd = false; String priceOverPswd = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ priceOverPswd = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile().getPriceOverridePassword(); }else{ priceOverPswd = new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getPriceOverridePassword(); } String costPswd = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ costPswd = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile().getCostPassword(); }else{ costPswd = new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getCostPassword(); } if (priceOverPswd == null || priceOverPswd.trim().equals("")) { if (costPswd == null || costPswd.trim().equals("")) { return true; }else { noPricingPswd = true; } } String pd = invoiceLineEntryPanel.fldPD.getText(); if (pd.equals("") || baseLineItemVO.getPriceDecision().equals(pd) && !waitForSecondInput) { return true; } if (!waitForSecondInput) { if ((pd.equals(PDDocument.PERCENT.toString()) || pd.equals(PDDocument.R.toString()) || pd.equals(PDDocument.T.toString()) || pd.equals(PDDocument.A.toString()) || pd.equals(PDDocument.B.toString()))) { waitForSecondInput = true; if (pd.equals(PDDocument.R.toString())) { isZRPricing = true; } return true; } if (pd.equals(PDDocument.Z.toString())) { isZRPricing = true; } } if (isZRPricing){ result = zrPricingPasswordValid(this.remoteStoreIP); isZRPricing = false; }else { if (noPricingPswd) { result = true; noPricingPswd = false; }else { //prompt for password Container parentView = invoiceLineEntryPanel; while (!(parentView instanceof Frame) && (parentView != null)) { parentView = parentView.getParent(); } PasswordController passwordController = new PasswordController((Frame) parentView); passwordController.setInitialData(PasswordConstants.PRICE_OVERRIDE_PASSWORD); ((JDialog) passwordController.getView()).setLocation(300,300); if(invoiceVO.isPhoneRoomMessagesFlag()){ passwordController.setInvoicingProfileVO(new TaapRouter().getInvoicingProfile(getRemoteStoreIP())); } passwordController.setViewVisible(true); result = passwordController.getPasswordValid(); } } waitForSecondInput = false; return result; } protected void handlePD() { final String methodSpec = "DefaultLineItemHandler.handlePD() - "; String pd = invoiceLineEntryPanel.fldPD.getText(); if (pd.startsWith("@")) { invoiceLineEntryPanel.fldPD.setText(""); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); BigDecimal price = null; try { price = (BigDecimal) fwoNumberPattern.parse(invoiceLineEntryPanel.fldPrice.getText()); } catch (PatternParseException ppe) { //do nothing } price.setScale(clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP); double newPrice = 0.0; if (pd.equals("")) { if (baseLineItemVO.getUnitPrice().signum() == 0 || baseLineItemVO.isCasePrice().booleanValue()) { setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } else if (!baseLineItemVO.getPriceDecision().equals("")) { invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision()); } } else if (pd.equals(PDDocument.A.toString())) { return; } else if (!pd.equals("") && !baseLineItemVO.getPriceDecision().equals(pd)) { pdChanged = true; logger.debug("__________mfm debug : pdChanged is set to true"); } // Code modified for Tender Types. // Avoid prompt for Price override password for a NAPA Gift Card. if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NAPA_GIFT_CARD && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD && !pricePasswordIsValid()) { //prompt for password setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } try { newPrice = Double.parseDouble(pd); // Code added for Tender Types. // Validate the price, if user enters the price out of business approved price range. if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && baseLineItemVO.getQuantityBilled().doubleValue() > 0) { if (isNapaGiftCardReload && ((int) newPrice < RELOAD_MIN_VALUE || (int) newPrice > RELOAD_MAX_VALUE)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9304", getMessageParams()); invoiceLineEntryPanel.fldPD.setText(""); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } else if (!isNapaGiftCardReload && ((int) newPrice < SELL_MIN_VALUE || (int) newPrice > SELL_MAX_VALUE)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9304", getMessageParams()); invoiceLineEntryPanel.fldPD.setText(""); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } } BigDecimal bdPrice = new BigDecimal(Double.toString(newPrice)); // Price value is rounded off to next penny if the decimal value contains more // than two decimal places bdPrice = InvoiceLineBL.getRoundedValue(bdPrice); baseLineItemVO.setDisplayPriceEntered(bdPrice.signum() > 0 ? Boolean.TRUE : Boolean.FALSE); if (baseLineItemVO.isCasePrice().booleanValue()) { baseLineItemVO.setPriceDecision("C"); invoiceLineEntryPanel.fldPD.setText("C"); } else { baseLineItemVO.setPriceDecision(" "); invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision()); } if(!invoiceVO.isPhoneRoomMessagesFlag()){ if (displayPriceWithTax()) { BigDecimal unitPrice = BD_ZERO; if (bdPrice.compareTo(new BigDecimal("0.00")) != 0) { unitPrice = InvoiceLineBL.getActualPriceFromDisplayPrice(bdPrice, baseLineItemVO, invoiceVO, customerVO, inventoryVO, miscChgVO); } baseLineItemVO.setUnitPrice(unitPrice); } else { baseLineItemVO.setUnitPrice(bdPrice); } }else{ StoreProfileVO storeProfileVO = new PhoneRoomTaapRouter().getStoreProfile(remoteStoreIP); Boolean displayPriceWithTaxPhoneRoom = storeProfileVO.getIncludeTaxInPrice()!=null?storeProfileVO.getIncludeTaxInPrice().booleanValue():false; if (displayPriceWithTaxPhoneRoom) { BigDecimal unitPrice = BD_ZERO; if (bdPrice.compareTo(new BigDecimal("0.00")) != 0) { unitPrice = PhoneRoomInvoiceLineBL.getActualPriceFromDisplayPrice(bdPrice, baseLineItemVO, invoiceVO, customerVO, inventoryVO, miscChgVO,remoteStoreIP,true); } baseLineItemVO.setUnitPrice(unitPrice); } else { baseLineItemVO.setUnitPrice(bdPrice); } } baseLineItemVO.setDisplayUnitPrice(bdPrice); logger.debug(methodSpec + "Display Price = " + bdPrice + ", Unit Price = " + baseLineItemVO.getUnitPrice()); updatePriceOverride(baseLineItemVO.getUnitPrice()); } catch (NumberFormatException nfe) { if (pd.length() == 1) { if ((pd.equals(PDDocument.PERCENT.toString()) || pd.equals(PDDocument.R.toString()) || pd.equals(PDDocument.T.toString()) || pd.equals(PDDocument.A.toString()) || pd.equals(PDDocument.B.toString()))) { if (invoiceLineEntryPanel.fldPD.hasFocus()) { displayPercentField(true); return; } } BigDecimal bdLandedPrice = new BigDecimal("0.00"); boolean useConversionFactor = CURRENCY_CONVERSION_FACTOR > 0.0000; boolean unitPriceChanged = false; if(baseLineItemVO.getUnitPrice() != null && !invoiceVO.isValidQuote()) { switch (pd.charAt(0)) { case 'L': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getList(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getList(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getList())); } unitPriceChanged = true; break; case 'G': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getRed(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getRed(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getRed())); } unitPriceChanged = true; break; case 'Y': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getYellow(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getYellow(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getYellow())); } unitPriceChanged = true; break; case 'N': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getGreen(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getGreen(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getGreen())); } unitPriceChanged = true; break; case 'P': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getPink(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getPink(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getPink())); } unitPriceChanged = true; break; case 'M': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getMasterInstaller(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getMasterInstaller(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice(InvoiceLineBL .getRoundedValue(inventoryVO.getMasterInstaller())); } unitPriceChanged = true; break; case 'J': if (useConversionFactor) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getBlue(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getBlue(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getBlue())); } unitPriceChanged = true; break; case 'Z': if (useConversionFactor) { if(baseLineItemVO != null && baseLineItemVO.isKitPart() && inventoryVO instanceof KitInventoryVO){ if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getKitPriceWithLandedFactor( inventoryVO, RefPriceSheet.COST, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getKitPriceWithLandedFactor( inventoryVO, RefPriceSheet.COST, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } } else { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getCost(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getCost(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getCost())); } unitPriceChanged = true; break; case 'V': if (useConversionFactor) { if (baseLineItemVO != null && baseLineItemVO.isKitPart() && inventoryVO instanceof KitInventoryVO) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getKitPriceWithLandedFactor( inventoryVO, RefPriceSheet.AVERAGE_COST, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getKitPriceWithLandedFactor( inventoryVO, RefPriceSheet.AVERAGE_COST, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } } else { if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdLandedPrice = InvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getAverageCost(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE); }else{ bdLandedPrice = PhoneRoomInvoiceLineBL.getPriceWithLandedFactor(inventoryVO .getAverageCost(), ZERO_MARKUP_PERCENT, pd, inventoryVO, LANDED_PRICE_FACTOR_TYPE,remoteStoreIP); } } bdLandedPrice = InvoiceLineBL.getRoundedValue(bdLandedPrice); baseLineItemVO.setUnitPrice(bdLandedPrice); } else { baseLineItemVO.setUnitPrice( InvoiceLineBL.getRoundedValue(inventoryVO.getAverageCost())); } unitPriceChanged = true; break; case '*': /*for '*' we don't call getPriceWithLandedFactor because getPrices will have already * correctly converted the price with LandedFactors figured in. (PPII)*/ baseLineItemVO.setUnitPrice(prices.getCustomPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayCustomPrice()); unitPriceChanged = true; break; case 'U': /*for '*' we don't call getPriceWithLandedFactor because getPrices will have already * correctly converted the price with LandedFactors figured in. (PPII) */ baseLineItemVO.setUnitPrice(prices.getUsualPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayUsualPrice()); unitPriceChanged = true; break; case '!': if (prices.getSpecialPrice().doubleValue() > 0) { baseLineItemVO.setUnitPrice(prices.getSpecialPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplaySpecialPrice()); } else { setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); invoiceLineEntryPanel.fldPD.setText(""); return; } unitPriceChanged = true; break; case 'S': if(!invoiceVO.isPhoneRoomMessagesFlag()){ baseLineItemVO.setUnitPrice(InvoiceLineBL.getRoundedValue( clientApplicationContext.getInventoryDAO(). getLowSuggestedPrice(inventoryVO))); }else{ baseLineItemVO.setUnitPrice(InvoiceLineBL.getRoundedValue( new PhoneRoomTaapRouter().getLowSuggestedPrice(getRemoteStoreIP(),inventoryVO))); } unitPriceChanged = true; break; } } baseLineItemVO.setPriceDecision(pd); if (inventoryVO == null) { return; } BigDecimal minForDiscount = inventoryVO.getInvQtyMinForDiscount(); if (minForDiscount == null) { minForDiscount = new BigDecimal("0.00"); } BigDecimal qty = baseLineItemVO.getQuantityBilled(); if (qty == null) { qty = new BigDecimal("1.00"); } if ("U*".indexOf(baseLineItemVO.getPriceDecision()) >= 0 && Math.abs(qty.doubleValue()) >= minForDiscount.doubleValue() && InvoiceLineBL.checkForQuantityDiscount(inventoryVO, customerVO, prices)) { baseLineItemVO.setUnitPrice(prices.getUnitPrice()); baseLineItemVO.setDisplayUnitPrice(prices.getDisplayUnitPrice()); unitPriceChanged = true; } if (unitPriceChanged) { if(!invoiceVO.isPhoneRoomMessagesFlag()){ InvoiceLineBL.setDisplayPriceFromUnitPrice(baseLineItemVO.getUnitPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO); }else{ PhoneRoomInvoiceLineBL.setDisplayPriceFromUnitPrice(baseLineItemVO.getUnitPrice(), baseLineItemVO, invoiceVO, customerVO, inventoryVO,remoteStoreIP); } logger.warn(methodSpec + "Price Decision = " + pd); logger.warn(methodSpec + "Unit Price = " + baseLineItemVO.getUnitPrice() + " Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice()); } updatePriceOverride(baseLineItemVO.getUnitPrice()); baseLineItemVO.setDisplayPriceEntered(Boolean.FALSE); } } if (prices != null) { baseLineItemVO.setOriginalUnitPrice(prices.getUnitPrice()); baseLineItemVO.setUnitSaved(prices.getUnitSaved()); } // If line item price value is zero & Invoicing Profile - 'Item Price Value Required' flag // is ON then display a warning message - 'Please enter a value greater than 0.00' final Integer refElectronicInvoiceVendorId = (!invoiceVO.isPhoneRoomMessagesFlag())?(clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getRefElectronicInvoiceVendorId()):(new TaapRouter().getInvoicingProfile(remoteStoreIP).getRefElectronicInvoiceVendorId()); final boolean itemPriceValueRequired = (!invoiceVO.isPhoneRoomMessagesFlag())?(clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getItemPriceValueRequired().booleanValue()):(new TaapRouter().getInvoicingProfile(remoteStoreIP).getItemPriceValueRequired().booleanValue()); if (refElectronicInvoiceVendorId != null && refElectronicInvoiceVendorId.intValue() == 1 && itemPriceValueRequired && baseLineItemVO.getUnitPrice().doubleValue() == 0) { SwingUtilities.invokeLater(new Runnable() { public void run() { messageManager.showMessage(invoiceLineEntryPanel, "10113"); } }); return; } afterPriceUpdate(); /* if the pdField has been changed and the price is less than cost, user must be warned. */ if (pdChanged) { baseLineItemVO.setUnitSaved(BD_ZERO); applyCorrectLineItemCost(customerVO, baseLineItemVO, inventoryVO); BigDecimal custMaxDiscountPct = customerVO.getMaxDiscountPct(); InvoicingProfileVO invoicingProfileVO = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ invoicingProfileVO = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile(); }else{ invoicingProfileVO = new TaapRouter().getInvoicingProfile(remoteStoreIP); } BigDecimal invMaxPriceDiscountPct = invoicingProfileVO.getMaxPriceDiscountPct(); BigDecimal updatedPrice = baseLineItemVO.getUnitPrice(); BigDecimal originalUnitPrice = baseLineItemVO.getOriginalUnitPrice(); StoreProfileVO storeProfileVO = getStoreProfile(); String priceOverPswd = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ priceOverPswd = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getInvoicingProfile().getPriceOverridePassword(); } else { priceOverPswd = new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getPriceOverridePassword(); } if((priceOverPswd == null || priceOverPswd.trim().equals("")) && (storeProfileVO.getManageGpAtPos().booleanValue()) && (updatedPrice.compareTo(originalUnitPrice) < 0)) { BigDecimal percentDiscount = ((originalUnitPrice.subtract(updatedPrice)) .divide(originalUnitPrice, 4 , RoundingMode.HALF_UP)).multiply(new BigDecimal(100)); if(((custMaxDiscountPct.compareTo(BigDecimal.ZERO) > 0 && percentDiscount.compareTo(custMaxDiscountPct) >= 0) || (invMaxPriceDiscountPct.compareTo(BigDecimal.ZERO) > 0 && percentDiscount.compareTo(invMaxPriceDiscountPct) >= 0) || (custMaxDiscountPct.compareTo(BigDecimal.ZERO) == 0 && invMaxPriceDiscountPct.compareTo(BigDecimal.ZERO) == 0 && percentDiscount.compareTo(invMaxPriceDiscountPct) >= 0)) && !askManagerPassword()) { try { String strUnitPrice = fwoNumberPattern.format(baseLineItemVO.getOriginalUnitPrice()); invoiceLineEntryPanel.fldPrice.setText(strUnitPrice); baseLineItemVO.setUnitPrice(baseLineItemVO.getOriginalUnitPrice()); String strUnitCost = fwoNumberPattern.format(baseLineItemVO.getOriginalUnitPrice() .multiply(baseLineItemVO.getQuantityBilled())); invoiceLineEntryPanel.fldUnit.setText(fwoNumberPattern.format(strUnitCost)); } catch (NumberPatternFormatException npfe) { logger.error("Error occurred while formatting the price" + npfe.getMessage()); } } } if (baseLineItemVO.getUnitPrice().compareTo(baseLineItemVO.getUnitCost()) < 0) { SwingUtilities.invokeLater(new Runnable() { public void run() { messageManager.showMessage(invoiceLineEntryPanel, "1366"); } }); } } } private boolean askManagerPassword() { //prompt for password Container parentView = invoiceLineEntryPanel; while (!(parentView instanceof Frame) && (parentView != null)) { parentView = parentView.getParent(); } ManagerPasswordController managerPasswordController = new ManagerPasswordController((Frame) parentView); managerPasswordController.setInitialData(PasswordConstants.SYSTEM_MANAGER_PWD); ((JDialog) managerPasswordController.getView()).setLocation(300,300); managerPasswordController.setViewVisible(true); return managerPasswordController.getPasswordValid(); } /** * Applies cost to the invoice line item with some special rules * * @param customer * @param invoiceLineItem * @param inventoryPart */ private void applyCorrectLineItemCost(CustomerVO customer, BaseLineItemVO invoiceLineItem, InventoryVO inventoryPart) { if (baseLineItemVO.getWarrantyItem().booleanValue() == true) { invoiceLineItem.setUnitCost(invoiceLineItem.getUnitPrice()); } else if (CustomerBL.isTransferCustomer(customer)) { invoiceLineItem.setUnitCost(BD_ZERO); } else if (invoiceLineItem.getPriceDecision().equals("!")) { invoiceLineItem.setUnitCost(prices.getSpecialCost()); } else { StoreProfileVO storeProfile = getStoreProfile(); // If the currency conversion factor value is non zero and if the line item is not a // warranty labor claim get the unit cost value from getPrice() functionality if (storeProfile != null && storeProfile.getCurrencyConversionFactor() != null && storeProfile.getCurrencyConversionFactor().doubleValue() > 0 && invoiceLineItem != null && !invoiceLineItem.isWarrantyLaborClaim().booleanValue() && prices != null) { BigDecimal unitCost = BD_ZERO; if (invoiceLineItem.isKitPart() && invoiceLineItem.getGeneratedByLineItem() == null && inventoryVO instanceof KitInventoryVO && customerVO != null) { // Gets the kit part unit cost as the sum of the cost of components // associated with a kit part by calling getPrice() functionality on each // component. unitCost = InvoiceLineBL.getKitPartCost(inventoryVO, customerVO); } else { unitCost = prices.getUnitCost(); } invoiceLineItem.setUnitCost(unitCost); } else { if (inventoryPart != null) { if (storeProfile.getUseAvgCost().booleanValue() == true && inventoryPart.getAverageCost().compareTo(BD_ZERO) > 0) { invoiceLineItem.setUnitCost(inventoryPart.getAverageCost()); } else { invoiceLineItem.setUnitCost(inventoryPart.getCost()); } } } } } protected void updatePriceOverride(BigDecimal bdPrice) { if (!baseLineItemVO.isPolicyAdjustment().booleanValue()) { //check for price override if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 0) || (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 1)) { logger.debug("checking for priceoverride"); if (prices.getUnitPrice().compareTo(bdPrice) == 0 || prices.getUnitPrice().doubleValue() == 0) { baseLineItemVO.setPriceOverrideEmployeeID(null); } else { logger.debug("setting PriceOverrideEmployeeID= " + clientApplicationContext.getCurrentUser().getEmployeeId()); baseLineItemVO.setPriceOverrideEmployeeID(clientApplicationContext. getCurrentUser().getEmployeeId()); } } } } protected void handlePercent() { FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); double newPrice = 0.0; BigDecimal price = null; try { price = (BigDecimal) fwoNumberPattern.parse(invoiceLineEntryPanel.fldPrice.getText()); } catch (PatternParseException ppe) { //do nothing } price.setScale(clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP); try { newPrice = Double.parseDouble(invoiceLineEntryPanel.fldPercent.getText()); if (waitForSecondInput) { if (!pricePasswordIsValid()) { //prompt for password setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); baseLineItemVO.setPriceDecision(prices.getPriceDecision()); return; } } String priceDecision = invoiceLineEntryPanel.fldPD.getText(); if (invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.PERCENT.toString())) { newPrice = InvoiceLineBL.getMarkup(newPrice, price.doubleValue()); } else if (priceDecision.equals(PDDocument.R.toString())) { BigDecimal cost = inventoryVO.getCost(); if (CURRENCY_CONVERSION_FACTOR > 0) { if (baseLineItemVO != null && baseLineItemVO.isKitPart() && inventoryVO instanceof KitInventoryVO) { cost = InvoiceLineBL.getKitPriceWithLandedFactor(inventoryVO, RefPriceSheet .DESIRED_GROSS_PROFIT_BASED_ON_REPLACEMENT_INVENTORY_COST, LANDED_PRICE_FACTOR_TYPE); } else { cost = InvoiceLineBL.getPriceWithLandedFactor(cost, ZERO_MARKUP_PERCENT, priceDecision, inventoryVO, LANDED_PRICE_FACTOR_TYPE); } } if (cost != null) { newPrice = InvoiceLineBL.getDesiredGrossProfit(newPrice, cost.doubleValue()); } } else if (priceDecision.equals(PDDocument.T.toString())) { BigDecimal averageCost = inventoryVO.getAverageCost(); if (CURRENCY_CONVERSION_FACTOR > 0) { if (baseLineItemVO != null && baseLineItemVO.isKitPart() && inventoryVO instanceof KitInventoryVO) { averageCost = InvoiceLineBL.getKitPriceWithLandedFactor(inventoryVO, RefPriceSheet.DESIRED_GROSS_PROFIT_BASED_ON_AVERAGE_INVENTORY_COST, LANDED_PRICE_FACTOR_TYPE); } else { averageCost = InvoiceLineBL.getPriceWithLandedFactor(averageCost, ZERO_MARKUP_PERCENT, priceDecision, inventoryVO, LANDED_PRICE_FACTOR_TYPE); } } if (averageCost != null) { newPrice = InvoiceLineBL.getDesiredGrossProfit(newPrice, averageCost .doubleValue()); } } else if (invoiceLineEntryPanel.fldPD.getText().equals(PDDocument.B.toString())) { } else { invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision()); //bug # 4852 return; } BigDecimal bdPrice = new BigDecimal(newPrice); bdPrice = InvoiceLineBL.getRoundedValue(bdPrice); //do not set the unit price if there are return items. if (baseLineItemVO.getReturnItems() == null) { if(displayPriceWithTax()){ InvoiceLineBL.setDisplayPriceFromUnitPrice(bdPrice, baseLineItemVO, null, customerVO, inventoryVO); } baseLineItemVO.setUnitPrice(bdPrice); } updatePriceOverride(bdPrice); afterPriceUpdate(); } catch (NumberFormatException nfe) { //do nothing } } protected void afterPriceUpdate() { logger.debug("inside afterPriceUpdate"); FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); baseLineItemVO.setSpecialSale( baseLineItemVO.getPriceDecision().equals("!") ? Boolean.TRUE : Boolean.FALSE); double newPrice = 0.0; try { newPrice = Double.parseDouble(invoiceLineEntryPanel.fldList.getText()); } catch (StringIndexOutOfBoundsException e) { //do nothing } catch (NumberFormatException nfe) { //do nothing } BigDecimal userListPrice = new BigDecimal(newPrice); userListPrice = userListPrice.setScale( clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP); boolean displayPriceWithTax = (!invoiceVO.isPhoneRoomMessagesFlag())?displayPriceWithTax():includePriceWithTaxPhoneRoom(); if (!baseLineItemVO.isPolicyAdjustment().booleanValue()) { if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 0) || (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == 1)) { BigDecimal bdList = BD_ZERO; try { bdList = new BigDecimal(invoiceLineEntryPanel.fldList.getText()); } catch (StringIndexOutOfBoundsException e) { //do nothing } catch (NumberFormatException nfe) { //do nothing } if (bdList.signum() == 0) { logger.debug("fldList=zero. use actualListPrice= " + baseLineItemVO.getActualListPrice()); //List field is zero, so get the actual list price to compare too userListPrice = baseLineItemVO.getActualListPrice(); } try { if (baseLineItemVO.getWarrantyItem().booleanValue() == true){ baseLineItemVO.setUnitListPrice(baseLineItemVO.getUnitPrice()); baseLineItemVO.setDisplayUnitListPrice(baseLineItemVO.getDisplayUnitPrice()); invoiceLineEntryPanel.fldList.setText(fwoNumberPattern.format( displayPriceWithTax ? baseLineItemVO.getDisplayUnitListPrice() : baseLineItemVO.getUnitListPrice())); } else { userListPrice = displayPriceWithTax ? baseLineItemVO.getUnitListPrice() : userListPrice; logger.debug("DefaultLineItemHandler.afterPriceUpdate() - checkListPrice - userListPrice = " + userListPrice); if (InvoiceLineBL.checkListPrice(baseLineItemVO, userListPrice)) { invoiceLineEntryPanel.fldList.setText(fwoNumberPattern.format(new BigDecimal(0).setScale( clientApplicationContext.getSystemDAO().getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP)).toString()); } else { invoiceLineEntryPanel.fldList.setText(fwoNumberPattern.format( displayPriceWithTax ? baseLineItemVO.getDisplayUnitListPrice() : baseLineItemVO.getActualListPrice())); } } } catch (NumberPatternFormatException npfe) { //do nothing } BigDecimal lowSuggested = (!invoiceVO.isPhoneRoomMessagesFlag())? clientApplicationContext.getInventoryDAO().getLowSuggestedPrice( inventoryVO):new PhoneRoomTaapRouter().getLowSuggestedPrice(remoteStoreIP,inventoryVO); if (InvoiceBL.compareLowSuggested(lowSuggested, baseLineItemVO)) { String strSuggest = lowSuggested.toString(); if (hideLowSuggPriceLbl) { clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); }else { clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); //1208 = 1,N,Low Suggested Price $1 if(displayPriceWithTax){ String taxLabel = messageManager.getMessage(String.valueOf(9951), new String[]{}).getText(); strSuggest = strSuggest.concat(" + ").concat(taxLabel); } appendToLine(InvoiceLineEntryPanel.LBL_LINE3_NAME, 1208, new String [] {strSuggest}, false); Toolkit.getDefaultToolkit().beep(); } } else { //reset the note line to clear any previous low suggest note. clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); } } } enableAndSetAfterPD(); } protected boolean okToCallGetPrice(String part, String line) { /*There are intermittent bugs happening in stores when calling get price with * an empty part number or empty line abbrev. Even though I cannot repeat the * errors, I am going to do a check and send focus back to part number if the * part or the line abbrev is empty. */ if (part == null || line == null || part.trim().length() < 1 || line.trim().length() < 1) { return false; } return true; } protected void checkPriceChangeDueToQuantity() { if (baseLineItemVO.isCasePrice().booleanValue()) { return; } if ((baseLineItemVO != null) && (baseLineItemVO.getRefInvoiceLineItemTypeID() != null)) { switch (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue()) { case RefInvoiceLineItemType.DELIVERY_CHARGE: case RefInvoiceLineItemType.FREIGHT: case RefInvoiceLineItemType.BAGFEE: case RefInvoiceLineItemType.SERVICE_CHARGE: case RefInvoiceLineItemType.MISCELLANEOUS: case RefInvoiceLineItemType.OTHER: case RefInvoiceLineItemType.TELEPHONE: case RefInvoiceLineItemType.COLORADO_DELIVERY_FEE: return; } } String part = FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText().trim(), new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); if (!okToCallGetPrice(part, invoiceLineEntryPanel.slfLine.getText())) { return; } PricesOutVO newPrices = null; logger.debug("DefaultLineItemHandler.checkPriceChangeDueToQuantity - callGetPrice "); if(!invoiceVO.isPhoneRoomMessagesFlag()){ newPrices = InvoiceLineBL.getPrices(customerVO.getID(), customerVO.getCustomerTypeCD(), part, invoiceLineEntryPanel.slfLine.getText(), baseLineItemVO.getQuantityBilled()); }else{ newPrices = PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO, customerVO.getCustomerTypeCD(), part, invoiceLineEntryPanel.slfLine.getText(), baseLineItemVO.getQuantityBilled(), this.remoteStoreIP,null); } boolean isPriceUpdateRequired = false; if (newPrices != null) { if (!newPrices.equals(prices)) { prices = newPrices; isPriceUpdateRequired = true; } else if (pdAfterQtyChange != null && baseLineItemVO != null && !baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled().doubleValue() > 0.0 && !baseLineItemVO.getPriceDecision().equals(newPrices.getPriceDecision()) && !pdAfterQtyChange.equals(newPrices.getPriceDecision())) { // Code to set the price to inventory price, when user changes the // quantity of a line item to different negative value and clicks on the // cancel button on the "Invoice Return Type" screen and changes the quantity // to a positive value. pdAfterQtyChange = newPrices.getPriceDecision(); isPriceUpdateRequired = true; } if (isPriceUpdateRequired) { setPriceAttributes(false); } } } protected void enableAndSetAfterPD() { final String methodSpec = "DefaultLineItemHandler.enableAndSetAfterPD() - "; FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); FwoNumberPattern fwoEPNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoEPNumberPattern.setMinFractionDigits(2); fwoEPNumberPattern.setMaxFractionDigits(2); boolean allowCounterManToOverRidePrice = true; if(!invoiceVO.isPhoneRoomMessagesFlag()){ allowCounterManToOverRidePrice = clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getAllowCtrmanOverridePrice().booleanValue(); }else{ allowCounterManToOverRidePrice = new TaapRouter().getInvoicingProfile(getRemoteStoreIP()).getAllowCtrmanOverridePrice().booleanValue(); } boolean displayPriceWithTax = (!invoiceVO.isPhoneRoomMessagesFlag())?displayPriceWithTax():includePriceWithTaxPhoneRoom(); if (!baseLineItemVO.getPriceDecision().equals("") || !allowCounterManToOverRidePrice || baseLineItemVO.getReturnItems() != null || InvoiceBL.isMainCounter() && InvoiceBL.doesInvoiceContainNOLBOPISOrder(invoiceVO)) { try { final BigDecimal unitPrice = displayPriceWithTax ? baseLineItemVO.getDisplayUnitPrice() : baseLineItemVO.getUnitPrice(); invoiceLineEntryPanel.fldPrice.setText(fwoNumberPattern.format(unitPrice)); if (baseLineItemVO.isCasePrice().booleanValue()) { invoiceLineEntryPanel.fldUnit.setText(fwoEPNumberPattern .format(unitPrice.setScale(2, BigDecimal.ROUND_HALF_UP))); } else { BigDecimal unitCost =null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ unitCost = displayPriceWithTax ? InvoiceLineBL.getDisplayExtendedPrice(baseLineItemVO) : InvoiceLineBL.getExtendedPrice(baseLineItemVO); }else{ unitCost = displayPriceWithTax ? PhoneRoomInvoiceLineBL.getDisplayExtendedPrice(baseLineItemVO,remoteStoreIP) : PhoneRoomInvoiceLineBL.getExtendedPrice(baseLineItemVO,remoteStoreIP,null); } logger.debug(methodSpec + "Unit Cost = " + unitCost); invoiceLineEntryPanel.fldUnit.setText(fwoEPNumberPattern.format(unitCost)); } } catch (NumberPatternFormatException npfe) { //do nothing } // Added for RADS - Main Counter Project // If line item is picked by RADS disables the DC textfield and // set the RefInvoiceLineItemTypeID for the DC Item if (baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null && InvoiceBL.isKitPartPickedByRads(invoiceVO, baseLineItemVO)) { setDCEnabled(false); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); invoiceLineEntryPanel.fldDC.setText("N"); baseLineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType( baseLineItemVO, this.customerVO, false)); checkTax(); } else if (baseLineItemVO.getPickedByRads() != null && baseLineItemVO.getPickedByRads().booleanValue()) { setDCEnabled(false); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); baseLineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType( baseLineItemVO, this.customerVO, invoiceLineEntryPanel.fldDC.getText() .equals("Y"))); checkTax(); } // ===================================== else if ((!invoiceVO.isPhoneRoomMessagesFlag())?(InvoiceLineBL.checkDC(customerVO, baseLineItemVO, false, inventoryVO)) :PhoneRoomInvoiceLineBL.checkDC(customerVO, baseLineItemVO, false, inventoryVO,remoteStoreIP)) { setDCEnabled(true); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); } else { checkTax(); } } } protected void handlePrice() { } protected void handleUnit() { } protected void handleDC() { if(taxDecision == null){ populateTaxDecision(); } baseLineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType( baseLineItemVO, this.customerVO, invoiceLineEntryPanel.fldDC.getText().equals("Y"))); checkTax(); } protected void checkTax() { if(taxDecision == null){ populateTaxDecision(); } // moved from enableAndSetAfterPD() method if (CustomerBL.isTransferCustomer(customerVO)) { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_NO); if(baseLineItemVO.getDisplayTaxable2()){ invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_NO); } setSecondaryTaxEnabled(false); invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); return; } if(baseLineItemVO.isCompletedLine() && baseLineItemVO.isPickupItem().booleanValue()){ setTaxEnabled(true); setSecondaryTaxEnabled(false); setOKEnabled(false); return; } if (firstTimeThroughTax) { String strTax = invoiceLineEntryPanel.fldTax.getText(); if ((strTax == null) || (strTax.equals(""))) { String strTaxDecision = ""; if (taxDecision != null) { strTaxDecision = taxDecision.getPrimaryTax(); } if (!strTaxDecision.equals(Tax.OPTIONAL)) { if (strTaxDecision.equals(Tax.ALWAYS)) { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_YES); if (baseLineItemVO.isPickupItem().booleanValue() && customerVO.getTaxStatusPrimaryRefOptionCD().equals(Tax.OPTIONAL)) { setTaxEnabled(true); handleTax(); return; } } else { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_NO); } if (canEnablePrimaryTax(customerVO,baseLineItemVO)) { setTaxEnabled(true); handleTax(); } else { handleTax(); } handlePPSECartCoreItemTax(); return; } else { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_YES); } } if (taxDecision.getPrimaryTax().equals(Tax.OPTIONAL)) { setTaxEnabled(true); } else { if (canEnablePrimaryTax(customerVO,baseLineItemVO) || (baseLineItemVO.isPickupItem().booleanValue() && customerVO.getTaxStatusPrimaryRefOptionCD().equals(Tax.OPTIONAL))) { setTaxEnabled(true); } handleTax(); } } else { handlePPSECartCoreItemTax(); //else enable first tax, disable second tax and OK if (taxDecision.getPrimaryTax().equals(Tax.OPTIONAL) || canEnablePrimaryTax(customerVO,baseLineItemVO)){ setTaxEnabled(true); if(!taxDecision.getPrimaryTax().equals(Tax.OPTIONAL) && canEnablePrimaryTax(customerVO,baseLineItemVO)){ handleTax(); } else { setSecondaryTaxEnabled(false); setOKEnabled(false); } } } } private void handlePPSECartCoreItemTax() { if (!baseLineItemVO.isCompletedLine() && baseLineItemVO.isPartAddedFromPPSE2() && (baseLineItemVO.isCoreTransaction() != null && baseLineItemVO.isCoreTransaction().booleanValue())) { String primaryTaxDecision = ""; String secondaryTaxDecision = ""; if (taxDecision != null) { primaryTaxDecision = taxDecision.getPrimaryTax(); secondaryTaxDecision = taxDecision.getSecondaryTax(); } if (primaryTaxDecision != null && !primaryTaxDecision.equals(Tax.OPTIONAL)) { if (primaryTaxDecision.equals(Tax.ALWAYS)) { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_YES); } else { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_NO); } } if (secondaryTaxDecision != null && !secondaryTaxDecision.equals(Tax.OPTIONAL)) { if (secondaryTaxDecision.equals(Tax.ALWAYS)) { invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_YES); } else { invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_NO); } } if ((primaryTaxDecision != null && !primaryTaxDecision.equals(Tax.OPTIONAL)) || (secondaryTaxDecision != null && !secondaryTaxDecision.equals(Tax.OPTIONAL))) { invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldQuantity.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldQuantity, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); invoiceLineEntryPanel.fldQuantity.setEnabled(false); } }); } } } protected void populateTaxDecision() { //for STEL -904 added Phone room flag check to fetch data from remote store incase if called from phone room if(!invoiceVO.isPhoneRoomMessagesFlag()){ if ((invoiceVO.getSecondaryTaxTableVO() == null && CommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO) && invoiceVO.getSavedInvoiceIdForDeletion() == null) || customerVO.getPrimaryTaxTable().getID() == invoiceVO.getPrimaryTaxTableID()) { taxDecision = Tax.getTaxDecision(customerVO, inventoryVO, miscChgVO, baseLineItemVO, invoiceVO.getPrimaryTaxTableVO(), (clientApplicationContext.getSystemDAO() .getTaxTable(loc, (clientApplicationContext.getSystemDAO().getTaxTable( loc, customerVO.getDeliveredTaxTableID())) .getSecondaryTaxTableID())), Profile.POINT_OF_SALE_CLIENT); logger.debug("__________ >>> IN populateTaxDecision if: taxDecision = " + taxDecision); } else { taxDecision = Tax.getTaxDecision(customerVO, inventoryVO, miscChgVO, baseLineItemVO, invoiceVO.getPrimaryTaxTableVO(), invoiceVO.getSecondaryTaxTableVO(), Profile.POINT_OF_SALE_CLIENT); logger.debug("__________ >>> IN populateTaxDecision else: taxDecision = " + taxDecision); } }else{ PhoneRoomTaapRouter phoneRoomTaapRouter = new PhoneRoomTaapRouter(); StoreProfileVO storeProfileVO = phoneRoomTaapRouter.getStoreProfile(this.remoteStoreIP); if ((invoiceVO.getSecondaryTaxTableVO() == null && PhoneRoomCommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO,remoteStoreIP) && invoiceVO.getSavedInvoiceIdForDeletion() == null) || (customerVO.getPrimaryTaxTable().getID() == invoiceVO.getPrimaryTaxTableID() && customerVO.getDeliveredTaxTableID()!=null)) { taxDecision = PhoneRoomTax.getTaxDecision(customerVO, inventoryVO, miscChgVO, baseLineItemVO, invoiceVO.getPrimaryTaxTableVO(), (phoneRoomTaapRouter .getTaxTable(loc, (phoneRoomTaapRouter.getTaxTable( loc, customerVO.getDeliveredTaxTableID(),remoteStoreIP)) .getSecondaryTaxTableID(),remoteStoreIP)), Profile.POINT_OF_SALE_CLIENT,remoteStoreIP,storeProfileVO.getRefLanguageCd()); logger.debug("__________ >>> IN populateTaxDecision if: taxDecision = " + taxDecision); } else { taxDecision = PhoneRoomTax.getTaxDecision(customerVO, inventoryVO, miscChgVO, baseLineItemVO, invoiceVO.getPrimaryTaxTableVO(), invoiceVO.getSecondaryTaxTableVO(), Profile.POINT_OF_SALE_CLIENT,remoteStoreIP,storeProfileVO.getRefLanguageCd()); logger.debug("__________ >>> IN populateTaxDecision else: taxDecision = " + taxDecision); } } } protected void handleTax() { if (CustomerBL.isTransferCustomer(customerVO)) { invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_NO); baseLineItemVO.setTaxable1(new Boolean(false)); setSecondaryTaxEnabled(false); baseLineItemVO.setTaxable2(new Boolean(false)); invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); return; } if (baseLineItemVO.isCompletedLine() && baseLineItemVO.isPickupItem().booleanValue() && baseLineItemVO.getDisplayTaxable2()) { setSecondaryTaxEnabled(true); setOKEnabled(false); return; } if(taxDecision == null){ populateTaxDecision(); } // baseLineItemVO.setTaxable1(BooleanParser.parseBoolean(Tax.TAXABLE_YES, Tax.TAXABLE_NO, invoiceLineEntryPanel.fldTax.getText())); if(!firstTimeThroughTax && baseLineItemVO.getQuantityBilled().doubleValue() > 0){ baseLineItemVO.setTaxable1(new Boolean(BooleanParser.parseYN(invoiceLineEntryPanel.fldTax.getText()))); } if (invoiceLineEntryPanel.fldTax.getText().equals("")) { setSecondaryTaxEnabled(false); setOKEnabled(false); return; } if (baseLineItemVO.getDisplayTaxable2()) { String strTax = invoiceLineEntryPanel.fldSecondaryTax.getText(); if ((strTax == null) || (strTax.equals(""))) { String strTaxDecision = ""; if (taxDecision != null) { strTaxDecision = taxDecision.getSecondaryTax(); } if (!strTaxDecision.equals(Tax.OPTIONAL)) { if (strTaxDecision.equals(Tax.ALWAYS)) { invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_YES); if (baseLineItemVO.isPickupItem().booleanValue() && customerVO.getTaxStatusSecondaryRefOptionCD().equals(Tax.OPTIONAL)) { setSecondaryTaxEnabled(true); invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); } else { setSecondaryTaxEnabled(false); } } else { invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_NO); setSecondaryTaxEnabled(false); } if (canEnableSecondaryTax(customerVO,baseLineItemVO)) { setSecondaryTaxEnabled(true); invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); } else { handleSecondaryTax(); } return; } else { invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_YES); setSecondaryTaxEnabled(true); } setSecondaryTaxEnabled(true); } else { if (taxDecision.getSecondaryTax().equals(Tax.OPTIONAL)) { setSecondaryTaxEnabled(true); setOKEnabled(false); } else { if (canEnableSecondaryTax(customerVO,baseLineItemVO) || (baseLineItemVO.isPickupItem().booleanValue() && customerVO.getTaxStatusSecondaryRefOptionCD().equals( Tax.OPTIONAL))) { setSecondaryTaxEnabled(true); } invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); } } } else { invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); } firstTimeThroughTax = false; } protected void handleSecondaryTax() { // baseLineItemVO.setTaxable2(BooleanParser.parseBoolean(Tax.TAXABLE_YES, Tax.TAXABLE_NO, invoiceLineEntryPanel.fldSecondaryTax.getText())); // Code added to get the value from secondary tax field only when it is enabled. if (invoiceLineEntryPanel.fldSecondaryTax.isEnabled()) { baseLineItemVO.setTaxable2(new Boolean(BooleanParser .parseYN(invoiceLineEntryPanel.fldSecondaryTax.getText()))); } if (invoiceLineEntryPanel.fldSecondaryTax.getText().equals("")) { setOKEnabled(false); return; } invoiceLineEntryPanel.fldOK.setText("Y"); setOKEnabled(true); } protected void handleOK() { String text = invoiceLineEntryPanel.fldOK.getText(); if (text.equals("Y")) { // Code added to avoid invoicing of zero quantity line item if (clientApplicationContext.isLoggedInAsPhoneRoom() && baseLineItemVO.getQuantityBilled().signum() == 0 && !baseLineItemVO.isCompletedLine()) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,"1289"); invoiceLineEntryPanel.fldOK.setText(""); return; } saveLineItem(); // Re-calculate line item price values based on tax decision flag selection if(!invoiceVO.isPhoneRoomMessagesFlag()){ if (displayPriceWithTax()) { InvoiceLineBL.recalculateLineItemPrices(baseLineItemVO, invoiceVO, customerVO, inventoryVO, miscChgVO); } }else{ if (includePriceWithTaxPhoneRoom()) { PhoneRoomInvoiceLineBL.recalculateLineItemPrices(baseLineItemVO, invoiceVO, customerVO, inventoryVO, miscChgVO,remoteStoreIP,includePriceWithTaxPhoneRoom()); } } isSupersedingPart = false; //making sure this is set to false } // Recheck the tax status of each line item and if Colorado Delivery Fee not applicable remove the CDF. if(!isCDFApplicable(invoiceVO, baseLineItemVO) && invoiceVO.isCoroladoFeeLineExists()) { InvoiceLineBL.removeCODeliveryLineItem(invoiceVO); } // else if (text.equals("T")) { // invoiceLineEntryPanel.fldTax.setText(Tax.TAXABLE_YES); // if (baseLineItemVO.getDisplayTaxable2()) { // invoiceLineEntryPanel.fldSecondaryTax.setText(Tax.TAXABLE_YES); // } // saveLineItem(); // } } /** * Checks if the any invoice line items has tax including the one being editied. * @param invoiceVO * @param baseItemVO * @return true if CDF applicable, else false */ private boolean isCDFApplicable(InvoiceVO invoiceVO, BaseLineItemVO baseItemVO) { boolean isCDFapplicable = false; Vector itemList = invoiceVO.getLineItems(); if (itemList.size() == 1 && invoiceVO.isCoroladoFeeLineExists() && ((BaseLineItemVO) itemList.get(0)).getLineAbbr() == CDF && (baseItemVO.getTaxable1() || baseItemVO.getTaxable2())) { isCDFapplicable = true; } else 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 bLineItemVO = (BaseLineItemVO) lineItem; if (null != baseItemVO.getId() && baseItemVO.getId().intValue() == bLineItemVO.getId().intValue()) { if(baseItemVO.getTaxable1().booleanValue() || baseItemVO.getTaxable2().booleanValue()) { isCDFapplicable = true; } } else if (bLineItemVO.getTaxable1().booleanValue() || bLineItemVO.getTaxable2().booleanValue()) { isCDFapplicable = true; } } } } return isCDFapplicable; } private void loadPartLine() { Vector inventoryLines = null; String text = invoiceLineEntryPanel.fldPartNumber.getText(); try { text = FwoUtil.stripChars(text, new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); if( invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) { inventoryLines = PhoneRoomInvoiceLineBL.getPartLines(text, true,this.remoteStoreIP); }else{ inventoryLines = InvoiceLineBL.getPartLines(text, true); } } catch (PointOfSaleException pose) { throw new ApplicationRuntimeException(pose, ApplicationRuntimeException.GENERIC_SHORT_MESSAGE_ID); } invoiceLineEntryPanel.slfLine.setData(inventoryLines); if (inventoryLines != null && inventoryLines.size() == 1) { BaseInventoryVO baseInventoryVO = (BaseInventoryVO) inventoryLines.get(0); invoiceLineEntryPanel.slfLine.setText(baseInventoryVO.getLineAbbrev()); } } /** * Fills in all of the appropriate fields within the line entry area for a * given base inventory value object. * * @param baseInventoryVO BaseInventoryVO */ protected void displayPartDetail(BaseInventoryVO baseInventoryVO) { logger.debug("in displayPartDetail() "); pdChanged = false;//we want to reset this when the line changes listChanged = false; FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); if(baseLineItemVO != null && baseLineItemVO.isVirtualKit()){ final BaseLineItemVO newBaseLineItemVO = (BaseLineItemVO)baseLineItemVO.clone(); newBaseLineItemVO.setLineAbbr(baseInventoryVO.getLineAbbrev()); newBaseLineItemVO.setPartNum(baseInventoryVO.getPartNumber()); if(!invoiceVO.isPhoneRoomMessagesFlag()) inventoryVO = InvoiceLineBL.getVirtualKitDetailInfo(customerVO, newBaseLineItemVO); else inventoryVO = PhoneRoomInvoiceLineBL.getVirtualKitDetailInfo(customerVO,newBaseLineItemVO,remoteStoreIP); } else { if(!invoiceVO.isPhoneRoomMessagesFlag()) inventoryVO = clientApplicationContext.getInventoryDAO().getPartDetailInfo(customerVO, baseInventoryVO, false); else inventoryVO = new PhoneRoomTaapRouter().getPartDetailInfo(customerVO,baseInventoryVO.getLineAbbrev(),baseInventoryVO.getPartNumber(),false,remoteStoreIP,clientApplicationContext.getCurrentLocale().getLanguage(),false); } // set the inventory stock locations line item from the inventory if(inventoryVO != null){ baseLineItemVO.setInventoryStockLocations(inventoryVO.getInventoryStockLocations()); } // check if the entered part is a kit part. if (inventoryVO != null && inventoryVO instanceof KitInventoryVO) { baseLineItemVO.setKitPart(true); } // Counter person is restricted from adding any additional line items to Return invoice if (!baseLineItemVO.isCompletedLine() && invoiceVO.isReturnInvoice() && invoiceVO.isReturnInvoiceLoaded()) { clientApplicationContext.getMessageMgr() .showMessage(invoiceLineEntryPanel, "10308"); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return; } // Counter person is restricted from adding any additional line items to invoice containing // NOL Order if (!baseLineItemVO.isCompletedLine() && InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO)) { clientApplicationContext.getMessageMgr() .showMessage(invoiceLineEntryPanel, "10124"); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return; } if (!baseLineItemVO.isCompletedLine() && InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && baseLineItemVO.getOrderQuantity().compareTo(BD_ZERO) == 0) { clientApplicationContext.getMessageMgr() .showMessage(invoiceLineEntryPanel, "10202"); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return; } if (inventoryVO == null) { Boolean reservedLine = (!invoiceVO.isPhoneRoomMessagesFlag())?InvoiceLineBL.isReservedLine(baseInventoryVO.getLineAbbrev()): new PhoneRoomTaapRouter().isReservedLine(baseInventoryVO.getLineAbbrev(),remoteStoreIP, String.valueOf(clientApplicationContext.getLocation())); if (reservedLine == null) { //check if part is a superseding part if (isSupersedingPart) { clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); this.appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1396, null, true); } else { //1211 = 1,N,Invalid line abbreviation this.appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1211, null, true); setLineEnabled(true); } loadPartLine(); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldDescription.setText(""); setDescriptionEnabled(false); invoiceLineEntryPanel.fldQuantity.setText(""); setQuantityEnabled(false); invoiceLineEntryPanel.fldList.setText(""); setListEnabled(false); invoiceLineEntryPanel.fldPD.setText(""); setPDEnabled(false, baseLineItemVO); invoiceLineEntryPanel.fldPrice.setText(""); setPriceEnabled(false); invoiceLineEntryPanel.fldUnit.setText(""); setUnitEnabled(false); invoiceLineEntryPanel.fldTax.setText(""); setTaxEnabled(false); invoiceLineEntryPanel.fldSecondaryTax.setText(""); setSecondaryTaxEnabled(false); invoiceLineEntryPanel.fldDC.setText(""); setDCEnabled(false); invoiceLineEntryPanel.fldOK.setText(""); setOKEnabled(false); invoiceLineEntryPanel.btnSupersede.setEnabled(false); } else if (reservedLine.booleanValue()) { //1212 = 1,N,Line abbreviation is reserved this.appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1212, null, true); if (invoiceLineEntryPanel.slfLine.getData().size() == 1 && baseInventoryVO.getLineAbbrev().equals( invoiceLineEntryPanel.slfLine.getText())) { invoiceLineEntryPanel.slfLine.setData(new Vector()); } invoiceLineEntryPanel.slfLine.setText(""); } else { if (invoiceLineEntryPanel.slfLine.getText().trim().equals("")) { invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldDescription.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldDescription, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), KeyEvent.SHIFT_MASK , KeyEvent.VK_TAB, '\t')); //these will be enabled if we have come from supersede dialog setOKEnabled(false); setTaxEnabled(false); setPDEnabled(false, baseLineItemVO); setQuantityEnabled(false); setDescriptionEnabled(false); invoiceLineEntryPanel.btnSupersede.setEnabled(false); clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE7_NAME); } else { clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); //1215 = 1,N,Do you wish to add part number $1 line $2? if(messageManager.showMessageYesNo(invoiceLineEntryPanel, String.valueOf(1215), new String[] {baseInventoryVO.getPartNumber(), baseInventoryVO.getLineAbbrev()})) { InventoryProfileVO inventoryProfileVO = null; if(!invoiceVO.isPhoneRoomMessagesFlag()){ inventoryProfileVO = ApplicationContext .getInstance().getProfile(Profile.BACKOFFICE_CLIENT, ClientApplicationContext .getClientApplicationContext() .getLocation()).getInventoryProfile(); }else{ Map invProfileParams = new HashMap(); invProfileParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + remoteStoreIP); invProfileParams.put(TaapRouter.LOC, "" + loc); inventoryProfileVO = new TaapRouter().getInventoryProfile(invProfileParams); } Integer partNumberLength = inventoryProfileVO.getPartNumberLength(); if (baseInventoryVO.getPartNumber().length() > partNumberLength .intValue()) { final String[] partNumLength = { partNumberLength.toString() }; SwingUtilities.invokeLater(new Runnable() { public void run() { ClientApplicationContext .getClientApplicationContext() .getMessageMgr().showMessage( invoiceLineEntryPanel, "9561", partNumLength); } }); invoiceLineEntryPanel.slfLine.setText(""); // these will be enabled if we have come from supersede dialog setOKEnabled(false); setTaxEnabled(false); setPDEnabled(false, baseLineItemVO); setQuantityEnabled(false); setDescriptionEnabled(false); invoiceLineEntryPanel.btnSupersede.setEnabled(false); clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE7_NAME); return; } final InventoryVO inventoryVO = new InventoryVO(); inventoryVO.setPartNumber(baseInventoryVO.getPartNumber()); inventoryVO.setExpandedPartNumber(expandedPartNumber); inventoryVO.setLineAbbrev(baseInventoryVO.getLineAbbrev()); inventoryVO.setLOC(loc); addPartLineController.setInventoryVO(inventoryVO); if (clientApplicationContext.isLoggedInAsPhoneRoom() && invoiceVO != null && invoiceVO.getRemoteStoreNumber() != null) { addPartLineController.setStoreNumber(invoiceVO.getRemoteStoreNumber()); } SwingUtilities.invokeLater(new Runnable() { public void run() { ((AddPartLineDialog) addPartLineController.getView()).setVisible(true); if (addPartLineController.isPartAdded()) { if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){ invoiceLineEntryPanel.btnBarcode.setVisible(false); // Check other stores functionality should work when not logged in as PhoneRoom if (!ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()) { invoiceLineEntryPanel.btnCheckOtherStores.setVisible(true); if(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()).getStoreProfile().getMultiStoreInUse().booleanValue() || clientApplicationContext.getVPNISCDAO().isStockCheckAvailable(loc.intValue())){ invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(true); } else { invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(false); } } } invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(true); if (baseLineItemVO.getPartDescription() != null && !baseLineItemVO.getPartDescription() .equals("")) { invoiceLineEntryPanel.fldDescription .setText(baseLineItemVO.getPartDescription()); setDescriptionEnabled(false); setQuantityEnabled(true); } else { setDescriptionEnabled(true); setQuantityEnabled(false); invoiceLineEntryPanel.fldDescription.setText(""); invoiceLineEntryPanel.fldQuantity.setText(""); invoiceLineEntryPanel.fldDescription.requestFocus(); } invoiceLineEntryPanel.slfLine.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.slfLine, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } else { setDescriptionEnabled(false); invoiceLineEntryPanel.slfLine.setText(""); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); } } }); } else { invoiceLineEntryPanel.slfLine.setText(""); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldDescription.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldDescription, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), KeyEvent.SHIFT_MASK , KeyEvent.VK_TAB, '\t')); } }); //these will be enabled if we have come from supersede dialog setOKEnabled(false); setTaxEnabled(false); setPDEnabled(false, baseLineItemVO); setQuantityEnabled(false); setDescriptionEnabled(false); invoiceLineEntryPanel.btnSupersede.setEnabled(false); clearLine(InvoiceLineEntryPanel.LBL_LINE1_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE3_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE5_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE6_NAME); clearLine(InvoiceLineEntryPanel.LBL_LINE7_NAME); } } } } else { // Code added for Tender Types. // i. Prevent user from invoicing a NAPA Gift Card on few selected special functions. // ii. Prevent Charge-Only customer from invoicing a NAPA Gift Card. // iii. To set the Invoice line Item Type id for NAPA Gift Card. if (inventoryVO != null && (inventoryVO.getPartNumber() != null || inventoryVO.getPartNumber().length() != 0) && (inventoryVO.getLineAbbrev() != null && (inventoryVO.getLineAbbrev().equalsIgnoreCase(TsoConstant.NGC_LINE_ABBREV) || inventoryVO.getLineAbbrev().equalsIgnoreCase(TsoConstant.NEW_NGC_LINE_ABBREV)))) { String selectedItem = invoiceLineEntryPanel.slfSpecialFunctions.getText(); if (baseLineItemVO.isSpecialFnCorSelected() || selectedItem.startsWith(TsoConstant.DEFECTIVE) || selectedItem.startsWith(TsoConstant.DOES_NOT_AFFECT_SALES) || selectedItem.startsWith(TsoConstant.WARRANTY_LABOR_CLAIM)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "9301"); handleSplFunctionsForNgc(); return; // prevent user to proceed if it's a GFT1/GFT line item and the store uses IPC, but the terminal doesn't have a pin pad. } else if (!ipcChecked() && baseLineItemVO.getRefInvoiceLineItemTypeID() == RefInvoiceLineItemType.NAPA_GIFT_CARD) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "5025"); if (!baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); displayLineItem(); return; } } else { baseLineItemVO.setLineAbbr(invoiceLineEntryPanel.slfLine.getText()); baseLineItemVO.setExpandedPartNum(inventoryVO.getExpandedPartNumber()); baseLineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType( baseLineItemVO, customerVO)); } } // Customer is authorised to sell only core items if 'Allow Only Core Sales' flag is ON // for a customer. if (customerVO != null && customerVO.getAllowOnlyCoreSales() != null && customerVO.getAllowOnlyCoreSales().booleanValue() && !baseLineItemVO.isCompletedLine() && !baseLineItemVO.isCoreTransaction().booleanValue() && baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() != RefInvoiceLineItemType.ENVIRONMENTAL_CHARGE && inventoryVO != null && inventoryVO.getPartNumber() != null && inventoryVO.getPartNumber().trim().length() > 0 && inventoryVO.getLineAbbrev() != null && inventoryVO.getLineAbbrev().trim().length() > 0) { // If part has associated core then automatically convert this part as "Core only" // line item and allow to proceed (As good as how we add core item from Special Function) if (inventoryVO.getCoreCost().compareTo(new BigDecimal(0.00)) != 0 || inventoryVO.getCorePrice().compareTo(new BigDecimal(0.00)) != 0) { baseLineItemVO.setCoreTransaction(new Boolean(true)); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(2); clientApplicationContext.getPointOfSaleEventDispatcher().fireSwitchLineItemHandler( new InvoiceEvent(this, baseLineItemVO)); return; } else { // If part doesn’t have core associated then display message as // "Customer is not allowed to buy this part" with "Ok" button clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10115"); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); invoiceLineEntryPanel.fldPartNumber.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return; } } // check if the entered part is a kit part. if (inventoryVO instanceof KitInventoryVO) { /** * Code added to display an alert message and set focus on Part Number field when user * attempts to invoice a Kit part against the special function COR. */ if(baseLineItemVO.isSpecialFnCorSelected()){ clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,"8011"); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); displayLineItem(); invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.slfSpecialFunctions, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_ENTER, '\n')); return; } else if (invoiceLineEntryPanel.slfSpecialFunctions.getText().startsWith( TsoConstant.WARRANTY_LABOR_CLAIM)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "8167"); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); displayLineItem(); invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.slfSpecialFunctions, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_ENTER, '\n')); return; } else if ((!invoiceVO.isPhoneRoomMessagesFlag()?InvoiceBL.isRgnInUse():PhoneRoomInvoiceBL.isRgnInUse(remoteStoreIP)) && invoiceLineEntryPanel.slfSpecialFunctions.getText().startsWith( TsoConstant.DEFECTIVE)) { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "8166"); invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); displayLineItem(); invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.slfSpecialFunctions, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_ENTER, '\n')); return; } else { baseLineItemVO.setKitPart(true); } } if (inventoryVO.getLineAbbrev().length() == 0) { //there was a problem with the DVD clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel,"2466"); invoiceLineEntryPanel.fldPartNumber.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); return; } boolean qtyOrderedFromOtherStore = false; if (clientApplicationContext.isLoggedInAsPhoneRoom() && baseLineItemVO.getPhoneRoomItems() != null && baseLineItemVO.getPhoneRoomItems().size() > 0) { qtyOrderedFromOtherStore = true; } if (barcodeVO != null && !qtyOrderedFromOtherStore) { if (barcodeVO.getPkgQty().intValue() == 0) { if (inventoryVO.getStandardPkg().intValue() == 0) { baseLineItemVO.setQuantityBilled(new BigDecimal("1.00")); } else { baseLineItemVO.setQuantityBilled(new BigDecimal(inventoryVO.getStandardPkg( ).toString()).setScale(2, BigDecimal.ROUND_HALF_UP)); } } else { baseLineItemVO.setQuantityBilled( new BigDecimal(barcodeVO.getPkgQty().doubleValue()).setScale(2, BigDecimal.ROUND_HALF_UP)); } } getPrices(baseInventoryVO); if (baseLineItemVO.getCoreTransaction().booleanValue()) { prices.setUnitRebate("N"); } setListEnabled(false); setPDEnabled(false, baseLineItemVO); setPriceEnabled(false); setUnitEnabled(false); final boolean isItemReturnDetailInfoRequired = (!invoiceVO.isPhoneRoomMessagesFlag())?clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getAskForItemReturnInfo().booleanValue():new TaapRouter().getInvoicingProfile(remoteStoreIP).getAskForItemReturnInfo().booleanValue(); boolean isPriceUpdateRequired = true; if (!isItemReturnDetailInfoRequired && !baseLineItemVO.isCompletedLine() && baseLineItemVO.getQuantityBilled().doubleValue() < 0.0 && baseLineItemVO.isCasePrice().booleanValue()) { isPriceUpdateRequired = false; } if (isPriceUpdateRequired) { setPriceAttributes(false); } if (!invoiceLineEntryPanel.fldPD.getText().equals( String.valueOf(PDDocument.EXCLAMATION.charValue())) && InvoiceLineBL.checkForQuantityDiscount(inventoryVO, customerVO, prices)) { BigDecimal minQtyForDiscount = inventoryVO.getInvQtyMinForDiscount().setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal up = baseLineItemVO.getUnitPrice(); BigDecimal fullPrice = up.multiply(minQtyForDiscount).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal discountPercent = inventoryVO.getDiscountForLargeInv().divide( new BigDecimal(100.00), 2, BigDecimal.ROUND_HALF_UP); BigDecimal discountedUnitPrice = up.subtract(up.multiply(discountPercent)).setScale(up.scale(), BigDecimal.ROUND_HALF_UP); BigDecimal discountedPrice = discountedUnitPrice.multiply(minQtyForDiscount).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal discount = fullPrice.subtract(discountedPrice).setScale(2, BigDecimal.ROUND_HALF_UP); //1213 = 1,N,Buy $1 and save $$2 this.appendToLine(InvoiceLineEntryPanel.LBL_LINE2_NAME, 1213, new String[] {inventoryVO.getInvQtyMinForDiscount().toString(), discount.toString()}, false); } else { this.clearLine(InvoiceLineEntryPanel.LBL_LINE2_NAME); } invoiceLineEntryPanel.fldUnit.setText(inventoryVO.getRefUnitDesignatorDescription()); // Added for RADS - Main Counter Project // If lineitem is picked by RADS, sets DC textfield to "Y" and disable that. int invoiceLineItemTypeId = baseLineItemVO.getRefInvoiceLineItemTypeID() != null ? baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() : 0; if (invoiceLineItemTypeId == RefInvoiceLineItemType.DC_ITEM || invoiceLineItemTypeId == RefInvoiceLineItemType.DC_ITEM_TRANSFER) { invoiceLineEntryPanel.fldDC.setText("Y"); } else if (baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().compareTo(new BigDecimal(0)) < 0) { invoiceLineEntryPanel.fldDC.setText("N"); setDCEnabled(false); } // ===================================== if (firstTimeThroughTax && !baseLineItemVO.isCompletedLine()) { setTaxEnabled(false); invoiceLineEntryPanel.fldTax.setText(""); setSecondaryTaxEnabled(false); invoiceLineEntryPanel.fldSecondaryTax.setText(""); } setOKEnabled(false); if (!baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.lblDescription.setEnabled(true); } if (inventoryVO.getExpandedPartNumber() != null && inventoryVO.getExpandedPartNumber().length() > 1) { invoiceLineEntryPanel.fldPartNumber.setText(inventoryVO.getExpandedPartNumber()); } if (!isSupersedingPart && baseLineItemVO.getPartDescription() != null && baseLineItemVO.getPartDescription().length() > 0) { //if we are coming from cataloging then we will want to use the description from cataloging invoiceLineEntryPanel.fldDescription.setText(baseLineItemVO.getPartDescription()); handleDescription(); // Code added for Tender Types. // Set the default quantity to 1 for NAPA Gift Card. setDefaultQuantityForGiftCards(); } else if (inventoryVO.getDescription() != null && inventoryVO.getDescription().length() > 0) { invoiceLineEntryPanel.fldDescription.setText(inventoryVO.getDescription()); handleDescription(); // Code added for Tender Types. // Set the default quantity to 1 for NAPA Gift Card. setDefaultQuantityForGiftCards(); } else { setDescriptionEnabled(true); } baseLineItemVO.setLineAbbr(invoiceLineEntryPanel.slfLine.getText()); baseLineItemVO.setExpandedPartNum(inventoryVO.getExpandedPartNumber()); baseLineItemVO.setPartNum(inventoryVO.getPartNumber()); baseLineItemVO.setRefInvoiceLineItemTypeID(InvoiceLineBL.getLineItemType(baseLineItemVO, customerVO)); if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){ invoiceLineEntryPanel.btnBarcode.setVisible(false); // Check other stores functionality should work when not logged in as PhoneRoom if (!ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()) { invoiceLineEntryPanel.btnCheckOtherStores.setVisible(true); if(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()).getStoreProfile().getMultiStoreInUse().booleanValue() || clientApplicationContext.getVPNISCDAO().isStockCheckAvailable(loc.intValue())){ invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(true); } else { invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(false); } } } invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(true); invoiceLineEntryPanel.btnPartInfo.setEnabled(true); if (baseLineItemVO.getQuantityBilled() != null && baseLineItemVO.getQuantityBilled().doubleValue() >= 0 && !baseLineItemVO.isCompletedLine()) { boolean supersedesExist = (!invoiceVO.isPhoneRoomMessagesFlag())?clientApplicationContext.getInventoryDAO() .doSupersedesExist(inventoryVO):new PhoneRoomTaapRouter().doSupersedesExist(remoteStoreIP,inventoryVO.getLineAbbrev(),inventoryVO.getPartNumber(),loc); invoiceLineEntryPanel.btnSupersede.setEnabled(supersedesExist && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)); } else { invoiceLineEntryPanel.btnSupersede.setEnabled(false); } invoiceLineEntryPanel.btnSupersede.setEnabled(canEnableSupersedeButton(null) && !InvoiceBL.doesInvoiceContainNOLOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainProlinkCSGOrder(invoiceVO) && !InvoiceBL.doesInvoiceContainCSGRestrictedReturnItem(invoiceVO)); if((!invoiceVO.isPhoneRoomMessagesFlag())?InvoiceBL.isDCInUSUsingRadsAndNAPAXpress():PhoneRoomInvoiceBL.isDCInUSUsingRadsAndNAPAXpress(remoteStoreIP)){ final InventoryVO inventoryVO = new InventoryVO(); inventoryVO.setLineAbbrev(invoiceLineEntryPanel.slfLine.getText() == null ? "" : invoiceLineEntryPanel.slfLine.getText()); inventoryVO.setExpandedPartNumber(invoiceLineEntryPanel.fldPartNumber.getText() == null ? "" : invoiceLineEntryPanel.fldPartNumber.getText()); try { final IDValuePairVO dcInfo = (!invoiceVO.isPhoneRoomMessagesFlag())?InvoiceLineBL.getServingDC(inventoryVO):PhoneRoomInvoiceLineBL.getServingDC(inventoryVO,remoteStoreIP); if(baseLineItemVO.isVirtualKit()){ if(!invoiceVO.isPhoneRoomMessagesFlag()) setDCStockInfo((String)dcInfo.getID(), InvoiceLineBL.getVirtualKitOnHandInServingDC(baseLineItemVO).toString()); else setDCStockInfo((String)dcInfo.getID(), PhoneRoomInvoiceLineBL.getVirtualKitOnHandInServingDC(baseLineItemVO,null, null, remoteStoreIP).toString()); } else { setDCStockInfo((String)dcInfo.getID(), (String)dcInfo.getValue()); } } catch(Exception exception) { logger.error(exception, exception); } } handleLineAnnotations(); displayInventoryNote(); BigDecimal listPrice = baseLineItemVO.isCompletedLine() ? baseLineItemVO.getUnitListPrice() : prices.getCalculatedList(); logger.debug("DefaultLineItemHandler.displayPartDetail - listPrice = " + listPrice); if (InvoiceLineBL.checkListPrice(baseLineItemVO, listPrice)) { logger.debug("DefaultLineItemHandler.displayPartDetail - checkListPrice 2 "); try { invoiceLineEntryPanel.fldList.setText(fwoNumberPattern.format("0.00")); } catch (NumberPatternFormatException npfe) { //do nothing } baseLineItemVO.setActualListPrice(listPrice); } logger.debug("DefaultLineItemHandler.displayPartDetail - DisplayActualListPrice = " + prices.getDisplayListPrice()); } } protected void getPrices(BaseInventoryVO baseInventoryVO) { BigDecimal quantity = baseLineItemVO.getQuantityBilled(); if (quantity == null){ quantity = new BigDecimal (0.00); } if (!okToCallGetPrice(baseInventoryVO.getPartNumber(), baseInventoryVO.getLineAbbrev())) { return; } if(!invoiceVO.isPhoneRoomMessagesFlag()) { prices = InvoiceLineBL.getPrices(customerVO.getID(), customerVO.getCustomerTypeCD(), baseInventoryVO.getPartNumber(), baseInventoryVO.getLineAbbrev(), quantity); }else{ prices = PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO, customerVO.getCustomerTypeCD(), baseInventoryVO.getPartNumber(), baseInventoryVO.getLineAbbrev(), quantity,remoteStoreIP,null); } } protected void displayInventoryNote() { if(baseLineItemVO.isItemEditedOutsideTams()){ return; } if ((baseLineItemVO.getQuantityBilled().doubleValue() >= 0) && inventoryVO.getInventoryStockVO() != null && inventoryVO.getInventoryStockVO().getInventoryNoteVO() != null) { final InventoryNoteVO inventoryNote = inventoryVO.getInventoryStockVO().getInventoryNoteVO(); SwingUtilities.invokeLater(new Runnable() { public void run() { if ((InvoiceLineBL.mustAcknowledgeNote(inventoryNote.getRefNoteHandlingID()) || inventoryNote.getText().length() > 100)) { StringBuffer tmpString = new StringBuffer(inventoryNote.getText()); if (inventoryNote.getText().length() > 100) { for (int i = 100; i > 0; i--) { if (tmpString.charAt(i) == ' ') { tmpString = tmpString.replace(i, i + 1, "\n"); break; } } } JOptionPane.showMessageDialog(invoiceLineEntryPanel, tmpString.toString()); } } }); } } protected boolean hasInventoryNote() { boolean displayInventoryNote = false; if (inventoryVO != null && inventoryVO.getInventoryStockVO() != null && inventoryVO.getInventoryStockVO().getInventoryNoteVO() != null) { final InventoryNoteVO inventoryNote = inventoryVO .getInventoryStockVO().getInventoryNoteVO(); displayInventoryNote = InvoiceLineBL .mustAcknowledgeNote(inventoryNote.getRefNoteHandlingID()) || inventoryNote.getText().length() > 100; } return displayInventoryNote; } protected void setPriceAttributes(boolean doCallGetPrice) { final String methodSpec = " DefaultLineItemHandler.setPriceAttributes - "; BigDecimal bdZero = new BigDecimal("0.0000"); BigDecimal bdCalculatedList = bdZero; BigDecimal bdDisplayListPrice = bdZero; BigDecimal bdUnitPrice = bdZero; BigDecimal bdDisplayUnitPrice = bdZero; BigDecimal bdUnitCost = bdZero; String strCalculatedList = new String(); String strUnitPrice = new String(); String strPriceDecision = new String(); boolean displayPriceWithTax = displayPriceWithTax(); if(invoiceVO.isPhoneRoomMessagesFlag()){ displayPriceWithTax = new PhoneRoomTaapRouter().getStoreProfile(this.remoteStoreIP).getIncludeTaxInPrice().booleanValue(); } if (baseLineItemVO.getReturnItems() == null || doCallGetPrice) { FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern .getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext .getSystemDAO().getPriceScale().intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext .getSystemDAO().getPriceScale().intValue()); if (doCallGetPrice) { logger.debug(methodSpec + "doCallGetPrice - " + doCallGetPrice); if(!invoiceVO.isPhoneRoomMessagesFlag()){ prices = InvoiceLineBL.getPrices(customerVO.getID(), customerVO .getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO .getQuantityBilled()); }else{ prices = PhoneRoomInvoiceLineBL.getPricesPhoneRoom(customerVO, customerVO .getCustomerTypeCD(), baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), baseLineItemVO .getQuantityBilled(),remoteStoreIP,null); } } /** * because the line is complete, we are displaying the Unit Price * from the invoiceLineListModel, not using the prices from * PricesOutVO and Inventory */ bdCalculatedList = prices.getCalculatedList(); bdDisplayListPrice = prices.getDisplayListPrice(); if (baseLineItemVO.isCompletedLine()) { logger.debug(methodSpec + " Completed Line Item "); bdUnitPrice = baseLineItemVO.getUnitPrice(); bdUnitCost = baseLineItemVO.getUnitCost(); strPriceDecision = baseLineItemVO.getPriceDecision(); if(displayPriceWithTax){ bdDisplayUnitPrice = baseLineItemVO.getDisplayUnitPrice(); if(!isSupersedingPart){ bdDisplayListPrice = baseLineItemVO.getDisplayUnitListPrice(); bdCalculatedList = baseLineItemVO.getUnitListPrice(); } } } else { bdUnitPrice = prices.getUnitPrice(); bdDisplayUnitPrice = prices.getDisplayUnitPrice(); if (baseLineItemVO != null && baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null && inventoryVO instanceof KitInventoryVO && customerVO != null) { // Gets the kit part unit cost as the sum of unit cost of the components // associated with a kit part by calling the getPrice() functionality on // each component. if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdUnitCost = InvoiceLineBL.getKitPartCost(inventoryVO, customerVO); }else{ bdUnitCost = PhoneRoomInvoiceLineBL.getKitPartCost(inventoryVO, customerVO,invoiceVO.getRemoteStoreNumber()); } } else { bdUnitCost = prices.getUnitCost(); } // Code modified for Tender Types. // Set empty price decision for a NAPA Gift Card. strPriceDecision = (invoiceLineEntryPanel.slfLine.getText().trim().equals( TsoConstant.NGC_LINE_ABBREV) || invoiceLineEntryPanel.slfLine.getText().trim().equals( TsoConstant.NEW_NGC_LINE_ABBREV)) ? "" : prices.getPriceDecision(); if(displayPriceWithTax && listChanged){ if (baseLineItemVO.getDisplayUnitListPrice() != null && baseLineItemVO.getDisplayUnitListPrice().compareTo(BD_ZERO) != 0) { bdDisplayListPrice = baseLineItemVO.getDisplayUnitListPrice(); } if (baseLineItemVO.getUnitListPrice() != null && baseLineItemVO.getUnitListPrice().compareTo(BD_ZERO) != 0 && baseLineItemVO.getUnitListPrice().compareTo(bdCalculatedList) != 0) { bdCalculatedList = baseLineItemVO.getUnitListPrice(); } } } logger.debug(methodSpec + "bdCalculatedList = " + bdCalculatedList); logger.debug(methodSpec + "bdDisplayListPrice = " + bdDisplayListPrice); try { strCalculatedList = fwoNumberPattern .format(displayPriceWithTax ? bdDisplayListPrice : bdCalculatedList); strUnitPrice = fwoNumberPattern .format(displayPriceWithTax ? bdDisplayUnitPrice : bdUnitPrice); } catch (NumberPatternFormatException npfe) { // do nothing } logger.debug(methodSpec + "fldList [strCalculatedList] = " + strCalculatedList + ", fldPrice [strUnitPrice] = " + strUnitPrice); invoiceLineEntryPanel.fldList.setText(strCalculatedList); invoiceLineEntryPanel.fldPrice.setText(strUnitPrice); invoiceLineEntryPanel.fldPD.setText(strPriceDecision); baseLineItemVO.setUnitListPrice(bdCalculatedList); baseLineItemVO.setDisplayUnitListPrice(bdDisplayListPrice); baseLineItemVO.setPriceDecision(strPriceDecision); baseLineItemVO.setUnitPrice(bdUnitPrice); baseLineItemVO.setDisplayUnitPrice(bdDisplayUnitPrice); } else { if (baseLineItemVO.isCompletedLine()) { bdUnitCost = baseLineItemVO.getUnitCost(); } else { if (baseLineItemVO != null && baseLineItemVO.isKitPart() && baseLineItemVO.getGeneratedByLineItem() == null && inventoryVO instanceof KitInventoryVO && customerVO != null) { // Gets the kit part unit cost as the sum of unit cost of the components // associated with a kit part by calling the getPrice() functionality on // each component. if(!invoiceVO.isPhoneRoomMessagesFlag()){ bdUnitCost = InvoiceLineBL.getKitPartCost(inventoryVO, customerVO); }else{ bdUnitCost = PhoneRoomInvoiceLineBL.getKitPartCost(inventoryVO, customerVO,invoiceVO.getRemoteStoreNumber()); } } else { bdUnitCost = prices.getUnitCost(); } } } if (CustomerBL.isTransferCustomer(customerVO)) { baseLineItemVO.setUnitCost(bdZero); } else { baseLineItemVO.setUnitCost(bdUnitCost); // dvk 4823 } } protected void setQuantityToDisplay (String displayQuantity) { String displayValue = displayQuantity; if (displayValue == null) { displayValue = "0.00"; } if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && (inventoryVO.getDescription() == null || inventoryVO.getDescription().equalsIgnoreCase(""))) { displayValue = "1.00"; } invoiceLineEntryPanel.fldQuantity.setText(displayValue); } protected void appendToLine(int lineNum, int errorMessage, String[] inputParameters, boolean clearLine) { appendToLine("LBL_LINE" + lineNum + "_NAME", messageManager.getMessage( String.valueOf(errorMessage), inputParameters).getText(), clearLine); } protected void appendToLine(String lineName, int errorMessage, String[] inputParameters, boolean clearLine) { appendToLine(lineName, messageManager.getMessage( String.valueOf(errorMessage), inputParameters).getText(), clearLine); } protected void appendToLine(int lineNum, String stringToAppend, boolean clearLine) { String lineName = "LBL_LINE" + lineNum + "_NAME"; JLabel line = getLine(lineName); if (line != null) { if (line.getText().length() > 0 && !clearLine) { line.setText(line.getText() + " | " + stringToAppend); } else { line.setText(stringToAppend); } activateLine(lineName); } } protected void appendToLine(String lineName, String stringToAppend, boolean clearLine) { JLabel line = getLine(lineName); if (line != null) { if (line.getText().length() > 0 && !clearLine) { line.setText(line.getText() + " | " + stringToAppend); } else { line.setText(stringToAppend); } activateLine(lineName); } } protected void activateLine(String lineName) { JLabel line = getLine(lineName); if (line.getText().length() > 0) { line.setEnabled(true); } } protected void clearLine(String lineName) { JLabel line = getLine(lineName); line.setText(""); } protected void addHtmlTagToJLabel(String lineName, String htmlTag, boolean append) { JLabel line = getLine(lineName); if (line.getText() != null) { if (append) { line.setText(line.getText()+htmlTag); } else { line.setText(htmlTag+line.getText()); } } else { line.setText(htmlTag); } } protected JLabel getLine(String lineName) { // logger.debug("entering getLine()"); JLabel line = null; if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE1_NAME)) { line = invoiceLineEntryPanel.lblLine1; } else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE2_NAME)) { line = invoiceLineEntryPanel.lblLine2; } else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE3_NAME)) { line = invoiceLineEntryPanel.lblLine3; } else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE4_NAME)) { line = invoiceLineEntryPanel.lblLine4; } else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE5_NAME)) { line = invoiceLineEntryPanel.lblLine5; } else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE6_NAME)) { line = invoiceLineEntryPanel.lblLine6; }else if (lineName.equals(InvoiceLineEntryPanel.LBL_LINE7_NAME)) { line = invoiceLineEntryPanel.lblLine7; } return line; } public JComponent getNextFocus(JComponent currentComponent) { int componentCount = invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponentCount() - 10; for (int i = componentCount; i > -1; i--) { JComponent component = (JComponent) invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponent(i); if (component.isEnabled() && component.isFocusTraversable() && !component.getName().equals(InvoiceLineEntryPanel.FLD_PERCENT_NAME)) { return (JComponent) component; } } return currentComponent; } protected void setComponents() { FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO().getPriceScale( ).intValue()); if (!baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldDescription.setText(""); invoiceLineEntryPanel.fldQuantity.setText(""); invoiceLineEntryPanel.fldList.setText(""); invoiceLineEntryPanel.fldPD.setText(""); invoiceLineEntryPanel.fldPrice.setText(""); invoiceLineEntryPanel.fldUnit.setText(""); invoiceLineEntryPanel.fldDC.setText(""); invoiceLineEntryPanel.fldTax.setText(""); invoiceLineEntryPanel.fldSecondaryTax.setText(""); invoiceLineEntryPanel.fldOK.setText(""); } else { invoiceLineEntryPanel.fldPartNumber.setText(baseLineItemVO.getExpandedPartNum()); invoiceLineEntryPanel.slfLine.setText(baseLineItemVO.getLineAbbr()); invoiceLineEntryPanel.fldDescription.setText(baseLineItemVO.getPartDescription()); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO.getQuantityBilled().toString()); invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision()); try { if ((!invoiceVO.isPhoneRoomMessagesFlag())?displayPriceWithTax():includePriceWithTaxPhoneRoom()) { invoiceLineEntryPanel.fldList.setText( fwoNumberPattern.format(baseLineItemVO.getDisplayUnitListPrice())); invoiceLineEntryPanel.fldPrice .setText(fwoNumberPattern.format(baseLineItemVO.getDisplayUnitPrice())); invoiceLineEntryPanel.fldUnit .setText(fwoNumberPattern.format(baseLineItemVO.getDisplayUnitCost())); } else { invoiceLineEntryPanel.fldList .setText(fwoNumberPattern.format(baseLineItemVO.getUnitListPrice())); invoiceLineEntryPanel.fldPrice .setText(fwoNumberPattern.format(baseLineItemVO.getUnitPrice())); invoiceLineEntryPanel.fldUnit .setText(fwoNumberPattern.format(baseLineItemVO.getUnitCost())); } } catch (NumberPatternFormatException npfe) { //do nothing } if (baseLineItemVO.getRefInvoiceLineItemTypeID().byteValue() == 1) { invoiceLineEntryPanel.fldDC.setText("Y"); } invoiceLineEntryPanel.fldTax.setText(BooleanParser.parseString(Tax.TAXABLE_YES, Tax.TAXABLE_NO, baseLineItemVO.getTaxable1())); invoiceLineEntryPanel.fldSecondaryTax.setText(BooleanParser.parseString(Tax.TAXABLE_YES, Tax.TAXABLE_NO, baseLineItemVO.getTaxable2())); invoiceLineEntryPanel.fldOK.setText("Y"); if (baseLineItemVO.getPartNum().trim().length() > 0) { BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(baseLineItemVO.getPartNum()); baseInventoryVO.setLineAbbrev(baseLineItemVO.getLineAbbr()); displayPartDetail(baseInventoryVO); } } } public void displayLineItem() { if(baseLineItemVO.isCompletedLine()){ clientApplicationContext.getPointOfSaleEventDispatcher().fireTamsIsBusy(new CartEvent(this)); } enableComponents(); setComponents(); setStoreDependentDisplay(); setTaxTableDependentDisplay(); invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true); invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(false); invoiceLineEntryPanel.pnlNapaOnline.setVisible(false); } protected void enableComponents() { if (!baseLineItemVO.isCompletedLine()) { invoiceLineEntryPanel.btnDelete.setEnabled(false); setPartNumberEnabled(true); setLineEnabled(false); setDescriptionEnabled(false); setQuantityEnabled(false); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setPriceEnabled(false); setUnitEnabled(false); setDCEnabled(false); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); } else { invoiceLineEntryPanel.btnDelete.setEnabled(true); if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){ invoiceLineEntryPanel.btnBarcode.setVisible(false); // Check other stores functionality should work when not logged in as PhoneRoom if (!ClientApplicationContext.getClientApplicationContext().isLoggedInAsPhoneRoom()) { invoiceLineEntryPanel.btnCheckOtherStores.setVisible(true); if(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, loc.intValue()).getStoreProfile().getMultiStoreInUse().booleanValue() || clientApplicationContext.getVPNISCDAO().isStockCheckAvailable(loc.intValue())){ invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(true); } else { invoiceLineEntryPanel.btnCheckOtherStores.setEnabled(false); } } } invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(true); setPartNumberEnabled(false); setLineEnabled(false); setDescriptionEnabled(false); setQuantityEnabled(true); setListEnabled(false); setPDEnabled(false, baseLineItemVO); setPriceEnabled(false); setUnitEnabled(false); setDCEnabled(false); setTaxEnabled(false); setSecondaryTaxEnabled(false); setOKEnabled(false); invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(false); } } protected void saveLineItem() { logger.debug("saveLineItem()"); // If the user has pressed the enter key too fast in the invoice return screen then // the line abbreviation will be empty. Effort was made to address this upstream but // was not successful. Hence this solution which is further downstream fixes the problem. // This line abbreviation check should be re-evaluated after Return Authorizations project. if(invoiceLineEntryPanel.slfLine.getText() == null || invoiceLineEntryPanel.slfLine.getText().trim().length() == 0) { return; } setLineFields(); if (baseLineItemVO.isCompletedLine() && !baseLineItemVO.isLineAddedToList()) { LineGenerationQueue.getInstance().addLineItemNoGenerateFirst(baseLineItemVO); baseLineItemVO.setLineAddedToList(true); } else { if(LineGenerationQueue.getInstance().isEmpty()) { baseLineItemVO.setCompletedLine(true); LineGenerationQueue.getInstance().addLineItem(this); } } } protected void setInventoryFields(){ if (inventoryVO == null) { baseLineItemVO.setNonStocking(Boolean.TRUE); } else { baseLineItemVO.setGroupCode(inventoryVO.getGroupCode()); baseLineItemVO.setStoreGroupID(inventoryVO.getStoreGroupID()); baseLineItemVO.setHazardousMaterialID(inventoryVO.getHazMatID()); baseLineItemVO.setDepartmentID(inventoryVO.getDepartmentID()); baseLineItemVO.setSubDepartmentID(inventoryVO.getSubDepartmentID()); baseLineItemVO.setRefSeasonalFlagCD(inventoryVO.getRefSeasonalFlagCD()); InvoiceLineBL.setAverageCost(inventoryVO, baseLineItemVO); baseLineItemVO.setRefUnitDesignator(inventoryVO.getRefUnitDesignatorCD()); if (inventoryVO.getInventoryStockVO() != null) { baseLineItemVO.setStoreDepartmentID(inventoryVO.getInventoryStockVO().getStoreDepartmentID()); } InvoiceLineBL.setDisplayItem(baseLineItemVO, inventoryVO); InvoiceLineBL.setNonStocking(baseLineItemVO, inventoryVO); } } protected void setPriceFields() { if (prices != null) { if (baseLineItemVO.getPriceDecision().equals("!")) { baseLineItemVO.setSpecialSaleCode(prices.getSpecialSaleCode()); } // ignore rebate on the component parts of a kit. if (!((baseLineItemVO.getGeneratedByLineItem() != null) && (baseLineItemVO .isKitPart()))) { boolean rebateApplies; if(!invoiceVO.isPhoneRoomMessagesFlag()){ rebateApplies= clientApplicationContext.getSystemDAO() .isRebateApplicable(baseLineItemVO, invoiceVO); }else{ rebateApplies = new PhoneRoomTaapRouter().isRebateApplicable(baseLineItemVO,invoiceVO,remoteStoreIP); } if (rebateApplies) { baseLineItemVO.setRebateItem(Boolean.TRUE); } else { InvoiceLineBL.setRebateItem(baseLineItemVO, prices .getUnitRebate(), invoiceVO); } } InvoiceLineBL.setPricingProfile(baseLineItemVO, prices); } } protected void setLineFields(){ setLineFields(false); } protected void setLineFields(boolean isReturnItem) { if ((baseLineItemVO.getRefInvoiceLineItemOriginID() == null) || (baseLineItemVO.getRefInvoiceLineItemOriginID().intValue() == 0)) { baseLineItemVO.setRefInvoiceLineItemOriginID(new Byte((byte) 1)); } String partNumber = FwoUtil.stripChars(invoiceLineEntryPanel.fldPartNumber.getText(), new char[] {PartNumberFormatCertifier.DASH, PartNumberFormatCertifier.FORWARD_SLASH, PartNumberFormatCertifier.PERIOD, PartNumberFormatCertifier.SPACE}); baseLineItemVO.setPartNum(partNumber); baseLineItemVO.setPartDescription(invoiceLineEntryPanel.fldDescription.getText()); baseLineItemVO.setLineAbbr(invoiceLineEntryPanel.slfLine.getText()); //if we have a labor item then we need to set the unit cost to price multiplied by invoicing_profile.labor_cost_percent if (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.LABOR && (baseLineItemVO.getUnitCost() != null && baseLineItemVO.getUnitCost().signum() == 0)) { baseLineItemVO.setUnitCost(clientApplicationContext.getProfile( Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getInvoicingProfile().getLaborCostPercent().multiply(baseLineItemVO.getUnitPrice() ).divide(new BigDecimal("100.00"), clientApplicationContext.getSystemDAO( ).getPriceScale().intValue(), BigDecimal.ROUND_HALF_UP)); } setInventoryFields(); setPriceFields(); baseLineItemVO.setCountermanEmployeeID(invoiceVO.getCountermanEmployeeID()); try { if(!invoiceVO.isPhoneRoomMessagesFlag()){ if (!displayPriceWithTax()) { baseLineItemVO.setUnitListPrice(new BigDecimal(invoiceLineEntryPanel.fldList.getText())); } }else{ if (!includePriceWithTaxPhoneRoom()) { baseLineItemVO.setUnitListPrice(new BigDecimal(invoiceLineEntryPanel.fldList.getText())); } } } catch (StringIndexOutOfBoundsException e) { baseLineItemVO.setUnitListPrice(BD_ZERO); logger.debug(e.toString(), e); } catch (NumberFormatException nfe) { baseLineItemVO.setUnitListPrice(BD_ZERO); logger.debug(nfe.toString(), nfe); } logger.debug("DefaultLineItemHandler.setLineFields - Unit List Price = " + baseLineItemVO.getUnitListPrice()); logger.debug("DefaultLineItemHandler.setLineFields - Display Unit List Price = " + baseLineItemVO.getDisplayUnitListPrice()); baseLineItemVO.setExtendedPrice( !invoiceVO.isPhoneRoomMessagesFlag()?InvoiceLineBL.getExtendedPrice(baseLineItemVO):PhoneRoomInvoiceLineBL.getExtendedPrice(baseLineItemVO,remoteStoreIP,null)); baseLineItemVO.setDisplayExtendedPrice( !invoiceVO.isPhoneRoomMessagesFlag()?InvoiceLineBL.getDisplayExtendedPrice(baseLineItemVO):PhoneRoomInvoiceLineBL.getDisplayExtendedPrice(baseLineItemVO,remoteStoreIP)); baseLineItemVO.setExtendedSaved(InvoiceLineBL.getExtendedSaved(baseLineItemVO)); if (!isReturnItem) { baseLineItemVO.setTaxable1(BooleanParser.parseBoolean("Y", "N", invoiceLineEntryPanel.fldTax.getText())); baseLineItemVO.setTaxable2(BooleanParser.parseBoolean("Y", "N", invoiceLineEntryPanel.fldSecondaryTax.getText())); } baseLineItemVO.setLOC(loc); if(!invoiceVO.isPhoneRoomMessagesFlag()){ InvoiceLineBL.setDoesnotAffectSalesHistory(baseLineItemVO, customerVO); }else{ PhoneRoomInvoiceLineBL.setDoesnotAffectSalesHistory(baseLineItemVO, customerVO, remoteStoreIP); } } protected void setStoreDependentDisplay() { if (!clientApplicationContext.isLoggedInAsPhoneRoom()) { Profile profile = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()); invoiceLineEntryPanel.lblDC.setVisible(profile.getStoreProfile().getDcStore().booleanValue() && profile.getStoreProfile().getDcStoreHasInventory().booleanValue()); invoiceLineEntryPanel.fldDC.setVisible(profile.getStoreProfile().getDcStore().booleanValue() && profile.getStoreProfile().getDcStoreHasInventory().booleanValue()); } } protected void setTaxTableDependentDisplay() { boolean showField = false; if (invoiceVO.getSavedInvoiceIdForDeletion() != null) { showField = ((invoiceVO.getSecondaryTaxTableID() != null && invoiceVO .getSecondaryTaxTableID().shortValue() > 0)); } else { if(!invoiceVO.isPhoneRoomMessagesFlag()) { showField = (invoiceVO.getPrimaryTaxTableVO() != null) && (((invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() != null) && (invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() .shortValue() > 0)) || (CommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO))); }else{ showField = (invoiceVO.getPrimaryTaxTableVO() != null) && (((invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() != null) && (invoiceVO.getPrimaryTaxTableVO().getSecondaryTaxTableID() .shortValue() > 0)) || (PhoneRoomCommonInvoiceLineBL.isDeliverySecondaryTaxExists(customerVO,remoteStoreIP))); } } invoiceLineEntryPanel.lblSecondaryTax.setVisible(showField); invoiceLineEntryPanel.fldSecondaryTax.setVisible(showField); } public InvoiceLineItemVO getLineItemVO() { return baseLineItemVO; } public void setInventoryVO(InventoryVO inventoryVO) { this.inventoryVO = inventoryVO; } InventoryVO getInventoryVO() { return inventoryVO; } PricesOutVO getPricesVO() { return prices; } InvoiceVO getInvoiceVO() { return invoiceVO; } CustomerVO getCustomerVO() { return customerVO; } public void setPrices(PricesOutVO prices) { this.prices = prices; } public void setMiscChg(MiscChgVO miscChgVO) { this.miscChgVO = miscChgVO; } protected void handleSupersede() { if (invoiceLineEntryPanel.btnSupersede.isEnabled()) { // Set the remote store number & customer number for the sake of getting supersede parts quantity // from remote store if employee logged in as phone room supersedeController.setRemoteStoreNumber(invoiceVO.getRemoteStoreNumber()); supersedeController.setInitialData(inventoryVO, customerVO.getID(), customerVO.getCustomerTypeCD()); supersedeController.setViewVisible(true); SupersedePartVO supersedePartVO = (SupersedePartVO) supersedeController.getModel(); if (supersedeController.getModel() != null) { invoiceLineEntryPanel.fldPartNumber.setText(supersedePartVO.getSupersedingPartNumber()); expandedPartNumber = supersedePartVO.getSupersedingPartNumber(); invoiceLineEntryPanel.slfLine.setText(supersedePartVO.getSupersedingLineAbbrev()); if(clientApplicationContext.isLoggedInAsPhoneRoom() && supersedePartVO.getStockOnHand() != null && invoiceVO.getRemoteStoreNumber() != null) { String availableString = supersedePartVO.getStockOnHand().toString() + " @ Store " + InvoiceBL.formatStoreNumber(invoiceVO.getRemoteStoreNumber()); appendToLine(InvoiceLineEntryPanel.LBL_LINE1_NAME, 1205, new String[] {availableString}, false); if(baseLineItemVO != null) { baseLineItemVO.setPhoneRoomItems(new ArrayList()); } } if(baseLineItemVO.isCompletedLine()){ deleteInvoiceLineItem(baseLineItemVO.getQuantityBilled()); setQuantityToDisplay(baseLineItemVO.getQuantityBilled().toString()); } final BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(supersedePartVO.getSupersedingPartNumber()); baseInventoryVO.setExpandedPartNumber(supersedePartVO.getSupersedingPartNumber()); baseInventoryVO.setLineAbbrev(supersedePartVO.getSupersedingLineAbbrev()); isSupersedingPart = true; if (clientApplicationContext.isLoggedInAsPhoneRoom() && baseLineItemVO.getPartNum() != null) { baseLineItemVO.setPartNum(null); } if(isSupersedingPart){ //reset special Order value to avoid usage of previous part status code. baseLineItemVO.setSpecialOrder(TsoConstant.LOCAL); } SwingUtilities.invokeLater(new Runnable() { public void run() { displayPartDetail(baseInventoryVO); } }); } } } protected void handleNAPATotalCredit() { } protected void handleNAPAAuthorizationNumber() { } protected boolean checkMaxInvoiceLinesReached(int linesToAdd) { boolean maxLinesReached = InvoiceLineBL.isMaximumLinesExceeded(invoiceVO.getLineItems().size(), linesToAdd); if (maxLinesReached) { SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "1356"); } }); PointOfSaleEventDispatcher.getInstance().fireMaxLinesInvoiced(new PointOfSaleListEvent(this, invoiceVO)); return true; } return false; } //called when '%', 'R', or 'T' has been typed at the PD field. public void displayPercentField(boolean percent) { if (percent && invoiceLineEntryPanel.fldPD.isVisible()) { //display the percent field invoiceLineEntryPanel.lblPercent.setVisible(true); invoiceLineEntryPanel.lblPercent.setEnabled(true); invoiceLineEntryPanel.fldPercent.setVisible(true); invoiceLineEntryPanel.fldPercent.setEnabled(true); invoiceLineEntryPanel.lblPercent.setText(invoiceLineEntryPanel.fldPD.getText()); baseLineItemVO.setPriceDecision(invoiceLineEntryPanel.fldPD.getText()); } else if (invoiceLineEntryPanel.fldPercent.isVisible()) { //display the PD field invoiceLineEntryPanel.lblPercent.setText(""); invoiceLineEntryPanel.lblPercent.setText(""); invoiceLineEntryPanel.fldPD.setVisible(true); invoiceLineEntryPanel.fldPD.setEnabled(true); } } private Short getBarcodePkgQty(BarcodeVO barcodeVO) { if (barcodeVO == null) { return new Short("1"); } else { BaseInventoryVO baseInvVO = new BaseInventoryVO(); baseInvVO.setPartNumber(barcodeVO.getPartNumber()); baseInvVO.setLineAbbrev(barcodeVO.getLineAbbrev()); InventoryVO invVO = clientApplicationContext.getInventoryDAO().getPartDetailInfo(customerVO, baseInvVO, false); if (invVO == null || invVO.getStandardPkg().intValue() == 0) { return new Short("1"); } else { return invVO.getStandardPkg(); } } } protected void handleOtherStores() {} protected void handleBarcode() { if (invoiceLineEntryPanel.btnBarcode.isEnabled()) { barcodeEntryController.reset(); barcodeEntryController.setViewVisible(true); BarcodeVO barcodeVO = (BarcodeVO) barcodeEntryController.getModel(); if (barcodeVO != null) { String bcNotOnFile = barcodeVO.getTmpBarcodeEntry(); if (bcNotOnFile == null | bcNotOnFile.equals("")) { if(barcodeVO.getPkgQty()==null || barcodeVO.getPkgQty().intValue()==0){ barcodeVO.setPkgQty(getBarcodePkgQty(barcodeVO)); } invoiceLineEntryPanel.fldPartNumber.setText(barcodeVO.getPartNumber()); invoiceLineEntryPanel.slfLine.setText(barcodeVO.getLineAbbrev()); invoiceLineEntryPanel.fldQuantity.setText(barcodeVO.getPkgQty().toString()); baseLineItemVO.setPartNum(barcodeVO.getPartNumber()); baseLineItemVO.setExpandedPartNum(barcodeVO.getPartNumber()); baseLineItemVO.setLineAbbr(barcodeVO.getLineAbbrev()); baseLineItemVO.setQuantityBilled(new BigDecimal(invoiceLineEntryPanel.fldQuantity.getText())); invoiceLineEntryPanel.lblLine.setEnabled(true); invoiceLineEntryPanel.slfLine.setEnabled(true); invoiceLineEntryPanel.btnBarcode.setEnabled(false); final BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(barcodeVO.getPartNumber()); baseInventoryVO.setLineAbbrev(barcodeVO.getLineAbbrev()); invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(false); SwingUtilities.invokeLater(new Runnable() { public void run() { displayPartDetail(baseInventoryVO); } }); }else { invoiceLineEntryPanel.fldPartNumber.setText(bcNotOnFile); //1214 = 3,N,Barcode not on file. Do you wish to add? appendToLine(InvoiceLineEntryPanel.LBL_LINE4_NAME, 1214, null, true); invoiceLineEntryPanel.fldYN.setVisible(true); invoiceLineEntryPanel.fldYN.setEnabled(true); } } } } protected void handleYN() { String response = invoiceLineEntryPanel.fldYN.getText(); if (response.equals("Y")){ clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); invoiceLineEntryPanel.fldYN.setVisible(false); invoiceLineEntryPanel.fldYN.setEnabled(false); addBarcodeController = new AddBarcodeController(invoiceLineEntryPanel); String barCodeToAdd = (invoiceLineEntryPanel.fldPartNumber.getText()).substring(2); final BarcodeVO barcodeVO = new BarcodeVO(); barcodeVO.setBarcode(barCodeToAdd); barcodeVO.setModByEmployeeLOC(loc); barcodeVO.setModByEmployeeID(clientApplicationContext.getCurrentUser().getEmployeeId()); addBarcodeController.setBarcodeVO(barcodeVO); addBarcodeController.setComponentFocus(((AddBarcodeDialog) addBarcodeController.getView()).fldProductLine); ((AddBarcodeDialog) addBarcodeController.getView()).setVisible(true); //User clicked [Ok] after entering the appropriate data to add to Barcode if (addBarcodeController.isBarAdded()) { invoiceLineEntryPanel.fldPartNumber.setText(barcodeVO.getPartNumber()); invoiceLineEntryPanel.slfLine.setText(barcodeVO.getLineAbbrev()); invoiceLineEntryPanel.fldQuantity.setText(barcodeVO.getPkgQty().toString()); baseLineItemVO.setPartNum(barcodeVO.getPartNumber()); baseLineItemVO.setExpandedPartNum(barcodeVO.getPartNumber()); baseLineItemVO.setLineAbbr(barcodeVO.getLineAbbrev()); baseLineItemVO.setQuantityBilled(new BigDecimal(barcodeVO.getPkgQty().toString())); final BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); baseInventoryVO.setPartNumber(barcodeVO.getPartNumber()); baseInventoryVO.setLineAbbrev(barcodeVO.getLineAbbrev()); invoiceLineEntryPanel.lblLine.setEnabled(true); invoiceLineEntryPanel.slfLine.setEnabled(true); invoiceLineEntryPanel.btnBarcode.setEnabled(false); invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(false); displayPartDetail(baseInventoryVO); invoiceLineEntryPanel.fldDescription.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldDescription, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); }else { //User clicked [Cancel] from the Add Barcode modal invoiceLineEntryPanel.fldPartNumber.setText(""); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber.dispatchEvent( new KeyEvent(invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); } }else if (response.equals("N")){ if (invoiceLineEntryPanel.lblLine4.isVisible()) { clearLine(InvoiceLineEntryPanel.LBL_LINE4_NAME); } invoiceLineEntryPanel.fldYN.setVisible(false); } } /** * This method is used to delete the invoice line item from the list panel */ private void deleteInvoiceLineItem(BigDecimal bdQuantity) { baseLineItemVO.setQuantityEdited(true); PointOfSaleEventDispatcher.getInstance() .fireInvoiceLineItemDeleteInvoked( new PointOfSaleListEvent(this, invoiceVO)); baseLineItemVO.setQuantityEdited(false); baseLineItemVO.setDefective(Boolean.FALSE); baseLineItemVO.setReturnItems(null); baseLineItemVO.setReturnCoreItems(null); baseLineItemVO.setVehicleMake(null); baseLineItemVO.setVehicleModel(null); baseLineItemVO.setVehicleYear(null); baseLineItemVO.setVehicleVO(null); final boolean isItemReturnDetailInfoRequired =(invoiceVO!=null && invoiceVO.isPhoneRoomMessagesFlag()) ?(new TaapRouter().getInvoicingProfile(this.remoteStoreIP).getAskForItemReturnInfo().booleanValue()) :(clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()) .getInvoicingProfile().getAskForItemReturnInfo().booleanValue()); if (baseLineItemVO.isCasePrice().booleanValue() && !isRegularToCase) { if (!isItemReturnDetailInfoRequired && (baseLineItemVO.isCaseQuantity() || (baseLineItemVO.getQuantityBilled().doubleValue() < 0.00 && bdQuantity.doubleValue() < 0.0))) { // Code added to display the old price in the unit price field in the following // scenarios with "Item Return Info Required" flag off. // i.When user changes the quantity of a return item which is a case transaction // to a different negative value. // ii.When user enters quantity as case, while changing the quantity of a line // item(return/purchase) which is a case transaction to different // value(negative/positive). setPriceAttributes(false); } else if (!baseLineItemVO.isCaseQuantity()) { // Code added to display the price from "getPrice" functionality and to clear the // case item flag and case price during the following scenario: // i. When user changes the quantity of a line item(return/positive) which is a case // transaction to different value(negative/positive) without entering quantity as // case. baseLineItemVO.setCompletedLine(false); baseLineItemVO.setCasePrice(Boolean.FALSE); // Code added to change the document of the PD field. setPDFieldDocument(); setPriceAttributes(false); } } baseLineItemVO.setCompletedLine(false); baseLineItemVO.setId(null); invoiceLineEntryPanel.btnDelete.setEnabled(false); } /** * This method is used to reset the description of return item * */ private void resetDescription(){ if(inventoryVO.getDescription() != null && inventoryVO.getDescription().length() > 0){ baseLineItemVO.setPartDescription(inventoryVO.getDescription()); invoiceLineEntryPanel.fldDescription.setText(baseLineItemVO.getPartDescription()); } else{ baseLineItemVO.setPartDescription(""); invoiceLineEntryPanel.fldDescription.setText(""); } } /** * This method is used to reset the attributes of return item. * @param baseLineItemVO value object for return item. */ private void resetAttributesOfReturnItem(BaseLineItemVO baseLineItemVO) { String storeLanguageCd = clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()).getStoreProfile().getRefLanguageCd(); String coreDescription = null; String warrantyDescription = null; try { coreDescription = clientApplicationContext.getRefTableDAO().getInvoiceLineDescription( new Integer(RefInvoiceLineItemDescription.CORE_DEPOSIT), storeLanguageCd); warrantyDescription = clientApplicationContext.getRefTableDAO() .getInvoiceLineDescription(new Integer(RefInvoiceLineItemDescription.WARRANTY), storeLanguageCd); } catch (ApplicationException applicationException) { logger.error("Error occured while retreiving invoice line description" + applicationException.toString(), applicationException); } String partDesc = baseLineItemVO.getPartDescription(); /** * Code added to reset the description : * i. If merchandise or defective return is made while editing a * core return item. * ii. If merchandise or core return is made while editing a * defective return item. */ if (!baseLineItemVO.isSpecialFnCorSelected() && ((partDesc.equals(coreDescription) && !baseLineItemVO.isCoreTransaction().booleanValue()) || (partDesc.equals(warrantyDescription) && !baseLineItemVO.isDefective().booleanValue()))) { resetDescription(); } /** * Code added to reset the price attributes : * i.If merchandise or defective return is made while editing a * core return item. */ if (!baseLineItemVO.isSpecialFnCorSelected() && partDesc.equals(coreDescription) && !baseLineItemVO.isCoreTransaction().booleanValue()) { setPriceAttributes(true); } } /** * This method is used to check whether supersede button can be enabled or disabled. * * Supersede button is disabled regardless of part having superseding part or not when * any one of the below condition is satisfied : * i.When negative quantity is entered during invoice line entry * ii.When return part or core line item is selected for editing. * iii.When replacement part line item created while creating a defective return with * replacement is selected for editing. * iv. When a part line item associated with return core is selected for editing * v. If it is a system generated core line item. * * @param bdQuantity is the quantity entered during invoice line entry. * @return boolean value indicates whether supersede button can be enabled or disabled. */ protected boolean canEnableSupersedeButton(BigDecimal bdQuantity){ if ((bdQuantity != null && bdQuantity.signum() < 0) || (baseLineItemVO != null && (baseLineItemVO.getQuantityBilled().signum() < 0 || baseLineItemVO.isUsedForReturn() || (baseLineItemVO.getGeneratedByLineItem() != null && ((baseLineItemVO.getQuantityBilled().signum() > 0 && ((InvoiceLineItemVO) baseLineItemVO .getGeneratedByLineItem()).getQuantityBilled() .signum() < 0) || baseLineItemVO.isCoreTransaction().booleanValue()))))) { return false; } else if (inventoryVO != null) { boolean supersedesExist = clientApplicationContext.getInventoryDAO().doSupersedesExist( inventoryVO); return supersedesExist; } return false ; } /** * This method is used to set the document to the PD field. */ public void setPDFieldDocument() { // Code modified for Tender Types. // Set the PD field document to allow only whole numbers in PD field for NAPA Gift Card. if (baseLineItemVO != null && (baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD)) { invoiceLineEntryPanel.fldPD.setDocument(new DefaultDocument( invoiceLineEntryPanel.fldPD, FwiConstant.NUMERIC)); } else if (baseLineItemVO != null && baseLineItemVO.isCasePrice().booleanValue()) { invoiceLineEntryPanel.fldPD.setDocument(new PDDocument(new Character[] { PDDocument.C })); } else { Character [] validOptionCharacters = new Character[] {PDDocument.L, PDDocument.G, PDDocument.Y, PDDocument.N, PDDocument.P, PDDocument.ASTERISK, PDDocument.J, PDDocument.PERCENT, PDDocument.Z, PDDocument.A, PDDocument.U, PDDocument.S, PDDocument.R, PDDocument.B, PDDocument.EXCLAMATION, PDDocument.ATSIGN}; if (!clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getStoreProfile().getStoreType().equals("J")) { Character [] temp = new Character [validOptionCharacters.length + 1]; System.arraycopy(validOptionCharacters, 0, temp, 0, validOptionCharacters.length); temp[temp.length - 1] = PDDocument.E; validOptionCharacters = temp; } if (clientApplicationContext.getProfile(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation() ).getStoreProfile().getUseAvgCost().booleanValue()) { Character [] temp = new Character [validOptionCharacters.length + 2]; System.arraycopy(validOptionCharacters, 0, temp, 0, validOptionCharacters.length); temp[temp.length - 1] = PDDocument.V; temp[temp.length - 2] = PDDocument.T; validOptionCharacters = temp; } invoiceLineEntryPanel.fldPD.setDocument(new PDDocument(validOptionCharacters)); } } /** * This method is used to set the original item return price values. */ private void resetRegularPriceValues() { final String methodSpec = " DefaultLineItemHandler.resetRegularPriceValues() - "; FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance( FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); fwoNumberPattern.setMinFractionDigits(clientApplicationContext.getSystemDAO() .getPriceScale().intValue()); fwoNumberPattern.setMaxFractionDigits(clientApplicationContext.getSystemDAO() .getPriceScale().intValue()); baseLineItemVO.setCasePrice(Boolean.FALSE); baseLineItemVO.setCaseQuantity(false); setPDFieldDocument(); invoiceLineEntryPanel.fldPD.setText(baseLineItemVO.getPriceDecision()); invoiceLineEntryPanel.fldUnit.setText(unitValue); logger.debug(methodSpec + " fldPrice : Unit Price = " + baseLineItemVO.getUnitPrice() + ", Display Unit Price = " + baseLineItemVO.getDisplayUnitPrice()); try { invoiceLineEntryPanel.fldPrice.setText(fwoNumberPattern.format(displayPriceWithTax() ? baseLineItemVO.getDisplayUnitPrice() : baseLineItemVO.getUnitPrice())); } catch (NumberPatternFormatException npfe) { logger.error("Error occured while formatting the price" + npfe.getMessage()); } isRegularToCase = false; } /** * Clears and resets fields and sets the focus on Part Number after acknowledgment of alert * messages when NAPA Gift Card is entered on few selected special functions. */ protected void handleSplFunctionsForNgc() { invoiceLineEntryPanel.slfLine.setText(""); invoiceLineEntryPanel.fldPartNumber.setText(""); invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); displayLineItem(); invoiceLineEntryPanel.slfSpecialFunctions.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.slfSpecialFunctions, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_ENTER, '\n')); } /** * Sets default quantity 1 for a NAPA Gift Card. */ private void setDefaultQuantityForGiftCards() { String currentLineAbbrev = invoiceLineEntryPanel.slfLine.getText(); if ((baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NAPA_GIFT_CARD || baseLineItemVO.getRefInvoiceLineItemTypeID().intValue() == RefInvoiceLineItemType.NEW_NAPA_GIFT_CARD) && baseLineItemVO.getQuantityBilled().doubleValue() >= 0 && (currentLineAbbrev != null && currentLineAbbrev.length() != 0 && (currentLineAbbrev.equalsIgnoreCase(TsoConstant.NGC_LINE_ABBREV) || currentLineAbbrev.equalsIgnoreCase(TsoConstant.NEW_NGC_LINE_ABBREV)))) { this.setQuantityToDisplay(QUNATITY_FOR_GIFT_CARDS); setQuantityEnabled(true); } } /** * Returns the business approved minimum and maximum price values for initial sale or reload. * * @return An array of {@link String} objects with business approved minimum and maximum * price values. */ private String[] getMessageParams() { String[] messageParams = new String[2]; if (!isNapaGiftCardReload) { messageParams[0] = Integer.toString(SELL_MIN_VALUE); messageParams[1] = Integer.toString(SELL_MAX_VALUE); } else if (isNapaGiftCardReload) { messageParams[0] = Integer.toString(RELOAD_MIN_VALUE); messageParams[1] = Integer.toString(RELOAD_MAX_VALUE); } return messageParams; } /** * This method will check weather the customer is having alternate core customer or not * If customer is having alternate core customer and transaction is a core transaction and the * alternate core customer primary tax status is NEVER then this method will return true. * If customer is not having alternate core customer or transaction is not a core transaction * and the primary tax status is NEVER then this method will return true. * If non of the above conditions satisfy then this method will return false. * @param customerVO - Current customer details. * @return - true if conditions satisfy, if not false. */ private boolean canEnablePrimaryTax(CustomerVO customerVO, BaseLineItemVO baseLineItemVO) { if (((customerVO.getAlternateCoreCustomerTax() == null || !baseLineItemVO .isCoreTransaction().booleanValue()) && customerVO.getTaxStatusPrimaryRefOptionCD() .equals(Tax.NEVER)) || (customerVO.getAlternateCoreCustomerTax() != null && baseLineItemVO.isCoreTransaction().booleanValue() && customerVO .getAlternateCoreCustomerTax().getTaxStatusPrimaryRefOptionCD().equals( Tax.NEVER))) { return true; } return false; } /** * This method will check weather the customer is having alternate core customer or not * If customer is having alternate core customer and transaction is a core transaction and the * alternate core customer secondary tax status is NEVER then this method will return true. * If customer is not having alternate core customer or transaction is not a core transaction * and the secondary tax status is NEVER then this method will return true. * If non of the above conditions satisfy then this method will return false. * @param customerVO - Current customer details. * @return - true if conditions satisfy, if not false. */ private boolean canEnableSecondaryTax(CustomerVO customerVO, BaseLineItemVO baseLineItemVO) { if (((customerVO.getAlternateCoreCustomerTax() == null || !baseLineItemVO .isCoreTransaction().booleanValue()) && customerVO .getTaxStatusSecondaryRefOptionCD().equals(Tax.NEVER)) || (baseLineItemVO.isCoreTransaction().booleanValue() && customerVO.getAlternateCoreCustomerTax() != null && customerVO .getAlternateCoreCustomerTax().getTaxStatusSecondaryRefOptionCD().equals( Tax.NEVER))) { return true; } return false; } // Added for RGN:Invoicing /* * (non-Javadoc) * @see com.gpc.client.pointofsale.invoice.line.AbstractLineItemHandler#handleWlcNoteLine() */ protected void handleWlcNoteLine() { } /** * This method gets the RGN special instruction value and displays the RGN special instruction * to the user. This method also displays return messages for rgn types that don't have control * file information */ private void displayRgnSpeicialInstruction() { RGNTypeVO rgnTypeVo = null; try { // Get the RGN Type and RGN special instruction from the control file rgnTypeVo = InvoiceBL.getRgnSpecialInstruction(baseLineItemVO, inventoryVO); } catch (ApplicationException e) { logger.error( "Application Exception is thrown while displaying the special instruction", e); clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "8159"); } if (rgnTypeVo != null && rgnTypeVo.getRGNType() != null) { final SpecialInstructionController specialInstructionController = new SpecialInstructionController(invoiceLineEntryPanel); specialInstructionController.setRgnTypeLabel(rgnTypeVo); specialInstructionController.setSpecialInstructionLabel(rgnTypeVo .getSpecialInstruction()); SwingUtilities.invokeLater(new Runnable() { public void run() { ((SpecialInstructionDialog) specialInstructionController.getView()) .setVisible(true); } }); } else { // Check for part numbers that don't have controlFileInfoAvailable if (inventoryVO != null && inventoryVO.getWarrantyVO() == null && inventoryVO.getProRataWarrantyList() == null && baseLineItemVO.isDefective().booleanValue()) { String refLanguageCd = ClientApplicationContext.getClientApplicationContext() .getCurrentUser().getRefLanguageCd(); try { if (!baseLineItemVO.isKitPart()) { List rgnTypes = RGNControlFileServiceFactory.getServiceInstance() .getRGNType(baseLineItemVO.getLineAbbr(), baseLineItemVO.getPartNum(), loc, refLanguageCd); if (!isControlFileInfoAvailable(rgnTypes)) { if (inventoryVO.getSupplierID() != null) { int supplierId = inventoryVO.getSupplierID().intValue(); String tempMessageNumber = null; if (supplierId == TsoConstant.SUPPLIER_NON_NAPA || supplierId == TsoConstant.SUPPLIER_P_AND_E) { tempMessageNumber = "8164"; } else if (supplierId == TsoConstant.SUPPLIER_NAPA || supplierId == TsoConstant.SUPPLIER_NAPA_DIRECT_SHIP) { tempMessageNumber = "8165"; } final String messageNumber = tempMessageNumber; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getMessageMgr().showMessage( invoiceLineEntryPanel, messageNumber); } }); } } } } catch (ApplicationException e) { logger.error("Error occured while getting the RGN Type info", e); clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "8159"); } } } } // ===================== /** * This method verifies whether Control File Information is available for a return line items or * not. * * @param rgnTypes RGN Types List * @return true, if control file information available else returns false. */ private boolean isControlFileInfoAvailable(List rgnTypes) { return (rgnTypes != null && !rgnTypes.isEmpty()); } /* * When IPC is on, check Integrated Payment Card criteria: a terminal not associated with a payment device needs to prevent the counterperson * from invoicing a NAPA Gift Card reload if INVOICING_PROFILE.USE_INTEGRATED_PAYMENTS is in 1 or 11. */ private boolean ipcChecked() { return (IntegratedPaymentCardHelper.getInstance().isEnabledAndConnected(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation())) || !(IntegratedPaymentCardHelper.getInstance().isEnabled(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation())); } private boolean ipcInUse () { return IntegratedPaymentCardHelper.getInstance().isEnabledAndConnected(Profile.POINT_OF_SALE_CLIENT, clientApplicationContext.getLocation()); } /** * This method verifies whether the customer has a valid certificate to buy the part. * * @param bdQuantity Contains value of Quantity field. * @return true, if customer is eligible to buy the part else returns false. */ protected boolean validatePartCertificate(BigDecimal bdQuantity) { if(baseLineItemVO.isCoreItem()) { return true; } if(baseLineItemVO.getGeneratedByLineItem() != null) { return true; } if(baseLineItemVO.isWarrantyLaborClaim().booleanValue()) { return true; } InvoicingProfileVO invoicingProfileVO = (!invoiceVO.isPhoneRoomMessagesFlag())?clientApplicationContext .getProfile(Profile.POINT_OF_SALE_CLIENT,clientApplicationContext.getLocation()) .getInvoicingProfile():(new TaapRouter().getInvoicingProfile(remoteStoreIP)); if (inventoryVO != null && invoicingProfileVO.getEnableValidateCertificate().booleanValue()) { baseLineItemVO.setInvoiceLineItemCertification(null); boolean isEligibleForPartSale ; if (!invoiceVO.isPhoneRoomMessagesFlag()) { isEligibleForPartSale = InvoiceLineBL.checkForPartSaleAndPopulateCertInfo(loc, invoiceVO.getCustomerID(), inventoryVO, baseLineItemVO, bdQuantity); } else { isEligibleForPartSale = PhoneRoomInvoiceLineBL.checkForPartSaleAndPopulateCertInfo(loc, invoiceVO.getCustomerID(), inventoryVO, baseLineItemVO, bdQuantity, remoteStoreIP); } // if block sale enabled, do not show the certification errors. if (!isEligibleForPartSale && bdQuantity.doubleValue() > 0) { if(baseLineItemVO.isCompletedLine()) { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoiceLineEntryPanel, "9944"); invoiceLineEntryPanel.fldQuantity.setText(baseLineItemVO .getQuantityBilled().toString()); } else { ClientApplicationContext.getClientApplicationContext() .getMessageMgr().showMessage(invoiceLineEntryPanel, "9940"); resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber .dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); } return false; } } return true; } /** * This method verifies whether the part blocked for sale or not. * * @param bdQuantity Contains value of Quantity field. * @return true, if customer is eligible to buy the part else returns false. */ protected boolean isPartElegibleForSale(BigDecimal bdQuantity, boolean isPhoneRoom) { if (bdQuantity.doubleValue() > 0 && inventoryVO != null) { boolean isPartEligibleForSale = InvoiceLineBL.isPartEligibleForSale(baseLineItemVO.getPartNum(), baseLineItemVO.getLineAbbr(), inventoryVO.getDescription(), invoiceLineEntryPanel, customerVO , baseLineItemVO.isKitPart(), isPhoneRoom); if (!isPartEligibleForSale) { invoiceLineEntryPanel.fldQuantity.setText(""); invoiceLineEntryPanel.fldQuantity.setEnabled(false); resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber); SwingUtilities.invokeLater(new Runnable() { public void run() { invoiceLineEntryPanel.fldPartNumber.dispatchEvent(new KeyEvent( invoiceLineEntryPanel.fldPartNumber, KeyEvent.KEY_PRESSED, new java.util.Date().getTime(), 0, KeyEvent.VK_TAB, '\t')); } }); return false; } } return true; } /** * This method resets the Entry Area. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ protected void resetEntryArea(Component exceptionLabelComponent, Component exceptionFieldComponent) { resetLineEntryArea(exceptionLabelComponent, exceptionFieldComponent); resetNoteEntryArea(exceptionLabelComponent, exceptionFieldComponent); resetNAPAOnlineArea(exceptionLabelComponent, exceptionFieldComponent); resetFunctionsArea(exceptionLabelComponent, exceptionFieldComponent); resetSpecialFunctions(0,true); invoiceLineEntryPanel.btnDelete.setVisible(true); invoiceLineEntryPanel.btnDelete.setEnabled(false); invoiceLineEntryPanel.fldYN.setVisible(false); invoiceLineEntryPanel.pnlInvoiceNoteEntry.setVisible(false); invoiceLineEntryPanel.pnlNapaOnline.setVisible(false); invoiceLineEntryPanel.pnlInvoiceLineEntry.setVisible(true); } /** * This method resets the Invoice Line Entry Panel. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ private void resetLineEntryArea(Component exceptionLabelComponent, Component exceptionFieldComponent) { Component components[] = invoiceLineEntryPanel.pnlInvoiceLineEntry.getComponents(); Component component = null; for (int i = 0; i < components.length; i++) { component = components[i]; if (!component.equals(exceptionLabelComponent) && !component.equals(exceptionFieldComponent) && !component.hasFocus()) { component.setEnabled(false); } if (component instanceof JTextField && !component.hasFocus()) { ((JTextField) component).setText(""); } if (component.getName().startsWith(InvoiceLineEntryPanel.LBL_LINE1_NAME.substring(0, 6)) && component.getName().length() > 7) { ((JLabel) component).setText(""); } } invoiceLineEntryPanel.slfLine.getTableModel().removeAllRows(); setPartNumberEnabled(true); } /** * This method resets the Note Entry Area. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ private void resetNoteEntryArea(Component exceptionLabelComponent, Component exceptionFieldComponent) { Component components[] = invoiceLineEntryPanel.pnlInvoiceNoteEntry.getComponents(); Component component = null; for (int i = 0; i < components.length; i++) { component = components[i]; if (!component.equals(exceptionLabelComponent) && !component.equals(exceptionFieldComponent) && !component.hasFocus()) { component.setEnabled(false); } if (component instanceof JTextField && !component.hasFocus()) { ((JTextField) component).setText(""); } } } /** * This method resets the NAPA Online Area. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ private void resetNAPAOnlineArea(Component exceptionLabelComponent, Component exceptionFieldComponent) { Component components[] = invoiceLineEntryPanel.pnlNapaReturnAuthNum.getComponents(); Component component = null; for (int i = 0; i < components.length; i++) { component = components[i]; if (component instanceof JTextField && !component.hasFocus()) { ((JTextField) component).setText(""); } } } /** * This method resets the Functions Area. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ private void resetFunctionsArea(Component exceptionLabelComponent, Component exceptionFieldComponent) { invoiceLineEntryPanel.pnlFunctions.setVisible(true); if (!invoiceLineEntryPanel.slfSpecialFunctions.equals(exceptionFieldComponent) && !invoiceLineEntryPanel.slfSpecialFunctions.hasFocus()) { invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(true); } if(!ClientApplicationContext.getClientApplicationContext().isCatalogInUse()){ invoiceLineEntryPanel.btnCheckOtherStores.setVisible(false); invoiceLineEntryPanel.btnBarcode.setVisible(true); } invoiceLineEntryPanel.btnBarcode.setEnabled(false); if (clientApplicationContext.isLoggedInAsPhoneRoom()) { invoiceLineEntryPanel.btnBarcode.setVisible(true); invoiceLineEntryPanel.btnOtherStores.setVisible(false); } invoiceLineEntryPanel.btnCheckOtherBalances.setEnabled(false); invoiceLineEntryPanel.btnPartInfo.setEnabled(false); if (invoiceVO.getLineItems() != null && !invoiceVO.getLineItems().isEmpty() && LineGenerationQueue.getInstance().isEmpty()) { } else { invoiceLineEntryPanel.btnFinalize.setEnabled(false); if (invoiceVO.getLineItems() == null || invoiceVO.getLineItems().isEmpty()) { FwoNumberPattern fwoNumberPattern = (FwoNumberPattern) FwoPattern.getNumberPatternInstance(FwoNumberPattern.DECIMAL, clientApplicationContext.getCurrentLocale(), true); try { invoiceLineEntryPanel.dlblSubtotal.setText(fwoNumberPattern.format( "0.00").toString()); invoiceLineEntryPanel.dlblAlternateCoreSubtotal.setText(fwoNumberPattern.format( "000,000.00").toString()); } catch (NumberPatternFormatException npfe) { } } if (customerVO == null) { invoiceLineEntryPanel.pnlAlternateCoreSubtotal.setVisible(false); } } invoiceLineEntryPanel.lblSubtotal.setEnabled(true); invoiceLineEntryPanel.dlblSubtotal.setEnabled(true); } /** * This method resets the Special Functions Area. * * @param exceptionLabelComponent,exceptionFieldComponent Contains the Label and Field components. */ public void resetSpecialFunctions(int index, boolean enabled) { invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(index); invoiceLineEntryPanel.slfSpecialFunctions.setEnabled(enabled); } //Code added for NDT to reset processed values for parts and set Message to unacknowledged when return info is not captured. private void unAcknowledgeMessageIfPartsExist() { Integer messageHeaderId; int numOfRowsUpdated = 0; SalesOrderVO salesOrderVO = invoiceVO.getSalesOrderVO(); if (salesOrderVO != null) { Integer salesOrderId = salesOrderVO.getId(); try { messageHeaderId = clientApplicationContext.getMessageDAO().findMessageHeaderIdBySalesOrderId( salesOrderId, new Integer(clientApplicationContext.getLocation())); if (messageHeaderId != null) { numOfRowsUpdated = clientApplicationContext.getMessageDAO() .updatePartProcessedValues(messageHeaderId); if (numOfRowsUpdated > 0) { final MessageHeaderVO messageHeaderVO = clientApplicationContext.getMessageDAO() .findMessageByID(messageHeaderId, null); if (messageHeaderVO != null) { messageHeaderVO.setAcknowledgedByEmpID(null); messageHeaderVO.setAcknowledgedDate(null); messageHeaderVO.setInvoicedByEmpID(null); clientApplicationContext.getMessageDAO().updateInvoicedByEmpId(messageHeaderVO); boolean updateFlag = clientApplicationContext.getMessageDAO() .updateMessageHeader(null, messageHeaderVO).booleanValue(); } } } } catch (ApplicationException e) { logger.error("Exception occured while unacknowledging if parts exists : "+e.getMessage()); } catch (RemoteException e) { logger.error("Exception occured while unacknowledging if parts exists : "+e.getMessage()); } } } /** * Mark the line items as processed in DB * @param baseLineItemVO */ private void updateMessagePartAsProcessed(BaseLineItemVO baseLineItemVO) { Integer messageHeaderId; int numOfRowsUpdated = 0; if (invoiceVO != null) { SalesOrderVO salesOrderVO = invoiceVO.getSalesOrderVO(); if (salesOrderVO != null) { Integer salesOrderId = salesOrderVO.getId(); try { if (salesOrderId != null) { messageHeaderId = clientApplicationContext.getMessageDAO().findMessageHeaderIdBySalesOrderId( salesOrderId, new Integer(clientApplicationContext.getLocation())); if (messageHeaderId != null && baseLineItemVO != null) { String itemReturnProcessed = "N"; clientApplicationContext.getMessageDAO().updateMessagePartWithReturnInfo(messageHeaderId, itemReturnProcessed, baseLineItemVO.getLineAbbr(), baseLineItemVO.getPartNum()); } } } catch (ApplicationException e) { logger.error("Exception occured while updating message part as processed : "+e.getMessage()); e.printStackTrace(); } catch (RemoteException e) { logger.error("Exception occured while updating message part as processed : "+e.getMessage()); e.printStackTrace(); } } } } /** * Handle the next return item in the list for processing. * If no more items left for processing, message popup stating it and checkout enabled. * If any return items were skipped, mark the message with skipped parts as * unacknowledge for later processing. * @param invoiceVO */ public void processNextReturnItem(InvoiceVO invoiceVO) { Vector vlineItems = null; BaseLineItemVO currLineItem = null; if (invoiceVO.isReturnInvoice()) { if (invoiceVO.isReturnInvoice() && null != invoiceVO.getReturnLineItems()) { vlineItems = invoiceVO.getReturnLineItems(); for (int i = 0; i < vlineItems.size(); i++) { if (vlineItems.get(i) instanceof BaseLineItemVO && !((BaseLineItemVO) vlineItems.get(i)).isLineAddedToList()) { currLineItem = (BaseLineItemVO) vlineItems.get(i); currLineItem.setLineAddedToList(true); break; } else { if(vlineItems.get(i) instanceof InvoiceNoteVO && !((InvoiceNoteVO) vlineItems.get(i)).isLineAddedToList() ) { InvoiceNoteVO invoiceNoteVO =(InvoiceNoteVO) vlineItems.get(i); invoiceNoteVO.setCompletedLine(true); invoiceNoteVO.setLineAddedToList(true); SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemAdded( new PointOfSaleListEvent(this, invoiceNoteVO)); } }); } } } } if (null != currLineItem) { BaseLineItemVO currLineItemVO = currLineItem; SwingUtilities.invokeLater(new Runnable() { public void run() { clientApplicationContext.getPointOfSaleEventDispatcher() .fireListModelChanged(new InvoiceEvent(this, currLineItemVO)); } }); invoiceLineEntryPanel.fldOK.setEnabled(false); invoiceLineEntryPanel.fldQuantity.requestFocus(); } else { resetLineEntryArea(null, null); if (invoiceVO != null && invoiceVO.isReturnInvoice()) { unAcknowledgeMessageIfPartsExist(); } if (doesInvoiceHasAnyLineItems(invoiceVO)) { invoiceVO.setReturnInvoiceLoaded(true); baseLineItemVO = new BaseLineItemVO(); clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10301"); invoiceLineEntryPanel.btnFinalize.setEnabled(true); setPartNumberEnabled(true); invoiceLineEntryPanel.fldPartNumber.grabFocus(); } else { clientApplicationContext.getMessageMgr().showMessage(invoiceLineEntryPanel, "10305"); clientApplicationContext.getPointOfSaleEventDispatcher() .fireInvoiceCancelled(new InvoiceEvent(this, new InvoiceVO())); } } } } /** * Check if there are any return items added to invoice. * @param invoiceVO * @return true when present, false when no return item present. */ boolean doesInvoiceHasAnyLineItems(InvoiceVO invoiceVO){ boolean hasReturnItems = false; Vector lineItems = (Vector)invoiceVO.getLineItems(); for(int i = 0; i < lineItems.size(); i++){ if (lineItems.get(i) instanceof BaseLineItemVO){ hasReturnItems = true; break; } } return hasReturnItems; } /** * Skip the current line when deleted, * create a note item stating part is not returnable. * Update the deleted line item as processed * Bring up the next line item for processing. * @param baseLineItemVO * @param invoiceVO */ public void skipDeletedPartReturn(BaseLineItemVO baseLineItemVO, InvoiceVO invoiceVO) { if (invoiceVO.isReturnInvoice() && null != invoiceVO.getReturnLineItems()) { Vector vlineItems = invoiceVO.getReturnLineItems(); skipLineItemRelatedNotes(baseLineItemVO, vlineItems); for (int i = 0; i < vlineItems.size(); i++) { if (vlineItems.get(i) instanceof BaseLineItemVO && !((BaseLineItemVO) vlineItems.get(i)).isLineAddedToList()) { BaseLineItemVO currItem = (BaseLineItemVO) vlineItems.get(i); if (currItem.getPartNum().equalsIgnoreCase(baseLineItemVO.getPartNum()) && currItem.getLineAbbr().equalsIgnoreCase(baseLineItemVO.getLineAbbr())) { currItem.setLineAddedToList(true); break; } } } InvoiceNoteVO invoiceNoteVO = new InvoiceNoteVO(); invoiceNoteVO.setText("Line: "+ baseLineItemVO.getLineAbbr()+" Part: " + baseLineItemVO.getPartNum() + " is not returnable"); invoiceNoteVO.setGeneratedByLineItem(null); invoiceNoteVO.setRefInvoiceNoteTyepID(new Integer(RefInvoiceNoteType.NORMAL_MESSAGE)); invoiceNoteVO.setCompletedLine(true); invoiceNoteVO.setLOC(loc); clientApplicationContext.getPointOfSaleEventDispatcher().fireInvoiceLineItemAdded( new PointOfSaleListEvent(this, invoiceNoteVO)); if (invoiceVO != null && invoiceVO.isReturnInvoice()) { updateMessagePartAsProcessed(baseLineItemVO); } processNextReturnItem(invoiceVO); } } private boolean includePriceWithTaxPhoneRoom() { StoreProfileVO storeProfileVO = new PhoneRoomTaapRouter().getStoreProfile(getRemoteStoreIP()); boolean includePriceWithTax = storeProfileVO.getIncludeTaxInPrice()!=null?storeProfileVO.getIncludeTaxInPrice().booleanValue():false; return includePriceWithTax; } /** * Skips the notes related to invoice line item passed. * @param baseLineItemVO * @param vlineItems */ private void skipLineItemRelatedNotes(BaseLineItemVO baseLineItemVO, Vector vlineItems) { for (int i = 0; i < vlineItems.size(); i++) { if (null != baseLineItemVO && vlineItems.get(i) instanceof InvoiceNoteVO) { InvoiceNoteVO currNote = (InvoiceNoteVO) vlineItems.get(i); if (null != baseLineItemVO.getSequence() && currNote.getGeneratedBySequence() != null && baseLineItemVO.getSequence().intValue() == currNote.getGeneratedBySequence().intValue() && !currNote.isLineAddedToList()) { currNote.setLineAddedToList(true); } } } } private void handleGiftCardCashPayout(FwoNumberPattern fwoNumberPattern) { if (newNapaGiftCardController == null) { newNapaGiftCardController = new NewNapaGiftCardController(invoiceLineEntryPanel, true); } int action = newNapaGiftCardController.setViewVisible(true, true, baseLineItemVO); if (action == 1) { try { String strUnitPrice = fwoNumberPattern.format(baseLineItemVO.getUnitPrice()); invoiceLineEntryPanel.fldPrice.setText(strUnitPrice); } catch (NumberPatternFormatException npfe) { logger.error("Error occured while formatting the price" + npfe.getMessage()); } baseLineItemVO.setPriceDecision(""); setListEnabled(false); setPDEnabled(false, baseLineItemVO); logger.debug("__________ >>> call checkTax() next ..."); checkTax(); setOKEnabled(true); invoiceLineEntryPanel.fldOK.setText("Y"); JComponent fldOk = getNextFocus(invoiceLineEntryPanel.fldOK); if (fldOk != null) { fldOk.requestFocus(); } invoiceLineEntryPanel.fldOK.dispatchEvent(new KeyEvent(invoiceLineEntryPanel.fldOK, KeyEvent.KEY_PRESSED, new Date().getTime(), 0, KeyEvent.VK_ENTER, '\n')); invoiceLineEntryPanel.fldPartNumber.setEnabled(true); invoiceLineEntryPanel.fldPartNumber.requestFocusInWindow(); /* * Processing the line queue. Before this fix, line queue process was dependent on * focusGained and focusLost from 'OK' text field. This was causing lot of user experience * issues. This fix will make sure that user does not need to come back to TAMS for parts * to get added to list. */ if ((baseLineItemVO == null || baseLineItemVO.isCompletedLine()) && !LineGenerationQueue.getInstance().isEmpty()) { PointOfSaleEventDispatcher.getInstance() .fireProcessLineQueue( new PointOfSaleEvent(this, baseLineItemVO)); invoiceLineEntryPanel.slfSpecialFunctions.setSelectedRow(0); resetEntryArea(invoiceLineEntryPanel.lblPartNumber, invoiceLineEntryPanel.fldPartNumber); setPartNumberEnabled(true); } invoiceLineEntryPanel.fldPartNumber.requestFocusInWindow(); } else { // resetEntryArea(null, null); baseLineItemVO.setQuantityBilled(BigDecimal.ZERO); invoiceLineEntryPanel.fldQuantity.requestFocus(); } } /** * This method strip Barcode prefix, if New Gift card is scanned. * And allows ANY preamble (or) NO preamble. * * @param - Scanned Barcode - barcodeText * @return - String */ private String removeBarcodePrefixForGiftCards(String barcodeText) { if (barcodeText != null && !barcodeText.isEmpty() && barcodeText.startsWith("@") && barcodeText.length() > 18) { String giftCardNumber = barcodeText.substring(barcodeText.length() - 18); if (!giftCardNumber.isEmpty() && getBinRangeProfile(giftCardNumber.substring(0, 8)) != null) { partNumberFieldScanned = true; return giftCardNumber; } logger.error(" ** Invalid Barcode - Scanned/Entered barcode doesn't have valid binRange profile **"); /* When Bin Range profile doesn't exists for scanned barcode, display "Invalid Barcode". */ barcodeText = "@!NVALID_" + barcodeText; } return barcodeText; } }