{{ venda.empresa.fantasia if venda.empresa and venda.empresa.fantasia else 'CAPESYSTEM' }}

{{ venda.empresa.razao_social if venda.empresa else 'Cape Sistemas de Gestão Empresarial LTDA' }}
{% if venda.empresa %} {% if venda.empresa.cnpj %}CNPJ: {{ venda.empresa.cnpj }}
{% endif %} {% if venda.empresa.endereco %}{{ venda.empresa.endereco }}{% endif %} {% if venda.empresa.numero %}, {{ venda.empresa.numero }}{% endif %} {% if venda.empresa.bairro %} - {{ venda.empresa.bairro }}{% endif %} {% if venda.empresa.cidade %} - {{ venda.empresa.cidade }}{% endif %} {% if venda.empresa.estado %}/{{ venda.empresa.estado }}{% endif %} {% if venda.empresa.cep %} - CEP {{ venda.empresa.cep }}{% endif %}
{% if venda.empresa.telefone %}Tel: {{ venda.empresa.telefone }}{% endif %} {% if venda.empresa.email %} | {{ venda.empresa.email }}{% endif %} {% endif %}
Pedido Nº
{{ venda.numero_pedido }}
📋 Dados do Pedido
Nº Pedido {{ venda.numero_pedido }}
Data Abertura {{ venda.data_venda.strftime('%d/%m/%Y') if venda.data_venda else 'N/A' }}
{% if venda.data_fechamento %}
Data Fechamento {{ venda.data_fechamento.strftime('%d/%m/%Y %H:%M') }}
{% endif %} {% if venda.data_entrega %}
Previsão Entrega {{ venda.data_entrega.strftime('%d/%m/%Y') }}
{% endif %}
Status {% if venda.status == 'aberto' %} Aberto {% elif venda.status == 'faturado' %} Faturado {% elif venda.status == 'finalizada' %} Finalizada {% elif venda.status == 'recebido' %} Recebido {% elif venda.status == 'entregue' %} Entregue {% elif venda.status == 'cancelado' %} Cancelado {% else %} {{ venda.status|default('N/A')|replace('_', ' ')|title }} {% endif %}
Origem {{ venda.origem|default('web')|upper }}
👤 Vendedor / Operador
{% if venda.vendedor %}
Vendedor {{ venda.vendedor.nome }}
{% endif %} {% if venda.usuario %}
Operador {{ venda.usuario.username if venda.usuario.username else (venda.usuario.email if venda.usuario.email else 'N/A') }}
{% endif %} {% if venda.recebido_por %}
Recebido por {{ venda.recebido_por.username if venda.recebido_por.username else (venda.recebido_por.email if venda.recebido_por.email else 'N/A') }}
{% endif %} {% if venda.data_recebimento %}
Data Recebimento {{ venda.data_recebimento.strftime('%d/%m/%Y %H:%M') }}
{% endif %} {% if not venda.vendedor and not venda.usuario %}
Não informado
{% endif %}
🏢 Cliente
Nome/Razão Social {{ venda.get_cliente_nome() }}
{% if venda.pessoa %} {% if venda.pessoa.cnpj %}
CNPJ {{ venda.pessoa.cnpj }}
{% elif venda.pessoa.cpf %}
CPF {{ venda.pessoa.cpf }}
{% endif %} {% if venda.pessoa.ie %}
IE {{ venda.pessoa.ie }}
{% endif %} {% endif %}
{% if venda.pessoa %} {% if venda.pessoa.telefone %}
Telefone {{ venda.pessoa.telefone }}
{% endif %} {% if venda.pessoa.celular %}
Celular {{ venda.pessoa.celular }}
{% endif %} {% if venda.pessoa.email %}
E-mail {{ venda.pessoa.email }}
{% endif %} {% endif %}
{% if venda.pessoa and venda.pessoa.endereco %}
Endereço {{ venda.pessoa.endereco }} {% if venda.pessoa.numero %}, {{ venda.pessoa.numero }}{% endif %} {% if venda.pessoa.complemento %} - {{ venda.pessoa.complemento }}{% endif %}
Bairro/Cidade/UF {% if venda.pessoa.bairro %}{{ venda.pessoa.bairro }}{% endif %} {% if venda.pessoa.cidade %} - {{ venda.pessoa.cidade }}{% endif %} {% if venda.pessoa.uf %}/{{ venda.pessoa.uf }}{% endif %} {% if venda.pessoa.cep %} - CEP: {{ venda.pessoa.cep }}{% endif %}
{% endif %}
{% if venda.chave_documento %}
📄 Documento Fiscal
{% if venda.tipo_documento == 65 %} NFC-e {% elif venda.tipo_documento == 55 %} NF-e {% else %} Doc. Fiscal {% endif %}
Número / Série {{ venda.numero_documento }} / {{ venda.serie_documento }}
Chave de Acesso:
{{ venda.chave_documento }}
{% endif %}
📦 Itens do Pedido ({{ venda.itens|length }} {% if venda.itens|length == 1 %}item{% else %}itens{% endif %})
{% for item in venda.itens %} {% endfor %}
# Código Descrição UN Qtd Vl. Unit. Desc. Total
{{ loop.index }} {{ item.produto.codigo if item.produto else '-' }} {{ item.descricao or (item.produto.nome if item.produto else 'Produto') }} {{ item.produto.unidade if item.produto else 'UN' }} {{ "%.2f"|format(item.quantidade) }} R$ {{ "%.2f"|format(item.valor_unitario) }} {% if item.desconto_item and item.desconto_item > 0 %}R$ {{ "%.2f"|format(item.desconto_item) }}{% else %}-{% endif %} R$ {{ "%.2f"|format(item.valor_total) }}
💳 Formas de Pagamento
{% if pagamentos and pagamentos|length > 0 %} {% for pag in pagamentos %}
{{ pag.forma_nome }}
{% if pag.desconto_automatico and pag.desconto_automatico > 0 %}
Desconto: {{ pag.desconto_percentual }}% (-R$ {{ "%.2f"|format(pag.desconto_automatico) }})
{% endif %} {% if pag.acrescimo_automatico and pag.acrescimo_automatico > 0 %}
Acréscimo: {{ pag.acrescimo_percentual }}% (+R$ {{ "%.2f"|format(pag.acrescimo_automatico) }})
{% endif %}
R$ {{ "%.2f"|format(pag.valor) }}
{% endfor %} {% elif venda.forma_pagamento %}
{{ venda.forma_pagamento }}
R$ {{ "%.2f"|format(venda.valor_total or 0) }}
{% else %}
Pagamento não informado
{% endif %} {% if venda.condicao_pagamento %}
Condição {{ venda.condicao_pagamento }}
{% endif %} {% if venda.valor_recebido_total and venda.valor_recebido_total > 0 %}
Valor Recebido R$ {{ "%.2f"|format(venda.valor_recebido_total) }}
{% if venda.troco_total and venda.troco_total > 0 %}
Troco R$ {{ "%.2f"|format(venda.troco_total) }}
{% endif %}
{% endif %}
💰 Resumo de Valores
Subtotal R$ {{ "%.2f"|format(venda.subtotal or ((venda.valor_total or 0) + (venda.desconto or 0) - (venda.acrescimo or 0))) }}
{% if venda.desconto and venda.desconto > 0 %}
Desconto - R$ {{ "%.2f"|format(venda.desconto) }}
{% endif %} {% if venda.acrescimo and venda.acrescimo > 0 %}
Acréscimo + R$ {{ "%.2f"|format(venda.acrescimo) }}
{% endif %}
TOTAL R$ {{ "%.2f"|format(venda.valor_total or 0) }}
{% if venda.observacoes or venda.observacoes_internas %}
{% if venda.observacoes %}
📝 Observações
{{ venda.observacoes }}
{% endif %} {% if venda.observacoes_internas %}
🔒 Observações Internas
{{ venda.observacoes_internas }}
{% endif %}
{% endif %}
Assinatura do Cliente
Assinatura do Vendedor