fix: add line items to repair tickets in music store seed
Tickets with work in progress or ready for pickup now have realistic line items (labor, parts, flat rates, consumables). The ready ticket (David Smith — Violin) has billable items for POS checkout testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -210,15 +210,32 @@ async function seed() {
|
||||
// First clear any generic tickets
|
||||
await sql`DELETE FROM repair_ticket WHERE id NOT IN (SELECT DISTINCT repair_ticket_id FROM repair_note)`
|
||||
|
||||
const tickets = [
|
||||
{ customer: 'Mike Thompson', item: 'Jay Haide Cello 4/4', serial: 'JH-C44-1892', problem: 'Endpin mechanism worn, slips during playing. Seam opening near lower bout.', condition: 'fair', status: 'in_progress', estimate: '95.00' },
|
||||
{ customer: 'Emily Chen', item: 'Scott Cao Viola 16"', serial: 'SC-VA16-0547', problem: 'Bridge warped, soundpost has shifted. Needs full setup.', condition: 'fair', status: 'pending_approval', estimate: '120.00' },
|
||||
{ customer: 'David Smith', item: 'German Workshop Violin 4/4', serial: null, problem: 'Bow needs rehair, bridge slightly warped', condition: 'fair', status: 'ready', estimate: '105.00' },
|
||||
{ customer: 'Carlos Garcia', item: 'Eastman VL305 Violin 4/4', serial: 'EA-V305-X42', problem: 'Fingerboard wear near 3rd position, open seam on top plate', condition: 'good', status: 'new', estimate: null },
|
||||
{ customer: 'Patricia Williams', item: 'Shen SB100 Bass 3/4', serial: 'SH-B34-0891', problem: 'Bridge feet not fitting soundboard, wolf tone on G string', condition: 'good', status: 'diagnosing', estimate: null },
|
||||
{ customer: 'Walk-In Customer', item: 'Student Violin 3/4', serial: null, problem: 'Pegs slipping, E string buzzing against fingerboard', condition: 'fair', status: 'intake', estimate: null },
|
||||
{ customer: 'Smith Family', item: 'Suzuki Student Violin 1/2', serial: null, problem: 'Pegs slipping, bridge leaning forward', condition: 'fair', status: 'new', estimate: null },
|
||||
{ customer: 'Rivera Family', item: 'Eastman VC80 Cello 3/4', serial: 'EA-VC80-3Q-X01', problem: 'A string peg cracked, needs replacement. Bow rehair overdue.', condition: 'good', status: 'in_progress', estimate: '85.00' },
|
||||
const tickets: { customer: string; item: string; serial: string | null; problem: string; condition: string; status: string; estimate: string | null; lineItems: { type: string; desc: string; qty: number; price: number; cost?: number }[] }[] = [
|
||||
{ customer: 'Mike Thompson', item: 'Jay Haide Cello 4/4', serial: 'JH-C44-1892', problem: 'Endpin mechanism worn, slips during playing. Seam opening near lower bout.', condition: 'fair', status: 'in_progress', estimate: '95.00', lineItems: [
|
||||
{ type: 'labor', desc: 'Endpin repair — remove and refit mechanism', qty: 1, price: 45 },
|
||||
{ type: 'labor', desc: 'Seam repair — lower bout', qty: 1, price: 45 },
|
||||
{ type: 'consumable', desc: 'Hide glue', qty: 1, price: 5, cost: 5 },
|
||||
]},
|
||||
{ customer: 'Emily Chen', item: 'Scott Cao Viola 16"', serial: 'SC-VA16-0547', problem: 'Bridge warped, soundpost has shifted. Needs full setup.', condition: 'fair', status: 'pending_approval', estimate: '120.00', lineItems: [
|
||||
{ type: 'flat_rate', desc: 'Bridge replacement — Viola', qty: 1, price: 75, cost: 18 },
|
||||
{ type: 'labor', desc: 'Soundpost adjustment', qty: 1, price: 25 },
|
||||
{ type: 'flat_rate', desc: 'String change — Viola', qty: 1, price: 35, cost: 32 },
|
||||
]},
|
||||
{ customer: 'David Smith', item: 'German Workshop Violin 4/4', serial: null, problem: 'Bow needs rehair, bridge slightly warped', condition: 'fair', status: 'ready', estimate: '105.00', lineItems: [
|
||||
{ type: 'flat_rate', desc: 'Bow rehair — Violin 4/4', qty: 1, price: 65, cost: 15 },
|
||||
{ type: 'flat_rate', desc: 'Bridge setup — Violin 4/4', qty: 1, price: 40, cost: 10 },
|
||||
{ type: 'consumable', desc: 'Bow hair — Mongolian white', qty: 1, price: 18, cost: 18 },
|
||||
]},
|
||||
{ customer: 'Carlos Garcia', item: 'Eastman VL305 Violin 4/4', serial: 'EA-V305-X42', problem: 'Fingerboard wear near 3rd position, open seam on top plate', condition: 'good', status: 'new', estimate: null, lineItems: [] },
|
||||
{ customer: 'Patricia Williams', item: 'Shen SB100 Bass 3/4', serial: 'SH-B34-0891', problem: 'Bridge feet not fitting soundboard, wolf tone on G string', condition: 'good', status: 'diagnosing', estimate: null, lineItems: [] },
|
||||
{ customer: 'Walk-In Customer', item: 'Student Violin 3/4', serial: null, problem: 'Pegs slipping, E string buzzing against fingerboard', condition: 'fair', status: 'intake', estimate: null, lineItems: [] },
|
||||
{ customer: 'Smith Family', item: 'Suzuki Student Violin 1/2', serial: null, problem: 'Pegs slipping, bridge leaning forward', condition: 'fair', status: 'new', estimate: null, lineItems: [] },
|
||||
{ customer: 'Rivera Family', item: 'Eastman VC80 Cello 3/4', serial: 'EA-VC80-3Q-X01', problem: 'A string peg cracked, needs replacement. Bow rehair overdue.', condition: 'good', status: 'in_progress', estimate: '85.00', lineItems: [
|
||||
{ type: 'part', desc: 'Pegs — Cello Boxwood Set (4)', qty: 1, price: 28, cost: 10 },
|
||||
{ type: 'labor', desc: 'Peg fitting — Cello', qty: 1, price: 35 },
|
||||
{ type: 'flat_rate', desc: 'Bow rehair — Cello', qty: 1, price: 75, cost: 18 },
|
||||
{ type: 'consumable', desc: 'Peg compound', qty: 1, price: 6, cost: 6 },
|
||||
]},
|
||||
]
|
||||
|
||||
for (const t of tickets) {
|
||||
@@ -226,8 +243,12 @@ async function seed() {
|
||||
if (existing.length > 0) continue
|
||||
const num = String(Math.floor(100000 + Math.random() * 900000))
|
||||
const acctId = acctIds[t.customer] ?? null
|
||||
await sql`INSERT INTO repair_ticket (ticket_number, customer_name, account_id, item_description, serial_number, problem_description, condition_in, status, estimated_cost) VALUES (${num}, ${t.customer}, ${acctId}, ${t.item}, ${t.serial}, ${t.problem}, ${t.condition}, ${t.status}, ${t.estimate})`
|
||||
console.log(` Ticket: ${t.customer} — ${t.item} [${t.status}]`)
|
||||
const [ticket] = await sql`INSERT INTO repair_ticket (ticket_number, customer_name, account_id, item_description, serial_number, problem_description, condition_in, status, estimated_cost) VALUES (${num}, ${t.customer}, ${acctId}, ${t.item}, ${t.serial}, ${t.problem}, ${t.condition}, ${t.status}, ${t.estimate}) RETURNING id`
|
||||
for (const li of t.lineItems) {
|
||||
const total = (li.qty * li.price).toFixed(2)
|
||||
await sql`INSERT INTO repair_line_item (repair_ticket_id, item_type, description, qty, unit_price, total_price, cost) VALUES (${ticket.id}, ${li.type}, ${li.desc}, ${li.qty}, ${li.price.toFixed(2)}, ${total}, ${li.cost?.toFixed(2) ?? null})`
|
||||
}
|
||||
console.log(` Ticket: ${t.customer} — ${t.item} [${t.status}]${t.lineItems.length > 0 ? ` (${t.lineItems.length} items)` : ''}`)
|
||||
}
|
||||
|
||||
// --- School Orchestra Batch ---
|
||||
|
||||
Reference in New Issue
Block a user