From 3ff2d8d8e1baa6334ff5902a5137079b0c47cb1d Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Mon, 4 May 2026 02:14:03 +0300 Subject: [PATCH] Update: 2026-05-04 02:14:03 --- app/modules_app/invoices/upload.php | 44 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/app/modules_app/invoices/upload.php b/app/modules_app/invoices/upload.php index 065580e..100c59a 100644 --- a/app/modules_app/invoices/upload.php +++ b/app/modules_app/invoices/upload.php @@ -91,28 +91,34 @@ if (move_uploaded_file($_FILES['invoice']['tmp_name'], $targetFile)) { buyer_tin, buyer_name, buyer_national_id, subtotal, tax_amount, discount_total, grand_total, currency_code, created_at - ) VALUES (?, ?, ?, ?, ?, ?, 'extracted', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()) + ) VALUES ( + :id, :tenant_id, :company_id, :uploaded_by, :path, 'extracted', + :num, :date, :type, :cat, :s_tin, :s_name, :s_addr, :b_tin, :b_name, :b_nid, + :sub, :tax, :disc, :total, :cur, NOW() + ) "); $stmt->execute([ - $invoiceId, - $tenantId, $companyId, $userId, $targetFile, - $extracted['invoice_number'] ?? null, - $extracted['invoice_date'] ?? null, - $extracted['invoice_type'] ?? 'cash', - $extracted['invoice_category'] ?? 'simplified', - // Encrypt sensitive details - \App\Core\Encryption::encrypt($extracted['supplier_tin'] ?? ''), - \App\Core\Encryption::encrypt($extracted['supplier_name'] ?? ''), - \App\Core\Encryption::encrypt($extracted['supplier_address'] ?? ''), - \App\Core\Encryption::encrypt($extracted['buyer_tin'] ?? ''), - \App\Core\Encryption::encrypt($extracted['buyer_name'] ?? ''), - \App\Core\Encryption::encrypt($extracted['buyer_national_id'] ?? ''), - $extracted['subtotal'] ?? 0, - $extracted['tax_amount'] ?? 0, - $extracted['discount_total'] ?? 0, - $extracted['grand_total'] ?? 0, - $extracted['currency'] ?? 'JOD' + 'id' => $invoiceId, + 'tenant_id' => $tenantId, + 'company_id' => $companyId, + 'uploaded_by'=> $userId, + 'path' => $targetFile, + 'num' => $extracted['invoice_number'] ?? null, + 'date' => $extracted['invoice_date'] ?? null, + 'type' => $extracted['invoice_type'] ?? 'cash', + 'cat' => $extracted['invoice_category'] ?? 'simplified', + 's_tin' => \App\Core\Encryption::encrypt($extracted['supplier_tin'] ?? ''), + 's_name' => \App\Core\Encryption::encrypt($extracted['supplier_name'] ?? ''), + 's_addr' => \App\Core\Encryption::encrypt($extracted['supplier_address'] ?? ''), + 'b_tin' => \App\Core\Encryption::encrypt($extracted['buyer_tin'] ?? ''), + 'b_name' => \App\Core\Encryption::encrypt($extracted['buyer_name'] ?? ''), + 'b_nid' => \App\Core\Encryption::encrypt($extracted['buyer_national_id'] ?? ''), + 'sub' => $extracted['subtotal'] ?? 0, + 'tax' => $extracted['tax_amount'] ?? 0, + 'disc' => $extracted['discount_total'] ?? 0, + 'total' => $extracted['grand_total'] ?? 0, + 'cur' => $extracted['currency'] ?? 'JOD' ]); // Save Line Items