Pricing bookings
You can price bookings using the CalculatePriceRequest
request or the PriceAndQueryRequest
.
CalculatePriceRequest
simply prices the requested items if this is all you need then use thisPriceAndQueryRequest
can price a basket of items at the same time as querying extra items to include on the booking.- There are some pricing use cases that
PriceAndQueryRequest
cannot serve; for example a long booking with breaks. UseCalculatePriceRequest
for these.
Calculate Price Request
You provide a list of Products
to price. You should set BookingDetails
with details about the booking that will be used
to apply discounts, and you can set Options
to disable or enable features of the pricing.
Each LineToPrice
in the Products
list will have a ProductCode
and SchoolCode
to indicate the item to be priced.
All products must contain a StartDate
and must contain either: a NumberOfUnits
or a EndDate
to indicate the quanity of item to pricel.
A
NumberOfUnits
to indicate how many units are required. The end date will be calulated by the service.A
EndDate
to indicate tha last date that a product product should be provided. The service will work out the number of units based on the date.
It is recommended that you use NumberOfUnits
as it avoids the need for you to account for school closures. You can also add StudentBreaks
to a product line to create gaps in the provided dates.
// Price a line based on quantity
LineToPrice toPrice = new LineToPrice();
toPrice.SchoolCode = 'S1';
toPrice.ProductCodes = 'C1';
toPrice.QuantityToPrice = new QuantityToPrice()
{
StartDate = new Date(2017, 5, 1),
NumberOfUnits = 4
};
// Price a line based on dates
LineToPrice toPrice2 = new LineToPrice();
toPrice2.SchoolCode = 'S1';
toPrice2.ProductCodes = 'C1';
toPrice2.DateSpans = new List<DateRange>();
toPrice.QuantityToPrice = new QuantityToPrice()
{
StartDate = new Date(2017, 5, 1),
EndDate = new Date(2017, 5, 26)
};
// Create the API request itself
CalculatePriceRequest request = new CalculatePriceRequest();
request.BookingDetails = new BookingDetails();
request.BookingDetails.BookingCreationDate = new Date(2017, 5, 31);
request.Products.Add(toPrice);
request.Products.Add(toPrice2);
ProductsAndPricingClient client = new ProductsAndPricingClient(GetConfig());
CalculatePriceResponse response = client.Post(request);
Calculate Price Response
The response returned when calculating prices has the following properties:
Products
is the same list of products passed up with the request, but it also includes the prices of each item.Fees
is a list of fees that were added based on the products.SpecialOfferChoices
is a list of the possible special offers to apply. See Discounts for more details. This will be blank if you set theOptions.ApplyBestSpecialOffer
flag totrue
in the request as the best special offer will have already been applied.- There are various amounts of money that are based on rolling up the amounts of money on the
Fees
andProducts
lists. These are described below.
Money Amount | Meaning |
---|---|
BasePrice |
This is the price before any discounts, commission or tax is applied |
DiscountTotal |
This is the amount of discount that is offered |
CommissionTotal |
This is the amount of commission that the agent will be paid |
TaxAmount |
This is the amount of tax payable |
You can also see the above monetry amounts on each record in Products
and Fees
if you wish to see
the price of individual items. The prices on the response object are calulcated by summing the individual product
and fee items.
Each Product
and Fee
also contains a list of the indiidual discounts that were applied to arrive at the DiscountTotal
amount.
See Discounts for more details.
Price And Query Request
The PriceAndQueryRequest
class allows you to price a booking in a very similar way to the CalculatePriceRequest
. You can specify Options
, BookingDetails
and BasketItems
to price in exactly the same way. Additionally you can specify a number of Queries
that allow for extra products to be queried and priced as well.
Each item in Queries
is a LimitedProductQuery
that allows you to specify criteria for products to find:
- You must specify a specific
SchoolCode
to search - You must specify the
DateRange
that the product will be used for - You may optionally specify products to find or product types. If you don't specify any of these all products will be returned
The result to each LimitedProductQuery
is a LimitedProductQuery
result that indicates the product found along witht the cost of the
product that would be incurred if it was added to the basket including any fees or discounts.