diff --git a/docs/mammon-api.yml b/docs/mammon-api.yml index 665e21a..1877bb8 100644 --- a/docs/mammon-api.yml +++ b/docs/mammon-api.yml @@ -960,7 +960,7 @@ paths: get: tags: - profit - summary: Get the daily profit series for a single ledger + summary: Get the daily profit series for a single or combined ledger operationId: profitPerDayInLedger parameters: - name: ledgerId @@ -972,8 +972,8 @@ paths: format: uuid responses: "200": - description: "Daily profit for the ledger, ascending by date, only for days\ - \ with ISK activity" + description: "Daily profit for the ledger, ascending by date. For a combined\ + \ ledger, per-date values are merged across its covered main ledgers." content: '*/*': schema: @@ -981,14 +981,15 @@ paths: items: $ref: "#/components/schemas/DailyProfitResponse" "400": - description: The ledger is the system ledger or a combined ledger + description: The ledger is the system ledger "404": description: No ledger with this id /ledgers/{ledgerId}/margin: get: tags: - profit - summary: Get the daily FIFO-realized margin series for a single ledger + summary: Get the daily FIFO-realized margin series for a single or combined + ledger operationId: marginPerDayInLedger parameters: - name: ledgerId @@ -1000,10 +1001,11 @@ paths: format: uuid responses: "200": - description: "Daily FIFO-realized margin for the ledger, ascending by date,\ - \ only for days with a consumption. iskIn is the sum of that day's profitable\ - \ consumptions, iskOut is the sum of that day's losing consumptions (as\ - \ a positive deficit); profit is iskIn minus iskOut." + description: "Daily FIFO-realized margin for the ledger, ascending by date.\ + \ iskIn is the sum of that day's profitable consumptions, iskOut is the\ + \ sum of that day's losing consumptions (as a positive deficit); profit\ + \ is iskIn minus iskOut. For a combined ledger, per-date values are merged\ + \ across its covered main ledgers." content: '*/*': schema: @@ -1011,7 +1013,7 @@ paths: items: $ref: "#/components/schemas/DailyProfitResponse" "400": - description: The ledger is the system ledger or a combined ledger + description: The ledger is the system ledger "404": description: No ledger with this id /ledgers/{ledgerId}/balance: @@ -1071,8 +1073,7 @@ paths: get: tags: - corporation - summary: "Resolve public information for several corporation ids at once, silently\ - \ omitting ids ESI cannot resolve" + summary: Resolve public information for several corporation ids at once operationId: findCorporations parameters: - name: ids @@ -1086,13 +1087,15 @@ paths: format: int64 responses: "200": - description: The corporations that resolved; unknown ids are omitted + description: The resolved corporations content: '*/*': schema: type: array items: $ref: "#/components/schemas/CorporationResponse" + "404": + description: Returned when no corporation exists for one of the given ids /corporations/{corporationId}: get: tags: @@ -1116,7 +1119,7 @@ paths: schema: $ref: "#/components/schemas/CorporationResponse" "404": - description: Returned when ESI has no corporation with the given id + description: Returned when no corporation exists with the given id /characters: get: tags: @@ -1149,17 +1152,27 @@ paths: get: tags: - acquisition - summary: "Find the caller's acquisitions, optionally filtered by ledger, market\ + summary: "Find the caller's acquisitions, optionally filtered by ledgers, market\ \ type and consumption state" operationId: findAllAcquisitions parameters: - name: ledgerId in: query - description: Only return acquisitions held in this ledger + description: "Only return acquisitions held in this ledger (deprecated, use\ + \ ledgerIds)" required: false schema: type: string format: uuid + - name: ledgerIds + in: query + description: Only return acquisitions held in these ledgers + required: false + schema: + type: array + items: + type: string + format: uuid - name: marketTypeId in: query description: Only return acquisitions of this market type diff --git a/src/generated/mammon/api.ts b/src/generated/mammon/api.ts index cc7fbab..cb7d86d 100644 --- a/src/generated/mammon/api.ts +++ b/src/generated/mammon/api.ts @@ -936,14 +936,15 @@ export const AcquisitionApiAxiosParamCreator = function (configuration?: Configu return { /** * - * @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state - * @param {string} [ledgerId] Only return acquisitions held in this ledger + * @summary Find the caller\'s acquisitions, optionally filtered by ledgers, market type and consumption state + * @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds) + * @param {Array} [ledgerIds] Only return acquisitions held in these ledgers * @param {number} [marketTypeId] Only return acquisitions of this market type * @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock) * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findAllAcquisitions: async (ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options: RawAxiosRequestConfig = {}): Promise => { + findAllAcquisitions: async (ledgerId?: string, ledgerIds?: Array, marketTypeId?: number, includeConsumed?: boolean, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/acquisitions`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); @@ -960,6 +961,10 @@ export const AcquisitionApiAxiosParamCreator = function (configuration?: Configu localVarQueryParameter['ledgerId'] = ledgerId; } + if (ledgerIds) { + localVarQueryParameter['ledgerIds'] = ledgerIds; + } + if (marketTypeId !== undefined) { localVarQueryParameter['marketTypeId'] = marketTypeId; } @@ -990,15 +995,16 @@ export const AcquisitionApiFp = function(configuration?: Configuration) { return { /** * - * @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state - * @param {string} [ledgerId] Only return acquisitions held in this ledger + * @summary Find the caller\'s acquisitions, optionally filtered by ledgers, market type and consumption state + * @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds) + * @param {Array} [ledgerIds] Only return acquisitions held in these ledgers * @param {number} [marketTypeId] Only return acquisitions of this market type * @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock) * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options); + async findAllAcquisitions(ledgerId?: string, ledgerIds?: Array, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findAllAcquisitions(ledgerId, ledgerIds, marketTypeId, includeConsumed, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap['AcquisitionApi.findAllAcquisitions']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); @@ -1014,15 +1020,16 @@ export const AcquisitionApiFactory = function (configuration?: Configuration, ba return { /** * - * @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state - * @param {string} [ledgerId] Only return acquisitions held in this ledger + * @summary Find the caller\'s acquisitions, optionally filtered by ledgers, market type and consumption state + * @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds) + * @param {Array} [ledgerIds] Only return acquisitions held in these ledgers * @param {number} [marketTypeId] Only return acquisitions of this market type * @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock) * @param {*} [options] Override http request option. * @throws {RequiredError} */ - findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): AxiosPromise> { - return localVarFp.findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options).then((request) => request(axios, basePath)); + findAllAcquisitions(ledgerId?: string, ledgerIds?: Array, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.findAllAcquisitions(ledgerId, ledgerIds, marketTypeId, includeConsumed, options).then((request) => request(axios, basePath)); }, }; }; @@ -1033,15 +1040,16 @@ export const AcquisitionApiFactory = function (configuration?: Configuration, ba export class AcquisitionApi extends BaseAPI { /** * - * @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state - * @param {string} [ledgerId] Only return acquisitions held in this ledger + * @summary Find the caller\'s acquisitions, optionally filtered by ledgers, market type and consumption state + * @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds) + * @param {Array} [ledgerIds] Only return acquisitions held in these ledgers * @param {number} [marketTypeId] Only return acquisitions of this market type * @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock) * @param {*} [options] Override http request option. * @throws {RequiredError} */ - public findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig) { - return AcquisitionApiFp(this.configuration).findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options).then((request) => request(this.axios, this.basePath)); + public findAllAcquisitions(ledgerId?: string, ledgerIds?: Array, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig) { + return AcquisitionApiFp(this.configuration).findAllAcquisitions(ledgerId, ledgerIds, marketTypeId, includeConsumed, options).then((request) => request(this.axios, this.basePath)); } } @@ -1856,7 +1864,7 @@ export const CorporationApiAxiosParamCreator = function (configuration?: Configu }, /** * - * @summary Resolve public information for several corporation ids at once, silently omitting ids ESI cannot resolve + * @summary Resolve public information for several corporation ids at once * @param {Array} ids Corporation ids to resolve, e.g. ids=98000001,98000002 * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -1915,7 +1923,7 @@ export const CorporationApiFp = function(configuration?: Configuration) { }, /** * - * @summary Resolve public information for several corporation ids at once, silently omitting ids ESI cannot resolve + * @summary Resolve public information for several corporation ids at once * @param {Array} ids Corporation ids to resolve, e.g. ids=98000001,98000002 * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -1947,7 +1955,7 @@ export const CorporationApiFactory = function (configuration?: Configuration, ba }, /** * - * @summary Resolve public information for several corporation ids at once, silently omitting ids ESI cannot resolve + * @summary Resolve public information for several corporation ids at once * @param {Array} ids Corporation ids to resolve, e.g. ids=98000001,98000002 * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -1975,7 +1983,7 @@ export class CorporationApi extends BaseAPI { /** * - * @summary Resolve public information for several corporation ids at once, silently omitting ids ESI cannot resolve + * @summary Resolve public information for several corporation ids at once * @param {Array} ids Corporation ids to resolve, e.g. ids=98000001,98000002 * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3728,7 +3736,7 @@ export const ProfitApiAxiosParamCreator = function (configuration?: Configuratio return { /** * - * @summary Get the daily FIFO-realized margin series for a single ledger + * @summary Get the daily FIFO-realized margin series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3762,7 +3770,7 @@ export const ProfitApiAxiosParamCreator = function (configuration?: Configuratio }, /** * - * @summary Get the daily profit series for a single ledger + * @summary Get the daily profit series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3805,7 +3813,7 @@ export const ProfitApiFp = function(configuration?: Configuration) { return { /** * - * @summary Get the daily FIFO-realized margin series for a single ledger + * @summary Get the daily FIFO-realized margin series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3818,7 +3826,7 @@ export const ProfitApiFp = function(configuration?: Configuration) { }, /** * - * @summary Get the daily profit series for a single ledger + * @summary Get the daily profit series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3840,7 +3848,7 @@ export const ProfitApiFactory = function (configuration?: Configuration, basePat return { /** * - * @summary Get the daily FIFO-realized margin series for a single ledger + * @summary Get the daily FIFO-realized margin series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3850,7 +3858,7 @@ export const ProfitApiFactory = function (configuration?: Configuration, basePat }, /** * - * @summary Get the daily profit series for a single ledger + * @summary Get the daily profit series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3867,7 +3875,7 @@ export const ProfitApiFactory = function (configuration?: Configuration, basePat export class ProfitApi extends BaseAPI { /** * - * @summary Get the daily FIFO-realized margin series for a single ledger + * @summary Get the daily FIFO-realized margin series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -3878,7 +3886,7 @@ export class ProfitApi extends BaseAPI { /** * - * @summary Get the daily profit series for a single ledger + * @summary Get the daily profit series for a single or combined ledger * @param {string} ledgerId Id of the ledger * @param {*} [options] Override http request option. * @throws {RequiredError} diff --git a/src/ledger/statistics.spec.ts b/src/ledger/statistics.spec.ts index 09d39bf..1c85af4 100644 --- a/src/ledger/statistics.spec.ts +++ b/src/ledger/statistics.spec.ts @@ -1,38 +1,11 @@ import {describe, expect, test} from 'vitest'; -import {latestDailyBalanceValue, resolveStatisticsMode, StatisticsModes} from './statistics'; -import type {CombinedLedger, MainLedger} from './ledger'; -import {LedgerTypes} from './ledger'; +import {latestDailyBalanceValue} from './statistics'; import type {DailyBalanceResponse} from '@/generated/mammon'; -const mainLedger = {type: LedgerTypes.Main, ledgerId: 'main-1', name: 'Main', balance: 0} as MainLedger; -const combinedLedger = {type: LedgerTypes.Combined, ledgerId: 'combined-1', name: 'Combined', balance: 0} as unknown as CombinedLedger; - const balance = (date: string, averageValue: number): DailyBalanceResponse => ({ date, averageValue, highestValue: averageValue, lowestValue: averageValue, }); -describe('resolveStatisticsMode', () => { - test('keeps cash flow mode for a main ledger', () => { - expect(resolveStatisticsMode(mainLedger, StatisticsModes.CashFlow)).toBe(StatisticsModes.CashFlow); - }); - - test('keeps margin mode for a main ledger', () => { - expect(resolveStatisticsMode(mainLedger, StatisticsModes.Margin)).toBe(StatisticsModes.Margin); - }); - - test('keeps daily balance mode for a combined ledger', () => { - expect(resolveStatisticsMode(combinedLedger, StatisticsModes.DailyBalance)).toBe(StatisticsModes.DailyBalance); - }); - - test('falls back to daily balance when cash flow is selected for a combined ledger', () => { - expect(resolveStatisticsMode(combinedLedger, StatisticsModes.CashFlow)).toBe(StatisticsModes.DailyBalance); - }); - - test('falls back to daily balance when margin is selected for a combined ledger', () => { - expect(resolveStatisticsMode(combinedLedger, StatisticsModes.Margin)).toBe(StatisticsModes.DailyBalance); - }); -}); - describe('latestDailyBalanceValue', () => { test('returns the average value of the most recent day in range', () => { const result = latestDailyBalanceValue([balance('2026-08-01', 100), balance('2026-08-02', 150)]); diff --git a/src/ledger/statistics.ts b/src/ledger/statistics.ts index e0c0ea9..bbd1b29 100644 --- a/src/ledger/statistics.ts +++ b/src/ledger/statistics.ts @@ -1,5 +1,4 @@ import type {DailyBalanceResponse} from "@/generated/mammon"; -import {isMain, type Ledger} from "./ledger"; export const StatisticsModes = { CashFlow: 'CASH_FLOW', @@ -8,8 +7,5 @@ export const StatisticsModes = { } as const; export type StatisticsMode = typeof StatisticsModes[keyof typeof StatisticsModes]; -export const resolveStatisticsMode = (ledger: Ledger, mode: StatisticsMode): StatisticsMode => - !isMain(ledger) && mode !== StatisticsModes.DailyBalance ? StatisticsModes.DailyBalance : mode; - export const latestDailyBalanceValue = (range: DailyBalanceResponse[]): number => range.at(-1)?.averageValue ?? 0; diff --git a/src/pages/ledger/ViewLedgerStatistics.vue b/src/pages/ledger/ViewLedgerStatistics.vue index e1d1326..f9decaf 100644 --- a/src/pages/ledger/ViewLedgerStatistics.vue +++ b/src/pages/ledger/ViewLedgerStatistics.vue @@ -1,6 +1,6 @@