Search in sources :

Example 31 with SourceAccountingLine

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

the class CuDisbursementVoucherExtractionHelperServiceImplTest method test.

public void test() {
    CuDisbursementVoucherDocument dv = null;
    try {
        dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dv != null) {
        dv.getDocumentHeader().setDocumentDescription("Test Document Description");
        dv.getDocumentHeader().setExplanation("Stuff");
        dv.initiateDocument();
        VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail("13366-0");
        VendorAddress vendoraddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
        System.out.println(vendoraddress.getVendorCityName() + "\n");
        dv.templateVendor(vendor, vendoraddress);
        dv.setPayeeAssigned(true);
        dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
        dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
        dv.setDisbVchrPaymentMethodCode("P");
        dv.setDisbVchrCheckStubText("check text");
        dv.setCampusCode("IT");
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode("IT");
        accountingLine.setAccountNumber("G081040");
        accountingLine.setFinancialObjectCode("2045");
        accountingLine.setAmount((new KualiDecimal(86.00)));
        accountingLine.setPostingYear(dv.getPostingYear());
        accountingLine.setDocumentNumber(dv.getDocumentNumber());
        dv.addSourceAccountingLine(accountingLine);
        try {
            documentService.saveDocument(dv);
        } catch (WorkflowException e) {
            throw new RuntimeException("Error saving new disbursement voucher document: " + e.getMessage(), e);
        }
    }
    Date transactionTimestamp = new Date(SpringContext.getBean(DateTimeService.class).getCurrentDate().getTime());
    Date processRunDate = new java.sql.Date(transactionTimestamp.getTime());
    PaymentGroup pg = cuDisbursementVoucherExtractionHelperService.createPaymentGroup(dv, processRunDate);
    assertTrue(pg.getPaymentDetails().get(0).getCustPaymentDocNbr().equalsIgnoreCase(dv.getDocumentNumber()));
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService)

Example 32 with SourceAccountingLine

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

the class CuDisbursementVoucherDocumentIntegrationTest method setupCuDisbursementVoucherDocument.

private CuDisbursementVoucherDocument setupCuDisbursementVoucherDocument() throws WorkflowException {
    CuDisbursementVoucherDocument dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    dv.getDocumentHeader().setDocumentDescription("Test Document Description");
    dv.getDocumentHeader().setExplanation("Stuff");
    dv.initiateDocument();
    VendorDetail vendor = vendorService.getVendorDetail("13366-0");
    VendorAddress vendoraddress = vendorService.getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
    dv.templateVendor(vendor, vendoraddress);
    dv.setPayeeAssigned(true);
    dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
    dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
    dv.setDisbVchrPaymentMethodCode("P");
    dv.setDisbVchrCheckStubText("check text");
    dv.setCampusCode("IT");
    SourceAccountingLine accountingLine = new SourceAccountingLine();
    accountingLine.setChartOfAccountsCode("IT");
    accountingLine.setAccountNumber("G081040");
    accountingLine.setFinancialObjectCode("2045");
    accountingLine.setAmount((new KualiDecimal(86.00)));
    accountingLine.setPostingYear(dv.getPostingYear());
    accountingLine.setDocumentNumber(dv.getDocumentNumber());
    dv.addSourceAccountingLine(accountingLine);
    documentService.saveDocument(dv);
    return dv;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 33 with SourceAccountingLine

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

the class IWantDocumentServiceImpl method copyIWantDocAccountingLinesToDVDoc.

/**
 * Copies the accounting lines from the I Want document to the Requisition document
 *
 * @param requisitionDocument
 * @param iWantDocument
 * @param requisitionForm
 */
private void copyIWantDocAccountingLinesToDVDoc(DisbursementVoucherDocument disbursementVoucherDocument, IWantDocument iWantDocument, DisbursementVoucherForm disbursementVoucherForm) {
    int accountsSize = iWantDocument.getAccounts() != null ? iWantDocument.getAccounts().size() : 0;
    if (accountsSize > 0) {
        for (IWantAccount iWantAccount : iWantDocument.getAccounts()) {
            SourceAccountingLine dvAccount = disbursementVoucherForm.getNewSourceLine();
            dvAccount.setChartOfAccountsCode(iWantAccount.getChartOfAccountsCode());
            dvAccount.setAccountNumber(iWantAccount.getAccountNumber());
            dvAccount.setSubAccountNumber(iWantAccount.getSubAccountNumber());
            dvAccount.setFinancialObjectCode(iWantAccount.getFinancialObjectCode());
            dvAccount.setFinancialSubObjectCode(iWantAccount.getFinancialSubObjectCode());
            dvAccount.setProjectCode(iWantAccount.getProjectCode());
            dvAccount.setOrganizationReferenceId(iWantAccount.getOrganizationReferenceId());
            if (CUPurapConstants.PERCENT.equalsIgnoreCase(iWantAccount.getUseAmountOrPercent()) && iWantAccount.getAmountOrPercent() != null) {
                // compute amount
                KualiDecimal lineAmount = iWantAccount.getAmountOrPercent().multiply(iWantDocument.getTotalDollarAmount());
                if (lineAmount.isNonZero()) {
                    lineAmount = lineAmount.divide(new KualiDecimal(100));
                }
                dvAccount.setAmount(lineAmount);
            } else {
                dvAccount.setAmount(iWantAccount.getAmountOrPercent());
            }
            disbursementVoucherDocument.addSourceAccountingLine(dvAccount);
            disbursementVoucherForm.setNewSourceLine(null);
        }
    }
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine)

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