Commit 2f2126fd by Nilu

coupons, payment plans

parent b4215bac
...@@ -29,10 +29,12 @@ ...@@ -29,10 +29,12 @@
<column name="is_ppj" type="Boolean" nullable="true"/> <column name="is_ppj" type="Boolean" nullable="true"/>
<column name="has_cap" type="Boolean" nullable="true"/> <column name="has_cap" type="Boolean" nullable="true"/>
<column name="max_cap" type="Long" nullable="true"/> <column name="max_cap" type="Long" nullable="true"/>
<column name="coupon_expiry_date" type="Date" nullable="true"/>
<column name="company_id" type="Long" length="11" nullable="false"/> <column name="company_id" type="Long" length="11" nullable="false"/>
<column name="billing_team_id" type="Long" length="11" nullable="true"/> <column name="billing_team_id" type="Long" length="11" nullable="true"/>
<column name="added_by_user_id" type="Long" length="11" nullable="false"/> <column name="added_by_user_id" type="Long" length="11" nullable="false"/>
<column name="payment_plan_id" type="Long" length="11" nullable="true"/> <column name="payment_plan_id" type="Long" length="11" nullable="true"/>
<column name="coupon_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_hiring_team" indexName="idx_tl_hiring_team_company_id" isUnique="false"><column name="company_id"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_hiring_team" indexName="idx_tl_hiring_team_company_id" isUnique="false"><column name="company_id"/></NODE>
......
...@@ -9,8 +9,12 @@ ...@@ -9,8 +9,12 @@
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="coupon_code" type="String" nullable="false" length="100"/> <column name="coupon_code" type="String" nullable="false" length="100"/>
<column name="percentage_off" type="Long" nullable="true"/> <column name="percentage_off" type="Double" nullable="true"/>
<column name="duration_in_months" type="Long" nullable="true"/> <column name="duration_in_months" type="Long" nullable="true"/>
<column name="coupon_duration" type="String" nullable="true" length="200"/>
<column name="redeem_by" type="Date" nullable="true"/>
<column name="max_redemptions" type="Long" nullable="true"/>
<column name="times_redeemed" type="Long" nullable="true"/>
</NODE> </NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -29,10 +29,12 @@ CREATE TABLE tl_hiring_team ( ...@@ -29,10 +29,12 @@ CREATE TABLE tl_hiring_team (
is_ppj char(1) NULL, is_ppj char(1) NULL,
has_cap char(1) NULL, has_cap char(1) NULL,
max_cap numeric(12) NULL, max_cap numeric(12) NULL,
coupon_expiry_date datetime NULL,
company_id numeric(12) NOT NULL, company_id numeric(12) NOT NULL,
billing_team_id numeric(12) NULL, billing_team_id numeric(12) NULL,
added_by_user_id numeric(12) NOT NULL, added_by_user_id numeric(12) NOT NULL,
payment_plan_id numeric(12) NULL payment_plan_id numeric(12) NULL,
coupon_id numeric(12) NULL
); );
......
...@@ -9,8 +9,12 @@ CREATE TABLE tl_coupon ( ...@@ -9,8 +9,12 @@ CREATE TABLE tl_coupon (
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
coupon_code varchar(100) NOT NULL, coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL, percentage_off numeric(20,5) NULL,
duration_in_months numeric(12) NULL duration_in_months numeric(12) NULL,
coupon_duration varchar(200) NULL,
redeem_by datetime NULL,
max_redemptions numeric(12) NULL,
times_redeemed numeric(12) NULL
); );
......
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
coupon_code varchar2(100) NOT NULL,
percentage_off number(12) NULL,
duration_in_months number(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -30,10 +30,12 @@ CREATE TABLE tl_hiring_team ( ...@@ -30,10 +30,12 @@ CREATE TABLE tl_hiring_team (
is_ppj char(1) NULL, is_ppj char(1) NULL,
has_cap char(1) NULL, has_cap char(1) NULL,
max_cap number(12) NULL, max_cap number(12) NULL,
coupon_expiry_date date NULL,
company_id number(12) NOT NULL, company_id number(12) NOT NULL,
billing_team_id number(12) NULL, billing_team_id number(12) NULL,
added_by_user_id number(12) NOT NULL, added_by_user_id number(12) NOT NULL,
payment_plan_id number(12) NULL payment_plan_id number(12) NULL,
coupon_id number(12) NULL
); );
......
...@@ -10,8 +10,12 @@ CREATE TABLE tl_coupon ( ...@@ -10,8 +10,12 @@ CREATE TABLE tl_coupon (
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
coupon_code varchar2(100) NOT NULL, coupon_code varchar2(100) NOT NULL,
percentage_off number(12) NULL, percentage_off number(20,5) NULL,
duration_in_months number(12) NULL duration_in_months number(12) NULL,
coupon_duration varchar2(200) NULL,
redeem_by date NULL,
max_redemptions number(12) NULL,
times_redeemed number(12) NULL
); );
......
-- @AutoRun
-- drop table tl_coupon;
CREATE TABLE tl_coupon (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT pk_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -30,10 +30,12 @@ CREATE TABLE tl_hiring_team ( ...@@ -30,10 +30,12 @@ CREATE TABLE tl_hiring_team (
is_ppj char(1) NULL, is_ppj char(1) NULL,
has_cap char(1) NULL, has_cap char(1) NULL,
max_cap numeric(12) NULL, max_cap numeric(12) NULL,
coupon_expiry_date timestamp NULL,
company_id numeric(12) NOT NULL, company_id numeric(12) NOT NULL,
billing_team_id numeric(12) NULL, billing_team_id numeric(12) NULL,
added_by_user_id numeric(12) NOT NULL, added_by_user_id numeric(12) NOT NULL,
payment_plan_id numeric(12) NULL payment_plan_id numeric(12) NULL,
coupon_id numeric(12) NULL
); );
......
...@@ -10,8 +10,12 @@ CREATE TABLE tl_coupon ( ...@@ -10,8 +10,12 @@ CREATE TABLE tl_coupon (
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
coupon_code varchar(100) NOT NULL, coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL, percentage_off numeric(20,5) NULL,
duration_in_months numeric(12) NULL duration_in_months numeric(12) NULL,
coupon_duration varchar(200) NULL,
redeem_by timestamp NULL,
max_redemptions numeric(12) NULL,
times_redeemed numeric(12) NULL
); );
......
package performa.form; package performa.form;
import com.stripe.model.Coupon; import com.stripe.model.Coupon;
import java.util.Calendar;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
import oneit.logging.LogMgr; import oneit.logging.LogMgr;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException; import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.servlets.forms.RedisplayResult; import oneit.servlets.forms.RedisplayResult;
import oneit.servlets.forms.SubmissionDetails; import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult; import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessFormProcessor;
import oneit.servlets.process.ORMProcessState; import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.ProcessRedirectResult;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException; import oneit.utils.BusinessException;
import oneit.utils.DateDiff;
import performa.orm.HiringTeam; import performa.orm.HiringTeam;
import performa.orm.PaymentPlan;
import performa.orm.StripeCoupon; import performa.orm.StripeCoupon;
import performa.orm.types.CouponDuration;
import performa.utils.StripeUtils; import performa.utils.StripeUtils;
public class ApplyCouponFP extends ORMProcessFormProcessor public class ApplyCouponFP extends SaveFP
{ {
@Override @Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{ {
HttpServletRequest request = submission.getRequest(); HttpServletRequest request = submission.getRequest();
HiringTeam hiringTeam = (HiringTeam) request.getAttribute("HiringTeam"); ObjectTransaction objTran = process.getTransaction();
HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam");
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1, "Inside ApplyCouponFP for ", hiringTeam ); LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1, "Inside ApplyCouponFP for ", hiringTeam );
Coupon coupon = StripeUtils.retrieveCoupon(hiringTeam.getCouponCode()); if(hiringTeam.getCoupon() != null && hiringTeam.getCoupon().getCouponCode().equals(hiringTeam.getCouponCode()))
{
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1, "Inside ApplyCouponFP for ", hiringTeam , " already has a coupon added with coupon code: ", hiringTeam.getCouponCode());
return RedisplayResult.getInstance();
}
Coupon coupon = StripeUtils.retrieveCoupon(hiringTeam.getCouponCode());
StripeCoupon[] stripeCoupons = StripeCoupon.SearchByAll()
.andCouponCode(new EqualsFilter<>(hiringTeam.getCouponCode()))
.search(objTran);
if(coupon.getValid()) if(coupon != null && coupon.getValid())
{ {
StripeCoupon stripeCoupon = StripeCoupon.createStripeCoupon(process.getTransaction()); StripeCoupon stripeCoupon = null;
stripeCoupon.setCouponCode(coupon.getId()); if(stripeCoupons != null && stripeCoupons.length > 0)
// stripeCoupon.setDurationInMonths(coupon.getDurationInMonths()); {
// stripeCoupon.setPercentageOff(coupon.getPercentOff()); stripeCoupon = stripeCoupons[0];
LogMgr.log (HiringTeam.LOG, LogLevel.PROCESSING1, "Using an already created coupon : " , stripeCoupon);
}
else
{
stripeCoupon = StripeCoupon.createStripeCoupon(objTran);
stripeCoupon.setCouponCode(coupon.getId());
stripeCoupon.setDurationInMonths(coupon.getDurationInMonths() != null ? coupon.getDurationInMonths().intValue() : 0);
stripeCoupon.setPercentageOff(coupon.getPercentOff() != null ? coupon.getPercentOff().doubleValue() : 0d);
stripeCoupon.setCouponDuration(CouponDuration.forName(coupon.getDuration().toUpperCase()));
stripeCoupon.setMaxRedemptions(coupon.getMaxRedemptions() != null ? coupon.getMaxRedemptions().intValue() : 0);
stripeCoupon.setTimesRedeemed(coupon.getTimesRedeemed() != null ? coupon.getTimesRedeemed().intValue() : 0);
if(coupon.getRedeemBy() != null)
{
stripeCoupon.setRedeemBy(new Date(coupon.getRedeemBy() * 1000));
}
LogMgr.log (HiringTeam.LOG, LogLevel.PROCESSING1, "Creating a new coupon for coupon code: ", hiringTeam.getCouponCode());
}
if(stripeCoupon.getCouponDuration() == CouponDuration.REPEATING)
{
hiringTeam.setCouponExpiryDate(DateDiff.add(new Date(), Calendar.MONTH, stripeCoupon.getDurationInMonths()));
}
hiringTeam.setCoupon(stripeCoupon);
}
else
{
return new ProcessRedirectResult((String) request.getAttribute("nextPage"), new String[]{ "invalidcoupon", "true"});
} }
System.out.println("coupon : " + coupon);
return RedisplayResult.getInstance(); return super.processForm(process, submission, params);
} }
} }
\ No newline at end of file
package performa.form; package performa.form;
import com.stripe.model.Subscription;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
...@@ -24,13 +25,10 @@ public class SaveCompanyFP extends SaveFP ...@@ -24,13 +25,10 @@ public class SaveCompanyFP extends SaveFP
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{ {
HttpServletRequest request = submission.getRequest(); HttpServletRequest request = submission.getRequest();
// Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company");
HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam"); HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment"); Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
PaymentPlan paymentPlan = (PaymentPlan) request.getAttribute("PaymentPlan"); PaymentPlan paymentPlan = (PaymentPlan) request.getAttribute("PaymentPlan");
// LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP saving company : ", company );
if(CollectionUtils.equals(hiringTeam.getIsLogoDeleted(), Boolean.TRUE)) if(CollectionUtils.equals(hiringTeam.getIsLogoDeleted(), Boolean.TRUE))
{ {
hiringTeam.setHiringTeamLogo(null); hiringTeam.setHiringTeamLogo(null);
...@@ -45,12 +43,13 @@ public class SaveCompanyFP extends SaveFP ...@@ -45,12 +43,13 @@ public class SaveCompanyFP extends SaveFP
if(hiringTeam.getStripeReference() == null) if(hiringTeam.getStripeReference() == null)
{ {
StripeUtils.createCustomer(hiringTeam); StripeUtils.createCustomer(hiringTeam);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP creating a customer in Stripe : ", hiringTeam );
} }
} }
if(CollectionUtils.equals(isPayment, Boolean.TRUE)) if(CollectionUtils.equals(isPayment, Boolean.TRUE))
{ {
hiringTeam.setPaymentPlan(paymentPlan);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Hiring Team payment plan updated.", hiringTeam, " payment plan: ", hiringTeam.getPaymentPlan()); LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Hiring Team payment plan updated.", hiringTeam, " payment plan: ", hiringTeam.getPaymentPlan());
...@@ -60,9 +59,16 @@ public class SaveCompanyFP extends SaveFP ...@@ -60,9 +59,16 @@ public class SaveCompanyFP extends SaveFP
} }
// cannot subscribe a user to a plan without card details // cannot subscribe a user to a plan without card details
StripeUtils.updatePlan(hiringTeam); Subscription updatedSubscription = StripeUtils.updatePlan(hiringTeam);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Strpe subscription updated.", hiringTeam, hiringTeam.getStripeSubscription()); if(updatedSubscription == null)
{
throw new BusinessException("Problem with changing your plan. Please contact admin.");
}
hiringTeam.setPaymentPlan(paymentPlan);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Stripe subscription updated.", hiringTeam, hiringTeam.getStripeSubscription());
} }
// //
// // Update company in intercom // // Update company in intercom
...@@ -76,8 +82,6 @@ public class SaveCompanyFP extends SaveFP ...@@ -76,8 +82,6 @@ public class SaveCompanyFP extends SaveFP
public void validate(ORMProcessState process, SubmissionDetails submission, MultiException exceptions, Map params) throws StorageException public void validate(ORMProcessState process, SubmissionDetails submission, MultiException exceptions, Map params) throws StorageException
{ {
HttpServletRequest request = submission.getRequest(); HttpServletRequest request = submission.getRequest();
// Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam"); HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam");
if(hiringTeam != null && !hiringTeam.getManageOwnBilling()) if(hiringTeam != null && !hiringTeam.getManageOwnBilling())
......
...@@ -65,6 +65,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -65,6 +65,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
public static final String FIELD_IsPPJ = "IsPPJ"; public static final String FIELD_IsPPJ = "IsPPJ";
public static final String FIELD_HasCap = "HasCap"; public static final String FIELD_HasCap = "HasCap";
public static final String FIELD_MaxCap = "MaxCap"; public static final String FIELD_MaxCap = "MaxCap";
public static final String FIELD_CouponExpiryDate = "CouponExpiryDate";
public static final String FIELD_IsLogoDeleted = "IsLogoDeleted"; public static final String FIELD_IsLogoDeleted = "IsLogoDeleted";
public static final String FIELD_CouponCode = "CouponCode"; public static final String FIELD_CouponCode = "CouponCode";
public static final String FIELD_StripeBrand = "StripeBrand"; public static final String FIELD_StripeBrand = "StripeBrand";
...@@ -74,6 +75,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -74,6 +75,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
public static final String SINGLEREFERENCE_BillingTeam = "BillingTeam"; public static final String SINGLEREFERENCE_BillingTeam = "BillingTeam";
public static final String SINGLEREFERENCE_AddedByUser = "AddedByUser"; public static final String SINGLEREFERENCE_AddedByUser = "AddedByUser";
public static final String SINGLEREFERENCE_PaymentPlan = "PaymentPlan"; public static final String SINGLEREFERENCE_PaymentPlan = "PaymentPlan";
public static final String SINGLEREFERENCE_Coupon = "Coupon";
public static final String MULTIPLEREFERENCE_Users = "Users"; public static final String MULTIPLEREFERENCE_Users = "Users";
public static final String BACKREF_Users = ""; public static final String BACKREF_Users = "";
public static final String MULTIPLEREFERENCE_Clients = "Clients"; public static final String MULTIPLEREFERENCE_Clients = "Clients";
...@@ -105,6 +107,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -105,6 +107,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
private static final DefaultAttributeHelper<HiringTeam> HELPER_IsPPJ = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_IsPPJ = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_HasCap = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_HasCap = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_MaxCap = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_MaxCap = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_CouponExpiryDate = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_IsLogoDeleted = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_IsLogoDeleted = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_CouponCode = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_CouponCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<HiringTeam> HELPER_StripeBrand = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<HiringTeam> HELPER_StripeBrand = DefaultAttributeHelper.INSTANCE;
...@@ -133,6 +136,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -133,6 +136,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
private Boolean _IsPPJ; private Boolean _IsPPJ;
private Boolean _HasCap; private Boolean _HasCap;
private Integer _MaxCap; private Integer _MaxCap;
private Date _CouponExpiryDate;
private Boolean _IsLogoDeleted; private Boolean _IsLogoDeleted;
private String _CouponCode; private String _CouponCode;
private String _StripeBrand; private String _StripeBrand;
...@@ -144,6 +148,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -144,6 +148,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
private SingleAssociation<HiringTeam, HiringTeam> _BillingTeam; private SingleAssociation<HiringTeam, HiringTeam> _BillingTeam;
private SingleAssociation<HiringTeam, CompanyUser> _AddedByUser; private SingleAssociation<HiringTeam, CompanyUser> _AddedByUser;
private SingleAssociation<HiringTeam, PaymentPlan> _PaymentPlan; private SingleAssociation<HiringTeam, PaymentPlan> _PaymentPlan;
private SingleAssociation<HiringTeam, StripeCoupon> _Coupon;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -180,6 +185,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -180,6 +185,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
private static final AttributeValidator[] FIELD_IsPPJ_Validators; private static final AttributeValidator[] FIELD_IsPPJ_Validators;
private static final AttributeValidator[] FIELD_HasCap_Validators; private static final AttributeValidator[] FIELD_HasCap_Validators;
private static final AttributeValidator[] FIELD_MaxCap_Validators; private static final AttributeValidator[] FIELD_MaxCap_Validators;
private static final AttributeValidator[] FIELD_CouponExpiryDate_Validators;
// Arrays of behaviour decorators // Arrays of behaviour decorators
...@@ -202,6 +208,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -202,6 +208,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
setupAssocMetaData_BillingTeam(); setupAssocMetaData_BillingTeam();
setupAssocMetaData_AddedByUser(); setupAssocMetaData_AddedByUser();
setupAssocMetaData_PaymentPlan(); setupAssocMetaData_PaymentPlan();
setupAssocMetaData_Coupon();
FIELD_IsLogoDeleted_Validators = (AttributeValidator[])setupAttribMetaData_IsLogoDeleted(validatorMapping).toArray (new AttributeValidator[0]); FIELD_IsLogoDeleted_Validators = (AttributeValidator[])setupAttribMetaData_IsLogoDeleted(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CouponCode_Validators = (AttributeValidator[])setupAttribMetaData_CouponCode(validatorMapping).toArray (new AttributeValidator[0]); FIELD_CouponCode_Validators = (AttributeValidator[])setupAttribMetaData_CouponCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_StripeBrand_Validators = (AttributeValidator[])setupAttribMetaData_StripeBrand(validatorMapping).toArray (new AttributeValidator[0]); FIELD_StripeBrand_Validators = (AttributeValidator[])setupAttribMetaData_StripeBrand(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -227,6 +234,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -227,6 +234,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
FIELD_IsPPJ_Validators = (AttributeValidator[])setupAttribMetaData_IsPPJ(validatorMapping).toArray (new AttributeValidator[0]); FIELD_IsPPJ_Validators = (AttributeValidator[])setupAttribMetaData_IsPPJ(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_HasCap_Validators = (AttributeValidator[])setupAttribMetaData_HasCap(validatorMapping).toArray (new AttributeValidator[0]); FIELD_HasCap_Validators = (AttributeValidator[])setupAttribMetaData_HasCap(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MaxCap_Validators = (AttributeValidator[])setupAttribMetaData_MaxCap(validatorMapping).toArray (new AttributeValidator[0]); FIELD_MaxCap_Validators = (AttributeValidator[])setupAttribMetaData_MaxCap(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CouponExpiryDate_Validators = (AttributeValidator[])setupAttribMetaData_CouponExpiryDate(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_HiringTeam.initialiseReference (); REFERENCE_HiringTeam.initialiseReference ();
...@@ -331,6 +339,21 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -331,6 +339,21 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Coupon()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "coupon_id");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Coupon");
metaInfo.put ("type", "StripeCoupon");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for HiringTeam.Coupon:", metaInfo);
ATTRIBUTES_METADATA_HiringTeam.put (SINGLEREFERENCE_Coupon, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_IsLogoDeleted(Map validatorMapping) private static List setupAttribMetaData_IsLogoDeleted(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -812,6 +835,24 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -812,6 +835,24 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
return validators; return validators;
} }
// Meta Info setup
private static List setupAttribMetaData_CouponExpiryDate(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "coupon_expiry_date");
metaInfo.put ("name", "CouponExpiryDate");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for HiringTeam.CouponExpiryDate:", metaInfo);
ATTRIBUTES_METADATA_HiringTeam.put (FIELD_CouponExpiryDate, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(HiringTeam.class, "CouponExpiryDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for HiringTeam.CouponExpiryDate:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION // END OF STATIC METADATA DEFINITION
...@@ -860,6 +901,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -860,6 +901,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_IsPPJ = (Boolean)(Boolean.TRUE); _IsPPJ = (Boolean)(Boolean.TRUE);
_HasCap = (Boolean)(Boolean.FALSE); _HasCap = (Boolean)(Boolean.FALSE);
_MaxCap = (Integer)(HELPER_MaxCap.initialise (_MaxCap)); _MaxCap = (Integer)(HELPER_MaxCap.initialise (_MaxCap));
_CouponExpiryDate = (Date)(HELPER_CouponExpiryDate.initialise (_CouponExpiryDate));
_IsLogoDeleted = (Boolean)(Boolean.FALSE); _IsLogoDeleted = (Boolean)(Boolean.FALSE);
_CouponCode = (String)(HELPER_CouponCode.initialise (_CouponCode)); _CouponCode = (String)(HELPER_CouponCode.initialise (_CouponCode));
_StripeBrand = (String)(HELPER_StripeBrand.initialise (_StripeBrand)); _StripeBrand = (String)(HELPER_StripeBrand.initialise (_StripeBrand));
...@@ -876,6 +918,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -876,6 +918,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_BillingTeam = new SingleAssociation<HiringTeam, HiringTeam> (this, SINGLEREFERENCE_BillingTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_hiring_team"); _BillingTeam = new SingleAssociation<HiringTeam, HiringTeam> (this, SINGLEREFERENCE_BillingTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_hiring_team");
_AddedByUser = new SingleAssociation<HiringTeam, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_hiring_team"); _AddedByUser = new SingleAssociation<HiringTeam, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_hiring_team");
_PaymentPlan = new SingleAssociation<HiringTeam, PaymentPlan> (this, SINGLEREFERENCE_PaymentPlan, null, PaymentPlan.REFERENCE_PaymentPlan, "tl_hiring_team"); _PaymentPlan = new SingleAssociation<HiringTeam, PaymentPlan> (this, SINGLEREFERENCE_PaymentPlan, null, PaymentPlan.REFERENCE_PaymentPlan, "tl_hiring_team");
_Coupon = new SingleAssociation<HiringTeam, StripeCoupon> (this, SINGLEREFERENCE_Coupon, null, StripeCoupon.REFERENCE_StripeCoupon, "tl_hiring_team");
_Users = new MultipleAssociation<HiringTeam, CompanyUserHiringTeamLink> (this, MULTIPLEREFERENCE_Users, CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, CompanyUserHiringTeamLink.REFERENCE_CompanyUserHiringTeamLink); _Users = new MultipleAssociation<HiringTeam, CompanyUserHiringTeamLink> (this, MULTIPLEREFERENCE_Users, CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, CompanyUserHiringTeamLink.REFERENCE_CompanyUserHiringTeamLink);
_Clients = new MultipleAssociation<HiringTeam, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_HiringTeam, Client.REFERENCE_Client); _Clients = new MultipleAssociation<HiringTeam, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_HiringTeam, Client.REFERENCE_Client);
...@@ -891,6 +934,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -891,6 +934,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_BillingTeam = new SingleAssociation<HiringTeam, HiringTeam> (this, SINGLEREFERENCE_BillingTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_hiring_team"); _BillingTeam = new SingleAssociation<HiringTeam, HiringTeam> (this, SINGLEREFERENCE_BillingTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_hiring_team");
_AddedByUser = new SingleAssociation<HiringTeam, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_hiring_team"); _AddedByUser = new SingleAssociation<HiringTeam, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_hiring_team");
_PaymentPlan = new SingleAssociation<HiringTeam, PaymentPlan> (this, SINGLEREFERENCE_PaymentPlan, null, PaymentPlan.REFERENCE_PaymentPlan, "tl_hiring_team"); _PaymentPlan = new SingleAssociation<HiringTeam, PaymentPlan> (this, SINGLEREFERENCE_PaymentPlan, null, PaymentPlan.REFERENCE_PaymentPlan, "tl_hiring_team");
_Coupon = new SingleAssociation<HiringTeam, StripeCoupon> (this, SINGLEREFERENCE_Coupon, null, StripeCoupon.REFERENCE_StripeCoupon, "tl_hiring_team");
_Users = new MultipleAssociation<HiringTeam, CompanyUserHiringTeamLink> (this, MULTIPLEREFERENCE_Users, CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, CompanyUserHiringTeamLink.REFERENCE_CompanyUserHiringTeamLink); _Users = new MultipleAssociation<HiringTeam, CompanyUserHiringTeamLink> (this, MULTIPLEREFERENCE_Users, CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, CompanyUserHiringTeamLink.REFERENCE_CompanyUserHiringTeamLink);
_Clients = new MultipleAssociation<HiringTeam, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_HiringTeam, Client.REFERENCE_Client); _Clients = new MultipleAssociation<HiringTeam, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_HiringTeam, Client.REFERENCE_Client);
...@@ -2960,6 +3004,104 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -2960,6 +3004,104 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
} }
/** /**
* Get the attribute CouponExpiryDate
*/
public Date getCouponExpiryDate ()
{
assertValid();
Date valToReturn = _CouponExpiryDate;
for (HiringTeamBehaviourDecorator bhd : HiringTeam_BehaviourDecorators)
{
valToReturn = bhd.getCouponExpiryDate ((HiringTeam)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCouponExpiryDateChange (Date newCouponExpiryDate) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCouponExpiryDateChange () throws FieldException
{
}
public FieldWriteability getWriteability_CouponExpiryDate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CouponExpiryDate. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCouponExpiryDate (Date newCouponExpiryDate) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CouponExpiryDate.compare (_CouponExpiryDate, newCouponExpiryDate);
try
{
for (HiringTeamBehaviourDecorator bhd : HiringTeam_BehaviourDecorators)
{
newCouponExpiryDate = bhd.setCouponExpiryDate ((HiringTeam)this, newCouponExpiryDate);
oldAndNewIdentical = HELPER_CouponExpiryDate.compare (_CouponExpiryDate, newCouponExpiryDate);
}
if (FIELD_CouponExpiryDate_Validators.length > 0)
{
Object newCouponExpiryDateObj = HELPER_CouponExpiryDate.toObject (newCouponExpiryDate);
if (newCouponExpiryDateObj != null)
{
int loopMax = FIELD_CouponExpiryDate_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_HiringTeam.get (FIELD_CouponExpiryDate);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CouponExpiryDate_Validators[v].checkAttribute (this, FIELD_CouponExpiryDate, metadata, newCouponExpiryDateObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CouponExpiryDate () != FieldWriteability.FALSE, "Field CouponExpiryDate is not writeable");
preCouponExpiryDateChange (newCouponExpiryDate);
markFieldChange (FIELD_CouponExpiryDate);
_CouponExpiryDate = newCouponExpiryDate;
postFieldChange (FIELD_CouponExpiryDate);
postCouponExpiryDateChange ();
}
}
/**
* Get the attribute IsLogoDeleted * Get the attribute IsLogoDeleted
*/ */
public Boolean getIsLogoDeleted () public Boolean getIsLogoDeleted ()
...@@ -3369,6 +3511,8 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3369,6 +3511,8 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
result.add("PaymentPlan"); result.add("PaymentPlan");
result.add("Coupon");
return result; return result;
} }
...@@ -3392,6 +3536,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3392,6 +3536,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
return _PaymentPlan.getReferencedType (); return _PaymentPlan.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
return _Coupon.getReferencedType ();
} }
else else
{ {
...@@ -3418,6 +3565,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3418,6 +3565,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
return null ; return null ;
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
return null ;
} }
else else
{ {
...@@ -3444,6 +3594,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3444,6 +3594,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
return getPaymentPlan (); return getPaymentPlan ();
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
return getCoupon ();
} }
else else
{ {
...@@ -3470,6 +3623,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3470,6 +3623,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
return getPaymentPlan (getType); return getPaymentPlan (getType);
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
return getCoupon (getType);
} }
else else
{ {
...@@ -3496,6 +3652,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3496,6 +3652,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
return getPaymentPlanID (); return getPaymentPlanID ();
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
return getCouponID ();
} }
else else
{ {
...@@ -3522,6 +3681,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3522,6 +3681,9 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_PaymentPlan)) }else if (assocName.equals (SINGLEREFERENCE_PaymentPlan))
{ {
setPaymentPlan ((PaymentPlan)(newValue)); setPaymentPlan ((PaymentPlan)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Coupon))
{
setCoupon ((StripeCoupon)(newValue));
} }
else else
{ {
...@@ -3923,6 +4085,100 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -3923,6 +4085,100 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
} }
/** /**
* Get the reference Coupon
*/
public StripeCoupon getCoupon () throws StorageException
{
assertValid();
try
{
return (StripeCoupon)(_Coupon.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in HiringTeam:", this.getObjectID (), ", was trying to get StripeCoupon:", getCouponID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Coupon.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public StripeCoupon getCoupon (Get getType) throws StorageException
{
assertValid();
return _Coupon.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCouponID ()
{
assertValid();
if (_Coupon == null)
{
return null;
}
else
{
return _Coupon.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCouponChange (StripeCoupon newCoupon) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCouponChange () throws FieldException
{
}
public FieldWriteability getWriteability_Coupon ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Coupon. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCoupon (StripeCoupon newCoupon) throws StorageException, FieldException
{
if (_Coupon.wouldReferencedChange (newCoupon))
{
assertValid();
Debug.assertion (getWriteability_Coupon () != FieldWriteability.FALSE, "Assoc Coupon is not writeable");
preCouponChange (newCoupon);
_Coupon.set (newCoupon);
postCouponChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings. * A list of multi assoc names e.g. list of strings.
*/ */
public List<String> getMultiAssocs() public List<String> getMultiAssocs()
...@@ -4359,10 +4615,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4359,10 +4615,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
tl_hiring_teamPSet.setAttrib (FIELD_IsPPJ, HELPER_IsPPJ.toObject (_IsPPJ)); // tl_hiring_teamPSet.setAttrib (FIELD_IsPPJ, HELPER_IsPPJ.toObject (_IsPPJ)); //
tl_hiring_teamPSet.setAttrib (FIELD_HasCap, HELPER_HasCap.toObject (_HasCap)); // tl_hiring_teamPSet.setAttrib (FIELD_HasCap, HELPER_HasCap.toObject (_HasCap)); //
tl_hiring_teamPSet.setAttrib (FIELD_MaxCap, HELPER_MaxCap.toObject (_MaxCap)); // tl_hiring_teamPSet.setAttrib (FIELD_MaxCap, HELPER_MaxCap.toObject (_MaxCap)); //
tl_hiring_teamPSet.setAttrib (FIELD_CouponExpiryDate, HELPER_CouponExpiryDate.toObject (_CouponExpiryDate)); //
_Company.getPersistentSets (allSets); _Company.getPersistentSets (allSets);
_BillingTeam.getPersistentSets (allSets); _BillingTeam.getPersistentSets (allSets);
_AddedByUser.getPersistentSets (allSets); _AddedByUser.getPersistentSets (allSets);
_PaymentPlan.getPersistentSets (allSets); _PaymentPlan.getPersistentSets (allSets);
_Coupon.getPersistentSets (allSets);
} }
...@@ -4398,10 +4656,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4398,10 +4656,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_IsPPJ = (Boolean)(HELPER_IsPPJ.fromObject (_IsPPJ, tl_hiring_teamPSet.getAttrib (FIELD_IsPPJ))); // _IsPPJ = (Boolean)(HELPER_IsPPJ.fromObject (_IsPPJ, tl_hiring_teamPSet.getAttrib (FIELD_IsPPJ))); //
_HasCap = (Boolean)(HELPER_HasCap.fromObject (_HasCap, tl_hiring_teamPSet.getAttrib (FIELD_HasCap))); // _HasCap = (Boolean)(HELPER_HasCap.fromObject (_HasCap, tl_hiring_teamPSet.getAttrib (FIELD_HasCap))); //
_MaxCap = (Integer)(HELPER_MaxCap.fromObject (_MaxCap, tl_hiring_teamPSet.getAttrib (FIELD_MaxCap))); // _MaxCap = (Integer)(HELPER_MaxCap.fromObject (_MaxCap, tl_hiring_teamPSet.getAttrib (FIELD_MaxCap))); //
_CouponExpiryDate = (Date)(HELPER_CouponExpiryDate.fromObject (_CouponExpiryDate, tl_hiring_teamPSet.getAttrib (FIELD_CouponExpiryDate))); //
_Company.setFromPersistentSets (objectID, allSets); _Company.setFromPersistentSets (objectID, allSets);
_BillingTeam.setFromPersistentSets (objectID, allSets); _BillingTeam.setFromPersistentSets (objectID, allSets);
_AddedByUser.setFromPersistentSets (objectID, allSets); _AddedByUser.setFromPersistentSets (objectID, allSets);
_PaymentPlan.setFromPersistentSets (objectID, allSets); _PaymentPlan.setFromPersistentSets (objectID, allSets);
_Coupon.setFromPersistentSets (objectID, allSets);
} }
...@@ -4606,6 +4866,15 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4606,6 +4866,15 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
e.addException (ex); e.addException (ex);
} }
try
{
setCouponExpiryDate (otherHiringTeam.getCouponExpiryDate ());
}
catch (FieldException ex)
{
e.addException (ex);
}
} }
} }
...@@ -4642,6 +4911,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4642,6 +4911,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_IsPPJ = sourceHiringTeam._IsPPJ; _IsPPJ = sourceHiringTeam._IsPPJ;
_HasCap = sourceHiringTeam._HasCap; _HasCap = sourceHiringTeam._HasCap;
_MaxCap = sourceHiringTeam._MaxCap; _MaxCap = sourceHiringTeam._MaxCap;
_CouponExpiryDate = sourceHiringTeam._CouponExpiryDate;
_IsLogoDeleted = sourceHiringTeam._IsLogoDeleted; _IsLogoDeleted = sourceHiringTeam._IsLogoDeleted;
_CouponCode = sourceHiringTeam._CouponCode; _CouponCode = sourceHiringTeam._CouponCode;
_StripeBrand = sourceHiringTeam._StripeBrand; _StripeBrand = sourceHiringTeam._StripeBrand;
...@@ -4666,6 +4936,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4666,6 +4936,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_BillingTeam.copyFrom (sourceHiringTeam._BillingTeam, linkToGhosts); _BillingTeam.copyFrom (sourceHiringTeam._BillingTeam, linkToGhosts);
_AddedByUser.copyFrom (sourceHiringTeam._AddedByUser, linkToGhosts); _AddedByUser.copyFrom (sourceHiringTeam._AddedByUser, linkToGhosts);
_PaymentPlan.copyFrom (sourceHiringTeam._PaymentPlan, linkToGhosts); _PaymentPlan.copyFrom (sourceHiringTeam._PaymentPlan, linkToGhosts);
_Coupon.copyFrom (sourceHiringTeam._Coupon, linkToGhosts);
} }
} }
...@@ -4729,6 +5000,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4729,6 +5000,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_IsPPJ = (Boolean)(HELPER_IsPPJ.readExternal (_IsPPJ, vals.get(FIELD_IsPPJ))); // _IsPPJ = (Boolean)(HELPER_IsPPJ.readExternal (_IsPPJ, vals.get(FIELD_IsPPJ))); //
_HasCap = (Boolean)(HELPER_HasCap.readExternal (_HasCap, vals.get(FIELD_HasCap))); // _HasCap = (Boolean)(HELPER_HasCap.readExternal (_HasCap, vals.get(FIELD_HasCap))); //
_MaxCap = (Integer)(HELPER_MaxCap.readExternal (_MaxCap, vals.get(FIELD_MaxCap))); // _MaxCap = (Integer)(HELPER_MaxCap.readExternal (_MaxCap, vals.get(FIELD_MaxCap))); //
_CouponExpiryDate = (Date)(HELPER_CouponExpiryDate.readExternal (_CouponExpiryDate, vals.get(FIELD_CouponExpiryDate))); //
_IsLogoDeleted = (Boolean)(HELPER_IsLogoDeleted.readExternal (_IsLogoDeleted, vals.get(FIELD_IsLogoDeleted))); // _IsLogoDeleted = (Boolean)(HELPER_IsLogoDeleted.readExternal (_IsLogoDeleted, vals.get(FIELD_IsLogoDeleted))); //
_CouponCode = (String)(HELPER_CouponCode.readExternal (_CouponCode, vals.get(FIELD_CouponCode))); // _CouponCode = (String)(HELPER_CouponCode.readExternal (_CouponCode, vals.get(FIELD_CouponCode))); //
_StripeBrand = (String)(HELPER_StripeBrand.readExternal (_StripeBrand, vals.get(FIELD_StripeBrand))); // _StripeBrand = (String)(HELPER_StripeBrand.readExternal (_StripeBrand, vals.get(FIELD_StripeBrand))); //
...@@ -4737,6 +5009,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4737,6 +5009,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
_BillingTeam.readExternalData(vals.get(SINGLEREFERENCE_BillingTeam)); _BillingTeam.readExternalData(vals.get(SINGLEREFERENCE_BillingTeam));
_AddedByUser.readExternalData(vals.get(SINGLEREFERENCE_AddedByUser)); _AddedByUser.readExternalData(vals.get(SINGLEREFERENCE_AddedByUser));
_PaymentPlan.readExternalData(vals.get(SINGLEREFERENCE_PaymentPlan)); _PaymentPlan.readExternalData(vals.get(SINGLEREFERENCE_PaymentPlan));
_Coupon.readExternalData(vals.get(SINGLEREFERENCE_Coupon));
_Users.readExternalData(vals.get(MULTIPLEREFERENCE_Users)); _Users.readExternalData(vals.get(MULTIPLEREFERENCE_Users));
_Clients.readExternalData(vals.get(MULTIPLEREFERENCE_Clients)); _Clients.readExternalData(vals.get(MULTIPLEREFERENCE_Clients));
...@@ -4771,6 +5044,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4771,6 +5044,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
vals.put (FIELD_IsPPJ, HELPER_IsPPJ.writeExternal (_IsPPJ)); vals.put (FIELD_IsPPJ, HELPER_IsPPJ.writeExternal (_IsPPJ));
vals.put (FIELD_HasCap, HELPER_HasCap.writeExternal (_HasCap)); vals.put (FIELD_HasCap, HELPER_HasCap.writeExternal (_HasCap));
vals.put (FIELD_MaxCap, HELPER_MaxCap.writeExternal (_MaxCap)); vals.put (FIELD_MaxCap, HELPER_MaxCap.writeExternal (_MaxCap));
vals.put (FIELD_CouponExpiryDate, HELPER_CouponExpiryDate.writeExternal (_CouponExpiryDate));
vals.put (FIELD_IsLogoDeleted, HELPER_IsLogoDeleted.writeExternal (_IsLogoDeleted)); vals.put (FIELD_IsLogoDeleted, HELPER_IsLogoDeleted.writeExternal (_IsLogoDeleted));
vals.put (FIELD_CouponCode, HELPER_CouponCode.writeExternal (_CouponCode)); vals.put (FIELD_CouponCode, HELPER_CouponCode.writeExternal (_CouponCode));
vals.put (FIELD_StripeBrand, HELPER_StripeBrand.writeExternal (_StripeBrand)); vals.put (FIELD_StripeBrand, HELPER_StripeBrand.writeExternal (_StripeBrand));
...@@ -4779,6 +5053,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4779,6 +5053,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
vals.put (SINGLEREFERENCE_BillingTeam, _BillingTeam.writeExternalData()); vals.put (SINGLEREFERENCE_BillingTeam, _BillingTeam.writeExternalData());
vals.put (SINGLEREFERENCE_AddedByUser, _AddedByUser.writeExternalData()); vals.put (SINGLEREFERENCE_AddedByUser, _AddedByUser.writeExternalData());
vals.put (SINGLEREFERENCE_PaymentPlan, _PaymentPlan.writeExternalData()); vals.put (SINGLEREFERENCE_PaymentPlan, _PaymentPlan.writeExternalData());
vals.put (SINGLEREFERENCE_Coupon, _Coupon.writeExternalData());
vals.put (MULTIPLEREFERENCE_Users, _Users.writeExternalData()); vals.put (MULTIPLEREFERENCE_Users, _Users.writeExternalData());
vals.put (MULTIPLEREFERENCE_Clients, _Clients.writeExternalData()); vals.put (MULTIPLEREFERENCE_Clients, _Clients.writeExternalData());
...@@ -4878,12 +5153,17 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4878,12 +5153,17 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
listener.notifyFieldChange(this, other, FIELD_MaxCap, HELPER_MaxCap.toObject(this._MaxCap), HELPER_MaxCap.toObject(otherHiringTeam._MaxCap)); listener.notifyFieldChange(this, other, FIELD_MaxCap, HELPER_MaxCap.toObject(this._MaxCap), HELPER_MaxCap.toObject(otherHiringTeam._MaxCap));
} }
if (!HELPER_CouponExpiryDate.compare(this._CouponExpiryDate, otherHiringTeam._CouponExpiryDate))
{
listener.notifyFieldChange(this, other, FIELD_CouponExpiryDate, HELPER_CouponExpiryDate.toObject(this._CouponExpiryDate), HELPER_CouponExpiryDate.toObject(otherHiringTeam._CouponExpiryDate));
}
// Compare single assocs // Compare single assocs
_Company.compare (otherHiringTeam._Company, listener); _Company.compare (otherHiringTeam._Company, listener);
_BillingTeam.compare (otherHiringTeam._BillingTeam, listener); _BillingTeam.compare (otherHiringTeam._BillingTeam, listener);
_AddedByUser.compare (otherHiringTeam._AddedByUser, listener); _AddedByUser.compare (otherHiringTeam._AddedByUser, listener);
_PaymentPlan.compare (otherHiringTeam._PaymentPlan, listener); _PaymentPlan.compare (otherHiringTeam._PaymentPlan, listener);
_Coupon.compare (otherHiringTeam._Coupon, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -4931,10 +5211,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4931,10 +5211,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
visitor.visitField(this, FIELD_IsPPJ, HELPER_IsPPJ.toObject(getIsPPJ())); visitor.visitField(this, FIELD_IsPPJ, HELPER_IsPPJ.toObject(getIsPPJ()));
visitor.visitField(this, FIELD_HasCap, HELPER_HasCap.toObject(getHasCap())); visitor.visitField(this, FIELD_HasCap, HELPER_HasCap.toObject(getHasCap()));
visitor.visitField(this, FIELD_MaxCap, HELPER_MaxCap.toObject(getMaxCap())); visitor.visitField(this, FIELD_MaxCap, HELPER_MaxCap.toObject(getMaxCap()));
visitor.visitField(this, FIELD_CouponExpiryDate, HELPER_CouponExpiryDate.toObject(getCouponExpiryDate()));
visitor.visitAssociation (_Company); visitor.visitAssociation (_Company);
visitor.visitAssociation (_BillingTeam); visitor.visitAssociation (_BillingTeam);
visitor.visitAssociation (_AddedByUser); visitor.visitAssociation (_AddedByUser);
visitor.visitAssociation (_PaymentPlan); visitor.visitAssociation (_PaymentPlan);
visitor.visitAssociation (_Coupon);
visitor.visitAssociation (_Users); visitor.visitAssociation (_Users);
visitor.visitAssociation (_Clients); visitor.visitAssociation (_Clients);
...@@ -4961,6 +5243,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -4961,6 +5243,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
visitor.visit (_PaymentPlan); visitor.visit (_PaymentPlan);
} }
if (scope.includes (_Coupon))
{
visitor.visit (_Coupon);
}
if (scope.includes (_Users)) if (scope.includes (_Users))
{ {
visitor.visit (_Users); visitor.visit (_Users);
...@@ -5078,6 +5364,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5078,6 +5364,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return filter.matches (getMaxCap ()); return filter.matches (getMaxCap ());
} }
else if (attribName.equals (FIELD_CouponExpiryDate))
{
return filter.matches (getCouponExpiryDate ());
}
else if (attribName.equals (SINGLEREFERENCE_Company)) else if (attribName.equals (SINGLEREFERENCE_Company))
{ {
return filter.matches (getCompany ()); return filter.matches (getCompany ());
...@@ -5094,6 +5384,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5094,6 +5384,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return filter.matches (getPaymentPlan ()); return filter.matches (getPaymentPlan ());
} }
else if (attribName.equals (SINGLEREFERENCE_Coupon))
{
return filter.matches (getCoupon ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -5251,6 +5545,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5251,6 +5545,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
return this; return this;
} }
public SearchAll andCouponExpiryDate (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_hiring_team.coupon_expiry_date", "CouponExpiryDate");
return this;
}
public SearchAll andCompany (QueryFilter<Company> filter) public SearchAll andCompany (QueryFilter<Company> filter)
{ {
filter.addFilter (context, "tl_hiring_team.company_id", "Company"); filter.addFilter (context, "tl_hiring_team.company_id", "Company");
...@@ -5275,6 +5575,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5275,6 +5575,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
return this; return this;
} }
public SearchAll andCoupon (QueryFilter<StripeCoupon> filter)
{
filter.addFilter (context, "tl_hiring_team.coupon_id", "Coupon");
return this;
}
public HiringTeam[] public HiringTeam[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -5394,6 +5700,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5394,6 +5700,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return HELPER_MaxCap.toObject (getMaxCap ()); return HELPER_MaxCap.toObject (getMaxCap ());
} }
else if (attribName.equals (FIELD_CouponExpiryDate))
{
return HELPER_CouponExpiryDate.toObject (getCouponExpiryDate ());
}
else if (attribName.equals (FIELD_IsLogoDeleted)) else if (attribName.equals (FIELD_IsLogoDeleted))
{ {
return HELPER_IsLogoDeleted.toObject (getIsLogoDeleted ()); return HELPER_IsLogoDeleted.toObject (getIsLogoDeleted ());
...@@ -5507,6 +5817,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5507,6 +5817,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return HELPER_MaxCap; return HELPER_MaxCap;
} }
else if (attribName.equals (FIELD_CouponExpiryDate))
{
return HELPER_CouponExpiryDate;
}
else if (attribName.equals (FIELD_IsLogoDeleted)) else if (attribName.equals (FIELD_IsLogoDeleted))
{ {
return HELPER_IsLogoDeleted; return HELPER_IsLogoDeleted;
...@@ -5620,6 +5934,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5620,6 +5934,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
setMaxCap ((Integer)(HELPER_MaxCap.fromObject (_MaxCap, attribValue))); setMaxCap ((Integer)(HELPER_MaxCap.fromObject (_MaxCap, attribValue)));
} }
else if (attribName.equals (FIELD_CouponExpiryDate))
{
setCouponExpiryDate ((Date)(HELPER_CouponExpiryDate.fromObject (_CouponExpiryDate, attribValue)));
}
else if (attribName.equals (FIELD_IsLogoDeleted)) else if (attribName.equals (FIELD_IsLogoDeleted))
{ {
setIsLogoDeleted ((Boolean)(HELPER_IsLogoDeleted.fromObject (_IsLogoDeleted, attribValue))); setIsLogoDeleted ((Boolean)(HELPER_IsLogoDeleted.fromObject (_IsLogoDeleted, attribValue)));
...@@ -5740,6 +6058,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5740,6 +6058,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return getWriteability_MaxCap (); return getWriteability_MaxCap ();
} }
else if (fieldName.equals (FIELD_CouponExpiryDate))
{
return getWriteability_CouponExpiryDate ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Users)) else if (fieldName.equals (MULTIPLEREFERENCE_Users))
{ {
return getWriteability_Users (); return getWriteability_Users ();
...@@ -5764,6 +6086,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5764,6 +6086,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return getWriteability_PaymentPlan (); return getWriteability_PaymentPlan ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Coupon))
{
return getWriteability_Coupon ();
}
else if (fieldName.equals (FIELD_IsLogoDeleted)) else if (fieldName.equals (FIELD_IsLogoDeleted))
{ {
return getWriteability_IsLogoDeleted (); return getWriteability_IsLogoDeleted ();
...@@ -5895,6 +6221,11 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5895,6 +6221,11 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
fields.add (FIELD_MaxCap); fields.add (FIELD_MaxCap);
} }
if (getWriteability_CouponExpiryDate () != FieldWriteability.TRUE)
{
fields.add (FIELD_CouponExpiryDate);
}
if (getWriteability_IsLogoDeleted () != FieldWriteability.TRUE) if (getWriteability_IsLogoDeleted () != FieldWriteability.TRUE)
{ {
fields.add (FIELD_IsLogoDeleted); fields.add (FIELD_IsLogoDeleted);
...@@ -5945,6 +6276,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -5945,6 +6276,7 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
result.add(HELPER_IsPPJ.getAttribObject (getClass (), _IsPPJ, false, FIELD_IsPPJ)); result.add(HELPER_IsPPJ.getAttribObject (getClass (), _IsPPJ, false, FIELD_IsPPJ));
result.add(HELPER_HasCap.getAttribObject (getClass (), _HasCap, false, FIELD_HasCap)); result.add(HELPER_HasCap.getAttribObject (getClass (), _HasCap, false, FIELD_HasCap));
result.add(HELPER_MaxCap.getAttribObject (getClass (), _MaxCap, false, FIELD_MaxCap)); result.add(HELPER_MaxCap.getAttribObject (getClass (), _MaxCap, false, FIELD_MaxCap));
result.add(HELPER_CouponExpiryDate.getAttribObject (getClass (), _CouponExpiryDate, false, FIELD_CouponExpiryDate));
result.add(HELPER_IsLogoDeleted.getAttribObject (getClass (), _IsLogoDeleted, false, FIELD_IsLogoDeleted)); result.add(HELPER_IsLogoDeleted.getAttribObject (getClass (), _IsLogoDeleted, false, FIELD_IsLogoDeleted));
result.add(HELPER_CouponCode.getAttribObject (getClass (), _CouponCode, false, FIELD_CouponCode)); result.add(HELPER_CouponCode.getAttribObject (getClass (), _CouponCode, false, FIELD_CouponCode));
result.add(HELPER_StripeBrand.getAttribObject (getClass (), _StripeBrand, false, FIELD_StripeBrand)); result.add(HELPER_StripeBrand.getAttribObject (getClass (), _StripeBrand, false, FIELD_StripeBrand));
...@@ -6396,6 +6728,24 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -6396,6 +6728,24 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
} }
/** /**
* Get the attribute CouponExpiryDate
*/
public Date getCouponExpiryDate (HiringTeam obj, Date original)
{
return original;
}
/**
* Change the value set for attribute CouponExpiryDate.
* May modify the field beforehand
* Occurs before validation.
*/
public Date setCouponExpiryDate (HiringTeam obj, Date newCouponExpiryDate) throws FieldException
{
return newCouponExpiryDate;
}
/**
* Get the attribute IsLogoDeleted * Get the attribute IsLogoDeleted
*/ */
public Boolean getIsLogoDeleted (HiringTeam obj, Boolean original) public Boolean getIsLogoDeleted (HiringTeam obj, Boolean original)
...@@ -6627,6 +6977,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -6627,6 +6977,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return toMaxCap (); return toMaxCap ();
} }
if (name.equals ("CouponExpiryDate"))
{
return toCouponExpiryDate ();
}
if (name.equals ("Company")) if (name.equals ("Company"))
{ {
return toCompany (); return toCompany ();
...@@ -6643,6 +6997,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -6643,6 +6997,10 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return toPaymentPlan (); return toPaymentPlan ();
} }
if (name.equals ("Coupon"))
{
return toCoupon ();
}
return super.to(name); return super.to(name);
...@@ -6698,6 +7056,8 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -6698,6 +7056,8 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
public PipeLine<From, Boolean> toHasCap () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_HasCap)); } public PipeLine<From, Boolean> toHasCap () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_HasCap)); }
public PipeLine<From, Integer> toMaxCap () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_MaxCap)); } public PipeLine<From, Integer> toMaxCap () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_MaxCap)); }
public PipeLine<From, Date> toCouponExpiryDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_CouponExpiryDate)); }
public Company.CompanyPipeLineFactory<From, Company> toCompany () { return toCompany (Filter.ALL); } public Company.CompanyPipeLineFactory<From, Company> toCompany () { return toCompany (Filter.ALL); }
public Company.CompanyPipeLineFactory<From, Company> toCompany (Filter<Company> filter) public Company.CompanyPipeLineFactory<From, Company> toCompany (Filter<Company> filter)
...@@ -6722,6 +7082,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass ...@@ -6722,6 +7082,12 @@ public abstract class BaseHiringTeam extends BaseBusinessClass
{ {
return PaymentPlan.REFERENCE_PaymentPlan.new PaymentPlanPipeLineFactory<From, PaymentPlan> (this, new ORMSingleAssocPipe<Me, PaymentPlan>(SINGLEREFERENCE_PaymentPlan, filter)); return PaymentPlan.REFERENCE_PaymentPlan.new PaymentPlanPipeLineFactory<From, PaymentPlan> (this, new ORMSingleAssocPipe<Me, PaymentPlan>(SINGLEREFERENCE_PaymentPlan, filter));
} }
public StripeCoupon.StripeCouponPipeLineFactory<From, StripeCoupon> toCoupon () { return toCoupon (Filter.ALL); }
public StripeCoupon.StripeCouponPipeLineFactory<From, StripeCoupon> toCoupon (Filter<StripeCoupon> filter)
{
return StripeCoupon.REFERENCE_StripeCoupon.new StripeCouponPipeLineFactory<From, StripeCoupon> (this, new ORMSingleAssocPipe<Me, StripeCoupon>(SINGLEREFERENCE_Coupon, filter));
}
public CompanyUserHiringTeamLink.CompanyUserHiringTeamLinkPipeLineFactory<From, CompanyUserHiringTeamLink> toUsers () { return toUsers(Filter.ALL); } public CompanyUserHiringTeamLink.CompanyUserHiringTeamLinkPipeLineFactory<From, CompanyUserHiringTeamLink> toUsers () { return toUsers(Filter.ALL); }
public CompanyUserHiringTeamLink.CompanyUserHiringTeamLinkPipeLineFactory<From, CompanyUserHiringTeamLink> toUsers (Filter<CompanyUserHiringTeamLink> filter) public CompanyUserHiringTeamLink.CompanyUserHiringTeamLinkPipeLineFactory<From, CompanyUserHiringTeamLink> toUsers (Filter<CompanyUserHiringTeamLink> filter)
...@@ -6841,6 +7207,20 @@ class DummyHiringTeam extends HiringTeam ...@@ -6841,6 +7207,20 @@ class DummyHiringTeam extends HiringTeam
return PaymentPlan.DUMMY_PaymentPlan.getObjectID(); return PaymentPlan.DUMMY_PaymentPlan.getObjectID();
} }
public StripeCoupon getCoupon () throws StorageException
{
return (StripeCoupon)(StripeCoupon.DUMMY_StripeCoupon);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCouponID ()
{
return StripeCoupon.DUMMY_StripeCoupon.getObjectID();
}
public int getUsersCount () throws StorageException public int getUsersCount () throws StorageException
{ {
return 0; return 0;
......
...@@ -43,6 +43,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -43,6 +43,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
public static final String FIELD_CouponCode = "CouponCode"; public static final String FIELD_CouponCode = "CouponCode";
public static final String FIELD_PercentageOff = "PercentageOff"; public static final String FIELD_PercentageOff = "PercentageOff";
public static final String FIELD_DurationInMonths = "DurationInMonths"; public static final String FIELD_DurationInMonths = "DurationInMonths";
public static final String FIELD_CouponDuration = "CouponDuration";
public static final String FIELD_RedeemBy = "RedeemBy";
public static final String FIELD_MaxRedemptions = "MaxRedemptions";
public static final String FIELD_TimesRedeemed = "TimesRedeemed";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -52,12 +56,20 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -52,12 +56,20 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
private static final DefaultAttributeHelper<StripeCoupon> HELPER_CouponCode = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<StripeCoupon> HELPER_CouponCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<StripeCoupon> HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<StripeCoupon> HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<StripeCoupon, CouponDuration> HELPER_CouponDuration = new EnumeratedAttributeHelper<StripeCoupon, CouponDuration> (CouponDuration.FACTORY_CouponDuration);
private static final DefaultAttributeHelper<StripeCoupon> HELPER_RedeemBy = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_MaxRedemptions = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_TimesRedeemed = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private String _CouponCode; private String _CouponCode;
private Integer _PercentageOff; private Double _PercentageOff;
private Integer _DurationInMonths; private Integer _DurationInMonths;
private CouponDuration _CouponDuration;
private Date _RedeemBy;
private Integer _MaxRedemptions;
private Integer _TimesRedeemed;
// Private attributes corresponding to single references // Private attributes corresponding to single references
...@@ -73,6 +85,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -73,6 +85,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
private static final AttributeValidator[] FIELD_CouponCode_Validators; private static final AttributeValidator[] FIELD_CouponCode_Validators;
private static final AttributeValidator[] FIELD_PercentageOff_Validators; private static final AttributeValidator[] FIELD_PercentageOff_Validators;
private static final AttributeValidator[] FIELD_DurationInMonths_Validators; private static final AttributeValidator[] FIELD_DurationInMonths_Validators;
private static final AttributeValidator[] FIELD_CouponDuration_Validators;
private static final AttributeValidator[] FIELD_RedeemBy_Validators;
private static final AttributeValidator[] FIELD_MaxRedemptions_Validators;
private static final AttributeValidator[] FIELD_TimesRedeemed_Validators;
// Arrays of behaviour decorators // Arrays of behaviour decorators
...@@ -89,6 +105,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -89,6 +105,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
FIELD_CouponCode_Validators = (AttributeValidator[])setupAttribMetaData_CouponCode(validatorMapping).toArray (new AttributeValidator[0]); FIELD_CouponCode_Validators = (AttributeValidator[])setupAttribMetaData_CouponCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PercentageOff_Validators = (AttributeValidator[])setupAttribMetaData_PercentageOff(validatorMapping).toArray (new AttributeValidator[0]); FIELD_PercentageOff_Validators = (AttributeValidator[])setupAttribMetaData_PercentageOff(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_DurationInMonths_Validators = (AttributeValidator[])setupAttribMetaData_DurationInMonths(validatorMapping).toArray (new AttributeValidator[0]); FIELD_DurationInMonths_Validators = (AttributeValidator[])setupAttribMetaData_DurationInMonths(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CouponDuration_Validators = (AttributeValidator[])setupAttribMetaData_CouponDuration(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_RedeemBy_Validators = (AttributeValidator[])setupAttribMetaData_RedeemBy(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MaxRedemptions_Validators = (AttributeValidator[])setupAttribMetaData_MaxRedemptions(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_TimesRedeemed_Validators = (AttributeValidator[])setupAttribMetaData_TimesRedeemed(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_StripeCoupon.initialiseReference (); REFERENCE_StripeCoupon.initialiseReference ();
...@@ -130,7 +150,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -130,7 +150,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
metaInfo.put ("dbcol", "percentage_off"); metaInfo.put ("dbcol", "percentage_off");
metaInfo.put ("name", "PercentageOff"); metaInfo.put ("name", "PercentageOff");
metaInfo.put ("type", "Integer"); metaInfo.put ("type", "Double");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.PercentageOff:", metaInfo); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.PercentageOff:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_PercentageOff, Collections.unmodifiableMap (metaInfo)); ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_PercentageOff, Collections.unmodifiableMap (metaInfo));
...@@ -159,6 +179,79 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -159,6 +179,79 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
return validators; return validators;
} }
// Meta Info setup
private static List setupAttribMetaData_CouponDuration(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "coupon_duration");
metaInfo.put ("name", "CouponDuration");
metaInfo.put ("type", "CouponDuration");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.CouponDuration:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_CouponDuration, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "CouponDuration", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.CouponDuration:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_RedeemBy(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "redeem_by");
metaInfo.put ("name", "RedeemBy");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.RedeemBy:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_RedeemBy, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "RedeemBy", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.RedeemBy:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_MaxRedemptions(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "max_redemptions");
metaInfo.put ("name", "MaxRedemptions");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.MaxRedemptions:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_MaxRedemptions, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "MaxRedemptions", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.MaxRedemptions:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_TimesRedeemed(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "times_redeemed");
metaInfo.put ("name", "TimesRedeemed");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.TimesRedeemed:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_TimesRedeemed, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "TimesRedeemed", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.TimesRedeemed:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION // END OF STATIC METADATA DEFINITION
...@@ -187,8 +280,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -187,8 +280,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
_CouponCode = (String)(HELPER_CouponCode.initialise (_CouponCode)); _CouponCode = (String)(HELPER_CouponCode.initialise (_CouponCode));
_PercentageOff = (Integer)(HELPER_PercentageOff.initialise (_PercentageOff)); _PercentageOff = (Double)(HELPER_PercentageOff.initialise (_PercentageOff));
_DurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (_DurationInMonths)); _DurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (_DurationInMonths));
_CouponDuration = (CouponDuration)(HELPER_CouponDuration.initialise (_CouponDuration));
_RedeemBy = (Date)(HELPER_RedeemBy.initialise (_RedeemBy));
_MaxRedemptions = (Integer)(HELPER_MaxRedemptions.initialise (_MaxRedemptions));
_TimesRedeemed = (Integer)(HELPER_TimesRedeemed.initialise (_TimesRedeemed));
} }
...@@ -315,10 +412,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -315,10 +412,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
/** /**
* Get the attribute PercentageOff * Get the attribute PercentageOff
*/ */
public Integer getPercentageOff () public Double getPercentageOff ()
{ {
assertValid(); assertValid();
Integer valToReturn = _PercentageOff; Double valToReturn = _PercentageOff;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators) for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{ {
...@@ -334,7 +431,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -334,7 +431,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
* Called prior to the attribute changing. Subclasses need not call super. If a field exception * Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value. * is thrown, the attribute change will fail. The new value is different to the old value.
*/ */
protected void prePercentageOffChange (Integer newPercentageOff) throws FieldException protected void prePercentageOffChange (Double newPercentageOff) throws FieldException
{ {
} }
...@@ -358,7 +455,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -358,7 +455,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
* Set the attribute PercentageOff. Checks to ensure a new value * Set the attribute PercentageOff. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute. * has been supplied. If so, marks the field as altered and sets the attribute.
*/ */
public void setPercentageOff (Integer newPercentageOff) throws FieldException public void setPercentageOff (Double newPercentageOff) throws FieldException
{ {
boolean oldAndNewIdentical = HELPER_PercentageOff.compare (_PercentageOff, newPercentageOff); boolean oldAndNewIdentical = HELPER_PercentageOff.compare (_PercentageOff, newPercentageOff);
...@@ -508,6 +605,398 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -508,6 +605,398 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
} }
} }
/**
* Get the attribute CouponDuration
*/
public CouponDuration getCouponDuration ()
{
assertValid();
CouponDuration valToReturn = _CouponDuration;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getCouponDuration ((StripeCoupon)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCouponDurationChange (CouponDuration newCouponDuration) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCouponDurationChange () throws FieldException
{
}
public FieldWriteability getWriteability_CouponDuration ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CouponDuration. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCouponDuration (CouponDuration newCouponDuration) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CouponDuration.compare (_CouponDuration, newCouponDuration);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newCouponDuration = bhd.setCouponDuration ((StripeCoupon)this, newCouponDuration);
oldAndNewIdentical = HELPER_CouponDuration.compare (_CouponDuration, newCouponDuration);
}
if (FIELD_CouponDuration_Validators.length > 0)
{
Object newCouponDurationObj = HELPER_CouponDuration.toObject (newCouponDuration);
if (newCouponDurationObj != null)
{
int loopMax = FIELD_CouponDuration_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_CouponDuration);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CouponDuration_Validators[v].checkAttribute (this, FIELD_CouponDuration, metadata, newCouponDurationObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CouponDuration () != FieldWriteability.FALSE, "Field CouponDuration is not writeable");
preCouponDurationChange (newCouponDuration);
markFieldChange (FIELD_CouponDuration);
_CouponDuration = newCouponDuration;
postFieldChange (FIELD_CouponDuration);
postCouponDurationChange ();
}
}
/**
* Get the attribute RedeemBy
*/
public Date getRedeemBy ()
{
assertValid();
Date valToReturn = _RedeemBy;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getRedeemBy ((StripeCoupon)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preRedeemByChange (Date newRedeemBy) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postRedeemByChange () throws FieldException
{
}
public FieldWriteability getWriteability_RedeemBy ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute RedeemBy. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setRedeemBy (Date newRedeemBy) throws FieldException
{
boolean oldAndNewIdentical = HELPER_RedeemBy.compare (_RedeemBy, newRedeemBy);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newRedeemBy = bhd.setRedeemBy ((StripeCoupon)this, newRedeemBy);
oldAndNewIdentical = HELPER_RedeemBy.compare (_RedeemBy, newRedeemBy);
}
if (FIELD_RedeemBy_Validators.length > 0)
{
Object newRedeemByObj = HELPER_RedeemBy.toObject (newRedeemBy);
if (newRedeemByObj != null)
{
int loopMax = FIELD_RedeemBy_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_RedeemBy);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_RedeemBy_Validators[v].checkAttribute (this, FIELD_RedeemBy, metadata, newRedeemByObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_RedeemBy () != FieldWriteability.FALSE, "Field RedeemBy is not writeable");
preRedeemByChange (newRedeemBy);
markFieldChange (FIELD_RedeemBy);
_RedeemBy = newRedeemBy;
postFieldChange (FIELD_RedeemBy);
postRedeemByChange ();
}
}
/**
* Get the attribute MaxRedemptions
*/
public Integer getMaxRedemptions ()
{
assertValid();
Integer valToReturn = _MaxRedemptions;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getMaxRedemptions ((StripeCoupon)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preMaxRedemptionsChange (Integer newMaxRedemptions) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postMaxRedemptionsChange () throws FieldException
{
}
public FieldWriteability getWriteability_MaxRedemptions ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute MaxRedemptions. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setMaxRedemptions (Integer newMaxRedemptions) throws FieldException
{
boolean oldAndNewIdentical = HELPER_MaxRedemptions.compare (_MaxRedemptions, newMaxRedemptions);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newMaxRedemptions = bhd.setMaxRedemptions ((StripeCoupon)this, newMaxRedemptions);
oldAndNewIdentical = HELPER_MaxRedemptions.compare (_MaxRedemptions, newMaxRedemptions);
}
if (FIELD_MaxRedemptions_Validators.length > 0)
{
Object newMaxRedemptionsObj = HELPER_MaxRedemptions.toObject (newMaxRedemptions);
if (newMaxRedemptionsObj != null)
{
int loopMax = FIELD_MaxRedemptions_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_MaxRedemptions);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_MaxRedemptions_Validators[v].checkAttribute (this, FIELD_MaxRedemptions, metadata, newMaxRedemptionsObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_MaxRedemptions () != FieldWriteability.FALSE, "Field MaxRedemptions is not writeable");
preMaxRedemptionsChange (newMaxRedemptions);
markFieldChange (FIELD_MaxRedemptions);
_MaxRedemptions = newMaxRedemptions;
postFieldChange (FIELD_MaxRedemptions);
postMaxRedemptionsChange ();
}
}
/**
* Get the attribute TimesRedeemed
*/
public Integer getTimesRedeemed ()
{
assertValid();
Integer valToReturn = _TimesRedeemed;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getTimesRedeemed ((StripeCoupon)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preTimesRedeemedChange (Integer newTimesRedeemed) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postTimesRedeemedChange () throws FieldException
{
}
public FieldWriteability getWriteability_TimesRedeemed ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute TimesRedeemed. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setTimesRedeemed (Integer newTimesRedeemed) throws FieldException
{
boolean oldAndNewIdentical = HELPER_TimesRedeemed.compare (_TimesRedeemed, newTimesRedeemed);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newTimesRedeemed = bhd.setTimesRedeemed ((StripeCoupon)this, newTimesRedeemed);
oldAndNewIdentical = HELPER_TimesRedeemed.compare (_TimesRedeemed, newTimesRedeemed);
}
if (FIELD_TimesRedeemed_Validators.length > 0)
{
Object newTimesRedeemedObj = HELPER_TimesRedeemed.toObject (newTimesRedeemed);
if (newTimesRedeemedObj != null)
{
int loopMax = FIELD_TimesRedeemed_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_TimesRedeemed);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_TimesRedeemed_Validators[v].checkAttribute (this, FIELD_TimesRedeemed, metadata, newTimesRedeemedObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_TimesRedeemed () != FieldWriteability.FALSE, "Field TimesRedeemed is not writeable");
preTimesRedeemedChange (newTimesRedeemed);
markFieldChange (FIELD_TimesRedeemed);
_TimesRedeemed = newTimesRedeemed;
postFieldChange (FIELD_TimesRedeemed);
postTimesRedeemedChange ();
}
}
/** /**
...@@ -769,6 +1258,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -769,6 +1258,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
tl_couponPSet.setAttrib (FIELD_CouponCode, HELPER_CouponCode.toObject (_CouponCode)); // tl_couponPSet.setAttrib (FIELD_CouponCode, HELPER_CouponCode.toObject (_CouponCode)); //
tl_couponPSet.setAttrib (FIELD_PercentageOff, HELPER_PercentageOff.toObject (_PercentageOff)); // tl_couponPSet.setAttrib (FIELD_PercentageOff, HELPER_PercentageOff.toObject (_PercentageOff)); //
tl_couponPSet.setAttrib (FIELD_DurationInMonths, HELPER_DurationInMonths.toObject (_DurationInMonths)); // tl_couponPSet.setAttrib (FIELD_DurationInMonths, HELPER_DurationInMonths.toObject (_DurationInMonths)); //
tl_couponPSet.setAttrib (FIELD_CouponDuration, HELPER_CouponDuration.toObject (_CouponDuration)); //
tl_couponPSet.setAttrib (FIELD_RedeemBy, HELPER_RedeemBy.toObject (_RedeemBy)); //
tl_couponPSet.setAttrib (FIELD_MaxRedemptions, HELPER_MaxRedemptions.toObject (_MaxRedemptions)); //
tl_couponPSet.setAttrib (FIELD_TimesRedeemed, HELPER_TimesRedeemed.toObject (_TimesRedeemed)); //
} }
...@@ -784,8 +1277,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -784,8 +1277,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
PersistentSet tl_couponPSet = allSets.getPersistentSet (objectID, "tl_coupon"); PersistentSet tl_couponPSet = allSets.getPersistentSet (objectID, "tl_coupon");
_CouponCode = (String)(HELPER_CouponCode.fromObject (_CouponCode, tl_couponPSet.getAttrib (FIELD_CouponCode))); // _CouponCode = (String)(HELPER_CouponCode.fromObject (_CouponCode, tl_couponPSet.getAttrib (FIELD_CouponCode))); //
_PercentageOff = (Integer)(HELPER_PercentageOff.fromObject (_PercentageOff, tl_couponPSet.getAttrib (FIELD_PercentageOff))); // _PercentageOff = (Double)(HELPER_PercentageOff.fromObject (_PercentageOff, tl_couponPSet.getAttrib (FIELD_PercentageOff))); //
_DurationInMonths = (Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, tl_couponPSet.getAttrib (FIELD_DurationInMonths))); // _DurationInMonths = (Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, tl_couponPSet.getAttrib (FIELD_DurationInMonths))); //
_CouponDuration = (CouponDuration)(HELPER_CouponDuration.fromObject (_CouponDuration, tl_couponPSet.getAttrib (FIELD_CouponDuration))); //
_RedeemBy = (Date)(HELPER_RedeemBy.fromObject (_RedeemBy, tl_couponPSet.getAttrib (FIELD_RedeemBy))); //
_MaxRedemptions = (Integer)(HELPER_MaxRedemptions.fromObject (_MaxRedemptions, tl_couponPSet.getAttrib (FIELD_MaxRedemptions))); //
_TimesRedeemed = (Integer)(HELPER_TimesRedeemed.fromObject (_TimesRedeemed, tl_couponPSet.getAttrib (FIELD_TimesRedeemed))); //
} }
...@@ -828,6 +1325,42 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -828,6 +1325,42 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
e.addException (ex); e.addException (ex);
} }
try
{
setCouponDuration (otherStripeCoupon.getCouponDuration ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setRedeemBy (otherStripeCoupon.getRedeemBy ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setMaxRedemptions (otherStripeCoupon.getMaxRedemptions ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setTimesRedeemed (otherStripeCoupon.getTimesRedeemed ());
}
catch (FieldException ex)
{
e.addException (ex);
}
} }
} }
...@@ -846,6 +1379,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -846,6 +1379,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
_CouponCode = sourceStripeCoupon._CouponCode; _CouponCode = sourceStripeCoupon._CouponCode;
_PercentageOff = sourceStripeCoupon._PercentageOff; _PercentageOff = sourceStripeCoupon._PercentageOff;
_DurationInMonths = sourceStripeCoupon._DurationInMonths; _DurationInMonths = sourceStripeCoupon._DurationInMonths;
_CouponDuration = sourceStripeCoupon._CouponDuration;
_RedeemBy = sourceStripeCoupon._RedeemBy;
_MaxRedemptions = sourceStripeCoupon._MaxRedemptions;
_TimesRedeemed = sourceStripeCoupon._TimesRedeemed;
} }
} }
...@@ -899,8 +1436,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -899,8 +1436,12 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
super.readExternalData(vals); super.readExternalData(vals);
_CouponCode = (String)(HELPER_CouponCode.readExternal (_CouponCode, vals.get(FIELD_CouponCode))); // _CouponCode = (String)(HELPER_CouponCode.readExternal (_CouponCode, vals.get(FIELD_CouponCode))); //
_PercentageOff = (Integer)(HELPER_PercentageOff.readExternal (_PercentageOff, vals.get(FIELD_PercentageOff))); // _PercentageOff = (Double)(HELPER_PercentageOff.readExternal (_PercentageOff, vals.get(FIELD_PercentageOff))); //
_DurationInMonths = (Integer)(HELPER_DurationInMonths.readExternal (_DurationInMonths, vals.get(FIELD_DurationInMonths))); // _DurationInMonths = (Integer)(HELPER_DurationInMonths.readExternal (_DurationInMonths, vals.get(FIELD_DurationInMonths))); //
_CouponDuration = (CouponDuration)(HELPER_CouponDuration.readExternal (_CouponDuration, vals.get(FIELD_CouponDuration))); //
_RedeemBy = (Date)(HELPER_RedeemBy.readExternal (_RedeemBy, vals.get(FIELD_RedeemBy))); //
_MaxRedemptions = (Integer)(HELPER_MaxRedemptions.readExternal (_MaxRedemptions, vals.get(FIELD_MaxRedemptions))); //
_TimesRedeemed = (Integer)(HELPER_TimesRedeemed.readExternal (_TimesRedeemed, vals.get(FIELD_TimesRedeemed))); //
} }
...@@ -915,6 +1456,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -915,6 +1456,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
vals.put (FIELD_CouponCode, HELPER_CouponCode.writeExternal (_CouponCode)); vals.put (FIELD_CouponCode, HELPER_CouponCode.writeExternal (_CouponCode));
vals.put (FIELD_PercentageOff, HELPER_PercentageOff.writeExternal (_PercentageOff)); vals.put (FIELD_PercentageOff, HELPER_PercentageOff.writeExternal (_PercentageOff));
vals.put (FIELD_DurationInMonths, HELPER_DurationInMonths.writeExternal (_DurationInMonths)); vals.put (FIELD_DurationInMonths, HELPER_DurationInMonths.writeExternal (_DurationInMonths));
vals.put (FIELD_CouponDuration, HELPER_CouponDuration.writeExternal (_CouponDuration));
vals.put (FIELD_RedeemBy, HELPER_RedeemBy.writeExternal (_RedeemBy));
vals.put (FIELD_MaxRedemptions, HELPER_MaxRedemptions.writeExternal (_MaxRedemptions));
vals.put (FIELD_TimesRedeemed, HELPER_TimesRedeemed.writeExternal (_TimesRedeemed));
} }
...@@ -940,6 +1485,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -940,6 +1485,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
listener.notifyFieldChange(this, other, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(this._DurationInMonths), HELPER_DurationInMonths.toObject(otherStripeCoupon._DurationInMonths)); listener.notifyFieldChange(this, other, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(this._DurationInMonths), HELPER_DurationInMonths.toObject(otherStripeCoupon._DurationInMonths));
} }
if (!HELPER_CouponDuration.compare(this._CouponDuration, otherStripeCoupon._CouponDuration))
{
listener.notifyFieldChange(this, other, FIELD_CouponDuration, HELPER_CouponDuration.toObject(this._CouponDuration), HELPER_CouponDuration.toObject(otherStripeCoupon._CouponDuration));
}
if (!HELPER_RedeemBy.compare(this._RedeemBy, otherStripeCoupon._RedeemBy))
{
listener.notifyFieldChange(this, other, FIELD_RedeemBy, HELPER_RedeemBy.toObject(this._RedeemBy), HELPER_RedeemBy.toObject(otherStripeCoupon._RedeemBy));
}
if (!HELPER_MaxRedemptions.compare(this._MaxRedemptions, otherStripeCoupon._MaxRedemptions))
{
listener.notifyFieldChange(this, other, FIELD_MaxRedemptions, HELPER_MaxRedemptions.toObject(this._MaxRedemptions), HELPER_MaxRedemptions.toObject(otherStripeCoupon._MaxRedemptions));
}
if (!HELPER_TimesRedeemed.compare(this._TimesRedeemed, otherStripeCoupon._TimesRedeemed))
{
listener.notifyFieldChange(this, other, FIELD_TimesRedeemed, HELPER_TimesRedeemed.toObject(this._TimesRedeemed), HELPER_TimesRedeemed.toObject(otherStripeCoupon._TimesRedeemed));
}
// Compare single assocs // Compare single assocs
...@@ -965,6 +1526,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -965,6 +1526,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
visitor.visitField(this, FIELD_CouponCode, HELPER_CouponCode.toObject(getCouponCode())); visitor.visitField(this, FIELD_CouponCode, HELPER_CouponCode.toObject(getCouponCode()));
visitor.visitField(this, FIELD_PercentageOff, HELPER_PercentageOff.toObject(getPercentageOff())); visitor.visitField(this, FIELD_PercentageOff, HELPER_PercentageOff.toObject(getPercentageOff()));
visitor.visitField(this, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(getDurationInMonths())); visitor.visitField(this, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(getDurationInMonths()));
visitor.visitField(this, FIELD_CouponDuration, HELPER_CouponDuration.toObject(getCouponDuration()));
visitor.visitField(this, FIELD_RedeemBy, HELPER_RedeemBy.toObject(getRedeemBy()));
visitor.visitField(this, FIELD_MaxRedemptions, HELPER_MaxRedemptions.toObject(getMaxRedemptions()));
visitor.visitField(this, FIELD_TimesRedeemed, HELPER_TimesRedeemed.toObject(getTimesRedeemed()));
} }
...@@ -1010,6 +1575,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1010,6 +1575,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
return filter.matches (getDurationInMonths ()); return filter.matches (getDurationInMonths ());
} }
else if (attribName.equals (FIELD_CouponDuration))
{
return filter.matches (getCouponDuration ());
}
else if (attribName.equals (FIELD_RedeemBy))
{
return filter.matches (getRedeemBy ());
}
else if (attribName.equals (FIELD_MaxRedemptions))
{
return filter.matches (getMaxRedemptions ());
}
else if (attribName.equals (FIELD_TimesRedeemed))
{
return filter.matches (getTimesRedeemed ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -1047,7 +1628,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1047,7 +1628,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
return this; return this;
} }
public SearchAll andPercentageOff (QueryFilter<Integer> filter) public SearchAll andPercentageOff (QueryFilter<Double> filter)
{ {
filter.addFilter (context, "tl_coupon.percentage_off", "PercentageOff"); filter.addFilter (context, "tl_coupon.percentage_off", "PercentageOff");
return this; return this;
...@@ -1059,6 +1640,30 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1059,6 +1640,30 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
return this; return this;
} }
public SearchAll andCouponDuration (QueryFilter<CouponDuration> filter)
{
filter.addFilter (context, "tl_coupon.coupon_duration", "CouponDuration");
return this;
}
public SearchAll andRedeemBy (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_coupon.redeem_by", "RedeemBy");
return this;
}
public SearchAll andMaxRedemptions (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_coupon.max_redemptions", "MaxRedemptions");
return this;
}
public SearchAll andTimesRedeemed (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_coupon.times_redeemed", "TimesRedeemed");
return this;
}
public StripeCoupon[] public StripeCoupon[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -1106,6 +1711,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1106,6 +1711,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
return HELPER_DurationInMonths.toObject (getDurationInMonths ()); return HELPER_DurationInMonths.toObject (getDurationInMonths ());
} }
else if (attribName.equals (FIELD_CouponDuration))
{
return HELPER_CouponDuration.toObject (getCouponDuration ());
}
else if (attribName.equals (FIELD_RedeemBy))
{
return HELPER_RedeemBy.toObject (getRedeemBy ());
}
else if (attribName.equals (FIELD_MaxRedemptions))
{
return HELPER_MaxRedemptions.toObject (getMaxRedemptions ());
}
else if (attribName.equals (FIELD_TimesRedeemed))
{
return HELPER_TimesRedeemed.toObject (getTimesRedeemed ());
}
else else
{ {
return super.getAttribute (attribName); return super.getAttribute (attribName);
...@@ -1131,6 +1752,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1131,6 +1752,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
return HELPER_DurationInMonths; return HELPER_DurationInMonths;
} }
else if (attribName.equals (FIELD_CouponDuration))
{
return HELPER_CouponDuration;
}
else if (attribName.equals (FIELD_RedeemBy))
{
return HELPER_RedeemBy;
}
else if (attribName.equals (FIELD_MaxRedemptions))
{
return HELPER_MaxRedemptions;
}
else if (attribName.equals (FIELD_TimesRedeemed))
{
return HELPER_TimesRedeemed;
}
else else
{ {
return super.getAttributeHelper (attribName); return super.getAttributeHelper (attribName);
...@@ -1150,12 +1787,28 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1150,12 +1787,28 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
} }
else if (attribName.equals (FIELD_PercentageOff)) else if (attribName.equals (FIELD_PercentageOff))
{ {
setPercentageOff ((Integer)(HELPER_PercentageOff.fromObject (_PercentageOff, attribValue))); setPercentageOff ((Double)(HELPER_PercentageOff.fromObject (_PercentageOff, attribValue)));
} }
else if (attribName.equals (FIELD_DurationInMonths)) else if (attribName.equals (FIELD_DurationInMonths))
{ {
setDurationInMonths ((Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, attribValue))); setDurationInMonths ((Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, attribValue)));
} }
else if (attribName.equals (FIELD_CouponDuration))
{
setCouponDuration ((CouponDuration)(HELPER_CouponDuration.fromObject (_CouponDuration, attribValue)));
}
else if (attribName.equals (FIELD_RedeemBy))
{
setRedeemBy ((Date)(HELPER_RedeemBy.fromObject (_RedeemBy, attribValue)));
}
else if (attribName.equals (FIELD_MaxRedemptions))
{
setMaxRedemptions ((Integer)(HELPER_MaxRedemptions.fromObject (_MaxRedemptions, attribValue)));
}
else if (attribName.equals (FIELD_TimesRedeemed))
{
setTimesRedeemed ((Integer)(HELPER_TimesRedeemed.fromObject (_TimesRedeemed, attribValue)));
}
else else
{ {
super.setAttribute (attribName, attribValue); super.setAttribute (attribName, attribValue);
...@@ -1188,6 +1841,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1188,6 +1841,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
return getWriteability_DurationInMonths (); return getWriteability_DurationInMonths ();
} }
else if (fieldName.equals (FIELD_CouponDuration))
{
return getWriteability_CouponDuration ();
}
else if (fieldName.equals (FIELD_RedeemBy))
{
return getWriteability_RedeemBy ();
}
else if (fieldName.equals (FIELD_MaxRedemptions))
{
return getWriteability_MaxRedemptions ();
}
else if (fieldName.equals (FIELD_TimesRedeemed))
{
return getWriteability_TimesRedeemed ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1213,6 +1882,26 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1213,6 +1882,26 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
fields.add (FIELD_DurationInMonths); fields.add (FIELD_DurationInMonths);
} }
if (getWriteability_CouponDuration () != FieldWriteability.TRUE)
{
fields.add (FIELD_CouponDuration);
}
if (getWriteability_RedeemBy () != FieldWriteability.TRUE)
{
fields.add (FIELD_RedeemBy);
}
if (getWriteability_MaxRedemptions () != FieldWriteability.TRUE)
{
fields.add (FIELD_MaxRedemptions);
}
if (getWriteability_TimesRedeemed () != FieldWriteability.TRUE)
{
fields.add (FIELD_TimesRedeemed);
}
super.putUnwriteable (fields); super.putUnwriteable (fields);
} }
...@@ -1225,6 +1914,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1225,6 +1914,10 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
result.add(HELPER_CouponCode.getAttribObject (getClass (), _CouponCode, true, FIELD_CouponCode)); result.add(HELPER_CouponCode.getAttribObject (getClass (), _CouponCode, true, FIELD_CouponCode));
result.add(HELPER_PercentageOff.getAttribObject (getClass (), _PercentageOff, false, FIELD_PercentageOff)); result.add(HELPER_PercentageOff.getAttribObject (getClass (), _PercentageOff, false, FIELD_PercentageOff));
result.add(HELPER_DurationInMonths.getAttribObject (getClass (), _DurationInMonths, false, FIELD_DurationInMonths)); result.add(HELPER_DurationInMonths.getAttribObject (getClass (), _DurationInMonths, false, FIELD_DurationInMonths));
result.add(HELPER_CouponDuration.getAttribObject (getClass (), _CouponDuration, false, FIELD_CouponDuration));
result.add(HELPER_RedeemBy.getAttribObject (getClass (), _RedeemBy, false, FIELD_RedeemBy));
result.add(HELPER_MaxRedemptions.getAttribObject (getClass (), _MaxRedemptions, false, FIELD_MaxRedemptions));
result.add(HELPER_TimesRedeemed.getAttribObject (getClass (), _TimesRedeemed, false, FIELD_TimesRedeemed));
return result; return result;
} }
...@@ -1296,7 +1989,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1296,7 +1989,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
/** /**
* Get the attribute PercentageOff * Get the attribute PercentageOff
*/ */
public Integer getPercentageOff (StripeCoupon obj, Integer original) public Double getPercentageOff (StripeCoupon obj, Double original)
{ {
return original; return original;
} }
...@@ -1306,7 +1999,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1306,7 +1999,7 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
* May modify the field beforehand * May modify the field beforehand
* Occurs before validation. * Occurs before validation.
*/ */
public Integer setPercentageOff (StripeCoupon obj, Integer newPercentageOff) throws FieldException public Double setPercentageOff (StripeCoupon obj, Double newPercentageOff) throws FieldException
{ {
return newPercentageOff; return newPercentageOff;
} }
...@@ -1329,6 +2022,78 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1329,6 +2022,78 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
return newDurationInMonths; return newDurationInMonths;
} }
/**
* Get the attribute CouponDuration
*/
public CouponDuration getCouponDuration (StripeCoupon obj, CouponDuration original)
{
return original;
}
/**
* Change the value set for attribute CouponDuration.
* May modify the field beforehand
* Occurs before validation.
*/
public CouponDuration setCouponDuration (StripeCoupon obj, CouponDuration newCouponDuration) throws FieldException
{
return newCouponDuration;
}
/**
* Get the attribute RedeemBy
*/
public Date getRedeemBy (StripeCoupon obj, Date original)
{
return original;
}
/**
* Change the value set for attribute RedeemBy.
* May modify the field beforehand
* Occurs before validation.
*/
public Date setRedeemBy (StripeCoupon obj, Date newRedeemBy) throws FieldException
{
return newRedeemBy;
}
/**
* Get the attribute MaxRedemptions
*/
public Integer getMaxRedemptions (StripeCoupon obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute MaxRedemptions.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setMaxRedemptions (StripeCoupon obj, Integer newMaxRedemptions) throws FieldException
{
return newMaxRedemptions;
}
/**
* Get the attribute TimesRedeemed
*/
public Integer getTimesRedeemed (StripeCoupon obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute TimesRedeemed.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setTimesRedeemed (StripeCoupon obj, Integer newTimesRedeemed) throws FieldException
{
return newTimesRedeemed;
}
} }
...@@ -1393,6 +2158,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1393,6 +2158,22 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
{ {
return toDurationInMonths (); return toDurationInMonths ();
} }
if (name.equals ("CouponDuration"))
{
return toCouponDuration ();
}
if (name.equals ("RedeemBy"))
{
return toRedeemBy ();
}
if (name.equals ("MaxRedemptions"))
{
return toMaxRedemptions ();
}
if (name.equals ("TimesRedeemed"))
{
return toTimesRedeemed ();
}
return super.to(name); return super.to(name);
...@@ -1401,10 +2182,18 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass ...@@ -1401,10 +2182,18 @@ public abstract class BaseStripeCoupon extends BaseBusinessClass
public PipeLine<From, String> toCouponCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CouponCode)); } public PipeLine<From, String> toCouponCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CouponCode)); }
public PipeLine<From, Integer> toPercentageOff () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_PercentageOff)); } public PipeLine<From, Double> toPercentageOff () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_PercentageOff)); }
public PipeLine<From, Integer> toDurationInMonths () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DurationInMonths)); } public PipeLine<From, Integer> toDurationInMonths () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DurationInMonths)); }
public PipeLine<From, CouponDuration> toCouponDuration () { return pipe(new ORMAttributePipe<Me, CouponDuration>(FIELD_CouponDuration)); }
public PipeLine<From, Date> toRedeemBy () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_RedeemBy)); }
public PipeLine<From, Integer> toMaxRedemptions () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_MaxRedemptions)); }
public PipeLine<From, Integer> toTimesRedeemed () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_TimesRedeemed)); }
} }
public boolean isTransientAttrib(String attribName) public boolean isTransientAttrib(String attribName)
......
package performa.orm; package performa.orm;
import com.stripe.model.Card; import com.stripe.model.Card;
import com.stripe.model.Coupon;
import java.util.Date;
import java.util.Set; import java.util.Set;
import oneit.logging.LoggingArea; import oneit.logging.LoggingArea;
import oneit.objstore.ValidationContext; import oneit.objstore.ValidationContext;
import oneit.objstore.rdbms.filters.EqualsFilter; import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.utils.DateDiff;
import oneit.utils.StringUtils; import oneit.utils.StringUtils;
import oneit.utils.filter.Filter; import oneit.utils.filter.Filter;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
...@@ -106,4 +109,28 @@ public class HiringTeam extends BaseHiringTeam ...@@ -106,4 +109,28 @@ public class HiringTeam extends BaseHiringTeam
{ {
return super.getUsedCredits() != null ? super.getUsedCredits() : 0; return super.getUsedCredits() != null ? super.getUsedCredits() : 0;
} }
public boolean hasValidCoupon() throws FieldException
{
return hasValidCouponOn(DateDiff.getToday());
}
public boolean hasValidCouponOn(Date date) throws FieldException
{
if(getCoupon() != null)
{
Coupon coupon = StripeUtils.retrieveCoupon(getCoupon().getCouponCode());
if(coupon.getValid() && (getCouponExpiryDate() == null || date.before(getCouponExpiryDate())))
{
return true;
}
}
setCoupon(null);
setCouponExpiryDate(null);
return false;
}
} }
\ No newline at end of file
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
<ATTRIB name="IsPPJ" type="Boolean" dbcol="is_ppj" defaultValue="Boolean.TRUE"/> <ATTRIB name="IsPPJ" type="Boolean" dbcol="is_ppj" defaultValue="Boolean.TRUE"/>
<ATTRIB name="HasCap" type="Boolean" dbcol="has_cap" defaultValue="Boolean.FALSE"/> <ATTRIB name="HasCap" type="Boolean" dbcol="has_cap" defaultValue="Boolean.FALSE"/>
<ATTRIB name="MaxCap" type="Integer" dbcol="max_cap" /> <ATTRIB name="MaxCap" type="Integer" dbcol="max_cap" />
<ATTRIB name="CouponExpiryDate" type="Date" dbcol="coupon_expiry_date" />
<SINGLEREFERENCE name="Company" type="Company" dbcol="company_id" mandatory="true" backreferenceName="HiringTeams" /> <SINGLEREFERENCE name="Company" type="Company" dbcol="company_id" mandatory="true" backreferenceName="HiringTeams" />
<SINGLEREFERENCE name="BillingTeam" type="HiringTeam" dbcol="billing_team_id" mandatory="false" /> <SINGLEREFERENCE name="BillingTeam" type="HiringTeam" dbcol="billing_team_id" mandatory="false" />
<SINGLEREFERENCE name="AddedByUser" type="CompanyUser" dbcol="added_by_user_id" mandatory="true" /> <SINGLEREFERENCE name="AddedByUser" type="CompanyUser" dbcol="added_by_user_id" mandatory="true" />
<SINGLEREFERENCE name="PaymentPlan" type="PaymentPlan" dbcol="payment_plan_id" mandatory="false" /> <SINGLEREFERENCE name="PaymentPlan" type="PaymentPlan" dbcol="payment_plan_id" mandatory="false" />
<SINGLEREFERENCE name="Coupon" type="StripeCoupon" dbcol="coupon_id" mandatory="false" />
</TABLE> </TABLE>
......
...@@ -50,6 +50,7 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -50,6 +50,7 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
private Boolean dummyIsPPJ; private Boolean dummyIsPPJ;
private Boolean dummyHasCap; private Boolean dummyHasCap;
private Integer dummyMaxCap; private Integer dummyMaxCap;
private Date dummyCouponExpiryDate;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -74,6 +75,7 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -74,6 +75,7 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
private static final DefaultAttributeHelper HELPER_IsPPJ = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_IsPPJ = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_HasCap = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_HasCap = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_MaxCap = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_MaxCap = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_CouponExpiryDate = DefaultAttributeHelper.INSTANCE;
...@@ -101,10 +103,11 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -101,10 +103,11 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
dummyIsPPJ = (Boolean)(HELPER_IsPPJ.initialise (dummyIsPPJ)); dummyIsPPJ = (Boolean)(HELPER_IsPPJ.initialise (dummyIsPPJ));
dummyHasCap = (Boolean)(HELPER_HasCap.initialise (dummyHasCap)); dummyHasCap = (Boolean)(HELPER_HasCap.initialise (dummyHasCap));
dummyMaxCap = (Integer)(HELPER_MaxCap.initialise (dummyMaxCap)); dummyMaxCap = (Integer)(HELPER_MaxCap.initialise (dummyMaxCap));
dummyCouponExpiryDate = (Date)(HELPER_CouponExpiryDate.initialise (dummyCouponExpiryDate));
} }
private String SELECT_COLUMNS = "{PREFIX}tl_hiring_team.object_id as id, {PREFIX}tl_hiring_team.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_hiring_team.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_hiring_team.hiring_team_name, {PREFIX}tl_hiring_team.hiring_team_logo, {PREFIX}tl_hiring_team.hiring_team_type, {PREFIX}tl_hiring_team.industry, {PREFIX}tl_hiring_team.time_zone, {PREFIX}tl_hiring_team.state, {PREFIX}tl_hiring_team.country, {PREFIX}tl_hiring_team.post_code, {PREFIX}tl_hiring_team.city, {PREFIX}tl_hiring_team.has_client_support, {PREFIX}tl_hiring_team.manage_own_billing, {PREFIX}tl_hiring_team.stripe_reference, {PREFIX}tl_hiring_team.stripe_subscription, {PREFIX}tl_hiring_team.name_on_card, {PREFIX}tl_hiring_team.card_post_code, {PREFIX}tl_hiring_team.card_id, {PREFIX}tl_hiring_team.plan_renewed_on, {PREFIX}tl_hiring_team.used_credits, {PREFIX}tl_hiring_team.is_ppj, {PREFIX}tl_hiring_team.has_cap, {PREFIX}tl_hiring_team.max_cap, {PREFIX}tl_hiring_team.company_id, {PREFIX}tl_hiring_team.billing_team_id, {PREFIX}tl_hiring_team.added_by_user_id, {PREFIX}tl_hiring_team.payment_plan_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_hiring_team.object_id as id, {PREFIX}tl_hiring_team.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_hiring_team.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_hiring_team.hiring_team_name, {PREFIX}tl_hiring_team.hiring_team_logo, {PREFIX}tl_hiring_team.hiring_team_type, {PREFIX}tl_hiring_team.industry, {PREFIX}tl_hiring_team.time_zone, {PREFIX}tl_hiring_team.state, {PREFIX}tl_hiring_team.country, {PREFIX}tl_hiring_team.post_code, {PREFIX}tl_hiring_team.city, {PREFIX}tl_hiring_team.has_client_support, {PREFIX}tl_hiring_team.manage_own_billing, {PREFIX}tl_hiring_team.stripe_reference, {PREFIX}tl_hiring_team.stripe_subscription, {PREFIX}tl_hiring_team.name_on_card, {PREFIX}tl_hiring_team.card_post_code, {PREFIX}tl_hiring_team.card_id, {PREFIX}tl_hiring_team.plan_renewed_on, {PREFIX}tl_hiring_team.used_credits, {PREFIX}tl_hiring_team.is_ppj, {PREFIX}tl_hiring_team.has_cap, {PREFIX}tl_hiring_team.max_cap, {PREFIX}tl_hiring_team.coupon_expiry_date, {PREFIX}tl_hiring_team.company_id, {PREFIX}tl_hiring_team.billing_team_id, {PREFIX}tl_hiring_team.added_by_user_id, {PREFIX}tl_hiring_team.payment_plan_id, {PREFIX}tl_hiring_team.coupon_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -176,10 +179,12 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -176,10 +179,12 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
!tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_IsPPJ)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_IsPPJ)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_HasCap)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_HasCap)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_MaxCap)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_MaxCap)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.FIELD_CouponExpiryDate)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_Company)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_Company)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_BillingTeam)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_BillingTeam)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_AddedByUser)|| !tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_AddedByUser)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_PaymentPlan)) !tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_PaymentPlan)||
!tl_hiring_teamPSet.containsAttrib(HiringTeam.SINGLEREFERENCE_Coupon))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -259,10 +264,10 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -259,10 +264,10 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_hiring_team " + "UPDATE {PREFIX}tl_hiring_team " +
"SET hiring_team_name = ?, hiring_team_logo = ?, hiring_team_type = ?, industry = ?, time_zone = ?, state = ?, country = ?, post_code = ?, city = ?, has_client_support = ?, manage_own_billing = ?, stripe_reference = ?, stripe_subscription = ?, name_on_card = ?, card_post_code = ?, card_id = ?, plan_renewed_on = ?, used_credits = ?, is_ppj = ?, has_cap = ?, max_cap = ?, company_id = ? , billing_team_id = ? , added_by_user_id = ? , payment_plan_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET hiring_team_name = ?, hiring_team_logo = ?, hiring_team_type = ?, industry = ?, time_zone = ?, state = ?, country = ?, post_code = ?, city = ?, has_client_support = ?, manage_own_billing = ?, stripe_reference = ?, stripe_subscription = ?, name_on_card = ?, card_post_code = ?, card_id = ?, plan_renewed_on = ?, used_credits = ?, is_ppj = ?, has_cap = ?, max_cap = ?, coupon_expiry_date = ?, company_id = ? , billing_team_id = ? , added_by_user_id = ? , payment_plan_id = ? , coupon_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_hiring_team.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_hiring_team.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_HiringTeamName.getForSQL(dummyHiringTeamName, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamName))).listEntry (HELPER_HiringTeamLogo.getForSQL(dummyHiringTeamLogo, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamLogo))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_TimeZone))).listEntry (HELPER_State.getForSQL(dummyState, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PostCode))).listEntry (HELPER_City.getForSQL(dummyCity, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_City))).listEntry (HELPER_HasClientSupport.getForSQL(dummyHasClientSupport, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasClientSupport))).listEntry (HELPER_ManageOwnBilling.getForSQL(dummyManageOwnBilling, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_ManageOwnBilling))).listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeReference))).listEntry (HELPER_StripeSubscription.getForSQL(dummyStripeSubscription, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeSubscription))).listEntry (HELPER_NameOnCard.getForSQL(dummyNameOnCard, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_NameOnCard))).listEntry (HELPER_CardPostCode.getForSQL(dummyCardPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardPostCode))).listEntry (HELPER_CardID.getForSQL(dummyCardID, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardID))).listEntry (HELPER_PlanRenewedOn.getForSQL(dummyPlanRenewedOn, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PlanRenewedOn))).listEntry (HELPER_UsedCredits.getForSQL(dummyUsedCredits, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_UsedCredits))).listEntry (HELPER_IsPPJ.getForSQL(dummyIsPPJ, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_IsPPJ))).listEntry (HELPER_HasCap.getForSQL(dummyHasCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasCap))).listEntry (HELPER_MaxCap.getForSQL(dummyMaxCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_MaxCap))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Company)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_BillingTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_AddedByUser)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_PaymentPlan)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_HiringTeamName.getForSQL(dummyHiringTeamName, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamName))).listEntry (HELPER_HiringTeamLogo.getForSQL(dummyHiringTeamLogo, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamLogo))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_TimeZone))).listEntry (HELPER_State.getForSQL(dummyState, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PostCode))).listEntry (HELPER_City.getForSQL(dummyCity, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_City))).listEntry (HELPER_HasClientSupport.getForSQL(dummyHasClientSupport, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasClientSupport))).listEntry (HELPER_ManageOwnBilling.getForSQL(dummyManageOwnBilling, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_ManageOwnBilling))).listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeReference))).listEntry (HELPER_StripeSubscription.getForSQL(dummyStripeSubscription, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeSubscription))).listEntry (HELPER_NameOnCard.getForSQL(dummyNameOnCard, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_NameOnCard))).listEntry (HELPER_CardPostCode.getForSQL(dummyCardPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardPostCode))).listEntry (HELPER_CardID.getForSQL(dummyCardID, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardID))).listEntry (HELPER_PlanRenewedOn.getForSQL(dummyPlanRenewedOn, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PlanRenewedOn))).listEntry (HELPER_UsedCredits.getForSQL(dummyUsedCredits, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_UsedCredits))).listEntry (HELPER_IsPPJ.getForSQL(dummyIsPPJ, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_IsPPJ))).listEntry (HELPER_HasCap.getForSQL(dummyHasCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasCap))).listEntry (HELPER_MaxCap.getForSQL(dummyMaxCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_MaxCap))).listEntry (HELPER_CouponExpiryDate.getForSQL(dummyCouponExpiryDate, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CouponExpiryDate))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Company)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_BillingTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_AddedByUser)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_PaymentPlan)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Coupon)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -539,11 +544,13 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -539,11 +544,13 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_IsPPJ, HELPER_IsPPJ.getFromRS(dummyIsPPJ, r, "is_ppj")); tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_IsPPJ, HELPER_IsPPJ.getFromRS(dummyIsPPJ, r, "is_ppj"));
tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_HasCap, HELPER_HasCap.getFromRS(dummyHasCap, r, "has_cap")); tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_HasCap, HELPER_HasCap.getFromRS(dummyHasCap, r, "has_cap"));
tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_MaxCap, HELPER_MaxCap.getFromRS(dummyMaxCap, r, "max_cap")); tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_MaxCap, HELPER_MaxCap.getFromRS(dummyMaxCap, r, "max_cap"));
tl_hiring_teamPSet.setAttrib(HiringTeam.FIELD_CouponExpiryDate, HELPER_CouponExpiryDate.getFromRS(dummyCouponExpiryDate, r, "coupon_expiry_date"));
tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_Company, r.getObject ("company_id")); tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_Company, r.getObject ("company_id"));
tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_BillingTeam, r.getObject ("billing_team_id")); tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_BillingTeam, r.getObject ("billing_team_id"));
tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_AddedByUser, r.getObject ("added_by_user_id")); tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_AddedByUser, r.getObject ("added_by_user_id"));
tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_PaymentPlan, r.getObject ("payment_plan_id")); tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_PaymentPlan, r.getObject ("payment_plan_id"));
tl_hiring_teamPSet.setAttrib(HiringTeam.SINGLEREFERENCE_Coupon, r.getObject ("coupon_id"));
} }
...@@ -560,10 +567,10 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr ...@@ -560,10 +567,10 @@ public class HiringTeamPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_hiring_team " + "INSERT INTO {PREFIX}tl_hiring_team " +
" (hiring_team_name, hiring_team_logo, hiring_team_type, industry, time_zone, state, country, post_code, city, has_client_support, manage_own_billing, stripe_reference, stripe_subscription, name_on_card, card_post_code, card_id, plan_renewed_on, used_credits, is_ppj, has_cap, max_cap, company_id, billing_team_id, added_by_user_id, payment_plan_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (hiring_team_name, hiring_team_logo, hiring_team_type, industry, time_zone, state, country, post_code, city, has_client_support, manage_own_billing, stripe_reference, stripe_subscription, name_on_card, card_post_code, card_id, plan_renewed_on, used_credits, is_ppj, has_cap, max_cap, coupon_expiry_date, company_id, billing_team_id, added_by_user_id, payment_plan_id, coupon_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_HiringTeamName.getForSQL(dummyHiringTeamName, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamName))).listEntry (HELPER_HiringTeamLogo.getForSQL(dummyHiringTeamLogo, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamLogo))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_TimeZone))).listEntry (HELPER_State.getForSQL(dummyState, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PostCode))).listEntry (HELPER_City.getForSQL(dummyCity, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_City))).listEntry (HELPER_HasClientSupport.getForSQL(dummyHasClientSupport, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasClientSupport))).listEntry (HELPER_ManageOwnBilling.getForSQL(dummyManageOwnBilling, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_ManageOwnBilling))).listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeReference))).listEntry (HELPER_StripeSubscription.getForSQL(dummyStripeSubscription, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeSubscription))).listEntry (HELPER_NameOnCard.getForSQL(dummyNameOnCard, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_NameOnCard))).listEntry (HELPER_CardPostCode.getForSQL(dummyCardPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardPostCode))).listEntry (HELPER_CardID.getForSQL(dummyCardID, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardID))).listEntry (HELPER_PlanRenewedOn.getForSQL(dummyPlanRenewedOn, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PlanRenewedOn))).listEntry (HELPER_UsedCredits.getForSQL(dummyUsedCredits, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_UsedCredits))).listEntry (HELPER_IsPPJ.getForSQL(dummyIsPPJ, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_IsPPJ))).listEntry (HELPER_HasCap.getForSQL(dummyHasCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasCap))).listEntry (HELPER_MaxCap.getForSQL(dummyMaxCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_MaxCap))) .listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Company)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_BillingTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_AddedByUser)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_PaymentPlan)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_HiringTeamName.getForSQL(dummyHiringTeamName, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamName))).listEntry (HELPER_HiringTeamLogo.getForSQL(dummyHiringTeamLogo, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamLogo))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_TimeZone))).listEntry (HELPER_State.getForSQL(dummyState, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PostCode))).listEntry (HELPER_City.getForSQL(dummyCity, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_City))).listEntry (HELPER_HasClientSupport.getForSQL(dummyHasClientSupport, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasClientSupport))).listEntry (HELPER_ManageOwnBilling.getForSQL(dummyManageOwnBilling, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_ManageOwnBilling))).listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeReference))).listEntry (HELPER_StripeSubscription.getForSQL(dummyStripeSubscription, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_StripeSubscription))).listEntry (HELPER_NameOnCard.getForSQL(dummyNameOnCard, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_NameOnCard))).listEntry (HELPER_CardPostCode.getForSQL(dummyCardPostCode, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardPostCode))).listEntry (HELPER_CardID.getForSQL(dummyCardID, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CardID))).listEntry (HELPER_PlanRenewedOn.getForSQL(dummyPlanRenewedOn, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_PlanRenewedOn))).listEntry (HELPER_UsedCredits.getForSQL(dummyUsedCredits, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_UsedCredits))).listEntry (HELPER_IsPPJ.getForSQL(dummyIsPPJ, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_IsPPJ))).listEntry (HELPER_HasCap.getForSQL(dummyHasCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_HasCap))).listEntry (HELPER_MaxCap.getForSQL(dummyMaxCap, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_MaxCap))).listEntry (HELPER_CouponExpiryDate.getForSQL(dummyCouponExpiryDate, tl_hiring_teamPSet.getAttrib (HiringTeam.FIELD_CouponExpiryDate))) .listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Company)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_BillingTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_AddedByUser)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_PaymentPlan)))).listEntry (SQLManager.CheckNull((Long)(tl_hiring_teamPSet.getAttrib (HiringTeam.SINGLEREFERENCE_Coupon)))) .listEntry (objectID.longID ()).toList().toArray());
tl_hiring_teamPSet.setStatus (PersistentSetStatus.PROCESSED); tl_hiring_teamPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -36,4 +36,20 @@ public class PaymentPlan extends BasePaymentPlan ...@@ -36,4 +36,20 @@ public class PaymentPlan extends BasePaymentPlan
return null; return null;
} }
public Double getAmountPerJob(HiringTeam hiringTeam)
{
if(getActiveJobCount() != null)
{
return (getAmount() / getActiveJobCount()) * (hiringTeam.getCoupon() != null ? (100 - hiringTeam.getCoupon().getPercentageOff()) * 0.01 : 1);
}
return getAmount();
}
public Double getTotalAmount(HiringTeam hiringTeam)
{
return getAmount() * (hiringTeam.getCoupon() != null ? (100 - hiringTeam.getCoupon().getPercentageOff()) * 0.01 : 1);
}
} }
\ No newline at end of file
...@@ -8,10 +8,14 @@ ...@@ -8,10 +8,14 @@
<TABLE name="tl_coupon" tablePrefix="object"> <TABLE name="tl_coupon" tablePrefix="object">
<ATTRIB name="CouponCode" type="String" dbcol="coupon_code" mandatory="true" length="100" /> <ATTRIB name="CouponCode" type="String" dbcol="coupon_code" mandatory="true" length="100" />
<ATTRIB name="PercentageOff" type="Integer" dbcol="percentage_off" /> <ATTRIB name="PercentageOff" type="Double" dbcol="percentage_off" />
<ATTRIB name="DurationInMonths" type="Integer" dbcol="duration_in_months" /> <ATTRIB name="DurationInMonths" type="Integer" dbcol="duration_in_months" />
<ATTRIB name="CouponDuration" type="CouponDuration" dbcol="coupon_duration" attribHelper="EnumeratedAttributeHelper" />
<ATTRIB name="RedeemBy" type="Date" dbcol="redeem_by" />
<ATTRIB name="MaxRedemptions" type="Integer" dbcol="max_redemptions" />
<ATTRIB name="TimesRedeemed" type="Integer" dbcol="times_redeemed" />
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="tl_coupon.object_id is not null" > <SEARCH type="All" paramFilter="tl_coupon.object_id is not null" >
......
...@@ -28,14 +28,22 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -28,14 +28,22 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private String dummyCouponCode; private String dummyCouponCode;
private Integer dummyPercentageOff; private Double dummyPercentageOff;
private Integer dummyDurationInMonths; private Integer dummyDurationInMonths;
private CouponDuration dummyCouponDuration;
private Date dummyRedeemBy;
private Integer dummyMaxRedemptions;
private Integer dummyTimesRedeemed;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_CouponCode = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_CouponCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_CouponDuration = new EnumeratedAttributeHelper (CouponDuration.FACTORY_CouponDuration);
private static final DefaultAttributeHelper HELPER_RedeemBy = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_MaxRedemptions = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_TimesRedeemed = DefaultAttributeHelper.INSTANCE;
...@@ -43,12 +51,16 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -43,12 +51,16 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
public StripeCouponPersistenceMgr () public StripeCouponPersistenceMgr ()
{ {
dummyCouponCode = (String)(HELPER_CouponCode.initialise (dummyCouponCode)); dummyCouponCode = (String)(HELPER_CouponCode.initialise (dummyCouponCode));
dummyPercentageOff = (Integer)(HELPER_PercentageOff.initialise (dummyPercentageOff)); dummyPercentageOff = (Double)(HELPER_PercentageOff.initialise (dummyPercentageOff));
dummyDurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (dummyDurationInMonths)); dummyDurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (dummyDurationInMonths));
dummyCouponDuration = (CouponDuration)(HELPER_CouponDuration.initialise (dummyCouponDuration));
dummyRedeemBy = (Date)(HELPER_RedeemBy.initialise (dummyRedeemBy));
dummyMaxRedemptions = (Integer)(HELPER_MaxRedemptions.initialise (dummyMaxRedemptions));
dummyTimesRedeemed = (Integer)(HELPER_TimesRedeemed.initialise (dummyTimesRedeemed));
} }
private String SELECT_COLUMNS = "{PREFIX}tl_coupon.object_id as id, {PREFIX}tl_coupon.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_coupon.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_coupon.coupon_code, {PREFIX}tl_coupon.percentage_off, {PREFIX}tl_coupon.duration_in_months, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_coupon.object_id as id, {PREFIX}tl_coupon.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_coupon.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_coupon.coupon_code, {PREFIX}tl_coupon.percentage_off, {PREFIX}tl_coupon.duration_in_months, {PREFIX}tl_coupon.coupon_duration, {PREFIX}tl_coupon.redeem_by, {PREFIX}tl_coupon.max_redemptions, {PREFIX}tl_coupon.times_redeemed, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -101,7 +113,11 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -101,7 +113,11 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
if (false || !tl_couponPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !tl_couponPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_CouponCode)|| !tl_couponPSet.containsAttrib(StripeCoupon.FIELD_CouponCode)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_PercentageOff)|| !tl_couponPSet.containsAttrib(StripeCoupon.FIELD_PercentageOff)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_DurationInMonths)) !tl_couponPSet.containsAttrib(StripeCoupon.FIELD_DurationInMonths)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_CouponDuration)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_RedeemBy)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_MaxRedemptions)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_TimesRedeemed))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -171,10 +187,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -171,10 +187,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_coupon " + "UPDATE {PREFIX}tl_coupon " +
"SET coupon_code = ?, percentage_off = ?, duration_in_months = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET coupon_code = ?, percentage_off = ?, duration_in_months = ?, coupon_duration = ?, redeem_by = ?, max_redemptions = ?, times_redeemed = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_coupon.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_coupon.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))).listEntry (HELPER_CouponDuration.getForSQL(dummyCouponDuration, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponDuration))).listEntry (HELPER_RedeemBy.getForSQL(dummyRedeemBy, tl_couponPSet.getAttrib (StripeCoupon.FIELD_RedeemBy))).listEntry (HELPER_MaxRedemptions.getForSQL(dummyMaxRedemptions, tl_couponPSet.getAttrib (StripeCoupon.FIELD_MaxRedemptions))).listEntry (HELPER_TimesRedeemed.getForSQL(dummyTimesRedeemed, tl_couponPSet.getAttrib (StripeCoupon.FIELD_TimesRedeemed))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -433,6 +449,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -433,6 +449,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
tl_couponPSet.setAttrib(StripeCoupon.FIELD_CouponCode, HELPER_CouponCode.getFromRS(dummyCouponCode, r, "coupon_code")); tl_couponPSet.setAttrib(StripeCoupon.FIELD_CouponCode, HELPER_CouponCode.getFromRS(dummyCouponCode, r, "coupon_code"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_PercentageOff, HELPER_PercentageOff.getFromRS(dummyPercentageOff, r, "percentage_off")); tl_couponPSet.setAttrib(StripeCoupon.FIELD_PercentageOff, HELPER_PercentageOff.getFromRS(dummyPercentageOff, r, "percentage_off"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_DurationInMonths, HELPER_DurationInMonths.getFromRS(dummyDurationInMonths, r, "duration_in_months")); tl_couponPSet.setAttrib(StripeCoupon.FIELD_DurationInMonths, HELPER_DurationInMonths.getFromRS(dummyDurationInMonths, r, "duration_in_months"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_CouponDuration, HELPER_CouponDuration.getFromRS(dummyCouponDuration, r, "coupon_duration"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_RedeemBy, HELPER_RedeemBy.getFromRS(dummyRedeemBy, r, "redeem_by"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_MaxRedemptions, HELPER_MaxRedemptions.getFromRS(dummyMaxRedemptions, r, "max_redemptions"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_TimesRedeemed, HELPER_TimesRedeemed.getFromRS(dummyTimesRedeemed, r, "times_redeemed"));
} }
...@@ -450,10 +470,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr ...@@ -450,10 +470,10 @@ public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_coupon " + "INSERT INTO {PREFIX}tl_coupon " +
" (coupon_code, percentage_off, duration_in_months, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (coupon_code, percentage_off, duration_in_months, coupon_duration, redeem_by, max_redemptions, times_redeemed, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))).listEntry (HELPER_CouponDuration.getForSQL(dummyCouponDuration, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponDuration))).listEntry (HELPER_RedeemBy.getForSQL(dummyRedeemBy, tl_couponPSet.getAttrib (StripeCoupon.FIELD_RedeemBy))).listEntry (HELPER_MaxRedemptions.getForSQL(dummyMaxRedemptions, tl_couponPSet.getAttrib (StripeCoupon.FIELD_MaxRedemptions))).listEntry (HELPER_TimesRedeemed.getForSQL(dummyTimesRedeemed, tl_couponPSet.getAttrib (StripeCoupon.FIELD_TimesRedeemed))) .listEntry (objectID.longID ()).toList().toArray());
tl_couponPSet.setStatus (PersistentSetStatus.PROCESSED); tl_couponPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class CouponDuration extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_CouponDuration = new CouponDurationFactory();
public static final CouponDuration FORVER = new CouponDuration ("FORVER", "FORVER", "Forever", false);
public static final CouponDuration ONCE = new CouponDuration ("ONCE", "ONCE", "Once", false);
public static final CouponDuration REPEATING = new CouponDuration ("REPEATING", "REPEATING", "Repeating", false);
private static final CouponDuration[] allCouponDurations =
new CouponDuration[] { FORVER,ONCE,REPEATING};
private static CouponDuration[] getAllCouponDurations ()
{
return allCouponDurations;
}
private CouponDuration (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allCouponDurations);
static
{
defineAdditionalData ();
}
public boolean isEqual (CouponDuration other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return CouponDuration.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return CouponDuration.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_CouponDuration;
}
public static CouponDuration forName (String name)
{
if (name == null) { return null; }
CouponDuration[] all = getAllCouponDurations();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static CouponDuration forValue (String value)
{
if (value == null) { return null; }
CouponDuration[] all = getAllCouponDurations();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllCouponDurations (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllCouponDurations());
}
public static CouponDuration[] getCouponDurationArray ()
{
return (CouponDuration[])getAllCouponDurations().clone ();
}
public static void defineAdditionalData ()
{
}
static class CouponDurationFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return CouponDuration.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return CouponDuration.forValue (name);
}
public Enumeration getAll ()
{
return CouponDuration.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="CouponDuration">
<VALUE name="FORVER" description="Forever" />
<VALUE name="ONCE" description="Once" />
<VALUE name="REPEATING" description="Repeating" />
</CONSTANT>
</ROOT>
\ No newline at end of file
...@@ -30,7 +30,6 @@ import oneit.security.SecUser; ...@@ -30,7 +30,6 @@ import oneit.security.SecUser;
import oneit.utils.DateDiff; import oneit.utils.DateDiff;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.Company; import performa.orm.Company;
import performa.orm.CompanyUser;
import performa.orm.HiringTeam; import performa.orm.HiringTeam;
import performa.orm.PaymentPlan; import performa.orm.PaymentPlan;
import spark.utils.IOUtils; import spark.utils.IOUtils;
...@@ -129,7 +128,7 @@ public class StripeUtils ...@@ -129,7 +128,7 @@ public class StripeUtils
} }
catch (StripeException ex) catch (StripeException ex)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while retrieving coupon in stripe coupon code: " + couponCode);
} }
return null; return null;
...@@ -139,9 +138,6 @@ public class StripeUtils ...@@ -139,9 +138,6 @@ public class StripeUtils
{ {
try try
{ {
// Subscription subscription = Subscription.retrieve(subscriptionRef);
// new Date(subscription.getCurrentPeriodEnd() * 1000)
// new Date(subscription.getCurrentPeriodStart()* 1000)
return Subscription.retrieve(subscriptionRef); return Subscription.retrieve(subscriptionRef);
} }
catch (StripeException ex) catch (StripeException ex)
...@@ -208,7 +204,7 @@ public class StripeUtils ...@@ -208,7 +204,7 @@ public class StripeUtils
} }
public static void updatePlan(HiringTeam hiringTeam) throws FieldException public static Subscription updatePlan(HiringTeam hiringTeam) throws FieldException
{ {
try try
{ {
...@@ -221,10 +217,9 @@ public class StripeUtils ...@@ -221,10 +217,9 @@ public class StripeUtils
if(hiringTeam.getStripeSubscription() != null) if(hiringTeam.getStripeSubscription() != null)
{ {
subscription = Subscription.retrieve(hiringTeam.getStripeSubscription()); subscription = Subscription.retrieve(hiringTeam.getStripeSubscription());
String subID = subscription.getSubscriptionItems().getData().get(0).getId();
itemA.put("id", subID); itemA.put("id", subscription.getSubscriptionItems().getData().get(0).getId());
itemB.put("id", subID); itemB.put("id", subscription.getSubscriptionItems().getData().get(1).getId());
} }
itemA.put("plan", paymentPlan.getStripeReference()); itemA.put("plan", paymentPlan.getStripeReference());
...@@ -236,7 +231,13 @@ public class StripeUtils ...@@ -236,7 +231,13 @@ public class StripeUtils
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("items", items); params.put("items", items);
params.put("prorate", false);
if(hiringTeam.getCoupon() != null)
{
params.put("coupon", hiringTeam.getCoupon().getCouponCode());
}
if(subscription != null) if(subscription != null)
{ {
subscription.update(params); subscription.update(params);
...@@ -251,11 +252,15 @@ public class StripeUtils ...@@ -251,11 +252,15 @@ public class StripeUtils
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Subscribing customer in stripe : ", subscription); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Subscribing customer in stripe : ", subscription);
hiringTeam.setStripeSubscription(subscription.getId()); hiringTeam.setStripeSubscription(subscription.getId());
return subscription;
} }
catch (StripeException ex) catch (StripeException ex)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating subscrition in stripe"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating subscrition in stripe");
} }
return null;
} }
......
...@@ -5807,8 +5807,8 @@ label, label .label-title span { ...@@ -5807,8 +5807,8 @@ label, label .label-title span {
margin-bottom:26px; margin-bottom:26px;
} }
.choose-plan-headings div {display: inline-block ; min-width: 125px;} .choose-plan-headings div {display: inline-block ; min-width: 125px;}
.choose-plan-headings .jobs-per-month {margin-right: 45px; } .choose-plan-headings .jobs-per-month {margin-right: 65px; }
.choose-plan-headings .cost-per-job {margin-right: 12px; } .choose-plan-headings .cost-per-job {margin-right: 50px; }
.choose-plan-headings {color: #8E97A0; font-size: 11px;margin-bottom: 10px;} .choose-plan-headings {color: #8E97A0; font-size: 11px;margin-bottom: 10px;}
...@@ -5863,7 +5863,7 @@ label, label .label-title span { ...@@ -5863,7 +5863,7 @@ label, label .label-title span {
display: block; display: block;
} }
.choose-plan-item div.jobs { .choose-plan-item div.jobs {
min-width: 140px; min-width: 170px;
} }
.choose-plan-item.active div.jobs { .choose-plan-item.active div.jobs {
color: #03A0E7; color: #03A0E7;
...@@ -5872,9 +5872,9 @@ label, label .label-title span { ...@@ -5872,9 +5872,9 @@ label, label .label-title span {
min-width: 140px; min-width: 140px;
} }
.choose-plan-item div.cost { .choose-plan-item div.cost {
min-width: 140px; min-width: 170px;
} }
.coupon-applied .choose-plan-item div.cost , .coupon-applied .choose-plan-item div.fee { .coupon-applied .choose-plan-item div.cost.discounted , .coupon-applied .choose-plan-item div.fee.discounted{
color: #67B413; color: #67B413;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
Subscription subscription = null; Subscription subscription = null;
PaymentPlan currentPlan = hiringTeam.getPaymentPlan(); PaymentPlan currentPlan = hiringTeam.getPaymentPlan();
boolean hasValidCoupon = hiringTeam.hasValidCoupon();
if(!hiringTeam.isPPJ() && currentPlan != null) if(!hiringTeam.isPPJ() && currentPlan != null)
{ {
...@@ -40,6 +41,8 @@ ...@@ -40,6 +41,8 @@
var Popup = null; var Popup = null;
$(document).ready(function() $(document).ready(function()
{ {
setTabingSideBarHeight();
recalcFunction = setupRecalc ($("form#editCompany"), {'recalcOnError':true}); recalcFunction = setupRecalc ($("form#editCompany"), {'recalcOnError':true});
Popup = new jBox('Modal', { Popup = new jBox('Modal', {
...@@ -110,21 +113,38 @@ ...@@ -110,21 +113,38 @@
<oneit:ormInput obj="<%= hiringTeam %>" type="text" attributeName="CouponCode" placeholder="Coupon Code" cssClass="form-control" /> <oneit:ormInput obj="<%= hiringTeam %>" type="text" attributeName="CouponCode" placeholder="Coupon Code" cssClass="form-control" />
<oneit:button value="APPLY" name="applyCoupon" cssClass="btn btn-input-inside" <oneit:button value="APPLY" name="applyCoupon" cssClass="btn btn-input-inside"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("HiringTeam", hiringTeam) .mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap())
.mapEntry ("attribNamesToRestore", Collections.singleton("HiringTeam"))
.toMap() %>" /> .toMap() %>" />
</div> </div>
</div> </div>
<div class="coupon-applied-alert"> <%
coupon applied if(hasValidCoupon)
<span class="coupon_code"> {
<oneit:toString value="ABCD123" mode="EscapeHTML"/> - save StripeCoupon coupon = hiringTeam.getCoupon();
<oneit:toString value="10%" mode="EscapeHTML"/> %>
</span> <div class="coupon-applied-alert">
<span class="expire"> coupon applied
Expires <span class="coupon_code">
<oneit:toString value="18 Sep 2018" mode="EscapeHTML"/> <oneit:toString value="<%= coupon.getCouponCode()%>" mode="EscapeHTML"/> - save
</span> <oneit:toString value="<%= coupon.getPercentageOff()%>" mode="PercentageWholeNumber"/>
</div> </span>
<%
if(hiringTeam.getCouponExpiryDate() != null)
{
%>
<span class="expire">
Expires
<oneit:toString value="<%= hiringTeam.getCouponExpiryDate() %>" mode="MidDate"/>
</span>
<%
}
%>
</div>
<%
}
%>
<div class="form-group row"> <div class="form-group row">
<div class="col-md-12 oneit-radio coupon-applied"> <div class="col-md-12 oneit-radio coupon-applied">
<div class="rectangle-5"> <div class="rectangle-5">
...@@ -142,10 +162,10 @@ ...@@ -142,10 +162,10 @@
</div> </div>
<div class="manage-plan-payplan"> <div class="manage-plan-payplan">
<div class="per-job-amount"> <div class="per-job-amount">
<oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/>/ Job <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="CurrencyDollarsOnly"/>/ Job
</div> </div>
<div class="per-job-amount-past"> <div class="per-job-amount-past">
was <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/> per job was <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="CurrencyDollarsOnly"/> per job
</div> </div>
</div> </div>
<div class="clearboth"></div> <div class="clearboth"></div>
...@@ -196,7 +216,7 @@ ...@@ -196,7 +216,7 @@
Choose Your Plan Choose Your Plan
</div> </div>
<div class="choose-plan-headings"> <div class="choose-plan-headings">
<div class="jobs-per-month">Jobe Per Month</div> <div class="jobs-per-month">Jobs Per Month</div>
<div class="cost-per-job">Cost Per Job</div> <div class="cost-per-job">Cost Per Job</div>
<div class="monthly-fee">Monthly Fee</div> <div class="monthly-fee">Monthly Fee</div>
</div> </div>
...@@ -209,17 +229,31 @@ ...@@ -209,17 +229,31 @@
<div class="jobs"> <div class="jobs">
<%= paymentPlan.getActiveJobCount() %> Jobs <%= paymentPlan.getActiveJobCount() %> Jobs
</div> </div>
<div class="cost"> <div class="cost <%= hasValidCoupon ? "discounted" : ""%>">
<oneit:toString value="<%= paymentPlan.getAmount() / paymentPlan.getActiveJobCount() %>" mode="Currency"/> <oneit:toString value="<%= paymentPlan.getAmountPerJob(hiringTeam) %>" mode="CurrencyDollarsOnly"/>
<span class="past-val"> <%
was <oneit:toString value="<%= 270.00 %>" mode="Currency"/> if(hasValidCoupon)
</span> {
%>
<span class="past-val">
Was <oneit:toString value="<%= paymentPlan.getAmount() / paymentPlan.getActiveJobCount() %>" mode="CurrencyDollarsOnly"/>
</span>
<%
}
%>
</div> </div>
<div class="fee"> <div class="fee <%= hasValidCoupon ? "discounted" : ""%>">
<oneit:toString value="<%= paymentPlan.getAmount() %>" mode="Currency"/><span class="month"> / month </span> <oneit:toString value="<%= paymentPlan.getTotalAmount(hiringTeam) %>" mode="CurrencyDollarsOnly"/><span class="month"> / month </span>
<span class="past-val"> <%
was <oneit:toString value="<%= 2700.00 %>" mode="Currency"/> if(hasValidCoupon)
</span> {
%>
<span class="past-val">
Was <oneit:toString value="<%= paymentPlan.getAmount() %>" mode="CurrencyDollarsOnly"/>
</span>
<%
}
%>
</div> </div>
<div class="select-button"> <div class="select-button">
<% <%
...@@ -247,10 +281,10 @@ ...@@ -247,10 +281,10 @@
{ {
%> %>
Upgrading your plan to <%= paymentPlan.getActiveJobCount() %> Jobs per month will incur an additional cost of Upgrading your plan to <%= paymentPlan.getActiveJobCount() %> Jobs per month will incur an additional cost of
<%= FormatUtils.stringify(paymentPlan.getAmount() - currentPlan.getAmount(), "Currency", "") %> be billed immediately. <%= FormatUtils.stringify(paymentPlan.getAmount() - currentPlan.getAmount(), "CurrencyDollarsOnly", "") %> be billed immediately.
<span> <span>
This cost is to cover the difference between your current active <%= currentPlan.getActiveJobCount() %> job plan (<%= FormatUtils.stringify(currentPlan.getAmount(), "Currency", "") %>) This cost is to cover the difference between your current active <%= currentPlan.getActiveJobCount() %> job plan (<%= FormatUtils.stringify(currentPlan.getAmount(), "Currency", "") %>)
and the new <%= paymentPlan.getActiveJobCount() %> job plan (<%= FormatUtils.stringify(paymentPlan.getAmount(), "Currency", "") %>). and the new <%= paymentPlan.getActiveJobCount() %> job plan (<%= FormatUtils.stringify(paymentPlan.getAmount(), "CurrencyDollarsOnly", "") %>).
</span> </span>
<% <%
} }
...@@ -276,7 +310,7 @@ ...@@ -276,7 +310,7 @@
</div> </div>
<div class="list-item"> <div class="list-item">
<span class="item-title">Date of next billing period</span> <span class="item-title">Date of next billing period</span>
<span class="item-value"><%= FormatUtils.stringify(paymentPlan.getAmount(), "Currency", "") %> on <oneit:toString value="<%= new Date(subscription.getCurrentPeriodEnd() * 1000) %>" mode="LongDate"/></span> <span class="item-value"><%= FormatUtils.stringify(paymentPlan.getAmount(), "CurrencyDollarsOnly", "") %> on <oneit:toString value="<%= new Date(subscription.getCurrentPeriodEnd() * 1000) %>" mode="LongDate"/></span>
</div> </div>
</div> </div>
<div class="upgrade-info"> <div class="upgrade-info">
...@@ -289,6 +323,11 @@ ...@@ -289,6 +323,11 @@
<a class="change-plan-no-button popup-no-button">No</a> <a class="change-plan-no-button popup-no-button">No</a>
<oneit:button skin="link" value="Yes" name="saveCompany" cssClass="change-plan-yes-button" <oneit:button skin="link" value="Yes" name="saveCompany" cssClass="change-plan-yes-button"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("IsPayment", Boolean.TRUE)
.mapEntry ("PaymentPlan", paymentPlan)
.mapEntry ("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap())
.mapEntry ("attribNamesToRestore", Collections.singleton("HiringTeam"))
.toMap() %>" /> .toMap() %>" />
</div> </div>
...@@ -300,6 +339,7 @@ ...@@ -300,6 +339,7 @@
%> %>
<oneit:button skin="link" value="Select" name="saveCompany" cssClass="btn select-btn" <oneit:button skin="link" value="Select" name="saveCompany" cssClass="btn select-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("IsPayment", Boolean.TRUE) .mapEntry ("IsPayment", Boolean.TRUE)
.mapEntry ("PaymentPlan", paymentPlan) .mapEntry ("PaymentPlan", paymentPlan)
.mapEntry ("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap()) .mapEntry ("procParams", CollectionUtils.mapEntry("HiringTeam", hiringTeam).toMap())
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">tl_hiring_team</tableName>
<column name="coupon_id" type="Long" length="11" nullable="true"/>
<column name="coupon_expiry_date" type="Date" nullable="true"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun --> <!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_coupon</tableName> <tableName factory="String">tl_coupon</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="coupon_code" type="String" nullable="false" length="100"/> <column name="coupon_code" type="String" nullable="false" length="100"/>
<column name="percentage_off" type="Long" nullable="true"/> <column name="percentage_off" type="Double" nullable="true"/>
<column name="duration_in_months" type="Long" nullable="true"/> <column name="duration_in_months" type="Long" nullable="true"/>
</NODE> <column name="coupon_duration" type="String" nullable="true" length="200"/>
<column name="redeem_by" type="Date" nullable="true"/>
<column name="max_redemptions" type="Long" nullable="true"/>
<column name="times_redeemed" type="Long" nullable="true"/>
</NODE>
</NODE></OBJECTS> </NODE>
\ No newline at end of file </OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment