1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.web.struts;
17
18 import org.kuali.ole.module.purap.businessobject.PurApItem;
19 import org.kuali.ole.module.purap.document.web.struts.RequisitionForm;
20 import org.kuali.ole.select.OleSelectConstant;
21 import org.kuali.ole.select.businessobject.OleRequisitionCopies;
22 import org.kuali.ole.select.businessobject.OleRequisitionItem;
23 import org.kuali.ole.select.businessobject.OleRequisitionPaymentHistory;
24 import org.kuali.ole.select.document.OleRequisitionDocument;
25 import org.kuali.ole.vnd.businessobject.VendorCustomerNumber;
26 import org.kuali.rice.core.api.util.type.KualiDecimal;
27
28 import java.math.BigDecimal;
29 import java.util.List;
30
31 public class OleRequisitionForm extends RequisitionForm {
32
33 private OleRequisitionCopies newOleCopies = new OleRequisitionCopies();
34 private OleRequisitionPaymentHistory newOleRequisitionPaymentHistory = new OleRequisitionPaymentHistory();
35 private boolean currencyTypeIndicator = true;
36
37
38
39 @Override
40 public PurApItem setupNewPurchasingItemLine() {
41 return new OleRequisitionItem();
42 }
43
44 @Override
45 public PurApItem getAndResetNewPurchasingItemLine() {
46
47 PurApItem aPurchasingItemLine = getNewPurchasingItemLine();
48 OleRequisitionItem reqItem = (OleRequisitionItem) aPurchasingItemLine;
49 setNewPurchasingItemLine(setupNewPurchasingItemLine());
50 OleRequisitionItem reqItems = (OleRequisitionItem) this.getNewPurchasingItemLine();
51
52 OleRequisitionDocument document = (OleRequisitionDocument) this.getDocument();
53 if (document.getVendorDetail() != null) {
54
55 if (document.getVendorDetail().getCurrencyType()!=null){
56 if(document.getVendorDetail().getCurrencyType().getCurrencyType().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME )){
57 currencyTypeIndicator=true;
58 }
59 else{
60 currencyTypeIndicator=false;
61 }
62 }
63 String customerNumber = document.getVendorCustomerNumber();
64 List<VendorCustomerNumber> vendorCustomerNumbers = document.getVendorDetail().getVendorCustomerNumbers();
65 if (customerNumber != null && vendorCustomerNumbers != null) {
66 for (VendorCustomerNumber vendorCustomerNumber : vendorCustomerNumbers) {
67 if (vendorCustomerNumber.getVendorCustomerNumber().equalsIgnoreCase(customerNumber)) {
68 if (!currencyTypeIndicator) {
69 if (customerNumber != null) {
70 reqItems.setItemForeignDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
71 reqItems.setItemForeignDiscountType(vendorCustomerNumber.getVendorDiscountType());
72 }
73
74 reqItems.setItemExchangeRate(reqItem.getItemExchangeRate());
75 setNewPurchasingItemLine(reqItems);
76 } else {
77 if (customerNumber != null) {
78 reqItems.setItemDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
79 reqItems.setItemDiscountType(vendorCustomerNumber.getVendorDiscountType());
80 }
81 setNewPurchasingItemLine(reqItems);
82 }
83 }
84 }
85 } else {
86 reqItems.setItemForeignDiscount(new KualiDecimal(0.0));
87 reqItems.setItemDiscount(new KualiDecimal(0));
88
89 }
90 }
91 return aPurchasingItemLine;
92
93 }
94
95
96
97
98
99
100 public OleRequisitionCopies getNewOleCopies() {
101 return newOleCopies;
102 }
103
104
105
106
107
108
109 public void setNewOleCopies(OleRequisitionCopies newOleCopies) {
110 this.newOleCopies = newOleCopies;
111 }
112
113
114
115
116
117
118 public OleRequisitionPaymentHistory getNewOleRequisitionPaymentHistory() {
119 return newOleRequisitionPaymentHistory;
120 }
121
122
123
124
125
126
127
128 public void setNewOleRequisitionPaymentHistory(OleRequisitionPaymentHistory newOleRequisitionPaymentHistory) {
129 this.newOleRequisitionPaymentHistory = newOleRequisitionPaymentHistory;
130 }
131
132 }