show all acquisitions in typeinfo

This commit is contained in:
2024-05-18 20:12:30 +02:00
parent 52a4b99214
commit d5aafc88a9
2 changed files with 55 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ type Result = {
interface Props { interface Props {
items?: AcquiredType[]; items?: AcquiredType[];
infoOnly?: boolean; infoOnly?: boolean;
showAll?: boolean;
} }
interface Emits { interface Emits {
@@ -33,7 +34,8 @@ interface Emits {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
items: () => [], items: () => [],
infoOnly: false infoOnly: false,
showAll: false
}); });
defineEmits<Emits>(); defineEmits<Emits>();
@@ -42,6 +44,27 @@ const marketTaxStore = useMarketTaxStore();
const threshold = useStorage('market-acquisition-threshold', 10); const threshold = useStorage('market-acquisition-threshold', 10);
const filter = ref(""); const filter = ref("");
const { sortedArray, headerProps } = useSort<Result>(computed(() => { const { sortedArray, headerProps } = useSort<Result>(computed(() => {
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);
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 list: Result[] = [];
const groups = Map.groupBy(props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())), r => r.type); const groups = Map.groupBy(props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())), r => r.type);
@@ -56,6 +79,7 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => {
const totalRemaining = group.reduce((acc, r) => acc + r.remaining, 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 price = group.reduce((acc, r) => acc + r.price * r.remaining, 0) / totalRemaining;
const precentProfit = marketTaxStore.calculateProfit(price, oldest.sell); const precentProfit = marketTaxStore.calculateProfit(price, oldest.sell);
list.push({ list.push({
type: oldest, type: oldest,
typeID: type.id, typeID: type.id,
@@ -70,10 +94,10 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => {
}); });
}); });
return list; return list;
}), { }), {
defaultSortKey: 'precentProfit', defaultSortKey: 'precentProfit',
defaultSortDirection: 'desc' defaultSortDirection: 'desc'
}) })
const getLineColor = (result: Result) => { const getLineColor = (result: Result) => {
if (result.precentProfit >= (threshold.value / 100)) { if (result.precentProfit >= (threshold.value / 100)) {
return 'line-green'; return 'line-green';

View File

@@ -107,7 +107,7 @@ watch(useRoute(), async route => {
</div> </div>
<div v-if="acquisitions && acquisitions.length > 0"> <div v-if="acquisitions && acquisitions.length > 0">
<span>Acquisitions:</span> <span>Acquisitions:</span>
<AcquisitionResultTable :items="acquisitions" infoOnly /> <AcquisitionResultTable :items="acquisitions" infoOnly showAll />
</div> </div>
</template> </template>
<BuyModal ref="buyModal" /> <BuyModal ref="buyModal" />