ledger balance

This commit is contained in:
Sirttas
2026-06-01 19:22:27 +02:00
parent 42c7e59d63
commit c23ec0cb53
26 changed files with 161 additions and 100 deletions
+5 -5
View File
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { computed } from 'vue';
import { RouterView, useRoute } from 'vue-router';
import { Sidebar } from './sidebar';
import { routeNames } from '@/routes';
import {computed} from 'vue';
import {RouterView, useRoute} from 'vue-router';
import {Sidebar} from './sidebar';
import {routeNames} from '@/routes';
const route = useRoute();
@@ -24,7 +24,7 @@ const hideSidebar = computed(() => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
div.main-container {
@apply px-4 sm:ml-64;
+1 -1
View File
@@ -61,7 +61,7 @@ useEventListener('keyup', e => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.chevron {
@apply w-4 h-4 me-1;
+4 -4
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { vOnClickOutside } from '@vueuse/components';
import { useEventListener } from '@vueuse/core';
import { watch } from 'vue';
import {vOnClickOutside} from '@vueuse/components';
import {useEventListener} from '@vueuse/core';
import {watch} from 'vue';
const open = defineModel('open', { default: false });
@@ -35,7 +35,7 @@ useEventListener('keyup', e => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.fade-enter-from, .fade-leave-to {
@apply opacity-0;
}
+1 -1
View File
@@ -64,7 +64,7 @@ const submit = () => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.fake-input {
@apply flex border bg-slate-500 rounded px-1 py-0.5;
}
+1 -1
View File
@@ -11,7 +11,7 @@ const modelValue = defineModel({ default: false });
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
input:checked ~ span:last-child {
--tw-translate-x: 1.25rem;
}
+2 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { HeaderComponent, SortDirection } from './sort';
import {HeaderComponent, SortDirection} from './sort';
interface Props {
currentSortKey: string | null;
@@ -33,7 +33,7 @@ const emit = defineEmits<Emit>();
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.sort-header {
@apply relative h-8 pe-3;
}
+11 -9
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useElementBounding, useVirtualList } from '@vueuse/core';
import { computed, ref } from 'vue';
import {useElementBounding, useVirtualList} from '@vueuse/core';
import {computed, ref} from 'vue';
interface Props {
list?: any[];
@@ -68,11 +68,18 @@ const itemHeightStyle = computed(() => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
div.table-container {
@apply bg-slate-600;
max-height: calc(100vh - v-bind(ypx));
:deep(>div) {
&::-webkit-scrollbar-track {
margin-top: v-bind(computedHeaderHeight);
margin-bottom: v-bind(computedFooterHeight);
}
}
div.table-container:deep(>div) {
@apply bg-slate-800;
>table {
>thead {
@@ -87,10 +94,5 @@ div.table-container {
height: v-bind(itemHeightStyle);
}
}
}
&::-webkit-scrollbar-track {
margin-top: v-bind(computedHeaderHeight);
margin-bottom: v-bind(computedFooterHeight);
}
}
</style>
+1 -1
View File
@@ -136,7 +136,7 @@ defineExpose({ open });
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
button.switch {
@apply flex items-center px-4 rounded-md bg-slate-600;
+1 -1
View File
@@ -26,7 +26,7 @@ const ledgerId = computed({
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.system-ledger {
@apply text-emerald-400;
+5 -1
View File
@@ -1,4 +1,5 @@
import {
BalanceResponse,
CombinedLedgerResponse,
CombinedLedgerResponseTypeEnum,
CreateCombinedLedgerRequest,
@@ -75,7 +76,10 @@ export const useLedgersStore = defineStore('ledgers', () => {
return {ledgers, findById, findAllById, createMain, createCombined, updateMain, updateCombined, refresh};
})
export const findAllTransactionInLeger = (ledger: Ledger | string): Promise<TransactionResponse[]> => transactionApi.finAllTransactionsInLedger(typeof ledger == 'string' ? ledger : ledger.ledgerId).then(response => response.data)
const getLedgerId = (ledger: Ledger | string): string => typeof ledger == 'string' ? ledger : ledger.ledgerId;
export const findAllTransactionInLeger = (ledger: Ledger | string): Promise<TransactionResponse[]> => transactionApi.finAllTransactionsInLedger(getLedgerId(ledger)).then(response => response.data)
export const getLedgerBalance = (ledger: Ledger | string): Promise<BalanceResponse> => ledgerApi.findBalanceByLedgerId(getLedgerId(ledger)).then(response => response.data)
export const useLedgerParam = () => {
const {findById} = useLedgersStore();
@@ -75,7 +75,7 @@ watchEffect(async () => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.tooltip {
@apply ms-auto;
@@ -1,11 +1,10 @@
<script setup lang="ts">
import { SortableHeader, useSort, VirtualScrollTable } from '@/components/table';
import { formatEveDate, formatIsk, percentFormater } from '@/formaters';
import { MarketType, MarketTypeLabel, TaxInput, useMarketTaxStore } from "@/market";
import { MinusIcon, PlusIcon } from '@heroicons/vue/24/outline';
import { useStorage } from '@vueuse/core';
import { computed, ref } from 'vue';
import { AcquiredType } from './AcquiredType';
import {SortableHeader, useSort, VirtualScrollTable} from '@/components/table';
import {MarketType, MarketTypeLabel, TaxInput, useMarketTaxStore} from "@/market";
import {MinusIcon, PlusIcon} from '@heroicons/vue/24/outline';
import {useStorage} from '@vueuse/core';
import {computed, ref} from 'vue';
import {AcquiredType} from './AcquiredType';
import AcquisitionQuantilsTooltip from './AcquisitionQuantilsTooltip.vue';
type Result = {
@@ -246,7 +245,7 @@ const total = computed(() => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
div.end {
@apply justify-self-end ms-2;
}
+3 -3
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { useMarketTaxStore } from "./tax";
import {storeToRefs} from "pinia";
import {useMarketTaxStore} from "./tax";
const { brokerFee, scc } = storeToRefs(useMarketTaxStore());
@@ -18,7 +18,7 @@ const { brokerFee, scc } = storeToRefs(useMarketTaxStore());
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
div.end {
@apply justify-self-end ms-2;
}
+9 -10
View File
@@ -1,13 +1,12 @@
<script setup lang="ts">
import { SliderCheckbox } from '@/components';
import { SortableHeader, useSort, VirtualScrollTable } from '@/components/table';
import { formatIsk, percentFormater } from '@/formaters';
import { getHistoryQuartils, MarketType, MarketTypeLabel, TaxInput, useMarketTaxStore } from "@/market";
import { BookmarkSlashIcon, ShoppingCartIcon } from '@heroicons/vue/24/outline';
import { useStorage } from '@vueuse/core';
import { computed, ref } from 'vue';
import { useAcquiredTypesStore } from '../acquisition';
import { TrackingResult } from './tracking';
import {SliderCheckbox} from '@/components';
import {SortableHeader, useSort, VirtualScrollTable} from '@/components/table';
import {getHistoryQuartils, MarketType, MarketTypeLabel, TaxInput, useMarketTaxStore} from "@/market";
import {BookmarkSlashIcon, ShoppingCartIcon} from '@heroicons/vue/24/outline';
import {useStorage} from '@vueuse/core';
import {computed, ref} from 'vue';
import {useAcquiredTypesStore} from '../acquisition';
import {TrackingResult} from './tracking';
type Result = {
type: MarketType;
@@ -168,7 +167,7 @@ const getLineColor = (result: Result) => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
div.end {
@apply justify-self-end ms-2;
}
+5 -5
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { vOnClickOutside } from '@vueuse/components';
import { useVirtualList } from '@vueuse/core';
import {vOnClickOutside} from '@vueuse/components';
import {useVirtualList} from '@vueuse/core';
import log from 'loglevel';
import { nextTick, ref, watch, watchEffect } from 'vue';
import { MarketType, searchMarketTypes } from './MarketType';
import {nextTick, ref, watch, watchEffect} from 'vue';
import {MarketType, searchMarketTypes} from './MarketType';
import MarketTypeLabel from "./MarketTypeLabel.vue";
interface Emits {
@@ -105,7 +105,7 @@ watchEffect(async () => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.fake-input {
@apply w-96 flex border bg-slate-500 rounded px-1 py-0.5;
+23 -11
View File
@@ -1,7 +1,9 @@
<script setup lang="ts">
import { ClipboardButton } from '@/components';
import { InformationCircleIcon } from '@heroicons/vue/24/outline';
import { routeNames } from '@/routes';
import {ClipboardButton} from '@/components';
import {InformationCircleIcon} from '@heroicons/vue/24/outline';
import {routeNames} from '@/routes';
import {computedAsync} from "@vueuse/core";
import {getMarketType} from "@/market";
interface Props {
@@ -10,29 +12,39 @@ interface Props {
hideCopy?: boolean;
}
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
name: "",
id: 0,
hideCopy: false
});
const computedName = computedAsync<string>(async () => {
if (props.name) {
return props.name;
} else if (props.id) {
return await getMarketType(props.id).then(marketType => marketType.name);
}
return "";
}, "");
</script>
<template>
<div v-if="id || name" class="flex flex-row">
<div v-if="id || computedName" class="flex flex-row">
<img v-if="id" :src="`https://images.evetech.net/types/${id}/icon?size=32`" class="inline-block w-5 h-5 me-1 mt-1" alt="" />
<template v-if="name">
{{ name }}
<RouterLink v-if="id" :to="{ name: routeNames.marketTypes, params: { type: id } }" class="button btn-icon ms-1 me-1 mt-1" title="Show item info">
<template v-if="computedName">
{{ computedName }}
<RouterLink v-if="id" :to="{ name: routeNames.marketTypes, params: { type: id } }" class="btn-icon ms-1 me-1 mt-1" title="Show item info">
<InformationCircleIcon />
</RouterLink>
<ClipboardButton v-if="!hideCopy" :value="name" />
<ClipboardButton v-if="!hideCopy" :value="computedName" />
</template>
</div>
</template>
<style scoped>
@reference "tailwindcss";
button:deep(>svg), .button:deep(>svg) {
@reference "@/style.css";
button:deep(>svg), .btn-icon:deep(>svg) {
@apply !w-4 !h-4;
}
</style>
+1 -1
View File
@@ -6,7 +6,7 @@ import {TransactionResponse} from "@/generated/mammon";
import {formatEveDate} from "@/formaters.ts";
import {IskLabel} from "@/market";
const {ledgerId, ledger} = useLedgerParam();
const {ledgerId} = useLedgerParam();
const transactions = computedAsync<TransactionResponse[]>(async () => {
if (ledgerId.value) {
+32 -7
View File
@@ -1,13 +1,16 @@
<script setup lang="ts">
import {EditLedgerModal, LedgerLabel, useLedgersStore} from "@/ledger";
import {EditLedgerModal, Ledger, LedgerLabel, useLedgersStore} from "@/ledger";
import {storeToRefs} from "pinia";
import {nextTick, ref} from "vue";
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
import {IskLabel} from "@/market";
import {SortableHeader, useSort, VirtualScrollTable} from "@/components/table";
const {ledgers} = storeToRefs(useLedgersStore());
const { sortedArray, headerProps } = useSort<Ledger>(ledgers)
const editModal = ref<typeof EditLedgerModal>();
const editingLedgerId = ref("");
@@ -21,13 +24,35 @@ const openEdit = async (ledgerId: string) => {
<template>
<div class="mt-4">
<div v-for="ledger in ledgers" :key="ledger.ledgerId" class="flex items-center mb-2">
<LedgerLabel :ledger="ledger" :link="true" />
<div class="flex grow">
<IskLabel class="ms-2" :amount="ledger.balance" />
</div>
<button class="btn-icon ms-2" @click="openEdit(ledger.ledgerId)"><PencilSquareIcon /></button>
<VirtualScrollTable :list="sortedArray" :itemHeight="33" bottom="1rem">
<template #default="{ list }">
<thead>
<tr>
<SortableHeader v-bind="headerProps" sortKey="name">Ledger</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="balance">Isk Balance</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="buttons" unsortable />
</tr>
</thead>
<tbody>
<tr v-for="l in list" :key="l.data.ledgerId">
<td>
<LedgerLabel :ledger="l.data" :link="true" />
</td>
<td class="text-right">
<IskLabel class="ms-2" :amount="l.data.balance" />
</td>
<td class="text-right">
<button class="btn-icon ms-2" @click="openEdit(l.data.ledgerId)"><PencilSquareIcon /></button>
</td>
</tr>
</tbody>
</template>
<template #empty>
<div class="text-center mt-4">
<span>No ledgers found</span>
</div>
</template>
</VirtualScrollTable>
</div>
<EditLedgerModal ref="editModal" :ledger-id="editingLedgerId" />
</template>
+20 -3
View File
@@ -1,11 +1,28 @@
<script setup lang="ts">
import {useLedgerParam} from "@/ledger";
import {getLedgerBalance, useLedgerParam} from "@/ledger";
import {computedAsync} from "@vueuse/core";
import {BalanceResponse} from "@/generated/mammon";
import {IskLabel, MarketTypeLabel} from "@/market";
const {ledgerId, ledger} = useLedgerParam();
const {ledgerId} = useLedgerParam();
const balance = computedAsync<BalanceResponse>(async () => {
if (ledgerId.value) {
return await getLedgerBalance(ledgerId.value);
}
return undefined;
});
</script>
<template>
<div class="mt-4">
<div v-if="balance" class="mt-4">
<div class="border-b-1">
<IskLabel class="mb-2" :amount="balance.iskBalance" />
</div>
<div v-for="item in balance.itemBalances" :key="item.typeId" class="mt-2 flex gap-2">
<MarketTypeLabel :id="item.typeId" />
<span>{{item.quantity}}</span>
</div>
</div>
</template>
+1 -1
View File
@@ -115,7 +115,7 @@ watch(useRoute(), async route => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
img.type-image {
width: 64px;
+1 -1
View File
@@ -108,7 +108,7 @@ watch(useRoute(), async route => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.rule-dropdown :deep(>button) {
@apply bg-slate-800 hover:bg-slate-800 border-none flex items-center w-full;
+1 -1
View File
@@ -13,7 +13,7 @@ const modelValue = defineModel({ default: false });
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
input:checked ~ span:last-child {
--tw-translate-x: 1.75rem;
}
+1 -1
View File
@@ -49,7 +49,7 @@ watch(ledgerRefsWithSystem, (newVal, oldVal) => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.system-ledger {
@apply text-emerald-400;
+1 -1
View File
@@ -60,7 +60,7 @@ useSortable(sortableContainer, clauses, { handle: '.sortable-handle'});
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.sortable-handle {
@apply cursor-grab;
+1 -1
View File
@@ -49,7 +49,7 @@ const logout = async () => {
</template>
<style scoped>
@reference "tailwindcss";
@reference "@/style.css";
.sidebar-button {
@apply flex items-center rounded-md hover:bg-slate-800 cursor-pointer;
+7 -4
View File
@@ -2,6 +2,12 @@
@custom-variant search-cancel (&::-webkit-search-cancel-button);
@utility btn-icon {
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent cursor-pointer;
> svg {
@apply w-6 h-6;
}
}
@layer base {
span, table, input, th, tr, td, button, a.button, div, hr {
@apply border-slate-600 text-slate-100 placeholder-slate-400;
@@ -72,10 +78,7 @@
}
.btn-icon {
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent cursor-pointer;
> svg {
@apply w-6 h-6;
}
@apply btn-icon;
}
a.tab {