Skip to Content
Meubles Morinière

Engineering choicesTechnical case studies6 min read

A promised date you can keep

A made-to-order piece takes several weeks to arrive. Its date is shown from the storefront to the quote, and then it shifts with suppliers. Here’s how the promise stays the same everywhere, freezes at payment and says in advance which link threatens it.

The problem

A made-to-order table takes several weeks to arrive: six to eight for the workshop’s reference lead time (REFERENCE_LEAD_TIME_WEEKS). Its delivery date shows up in a lot of places: on the storefront’s product page (“delivered by…”), on the home page, in the Christmas order deadline, in the Google Merchant Center feed, in a quote’s PDF, on the checkout page, in the order confirmation and in the deadline the workshop sets itself.

On November 7, 2026, a consistency audit across the ERP, the database and the storefront showed that these dates didn’t agree (93c1b6eaad). The home page and the Christmas deadline left out the shipping time, while the product page and the order added it. A quote’s lead time was recomputed from the product, when it should have stayed the one in the PDF the customer had read. When you switched to a made-to-order variant, the date stayed the one of a piece in stock. In fact, each screen counted in its own way.

And once the date has been given, it moves. A supplier delivers late, or a store closure falls in the middle.

The constraints

  • The announced date binds the store. In distance selling, it delivers on the date or within the period it stated (French Consumer Code, article L216-1).
  • Workshop time isn’t calendar time. A lead time is counted in workshop weeks, as a range. It’s counted in working days, without public holidays or store closures, and in Paris time while the servers run in UTC.
  • Suppliers don’t always meet their lead time, and each one only accounts for a few purchases a year. A statistic over three receipts is fragile.
  • What was promised has to stay readable once the date has moved, because that’s what says whether the customer needs to be told.

The alternatives

  • Announce the bottom or the middle of the range. It’s more attractive, but it’s wrong half of the time. That option was ruled out: “Always the UPPER bound: an announced date is a date we keep” (offerDeliveryDates, from the purchase-decision analysis of November 3, 2026).
  • Give only a number of weeks, and the date after payment. That’s how it was before. The same analysis moved the date before payment, where it helps the customer decide.
  • Keep a single date on the order, and update it when a supplier runs late. Then you lose what was promised, so you no longer know that the customer needs to be told.
  • Let each screen compute its date. That’s what had caused the gaps found by the audit.

The decision

There’s a single calculation rule, written in packages/domain. The storefront, the feed and the ERP all call it (Lead times and promised dates). We always announce the upper bound. The order has two dates: the promise, which freezes at payment, and the workshop deadline, which moves. What suppliers actually do can lengthen a promise, but never shortens it. And a view says which link threatens the date, before the date has passed.

The implementation

One rule, and we announce the upper bound

A lead time is a range in weeks (LeadTimeWeeks). We look for it on the product, then on its brand, then we take the workshop’s reference lead time (productLeadTimeWeeks). The deadline starts on the day of payment. We add the upper bound converted into workshop working days, without public holidays or closures, in store time (workshopDueDate, packages/domain/src/workshop-due-date.ts; STORE_TIME_ZONE). Delivery adds the longest shipping time of the chosen method, and a pickup has none (deliveryDueDate, orderDeliveryDueAt). The Merchant Center feed calls workshopDueDate itself. The product page, the home page and the Christmas deadline count with the same primitive and the same constant (addWorkshopBusinessDays, apps/site/modules/products/lib/offer-delivery-dates.ts). When a delivery method doesn’t state its shipping time, the product page only promises the departure from the workshop, and the Christmas deadline doesn’t promise that piece.

workshopDueDatepackages/domain/src/workshop-due-date.ts · lines 21–34
export function workshopDueDate(
	paidAt: Date,
	closures: readonly ClosurePeriodLike[],
	leadTimeWeeks: LeadTimeWeeks = REFERENCE_LEAD_TIME_WEEKS,
	timeZone: string = STORE_TIME_ZONE,
): Date {
	const paidDay = toIsoDateIn(paidAt, timeZone);
	const day = addWorkshopBusinessDays(
		paidDay,
		workshopShippingBusinessDays(leadTimeWeeks),
		closures,
	) as CivilDay;
	return new Date(zonedMidnight(day, timeZone).getTime() + localTimeOfDayMs(paidAt, timeZone));
}

The promise is frozen at payment

At payment, the ERP writes the same value into workshopDueAt and promisedWorkshopDueAt (webhook-session.service.ts). The storefront can’t write either of them: the database guard refuses a storefront order that has them. After that, only the deadline moves. If it’s pushed past the promise, the ERP flags it (isWorkshopDuePostponed) and offers to send the customer a postponement notice. That way, they hear it from the store, and not from their calendar.

