question

selectnj avatar image
selectnj asked Raymond Lee Deactivated commented

When is the modifiedTime updated

Is the modifiedTime field changed when the order is sync'ed, similar to the order createdTime ?
Also, can we count on the modifiedTime being less than (earlier than) the item createdTime for items added to a recalled order. We want to use the timestamps to verify which items are new to the sale and which items were previously added. Currently we are using the order createdTime as part of our algorithm but if there are large delays in syncing the order, the createdTime is updated and may throw things off.
Orders
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

How about keeping your own DB of order ID, item ID, and times?

1 Like 1 ·
Raymond Lee avatar image
Raymond Lee Deactivated answered Raymond Lee Deactivated edited
Here are the three timestamp fields and when they are changed:
createdTime: The time that the object is created on Clovers database.
clientCreatedTime: The time that the object is created on a Clover device, via Web, or via API call. This can differ from the createdTime if the object was created on an offline Clover device, and the Clover device is syncd at a later time to update the Clover database when the device is back online. In such a case the clientCreatedTime will be earlier than the createdTime.
modifiedTime: The last time the object was modified.

So the modifiedTime field is changed when the order is sync'd IF the order has been modified. The order's clientCreatedTime and createdTime will not change after it is set, as the order can only be created once.

It is not possible for the modifiedTime for an order to be less than/earlier than a line item that is added to that order, as the modifiedTime will automatically be changed to equal the createdTime of the newly added line item. This is because adding a line item to an order counts as modifying it.

Yes, you can use the line item's created times to see which ones are new, and which ones were previously in the order already. For your algorithm, you should use the clientCreatedTime, as that is the absolute time when the order is created (whether it is offline/online clover device, web, or API), and is not affected by any delays in syncing the order.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

selectnj avatar image selectnj commented ·

We have tried to simulate this scenario and now have additional questions. We took our clover device offline by unplugging the network cable. We then entered a one item sale, saved it, reopened, added another item, saved again and then reopened a third time to add another item before closing out the ticket. Total of 3 items. After plugging the network cable back in and allowing it to sync we noticed the following, which was not what we expected.......

clientCreatedTime = orderCreatedTime and is the same on all 3 instances of the ticket. (1550182590398)

itemCreatedTime for item 1 is less than clientCreatedTime (1550182590377)

There is no modifiedTime found at any point.

Our App logs the data we get. Attached is a copy of the log.

logdetails-4.txt

0 Likes 0 ·
logdetails-4.txt (4.5 KiB)
Raymond Lee avatar image
Raymond Lee Deactivated answered Raymond Lee Deactivated commented
It is possible you are retrieving the order information before it has fully sync'd to the Clover database, which would explain your 3 observations:
1. Missing modifiedTime, and missing orderClientCreatedTime for line items.2. clientCreatedTime = createdTime.
3. Item createdTime is earlier than the createdTime you received.

The reason for this, is that the order sync happens in multiple steps:
1. First the top level order object is created with a createdTime, a placeholder clientCreatedTime, and no modifiedTime.
2. Each individual action that was performed on the order while the device was offline is sync'd individually to the Clover device. So in your case, each line item add is sync'd individually.
3. Lastly, the rest of the order data is updated/sync'd (including the correct clientCreatedTime, as well as a modifiedTime), and the line items are updated with the order's correct clientCreatedTime.

So the clientCreatedTime you are seeing is a placeholder; if you do a GET request for the same order "TH33ZXWPA9WAT", you will see the correct timestamps.
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

selectnj avatar image selectnj commented ·

We are not using the REST api. Our app runs on the Clover station and uses intents (ORDER_SAVED and PAYMENT_PROCESSED). We are getting the order immediately when it is entered at the POS. Is there a method we can use to insure the order has been synced without using REST ?

0 Likes 0 ·
Raymond Lee avatar image Raymond Lee selectnj commented ·

In that case, if you are pulling the Order data from Android SDK, it will reflect the local Order information to the Clover device, not the Clover database. So if you are pulling the Order data before it has been sync'd it will show the null modifiedTime.

There is currently no method you can use the insure the order data on the Clover device is the most up to date / synced with the database without using REST API, especially since you could be pulling the order data while the Clover device is offline.

If needed, here are the times in which order data is sync'd to the Clover device:

1. When the merchant opens up the order from the Orders app.

2. When the merchants hits the sync button at the top right corner of the Clover apps.

3. The Clover device receives the order update notification, and syncs the order.

4. The Clover device automatically sync's on its own once in a while as well.

0 Likes 0 ·

Welcome to the
Clover Developer Community