Shows New Bookings Entered TODAY
SELECT B.booking_no AS Code,
B.organizationv6 AS Company,
B.ddate AS [Out Date],
D.div_name AS Division,
CASE
WHEN B.bookingprogressstatus = 0 THEN 'Quote'
WHEN B.bookingprogressstatus = 1 THEN 'Light Pencil'
WHEN B.bookingprogressstatus = 2 THEN 'Heavy Pencil'
WHEN B.bookingprogressstatus = 3 THEN 'Confirmed'
ELSE 'Cancelled'
END AS [Progress Status],
B.showname AS [Show Name],
V.venuename AS Venue,
B.price_quoted AS Revenue,
CASE
WHEN (
B.booking_type_v32 = 6
OR B.booking_type_v32 = 7) THEN Cast(B.sales_discount_rate AS DECIMAL (6,2))
ELSE Cast(B.discount_rate AS DECIMAL(6,2))
END AS [Disc %],
CASE
WHEN B.booking_type_v32 = 6 THEN Cast(((b.sales_amount - B.sales_undisc_amount) * (b.sales_discount_rate /100)) AS DECIMAL (9,2))
ELSE Cast(((b.hire_price - B.un_disc_amount) * (b.discount_rate/100)) AS DECIMAL(9,2))
END AS [Discount Amt],
O.firstname AS [Operator First],
O.lastname AS [Operator Last],
B.salesperson,
B.entrydate AS [Booking Created],
B.condate AS [Confirmed Date],
B.inv_date AS [Invoiced Date],
CASE
WHEN B.booking_type_v32 = 0 THEN 'Rental'
WHEN B.booking_type_v32 = 1 THEN 'Sub Hire'
WHEN B.booking_type_v32 = 2 THEN 'Quote'
WHEN B.booking_type_v32 = 3 THEN 'Rental Quote Monthly'
WHEN B.booking_type_v32 = 4 THEN 'Rental Monthly'
WHEN B.booking_type_v32 = 5 THEN 'Sub Rental'
WHEN B.booking_type_v32 = 6 THEN 'Sale'
WHEN B.booking_type_v32 = 7 THEN 'Sales Quote'
WHEN B.booking_type_v32 = 11 THEN 'Location Transfer'
WHEN B.booking_type_v32 = 13 THEN 'Sundry Transfer'
WHEN B.booking_type_v32 = 14 THEN 'Rental 7'
WHEN B.booking_type_v32 = 15 THEN 'Rental 14'
WHEN B.booking_type_v32 = 16 THEN 'Rental 28'
WHEN B.booking_type_v32 = 17 THEN 'Rental Quarterly'
WHEN B.booking_type_v32 = 18 THEN 'Rental Quote 7'
WHEN B.booking_type_v32 = 19 THEN 'rental_quote_14'
WHEN B.booking_type_v32 = 20 THEN 'Rental Quote 28'
WHEN B.booking_type_v32 = 21 THEN 'Rental Quote Quarterly'
ELSE ''
END AS Type,
CASE
WHEN B.status = 0 THEN 'Booked'
WHEN B.status = 1 THEN 'Checked Out'
WHEN B.status = 2 THEN 'Returned'
ELSE ''
END AS State,
B.invoiced,
B.invoice_no
FROM dbo.tblbookings AS B
LEFT OUTER JOIN dbo.tbldivlist AS D
ON B.division = D.div_number
LEFT OUTER JOIN dbo.tbloperators AS O
ON B.operatorsid = O.id
LEFT OUTER JOIN dbo.tblvenues AS V
ON B.venueid = V.id
WHERE CONVERT(VARCHAR(12),b.entrydate, 112) >= CONVERT(VARCHAR(12),Getdate(), 112)