Build a SaaS-based Inventory Management + POS + Basic Accounting system using Laravel (backend) and MySQL. The system must follow multi-tenant architecture with strict data isolation. ================================================== 1. MULTI-TENANT (SAAS) ================================================== - Each tenant = one customer account - Each tenant can have multiple companies (restricted by subscription plan) Tables: - tenants: id, name, plan_id, subscription_status - plans: id, name, price, max_companies (nullable), max_users Rules: - Restrict company creation based on plan.max_companies ================================================== 2. COMPANY MASTER ================================================== - companies: - id, tenant_id - name, gst_number, state, address - invoice_prefix - One tenant → multiple companies - Each company has separate: - GST - stock - invoices - accounting ================================================== 3. USER MANAGEMENT ================================================== - users belong to tenant - user_companies: - user_id, company_id, role ================================================== 4. LEDGER SYSTEM (ACCOUNTING BASE) ================================================== Create unified ledger table instead of separate customer/supplier: TABLE: ledgers - id - tenant_id - company_id - name - type (customer, supplier) - group (sundry_debtors, sundry_creditors) - gst_number - state - opening_balance - balance_type (debit/credit) RULES: - Customers → Sundry Debtors - Suppliers → Sundry Creditors ================================================== 5. PRODUCTS ================================================== - products: - id, tenant_id, company_id - name, sku - purchase_price, selling_price - gst_rate, hsn_code - stock_quantity ================================================== 6. PURCHASE MODULE ================================================== - purchases - purchase_items On Purchase: - Increase stock - Increase creditor balance ================================================== 7. SALES (POS SYSTEM) ================================================== Support BOTH: A. B2C (Retail) - Fast billing - GST inclusive pricing B. B2B (Business) - GST invoice required Tables: - sales - sale_items sale_items fields: - quantity - price - discount - taxable_value - cgst_amount - sgst_amount - igst_amount - total On Sale: - Decrease stock - If credit sale → increase debtor balance ================================================== 8. CREDIT NOTE (SALES RETURN) ================================================== - credit_notes - credit_note_items LOGIC: - Customer returns goods - Increase stock - Reduce debtor balance - Reverse GST ================================================== 9. DEBIT NOTE (PURCHASE RETURN) ================================================== - debit_notes - debit_note_items LOGIC: - Return goods to supplier - Decrease stock - Reduce creditor balance - Reverse GST ================================================== 10. PAYMENTS ================================================== TABLE: payments - id - tenant_id - company_id - ledger_id - type (receipt/payment) - amount - payment_mode (cash, UPI, card) - reference LOGIC: - Receipt → reduce debtor - Payment → reduce creditor ================================================== 11. GST RULES (INDIA) ================================================== - Product has gst_rate Tax logic: IF company_state == customer_state: apply CGST + SGST ELSE: apply IGST Support: - Tax inclusive - Tax exclusive ================================================== 12. STOCK MANAGEMENT ================================================== Maintain in products.stock_quantity Updates: - Purchase → increase - Sale → decrease - Credit Note → increase - Debit Note → decrease ================================================== 13. VALIDATIONS ================================================== - Prevent negative stock - Prevent company creation beyond plan limit - Ensure tenant_id and company_id in ALL tables - Always filter queries: WHERE tenant_id = ? AND company_id = ? ================================================== 14. ARCHITECTURE ================================================== - Laravel API (clean architecture) - Service Layer: - SaleService - PurchaseService - LedgerService - CreditNoteService - DebitNoteService - Middleware: - TenantMiddleware - CompanyMiddleware ================================================== 15. DELIVERABLES ================================================== Generate: 1. Database migrations 2. Eloquent models with relationships 3. Controllers (CRUD + POS APIs) 4. Service classes (business logic) 5. GST helper functions 6. API routes ================================================== IMPORTANT NOTES ================================================== - Do NOT mix tenant/company data - Use ledger instead of separate customer/supplier tables - Keep system scalable (SaaS ready) - Follow Laravel best practices