-- SkyPOS seed data — one test merchant (coffee shop), one staff login,
-- direct-sell stock items, and one recipe built from ingredients.
-- Login: staff@testcafe.skypos / staff123

INSERT INTO merchants (name, slug, business_type) VALUES
  ('Test Cafe', 'testcafe', 'coffee_shop');

SET @merchant_id = LAST_INSERT_ID();

-- Direct-sell stock item: bottled drink, sold as-is, no recipe
INSERT INTO stock_items (merchant_id, name, unit, unit_cost, quantity_on_hand, reorder_threshold, is_sellable, price) VALUES
  (@merchant_id, 'Bottled Water', 'each', 5.00, 24.000, 6.000, 1, 15.00);

-- Ingredients for a recipe (not directly sellable themselves)
INSERT INTO stock_items (merchant_id, name, unit, unit_cost, quantity_on_hand, reorder_threshold, is_sellable, price) VALUES
  (@merchant_id, 'Bread Slice', 'each', 1.50, 40.000, 10.000, 0, NULL),
  (@merchant_id, 'Bacon Rasher', 'each', 3.00, 20.000, 5.000, 0, NULL),
  (@merchant_id, 'Butter', 'g', 0.05, 500.000, 100.000, 0, NULL);

SET @bread_id = (SELECT id FROM stock_items WHERE merchant_id = @merchant_id AND name = 'Bread Slice');
SET @bacon_id = (SELECT id FROM stock_items WHERE merchant_id = @merchant_id AND name = 'Bacon Rasher');
SET @butter_id = (SELECT id FROM stock_items WHERE merchant_id = @merchant_id AND name = 'Butter');

INSERT INTO recipes (merchant_id, name, price, is_active) VALUES
  (@merchant_id, 'Bacon Sandwich', 45.00, 1);

SET @recipe_id = LAST_INSERT_ID();

INSERT INTO recipe_ingredients (recipe_id, stock_item_id, quantity_used) VALUES
  (@recipe_id, @bread_id, 2.000),
  (@recipe_id, @bacon_id, 3.000),
  (@recipe_id, @butter_id, 10.000);
