fix(protese): painel do lab usa fechamento próprio em vez do financeiro de pacientes (corrige 403)
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 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ export const LabHomeView: React.FC = () => {
|
|||||||
const carregar = useCallback(async () => {
|
const carregar = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
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 : []);
|
setOs(Array.isArray(b) ? b : []);
|
||||||
setFin(Array.isArray(f) ? f : []);
|
setFin(Array.isArray(f) ? f : []);
|
||||||
} catch { /* silent */ } finally { setLoading(false); }
|
} catch { /* silent */ } finally { setLoading(false); }
|
||||||
@@ -27,10 +27,8 @@ export const LabHomeView: React.FC = () => {
|
|||||||
const atrasadas = os.filter(o => o.atrasada).length;
|
const atrasadas = os.filter(o => o.atrasada).length;
|
||||||
const ymMes = new Date().toISOString().slice(0, 7);
|
const ymMes = new Date().toISOString().slice(0, 7);
|
||||||
const entreguesMes = os.filter(o => o.status === 'entregue' && (o.updated_at || '').slice(0, 7) === ymMes).length;
|
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).
|
// Faturamento do mês: do fechamento do próprio lab (custo das OS entregues no mês).
|
||||||
const fatMes = fin
|
const fatMes = Number(fin.find(m => m.mes === ymMes)?.faturado || 0);
|
||||||
.filter(l => l.origem === 'protese' && (l.data_competencia || l.datavencimento || '').slice(0, 7) === ymMes)
|
|
||||||
.reduce((s, l) => s + Number(l.valor || 0), 0);
|
|
||||||
|
|
||||||
const KPI: React.FC<{ titulo: string; valor: string; cor: string; Icon: any; sub?: string }> = ({ titulo, valor, cor, Icon, sub }) => (
|
const KPI: React.FC<{ titulo: string; valor: string; cor: string; Icon: any; sub?: string }> = ({ titulo, valor, cor, Icon, sub }) => (
|
||||||
<div className="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm relative overflow-hidden">
|
<div className="bg-white p-5 rounded-2xl border border-gray-100 shadow-sm relative overflow-hidden">
|
||||||
|
|||||||
Reference in New Issue
Block a user