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 org.kuali.core.util.KualiDecimal;
019: import org.kuali.module.purap.bo.PurApItem;
020: import org.kuali.module.purap.bo.PurchaseOrderItem;
021: import org.kuali.module.purap.document.PurchaseOrderDocument;
022:
023: /**
024: * Fixture class for Purchase Order Item.
025: */
026: public enum PurchaseOrderItemFixture {
027:
028: PO_QTY_UNRESTRICTED_ITEM_1(
029: null, // documentNumber,
030: null, // itemInvoicedTotalQuantity,
031: null, // itemInvoicedTotalAmount,
032: null, // itemReceivedTotalQuantity,
033: null, // itemReturnedTotalQuantity,
034: null, // itemOutstandingEncumberedQuantity,
035: null, // itemOutstandingEncumberedAmount,
036: true, // itemActiveIndicator,
037: null, // purchaseOrderCommodityCd,
038: PurApItemFixture.BASIC_QTY_ITEM_1, // purApItemFixture
039: new PurchaseOrderAccountingLineFixture[] { PurchaseOrderAccountingLineFixture.BASIC_PO_ACCOUNT_1 } // purchaseOrderAccountMultiFixtures
040: );
041:
042: private String documentNumber;
043: private KualiDecimal itemInvoicedTotalQuantity;
044: private KualiDecimal itemInvoicedTotalAmount;
045: private KualiDecimal itemReceivedTotalQuantity;
046: private KualiDecimal itemReturnedTotalQuantity;
047: private KualiDecimal itemOutstandingEncumberedQuantity;
048: private KualiDecimal itemOutstandingEncumberedAmount;
049: private boolean itemActiveIndicator = true;
050: private String purchaseOrderCommodityCd;
051:
052: private PurApItemFixture purApItemFixture;
053: private PurchaseOrderAccountingLineFixture[] purchaseOrderAccountingLineFixtures;
054:
055: /**
056: * Private Constructor.
057: */
058: private PurchaseOrderItemFixture(
059: String documentNumber,
060: KualiDecimal itemInvoicedTotalQuantity,
061: KualiDecimal itemInvoicedTotalAmount,
062: KualiDecimal itemReceivedTotalQuantity,
063: KualiDecimal itemReturnedTotalQuantity,
064: KualiDecimal itemOutstandingEncumberedQuantity,
065: KualiDecimal itemOutstandingEncumberedAmount,
066: boolean itemActiveIndicator,
067: String purchaseOrderCommodityCd,
068: PurApItemFixture purApItemFixture,
069: PurchaseOrderAccountingLineFixture[] purchaseOrderAccountingLineFixtures) {
070: this .documentNumber = documentNumber;
071: this .itemInvoicedTotalQuantity = itemInvoicedTotalQuantity;
072: this .itemInvoicedTotalAmount = itemInvoicedTotalAmount;
073: this .itemReceivedTotalQuantity = itemReceivedTotalQuantity;
074: this .itemReturnedTotalQuantity = itemReturnedTotalQuantity;
075: this .itemOutstandingEncumberedQuantity = itemOutstandingEncumberedQuantity;
076: this .itemOutstandingEncumberedAmount = itemOutstandingEncumberedAmount;
077: this .itemActiveIndicator = itemActiveIndicator;
078: this .purchaseOrderCommodityCd = purchaseOrderCommodityCd;
079: this .purApItemFixture = purApItemFixture;
080: this .purchaseOrderAccountingLineFixtures = purchaseOrderAccountingLineFixtures;
081: }
082:
083: /**
084: * Creates a Purchase Order Item from this fixture and adds the item to the specified Purchase Order Document.
085: *
086: * @param purchaseOrderDocument the specified Purchase Order Document.
087: */
088: public void addTo(PurchaseOrderDocument purchaseOrderDocument) {
089: PurchaseOrderItem item = null;
090: item = (PurchaseOrderItem) this
091: .createPurchaseOrderItem(purApItemFixture);
092: purchaseOrderDocument.addItem(item);
093: // iterate over the accounts
094: for (PurchaseOrderAccountingLineFixture purchaseOrderAccountMultiFixture : purchaseOrderAccountingLineFixtures) {
095: purchaseOrderAccountMultiFixture.addTo(item);
096: }
097: }
098:
099: /**
100: * Creates a Purchase Order Item using the specified PurAp Item Fixture.
101: *
102: * @param purApItemFixture the specified PurAp Item Fixture.
103: * @return the created Purchase Order Item.
104: */
105: public PurApItem createPurchaseOrderItem(
106: PurApItemFixture purApItemFixture) {
107: PurchaseOrderItem item = (PurchaseOrderItem) purApItemFixture
108: .createPurApItem(PurchaseOrderItem.class);
109: item.setDocumentNumber(documentNumber);
110: item.setItemInvoicedTotalQuantity(itemInvoicedTotalQuantity);
111: item.setItemInvoicedTotalAmount(itemInvoicedTotalAmount);
112: item.setItemReceivedTotalQuantity(itemReceivedTotalQuantity);
113: item.setItemReturnedTotalQuantity(itemReturnedTotalQuantity);
114: item
115: .setItemOutstandingEncumberedQuantity(itemOutstandingEncumberedQuantity);
116: item
117: .setItemOutstandingEncumberedAmount(itemOutstandingEncumberedAmount);
118: item.setItemActiveIndicator(itemActiveIndicator);
119: item.setPurchaseOrderCommodityCd(purchaseOrderCommodityCd);
120:
121: return item;
122: }
123: }
|