Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoice getFullyPaidOnDateAsDate returns incorrect date for timezones west of UTC #294

Open
IanSimpson opened this issue Aug 3, 2022 · 0 comments
Assignees

Comments

@IanSimpson
Copy link
Contributor

SDK you're using (please complete the following information):

  • Version 2.9.0 (still seems to exist in 2.14.1)

Describe the bug
The Xero API returns a MSDateTimeFormat for the payment date. This works out to midnight on the local date for that company. I.e., for an invoice paid on July 27 at any time, it returns a value of /Date(1658880000000+0000)/.

Converting that to a unix timestamp (1658880000) and then a human-friendly date, we get Wednesday, 27 July 2022 00:00:00 GMT.

If I call the ->getFullyPaidOnDateAsDate() function from a server whose timezone is located in the USA, my output looks like this:

DateTime Object
(
    [date] => 2022-07-26 00:00:00.000000
    [timezone_type] => 3
    [timezone] => America/Chicago
)

Note July 26.

Cross-checking against Xero confirms that the payment was made on the 27th.

image

To Reproduce
Steps to reproduce the behavior:

  1. Record payment on an invoice in a US-based company
  2. Fetch the invoice from the API, and output $invoice->getFullyPaidOnDateAsDate()->format('Y-m-d');, on a server set to a timezone in the US
  3. Observe the that the payment date is wrong by a day

Expected behavior
I'd expect that the getFullyPaidOnDateAsDate() function returns the date that the invoice was fully paid, instead of another adjacent date

@pumpkinball pumpkinball self-assigned this Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants