# ************************************************************
# Sequel Pro SQL dump
# Versão 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: enovo.pt (MySQL 5.7.32)
# Base de Dados: asfaltol_master
# Tempo de Geração: 2020-12-03 23:00:59 +0000
# ************************************************************


/*!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 utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


# Dump da tabela purchase_invoices
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_invoices`;

CREATE TABLE `purchase_invoices` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type_id` int(10) unsigned DEFAULT NULL,
  `target` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `target_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `assigned_targets` text COLLATE utf8_unicode_ci,
  `source` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `gateway` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `provider_id` int(10) unsigned NOT NULL,
  `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_id` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_series` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_series_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `reference` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `subtotal` decimal(10,2) DEFAULT NULL,
  `vat_total` decimal(10,2) DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `total_discount` decimal(10,2) DEFAULT NULL,
  `total_unpaid` decimal(10,2) DEFAULT NULL,
  `irs_tax` decimal(10,2) DEFAULT NULL,
  `rounding_value` decimal(10,2) DEFAULT NULL,
  `currency` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_condition` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_date` date DEFAULT NULL,
  `payment_method` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_code` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `vat` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_zip_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_country` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
  `billing_email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `obs` text COLLATE utf8_unicode_ci,
  `filepath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `filename` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `is_draft` tinyint(1) NOT NULL DEFAULT '0',
  `is_settle` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
  `ignore_stats` tinyint(1) NOT NULL DEFAULT '0',
  `is_scheduled` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_invoices_customer_id_foreign` (`provider_id`),
  KEY `purchase_invoices_target_index` (`target`),
  KEY `purchase_invoices_target_id_index` (`target_id`),
  KEY `purchase_invoices_source_index` (`source`),
  KEY `purchase_invoices_gateway_index` (`gateway`),
  KEY `purchase_invoice_type_id_foreign` (`type_id`),
  CONSTRAINT `purchase_invoice_provider_id_foreign` FOREIGN KEY (`provider_id`) REFERENCES `providers` (`id`),
  CONSTRAINT `purchase_invoice_type_id_foreign` FOREIGN KEY (`type_id`) REFERENCES `purchase_invoices_types` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



# Dump da tabela purchase_invoices_lines
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_invoices_lines`;

CREATE TABLE `purchase_invoices_lines` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` int(10) unsigned DEFAULT NULL,
  `key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `reference` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `total_price` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `subtotal` decimal(10,2) DEFAULT NULL,
  `tax_rate` decimal(10,2) DEFAULT NULL,
  `exemption_reason` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
  `exemption_reason_code` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
  `hidden` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_invoices_lines_invoice_id_foreign_key` (`invoice_id`),
  CONSTRAINT `purchase_invoices_lines_invoice_id_foreign_key` FOREIGN KEY (`invoice_id`) REFERENCES `purchase_invoices` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



# Dump da tabela purchase_invoices_types
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_invoices_types`;

CREATE TABLE `purchase_invoices_types` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `source` varchar(50) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `is_static` tinyint(1) NOT NULL DEFAULT '0',
  `color` varchar(10) DEFAULT NULL,
  `target_type` varchar(50) DEFAULT NULL,
  `sort` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

LOCK TABLES `purchase_invoices_types` WRITE;
/*!40000 ALTER TABLE `purchase_invoices_types` DISABLE KEYS */;

INSERT INTO `purchase_invoices_types` (`id`, `source`, `name`, `is_static`, `color`, `target_type`, `sort`, `created_at`, `updated_at`, `deleted_at`)
VALUES
	(1,NULL,'Subcontratação Transportes',0,NULL,'Shipment',1,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(2,NULL,'Abastecimentos',0,NULL,'Vehicle',2,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(3,NULL,'Oficinas e Manutenções',0,NULL,'Vehicle',3,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(4,NULL,'Seguros e Finanças Auto',0,NULL,'Vehicle',4,'2020-08-17 16:44:10','2020-09-18 11:21:45',NULL),
	(5,NULL,'Alugueres e Rentings',0,NULL,'Vehicle',5,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(6,NULL,'Custos Administrativos',0,NULL,NULL,6,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(7,NULL,'Ordenados',0,NULL,'User',7,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(8,NULL,'Água, Luz e Gás',0,NULL,NULL,8,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(9,NULL,'Despesas Informáticas',0,NULL,NULL,9,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(10,NULL,'Despesas Diversas',0,NULL,NULL,10,'2020-08-17 16:44:10','2020-08-17 16:44:10',NULL),
	(11,NULL,'Seguros e Finanças Motoristas',0,NULL,'User',11,'2020-09-18 11:22:05','2020-09-18 11:22:05',NULL);

/*!40000 ALTER TABLE `purchase_invoices_types` ENABLE KEYS */;
UNLOCK TABLES;


# Dump da tabela purchase_payment_note_invoices
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_payment_note_invoices`;

CREATE TABLE `purchase_payment_note_invoices` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `payment_note_id` int(10) unsigned DEFAULT NULL,
  `invoice_id` int(10) unsigned DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_payment_note_invoice_fk` (`invoice_id`),
  KEY `purchase_payment_note_payment_id_fk` (`payment_note_id`),
  CONSTRAINT `purchase_payment_note_invoice_fk` FOREIGN KEY (`invoice_id`) REFERENCES `purchase_invoices` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump da tabela purchase_payment_note_methods
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_payment_note_methods`;

CREATE TABLE `purchase_payment_note_methods` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `payment_note_id` int(10) unsigned DEFAULT NULL,
  `method` varchar(25) DEFAULT NULL,
  `bank` varchar(50) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `obs` varchar(500) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_payment_method_payment_id_foreign` (`payment_note_id`),
  CONSTRAINT `purchase_payment_method_payment_id_foreign` FOREIGN KEY (`payment_note_id`) REFERENCES `purchase_payment_notes` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump da tabela purchase_payment_notes
# ------------------------------------------------------------

DROP TABLE IF EXISTS `purchase_payment_notes`;

CREATE TABLE `purchase_payment_notes` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `source` varchar(255) DEFAULT NULL,
  `code` varchar(12) DEFAULT NULL,
  `provider_id` int(10) unsigned DEFAULT NULL,
  `vat` varchar(255) DEFAULT NULL,
  `billing_code` varchar(255) DEFAULT NULL,
  `billing_name` varchar(255) DEFAULT NULL,
  `billing_address` varchar(255) DEFAULT NULL,
  `billing_zip_code` varchar(255) DEFAULT NULL,
  `billing_city` varchar(255) DEFAULT NULL,
  `billing_country` varchar(5) DEFAULT NULL,
  `doc_id` varchar(20) DEFAULT NULL,
  `doc_date` date DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!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 */;
