show all acquisitions in typeinfo
This commit is contained in:
@@ -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<Props>(), {
|
||||
items: () => [],
|
||||
infoOnly: false
|
||||
infoOnly: false,
|
||||
showAll: false
|
||||
});
|
||||
defineEmits<Emits>();
|
||||
|
||||
@@ -42,38 +44,60 @@ const marketTaxStore = useMarketTaxStore();
|
||||
const threshold = useStorage('market-acquisition-threshold', 10);
|
||||
const filter = ref("");
|
||||
const { sortedArray, headerProps } = useSort<Result>(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';
|
||||
|
||||
@@ -107,7 +107,7 @@ watch(useRoute(), async route => {
|
||||
</div>
|
||||
<div v-if="acquisitions && acquisitions.length > 0">
|
||||
<span>Acquisitions:</span>
|
||||
<AcquisitionResultTable :items="acquisitions" infoOnly />
|
||||
<AcquisitionResultTable :items="acquisitions" infoOnly showAll />
|
||||
</div>
|
||||
</template>
|
||||
<BuyModal ref="buyModal" />
|
||||
|
||||
Reference in New Issue
Block a user