How to read original orders and change orders from the API

A booking reference is the rental contract. Sharefox keeps the original order on that reference and, once the order is locked, stores later changes as separate change orders.


This article explains how these orders relate, and which admin API calls return all three order content versions: the original order, each change order, and the latest combined order content.


How the original order and change orders relate

The original order is the first order on a booking reference. In the API it has isChangeOrder: false property, and it has its own order id.

  • While that order is still unlocked, further edits update the same order id. This can cover for example the period before the order is paid online or billed or signed, and locked by such a process

Once the order is locked, the original order stays as it is. The next change is stored on a change order:

  • The change order has a new order id and the same booking reference
  • It contains what changed after the previous order in the chain was locked. That can be a new fee, or correction items when the rental period changes (eg. the new price minus the old price)

The same rule continues along the chain of change orders: edits to an unlocked change order update that specific order; after that change order is locked, new changes will create a new change order for the same booking reference.

From the API you can read all "three versions" of the contract content:

  • The original order
  • Each change order
  • The latest entire order content, combining the original order and the change orders

About order locking

Locking keeps the order in sync with other systems, so a record that has already been shared stays as it was sent. An order can be locked in these situations:

  • An online payment, so the order stays in sync with the payment provider (for example Nets).
  • An invoice basis that has been sent from Sharefox to other systems
  • A manual lock (user action in Admin Order page)
  • A monthly lock used for reporting

The full list of lock triggers, and how a locked order behaves in Admin, is in What is order locking and how does it work?.


How to read these from the API

These calls use an admin user token. Authentication is described in How to use the Sharefox API. The request and response schemas are in the API documentation.

One order: the original order or one change order

GET /admin/orders/{orderId}

  • Returns the single order with that id. Send the original order id to read the original order. Send a change order id to read that change order on its own.

The latest entire order

GET /admin/orders/reference/{reference}

  • Returns the latest entire order content, combining the original order and the change orders on that booking reference
  • id property is the original order id
  • changes property lists every order on that reference: the original order and each change order. Each entry includes that order's id.

Note: Adding the extra "mode" parameter in GET /admin/orders/{orderId}?mode=booking returns the same combined order as GET /admin/orders/reference/{reference}.

Example

A booking is created with reference BR12 and original order id 501 (is_change_order: false).

  • While order 501 is unlocked, a correction is made before payment updating order 501
  • The customer pays online. Order 501 is locked
  • A fee is added afterwards from Admin. Sharefox creates a change order 502 on reference BR12. Order 502 contains the new fee. Order 501 is unchanged
  • An extra charge from Admin on order 502 locks this order
  • The rental period is changed after order 502 is locked. Sharefox creates change order 503 on the same reference. Order 503 contains the correction items: new price minus old price

You can then read:

  • GET /admin/orders/501 — the original order.
  • GET /admin/orders/502 — the change order that added the fee
  • GET /admin/orders/503 — the change order with the rental-period correction
  • GET /admin/orders/reference/BR12 — the combined order. Id is 501. Changes lists orders 501, 502, and 503

GET /admin/orders/501?mode=booking returns that same combined order.


Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us