-- MySQL Backup
-- Host: localhost
-- Database: sonali_db
-- Backup Time: 2026-08-13 04:45:15

DROP TABLE IF EXISTS `customers`;

CREATE TABLE `customers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(191) NOT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('1', 'বিপুল - বাজার', '', '', '2025-12-07 14:29:02');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('2', 'আলী - আলাদা হিসাব\n', '', '', '2025-12-17 12:19:28');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('3', 'সুজন জামাই', '', '', '2025-12-26 12:15:41');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('4', 'রহমান - বাজার\n', '', '', '2025-12-26 13:31:54');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('5', 'সরকার - বাজার\n', '', '', '2025-12-26 13:32:02');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('6', 'বস অর্ডার', '', NULL, '2026-03-26 13:12:56');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('7', 'দুলাল', '', NULL, '2026-04-05 11:40:46');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('8', 'মনির সরকার - আলাদা', '', NULL, '2026-04-14 14:46:25');
INSERT INTO `customers` (`id`, `name`, `phone`, `note`, `created_at`) VALUES ('9', 'ফরহাদ - আলাদা', '', NULL, '2026-07-02 13:01:10');

DROP TABLE IF EXISTS `transactions`;

CREATE TABLE `transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_id` int(11) NOT NULL,
  `type` enum('due','payment') NOT NULL,
  `kg` decimal(12,3) DEFAULT NULL,
  `rate` decimal(12,2) DEFAULT NULL,
  `amount` decimal(14,2) NOT NULL,
  `note` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `customer_id` (`customer_id`),
  CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=389 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `transactions` (`id`, `customer_id`, `type`, `kg`, `rate`, `amount`, `note`, `created_at`) VALUES ('387', '1', 'due', '76.000', '285.00', '21660.00', '', '2026-08-12 12:50:51');
INSERT INTO `transactions` (`id`, `customer_id`, `type`, `kg`, `rate`, `amount`, `note`, `created_at`) VALUES ('388', '1', 'payment', '0.000', '0.00', '20000.00', '', '2026-08-12 15:08:12');

