--
-- Host: 127.0.0.1    Database: moonui2_dev_be
-- ------------------------------------------------------


--
-- Table structure for table `sales_invoices`
--

CREATE TABLE `sales_invoices` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint(20) unsigned NOT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  `invoice_number` varchar(255) DEFAULT NULL,
  `receipt_number` varchar(255) DEFAULT NULL,
  `receipt_barcode` varchar(255) DEFAULT NULL,
  `is_pos` tinyint(1) NOT NULL DEFAULT 0,
  `pos_session_id` bigint(20) unsigned DEFAULT NULL,
  `pos_terminal_id` bigint(20) unsigned DEFAULT NULL,
  `source` varchar(255) NOT NULL DEFAULT 'manual',
  `pos_idempotency_key` varchar(64) DEFAULT NULL,
  `date` date NOT NULL,
  `due_date` date DEFAULT NULL,
  `customer_id` bigint(20) unsigned NOT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `salesperson_id` bigint(20) unsigned DEFAULT NULL,
  `warehouse_id` bigint(20) unsigned DEFAULT NULL,
  `sales_order_id` bigint(20) unsigned DEFAULT NULL,
  `status` varchar(255) NOT NULL DEFAULT 'draft',
  `payment_status` varchar(255) NOT NULL DEFAULT 'pending',
  `reference` varchar(255) DEFAULT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `notes_ar` text DEFAULT NULL,
  `terms` text DEFAULT NULL,
  `terms_ar` text DEFAULT NULL,
  `currency_code` varchar(10) NOT NULL DEFAULT 'KWD',
  `exchange_rate` decimal(12,6) NOT NULL DEFAULT 1.000000,
  `payment_terms_days` int(11) NOT NULL DEFAULT 0,
  `subtotal` decimal(15,3) NOT NULL DEFAULT 0.000,
  `discount_amount` decimal(15,3) NOT NULL DEFAULT 0.000,
  `discount1_percent` decimal(8,3) DEFAULT NULL,
  `discount1_amount` decimal(15,3) DEFAULT NULL,
  `discount2_percent` decimal(8,3) DEFAULT NULL,
  `discount2_amount` decimal(15,3) DEFAULT NULL,
  `discount3_percent` decimal(8,3) DEFAULT NULL,
  `discount3_amount` decimal(15,3) DEFAULT NULL,
  `header_discount_amount` decimal(15,3) DEFAULT 0.000,
  `tax_amount` decimal(15,3) NOT NULL DEFAULT 0.000,
  `total` decimal(15,3) NOT NULL DEFAULT 0.000,
  `amount_paid` decimal(15,3) NOT NULL DEFAULT 0.000,
  `balance_due` decimal(15,3) NOT NULL DEFAULT 0.000,
  `journal_entry_id` bigint(20) unsigned DEFAULT NULL,
  `cogs_journal_entry_id` bigint(20) unsigned DEFAULT NULL,
  `cancel_journal_entry_id` bigint(20) unsigned DEFAULT NULL,
  `fulfillment_status` varchar(255) NOT NULL DEFAULT 'pending',
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `approved_by` bigint(20) unsigned DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `posted_by` bigint(20) unsigned DEFAULT NULL,
  `posted_at` timestamp NULL DEFAULT NULL,
  `cancelled_by` bigint(20) unsigned DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `cancellation_reason` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sales_invoices_company_id_invoice_number_unique` (`company_id`,`invoice_number`),
  UNIQUE KEY `sales_invoices_company_receipt_branch_unique` (`company_id`,`receipt_number`,`branch_id`),
  UNIQUE KEY `sales_invoices_company_pos_idempotency_unique` (`company_id`,`pos_idempotency_key`),
  KEY `sales_invoices_branch_id_foreign` (`branch_id`),
  KEY `sales_invoices_customer_id_foreign` (`customer_id`),
  KEY `sales_invoices_salesperson_id_foreign` (`salesperson_id`),
  KEY `sales_invoices_warehouse_id_foreign` (`warehouse_id`),
  KEY `sales_invoices_sales_order_id_foreign` (`sales_order_id`),
  KEY `sales_invoices_journal_entry_id_foreign` (`journal_entry_id`),
  KEY `sales_invoices_cogs_journal_entry_id_foreign` (`cogs_journal_entry_id`),
  KEY `sales_invoices_created_by_foreign` (`created_by`),
  KEY `sales_invoices_approved_by_foreign` (`approved_by`),
  KEY `sales_invoices_posted_by_foreign` (`posted_by`),
  KEY `sales_invoices_cancelled_by_foreign` (`cancelled_by`),
  KEY `sales_invoices_company_id_status_index` (`company_id`,`status`),
  KEY `sales_invoices_company_id_date_index` (`company_id`,`date`),
  KEY `sales_invoices_company_id_due_date_index` (`company_id`,`due_date`),
  KEY `sales_invoices_company_id_customer_id_index` (`company_id`,`customer_id`),
  KEY `sales_invoices_company_id_payment_status_index` (`company_id`,`payment_status`),
  KEY `sales_invoices_company_id_sales_order_id_index` (`company_id`,`sales_order_id`),
  KEY `sales_invoices_cancel_journal_entry_id_foreign` (`cancel_journal_entry_id`),
  KEY `sales_invoices_receipt_barcode_index` (`receipt_barcode`),
  KEY `sales_invoices_company_id_is_pos_index` (`company_id`,`is_pos`),
  KEY `sales_invoices_pos_session_id_foreign` (`pos_session_id`),
  KEY `sales_invoices_pos_terminal_id_foreign` (`pos_terminal_id`),
  KEY `sales_invoices_company_id_receipt_number_index` (`company_id`,`receipt_number`),
  CONSTRAINT `sales_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_cancel_journal_entry_id_foreign` FOREIGN KEY (`cancel_journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_cancelled_by_foreign` FOREIGN KEY (`cancelled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_cogs_journal_entry_id_foreign` FOREIGN KEY (`cogs_journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `sales_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `business_partners` (`id`),
  CONSTRAINT `sales_invoices_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_pos_session_id_foreign` FOREIGN KEY (`pos_session_id`) REFERENCES `pos_sessions` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_pos_terminal_id_foreign` FOREIGN KEY (`pos_terminal_id`) REFERENCES `pos_terminals` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_posted_by_foreign` FOREIGN KEY (`posted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_sales_order_id_foreign` FOREIGN KEY (`sales_order_id`) REFERENCES `sales_orders` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_salesperson_id_foreign` FOREIGN KEY (`salesperson_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sales_invoices`
--

INSERT INTO `sales_invoices` VALUES
(1,4,4,'INV-2026-00001','POS-2026-03-00001','POSPOS20260300001',1,2,1,'pos',NULL,'2026-03-25',NULL,2,NULL,NULL,1,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,650.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,650.000,0.000,650.000,NULL,NULL,NULL,'pending',3,3,'2026-03-25 12:16:59',3,'2026-03-25 12:16:59',NULL,NULL,NULL,'2026-03-25 12:16:59','2026-03-25 12:16:59',NULL),
(2,4,4,'INV-2026-00002','POS-2026-03-00002','POSPOS20260300002',1,2,1,'pos',NULL,'2026-03-25',NULL,2,NULL,NULL,1,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,744.950,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,744.950,0.000,744.950,NULL,NULL,NULL,'pending',3,3,'2026-03-25 12:17:25',3,'2026-03-25 12:17:25',NULL,NULL,NULL,'2026-03-25 12:17:25','2026-03-25 12:17:25',NULL),
(3,4,4,'INV-2026-00003','POS-2026-03-00003','POSPOS20260300003',1,2,1,'pos',NULL,'2026-03-25',NULL,2,NULL,NULL,1,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,744.950,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,744.950,744.950,0.000,NULL,NULL,NULL,'pending',3,3,'2026-03-25 12:26:08',3,'2026-03-25 12:26:08',NULL,NULL,NULL,'2026-03-25 12:26:08','2026-03-25 12:26:09',NULL),
(4,4,4,'INV-2026-00004','POS-2026-03-00004','POSPOS20260300004',1,2,1,'pos',NULL,'2026-03-25',NULL,4,NULL,NULL,1,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,65.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,65.000,0.000,65.000,NULL,NULL,NULL,'pending',3,3,'2026-03-25 12:35:38',3,'2026-03-25 12:35:38',NULL,NULL,NULL,'2026-03-25 12:35:38','2026-03-25 12:35:38',NULL),
(5,4,4,'INV-2026-00005','POS-2026-03-00005','POSPOS20260300005',1,2,1,'pos',NULL,'2026-03-25',NULL,2,NULL,NULL,1,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,130.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,130.000,0.000,130.000,NULL,NULL,NULL,'pending',3,3,'2026-03-25 12:37:23',3,'2026-03-25 12:37:23',NULL,NULL,NULL,'2026-03-25 12:37:23','2026-03-25 12:37:23',NULL),
(6,4,NULL,'INV-2026-00006',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-04-28','2026-05-28',5,NULL,NULL,NULL,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'EG',1.000000,30,95.000,5.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,95.000,95.000,0.000,NULL,NULL,NULL,'pending',3,3,'2026-04-28 16:09:29',3,'2026-04-28 16:09:30',NULL,NULL,NULL,'2026-04-28 16:09:27','2026-06-20 16:06:04',NULL),
(8,4,NULL,'INV-2026-00008',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-18','2026-07-18',26,NULL,NULL,NULL,7,'approved','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,3000.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,3000.000,0.000,3000.000,NULL,NULL,NULL,'pending',3,3,'2026-06-18 18:31:39',NULL,NULL,NULL,NULL,NULL,'2026-06-18 18:31:23','2026-06-18 18:31:39',NULL),
(9,4,NULL,'INV-2026-00009',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-20','2026-07-20',26,NULL,NULL,NULL,NULL,'partially_paid','partial',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,1100.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,1100.000,500.000,600.000,493,NULL,NULL,'pending',3,3,'2026-06-20 01:32:29',3,'2026-06-20 01:32:30',NULL,NULL,NULL,'2026-06-20 01:32:28','2026-06-22 19:42:57',NULL),
(10,4,NULL,'INV-2026-00010',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-22','2026-07-22',61,NULL,NULL,10,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,360.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,360.000,0.000,360.000,518,NULL,NULL,'fully_delivered',3,3,'2026-06-22 20:32:29',3,'2026-06-22 20:32:30',NULL,NULL,NULL,'2026-06-22 20:32:27','2026-07-14 23:18:25',NULL),
(11,4,NULL,'INV-2026-00011',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-23','2026-07-23',61,NULL,NULL,12,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,200.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,200.000,200.000,0.000,519,NULL,NULL,'pending',3,3,'2026-06-23 01:40:40',3,'2026-06-23 01:40:40',NULL,NULL,NULL,'2026-06-23 01:40:38','2026-06-23 01:42:20',NULL),
(12,4,NULL,'INV-2026-00012',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-23','2026-07-20',26,NULL,NULL,NULL,NULL,'draft','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,1100.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,1100.000,0.000,1100.000,NULL,NULL,NULL,'pending',3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-23 02:29:52','2026-06-23 02:29:53',NULL),
(13,4,NULL,'INV-2026-00013',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-23','2026-07-23',61,NULL,NULL,12,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,720.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,720.000,720.000,0.000,521,NULL,NULL,'fully_delivered',3,3,'2026-06-23 02:30:21',3,'2026-06-23 02:30:22',NULL,NULL,NULL,'2026-06-23 02:30:20','2026-07-14 23:18:22',NULL),
(14,4,NULL,'INV-2026-00014',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-06-23','2026-07-23',61,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,40.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,40.000,40.000,0.000,523,NULL,NULL,'fully_delivered',3,3,'2026-06-23 17:10:20',3,'2026-06-23 17:10:21',NULL,NULL,NULL,'2026-06-23 17:10:18','2026-07-14 23:18:19',NULL),
(15,4,NULL,'INV-2026-00015',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-12','2026-08-11',61,NULL,NULL,13,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,720.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,720.000,720.000,0.000,547,NULL,NULL,'fully_delivered',26,26,'2026-07-12 01:04:59',26,'2026-07-12 01:05:00',NULL,NULL,NULL,'2026-07-12 01:04:58','2026-07-12 01:06:40',NULL),
(16,4,NULL,'INV-2026-00016',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-14','2026-08-13',61,NULL,NULL,NULL,11,'approved','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,600.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,600.000,0.000,600.000,NULL,NULL,NULL,'pending',26,26,'2026-07-16 20:35:51',NULL,NULL,NULL,NULL,NULL,'2026-07-14 22:34:59','2026-07-16 20:35:51',NULL),
(17,4,NULL,'INV-2026-00017',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-14','2026-08-13',61,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,120.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,120.000,120.000,0.000,552,NULL,NULL,'pending',26,26,'2026-07-14 23:38:37',26,'2026-07-14 23:38:38',NULL,NULL,NULL,'2026-07-14 23:38:36','2026-07-14 23:38:39',NULL),
(18,4,NULL,'INV-2026-00018',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-17','2026-08-16',61,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,98.000,0.000,NULL,NULL,NULL,NULL,NULL,NULL,0.000,0.000,98.000,98.000,0.000,561,NULL,NULL,'fully_delivered',26,26,'2026-07-17 12:28:12',26,'2026-07-17 12:28:13',NULL,NULL,NULL,'2026-07-17 12:28:10','2026-07-17 12:30:20',NULL),
(19,4,NULL,'INV-2026-00019',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-17','2026-08-16',65,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,2000.000,0.000,10.000,200.000,5.000,90.000,5.000,85.500,375.500,0.000,1624.500,1624.500,0.000,566,NULL,NULL,'fully_delivered',26,26,'2026-07-17 23:47:59',26,'2026-07-17 23:48:01',NULL,NULL,NULL,'2026-07-17 23:47:57','2026-07-18 17:10:56',NULL),
(20,4,NULL,'INV-2026-00020',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-18','2026-08-17',61,NULL,NULL,10,NULL,'cancelled','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,200.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,200.000,0.000,0.000,NULL,NULL,NULL,'pending',26,26,'2026-07-18 16:13:23',NULL,NULL,26,'2026-07-18 17:03:58',NULL,'2026-07-18 15:53:40','2026-07-18 17:03:58',NULL),
(21,4,NULL,'INV-2026-00021',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-18','2026-08-17',61,NULL,28,10,NULL,'partially_paid','partial',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,1800.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,1800.000,190.000,1610.000,568,NULL,NULL,'pending',26,26,'2026-07-18 17:07:16',26,'2026-07-18 17:07:17',NULL,NULL,NULL,'2026-07-18 17:06:57','2026-07-18 17:07:28',NULL),
(22,4,NULL,'INV-2026-00022',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-18','2026-08-17',61,NULL,NULL,10,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,400.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,400.000,0.000,400.000,571,NULL,NULL,'pending',26,26,'2026-07-18 18:04:41',26,'2026-07-18 18:04:42',NULL,NULL,NULL,'2026-07-18 18:04:40','2026-07-18 18:04:42',NULL),
(23,4,NULL,'INV-2026-00023',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-18','2026-08-17',61,NULL,28,10,NULL,'posted','pending',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,200.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,200.000,0.000,200.000,572,NULL,NULL,'pending',26,26,'2026-07-18 18:55:02',26,'2026-07-18 18:55:04',NULL,NULL,NULL,'2026-07-18 18:55:01','2026-07-18 18:55:04',NULL),
(24,4,NULL,'INV-2026-00024',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-28','2026-08-27',61,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,60.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,60.000,60.000,0.000,581,NULL,NULL,'fully_delivered',26,26,'2026-07-28 13:15:48',26,'2026-07-28 13:15:49',NULL,NULL,NULL,'2026-07-28 13:15:47','2026-07-28 13:16:18',NULL),
(25,4,NULL,'INV-2026-00025',NULL,NULL,0,NULL,NULL,'manual',NULL,'2026-07-29','2026-08-28',61,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'SAR',1.000000,30,10.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,10.000,10.000,0.000,585,NULL,NULL,'pending',26,26,'2026-07-29 02:48:47',26,'2026-07-29 02:48:48',NULL,NULL,NULL,'2026-07-29 02:48:46','2026-07-29 02:48:49',NULL),
(26,4,5,'INV-2026-00026','POS-2026-08-00001','POSPOS20260800001',1,3,2,'pos',NULL,'2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,20.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,20.000,20.000,0.000,588,589,NULL,'pending',26,26,'2026-08-01 19:00:22',26,'2026-08-01 19:00:27',NULL,NULL,NULL,'2026-08-01 19:00:22','2026-08-01 19:00:29',NULL),
(27,4,5,'INV-2026-00027','POS-2026-08-00002','POSPOS20260800002',1,3,2,'pos',NULL,'2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,64.000,16.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,64.000,64.000,0.000,591,592,NULL,'pending',26,26,'2026-08-01 19:01:35',26,'2026-08-01 19:01:40',NULL,NULL,NULL,'2026-08-01 19:01:35','2026-08-01 19:01:42',NULL),
(28,4,5,'INV-2026-00028','POS-2026-08-00003','POSPOS20260800003',1,3,2,'pos',NULL,'2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,20.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,20.000,20.000,0.000,594,595,NULL,'pending',26,26,'2026-08-01 19:01:52',26,'2026-08-01 19:01:57',NULL,NULL,NULL,'2026-08-01 19:01:52','2026-08-01 19:01:59',NULL),
(29,4,5,'INV-2026-00029','POS-2026-08-00004','POSPOS20260800004',1,3,2,'pos',NULL,'2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,20.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,20.000,20.000,0.000,597,598,NULL,'pending',26,26,'2026-08-01 19:02:12',26,'2026-08-01 19:02:17',NULL,NULL,NULL,'2026-08-01 19:02:12','2026-08-01 19:02:19',NULL),
(30,4,5,'INV-2026-00030','POS-2026-08-00005','POSPOS20260800005',1,4,2,'pos','5f5068dc-29e8-4b87-9970-e812756d1f9a','2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,60.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,60.000,60.000,0.000,600,601,NULL,'pending',26,26,'2026-08-01 22:05:00',26,'2026-08-01 22:05:09',NULL,NULL,NULL,'2026-08-01 22:05:00','2026-08-01 22:05:11',NULL),
(31,4,5,'INV-2026-00031','POS-2026-08-00006','POSPOS20260800006',1,4,2,'pos','e7fa2de7-87a6-43ba-8f86-a2c98342f15f','2026-08-01',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,40.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,40.000,40.000,0.000,603,604,NULL,'pending',26,26,'2026-08-01 22:51:53',26,'2026-08-01 22:51:55',NULL,NULL,NULL,'2026-08-01 22:51:53','2026-08-01 22:51:55',NULL),
(32,4,5,'INV-2026-00032','POS-2026-08-00007','POSPOS20260800007',1,6,2,'pos','ac06b2cf-905c-410c-911f-e2433329d8a7','2026-08-02',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,40.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,40.000,40.000,0.000,606,607,NULL,'pending',26,26,'2026-08-02 04:19:54',26,'2026-08-02 04:19:56',NULL,NULL,NULL,'2026-08-02 04:19:54','2026-08-02 04:19:57',NULL),
(33,4,5,'INV-2026-00033','POS-2026-08-00008','POSPOS20260800008',1,7,2,'pos','592953b9-04e9-4631-8819-2ba91ceae1d2','2026-08-02',NULL,2,NULL,NULL,10,NULL,'paid','paid',NULL,NULL,NULL,NULL,NULL,NULL,'KWD',1.000000,0,440.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,440.000,440.000,0.000,609,610,NULL,'pending',26,26,'2026-08-02 15:02:36',26,'2026-08-02 15:02:41',NULL,NULL,NULL,'2026-08-02 15:02:36','2026-08-02 15:02:43',NULL);

--
-- Table structure for table `bank_accounts`
--

CREATE TABLE `bank_accounts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint(20) unsigned NOT NULL,
  `bank_name` varchar(255) NOT NULL,
  `bank_name_ar` varchar(255) DEFAULT NULL,
  `account_number` varchar(255) NOT NULL,
  `iban` varchar(255) DEFAULT NULL,
  `swift_code` varchar(255) DEFAULT NULL,
  `currency_id` bigint(20) unsigned DEFAULT NULL,
  `account_id` bigint(20) unsigned NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `bank_accounts_company_id_foreign` (`company_id`),
  KEY `bank_accounts_currency_id_foreign` (`currency_id`),
  KEY `bank_accounts_account_id_foreign` (`account_id`),
  CONSTRAINT `bank_accounts_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
  CONSTRAINT `bank_accounts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `bank_accounts_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bank_accounts`
--

INSERT INTO `bank_accounts` VALUES
(1,4,'بنك مصر','بنك مصر','32543253215432',NULL,NULL,NULL,66,1,'2026-03-25 11:16:13','2026-05-31 13:59:43','2026-05-31 13:59:43'),
(2,4,'NBE Lab Test','الأهلي تجريبي','123456789',NULL,NULL,NULL,212,1,'2026-05-30 05:22:28','2026-05-30 05:22:52','2026-05-30 05:22:52'),
(3,4,'CIB',NULL,'11115555',NULL,NULL,7,255,1,'2026-06-18 14:32:01','2026-06-18 14:32:01',NULL);

--
-- Table structure for table `currencies`
--

CREATE TABLE `currencies` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint(20) unsigned NOT NULL,
  `code` varchar(10) NOT NULL COMMENT 'ISO 4217',
  `name` varchar(255) NOT NULL,
  `name_ar` varchar(255) NOT NULL,
  `symbol` varchar(10) NOT NULL,
  `decimals` tinyint(3) unsigned NOT NULL DEFAULT 2,
  `is_base` tinyint(1) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `currencies_company_id_code_unique` (`company_id`,`code`),
  CONSTRAINT `currencies_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `currencies`
--

INSERT INTO `currencies` VALUES
(1,4,'KWD','Kuwaiti Dinar','دينار كويتي','د.ك',2,0,1,'2026-02-18 20:51:55','2026-02-18 20:51:55',NULL),
(2,4,'USD','US Dollar','دولار أمريكي','$',2,0,1,'2026-02-18 23:04:49','2026-02-18 23:04:51','2026-02-18 23:04:51'),
(6,4,'EUR','Euro','يورو','E',2,0,1,'2026-02-18 23:53:03','2026-06-20 00:27:05',NULL),
(7,4,'EG','جنيه','جنيه','EG',2,0,0,'2026-02-19 18:14:18','2026-04-27 08:39:45',NULL),
(8,4,'EGP','جنيه مصري','جنيه مصري','ج.م',2,0,0,'2026-02-27 23:23:06','2026-04-27 08:39:36',NULL),
(9,4,'SAR','ريال سعودى','ريال سعودى','SAR',2,1,1,'2026-04-27 08:39:21','2026-06-20 00:27:05',NULL);


