IF OBJECT_ID('tempdb..#lHR_TrvlCashRegItem') IS NOT NULL
    DROP TABLE #lHR_TrvlCashRegItem;

CREATE TABLE #lHR_TrvlCashRegItem (
    acKey nvarchar(13) NULL,
    acSelected char(1) NULL DEFAULT ('T'),
    acCostDrv nvarchar(16) NULL DEFAULT (''),
    anValue money NULL DEFAULT ((0)),
    anPayedCRAll money NULL DEFAULT ((0)),
    anPayedCRK money NULL DEFAULT ((0)),
    anPayedCRD money NULL DEFAULT ((0)),
    anPayedCRS money NULL DEFAULT ((0)),
    anValueForPay money NULL DEFAULT ((0)),
    anID int IDENTITY(1,1) NOT NULL,
    acTrvlType char(1) NULL,
    anTypeExp int NULL
);

EXEC pHR_TrvlCashRegItemPrep 
    @cKey = @cKey,
    @cCurrency = @cCurrency,
    @nPayOrderValue = @nPayOrderValue,
    @cKeyPayOrder = NULL,
    @cFgn = @cFgn,
    @dDate = @dDate;

SELECT 
    anID,
    acKey,
    acSelected,
    acTrvlType,
    anTypeExp,
    anValue,
    anPayedCRAll,
    anPayedCRK,
    anPayedCRD,
    anPayedCRS,
    anValueForPay
FROM #lHR_TrvlCashRegItem
ORDER BY acCostDrv DESC, acTrvlType, anTypeExp;

