Ejemplo n.º 1
0
  public List<Long> retrieveValidAssetNumberForLocking(
      Integer poId, String capitalAssetSystemTypeCode, PurApItem purApItem) {
    List<Long> capitalAssetNumbers = new ArrayList<Long>();
    CapitalAssetSystem capitalAssetSystem = null;

    if (PurapConstants.CapitalAssetTabStrings.INDIVIDUAL_ASSETS.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      // If PurAp sets the CAMS as INDIVIDUAL system
      capitalAssetSystem = getCapitalAssetSystemForIndividual(poId, purApItem);

    } else if (PurapConstants.CapitalAssetTabStrings.ONE_SYSTEM.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      capitalAssetSystem =
          this.getPurchaseOrderService().retrieveCapitalAssetSystemForOneSystem(poId);
    } else if (PurapConstants.CapitalAssetTabStrings.MULTIPLE_SYSTEMS.equalsIgnoreCase(
        capitalAssetSystemTypeCode)) {
      List<CapitalAssetSystem> capitalAssetSystems =
          this.getPurchaseOrderService().retrieveCapitalAssetSystemsForMultipleSystem(poId);
      if (ObjectUtils.isNotNull(capitalAssetSystems) && !capitalAssetSystems.isEmpty()) {
        // PurAp doesn't support multiple system asset information for KFS3.0. It works as One
        // system.
        capitalAssetSystem = capitalAssetSystems.get(0);
      }
    }

    if (ObjectUtils.isNotNull(capitalAssetSystem)
        && capitalAssetSystem.getItemCapitalAssets() != null
        && !capitalAssetSystem.getItemCapitalAssets().isEmpty()) {
      for (ItemCapitalAsset itemCapitalAsset : capitalAssetSystem.getItemCapitalAssets()) {
        if (itemCapitalAsset.getCapitalAssetNumber() != null) {
          Map pKeys = new HashMap<String, Object>();
          // Asset must be valid and capital active 'A','C','S','U'
          pKeys.put(
              CamsPropertyConstants.Asset.CAPITAL_ASSET_NUMBER,
              itemCapitalAsset.getCapitalAssetNumber());

          Asset asset = (Asset) businessObjectService.findByPrimaryKey(Asset.class, pKeys);
          if (ObjectUtils.isNotNull(asset)
              && getAssetService().isCapitalAsset(asset)
              && !getAssetService().isAssetRetired(asset)) {
            capitalAssetNumbers.add(itemCapitalAsset.getCapitalAssetNumber());
          }
        }
      }
    }
    return capitalAssetNumbers;
  }
Ejemplo n.º 2
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);
      }
    }
  }