Forum Discussion

Mike_James's avatar
Mike_James
Ultimate Cover User
1 month ago
Solved

Cloud API 2025.11 incomplete retrieval of sales invoices entered in advance

We provide reporting services to a high-volume client in the food industry, providing meals to elderly clients. To manage the Christmas shutdown, orders are placed by (or on behalf of) these clients up to 8 weeks in advance, and the orders are recorded as post-dated sales invoices in the business's MYOB AccountRight file.  (During the year, orders are also placed in advance, but not to quite the same extent).

Our reports are run daily and provide information to the kitchen (meal volumes by product), the packers (labels) and the drivers (route data). Our reports are critical to daily operations. Cooking, packing/chilling and delivery must operate a 3-day cycle without breaks.

Being a high-volume business, we have streamlined the extract of sales data for the reports to only read the day required for the reports and one day prior. Extracting all data every day would waste a lot of time.

When running our suite of reports yesterday for the coming Monday 5th January, the reports were mostly incomplete. We compared a sample of our reported sales to MYOB sales reports by item, and found no pattern. But then we exported all the day's sales (manually via the File Import/Export assistant) and analysed sales for two products in Excel. We found that in one case all our reported sales were in one group at the end of the block (ie none of the sales entered prior had been picked up by the API), and in the other case our reported sales were in 2 blocks, book-ending a bunch of sales not reported. This pattern seemed significant.

We then took a backup of the file and restored it locally, and our reports for that day (and the next) were run correctly and completely from the local without error.

We reverted to the cloud file, and discovered that if we extracted all sales dated in the past 3 weeks, then the reports for 5th January were correct. 

We were unable to locate any missing invoices in the JSON responses from the API, so we concluded that they had not been returned by the API. The record volumes confirmed this.

We rely on the Sales/Invoice/Item endpoint. We are concerned to note the description of the date field as "Transaction Date Entry", which we suspect has acquired the meaning of "Entry date" and not "Transaction Date". Is it possible that the cloud API is applying the Date filter incorrectly? (Note that the local file returns data correctly per the supplied filter).

Sample local URL includes: Sale/Invoice/Item?$top=400&$filter=Date%20ge%20datetime'2026-01-05'. A skip parameter is applied in NextPage URLs.

We know what to do as a workaround, our question is why does the API return correct data from a local file but not from a cloud file?

  • After further research I have concluded that providing x date or date range retrieves the data for exactly that date range. Use of OrderBy when using Top/Skip avoids all the other issues. This should be made clear in the API documentation for those like me who have not learned this lesson already.

2 Replies

  • Mike_James's avatar
    Mike_James
    Ultimate Cover User
    23 days ago

    After further research I have concluded that providing x date or date range retrieves the data for exactly that date range. Use of OrderBy when using Top/Skip avoids all the other issues. This should be made clear in the API documentation for those like me who have not learned this lesson already.

  • Mike_James's avatar
    Mike_James
    Ultimate Cover User
    1 month ago

    This query was submitted to the API support team, and their answers (so far) are:

    • The theory about the invoice date being treated as entered date is not correct, so this can be ignored.
    • When top/skip are used, OrderBy MUST also be used, eg OrderBy Date asc, UID asc. (My note: the API documentation does not state this). The sequence of parameters should be filter, orderby, top, skip.
      My comment: we rely on the URL per the NextPageLink value. Will this include OrderBy if it appears in the original URL?
    • Querying a local file goes through a very different process with "more stable/consistent ordering characteristics".
    • "MYOB has previously stated that datetime values in Filter clauses are treated as UTC". (My comment: have not seen this as such. Therefore (I assume) to extract an invoice dated "2026-01-16T00:00:00", the filter value would need to be "2026-01-15T23:00:00" from NZ, ie local time less 13 hours.