chet novoe
This commit is contained in:
@@ -3,7 +3,7 @@ import {Budget, BudgetCategory} from "@/models/Budget";
|
||||
// Импортируете настроенный экземпляр axios
|
||||
|
||||
export const getBudgetInfos = async () => {
|
||||
console.log('getBudgetInfos');
|
||||
|
||||
let response = await apiClient.get('/budgets/');
|
||||
let budgetInfos = response.data;
|
||||
budgetInfos.forEach((budgetInfo: Budget) => {
|
||||
@@ -24,22 +24,43 @@ export const getBudgetInfos = async () => {
|
||||
return budgetInfos
|
||||
}
|
||||
|
||||
export const getBudgetTransactions = async (budgetId, transactionType, categoryType) => {
|
||||
|
||||
let url = `/budgets/${budgetId}/transactions`
|
||||
if (transactionType) {
|
||||
url += '/' + transactionType
|
||||
}
|
||||
if (transactionType && categoryType) {
|
||||
url += '/'+categoryType
|
||||
}
|
||||
// if (!categoryType) {
|
||||
// throw new Error('No CategoryType');
|
||||
// }
|
||||
let response = await apiClient.get(url);
|
||||
let transactions = response.data;
|
||||
transactions.forEach(e => {
|
||||
e.date = new Date(e.date)
|
||||
})
|
||||
return transactions
|
||||
}
|
||||
|
||||
export const getBudgetCategories = async (budgetId) => {
|
||||
let response = await apiClient.get('/budgets/' + budgetId + '/categories/');
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const getBudgetCategoriesSums = async (budgetId) => {
|
||||
let response = await apiClient.get('/budgets/' + budgetId + '/categories/_calc_sums');
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const getBudgetInfo = async (budget_id: number) => {
|
||||
console.log('getBudgetInfo');
|
||||
|
||||
let budgetInfo = await apiClient.get('/budgets/' + budget_id);
|
||||
budgetInfo = budgetInfo.data;
|
||||
|
||||
budgetInfo.plannedExpenses.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.dateFrom = new Date(budgetInfo.dateFrom)
|
||||
budgetInfo.dateTo = new Date(budgetInfo.dateTo)
|
||||
return budgetInfo
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user