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 Individual system asset transaction type and asset numbers.
   *
   * @param poId
   * @param purApDocs
   */
  protected void setIndividualAssetsFromPurAp(
      Integer poId,
      List<PurchasingAccountsPayableDocument> purApDocs,
      String capitalAssetSystemStateCode) {
    List<PurchasingCapitalAssetItem> capitalAssetItems =
        this.getPurchaseOrderService().retrieveCapitalAssetItemsForIndividual(poId);
    String capitalAssetTransactionTypeCode = null;
    List<ItemCapitalAsset> purApCapitalAssets = null;

    // For each capitalAssetItem from PurAp, we set it to all matching CAB items
    for (PurchasingCapitalAssetItem purchasingCapitalAssetItem : capitalAssetItems) {
      capitalAssetTransactionTypeCode =
          purchasingCapitalAssetItem.getCapitalAssetTransactionTypeCode();
      // get matching CAB items origin from the same PO item.
      List<PurchasingAccountsPayableItemAsset> matchingItems =
          getMatchingItems(purchasingCapitalAssetItem.getItemIdentifier(), purApDocs);
      // if modify existing asset, acquire the assets from Puraps
      if (PurapConstants.CapitalAssetSystemStates.MODIFY.equalsIgnoreCase(
          capitalAssetSystemStateCode)) {
        purApCapitalAssets =
            getAssetsFromItemCapitalAsset(
                purchasingCapitalAssetItem
                    .getPurchasingCapitalAssetSystem()
                    .getItemCapitalAssets());
      }

      // set TransactionTypeCode, itemCapitalAssets and system identifier for each matching item
      setItemAssetsCamsTransaction(
          purchasingCapitalAssetItem.getCapitalAssetSystemIdentifier(),
          capitalAssetTransactionTypeCode,
          purApCapitalAssets,
          matchingItems);
    }
  }