corporation transactions + cleanup

This commit is contained in:
Sirttas
2026-06-06 23:44:09 +02:00
parent cd1965acc4
commit 7e0ea10d68
6 changed files with 150 additions and 153 deletions
+75 -50
View File
@@ -309,9 +309,7 @@ paths:
schema:
type: array
items:
oneOf:
- $ref: "#/components/schemas/CombinedLedgerResponse"
- $ref: "#/components/schemas/MainLedgerResponse"
$ref: "#/components/schemas/LedgerResponse"
/ledgers/{ledgerId}:
get:
tags:
@@ -332,9 +330,7 @@ paths:
content:
'*/*':
schema:
oneOf:
- $ref: "#/components/schemas/CombinedLedgerResponse"
- $ref: "#/components/schemas/MainLedgerResponse"
$ref: "#/components/schemas/LedgerResponse"
"400":
description: The ledger cannot be exposed (system ledger)
"404":
@@ -419,27 +415,57 @@ paths:
$ref: "#/components/schemas/AcquisitionResponse"
components:
schemas:
RuleClauseResponse:
type: object
properties:
rate:
type: string
enum:
- NONE
- VALUE
- JITA_BUY
- JITA_SELL
- EVE_ESTIMATE
fromLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
toLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
IskRuleClauseResponse:
allOf:
- $ref: "#/components/schemas/RuleClauseResponse"
- type: object
properties:
fromLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
toLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
required:
- fromLedgerRef
- toLedgerRef
ItemExchangeRuleClauseResponse:
allOf:
- $ref: "#/components/schemas/RuleClauseResponse"
- type: object
properties:
rate:
type: string
enum:
- NONE
- VALUE
- JITA_BUY
- JITA_SELL
- EVE_ESTIMATE
fromLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
toLedgerRef:
type: string
pattern: "[a-z]+(-[a-z]+)*"
required:
- fromLedgerRef
- rate
- toLedgerRef
RuleClauseResponse:
discriminator:
propertyName: type
mapping:
ISK: "#/components/schemas/IskRuleClauseResponse"
ITEM_EXCHANGE: "#/components/schemas/ItemExchangeRuleClauseResponse"
oneOf:
- $ref: "#/components/schemas/IskRuleClauseResponse"
- $ref: "#/components/schemas/ItemExchangeRuleClauseResponse"
properties:
type:
type: string
required:
- type
RuleResponse:
type: object
properties:
@@ -454,6 +480,8 @@ components:
properties:
name:
type: string
usedForAcquisitions:
type: boolean
ledgerRefs:
type: array
items:
@@ -467,6 +495,7 @@ components:
- ledgerRefs
- name
- rules
- usedForAcquisitions
RuleBookResponse:
type: object
properties:
@@ -475,6 +504,8 @@ components:
format: uuid
name:
type: string
usedForAcquisitions:
type: boolean
ledgerRefs:
type: array
items:
@@ -489,6 +520,7 @@ components:
- name
- ruleBookId
- rules
- usedForAcquisitions
UpdateMainLedgerRequest:
type: object
properties:
@@ -508,10 +540,6 @@ components:
type: string
balance:
type: number
type:
type: string
enum:
- MAIN
required:
- balance
- ledgerId
@@ -546,10 +574,6 @@ components:
items:
type: string
format: uuid
type:
type: string
enum:
- COMBINED
required:
- balance
- ledgerId
@@ -592,6 +616,8 @@ components:
properties:
name:
type: string
usedForAcquisitions:
type: boolean
ledgerRefs:
type: array
items:
@@ -605,6 +631,7 @@ components:
- ledgerRefs
- name
- rules
- usedForAcquisitions
CreateMainLedgerRequest:
type: object
properties:
@@ -626,15 +653,19 @@ components:
- memberLedgerIds
- name
LedgerResponse:
type: object
discriminator:
propertyName: type
mapping:
MAIN: "#/components/schemas/MainLedgerResponse"
COMBINED: "#/components/schemas/CombinedLedgerResponse"
oneOf:
- $ref: "#/components/schemas/MainLedgerResponse"
- $ref: "#/components/schemas/CombinedLedgerResponse"
properties:
type:
type: string
enum:
- MAIN
- COMBINED
required:
- type
IskTransferResponse:
allOf:
- $ref: "#/components/schemas/TransferResponse"
@@ -648,10 +679,6 @@ components:
format: uuid
amount:
type: number
type:
type: string
enum:
- ISK
required:
- amount
- fromLedgerId
@@ -673,10 +700,6 @@ components:
quantity:
type: integer
format: int64
type:
type: string
enum:
- ITEM
required:
- fromLedgerId
- marketTypeId
@@ -699,9 +722,7 @@ components:
transfers:
type: array
items:
oneOf:
- $ref: "#/components/schemas/IskTransferResponse"
- $ref: "#/components/schemas/ItemTransferResponse"
$ref: "#/components/schemas/TransferResponse"
required:
- characterId
- datetime
@@ -709,15 +730,19 @@ components:
- transactionId
- transfers
TransferResponse:
type: object
discriminator:
propertyName: type
mapping:
ISK: "#/components/schemas/IskTransferResponse"
ITEM: "#/components/schemas/ItemTransferResponse"
oneOf:
- $ref: "#/components/schemas/IskTransferResponse"
- $ref: "#/components/schemas/ItemTransferResponse"
properties:
type:
type: string
enum:
- ISK
- ITEM
required:
- type
BalanceResponse:
type: object
properties:
+46 -86
View File
@@ -59,15 +59,7 @@ export interface CombinedLedgerResponse extends LedgerResponse {
'name': string;
'balance': number;
'memberLedgerIds': Array<string>;
'type'?: CombinedLedgerResponseTypeEnum;
}
export const CombinedLedgerResponseTypeEnum = {
Combined: 'COMBINED',
} as const;
export type CombinedLedgerResponseTypeEnum = typeof CombinedLedgerResponseTypeEnum[keyof typeof CombinedLedgerResponseTypeEnum];
export interface CreateCombinedLedgerRequest {
'name': string;
'memberLedgerIds': Array<string>;
@@ -77,82 +69,32 @@ export interface CreateMainLedgerRequest {
}
export interface CreateRuleBookRequest {
'name': string;
'usedForAcquisitions': boolean;
'ledgerRefs': Array<string>;
'rules': { [key: string]: RuleResponse; };
}
/**
* @type FindAllLedgers200ResponseInner
*/
export type FindAllLedgers200ResponseInner = CombinedLedgerResponse | MainLedgerResponse;
export interface IskRuleClauseResponse extends RuleClauseResponse {
'fromLedgerRef': string;
'toLedgerRef': string;
}
export interface IskTransferResponse extends TransferResponse {
'fromLedgerId': string;
'toLedgerId': string;
'amount': number;
'type'?: IskTransferResponseTypeEnum;
}
export const IskTransferResponseTypeEnum = {
Isk: 'ISK',
} as const;
export type IskTransferResponseTypeEnum = typeof IskTransferResponseTypeEnum[keyof typeof IskTransferResponseTypeEnum];
export interface ItemBalanceResponse {
'typeId': number;
'quantity': number;
}
export interface ItemTransferResponse extends TransferResponse {
'fromLedgerId': string;
'toLedgerId': string;
'marketTypeId': number;
'quantity': number;
'type'?: ItemTransferResponseTypeEnum;
}
export const ItemTransferResponseTypeEnum = {
Item: 'ITEM',
} as const;
export type ItemTransferResponseTypeEnum = typeof ItemTransferResponseTypeEnum[keyof typeof ItemTransferResponseTypeEnum];
export interface LedgerResponse {
'type'?: LedgerResponseTypeEnum;
}
export const LedgerResponseTypeEnum = {
Main: 'MAIN',
Combined: 'COMBINED',
} as const;
export type LedgerResponseTypeEnum = typeof LedgerResponseTypeEnum[keyof typeof LedgerResponseTypeEnum];
export interface MainLedgerResponse extends LedgerResponse {
'ledgerId': string;
'name': string;
'balance': number;
'type'?: MainLedgerResponseTypeEnum;
}
export const MainLedgerResponseTypeEnum = {
Main: 'MAIN',
} as const;
export type MainLedgerResponseTypeEnum = typeof MainLedgerResponseTypeEnum[keyof typeof MainLedgerResponseTypeEnum];
export interface RuleBookResponse {
'ruleBookId': string;
'name': string;
'ledgerRefs': Array<string>;
'rules': { [key: string]: RuleResponse; };
}
export interface RuleClauseResponse {
'rate': RuleClauseResponseRateEnum;
export interface ItemExchangeRuleClauseResponse extends RuleClauseResponse {
'rate': ItemExchangeRuleClauseResponseRateEnum;
'fromLedgerRef': string;
'toLedgerRef': string;
}
export const RuleClauseResponseRateEnum = {
export const ItemExchangeRuleClauseResponseRateEnum = {
None: 'NONE',
Value: 'VALUE',
JitaBuy: 'JITA_BUY',
@@ -160,7 +102,35 @@ export const RuleClauseResponseRateEnum = {
EveEstimate: 'EVE_ESTIMATE',
} as const;
export type RuleClauseResponseRateEnum = typeof RuleClauseResponseRateEnum[keyof typeof RuleClauseResponseRateEnum];
export type ItemExchangeRuleClauseResponseRateEnum = typeof ItemExchangeRuleClauseResponseRateEnum[keyof typeof ItemExchangeRuleClauseResponseRateEnum];
export interface ItemTransferResponse extends TransferResponse {
'fromLedgerId': string;
'toLedgerId': string;
'marketTypeId': number;
'quantity': number;
}
/**
* @type LedgerResponse
*/
export type LedgerResponse = { type: 'COMBINED' } & CombinedLedgerResponse | { type: 'MAIN' } & MainLedgerResponse;
export interface MainLedgerResponse extends LedgerResponse {
'ledgerId': string;
'name': string;
'balance': number;
}
export interface RuleBookResponse {
'ruleBookId': string;
'name': string;
'usedForAcquisitions': boolean;
'ledgerRefs': Array<string>;
'rules': { [key: string]: RuleResponse; };
}
/**
* @type RuleClauseResponse
*/
export type RuleClauseResponse = { type: 'ISK' } & IskRuleClauseResponse | { type: 'ITEM_EXCHANGE' } & ItemExchangeRuleClauseResponse;
export interface RuleResponse {
'clauses': Array<RuleClauseResponse>;
@@ -174,23 +144,12 @@ export interface TransactionResponse {
'characterId': number;
'datetime': string;
'description': string;
'transfers': Array<TransactionResponseTransfersInner>;
'transfers': Array<TransferResponse>;
}
/**
* @type TransactionResponseTransfersInner
* @type TransferResponse
*/
export type TransactionResponseTransfersInner = IskTransferResponse | ItemTransferResponse;
export interface TransferResponse {
'type'?: TransferResponseTypeEnum;
}
export const TransferResponseTypeEnum = {
Isk: 'ISK',
Item: 'ITEM',
} as const;
export type TransferResponseTypeEnum = typeof TransferResponseTypeEnum[keyof typeof TransferResponseTypeEnum];
export type TransferResponse = { type: 'ISK' } & IskTransferResponse | { type: 'ITEM' } & ItemTransferResponse;
export interface UpdateCombinedLedgerRequest {
'name': string;
@@ -201,6 +160,7 @@ export interface UpdateMainLedgerRequest {
}
export interface UpdateRuleBookRequest {
'name': string;
'usedForAcquisitions': boolean;
'ledgerRefs': Array<string>;
'rules': { [key: string]: RuleResponse; };
}
@@ -1022,7 +982,7 @@ export const LedgerApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async findAllLedgers(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<FindAllLedgers200ResponseInner>>> {
async findAllLedgers(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<LedgerResponse>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findAllLedgers(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.findAllLedgers']?.[localVarOperationServerIndex]?.url;
@@ -1048,7 +1008,7 @@ export const LedgerApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FindAllLedgers200ResponseInner>> {
async findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<LedgerResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.findLedgerById(ledgerId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['LedgerApi.findLedgerById']?.[localVarOperationServerIndex]?.url;
@@ -1117,7 +1077,7 @@ export const LedgerApiFactory = function (configuration?: Configuration, basePat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findAllLedgers(options?: RawAxiosRequestConfig): AxiosPromise<Array<FindAllLedgers200ResponseInner>> {
findAllLedgers(options?: RawAxiosRequestConfig): AxiosPromise<Array<LedgerResponse>> {
return localVarFp.findAllLedgers(options).then((request) => request(axios, basePath));
},
/**
@@ -1137,7 +1097,7 @@ export const LedgerApiFactory = function (configuration?: Configuration, basePat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise<FindAllLedgers200ResponseInner> {
findLedgerById(ledgerId: string, options?: RawAxiosRequestConfig): AxiosPromise<LedgerResponse> {
return localVarFp.findLedgerById(ledgerId, options).then((request) => request(axios, basePath));
},
/**
+1 -1
View File
@@ -94,7 +94,7 @@ watch(useRoute(), async route => {
<template #button>
<span>{{ activityType.name }}</span>
</template>
<RuleInput :ledgerRefs="ledgerRefs" v-model="rules[activityType.key]" />
<RuleInput :ledgerRefs="ledgerRefs" :activityType="activityType.key" v-model="rules[activityType.key]" />
</Dropdown>
</div>
+13 -6
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {RuleClauseResponse} from "@/generated/mammon";
import {ItemExchangeRuleClauseResponse, ItemExchangeRuleClauseResponseRateEnum, RuleClauseResponse} from "@/generated/mammon";
import {computed, watch} from "vue";
import {systemLedgerRef} from "@/ledger";
import {ratesTypes} from "@/rules/rules.ts";
@@ -8,16 +8,21 @@ import LedgerRefSelect from "./LedgerRefSelect.vue";
interface Props {
ledgerRefs: string[];
hasRate: boolean;
}
const props = defineProps<Props>()
const rule = defineModel<RuleClauseResponse>({ default: {
rate: ratesTypes.None,
type: 'ITEM_EXCHANGE',
rate: ItemExchangeRuleClauseResponseRateEnum.None,
fromLedgerRef: systemLedgerRef,
toLedgerRef: systemLedgerRef,
}});
// Only item-exchange clauses carry a rate; narrow for the rate <select>.
const itemRule = computed(() => rule.value as ItemExchangeRuleClauseResponse)
const ledgerRefsWithSystem = computed<string[]>(() => [systemLedgerRef, ...props.ledgerRefs])
watch(ledgerRefsWithSystem, (newVal, oldVal) => {
@@ -39,8 +44,10 @@ watch(ledgerRefsWithSystem, (newVal, oldVal) => {
<LedgerRefSelect class="me-2 grow" v-model="rule.fromLedgerRef" :ledger-refs="ledgerRefsWithSystem"/>
To:
<LedgerRefSelect class="me-2 grow" v-model="rule.toLedgerRef" :ledger-refs="ledgerRefsWithSystem"/>
At:
<select class="me-2 grow" v-model="rule.rate">
<option v-for="rateType in ratesTypes" :key="rateType.key" :value="rateType.key">{{ rateType.name }}</option>
</select>
<template v-if="hasRate">
At:
<select class="me-2 grow" v-model="itemRule.rate">
<option v-for="rateType in ratesTypes" :key="rateType.key" :value="rateType.key">{{ rateType.name }}</option>
</select>
</template>
</template>
+10 -7
View File
@@ -1,18 +1,22 @@
<script setup lang="ts">
import {RuleClauseResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
import {ItemExchangeRuleClauseResponseRateEnum, RuleClauseResponse, RuleResponse} from "@/generated/mammon";
import RuleClauseInput from "@/rules/RuleClauseInput.vue";
import {computed, useTemplateRef} from "vue";
import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
import {useSortable} from "@vueuse/integrations/useSortable";
import {systemLedgerRef} from "@/ledger";
import {ActivityType, activityTypeHasRate} from "@/rules/rules.ts";
interface Props {
ledgerRefs: string[];
activityType: ActivityType;
}
const props = defineProps<Props>()
const hasRate = computed<boolean>(() => activityTypeHasRate(props.activityType));
const rule = defineModel<RuleResponse>({default: {clauses:[]}});
const clauses = computed<RuleClauseResponse[]>({
get: () => rule.value && rule.value.clauses ? rule.value.clauses : [],
@@ -20,11 +24,10 @@ const clauses = computed<RuleClauseResponse[]>({
})
const addClause = () => {
clauses.value = [...clauses.value, {
rate: RuleClauseResponseRateEnum.None,
fromLedgerRef: systemLedgerRef,
toLedgerRef: systemLedgerRef
}]
const clause: RuleClauseResponse = hasRate.value
? {type: 'ITEM_EXCHANGE', rate: ItemExchangeRuleClauseResponseRateEnum.None, fromLedgerRef: systemLedgerRef, toLedgerRef: systemLedgerRef}
: {type: 'ISK', fromLedgerRef: systemLedgerRef, toLedgerRef: systemLedgerRef};
clauses.value = [...clauses.value, clause]
}
const setClause = (index: number, clause?: RuleClauseResponse) => {
@@ -49,7 +52,7 @@ useSortable(sortableContainer, clauses, { handle: '.sortable-handle'});
<span class="sortable-handle flex">
<Bars4Icon class="w-6"/>
</span>
<RuleClauseInput :ledgerRefs="ledgerRefs" :modelValue="clause" @update:modelValue="v => setClause(index, v)" />
<RuleClauseInput :ledgerRefs="ledgerRefs" :hasRate="hasRate" :modelValue="clause" @update:modelValue="v => setClause(index, v)" />
<button class="btn-icon" @click="removeClause(index)"><TrashIcon /></button>
</div>
</div>
+4 -2
View File
@@ -2,8 +2,8 @@ import {characterRuleBookApi, ruleBookApi} from "@/mammon";
import {
CharacterRuleBookResponse,
CreateRuleBookRequest,
ItemExchangeRuleClauseResponseRateEnum,
RuleBookResponse,
RuleClauseResponseRateEnum,
RuleResponse,
SetCharacterRuleBookRequest
} from "@/generated/mammon";
@@ -24,6 +24,8 @@ export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key
export type Rules = { [key: ActivityType]: RuleResponse; };
export type RuleBook = RuleBookResponse & { rules: Rules }
export const activityTypeHasRate = (key: ActivityType): boolean => key !== activityTypes.bountyEarned.key;
export const ratesTypes = {
None: {key: "NONE", name: "0 ISK"},
Value: {key: "VALUE", name: "Value"},
@@ -32,7 +34,7 @@ export const ratesTypes = {
EveEstimate: {key: "EVE_ESTIMATE", name: "Eve Estimate"},
} as const;
export type Rate = { key: RuleClauseResponseRateEnum, name: string }
export type Rate = { key: ItemExchangeRuleClauseResponseRateEnum, name: string }
export const useRuleBooksStore = defineStore('rule-books', () => {
const ruleBooks = ref<RuleBook[]>([]);