2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

UTC Datetime inconsistency for LedgerPostings/Reports

This commit is contained in:
Isaac GC 2024-01-30 21:12:33 -08:00
parent de2ae58b16
commit 9b2382a1a8

View File

@ -90,12 +90,28 @@ export class LedgerPosting {
return map[account]; return map[account];
} }
// Timezone inconsistency fix (very ugly code for now)
let entryDateTime = this.refDoc.date as string | Date;
let dateTimeValue: Date;
if (typeof entryDateTime === 'string' || entryDateTime instanceof String) {
dateTimeValue = new Date(entryDateTime);
} else {
dateTimeValue = entryDateTime;
}
let dtFixedValue = dateTimeValue;
let dtMinutes = dtFixedValue.getTimezoneOffset() % 60;
let dtHours = (dtFixedValue.getTimezoneOffset() - dtMinutes) / 60;
dtFixedValue.setHours(dtFixedValue.getHours() - dtHours);
dtFixedValue.setMinutes(dtFixedValue.getMinutes() - dtMinutes);
// end ugly timezone fix code
const ledgerEntry = this.fyo.doc.getNewDoc( const ledgerEntry = this.fyo.doc.getNewDoc(
ModelNameEnum.AccountingLedgerEntry, ModelNameEnum.AccountingLedgerEntry,
{ {
account: account, account: account,
party: (this.refDoc.party as string) ?? '', party: (this.refDoc.party as string) ?? '',
date: this.refDoc.date as string | Date, date: dtFixedValue,
referenceType: this.refDoc.schemaName, referenceType: this.refDoc.schemaName,
referenceName: this.refDoc.name!, referenceName: this.refDoc.name!,
reverted: this.reverted, reverted: this.reverted,