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.VendorCreditMemoForm;
21 import org.kuali.ole.select.businessobject.OleCreditMemoItem;
22 import org.kuali.ole.select.document.OleVendorCreditMemoDocument;
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
33
34 public class OleVendorCreditMemoForm extends VendorCreditMemoForm {
35
36 private PurApItem newCreditItemLine;
37
38 public OleVendorCreditMemoForm() {
39 super();
40 this.setNewCreditItemLine(null);
41 this.setNewPurchasingItemLine(setupNewPurchasingItemLine());
42 }
43
44
45 public PurApItem getNewCreditItemLine() {
46 return newCreditItemLine;
47 }
48
49
50 public void setNewCreditItemLine(PurApItem newCreditItemLine) {
51 this.newCreditItemLine = newCreditItemLine;
52 }
53
54
55 @Override
56 public PurApItem setupNewPurchasingItemLine() {
57 OleCreditMemoItem newItem = new OleCreditMemoItem();
58 newItem.setItemTypeCode(PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE);
59 return newItem;
60 }
61
62 @Override
63 public PurApItem getAndResetNewPurchasingItemLine() {
64
65 PurApItem aPurchasingItemLine = getNewPurchasingItemLine();
66 OleCreditMemoItem crdtItem = (OleCreditMemoItem) aPurchasingItemLine;
67 setNewPurchasingItemLine(setupNewPurchasingItemLine());
68 OleCreditMemoItem crdtItems = (OleCreditMemoItem) this.getNewPurchasingItemLine();
69
70 OleVendorCreditMemoDocument document = (OleVendorCreditMemoDocument) this.getDocument();
71 if (document.getVendorDetail() != null) {
72 String customerNumber = document.getVendorCustomerNumber();
73
74 List<VendorCustomerNumber> vendorCustomerNumbers = document.getVendorDetail().getVendorCustomerNumbers();
75 if (customerNumber != null && vendorCustomerNumbers != null) {
76 for (VendorCustomerNumber vendorCustomerNumber : vendorCustomerNumbers) {
77 if (vendorCustomerNumber.getVendorCustomerNumber().equalsIgnoreCase(customerNumber)) {
78 if (document.getVendorDetail().getVendorHeader().getVendorForeignIndicator()) {
79 if (customerNumber != null) {
80 crdtItems.setItemForeignDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
81 crdtItems.setItemForeignDiscountType(vendorCustomerNumber.getVendorDiscountType());
82 }
83
84 crdtItems.setItemExchangeRate(crdtItem.getItemExchangeRate());
85 setNewPurchasingItemLine(crdtItems);
86 }
87 }
88 }
89 } else {
90 crdtItems.setItemForeignDiscount(new KualiDecimal(0.0));
91 crdtItems.setItemForeignDiscount(new KualiDecimal(0.0));
92 }
93 }
94 return aPurchasingItemLine;
95 }
96
97 }