Ejemplo n.º 1
0
 @ConfigureContext(session = appleton, shouldCommitTransactions = true)
 public void testGenerateSummaryAccounts_OnePREQAccountTwoItemsWithPositiveTotal() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.PREQ_PRORATION_ONE_ACCOUNT;
   PurchasingAccountsPayableDocument doc = fixture.generatePaymentRequestDocument_TwoItems();
   makePerAccountComparisons(fixture, doc);
 }
Ejemplo n.º 2
0
 /*
  * Tests of updateAccountAmounts(PurchasingAccountsPayableDocument document)
  */
 @ConfigureContext(session = appleton)
 public void testUpdateAccountAmounts_BeforeFullEntry_PercentToAmount() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.PREQ_PRORATION_THIRDS;
   PurchasingAccountsPayableDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   purapAccountingService.updateAccountAmounts(preq);
   assertFalse(preq.getItems().get(0).getTotalAmount().isZero());
 }
Ejemplo n.º 3
0
 public void testGenerateSummary_TwoItems_OneAccount() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.REQ_SUMMARY_TWO_ITEMS_ONE_ACCOUNT;
   List<SourceAccountingLine> originalSourceAccounts = fixture.getSourceAccountingLineList();
   List<PurApItem> items = fixture.getItems();
   List<SourceAccountingLine> sourceLines = purapAccountingService.generateSummary(items);
   assertEquals(sourceLines.size(), originalSourceAccounts.size());
   checkAccountConsolidation(sourceLines, originalSourceAccounts);
 }
Ejemplo n.º 4
0
 @ConfigureContext(session = parke)
 public void testUpdateItemAccountAmounts_ThreeAccounts() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.REQ_PRORATION_THIRDS;
   RequisitionDocument req = fixture.generateRequisitionDocument_OneItem();
   RequisitionItem item = (RequisitionItem) req.getItems().get(0);
   KualiDecimal total = item.getTotalAmount();
   purapAccountingService.updateItemAccountAmounts(item);
   PurApAccountingLine line1 = item.getSourceAccountingLines().get(0);
   assertTrue(line1.getAmount().compareTo(total.divide(new KualiDecimal(3))) == 0);
 }
Ejemplo n.º 5
0
 @ConfigureContext(session = appleton)
 public void testUpdateAccountAmounts_AfterFullEntry_PercentNotToAmount() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.PREQ_PRORATION_THIRDS;
   PurchasingAccountsPayableDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   preq.setApplicationDocumentStatus(
       PurapConstants.PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED);
   preq.getItems().get(0).setExtendedPrice(KualiDecimal.ZERO);
   purapAccountingService.updateAccountAmounts(preq);
   assertTrue(preq.getItems().get(0).getTotalAmount().isZero());
 }
Ejemplo n.º 6
0
 public void testGenerateSummary_OneItem_OneAccount() {
   // TestUtils.setSystemParameter(Document.class,PurapParameterConstants.ENABLE_SALES_TAX_IND,"Y");
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.REQ_SUMMARY_ONE_ITEM_ONE_ACCOUNT;
   List<SourceAccountingLine> originalSourceAccounts = fixture.getSourceAccountingLineList();
   List<PurApItem> items = fixture.getItems();
   List<SourceAccountingLine> sourceLines = purapAccountingService.generateSummary(items);
   assertEquals(sourceLines.size(), originalSourceAccounts.size());
   checkAccountConsolidation(sourceLines, originalSourceAccounts);
 }
Ejemplo n.º 7
0
 @ConfigureContext(session = appleton, shouldCommitTransactions = true)
 public void testDeleteSummaryAccounts_CreditMemo() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.CREDIT_MEMO_ONE_ACCOUNT;
   VendorCreditMemoDocument vcm = fixture.generateVendorCreditMemoDocument_OneItem();
   List<SummaryAccount> summaryAccounts = purapAccountingService.generateSummaryAccounts(vcm);
   assertNotNull(summaryAccounts);
   purapAccountingService.deleteSummaryAccounts(
       vcm.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
   assertNull(
       purapAccountingService.getAccountsPayableSummaryAccounts(
           vcm.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT));
 }
Ejemplo n.º 8
0
 /*
  * Tests of deleteSummaryAccounts(Integer purapDocumentIdentifier)
  */
 @ConfigureContext(session = appleton, shouldCommitTransactions = true)
 public void testDeleteSummaryAccounts_PaymentRequest() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.PREQ_PRORATION_ONE_ACCOUNT;
   PaymentRequestDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   List<SummaryAccount> summaryAccounts = purapAccountingService.generateSummaryAccounts(preq);
   assertNotNull(summaryAccounts);
   purapAccountingService.deleteSummaryAccounts(
       preq.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
   assertNull(
       purapAccountingService.getAccountsPayableSummaryAccounts(
           preq.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT));
 }
Ejemplo n.º 9
0
 @ConfigureContext(session = appleton)
 public void testUpdateAccountAmounts_AfterFullEntry_AmountToPercent() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.PREQ_PRORATION_THIRDS;
   PurchasingAccountsPayableDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   preq.setApplicationDocumentStatus(
       PurapConstants.PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED);
   purapAccountingService.updateAccountAmounts(preq);
   PurApItem item = preq.getItems().get(0);
   int i = 0;
   for (PurApAccountingLine correctLine : fixture.getPurApAccountingLineList()) {
     PurApAccountingLine line = item.getSourceAccountingLines().get(i++);
     assertTrue(line.getAccountLinePercent().equals(correctLine.getAccountLinePercent()));
   }
 }
