From 92ec321d089fa7c4db3e12d79529dce6ecc464af Mon Sep 17 00:00:00 2001 From: Ollama Date: Wed, 1 Apr 2026 06:57:54 +0000 Subject: [PATCH] fix: Clear sale session after completing sale The clear_all() calls in postComplete() were placed after return statements, making them unreachable dead code. This caused the completed sale to remain in the session and appear in the Register when navigating back. The fix moves clear_all() and clear_mode() calls before the return statements so they are actually executed, properly clearing the sale cart, customer, and payments from the session after sale completion. This fixes the regression reported by @odiea where users had to manually cancel sales after each transaction. --- app/Controllers/Sales.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 628ae5057..da4a428c6 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -786,8 +786,8 @@ class Sales extends Secure_Controller $data['error_message'] = lang('Sales.transaction_failed'); } else { $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']); - return view('sales/' . $invoice_view, $data); $this->sale_lib->clear_all(); + return view('sales/' . $invoice_view, $data); } } } elseif ($this->sale_lib->is_work_order_mode()) { @@ -820,9 +820,9 @@ class Sales extends Secure_Controller $data['barcode'] = null; - return view('sales/work_order', $data); $this->sale_lib->clear_mode(); $this->sale_lib->clear_all(); + return view('sales/work_order', $data); } } elseif ($this->sale_lib->is_quote_mode()) { $data['sales_quote'] = lang('Sales.quote'); @@ -848,9 +848,9 @@ class Sales extends Secure_Controller $data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']); $data['barcode'] = null; - return view('sales/quote', $data); $this->sale_lib->clear_mode(); $this->sale_lib->clear_all(); + return view('sales/quote', $data); } } else { // Save the data to the sales table @@ -871,8 +871,8 @@ class Sales extends Secure_Controller $data['error_message'] = lang('Sales.transaction_failed'); } else { $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']); - return view('sales/receipt', $data); $this->sale_lib->clear_all(); + return view('sales/receipt', $data); } } }