mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
fix: setupwizard datetime issue
This commit is contained in:
parent
ff8b5431f5
commit
9804486562
@ -14,7 +14,7 @@ import {
|
|||||||
flow,
|
flow,
|
||||||
getFlowConstant,
|
getFlowConstant,
|
||||||
getRandomDates,
|
getRandomDates,
|
||||||
purchaseItemPartyMap
|
purchaseItemPartyMap,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
import items from './items.json';
|
import items from './items.json';
|
||||||
import logo from './logo';
|
import logo from './logo';
|
||||||
@ -39,8 +39,8 @@ export async function setupDummyInstance(
|
|||||||
email: 'lin@flosclothes.com',
|
email: 'lin@flosclothes.com',
|
||||||
bankName: 'Supreme Bank',
|
bankName: 'Supreme Bank',
|
||||||
currency: 'INR',
|
currency: 'INR',
|
||||||
fiscalYearStart: getFiscalYear('04-01', true),
|
fiscalYearStart: getFiscalYear('04-01', true)!.toISOString(),
|
||||||
fiscalYearEnd: getFiscalYear('04-01', false),
|
fiscalYearEnd: getFiscalYear('04-01', false)!.toISOString(),
|
||||||
chartOfAccounts: 'India - Chart of Accounts',
|
chartOfAccounts: 'India - Chart of Accounts',
|
||||||
};
|
};
|
||||||
await setupInstance(dbPath, options, fyo);
|
await setupInstance(dbPath, options, fyo);
|
||||||
|
@ -283,14 +283,12 @@ function toDocAttachment(value: RawValue, field: Field): null | Attachment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value !== 'string') {
|
if (typeof value !== 'string') {
|
||||||
console.log('being thrown doc1', typeof value, value);
|
|
||||||
throwError(value, field, 'doc');
|
throwError(value, field, 'doc');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.parse(value) || null;
|
return JSON.parse(value) || null;
|
||||||
} catch {
|
} catch {
|
||||||
console.log('being thrown doc2', typeof value, value);
|
|
||||||
throwError(value, field, 'doc');
|
throwError(value, field, 'doc');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,7 +427,6 @@ function toRawAttachment(value: DocValue, field: Field): null | string {
|
|||||||
return JSON.stringify(value);
|
return JSON.stringify(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('being thrown raw', typeof value, value);
|
|
||||||
throwError(value, field, 'raw');
|
throwError(value, field, 'raw');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,17 +42,21 @@ export function getCOAList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class SetupWizard extends Doc {
|
export class SetupWizard extends Doc {
|
||||||
fiscalYearEnd?: string;
|
fiscalYearEnd?: Date;
|
||||||
fiscalYearStart?: string;
|
fiscalYearStart?: Date;
|
||||||
|
|
||||||
formulas: FormulaMap = {
|
formulas: FormulaMap = {
|
||||||
fiscalYearStart: {
|
fiscalYearStart: {
|
||||||
formula: async (fieldname?: string) => {
|
formula: async (fieldname?: string) => {
|
||||||
if (fieldname === 'fiscalYearEnd' && this.fiscalYearEnd) {
|
if (
|
||||||
return DateTime.fromISO(this.fiscalYearEnd)
|
fieldname === 'fiscalYearEnd' &&
|
||||||
|
this.fiscalYearEnd &&
|
||||||
|
!this.fiscalYearStart
|
||||||
|
) {
|
||||||
|
return DateTime.fromJSDate(this.fiscalYearEnd)
|
||||||
.minus({ years: 1 })
|
.minus({ years: 1 })
|
||||||
.plus({ days: 1 })
|
.plus({ days: 1 })
|
||||||
.toISODate();
|
.toJSDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.country) {
|
if (!this.country) {
|
||||||
@ -68,11 +72,15 @@ export class SetupWizard extends Doc {
|
|||||||
},
|
},
|
||||||
fiscalYearEnd: {
|
fiscalYearEnd: {
|
||||||
formula: async (fieldname?: string) => {
|
formula: async (fieldname?: string) => {
|
||||||
if (fieldname === 'fiscalYearStart' && this.fiscalYearStart) {
|
if (
|
||||||
return DateTime.fromISO(this.fiscalYearStart)
|
fieldname === 'fiscalYearStart' &&
|
||||||
|
this.fiscalYearStart &&
|
||||||
|
!this.fiscalYearEnd
|
||||||
|
) {
|
||||||
|
return DateTime.fromJSDate(this.fiscalYearStart)
|
||||||
.plus({ years: 1 })
|
.plus({ years: 1 })
|
||||||
.minus({ days: 1 })
|
.minus({ days: 1 })
|
||||||
.toISODate();
|
.toJSDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.country) {
|
if (!this.country) {
|
||||||
|
@ -80,7 +80,6 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
getStatus,
|
getStatus,
|
||||||
async openEntry(name: string) {
|
async openEntry(name: string) {
|
||||||
console.log('op', name);
|
|
||||||
const route = getEntryRoute(this.linked.schemaName, name);
|
const route = getEntryRoute(this.linked.schemaName, name);
|
||||||
await routeTo(route);
|
await routeTo(route);
|
||||||
},
|
},
|
||||||
|
@ -109,6 +109,10 @@ export default {
|
|||||||
this.doc.on('change', () => {
|
this.doc.on('change', () => {
|
||||||
this.valuesFilled = this.allValuesFilled();
|
this.valuesFilled = this.allValuesFilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.fyo.store.isDevelopment) {
|
||||||
|
window.sw = this;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fill() {
|
async fill() {
|
||||||
|
@ -17,8 +17,8 @@ export function getTestSetupWizardOptions(): SetupWizardOptions {
|
|||||||
email: 'test@testmyfantasy.com',
|
email: 'test@testmyfantasy.com',
|
||||||
bankName: 'Test Bank of Scriptia',
|
bankName: 'Test Bank of Scriptia',
|
||||||
currency: 'INR',
|
currency: 'INR',
|
||||||
fiscalYearStart: getFiscalYear('04-01', true),
|
fiscalYearStart: getFiscalYear('04-01', true)!.toISOString(),
|
||||||
fiscalYearEnd: getFiscalYear('04-01', false),
|
fiscalYearEnd: getFiscalYear('04-01', false)!.toISOString(),
|
||||||
chartOfAccounts: 'India - Chart of Accounts',
|
chartOfAccounts: 'India - Chart of Accounts',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,12 @@ export function getCountryCodeFromCountry(countryName: string): string {
|
|||||||
return countryInfo.code;
|
return countryInfo.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFiscalYear(date: string, isStart: boolean) {
|
export function getFiscalYear(
|
||||||
|
date: string,
|
||||||
|
isStart: boolean
|
||||||
|
): undefined | Date {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return '';
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const today = DateTime.local();
|
const today = DateTime.local();
|
||||||
@ -28,12 +31,12 @@ export function getFiscalYear(date: string, isStart: boolean) {
|
|||||||
if (isStart) {
|
if (isStart) {
|
||||||
return dateTime
|
return dateTime
|
||||||
.plus({ year: [1, 2, 3].includes(today.month) ? -1 : 0 })
|
.plus({ year: [1, 2, 3].includes(today.month) ? -1 : 0 })
|
||||||
.toISODate();
|
.toJSDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dateTime
|
return dateTime
|
||||||
.plus({ year: [1, 2, 3].includes(today.month) ? 0 : 1 })
|
.plus({ year: [1, 2, 3].includes(today.month) ? 0 : 1 })
|
||||||
.toISODate();
|
.toJSDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logUnexpected(detail: Partial<UnexpectedLogObject>) {
|
export function logUnexpected(detail: Partial<UnexpectedLogObject>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user