Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Bug report: unable to get full months in profit and loss report

Started by N Pinkerton -   in API Endpoints

I'm aware this issue has come up before.
The docs (https://developer.xero.com/documentation/api/accounting/reports/#profit-and-loss) state that if you request a month with less than 31 days, compare months will not show the full month's data.

I find this behaviour as annoying as previous posters. But, apparently, it's intended.

My bug has to do with the last bit of the info above "To ensure you always get a full month of data in previous periods either:
Start from current month (i.e. don't specifiy a fromDate or toDate on the request), or
Start in a month with 31 days (e.g. start in July instead of June)
"

When asking for 12 months of data and not specifying from or too dates, I still seem to get only up to 30 days (we are in June now and June has 30 days). But, according to the above, I should be able to get the last 12 months of full data if starting in the current month.

To replicate the issue:

- Make an api call (I'm using Xero-node but have confirmed the bug in the api explorer)
- API: Accounting, Endpoint: reports, Operation: Get Profit and Loss
- Params: periods 11, timeframe MONTH
- do not set fromDate or toDate as instructed above

headers that come back are (note the months that should have 31 days):

{
"Value": ""
},
{
"Value": "30 Jun 22"
},
{
"Value": "30 May 22"
},
{
"Value": "30 Apr 22"
},
{
"Value": "30 Mar 22"
},
{
"Value": "28 Feb 22"
},
{
"Value": "30 Jan 22"
},
{
"Value": "30 Dec 21"
},
{
"Value": "30 Nov 21"
},
{
"Value": "30 Oct 21"
},
{
"Value": "30 Sep 21"
},
{
"Value": "30 Aug 21"
},
{
"Value": "30 Jul 21"
}

Accompanying data is different from profit and loss in xero (months with more than 30 days are slightly lower values).
Apologies for the confusion.
I will get the documentation updated as the only workaround is to start in a month that has 31 days and combine reports to get the periods you need
 

Sally C (Community Manager)  

Thanks for your reply, though the documentation being wrong was not the answer I was hoping for.

You seem to acknowledge this is a bug (by talking about workarounds) - is addressing the issue on the roadmap? Adding a "CALANDAR_MONTH" option to the timeframe parameter would be ideal.
 

N Pinkerton  

The issue has been raised with our Product Team but there is no timescale yet for this
 

Sally C (Community Manager)