Quotes: Validation Rules

All validation from the Transactions domain applies.

When a quote is created or modified, validation will be performed on several fields. If any of these validations fail, then the API will return an HTTP-400 response.

Field

Validation

site_code

Checks that the specified site exists. The site code is extracted from the ‘quote_code’ parameter.

accounts_receivable_code

loyalty_account_code 

Checks that the customer exists. Either accounts_receivable_code or loyalty_account_code is required.

product_code

Checks that the specified product exists.

lost_reason_code Checks that the reason exists. See Configuration section.
quote_version When updating a quote, checks that the quote version matches the current version.
line_version When updating a line, checks that the line version matches the current version.
expiry_date Checks that the date formatting is correct. If not provided for a new quote, current date + default quote validity days will be used. See Configuration section.

Quote Code

When a quote is created via PUT, a unique, non-existing quote_code must be supplied as a parameter. The 13-digit quote code is in the format ssstttnnnnnnn where sss is the site_code, ttt is the terminal ID, and nnnnnnn is a sequential number.

Search Dates

When specifying the dates in the search criteria the FROM date starts at 00:00 in the morning and the TO date ends at 23:99; e.g:.

"expiry_date" : {

"date_from" : "2022-11-22",

"date_to" : "2022-11-23"

 

For the above it will search for all quotes between 2022-11-22 00:00:00 and 2022-11-23 23:99:99.

Quote Versioning

Quotes can be created via the PUT endpoint. The API will assign a quote version and line version, which will be included in the response as the quote_version property. It is advisable to use quote_version = 1 and line_version = 1 when creating a quote.

Quotes can be updated via the PUT endpoint. The caller must include the current quote_version, line_versions and unique_quote_line_ids in the request. If the quote_version or line_version that is supplied does not match the current version of the quote or line, the call will be rejected with an HTTP-409 error. If the quote_version and line_version match and all other validation passes, the quote will be updated and the API will respond with a new quote_version and line_version.

Once a quote has been updated, it is distributed to stores and any application that contains quote functionality. Because the data is distributed, there is the potential for the quote to be updated in more than one place. The API maintains a quote version for each quote and quote line to ensure that the calling application is working with the most recent version of that quote and line.

If an update is rejected, the client may retrieve the new version of the quote and present the user with the information required to resolve the issue and re-submit their request.

Quote header versioning is independent from line versioning. line_version will increase on line update while quote_version stays the same and vice versa.

Example:

Client 1

Client 2

API

Creates a quote via PUT.

Quote version: 1

 

Quote is created.

Returns quote version: 1

 

Retrieves the quote via GET.

Quote version: 1

Returns quote version: 1

Updates via PUT.

Quote version: 1

 

Quote is updated.

Returns quote version: 2

 

Updates via PUT.

Quote version: 1

Request is rejected as the quote has changed and the update may be inconsistent.

 

Retrieves the quote via GET.

Quote version: 2

Returns quote version: 2

 

Updates via PUT.

Quote version: 2

Quote is updated.

Returns quote version: 3