waynerobinson / xeroizer

Xero accounting system API library.
http://waynerobinson.github.com/xeroizer
Other
238 stars 311 forks source link

Use date parameter when get ProfitAndLoss report #506

Closed varg90 closed 4 years ago

varg90 commented 4 years ago

Hello. I use xeroizer (2.18.1) gem for my rails (5.1.4) app.

Everything worked fine until I add a date to client.ProfitAndLoss.get() parameters, I faced a problem when I tried to add an ability for user to pick the report date.

Something like this: client.ProfitAndLoss.get timeframe: 'MONTH', periods: 11, fromDate: active_date - 1.year, toDate: active_date (I also tried date: active_date)

active_date is a ruby Date object

If I use fromDate and toDate it returns a report for this period with sums (whole date range value instead of the current month value). If I use date parameter it seems to be ignored at all.

I also didn't find how to provide date with their API Previewer, but this report definitely could be generated if you visit reporting.xero.com and then Accounting page -> Reports -> Income Statement (Old) -> Compare Periods. You can see the Date field, that works exactly as I need.

Could anyone give me an advice how can I get exactly the same report, that I got if I don't provide any date params (today by default), but for the custom date. date, fromDate and toDate don't work, or I may use it wrong.

Spent a lot of time for that, will really appreciate any help. Thanks

varg90 commented 4 years ago

If anyone still looking for a solution: You should set fromDate: active_date = 1.month instead of 1.year and keep periods: 11. It will work as expected, the report fromDate will be 1 year ago