Commit de28186a by Nilu

fix issues with credit upgrades

parent d0ff2a80
package performa.form;
import com.stripe.Stripe;
import java.util.HashMap;
import java.util.Map;
import oneit.appservices.config.ConfigMgr;
......@@ -104,8 +103,8 @@ public class MakePaymentFP extends SaveFP
if(!ppj && company.getPaymentPlan() != null)
{
// cannot subscribe to a plan without card details
company.setPlanRenewedOn(DateDiff.getToday());
company.setUsedCredits(1);
// company.setPlanRenewedOn(DateDiff.getToday());
// company.setUsedCredits(1);
StripeUtils.updatePlan(company);
}
......
......@@ -119,6 +119,11 @@ public class SaveJobFP extends SaveFP
if(status != null && status == JobStatus.OPEN)
{
BusinessObjectParser.assertFieldCondition(company.getSelectedPaymentPlan() != null || company.getPaymentPlan() != null, company, Company.SINGLEREFERENCE_PaymentPlan, "mandatory", exceptions, true, request);
if(company.getSelectedPaymentPlan() != null)
{
BusinessObjectParser.assertFieldCondition(company.getSelectedPaymentPlan().getActiveJobCount() > company.getUsedCredits() , job, Job.FIELD_JobStatus, "insufficientCredit", exceptions, true, request);
}
}
if(job.getJobStatus() == JobStatus.OPEN)
......
......@@ -12,7 +12,6 @@ import com.stripe.model.Event;
import com.stripe.model.Invoice;
import com.stripe.model.Plan;
import com.stripe.model.Subscription;
import com.stripe.net.APIResource;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
......@@ -20,6 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oneit.appservices.config.ConfigMgr;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
......@@ -227,7 +227,7 @@ public class StripeUtils
{
String rawJson = IOUtils.toString(request.getInputStream());
Event event = APIResource.GSON.fromJson(rawJson, Event.class);
Event event = Event.GSON.fromJson(rawJson, Event.class);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Event received from stripe : ", event);
......
......@@ -108,7 +108,7 @@
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'select-plan enabled': 'select-plan disabled'" company="<%= company %>">
<oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green save-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", paymentPage)
.mapEntry("PPJ", Boolean.TRUE)
.mapEntry("PPJ", Boolean.FALSE)
.mapEntry ("fromPage", fromPage)
.mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("restartProcess", Boolean.TRUE)
......
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