|
@@ -150,8 +150,8 @@
|
|
|
<div class="bg-gradient-to-r from-green-400 to-green-600 rounded-lg p-6 text-white">
|
|
<div class="bg-gradient-to-r from-green-400 to-green-600 rounded-lg p-6 text-white">
|
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center justify-between">
|
|
|
<div>
|
|
<div>
|
|
|
- <p class="text-green-100 text-sm">Solde Actuel</p>
|
|
|
|
|
- <p class="text-2xl font-bold">{{ formatCurrency(currentBalance?.currentBalance || 0) }}</p>
|
|
|
|
|
|
|
+ <p class="text-green-100 text-sm">Solde Total Généré</p>
|
|
|
|
|
+ <p class="text-2xl font-bold text-white">{{ reservationsSum }} CFA</p>
|
|
|
</div>
|
|
</div>
|
|
|
<i class="fas fa-wallet text-3xl text-green-200"></i>
|
|
<i class="fas fa-wallet text-3xl text-green-200"></i>
|
|
|
</div>
|
|
</div>
|
|
@@ -160,7 +160,7 @@
|
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center justify-between">
|
|
|
<div>
|
|
<div>
|
|
|
<p class="text-blue-100 text-sm">Transactions ce mois</p>
|
|
<p class="text-blue-100 text-sm">Transactions ce mois</p>
|
|
|
- <p class="text-2xl font-bold">{{ monthlyTransactions }}</p>
|
|
|
|
|
|
|
+ <p class="text-2xl font-bold text-white">{{ monthlyTransactions }}</p>
|
|
|
</div>
|
|
</div>
|
|
|
<i class="fas fa-exchange-alt text-3xl text-blue-200"></i>
|
|
<i class="fas fa-exchange-alt text-3xl text-blue-200"></i>
|
|
|
</div>
|
|
</div>
|
|
@@ -169,7 +169,7 @@
|
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center justify-between">
|
|
|
<div>
|
|
<div>
|
|
|
<p class="text-purple-100 text-sm">Dernière mise à jour</p>
|
|
<p class="text-purple-100 text-sm">Dernière mise à jour</p>
|
|
|
- <p class="text-lg font-semibold">{{ formatDate(currentBalance?.lastUpdated) }}</p>
|
|
|
|
|
|
|
+ <p class="text-lg font-semibold text-white">{{ formatDate(currentBalance?.lastUpdated) }}</p>
|
|
|
</div>
|
|
</div>
|
|
|
<i class="fas fa-clock text-3xl text-purple-200"></i>
|
|
<i class="fas fa-clock text-3xl text-purple-200"></i>
|
|
|
</div>
|
|
</div>
|
|
@@ -453,12 +453,14 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, computed, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, computed, onMounted, onBeforeMount } from 'vue'
|
|
|
import Sidebar from '@/components/Sidebar.vue'
|
|
import Sidebar from '@/components/Sidebar.vue'
|
|
|
import TopBar from '@/components/TopBar.vue'
|
|
import TopBar from '@/components/TopBar.vue'
|
|
|
import { useUserStore } from '@/stores/useUserStore'
|
|
import { useUserStore } from '@/stores/useUserStore'
|
|
|
import { useToast } from '@/composables/useToast'
|
|
import { useToast } from '@/composables/useToast'
|
|
|
import BudgetService, { type Subscription, type Balance, type Transaction, type PaymentRequest, type Receipt } from '@/services/BudgetService'
|
|
import BudgetService, { type Subscription, type Balance, type Transaction, type PaymentRequest, type Receipt } from '@/services/BudgetService'
|
|
|
|
|
+import ReservationService from '@/services/ReservationService'
|
|
|
|
|
+import { useUserCompanyStore } from '@/stores/useCompanyStore'
|
|
|
|
|
|
|
|
// Stores et composables
|
|
// Stores et composables
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
@@ -480,6 +482,7 @@ const currentBalance = ref<Balance | null>(null)
|
|
|
const transactions = ref<Transaction[]>([])
|
|
const transactions = ref<Transaction[]>([])
|
|
|
const paymentRequests = ref<PaymentRequest[]>([])
|
|
const paymentRequests = ref<PaymentRequest[]>([])
|
|
|
const receipts = ref<Receipt[]>([])
|
|
const receipts = ref<Receipt[]>([])
|
|
|
|
|
+const reservationsSum = ref<number>(0)
|
|
|
|
|
|
|
|
// Filtres
|
|
// Filtres
|
|
|
const transactionFilter = ref('')
|
|
const transactionFilter = ref('')
|
|
@@ -545,7 +548,7 @@ const formatDate = (dateString: string | undefined) => {
|
|
|
const formatCurrency = (amount: number) => {
|
|
const formatCurrency = (amount: number) => {
|
|
|
return new Intl.NumberFormat('fr-FR', {
|
|
return new Intl.NumberFormat('fr-FR', {
|
|
|
style: 'currency',
|
|
style: 'currency',
|
|
|
- currency: 'EUR'
|
|
|
|
|
|
|
+ currency: 'CFA'
|
|
|
}).format(amount)
|
|
}).format(amount)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -570,7 +573,7 @@ const getPaymentStatusLabel = (status: string) => {
|
|
|
|
|
|
|
|
const subscribeToService = async (subscriptionId: number) => {
|
|
const subscribeToService = async (subscriptionId: number) => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) {
|
|
if (!companyId) {
|
|
|
error('Entreprise non trouvée')
|
|
error('Entreprise non trouvée')
|
|
|
return
|
|
return
|
|
@@ -590,7 +593,7 @@ const subscribeToService = async (subscriptionId: number) => {
|
|
|
|
|
|
|
|
const addFunds = async () => {
|
|
const addFunds = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) {
|
|
if (!companyId) {
|
|
|
error('Entreprise non trouvée')
|
|
error('Entreprise non trouvée')
|
|
|
return
|
|
return
|
|
@@ -612,7 +615,7 @@ const addFunds = async () => {
|
|
|
|
|
|
|
|
const createPaymentRequest = async () => {
|
|
const createPaymentRequest = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) {
|
|
if (!companyId) {
|
|
|
error('Entreprise non trouvée')
|
|
error('Entreprise non trouvée')
|
|
|
return
|
|
return
|
|
@@ -662,7 +665,7 @@ const downloadReceipt = async (receiptId: number) => {
|
|
|
// Chargement des données
|
|
// Chargement des données
|
|
|
const loadSubscriptions = async () => {
|
|
const loadSubscriptions = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) return
|
|
if (!companyId) return
|
|
|
|
|
|
|
|
const [active, available] = await Promise.all([
|
|
const [active, available] = await Promise.all([
|
|
@@ -679,24 +682,47 @@ const loadSubscriptions = async () => {
|
|
|
|
|
|
|
|
const loadBalance = async () => {
|
|
const loadBalance = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
- if (!companyId) return
|
|
|
|
|
|
|
+ console.log('🔍 loadBalance - Début de la fonction')
|
|
|
|
|
+ console.log('🔍 userStore:', userStore)
|
|
|
|
|
+ console.log('🔍 userStore.userCompany:', userStore.userCompany)
|
|
|
|
|
+
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
|
|
+ console.log('🔍 companyId récupéré:', companyId)
|
|
|
|
|
+
|
|
|
|
|
+ if (!companyId) {
|
|
|
|
|
+ console.log('❌ Aucun companyId trouvé, arrêt de la fonction', useUserCompanyStore().id)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const [balance, transactionsResult] = await Promise.all([
|
|
|
|
|
|
|
+ console.log('🚀 Appel des APIs avec companyId:', companyId)
|
|
|
|
|
+ const [balance, transactionsResult, reservationsSumResult] = await Promise.all([
|
|
|
BudgetService.getBalance(companyId),
|
|
BudgetService.getBalance(companyId),
|
|
|
- BudgetService.getTransactions(companyId, 1, 50)
|
|
|
|
|
|
|
+ BudgetService.getTransactions(companyId, 1, 50),
|
|
|
|
|
+ ReservationService.getCompanyReservationsSum(companyId)
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
+ const test = await ReservationService.getCompanyReservationsSum(companyId)
|
|
|
|
|
+
|
|
|
|
|
+ console.log('📊 Résultats reçus:', test)
|
|
|
|
|
+ console.log(' - balance:', balance)
|
|
|
|
|
+ console.log(' - transactionsResult:', transactionsResult)
|
|
|
|
|
+ console.log(' - reservationsSumResult:', reservationsSumResult)
|
|
|
|
|
+
|
|
|
currentBalance.value = balance
|
|
currentBalance.value = balance
|
|
|
transactions.value = transactionsResult.transactions
|
|
transactions.value = transactionsResult.transactions
|
|
|
|
|
+ reservationsSum.value = reservationsSumResult?.data?.totalAmount || 0
|
|
|
|
|
+
|
|
|
|
|
+ console.log('✅ loadBalance terminé avec succès')
|
|
|
|
|
+ console.log(' - currentBalance.value:', currentBalance.value)
|
|
|
|
|
+ console.log(' - reservationsSum.value:', reservationsSum.value)
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
- console.error('Erreur lors du chargement du solde:', err)
|
|
|
|
|
|
|
+ console.error('❌ Erreur lors du chargement du solde:', err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const loadPaymentRequests = async () => {
|
|
const loadPaymentRequests = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) return
|
|
if (!companyId) return
|
|
|
|
|
|
|
|
const result = await BudgetService.getPaymentRequests(companyId, 1, 50)
|
|
const result = await BudgetService.getPaymentRequests(companyId, 1, 50)
|
|
@@ -708,7 +734,7 @@ const loadPaymentRequests = async () => {
|
|
|
|
|
|
|
|
const loadReceipts = async () => {
|
|
const loadReceipts = async () => {
|
|
|
try {
|
|
try {
|
|
|
- const companyId = userStore.userCompany?.id
|
|
|
|
|
|
|
+ const companyId = useUserCompanyStore().id
|
|
|
if (!companyId) return
|
|
if (!companyId) return
|
|
|
|
|
|
|
|
const result = await BudgetService.getReceipts(companyId, 1, 50)
|
|
const result = await BudgetService.getReceipts(companyId, 1, 50)
|
|
@@ -719,13 +745,15 @@ const loadReceipts = async () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Chargement initial
|
|
// Chargement initial
|
|
|
-onMounted(async () => {
|
|
|
|
|
- await Promise.all([
|
|
|
|
|
- loadSubscriptions(),
|
|
|
|
|
- loadBalance(),
|
|
|
|
|
- loadPaymentRequests(),
|
|
|
|
|
- loadReceipts()
|
|
|
|
|
- ])
|
|
|
|
|
|
|
+onBeforeMount(async () => {
|
|
|
|
|
+
|
|
|
|
|
+ await loadSubscriptions(),
|
|
|
|
|
+ await loadBalance(),
|
|
|
|
|
+ await loadPaymentRequests(),
|
|
|
|
|
+ await loadReceipts()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ console.log('Reservations sum:', reservationsSum.value)
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|