0% found this document useful (0 votes)
2 views

Workflow of the Override Process

The document outlines the workflow for managing temporary serviceability overrides for couriers based on postal codes. It details the API calls for checking serviceability and adding overrides, as well as the creation of a new entity to store these overrides. The process includes methods for checking active overrides and restoring serviceability after the override period expires.

Uploaded by

SARTHAK BEHL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Workflow of the Override Process

The document outlines the workflow for managing temporary serviceability overrides for couriers based on postal codes. It details the API calls for checking serviceability and adding overrides, as well as the creation of a new entity to store these overrides. The process includes methods for checking active overrides and restoring serviceability after the override period expires.

Uploaded by

SARTHAK BEHL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Workflow of the Override Process

Checking serviceability:

• Call GET /api/serviceability/check?courierCode={code}&postalCode={code}.


• The system will first check if there's a temporary override. If an override exists and it's
within the specified timeframe, the result will reflect the override.
• If no override is found, the default serviceability logic is applied.

Adding a temporary override:

• Call POST /api/serviceability/override with the courier, postal code, override


flag (true for non-serviceable), reason, and time range.
• This will insert a temporary record into the TemporaryServiceabilityOverride
table.

Plan:

1. Create a New Entity (TemporaryServiceabilityOverride): This will store


exceptions for a courier that would temporarily override serviceability.
2. Service Method to Apply Override: This method will check for any postal codes
that have temporary overrides before determining the serviceability status.
3. Method Logic:
o For each postal code, check if there's an active temporary override.
o If an override exists, the courier should be marked as non-serviceable for that
postal code.
4. Restore Serviceability: After the temporary period expires, the overrides will
automatically become invalid, or we can provide a mechanism to clear them.

@Entity

public class TemporaryServiceabilityOverride extends AuditableBaseEntity<String> {

private String courierCode;

private String postalCode;

private Boolean overrideServiceability; // true = override and mark non-serviceable

private LocalDateTime overrideStartTime;

private LocalDateTime overrideEndTime;

private String reason; // Optional field to describe the override reason


in service class

public boolean isServiceable(String courierCode, String postalCode)

// Check for active temporary overrides

List<TemporaryServiceabilityOverride> overrides =
overrideRepository.findActiveOverrides(courierCode, postalCode, LocalDateTime.now());

// If there is an override marking this non-serviceable, return false

if (overrides != null && !overrides.isEmpty()) {

for (TemporaryServiceabilityOverride override : overrides) {

if (override.getOverrideServiceability() != null &&


override.getOverrideServiceability()) {

log.debug("Serviceability temporarily disabled for courier {} and postalCode


{}", courierCode, postalCode);

return false;

// Otherwise, fall back to checking the original `GenericServiceability` data

Optional<GenericServiceability> serviceability =
repository.findByCourierCodeAndPostalCode(courierCode, postalCode);

return serviceability.map(GenericServiceability::getPrepaidEnabled).orElse(false); //
For example, checking prepaidEnabled

public void addTemporaryOverride(String courierCode, String postalCode, boolean


overrideServiceability, String reason, LocalDateTime start, LocalDateTime end) {

TemporaryServiceabilityOverride override = new TemporaryServiceabilityOverride();


override.setCourierCode(courierCode);

override.setPostalCode(postalCode);

override.setOverrideServiceability(overrideServiceability);

override.setOverrideStartTime(start);

override.setOverrideEndTime(end);

override.setReason(reason);

overrideRepository.save(override);

log.info("Temporary override added for courier {} and postal code {} with reason {}",
courierCode, postalCode, reason);

You might also like