001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.purap.fixtures;
017:
018: import java.sql.Date;
019: import java.sql.Timestamp;
020:
021: import org.kuali.core.service.DateTimeService;
022: import org.kuali.core.util.KualiDecimal;
023: import org.kuali.kfs.context.SpringContext;
024: import org.kuali.module.purap.document.CreditMemoDocument;
025:
026: public enum CreditMemoDocumentFixture {
027:
028: CM_ONLY_REQUIRED_PO_FIELDS(
029: null, // paymentRequestIdentifier
030: null, // creditMemoNumber
031: null, // creditMemoDate
032: null, // creditMemoAmount
033: null, // creditMemoPaidTimestamp
034: null, // itemMiscellaneousCreditDescription
035: null, // purchaseOrderEndDate
036: PurchasingAccountsPayableDocumentFixture.CM_ONLY_REQUIRED_FIELDS, // purapDocumentFixture
037: AccountsPayableDocumentFixture.CM_ONLY_REQUIRED_FIELDS, // apDocumentFixture
038: new CreditMemoItemFixture[] { CreditMemoItemFixture.CM_QTY_UNRESTRICTED_ITEM_1 } // requisitionItemMultiFixtures
039: ), CM_ONLY_REQUIRED_FIELDS(
040: null, // paymentRequestIdentifier
041: "12345", // creditMemoNumber
042: SpringContext.getBean(DateTimeService.class)
043: .getCurrentSqlDate(), // creditMemoDate
044: new KualiDecimal(1), // creditMemoAmount
045: null, // creditMemoPaidTimestamp
046: null, // itemMiscellaneousCreditDescription
047: null, // purchaseOrderEndDate
048: PurchasingAccountsPayableDocumentFixture.CM_ONLY_REQUIRED_FIELDS, // purapDocumentFixture
049: AccountsPayableDocumentFixture.CM_ONLY_REQUIRED_FIELDS, // apDocumentFixture
050: new CreditMemoItemFixture[] { CreditMemoItemFixture.CM_QTY_UNRESTRICTED_ITEM_1 } // creditMemoItemMultiFixtures
051: );
052:
053: public final Integer paymentRequestIdentifier;
054: public final String creditMemoNumber;
055: public final Date creditMemoDate;
056: public final KualiDecimal creditMemoAmount;
057: public final Timestamp creditMemoPaidTimestamp;
058: public final String itemMiscellaneousCreditDescription;
059: public final Date purchaseOrderEndDate;
060:
061: private PurchasingAccountsPayableDocumentFixture purapDocumentFixture;
062: private AccountsPayableDocumentFixture apDocumentFixture;
063: private CreditMemoItemFixture[] creditMemoItemFixtures;
064:
065: private CreditMemoDocumentFixture(
066: Integer paymentRequestIdentifier,
067: String creditMemoNumber,
068: Date creditMemoDate,
069: KualiDecimal creditMemoAmount,
070: Timestamp creditMemoPaidTimestamp,
071: String itemMiscellaneousCreditDescription,
072: Date purchaseOrderEndDate,
073: PurchasingAccountsPayableDocumentFixture purapDocumentFixture,
074: AccountsPayableDocumentFixture apDocumentFixture,
075: CreditMemoItemFixture[] creditMemoItemFixtures) {
076:
077: this .paymentRequestIdentifier = paymentRequestIdentifier;
078: this .creditMemoNumber = creditMemoNumber;
079: this .creditMemoDate = creditMemoDate;
080: this .creditMemoAmount = creditMemoAmount;
081: this .creditMemoPaidTimestamp = creditMemoPaidTimestamp;
082: this .itemMiscellaneousCreditDescription = itemMiscellaneousCreditDescription;
083: this .purchaseOrderEndDate = purchaseOrderEndDate;
084: this .purapDocumentFixture = purapDocumentFixture;
085: this .apDocumentFixture = apDocumentFixture;
086: this .creditMemoItemFixtures = creditMemoItemFixtures;
087: }
088:
089: public CreditMemoDocument createCreditMemoDocument() {
090: CreditMemoDocument doc = apDocumentFixture
091: .createCreditMemoDocument(purapDocumentFixture);
092: doc.setPaymentRequestIdentifier(this .paymentRequestIdentifier);
093: doc.setCreditMemoNumber(this .creditMemoNumber);
094: doc.setCreditMemoDate(this .creditMemoDate);
095: doc.setCreditMemoAmount(this .creditMemoAmount);
096: doc.setCreditMemoPaidTimestamp(this .creditMemoPaidTimestamp);
097: doc
098: .setItemMiscellaneousCreditDescription(this .itemMiscellaneousCreditDescription);
099: doc.setPurchaseOrderEndDate(this .purchaseOrderEndDate);
100:
101: for (CreditMemoItemFixture creditMemoItemFixture : creditMemoItemFixtures) {
102: creditMemoItemFixture.addTo(doc);
103: }
104:
105: return doc;
106: }
107:
108: }
|