Files
SGF/packages/general-ledger/ui/reports.php
T
2026-11-04 09:37:20 +02:00

18 lines
7.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$e=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8');
$money=static fn($v)=>($v<0?'-':'').number_format(intdiv(abs($v),100),0,',',' ').','.str_pad((string)(abs($v)%100),2,'0',STR_PAD_LEFT);
$query=$data['query'];$detail=$data['kind']==='account_ledger';$base='/general-ledger/'.($detail?'account-ledger':'trial-balance');
$url=static fn($path,$changes=[])=>$path.'?'.http_build_query(array_replace($query,$changes));
?><!doctype html><html lang="pt"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title><?= $detail?'Razão por conta':'Balancete' ?> de ensaio</title><style>body{font:17px system-ui;background:#f3f6f5;color:#142b28;margin:0}main{max-width:1200px;margin:auto;padding:24px}header,section{background:white;border:1px solid #d5e0dc;border-radius:12px;padding:24px;margin:18px 0}.notice{background:#fff2cc;padding:16px}label{display:inline-block;margin:10px}input,select,button{font:inherit;padding:9px}a{color:#125a4b}table{border-collapse:collapse;width:100%}th,td{padding:10px;border-bottom:1px solid #ddd;text-align:right;white-space:nowrap}th:first-child,td:first-child{text-align:left}.scroll{overflow:auto}code{overflow-wrap:anywhere}details{white-space:normal;max-width:30rem}nav a{display:inline-block;padding:10px}</style></head><body><main>
<header><a href="<?= $e($settings['return_url']) ?>">Voltar ao diário</a><h1><?= $e($settings['host']) ?> — <?= $detail?'razão por conta':'balancete' ?> de ensaio</h1><p class="notice">Exclusivamente sintético. Contas artificiais, MZN. Consulta de lançamentos aplicados; não constitui demonstração financeira legal nem saldo por liquidar.</p><p>Datas inclusivas. Abertura: lançamentos anteriores ao início. Movimentos: intervalo seleccionado. Fecho: abertura mais movimentos. Propostas ainda sem lançamento não entram nos montantes.</p></header>
<section><form method="get"><label>Início<input name="from_on" type="date" value="<?= $e($query['from_on']) ?>" required></label><label>Fim<input name="to_on" type="date" value="<?= $e($query['to_on']) ?>" required></label><?php if(isset($query['account_id'])): ?><input type="hidden" name="account_id" value="<?= $e($query['account_id']) ?>"><?php endif ?><label>Por página<select name="per_page"><?php foreach([25,100] as $n): ?><option value="<?= $n ?>" <?= $query['per_page']===$n?'selected':'' ?>><?= $n ?></option><?php endforeach ?></select></label><button>Consultar</button></form>
<?php if($detail): ?><p><a href="<?= $e('/general-ledger/trial-balance?'.http_build_query(array_diff_key($query,['account_id'=>true,'page'=>true]))) ?>">Voltar ao balancete completo do intervalo</a></p><h2><?= $e($data['account']['code']) ?> — <?= $e($data['account']['label']) ?></h2><p>Abertura D−C <?= $money($data['opening_net_minor']) ?> · Fecho D−C <?= $money($data['closing_net_minor']) ?> MZN</p><?php endif ?>
<p>Movimentos de todo o filtro: débitos <strong><?= $money($data['totals']['debit_minor']) ?></strong> · créditos <strong><?= $money($data['totals']['credit_minor']) ?></strong> MZN. Totais independentes da página.</p>
<?php if(!$detail): ?><p>Abertura: D <?= $money($data['totals']['opening_debit_minor']) ?> / C <?= $money($data['totals']['opening_credit_minor']) ?> · Fecho: D <?= $money($data['totals']['closing_debit_minor']) ?> / C <?= $money($data['totals']['closing_credit_minor']) ?> MZN.</p><?php endif ?>
<div class="scroll"><table><?php if(!$detail): ?><caption>Contas com lançamentos até ao fim do intervalo</caption><thead><tr><th scope="col">Conta</th><th scope="col">Abertura D−C</th><th scope="col">Débitos</th><th scope="col">Créditos</th><th scope="col">Fecho D−C</th></tr></thead><tbody><?php foreach($data['rows'] as $r): ?><tr><td><a href="<?= $e($url('/general-ledger/account-ledger',['account_id'=>$r['account_id'],'page'=>1])) ?>"><?= $e($r['code']) ?></a><br><?= $e($r['label']) ?></td><td><?= $money($r['opening_net_minor']) ?></td><td><?= $money($r['debit_minor']) ?></td><td><?= $money($r['credit_minor']) ?></td><td><?= $money($r['closing_net_minor']) ?></td></tr><?php endforeach ?></tbody>
<?php else: ?><caption>Linhas aplicadas e saldo acumulado por data, lançamento e linha</caption><thead><tr><th scope="col">Data / evidência</th><th scope="col">Débito</th><th scope="col">Crédito</th><th scope="col">Saldo D−C</th></tr></thead><tbody><?php foreach($data['rows'] as $r): ?><tr><td><?= $e($r['journal_on']) ?> · lançamento #<?= $e($r['journal_id']) ?> / linha <?= $e($r['line_no']) ?><details><summary><?= $e($r['effect_type']) ?></summary><p><?= $e($r['reason']) ?></p><p>Proposta #<?= $e($r['proposal_id']) ?> · revisão #<?= $e($r['review_id']) ?> · aplicador #<?= $e($r['posted_by']) ?> · <?= $e($r['created_at']) ?></p><p>Versão da fonte <code><?= $e($r['source_revision']) ?></code></p><?php if(($settings['industrial_links']??false)&&($r['industrial_lot_id']??null)!==null): ?><a href="<?= $e('/general-ledger/industrial?lot_id='.$r['industrial_lot_id']) ?>">Conferir lote, resultado e decisões</a><?php elseif(($settings['cost_links']??false)&&$r['cost_order_id']!==null): ?><a href="<?= $e('/general-ledger/costs?order_id='.$r['cost_order_id']) ?>">Conferir ordem, custo e decisões</a><?php elseif(($settings['sales_links']??false)&&$r['invoice_id']!==null): ?><a href="<?= $e('/general-ledger/sales?invoice_id='.$r['invoice_id']) ?>">Conferir origem comercial e financeira</a><?php else: ?><p>Obrigação de origem #<?= $e($r['obligation_id']) ?>; a fotografia completa permanece no diário.</p><?php endif ?></details></td><td><?= $money($r['debit_minor']) ?></td><td><?= $money($r['credit_minor']) ?></td><td><?= $money($r['balance_minor']) ?></td></tr><?php endforeach ?></tbody><?php endif ?></table></div>
<?php if(!$data['rows']): ?><p>Sem linhas nesta página. <?= $data['basis']['journals']===0?'Não existem lançamentos aplicados até à data final neste âmbito.':'Confira o filtro e a paginação; os totais acima incluem o conjunto completo.' ?></p><?php endif ?>
<nav aria-label="Paginação do relatório"><p>Página <?= $e($data['pagination']['page']) ?> de <?= $e($data['pagination']['last_page']) ?> · <?= $e($data['pagination']['total']) ?> <?= $detail?'linhas':'contas' ?></p><?php foreach([-1=>'Anterior',1=>'Seguinte'] as $delta=>$label): $p=$query['page']+$delta;if($p>=1&&$p<=$data['pagination']['last_page']): ?><a href="<?= $e($url($base,['page'=>$p])) ?>"><?= $e($label) ?></a><?php endif;endforeach ?></nav></section>
<section><h2>Base da consulta</h2><p>Tenant #<?= $e($data['basis']['scope']['tenant_id']) ?> · empresa #<?= $e($data['basis']['scope']['company_id']) ?> · unidade #<?= $e($data['basis']['scope']['unit_id']) ?>. Até <?= $e($data['basis']['through_on']) ?>: <?= $e($data['basis']['journals']) ?> lançamentos; último identificador #<?= $e($data['basis']['last_journal_id']) ?>.</p><p>O marcador identifica o estado append-only consultado; uma inserção posterior, mesmo retrodatada, gera outro estado. Não é aprovação de fecho nem uma fotografia persistida do relatório.</p></section>
</main></body></html>