Skip to main content

Credits Improvement

HQ Assignment

HQ Assignment Improvement Diagram

In the previous implementation, although credit_negative_validation exists, HQ can still assign credits to their outlets even when the company does not have sufficient total credits.

This creates a scenario where outlet credits may appear valid while the overall company balance is actually insufficient.

Improvement

Add validation when HQ assigns credits to locations.

The total credits assigned to locations should be validated to ensure that the company’s overall credit balance does not become negative.

Select Applicant Validation

Select Applicant Validation Diagram

In the current implementation, we calculate:

  available_credits - (total_credit_used)

If the result is less than negative_credit_validation_floor, the system prevents the Hiring Manager (HM) from creating the job.

However, the issue is that no additional validation is performed when the HM selects applicants. The initial validation assumes that each job will only have one selected applicant.

When the HM selects multiple applicants for the same job, the previous calculation may become inaccurate, which can cause the actual credit usage to exceed the allowed negative credit threshold.

Improvement

Add validation when the Hiring Manager (HM) selects applicants for a job.

This validation ensures that the location or company does not go into negative credits when calculating the expected salary for the selected applicants.

If the total expected salary exceeds the available credits, the system should return an error and prevent the selection.


Example

Location Credits

  location.available_credits = 320

Job Details

  job.hourly_rate = 30
job.total_time = 10 hours
job.total_job_salary = 300 (30 × 10)

Case 1 – HM selects 1 applicant

The system calculates:

  1 × total_job_salary < location.available_credits
300 < 320 = true

Since the credits are sufficient, the system allows the applicant to be selected.


Case 2 – HM selects 3 applicants

The system calculates:

  3 × total_job_salary < location.available_credits
900 < 320 = false

Since the expected salary exceeds the available credits, the system returns an error and prevents the selection.