cleanup acquisitions

This commit is contained in:
2024-05-18 21:12:11 +02:00
parent d5aafc88a9
commit f677a1d61b

View File

@@ -44,29 +44,29 @@ 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) { const filteredItems = props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase()));
return props.items
.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase()))
.map(r => {
const precentProfit = marketTaxStore.calculateProfit(r.price, r.sell);
return { if (props.showAll) {
type: r, return filteredItems.map(r => {
typeID: r.type.id, const precentProfit = marketTaxStore.calculateProfit(r.price, r.sell);
name: r.type.name,
buy: r.buy, return {
sell: r.sell, type: r,
price: r.price, typeID: r.type.id,
remaining: r.remaining, name: r.type.name,
quantity: r.quantity, buy: r.buy,
precentProfit, sell: r.sell,
iskProfit: r.price * precentProfit * r.remaining 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(filteredItems, r => r.type);
groups.forEach((group, type) => { groups.forEach((group, type) => {
const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined); const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined);