Commit de28186a by Nilu

fix issues with credit upgrades

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