REPOSITORY CODING · MEDIUM
Recommend the lowest landed price before delivery speed
The recommendation favors a faster but more expensive supplier. Restore the complete order: total cents, lead days, supplier, quote ID. The recommended object must be the first eligible option, or null for an empty comparison.
Repository ImplementationSupplier quotation comparison desk
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
PHP · 50 minute session
- Compare quotes for a requested SKU and positive quantity. Buy whole packs, rounding the pack count up. The quote must have enough stock packs and leadDays no greater than maxLeadDays.
- Prices use integer cents in one already-agreed currency. Each quote has quantity tiers in packs, including minPacks=1. Use the greatest threshold reached by the purchased pack count. Thresholds may be supplied in any order.
- For tax-exclusive prices, add basis-point tax rounded half-up once on the entire goods line. Do not add tax again for tax-inclusive quotes. ShippingCents is an already-taxed final amount added once.
- Quote identity is supplier plus id. Resolve the highest revision before eligibility filtering. A quote expires at now >= expires. Do not resurrect an older revision when a newer one is expired or ineligible.
- Return eligible options ordered by totalCents, leadDays, supplier and quote ID; the first is recommended or null. Return excluded latest quotes ordered by supplier and ID, with reason precedence different-sku, expired, late, insufficient-stock.
- Reject contradictory same revisions, duplicate tier thresholds and invalid numeric values. Exact duplicate deliveries are ignored. This service compares proposals only; it does not place orders or make payments.