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.module.purap.PurapConstants.ItemTypeCodes;
24: import org.kuali.module.purap.bo.PurchaseOrderItem;
25: import org.kuali.module.purap.bo.RequisitionItem;
26: import org.kuali.module.purap.document.PurchaseOrderDocument;
27: import org.kuali.module.purap.document.RequisitionDocument;
28: import org.kuali.module.purap.fixtures.PurapTestConstants.AmountsLimits;
29:
30: public enum AmountsLimitsFixture {
31: ZERO_AMOUNT_SMALL_LIMIT(AmountsLimits.ZERO,
32: AmountsLimits.SMALL_POSITIVE_AMOUNT), SMALL_AMOUNT_SMALL_LIMIT(
33: AmountsLimits.SMALL_POSITIVE_AMOUNT,
34: AmountsLimits.SMALL_POSITIVE_AMOUNT), LARGE_AMOUNT_SMALL_LIMIT(
35: AmountsLimits.LARGE_POSITIVE_AMOUNT,
36: AmountsLimits.SMALL_POSITIVE_AMOUNT), ;
37:
38: private KualiDecimal totalAmount;
39: private KualiDecimal poLimit;
40:
41: private AmountsLimitsFixture(KualiDecimal amt, KualiDecimal lim) {
42: this .totalAmount = amt;
43: this .poLimit = lim;
44: }
45:
46: public RequisitionDocument populateRequisition() {
47: RequisitionDocument req = new RequisitionDocument();
48: RequisitionItem item = new RequisitionItem();
49: item.setItemUnitPrice(new BigDecimal(this .totalAmount
50: .doubleValue()));
51: item.setItemQuantity(new KualiDecimal(1));
52: item.setItemTypeCode(ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
53: item.refreshNonUpdateableReferences();
54: item.getItemType().setQuantityBasedGeneralLedgerIndicator(true);
55: List<RequisitionItem> items = new ArrayList();
56: items.add(item);
57: req.setItems(items);
58: req.setPurchaseOrderTotalLimit(this .poLimit);
59: req.refreshNonUpdateableReferences();
60: return req;
61: }
62:
63: public PurchaseOrderDocument populatePurchaseOrder() {
64: PurchaseOrderDocument po = new PurchaseOrderDocument();
65: PurchaseOrderItem item = new PurchaseOrderItem();
66: item.setItemUnitPrice(new BigDecimal(this .totalAmount
67: .doubleValue()));
68: item.setItemQuantity(new KualiDecimal(1));
69: item.setItemTypeCode(ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
70: item.refreshNonUpdateableReferences();
71: item.getItemType().setQuantityBasedGeneralLedgerIndicator(true);
72: List<PurchaseOrderItem> items = new ArrayList();
73: items.add(item);
74: po.setItems(items);
75: po.setPurchaseOrderTotalLimit(this.poLimit);
76: return po;
77: }
78: }
|