Compare commits
2 Commits
e6ee697508
...
653f7dbeeb
| Author | SHA1 | Date | |
|---|---|---|---|
| 653f7dbeeb | |||
| 5506125b2e |
@@ -1,6 +1,7 @@
|
|||||||
import {logResource} from "@/service";
|
import {logResource} from "@/service";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
|
AcquisitionApi,
|
||||||
ActivityApi,
|
ActivityApi,
|
||||||
CharacterApi,
|
CharacterApi,
|
||||||
CharacterRuleBookApi,
|
CharacterRuleBookApi,
|
||||||
@@ -29,3 +30,4 @@ export const ruleBookApi = new RuleBookApi(undefined, mammonUrl, mammonAxiosInst
|
|||||||
export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
export const processingApi = new ProcessingApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const processingApi = new ProcessingApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
|
export const acquisitionApi = new AcquisitionApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MarketType } from "..";
|
import { MarketType } from "..";
|
||||||
import { MarbasAcquiredType } from "./acquisition";
|
import { RawAcquiredType } from "./acquisition";
|
||||||
|
|
||||||
export type AcquiredType = Omit<MarbasAcquiredType, 'type'> & {
|
export type AcquiredType = Omit<RawAcquiredType, 'type'> & {
|
||||||
type: MarketType,
|
type: MarketType,
|
||||||
buy: number,
|
buy: number,
|
||||||
sell: number
|
sell: number
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import {useStorage} from '@vueuse/core';
|
|||||||
import {computed, ref} from 'vue';
|
import {computed, ref} from 'vue';
|
||||||
import {AcquiredType} from './AcquiredType';
|
import {AcquiredType} from './AcquiredType';
|
||||||
import AcquisitionQuantilsTooltip from './AcquisitionQuantilsTooltip.vue';
|
import AcquisitionQuantilsTooltip from './AcquisitionQuantilsTooltip.vue';
|
||||||
|
import {formatEveDate, formatIsk, percentFormater} from "@/formaters.ts";
|
||||||
|
|
||||||
type Result = {
|
type Result = {
|
||||||
id: number;
|
id: string;
|
||||||
type: MarketType;
|
type: MarketType;
|
||||||
name: string;
|
name: string;
|
||||||
buy: number;
|
buy: number;
|
||||||
@@ -97,7 +98,7 @@ const { sortedArray, headerProps, showColumn } = useSort<Result>(computed(() =>
|
|||||||
const precentProfit = marketTaxStore.calculateProfit(price, first.sell);
|
const precentProfit = marketTaxStore.calculateProfit(price, first.sell);
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
id: typeID,
|
id: typeID.toString(),
|
||||||
type: first.type,
|
type: first.type,
|
||||||
name: first.type.name,
|
name: first.type.name,
|
||||||
buy: first.buy,
|
buy: first.buy,
|
||||||
|
|||||||
@@ -1,39 +1,41 @@
|
|||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref} from "vue";
|
||||||
|
import {acquisitionApi} from "@/mammon";
|
||||||
|
import {AcquisitionResponse, AcquisitionResponseSourceEnum} from "@/generated/mammon";
|
||||||
|
|
||||||
export type AcquiredTypeSource = 'bo' | 'so' | 'prod' | 'misc';
|
export type AcquiredTypeSource = 'bo' | 'so' | 'prod' | 'misc';
|
||||||
|
|
||||||
|
export type RawAcquiredType = {
|
||||||
|
id: string;
|
||||||
|
type: number;
|
||||||
|
quantity: number;
|
||||||
|
remaining: number;
|
||||||
|
price: number;
|
||||||
|
date: Date;
|
||||||
|
source: AcquisitionResponseSourceEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
const toAcquiredType = (a: AcquisitionResponse): RawAcquiredType => ({
|
||||||
|
id: a.acquisitionId,
|
||||||
|
type: a.marketTypeId,
|
||||||
|
quantity: a.quantity,
|
||||||
|
remaining: a.remaining,
|
||||||
|
price: a.unitCost,
|
||||||
|
date: new Date(a.datetime),
|
||||||
|
source: a.source,
|
||||||
|
});
|
||||||
|
|
||||||
export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
|
export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
|
||||||
const acquiredTypes = ref<any[]>([]); // TODO
|
const acquiredTypes = ref<RawAcquiredType[]>([]);
|
||||||
|
|
||||||
const types = computed(() => acquiredTypes.value.filter(item => item.remaining > 0));
|
const types = computed(() => acquiredTypes.value.filter(item => item.remaining > 0));
|
||||||
const addAcquiredType = async (type: number, quantity: number, price: number, source?: AcquiredTypeSource) => {
|
|
||||||
const newItem = [];
|
|
||||||
|
|
||||||
acquiredTypes.value = [...acquiredTypes.value, newItem];
|
// Display-only: the backend exposes no write endpoint yet, so buy/sell are no-ops.
|
||||||
};
|
const addAcquiredType = async (_type: number, _quantity: number, _price: number, _source?: AcquiredTypeSource) => {};
|
||||||
const removeAcquiredType = async (id: number, quantity: number) => {
|
const removeAcquiredType = async (_id: string, _quantity: number) => {};
|
||||||
const found = acquiredTypes.value.find(t => t.id === id);
|
|
||||||
|
|
||||||
if (!found) {
|
const refresh = () => acquisitionApi.findAllAcquisitions()
|
||||||
return 0;
|
.then(response => acquiredTypes.value = response.data.map(toAcquiredType));
|
||||||
}
|
|
||||||
|
|
||||||
const item = {
|
|
||||||
...found,
|
|
||||||
remaining: Math.max(0, found.remaining - quantity)
|
|
||||||
};
|
|
||||||
|
|
||||||
acquiredTypes.value = acquiredTypes.value.map(i => {
|
|
||||||
if (i.id === item.id) {
|
|
||||||
return item;
|
|
||||||
} else {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const refresh = () => {}
|
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {esiAxiosInstance} from '@/service';
|
import {esiAxiosInstance} from '@/service';
|
||||||
|
|
||||||
export type MarketType = {
|
export type MarketType = {
|
||||||
type_id: number;
|
id: number;
|
||||||
group_id: number;
|
group_id: number;
|
||||||
market_group_id: number;
|
market_group_id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -19,9 +19,11 @@ const fetchType = (id: number): Promise<MarketType> => {
|
|||||||
if (cache.has(id)) {
|
if (cache.has(id)) {
|
||||||
return Promise.resolve(cache.get(id)!);
|
return Promise.resolve(cache.get(id)!);
|
||||||
}
|
}
|
||||||
return esiAxiosInstance.get<MarketType>(`/universe/types/${id}/`).then(r => {
|
return esiAxiosInstance.get<Omit<MarketType, 'id'> & { type_id: number }>(`/universe/types/${id}/`).then(r => {
|
||||||
cache.set(id, r.data);
|
const { type_id, ...rest } = r.data;
|
||||||
return r.data;
|
const marketType: MarketType = { id: type_id, ...rest };
|
||||||
|
cache.set(id, marketType);
|
||||||
|
return marketType;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ watchEffect(async () => {
|
|||||||
<template>
|
<template>
|
||||||
<div @click="() => isOpen = true" v-on-click-outside="() => isOpen = false">
|
<div @click="() => isOpen = true" v-on-click-outside="() => isOpen = false">
|
||||||
<div class="fake-input">
|
<div class="fake-input">
|
||||||
<img v-if="modelValue?.id" :src="`https://images.evetech.net/types/${modelValue.id}/icon?size=32`" alt="" />
|
<img v-if="modelValue?.type_id" :src="`https://images.evetech.net/types/${modelValue.type_id}/icon?size=32`" alt="" />
|
||||||
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
|
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="suggestions.length > 1" class="z-20 absolute w-96">
|
<div v-if="suggestions.length > 1" class="z-20 absolute w-96">
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
import {RouterView} from 'vue-router';
|
import {RouterView} from 'vue-router';
|
||||||
import {EditLedgerModal, useLedgersStore} from "@/ledger";
|
import {EditLedgerModal, useLedgersStore} from "@/ledger";
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {processingApi} from "@/mammon";
|
import {activityApi, processingApi} from "@/mammon";
|
||||||
|
|
||||||
const {refresh} = useLedgersStore();
|
const {refresh} = useLedgersStore();
|
||||||
|
|
||||||
const editLedgerModal = ref<typeof EditLedgerModal>();
|
const editLedgerModal = ref<typeof EditLedgerModal>();
|
||||||
|
|
||||||
const processActivities = async () => {
|
const processActivities = async () => {
|
||||||
|
await activityApi.fetchAllNewActivities();
|
||||||
await processingApi.processNewActivities();
|
await processingApi.processNewActivities();
|
||||||
await refresh();
|
await refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { MarketTypePrice, getMarketTypes, useApraisalStore } from "@/market";
|
import {getMarketTypes, MarketTypePrice, useApraisalStore} from "@/market";
|
||||||
import {AcquiredType, AcquisitionResultTable, BuyModal, SellModal, useAcquiredTypesStore} from '@/market/acquisition';
|
import {AcquiredType, AcquisitionResultTable, BuyModal, SellModal, useAcquiredTypesStore} from '@/market/acquisition';
|
||||||
import {ref, watch} from 'vue';
|
import {ref, watch} from 'vue';
|
||||||
|
import {activityApi, processingApi} from "@/mammon";
|
||||||
|
|
||||||
const buyModal = ref<typeof BuyModal>();
|
const buyModal = ref<typeof BuyModal>();
|
||||||
const sellModal = ref<typeof SellModal>();
|
const sellModal = ref<typeof SellModal>();
|
||||||
@@ -10,7 +11,11 @@ const apraisalStore = useApraisalStore();
|
|||||||
const acquiredTypesStore = useAcquiredTypesStore();
|
const acquiredTypesStore = useAcquiredTypesStore();
|
||||||
const items = ref<AcquiredType[]>([]);
|
const items = ref<AcquiredType[]>([]);
|
||||||
|
|
||||||
const refresh = async () => await acquiredTypesStore.refresh();
|
const refresh = async () => {
|
||||||
|
await activityApi.fetchAllNewActivities();
|
||||||
|
await processingApi.processNewActivities();
|
||||||
|
await acquiredTypesStore.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => acquiredTypesStore.acquiredTypes, async itms => {
|
watch(() => acquiredTypesStore.acquiredTypes, async itms => {
|
||||||
if (itms.length === 0) {
|
if (itms.length === 0) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import {RouterLink} from 'vue-router';
|
|||||||
import {routeNames} from '@/routes';
|
import {routeNames} from '@/routes';
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
|
{name: "Market", path: "/market"},
|
||||||
{name: "Ledger", path: "/ledgers"},
|
{name: "Ledger", path: "/ledgers"},
|
||||||
{name: "Rules", path: "/rules"},
|
{name: "Rules", path: "/rules"},
|
||||||
{name: "Market", path: "/market"},
|
|
||||||
{name: "Reprocess", path: "/reprocess"},
|
{name: "Reprocess", path: "/reprocess"},
|
||||||
{name: "Tools", path: "/tools"}
|
{name: "Tools", path: "/tools"}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user