INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) 
	VALUES('SiiTypeInvoiceIn', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson');

DROP TABLE IF EXISTS vn.invoiceInCorrection;

CREATE TABLE `invoiceInCorrection` (
	`correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa',
	`correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada',
	`cplusRectificationTypeFk` int(10) unsigned NOT NULL,
	`siiTypeInvoiceInFk` int(10) unsigned NOT NULL,
	`invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3,
	PRIMARY KEY (`correctingFk`),
	KEY `invoiceInCorrection_correctedFk` (`correctedFk`),
	KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`),
	KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`),
	KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`),
	CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
	CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
	CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE,
	CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE,
	CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

