-- Base SaaS catalog
SET NAMES utf8mb4;
START TRANSACTION;

INSERT INTO subscription_features(feature_key,name,value_type,description) VALUES
('pos','POS','BOOLEAN','Point-of-sale workflows'),
('inventory','Inventory','BOOLEAN','Stock and inventory management'),
('purchasing','Purchasing','BOOLEAN','Direct purchasing'),
('purchase_orders','Purchase Orders / GRN','BOOLEAN','Purchase order and goods receiving'),
('stock_take','Stock Take','BOOLEAN','Stock count workflow'),
('customer_credit','Customer Credit','BOOLEAN','Customer ledger and collections'),
('supplier_ledger','Supplier Ledger','BOOLEAN','Supplier payable ledger'),
('batch_expiry','Batch / Expiry','BOOLEAN','Batch and expiry tracking'),
('fifo_costing','FIFO Costing','BOOLEAN','FIFO COGS and valuation'),
('approval_workflows','Approval Workflows','BOOLEAN','Threshold/manager approvals'),
('advanced_rbac','Advanced RBAC','BOOLEAN','Custom roles and permission overrides'),
('multi_outlet','Multi Outlet','BOOLEAN','Multiple outlets'),
('api_access','API Access','BOOLEAN','External API integrations'),
('advanced_audit','Advanced Audit','BOOLEAN','Extended activity/security audit'),
('max_outlets','Maximum Outlets','INTEGER','Plan outlet limit'),
('max_devices','Maximum Devices','INTEGER','Plan device limit'),
('max_users','Maximum Users','INTEGER','Plan active user limit'),
('max_products','Maximum Products','INTEGER','Plan active product limit')
ON DUPLICATE KEY UPDATE name=VALUES(name),value_type=VALUES(value_type),description=VALUES(description);

INSERT INTO payment_gateways(gateway_key,name,driver_class,environment,is_enabled,sort_order,capabilities_json,allowed_currencies)
VALUES(
 'SHASPAY','ShasPay','App\\Services\\Payments\\Gateways\\ShasPayGateway',
 'SANDBOX',0,10,
 '{"hosted_checkout":true,"status_inquiry":true,"webhook":true,"refund_status":true,"recurring":false}',
 'KWD,USD'
)
ON DUPLICATE KEY UPDATE name=VALUES(name),driver_class=VALUES(driver_class),sort_order=VALUES(sort_order),capabilities_json=VALUES(capabilities_json);

COMMIT;
