-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #831 from frappe/bug_fix_recorddate_inconsistency
Bug fix recorddate inconsistency
- Loading branch information
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
**/types.ts | ||
**/dist_electron | ||
**/dummy/*.json | ||
**/.github/ISSUE_TEMPLATE/*.yml | ||
**/.github/ISSUE_TEMPLATE/*.yml | ||
**/patches/v0_21_0/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { DatabaseManager } from '../../database/manager'; | ||
|
||
/* eslint-disable */ | ||
async function execute(dm: DatabaseManager) { | ||
await dm.db!.knex!('AccountingLedgerEntry') | ||
.select('name', 'date') | ||
.then((trx: Array<{name: string; date: Date;}> ) => { | ||
trx.forEach(async entry => { | ||
const entryDate = new Date(entry['date']); | ||
const timeZoneOffset = entryDate.getTimezoneOffset(); | ||
const offsetMinutes = timeZoneOffset % 60; | ||
const offsetHours = (timeZoneOffset - offsetMinutes) / 60; | ||
|
||
let daysToAdd = 0; // If behind or at GMT/Zulu time, don't need to add a day | ||
if (timeZoneOffset < 0) { | ||
// If ahead of GMT/Zulu time, need to advance a day forward first | ||
daysToAdd = 1; | ||
} | ||
|
||
entryDate.setDate(entryDate.getDate() + daysToAdd); | ||
entryDate.setHours(0 - offsetHours); | ||
entryDate.setMinutes(0 - offsetMinutes); | ||
entryDate.setSeconds(0); | ||
entryDate.setMilliseconds(0); | ||
|
||
await dm.db!.knex!('AccountingLedgerEntry') | ||
.where({ name: entry['name'] }) | ||
.update({ date: entryDate.toISOString() }); | ||
}); | ||
}); | ||
} | ||
|
||
export default { execute, beforeMigrate: true }; | ||
/* eslint-enable */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters