Commit 8c2fa209 by chenith

HT015: Manage payment for the Company

parent 678e69b4
...@@ -5,12 +5,14 @@ import javax.servlet.http.HttpServletRequest; ...@@ -5,12 +5,14 @@ import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
import oneit.logging.LogMgr; import oneit.logging.LogMgr;
import oneit.objstore.StorageException; import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.servlets.forms.SubmissionDetails; import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult; import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState; import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP; import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException; import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils; import oneit.utils.CollectionUtils;
import oneit.utils.MultiException;
import performa.intercom.utils.IntercomUtils; import performa.intercom.utils.IntercomUtils;
import performa.orm.Company; import performa.orm.Company;
...@@ -20,8 +22,9 @@ public class SaveCompanyFP extends SaveFP ...@@ -20,8 +22,9 @@ public class SaveCompanyFP 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();
Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company"); Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP saving company : ", company ); LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP saving company : ", company );
...@@ -30,11 +33,35 @@ public class SaveCompanyFP extends SaveFP ...@@ -30,11 +33,35 @@ public class SaveCompanyFP extends SaveFP
company.setCompanyLogo(null); company.setCompanyLogo(null);
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP setting comany logo to null of company : ", company ); LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP setting comany logo to null of company : ", company );
} }
if(CollectionUtils.equals(isPayment, Boolean.TRUE) && company.getPaymentJobCount()!=null)
{
company.setPaymentPlan(company.getSelectedPaymentPlan());
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"Company payment plan updated.", company, company.getPaymentPlan());
}
// Update company in intercom // Update company in intercom
IntercomUtils.updateCompany(company); IntercomUtils.updateCompany(company);
return super.processForm(process, submission, params); return super.processForm(process, submission, params);
} }
@Override
public void validate(ORMProcessState process, SubmissionDetails submission, MultiException exceptions, Map params) throws StorageException
{
HttpServletRequest request = submission.getRequest();
Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
//to select payment plan when job open
if(CollectionUtils.equals(isPayment, Boolean.TRUE) && company.getPaymentJobCount()!=null)
{
BusinessObjectParser.assertFieldCondition(company.getSelectedPaymentPlan()!= null, company , Company.SINGLEREFERENCE_PaymentPlan, "mandatory", exceptions, true, request);
}
super.validate(process, submission, exceptions, params);
}
} }
\ No newline at end of file
...@@ -51,8 +51,11 @@ public class SaveJobFP extends SaveFP ...@@ -51,8 +51,11 @@ public class SaveJobFP extends SaveFP
if(status == JobStatus.OPEN) if(status == JobStatus.OPEN)
{ {
job.setJobStatus(status);
company.setPaymentPlan(company.getSelectedPaymentPlan()); company.setPaymentPlan(company.getSelectedPaymentPlan());
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"Company payment plan updated.", job, company, company.getPaymentPlan());
job.setJobStatus(status);
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"Job status changed as Open. ", job ); LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"Job status changed as Open. ", job );
} }
...@@ -108,7 +111,7 @@ public class SaveJobFP extends SaveFP ...@@ -108,7 +111,7 @@ public class SaveJobFP extends SaveFP
CompanyUser companyUser = loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser); CompanyUser companyUser = loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
Company company = companyUser.getCompany(); Company company = companyUser.getCompany();
BusinessObjectParser.assertFieldCondition(company.getSelectedPaymentPlan()!= null, job , Company.SINGLEREFERENCE_PaymentPlan, "mandatory", exceptions, true, request); BusinessObjectParser.assertFieldCondition(company.getSelectedPaymentPlan()!= null, company, Company.SINGLEREFERENCE_PaymentPlan, "mandatory", exceptions, true, request);
} }
super.validate(process, submission, exceptions, params); super.validate(process, submission, exceptions, params);
......
...@@ -5989,7 +5989,7 @@ input{ ...@@ -5989,7 +5989,7 @@ input{
.payment-type-row{ .payment-type-row{
padding-top: 30px; padding-top: 30px;
padding-bottom: 80px; padding-bottom: 70px;
} }
.active-jobs-per-mont { .active-jobs-per-mont {
...@@ -6047,6 +6047,7 @@ input{ ...@@ -6047,6 +6047,7 @@ input{
font-family: "Usual-Light"; font-family: "Usual-Light";
font-size: 12px; font-size: 12px;
font-style: italic; font-style: italic;
padding-top: 20px;
} }
.payment-paln-count{ .payment-paln-count{
...@@ -6054,4 +6055,39 @@ input{ ...@@ -6054,4 +6055,39 @@ input{
font-size: 24px; font-size: 24px;
text-align: center; text-align: center;
margin-top: 6px; margin-top: 6px;
}
.payment-grey-area{
height: 370px;
}
.pay-subsc-row{
vertical-align: middle;
}
.pay-subsc-txt{
margin-top: 7px;
}
.pay-subsc-amt {
color: #03A0E7;
font-family: "Usual-Light";
font-size: 16px;
}
.pay-subsc-det {
color: #777777;
font-family: "Usual-Light";
font-size: 12px;
font-style: italic;
margin-top: 6px;
}
.pay-subsc-det-row{
padding-top: 50px;
margin-bottom: 70px;
}
.pay-subsc-btn-row{
padding-bottom: 40px;
} }
\ No newline at end of file
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
PaymentPlan[] plans = Utils.getPaymentPlansForJobs(transaction); PaymentPlan[] plans = Utils.getPaymentPlansForJobs(transaction);
Integer maxCount = 0; Integer maxCount = 0;
Integer minCount = 0; Integer minCount = 0;
Integer curCount = company.getPaymentPlan()!=null ? company.getPaymentPlan().getActiveJobCount() : 0;
if(company.getPaymentPlan()!=null && company.getPaymentJobCount()==null) if(company.getPaymentPlan()!=null && company.getPaymentJobCount()==null)
{ {
...@@ -37,7 +36,26 @@ ...@@ -37,7 +36,26 @@
$(document).ready(function() $(document).ready(function()
{ {
recalcFunction = setupRecalc ($("form"), {'recalcOnError':true}); recalcFunction = setupRecalc ($("form"), {'recalcOnError':true});
validate();
$('input').on('change keyup', function() { validate() });
}); });
function validate() {
var empty = false;
$('input[required]').each(function() {
if ($( this ).val() == '') {
empty = true;
}
});
if (empty) {
$('.save-btn').attr('disabled', 'disabled');
} else {
$('.save-btn').removeAttr('disabled');
}
}
</script> </script>
<oneit:form name="editJob" method="post" enctype="multipart/form-data"> <oneit:form name="editJob" method="post" enctype="multipart/form-data">
...@@ -60,7 +78,7 @@ ...@@ -60,7 +78,7 @@
<div class="active-jobs-per-mont"> <div class="active-jobs-per-mont">
Active Jobs Per Month Active Jobs Per Month
</div> </div>
<oneit:ormInput type="number" obj="<%= company %>" attributeName="PaymentJobCount" <oneit:ormInput type="number" obj="<%= company %>" attributeName="PaymentJobCount" required="true"
min="<%= minCount %>" max="<%= maxCount %>" step="1" cssClass="payment-paln-count"/> min="<%= minCount %>" max="<%= maxCount %>" step="1" cssClass="payment-paln-count"/>
</div> </div>
<div class="col-md-6 col-sm-6 col-xs-6 text-left"> <div class="col-md-6 col-sm-6 col-xs-6 text-left">
...@@ -79,33 +97,35 @@ ...@@ -79,33 +97,35 @@
</div> </div>
</div> </div>
<div class="a-label-row text-center">
<oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green save-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("fromPage", fromPage)
.mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
</div>
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>"> <div class="a-label-row text-center">
<div class="a-label-row text-center"> <div class="col-md-4 col-sm-4 col-xs-4">
<oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("fromPage", fromPage)
.mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
</div> </div>
<div class="a-label-row text-center"> <div class="col-md-6 col-sm-6 col-xs-6 text-center">
<div class="col-md-4 col-sm-4 col-xs-4"> <div class="payment-job-det ">
</div> <oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<div class="col-md-4 col-sm-4 col-xs-4 payment-job-det text-center"> <oneit:recalc mode="EscapeHTML" script="company.getPaymentPlanAmount()" company="<%= company %>" nullValue=""/>
<oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/> Monthly for up to
Monthly for up to <oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/>
<oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/> jobs / month
jobs / month Save
Save <oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/>
<oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/> per month
per month </oneit:recalcClass>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
</div> </div>
</div> </div>
</oneit:recalcClass> <div class="col-md-2 col-sm-2 col-xs-2">
</div>
</div>
</div> </div>
<div class="form-page-area payment-optio-sep"> <div class="form-page-area payment-optio-sep">
......
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