Target Packing Date Feature

The Target Packing Date feature allows the target packing date to be dynamically determined during the package creation process. This functionality leverages date values stored in the attributes field of OrderItem objects and can override the default calculation logic.

By enabling this feature, businesses can adapt package creation dates to meet special customer requests, scheduled deliveries, or business-specific requirements instead of relying solely on system-defined defaults.

How It Works

During the package creation process, the system determines the target_packing_date in the following order of priority:

  1. Manually provided target_packing_date Passed as a parameter to the create_package method.

  2. Dynamic date from OrderItem attributes Extracted based on the configured attribute key and format.

  3. Default calculation Computed as order.date_placed + stock_location.get_target_packing_interval.

Configuration

The feature requires two ApplicationSettings values to be configured.

1. TARGET_PACKING_DATE_ATTRIBUTE_KEY

  • Description: The attribute key to be searched within OrderItem.attributes.

  • Type: String

  • Default: None (feature disabled)

  • Example values:

    • "delivery_date"

    • "scheduled_date"

    • "target_ship_date"

2. TARGET_PACKING_DATE_FORMAT

  • Description: The date format expected for parsing the attribute value (Python strptime format).

  • Type: String

  • Default: "%d/%m/%Y" (DD/MM/YYYY)

  • Example values:

    • "%d/%m/%Y" → 25/12/2024

    • "%Y-%m-%d" → 2024-12-25

    • "%d.%m.%Y" → 25.12.2024

    • "%m/%d/%Y" → 12/25/2024

Configuration Examples

Usage Scenarios

Scenario 1: E-commerce Delivery Date

Scenario 2: B2B Scheduled Shipment

Scenario 3: Special Event Date

Error Handling

Invalid Date Format

Missing Configuration

Attribute Key Not Found

Multiple OrderItem Scenario

When a package contains multiple OrderItems:

  • The first valid date found is used.

  • Remaining OrderItems are ignored for target packing date determination.

Performance Notes

  • O(n) complexity: The check is linear relative to the number of OrderItems.

  • Early exit: The loop terminates as soon as a valid date is found.

  • Lazy evaluation: If TARGET_PACKING_DATE_ATTRIBUTE_KEY is None, no checks are performed.

Common Issues & Solutions

Problem: Date format mismatch

Solution: Ensure the format in ApplicationSettings matches the attribute value.


Problem: Feature not working

Checklist:

  1. Is TARGET_PACKING_DATE_ATTRIBUTE_KEY configured?

  2. Does the OrderItem.attributes contain the specified key?

  3. Is the date format correct?

  4. Are there warning logs?


Problem: Wrong date is used

Cause: In multi-OrderItem packages, the first valid date is applied.

Solution:

  • Ensure all OrderItems share the same date, or

  • Implement custom logic for selection if needed.

Last updated

Was this helpful?