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