mirror of
https://github.com/frappe/books.git
synced 2024-12-22 02:49:03 +00:00
bumped version number and fixed patch
This commit is contained in:
parent
d4b6c0d4f6
commit
556d91dc6c
@ -37,7 +37,7 @@ export default [
|
||||
},
|
||||
{
|
||||
name: 'fixLedgerDateTime',
|
||||
version: '0.21.1',
|
||||
version: '0.21.2',
|
||||
patch: fixLedgerDateTime,
|
||||
},
|
||||
] as Patch[];
|
||||
|
@ -2,30 +2,36 @@ import { DatabaseManager } from '../../database/manager';
|
||||
|
||||
/* eslint-disable */
|
||||
async function execute(dm: DatabaseManager) {
|
||||
|
||||
const sourceTables = [
|
||||
"PurchaseInvoice",
|
||||
"SalesInvoice",
|
||||
"JournalEntry",
|
||||
"Payment",
|
||||
"StockMovement",
|
||||
"StockTransfer"
|
||||
];
|
||||
|
||||
await dm.db!.knex!('AccountingLedgerEntry')
|
||||
.select('name', 'date')
|
||||
.then((trx: Array<{name: string; date: Date;}> ) => {
|
||||
.select('name', 'date', 'referenceName')
|
||||
.then((trx: Array<{name: string; date: Date; referenceName: string;}> ) => {
|
||||
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() });
|
||||
sourceTables.forEach(async table => {
|
||||
await dm.db!.knex!
|
||||
.select('name','date')
|
||||
.from(table)
|
||||
.where({ name: entry['referenceName'] })
|
||||
.then(async (resp: Array<{name: string; date: Date;}>) => {
|
||||
if (resp.length !== 0) {
|
||||
|
||||
const dateTimeValue = new Date(resp[0]['date']);
|
||||
await dm.db!.knex!('AccountingLedgerEntry')
|
||||
.where({ name: entry['name'] })
|
||||
.update({ date: dateTimeValue.toISOString() });
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frappe-books",
|
||||
"version": "0.21.1",
|
||||
"version": "0.21.2",
|
||||
"description": "Simple book-keeping app for everyone",
|
||||
"author": {
|
||||
"name": "Frappe Technologies Pvt. Ltd.",
|
||||
|
Loading…
Reference in New Issue
Block a user