|
Current Problem
Similar to the OrderDateDayofWeek, add condition that checks day of week for RequiredDespatchDate. This would allow e.g. changing the courier service based on the despatch day (so if you are despatching on a Friday, you send with a Saturday service). Honestly quite chocked this does not come out-of-the-box in Mintsoft Shipping Mgmt. |
|
| Idea to resolve Problem | See text. |
Here is the code for it
// =============================================================================
// Mintsoft Order Rules – New Condition Fields
//
// Feature Request: RequiredDespatchDateDayOfWeek & RequiredDespatchDateTimeOfDay
//
// These two condition types are direct equivalents of the existing:
// - OrderDateDayOfWeek (string operators, e.g. "Monday", "Friday")
// - OrderDateTimeOfDay (decimal operators, e.g. GreaterThan 14.0 = after 2pm)
//
// ...but derived from RequiredDespatchDate instead of OrderDate.
//
// Follows the same patterns already established in the codebase.
// =============================================================================
using System;
namespace Mintsoft.OrderRules.Conditions
{
/// <summary>
/// Evaluates the day of the week of an order's RequiredDespatchDate.
///
/// Mirrors the behaviour of OrderDateDayOfWeek but uses RequiredDespatchDate
/// as the source field.
///
/// Supported operators: all string operators except Empty / IsNotEmpty.
/// - Equals e.g. "Monday"
/// - NotEqual e.g. "Saturday"
/// - Contains e.g. "on" matches Monday, Wednesday, etc.
/// - DoesNotContain
/// - StartsWith e.g. "T" matches Tuesday, Thursday
/// - DoesNotStartWith
///
/// Param value: a day name string (case-insensitive), e.g. "Friday"
/// </summary>
public class RequiredDespatchDateDayOfWeekCondition : IOrderRuleCondition
{
public string ConditionType => "RequiredDespatchDateDayOfWeek";
}
// =============================================================================
// Supporting infrastructure (shown for completeness / clarity).
// These are assumed to already exist in the codebase, mirroring what
// OrderDateDayOfWeek and OrderDateTimeOfDay already use.
// Included here so the feature request is self-contained and unambiguous.
// =============================================================================
namespace Mintsoft.OrderRules.Conditions
{
/// <summary>
/// Evaluates string-based condition operators.
/// Already used by: OrderDateDayOfWeek, CourierService, PostCode, etc.
/// </summary>
public static class StringConditionEvaluator
{
public static bool Evaluate(string fieldValue, string operatorType, string paramValue)
{
if (fieldValue == null)
return false;
}
// =============================================================================
// Usage examples
// =============================================================================
//
// EXAMPLE 1: Change courier to "SATURDAY_SERVICE" if RequiredDespatchDate
// falls on a Friday (so it ships Friday, arrives Saturday).
//
// Condition Field: RequiredDespatchDateDayOfWeek
// Operator: Equals
// Value: Friday
// Action: ChangeCourierService → SATURDAY_SERVICE
//
//
// EXAMPLE 2: Change courier to "NEXT_DAY_AM" if RequiredDespatchDate is
// before noon (e.g. urgent morning despatch).
//
// Condition Field: RequiredDespatchDateTimeOfDay
// Operator: LessThan
// Value: 12.0
// Action: ChangeCourierService → NEXT_DAY_AM
//
//
// EXAMPLE 3: Combined AND rule – Friday AND after 2pm gets an express service.
//
// Condition Type: AND
// Condition 1: RequiredDespatchDateDayOfWeek Equals Friday
// Condition 2: RequiredDespatchDateTimeOfDay GreaterThan 14.0
// Action: ChangeCourierService → EXPRESS_FRIDAY_PM
//
// =============================================================================