diff --git a/src/modules/data-entry/views/receipts/ReceiptCreateView.vue b/src/modules/data-entry/views/receipts/ReceiptCreateView.vue index a67e488..5471a3a 100644 --- a/src/modules/data-entry/views/receipts/ReceiptCreateView.vue +++ b/src/modules/data-entry/views/receipts/ReceiptCreateView.vue @@ -914,6 +914,48 @@ const syncSuppliersIfNeeded = async () => { } } +// Watch for route param changes - reload receipt when navigating from create to view +// This handles the case where Vue Router reuses the component instance +watch( + () => route.params.id, + async (newId, oldId) => { + if (newId && newId !== oldId) { + // Navigated to a receipt (view or edit mode) + console.log('[ReceiptCreateView] Route changed to receipt:', newId) + await loadReceipt() + } else if (!newId && oldId) { + // Navigated back to create mode - reset state + console.log('[ReceiptCreateView] Route changed to create mode') + receipt.value = null + existingAttachments.value = [] + selectedFiles.value = [] + ocrData.value = null + form.value = { + receipt_type: 'bon_fiscal', + direction: 'cheltuiala', + receipt_date: new Date(), + amount: null, + partner_name: null, + cui: '', + ocr_raw_text: '', + expense_type_code: null, + payment_mode: null, + cash_register_id: null, + cash_register_name: null, + cash_register_account: null, + receipt_number: '', + description: '', + company_id: getSelectedCompanyId(), + tva_breakdown: [], + tva_total: null, + items_count: null, + vendor_address: '', + payment_methods: [], + } + } + } +) + // Watch for company changes - sync suppliers in background watch( () => companyStore.selectedCompany,