Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PERFORMA_REPLICA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
PERFORMA_REPLICA
Commits
924d0d1d
Commit
924d0d1d
authored
Oct 31, 2018
by
Nilu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reporting usage when on overage plan
parent
2472b185
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
66 deletions
+115
-66
MakePaymentFP.java
cmsWebApp/src/performa/form/MakePaymentFP.java
+19
-22
SaveCompanyFP.java
cmsWebApp/src/performa/form/SaveCompanyFP.java
+12
-0
SaveJobFP.java
cmsWebApp/src/performa/form/SaveJobFP.java
+27
-14
HiringTeam.java
cmsWebApp/src/performa/orm/HiringTeam.java
+6
-0
WebUtils.java
cmsWebApp/src/performa/utils/WebUtils.java
+1
-0
job_review_submit.jsp
...bApp/webroot/extensions/adminportal/job_review_submit.jsp
+47
-29
manage_plan.jsp
cmsWebApp/webroot/extensions/adminportal/manage_plan.jsp
+3
-1
No files found.
cmsWebApp/src/performa/form/MakePaymentFP.java
View file @
924d0d1d
...
...
@@ -18,12 +18,9 @@ import com.stripe.model.Card;
import
com.stripe.model.Charge
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
oneit.logging.LoggingArea
;
import
oneit.security.SecUser
;
import
oneit.utils.DateDiff
;
import
performa.intercom.utils.IntercomUtils
;
import
performa.orm.Company
;
import
performa.orm.CompanyUser
;
import
performa.orm.HiringTeam
;
...
...
@@ -51,7 +48,7 @@ public class MakePaymentFP extends SaveFP
CompanyUser
companyUser
=
secUser
.
getExtension
(
CompanyUser
.
REFERENCE_CompanyUser
);
Company
company
=
companyUser
.
getCompany
();
Job
job
=
(
Job
)
process
.
getAttribute
(
"Job"
);
HiringTeam
hiringTeam
=
(
HiringTeam
)
process
.
getAttribute
(
"HiringTeam"
);
HiringTeam
hiringTeam
=
(
HiringTeam
)
process
.
getAttribute
(
"HiringTeam"
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"In MakePaymentFP from customer to open job: "
+
company
.
getStripeReference
());
...
...
@@ -65,7 +62,7 @@ public class MakePaymentFP extends SaveFP
ReplaceCardFP
.
replaceCardDetails
(
process
,
submission
);
}
if
(
company
.
getCardID
()
!=
null
&&
ppj
)
if
(
hiringTeam
.
getCardID
()
!=
null
&&
hiringTeam
.
isTrue
(
hiringTeam
.
getIsPPJ
())
)
{
try
{
...
...
@@ -73,7 +70,7 @@ public class MakePaymentFP extends SaveFP
chargeParams
.
put
(
"amount"
,
NullArith
.
intVal
(
NullArith
.
multiply
(
job
.
getAssessmentType
()
==
AssessmentType
.
COMPREHENSIVE
?
499.0
:
399.0
,
100
,
0
d
)));
chargeParams
.
put
(
"currency"
,
"aud"
);
chargeParams
.
put
(
"description"
,
"Charges of creating job"
);
chargeParams
.
put
(
"customer"
,
company
.
getStripeReference
());
chargeParams
.
put
(
"customer"
,
hiringTeam
.
getStripeReference
());
Charge
.
create
(
chargeParams
);
}
...
...
@@ -85,7 +82,7 @@ public class MakePaymentFP extends SaveFP
}
}
if
(
company
.
getCardID
()
==
null
)
if
(
hiringTeam
.
getCardID
()
==
null
)
{
Card
card
=
StripeUtils
.
retrieveCard
(
hiringTeam
);
...
...
@@ -98,7 +95,7 @@ public class MakePaymentFP extends SaveFP
job
.
setOpenDate
(
new
Date
());
job
.
setJobStatus
(
JobStatus
.
OPEN
);
job
.
setLastEdited
(
new
Date
());
job
.
setIsPPJ
(
ppj
);
job
.
setIsPPJ
(
hiringTeam
.
getIsPPJ
()
);
if
(
job
.
getShortenedURL
()
==
null
)
{
...
...
@@ -116,20 +113,20 @@ public class MakePaymentFP extends SaveFP
// restarting process as custom attributes needs to be updated to intercom
Set
<
String
>
attribsToRestore
=
new
HashSet
<>();
attribsToRestore
.
add
(
"Job"
);
attribsToRestore
.
add
(
"Company"
);
completeProcessRestartAndRestoreAttribs
(
process
,
attribsToRestore
);
secUser
=
SecUser
.
getTXUser
(
process
.
getTransaction
());
companyUser
=
secUser
.
getExtension
(
CompanyUser
.
REFERENCE_CompanyUser
);
// Update company in intercom
if
(
companyUser
.
getCompany
()
!=
null
)
{
IntercomUtils
.
updateCompany
(
companyUser
.
getCompany
());
}
//
Set<String> attribsToRestore = new HashSet<>();
//
attribsToRestore.add("Job");
//
attribsToRestore.add("Company");
//
//
completeProcessRestartAndRestoreAttribs(process, attribsToRestore);
//
//
secUser = SecUser.getTXUser(process.getTransaction());
//
companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
//
//
// Update company in intercom
//
if(companyUser.getCompany() != null)
//
{
//
IntercomUtils.updateCompany(companyUser.getCompany());
//
}
return
super
.
processForm
(
process
,
submission
,
p
);
}
...
...
cmsWebApp/src/performa/form/SaveCompanyFP.java
View file @
924d0d1d
...
...
@@ -116,6 +116,18 @@ public class SaveCompanyFP extends SaveFP
{
hiringTeam
.
setMaxCap
(
null
);
}
if
(
hiringTeam
.
isTrue
(
hiringTeam
.
getHasCap
())
&&
hiringTeam
.
getPaymentPlan
()
!=
null
)
{
if
(
hiringTeam
.
getMaxCap
()
==
null
)
{
hiringTeam
.
setMaxCap
(
hiringTeam
.
getPaymentPlan
().
getActiveJobCount
());
}
else
if
(
hiringTeam
.
getMaxCap
()
<
hiringTeam
.
getPaymentPlan
().
getActiveJobCount
())
{
throw
new
BusinessException
(
"Cap should be greater than the number of jobs of the selected plan"
);
}
}
// // Update company in intercom
// IntercomUtils.updateCompany(company);
...
...
cmsWebApp/src/performa/form/SaveJobFP.java
View file @
924d0d1d
...
...
@@ -20,6 +20,7 @@ import oneit.utils.math.NullArith;
import
performa.intercom.utils.IntercomUtils
;
import
performa.orm.*
;
import
performa.orm.types.*
;
import
performa.utils.StripeUtils
;
public
class
SaveJobFP
extends
SaveFP
...
...
@@ -34,6 +35,7 @@ public class SaveJobFP extends SaveFP
SecUser
secUser
=
SecUser
.
getTXUser
(
process
.
getTransaction
());
CompanyUser
companyUser
=
secUser
.
getExtension
(
CompanyUser
.
REFERENCE_CompanyUser
);
Company
company
=
companyUser
.
getCompany
();
HiringTeam
hiringTeam
=
job
.
getHiringTeam
();
LogMgr
.
log
(
Job
.
LOG
,
LogLevel
.
PROCESSING1
,
"In SaveJobFP saving job : "
,
job
);
...
...
@@ -51,16 +53,26 @@ public class SaveJobFP extends SaveFP
job
.
setApplyBy
(
DateDiff
.
add
(
DateDiff
.
getToday
(),
Calendar
.
DATE
,
30
));
job
.
setOpenDate
(
new
Date
());
company
.
setUsedCredits
(
NullArith
.
add
(
company
.
getUsedCredits
(),
1
).
intValue
());
if
(!
hiringTeam
.
canCreateJob
())
{
throw
new
BusinessException
(
"Please change payment plan settings to open this job"
);
}
hiringTeam
.
setUsedCredits
(
NullArith
.
add
(
hiringTeam
.
getUsedCredits
(),
1
).
intValue
());
if
(
hiringTeam
.
getUsedCredits
()
>
hiringTeam
.
getAvailableCredits
())
{
StripeUtils
.
recordUsage
(
hiringTeam
);
}
if
(
status
==
JobStatus
.
OPEN
)
{
if
(
company
.
getSelectedPaymentPlan
()
!=
null
)
{
company
.
setPaymentPlan
(
company
.
getSelectedPaymentPlan
());
LogMgr
.
log
(
Company
.
LOG
,
LogLevel
.
PROCESSING1
,
"Company payment plan updated."
,
job
,
company
,
company
.
getPaymentPlan
());
}
// if(hiringTeam
.getSelectedPaymentPlan() != null)
//
{
//
company.setPaymentPlan(company.getSelectedPaymentPlan());
//
//
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"Company payment plan updated.", job, company, company.getPaymentPlan());
//
}
job
.
setJobStatus
(
status
);
...
...
@@ -115,6 +127,7 @@ public class SaveJobFP extends SaveFP
SecUser
loggedInUser
=
SecUser
.
getTXUser
(
process
.
getTransaction
());
CompanyUser
companyUser
=
loggedInUser
.
getExtension
(
CompanyUser
.
REFERENCE_CompanyUser
);
Company
company
=
companyUser
.
getCompany
();
HiringTeam
hiringTeam
=
job
.
getHiringTeam
();
if
(
job
.
getJobStatus
()
!=
JobStatus
.
DRAFT
||
openJob
==
Boolean
.
TRUE
)
{
...
...
@@ -129,19 +142,19 @@ public class SaveJobFP extends SaveFP
//to select payment plan when job 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(company.getSelectedPaymentPlan() != null)
//
{
BusinessObjectParser
.
assertFieldCondition
(
hiringTeam
.
canCreateJob
()
,
job
,
Job
.
FIELD_JobStatus
,
"insufficientCredit"
,
exceptions
,
true
,
request
);
//
}
}
if
(
job
.
getJobStatus
()
==
JobStatus
.
OPEN
)
{
BusinessObjectParser
.
assertFieldCondition
(
company
.
getCardID
()
!=
null
,
company
,
Company
.
FIELD_CardID
,
"mandatoryCardDetails"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(
hiringTeam
.
getCardID
()
!=
null
,
hiringTeam
,
HiringTeam
.
FIELD_CardID
,
"mandatoryCardDetails"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(
company
.
canCreateJob
()
,
job
,
Job
.
FIELD_JobStatus
,
"insufficientCredit"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(
hiringTeam
.
canCreateJob
()
,
job
,
Job
.
FIELD_JobStatus
,
"insufficientCredit"
,
exceptions
,
true
,
request
);
}
super
.
validate
(
process
,
submission
,
exceptions
,
params
);
...
...
cmsWebApp/src/performa/orm/HiringTeam.java
View file @
924d0d1d
...
...
@@ -144,4 +144,9 @@ public class HiringTeam extends BaseHiringTeam
return
false
;
}
public
boolean
canCreateJob
()
{
return
getAvailableCredits
()
>
getUsedCredits
()
||
!
getHasCap
()
||
(
getHasCap
()
&&
getMaxCap
()
>
getUsedCredits
());
}
}
\ No newline at end of file
cmsWebApp/src/performa/utils/WebUtils.java
View file @
924d0d1d
...
...
@@ -38,6 +38,7 @@ public class WebUtils
public
static
final
String
CLIENTS
=
"Clients"
;
public
static
final
String
EDIT_CLIENT
=
"EditClient"
;
public
static
final
String
MANAGE_USERS
=
"ManageUsers"
;
public
static
final
String
MANAGE_PLAN
=
"ManagePlan"
;
public
static
final
String
MY_COMPANY
=
"MyCompany"
;
public
static
final
String
BILLING
=
"Billing"
;
public
static
final
String
VIEW_APPLICANTS
=
"ViewApplicants"
;
...
...
cmsWebApp/webroot/extensions/adminportal/job_review_submit.jsp
View file @
924d0d1d
...
...
@@ -14,6 +14,11 @@
String fifthPage = WebUtils.getSamePageInRenderMode(request, WebUtils.JOB_REVIEW);
String jobsPage = WebUtils.getSamePageInRenderMode(request, "Page");
Article companyArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.MY_COMPANY);
String billingPage = companyArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.BILLING).toMap());
String planPage = companyArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.MANAGE_PLAN).toMap());
String sharingPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CREATED_JOB) + "&fromJob=true";
if(job == null && request.getParameter("JobID")!= null)
{
job = Job.getJobByID(transaction, Long.parseLong(request.getParameter("JobID")));
...
...
@@ -25,6 +30,10 @@
Company company = companyUser.getCompany();
Debug.assertion(job != null, "Job is null in admin portal create job");
HiringTeam hiringTeam = job.getHiringTeam();
process.setAttribute("HiringTeam", hiringTeam);
%>
<oneit:form name="editJob" method="post" enctype="multipart/form-data">
...
...
@@ -35,10 +44,10 @@
<h1 class="page-title">Review Job
<%
if(
company.getPaymentPlan()!=
null)
if(
hiringTeam.getPaymentPlan() !=
null)
{
Integer activeCount =
company.getOpenJobsCount
();
Integer totCount =
company.getPaymentPlan().getActiveJobCount
();
Integer activeCount =
hiringTeam.getUsedCredits
();
Integer totCount =
hiringTeam.getAvailableCredits
();
Integer remCount = (totCount - activeCount) > 0 ? (totCount - activeCount) : 0;
%>
<div style="float:right;">
...
...
@@ -336,39 +345,48 @@
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
<%
if(
company.canCreateJob()
)
if(
hiringTeam.getCardID() == null
)
{
if(company.getCardID() != null)
{
String createJobPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CREATED_JOB) + "&fromJob=true";
%>
<oneit:button value="Confirm and Create Job" name="saveJob" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", createJobPage)
.mapEntry ("fromPage", fifthPage)
.mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
%>
<oneit:button value="Open this Job" name="saveJob" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", billingPage)
.mapEntry("JobStatus", JobStatus.DRAFT)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", new HashSet<String> (Arrays.asList(new String[] {"Job", "HiringTeam"})))
.mapEntry(NotificationUtils.DISPLAY_NOTIFICATION_PARAM, false)
.toMap() %>" />
<%
}
else
{
String createJobPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CARD_PAYMENT);
%>
<oneit:button value="Confirm and Create Job" name="gotoPage" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", createJobPage).toMap() %>" />
}
else if(hiringTeam.isTrue(hiringTeam.getIsPPJ()))
{
%>
<oneit:button value="Open this Job" name="savePayment" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", sharingPage).toMap() %>" />
<%
}
else if(hiringTeam.canCreateJob())
{
%>
<oneit:button value="Open this Job" name="saveJob" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", sharingPage)
.mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
<%
}
}
else
{
%>
<oneit:button value="Confirm and make payment" name="gotoPage" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage).toMap() %>" />
%>
<oneit:button value="Open this Job" name="saveJob" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", planPage)
.mapEntry("JobStatus", JobStatus.DRAFT)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", new HashSet<String> (Arrays.asList(new String[] {"Job", "HiringTeam"})))
.mapEntry(NotificationUtils.DISPLAY_NOTIFICATION_PARAM, false)
.toMap() %>" />
<%
}
%>
...
...
cmsWebApp/webroot/extensions/adminportal/manage_plan.jsp
View file @
924d0d1d
...
...
@@ -372,7 +372,7 @@ System.out.println(subscription);
<span> No, leave it open</span>
<label class="switch">
<oneit:recalcClass htmlTag="span" classScript="hiringTeam.isTrue(hiringTeam.getHasCap()) ? 'checkbox checked': 'checkbox unchecked'" hiringTeam="<%= hiringTeam %>">
<oneit:ormInput obj="<%= hiringTeam %>" attributeName="HasCap" type="checkbox"/>
<oneit:ormInput obj="<%= hiringTeam %>" attributeName="HasCap" type="checkbox"
onChange="paymentPlanChanged()"
/>
</oneit:recalcClass>
<div class="slider round"></div>
</label>
...
...
@@ -385,6 +385,8 @@ System.out.println(subscription);
<oneit:button value="Set Max" name="saveCompany" cssClass="btn btn-primary"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("HiringTeam"))
.toMap() %>" />
</oneit:recalcClass>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment