Search in sources :

Example 16 with SourceAccountingLine

use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.

the class CuPreEncumbranceActionTest method setTabStatesHasTwoAccountingLines.

@Test
public void setTabStatesHasTwoAccountingLines() throws Exception {
    List<SourceAccountingLine> sourceAccountingLines = new ArrayList<>();
    sourceAccountingLines.add(new SourceAccountingLine());
    sourceAccountingLines.add(new SourceAccountingLine());
    preEncumbranceDocument.setSourceAccountingLines(sourceAccountingLines);
    cuPreEncumbranceAction.setTabStates(kualiAccountingDocumentFormBase);
    Assert.assertFalse("TabStates should NOT be empty", kualiAccountingDocumentFormBase.getTabStates().isEmpty());
    Assert.assertEquals("Automatic Partial Dis-Encumbrances section for new source line should be OPEN", "OPEN", kualiAccountingDocumentFormBase.getTabState("EncumbranceAutomaticPartialDisEncumbrances-newSourceLine"));
    Assert.assertEquals("Automatic Partial Dis-Encumbrances section for first source accounting line should be OPEN", "OPEN", kualiAccountingDocumentFormBase.getTabState("EncumbranceAutomaticPartialDisEncumbrances-document-sourceAccountingLine(0)"));
    Assert.assertEquals("Automatic Partial Dis-Encumbrances section for second source accounting line should be OPEN", "OPEN", kualiAccountingDocumentFormBase.getTabState("EncumbranceAutomaticPartialDisEncumbrances-document-sourceAccountingLine(1)"));
}
Also used : ArrayList(java.util.ArrayList) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) Test(org.junit.Test)

Example 17 with SourceAccountingLine

use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImplTest method testSetupSourceAccountingLine_NegativeAmount.

@Test
public void testSetupSourceAccountingLine_NegativeAmount() {
    SourceAccountingLine sourceAccountingLine = new SourceAccountingLine();
    AchIncomeTransaction achIncomeTransaction = new AchIncomeTransaction();
    achIncomeTransaction.setTransactionAmount(new KualiDecimal(10));
    advanceDepositService.setupSourceAccountingLine(achIncomeTransaction, advanceDepositDocument, "IT", EXPENSE_OBJECT_CODE, "1234567");
    assertEquals("Accounting line amount should be the transaction amount negated", achIncomeTransaction.getTransactionAmount().negated(), advanceDepositDocument.getSourceAccountingLine(0).getAmount());
}
Also used : AchIncomeTransaction(edu.cornell.kfs.fp.businessobject.AchIncomeTransaction) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) Test(org.junit.Test)

Example 18 with SourceAccountingLine

use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImplTest method testSetupSourceAccountingLine_PositiveAmount.

@Test
public void testSetupSourceAccountingLine_PositiveAmount() {
    SourceAccountingLine sourceAccountingLine = new SourceAccountingLine();
    AchIncomeTransaction achIncomeTransaction = new AchIncomeTransaction();
    achIncomeTransaction.setTransactionAmount(new KualiDecimal(10));
    advanceDepositService.setupSourceAccountingLine(achIncomeTransaction, advanceDepositDocument, "IT", NON_ASSET_EXPENSE_OBJECT_CODE, "1234567");
    assertEquals("Accounting line amount should equal the transaction amount", achIncomeTransaction.getTransactionAmount(), advanceDepositDocument.getSourceAccountingLine(0).getAmount());
}
Also used : AchIncomeTransaction(edu.cornell.kfs.fp.businessobject.AchIncomeTransaction) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) Test(org.junit.Test)

Example 19 with SourceAccountingLine

use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method populateDisbursementVoucherFields.

/**
 * Populates fields on the disbursement voucher document and performs validation
 *
 * @param disbursementVoucherDocument disbursement voucher document to populate
 * @param batchDisbursementVoucherDocument batch dv document to pull values from
 * @param batchDefault contains default values to use if value in feed is empty
 * @param MessageMap MessageMap for adding encountered errors
 */
