Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
36309 amit 1
-- Seed Dummy/GOOD/OURS warehouses under fallback vendor (id = 40) for every billing region
2
-- in ProfitMandiConstants.WAREHOUSE_MAP that doesn't already have one.
3
--
4
-- Phantom order allocations (placement when stock is insufficient or missing) route to the
5
-- Dummy warehouse for the partner's billing region. This guarantees every region has a
6
-- deterministic phantom target; going forward WarehouseServiceImpl.ensureDummyForBillingRegion
7
-- auto-creates Dummies when a new billing region's first warehouse is created.
8
--
9
-- Idempotent: uses NOT EXISTS to skip regions that already have a Dummy (the 5 pre-existing
10
-- regions with coverage: 7, 7441, 7573, 9203, 9213).
11
--
12
-- Applied on: hadb1 (remote) and local 127.0.0.1 as part of this refactor.
13
 
14
INSERT INTO inventory.warehouse
15
    (displayName, vendor_id, billingWarehouseId, shippingWarehouseId,
16
     inventoryType, warehouseType, status, billingType,
17
     state_id, addedOn, lastCheckedOn)
18
SELECT
19
    CONCAT(bw.displayName, '/Dummy/G'),
20
    40,
21
    bw.id,
22
    bw.id,
23
    'GOOD',
24
    'OURS',
25
    3,
26
    0,
27
    bw.state_id,
28
    NOW(),
29
    NOW()
30
FROM inventory.warehouse bw
31
WHERE bw.id IN (7720, 8947, 8468, 7678, 9349, 8889, 9470, 9513, 9514,
32
                10010, 10516, 10519, 10520, 10521)
33
  AND NOT EXISTS (
34
    SELECT 1 FROM inventory.warehouse w
35
    WHERE w.vendor_id = 40 AND w.billingWarehouseId = bw.id
36
      AND w.inventoryType = 'GOOD' AND w.warehouseType = 'OURS'
37
  );
38
 
39
-- Verify coverage:
40
-- SELECT billingWarehouseId, id, displayName
41
-- FROM inventory.warehouse
42
-- WHERE vendor_id = 40 AND inventoryType='GOOD' AND warehouseType='OURS'
43
-- ORDER BY billingWarehouseId;