Commit 074780d8 by nilu

S21277914 # Client - Incoming Issues (raised by Client) #Allow Cancel Job

parent e5d5d80f
......@@ -27,6 +27,7 @@
<column name="card_post_code" type="String" nullable="true" length="10"/>
<column name="card_id" type="String" nullable="true" length="100"/>
<column name="plan_renewed_on" type="Date" nullable="true"/>
<column name="ppj_credits" type="Long" nullable="true"/>
<column name="used_credits" type="Long" nullable="true"/>
<column name="available_credits" type="Long" nullable="true"/>
<column name="is_ppj" type="Boolean" nullable="true"/>
......
......@@ -27,6 +27,7 @@ CREATE TABLE tl_hiring_team (
card_post_code varchar(10) NULL,
card_id varchar(100) NULL,
plan_renewed_on datetime NULL,
ppj_credits numeric(12) NULL,
used_credits numeric(12) NULL,
available_credits numeric(12) NULL,
is_ppj char(1) NULL,
......
......@@ -28,6 +28,7 @@ CREATE TABLE tl_hiring_team (
card_post_code varchar2(10) NULL,
card_id varchar2(100) NULL,
plan_renewed_on date NULL,
ppj_credits number(12) NULL,
used_credits number(12) NULL,
available_credits number(12) NULL,
is_ppj char(1) NULL,
......
......@@ -28,6 +28,7 @@ CREATE TABLE tl_hiring_team (
card_post_code varchar(10) NULL,
card_id varchar(100) NULL,
plan_renewed_on timestamp NULL,
ppj_credits numeric(12) NULL,
used_credits numeric(12) NULL,
available_credits numeric(12) NULL,
is_ppj char(1) NULL,
......
......@@ -6,7 +6,9 @@ import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.LessThanFilter;
import oneit.utils.DateDiff;
import oneit.utils.math.NullArith;
import oneit.utils.parsers.FieldException;
import performa.orm.HiringTeam;
import performa.orm.Job;
import performa.orm.types.JobStatus;
......@@ -30,7 +32,39 @@ public class CloseJobBatch extends ORMBatch
job.setIsManuallyClosed(Boolean.FALSE);
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Setting Job Status to Closed in job : ", job);
if(job.getJobApplicationsCount() == 0)
{
HiringTeam hiringTeam = job.getHiringTeam();
HiringTeam billingTeam = hiringTeam.getManageOwnBilling() ? hiringTeam : hiringTeam.getBilledByTeam();
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "No Applicants for job: ", job, " hence crediting account : ", billingTeam);
if(billingTeam.isTrue(billingTeam.getOnTrial()))
{
billingTeam.setTrialJobCount(billingTeam.getTrialJobCount() - 1);
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Reducing trail job count of hiring team : ", billingTeam);
}
else
{
if(billingTeam.getIsPPJ())
{
billingTeam.setPPJCredits(NullArith.add(billingTeam.getPPJCredits(), 1).intValue());
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Increasing PPJ Credits of hiring team : ", billingTeam);
}
else
{
if(billingTeam.getUsedCredits() > billingTeam.getAvailableCredits())
{
billingTeam.setAvailableCredits(NullArith.add(billingTeam.getAvailableCredits(), 1).intValue());
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Increasing Available Credits of hiring team (to recover usage records on stripe) : ", billingTeam);
}
billingTeam.setUsedCredits(NullArith.subtract(billingTeam.getUsedCredits(), 1).intValue());
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Reducing used credits of hiring team ", billingTeam);
}
}
}
}
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.DateDiff;
import oneit.utils.math.NullArith;
import performa.orm.CompanyUser;
import performa.orm.HiringTeam;
import performa.orm.Job;
import performa.utils.StripeUtils;
......@@ -34,11 +33,9 @@ public class ExtendJobFP extends SaveFP
HiringTeam hiringTeam = job.getHiringTeam();
HiringTeam billingTeam = hiringTeam.getManageOwnBilling() ? hiringTeam : hiringTeam.getBilledByTeam();
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Start of Extend job : ", job);
job.setApplyBy(DateDiff.add(job.getApplyBy(), Calendar.DATE, 30));
job.setLastEdited(new Date());
......@@ -53,7 +50,7 @@ public class ExtendJobFP extends SaveFP
}
else if(billingTeam.getIsPPJ())
{
StripeUtils.makePayment(hiringTeam, job);
hiringTeam.makePayment(job);
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Job Extended. Apply by date : ", job.getApplyBy());
......
......@@ -59,7 +59,7 @@ public class MakePaymentFP extends SaveFP
if(hiringTeam.getCardID() != null && hiringTeam.isTrue(hiringTeam.getIsPPJ()))
{
StripeUtils.makePayment(hiringTeam, job);
hiringTeam.makePayment(job);
}
if(hiringTeam.getCardID() == null)
......
......@@ -35,7 +35,34 @@ public class SaveJobFP extends SaveFP
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"In SaveJobFP saving job : ", job );
if(job.getJobStatus() == JobStatus.DRAFT && status != null && status == JobStatus.OPEN)
if(job.getJobStatus() == JobStatus.OPEN && status != null && status == JobStatus.CANCELLED)
{
if(billingTeam.isTrue(billingTeam.getOnTrial()))
{
billingTeam.setTrialJobCount(billingTeam.getTrialJobCount() - 1);
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Cancelling job: ", job, " hence reducing trial job count : ", billingTeam);
}
else
{
if(billingTeam.getIsPPJ())
{
billingTeam.setPPJCredits(NullArith.add(billingTeam.getPPJCredits(), 1).intValue());
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Cancelling job: ", job, " hence increasing PPJ credits : ", billingTeam);
}
else
{
if(billingTeam.getUsedCredits() > billingTeam.getAvailableCredits())
{
billingTeam.setAvailableCredits(NullArith.add(billingTeam.getAvailableCredits(), 1).intValue());
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Cancelling job: ", job, " hence increasing available credits (to recover usage records on stripe) : ", billingTeam);
}
billingTeam.setUsedCredits(NullArith.subtract(billingTeam.getUsedCredits(), 1).intValue());
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Cancelling job: ", job, " hence reducing used credits : ", billingTeam);
}
}
}
else if(job.getJobStatus() == JobStatus.DRAFT && status != null && status == JobStatus.OPEN)
{
job.setApplyBy(DateDiff.add(DateDiff.getToday(), Calendar.DATE, 30));
job.setOpenDate(new Date());
......@@ -55,7 +82,7 @@ public class SaveJobFP extends SaveFP
}
else if(billingTeam.getIsPPJ())
{
StripeUtils.makePayment(hiringTeam, job);
billingTeam.makePayment(job);
}
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"Job status changed as Open. ", job );
......
......@@ -9,10 +9,12 @@ import oneit.objstore.FieldWriteability;
import oneit.objstore.ValidationContext;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.security.SecUser;
import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils;
import oneit.utils.DateDiff;
import oneit.utils.StringUtils;
import oneit.utils.filter.Filter;
import oneit.utils.math.NullArith;
import oneit.utils.parsers.FieldException;
import performa.orm.types.CurrencyType;
import performa.orm.types.RoleType;
......@@ -111,6 +113,13 @@ public class HiringTeam extends BaseHiringTeam
{
return super.getUsedCredits() != null ? super.getUsedCredits() : 0;
}
@Override
public Integer getPPJCredits()
{
return super.getPPJCredits() != null ? super.getPPJCredits() : 0;
}
@Override
......@@ -307,4 +316,16 @@ public class HiringTeam extends BaseHiringTeam
{
return super.getTrialJobCount() != null ? super.getTrialJobCount() : 0;
}
public void makePayment(Job job) throws BusinessException
{
if(getPPJCredits() > 0)
{
setPPJCredits(NullArith.subtract(getPPJCredits(), 1).intValue());
}
else
{
StripeUtils.makePayment(this, job);
}
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@
<ATTRIB name="CardPostCode" type="String" dbcol="card_post_code" length="10" />
<ATTRIB name="CardID" type="String" dbcol="card_id" length="100" />
<ATTRIB name="PlanRenewedOn" type="Date" dbcol="plan_renewed_on" mandatory="false" />
<ATTRIB name="PPJCredits" type="Integer" dbcol="ppj_credits" />
<ATTRIB name="UsedCredits" type="Integer" dbcol="used_credits" />
<ATTRIB name="AvailableCredits" type="Integer" dbcol="available_credits" />
<ATTRIB name="IsPPJ" type="Boolean" dbcol="is_ppj" />
......
......@@ -490,8 +490,6 @@ public class StripeUtils
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Setting hiring team with reset plan details : ", hiringTeam);
}
}
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">tl_hiring_team</tableName>
<column name="ppj_credits" type="Long" nullable="true"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
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