protected void populateDisbursementVoucherFields(DisbursementVoucherDocument disbursementVoucherDocument, BatchDisbursementVoucherDocument batchDisbursementVoucherDocument, DisbursementVoucherBatchDefault batchDefault, MessageMap MessageMap) {
    disbursementVoucherDocument.getDocumentHeader().setDocumentDescription(kualiConfigurationService.getPropertyValueAsString(FPKeyConstants.MESSAGE_DV_BATCH_DOCUMENT_DESCRIPTION));
    // populate fields of document from batch instance
    disbursementVoucherDocument.getDocumentHeader().setExplanation(batchDisbursementVoucherDocument.getDocumentHeader().getExplanation());
    disbursementVoucherDocument.getDocumentHeader().setOrganizationDocumentNumber(batchDisbursementVoucherDocument.getDocumentHeader().getOrganizationDocumentNumber());
    disbursementVoucherDocument.setDisbVchrContactPersonName(batchDisbursementVoucherDocument.getDisbVchrContactPersonName());
    disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDisbursementVoucherDocument.getDisbVchrContactPhoneNumber());
    disbursementVoucherDocument.setDisbVchrContactEmailId(batchDisbursementVoucherDocument.getDisbVchrContactEmailId());
    disbursementVoucherDocument.setDisbursementVoucherDueDate(batchDisbursementVoucherDocument.getDisbursementVoucherDueDate());
    disbursementVoucherDocument.setDisbVchrAttachmentCode(batchDisbursementVoucherDocument.isDisbVchrAttachmentCode());
    disbursementVoucherDocument.setDisbVchrSpecialHandlingCode(batchDisbursementVoucherDocument.isDisbVchrSpecialHandlingCode());
    disbursementVoucherDocument.setDisbVchrCheckTotalAmount(batchDisbursementVoucherDocument.getDisbVchrCheckTotalAmount());
    disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDisbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode());
    disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDisbursementVoucherDocument.getDisbVchrPaymentMethodCode());
    disbursementVoucherDocument.setCampusCode(batchDisbursementVoucherDocument.getCampusCode());
    disbursementVoucherDocument.setDisbVchrCheckStubText(batchDisbursementVoucherDocument.getDisbVchrCheckStubText());
    disbursementVoucherDocument.setDisbVchrBankCode(batchDisbursementVoucherDocument.getDisbVchrBankCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPaymentReasonCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    String payeeTypeCode = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbursementVoucherPayeeTypeCode();
    String payeeIdNumber = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
    if (KFSConstants.PaymentPayeeTypes.VENDOR.equals(payeeTypeCode)) {
        if (StringUtils.contains(payeeIdNumber, "-")) {
            VendorDetail vendorDetail = vendorService.getVendorDetail(payeeIdNumber);
            if (vendorDetail != null) {
                VendorAddress vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, disbursementVoucherDocument.getCampusCode());
                if (vendorAddress == null) {
                    vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.REMIT, disbursementVoucherDocument.getCampusCode());
                }
                if (vendorAddress != null) {
                    disbursementVoucherDocument.templateVendor(vendorDetail, vendorAddress);
                }
            } else {
                batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
            }
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
        }
    } else if (KFSConstants.PaymentPayeeTypes.EMPLOYEE.equals(payeeTypeCode)) {
        Person person = personService.getPersonByEmployeeId(payeeIdNumber);
        if (person != null) {
            disbursementVoucherDocument.templateEmployee(person);
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
        }
    }
    // override payee details with values from feed if given (not blank)
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode());
    }
    // set special handling fields
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingPersonName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingPersonName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine1Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine2Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCityName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingZipCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingStateCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCountryCode());
    disbursementVoucherDocument.setDvNonResidentAlienTax(batchDisbursementVoucherDocument.getDvNonResidentAlienTax());
    disbursementVoucherDocument.getDvNonResidentAlienTax().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    // set defaults
    if (batchDefault != null) {
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPersonName())) {
            disbursementVoucherDocument.setDisbVchrContactPersonName(batchDefault.getDisbVchrContactPersonName());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPhoneNumber())) {
            disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDefault.getDisbVchrContactPhoneNumber());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactEmailId())) {
            disbursementVoucherDocument.setDisbVchrContactEmailId(batchDefault.getDisbVchrContactEmailId());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getCampusCode())) {
            disbursementVoucherDocument.setCampusCode(batchDefault.getCampusCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrPaymentMethodCode())) {
            disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDefault.getDisbVchrPaymentMethodCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode())) {
            disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDefault.getDisbursementVoucherDocumentationLocationCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrBankCode())) {
            disbursementVoucherDocument.setDisbVchrBankCode(batchDefault.getDisbVchrBankCode());
        }
    }
    // set accounting
    for (Iterator iterator = batchDisbursementVoucherDocument.getSourceAccountingLines().iterator(); iterator.hasNext(); ) {
        SourceAccountingLine batchAccountingLine = (SourceAccountingLine) iterator.next();
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode(batchAccountingLine.getChartOfAccountsCode());
        accountingLine.setAccountNumber(batchAccountingLine.getAccountNumber());
        if (StringUtils.isNotBlank(batchAccountingLine.getSubAccountNumber())) {
            accountingLine.setSubAccountNumber(batchAccountingLine.getSubAccountNumber());
        }
        accountingLine.setFinancialObjectCode(batchAccountingLine.getFinancialObjectCode());
        if (StringUtils.isNotBlank(batchAccountingLine.getFinancialSubObjectCode())) {
            accountingLine.setFinancialSubObjectCode(batchAccountingLine.getFinancialSubObjectCode());
        }
        if (StringUtils.isNotBlank(batchAccountingLine.getProjectCode())) {
            accountingLine.setProjectCode(batchAccountingLine.getProjectCode());
        }
        accountingLine.setOrganizationReferenceId(batchAccountingLine.getOrganizationReferenceId());
        accountingLine.setFinancialDocumentLineDescription(batchAccountingLine.getFinancialDocumentLineDescription());
        accountingLine.setAmount(batchAccountingLine.getAmount());
        // set accounting defaults
        if (batchDefault != null) {
            if (StringUtils.isBlank(accountingLine.getChartOfAccountsCode())) {
                accountingLine.setChartOfAccountsCode(batchDefault.getChartOfAccountsCode());
            }
            if (StringUtils.isBlank(accountingLine.getAccountNumber())) {
                accountingLine.setAccountNumber(batchDefault.getAccountNumber());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialObjectCode())) {
                accountingLine.setFinancialObjectCode(batchDefault.getFinancialObjectCode());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialDocumentLineDescription())) {
                accountingLine.setFinancialDocumentLineDescription(batchDefault.getFinancialDocumentLineDescription());
            }
        }
        accountingLine.setPostingYear(disbursementVoucherDocument.getPostingYear());
        accountingLine.setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
        disbursementVoucherDocument.addSourceAccountingLine(accountingLine);
    }
    // set notes
    for (Iterator iterator = batchDisbursementVoucherDocument.getNotes().iterator(); iterator.hasNext(); ) {
        Note note = (Note) iterator.next();
        note.setRemoteObjectIdentifier(disbursementVoucherDocument.getObjectId());
        note.setAuthorUniversalIdentifier(batchFeedHelperService.getSystemUser().getPrincipalId());
        note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        note.setNotePostedTimestampToCurrent();
        disbursementVoucherDocument.addNote(note);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) Note(org.kuali.kfs.krad.bo.Note) Iterator(java.util.Iterator) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) Person(org.kuali.rice.kim.api.identity.Person)

