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.InvoiceForm;
21 import org.kuali.ole.select.businessobject.OleInvoiceItem;
22 import org.kuali.ole.select.document.OleInvoiceDocument;
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 OleInvoiceForm extends InvoiceForm {
33
34
35 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleInvoiceForm.class);
36
37 private PurApItem newPaymentItemLine;
38
39 private boolean filterProcessItems = true;
40
41
42
43
44
45
46 @Override
47 public PurApItem setupNewPurchasingItemLine() {
48 OleInvoiceItem newItem = new OleInvoiceItem();
49 newItem.setItemTypeCode(PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE);
50 return newItem;
51 }
52
53 @Override
54 public PurApItem getAndResetNewPurchasingItemLine() {
55
56 PurApItem aPurchasingItemLine = getNewPurchasingItemLine();
57 OleInvoiceItem reqItem = (OleInvoiceItem) aPurchasingItemLine;
58 setNewPurchasingItemLine(setupNewPurchasingItemLine());
59 OleInvoiceItem reqItems = (OleInvoiceItem) this.getNewPurchasingItemLine();
60
61 OleInvoiceDocument document = (OleInvoiceDocument) this.getDocument();
62 if (document.getVendorDetail() != null) {
63 String customerNumber = document.getVendorCustomerNumber();
64
65 List<VendorCustomerNumber> vendorCustomerNumbers = document.getVendorDetail().getVendorCustomerNumbers();
66 if (customerNumber != null && vendorCustomerNumbers != null) {
67 for (VendorCustomerNumber vendorCustomerNumber : vendorCustomerNumbers) {
68 if (vendorCustomerNumber.getVendorCustomerNumber().equalsIgnoreCase(customerNumber)) {
69 if (document.getVendorDetail().getVendorHeader().getVendorForeignIndicator()) {
70 if (customerNumber != null) {
71 reqItems.setItemForeignDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
72 reqItems.setItemForeignDiscountType(vendorCustomerNumber.getVendorDiscountType());
73 }
74
75 reqItems.setItemExchangeRate(reqItem.getItemExchangeRate());
76 setNewPurchasingItemLine(reqItems);
77 } else {
78 if (customerNumber != null) {
79 reqItems.setItemDiscount(new KualiDecimal(vendorCustomerNumber.getVendorDiscountPercentage() != null ? vendorCustomerNumber.getVendorDiscountPercentage().bigDecimalValue() : new BigDecimal(0.0)));
80 reqItems.setItemDiscountType(vendorCustomerNumber.getVendorDiscountType());
81 }
82 setNewPurchasingItemLine(reqItems);
83 }
84 }
85 }
86 } else {
87 reqItems.setItemForeignDiscount(new KualiDecimal(0.0));
88 reqItems.setItemDiscount(new KualiDecimal(0));
89 }
90 }
91 return aPurchasingItemLine;
92
93 }
94
95 public PurApItem getNewPaymentItemLine() {
96 return newPaymentItemLine;
97 }
98
99 public void setNewPaymentItemLine(PurApItem newPaymentItemLine) {
100 this.newPaymentItemLine = newPaymentItemLine;
101 }
102
103 public boolean isFilterProcessItems() {
104 return filterProcessItems;
105 }
106
107 public void setFilterProcessItems(boolean filterProcessItems) {
108 this.filterProcessItems = filterProcessItems;
109 }
110
111 public OleInvoiceForm() {
112 super();
113 this.setNewPaymentItemLine(null);
114 this.setNewPurchasingItemLine(setupNewPurchasingItemLine());
115 }
116
117 }