Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions force-app/main/default/classes/AccountHelper.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public with sharing class AccountHelper {
public AccountHelper() {

}
}
5 changes: 5 additions & 0 deletions force-app/main/default/classes/AccountHelper.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
28 changes: 28 additions & 0 deletions force-app/main/default/classes/Application.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public with sharing class Application {
public static void populateFederalTax(List<Application__c> applications) {
if (!applications.isEmpty()) {
for (Application__c app : applications) {
app.Federal_Tax_Amount__c = ApplicationHelper.calculateFederalTax(app.Annual_Salary__c);
app.Medicare_Withholding__c = ApplicationHelper.calculateMedicareTax(app.Annual_Salary__c);
app.Social_Security__c = ApplicationHelper.calculateSocialSecurityTax(app.Annual_Salary__c);
}
}
}

public static void createTasksOnChangeStatus(List<Application__c> newApps, Map<Id, Application__c> oldAppMap) {
if (!newApps.isEmpty()) {
List<Task> tasksToCreate = new List<Task>();
for (Application__c app : newApps) {
Application__c oldApp = oldAppMap.get(app.Id);

if (app.Application_Status__c != oldApp.Application_Status__c) {
List<Task> newTasks = ApplicationHelper.createTasksForStatus(app);
tasksToCreate.addAll(newTasks);
}
if (!tasksToCreate.isEmpty()) {
Database.insert(tasksToCreate, AccessLevel.USER_MODE);
}
}
}
}
}
5 changes: 5 additions & 0 deletions force-app/main/default/classes/Application.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
270 changes: 270 additions & 0 deletions force-app/main/default/classes/ApplicationHelper.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
public with sharing class ApplicationHelper {

public static Decimal calculateFederalTax(Decimal annualSalary) {
// calculate federal tax amount
// get applicable tax brackets for salary amount
List<Tax_Rate__c> applicableTaxRates = [SELECT Tax_Rate_Type__c, Bracket_Min__c, Bracket_Max__c, Tax_Rate__c
FROM Tax_Rate__c
WHERE Tax_Rate_Type__c = 'Federal' AND Bracket_Min__c <= :annualSalary
WITH SECURITY_ENFORCED
ORDER BY Bracket_Min__c];
Decimal remainingSalary = annualSalary;
Decimal taxAmount = 0;
for (Tax_Rate__c bracket : applicableTaxRates) {
if (remainingSalary <= 0) {
break;
}
// figure out the tax amount for each bracket
Decimal lowerBracket = bracket.Bracket_Min__c;
Decimal upperBracket = bracket.Bracket_Max__c != null? bracket.Bracket_Max__c : Decimal.valueOf(999999999);
Decimal taxableBracketRange = upperBracket - lowerBracket;
Decimal taxableAmount = Math.min(RemainingSalary, taxableBracketRange);
Decimal taxOnBracket = taxableAmount * (bracket.Tax_Rate__c / 100);
taxAmount += taxOnBracket;
remainingSalary -= taxableAmount;
}
return taxAmount.setScale(2);
}
public static Decimal calculateMedicareTax(Decimal annualSalary) {
// calculate Medicare tax
List<Tax_Rate__c> medicareRate = [SELECT Tax_Rate_Type__c, Medicare_Threshold_Amount__c, Tax_Rate__c, Additional_Medicare_Tax_Rate__c
FROM Tax_Rate__c
WHERE Tax_Rate_Type__c = 'Medicare'
WITH SECURITY_ENFORCED
LIMIT 1];
Decimal medicareTaxAmount = 0;
Decimal taxAmountAboveThreshold = 0;
if (annualSalary < medicareRate[0].Medicare_Threshold_Amount__c) {
medicareTaxAmount = annualSalary * (medicareRate[0].Tax_Rate__c / 100);
} else {
taxAmountAboveThreshold = (annualSalary - medicareRate[0].Medicare_Threshold_Amount__c) * (medicareRate[0].Additional_Medicare_Tax_Rate__c / 100);
medicareTaxAmount = (annualSalary * (medicareRate[0].Tax_Rate__c / 100)) + taxAmountAboveThreshold;
}
return medicareTaxAmount.setScale(2);
}
public static Decimal calculateSocialSecurityTax(Decimal annualSalary) {
// calculate Social Security tax
List<Tax_Rate__c> socialSecurityRate = [SELECT Tax_Rate_Type__c, Tax_Rate__c, Social_Security_Wage_Limit__c
FROM Tax_Rate__c
WHERE Tax_Rate_Type__c = 'Social Security'
WITH SECURITY_ENFORCED
LIMIT 1];
Decimal taxableAmount = Math.min(annualSalary, socialSecurityRate[0].Social_Security_Wage_Limit__c);
Decimal socialSecurityTaxAmount = taxableAmount * (socialSecurityRate[0].Tax_Rate__c / 100);
System.debug('TaxableAmount::: ' + taxableAmount + ' Social Security Tax Amount::: ' + socialSecurityTaxAmount);
return socialSecurityTaxAmount.setScale(2);
}
public static List<Task> createTasksForStatus(Application__c app) {
// create tasks associated with application status
List<Task> tasksToCreate = new List<Task>();
switch on app.Application_Status__c {
when 'Saved' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Validate job alignment',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Check if the job description aligns with your interests and values'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Review skills for fit',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Review the highlighted skills to see if the role is a good fit'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Mark excitement level',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Research the company or role and mark your excitement level'
));
}
when 'Applying' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Research - find someone who works at company',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Find and research someone who works at the company and add them as a contact'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Set informal interview',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Set up an informational interview to learn more about the role/company'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Identify potential referrals',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Identify potential referrals to help get your application on the top of the pile'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Customize achievements',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Customize your work achievements using the job description keywords'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Submit application to Company webiste',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Submit your application on the company website if possible'
));
}
when 'Applied' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Reach out to hiring manager',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Reach out to the hiring manager or recruiter'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Follow up on your application',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(2),
Description = '- Follow up on your application via email weekly'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Identify and save similar job opps',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Continue identifying and saving similar job opportunities'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Set up weekly networking calls',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(1),
Description = '- Set up weekly networking calls to explore similar companies/roles'
));
}
when 'Interviewing' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Prepare elevator pitch',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Prepare your blurb or “tell me about yourself” response'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Practice interview questions',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Practice answering behavioral interview questions'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Research company and interviewers',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(2),
Description = '- Research the company and your interviewers'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Prepare for virtual interiew',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(2),
Description = '- Set up your virtual interview space and test your tech'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Send Thank you emails',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(2),
Description = '- Send thank you emails within 24 hours'
));
}
when 'Negotiating' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Salary research',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Research your market value and know your numbers'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Prepare your negotiation scripts',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Prepare your negotiation scripts'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Evaluate your offer',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Evaluate your offer and decline or accept'
));
}
when 'Accepted' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Plan your resignation and recharge',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(2),
Description = '- Plan your resignation if applicable \n - Take some time to relax and recharge'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Prepare for your first day of onboarding',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(2),
Description = '- Prepare for your first day of onboarding'
));
}
when 'Closed' {
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Send a follow-up email to interviewer',
Status = 'Not Started',
Priority = 'High',
ActivityDate = Date.today().addDays(1),
Description = '- Send a follow-up email thanking the interviewer and asking for feedback'
));
tasksToCreate.add(new Task(
WhatId = app.Id,
Subject = 'Review your notes',
Status = 'Not Started',
Priority = 'Normal',
ActivityDate = Date.today().addDays(3),
Description = '- Review your notes and reflect on areas of improvement'
));
}
}
return tasksToCreate;
}
}
5 changes: 5 additions & 0 deletions force-app/main/default/classes/ApplicationHelper.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
5 changes: 5 additions & 0 deletions force-app/main/default/classes/ContactHelper.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public with sharing class ContactHelper {
public ContactHelper() {

}
}
5 changes: 5 additions & 0 deletions force-app/main/default/classes/ContactHelper.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
36 changes: 36 additions & 0 deletions force-app/main/default/classes/JobApplicationHelper.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public with sharing class JobApplicationHelper {
public static void setPrimaryContacts(List<Job__c> jobRecords) {
List<Job__c> jobRecordsToUpdate = new List<Job__c>();
// set the primary contact on Job record
jobRecords = [SELECT Id, Company__c, Company__r.Name, Primary_Contact__c
FROM Job__c
WHERE Primary_Contact__c = null
WITH SECURITY_ENFORCED];
// get set of account ids where primary contact is null
Set<Id> companyAcctIds = new Set<Id>();
for (Job__c jobs : jobRecords) {
companyAcctIds.add(jobs.Company__c);
}
// map contacts to accounts
Map<Id, Id> accountIdToContactId = new Map<Id, Id>();
for (Contact cont : [SELECT Id, FirstName, LastName, AccountId, Level__c, RecordTypeId
FROM Contact
WHERE AccountId IN :companyAcctIds
AND RecordType.DeveloperName = 'General'
WITH SECURITY_ENFORCED])
{
if (!accountIdToContactId.containsKey(cont.AccountId)) {
accountIdToContactId.put(cont.AccountId, cont.Id);
}
}
// assign the primary contact to job based on AccountId
for (Job__c jobContact : jobRecords) {
if (jobContact.Company__c != null && accountIdToContactId.containsKey(jobContact.Company__c)) {
Id contactIdToAssign = accountIdToContactId.get(jobContact.Company__c);
jobContact.Primary_Contact__c = contactIdToAssign;
jobRecordsToUpdate.add(jobContact);
}
}
Database.update(jobRecordsToUpdate, AccessLevel.USER_MODE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
8 changes: 8 additions & 0 deletions force-app/main/default/triggers/ApplicationTrigger.trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
trigger ApplicationTrigger on Application__c (before insert, after update) {
if (trigger.isBefore && trigger.isInsert) {
Application.populateFederalTax(Trigger.new);
}
if (trigger.isAfter && trigger.isUpdate) {
Application.createTasksOnChangeStatus(Trigger.new, Trigger.oldMap);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexTrigger>
Loading