1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.businessobject;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.DocumentUniqueIDPrefix;
20 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.BibInfoRecord;
21 import org.kuali.ole.module.purap.PurapConstants;
22 import org.kuali.ole.module.purap.PurapPropertyConstants;
23 import org.kuali.ole.module.purap.businessobject.InvoiceItem;
24 import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
25 import org.kuali.ole.module.purap.businessobject.PurApItemUseTax;
26 import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
27 import org.kuali.ole.module.purap.document.InvoiceDocument;
28 import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
29 import org.kuali.ole.module.purap.document.service.OlePurapService;
30 import org.kuali.ole.module.purap.document.service.PurapService;
31 import org.kuali.ole.module.purap.exception.PurError;
32 import org.kuali.ole.module.purap.util.ExpiredOrClosedAccountEntry;
33 import org.kuali.ole.module.purap.util.PurApRelatedViews;
34 import org.kuali.ole.pojo.OleOrderRecord;
35 import org.kuali.ole.select.OleSelectConstant;
36 import org.kuali.ole.select.bo.OLELinkPurapDonor;
37 import org.kuali.ole.select.document.OleInvoiceDocument;
38 import org.kuali.ole.select.lookup.DocData;
39 import org.kuali.ole.sys.OLEConstants;
40 import org.kuali.ole.sys.businessobject.SourceAccountingLine;
41 import org.kuali.ole.sys.businessobject.UnitOfMeasure;
42 import org.kuali.ole.sys.context.SpringContext;
43 import org.kuali.rice.core.api.util.type.AbstractKualiDecimal;
44 import org.kuali.rice.core.api.util.type.KualiDecimal;
45 import org.kuali.rice.core.api.util.type.KualiInteger;
46 import org.kuali.rice.kew.api.KewApiConstants;
47 import org.kuali.rice.kew.api.KewApiServiceLocator;
48 import org.kuali.rice.kew.api.doctype.DocumentType;
49 import org.kuali.rice.krad.util.KRADConstants;
50 import org.kuali.rice.krad.util.ObjectUtils;
51
52 import java.math.BigDecimal;
53 import java.util.ArrayList;
54 import java.util.Date;
55 import java.util.HashMap;
56 import java.util.List;
57
58 public class OleInvoiceItem extends InvoiceItem {
59
60 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleInvoiceItem.class);
61
62 private BigDecimal itemExtendedPrice;
63 protected String itemCurrencyType;
64 protected KualiDecimal itemForeignListPrice;
65 protected KualiDecimal itemForeignDiscount;
66 protected String itemForeignDiscountType;
67 protected KualiDecimal itemForeignDiscountAmt;
68 protected KualiDecimal itemForeignUnitCost;
69 protected KualiDecimal itemExchangeRate;
70 protected KualiDecimal itemUnitCostUSD;
71 protected KualiDecimal foreignCurrencyExtendedPrice;
72
73 protected boolean itemRouteToRequestorIndicator;
74 protected boolean itemPublicViewIndicator;
75
76 protected boolean debitItem = true;
77 protected String invoiceListPrice;
78 protected String invoiceForeignListPrice;
79 protected String additionalUnitPrice;
80 protected String localTitleId;
81
82
83 protected Integer formatTypeId;
84 protected KualiInteger itemNoOfParts;
85 protected KualiDecimal itemListPrice;
86 protected KualiDecimal itemDiscount;
87 private String discountItem;
88 protected String itemDiscountType;
89 protected BigDecimal itemSurcharge;
90 protected String note;
91 protected List<OleInvoiceNote> notes;
92 protected Integer poItemIdentifier;
93
94 private Boolean relatedViewExist;
95 private transient PurApRelatedViews relatedViews;
96 private UnitOfMeasure itemUnitOfMeasure;
97
98 private String vendorItemIdentifier;
99
100
101 private BibInfoBean bibInfoBean;
102 protected String itemTitleId;
103 protected String bibUUID;
104 private DocData docData;
105 private InvoiceDocument invoiceDocument;
106 private OleOrderRecord oleOrderRecord;
107 protected Integer receiptStatusId;
108 private OleReceiptStatus oleReceiptStatus;
109 private boolean useTaxIndicator;
110
111
112
113 private KualiInteger oleItemQuantity;
114 private String oleCopiesOrdered;
115 private KualiInteger olePoOutstandingQuantity;
116 private String oleOpenQuantity;
117 private OleFormatType formatType = new OleFormatType();
118 private String poItemLink;
119 private Date purchaseOrderEndDate;
120 private String docFormat;
121
122 private Date subscriptionFromDate;
123 private Date subscriptionToDate;
124 private boolean subscriptionOverlap;
125 private List<SourceAccountingLine> sourceAccountingLineList = new ArrayList<SourceAccountingLine>();
126 private OLEInvoiceOffsetAccountingLine oleInvoiceOffsetAccountingLine;
127
128 private String donorCode;
129 private String donorId;
130 private List<OLELinkPurapDonor> oleDonors = new ArrayList<>();
131 private List<OLEPaidCopy> paidCopies = new ArrayList<>();
132 private Integer tempPurchaseOrderIdentifier;
133 private String listPrice;
134 private String foreignListPrice;
135 private String foreignUnitCost;
136 private String foreignDiscount;
137 private String exchangeRate;
138 private String invoicedCurrency;
139 protected String additionalForeignUnitCost;
140
141 private Integer reLinkPO;
142 private Integer requisitionItemIdentifier;
143 private Integer tempItemIdentifier;
144 public String itemTitle;
145 private boolean enableDetailsSection=false;
146 private Integer sequenceNumber;
147
148 private BibInfoRecord bibInfoRecord;
149 private String fundCode;
150
151 public BibInfoRecord getBibInfoRecord() {
152 return bibInfoRecord;
153 }
154
155 public void setBibInfoRecord(BibInfoRecord bibInfoRecord) {
156 this.bibInfoRecord = bibInfoRecord;
157 }
158
159 public Integer getTempItemIdentifier() {
160 return tempItemIdentifier;
161 }
162
163 public void setTempItemIdentifier(Integer tempItemIdentifier) {
164 this.tempItemIdentifier = tempItemIdentifier;
165 }
166
167 public String getDocFormat() {
168 return docFormat;
169 }
170
171 public Integer getTempPurchaseOrderIdentifier() {
172 if (poItemIdentifier != null) {
173 tempPurchaseOrderIdentifier = getPurchaseOrderIdentifier();
174 } else {
175 tempPurchaseOrderIdentifier = null;
176 }
177 return tempPurchaseOrderIdentifier;
178 }
179
180 public void setTempPurchaseOrderIdentifier(Integer tempPurchaseOrderIdentifier) {
181 this.tempPurchaseOrderIdentifier = tempPurchaseOrderIdentifier;
182 }
183
184 public void setDocFormat(String docFormat) {
185 this.docFormat = docFormat;
186 }
187
188 public String getOleOpenQuantity() {
189
190
191
192 return oleOpenQuantity;
193 }
194
195 public void setOleOpenQuantity(String oleOpenQuantity) {
196 this.oleOpenQuantity = oleOpenQuantity;
197 }
198
199 public String getVendorItemIdentifier() {
200 return vendorItemIdentifier;
201 }
202
203 public void setVendorItemIdentifier(String vendorItemIdentifier) {
204 this.vendorItemIdentifier = vendorItemIdentifier;
205 }
206
207 public String getLocalTitleId() {
208 return localTitleId;
209 }
210
211 public String getDonorCode() {
212 return donorCode;
213 }
214
215 public void setDonorCode(String donorCode) {
216 this.donorCode = donorCode;
217 }
218
219 public String getDonorId() {
220 return donorId;
221 }
222
223 public void setDonorId(String donorId) {
224 this.donorId = donorId;
225 }
226
227 public List<OLELinkPurapDonor> getOleDonors() {
228 return oleDonors;
229 }
230
231 public void setOleDonors(List<OLELinkPurapDonor> oleDonors) {
232 this.oleDonors = oleDonors;
233 }
234
235 public void setLocalTitleId(String localTitleId) {
236 this.localTitleId = localTitleId;
237 }
238
239
240
241
242
243
244 public Integer getReceiptStatusId() {
245 return receiptStatusId;
246 }
247
248
249
250
251
252
253 public void setReceiptStatusId(Integer receiptStatusId) {
254 this.receiptStatusId = receiptStatusId;
255 }
256
257
258
259
260
261
262 public OleReceiptStatus getOleReceiptStatus() {
263 return oleReceiptStatus;
264 }
265
266
267
268
269
270
271 public void setOleReceiptStatus(OleReceiptStatus oleReceiptStatus) {
272 this.oleReceiptStatus = oleReceiptStatus;
273 }
274
275 public OleOrderRecord getOleOrderRecord() {
276 return oleOrderRecord;
277 }
278
279 public void setOleOrderRecord(OleOrderRecord oleOrderRecord) {
280 this.oleOrderRecord = oleOrderRecord;
281 }
282
283
284 protected boolean additionalChargeUsd;
285
286
287
288
289 public OleInvoiceItem() {
290 this.setItemNoOfParts(new KualiInteger(1));
291 this.setItemUnitOfMeasureCode(PurapConstants.InvoiceDocumentStrings.CUSTOMER_INVOICE_DETAIL_UOM_DEFAULT);
292 this.setOleItemQuantity(new KualiInteger(1));
293 this.setItemListPrice(new KualiDecimal(0.00));
294 notes = new ArrayList<OleInvoiceNote>();
295 }
296
297
298
299
300
301
302
303
304 public OleInvoiceItem(PurchaseOrderItem poi, InvoiceDocument prqs, HashMap<String, ExpiredOrClosedAccountEntry> expiredOrClosedAccountList) {
305 super(poi, prqs, expiredOrClosedAccountList);
306 this.setInvoiceDocument(prqs);
307 LOG.debug("Inside OleInvoiceItem Constructor");
308 LOG.debug("Setting the Format,Discount and Price Details");
309 notes = new ArrayList<OleInvoiceNote>();
310
311 OlePurchaseOrderItem olePoi = (OlePurchaseOrderItem) poi;
312 olePoi.getItemTypeCode();
313 notes.addAll(olePoi.getInvoiceNotes());
314 this.setItemForeignDiscount(olePoi.getInvoiceForeignDiscount() != null ? new KualiDecimal(olePoi.getInvoiceForeignDiscount()) : new KualiDecimal(0.00));
315 this.setForeignDiscount(olePoi.getInvoiceForeignDiscount());
316 this.setItemForeignDiscountType(olePoi.getInvoiceForeignDiscountType());
317 this.setItemForeignDiscountAmt(olePoi.getItemForeignDiscountAmt());
318 this.setItemCurrencyType(olePoi.getInvoiceForeignCurrency() != null ? olePoi.getInvoiceForeignCurrency() : olePoi.getItemCurrencyType());
319 this.setInvoicedCurrency(olePoi.getInvoiceForeignCurrency() != null ? olePoi.getInvoiceForeignCurrency() : olePoi.getItemCurrencyType());
320 this.setItemExchangeRate(olePoi.getInvoiceExchangeRate() != null ? new KualiDecimal(olePoi.getInvoiceExchangeRate()) : new KualiDecimal(0.00));
321 this.setExchangeRate(olePoi.getInvoiceExchangeRate() != null ? olePoi.getInvoiceExchangeRate() : null);
322 this.setItemUnitCostUSD(olePoi.getItemUnitCostUSD());
323 this.setFormatTypeId(olePoi.getFormatTypeId());
324 this.setItemNoOfParts(olePoi.getNoOfPartsInvoiced());
325 this.setOleDonors(olePoi.getOleDonors());
326 this.setItemListPrice(olePoi.getItemListPrice());
327 this.setItemDiscount(olePoi.getItemDiscount() != null ? olePoi.getItemDiscount() : new KualiDecimal(0.00));
328 this.setItemDiscountType(olePoi.getItemDiscountType());
329 this.setItemCatalogNumber(olePoi.getItemCatalogNumber());
330 this.setPoItemIdentifier(olePoi.getItemIdentifier());
331 this.setExtendedPrice(olePoi.getExtendedPrice());
332 this.setItemQuantity(olePoi.getItemQuantity());
333 this.setBibInfoBean(olePoi.getBibInfoBean());
334 if (olePoi.getItemTitleId() != null) {
335 this.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(olePoi.getItemTitleId()));
336 }
337 this.setItemTitleId(olePoi.getItemTitleId());
338 if (olePoi.getNoOfCopiesInvoiced() != null) {
339 this.setItemQuantity(olePoi.getNoOfCopiesInvoiced().kualiDecimalValue());
340 }
341 if (new KualiDecimal(olePoi.getInvoiceItemListPrice()).isLessThan(AbstractKualiDecimal.ZERO)) {
342 this.setInvoiceListPrice(olePoi.getInvoiceItemListPrice());
343 this.setListPrice(olePoi.getInvoiceItemListPrice());
344
345 } else {
346 this.setItemListPrice(new KualiDecimal(olePoi.getInvoiceItemListPrice()));
347 }
348 if (new KualiDecimal(olePoi.getInvoiceForeignItemListPrice()).isLessThan(AbstractKualiDecimal.ZERO)) {
349 this.setInvoiceForeignListPrice(olePoi.getInvoiceForeignItemListPrice());
350 this.setForeignListPrice(olePoi.getInvoiceForeignItemListPrice());
351 } else {
352 this.setItemForeignListPrice(new KualiDecimal(olePoi.getInvoiceForeignItemListPrice()));
353 }
354
355 this.setItemUnitPrice(SpringContext.getBean(OlePurapService.class).calculateDiscount(this).setScale(4, BigDecimal.ROUND_HALF_UP));
356 this.setItemForeignUnitCost(SpringContext.getBean(OlePurapService.class).calculateForeignCurrency(this).itemForeignUnitCost);
357 this.setForeignUnitCost(this.getItemForeignUnitCost().toString());
358 this.setExtendedPrice(this.calculateExtendedPrice());
359 this.setReceiptStatusId(olePoi.getReceiptStatusId());
360 this.setItemSurcharge(olePoi.getItemSurcharge());
361 this.setPurapDocumentIdentifier(prqs.getPurapDocumentIdentifier());
362
363 this.setSubscriptionOverlap(olePoi.isSubscriptionOverlap());
364 this.setSubscriptionFromDate(olePoi.getSubscriptionFromDate());
365 this.setSubscriptionToDate(olePoi.getSubscriptionToDate());
366 this.setItemRouteToRequestorIndicator(olePoi.isItemRouteToRequestorIndicator());
367 this.setItemPublicViewIndicator(olePoi.isItemPublicViewIndicator());
368 }
369
370
371
372
373
374
375
376 public OleInvoiceItem(PurchaseOrderItem poi, InvoiceDocument prqs) {
377 super(poi, prqs);
378 this.setInvoiceDocument(prqs);
379 LOG.debug("Inside OleInvoiceItem Constructor");
380 LOG.debug("Setting the Format,Discount and Price Details");
381 notes = new ArrayList<OleInvoiceNote>();
382 OlePurchaseOrderItem olePoi = (OlePurchaseOrderItem) poi;
383 notes.addAll(olePoi.getInvoiceNotes());
384 this.setItemForeignDiscount(olePoi.getInvoiceForeignDiscount() != null? new KualiDecimal(olePoi.getInvoiceForeignDiscount()) : new KualiDecimal(0.00));
385 this.setForeignDiscount(olePoi.getInvoiceForeignDiscount());
386 this.setItemForeignDiscountType(olePoi.getItemForeignDiscountType());
387 this.setItemForeignDiscountAmt(olePoi.getItemForeignDiscountAmt());
388 this.setItemForeignUnitCost(olePoi.getItemForeignUnitCost());
389 this.setItemTitleId(olePoi.getItemTitleId());
390 this.setItemCurrencyType(olePoi.getInvoiceForeignCurrency()!=null ? olePoi.getInvoiceForeignCurrency() : olePoi.getItemCurrencyType());
391 this.setInvoicedCurrency(olePoi.getInvoiceForeignCurrency()!=null? olePoi.getInvoiceForeignCurrency() : olePoi.getItemCurrencyType());
392 this.setItemExchangeRate(olePoi.getInvoiceExchangeRate()!= null ? new KualiDecimal(olePoi.getInvoiceExchangeRate()) : new KualiDecimal(0.00));
393 this.setExchangeRate(olePoi.getInvoiceExchangeRate()!= null? olePoi.getInvoiceExchangeRate() : null);
394 this.setItemUnitCostUSD(olePoi.getItemUnitCostUSD());
395 this.setOleDonors(olePoi.getOleDonors());
396 this.setFormatTypeId(olePoi.getFormatTypeId());
397 this.setItemNoOfParts(olePoi.getItemNoOfParts());
398 this.setItemListPrice(olePoi.getItemListPrice());
399 this.setItemDiscount(olePoi.getItemDiscount() != null ? olePoi.getItemDiscount() : new KualiDecimal(0.00));
400 this.setItemDiscountType(olePoi.getItemDiscountType());
401 this.setItemCatalogNumber(olePoi.getItemCatalogNumber());
402 if (olePoi.getItemTitleId() != null) {
403 this.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(olePoi.getItemTitleId()));
404 }
405 this.setPoItemIdentifier(olePoi.getItemIdentifier());
406 if (olePoi.getNoOfCopiesInvoiced() != null) {
407 this.setItemQuantity(olePoi.getNoOfCopiesInvoiced().kualiDecimalValue());
408 }
409 if (new KualiDecimal(olePoi.getInvoiceItemListPrice()).isLessThan(AbstractKualiDecimal.ZERO)) {
410 this.setInvoiceListPrice(olePoi.getInvoiceItemListPrice());
411 this.setListPrice(olePoi.getInvoiceItemListPrice());
412
413 } else {
414 this.setItemListPrice(new KualiDecimal(olePoi.getInvoiceItemListPrice()));
415 }
416 if (new KualiDecimal(olePoi.getInvoiceForeignItemListPrice()).isLessThan(AbstractKualiDecimal.ZERO)) {
417 this.setInvoiceForeignListPrice(olePoi.getInvoiceForeignItemListPrice());
418 this.setForeignListPrice(olePoi.getInvoiceForeignItemListPrice());
419 } else {
420 this.setItemForeignListPrice(new KualiDecimal(olePoi.getInvoiceForeignItemListPrice()));
421 }
422
423 this.setItemUnitPrice(SpringContext.getBean(OlePurapService.class).calculateDiscount(this).setScale(4, BigDecimal.ROUND_HALF_UP));
424 this.setItemForeignUnitCost(SpringContext.getBean(OlePurapService.class).calculateForeignCurrency(this).itemForeignUnitCost);
425 this.setForeignUnitCost(this.getItemForeignUnitCost().toString());
426 this.setExtendedPrice(this.calculateExtendedPrice());
427 this.setPurapDocumentIdentifier(prqs.getPurapDocumentIdentifier());
428 this.setItemRouteToRequestorIndicator(olePoi.isItemRouteToRequestorIndicator());
429 this.setItemPublicViewIndicator(olePoi.isItemPublicViewIndicator());
430 }
431
432 @Override
433 public boolean isConsideredEnteredWithZero() {
434 return isConsideredEntered(true);
435 }
436
437 @Override
438 public boolean isConsideredEnteredWithoutZero() {
439 return isConsideredEntered(false);
440 }
441
442 private boolean isConsideredEntered(boolean allowsZero) {
443 if (getItemType().isLineItemIndicator()) {
444 if ((getItemType().isQuantityBasedGeneralLedgerIndicator())) {
445 if ((ObjectUtils.isNull(getItemQuantity()) || getItemQuantity().isZero()) && (ObjectUtils.isNull(getExtendedPrice()) || (allowsZero && getExtendedPrice().isZero()))) {
446 return false;
447 }
448 } else {
449 if (ObjectUtils.isNull(getExtendedPrice()) || (allowsZero && getExtendedPrice().isZero())) {
450 return false;
451 }
452 }
453 } else {
454 if ((ObjectUtils.isNull(getItemUnitPrice()) || (allowsZero && this.getItemUnitPrice().compareTo(new BigDecimal(0)) == 0)) && (StringUtils.isBlank(getItemDescription()))) {
455 return false;
456 }
457 }
458
459 return true;
460 }
461
462 public String getItemCurrencyType() {
463 return itemCurrencyType;
464 }
465
466 public void setItemCurrencyType(String itemCurrencyType) {
467 this.itemCurrencyType = itemCurrencyType;
468 }
469
470 public KualiDecimal getItemForeignListPrice() {
471 return itemForeignListPrice;
472 }
473
474 public void setItemForeignListPrice(KualiDecimal itemForeignListPrice) {
475 this.itemForeignListPrice = itemForeignListPrice;
476 }
477
478 public KualiDecimal getItemForeignDiscount() {
479 return itemForeignDiscount;
480 }
481
482 public void setItemForeignDiscount(KualiDecimal itemForeignDiscount) {
483 this.itemForeignDiscount = itemForeignDiscount;
484 }
485
486 public String getItemForeignDiscountType() {
487 return itemForeignDiscountType;
488 }
489
490 public void setItemForeignDiscountType(String itemForeignDiscountType) {
491 this.itemForeignDiscountType = itemForeignDiscountType;
492 }
493
494 public KualiDecimal getItemForeignDiscountAmt() {
495 return itemForeignDiscountAmt;
496 }
497
498 public void setItemForeignDiscountAmt(KualiDecimal itemForeignDiscountAmt) {
499 this.itemForeignDiscountAmt = itemForeignDiscountAmt;
500 }
501
502 public KualiDecimal getItemForeignUnitCost() {
503 return itemForeignUnitCost;
504 }
505
506 public void setItemForeignUnitCost(KualiDecimal itemForeignUnitCost) {
507 this.itemForeignUnitCost = itemForeignUnitCost;
508 }
509
510 public String getInvoicedCurrency() {
511 return invoicedCurrency;
512 }
513
514 public void setInvoicedCurrency(String invoicedCurrency) {
515 this.invoicedCurrency = invoicedCurrency;
516 }
517
518 public String getExchangeRate() {
519 if (exchangeRate != null && !exchangeRate.isEmpty()) {
520 return exchangeRate;
521 } else {
522 return itemExchangeRate!= null? itemExchangeRate.toString() :null;
523 }
524 }
525
526 public void setExchangeRate(String exchangeRate) {
527 this.exchangeRate = exchangeRate;
528 }
529
530 public String getForeignDiscount() {
531 if (foreignDiscount != null && !foreignDiscount.isEmpty()) {
532 return foreignDiscount;
533 } else {
534 return itemForeignDiscount!= null? itemForeignDiscount.toString() :null;
535 }
536 }
537
538 public void setForeignDiscount(String foreignDiscount) {
539 this.foreignDiscount = foreignDiscount;
540 }
541
542 public String getForeignUnitCost() {
543 if (foreignUnitCost != null && !foreignUnitCost.isEmpty()) {
544 return foreignUnitCost;
545 } else {
546 if (!debitItem) {
547 return itemForeignUnitCost != null ? "(" + itemForeignUnitCost.toString().replace("-", "") + ")" : null;
548 } else {
549 return itemForeignUnitCost.toString();
550 }
551 }
552 }
553
554 public void setForeignUnitCost(String foreignUnitCost) {
555 this.foreignUnitCost = foreignUnitCost;
556 if (foreignUnitCost != null) {
557 if (foreignUnitCost.contains("(") || foreignUnitCost.contains(")")) {
558 foreignUnitCost = foreignUnitCost.replace("(", "");
559 foreignUnitCost = foreignUnitCost.replace(")", "");
560 foreignUnitCost = "-" + foreignUnitCost;
561 this.foreignUnitCost = foreignUnitCost;
562 }
563 if (new KualiDecimal(foreignUnitCost).isLessThan(KualiDecimal.ZERO)) {
564 foreignUnitCost = foreignUnitCost.replace("-", "");
565 foreignUnitCost = "(" + foreignUnitCost + ")";
566 this.foreignUnitCost = foreignUnitCost;
567 } else {
568 this.foreignUnitCost = foreignUnitCost;
569 }
570 }
571
572 }
573
574 public String getAdditionalForeignUnitCost() {
575 if (!isDebitItem()) {
576 additionalForeignUnitCost = this.getItemForeignUnitCost() != null ? this.getItemForeignUnitCost().negated().toString() : null;
577 } else{
578 additionalForeignUnitCost = this.getItemForeignUnitCost() != null ? this.getItemForeignUnitCost().toString() : null;
579 }
580 return this.additionalForeignUnitCost;
581 }
582
583 public void setAdditionalForeignUnitCost(String additionalForeignUnitCost) {
584 if (additionalForeignUnitCost != null && !additionalForeignUnitCost.isEmpty() &&
585 (new KualiDecimal(additionalForeignUnitCost)).isLessThan(AbstractKualiDecimal.ZERO)) {
586
587 this.setItemForeignUnitCost(new KualiDecimal(additionalForeignUnitCost).abs());
588 this.additionalForeignUnitCost = additionalForeignUnitCost;
589 } else if (additionalForeignUnitCost != null && !additionalForeignUnitCost.isEmpty() &&
590 (new KualiDecimal(additionalForeignUnitCost)).isGreaterEqual(AbstractKualiDecimal.ZERO)) {
591
592 this.setItemForeignUnitCost((new KualiDecimal(additionalForeignUnitCost)));
593 this.additionalForeignUnitCost = additionalForeignUnitCost;
594 }
595 else {
596 this.setItemForeignUnitCost(null);
597 this.additionalForeignUnitCost = additionalForeignUnitCost;
598 }
599 }
600
601 public KualiDecimal getItemExchangeRate() {
602 return itemExchangeRate;
603 }
604
605 public void setItemExchangeRate(KualiDecimal itemExchangeRate) {
606 this.itemExchangeRate = itemExchangeRate;
607 }
608
609 public KualiDecimal getItemUnitCostUSD() {
610 return itemUnitCostUSD;
611 }
612
613 public void setItemUnitCostUSD(KualiDecimal itemUnitCostUSD) {
614 this.itemUnitCostUSD = itemUnitCostUSD;
615 }
616
617 public Integer getFormatTypeId() {
618 return formatTypeId;
619 }
620
621 public void setFormatTypeId(Integer formatTypeId) {
622 this.formatTypeId = formatTypeId;
623 }
624
625 public KualiInteger getItemNoOfParts() {
626 if (this.itemNoOfParts != null) {
627 return itemNoOfParts;
628 } else {
629 return itemNoOfParts;
630 }
631 }
632
633 public void setItemNoOfParts(KualiInteger itemNoOfParts) {
634 this.itemNoOfParts = itemNoOfParts;
635 }
636
637 public KualiDecimal getItemListPrice() {
638 return itemListPrice;
639 }
640
641 public void setItemListPrice(KualiDecimal itemListPrice) {
642 this.itemListPrice = itemListPrice;
643 }
644
645 public String getDiscountItem() {
646 return String.valueOf(itemDiscount) != null ? String.valueOf(itemDiscount) : "0";
647 }
648
649 public void setDiscountItem(String discountItem) {
650 this.itemDiscount = new KualiDecimal(discountItem);
651 }
652
653 public KualiDecimal getItemDiscount() {
654 return itemDiscount;
655 }
656
657 public void setItemDiscount(KualiDecimal itemDiscount) {
658 this.itemDiscount = itemDiscount;
659 }
660
661 public String getItemDiscountType() {
662 return itemDiscountType;
663 }
664
665 public void setItemDiscountType(String itemDiscountType) {
666 this.itemDiscountType = itemDiscountType;
667 }
668
669 public BigDecimal getItemSurcharge() {
670 return itemSurcharge;
671 }
672
673 public void setItemSurcharge(BigDecimal itemSurcharge) {
674 this.itemSurcharge = itemSurcharge;
675 }
676
677 public Integer getPoItemIdentifier() {
678 return poItemIdentifier;
679 }
680
681 public void setPoItemIdentifier(Integer poItemIdentifier) {
682 this.poItemIdentifier = poItemIdentifier;
683 }
684
685 public String getNote() {
686 return note;
687 }
688
689 public void setNote(String note) {
690 this.note = note;
691 }
692
693 public List<OleInvoiceNote> getNotes() {
694 return notes;
695 }
696
697 public void setNotes(List<OleInvoiceNote> notes) {
698 this.notes = notes;
699 }
700
701 public UnitOfMeasure getItemUnitOfMeasure() {
702 if (ObjectUtils.isNull(itemUnitOfMeasure) || !StringUtils.equalsIgnoreCase(itemUnitOfMeasure.getItemUnitOfMeasureCode(), getItemUnitOfMeasureCode())) {
703 refreshReferenceObject(PurapPropertyConstants.ITEM_UNIT_OF_MEASURE);
704 }
705 return itemUnitOfMeasure;
706 }
707
708 public void setItemUnitOfMeasure(UnitOfMeasure itemUnitOfMeasure) {
709 this.itemUnitOfMeasure = itemUnitOfMeasure;
710 }
711
712 public boolean getIsUnorderedItem() {
713 if (this.getItemTypeCode().equalsIgnoreCase(PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE)) {
714 return false;
715 }
716 return true;
717 }
718
719 public KualiDecimal getForeignCurrencyExtendedPrice() {
720 return foreignCurrencyExtendedPrice;
721 }
722
723 public void setForeignCurrencyExtendedPrice(KualiDecimal foreignCurrencyExtendedPrice) {
724 this.foreignCurrencyExtendedPrice = foreignCurrencyExtendedPrice;
725 }
726
727 public String getItemTitleId() {
728 return itemTitleId;
729 }
730
731 public void setItemTitleId(String itemTitleId) {
732 this.itemTitleId = itemTitleId;
733 }
734
735 public BibInfoBean getBibInfoBean() {
736 return bibInfoBean;
737 }
738
739 public void setBibInfoBean(BibInfoBean bibInfoBean) {
740 this.bibInfoBean = bibInfoBean;
741 }
742
743 public String getBibUUID() {
744 return bibUUID;
745 }
746
747 public void setBibUUID(String bibUUID) {
748 this.bibUUID = bibUUID;
749 }
750
751 public DocData getDocData() {
752 return docData;
753 }
754
755 public void setDocData(DocData docData) {
756 this.docData = docData;
757 }
758
759 public InvoiceDocument getInvoiceDocument() {
760 return invoiceDocument;
761 }
762
763 public void setInvoiceDocument(InvoiceDocument invoiceDocument) {
764 setPurapDocument(invoiceDocument);
765 this.invoiceDocument = invoiceDocument;
766 }
767
768 public boolean isAdditionalChargeUsd() {
769 return additionalChargeUsd;
770 }
771
772 public void setAdditionalChargeUsd(boolean additionalChargeUsd) {
773 this.additionalChargeUsd = additionalChargeUsd;
774 }
775
776 public String getOleCopiesOrdered() {
777 return String.valueOf(super.getItemQuantity().intValue());
778 }
779
780 public void setOleCopiesOrdered(String oleCopiesOrdered) {
781 super.setItemQuantity(new KualiDecimal(oleCopiesOrdered));
782 }
783
784
785
786
787
788
789 public KualiInteger getOleItemQuantity() {
790 return new KualiInteger(super.getItemQuantity().intValue());
791 }
792
793
794
795
796
797
798 public void setOleItemQuantity(KualiInteger oleItemQuantity) {
799 super.setItemQuantity(new KualiDecimal(oleItemQuantity.intValue()));
800 }
801
802
803
804
805
806
807 public KualiInteger getOlePoOutstandingQuantity() {
808 if (getPoOutstandingQuantity() != null) {
809 return new KualiInteger(super.getPoOutstandingQuantity().intValue());
810 }
811 return new KualiInteger(0);
812 }
813
814
815
816
817
818
819 public void setOlePoOutstandingQuantity(KualiInteger olePoOutstandingQuantity) {
820 if (olePoOutstandingQuantity != null) {
821 super.setPoOutstandingQuantity(new KualiDecimal(olePoOutstandingQuantity.intValue()));
822 }
823 }
824
825 public boolean isUseTaxIndicator() {
826 return useTaxIndicator;
827 }
828
829 public void setUseTaxIndicator(boolean useTaxIndicator) {
830 this.useTaxIndicator = useTaxIndicator;
831 }
832
833 @Override
834 public KualiDecimal getItemTaxAmount() {
835 KualiDecimal taxAmount = KualiDecimal.ZERO;
836
837
838
839
840
841 if (this.isUseTaxIndicator() == false) {
842 taxAmount = this.getItemSalesTaxAmount();
843 } else {
844
845 for (PurApItemUseTax useTaxItem : this.getUseTaxItems()) {
846 taxAmount = taxAmount.add(useTaxItem.getTaxAmount());
847 }
848 }
849
850 return taxAmount;
851 }
852
853 public OleFormatType getFormatType() {
854 return formatType;
855 }
856
857 public void setFormatType(OleFormatType formatType) {
858 this.formatType = formatType;
859 }
860
861 public PurApRelatedViews getRelatedViews() {
862 if (relatedViews == null) {
863 relatedViews = new PurApRelatedViews(
864 this.getInvoiceDocument() != null ? this.getInvoiceDocument().getDocumentNumber()
865 : null,
866 this.getAccountsPayablePurchasingDocumentLinkIdentifier() != null ?
867 this.getAccountsPayablePurchasingDocumentLinkIdentifier() : null);
868 }
869 return relatedViews;
870 }
871
872 public void setRelatedViews(PurApRelatedViews relatedViews) {
873 this.relatedViews = relatedViews;
874 }
875
876 public Boolean getRelatedViewExist() {
877 if (this.relatedViews != null) {
878 this.relatedViewExist = Boolean.TRUE;
879 } else {
880 this.relatedViewExist = Boolean.FALSE;
881 }
882 return relatedViewExist;
883 }
884
885 public void setRelatedViewExist(Boolean relatedViewExist) {
886 this.relatedViewExist = relatedViewExist;
887 }
888
889 public boolean isDebitItem() {
890 return debitItem;
891 }
892
893 public void setDebitItem(boolean debitItem) {
894 this.debitItem = debitItem;
895 }
896
897 public String getInvoiceListPrice() {
898 if (!isDebitItem()) {
899 return this.getItemListPrice() != null ? this.getItemListPrice().negated().toString() : null;
900 }
901 return itemListPrice.toString();
902 }
903
904 public void setInvoiceListPrice(String invoiceListPrice) {
905 if (invoiceListPrice != null && !invoiceListPrice.isEmpty() &&
906 (new KualiDecimal(invoiceListPrice)).isLessThan(AbstractKualiDecimal.ZERO)) {
907 this.setDebitItem(false);
908 } else {
909 this.setDebitItem(true);
910 }
911 this.setItemListPrice((new KualiDecimal(invoiceListPrice)).abs());
912 this.invoiceListPrice = invoiceListPrice;
913 }
914
915 public String getInvoiceForeignListPrice() {
916 if (!isDebitItem()) {
917 return this.getItemForeignListPrice() != null ? this.getItemForeignListPrice().negated().toString() : null;
918 }
919 return invoiceForeignListPrice;
920 }
921
922 public void setInvoiceForeignListPrice(String invoiceForeignListPrice) {
923 if (invoiceForeignListPrice != null && !invoiceForeignListPrice.isEmpty() &&
924 (new KualiDecimal(invoiceForeignListPrice)).isLessThan(AbstractKualiDecimal.ZERO)) {
925 this.setDebitItem(false);
926 } else {
927 this.setDebitItem(true);
928 }
929 this.setItemForeignListPrice((new KualiDecimal(invoiceForeignListPrice)).abs());
930 this.invoiceForeignListPrice = invoiceForeignListPrice;
931 }
932
933 public String getAdditionalUnitPrice() {
934 if (!isDebitItem()) {
935 additionalUnitPrice = this.getItemUnitPrice() != null ? this.getItemUnitPrice().negate().toString() : null;
936 } else{
937 additionalUnitPrice = this.getItemUnitPrice() != null ? this.getItemUnitPrice().toString() : null;
938 }
939 return this.additionalUnitPrice;
940 }
941
942 public String getListPrice() {
943 if (listPrice != null && !listPrice.isEmpty()) {
944 return listPrice;
945 } else if (invoiceListPrice != null && new KualiDecimal(invoiceListPrice).isLessThan(KualiDecimal.ZERO)) {
946 return "(" + invoiceListPrice.replace("-", "") + ")";
947 } else {
948 if (!debitItem) {
949 return "(" + itemListPrice.toString().replace("-", "") + ")";
950 } else {
951 return itemListPrice.toString();
952 }
953 }
954 }
955
956 public void setListPrice(String listPrice) {
957 this.listPrice = listPrice;
958 if (listPrice.contains("(") || listPrice.contains(")")) {
959 listPrice = listPrice.replace("(", "");
960 listPrice = listPrice.replace(")", "");
961 listPrice = "-" + listPrice;
962 this.listPrice = listPrice;
963 }
964 if (new KualiDecimal(listPrice).isLessThan(KualiDecimal.ZERO)) {
965 this.setInvoiceListPrice(listPrice);
966 listPrice = listPrice.replace("-", "");
967 listPrice = "(" + listPrice + ")";
968 this.listPrice = listPrice;
969 } else {
970 this.setInvoiceListPrice(listPrice);
971 this.listPrice = listPrice;
972 }
973
974 }
975
976 public String getForeignListPrice() {
977 if (foreignListPrice != null && !foreignListPrice.isEmpty()) {
978 return foreignListPrice;
979 } else if (invoiceForeignListPrice != null && new KualiDecimal(invoiceForeignListPrice).isLessThan(KualiDecimal.ZERO)) {
980 return "(" + invoiceForeignListPrice.replace("-", "") + ")";
981 } else {
982 if (!debitItem) {
983 return "(" + itemForeignListPrice.toString().replace("-", "") + ")";
984 } else {
985 return itemForeignListPrice.toString();
986 }
987 }
988 }
989
990 public void setForeignListPrice(String foreignListPrice) {
991 this.foreignListPrice = foreignListPrice;
992 if(foreignListPrice != null) {
993 if (foreignListPrice.contains("(") || foreignListPrice.contains(")")) {
994 foreignListPrice = foreignListPrice.replace("(", "");
995 foreignListPrice = foreignListPrice.replace(")", "");
996 foreignListPrice = "-" + foreignListPrice;
997 this.foreignListPrice = foreignListPrice;
998 }
999 if (new KualiDecimal(foreignListPrice).isLessThan(KualiDecimal.ZERO)) {
1000 this.setInvoiceForeignListPrice(foreignListPrice);
1001 foreignListPrice = foreignListPrice.replace("-", "");
1002 foreignListPrice = "(" + foreignListPrice + ")";
1003 this.foreignListPrice = foreignListPrice;
1004 } else {
1005 this.setInvoiceForeignListPrice(foreignListPrice);
1006 this.foreignListPrice = foreignListPrice;
1007 }
1008 }
1009 }
1010
1011 public void setAdditionalUnitPrice(String additionalUnitPrice) {
1012 if (additionalUnitPrice != null && !additionalUnitPrice.isEmpty() &&
1013 (new KualiDecimal(additionalUnitPrice)).isLessThan(AbstractKualiDecimal.ZERO)) {
1014 this.setDebitItem(false);
1015 this.setItemUnitPrice((new BigDecimal(additionalUnitPrice)).abs());
1016 this.additionalUnitPrice = additionalUnitPrice;
1017 } else if (additionalUnitPrice != null && !additionalUnitPrice.isEmpty() &&
1018 (new KualiDecimal(additionalUnitPrice)).isGreaterEqual(AbstractKualiDecimal.ZERO)) {
1019 this.setDebitItem(true);
1020 this.setItemUnitPrice((new BigDecimal(additionalUnitPrice)));
1021 this.additionalUnitPrice = additionalUnitPrice;
1022 }
1023 else {
1024 this.setItemUnitPrice(null);
1025 this.additionalUnitPrice = additionalUnitPrice;
1026 }
1027
1028 }
1029
1030 public String getPoItemLink() {
1031 if (poItemIdentifier != null) {
1032 String documentTypeName = PurapConstants.PurchaseOrderDocTypes.PURCHASE_ORDER_DOCUMENT;
1033 DocumentType docType = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName);
1034 String docHandlerUrl = docType.getResolvedDocumentHandlerUrl();
1035 int endSubString = docHandlerUrl.lastIndexOf("/");
1036 String serverName = docHandlerUrl.substring(0, endSubString);
1037 String handler = docHandlerUrl.substring(endSubString + 1, docHandlerUrl.lastIndexOf("?"));
1038 poItemLink = serverName + "/" + KRADConstants.PORTAL_ACTION + "?channelTitle=" + docType.getName() + "&channelUrl=" +
1039 handler + "?" + KRADConstants.DISPATCH_REQUEST_PARAMETER + "=" + KRADConstants.DOC_HANDLER_METHOD + "&" +
1040 KRADConstants.PARAMETER_DOC_ID + "=" + this.getPurchaseOrderDocument().getDocumentNumber() + "&" + KRADConstants.PARAMETER_COMMAND + "=" +
1041 KewApiConstants.DOCSEARCH_COMMAND;
1042
1043 } else {
1044 poItemLink = "";
1045 }
1046 return poItemLink;
1047 }
1048
1049 public void setPoItemLink(String poItemLink) {
1050 this.poItemLink = poItemLink;
1051 }
1052
1053 public Date getSubscriptionFromDate() {
1054 return subscriptionFromDate;
1055 }
1056
1057 public void setSubscriptionFromDate(Date subscriptionFromDate) {
1058 this.subscriptionFromDate = subscriptionFromDate;
1059 }
1060
1061 public Date getSubscriptionToDate() {
1062 return subscriptionToDate;
1063 }
1064
1065 public void setSubscriptionToDate(Date subscriptionToDate) {
1066 this.subscriptionToDate = subscriptionToDate;
1067 }
1068
1069 public boolean isSubscriptionOverlap() {
1070 return subscriptionOverlap;
1071 }
1072
1073 public void setSubscriptionOverlap(boolean subscriptionOverlap) {
1074 this.subscriptionOverlap = subscriptionOverlap;
1075 }
1076
1077 public Date getPurchaseOrderEndDate() {
1078 return purchaseOrderEndDate;
1079 }
1080
1081 public void setPurchaseOrderEndDate(Date purchaseOrderEndDate) {
1082 this.purchaseOrderEndDate = purchaseOrderEndDate;
1083 }
1084
1085
1086 public void setPaidCopies(List<OLEPaidCopy> paidCopies) {
1087 this.paidCopies = paidCopies;
1088 }
1089
1090 public List<OLEPaidCopy> getPaidCopies() {
1091 return paidCopies;
1092 }
1093
1094 public void setOleInvoiceOffsetAccountingLine(OLEInvoiceOffsetAccountingLine oleInvoiceOffsetAccountingLine) {
1095 this.oleInvoiceOffsetAccountingLine = oleInvoiceOffsetAccountingLine;
1096 }
1097
1098 public List<SourceAccountingLine> getSourceAccountingLineList() {
1099 return sourceAccountingLineList;
1100 }
1101
1102 public void setSourceAccountingLineList(List<SourceAccountingLine> sourceAccountingLineList) {
1103 this.sourceAccountingLineList = sourceAccountingLineList;
1104 }
1105
1106 public OLEInvoiceOffsetAccountingLine getOleInvoiceOffsetAccountingLine() {
1107 return oleInvoiceOffsetAccountingLine;
1108 }
1109
1110 public Integer getReLinkPO() {
1111 return reLinkPO;
1112 }
1113
1114 public void setReLinkPO(Integer reLinkPO) {
1115 this.reLinkPO = reLinkPO;
1116 }
1117
1118 @Override
1119 public PurchaseOrderItem getPurchaseOrderItem() {
1120 InvoiceDocument invDoc = getInvoice();
1121
1122
1123
1124
1125
1126 PurchaseOrderItem poi = null;
1127
1128
1129 if (invDoc!= null) {
1130 PurchaseOrderDocument po = invDoc.getPurchaseOrderDocument(this.getPurchaseOrderIdentifier());
1131 if (po != null) {
1132 this.setPostingYear(po.getPostingYear());
1133 if (po.getRecurringPaymentType() != null) {
1134 this.setRecurringPaymentType(po.getRecurringPaymentType());
1135 this.setRecurringPaymentTypeCode(po.getRecurringPaymentTypeCode());
1136
1137 }
1138
1139 if (this.getItemType().isLineItemIndicator() && this.getItemLineNumber() != null && this.getItemLineNumber()< 0) {
1140 List<PurchaseOrderItem> items = po.getItems();
1141 poi = items.get(this.getItemLineNumber().intValue() - 1);
1142
1143
1144
1145
1146
1147
1148
1149 } else if (this.getItemType().isLineItemIndicator()) {
1150 List<PurchaseOrderItem> items = po.getItems();
1151 for (int count = 0; count < items.size(); count++) {
1152 if (this.getPoItemIdentifier() != null) {
1153 if (this.getPoItemIdentifier().compareTo((items.get(count)).getItemIdentifier()) == 0) {
1154 this.setItemLineNumber(items.get(count).getItemLineNumber());
1155 poi = items.get(this.getItemLineNumber().intValue() - 1);
1156 break;
1157 }
1158 }
1159
1160 }
1161 } else {
1162 poi = (PurchaseOrderItem) SpringContext.getBean(PurapService.class).getBelowTheLineByType(po, this.getItemType());
1163 if (poi != null) {
1164 this.setItemLineNumber(poi.getItemLineNumber());
1165 }
1166 }
1167 }
1168
1169 if (poi != null) {
1170 this.setPoItem(poi);
1171 return poi;
1172 } else {
1173 if (LOG.isDebugEnabled()) {
1174 LOG.debug("getPurchaseOrderItem() Returning null because PurchaseOrderItem object for line number" + getItemLineNumber() + "or itemType " + getItemTypeCode() + " is null");
1175 }
1176 return null;
1177 }
1178 } else {
1179
1180 LOG.error("getPurchaseOrderItem() Returning null because invoice object is null");
1181 throw new PurError("Payment Request Object in Purchase Order item line number " + getItemLineNumber() + "or itemType " + getItemTypeCode() + " is null");
1182 }
1183 }
1184
1185 public Integer getRequisitionItemIdentifier() {
1186 return requisitionItemIdentifier;
1187 }
1188
1189 public void setRequisitionItemIdentifier(Integer requisitionItemIdentifier) {
1190 this.requisitionItemIdentifier = requisitionItemIdentifier;
1191 }
1192
1193
1194 public String getItemTitle() {
1195 itemTitle = getItemDescription();
1196 if(itemTitle.contains(OLEConstants.ANGLE_BRACKET_LESS_THAN)){
1197 itemTitle = itemTitle.replace(OLEConstants.ANGLE_BRACKET_LESS_THAN,"<");
1198 }
1199 if(itemTitle.contains(OLEConstants.ANGLE_BRACKET_GREATER_THAN)){
1200 itemTitle = itemTitle.replace(OLEConstants.ANGLE_BRACKET_GREATER_THAN,">");
1201 }
1202 return itemTitle;
1203 }
1204
1205 public void setItemTitle(String itemTitle) {
1206 this.itemTitle = itemTitle;
1207 }
1208
1209 public boolean isItemPublicViewIndicator() {
1210 return itemPublicViewIndicator;
1211 }
1212
1213 public void setItemPublicViewIndicator(boolean itemPublicViewIndicator) {
1214 this.itemPublicViewIndicator = itemPublicViewIndicator;
1215 }
1216
1217 public boolean isItemRouteToRequestorIndicator() {
1218 return itemRouteToRequestorIndicator;
1219 }
1220
1221 public void setItemRouteToRequestorIndicator(boolean itemRouteToRequestorIndicator) {
1222 this.itemRouteToRequestorIndicator = itemRouteToRequestorIndicator;
1223 }
1224
1225 public boolean isEnableDetailsSection() {
1226 return enableDetailsSection;
1227 }
1228
1229 public void setEnableDetailsSection(boolean enableDetailsSection) {
1230 this.enableDetailsSection = enableDetailsSection;
1231 }
1232
1233 public BigDecimal getItemExtendedPrice() {
1234 return calculateItemExtendedPrice();
1235 }
1236
1237
1238 public BigDecimal calculateItemExtendedPrice() {
1239 BigDecimal extendedPrice = BigDecimal.ZERO;
1240 BigDecimal itemUnitPrice = getItemUnitPrice();
1241 if (ObjectUtils.isNotNull(itemUnitPrice)) {
1242 if (this.getItemType().isAmountBasedGeneralLedgerIndicator()) {
1243
1244 extendedPrice = itemUnitPrice;
1245 } else if (ObjectUtils.isNotNull(this.getItemQuantity())) {
1246 BigDecimal calcExtendedPrice = itemUnitPrice.multiply(this.getItemQuantity().bigDecimalValue());
1247
1248 extendedPrice = calcExtendedPrice.setScale(4, KualiDecimal.ROUND_BEHAVIOR);
1249 }
1250 }
1251 return extendedPrice;
1252 }
1253
1254 @Override
1255 public KualiDecimal getTotalAmount() {
1256 KualiDecimal totalAmount = getExtendedPrice();
1257 if (ObjectUtils.isNull(totalAmount)) {
1258 totalAmount = KualiDecimal.ZERO;
1259 }
1260
1261 KualiDecimal taxAmount = getItemTaxAmount();
1262 if (ObjectUtils.isNull(taxAmount)) {
1263 taxAmount = KualiDecimal.ZERO;
1264 }
1265
1266 totalAmount = totalAmount.add(taxAmount);
1267
1268 return totalAmount;
1269 }
1270
1271 public BigDecimal getInvoiceTotalAmount() {
1272 BigDecimal totalAmount = getItemExtendedPrice();
1273 if (ObjectUtils.isNull(totalAmount)) {
1274 totalAmount = BigDecimal.ZERO;
1275 }
1276
1277 KualiDecimal taxAmount = getItemTaxAmount();
1278 if (ObjectUtils.isNull(taxAmount)) {
1279 taxAmount = KualiDecimal.ZERO;
1280 }
1281
1282 totalAmount = totalAmount.add(taxAmount.bigDecimalValue());
1283
1284 return totalAmount;
1285 }
1286
1287
1288 public KualiDecimal getForeignTotalAmount() {
1289 KualiDecimal totalAmount = calculateForeignExtendedPrice();
1290 if (ObjectUtils.isNull(totalAmount)) {
1291 totalAmount = KualiDecimal.ZERO;
1292 }
1293
1294 KualiDecimal taxAmount = getItemTaxAmount();
1295 if (ObjectUtils.isNull(taxAmount)) {
1296 taxAmount = KualiDecimal.ZERO;
1297 }
1298
1299 totalAmount = totalAmount.add(taxAmount);
1300
1301 return totalAmount;
1302 }
1303
1304 public KualiDecimal calculateForeignExtendedPrice() {
1305 KualiDecimal extendedPrice = KualiDecimal.ZERO;
1306 if (this.getItemTypeCode().equalsIgnoreCase(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE)) {
1307 if (ObjectUtils.isNotNull(itemForeignUnitCost)) {
1308 if (this.getItemType().isAmountBasedGeneralLedgerIndicator()) {
1309 extendedPrice = new KualiDecimal(this.itemForeignUnitCost.toString());
1310 } else if (ObjectUtils.isNotNull(this.getItemQuantity())) {
1311 BigDecimal calcExtendedPrice = this.itemForeignUnitCost.bigDecimalValue().multiply(this.getItemQuantity().bigDecimalValue());
1312 extendedPrice = new KualiDecimal(calcExtendedPrice.setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR));
1313 }
1314 }
1315 }
1316 return extendedPrice;
1317 }
1318
1319 public String getFundCode() {
1320 return fundCode;
1321 }
1322 public Integer getSequenceNumber() {
1323 return sequenceNumber;
1324 }
1325
1326 public void setFundCode(String fundCode) {
1327 this.fundCode = fundCode;
1328 }
1329 public void setSequenceNumber(Integer sequenceNumber) {
1330 this.sequenceNumber = sequenceNumber;
1331 }
1332 }