tags and new analytics new in budget

This commit is contained in:
xds
2025-02-23 12:22:40 +03:00
parent 6d3638896f
commit 85b6d0a796
29 changed files with 1102 additions and 565 deletions

View File

@@ -7,24 +7,24 @@ import {useSpaceStore} from "@/stores/spaceStore";
export const getBudgetInfos = async () => {
try {
let spaceId = localStorage.getItem("spaceId")
let response = await apiClient.get(`/spaces/${spaceId}/budgets`);
let budgetInfos = response.data;
budgetInfos.forEach((budgetInfo: Budget) => {
budgetInfo.dateFrom = new Date(budgetInfo.dateFrom);
budgetInfo.dateTo = new Date(budgetInfo.dateTo);
budgetInfo.plannedExpenses?.forEach(e => {
e.date = new Date(e.date)
})
let response = await apiClient.get(`/spaces/${spaceId}/budgets`);
let budgetInfos = response.data;
budgetInfos.forEach((budgetInfo: Budget) => {
budgetInfo.dateFrom = new Date(budgetInfo.dateFrom);
budgetInfo.dateTo = new Date(budgetInfo.dateTo);
budgetInfo.plannedExpenses?.forEach(e => {
e.date = new Date(e.date)
})
budgetInfo.plannedIncomes?.forEach(e => {
e.date = new Date(e.date)
})
budgetInfo.plannedIncomes?.forEach(e => {
e.date = new Date(e.date)
})
budgetInfo.transactions?.forEach(e => {
e.date = new Date(e.date)
budgetInfo.transactions?.forEach(e => {
e.date = new Date(e.date)
})
})
})
return budgetInfos
return budgetInfos
} catch (e) {
console.log(e)
throw e
@@ -94,21 +94,22 @@ export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCat
export const createBudget = async (budget: Budget, createRecurrent: Boolean) => {
try {
let spaceId = localStorage.getItem("spaceId")
let budgetToCreate = JSON.parse(JSON.stringify(budget));
budgetToCreate.dateFrom = format(budget.dateFrom, 'yyyy-MM-dd')
budgetToCreate.dateTo = format(budget.dateTo, 'yyyy-MM-dd')
let data = {
budget: budgetToCreate,
createRecurrent: createRecurrent
}
await apiClient.post(`/spaces/${spaceId}/budgets`, data);
} catch (e){
console.error(e)
throw e
}
const spaceStore = useSpaceStore()
console.log(budget)
let budgetToCreate = JSON.parse(JSON.stringify(budget));
budgetToCreate.dateFrom = format(budget.dateFrom, 'yyyy-MM-dd')
budgetToCreate.dateTo = format(budget.dateTo, 'yyyy-MM-dd')
let data = {
budget: budgetToCreate,
createRecurrent: createRecurrent
}
return await apiClient.post(`/spaces/${spaceStore.space?.id}/budgets`, budgetToCreate)
.then(res => res.data)
.catch(err => {
throw err
})
}