feat: Add totals from all filtered records to invoices, treasury, and trial balance

Previously, totals were computed client-side from only the current page data,
which gave incorrect results when paginating. Now the backend calculates totals
across ALL filtered records and returns them in the API response.

- Invoice: Add total_sold_all field for sum of all filtered invoice balances
- Treasury: Add sold_precedent_all, total_incasari_all, total_plati_all, sold_final_all
- Trial Balance: Add 6-column totals (debit/credit for each balance type)
- Frontend stores and views updated to use backend totals

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-09 15:45:24 +02:00
parent c75e896a84
commit de24a79db5
12 changed files with 248 additions and 76 deletions

View File

@@ -11,6 +11,16 @@ export const useTrialBalanceStore = defineStore("trialBalance", () => {
const isLoading = ref(false);
const error = ref(null);
// Totaluri din TOATE înregistrările filtrate (nu doar pagina curentă)
const totals = ref({
total_sold_precedent_debit: 0,
total_sold_precedent_credit: 0,
total_rulaj_lunar_debit: 0,
total_rulaj_lunar_credit: 0,
total_sold_final_debit: 0,
total_sold_final_credit: 0,
});
const filters = ref({
luna: new Date().getMonth() + 1, // Current month (1-12)
an: new Date().getFullYear(), // Current year
@@ -83,6 +93,11 @@ export const useTrialBalanceStore = defineStore("trialBalance", () => {
totalPages: paginationData.total_pages,
};
// Store totals from ALL filtered records (not just current page)
if (response.data.data.totals) {
totals.value = response.data.data.totals;
}
return { success: true };
} else {
throw new Error("Invalid response format");
@@ -146,6 +161,14 @@ export const useTrialBalanceStore = defineStore("trialBalance", () => {
trialBalanceData.value = [];
isLoading.value = false;
error.value = null;
totals.value = {
total_sold_precedent_debit: 0,
total_sold_precedent_credit: 0,
total_rulaj_lunar_debit: 0,
total_rulaj_lunar_credit: 0,
total_sold_final_debit: 0,
total_sold_final_credit: 0,
};
filters.value = {
luna: new Date().getMonth() + 1,
an: new Date().getFullYear(),
@@ -169,6 +192,7 @@ export const useTrialBalanceStore = defineStore("trialBalance", () => {
trialBalanceData,
isLoading,
error,
totals,
filters,
pagination,
sorting,