Commit 2472b185 by Nilu

cancelling subscription at the end of period if moved to ppj. show cap value…

cancelling subscription at  the end of period if moved to ppj. show cap value only if toggle is selected to set cap
parent 72e359bf
......@@ -49,9 +49,24 @@ public class SaveCompanyFP extends SaveFP
}
}
if(CollectionUtils.equals(isPayment, Boolean.TRUE))
if(hiringTeam.getIsPPJ())
{
Subscription subscription = StripeUtils.retrieveSubscription(hiringTeam.getStripeSubscription());
if(subscription != null)
{
StripeUtils.cancelSubscription(subscription);
hiringTeam.setPaymentPlan(null);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP cancelling a subscription in Stripe since moving to PPJ : ", subscription );
}
}
if(CollectionUtils.equals(isPayment, Boolean.TRUE))
{
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Hiring Team payment plan updated.", hiringTeam, " payment plan: ", hiringTeam.getPaymentPlan());
if(hiringTeam.getCardID() == null)
......@@ -96,7 +111,11 @@ public class SaveCompanyFP extends SaveFP
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Stripe subscription updated.", hiringTeam, hiringTeam.getStripeSubscription());
}
//
if(!hiringTeam.isTrue(hiringTeam.getHasCap()))
{
hiringTeam.setMaxCap(null);
}
// // Update company in intercom
// IntercomUtils.updateCompany(company);
......
......@@ -287,7 +287,7 @@ public class StripeUtils
}
public static void recordUsage(HiringTeam hiringTeam)
public static void recordUsage(HiringTeam hiringTeam) throws BusinessException
{
try
{
......@@ -305,7 +305,28 @@ public class StripeUtils
}
catch (StripeException ex)
{
Logger.getLogger(StripeUtils.class.getName()).log(Level.SEVERE, null, ex);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while recoding usage in stripe for hiring team: "+ hiringTeam);
throw new BusinessException("Problem with opening your job. Please contact adminstrator for more info.");
}
}
public static void cancelSubscription(Subscription subscription) throws BusinessException
{
try
{
Map<String, Object> params = new HashMap<>();
params.put("cancel_at_period_end", true);
subscription.update(params);
}
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while cancelling subscription in stripe : "+ subscription);
throw new BusinessException("Problem with cancelling your subscription. Please contact adminstrator for more info.");
}
}
......
......@@ -185,7 +185,7 @@ System.out.println(subscription);
<div class="manage-plan-row">
<div class="radio">
<label>
<oneit:ormInput obj="<%= hiringTeam %>" type="radio" attributeName="IsPPJ" value="false" onchange="paymentPlanChanged()"/>
<oneit:ormInput obj="<%= hiringTeam %>" type="radio" attributeName="IsPPJ" value="false"/>
</label>
</div>
<div class="manage-plan-title">
......@@ -380,16 +380,15 @@ System.out.println(subscription);
</div>
</div>
<div class="setmax">
<div>
<oneit:recalcClass htmlTag="div" classScript="hiringTeam.isTrue(hiringTeam.getHasCap()) ? 'show': 'hide'" hiringTeam="<%= hiringTeam %>">
<oneit:ormInput obj="<%= hiringTeam %>" type="text" attributeName="MaxCap" cssClass="form-control" />
<oneit:button value="Set Max" name="saveCompany" cssClass="btn btn-primary"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.toMap() %>" />
</oneit:recalcClass>
</div>
</div>
</div>
</div>
</div>
</div>
......
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