Ejemplo n.º 10
0
 public void testGenerateAccountDistributionForProration_OneAcctGood() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.PREQ_PRORATION_ONE_ACCOUNT;
   List<PurApAccountingLine> distributedAccounts =
       purapAccountingService.generateAccountDistributionForProration(
           fixture.getSourceAccountingLineList(),
           fixture.getTotalAmount(),
           fixture.getPercentScale(),
           fixture.getAccountClass());
   List<BigDecimal> correctPercents = new ArrayList<BigDecimal>();
   correctPercents.add(0, new BigDecimal("100"));
   assertEquals(distributedAccounts.size(), correctPercents.size());
   comparePercentages(distributedAccounts, correctPercents);
 }
Ejemplo n.º 11
0
 @ConfigureContext(session = appleton)
 public void testUpdateAccountAmounts_BeforeFullEntry_AmountNotToPercent() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.PREQ_PRORATION_THIRDS;
   PurchasingAccountsPayableDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   purapAccountingService.updateAccountAmounts(preq);
   PurApItem item = preq.getItems().get(0);
   int i = 0;
   boolean orResult = false;
   for (PurApAccountingLine correctLine : fixture.getPurApAccountingLineList()) {
     PurApAccountingLine line = item.getSourceAccountingLines().get(i++);
     if (!line.getAccountLinePercent().equals(correctLine.getAccountLinePercent())) {
       orResult = true;
       break;
     }
   }
   assertFalse(orResult);
 }
Ejemplo n.º 12
0
 public void testGenerateSummaryWithNoZeroTotalsUsingAlternateAmount_TwoItems_OneAccount() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.REQ_SUMMARY_TWO_ITEMS_ONE_ACCOUNT;
   List<SourceAccountingLine> originalSourceAccounts = fixture.getSourceAccountingLineList();
   List<PurApItem> items = fixture.getItems();
   GlobalVariables.getUserSession().setBackdoorUser("parke");
   RequisitionDocumentFixture reqFixture = RequisitionDocumentFixture.REQ_ONLY_REQUIRED_FIELDS;
   RequisitionDocument req = reqFixture.createRequisitionDocument();
   GlobalVariables.getUserSession().setBackdoorUser("kfs");
   for (PurApItem item : items) {
     item.setPurapDocument(req);
   }
   List<SourceAccountingLine> sourceLines =
       purapAccountingService.generateSummaryWithNoZeroTotalsUsingAlternateAmount(items);
   assertEquals(sourceLines.size(), originalSourceAccounts.size());
   checkAccountConsolidation(sourceLines, originalSourceAccounts);
 }
Ejemplo n.º 13
0
 /*
  * Tests of generateAccountDistributionForProrationWithZeroTotal(PurchasingAccountsPayableDocument purapdoc)
  */
 @ConfigureContext(session = appleton, shouldCommitTransactions = true)
 public void testGenerateAccountDistributionForProrationWithZeroTotal_OneAcct() {
   PurapAccountingServiceFixture fixture =
       PurapAccountingServiceFixture.PREQ_PRORATION_ONE_ACCOUNT_ZERO_TOTAL;
   PurchasingAccountsPayableDocument preq = fixture.generatePaymentRequestDocument_OneItem();
   List<PurApAccountingLine> distributedAccounts = null;
   try {
     distributedAccounts =
         purapAccountingService.generateAccountDistributionForProrationWithZeroTotal(preq);
   } catch (RuntimeException re) {
     fail(re.toString());
   }
   List<BigDecimal> correctPercents = new ArrayList<BigDecimal>();
   correctPercents.add(0, new BigDecimal("100"));
   assertEquals(distributedAccounts.size(), correctPercents.size());
   comparePercentages(distributedAccounts, correctPercents);
 }
Ejemplo n.º 14
0
  /**
   * Used by tests of generateSummaryAccounts and related methods to marshall the comparisons of the
   * accounts and items of the generated summary accounts.
   *
   * @param fixture The PurapAccountingServiceFixture
   * @param document A PurchasingAccountsPayableDocument generated from the fixture.
   */
  private void makePerAccountComparisons(
      PurapAccountingServiceFixture fixture, PurchasingAccountsPayableDocument doc) {
    int itemCount = doc.getItems().size();
    List<SummaryAccount> accounts = purapAccountingService.generateSummaryAccounts(doc);

    List<SourceAccountingLine> originalSourceAccounts = fixture.getSourceAccountingLineList();
    assertEquals(accounts.size(), originalSourceAccounts.size());
    for (int i = 0; i < originalSourceAccounts.size(); i++) {
      SummaryAccount account = accounts.get(i);
      SourceAccountingLine sourceAccount = account.getAccount();
      compareSourceAccounts(sourceAccount, originalSourceAccounts.get(i));
      List<PurApSummaryItem> summaryItems = account.getItems();
      assertTrue(summaryItems.size() <= itemCount);
    }
  }
Ejemplo n.º 15
0
 @ConfigureContext(session = parke, shouldCommitTransactions = true)
 public void testGenerateSummaryAccounts_OneRequisitionAccountOneItemWithPositiveTotal() {
   PurapAccountingServiceFixture fixture = PurapAccountingServiceFixture.REQ_PRORATION_ONE_ACCOUNT;
   PurchasingAccountsPayableDocument doc = fixture.generateRequisitionDocument_OneItem();
   makePerAccountComparisons(fixture, doc);
 }