You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/10/04 18:23:51 UTC
svn commit: r581961 - in /ofbiz/trunk/applications:
order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
product/entitydef/entitymodel.xml
product/script/org/ofbiz/product/promo/PromoServices.xml
Author: jacopoc
Date: Thu Oct 4 09:23:50 2007
New Revision: 581961
URL: http://svn.apache.org/viewvc?rev=581961&view=rev
Log:
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.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
ofbiz/trunk/applications/product/entitydef/entitymodel.xml
ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=581961&r1=581960&r2=581961&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Thu Oct 4 09:23:50 2007
@@ -512,6 +512,17 @@
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 @@
}
// 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));
Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=581961&r1=581960&r2=581961&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Thu Oct 4 09:23:50 2007
@@ -2794,6 +2794,8 @@
<field name="requireEmailOrParty" type="indicator"></field>
<field name="useLimitPerCode" type="numeric"></field>
<field name="useLimitPerCustomer" type="numeric"></field>
+ <field name="fromDate" type="date-time"></field>
+ <field name="thruDate" type="date-time"></field>
<field name="createdDate" type="date-time"></field>
<field name="createdByUserLogin" type="id-vlong"></field>
<field name="lastModifiedDate" type="date-time"></field>
Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=581961&r1=581960&r2=581961&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml Thu Oct 4 09:23:50 2007
@@ -160,6 +160,9 @@
<field-to-result field-name="productPromoCodeId" map-name="newEntity"/>
<now-timestamp-to-env env-name="nowTimestamp"/>
+ <if-empty field-name="newEntity.fromDate">
+ <set field="newEntity.fromDate" from-field="nowTimestamp"/>
+ </if-empty>
<set from-field="nowTimestamp" field="newEntity.createdDate"/>
<set from-field="nowTimestamp" field="newEntity.lastModifiedDate"/>
<set from-field="userLogin.userLoginId" field="newEntity.lastModifiedByUserLogin"/>