protected CapitalAssetSystem getCapitalAssetSystemForIndividual( Integer poId, PurApItem purApItem) { List<PurchasingCapitalAssetItem> capitalAssetItems = this.getPurchaseOrderService().retrieveCapitalAssetItemsForIndividual(poId); if (capitalAssetItems == null || capitalAssetItems.isEmpty()) { return null; } Integer purchaseOrderItemIdentifier = null; PurchaseOrderItem poi = null; if (purApItem instanceof PaymentRequestItem) { poi = ((PaymentRequestItem) purApItem).getPurchaseOrderItem(); } else if (purApItem instanceof CreditMemoItem) { poi = getPurchaseOrderItemfromCreditMemoItem((CreditMemoItem) purApItem); } if (poi != null) { purchaseOrderItemIdentifier = poi.getItemIdentifier(); } for (PurchasingCapitalAssetItem capitalAssetItem : capitalAssetItems) { if (capitalAssetItem.getItemIdentifier().equals(purchaseOrderItemIdentifier)) { return capitalAssetItem.getPurchasingCapitalAssetSystem(); } } return null; }
/** * Set CAB line item information from PurAp PaymentRequestItem or CreditMemoItem. * * @param purchasingAccountsPayableItemAsset * @param docTypeCode */ public void setAccountsPayableItemsFromPurAp( PurchasingAccountsPayableItemAsset purchasingAccountsPayableItemAsset, String docTypeCode) { Map<String, Object> pKeys = new HashMap<String, Object>(); pKeys.put( PurapPropertyConstants.ITEM_IDENTIFIER, purchasingAccountsPayableItemAsset.getAccountsPayableLineItemIdentifier()); // Access PurAp data based on item type(PREQ or CM). if (CabConstants.PREQ.equalsIgnoreCase(docTypeCode)) { // for PREQ document PaymentRequestItem item = (PaymentRequestItem) businessObjectService.findByPrimaryKey(PaymentRequestItem.class, pKeys); if (ObjectUtils.isNull(item)) { throw new PurApDocumentUnavailableException( "PaymentRequestItem with id = " + purchasingAccountsPayableItemAsset.getAccountsPayableLineItemIdentifier() + " doesn't exist in table."); } purchasingAccountsPayableItemAsset.setItemLineNumber(item.getItemLineNumber()); if (item.getItemType() != null) { purchasingAccountsPayableItemAsset.setAdditionalChargeNonTradeInIndicator( item.getItemType().isAdditionalChargeIndicator() & !CabConstants.TRADE_IN_TYPE_CODE.equalsIgnoreCase(item.getItemTypeCode())); purchasingAccountsPayableItemAsset.setTradeInAllowance( item.getItemType().isAdditionalChargeIndicator() & CabConstants.TRADE_IN_TYPE_CODE.equalsIgnoreCase(item.getItemTypeCode())); purchasingAccountsPayableItemAsset.setItemTypeCode(item.getItemTypeCode()); } purchasingAccountsPayableItemAsset.setItemAssignedToTradeInIndicator( item.getItemAssignedToTradeInIndicator()); // PurchaseOrderItemIdentifier will be used when populate PurAp asset data PurchaseOrderItem poi = item.getPurchaseOrderItem(); if (poi != null) { purchasingAccountsPayableItemAsset.setPurchaseOrderItemIdentifier(poi.getItemIdentifier()); } } else { // for CM document CreditMemoItem item = (CreditMemoItem) businessObjectService.findByPrimaryKey(CreditMemoItem.class, pKeys); if (ObjectUtils.isNull(item)) { throw new PurApDocumentUnavailableException( "CreditMemoItem with id = " + purchasingAccountsPayableItemAsset.getAccountsPayableLineItemIdentifier() + " doesn't exist in table."); } purchasingAccountsPayableItemAsset.setItemLineNumber(item.getItemLineNumber()); if (item.getItemType() != null) { purchasingAccountsPayableItemAsset.setAdditionalChargeNonTradeInIndicator( item.getItemType().isAdditionalChargeIndicator() & !CabConstants.TRADE_IN_TYPE_CODE.equalsIgnoreCase(item.getItemTypeCode())); purchasingAccountsPayableItemAsset.setTradeInAllowance( item.getItemType().isAdditionalChargeIndicator() & CabConstants.TRADE_IN_TYPE_CODE.equalsIgnoreCase(item.getItemTypeCode())); purchasingAccountsPayableItemAsset.setItemTypeCode(item.getItemTypeCode()); } purchasingAccountsPayableItemAsset.setItemAssignedToTradeInIndicator( item.getItemAssignedToTradeInIndicator()); // PurchaseOrderItemIdentifier will be used when populate PurAp asset data PurchaseOrderItem poi = getPurchaseOrderItemfromCreditMemoItem(item); if (poi != null) { purchasingAccountsPayableItemAsset.setPurchaseOrderItemIdentifier(poi.getItemIdentifier()); } // if PREQ Credit Memo document VendorCreditMemoDocument cmDoc = (VendorCreditMemoDocument) item.getPurapDocument(); if (ObjectUtils.isNotNull(cmDoc) && cmDoc.isSourceDocumentPaymentRequest()) { purchasingAccountsPayableItemAsset.setPaymentRequestIdentifier( cmDoc.getPaymentRequestIdentifier()); } } }