diff --git a/src/custom-functions/bcode.test.ts b/src/custom-functions/bcode.test.ts index 219423c..ef0820c 100644 --- a/src/custom-functions/bcode.test.ts +++ b/src/custom-functions/bcode.test.ts @@ -29,4 +29,5 @@ test('isV3Call', () => { expect(isV3Call('2020Q1', 'net_sales')).toBeTruthy() expect(isV3Call('LYLQ', 'net_sales')).toBeTruthy() expect(isV3Call('2020-09-06', 'market_capital')).toBeTruthy() + expect(isV3Call('latest', 'market_capital')).toBeTruthy() }) diff --git a/src/fiscal-periods/period-parser.test.ts b/src/fiscal-periods/period-parser.test.ts index b784018..e79bf6c 100644 --- a/src/fiscal-periods/period-parser.test.ts +++ b/src/fiscal-periods/period-parser.test.ts @@ -13,12 +13,15 @@ test('parse', () => { expect(PeriodParser.parse('2020LQ')).toEqual(new YearQuarterParam(2020, LQ)) expect(PeriodParser.parse('LYQ3')).toEqual(new YearQuarterParam(LY, 3)) expect(PeriodParser.parse('LYLQ')).toEqual(new YearQuarterParam(LY, LQ)) + expect(PeriodParser.parse('lylq')).toEqual(new YearQuarterParam(LY, LQ)) expect(PeriodParser.parse('LY-1Q4')).toEqual(new YearQuarterParam(new LyWithOffset(-1), 4)) expect(PeriodParser.parse('2020LQ-1')).toEqual(new YearQuarterParam(2020, new LqWithOffset(-1))) expect(PeriodParser.parse('LY-1LQ-1')).toEqual(new YearQuarterParam(new LyWithOffset(-1), new LqWithOffset(-1))) + expect(PeriodParser.parse('ly-1lq-1')).toEqual(new YearQuarterParam(new LyWithOffset(-1), new LqWithOffset(-1))) expect(PeriodParser.parse('2020-09-06')).toEqual(new DateParam(new Date('2020-09-06'))) + expect(PeriodParser.parse('latest')).toEqual(new DateParam('latest')) + expect(PeriodParser.parse('Latest')).toEqual(new DateParam('latest')) expect(() => PeriodParser.parse('foo')).toThrow(ParseError) expect(() => PeriodParser.parse('2020/09/06')).toThrow(ParseError) - expect(() => PeriodParser.parse('latest')).toThrow(ParseError) expect(() => PeriodParser.parse('0Q1')).toThrow(ParseError) }) diff --git a/src/fiscal-periods/period-parser.ts b/src/fiscal-periods/period-parser.ts index b1a9e7f..6c2553d 100644 --- a/src/fiscal-periods/period-parser.ts +++ b/src/fiscal-periods/period-parser.ts @@ -8,8 +8,6 @@ export class PeriodParser { } static parse(str: string): DateParam | YearQuarterParam { - str = str.toUpperCase() - try { return YearQuarterParam.parse(str) } catch { @@ -17,10 +15,7 @@ export class PeriodParser { } try { - const date = DateParam.parse(str) - if (!date.isLatest()) { - return date - } + return DateParam.parse(str) } catch { // noop }