All MicroEvals
Prompt: Build Complete Delivery Note Module (Frontend + Back...
Create MicroEval
Header image for Prompt: Build Complete Delivery Note Module (Frontend + Back...

Prompt: Build Complete Delivery Note Module (Frontend + Back...

Prompt

Prompt: Build Complete Delivery Note Module (Frontend + Backend) Role: Senior Full-Stack Developer (Flask, SQLAlchemy, jQuery). Objective: Write the complete, production-ready code for the Delivery Note Module from scratch. This includes the HTML template, JavaScript logic, and specific backend updates. The goal is to resolve all persistent issues (layout, auto-numbering crashes, save errors, and missing features) in one go. Part 1: Backend Updates (app.py) Task: Rewrite the generate_voucher_number function to be "Zero-Config" compliant. Logic: Query VoucherSeries for the given financial_year_id and voucher_type. Critical Fix: If NO series is found, automatically create a default series immediately (do not raise an error). Default Prefix: First 3 letters of type (e.g., "DEL/"). Starting Number: 1. Padding: 3. Action: session.add(series), session.flush(). Proceed to generate the number using this new or existing series. Part 2: Frontend UI (templates/delivery_notes.html) Task: Create a new file with the following strict structure: Layout Inheritance: Navbar: Exact copy of index.html navbar (including mobile-menu-btn). Sidebar: Exact copy of index.html sidebar logic (including .sidebar-overlay). CSS: Include the full CSS block from index.html to ensure the sidebar works on Android (z-index, transitions, overlay). Header Section: Breadcrumb/Title: "Delivery Notes". Quick Actions: Month Dropdown: "Jump to Month" (Auto-populated via JS). Settings Button: "Set Prefix" (Opens Modal). Primary Button: "New Delivery Note" (Opens Create Modal). Advanced Filter Card (Matching purchases.html): Fields: Date Range (From/To), Client (Select2), Status (Unbilled/Invoiced/All). Summary Box: Display "Total Value: ₹ X.XX" inside this card. Data Table: Columns: Checkbox, Date, Challan No, Client Name, Status Badge, Amount, Actions (Edit/Print). Style: table-hover, vertical-align middle. Sticky Footer (Bulk Actions): Hidden by default. slides up when rows are selected. Buttons: "Generate Invoice", "Print Selected", "Delete". Part 3: Frontend Logic (static/js/delivery_notes.js) Task: Write a robust modular script (DeliveryNotes object) with the following features: Initialization: Bind Sidebar Toggles (Mobile support). Populate Month Dropdown (Last 12 months). Load Master Data (Clients/Items) for select inputs. Modal Logic (Create/Edit): Auto-Numbering Preview: When opening "New", call /api/settings/prefix?preview_next=true. Display the result (e.g., "DEL/001") in the "Challan No" field but keep it readonly. Edit Mode: Fetch /api/vouchers/<id>. Populate Date, Client (trigger change), Narration, and All Items (Create rows dynamically). Item Table Logic: Row Calculation: Qty * Rate = Amount. Update Subtotal/Grand Total instantly on change. Item Selection: When an item is picked, auto-fill HSN, Unit, and Rate from the item's data attributes. Save Logic (Critical Fixes): Payload Construction: voucher_no: If value is "Auto" or empty, send null. Else send the value. type: Send exactly 'Delivery Note' (Title Case). items: Ensure qty, rate, amount are parsed as floats (not strings). Validation: Block save if Client is empty. Error Handling: Alert xhr.responseJSON.error if save fails. Print Logic: Open "Print Options Modal" (Checkboxes for HSN/Rate/Amount). On confirm, POST to /api/print/voucher/<id> with the selected options. Output: Provide the complete, copy-paste ready code for: app.py (Only the updated generate_voucher_number function). templates/delivery_notes.html. static/js/delivery_notes.js.

A system prompt was added to support web rendering

Drag to resize
Drag to resize
Drag to resize