Files
roa2web-service-auto/reports-app/frontend/src/stores/treasury.js
Marius Mutu f52aa27bdc chore: Fix .env.test quotes and format frontend code
- Fix TEST_ORACLE_USER quotes in .env.test for shell source compatibility
- Format 14 frontend files with Prettier (stores, views, utils)
- All 122 tests passing (77 telegram + 35 backend + 10 E2E)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 00:31:20 +02:00

78 lines
1.8 KiB
JavaScript

import { defineStore } from "pinia";
import { ref } from "vue";
import { apiService } from "../services/api";
export const useTreasuryStore = defineStore("treasury", () => {
const registers = ref([]);
const isLoading = ref(false);
const error = ref(null);
const pagination = ref({
page: 0,
rows: 50,
totalRecords: 0,
});
const totals = ref({
total_incasari: 0,
total_plati: 0,
});
const loadBankCashRegister = async (companyId, filters = {}) => {
isLoading.value = true;
error.value = null;
try {
const params = {
company: companyId,
page: pagination.value.page + 1,
page_size: pagination.value.rows,
...filters,
};
const response = await apiService.get("/treasury/bank-cash-register", {
params,
});
registers.value = response.data.registers || [];
pagination.value.totalRecords = response.data.total_count || 0;
totals.value = {
total_incasari: response.data.total_incasari,
total_plati: response.data.total_plati,
};
return { success: true };
} catch (err) {
error.value = err.response?.data?.detail || "Failed to load register";
console.error("Failed to load register:", err);
return { success: false, error: error.value };
} finally {
isLoading.value = false;
}
};
const setPagination = (newPagination) => {
pagination.value = { ...pagination.value, ...newPagination };
};
const reset = () => {
registers.value = [];
isLoading.value = false;
error.value = null;
pagination.value = {
page: 0,
rows: 50,
totalRecords: 0,
};
};
return {
registers,
isLoading,
error,
pagination,
totals,
loadBankCashRegister,
setPagination,
reset,
};
});