Example 20 with SourceAccountingLine

use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method generateDisbursementDocumentsFromRecurringDV.

@Override
public List<DisbursementVoucherDocument> generateDisbursementDocumentsFromRecurringDV(RecurringDisbursementVoucherDocument recurringDV) throws WorkflowException {
    List<DisbursementVoucherDocument> generatedDVs = new ArrayList<DisbursementVoucherDocument>();
    int rowId = 0;
    for (Object accountingLine : recurringDV.getSourceAccountingLines()) {
        ScheduledSourceAccountingLine scheduledAccountingLine = (ScheduledSourceAccountingLine) accountingLine;
        TreeMap<Date, KualiDecimal> datesAndAmounts = getScheduledAccountingLineService().generateDatesAndAmounts(scheduledAccountingLine, rowId);
        for (Date date : datesAndAmounts.keySet()) {
            KualiDecimal amount = datesAndAmounts.get(date);
            CuDisbursementVoucherDocument disbursementVoucherDocument = getCuDisbursementVoucherDocument(generatedDVs, recurringDV, date);
            disbursementVoucherDocument.setDisbVchrCheckTotalAmount(calculateDVCheckAmount(amount, disbursementVoucherDocument));
            RecurringDisbursementVoucherDetail dvDetail = getDetailtem(recurringDV.getRecurringDisbursementVoucherDetails(), date);
            dvDetail.setDvDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
            disbursementVoucherDocument.setDisbVchrCheckStubText(dvDetail.getDvCheckStub());
            SourceAccountingLine line = buildSourceAccountingLine(scheduledAccountingLine);
            line.setAmount(amount);
            disbursementVoucherDocument.addSourceAccountingLine(line);
        }
        rowId++;
    }
    saveDisbursementVouchers(generatedDVs, recurringDV);
    return generatedDVs;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Date(java.sql.Date)

Aggregations

SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)33 ArrayList (java.util.ArrayList)14 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)14 HashMap (java.util.HashMap)7 Iterator (java.util.Iterator)7 Map (java.util.Map)5 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)5 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)4 Date (java.sql.Date)4 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)4 PurchaseOrderAccount (org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount)4 PurapAccountingService (org.kuali.kfs.module.purap.service.PurapAccountingService)4 List (java.util.List)3 Test (org.junit.Test)3 PurApItemUseTax (org.kuali.kfs.module.purap.businessobject.PurApItemUseTax)3 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)3 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)3 SummaryAccount (org.kuali.kfs.module.purap.util.SummaryAccount)3 UseTaxContainer (org.kuali.kfs.module.purap.util.UseTaxContainer)3 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)3