diff --git a/app/core/JoFotara.php b/app/core/JoFotara.php new file mode 100644 index 0000000..cc8bf1f --- /dev/null +++ b/app/core/JoFotara.php @@ -0,0 +1,72 @@ +clientId = env('JOFOTARA_CLIENT_ID', ''); + $this->secretKey = env('JOFOTARA_SECRET', ''); + $this->environment = env('JOFOTARA_ENV', 'sandbox'); // sandbox or production + } + + /** + * 1. Generate UBL 2.1 XML for an invoice + */ + public function generateXML(array $invoiceData): string + { + // To be implemented: Full XML DOM Document generation based on UBL 2.1 schema + // This will map $invoiceData (Supplier, Buyer, Lines, Taxes) to exact XML nodes. + return "This will be full UBL 2.1 XML"; + } + + /** + * 2. Generate Base64 TLV QR Code (required by Jordan Tax Authority) + * Tag 1: Seller Name + * Tag 2: Tax Number + * Tag 3: Timestamp + * Tag 4: Invoice Total + * Tag 5: VAT Total + */ + public function generateQRCode(array $invoiceData): string + { + $sellerName = $invoiceData['supplier_name'] ?? ''; + $taxNumber = $invoiceData['supplier_tin'] ?? ''; + $timestamp = date('Y-m-d\TH:i:s\Z', strtotime($invoiceData['invoice_date'] ?? 'now')); + $total = number_format($invoiceData['grand_total'] ?? 0, 3, '.', ''); + $vat = number_format($invoiceData['tax_amount'] ?? 0, 3, '.', ''); + + $tlv = $this->toTLV(1, $sellerName) . + $this->toTLV(2, $taxNumber) . + $this->toTLV(3, $timestamp) . + $this->toTLV(4, $total) . + $this->toTLV(5, $vat); + + return base64_encode($tlv); + } + + private function toTLV(int $tag, string $value): string + { + return chr($tag) . chr(strlen($value)) . $value; + } + + /** + * 3. Submit Invoice to JoFotara API + */ + public function submitInvoice(string $xmlContent): array + { + // To be implemented: cURL request to JoFotara Core API + // Requires ECDSA signing of the XML before submission + return ['success' => true, 'uuid' => 'dummy-jofotara-id']; + } +} diff --git a/public/shell.php b/public/shell.php index 3f3bcad..c23ff08 100644 --- a/public/shell.php +++ b/public/shell.php @@ -133,7 +133,94 @@ - + +
+
+
+
📄
+

إجمالي الفواتير

+

+
+
+
+

قيد المعالجة

+

+
+
+
+

تم الاعتماد

+

+
+
+
+ + +
+
+ + + + + + + + + + + + + + +
الشركةالأرقام الرسميةالعنوانالمكتبإجراءات
لا توجد شركات بعد
+
+
+ + +
+
+ + + + + + + + + + + + + + +
المستخدمالمكتبالدورالحالةإجراءات
لا يوجد مستخدمون بعد
+
+
@@ -247,7 +334,58 @@ - + +
+
+

رفع فواتير جديدة 📤

+

سيقوم النظام باستخراج البيانات آلياً باستخدام الذكاء الاصطناعي

+
+
+ + +
+
+ +
+ 📄 +

+

PDF, PNG, JPG (Max 5MB)

+
+
+
+ + +
+
+
+
+ + +
+
+

إضافة مستخدم جديد 👥

+
+
+
+
+
+ +
+
+ + +
+
+
+