ReviewAloud/priyansh-narang2308/reviewaloud-sandboxDemo · sample data

Order history helpers #2

Open
priyansh-narang2308main ← feature/order-historyc8277dc3 files · +30 −1Open on GitHub ↗

Demo, no login. A snapshot of a real public sandbox PR with planted test cases. Dictate or type real comments; publishing is simulated and Promise Ledger results are a recorded live run · 20 oct 2026. Nothing is sent to GitHub or AI. Use it on your own PRs →

Added

.gitignore

+1 −0
@@ -0,0 +1 @@
1.DS_Store
Modified

src/format.ts

+1 −1
@@ -1,5 +1,5 @@
11export function formatPrice(amount: number): string {
2 return "Rs " + amount.toFixed(2);
2 return "Rs " + (Math.round(amount * 100) / 100).toFixed(2);
33}
44
55export function formatQuantity(q: number): string {
Added

src/orders.ts

+28 −0
@@ -0,0 +1,28 @@
1import { type Cart, discountRate, subtotal } from "./cart";
2
3export type Order = { id: string; cart: Cart; placedAt: string };
4
5export function orderTotal(order: Order): number {
6 const base = subtotal(order.cart);
7 return base - base * discountRate(order.cart.discountCode);
8}
9
10export function averageOrderValue(orders: Order[]): number {
11 // Average value across all orders.
12 const sum = orders.reduce((n, o) => n + orderTotal(o), 0);
13 return sum / orders.length;
14}
15
16export function recentOrders(orders: Order[]): Order[] {
17 return [...orders].sort((a, b) => b.placedAt.localeCompare(a.placedAt));
18}
19
20export function roundedTotal(order: Order): number {
21 return orderTotal(order);
22}
23
24export function addLine(order: Order, quantity: number, unitPrice: number): Order {
25 if (quantity <= 0) throw new Error("Quantity must be positive");
26 order.cart.items.push({ sku: `line-${order.cart.items.length}`, name: "custom", quantity, unitPrice });
27 return order;
28}
No line pinned

Click a diff line to pin it · shift-click for a range

0 drafts

Keyboard shortcuts

click
Pin a line (focuses the comment box for Wispr Flow)
shiftclick
Extend to a range within the hunk
j
Next line
k
Previous line
shiftj/k
Extend selection
n
Next hunk
p
Previous hunk
]
Next file
[
Previous file
c
Focus the comment box (also Enter)
⌘↵
Save comment
Esc
Leave the comment box · again to unpin
?
Show this list

Publish review · priyansh-narang2308/reviewaloud-sandbox#2

0 comments will be created as a draft review. Only you can see it on GitHub until you submit.