CREATE OR REPLACE VIEW public.vw_bi_fct_trade_fulfillment_event AS
 SELECT sm."intPurchaseLineId" AS "intTradeId",
    'Physical'::text AS "Trade Category",
    'Purchase'::text AS "Trade Type",
    'Shipped'::text AS "Event Type",
    sm."dtmBLDate" AS "Event Date",
    sm."dblQuantity" AS "Quantity",
    sm."intLotId",
    sm."strLotStatus" AS "Lot Status",
    sm."intShipmentId"
   FROM vw_utility_stock_movements sm
  WHERE (sm."strMovementType" = 'Inbound'::text)
UNION ALL
 SELECT sm."intSaleLineId" AS "intTradeId",
    'Physical'::text AS "Trade Category",
    'Sale'::text AS "Trade Type",
    'Shipped'::text AS "Event Type",
    sm."dtmBLDate" AS "Event Date",
    sm."dblQuantity" AS "Quantity",
    sm."intLotId",
    sm."strLotStatus" AS "Lot Status",
    sm."intShipmentId"
   FROM vw_utility_stock_movements sm
  WHERE (sm."strMovementType" = 'Outbound'::text)
UNION ALL
 SELECT sm."intPurchaseLineId" AS "intTradeId",
    'Physical'::text AS "Trade Category",
    'Purchase'::text AS "Trade Type",
    'Shipped'::text AS "Event Type",
    sm."dtmBLDate" AS "Event Date",
    sm."dblQuantity" AS "Quantity",
    sm."intLotId",
    sm."strLotStatus" AS "Lot Status",
    sm."intShipmentId"
   FROM vw_utility_stock_movements sm
  WHERE (sm."strMovementType" = 'Dropship'::text)
UNION ALL
 SELECT sm."intSaleLineId" AS "intTradeId",
    'Physical'::text AS "Trade Category",
    'Sale'::text AS "Trade Type",
    'Shipped'::text AS "Event Type",
    sm."dtmBLDate" AS "Event Date",
    sm."dblQuantity" AS "Quantity",
    sm."intLotId",
    sm."strLotStatus" AS "Lot Status",
    sm."intShipmentId"
   FROM vw_utility_stock_movements sm
  WHERE (sm."strMovementType" = 'Dropship'::text);;
