mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
fixing reports/ledger issues
This commit is contained in:
parent
8db453c2f0
commit
dd7cb43abc
@ -61,6 +61,21 @@ export class LedgerPosting {
|
||||
this._validateIsEqual();
|
||||
}
|
||||
|
||||
timezoneDateTimeAdjuster(setDate: string | Date) {
|
||||
const dateTimeValue = new Date(setDate);
|
||||
|
||||
const dtFixedValue = dateTimeValue;
|
||||
const dtMinutes = dtFixedValue.getTimezoneOffset() % 60;
|
||||
const dtHours = (dtFixedValue.getTimezoneOffset() - dtMinutes) / 60;
|
||||
// Forcing the time to always be set to 00:00.000 for locale time
|
||||
dtFixedValue.setHours(0 - dtHours);
|
||||
dtFixedValue.setMinutes(0 - dtMinutes);
|
||||
dtFixedValue.setSeconds(0);
|
||||
dtFixedValue.setMilliseconds(0);
|
||||
|
||||
return dtFixedValue;
|
||||
}
|
||||
|
||||
async makeRoundOffEntry() {
|
||||
const { debit, credit } = this._getTotalDebitAndCredit();
|
||||
const difference = debit.sub(credit);
|
||||
@ -90,23 +105,6 @@ export class LedgerPosting {
|
||||
return map[account];
|
||||
}
|
||||
|
||||
// Timezone inconsistency fix (very ugly code for now)
|
||||
const entryDateTime = this.refDoc.date as string | Date;
|
||||
let dateTimeValue: Date;
|
||||
if (typeof entryDateTime === 'string' || entryDateTime instanceof String) {
|
||||
dateTimeValue = new Date(entryDateTime);
|
||||
} else {
|
||||
dateTimeValue = entryDateTime;
|
||||
}
|
||||
const dtFixedValue = dateTimeValue;
|
||||
const dtMinutes = dtFixedValue.getTimezoneOffset() % 60;
|
||||
const dtHours = (dtFixedValue.getTimezoneOffset() - dtMinutes) / 60;
|
||||
// Forcing the time to always be set to 00:00.000 for locale time
|
||||
dtFixedValue.setHours(0 - dtHours);
|
||||
dtFixedValue.setMinutes(0 - dtMinutes);
|
||||
dtFixedValue.setSeconds(0);
|
||||
dtFixedValue.setMilliseconds(0);
|
||||
|
||||
// end ugly timezone fix code
|
||||
|
||||
const ledgerEntry = this.fyo.doc.getNewDoc(
|
||||
@ -114,7 +112,7 @@ export class LedgerPosting {
|
||||
{
|
||||
account: account,
|
||||
party: (this.refDoc.party as string) ?? '',
|
||||
date: dtFixedValue,
|
||||
date: this.timezoneDateTimeAdjuster(this.refDoc.date as string | Date),
|
||||
referenceType: this.refDoc.schemaName,
|
||||
referenceName: this.refDoc.name!,
|
||||
reverted: this.reverted,
|
||||
|
Loading…
Reference in New Issue
Block a user