Time Rated Services

Tags: v6

General Description

The SyrveFront application can be used to sell not only goods and dishes but also services with time-based pricing. These can include establishments with payment for the time spent (water parks, anti-cafes), equipment rentals, and much more, but a classic example is billiards, which will be used in this article to describe the subject area.

Starting and Stopping

The service can be started and stopped. When the service is started, time is counted, the “quantity” increases, and, accordingly, the cost rises. When the service is stopped, the time count is paused, and these periods are not charged.

The service can be ordered for a specific time; in this case, all ordered time is charged, even if the service was actually used for a shorter time. For example, a visitor can order billiards for an hour, with the cost initially set for 1 hour and not changing, while the “quantity” will increase over time. When the specified time limit is reached, the service will automatically stop. Another option is payment based on actual usage; you can play until you get tired and pay for the total time, then no limit is set, but the service will stop when the maximum possible duration of 12 hours is reached.

Starting and stopping the service may be accompanied by an additional action tied to the table on which the order is placed. In the case of billiards, this may involve turning on the lighting above the table during the game: initially, the light is off, the service is started — the light turns on, stopped — it goes out. This leads to a limitation — no more than one service can be started on a table. Currently, this limitation applies to all tables regardless of whether such additional actions are configured. In future versions, this limitation will not apply to tables or services that do not have ties to external devices.

Pricing

The cost of the service may depend on the day of the week and change over time. Two pricing options are possible:

Time accounting is conducted according to the following rules:

Data Structures

Service

IOrderServiceItem — an order item corresponding to a time-based service. It is located in the collection IOrder.Items alongside dishes that can be prepared (IOrderCookingItem). In the menu, the time-based service corresponds to a product (IProduct) with the type ProductType.Service and has pricing parameters IProduct.RateSchedule (if pricing parameters are not set, it is a service without time-based pricing, it is added to the order and paid for like a regular dish).

Key properties of the time-based service:

Service Period

IOrderServiceItemPeriod — the period of service operation under a specific rate, includes all time segments when the corresponding rate was active.

Key properties of the time-based service period:

Pricing Settings

RateSchedule — settings for the time-based service, key properties:

Service Management

AddOrderServiceItem — adding a service to an order.

StartService — starting a service.

StopService — stopping a service. The service will stop automatically when the order is checked or paid.

Examples

In the SamplePlugin, which is part of the SDK, there are examples of adding a service to an order, starting, and stopping a service — the methods [StartService] and [StopService] in the class EditorTester:

private static void StartService()
{
    var order = PluginContext.Operations.GetOrders().Last(x => x.Status == OrderStatus.New);
    var serviceProduct = PluginContext.Operations.GetActiveProducts().Last(x => x.Type == ProductType.Service && x.RateSchedule != null);
    var credentials = PluginContext.Operations.GetCredentials();
    var service = PluginContext.Operations.AddOrderServiceItem(serviceProduct, order, order.Guests.Last(), credentials, TimeSpan.FromHours(2));
    PluginContext.Operations.StartService(credentials, order, service);
}

private static void StopService()
{
    var order = PluginContext.Operations.GetOrders().Last(x => x.Status == OrderStatus.New);
    var service = order.Items.OfType<IOrderServiceItem>().Last(x => x.IsStarted);
    PluginContext.Operations.StopService(PluginContext.Operations.GetCredentials(), order, service);
}