1
14
15 package com.liferay.portlet.shopping.model.impl;
16
17 import com.liferay.portal.kernel.util.CalendarUtil;
18 import com.liferay.portlet.shopping.model.ShoppingCoupon;
19
20 import java.util.Date;
21
22
27 public class ShoppingCouponImpl
28 extends ShoppingCouponModelImpl implements ShoppingCoupon {
29
30 public static final String DISCOUNT_TYPE_ACTUAL = "actual";
31
32 public static final String DISCOUNT_TYPE_FREE_SHIPPING = "free-shipping";
33
34 public static final String DISCOUNT_TYPE_PERCENTAGE = "percentage";
35
36 public static final String DISCOUNT_TYPE_TAX_FREE = "tax-free";
37
38 public static final String[] DISCOUNT_TYPES = {
39 "percentage", "actual", "free-shipping", "tax-free"
40 };
41
42 public ShoppingCouponImpl() {
43 }
44
45 public boolean hasValidDateRange() {
46 if (hasValidStartDate() && hasValidEndDate()) {
47 return true;
48 }
49 else {
50 return false;
51 }
52 }
53
54 public boolean hasValidEndDate() {
55 if (getEndDate() != null) {
56 Date now = new Date();
57
58 if (now.after(getEndDate())) {
59 return false;
60 }
61 }
62
63 return true;
64 }
65
66 public boolean hasValidStartDate() {
67 Date now = new Date();
68
69 if (CalendarUtil.beforeByDay(now, getStartDate())) {
70 return false;
71 }
72 else {
73 return true;
74 }
75 }
76
77 }