CREATE TABLE `financeiro_contas_fornecedores` (
    `id`                          INT(10) UNSIGNED                     NOT NULL AUTO_INCREMENT,

    -- req
    `nome`                        VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
    `data`                        DATE                                 NOT NULL,
    `pago`                        TINYINT(1)                           NOT NULL DEFAULT '0',
    `valor`                       INT(11)                              NOT NULL,

    -- null
    `forma_pagamento`             VARCHAR(255) COLLATE utf8_unicode_ci          DEFAULT NULL,
    `nota_fiscal`                 VARCHAR(255) COLLATE utf8_unicode_ci          DEFAULT NULL,
    `boleto`                      VARCHAR(255) COLLATE utf8_unicode_ci          DEFAULT NULL,
    `comprovante`                 VARCHAR(255) COLLATE utf8_unicode_ci          DEFAULT NULL,
    `fornecedor_id`               INT(10) UNSIGNED                              DEFAULT NULL,
    `conta_id`                    INT(10) UNSIGNED                              DEFAULT NULL,
    `plano_de_contas_id`          INT(10) UNSIGNED                              DEFAULT NULL,
    `centros_de_custo_cadaris_id` INT(10) UNSIGNED                              DEFAULT NULL,
    `created_at`                  TIMESTAMP                            NULL     DEFAULT NULL,
    `updated_at`                  TIMESTAMP                            NULL     DEFAULT NULL,

    PRIMARY KEY (`id`),
    KEY `financeiro_contas_fornecedores_fornecedor_id_foreign`(`fornecedor_id`),
    KEY `financeiro_contas_fornecedores_conta_id_foreign`(`conta_id`),
    KEY `financeiro_cf_cdcc_fk`(`centros_de_custo_cadaris_id`),
    KEY `financeiro_cf_pdc_fk`(`plano_de_contas_id`),
    CONSTRAINT `financeiro_cf_cdcc_fk` FOREIGN KEY (`centros_de_custo_cadaris_id`) REFERENCES `cadastro_centros_de_custo_cadaris`(`id`) ON DELETE SET NULL,
    CONSTRAINT `financeiro_cf_pdc_fk` FOREIGN KEY (`plano_de_contas_id`) REFERENCES `cadastro_plano_de_contas_itens`(`id`) ON DELETE SET NULL,
    CONSTRAINT `financeiro_contas_fornecedores_conta_id_foreign` FOREIGN KEY (`conta_id`) REFERENCES `financeiro_contas_bancarias`(`id`) ON DELETE SET NULL,
    CONSTRAINT `financeiro_contas_fornecedores_fornecedor_id_foreign` FOREIGN KEY (`fornecedor_id`) REFERENCES `fornecedores_empresas`(`id`) ON DELETE SET NULL
)
    ENGINE = InnoDB
    AUTO_INCREMENT = 1849
    DEFAULT CHARSET = utf8
    COLLATE = utf8_unicode_ci;



