CREATE PROCEDURE dbo.OnlineDepositInfoGet @AReferenceNumber INT, @AGuestNumber INT AS
SET NOCOUNT ON

/*
  Created by Kent Johansen November 2016
  Get deposit amount
*/
                                        
SELECT Followup.FollowupNumber, Followup.DepositAmount
FROM FollowUp WITH (NOLOCK)
INNER JOIN ReservationFollowUpXTab WITH (NOLOCK) ON ReservationFollowUpXTab.FollowUpNumber = FollowUp.FollowUpNumber
  AND ReservationFollowUpXTab.ReferenceNumber = @AReferenceNumber
  AND ReservationFollowUpXTab.GuestNumber = @AGuestNumber
INNER JOIN Reservations WITH (NOLOCK) ON Reservations.ReferenceNumber = ReservationFollowUpXTab.ReferenceNumber
  AND Reservations.GuestNumber = ReservationFollowUpXTab.GuestNumber
WHERE ISNULL(DepositAmount, 0) > 0
AND FollowUp.State IN (0,1,2)
AND FollowUp.Type IN (15)
ORDER BY RuleNumber