-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 06, 2026 at 12:05 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `paymentpack`
--

-- --------------------------------------------------------

--
-- Table structure for table `receipts`
--

CREATE TABLE `receipts` (
  `id` int(11) NOT NULL,
  `DemanderCode_str` varchar(50) DEFAULT NULL,
  `Demander` varchar(255) DEFAULT NULL,
  `OrderNo_str` varchar(100) DEFAULT NULL,
  `InvoiceNo_str` varchar(100) NOT NULL,
  `ReceiptNo_str` varchar(100) DEFAULT NULL,
  `OrderActivatedDate` date DEFAULT NULL,
  `ReceivedDate` date DEFAULT NULL,
  `NSN_str` varchar(50) DEFAULT NULL,
  `ICN_str` varchar(50) DEFAULT NULL,
  `packDescription_Str` text DEFAULT NULL,
  `QtyOrdered_int` int(11) DEFAULT 0,
  `QtyReceived_int` int(11) DEFAULT 0,
  `BatchNumber_str` varchar(50) DEFAULT NULL,
  `Expiry_dat` date DEFAULT NULL,
  `PackCost_mon` decimal(10,2) DEFAULT 0.00,
  `TotalCost_mon` decimal(10,2) DEFAULT 0.00,
  `Supplier_str` varchar(255) DEFAULT NULL,
  `OrderType` varchar(50) DEFAULT NULL,
  `Complete` varchar(10) DEFAULT NULL,
  `facility` varchar(255) DEFAULT NULL,
  `district` varchar(255) DEFAULT NULL,
  `uploaded_by` varchar(255) DEFAULT NULL,
  `del_point` varchar(7) DEFAULT NULL,
  `upload_month` varchar(7) DEFAULT NULL,
  `upload_date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--- Triggers `receipts`
--
DELIMITER $$
CREATE TRIGGER `before_insert_receipts_paymentpack` BEFORE INSERT ON `receipts` FOR EACH ROW BEGIN
    IF NEW.upload_month IS NULL THEN
        SET NEW.upload_month = DATE_FORMAT(NEW.upload_date, '%Y-%m');
    END IF;
END
$$
DELIMITER ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `receipts`
--
ALTER TABLE `receipts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_invoice` (`InvoiceNo_str`),
  ADD KEY `idx_facility_month` (`facility`,`upload_month`),
  ADD KEY `idx_del_point` (`del_point`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `receipts`
--
ALTER TABLE `receipts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4170;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