INSERT INTO financeiro_contas_fornecedores ( --
    `fornecedor_id`,
    `nota_fiscal`,
    `data`,
    `valor`,
    `nome`,
    `plano_de_contas_id`,
--
#     `centros_de_custo_cadaris_id`,
#     `forma_pagamento`,
#     `boleto`,
    `pago`, -- =1
#     `comprovante`,
    `conta_id`, -- =3
    `created_at`, -- =NOW()
    `updated_at` -- =NOW()
)
    VALUE
    -- (SELECT id FROM fornecedores_empresas WHERE codigo = LIMIT 1)
    -- , 1,3,NOW(),NOW()
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 204 LIMIT 1), '', '2019-02-25', 5989, 'Compra garantia note', 765, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 205 LIMIT 1), '583882', '2019-06-19', 21428, 'Curso Fred - 07/07', 799, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 205 LIMIT 1), '584098', '2019-06-26', 23125, 'Curso Guilherme - 06/08', 74, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 206 LIMIT 1), '', '2019-08-02', 44968, 'Compra de vidros 05/05', 74, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 207 LIMIT 1), '', '2019-08-08', 9006, 'Curso Maris 05/12', 799, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 208 LIMIT 1), '250180', '2019-08-09', 20541, 'Curso Maris 05/06', 799, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 209 LIMIT 1), '116258', '2018-07-25', 46241, 'parcela 04/12', 697, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 204 LIMIT 1), '1409333', '2019-09-25', 57980, 'Notebook's e PC's 03/10', 623, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 210 LIMIT 1), '196698', '2019-09-25', 57833, 'Compra tintas 03/06', NUL, 1, 3, NOW(), NOW() L),
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 203 LIMIT 1), '5667110', '2019-09-27', 16035, 'Compra produtos informática 03/03', 579, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 203 LIMIT 1), '5667110', '2019-09-27', 692, 'Frete 03/03', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 214 LIMIT 1), '', '2019-09-30', 4300, 'Estúdio fotográfico 03/03', 664, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 214 LIMIT 1), '', '2019-09-30', 349, 'Frete 03/03', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 215 LIMIT 1), '', '2019-10-01', 191250, 'Compra cadeiras 03/04', 623, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 186 LIMIT 1), '', '2019-10-04', 48502, 'Compras reforma 03/06', NUL, 1, 3, NOW(), NOW() L),
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 216 LIMIT 1), '2658332', '2019-10-08', 36729, 'Compra Reforma 03/05', NUL, 1, 3, NOW(), NOW() L),
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 217 LIMIT 1), '267', '2019-10-11', 43750, 'Conserto tubulação 03/04', NUL, 1, 3, NOW(), NOW() L),
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 218 LIMIT 1), '745440', '2019-10-16', 8952, 'Compra bateria 03/04', 579, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 218 LIMIT 1), '745440', '2019-10-16', 1823, 'Frete bateria 03/04', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 228 LIMIT 1), '42896', '2019-10-18', 23250, 'Compra e instalação tapete 03/04', 580, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 229 LIMIT 1), '', '2020-10-29', 29017, 'Microfone 02/03', 580, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 186 LIMIT 1), '12208', '2019-11-17', 22617, 'Parcela 02/06', 548, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 203 LIMIT 1), '5667110', '2019-11-25', 31663, 'Compra Switch - parcela 01/03', 579, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 203 LIMIT 1), '5667110', '2019-11-25', 970, 'Frete Switch', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-11-25', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 220 LIMIT 1), '', '2019-11-25', 22500, 'Curso Maris', 799, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 220 LIMIT 1), '', '2019-11-25', 22500, 'Curso Olivia', 74, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 221 LIMIT 1), '4056027', '2019-11-28', 12900, 'Compra brindes funcionários - 01/03', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 32 LIMIT 1), '', '2019-11-29', 2766, 'Compra livro', 618, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 222 LIMIT 1), '1190436', '2019-11-29', 31768, 'Compra cerveja confraternização', 621, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 222 LIMIT 1), '1190436', '2019-11-29', 1590, 'Frete', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 223 LIMIT 1), '', '2019-11-30', 14293, 'Analise de SEO', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 223 LIMIT 1), '', '2019-11-30', 14293, 'Analise de SEO', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 223 LIMIT 1), '', '2019-11-30', 14293, 'Analise de SEO', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 10 LIMIT 1), '', '2019-10-01', 11602, 'Hospedagem', 699, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 218 LIMIT 1), '7025', '2019-12-02', 89940, 'Compra de banqueta', 623, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 32 LIMIT 1), '', '2019-12-03', 32233, 'Hospedagem', 699, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 32 LIMIT 1), '', '2019-12-03', 22885, 'Hospedagem', 699, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 32 LIMIT 1), '', '2019-12-03', 9348, 'Hospedagem', 699, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 225 LIMIT 1), '582938', '2019-12-06', 2563, 'telefone sem fio - 01/03', 623, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 225 LIMIT 1), '493629', '2019-12-06', 7727, 'telefone sem fio - 01/03', 574, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 225 LIMIT 1), '582938', '2019-12-06', 198, 'frete', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 226 LIMIT 1), '', '2019-12-05', 1950, 'Caixas Sorrir Muda tudo', 638, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 226 LIMIT 1), '', '2019-12-05', 18999, 'Caixas Sorrir Muda tudo - 01/04', 638, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 227 LIMIT 1), '', '2019-12-06', 43350, 'Brindes funcionários - 01/02', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 119 LIMIT 1), '', '2019-11-08', 699, '', 543, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 67 LIMIT 1), '', '2019-12-13', 4710, 'Reunião', 616, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 230 LIMIT 1), '', '2019-12-17', 2100, 'Motoboy - Leadcomm', 549, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '', '2019-12-21', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-12-22', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-12-22', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-12-22', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-12-22', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW()) ,
    ((SELECT id FROM fornecedores_empresas WHERE codigo = 219 LIMIT 1), '127074', '2019-12-22', 2840, 'Contratação de ferramenta', 663, 1, 3, NOW(), NOW())

--
;

# SELECT count(*)
# FROM fornecedores_empresas
# WHERE codigo IN ()

# SELECT count(*)
# FROM cadastro_plano_de_contas_itens
# WHERE conta_reduzida IN ()
