frappe / books

Free Accounting Software
https://frappe.io/books
GNU Affero General Public License v3.0
2.68k stars 614 forks source link

Bug fix recorddate inconsistency #831

Closed Isaac-GC closed 5 months ago

Isaac-GC commented 5 months ago

After doing some testing in various timezones it looks like this (very ugly) patch successfully fixes the various timestamp inconsistency issues, which resulted in incorrect ledgers, profit/loss, etc

What was happening is that depending on one's timezone, the Date that was saved in the JournalEntry/Ledger would convert the Datetime to a timestamp of 00:00.000 for the local timezone and then calculates the GMT timestamp based on the local timezone. This creates an instance where what is saved may not properly reflect what was entered and expected in the related invoices (or other items).

Here are two test cases showing the issue of what was happening:

  1. Test case 1 (Myanmar timezone -> GMT +6.5) image

The time is converted to GMT which is 6.5 hours behind Myanmar at that point of time, resulting in saving the datetime as previous date (in this test case, 2022-12-31T17:30.000Z)


  1. Test case 2 (US Pacific timezone -> GMT -8) Screenshot 2024-01-30 193727

In this case, when the timestamp for the local timezone is 00:00.000, GMT time will be 8 hours ahead (2023-01-01T08:00.000Z)

Isaac-GC commented 5 months ago

The plan is to break it out in the future, but as you mentioned we should check the scope of the entirety of the issue. I included it in the function to ensure its scope is only applied to that section and children that use it.

For the scope of the issue, if you look at the db patch, it shows all of the models affected