From d5aafc88a9bb57c63840231c373dc57c3461968e Mon Sep 17 00:00:00 2001 From: Sirttas Date: Sat, 18 May 2024 20:12:30 +0200 Subject: [PATCH] show all acquisitions in typeinfo --- .../acquisition/AcquisitionResultTable.vue | 84 ++++++++++++------- src/pages/market/TypeInfo.vue | 2 +- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/market/acquisition/AcquisitionResultTable.vue b/src/market/acquisition/AcquisitionResultTable.vue index 2ec1061..f4f7819 100644 --- a/src/market/acquisition/AcquisitionResultTable.vue +++ b/src/market/acquisition/AcquisitionResultTable.vue @@ -24,6 +24,7 @@ type Result = { interface Props { items?: AcquiredType[]; infoOnly?: boolean; + showAll?: boolean; } interface Emits { @@ -33,7 +34,8 @@ interface Emits { const props = withDefaults(defineProps(), { items: () => [], - infoOnly: false + infoOnly: false, + showAll: false }); defineEmits(); @@ -42,38 +44,60 @@ const marketTaxStore = useMarketTaxStore(); const threshold = useStorage('market-acquisition-threshold', 10); const filter = ref(""); const { sortedArray, headerProps } = useSort(computed(() => { - const list: Result[] = []; - const groups = Map.groupBy(props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())), r => r.type); + if (props.showAll) { + return props.items + .filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())) + .map(r => { + const precentProfit = marketTaxStore.calculateProfit(r.price, r.sell); - groups.forEach((group, type) => { - const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined); - - if (!oldest) { - return; - } - - const total = group.reduce((acc, r) => acc + r.quantity, 0); - const totalRemaining = group.reduce((acc, r) => acc + r.remaining, 0); - const price = group.reduce((acc, r) => acc + r.price * r.remaining, 0) / totalRemaining; - const precentProfit = marketTaxStore.calculateProfit(price, oldest.sell); - list.push({ - type: oldest, - typeID: type.id, - name: type.name, - buy: oldest.buy, - sell: oldest.sell, - price: price, - remaining: totalRemaining, - quantity: total, - precentProfit, - iskProfit: price * precentProfit * totalRemaining + return { + type: r, + typeID: r.type.id, + name: r.type.name, + buy: r.buy, + sell: r.sell, + price: r.price, + remaining: r.remaining, + quantity: r.quantity, + precentProfit, + iskProfit: r.price * precentProfit * r.remaining + }; }); + } + + const list: Result[] = []; + const groups = Map.groupBy(props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())), r => r.type); + + groups.forEach((group, type) => { + const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined); + + if (!oldest) { + return; + } + + const total = group.reduce((acc, r) => acc + r.quantity, 0); + const totalRemaining = group.reduce((acc, r) => acc + r.remaining, 0); + const price = group.reduce((acc, r) => acc + r.price * r.remaining, 0) / totalRemaining; + const precentProfit = marketTaxStore.calculateProfit(price, oldest.sell); + + list.push({ + type: oldest, + typeID: type.id, + name: type.name, + buy: oldest.buy, + sell: oldest.sell, + price: price, + remaining: totalRemaining, + quantity: total, + precentProfit, + iskProfit: price * precentProfit * totalRemaining }); - return list; - }), { - defaultSortKey: 'precentProfit', - defaultSortDirection: 'desc' - }) + }); + return list; +}), { + defaultSortKey: 'precentProfit', + defaultSortDirection: 'desc' +}) const getLineColor = (result: Result) => { if (result.precentProfit >= (threshold.value / 100)) { return 'line-green'; diff --git a/src/pages/market/TypeInfo.vue b/src/pages/market/TypeInfo.vue index 42467a0..eae563e 100644 --- a/src/pages/market/TypeInfo.vue +++ b/src/pages/market/TypeInfo.vue @@ -107,7 +107,7 @@ watch(useRoute(), async route => {
Acquisitions: - +