feat: Enhance invoice management with PDF optimization and date fixes

Optimize PDF export layout with compact columns and more space for partner names.
Add accounting period display to invoices matching Trial Balance format. Fix date
filtering to use local timezone instead of UTC. Update invoice ordering to
chronological sequence (DATAACT, NRACT, NUME).

**Backend changes:**
- Add accounting period query from calendar table
- Add currency (valuta) and cont filter support
- Change invoice ordering to chronological (DATAACT ASC, NRACT ASC, NUME)
- Add accounting_period field to InvoiceListResponse model

**Frontend changes:**
- Optimize PDF column widths (37% for partner names, compact numeric columns)
- Add custom column width support in exportUtils
- Fix date conversion from UTC to local timezone (prevents day shift)
- Add accounting period display in PDF exports
- Enhance E2E test coverage

**Cleanup:**
- Remove obsolete Trial Balance feature documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 15:29:24 +02:00
parent a45dfa826d
commit 8eed1566a3
11 changed files with 750 additions and 1051 deletions

View File

@@ -7,6 +7,7 @@ export const useInvoicesStore = defineStore("invoices", () => {
const invoices = ref([]);
const isLoading = ref(false);
const error = ref(null);
const accountingPeriod = ref({ an: null, luna: null });
const filters = ref({
company: null,
type: "CLIENTI", // CLIENTI or FURNIZORI
@@ -15,7 +16,7 @@ export const useInvoicesStore = defineStore("invoices", () => {
searchTerm: "",
});
const pagination = ref({
page: 0,
page: 1,
rows: 50,
totalRecords: 0,
});
@@ -57,16 +58,32 @@ export const useInvoicesStore = defineStore("invoices", () => {
try {
const params = {
partner_type: filters.value.type,
page: pagination.value.page + 1,
size: pagination.value.rows,
page: pagination.value.page,
page_size: pagination.value.rows,
...options,
};
if (filters.value.dateFrom) {
params.date_from = filters.value.dateFrom;
// Convert Date object to YYYY-MM-DD string format (LOCAL date, not UTC)
if (filters.value.dateFrom instanceof Date) {
const year = filters.value.dateFrom.getFullYear();
const month = String(filters.value.dateFrom.getMonth() + 1).padStart(2, '0');
const day = String(filters.value.dateFrom.getDate()).padStart(2, '0');
params.date_from = `${year}-${month}-${day}`;
} else {
params.date_from = filters.value.dateFrom;
}
}
if (filters.value.dateTo) {
params.date_to = filters.value.dateTo;
// Convert Date object to YYYY-MM-DD string format (LOCAL date, not UTC)
if (filters.value.dateTo instanceof Date) {
const year = filters.value.dateTo.getFullYear();
const month = String(filters.value.dateTo.getMonth() + 1).padStart(2, '0');
const day = String(filters.value.dateTo.getDate()).padStart(2, '0');
params.date_to = `${year}-${month}-${day}`;
} else {
params.date_to = filters.value.dateTo;
}
}
if (filters.value.searchTerm) {
params.search = filters.value.searchTerm;
@@ -83,6 +100,11 @@ export const useInvoicesStore = defineStore("invoices", () => {
invoices.value = response.data.invoices || [];
pagination.value.totalRecords = response.data.total_count || 0;
// Store accounting period if available
if (response.data.accounting_period) {
accountingPeriod.value = response.data.accounting_period;
}
return { success: true };
} catch (err) {
error.value = err.response?.data?.detail || "Failed to load invoices";
@@ -123,9 +145,10 @@ export const useInvoicesStore = defineStore("invoices", () => {
invoices.value = [];
isLoading.value = false;
error.value = null;
accountingPeriod.value = { an: null, luna: null };
clearFilters();
pagination.value = {
page: 0,
page: 1,
rows: 50,
totalRecords: 0,
};
@@ -140,6 +163,7 @@ export const useInvoicesStore = defineStore("invoices", () => {
invoices,
isLoading,
error,
accountingPeriod,
filters,
pagination,