F1 AI Sales & Inventory Web App

SIMS — 5 AI Prompts to Build a Complete Sales & Inventory Management System

Google Apps Script + Google Sheets · Navy Blue dashboard · paste each prompt in order

Watch the Full Build Tutorial on YouTube

1

Foundation & Auth

Build a Google Apps Script web app — Sales & Inventory Management System. Two files: Code.gs + index.html (React 18 via CDN, DataTables, SweetAlert2, Chart.js, Font Awesome). Navy Blue theme (#001f3f / #0074D9), collapsible sidebar, skeleton loaders, mobile friendly. Create sheets: Users (userId, fullName, emailAddress, passwordPlain, phoneNumber, userRole, accountStatus, createdAt, updatedAt, lastLoginAt, profileImageUrl), ActivityLogs, AppSettings (key/value — applicationName, currencySymbol, logoUrl, aiProvider, geminiApiKey, openaiApiKey). Write utility helpers with clear names: getSheetByName, readAllRows, generateNextId, findRowByColumn, currentIsoTimestamp, cacheOrCompute, invalidateAllCaches, recordActivityLog. Server functions: authenticateUser, getAllUsers, createUser, updateUserDetails, deleteUserAccount, toggleUserAccountStatus, getCurrentUserProfile, changeMyPassword, getPublicAppSettings, getAdminAppSettings, saveAppSettings, uploadApplicationLogo. Frontend: login screen, dashboard shell with sidebar (Users / Profile / Settings), SweetAlert2 for all dialogs, google.script.run for all AJAX, pass userId+userRole on every call. Seed one admin user.
2

Master Data

Add master-data modules to SIMS. Reuse utilities + theme from Prompt 1. New sheets: Customers (customerId, customerName, emailAddress, phoneNumber, streetAddress, cityName, taxRegistrationNumber, contactPersonName, creditLimit, outstandingBalance, paymentTerms, accountStatus), Products (productId, productName, skuCode, measurementUnit, sellingPrice, costPrice, stockOnHand, lowStockThreshold, isTaxable, categoryName, productStatus), Suppliers (same shape as Customers minus credit), TaxSettings (taxId, taxName, taxRatePercent, isDefaultTax, taxStatus). Server functions: getAllCustomers / createCustomer / updateCustomerDetails / deleteCustomer, same set for products & suppliers & tax, plus adjustProductStock(productId, quantityDelta, reason, userId, userRole) and clearOtherDefaultTaxFlags. Frontend: DataTable per module (10/page, CSV/PDF/Print), add/edit modals, SweetAlert2 confirms, skeleton loaders, floating loading popup (not full-page dim), DaisyUI-style toggle switches. Build a reusable SearchableDropdown & SearchableMultiSelect — never plain <select>. Products list shows low-stock red badge when stockOnHand < lowStockThreshold.
3

Sales Pipeline

Build the sales flow: Quotation → Sales Order → Invoice → Payment. Sheets: Quotations + QuotationItems, SalesOrders + SalesOrderItems, SalesInvoices + SalesInvoiceItems, CustomerPayments. Each header: id, parent doc number, customerId, dates, subTotalAmount, discountAmount, taxAmount, grandTotalAmount, status, amountPaid, balanceDue. Auto-number helpers: generateQuotationNumber (QUO-YYYYMM-0001), generateOrderNumber (SO-…), generateInvoiceNumber (INV-…). Server functions: CRUD for each + convertQuotationToOrder, changeSalesOrderStatus (Draft→Confirmed→Shipped→Delivered — call adjustProductStock on Shipped), getInvoiceableOrders, createInvoiceFromOrder, cancelInvoice, recordCustomerPayment (updates amountPaid, balanceDue, flips status to Paid, updates customer outstandingBalance). Frontend: sidebar — Quotations, Sales Orders, Invoices. CRM-style chevron pipeline tabs (clip-path, click to filter). Line-item editor with SearchableDropdown + qty + price + discount auto-totals. Printable invoice view with logo + currency from AppSettings. "Record Payment" modal. Validation: no invoice for already-invoiced order, no payment > balanceDue, no cancelling paid invoice without admin.
4

Procurement & Expenses

Build the payables side + ledgers. Sheets: PurchaseOrders + PurchaseOrderItems, SupplierPayments, BusinessExpenses (expenseId, expenseDate, expenseCategory, expenseDescription, expenseAmount, paymentMethod, vendorName, isRecurring). Auto-number: generatePurchaseOrderNumber (PO-YYYYMM-0001). Server functions: CRUD for PO + changePurchaseOrderStatus (Draft→Sent→Confirmed→Received — on Received call adjustProductStock with +quantity), recordSupplierPayment (updates amountPaid, balanceDue), getUnpaidPurchaseOrdersForSupplier, getCustomerLedger(customerId, startDate, endDate), getSupplierLedger(supplierId, …) — chronological debit/credit/running-balance. Expense CRUD with categories: Rent, Utilities, Salaries, Marketing, Office Supplies, Travel, Software, Other. Frontend: sidebar groups — Procurement (Purchase Orders), Finance (Expenses, Customer Ledger, Supplier Ledger). PO page mirrors Sales Order UX (chevron tabs, line editor, payment modal). Ledger pages: date-range + party dropdown + colour-coded debit/credit/running-balance DataTable, printable. Expense page: monthly total card + category filter. Use parseFloat(value)||0 everywhere. Format money with currencySymbol from AppSettings.
5

Dashboard, Reports, Email & AI Chat

Ship the intelligence layer. getDashboardAnalytics returns: totalRevenueThisMonth, totalPurchasesThisMonth, totalExpensesThisMonth, netProfitThisMonth, outstandingReceivables, outstandingPayables, lowStockProductCount, topFiveCustomersByRevenue, topFiveProductsBySales, revenueByMonthSeries (12mo), salesVsExpensesSeries (6mo), invoiceStatusBreakdown. Each month figure carries percentChangeVsLastMonth. Cache 5 min. Home page: 6 stat cards + highlight card + 3 Chart.js charts (line/bar/doughnut). getReportData(reportType, filters, userId, userRole) — types: salesByPeriod, salesByCustomer, salesByProduct, inventoryValuation, lowStock, accountsReceivableAging (0-30/31-60/61-90/90+), accountsPayableAging, profitAndLoss, expensesByCategory, taxReport. Reports page: type dropdown + date range → DataTable with CSV/PDF/Print. Email: buildBrandedEmailHtml helper + sendInvoiceEmail, sendPaymentReceiptEmail, sendPaymentReminderEmail, sendSalesOrderEmail, sendPurchaseOrderEmail. Log each send. Check MailApp quota first. AI Assistant: chatWithAiAssistant(userMessage, userId, userRole) — reads aiProvider + keys from AppSettings, builds live context via buildAssistantContextSnapshot (today's sales, top customers, low stock, unpaid invoices), routes to callGeminiApi or callOpenAiApi. Chat UI: bubble conversation, typing indicator, suggested-prompt chips. Also: getActivityLogs (admin audit page, filterable), seedDemoData (generic YouTube-safe names like "Horizon Trading LLC"), About page with role matrix + Rameez Scripts credits.