-- COMPREHENSIVE RESTORATION SCRIPT (MySQL/MariaDB)
-- Merged from Snippets 1, 2, 3 (Initial, V4, V5)
-- Total Tables: ~42

SET FOREIGN_KEY_CHECKS = 0;

-- --- DROP ALL TABLES ---
DROP TABLE IF EXISTS audit_logs;
DROP TABLE IF EXISTS attendance_records;
DROP TABLE IF EXISTS biometric_credentials;
DROP TABLE IF EXISTS sst_history;
DROP TABLE IF EXISTS credit_notes;
DROP TABLE IF EXISTS quality_checks;
DROP TABLE IF EXISTS app_settings;
DROP TABLE IF EXISTS settings;
DROP TABLE IF EXISTS machines;
DROP TABLE IF EXISTS delivery_notes;
DROP TABLE IF EXISTS purchase_orders;
DROP TABLE IF EXISTS plates;
DROP TABLE IF EXISTS finishing_blocks;
DROP TABLE IF EXISTS cheques;
DROP TABLE IF EXISTS payments;
DROP TABLE IF EXISTS roles;
DROP TABLE IF EXISTS recurring_invoices;
DROP TABLE IF EXISTS budgets;
DROP TABLE IF EXISTS customer_monitor_notes;
DROP TABLE IF EXISTS capital_contributions;
DROP TABLE IF EXISTS distributions;
DROP TABLE IF EXISTS accounting_entries;
DROP TABLE IF EXISTS accounts;
DROP TABLE IF EXISTS inventory_transactions;
DROP TABLE IF EXISTS inventory_stock;
DROP TABLE IF EXISTS warehouses;
DROP TABLE IF EXISTS production_steps;
DROP TABLE IF EXISTS order_items;
DROP TABLE IF EXISTS quotations;
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS partners;
DROP TABLE IF EXISTS chatbots;
DROP TABLE IF EXISTS employees;
DROP TABLE IF EXISTS printing_options;
DROP TABLE IF EXISTS finishing_options;
DROP TABLE IF EXISTS paper_types;
DROP TABLE IF EXISTS materials;
DROP TABLE IF EXISTS suppliers;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS fixed_assets;
DROP TABLE IF EXISTS liabilities;
DROP TABLE IF EXISTS commission_persons;
DROP TABLE IF EXISTS commissions;
DROP TABLE IF EXISTS expenses;
DROP TABLE IF EXISTS payslips;

SET FOREIGN_KEY_CHECKS = 1;

-- --- CREATE TABLES ---

