Update: 2026-05-04 02:14:03

This commit is contained in:
Hamza-Ayed
2026-05-04 02:14:03 +03:00
parent 303205d52d
commit 3ff2d8d8e1

View File

@@ -91,28 +91,34 @@ if (move_uploaded_file($_FILES['invoice']['tmp_name'], $targetFile)) {
buyer_tin, buyer_name, buyer_national_id, buyer_tin, buyer_name, buyer_national_id,
subtotal, tax_amount, discount_total, grand_total, currency_code, subtotal, tax_amount, discount_total, grand_total, currency_code,
created_at 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([ $stmt->execute([
$invoiceId, 'id' => $invoiceId,
$tenantId, $companyId, $userId, $targetFile, 'tenant_id' => $tenantId,
$extracted['invoice_number'] ?? null, 'company_id' => $companyId,
$extracted['invoice_date'] ?? null, 'uploaded_by'=> $userId,
$extracted['invoice_type'] ?? 'cash', 'path' => $targetFile,
$extracted['invoice_category'] ?? 'simplified', 'num' => $extracted['invoice_number'] ?? null,
// Encrypt sensitive details 'date' => $extracted['invoice_date'] ?? null,
\App\Core\Encryption::encrypt($extracted['supplier_tin'] ?? ''), 'type' => $extracted['invoice_type'] ?? 'cash',
\App\Core\Encryption::encrypt($extracted['supplier_name'] ?? ''), 'cat' => $extracted['invoice_category'] ?? 'simplified',
\App\Core\Encryption::encrypt($extracted['supplier_address'] ?? ''), 's_tin' => \App\Core\Encryption::encrypt($extracted['supplier_tin'] ?? ''),
\App\Core\Encryption::encrypt($extracted['buyer_tin'] ?? ''), 's_name' => \App\Core\Encryption::encrypt($extracted['supplier_name'] ?? ''),
\App\Core\Encryption::encrypt($extracted['buyer_name'] ?? ''), 's_addr' => \App\Core\Encryption::encrypt($extracted['supplier_address'] ?? ''),
\App\Core\Encryption::encrypt($extracted['buyer_national_id'] ?? ''), 'b_tin' => \App\Core\Encryption::encrypt($extracted['buyer_tin'] ?? ''),
$extracted['subtotal'] ?? 0, 'b_name' => \App\Core\Encryption::encrypt($extracted['buyer_name'] ?? ''),
$extracted['tax_amount'] ?? 0, 'b_nid' => \App\Core\Encryption::encrypt($extracted['buyer_national_id'] ?? ''),
$extracted['discount_total'] ?? 0, 'sub' => $extracted['subtotal'] ?? 0,
$extracted['grand_total'] ?? 0, 'tax' => $extracted['tax_amount'] ?? 0,
$extracted['currency'] ?? 'JOD' 'disc' => $extracted['discount_total'] ?? 0,
'total' => $extracted['grand_total'] ?? 0,
'cur' => $extracted['currency'] ?? 'JOD'
]); ]);
// Save Line Items // Save Line Items