mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +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',
|
name: 'fixLedgerDateTime',
|
||||||
version: '0.21.1',
|
version: '0.21.2',
|
||||||
patch: fixLedgerDateTime,
|
patch: fixLedgerDateTime,
|
||||||
},
|
},
|
||||||
] as Patch[];
|
] as Patch[];
|
||||||
|
@ -2,30 +2,36 @@ import { DatabaseManager } from '../../database/manager';
|
|||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
async function execute(dm: DatabaseManager) {
|
async function execute(dm: DatabaseManager) {
|
||||||
|
|
||||||
|
const sourceTables = [
|
||||||
|
"PurchaseInvoice",
|
||||||
|
"SalesInvoice",
|
||||||
|
"JournalEntry",
|
||||||
|
"Payment",
|
||||||
|
"StockMovement",
|
||||||
|
"StockTransfer"
|
||||||
|
];
|
||||||
|
|
||||||
await dm.db!.knex!('AccountingLedgerEntry')
|
await dm.db!.knex!('AccountingLedgerEntry')
|
||||||
.select('name', 'date')
|
.select('name', 'date', 'referenceName')
|
||||||
.then((trx: Array<{name: string; date: Date;}> ) => {
|
.then((trx: Array<{name: string; date: Date; referenceName: string;}> ) => {
|
||||||
trx.forEach(async entry => {
|
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
|
sourceTables.forEach(async table => {
|
||||||
if (timeZoneOffset < 0) {
|
await dm.db!.knex!
|
||||||
// If ahead of GMT/Zulu time, need to advance a day forward first
|
.select('name','date')
|
||||||
daysToAdd = 1;
|
.from(table)
|
||||||
}
|
.where({ name: entry['referenceName'] })
|
||||||
|
.then(async (resp: Array<{name: string; date: Date;}>) => {
|
||||||
entryDate.setDate(entryDate.getDate() + daysToAdd);
|
if (resp.length !== 0) {
|
||||||
entryDate.setHours(0 - offsetHours);
|
|
||||||
entryDate.setMinutes(0 - offsetMinutes);
|
|
||||||
entryDate.setSeconds(0);
|
|
||||||
entryDate.setMilliseconds(0);
|
|
||||||
|
|
||||||
|
const dateTimeValue = new Date(resp[0]['date']);
|
||||||
await dm.db!.knex!('AccountingLedgerEntry')
|
await dm.db!.knex!('AccountingLedgerEntry')
|
||||||
.where({ name: entry['name'] })
|
.where({ name: entry['name'] })
|
||||||
.update({ date: entryDate.toISOString() });
|
.update({ date: dateTimeValue.toISOString() });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frappe-books",
|
"name": "frappe-books",
|
||||||
"version": "0.21.1",
|
"version": "0.21.2",
|
||||||
"description": "Simple book-keeping app for everyone",
|
"description": "Simple book-keeping app for everyone",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Frappe Technologies Pvt. Ltd.",
|
"name": "Frappe Technologies Pvt. Ltd.",
|
||||||
|
Loading…
Reference in New Issue
Block a user