Problems with tax by day report queries

shreyansshreyans Member Posts: 16
edited December 2018 in Development
Hi, I am trying to use the taxByDay request, the startDate and endDate parameters seems to be buggy.

https://api.lightspeedapp.com/API/Account/{id}/Reports/Accounting/TaxesByDay.json?startDate=11/21/2018&endDate=11/30/2018

for account between 21st and 30th, I get records for 20th as well.

{
    "@attributes": {
        "count": "4",
        "limit": "100",
        "offset": "0"
    },
    "Taxes": [
        {
            "date": "11/20/2018",
            "shopID": "1",
            "taxCategoryID": "1",
            "taxCategoryName": "Sales Tax",
            "tax": "0.08"
        },
        {
            "date": "11/21/2018",
            "shopID": "1",
            "taxCategoryID": "1",
            "taxCategoryName": "Sales Tax",
            "tax": "0.49"
        },
        {
            "date": "11/28/2018",
            "shopID": "1",
            "taxCategoryID": "1",
            "taxCategoryName": "Sales Tax",
            "tax": "0.41"
        },
        {
            "date": "11/29/2018",
            "shopID": "1",
            "taxCategoryID": "1",
            "taxCategoryName": "Sales Tax",
            "tax": "0.50"
        }
    ]
}


When i try requesting for just 20th and 21st 

https://api.lightspeedapp.com/API/Account/{id}/Reports/Accounting/TaxesByDay.json?startDate=11/20/2018&endDate=11/21/2018

I get this 

{
    "@attributes": {
        "count": "0",
        "limit": "100",
        "offset": "0"
    }
}

The first payload clearly shows data existing for 20th and 21st and even then i get 0 results here. 

How can I get the accurate reports by using start date and end date.

Thanks.

2 comments

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 573 moderator
    edited December 2018
    Hey @shreyans it looks like you've discovered a bug.

    You need to manually set the date to midnight UTC time like so:

    startDate=2018/11/21T00:00:00
    0

    The reason you have to do this is because when you only set the date like this: 11/21/2018 it searches the whole 24 hour range period starting at your local time which relative to the UTC is the day before.

    As your local time is PST, it starts from 11/20/2018(PST) to 11/21/2018(PST). So to fix your start-date range you'll need to make sure you're set to midnight and then put the offset of -0800

    So the final form of your query should be:

    startDate=2018/11/21T00:00:00-0800


    and in full form:

    https://api.lightspeedapp.com/API/Account/{{accountID}}/Reports/Accounting/TaxesByDay.json?startDate=2018/11/21T00:00:00-08:00&endDate=2018/11/30T00:00:00-08:00


    This will limit you to the 3 results you expect 

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

Sign In or Register to comment.