dev.atedeg.mdm.pricing

Type members

Classlikes

final case class Client(code: ClientID)

A physical or legal entity that places order lines.

A physical or legal entity that places order lines.

final case class ClientID(id: UUID)

An ID which uniquely identifies a client.

An ID which uniquely identifies a client.

final case class DiscountPercentage(n: DecimalInOpenClosedRange[0.0d, 1.0d])

A discount percentage, expressed as a number between 0 (exclusive) and 100 (inclusive).

A discount percentage, expressed as a number between 0 (exclusive) and 100 (inclusive).

final case class IncomingOrderLine(quantity: Quantity, product: Product)

A product with its ordered quantity.

A product with its ordered quantity.

object Main extends IOApp
final case class PriceInEuroCents(n: NonNegativeNumber)

A price expressed in cents, the smallest currency unit for euros.

A price expressed in cents, the smallest currency unit for euros.

final case class PriceList(priceList: Map[Product, PriceInEuroCents])

Associates to each product its unitary price.

Associates to each product its unitary price.

final case class Promotion(client: Client, expiryDate: LocalDateTime, lines: NonEmptyList[PromotionLine])

A promotion for a client, with an expiry date, containing promotion lines for some products.

A promotion for a client, with an expiry date, containing promotion lines for some products.

enum PromotionLine(val product: Product)

A promotion line, which describes the promotion.

A promotion line, which describes the promotion.

final case class Quantity(n: PositiveNumber)

A quantity of something.

A quantity of something.

final case class ThresholdQuantity(n: PositiveNumber)

A threshold under which the discount does not apply.

A threshold under which the discount does not apply.

Value members

Concrete methods

@SuppressWarnings(scala.Array.apply[java.lang.String]("org.wartremover.warts.ListAppend")(scala.reflect.ClassTag.apply[java.lang.String](classOf[java.lang.String])))
def priceOrderLine(priceList: PriceList, clientPromotions: List[Promotion], today: LocalDateTime)(orderLine: IncomingOrderLine): PriceInEuroCents

Computes the price of an order line, according to any promotion that may be applied for a certain client.

Computes the price of an order line, according to any promotion that may be applied for a certain client.