using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PowderCoating.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class SeedInitialDashboardTips : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // Only seed if the table is empty — preserves any tips already managed via the UI
            migrationBuilder.Sql(@"
IF NOT EXISTS (SELECT 1 FROM [DashboardTips])
BEGIN
    INSERT INTO [DashboardTips] ([TipText], [IsActive], [CreatedAt]) VALUES
    ('Jobs can be viewed as a Kanban board. Click the ''Board View'' button on the Jobs page to drag-and-drop jobs between status columns.', 1, GETUTCDATE()),
    ('Speed up job creation with Job Templates. Save a common job configuration as a template from the job details page and reuse it next time.', 1, GETUTCDATE()),
    ('Customers can approve quotes online without calling you. Use the ''Send for Approval'' button on a quote — they get a link to review, approve, or reject.', 1, GETUTCDATE()),
    ('Use the AI Photo Quote feature to estimate surface area and pricing from photos. Start a new quote and choose ''AI Photo Quote'' as the item type.', 1, GETUTCDATE()),
    ('Track who''s working on what with Worker Assignment. Open any job and use the Assignment card to assign it to a specific shop worker.', 1, GETUTCDATE()),
    ('Set a Reorder Point on inventory items and you''ll get low-stock alerts on the dashboard before you run out.', 1, GETUTCDATE()),
    ('The Oven Scheduler helps you batch jobs by coating type and color to minimize changeovers. Find it under Operations in the main menu.', 1, GETUTCDATE()),
    ('The Shop Access Code on each job generates a QR code your team can scan to advance the job status right from the shop floor — no login required.', 1, GETUTCDATE()),
    ('Record a deposit on a quote or job before work starts. Deposits are automatically applied to the invoice when you create it.', 1, GETUTCDATE()),
    ('Pricing Tiers let you set automatic discounts for your best commercial customers. Configure them under Settings → Pricing Tiers.', 1, GETUTCDATE()),
    ('Flag a customer as Tax Exempt and the system will automatically zero out tax on their quotes and invoices.', 1, GETUTCDATE()),
    ('The Reports section has over 20 reports including Profit & Loss, AR Aging, Powder Usage, and Job Cycle Time — all exportable to PDF.', 1, GETUTCDATE()),
    ('Add photos directly from the job details page. Photos are stored with the job and are visible to customers using the Shop Access Code.', 1, GETUTCDATE()),
    ('Use Job Notes to log progress, flag issues, or leave instructions for the next shift — all visible in real time on the job details page.', 1, GETUTCDATE()),
    ('The Oven Scheduler tracks capacity by square footage, so you can fill each oven run to its rated maximum load.', 1, GETUTCDATE()),
    ('Export your customers, jobs, quotes, and inventory to CSV anytime from the Tools page. You can also export all data at once as a ZIP.', 1, GETUTCDATE()),
    ('Import your existing QuickBooks data — customers, vendors, chart of accounts, and inventory — directly from the Tools page.', 1, GETUTCDATE()),
    ('Catalog Items are your pre-priced services. Add common coating types, prep services, and labor rates once and reuse them on any quote.', 1, GETUTCDATE()),
    ('Multi-stage jobs? Use Prep Services on quote items to add sandblasting, masking, or custom prep costs to each individual line item.', 1, GETUTCDATE()),
    ('The Setup Wizard walks you through all your operating costs — oven cost per hour, labor rates, overhead — so pricing calculations are accurate from day one.', 1, GETUTCDATE()),
    ('Create an invoice directly from a completed job in one click. All line items carry over automatically with no re-entry needed.', 1, GETUTCDATE()),
    ('Partial payments are supported on invoices. Record multiple payments over time and the system tracks the remaining balance automatically.', 1, GETUTCDATE()),
    ('The Accounts Payable module tracks your vendor bills so you always know what''s owed and when it''s due.', 1, GETUTCDATE()),
    ('Purchase Orders let you formalize vendor orders, receive inventory against them, and convert them directly to vendor bills.', 1, GETUTCDATE()),
    ('Equipment records track each piece of shop equipment, its service history, and current status so nothing falls through the cracks.', 1, GETUTCDATE()),
    ('Schedule preventive maintenance tasks on your equipment and the system will flag overdue items on your dashboard automatically.', 1, GETUTCDATE()),
    ('Gift Certificates can be issued and redeemed from the Billing section — great for promotions, referral programs, or customer goodwill.', 1, GETUTCDATE()),
    ('Use the Quotes section to build estimates for prospects (non-customers) and convert them to a full customer record once the quote is approved.', 1, GETUTCDATE()),
    ('The Job Cycle Time report shows average time from job creation to delivery — a great way to spot bottlenecks in your shop workflow.', 1, GETUTCDATE()),
    ('The Powder Usage report breaks down consumption by color and job so you can optimize purchasing and reduce waste.', 1, GETUTCDATE()),
    ('The AR Aging report shows outstanding invoices grouped by age — 30, 60, 90+ days — so you can prioritize collections calls.', 1, GETUTCDATE()),
    ('You can add multiple coats with different colors to a single quote item. The system calculates powder needed for each coat separately.', 1, GETUTCDATE()),
    ('Powder Needed is calculated live in the quote wizard based on surface area, coverage rate, and efficiency — so you know exactly how much to order before you start.', 1, GETUTCDATE()),
    ('The Oven Scheduler''s ''Suggest Batches'' feature automatically groups pending jobs by coating compatibility to maximize each oven run.', 1, GETUTCDATE()),
    ('Shop Workers can be assigned roles like Sandblaster, Coater, or Quality Control. These roles help you track who does what on each job.', 1, GETUTCDATE()),
    ('Print or text a job''s QR code to your shop workers. Scanning it opens a simple page where they can move the job to the next status step without touching the main app.', 1, GETUTCDATE()),
    ('Credit limits on commercial customers help you manage risk. The system tracks each customer''s outstanding balance against their limit.', 1, GETUTCDATE()),
    ('The AI Photo Quote uses Claude AI to analyze photos of the item, ask clarifying questions, and estimate surface area, complexity, and pricing — all before the item arrives.', 1, GETUTCDATE()),
    ('Vendor records include payment terms, contact info, and a linked transaction history so you can see everything related to a supplier in one place.', 1, GETUTCDATE()),
    ('The Setup Wizard can be re-run any time from Company Settings if you want to update your operating costs, oven configuration, or workflow defaults.', 1, GETUTCDATE()),
    ('Bills and Expenses are now in one unified list under Bills / Expenses in the menu. Use the type filter to view just bills, just expenses, or both at once.', 1, GETUTCDATE()),
    ('Upload a PDF or photo receipt when creating a bill. The system stores it with the bill so you always have documentation at hand.', 1, GETUTCDATE()),
    ('The ''Upload and Process Receipt Image'' button on a new bill uses AI to extract the vendor, date, total, and line items — and attaches the file automatically.', 1, GETUTCDATE()),
    ('When entering bill line items, the system automatically suggests the best expense account as soon as you finish typing the description — no manual lookup needed.', 1, GETUTCDATE()),
    ('Mark a bill as paid right from the Create screen using the ''I Already Paid This'' toggle. Record the payment method and bank account in one step.', 1, GETUTCDATE()),
    ('The Cash Flow Forecast report uses AI to project your 30, 60, and 90-day cash position based on open invoices, outstanding bills, and your active job pipeline.', 1, GETUTCDATE()),
    ('Run the Anomaly Detection report regularly to catch duplicate bills, unusual vendor charges, and expense accounts running over their normal monthly spend.', 1, GETUTCDATE()),
    ('Anomaly Detection flags duplicates as Critical — meaning two bills from the same vendor for the same amount within 30 days. Always worth a quick review before paying.', 1, GETUTCDATE()),
    ('The AR Follow-up Email tool in the AR Aging report drafts a professional collections email for you — the tone automatically adjusts based on how many days overdue the invoice is.', 1, GETUTCDATE()),
    ('The Plain-English Financial Summary in the Full Analytics view turns your P&L numbers into a short, readable paragraph — great for a quick monthly health check.', 1, GETUTCDATE())
END
");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("DELETE FROM [DashboardTips]");
        }
    }
}
