From 7566c0115997c341df5ddd7613fd082e5f4452f8 Mon Sep 17 00:00:00 2001 From: VPS 4 Builder Date: Thu, 25 Jun 2026 04:22:45 +0200 Subject: [PATCH] =?UTF-8?q?fix(protese):=20painel=20do=20lab=20usa=20fecha?= =?UTF-8?q?mento=20pr=C3=B3prio=20em=20vez=20do=20financeiro=20de=20pacien?= =?UTF-8?q?tes=20(corrige=20403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LabHomeView chamava GET /api/financeiro (capability 'financeiro', negada ao protético) só para o KPI "faturamento do mês" → 403 no console ao abrir o painel do laboratório. Passa a usar GET /api/protese/lab/fechamento (custo das OS entregues no mês), que é do escopo do lab. Co-Authored-By: Claude Opus 4.8 --- frontend/views/LabHomeView.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/views/LabHomeView.tsx b/frontend/views/LabHomeView.tsx index f2e8223..1b89852 100644 --- a/frontend/views/LabHomeView.tsx +++ b/frontend/views/LabHomeView.tsx @@ -16,7 +16,7 @@ export const LabHomeView: React.FC = () => { const carregar = useCallback(async () => { setLoading(true); try { - const [b, f] = await Promise.all([HybridBackend.getProteseBancada(), HybridBackend.getFinanceiro()]); + const [b, f] = await Promise.all([HybridBackend.getProteseBancada(), HybridBackend.getLabFechamento()]); setOs(Array.isArray(b) ? b : []); setFin(Array.isArray(f) ? f : []); } catch { /* silent */ } finally { setLoading(false); } @@ -27,10 +27,8 @@ export const LabHomeView: React.FC = () => { const atrasadas = os.filter(o => o.atrasada).length; const ymMes = new Date().toISOString().slice(0, 7); const entreguesMes = os.filter(o => o.status === 'entregue' && (o.updated_at || '').slice(0, 7) === ymMes).length; - // Faturamento do mês: RECEITA de prótese lançada no workspace do lab (espelho da entrega). - const fatMes = fin - .filter(l => l.origem === 'protese' && (l.data_competencia || l.datavencimento || '').slice(0, 7) === ymMes) - .reduce((s, l) => s + Number(l.valor || 0), 0); + // Faturamento do mês: do fechamento do próprio lab (custo das OS entregues no mês). + const fatMes = Number(fin.find(m => m.mes === ymMes)?.faturado || 0); const KPI: React.FC<{ titulo: string; valor: string; cor: string; Icon: any; sub?: string }> = ({ titulo, valor, cor, Icon, sub }) => (