/* L2MAKER - API da SEFAZ
   HTTP://www.l2maker.com.br/ 
*/
-- SCRIPT DO EXEMPLO PARA POSTGRESQL 9
/* Estas duas VIEWS devem ser editadas para obter os dados reais, no exemplo elas sempre retornam apenas 1 registro. */

CREATE OR REPLACE VIEW nfe_nota_fiscal_vi AS 
 SELECT 1 AS nfe_codigo,
    0 AS nfe_numero,
    '55' AS nfe_modelo,
    '1' AS nfe_serie,
    now() AS nfe_dh_emissao,
    1 AS nfe_tp_impressao,
    'VENDA MERC ADQ TERC' AS nfe_nat_operacao,
    1 AS nfe_ind_pag,
    1 AS nfe_tp_nf,
    1 AS nfe_id_dest,
    '2927408'::character(7) AS nfe_municipio_fg,
    1 AS nfe_finalidade,
    1 AS nfe_consumidor_final,
    1 AS nfe_venda_presencial,
    '18590980000195' AS emitente_cnpj,
    'NOME DA EMPRESA' AS emitente_razao_social,
    'L2 Soluções Tecnológicas Ltda' AS emitente_nome_fantasia,
    'Av. Luis Viana' AS emitente_logradouro,
    '6462' AS emitente_numero,
    'Sala 226 B' AS emitente_complemento,
    'Patamares' AS emitente_bairro,
    '2936921' AS emitente_municipio_ibge,
    'Salvador' AS emitente_municipio_nome,
    'BA' AS emitente_uf,
    '41730101' AS emitente_cep,
    '67913396' AS emitente_ie,
    3 AS emitente_crt,
    '30287108899' AS destinatario_cpf,
    '' AS destinatario_cnpj,
    'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL' AS destinatario_razao_social,
    'Av. Luis Viana' AS destinatario_logradouro,
    '6462' AS destinatario_numero,
    'Sala 226 B' AS destinatario_complemento,
    'Patamares' AS destinatario_bairro,
    '2936921' AS destinatario_municipio_ibge,
    'Salvador' AS destinatario_municipio_nome,
    'BA' AS destinatario_uf,
    '41730101' AS destinatario_cep,
    '7130377906' AS destinatario_fone,
    '1058' AS destinatario_pais_codigo,
    'Brasil' AS destinatario_pais_nome,
    9 AS destinatario_ind_ie,
    '' AS destinatario_ie,
    'nome@conta.com.br' AS destinatario_email,
    '30287108899' AS autorizado1,
    '18590980000195' AS autorizado2,
    12.34 AS total_icms_bc,
    12.34 AS total_icms_valor,
    0.34 AS total_icms_desonerado,
    0.01 AS total_icms_fcp_uf_dest,
    0.01 AS total_icms_uf_dest,
    0.01 AS total_icms_uf_remet,
    0.01 AS total_icms_bcst,
    0.01 AS total_icms_st,
    1000.01 AS total_produtos,
    0.01 AS total_frete,
    0.01 AS total_seguro,
    0.01 AS total_desconto,
    0.01 AS total_ii,
    0.01 AS total_ipi,
    0.01 AS total_pis,
    0.01 AS total_cofins,
    0.01 AS total_outro,
    1010.01 AS total_nf,
    12.34 AS total_tributos;


CREATE OR REPLACE VIEW nfe_nota_fiscal_item_vi AS 
 SELECT 1 AS nfe_codigo,
    '1005' AS prod_codigo,
    '' AS prod_ean,
    'GAS COMBUSTIVEL RESIDENCIAL' AS prod_descricao,
    '27112100' AS prod_ncm,
    '2711210' AS prod_cest,
    '5656' AS prod_cfop,
    'M3' AS prod_un_com,
    12.0000 AS prod_qtd_com,
    1.23 AS prod_vlr_un_com,
    15.256 AS prod_valor,
    '' AS prod_ean_trib,
    'M3' AS prod_un_trib,
    12.0000 AS prod_qtd_trib,
    1.25 AS prod_vlr_un_trib,
    0.54 AS prod_vlr_desconto,
    0.05 AS prod_vlr_outro,
    1 AS prod_ind_total,
    3 AS icms_sn102_orgi,
    '400' AS icms_sn102_csosn,
    '07' AS pis_nt_cst,
    '07' AS cofins_nt_cst;


/* L2MAKER - HTTP://www.l2maker.com.br/ */