예제 #1
0
  /**
   * Set CAMS transaction type code the user entered in PurAp
   *
   * @param poId
   */
  public void setCamsTransactionFromPurAp(List<PurchasingAccountsPayableDocument> purApDocs) {
    if (ObjectUtils.isNull(purApDocs) || purApDocs.isEmpty()) {
      return;
    }
    Integer poId = purApDocs.get(0).getPurchaseOrderIdentifier();
    PurchaseOrderDocument purApdocument = getCurrentDocumentForPurchaseOrderIdentifier(poId);
    if (ObjectUtils.isNull(purApdocument)) {
      return;
    }

    String capitalAssetSystemTypeCode = purApdocument.getCapitalAssetSystemTypeCode();
    String capitalAssetSystemStateCode = purApdocument.getCapitalAssetSystemStateCode();
    boolean individualItemLock = false;

    if (PurapConstants.CapitalAssetTabStrings.INDIVIDUAL_ASSETS.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      // If PurAp sets the CAMS as INDIVIDUAL system
      setIndividualAssetsFromPurAp(poId, purApDocs, capitalAssetSystemStateCode);
      individualItemLock = true;
    } else if (PurapConstants.CapitalAssetTabStrings.ONE_SYSTEM.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      // If PurAp sets the CAMS as ONE system
      setOneSystemFromPurAp(poId, purApDocs, capitalAssetSystemStateCode);

    } else if (PurapConstants.CapitalAssetTabStrings.MULTIPLE_SYSTEMS.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      // If PurAp sets the CAMS as MULTIPLE system
      setMultipleSystemFromPurAp(poId, purApDocs, capitalAssetSystemStateCode);
    }

    // Setting locking information based on capital asset system type code. Currently, only
    // individual system can set asset
    // numbers for each item
    for (PurchasingAccountsPayableDocument purApDoc : purApDocs) {
      for (PurchasingAccountsPayableItemAsset itemAsset :
          purApDoc.getPurchasingAccountsPayableItemAssets()) {
        itemAsset.setLockingInformation(
            individualItemLock
                ? itemAsset.getAccountsPayableLineItemIdentifier().toString()
                : CamsConstants.defaultLockingInformation);
      }
    }
  }
예제 #2
0
  /**
   * 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());
      }
    }
  }