show all acquisitions in typeinfo
This commit is contained in:
@@ -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,38 +44,60 @@ 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(() => {
|
||||||
const list: Result[] = [];
|
if (props.showAll) {
|
||||||
const groups = Map.groupBy(props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase())), r => r.type);
|
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) => {
|
return {
|
||||||
const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined);
|
type: r,
|
||||||
|
typeID: r.type.id,
|
||||||
if (!oldest) {
|
name: r.type.name,
|
||||||
return;
|
buy: r.buy,
|
||||||
}
|
sell: r.sell,
|
||||||
|
price: r.price,
|
||||||
const total = group.reduce((acc, r) => acc + r.quantity, 0);
|
remaining: r.remaining,
|
||||||
const totalRemaining = group.reduce((acc, r) => acc + r.remaining, 0);
|
quantity: r.quantity,
|
||||||
const price = group.reduce((acc, r) => acc + r.price * r.remaining, 0) / totalRemaining;
|
precentProfit,
|
||||||
const precentProfit = marketTaxStore.calculateProfit(price, oldest.sell);
|
iskProfit: r.price * precentProfit * r.remaining
|
||||||
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
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
});
|
||||||
}), {
|
return list;
|
||||||
defaultSortKey: 'precentProfit',
|
}), {
|
||||||
defaultSortDirection: 'desc'
|
defaultSortKey: 'precentProfit',
|
||||||
})
|
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';
|
||||||
|
|||||||
@@ -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" />
|
||||||
|
|||||||
Reference in New Issue
Block a user