ledger gemory draft
This commit is contained in:
@@ -74,7 +74,8 @@ watchEffect(async () => {
|
||||
</Tooltip>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
.tooltip {
|
||||
@apply ms-auto;
|
||||
>:deep(div.header) {
|
||||
|
||||
@@ -245,7 +245,8 @@ const total = computed(() => {
|
||||
</VirtualScrollTable>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
div.end {
|
||||
@apply justify-self-end ms-2;
|
||||
}
|
||||
|
||||
@@ -1,48 +1,16 @@
|
||||
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
|
||||
import { AxiosResponse } from "axios";
|
||||
import log from "loglevel";
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
export type AcquiredTypeSource = 'bo' | 'so' | 'prod' | 'misc';
|
||||
|
||||
export type MarbasAcquiredType = MarbasObject & {
|
||||
type: number;
|
||||
quantity: number;
|
||||
remaining: number;
|
||||
price: number;
|
||||
date: Date;
|
||||
source: AcquiredTypeSource;
|
||||
}
|
||||
|
||||
type RawMarbasAcquiredType = Omit<MarbasAcquiredType, 'date'> & {
|
||||
date: string;
|
||||
}
|
||||
|
||||
type InsertableRawMarbasAcquiredType = Omit<MarbasAcquiredType, 'id' | 'date'>;
|
||||
|
||||
const mapRawMarbasAcquiredType = (raw: RawMarbasAcquiredType): MarbasAcquiredType => ({
|
||||
...raw,
|
||||
date: raw.date ? new Date(raw.date) : new Date()
|
||||
});
|
||||
|
||||
const endpoint = '/api/acquisitions/';
|
||||
|
||||
export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
|
||||
const acquiredTypes = ref<MarbasAcquiredType[]>([]);
|
||||
const acquiredTypes = ref<any[]>([]); // TODO
|
||||
|
||||
const types = computed(() => acquiredTypes.value.filter(item => item.remaining > 0));
|
||||
const addAcquiredType = async (type: number, quantity: number, price: number, source?: AcquiredTypeSource) => {
|
||||
const newItem = mapRawMarbasAcquiredType((await marbasAxiosInstance.post<RawMarbasAcquiredType, AxiosResponse<RawMarbasAcquiredType>, InsertableRawMarbasAcquiredType>(endpoint, {
|
||||
type: type,
|
||||
quantity: quantity,
|
||||
remaining: quantity,
|
||||
price: price,
|
||||
source: source ?? 'misc',
|
||||
})).data);
|
||||
const newItem = [];
|
||||
|
||||
acquiredTypes.value = [...acquiredTypes.value, newItem];
|
||||
log.info(`Acquired type ${newItem.id} with quantity ${newItem.quantity} and price ${newItem.price}`, newItem);
|
||||
};
|
||||
const removeAcquiredType = async (id: number, quantity: number) => {
|
||||
const found = acquiredTypes.value.find(t => t.id === id);
|
||||
@@ -63,11 +31,9 @@ export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
|
||||
return i;
|
||||
}
|
||||
});
|
||||
await marbasAxiosInstance.put(`${endpoint}${item.id}/`, item);
|
||||
log.info(`Acquired type ${item.id} remaining: ${item.remaining}`, item);
|
||||
};
|
||||
|
||||
const refresh = () => marbasAxiosInstance.get<RawMarbasAcquiredType[]>(endpoint).then(res => acquiredTypes.value = res.data.map(mapRawMarbasAcquiredType));
|
||||
const refresh = () => {}
|
||||
|
||||
refresh();
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ const { brokerFee, scc } = storeToRefs(useMarketTaxStore());
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
div.end {
|
||||
@apply justify-self-end ms-2;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,8 @@ const getLineColor = (result: Result) => {
|
||||
</VirtualScrollTable>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
div.end {
|
||||
@apply justify-self-end ms-2;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
|
||||
import { EsiMarketOrderHistory, getHistory, MarketType, MarketTypePrice } from "@/market";
|
||||
import log from "loglevel";
|
||||
import { defineStore } from "pinia";
|
||||
@@ -12,21 +11,16 @@ export type TrackingResult = {
|
||||
orderCount: number,
|
||||
}
|
||||
|
||||
export type MarbasTrackedType = MarbasObject & {
|
||||
type: number
|
||||
};
|
||||
|
||||
const endpoint = '/api/types_tracking/';
|
||||
|
||||
export const useMarketTrackingStore = defineStore('marketTracking', () => {
|
||||
const trackedTypes = ref<MarbasTrackedType[]>([]);
|
||||
const trackedTypes = ref<any[]>([]); // TODO
|
||||
|
||||
const types = computed(() => trackedTypes.value.map(item => item.type) ?? []);
|
||||
const addType = async (type: number) => {
|
||||
const found = trackedTypes.value.find(item => item.type === type);
|
||||
|
||||
if (!found) {
|
||||
trackedTypes.value = [...trackedTypes.value, (await marbasAxiosInstance.post<MarbasTrackedType>(endpoint, { type })).data];
|
||||
log.info(`Tracking type ${type}`);
|
||||
}
|
||||
}
|
||||
@@ -38,12 +32,8 @@ export const useMarketTrackingStore = defineStore('marketTracking', () => {
|
||||
}
|
||||
|
||||
trackedTypes.value = trackedTypes.value.filter(t => t.id !== found.id);
|
||||
await marbasAxiosInstance.delete(`${endpoint}${found.id}`);
|
||||
log.info(`Stopped tracking type ${type}`);
|
||||
}
|
||||
|
||||
marbasAxiosInstance.get<MarbasTrackedType[]>(endpoint).then(res => trackedTypes.value = res.data);
|
||||
|
||||
return { types, addType, removeType };
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { marbasAxiosInstance } from "@/marbas";
|
||||
|
||||
export type MarketType = {
|
||||
id: number;
|
||||
group_id: number;
|
||||
@@ -18,15 +16,9 @@ export const getMarketTypes = async (types: (string | number)[]): Promise<Market
|
||||
if (types.length === 0) {
|
||||
return [];
|
||||
} else if (types.length === 1 && typeof types[0] === "number") {
|
||||
return [(await marbasAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
|
||||
return [];
|
||||
}
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
|
||||
if (typeof t === "number") {
|
||||
return { id: t };
|
||||
} else {
|
||||
return { name: t };
|
||||
}
|
||||
}))).data;
|
||||
return []
|
||||
}
|
||||
|
||||
const blueprintMarketGrous = [ // TODO add all groups
|
||||
@@ -49,9 +41,5 @@ const blueprintMarketGrous = [ // TODO add all groups
|
||||
]
|
||||
|
||||
export const searchMarketTypes = async (search: string): Promise<MarketType[]> => {
|
||||
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", [{
|
||||
name__icontains: search,
|
||||
marketgroup_id___not: null,
|
||||
marketgroup_id__in___not: blueprintMarketGrous,
|
||||
}])).data;
|
||||
return []
|
||||
}
|
||||
@@ -104,7 +104,8 @@ watchEffect(async () => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
.fake-input {
|
||||
@apply w-96 flex border bg-slate-500 rounded px-1 py-0.5;
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ withDefaults(defineProps<Props>(), {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
<style scoped>
|
||||
@reference "tailwindcss";
|
||||
button:deep(>svg), .button:deep(>svg) {
|
||||
@apply !w-4 !h-4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user