Commit 8c2fa209 by chenith

HT015: Manage payment for the Company

parent 678e69b4
......@@ -5,12 +5,14 @@ import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils;
import oneit.utils.MultiException;
import performa.intercom.utils.IntercomUtils;
import performa.orm.Company;
......@@ -22,6 +24,7 @@ public class SaveCompanyFP extends SaveFP
{
HttpServletRequest request = submission.getRequest();
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 );
......@@ -32,9 +35,33 @@ public class SaveCompanyFP extends SaveFP
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
IntercomUtils.updateCompany(company);
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,9 +51,12 @@ public class SaveJobFP extends SaveFP
if(status == JobStatus.OPEN)
{
job.setJobStatus(status);
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 );
}
}
......@@ -108,7 +111,7 @@ public class SaveJobFP extends SaveFP
CompanyUser companyUser = loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
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);
......
......@@ -5989,7 +5989,7 @@ input{
.payment-type-row{
padding-top: 30px;
padding-bottom: 80px;
padding-bottom: 70px;
}
.active-jobs-per-mont {
......@@ -6047,6 +6047,7 @@ input{
font-family: "Usual-Light";
font-size: 12px;
font-style: italic;
padding-top: 20px;
}
.payment-paln-count{
......@@ -6055,3 +6056,38 @@ input{
text-align: center;
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 @@
PaymentPlan[] plans = Utils.getPaymentPlansForJobs(transaction);
Integer maxCount = 0;
Integer minCount = 0;
Integer curCount = company.getPaymentPlan()!=null ? company.getPaymentPlan().getActiveJobCount() : 0;
if(company.getPaymentPlan()!=null && company.getPaymentJobCount()==null)
{
......@@ -37,7 +36,26 @@
$(document).ready(function()
{
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>
<oneit:form name="editJob" method="post" enctype="multipart/form-data">
......@@ -60,7 +78,7 @@
<div class="active-jobs-per-mont">
Active Jobs Per Month
</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"/>
</div>
<div class="col-md-6 col-sm-6 col-xs-6 text-left">
......@@ -79,10 +97,8 @@
</div>
</div>
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<div class="a-label-row text-center">
<oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green"
<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)
......@@ -90,22 +106,26 @@
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
</div>
<div class="a-label-row text-center">
<div class="col-md-4 col-sm-4 col-xs-4">
</div>
<div class="col-md-4 col-sm-4 col-xs-4 payment-job-det text-center">
<oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/>
<div class="col-md-6 col-sm-6 col-xs-6 text-center">
<div class="payment-job-det ">
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<oneit:recalc mode="EscapeHTML" script="company.getPaymentPlanAmount()" company="<%= company %>" nullValue=""/>
Monthly for up to
<oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/>
jobs / month
Save
<oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/>
per month
</oneit:recalcClass>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
</div>
<div class="col-md-2 col-sm-2 col-xs-2">
</div>
</div>
</oneit:recalcClass>
</div>
<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