From 2e467fac30cf5fb5a5e6e62100a388ea6548e8a5 Mon Sep 17 00:00:00 2001 From: Jacopo Cappellato Date: Thu, 4 Oct 2007 16:23:50 +0000 Subject: [PATCH] Added fromDate and thruDate fields to the ProductPromoCode entity; if the dates are set they are used to specify the validity range of the promotion code. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@581961 13f79535-47bb-0310-9956-ffa450edef68 --- .../shoppingcart/product/ProductPromoWorker.java | 12 +++++++++++- applications/product/entitydef/entitymodel.xml | 2 ++ .../script/org/ofbiz/product/promo/PromoServices.xml | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java index c57f7f4e70..88f2400d89 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java @@ -512,6 +512,17 @@ public class ProductPromoWorker { if (productPromoCode == null) { return "The promotion code [" + productPromoCodeId + "] is not valid."; } + Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); + if (productPromoCode.getTimestamp("thruDate") != null) { + if (nowTimestamp.after(productPromoCode.getTimestamp("thruDate"))) { + return "The promotion code [" + productPromoCodeId + "] is expired in: " + productPromoCode.getTimestamp("thruDate"); + } + } + if (productPromoCode.getTimestamp("fromDate") != null) { + if (nowTimestamp.before(productPromoCode.getTimestamp("fromDate"))) { + return "The promotion code [" + productPromoCodeId + "] will be activated in: " + productPromoCode.getTimestamp("fromDate"); + } + } if ("Y".equals(productPromoCode.getString("requireEmailOrParty"))) { boolean hasEmailOrParty = false; @@ -524,7 +535,6 @@ public class ProductPromoWorker { } // check email address in ProductPromoCodeEmail - Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); List validEmailCondList = new ArrayList(); validEmailCondList.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId)); validEmailCondList.add(new EntityExpr("productPromoCodeId", EntityOperator.EQUALS, productPromoCodeId)); diff --git a/applications/product/entitydef/entitymodel.xml b/applications/product/entitydef/entitymodel.xml index 390b0641cb..aad5eb157c 100644 --- a/applications/product/entitydef/entitymodel.xml +++ b/applications/product/entitydef/entitymodel.xml @@ -2794,6 +2794,8 @@ under the License. + + diff --git a/applications/product/script/org/ofbiz/product/promo/PromoServices.xml b/applications/product/script/org/ofbiz/product/promo/PromoServices.xml index 80b79e8ded..623a41d47f 100644 --- a/applications/product/script/org/ofbiz/product/promo/PromoServices.xml +++ b/applications/product/script/org/ofbiz/product/promo/PromoServices.xml @@ -160,6 +160,9 @@ under the License. + + +