feat: Add accounting period selector for all views
- Add PeriodSelectorMini component for global period selection - Add accountingPeriod store for shared period state - Add calendar service/router/model for available periods API - Update Dashboard, Invoices, Trial Balance, Bank/Cash Register views to respect selected period - Fix Trial Balance navigation sync bug (period now syncs on mount) - Update backend services to accept luna/an parameters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -238,11 +238,13 @@ import { ref, computed, onMounted, watch } from "vue";
|
||||
import { useToast } from "primevue/usetoast";
|
||||
import { useCompanyStore } from "../stores/companies";
|
||||
import { useTrialBalanceStore } from "../stores/trialBalance";
|
||||
import { useAccountingPeriodStore } from "../stores/accountingPeriod";
|
||||
import { exportToExcel, exportToPDF } from "../utils/exportUtils";
|
||||
|
||||
const toast = useToast();
|
||||
const companyStore = useCompanyStore();
|
||||
const trialBalanceStore = useTrialBalanceStore();
|
||||
const periodStore = useAccountingPeriodStore();
|
||||
|
||||
// State
|
||||
const selectedCompanyId = ref(companyStore.selectedCompany?.id_firma || null);
|
||||
@@ -254,22 +256,8 @@ const localFilters = ref({
|
||||
|
||||
// Computed
|
||||
const currentPeriodText = computed(() => {
|
||||
const months = [
|
||||
"Ianuarie",
|
||||
"Februarie",
|
||||
"Martie",
|
||||
"Aprilie",
|
||||
"Mai",
|
||||
"Iunie",
|
||||
"Iulie",
|
||||
"August",
|
||||
"Septembrie",
|
||||
"Octombrie",
|
||||
"Noiembrie",
|
||||
"Decembrie",
|
||||
];
|
||||
const monthName = months[trialBalanceStore.filters.luna - 1] || "";
|
||||
return `${monthName} ${trialBalanceStore.filters.an}`;
|
||||
// Use the global period store
|
||||
return periodStore.selectedPeriod?.display_name || "";
|
||||
});
|
||||
|
||||
// Methods
|
||||
@@ -599,6 +587,14 @@ onMounted(async () => {
|
||||
await companyStore.loadCompanies();
|
||||
}
|
||||
|
||||
// FIX: Sync period from global periodStore BEFORE loading data
|
||||
// This ensures Trial Balance shows the correct period when navigating
|
||||
// from other views (e.g., Invoices with November selected)
|
||||
if (periodStore.selectedPeriod) {
|
||||
trialBalanceStore.filters.luna = periodStore.selectedPeriod.luna;
|
||||
trialBalanceStore.filters.an = periodStore.selectedPeriod.an;
|
||||
}
|
||||
|
||||
// Load trial balance if company is selected
|
||||
if (companyStore.selectedCompany) {
|
||||
await loadTrialBalance();
|
||||
@@ -614,6 +610,20 @@ watch(
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Watch for period changes - sync luna/an with trial balance store
|
||||
watch(
|
||||
() => periodStore.selectedPeriod,
|
||||
async (newPeriod) => {
|
||||
if (newPeriod && companyStore.selectedCompany) {
|
||||
await trialBalanceStore.changePeriod(
|
||||
newPeriod.luna,
|
||||
newPeriod.an,
|
||||
companyStore.selectedCompany.id_firma
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user