Search in sources :

Example 26 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class ObjectCodeServiceImpl method getObjectCodeNamesByCharts.

@Override
public String getObjectCodeNamesByCharts(Integer universityFiscalYear, String[] chartOfAccountCodes, String financialObjectCode) {
    String onlyObjectCodeName = "";
    SortedSet<String> objectCodeNames = new TreeSet<>();
    for (String chartOfAccountsCode : chartOfAccountCodes) {
        ObjectCode objCode = this.getByPrimaryId(universityFiscalYear, chartOfAccountsCode, financialObjectCode);
        if (objCode != null) {
            onlyObjectCodeName = objCode.getFinancialObjectCodeName();
            objectCodeNames.add(objCode.getFinancialObjectCodeName());
        } else {
            onlyObjectCodeName = "Not Found";
        }
    }
    if (objectCodeNames.size() > 1) {
        return StringUtils.join(objectCodeNames.toArray(), ", ");
    } else {
        return onlyObjectCodeName;
    }
}
Also used : TreeSet(java.util.TreeSet) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 27 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class AssetGlobalServiceImpl method setupAsset.

/**
 * Creates a new Asset appropriate for either create new or separate. This does not create the payments for this
 * asset.
 *
 * @param assetGlobal       containing data for the asset to be created
 * @param assetGlobalDetail containing data for the asset to be created
 * @param separate          indicating whether this is a separate and asset or not
 * @return set of assets appropriate for this creation without payments
 */
protected Asset setupAsset(AssetGlobal assetGlobal, AssetGlobalDetail assetGlobalDetail, boolean separate) {
    Asset asset = new Asset(assetGlobal, assetGlobalDetail, separate);
    // set financialObjectSubTypeCode per first payment entry if one exists
    if (!assetGlobal.getAssetPaymentDetails().isEmpty() && ObjectUtils.isNotNull(assetGlobal.getAssetPaymentDetails().get(0).getObjectCode())) {
        AssetPaymentDetail assetPaymentDetail = assetGlobal.getAssetPaymentDetails().get(0);
        ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear(assetPaymentDetail.getChartOfAccountsCode(), assetPaymentDetail.getFinancialObjectCode());
        asset.setFinancialObjectSubTypeCode(objectCode.getFinancialObjectSubTypeCode());
    }
    // create off campus location for each asset only if it was filled in
    boolean offCampus = StringUtils.isNotBlank(assetGlobalDetail.getOffCampusName()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusAddress()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusCityName()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusStateCode()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusZipCode()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusCountryCode());
    if (offCampus) {
        setupAssetLocationOffCampus(assetGlobalDetail, asset);
    }
    // set specific values for new assets if document is Asset Separate
    if (separate) {
        KualiDecimal divisor = assetGlobal.getSeparateSourceCapitalAsset().getTotalCostAmount();
        if (divisor.isZero()) {
            asset.setSalvageAmount(KualiDecimal.ZERO);
            asset.setReplacementAmount(KualiDecimal.ZERO);
            asset.setFabricationEstimatedTotalAmount(KualiDecimal.ZERO);
        } else {
            double separateRatio = assetGlobalDetail.getSeparateSourceAmount().doubleValue() / divisor.doubleValue();
            asset.setSalvageAmount(KualiDecimalUtils.safeMultiply(assetGlobal.getSeparateSourceCapitalAsset().getSalvageAmount(), separateRatio));
            asset.setReplacementAmount(KualiDecimalUtils.safeMultiply(assetGlobal.getSeparateSourceCapitalAsset().getReplacementAmount(), separateRatio));
            asset.setFabricationEstimatedTotalAmount(KualiDecimalUtils.safeMultiply(assetGlobal.getSeparateSourceCapitalAsset().getFabricationEstimatedTotalAmount(), separateRatio));
        }
        Date lastInventoryDate = assetGlobal.getLastInventoryDate();
        if (lastInventoryDate != null) {
            asset.setLastInventoryDate(new Timestamp(lastInventoryDate.getTime()));
        }
    }
    return asset;
}
Also used : AssetPaymentDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentDetail) Asset(org.kuali.kfs.module.cam.businessobject.Asset) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) AssetObjectCode(org.kuali.kfs.module.cam.businessobject.AssetObjectCode) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Example 28 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class AssetGlobalServiceImpl method setupCreateNewAssetPayment.

/**
 * Creates a payment for an asset in create new mode.
 *
 * @param capitalAssetNumber      to use for the payment
 * @param acquisitionTypeCode     for logic in determining how dates are to be set
 * @param assetGlobalDetailsSize  for logic in determining depreciation amounts (if asset is depreciable)
 * @param assetGlobalDetailsIndex for logic in determining depreciation amounts (if asset is depreciable)
 * @param assetPaymentDetail      containing data for the payment
 * @return payment for an asset in create new
 */
