DiscountedOrder domain type + DiscountCalculator (half-up, strict barrier) with unit tests
yak: discountedorder-discountcalculator-with-unit-tests-zrtn
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace After;
|
||||
|
||||
/// <summary>
|
||||
/// The result of discounting an <see cref="Order"/>: a separate domain type,
|
||||
/// not a modified order. The discount is derived data — computed on demand,
|
||||
/// correlated to its order by <see cref="OrderId"/>. What a caller does with
|
||||
/// it (and what of it ever reaches <see cref="OrderDto"/> or
|
||||
/// <see cref="OrderData"/>) is deliberately left to the caller.
|
||||
/// </summary>
|
||||
public sealed record DiscountedOrder
|
||||
{
|
||||
/// <summary>Primary key of the discounted <see cref="Order"/>.</summary>
|
||||
public Guid OrderId { get; init; }
|
||||
|
||||
/// <summary>The order's total in cents, as read from it (the untouched input).</summary>
|
||||
public int TotalInCents { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The percentage actually applied, as an integer percent. 0 when the
|
||||
/// order did not pass the discount barrier.
|
||||
/// </summary>
|
||||
public int DiscountPercentage { get; init; }
|
||||
|
||||
/// <summary>The total after the discount, in cents.</summary>
|
||||
public int DiscountedTotalInCents { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user