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.PurapConstants;
19 import org.kuali.ole.module.purap.businessobject.PurApItem;
20 import org.kuali.ole.module.purap.document.web.struts.PaymentRequestForm;
21 import org.kuali.ole.select.businessobject.OlePaymentRequestItem;
22 import org.kuali.ole.select.document.OlePaymentRequestDocument;
23 import org.kuali.ole.vnd.businessobject.VendorCustomerNumber;
24 import org.kuali.rice.core.api.util.type.KualiDecimal;
25
26 import java.math.BigDecimal;
27 import java.util.List;
28
29
30
31
32 public class OlePaymentRequestForm extends PaymentRequestForm {
33
34
35 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePaymentRequestForm.class);
36
37 private PurApItem newPaymentItemLine;
38
39
40
41
42
43
44 @Override
45 public PurApItem setupNewPurchasingItemLine() {
46 OlePaymentRequestItem newItem = new OlePaymentRequestItem();
47 newItem.setItemTypeCode(PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE);
48 return newItem;
49 }
50
51 @Override
52 public PurApItem getAndResetNewPurchasingItemLine() {
53
54 PurApItem aPurchasingItemLine = getNewPurchasingItemLine();
55 OlePaymentRequestItem reqItem = (OlePaymentRequestItem) aPurchasingItemLine;
56 setNewPurchasingItemLine(setupNewPurchasingItemLine());
57 OlePaymentRequestItem reqItems = (OlePaymentRequestItem) this.getNewPurchasingItemLine();
58
59 OlePaymentRequestDocument document = (OlePaymentRequestDocument) this.getDocument();
60 if (document.getVendorDetail() != null) {
61 String customerNumber = document.getVendorCustomerNumber();
62
63 List<VendorCustomerNumber> vendorCustomerNumbers = document.getVendorDetail().getVendorCustomerNumbers();
64 if (customerNumber != null && vendorCustomerNumbers != null) {
65 for (VendorCustomerNumber vendorCustomerNumber : vendorCustomerNumbers) {
66 if (vendorCustomerNumber.getVendorCustomerNumber().equalsIgnoreCase(customerNumber)) {
67 if (document.getVendorDetail().getVendorHeader().getVendorForeignIndicator()) {
68 if (customerNumber != null) {
69 reqItems.setItemForeignDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
70 reqItems.setItemForeignDiscountType(vendorCustomerNumber.getVendorDiscountType());
71 }
72
73 reqItems.setItemExchangeRate(reqItem.getItemExchangeRate());
74 setNewPurchasingItemLine(reqItems);
75 } else {
76 if (customerNumber != null) {
77 reqItems.setItemDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
78 reqItems.setItemDiscountType(vendorCustomerNumber.getVendorDiscountType());
79 }
80 setNewPurchasingItemLine(reqItems);
81 }
82 }
83 }
84 } else {
85 reqItems.setItemForeignDiscount(new KualiDecimal(0.0));
86 reqItems.setItemDiscount(new KualiDecimal(0));
87 }
88 }
89 return aPurchasingItemLine;
90
91 }
92
93 public PurApItem getNewPaymentItemLine() {
94 return newPaymentItemLine;
95 }
96
97 public void setNewPaymentItemLine(PurApItem newPaymentItemLine) {
98 this.newPaymentItemLine = newPaymentItemLine;
99 }
100
101 public OlePaymentRequestForm() {
102 super();
103 this.setNewPaymentItemLine(null);
104 this.setNewPurchasingItemLine(setupNewPurchasingItemLine());
105 }
106
107 }