-- 1. USERS
CREATE TABLE users (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    email VARCHAR(255) UNIQUE NOT NULL,
    password_hash TEXT NOT NULL,
    name VARCHAR(255),
    role VARCHAR(50) DEFAULT 'customer',
    avatar_url TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 2. CUSTOMERS
CREATE TABLE customers (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255),
    phone VARCHAR(50),
    company TEXT,
    address TEXT,
    tin VARCHAR(100),
    total_orders INTEGER DEFAULT 0,
    total_spent DECIMAL(14,2) DEFAULT 0,
    account_balance DECIMAL(14,2) DEFAULT 0,
    grant_portal_access BOOLEAN DEFAULT FALSE,
    portal_email VARCHAR(255),
    portal_password VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 3. SUPPLIERS
CREATE TABLE suppliers (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    contact_person VARCHAR(255),
    email VARCHAR(255),
    phone VARCHAR(50),
    contact VARCHAR(255),
    address TEXT,
    category VARCHAR(100),
    current_balance DECIMAL(14,2) DEFAULT 0,
    credit_limit DECIMAL(14,2) DEFAULT 10000,
    payment_terms TEXT,
    paymentTerms TEXT,
    isActive BOOLEAN DEFAULT TRUE,
    hasPortalAccess BOOLEAN DEFAULT FALSE,
    portal_username VARCHAR(255),
    portal_password VARCHAR(255),
    tin VARCHAR(100),
    rating INTEGER DEFAULT 5,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 4. MATERIALS
CREATE TABLE materials (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    category VARCHAR(100) NOT NULL,
    unit VARCHAR(50) NOT NULL,
    unit_price DECIMAL(14,2) DEFAULT 0,
    avg_cost DECIMAL(14,2) DEFAULT 0,
    current_stock DECIMAL(14,2) DEFAULT 0,
    min_stock DECIMAL(14,2) DEFAULT 0,
    inventory_lots JSON,
    supplier_id VARCHAR(36),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 5. PAPER TYPES
CREATE TABLE paper_types (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    weight VARCHAR(50),
    finish VARCHAR(100),
    description TEXT,
    price_per_unit DECIMAL(14,4) DEFAULT 0,
    unit_price DECIMAL(14,4) DEFAULT 0,
    in_stock INTEGER DEFAULT 0,
    current_stock INTEGER DEFAULT 0,
    suitable_sides VARCHAR(50),
    photo_url TEXT,
    sizes JSON,
    supplier_id VARCHAR(36),
    supplier VARCHAR(255),
    min_stock_level INTEGER DEFAULT 0,
    min_stock INTEGER DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 6. FINISHING OPTIONS
CREATE TABLE finishing_options (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    description TEXT,
    unit_price DECIMAL(14,2) DEFAULT 0,
    unit_cost DECIMAL(14,2) DEFAULT 0,
    price DECIMAL(14,2) DEFAULT 0,
    estimated_days INTEGER DEFAULT 1,
    cost_unit VARCHAR(50),
    price_tiers JSON,
    photo_url TEXT,
    requires_block BOOLEAN DEFAULT FALSE,
    block_settings JSON,
    supplier_id VARCHAR(36),
    supplier_name VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 7. ORDERS
CREATE TABLE orders (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    invoice_number VARCHAR(100) UNIQUE NOT NULL,
    barcode VARCHAR(255),
    customer_id VARCHAR(36),
    title VARCHAR(255) NOT NULL,
    description TEXT,
    status VARCHAR(50) DEFAULT 'pending',
    payment_status VARCHAR(50) DEFAULT 'unpaid',
    payment_type VARCHAR(50),
    total_price DECIMAL(14,2) DEFAULT 0,
    sst_percentage DECIMAL(5,2) DEFAULT 0,
    specifications JSON,
    files JSON,
    estimated_delivery TIMESTAMP NULL,
    completed_at TIMESTAMP NULL,
    paid_amount DECIMAL(14,2) DEFAULT 0,
    cost_of_goods_sold DECIMAL(14,2) DEFAULT 0,
    e_invoice_status VARCHAR(50) DEFAULT 'not_submitted',
    e_invoice_rejection_reason TEXT,
    validation_url TEXT,
    commission_person_id VARCHAR(36),
    commission_amount DECIMAL(14,2) DEFAULT 0,
    current_production_step_index INTEGER DEFAULT 0,
    quality_check_id VARCHAR(36),
    quality_status VARCHAR(50),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE SET NULL
);

-- 8. ORDER ITEMS
CREATE TABLE order_items (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    order_id VARCHAR(36) NOT NULL,
    name VARCHAR(255) NOT NULL,
    quantity INTEGER DEFAULT 1,
    specifications JSON,
    unit_price DECIMAL(14,2) DEFAULT 0,
    total_price DECIMAL(14,2) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE
);

-- 9. PRODUCTION STEPS
CREATE TABLE production_steps (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    order_id VARCHAR(36),
    name VARCHAR(255) NOT NULL,
    type VARCHAR(100) NOT NULL,
    status VARCHAR(50) DEFAULT 'pending',
    assigned_to VARCHAR(36),
    started_at TIMESTAMP NULL,
    received_at TIMESTAMP NULL,
    received_by VARCHAR(36),
    completed_at TIMESTAMP NULL,
    completed_by VARCHAR(36),
    completed BOOLEAN DEFAULT FALSE,
    notes TEXT,
    step_order INTEGER DEFAULT 0,
    estimated_days INTEGER DEFAULT 0,
    cost DECIMAL(14,2) DEFAULT 0,
    supplier_id VARCHAR(36),
    finishing_option_id VARCHAR(36),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE,
    FOREIGN KEY (assigned_to) REFERENCES users(id) ON DELETE SET NULL,
    FOREIGN KEY (received_by) REFERENCES users(id) ON DELETE SET NULL,
    FOREIGN KEY (completed_by) REFERENCES users(id) ON DELETE SET NULL,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL,
    FOREIGN KEY (finishing_option_id) REFERENCES finishing_options(id) ON DELETE SET NULL
);

-- 10. WAREHOUSES
CREATE TABLE warehouses (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    location TEXT,
    type VARCHAR(50) DEFAULT 'internal',
    code VARCHAR(50),
    is_default BOOLEAN DEFAULT FALSE,
    manager_name VARCHAR(255),
    contact_number VARCHAR(50),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 11. INVENTORY STOCK
CREATE TABLE inventory_stock (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    material_id VARCHAR(36),
    warehouse_id VARCHAR(36),
    quantity DECIMAL(14,2) DEFAULT 0,
    bin_number VARCHAR(100),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE(material_id, warehouse_id, bin_number),
    FOREIGN KEY (material_id) REFERENCES materials(id) ON DELETE CASCADE,
    FOREIGN KEY (warehouse_id) REFERENCES warehouses(id) ON DELETE CASCADE
);

-- 12. ACCOUNTS
CREATE TABLE accounts (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    code VARCHAR(100) UNIQUE NOT NULL,
    name VARCHAR(255) NOT NULL,
    type VARCHAR(100) NOT NULL,
    description TEXT,
    parent_id VARCHAR(36),
    is_system BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (parent_id) REFERENCES accounts(id) ON DELETE SET NULL
);

-- 13. ACCOUNTING ENTRIES
CREATE TABLE accounting_entries (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    category VARCHAR(100),
    description TEXT NOT NULL,
    reference VARCHAR(255),
    account_id VARCHAR(36),
    amount DECIMAL(16,2) DEFAULT 0,
    type ENUM('debit', 'credit'),
    order_id VARCHAR(36),
    customer_id VARCHAR(36),
    supplier_id VARCHAR(36),
    payment_method VARCHAR(100),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE RESTRICT,
    FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE SET NULL,
    FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE SET NULL,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 14. CHATBOTS
CREATE TABLE chatbots (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    description TEXT,
    avatar_url TEXT,
    system_instruction TEXT,
    model VARCHAR(255),
    is_default BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 15. PRINTING OPTIONS
CREATE TABLE printing_options (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name TEXT NOT NULL,
    description TEXT,
    type VARCHAR(100),
    base_price DECIMAL(10,2) DEFAULT 0,
    capacity_per_hour INTEGER DEFAULT 0,
    machine_model VARCHAR(255),
    supplier_id VARCHAR(36),
    supplier_name VARCHAR(255),
    operator_id VARCHAR(36),
    operator_name VARCHAR(255),
    photo_url TEXT,
    price_tiers JSON,
    sizes JSON,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 16. PARTNERS
CREATE TABLE partners (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    type VARCHAR(100),
    contact_info TEXT,
    participation_level VARCHAR(100),
    ownership_percentage DECIMAL(5,2) DEFAULT 0,
    photo_url TEXT,
    total_contribution DECIMAL(16,2) DEFAULT 0,
    total_distribution DECIMAL(16,2) DEFAULT 0,
    net_equity DECIMAL(16,2) DEFAULT 0,
    join_date DATE,
    email VARCHAR(255),
    phone VARCHAR(50),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 17. EMPLOYEES
CREATE TABLE employees (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE,
    role VARCHAR(100),
    start_date DATE,
    salary DECIMAL(10,2),
    hourly_rate DECIMAL(10,2),
    hours_worked DECIMAL(10,2) DEFAULT 0,
    total_earnings DECIMAL(10,2) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 18. QUOTATIONS
CREATE TABLE quotations (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    quotation_number VARCHAR(100) UNIQUE NOT NULL,
    customer_id VARCHAR(36),
    customer_name VARCHAR(255),
    date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    expiry_date TIMESTAMP NULL,
    items JSON,
    subtotal DECIMAL(14,2) DEFAULT 0,
    tax DECIMAL(14,2) DEFAULT 0,
    total DECIMAL(14,2) DEFAULT 0,
    status VARCHAR(50) DEFAULT 'draft',
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 19. APP SETTINGS / SETTINGS (Consolidated Logic)
CREATE TABLE settings (
    `key` VARCHAR(255) PRIMARY KEY,
    value JSON NOT NULL,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE app_settings (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    `key` VARCHAR(255) UNIQUE NOT NULL,
    value JSON NOT NULL,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- 20. MACHINES
CREATE TABLE machines (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    model VARCHAR(255),
    type VARCHAR(100),
    photo_url TEXT,
    status VARCHAR(50) DEFAULT 'operational',
    last_maintenance DATE,
    next_maintenance DATE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 21. PLATES & FINISHING BLOCKS
CREATE TABLE plates (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name TEXT NOT NULL,
    job_id VARCHAR(36),
    customer_name TEXT,
    purchase_date DATE,
    cost DECIMAL(14,2) DEFAULT 0,
    supplier_id VARCHAR(36),
    supplier_name TEXT,
    status VARCHAR(50) DEFAULT 'available',
    location TEXT,
    last_used TIMESTAMP NULL,
    times_used INTEGER DEFAULT 0,
    notes TEXT,
    photo_url TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE finishing_blocks (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name TEXT NOT NULL,
    job_id VARCHAR(36),
    customer_name TEXT,
    finishing_type VARCHAR(100),
    purchase_date DATE,
    cost DECIMAL(14,2) DEFAULT 0,
    supplier_id VARCHAR(36),
    supplier_name TEXT,
    status VARCHAR(50) DEFAULT 'available',
    location TEXT,
    last_used TIMESTAMP NULL,
    times_used INTEGER DEFAULT 0,
    notes TEXT,
    photo_url TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 22. AUDIT LOGS
CREATE TABLE audit_logs (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    user_id VARCHAR(36),
    user_name VARCHAR(255),
    action VARCHAR(50),
    entity VARCHAR(100),
    entity_id VARCHAR(36),
    details TEXT
);

-- 23. ATTENDANCE RECORDS
CREATE TABLE attendance_records (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    employee_id VARCHAR(36) NOT NULL,
    check_in TIMESTAMP NULL,
    check_out TIMESTAMP NULL,
    status VARCHAR(50) DEFAULT 'present',
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    action ENUM('check-in', 'check-out'),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE CASCADE
);

-- 24. BIOMETRIC CREDENTIALS
CREATE TABLE biometric_credentials (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    employee_id VARCHAR(36) NOT NULL,
    credential_id TEXT NOT NULL,
    public_key TEXT NOT NULL,
    registered_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE CASCADE
);

-- 25. SST HISTORY
CREATE TABLE sst_history (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    percentage DECIMAL(5,2) NOT NULL,
    effective_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    changed_by VARCHAR(255),
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 26. QUALITY CHECKS
CREATE TABLE quality_checks (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    order_id VARCHAR(36),
    order_title TEXT,
    customer_name TEXT,
    check_type VARCHAR(100),
    status VARCHAR(50) DEFAULT 'pending',
    inspector VARCHAR(255),
    checked_at TIMESTAMP NULL,
    score INTEGER DEFAULT 0,
    notes TEXT,
    images JSON,
    defects JSON,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 27. COMMISSIONS
CREATE TABLE commissions (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    person_name VARCHAR(255) NOT NULL,
    email VARCHAR(255),
    phone VARCHAR(50),
    type VARCHAR(50),
    commission_type ENUM('percentage', 'fixed'),
    commission_rate DECIMAL(5,2),
    total_commission DECIMAL(14,2) DEFAULT 0,
    pending_commission DECIMAL(14,2) DEFAULT 0,
    paid_commission DECIMAL(14,2) DEFAULT 0,
    total_sales DECIMAL(14,2) DEFAULT 0,
    join_date DATE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 28. PAYSLIPS
CREATE TABLE payslips (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    employee_id VARCHAR(36),
    pay_period VARCHAR(100),
    pay_date DATE,
    gross_salary DECIMAL(14,2) DEFAULT 0,
    deductions JSON,
    net_pay DECIMAL(14,2) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 29. EXPENSES
CREATE TABLE expenses (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    date DATE NOT NULL,
    category VARCHAR(100),
    amount DECIMAL(14,2) NOT NULL,
    description TEXT,
    payment_method VARCHAR(100),
    supplier_id VARCHAR(36),
    status VARCHAR(50) DEFAULT 'paid',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 30. FIXED ASSETS
CREATE TABLE fixed_assets (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    purchase_date DATE,
    purchase_cost DECIMAL(14,2),
    current_value DECIMAL(14,2),
    depreciation_rate DECIMAL(5,2),
    location VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 31. LIABILITIES
CREATE TABLE liabilities (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(255) NOT NULL,
    type VARCHAR(100),
    amount DECIMAL(14,2) NOT NULL,
    due_date DATE,
    interest_rate DECIMAL(5,2),
    status VARCHAR(50) DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 32. BUDGETS
CREATE TABLE budgets (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    category VARCHAR(100) NOT NULL,
    amount DECIMAL(14,2) NOT NULL,
    period VARCHAR(50),
    spent DECIMAL(14,2) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 33. CUSTOMER MONITOR NOTES
CREATE TABLE customer_monitor_notes (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    customer_id VARCHAR(36) NOT NULL,
    note TEXT NOT NULL,
    author_name VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE CASCADE
);

-- 34. CAPITAL CONTRIBUTIONS
CREATE TABLE capital_contributions (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    partner_id VARCHAR(36) NOT NULL,
    amount DECIMAL(14,2) NOT NULL,
    date DATE NOT NULL,
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (partner_id) REFERENCES partners(id) ON DELETE CASCADE
);

-- 35. PURCHASE ORDERS
CREATE TABLE purchase_orders (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    po_number VARCHAR(100) UNIQUE NOT NULL,
    supplier_id VARCHAR(36),
    order_date DATE,
    total_amount DECIMAL(14,2),
    status VARCHAR(50) DEFAULT 'pending',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (supplier_id) REFERENCES suppliers(id) ON DELETE SET NULL
);

-- 36. DELIVERY NOTES
CREATE TABLE delivery_notes (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    delivery_note_number VARCHAR(100) UNIQUE NOT NULL,
    order_id VARCHAR(36),
    customer_name VARCHAR(255),
    delivery_date DATE,
    recipient_name VARCHAR(255),
    status VARCHAR(50) DEFAULT 'draft',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE SET NULL
);

-- 37. CREDIT NOTES
CREATE TABLE credit_notes (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    credit_note_number VARCHAR(100) UNIQUE NOT NULL,
    customer_id VARCHAR(36),
    customer_name VARCHAR(255),
    date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    original_invoice_number VARCHAR(100),
    items JSON,
    subtotal DECIMAL(14,2) DEFAULT 0,
    tax DECIMAL(14,2) DEFAULT 0,
    total DECIMAL(14,2) DEFAULT 0,
    status VARCHAR(50) DEFAULT 'draft',
    reason TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE SET NULL
);

-- 38. INVENTORY TRANSACTIONS
CREATE TABLE inventory_transactions (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    sku VARCHAR(100),
    item_name VARCHAR(255),
    type ENUM('in', 'out', 'adjustment') NOT NULL,
    quantity DECIMAL(14,2) NOT NULL,
    reference_id VARCHAR(100),
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 39. ROLES
CREATE TABLE roles (
    id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
    name VARCHAR(100) UNIQUE NOT NULL,
    permissions JSON,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 40. INITIAL DATA
SET FOREIGN_KEY_CHECKS = 0;
INSERT INTO app_settings (`key`, value) VALUES ('general_settings', '{\"site_name\": \"Pioneer Cetak\", \"currency\": \"MYR\"}');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('admin-uuid-1234', 'admin@pioneer.com', '$2b$10$kaZ76oDCcKe7wv.rCRDcd.sU4dq0OJ1xvpWbJgo8XVHMjQ2u7euAC', 'Admin', 'admin');
SET FOREIGN_KEY_CHECKS = 1;


-- --- SECTION SPLIT ---

-- Advanced Print MIS Schema Upgrade

-- 1. Matrix Pricing Table
CREATE TABLE IF NOT EXISTS price_matrix (
    id VARCHAR(50) PRIMARY KEY,
    paper_type_id VARCHAR(50),
    print_type ENUM('digital', 'offset') DEFAULT 'offset',
    sheet_size_id VARCHAR(50),
    qty_threshold INT NOT NULL,
    price DECIMAL(10, 4) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (paper_type_id) REFERENCES paper_types(id) ON DELETE CASCADE
);

-- 2. Parent Sheets Table (Raw material from supplier)
CREATE TABLE IF NOT EXISTS parent_sheets (
    id VARCHAR(50) PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    width DECIMAL(10, 2) NOT NULL, -- mm
    length DECIMAL(10, 2) NOT NULL, -- mm
    paper_type_id VARCHAR(50),
    cost_per_sheet DECIMAL(10, 4),
    in_stock INT DEFAULT 0,
    FOREIGN KEY (paper_type_id) REFERENCES paper_types(id)
);

-- 3. Press Sheets Table (Size for specific machine)
CREATE TABLE IF NOT EXISTS press_sheets (
    id VARCHAR(50) PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    width DECIMAL(10, 2) NOT NULL,
    length DECIMAL(10, 2) NOT NULL,
    gripper_margin DECIMAL(10, 2) DEFAULT 10,
    color_bar_margin DECIMAL(10, 2) DEFAULT 5,
    machine_id VARCHAR(50),
    FOREIGN KEY (machine_id) REFERENCES printing_options(id)
);

-- 4. Update Finishing Options with setup components
ALTER TABLE finishing_options 
ADD COLUMN IF NOT EXISTS setup_cost DECIMAL(10, 2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS unit_cost_type ENUM('item', 'sqcm', 'sheet') DEFAULT 'item';

-- Seed initial data for testing
INSERT IGNORE INTO parent_sheets (id, name, width, length, paper_type_id, cost_per_sheet, in_stock)
VALUES 
('ps-1', 'Standard A1 Parent', 594, 841, 'pt-1', 0.50, 1000),
('ps-2', 'Standard B1 Parent', 707, 1000, 'pt-1', 0.85, 1000);

INSERT IGNORE INTO price_matrix (id, paper_type_id, qty_threshold, price)
VALUES 
('pm-1', 'pt-1', 1000, 0.45),
('pm-2', 'pt-1', 2000, 0.40),
('pm-3', 'pt-1', 5000, 0.35);

-- 5. Update Printing Options for machine logic
ALTER TABLE printing_options
ADD COLUMN IF NOT EXISTS setup_cost DECIMAL(10, 2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS click_charge DECIMAL(10, 4) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS hourly_rate DECIMAL(10, 2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS min_width DECIMAL(10, 2),
ADD COLUMN IF NOT EXISTS min_length DECIMAL(10, 2),
ADD COLUMN IF NOT EXISTS max_width DECIMAL(10, 2),
ADD COLUMN IF NOT EXISTS max_length DECIMAL(10, 2);


-- --- SECTION SPLIT ---

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE paper_types;
TRUNCATE TABLE finishing_options;
TRUNCATE TABLE printing_options;
TRUNCATE TABLE partners;
TRUNCATE TABLE chatbots;
TRUNCATE TABLE roles;
TRUNCATE TABLE users;

INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-1', 'Simili Paper', 'Uncoated wood-free paper', 'Paper Supply Co.', 10000, 'both', '/materials/paper/similipaper.jpg', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"50","costPrice":0.1,"sellPrice":0.15000000000000002},{"id":"th-1774464405936-1","thickness":"55","costPrice":0.11,"sellPrice":0.165},{"id":"th-1774464405936-2","thickness":"60","costPrice":0.12,"sellPrice":0.18},{"id":"th-1774464405936-3","thickness":"70","costPrice":0.14,"sellPrice":0.21000000000000002},{"id":"th-1774464405936-4","thickness":"80","costPrice":0.16,"sellPrice":0.24},{"id":"th-1774464405936-5","thickness":"100","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-6","thickness":"120","costPrice":0.24,"sellPrice":0.36},{"id":"th-1774464405936-7","thickness":"140","costPrice":0.28,"sellPrice":0.42000000000000004},{"id":"th-1774464405936-8","thickness":"160","costPrice":0.32,"sellPrice":0.48}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"50","costPrice":0.1,"sellPrice":0.15000000000000002},{"id":"th-1774464405936-1","thickness":"55","costPrice":0.11,"sellPrice":0.165},{"id":"th-1774464405936-2","thickness":"60","costPrice":0.12,"sellPrice":0.18},{"id":"th-1774464405936-3","thickness":"70","costPrice":0.14,"sellPrice":0.21000000000000002},{"id":"th-1774464405936-4","thickness":"80","costPrice":0.16,"sellPrice":0.24},{"id":"th-1774464405936-5","thickness":"100","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-6","thickness":"120","costPrice":0.24,"sellPrice":0.36},{"id":"th-1774464405936-7","thickness":"140","costPrice":0.28,"sellPrice":0.42000000000000004},{"id":"th-1774464405936-8","thickness":"160","costPrice":0.32,"sellPrice":0.48}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"50","costPrice":0.1,"sellPrice":0.15000000000000002},{"id":"th-1774464405936-1","thickness":"55","costPrice":0.11,"sellPrice":0.165},{"id":"th-1774464405936-2","thickness":"60","costPrice":0.12,"sellPrice":0.18},{"id":"th-1774464405936-3","thickness":"70","costPrice":0.14,"sellPrice":0.21000000000000002},{"id":"th-1774464405936-4","thickness":"80","costPrice":0.16,"sellPrice":0.24},{"id":"th-1774464405936-5","thickness":"100","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-6","thickness":"120","costPrice":0.24,"sellPrice":0.36},{"id":"th-1774464405936-7","thickness":"140","costPrice":0.28,"sellPrice":0.42000000000000004},{"id":"th-1774464405936-8","thickness":"160","costPrice":0.32,"sellPrice":0.48}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"50","costPrice":0.1,"sellPrice":0.15000000000000002},{"id":"th-1774464405936-1","thickness":"55","costPrice":0.11,"sellPrice":0.165},{"id":"th-1774464405936-2","thickness":"60","costPrice":0.12,"sellPrice":0.18},{"id":"th-1774464405936-3","thickness":"70","costPrice":0.14,"sellPrice":0.21000000000000002},{"id":"th-1774464405936-4","thickness":"80","costPrice":0.16,"sellPrice":0.24},{"id":"th-1774464405936-5","thickness":"100","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-6","thickness":"120","costPrice":0.24,"sellPrice":0.36},{"id":"th-1774464405936-7","thickness":"140","costPrice":0.28,"sellPrice":0.42000000000000004},{"id":"th-1774464405936-8","thickness":"160","costPrice":0.32,"sellPrice":0.48}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-2', 'Art Paper', 'Coated paper (1 or 2 faces)', 'Paper Supply Co.', 8000, 'both', '/materials/paper/artpaper.avif', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"80","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-1","thickness":"85","costPrice":0.2125,"sellPrice":0.31875},{"id":"th-1774464405936-2","thickness":"100","costPrice":0.25,"sellPrice":0.375},{"id":"th-1774464405936-3","thickness":"105","costPrice":0.2625,"sellPrice":0.39375000000000004},{"id":"th-1774464405936-4","thickness":"120","costPrice":0.3,"sellPrice":0.44999999999999996},{"id":"th-1774464405936-5","thickness":"128","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-6","thickness":"150","costPrice":0.375,"sellPrice":0.5625},{"id":"th-1774464405936-7","thickness":"157","costPrice":0.3925,"sellPrice":0.58875}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"80","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-1","thickness":"85","costPrice":0.2125,"sellPrice":0.31875},{"id":"th-1774464405936-2","thickness":"100","costPrice":0.25,"sellPrice":0.375},{"id":"th-1774464405936-3","thickness":"105","costPrice":0.2625,"sellPrice":0.39375000000000004},{"id":"th-1774464405936-4","thickness":"120","costPrice":0.3,"sellPrice":0.44999999999999996},{"id":"th-1774464405936-5","thickness":"128","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-6","thickness":"150","costPrice":0.375,"sellPrice":0.5625},{"id":"th-1774464405936-7","thickness":"157","costPrice":0.3925,"sellPrice":0.58875}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"80","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-1","thickness":"85","costPrice":0.2125,"sellPrice":0.31875},{"id":"th-1774464405936-2","thickness":"100","costPrice":0.25,"sellPrice":0.375},{"id":"th-1774464405936-3","thickness":"105","costPrice":0.2625,"sellPrice":0.39375000000000004},{"id":"th-1774464405936-4","thickness":"120","costPrice":0.3,"sellPrice":0.44999999999999996},{"id":"th-1774464405936-5","thickness":"128","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-6","thickness":"150","costPrice":0.375,"sellPrice":0.5625},{"id":"th-1774464405936-7","thickness":"157","costPrice":0.3925,"sellPrice":0.58875}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"80","costPrice":0.2,"sellPrice":0.30000000000000004},{"id":"th-1774464405936-1","thickness":"85","costPrice":0.2125,"sellPrice":0.31875},{"id":"th-1774464405936-2","thickness":"100","costPrice":0.25,"sellPrice":0.375},{"id":"th-1774464405936-3","thickness":"105","costPrice":0.2625,"sellPrice":0.39375000000000004},{"id":"th-1774464405936-4","thickness":"120","costPrice":0.3,"sellPrice":0.44999999999999996},{"id":"th-1774464405936-5","thickness":"128","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-6","thickness":"150","costPrice":0.375,"sellPrice":0.5625},{"id":"th-1774464405936-7","thickness":"157","costPrice":0.3925,"sellPrice":0.58875}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-3', 'Art Card', 'Thick coated paper', 'Paper Supply Co.', 5000, 'both', '/materials/paper/artcard.avif', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"190","costPrice":0.5700000000000001,"sellPrice":0.8550000000000001},{"id":"th-1774464405936-1","thickness":"210","costPrice":0.63,"sellPrice":0.9450000000000001},{"id":"th-1774464405936-2","thickness":"230","costPrice":0.6900000000000001,"sellPrice":1.0350000000000001},{"id":"th-1774464405936-3","thickness":"250","costPrice":0.75,"sellPrice":1.125},{"id":"th-1774464405936-4","thickness":"260","costPrice":0.78,"sellPrice":1.17},{"id":"th-1774464405936-5","thickness":"300","costPrice":0.9,"sellPrice":1.35},{"id":"th-1774464405936-6","thickness":"350","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-7","thickness":"400","costPrice":1.2,"sellPrice":1.7999999999999998}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"190","costPrice":0.5700000000000001,"sellPrice":0.8550000000000001},{"id":"th-1774464405936-1","thickness":"210","costPrice":0.63,"sellPrice":0.9450000000000001},{"id":"th-1774464405936-2","thickness":"230","costPrice":0.6900000000000001,"sellPrice":1.0350000000000001},{"id":"th-1774464405936-3","thickness":"250","costPrice":0.75,"sellPrice":1.125},{"id":"th-1774464405936-4","thickness":"260","costPrice":0.78,"sellPrice":1.17},{"id":"th-1774464405936-5","thickness":"300","costPrice":0.9,"sellPrice":1.35},{"id":"th-1774464405936-6","thickness":"350","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-7","thickness":"400","costPrice":1.2,"sellPrice":1.7999999999999998}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"190","costPrice":0.5700000000000001,"sellPrice":0.8550000000000001},{"id":"th-1774464405936-1","thickness":"210","costPrice":0.63,"sellPrice":0.9450000000000001},{"id":"th-1774464405936-2","thickness":"230","costPrice":0.6900000000000001,"sellPrice":1.0350000000000001},{"id":"th-1774464405936-3","thickness":"250","costPrice":0.75,"sellPrice":1.125},{"id":"th-1774464405936-4","thickness":"260","costPrice":0.78,"sellPrice":1.17},{"id":"th-1774464405936-5","thickness":"300","costPrice":0.9,"sellPrice":1.35},{"id":"th-1774464405936-6","thickness":"350","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-7","thickness":"400","costPrice":1.2,"sellPrice":1.7999999999999998}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"190","costPrice":0.5700000000000001,"sellPrice":0.8550000000000001},{"id":"th-1774464405936-1","thickness":"210","costPrice":0.63,"sellPrice":0.9450000000000001},{"id":"th-1774464405936-2","thickness":"230","costPrice":0.6900000000000001,"sellPrice":1.0350000000000001},{"id":"th-1774464405936-3","thickness":"250","costPrice":0.75,"sellPrice":1.125},{"id":"th-1774464405936-4","thickness":"260","costPrice":0.78,"sellPrice":1.17},{"id":"th-1774464405936-5","thickness":"300","costPrice":0.9,"sellPrice":1.35},{"id":"th-1774464405936-6","thickness":"350","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-7","thickness":"400","costPrice":1.2,"sellPrice":1.7999999999999998}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-4', 'Ivory Card', 'Uncoated premium card', 'Paper Supply Co.', 4000, 'both', '/materials/paper/lvorycard.avif', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-1","thickness":"120","costPrice":0.384,"sellPrice":0.5760000000000001},{"id":"th-1774464405936-2","thickness":"140","costPrice":0.448,"sellPrice":0.672},{"id":"th-1774464405936-3","thickness":"180","costPrice":0.5760000000000001,"sellPrice":0.8640000000000001},{"id":"th-1774464405936-4","thickness":"210","costPrice":0.672,"sellPrice":1.008},{"id":"th-1774464405936-5","thickness":"230","costPrice":0.736,"sellPrice":1.104},{"id":"th-1774464405936-6","thickness":"250","costPrice":0.8,"sellPrice":1.2000000000000002},{"id":"th-1774464405936-7","thickness":"270","costPrice":0.864,"sellPrice":1.296},{"id":"th-1774464405936-8","thickness":"300","costPrice":0.9600000000000001,"sellPrice":1.4400000000000002},{"id":"th-1774464405936-9","thickness":"350","costPrice":1.12,"sellPrice":1.6800000000000002}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-1","thickness":"120","costPrice":0.384,"sellPrice":0.5760000000000001},{"id":"th-1774464405936-2","thickness":"140","costPrice":0.448,"sellPrice":0.672},{"id":"th-1774464405936-3","thickness":"180","costPrice":0.5760000000000001,"sellPrice":0.8640000000000001},{"id":"th-1774464405936-4","thickness":"210","costPrice":0.672,"sellPrice":1.008},{"id":"th-1774464405936-5","thickness":"230","costPrice":0.736,"sellPrice":1.104},{"id":"th-1774464405936-6","thickness":"250","costPrice":0.8,"sellPrice":1.2000000000000002},{"id":"th-1774464405936-7","thickness":"270","costPrice":0.864,"sellPrice":1.296},{"id":"th-1774464405936-8","thickness":"300","costPrice":0.9600000000000001,"sellPrice":1.4400000000000002},{"id":"th-1774464405936-9","thickness":"350","costPrice":1.12,"sellPrice":1.6800000000000002}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-1","thickness":"120","costPrice":0.384,"sellPrice":0.5760000000000001},{"id":"th-1774464405936-2","thickness":"140","costPrice":0.448,"sellPrice":0.672},{"id":"th-1774464405936-3","thickness":"180","costPrice":0.5760000000000001,"sellPrice":0.8640000000000001},{"id":"th-1774464405936-4","thickness":"210","costPrice":0.672,"sellPrice":1.008},{"id":"th-1774464405936-5","thickness":"230","costPrice":0.736,"sellPrice":1.104},{"id":"th-1774464405936-6","thickness":"250","costPrice":0.8,"sellPrice":1.2000000000000002},{"id":"th-1774464405936-7","thickness":"270","costPrice":0.864,"sellPrice":1.296},{"id":"th-1774464405936-8","thickness":"300","costPrice":0.9600000000000001,"sellPrice":1.4400000000000002},{"id":"th-1774464405936-9","thickness":"350","costPrice":1.12,"sellPrice":1.6800000000000002}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.32,"sellPrice":0.48},{"id":"th-1774464405936-1","thickness":"120","costPrice":0.384,"sellPrice":0.5760000000000001},{"id":"th-1774464405936-2","thickness":"140","costPrice":0.448,"sellPrice":0.672},{"id":"th-1774464405936-3","thickness":"180","costPrice":0.5760000000000001,"sellPrice":0.8640000000000001},{"id":"th-1774464405936-4","thickness":"210","costPrice":0.672,"sellPrice":1.008},{"id":"th-1774464405936-5","thickness":"230","costPrice":0.736,"sellPrice":1.104},{"id":"th-1774464405936-6","thickness":"250","costPrice":0.8,"sellPrice":1.2000000000000002},{"id":"th-1774464405936-7","thickness":"270","costPrice":0.864,"sellPrice":1.296},{"id":"th-1774464405936-8","thickness":"300","costPrice":0.9600000000000001,"sellPrice":1.4400000000000002},{"id":"th-1774464405936-9","thickness":"350","costPrice":1.12,"sellPrice":1.6800000000000002}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-5', 'Duplex Board', 'Board with two layers', 'Paper Supply Co.', 3000, 'single', '/materials/paper/DuplexBoard.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"250","costPrice":0.875,"sellPrice":1.3125},{"id":"th-1774464405936-1","thickness":"270","costPrice":0.9450000000000001,"sellPrice":1.4175},{"id":"th-1774464405936-2","thickness":"300","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-3","thickness":"350","costPrice":1.225,"sellPrice":1.8375000000000001},{"id":"th-1774464405936-4","thickness":"400","costPrice":1.4000000000000001,"sellPrice":2.1},{"id":"th-1774464405936-5","thickness":"450","costPrice":1.575,"sellPrice":2.3625}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"250","costPrice":0.875,"sellPrice":1.3125},{"id":"th-1774464405936-1","thickness":"270","costPrice":0.9450000000000001,"sellPrice":1.4175},{"id":"th-1774464405936-2","thickness":"300","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-3","thickness":"350","costPrice":1.225,"sellPrice":1.8375000000000001},{"id":"th-1774464405936-4","thickness":"400","costPrice":1.4000000000000001,"sellPrice":2.1},{"id":"th-1774464405936-5","thickness":"450","costPrice":1.575,"sellPrice":2.3625}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"250","costPrice":0.875,"sellPrice":1.3125},{"id":"th-1774464405936-1","thickness":"270","costPrice":0.9450000000000001,"sellPrice":1.4175},{"id":"th-1774464405936-2","thickness":"300","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-3","thickness":"350","costPrice":1.225,"sellPrice":1.8375000000000001},{"id":"th-1774464405936-4","thickness":"400","costPrice":1.4000000000000001,"sellPrice":2.1},{"id":"th-1774464405936-5","thickness":"450","costPrice":1.575,"sellPrice":2.3625}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"250","costPrice":0.875,"sellPrice":1.3125},{"id":"th-1774464405936-1","thickness":"270","costPrice":0.9450000000000001,"sellPrice":1.4175},{"id":"th-1774464405936-2","thickness":"300","costPrice":1.05,"sellPrice":1.5750000000000002},{"id":"th-1774464405936-3","thickness":"350","costPrice":1.225,"sellPrice":1.8375000000000001},{"id":"th-1774464405936-4","thickness":"400","costPrice":1.4000000000000001,"sellPrice":2.1},{"id":"th-1774464405936-5","thickness":"450","costPrice":1.575,"sellPrice":2.3625}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-6', 'Kraft Paper', 'Natural brown kraft paper', 'Eco Papers', 6000, 'both', '/materials/paper/KraftPaper.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.22,"sellPrice":0.33},{"id":"th-1774464405936-1","thickness":"125","costPrice":0.275,"sellPrice":0.41250000000000003},{"id":"th-1774464405936-2","thickness":"150","costPrice":0.33,"sellPrice":0.495},{"id":"th-1774464405936-3","thickness":"175","costPrice":0.385,"sellPrice":0.5775}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.22,"sellPrice":0.33},{"id":"th-1774464405936-1","thickness":"125","costPrice":0.275,"sellPrice":0.41250000000000003},{"id":"th-1774464405936-2","thickness":"150","costPrice":0.33,"sellPrice":0.495},{"id":"th-1774464405936-3","thickness":"175","costPrice":0.385,"sellPrice":0.5775}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.22,"sellPrice":0.33},{"id":"th-1774464405936-1","thickness":"125","costPrice":0.275,"sellPrice":0.41250000000000003},{"id":"th-1774464405936-2","thickness":"150","costPrice":0.33,"sellPrice":0.495},{"id":"th-1774464405936-3","thickness":"175","costPrice":0.385,"sellPrice":0.5775}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"100","costPrice":0.22,"sellPrice":0.33},{"id":"th-1774464405936-1","thickness":"125","costPrice":0.275,"sellPrice":0.41250000000000003},{"id":"th-1774464405936-2","thickness":"150","costPrice":0.33,"sellPrice":0.495},{"id":"th-1774464405936-3","thickness":"175","costPrice":0.385,"sellPrice":0.5775}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-7', 'Newsprint', 'Lightweight, inexpensive paper', 'Eco Papers', 20000, 'both', '/materials/paper/Newsprint.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405936-0","thicknesses":[{"id":"th-1774464405936-0","thickness":"45","costPrice":0.045,"sellPrice":0.0675},{"id":"th-1774464405936-1","thickness":"48","costPrice":0.048,"sellPrice":0.07200000000000001}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405936-1","thicknesses":[{"id":"th-1774464405936-0","thickness":"45","costPrice":0.045,"sellPrice":0.0675},{"id":"th-1774464405936-1","thickness":"48","costPrice":0.048,"sellPrice":0.07200000000000001}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405936-2","thicknesses":[{"id":"th-1774464405936-0","thickness":"45","costPrice":0.045,"sellPrice":0.0675},{"id":"th-1774464405936-1","thickness":"48","costPrice":0.048,"sellPrice":0.07200000000000001}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405936-3","thicknesses":[{"id":"th-1774464405936-0","thickness":"45","costPrice":0.045,"sellPrice":0.0675},{"id":"th-1774464405936-1","thickness":"48","costPrice":0.048,"sellPrice":0.07200000000000001}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-8', 'Synthetic Paper (Yupo)', 'Waterproof, tear-resistant paper', 'Specialty Papers', 1500, 'both', '/materials/paper/SyntheticPaper(Yupo).webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"150","costPrice":1.2,"sellPrice":1.7999999999999998},{"id":"th-1774464405937-1","thickness":"200","costPrice":1.6,"sellPrice":2.4000000000000004}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"150","costPrice":1.2,"sellPrice":1.7999999999999998},{"id":"th-1774464405937-1","thickness":"200","costPrice":1.6,"sellPrice":2.4000000000000004}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"150","costPrice":1.2,"sellPrice":1.7999999999999998},{"id":"th-1774464405937-1","thickness":"200","costPrice":1.6,"sellPrice":2.4000000000000004}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"150","costPrice":1.2,"sellPrice":1.7999999999999998},{"id":"th-1774464405937-1","thickness":"200","costPrice":1.6,"sellPrice":2.4000000000000004}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-9', 'Carbonless (NCR)', 'No Carbon Required paper', 'Paper Supply Co.', 7000, 'single', '/materials/paper/Carbonless (NCR).webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"50","costPrice":0.35000000000000003,"sellPrice":0.525},{"id":"th-1774464405937-1","thickness":"55","costPrice":0.385,"sellPrice":0.5775}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"50","costPrice":0.35000000000000003,"sellPrice":0.525},{"id":"th-1774464405937-1","thickness":"55","costPrice":0.385,"sellPrice":0.5775}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"50","costPrice":0.35000000000000003,"sellPrice":0.525},{"id":"th-1774464405937-1","thickness":"55","costPrice":0.385,"sellPrice":0.5775}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"50","costPrice":0.35000000000000003,"sellPrice":0.525},{"id":"th-1774464405937-1","thickness":"55","costPrice":0.385,"sellPrice":0.5775}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-10', 'Tracing Paper', 'Translucent paper for tracing', 'Specialty Papers', 2000, 'single', '/materials/paper/TracingPaper.jpg', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"110","costPrice":0.825,"sellPrice":1.2374999999999998}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"110","costPrice":0.825,"sellPrice":1.2374999999999998}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"110","costPrice":0.825,"sellPrice":1.2374999999999998}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"110","costPrice":0.825,"sellPrice":1.2374999999999998}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-11', 'Linen Card', 'Cardstock with a linen texture', 'Specialty Papers', 2500, 'both', '/materials/paper/LinenCard.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.4,"sellPrice":0.6000000000000001},{"id":"th-1774464405937-1","thickness":"220","costPrice":0.88,"sellPrice":1.32},{"id":"th-1774464405937-2","thickness":"250","costPrice":1,"sellPrice":1.5}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.4,"sellPrice":0.6000000000000001},{"id":"th-1774464405937-1","thickness":"220","costPrice":0.88,"sellPrice":1.32},{"id":"th-1774464405937-2","thickness":"250","costPrice":1,"sellPrice":1.5}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.4,"sellPrice":0.6000000000000001},{"id":"th-1774464405937-1","thickness":"220","costPrice":0.88,"sellPrice":1.32},{"id":"th-1774464405937-2","thickness":"250","costPrice":1,"sellPrice":1.5}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.4,"sellPrice":0.6000000000000001},{"id":"th-1774464405937-1","thickness":"220","costPrice":0.88,"sellPrice":1.32},{"id":"th-1774464405937-2","thickness":"250","costPrice":1,"sellPrice":1.5}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-12', 'Conqueror', 'Premium watermarked paper', 'Specialty Papers', 2000, 'both', '/materials/paper/Conqueror.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.6,"sellPrice":0.8999999999999999},{"id":"th-1774464405937-1","thickness":"220","costPrice":1.32,"sellPrice":1.98},{"id":"th-1774464405937-2","thickness":"250","costPrice":1.5,"sellPrice":2.25}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.6,"sellPrice":0.8999999999999999},{"id":"th-1774464405937-1","thickness":"220","costPrice":1.32,"sellPrice":1.98},{"id":"th-1774464405937-2","thickness":"250","costPrice":1.5,"sellPrice":2.25}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.6,"sellPrice":0.8999999999999999},{"id":"th-1774464405937-1","thickness":"220","costPrice":1.32,"sellPrice":1.98},{"id":"th-1774464405937-2","thickness":"250","costPrice":1.5,"sellPrice":2.25}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"100","costPrice":0.6,"sellPrice":0.8999999999999999},{"id":"th-1774464405937-1","thickness":"220","costPrice":1.32,"sellPrice":1.98},{"id":"th-1774464405937-2","thickness":"250","costPrice":1.5,"sellPrice":2.25}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-13', 'Lumin', 'Specialty textured paper', 'Specialty Papers', 1800, 'both', '/materials/paper/Lumin.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-14', 'Radiant', 'Specialty vibrant paper', 'Specialty Papers', 1800, 'both', '/materials/paper/Radiant.webp', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"120","costPrice":0.6599999999999999,"sellPrice":0.9899999999999999},{"id":"th-1774464405937-1","thickness":"250","costPrice":1.375,"sellPrice":2.0625},{"id":"th-1774464405937-2","thickness":"300","costPrice":1.65,"sellPrice":2.4749999999999996}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-15', 'Mirrorcoat', 'High-gloss sticker paper', 'Paper Supply Co.', 9000, 'single', '/materials/paper/Mirrorcoat.avif', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.24,"sellPrice":0.36}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.24,"sellPrice":0.36}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.24,"sellPrice":0.36}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.24,"sellPrice":0.36}]}]');
INSERT INTO paper_types (id, name, description, supplier, in_stock, suitable_sides, photo_url, sizes) VALUES ('pt-16', 'Simili Sticker', 'Matte sticker paper', 'Paper Supply Co.', 9000, 'single', '/materials/paper/similisticker.jpg', '[{"name":"25x34.5","width":25,"height":34.5,"unit":"inch","id":"sz-25x34.5-1774464405937-0","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.224,"sellPrice":0.336}]},{"name":"25x35.5","width":25,"height":35.5,"unit":"inch","id":"sz-25x35.5-1774464405937-1","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.224,"sellPrice":0.336}]},{"name":"25x37","width":25,"height":37,"unit":"inch","id":"sz-25x37-1774464405937-2","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.224,"sellPrice":0.336}]},{"name":"31x43","width":31,"height":43,"unit":"inch","id":"sz-31x43-1774464405937-3","thicknesses":[{"id":"th-1774464405937-0","thickness":"80","costPrice":0.224,"sellPrice":0.336}]}]');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-1', 'Matte Lamination', 'Non-glossy film for a soft professional finish', 'sqcm', '[{"fromQty":1,"toQty":100,"costPrice":0.02,"sellPrice":0.5},{"fromQty":101,"toQty":500,"costPrice":0.02,"sellPrice":0.45},{"fromQty":501,"toQty":null,"costPrice":0.02,"sellPrice":0.4}]', '3', 'Finishing Masters', 2, '/materials/finishing/Matte_Lamination.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-2', 'Spot UV', 'Gloss applied only to specific areas', 'sqcm', '[{"fromQty":1,"toQty":100,"costPrice":0.05,"sellPrice":0.8},{"fromQty":101,"toQty":500,"costPrice":0.05,"sellPrice":0.7},{"fromQty":501,"toQty":null,"costPrice":0.05,"sellPrice":0.6}]', '3', 'Finishing Masters', 3, '/materials/finishing/spotuv.webp', 1, '{"pricePerUnit":1,"unit":"sqcm"}');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-3', 'Round Corners', 'Rounding the corners of the printed piece.', 'item', '[{"fromQty":1,"toQty":1000,"costPrice":0.05,"sellPrice":0.1},{"fromQty":1001,"toQty":null,"costPrice":0.05,"sellPrice":0.08}]', NULL, 'In-house', 1, '/materials/finishing/round_corner.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-4', 'Cutting / Trimming', 'Final cut to size with clean edges', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.02}]', NULL, 'In-house', 0, '/materials/finishing/cutting.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-5', 'Folding', 'Folding sheets into desired layout (e.g., brochure folds)', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.02,"sellPrice":0.04}]', NULL, 'In-house', 1, '/materials/finishing/folding1.png', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-6', 'Collating', 'Arranging pages in correct sequence', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.02}]', NULL, 'In-house', 1, '/materials/finishing/collate.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-7', 'Numbering', 'Adding serial numbers to documents', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.03,"sellPrice":0.06}]', NULL, 'In-house', 1, '/materials/finishing/numbering.png', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-8', 'Perforation', 'Rows of small holes for easy tearing', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.02,"sellPrice":0.04}]', NULL, 'In-house', 1, '/materials/finishing/Perforation.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-9', 'Scoring', 'Pressed line for accurate folding', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.02,"sellPrice":0.04}]', NULL, 'In-house', 1, '/materials/finishing/Scoring.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-10', 'Creasing', 'Pressed groove on heavy stock for clean folds', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.02,"sellPrice":0.04}]', NULL, 'In-house', 1, '/materials/finishing/Creasing.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-11', 'Saddle Stitching', 'Stapling pages through the spine', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.1,"sellPrice":0.2}]', NULL, 'In-house', 1, '/materials/finishing/Saddle_Stitching.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-12', 'Perfect Binding', 'Glued spine binding, used in magazines/books', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.5,"sellPrice":1}]', '3', 'Finishing Masters', 3, '/materials/finishing/Perfect_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-13', 'Spiral Binding', 'Plastic coil binding for flexible opening', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.4,"sellPrice":0.8}]', NULL, 'In-house', 2, '/materials/finishing/Spiral_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-14', 'Wire-O Binding', 'Metal loop binding for premium look', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.6,"sellPrice":1.2}]', '3', 'Finishing Masters', 2, '/materials/finishing/Wire-O_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-15', 'Case Binding (Hardcover)', 'Durable hardcover binding', 'item', '[{"fromQty":1,"toQty":null,"costPrice":5,"sellPrice":10}]', '3', 'Finishing Masters', 5, '/materials/finishing/Case_Binding_(Hardcover).jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-16', 'Comb Binding', 'Plastic comb spine, common for reports', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.3,"sellPrice":0.6}]', NULL, 'In-house', 1, '/materials/finishing/Comb_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-17', 'Layflat Binding', 'Allows book to lay flat when opened', 'item', '[{"fromQty":1,"toQty":null,"costPrice":1.5,"sellPrice":3}]', '3', 'Finishing Masters', 4, '/materials/finishing/Layflat_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-18', 'Singer Sewn Binding', 'Stitched spine with visible threads', 'item', '[{"fromQty":1,"toQty":null,"costPrice":1,"sellPrice":2}]', '3', 'Finishing Masters', 3, '/materials/finishing/Singer_Sewn_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-19', 'Japanese Binding', 'Traditional sewn binding style', 'item', '[{"fromQty":1,"toQty":null,"costPrice":2,"sellPrice":4}]', '3', 'Finishing Masters', 4, '/materials/finishing/Japanese_Binding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-20', 'Gloss Lamination', 'Shiny plastic film for durability and gloss', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.02,"sellPrice":0.5}]', '3', 'Finishing Masters', 2, '/materials/finishing/Gloss_Lamination.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-21', 'Soft-Touch Lamination', 'Velvety matte texture with luxurious feel', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.04,"sellPrice":0.9}]', '3', 'Finishing Masters', 2, '/materials/finishing/Soft-Touch_Lamination.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-22', 'UV Coating', 'High-gloss or matte UV-cured coating', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.03,"sellPrice":0.6}]', '3', 'Finishing Masters', 2, '/materials/finishing/UV_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-23', 'Aqueous Coating', 'Water-based protective coating', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.3}]', NULL, 'In-house', 1, '/materials/finishing/Aqueous_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-24', 'Satin Coating', 'Smooth satin finish for subtle sheen', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.015,"sellPrice":0.35}]', NULL, 'In-house', 1, '/materials/finishing/Satin_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-25', 'Varnish', 'Basic in-line print protection layer', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.25}]', NULL, 'In-house', 1, '/materials/finishing/Varnish.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-26', 'Soft-touch Varnish', 'Silky feel similar to soft-touch lamination', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.035,"sellPrice":0.8}]', '3', 'Finishing Masters', 2, '/materials/finishing/Soft-touch_Varnish.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-27', 'Pearl Coating', 'Adds a pearl-like shimmer effect', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.06,"sellPrice":1.2}]', '3', 'Finishing Masters', 3, '/materials/finishing/Pearl_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-28', 'Foil Stamping', 'Metallic or holographic foil via heat stamping', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.1,"sellPrice":0.5}]', '3', 'Finishing Masters', 3, '/materials/finishing/Foil_Stamping.jpg', 1, '{"pricePerUnit":1.5,"unit":"sqcm"}');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-29', 'Embossing', 'Raised design pressed into the paper', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.08,"sellPrice":0.4}]', '3', 'Finishing Masters', 3, '/materials/finishing/Embossing.jpg', 1, '{"pricePerUnit":1.2,"unit":"sqcm"}');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-30', 'Debossing', 'Indented design pressed into the paper', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.08,"sellPrice":0.4}]', '3', 'Finishing Masters', 3, '/materials/finishing/Debossing.jpg', 1, '{"pricePerUnit":1.2,"unit":"sqcm"}');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-31', 'Thermography', 'Raised ink effect using heat and powder', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.07,"sellPrice":0.35}]', '3', 'Finishing Masters', 2, '/materials/finishing/Thermography.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-32', 'Die Cutting', 'Custom shape cuts or windows', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.15,"sellPrice":0.3}]', '3', 'Finishing Masters', 3, '/materials/finishing/Die_Cutting.jpg', 1, '{"pricePerUnit":1,"unit":"sqcm"}');
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-33', 'Laser Cutting', 'Intricate laser precision cuts', 'item', '[{"fromQty":1,"toQty":null,"costPrice":1,"sellPrice":2}]', '3', 'Finishing Masters', 4, '/materials/finishing/Laser_Cutting.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-34', 'Drilling', 'Hole punches for binding or filing', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.02}]', NULL, 'In-house', 1, '/materials/finishing/Drilling.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-35', 'Lenticular Printing', 'Creates motion illusion when tilted', 'item', '[{"fromQty":1,"toQty":null,"costPrice":2,"sellPrice":4}]', '3', 'Finishing Masters', 5, '/materials/finishing/Lenticular_Printing.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-36', 'Edge Gilding', 'Colored or metallic edges on paper blocks', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.5,"sellPrice":1}]', '3', 'Finishing Masters', 3, '/materials/finishing/Edge_Gilding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-37', 'Sandpaper Varnish', 'Rough texture like sandpaper finish', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.12,"sellPrice":0.5}]', '3', 'Finishing Masters', 3, '/materials/finishing/Sandpaper_Varnish.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-38', 'Glitter Coating', 'Embedded glitter particles for sparkle', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.15,"sellPrice":0.6}]', '3', 'Finishing Masters', 3, '/materials/finishing/Glitter_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-39', 'Scented Coating', 'Infused fragrance for sensory appeal', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.2,"sellPrice":0.7}]', '3', 'Finishing Masters', 4, '/materials/finishing/Scented_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-40', 'Scratch-off Coating', 'Coating that can be scratched off', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.05,"sellPrice":0.2}]', '3', 'Finishing Masters', 2, '/materials/finishing/Scratch-off_Coating.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-41', 'Magnetic Patch Application', 'Thin magnetic surface for function or attachment', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.3,"sellPrice":0.6}]', '3', 'Finishing Masters', 2, '/materials/finishing/Magnetic_Patch_Application.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-42', 'Gluing / Tipping', 'Attaching samples or cards using glue', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.05,"sellPrice":0.1}]', NULL, 'In-house', 1, '/materials/finishing/Gluing_Tipping.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-43', 'Mounting to Board', 'Mounting prints onto rigid boards', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.1,"sellPrice":0.25}]', '3', 'Finishing Masters', 3, '/materials/finishing/Mounting to_Board.avif', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-44', 'Window Patching', 'Clear film on cut-out windows', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.2,"sellPrice":0.4}]', '3', 'Finishing Masters', 3, '/materials/finishing/Window_Patching.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-45', 'Inserting', 'Placing inserts manually or with machine', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.03,"sellPrice":0.06}]', NULL, 'In-house', 1, '/materials/finishing/Inserting.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-46', 'Folding & Gluing (Boxes)', 'Folding + gluing boxes or folders', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.25,"sellPrice":0.5}]', '3', 'Finishing Masters', 3, '/materials/finishing/Folding_&_Gluing_(Boxes).webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-47', 'Shrink Wrapping', 'Plastic wrap for protection and bundling', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.1,"sellPrice":0.2}]', NULL, 'In-house', 1, '/materials/finishing/Shrink_Wrapping.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-48', 'Belly Banding', 'Paper band wrap around products', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.08,"sellPrice":0.16}]', NULL, 'In-house', 1, '/materials/finishing/Belly_Banding.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-49', 'Stringing / Ribboning', 'Adding string or ribbon to printed items', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.15,"sellPrice":0.3}]', '3', 'Finishing Masters', 2, '/materials/finishing/Stringing _Ribboning.jpeg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-50', 'Eyeleting', 'Metal eyelet for hanging or reinforcement', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.05,"sellPrice":0.1}]', NULL, 'In-house', 1, '/materials/finishing/Eyeleting.avif', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-51', 'Hologram Stamping', 'Stamped hologram for authenticity', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.3,"sellPrice":0.8}]', '3', 'Finishing Masters', 4, '/materials/finishing/Hologram_Stamping.avif', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-52', 'Security Foil', 'Foil with anti-counterfeit properties', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.25,"sellPrice":0.7}]', '3', 'Finishing Masters', 4, '/materials/finishing/Security_Foil.webp', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-53', 'Microtext Printing', 'Tiny text only visible under magnification', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.15,"sellPrice":0.5}]', '3', 'Finishing Masters', 3, '/materials/finishing/Microtext_Printing.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-54', 'Anti-copy Patterns', 'Patterns that prevent unauthorized copying', 'sqcm', '[{"fromQty":1,"toQty":null,"costPrice":0.1,"sellPrice":0.3}]', '3', 'Finishing Masters', 2, '/materials/finishing/Anti-copy_Patterns.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-55', 'Barcoding / QR Coding', 'Barcode or QR for tracking or scanning', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.01,"sellPrice":0.02}]', NULL, 'In-house', 0, '/materials/finishing/Barcoding___QR_Coding.jpg', 0, NULL);
INSERT INTO finishing_options (id, name, description, cost_unit, price_tiers, supplier_id, supplier_name, estimated_days, photo_url, requires_block, block_settings) VALUES ('fo-56', 'Variable Data Printing (VDP)', 'Personalized data per piece (e.g., name, ID)', 'item', '[{"fromQty":1,"toQty":null,"costPrice":0.05,"sellPrice":0.1}]', NULL, 'In-house', 1, '/materials/finishing/Variable Data Printing (VDP).jpg', 0, NULL);
INSERT INTO printing_options (id, name, type, machine_model, supplier_id, supplier_name, operator_id, operator_name, photo_url, price_tiers, sizes) VALUES ('pr-1', 'HP Indigo 7900', 'Digital', 'Indigo 7900', NULL, 'In-house', '3', 'Aban makin', '/materials/machines/konicaminolta.jpg', '[{"fromQty":1,"toQty":500,"sellPrice":0.5},{"fromQty":501,"toQty":1000,"sellPrice":0.45},{"fromQty":1001,"toQty":null,"sellPrice":0.4}]', '[{"id":"size-pr1-1","name":"A3 (297x420mm)","width":297,"height":420,"unit":"mm"},{"id":"size-pr1-2","name":"SRA3 (320x450mm)","width":320,"height":450,"unit":"mm"}]');
INSERT INTO printing_options (id, name, type, machine_model, supplier_id, supplier_name, operator_id, operator_name, photo_url, price_tiers, sizes) VALUES ('pr-2', 'Komori Lithrone G40', 'Offset', 'Lithrone G40', '2', 'Premium Printers Inc.', NULL, NULL, '/materials/machines/KomoriLithrone.jpg', '[{"fromQty":1,"toQty":1000,"costPrice":0.15,"sellPrice":0.3},{"fromQty":1001,"toQty":5000,"costPrice":0.12,"sellPrice":0.25},{"fromQty":5001,"toQty":null,"costPrice":0.1,"sellPrice":0.2}]', '[{"id":"size-pr2-1","name":"18.5 x 25 inch","width":18.5,"height":25,"unit":"inch"}]');
INSERT INTO partners (id, name, type, ownership_percentage, join_date, email, phone, photo_url, total_contribution, total_distribution, net_equity) VALUES ('partner-1', 'Jackie Tong', 'founder', 65, '2022-01-01', 'pioneercetak@gmail.com', '0125946758', '/materials/partners/Jackie.jpg', 650000, 0, 650000);
INSERT INTO partners (id, name, type, ownership_percentage, join_date, email, phone, photo_url, total_contribution, total_distribution, net_equity) VALUES ('partner-2', 'Salah Ahmed', 'founder', 35, '2022-01-01', 'alsalahee@gmail.com', '0182948185', '/materials/partners/Salah.jpg', 350000, 0, 350000);
INSERT INTO chatbots (id, name, avatar_url, system_instruction, model, is_default) VALUES ('chatbot-1', 'Jackie (Admin)', '/materials/chatbots/Jackie_Admin.jpg', 'You are an expert internal analyst for Pioneer Cetak named Jackie. Your role is to help the admin user by analyzing and summarizing all business data. You have access to customers, suppliers, orders, quotations, expenses, payments, accounting entries, and more. Use the provided JSON data to answer questions. Be concise, accurate, and provide data-driven insights. When asked for summaries, provide key figures and brief explanations. You can perform complex analysis across different data points.', 'gemini-2.5-flash', 1);
INSERT INTO chatbots (id, name, avatar_url, system_instruction, model, is_default) VALUES ('chatbot-salah', 'Salah (Admin)', '/materials/chatbots/Salah_Admin.jpg', 'You are Salah, a sharp and efficient internal analyst for Pioneer Cetak. Your expertise is in financial data, operational efficiency, and identifying cost-saving opportunities. Provide direct, data-driven answers and actionable recommendations based on the provided JSON data. You are a counterpart to Jackie, focusing on the numbers and performance metrics.', 'gemini-2.5-flash', 0);
INSERT INTO chatbots (id, name, avatar_url, system_instruction, model, is_default) VALUES ('chatbot-2', 'Jackie (Customer)', '/materials/chatbots/Jackie_Customer.jpg', 'You are a friendly and knowledgeable printing expert from Pioneer Cetak. Your goal is to assist customers with their printing needs, answer questions, and provide price quotes. Use the product and pricing information below. All prices are in Malaysian Ringgit (RM). When a user asks for a quote, ask for quantity, paper type, size, and finishing options. Use the provided pricing data to calculate the total cost. Be helpful and clear. If a price is tiered, mention it.', 'gemini-2.5-flash', 1);
INSERT INTO roles (id, name, description, permissions) VALUES ('role-1', 'Admin', 'Has access to all system features, including user management and system settings.', '["all"]');
INSERT INTO roles (id, name, description, permissions) VALUES ('role-2', 'Manager', 'Can manage production, view reports, and oversee general operations.', '["dashboard:view","orders:view","orders:edit","production:view","production:manage_workflow","quality:view","inventory:view","accounting:view","hr:view","analytics:view"]');
INSERT INTO roles (id, name, description, permissions) VALUES ('role-3', 'Worker', 'Access to production-related modules to update job status.', '["dashboard:view","orders:view","production:view","production:update_status"]');
INSERT INTO roles (id, name, description, permissions) VALUES ('role-4', 'Customer', 'Can place new orders, request quotes, and view their order history.', '["dashboard:view","orders:view_own","orders:create"]');
INSERT INTO roles (id, name, description, permissions) VALUES ('role-5', 'Supplier', 'Can view orders assigned to them and manage their information.', '["dashboard:view","orders:view_assigned"]');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('42981da4-8785-48ff-9800-4780516fcde3', 'admin@printshop.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Admin', 'admin');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('eeb62351-ad37-4be7-9e0c-3965b6375001', 'manager@printshop.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Manager', 'manager');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('2f9a74c3-e832-4740-9e05-64357c3da334', 'worker@printshop.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Worker', 'worker');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('5f9a74c3-e832-4740-9e05-64357c3da335', 'customer@example.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Customer User', 'customer');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('6f9a74c3-e832-4740-9e05-64357c3da336', 'supplier@example.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Supplier User', 'supplier');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('3', 'aban@printshop.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Aban Makin', 'worker');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('7', 'saqeeb@printshop.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Saqeeb', 'worker');
INSERT INTO users (id, email, password_hash, name, role) VALUES ('admin-uuid-1234', 'admin@pioneer.com', '$2b$10$SjWNZXM5EQ9wF2Hf8AiJmun8T5ptkapPgNDIZwR.mNt/5mEkKnKnK', 'Admin', 'admin');

SET FOREIGN_KEY_CHECKS = 1;
ALTER TABLE paper_types ADD COLUMN IF NOT EXISTS params JSON;

ALTER TABLE materials ADD COLUMN IF NOT EXISTS params JSON;

ALTER TABLE finishing_options ADD COLUMN IF NOT EXISTS params JSON;

ALTER TABLE plates ADD COLUMN IF NOT EXISTS params JSON;

ALTER TABLE finishing_blocks ADD COLUMN IF NOT EXISTS params JSON;

ALTER TABLE printing_options ADD COLUMN IF NOT EXISTS params JSON;
