This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
softn-generating-receipt.sql
99 lines (85 loc) · 3.82 KB
/
softn-generating-receipt.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
-- -----------------------------------------------------
-- Table `clients`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `clients` (
`id` INT NOT NULL AUTO_INCREMENT,
`client_name` VARCHAR(37) NOT NULL,
`client_address` VARCHAR(37) NULL,
`client_identification_document` VARCHAR(10) NOT NULL,
`client_city` VARCHAR(37) NULL,
`client_number_receipts` INT NULL DEFAULT 0,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `products` (
`id` INT NOT NULL AUTO_INCREMENT,
`product_name` VARCHAR(37) NOT NULL,
`product_price_unit` DECIMAL(10,2) NOT NULL,
`product_reference` VARCHAR(6) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `receipts`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `receipts` (
`id` INT NOT NULL AUTO_INCREMENT,
`receipt_type` VARCHAR(20) NOT NULL,
`receipt_number` INT NULL,
`receipt_date` DATE NOT NULL,
`receipt_license_plate` VARCHAR(20) NULL,
`client_id` INT NOT NULL,
PRIMARY KEY (`id`, `client_id`),
CONSTRAINT `fk_Receipts_Clients`
FOREIGN KEY (`client_id`)
REFERENCES `clients` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Receipts_Clients_id` ON `receipts` (`client_id` ASC);
-- -----------------------------------------------------
-- Table `options`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `options` (
`id` INT NOT NULL AUTO_INCREMENT,
`option_key` VARCHAR(45) NULL,
`option_value` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
CREATE UNIQUE INDEX `option_key_UNIQUE` ON `options` (`option_key` ASC);
-- -----------------------------------------------------
-- Table `receipts_has_products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `receipts_has_products` (
`receipt_id` INT NOT NULL,
`product_id` INT NOT NULL,
`receipt_product_unit` INT NOT NULL DEFAULT 1,
PRIMARY KEY (`receipt_id`, `product_id`),
CONSTRAINT `fk_Receipts_has_Products_Receipt`
FOREIGN KEY (`receipt_id`)
REFERENCES `receipts` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `fk_Receipts_has_Products_Product`
FOREIGN KEY (`product_id`)
REFERENCES `products` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Receipts_has_Products_Product_id` ON `receipts_has_products` (`product_id` ASC);
CREATE INDEX `fk_Receipts_has_Products_Receipt_id` ON `receipts_has_products` (`receipt_id` ASC);
-- -----------------------------------------------------
-- Data for table `options`
-- -----------------------------------------------------
START TRANSACTION;
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_name', 'Nicolas');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_identification_document', '55588414J');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_address', '1261 Aliquam Avenue');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_phone_number', '1234567890');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_web_site', 'http://www.softn.red/');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('option_iva', '21');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('setting_date_format', 'd/m/Y');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('setting_pagination_number_row_show', '5');
INSERT INTO `options` (`option_key`, `option_value`) VALUES ('setting_invoice_background_image', 'http://localhost/softn-generating-receipt/public/assets/images/facturaFondo.png');
COMMIT;