The date promised to the customer and the workshop deadlineAt payment, the same date is written to two columns. payment (paidAt), upper bound of the lead time, in workshop business days (reference: 6 to 8 weeks, so 8 × 5 = 40 business days, holidays and closures skipped), leaves the workshop (workshopDueAt = promisedWorkshopDueAt), longest transit of the shipping method (a pickup has none), delivery (orderDeliveryDueAt). Afterwards, only the deadline moves. The team pushes it back when a supplier is late (rescheduleWorkshopDue), and so does switching a stocked piece for a made-to-order one. promised date (promisedWorkshopDueAt), postponed deadline (workshopDueAt), delivery follows. isWorkshopDuePostponed: the ERP flags it and offers the customer a postponement notice.At payment, the same date is written to two columnspaymentpaidAtleaves the workshopworkshopDueAt= promisedWorkshopDueAtdeliveryorderDeliveryDueAtupper bound of the lead time, in workshopbusiness daysreference: 6 to 8 weeks, so 8 × 5 = 40business days, holidays and closures skippedlongest transit of the shipping methoda pickup has noneAfterwards, only the deadline movesThe team pushes it back when a supplier is late (rescheduleWorkshopDue), and so does switchinga stocked piece for a made-to-order one.paymentpaidAtpromised datepromisedWorkshopDueAtpostponed deadlineworkshopDueAtisWorkshopDuePostponed: the ERP flags it andoffers the customer a postponement noticedelivery follows
Not to scale. The reference lead time and business days per week are read from packages/domain at every build of this documentation. The functions and columns named are checked there.
isWorkshopDuePostponedpackages/domain/src/workshop-due-date.ts · lines 159–166
export function isWorkshopDuePostponed(order: PromisedDue): boolean {
	const promised = promisedWorkshopDueOf(order);
	return (
		promised !== null &&
		order.workshopDueAt !== null &&
		order.workshopDueAt.getTime() > promised.getTime()
	);
}

A quote keeps the lead time of its PDF

The lead time a quote promises is frozen when it’s sent (Quote.leadTimeWeeksMin, leadTimeWeeksMax, locked by Quote_guard, migration 20261107120000_delai_promis_du_devis). The quote page on the storefront, online payment and acceptance in the store read it back without recomputing it: “the due date of their order is the one in the document they signed”.

A supplier’s observed lead time

A supplier’s observed lead time is computed from its last ten receipts over the past twenty-four months, and it takes at least three (apps/erp/shared/lib/supplier-lead-time.ts). It goes from the median to the lead time that eight purchases out of ten met, and a week that has started counts as a full week. The lead time a quote promises takes, bound by bound, the longer of the declared lead time and the observed one (promisedLeadTimeWeeks). It gets longer for a slower supplier, but it never gets shorter for a faster one: “the margin of a faster supplier stays with the store”.

The promise chain

For a paid order waiting on a piece from a supplier, each link from the purchase to the delivery gets a verdict: late, at risk, unknown, on time, done (apps/erp/modules/orders/lib/promise-chain.ts). The worst one becomes the weak link. The date you can expect from a purchase in transit always says what it rests on. First, it’s the date recorded on the purchase (usually the one in the supplier’s order acknowledgement), shifted by the average delay when the supplier is late more than half the time. If there isn’t one, it’s the order date plus the lead time that eight purchases out of ten met. Otherwise, there’s nothing. “No model decides anything here, and nothing is written: it is a view, recomputed on every render.”

The results

  • The date is the same everywhere. The product page, the home page, the Christmas deadline, the feed and the order count with the same primitives, and every gap found on November 7 was fixed at its source.
  • The promise no longer gets lost. The order keeps what was promised at payment, the workshop keeps its deadline, and the gap between the two is what triggers the notice to the customer.
  • You see the threat before the date. The promise chain says which purchase, from which supplier, puts which order at risk, and what that forecast rests on.

The limits

  • The storefront’s product page announces the declared lead time. Only the quote lengthens it according to the supplier’s observed lead time. On the storefront, a slow supplier only shows once the order is paid, in the promise chain.
  • The same rule is written twice. The storefront counts in calendar days, the order in instants. Both rely on the same primitive and the same constant, but it’s not the same function.
  • Three receipts isn’t much. Below that threshold, the observed lead time doesn’t exist and only the declared lead time applies. Above it, the observed lead time follows the last ten purchases. So it only sees a supplier slowing down after a few late receipts.
  • With the upper bound, the store often looks slower than it is. That’s what it costs to announce a date we actually meet.

On this page