01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.purap.fixtures;
17:
18: import java.math.BigDecimal;
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.kuali.core.util.KualiDecimal;
23: import org.kuali.core.util.ObjectUtils;
24: import org.kuali.module.purap.PurapConstants.ItemTypeCodes;
25: import org.kuali.module.purap.bo.PurApAccountingLine;
26: import org.kuali.module.purap.bo.PurchaseOrderAccount;
27: import org.kuali.module.purap.bo.PurchaseOrderItem;
28: import org.kuali.module.purap.fixtures.PurapTestConstants.ItemsAccounts;
29:
30: public enum ItemAccountsFixture {
31:
32: WITH_QUANTITY_WITH_PRICE_WITH_ACCOUNT(ItemsAccounts.QUANTITY,
33: ItemsAccounts.ITEM_UOM, ItemsAccounts.ITEM_CATALOG_NUMBER,
34: ItemsAccounts.ITEM_DESC, ItemsAccounts.UNIT_PRICE,
35: ItemsAccounts.PO_ACCOUNT), NULL_QUANTITY_WITH_PRICE_WITH_ACCOUNT(
36: null, ItemsAccounts.ITEM_DESC, ItemsAccounts.ITEM_UOM,
37: ItemsAccounts.ITEM_CATALOG_NUMBER,
38: ItemsAccounts.UNIT_PRICE, ItemsAccounts.PO_ACCOUNT), WITH_QUANTITY_NULL_PRICE_WITH_ACCOUNT(
39: ItemsAccounts.QUANTITY, ItemsAccounts.ITEM_UOM,
40: ItemsAccounts.ITEM_CATALOG_NUMBER, ItemsAccounts.ITEM_DESC,
41: null, ItemsAccounts.PO_ACCOUNT), WITH_QUANTITY_WITH_PRICE_NULL_ACCOUNT(
42: ItemsAccounts.QUANTITY, ItemsAccounts.ITEM_UOM,
43: ItemsAccounts.ITEM_CATALOG_NUMBER, ItemsAccounts.ITEM_DESC,
44: ItemsAccounts.UNIT_PRICE, null), NULL_ITEM_WITH_ACCOUNT(
45: null, null, null, null, null, ItemsAccounts.PO_ACCOUNT), ;
46:
47: private PurchaseOrderItem poItem;
48: private String itemDescription;
49: private KualiDecimal quantity;
50: private String unitOfMeasure;
51: private String catNbr;
52: private String itemDesc;
53: private BigDecimal unitPrice;
54: private PurchaseOrderAccount poAccount;
55: private String acctNumber;
56:
57: private ItemAccountsFixture(KualiDecimal quantity,
58: String unitOfMeasure, String catNbr, String itemDesc,
59: BigDecimal unitPrice, PurchaseOrderAccount acct) {
60: this .poItem = (PurchaseOrderItem) PurchaseOrderItemFixture.PO_QTY_UNRESTRICTED_ITEM_1
61: .createPurchaseOrderItem(PurApItemFixture.BASIC_QTY_ITEM_1);
62: this .quantity = quantity;
63: this .unitOfMeasure = unitOfMeasure;
64: this .catNbr = catNbr;
65: this .itemDescription = itemDesc;
66: this .unitPrice = unitPrice;
67: this .poAccount = acct;
68: }
69:
70: public PurchaseOrderItem populateItem() {
71: this .poItem.setItemQuantity(this .quantity);
72: this .poItem.setItemUnitOfMeasureCode(this .unitOfMeasure);
73: this .poItem.setItemCatalogNumber(this .catNbr);
74: this .poItem.setItemDescription(this .itemDescription);
75: this .poItem.setItemUnitPrice(this .unitPrice);
76: if (ObjectUtils.isNotNull(this .poAccount)) {
77: this .poAccount
78: .setAccountNumber(ItemsAccounts.ACCOUNT_NUMBER);
79: List<PurApAccountingLine> lines = new ArrayList();
80: lines.add((PurApAccountingLine) this .poAccount);
81: this .poItem.setSourceAccountingLines(lines);
82: }
83: this .poItem.setItemTypeCode(ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
84: this .poItem.setItemLineNumber(new Integer(1));
85: this.poItem.refreshNonUpdateableReferences();
86: return this.poItem;
87: }
88:
89: }
|