protected AssetPayment setupCreateNewAssetPayment(Long capitalAssetNumber, String acquisitionTypeCode, int assetGlobalDetailsSize, int assetGlobalDetailsIndex, AssetPaymentDetail assetPaymentDetail) {
    AssetPayment assetPayment = new AssetPayment(assetPaymentDetail, acquisitionTypeCode);
    assetPayment.setCapitalAssetNumber(capitalAssetNumber);
    assetPayment.setPaymentSequenceNumber(assetPaymentDetail.getSequenceNumber());
    assetPayment.setTransferPaymentCode(CamsConstants.AssetPayment.TRANSFER_PAYMENT_CODE_N);
    // Running this every time of the loop is inefficient, could be put into HashMap
    KualiDecimal[] amountBuckets = KualiDecimalUtils.allocateByQuantity(assetPaymentDetail.getAmount(), assetGlobalDetailsSize);
    assetPayment.setAccountChargeAmount(amountBuckets[assetGlobalDetailsIndex]);
    ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear(assetPayment.getChartOfAccountsCode(), assetPayment.getFinancialObjectCode());
    boolean isDepreciablePayment = ObjectUtils.isNotNull(assetPaymentDetail.getObjectCode()) && !Arrays.asList(parameterService.getParameterValueAsString(AssetDepreciationStep.class, CamsParameterConstants.NON_DEPRECIABLE_FEDERALLY_OWNED_OBJECT_SUB_TYPES).split(";")).contains(objectCode.getFinancialObjectSubTypeCode());
    if (isDepreciablePayment) {
        assetPayment.setPrimaryDepreciationBaseAmount(amountBuckets[assetGlobalDetailsIndex]);
    } else {
        assetPayment.setPrimaryDepreciationBaseAmount(KualiDecimal.ZERO);
    }
    return assetPayment;
}
Also used : AssetPayment(org.kuali.kfs.module.cam.businessobject.AssetPayment) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) AssetObjectCode(org.kuali.kfs.module.cam.businessobject.AssetObjectCode) AssetDepreciationStep(org.kuali.kfs.module.cam.batch.AssetDepreciationStep)

Example 29 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class LaborPendingEntryGenerator method refreshObjectCodeNonUpdateableReferences.

/**
 * refreshes labor ledger pending entry's object codes.
 *
 * @param llpes
 */
public static void refreshObjectCodeNonUpdateableReferences(List<LaborLedgerPendingEntry> llpes) {
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    // refresh nonupdateable references for financial object...
    Map<String, String> primaryKeys = new HashMap<>();
    for (LaborLedgerPendingEntry llpe : llpes) {
        primaryKeys.put("financialObjectCode", llpe.getFinancialObjectCode());
        ObjectCode objectCode = bos.findByPrimaryKey(ObjectCode.class, primaryKeys);
        llpe.setFinancialObject(objectCode);
    }
}
Also used : HashMap(java.util.HashMap) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 30 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class MockObjectCodeService method getByPrimaryIdForCurrentYear.

@Override
public ObjectCode getByPrimaryIdForCurrentYear(String chartOfAccountsCode, String financialObjectCode) {
    ObjectCode objectCode = null;
    if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.VALID_OBJ_CD.equalsIgnoreCase(financialObjectCode)) {
        objectCode = createObjectCode(chartOfAccountsCode, financialObjectCode);
        objectCode.setActive(true);
    }
    if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.INACTIVE_OBJ_CD.equalsIgnoreCase(financialObjectCode)) {
        objectCode = createObjectCode(chartOfAccountsCode, financialObjectCode);
        objectCode.setActive(false);
    }
    return objectCode;
}
Also used : ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Aggregations

ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)30 SubObjectCode (org.kuali.kfs.coa.businessobject.SubObjectCode)9 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 ArrayList (java.util.ArrayList)4 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)4 HashMap (java.util.HashMap)3 ObjectCodeService (org.kuali.kfs.coa.service.ObjectCodeService)3 FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)3 AssetObjectCode (org.kuali.kfs.module.cam.businessobject.AssetObjectCode)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 PaymentMethodChart (edu.cornell.kfs.fp.businessobject.PaymentMethodChart)2 Date (java.sql.Date)2 Timestamp (java.sql.Timestamp)2 Account (org.kuali.kfs.coa.businessobject.Account)2 ObjectType (org.kuali.kfs.coa.businessobject.ObjectType)2 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)2 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)2 SubObjectCodeService (org.kuali.kfs.coa.service.SubObjectCodeService)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 AccountingLineOverride (org.kuali.kfs.sys.businessobject.AccountingLineOverride)2