feat(#53): Show combined-ledger daily trade profit and margin
This commit is contained in:
1 parent
56f70eb599
commit
87d105b7b8
5 files changed
+68
-84
No files matched your search
+29
-16
@@ -960,7 +960,7 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- profit
|
- 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
|
operationId: profitPerDayInLedger
|
||||||
parameters:
|
parameters:
|
||||||
- name: ledgerId
|
- name: ledgerId
|
||||||
@@ -972,8 +972,8 @@ paths:
|
|||||||
format: uuid
|
format: uuid
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "Daily profit for the ledger, ascending by date, only for days\
|
description: "Daily profit for the ledger, ascending by date. For a combined\
|
||||||
\ with ISK activity"
|
\ ledger, per-date values are merged across its covered main ledgers."
|
||||||
content:
|
content:
|
||||||
'*/*':
|
'*/*':
|
||||||
schema:
|
schema:
|
||||||
@@ -981,14 +981,15 @@ paths:
|
|||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/DailyProfitResponse"
|
$ref: "#/components/schemas/DailyProfitResponse"
|
||||||
"400":
|
"400":
|
||||||
description: The ledger is the system ledger or a combined ledger
|
description: The ledger is the system ledger
|
||||||
"404":
|
"404":
|
||||||
description: No ledger with this id
|
description: No ledger with this id
|
||||||
/ledgers/{ledgerId}/margin:
|
/ledgers/{ledgerId}/margin:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- profit
|
- 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
|
operationId: marginPerDayInLedger
|
||||||
parameters:
|
parameters:
|
||||||
- name: ledgerId
|
- name: ledgerId
|
||||||
@@ -1000,10 +1001,11 @@ paths:
|
|||||||
format: uuid
|
format: uuid
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "Daily FIFO-realized margin for the ledger, ascending by date,\
|
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\
|
\ iskIn is the sum of that day's profitable consumptions, iskOut is the\
|
||||||
\ consumptions, iskOut is the sum of that day's losing consumptions (as\
|
\ sum of that day's losing consumptions (as a positive deficit); profit\
|
||||||
\ a positive deficit); profit is iskIn minus iskOut."
|
\ is iskIn minus iskOut. For a combined ledger, per-date values are merged\
|
||||||
|
\ across its covered main ledgers."
|
||||||
content:
|
content:
|
||||||
'*/*':
|
'*/*':
|
||||||
schema:
|
schema:
|
||||||
@@ -1011,7 +1013,7 @@ paths:
|
|||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/DailyProfitResponse"
|
$ref: "#/components/schemas/DailyProfitResponse"
|
||||||
"400":
|
"400":
|
||||||
description: The ledger is the system ledger or a combined ledger
|
description: The ledger is the system ledger
|
||||||
"404":
|
"404":
|
||||||
description: No ledger with this id
|
description: No ledger with this id
|
||||||
/ledgers/{ledgerId}/balance:
|
/ledgers/{ledgerId}/balance:
|
||||||
@@ -1071,8 +1073,7 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- corporation
|
- corporation
|
||||||
summary: "Resolve public information for several corporation ids at once, silently\
|
summary: Resolve public information for several corporation ids at once
|
||||||
\ omitting ids ESI cannot resolve"
|
|
||||||
operationId: findCorporations
|
operationId: findCorporations
|
||||||
parameters:
|
parameters:
|
||||||
- name: ids
|
- name: ids
|
||||||
@@ -1086,13 +1087,15 @@ paths:
|
|||||||
format: int64
|
format: int64
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: The corporations that resolved; unknown ids are omitted
|
description: The resolved corporations
|
||||||
content:
|
content:
|
||||||
'*/*':
|
'*/*':
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/CorporationResponse"
|
$ref: "#/components/schemas/CorporationResponse"
|
||||||
|
"404":
|
||||||
|
description: Returned when no corporation exists for one of the given ids
|
||||||
/corporations/{corporationId}:
|
/corporations/{corporationId}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -1116,7 +1119,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/CorporationResponse"
|
$ref: "#/components/schemas/CorporationResponse"
|
||||||
"404":
|
"404":
|
||||||
description: Returned when ESI has no corporation with the given id
|
description: Returned when no corporation exists with the given id
|
||||||
/characters:
|
/characters:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -1149,17 +1152,27 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- acquisition
|
- 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"
|
\ type and consumption state"
|
||||||
operationId: findAllAcquisitions
|
operationId: findAllAcquisitions
|
||||||
parameters:
|
parameters:
|
||||||
- name: ledgerId
|
- name: ledgerId
|
||||||
in: query
|
in: query
|
||||||
description: Only return acquisitions held in this ledger
|
description: "Only return acquisitions held in this ledger (deprecated, use\
|
||||||
|
\ ledgerIds)"
|
||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
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
|
- name: marketTypeId
|
||||||
in: query
|
in: query
|
||||||
description: Only return acquisitions of this market type
|
description: Only return acquisitions of this market type
|
||||||
|
|||||||
+35
-27
@@ -936,14 +936,15 @@ export const AcquisitionApiAxiosParamCreator = function (configuration?: Configu
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state
|
* @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
|
* @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds)
|
||||||
|
* @param {Array<string>} [ledgerIds] Only return acquisitions held in these ledgers
|
||||||
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
||||||
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
findAllAcquisitions: async (ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
findAllAcquisitions: async (ledgerId?: string, ledgerIds?: Array<string>, marketTypeId?: number, includeConsumed?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
const localVarPath = `/acquisitions`;
|
const localVarPath = `/acquisitions`;
|
||||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
@@ -960,6 +961,10 @@ export const AcquisitionApiAxiosParamCreator = function (configuration?: Configu
|
|||||||
localVarQueryParameter['ledgerId'] = ledgerId;
|
localVarQueryParameter['ledgerId'] = ledgerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ledgerIds) {
|
||||||
|
localVarQueryParameter['ledgerIds'] = ledgerIds;
|
||||||
|
}
|
||||||
|
|
||||||
if (marketTypeId !== undefined) {
|
if (marketTypeId !== undefined) {
|
||||||
localVarQueryParameter['marketTypeId'] = marketTypeId;
|
localVarQueryParameter['marketTypeId'] = marketTypeId;
|
||||||
}
|
}
|
||||||
@@ -990,15 +995,16 @@ export const AcquisitionApiFp = function(configuration?: Configuration) {
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state
|
* @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
|
* @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds)
|
||||||
|
* @param {Array<string>} [ledgerIds] Only return acquisitions held in these ledgers
|
||||||
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
||||||
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AcquisitionResponse>>> {
|
async findAllAcquisitions(ledgerId?: string, ledgerIds?: Array<string>, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AcquisitionResponse>>> {
|
||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllAcquisitions(ledgerId, ledgerIds, marketTypeId, includeConsumed, options);
|
||||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||||
const localVarOperationServerBasePath = operationServerMap['AcquisitionApi.findAllAcquisitions']?.[localVarOperationServerIndex]?.url;
|
const localVarOperationServerBasePath = operationServerMap['AcquisitionApi.findAllAcquisitions']?.[localVarOperationServerIndex]?.url;
|
||||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
@@ -1014,15 +1020,16 @@ export const AcquisitionApiFactory = function (configuration?: Configuration, ba
|
|||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state
|
* @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
|
* @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds)
|
||||||
|
* @param {Array<string>} [ledgerIds] Only return acquisitions held in these ledgers
|
||||||
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
||||||
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): AxiosPromise<Array<AcquisitionResponse>> {
|
findAllAcquisitions(ledgerId?: string, ledgerIds?: Array<string>, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig): AxiosPromise<Array<AcquisitionResponse>> {
|
||||||
return localVarFp.findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options).then((request) => request(axios, basePath));
|
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 {
|
export class AcquisitionApi extends BaseAPI {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary Find the caller\'s acquisitions, optionally filtered by ledger, market type and consumption state
|
* @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
|
* @param {string} [ledgerId] Only return acquisitions held in this ledger (deprecated, use ledgerIds)
|
||||||
|
* @param {Array<string>} [ledgerIds] Only return acquisitions held in these ledgers
|
||||||
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
* @param {number} [marketTypeId] Only return acquisitions of this market type
|
||||||
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
* @param {boolean} [includeConsumed] Include fully consumed acquisitions (no remaining stock)
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
public findAllAcquisitions(ledgerId?: string, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig) {
|
public findAllAcquisitions(ledgerId?: string, ledgerIds?: Array<string>, marketTypeId?: number, includeConsumed?: boolean, options?: RawAxiosRequestConfig) {
|
||||||
return AcquisitionApiFp(this.configuration).findAllAcquisitions(ledgerId, marketTypeId, includeConsumed, options).then((request) => request(this.axios, this.basePath));
|
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<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
* @param {Array<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
* @param {Array<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
* @param {Array<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
* @param {Array<number>} ids Corporation ids to resolve, e.g. ids=98000001,98000002
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
@@ -3728,7 +3736,7 @@ export const ProfitApiAxiosParamCreator = function (configuration?: Configuratio
|
|||||||
return {
|
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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
@@ -3805,7 +3813,7 @@ export const ProfitApiFp = function(configuration?: Configuration) {
|
|||||||
return {
|
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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
@@ -3840,7 +3848,7 @@ export const ProfitApiFactory = function (configuration?: Configuration, basePat
|
|||||||
return {
|
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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
@@ -3867,7 +3875,7 @@ export const ProfitApiFactory = function (configuration?: Configuration, basePat
|
|||||||
export class ProfitApi extends BaseAPI {
|
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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @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 {string} ledgerId Id of the ledger
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
|
|||||||
@@ -1,38 +1,11 @@
|
|||||||
import {describe, expect, test} from 'vitest';
|
import {describe, expect, test} from 'vitest';
|
||||||
import {latestDailyBalanceValue, resolveStatisticsMode, StatisticsModes} from './statistics';
|
import {latestDailyBalanceValue} from './statistics';
|
||||||
import type {CombinedLedger, MainLedger} from './ledger';
|
|
||||||
import {LedgerTypes} from './ledger';
|
|
||||||
import type {DailyBalanceResponse} from '@/generated/mammon';
|
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 => ({
|
const balance = (date: string, averageValue: number): DailyBalanceResponse => ({
|
||||||
date, averageValue, highestValue: averageValue, lowestValue: averageValue,
|
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', () => {
|
describe('latestDailyBalanceValue', () => {
|
||||||
test('returns the average value of the most recent day in range', () => {
|
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)]);
|
const result = latestDailyBalanceValue([balance('2026-08-01', 100), balance('2026-08-02', 150)]);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type {DailyBalanceResponse} from "@/generated/mammon";
|
import type {DailyBalanceResponse} from "@/generated/mammon";
|
||||||
import {isMain, type Ledger} from "./ledger";
|
|
||||||
|
|
||||||
export const StatisticsModes = {
|
export const StatisticsModes = {
|
||||||
CashFlow: 'CASH_FLOW',
|
CashFlow: 'CASH_FLOW',
|
||||||
@@ -8,8 +7,5 @@ export const StatisticsModes = {
|
|||||||
} as const;
|
} as const;
|
||||||
export type StatisticsMode = typeof StatisticsModes[keyof typeof StatisticsModes];
|
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 =>
|
export const latestDailyBalanceValue = (range: DailyBalanceResponse[]): number =>
|
||||||
range.at(-1)?.averageValue ?? 0;
|
range.at(-1)?.averageValue ?? 0;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watch} from "vue";
|
import {ref} from "vue";
|
||||||
import {isMain, resolveStatisticsMode, StatisticsModes, type StatisticsMode, useLedgerParam} from "@/ledger";
|
import {StatisticsModes, type StatisticsMode, useLedgerParam} from "@/ledger";
|
||||||
import DailyBalanceChart from "./DailyBalanceChart.vue";
|
import DailyBalanceChart from "./DailyBalanceChart.vue";
|
||||||
import ProfitChart from "./ProfitChart.vue";
|
import ProfitChart from "./ProfitChart.vue";
|
||||||
|
|
||||||
@@ -8,19 +8,13 @@ const {ledgerId, ledger} = useLedgerParam();
|
|||||||
|
|
||||||
const mode = ref<StatisticsMode>(StatisticsModes.DailyBalance);
|
const mode = ref<StatisticsMode>(StatisticsModes.DailyBalance);
|
||||||
|
|
||||||
watch(ledger, l => {
|
|
||||||
if (l) {
|
|
||||||
mode.value = resolveStatisticsMode(l, mode.value);
|
|
||||||
}
|
|
||||||
}, {immediate: true});
|
|
||||||
|
|
||||||
const isDailyBalance = (mode: StatisticsMode): mode is typeof StatisticsModes.DailyBalance =>
|
const isDailyBalance = (mode: StatisticsMode): mode is typeof StatisticsModes.DailyBalance =>
|
||||||
mode === StatisticsModes.DailyBalance;
|
mode === StatisticsModes.DailyBalance;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="ledger" class="mt-4">
|
<div v-if="ledger" class="mt-4">
|
||||||
<div v-if="isMain(ledger)" class="flex justify-center mb-4">
|
<div class="flex justify-center mb-4">
|
||||||
<div class="flex bg-slate-600 rounded-s-md p-1">
|
<div class="flex bg-slate-600 rounded-s-md p-1">
|
||||||
<button class="switch" :class="{active: mode === StatisticsModes.DailyBalance}" @click="mode = StatisticsModes.DailyBalance">Daily Balance</button>
|
<button class="switch" :class="{active: mode === StatisticsModes.DailyBalance}" @click="mode = StatisticsModes.DailyBalance">Daily Balance</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user