edit ledger

This commit is contained in:
Sirttas
2026-05-18 21:19:01 +02:00
parent 02466eea14
commit 3ca0cf23f1
5 changed files with 402 additions and 75 deletions
+274 -35
View File
@@ -23,29 +23,60 @@ import type { RequestArgs } from './base';
// @ts-ignore // @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
export interface CombiningLedgerDto extends LedgerDto { export interface CombiningLedgerResponse extends LedgerResponse {
'ledgerId': number; 'ledgerId': number;
'name': string; 'name': string;
'memberLedgerIds': Array<number>; 'memberLedgerIds': Array<number>;
'type'?: CombiningLedgerResponseTypeEnum;
} }
export interface CreateCombiningLedgerCommand {
export const CombiningLedgerResponseTypeEnum = {
Combining: 'COMBINING',
} as const;
export type CombiningLedgerResponseTypeEnum = typeof CombiningLedgerResponseTypeEnum[keyof typeof CombiningLedgerResponseTypeEnum];
export interface CreateCombiningLedgerRequest {
'name': string; 'name': string;
'memberLedgerIds': Array<number>; 'memberLedgerIds': Array<number>;
} }
export interface CreateMainLedgerCommand { export interface CreateMainLedgerRequest {
'name': string; 'name': string;
} }
/** /**
* @type FindAll200ResponseInner * @type FindAll200ResponseInner
*/ */
export type FindAll200ResponseInner = CombiningLedgerDto | MainLedgerDto; export type FindAll200ResponseInner = CombiningLedgerResponse | MainLedgerResponse;
export interface LedgerDto { export interface LedgerResponse {
'type': string; 'type'?: LedgerResponseTypeEnum;
} }
export interface MainLedgerDto extends LedgerDto {
export const LedgerResponseTypeEnum = {
Main: 'MAIN',
Combining: 'COMBINING',
} as const;
export type LedgerResponseTypeEnum = typeof LedgerResponseTypeEnum[keyof typeof LedgerResponseTypeEnum];
export interface MainLedgerResponse extends LedgerResponse {
'ledgerId': number; 'ledgerId': number;
'name': string; 'name': string;
'type'?: MainLedgerResponseTypeEnum;
}
export const MainLedgerResponseTypeEnum = {
Main: 'MAIN',
} as const;
export type MainLedgerResponseTypeEnum = typeof MainLedgerResponseTypeEnum[keyof typeof MainLedgerResponseTypeEnum];
export interface UpdateCombiningLedgerRequest {
'name': string;
'memberLedgerIds': Array<number>;
}
export interface UpdateMainLedgerRequest {
'name': string;
} }
/** /**
@@ -55,13 +86,13 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
return { return {
/** /**
* *
* @param {CreateCombiningLedgerCommand} createCombiningLedgerCommand * @param {CreateCombiningLedgerRequest} createCombiningLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createCombiningLedger: async (createCombiningLedgerCommand: CreateCombiningLedgerCommand, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { createCombiningLedger: async (createCombiningLedgerRequest: CreateCombiningLedgerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'createCombiningLedgerCommand' is not null or undefined // verify required parameter 'createCombiningLedgerRequest' is not null or undefined
assertParamExists('createCombiningLedger', 'createCombiningLedgerCommand', createCombiningLedgerCommand) assertParamExists('createCombiningLedger', 'createCombiningLedgerRequest', createCombiningLedgerRequest)
const localVarPath = `/ledgers/combining`; const localVarPath = `/ledgers/combining`;
// 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);
@@ -80,7 +111,7 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
setSearchParams(localVarUrlObj, localVarQueryParameter); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(createCombiningLedgerCommand, localVarRequestOptions, configuration) localVarRequestOptions.data = serializeDataIfNeeded(createCombiningLedgerRequest, localVarRequestOptions, configuration)
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@@ -89,13 +120,13 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
}, },
/** /**
* *
* @param {CreateMainLedgerCommand} createMainLedgerCommand * @param {CreateMainLedgerRequest} createMainLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createMainLedger: async (createMainLedgerCommand: CreateMainLedgerCommand, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { createMainLedger: async (createMainLedgerRequest: CreateMainLedgerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'createMainLedgerCommand' is not null or undefined // verify required parameter 'createMainLedgerRequest' is not null or undefined
assertParamExists('createMainLedger', 'createMainLedgerCommand', createMainLedgerCommand) assertParamExists('createMainLedger', 'createMainLedgerRequest', createMainLedgerRequest)
const localVarPath = `/ledgers/main`; const localVarPath = `/ledgers/main`;
// 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);
@@ -114,7 +145,7 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
setSearchParams(localVarUrlObj, localVarQueryParameter); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(createMainLedgerCommand, localVarRequestOptions, configuration) localVarRequestOptions.data = serializeDataIfNeeded(createMainLedgerRequest, localVarRequestOptions, configuration)
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@@ -145,6 +176,115 @@ export const LedgerControllerApiAxiosParamCreator = function (configuration?: Co
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {number} ledgerId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findById: async (ledgerId: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ledgerId' is not null or undefined
assertParamExists('findById', 'ledgerId', ledgerId)
const localVarPath = `/ledgers/{ledgerId}`
.replace('{ledgerId}', encodeURIComponent(String(ledgerId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Accept'] = '*/*';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {number} ledgerId
* @param {UpdateCombiningLedgerRequest} updateCombiningLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateCombiningLedger: async (ledgerId: number, updateCombiningLedgerRequest: UpdateCombiningLedgerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ledgerId' is not null or undefined
assertParamExists('updateCombiningLedger', 'ledgerId', ledgerId)
// verify required parameter 'updateCombiningLedgerRequest' is not null or undefined
assertParamExists('updateCombiningLedger', 'updateCombiningLedgerRequest', updateCombiningLedgerRequest)
const localVarPath = `/ledgers/combining/{ledgerId}`
.replace('{ledgerId}', encodeURIComponent(String(ledgerId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Content-Type'] = 'application/json';
localVarHeaderParameter['Accept'] = '*/*';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(updateCombiningLedgerRequest, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {number} ledgerId
* @param {UpdateMainLedgerRequest} updateMainLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateMainLedger: async (ledgerId: number, updateMainLedgerRequest: UpdateMainLedgerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ledgerId' is not null or undefined
assertParamExists('updateMainLedger', 'ledgerId', ledgerId)
// verify required parameter 'updateMainLedgerRequest' is not null or undefined
assertParamExists('updateMainLedger', 'updateMainLedgerRequest', updateMainLedgerRequest)
const localVarPath = `/ledgers/main/{ledgerId}`
.replace('{ledgerId}', encodeURIComponent(String(ledgerId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Content-Type'] = 'application/json';
localVarHeaderParameter['Accept'] = '*/*';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(updateMainLedgerRequest, localVarRequestOptions, configuration)
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
options: localVarRequestOptions, options: localVarRequestOptions,
@@ -161,24 +301,24 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
return { return {
/** /**
* *
* @param {CreateCombiningLedgerCommand} createCombiningLedgerCommand * @param {CreateCombiningLedgerRequest} createCombiningLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async createCombiningLedger(createCombiningLedgerCommand: CreateCombiningLedgerCommand, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CombiningLedgerDto>> { async createCombiningLedger(createCombiningLedgerRequest: CreateCombiningLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CombiningLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createCombiningLedger(createCombiningLedgerCommand, options); const localVarAxiosArgs = await localVarAxiosParamCreator.createCombiningLedger(createCombiningLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createCombiningLedger']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createCombiningLedger']?.[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);
}, },
/** /**
* *
* @param {CreateMainLedgerCommand} createMainLedgerCommand * @param {CreateMainLedgerRequest} createMainLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async createMainLedger(createMainLedgerCommand: CreateMainLedgerCommand, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<MainLedgerDto>> { async createMainLedger(createMainLedgerRequest: CreateMainLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<MainLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createMainLedger(createMainLedgerCommand, options); const localVarAxiosArgs = await localVarAxiosParamCreator.createMainLedger(createMainLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createMainLedger']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.createMainLedger']?.[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);
@@ -194,6 +334,44 @@ export const LedgerControllerApiFp = function(configuration?: Configuration) {
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAll']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findAll']?.[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);
}, },
/**
*
* @param {number} ledgerId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async findById(ledgerId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FindAll200ResponseInner>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findById(ledgerId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.findById']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {number} ledgerId
* @param {UpdateCombiningLedgerRequest} updateCombiningLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateCombiningLedger(ledgerId: number, updateCombiningLedgerRequest: UpdateCombiningLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CombiningLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateCombiningLedger(ledgerId, updateCombiningLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.updateCombiningLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {number} ledgerId
* @param {UpdateMainLedgerRequest} updateMainLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateMainLedger(ledgerId: number, updateMainLedgerRequest: UpdateMainLedgerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<MainLedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateMainLedger(ledgerId, updateMainLedgerRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerControllerApi.updateMainLedger']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
} }
}; };
@@ -205,21 +383,21 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
return { return {
/** /**
* *
* @param {CreateCombiningLedgerCommand} createCombiningLedgerCommand * @param {CreateCombiningLedgerRequest} createCombiningLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createCombiningLedger(createCombiningLedgerCommand: CreateCombiningLedgerCommand, options?: RawAxiosRequestConfig): AxiosPromise<CombiningLedgerDto> { createCombiningLedger(createCombiningLedgerRequest: CreateCombiningLedgerRequest, options?: RawAxiosRequestConfig): AxiosPromise<CombiningLedgerResponse> {
return localVarFp.createCombiningLedger(createCombiningLedgerCommand, options).then((request) => request(axios, basePath)); return localVarFp.createCombiningLedger(createCombiningLedgerRequest, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
* @param {CreateMainLedgerCommand} createMainLedgerCommand * @param {CreateMainLedgerRequest} createMainLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createMainLedger(createMainLedgerCommand: CreateMainLedgerCommand, options?: RawAxiosRequestConfig): AxiosPromise<MainLedgerDto> { createMainLedger(createMainLedgerRequest: CreateMainLedgerRequest, options?: RawAxiosRequestConfig): AxiosPromise<MainLedgerResponse> {
return localVarFp.createMainLedger(createMainLedgerCommand, options).then((request) => request(axios, basePath)); return localVarFp.createMainLedger(createMainLedgerRequest, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@@ -229,6 +407,35 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
findAll(options?: RawAxiosRequestConfig): AxiosPromise<Array<FindAll200ResponseInner>> { findAll(options?: RawAxiosRequestConfig): AxiosPromise<Array<FindAll200ResponseInner>> {
return localVarFp.findAll(options).then((request) => request(axios, basePath)); return localVarFp.findAll(options).then((request) => request(axios, basePath));
}, },
/**
*
* @param {number} ledgerId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findById(ledgerId: number, options?: RawAxiosRequestConfig): AxiosPromise<FindAll200ResponseInner> {
return localVarFp.findById(ledgerId, options).then((request) => request(axios, basePath));
},
/**
*
* @param {number} ledgerId
* @param {UpdateCombiningLedgerRequest} updateCombiningLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateCombiningLedger(ledgerId: number, updateCombiningLedgerRequest: UpdateCombiningLedgerRequest, options?: RawAxiosRequestConfig): AxiosPromise<CombiningLedgerResponse> {
return localVarFp.updateCombiningLedger(ledgerId, updateCombiningLedgerRequest, options).then((request) => request(axios, basePath));
},
/**
*
* @param {number} ledgerId
* @param {UpdateMainLedgerRequest} updateMainLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateMainLedger(ledgerId: number, updateMainLedgerRequest: UpdateMainLedgerRequest, options?: RawAxiosRequestConfig): AxiosPromise<MainLedgerResponse> {
return localVarFp.updateMainLedger(ledgerId, updateMainLedgerRequest, options).then((request) => request(axios, basePath));
},
}; };
}; };
@@ -238,22 +445,22 @@ export const LedgerControllerApiFactory = function (configuration?: Configuratio
export class LedgerControllerApi extends BaseAPI { export class LedgerControllerApi extends BaseAPI {
/** /**
* *
* @param {CreateCombiningLedgerCommand} createCombiningLedgerCommand * @param {CreateCombiningLedgerRequest} createCombiningLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
public createCombiningLedger(createCombiningLedgerCommand: CreateCombiningLedgerCommand, options?: RawAxiosRequestConfig) { public createCombiningLedger(createCombiningLedgerRequest: CreateCombiningLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).createCombiningLedger(createCombiningLedgerCommand, options).then((request) => request(this.axios, this.basePath)); return LedgerControllerApiFp(this.configuration).createCombiningLedger(createCombiningLedgerRequest, options).then((request) => request(this.axios, this.basePath));
} }
/** /**
* *
* @param {CreateMainLedgerCommand} createMainLedgerCommand * @param {CreateMainLedgerRequest} createMainLedgerRequest
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
public createMainLedger(createMainLedgerCommand: CreateMainLedgerCommand, options?: RawAxiosRequestConfig) { public createMainLedger(createMainLedgerRequest: CreateMainLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).createMainLedger(createMainLedgerCommand, options).then((request) => request(this.axios, this.basePath)); return LedgerControllerApiFp(this.configuration).createMainLedger(createMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
} }
/** /**
@@ -264,6 +471,38 @@ export class LedgerControllerApi extends BaseAPI {
public findAll(options?: RawAxiosRequestConfig) { public findAll(options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath)); return LedgerControllerApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
} }
/**
*
* @param {number} ledgerId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public findById(ledgerId: number, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).findById(ledgerId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {number} ledgerId
* @param {UpdateCombiningLedgerRequest} updateCombiningLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public updateCombiningLedger(ledgerId: number, updateCombiningLedgerRequest: UpdateCombiningLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).updateCombiningLedger(ledgerId, updateCombiningLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {number} ledgerId
* @param {UpdateMainLedgerRequest} updateMainLedgerRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public updateMainLedger(ledgerId: number, updateMainLedgerRequest: UpdateMainLedgerRequest, options?: RawAxiosRequestConfig) {
return LedgerControllerApiFp(this.configuration).updateMainLedger(ledgerId, updateMainLedgerRequest, options).then((request) => request(this.axios, this.basePath));
}
} }
+63 -19
View File
@@ -2,23 +2,32 @@
import {computed, ref} from "vue"; import {computed, ref} from "vue";
import {storeToRefs} from "pinia"; import {storeToRefs} from "pinia";
import {COMBINING_LEDGER, Ledger, LedgerType, MAIN_LEDGER, useLedgersStore} from "./ledger"; import {isCombining, Ledger, LedgerType, LedgerTypes, useLedgersStore} from "./ledger";
import {Modal} from "@/components"; import {Modal} from "@/components";
import LedgerLabel from "./LedgerLabel.vue"; import LedgerLabel from "./LedgerLabel.vue";
import {PlusIcon, TrashIcon} from '@heroicons/vue/24/outline'; import {PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
interface Props {
ledgerId?: number;
}
const props = withDefaults(defineProps<Props>(), {
ledgerId: 0
});
const ledgersStore = useLedgersStore(); const ledgersStore = useLedgersStore();
const {ledgers} = storeToRefs(ledgersStore); const {ledgers} = storeToRefs(ledgersStore);
const {createMain, createCombining} = ledgersStore; const {findById, findAllById, createMain, createCombining, updateMain, updateCombining} = ledgersStore;
const modalOpen = ref<boolean>(false); const modalOpen = ref<boolean>(false);
const type = ref<LedgerType>(MAIN_LEDGER); const type = ref<LedgerType>(LedgerTypes.Main);
const name = ref(""); const name = ref("");
const members = ref<Ledger[]>([]); const members = ref<Ledger[]>([]);
const selectedLedger = ref<Ledger>(); const selectedLedger = ref<Ledger>();
const availableLedgers = computed(() => ledgers.value.filter(l => !members.value.includes(l))); const availableLedgers = computed(() => ledgers.value.filter(l => !members.value.includes(l)));
const addMember = () => { const addMember = () => {
if (selectedLedger.value && !members.value.includes(selectedLedger.value)) { if (selectedLedger.value && !members.value.includes(selectedLedger.value)) {
members.value = [...members.value, selectedLedger.value]; members.value = [...members.value, selectedLedger.value];
@@ -27,21 +36,54 @@ const addMember = () => {
} }
const open = () => { const open = () => {
type.value = MAIN_LEDGER; const ledger = isCreating.value ? undefined : findById(props.ledgerId);
name.value = "";
members.value = []; if (ledger) {
type.value = ledger.type;
name.value = ledger.name;
members.value = isCombining(ledger) ? findAllById(ledger.memberLedgerIds) : [];
} else {
type.value = LedgerTypes.Main;
name.value = "";
members.value = [];
}
modalOpen.value = true; modalOpen.value = true;
} }
const canCreate = computed(() => name.value.trim().length > 0); const canSave = computed(() => name.value.trim().length > 0);
const isCreating = computed(() => props.ledgerId === 0)
const title = computed(() => {
if (isCreating.value) {
return `Creating ${type.value === LedgerTypes.Main ? 'Main' : 'Combining'} Ledger`
}
return `Updating ${name.value}`
})
const create = () => { const create = () => {
if (!canCreate.value) { if (type.value === LedgerTypes.Main) {
return; createMain({name: name.value})
} else if (type.value === MAIN_LEDGER) {
createMain({ name: name.value })
} else { } else {
createCombining({ name: name.value, memberLedgerIds: members.value.map(l => l.ledgerId) }) createCombining({name: name.value, memberLedgerIds: members.value.map(l => l.ledgerId)})
}
}
const update = () => {
if (type.value === LedgerTypes.Main) {
updateMain(props.ledgerId, {name: name.value})
} else {
updateCombining(props.ledgerId, {name: name.value, memberLedgerIds: members.value.map(l => l.ledgerId)})
}
}
const save = () => {
if (!canSave.value) {
return;
}
if (isCreating.value) {
create();
} else {
update();
} }
modalOpen.value = false; modalOpen.value = false;
} }
@@ -51,24 +93,26 @@ defineExpose({ open });
<template> <template>
<Modal v-model:open="modalOpen"> <Modal v-model:open="modalOpen">
<div class="bg-slate-800 rounded pb-4"> <div class="bg-slate-800 rounded pb-4 w-96">
<span class="m-2">Creating {{ type === MAIN_LEDGER ? 'Main' : 'Combining' }} Ledger</span> <span class="m-2">{{ title }}</span>
<hr /> <hr />
<div class="mt-4"> <div class="mt-4">
<div class="flex justify-center"> <div class="flex justify-center">
<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: type === MAIN_LEDGER}" @click="type = MAIN_LEDGER">Main</button> <button class="switch" :class="{active: type === LedgerTypes.Main}" @click="type = LedgerTypes.Main">Main</button>
</div> </div>
<div class="switch flex bg-slate-600 rounded-e-md p-1"> <div class="switch flex bg-slate-600 rounded-e-md p-1">
<button class="switch" :class="{active: type === COMBINING_LEDGER}" @click="type = COMBINING_LEDGER">Combining</button> <button class="switch" :class="{active: type === LedgerTypes.Combining}" @click="type = LedgerTypes.Combining">Combining</button>
</div> </div>
</div> </div>
<div class="m-4"> <div class="m-4">
Name: Name:
<input type="text" v-model="name" /> <div class="flex">
<input type="text" class="flex grow" v-model="name" />
</div>
</div> </div>
</div> </div>
<div v-if="type === COMBINING_LEDGER" class="ms-4 mb-4"> <div v-if="type === LedgerTypes.Combining" class="ms-4 mb-4">
Member Ledgers: Member Ledgers:
<div v-for="ledger in members" :key="ledger.ledgerId" class="flex"> <div v-for="ledger in members" :key="ledger.ledgerId" class="flex">
<LedgerLabel class="flex grow mb-2" :ledger="ledger" /> <LedgerLabel class="flex grow mb-2" :ledger="ledger" />
@@ -86,7 +130,7 @@ defineExpose({ open });
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<button class="me-4" @click="create" :disabled="!canCreate">Create</button> <button class="me-4" @click="save" :disabled="!canSave">Save</button>
</div> </div>
</div> </div>
</Modal> </Modal>
+2 -2
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import {COMBINING_LEDGER, Ledger} from "@/ledger/ledger.ts"; import {isCombining, Ledger} from "@/ledger/ledger.ts";
import {FolderOpenIcon} from '@heroicons/vue/24/outline'; import {FolderOpenIcon} from '@heroicons/vue/24/outline';
interface Props { interface Props {
@@ -12,7 +12,7 @@ const props = defineProps<Props>();
<template> <template>
<div class="flex"> <div class="flex">
<FolderOpenIcon v-if="ledger.type === COMBINING_LEDGER" class="w-4 me-1" /> <FolderOpenIcon v-if="isCombining(ledger)" class="w-4 me-1" />
<div v-else class="w-4 me-1"/> <div v-else class="w-4 me-1"/>
<span>{{ ledger.name }}</span> <span>{{ ledger.name }}</span>
</div> </div>
+46 -17
View File
@@ -1,34 +1,63 @@
import {CreateCombiningLedgerCommand, CreateMainLedgerCommand, FindAll200ResponseInner} from "@/generated/mammon"; import {
CombiningLedgerResponse,
CombiningLedgerResponseTypeEnum,
CreateCombiningLedgerRequest,
CreateMainLedgerRequest,
LedgerResponseTypeEnum,
MainLedgerResponse,
MainLedgerResponseTypeEnum,
UpdateCombiningLedgerRequest,
UpdateMainLedgerRequest
} from "@/generated/mammon";
import {defineStore} from "pinia"; import {defineStore} from "pinia";
import {ref} from "vue"; import {ref, triggerRef} from "vue";
import {ledgerControllerApi} from "@/mammon"; import {ledgerControllerApi} from "@/mammon";
export const MAIN_LEDGER = "MAIN"; export const LedgerTypes = LedgerResponseTypeEnum;
export const COMBINING_LEDGER = "COMBINING";
export type LedgerType = typeof MAIN_LEDGER | typeof COMBINING_LEDGER; export type LedgerType = LedgerResponseTypeEnum;
export type Ledger = FindAll200ResponseInner; export type MainLedger = MainLedgerResponse & {type: MainLedgerResponseTypeEnum}
export type CombiningLedger = CombiningLedgerResponse & {type: CombiningLedgerResponseTypeEnum}
export type Ledger = MainLedger | CombiningLedger;
export const isMain = (ledger: Ledger): ledger is MainLedger => {
return ledger.type === LedgerTypes.Main;
}
export const isCombining = (ledger: Ledger): ledger is CombiningLedger => {
return ledger.type === LedgerTypes.Combining;
}
export const useLedgersStore = defineStore('ledgers', () => { export const useLedgersStore = defineStore('ledgers', () => {
const ledgers = ref<Ledger[]>([]); const ledgers = ref<Ledger[]>([]);
const createMain = (ledger: CreateMainLedgerCommand) => ledgerControllerApi.createMainLedger(ledger).then(response => { const addLedger = (ledger: Ledger) => {
const ledger = response.data;
ledgers.value.push(ledger); ledgers.value.push(ledger);
triggerRef(ledgers);
return ledger; return ledger;
}); };
const createCombining = (ledger: CreateCombiningLedgerCommand) => ledgerControllerApi.createCombiningLedger(ledger).then(response => { const replaceLedger = (ledger: Ledger) => {
const ledger = response.data; const index = ledgers.value.findIndex(l => l.ledgerId === ledger.ledgerId);
ledgers.value.push(ledger); if (index !== -1) {
ledgers.value[index] = ledger;
}
triggerRef(ledgers);
return ledger; return ledger;
}); };
const refresh = () => ledgerControllerApi.findAll().then(response => ledgers.value = response.data); const findById = (ledgerId: number): Ledger | undefined => ledgers.value.find(l => l.ledgerId === ledgerId);
const findAllById = (ledgerIds: number[]): Ledger[] => ledgerIds.map(findById).filter((x): x is Ledger => x !== undefined)
const createMain = (ledger: CreateMainLedgerRequest) => ledgerControllerApi.createMainLedger(ledger).then(response => addLedger(response.data as Ledger));
const createCombining = (ledger: CreateCombiningLedgerRequest) => ledgerControllerApi.createCombiningLedger(ledger).then(response => addLedger(response.data as Ledger));
const updateMain = (ledgerId: number, ledger: UpdateMainLedgerRequest) => ledgerControllerApi.updateMainLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const updateCombining = (ledgerId: number, ledger: UpdateCombiningLedgerRequest) => ledgerControllerApi.updateCombiningLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const refresh = () => ledgerControllerApi.findAll().then(response => ledgers.value = response.data as Ledger[]);
refresh(); refresh();
return {ledgers, createMain, createCombining, refresh}; return {ledgers, findById, findAllById, createMain, createCombining, updateMain, updateCombining, refresh};
}) })
+17 -2
View File
@@ -1,14 +1,29 @@
<script setup lang="ts"> <script setup lang="ts">
import {LedgerLabel, useLedgersStore} from "@/ledger"; import {CreateLedgerModal, LedgerLabel, useLedgersStore} from "@/ledger";
import {storeToRefs} from "pinia"; import {storeToRefs} from "pinia";
import {nextTick, ref} from "vue";
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
const {ledgers} = storeToRefs(useLedgersStore()); const {ledgers} = storeToRefs(useLedgersStore());
const editModal = ref<typeof CreateLedgerModal>();
const editingLedgerId = ref(0);
const openEdit = async (ledgerId: number) => {
editingLedgerId.value = ledgerId;
await nextTick();
editModal.value?.open();
};
</script> </script>
<template> <template>
<div class="mt-4"> <div class="mt-4">
<LedgerLabel v-for="ledger in ledgers" :key="ledger.ledgerId" class="mb-2" :ledger="ledger"/> <div v-for="ledger in ledgers" :key="ledger.ledgerId" class="flex items-center mb-2">
<LedgerLabel class="grow" :ledger="ledger" />
<button class="btn-icon ms-2" @click="openEdit(ledger.ledgerId)"><PencilSquareIcon /></button>
</div>
</div> </div>
<CreateLedgerModal ref="editModal" :ledger-id="editingLedgerId" />
</template> </template>