feat: the Financeiro profile (Dropstar, 2026-10-30)
All checks were successful
Build and deploy / Validate source (push) Successful in 14s
Build and deploy / Integration suite on a real stack (push) Successful in 4m44s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m12s
All checks were successful
Build and deploy / Validate source (push) Successful in 14s
Build and deploy / Integration suite on a real stack (push) Successful in 4m44s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m12s
Financeiro sees the whole board, Pagamentos, Números and Cotações, and cancels an order with its reason. It moves no card and touches no file; resolving a payment stays with Gestão and Administração. Two narrower capabilities carry it: "payments" (the Pagamentos list) and "cancel", which used to need "manage". The order panel's menu shows each profile only what it may do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -281,7 +281,7 @@ def finished_page(request: Request, before_created_at: datetime | None = None, b
|
||||
@router.get('/api/operator/payment-events')
|
||||
def payment_events(state: Literal['open','resolved','all'] = 'open',
|
||||
offset: int = Query(default=0, ge=0),
|
||||
limit: int = Query(default=20, ge=1, le=100), user=Depends(can('manage'))):
|
||||
limit: int = Query(default=20, ge=1, le=100), user=Depends(can('payments'))):
|
||||
"""Payments that needed a person, newest first: open ones to act on, resolved ones as history."""
|
||||
where = {'open': 'AND resolved_at IS NULL', 'resolved': 'AND resolved_at IS NOT NULL', 'all': ''}[state]
|
||||
with db.connect() as c:
|
||||
@@ -611,7 +611,7 @@ def release_files(c, uploads):
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/cancel')
|
||||
def cancel_order(uid: UUID, body: Resolution, user=Depends(can('manage'))):
|
||||
def cancel_order(uid: UUID, body: Resolution, user=Depends(can('cancel'))):
|
||||
"""A paid order leaves the board but keeps its payment and history. Nothing
|
||||
is refunded here (that is done at the provider); Tiny is told, so the
|
||||
order is cancelled there too while it was not invoiced (app/tiny.py)."""
|
||||
|
||||
@@ -25,7 +25,7 @@ class UserIn(StrictModel):
|
||||
# The profiles an administrator may give; superadmin only comes from the console.
|
||||
name: str = Field(min_length=1, max_length=80)
|
||||
email: str = Field(min_length=3, max_length=254)
|
||||
role: Literal['admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor']
|
||||
role: Literal['admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor', 'financeiro']
|
||||
password: str | None = Field(default=None, min_length=8, max_length=128)
|
||||
active: bool = True
|
||||
machines: list[UUID] = Field(default_factory=list, max_length=50)
|
||||
|
||||
@@ -122,7 +122,7 @@ def login_failed(email):
|
||||
# backup, the Tiny log): the others see there only what is on and off.
|
||||
# The designer approves and refuses artwork and asks for corrections, on every
|
||||
# order whatever its machine. Which cards each profile moves is MOVES.
|
||||
ROLES = ('superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor')
|
||||
ROLES = ('superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor', 'financeiro')
|
||||
CAPABILITIES = {
|
||||
'view': set(ROLES),
|
||||
'produce': {'superadmin', 'admin', 'gestao', 'designer', 'operador'},
|
||||
@@ -137,6 +137,11 @@ CAPABILITIES = {
|
||||
'authorize': {'superadmin', 'admin'},
|
||||
'users': {'superadmin', 'admin'},
|
||||
'integrations': {'superadmin'},
|
||||
# Financeiro (Dropstar, 2026-10-30): sees the board, Pagamentos, Números and
|
||||
# Cotações, and cancels an order with its reason; moves no card, touches no
|
||||
# file. Resolving a payment stays with "manage".
|
||||
'payments': {'superadmin', 'admin', 'gestao', 'financeiro'},
|
||||
'cancel': {'superadmin', 'admin', 'gestao', 'financeiro'},
|
||||
# "Retirado" at the counter (Dropstar's third round, item 14): everyone
|
||||
# but the seller, who only views (D-30). It includes everyone who produces,
|
||||
# so an operator upload (artwork.py) takes it for its parts.
|
||||
|
||||
@@ -253,7 +253,7 @@ CREATE TABLE IF NOT EXISTS dtf_local.cnpj_names (
|
||||
ALTER TABLE dtf_local.operators ADD COLUMN IF NOT EXISTS role text NOT NULL DEFAULT 'admin';
|
||||
ALTER TABLE dtf_local.operators DROP CONSTRAINT IF EXISTS operators_role;
|
||||
ALTER TABLE dtf_local.operators ADD CONSTRAINT operators_role
|
||||
CHECK (role IN ('superadmin','admin','gestao','designer','operador','revisor','vendedor'));
|
||||
CHECK (role IN ('superadmin','admin','gestao','designer','operador','revisor','vendedor','financeiro'));
|
||||
-- The print machines, and which products each prints. An order keeps the
|
||||
-- machine someone chose (machine_chosen) or the one given automatically: the
|
||||
-- active machine of its product with the fewest metres open (app/machines.py).
|
||||
|
||||
@@ -177,6 +177,27 @@ def run():
|
||||
# The seller only views the board (D-30): no order registered by hand either.
|
||||
assert seller.call('/operator/me')['can'] == ['view']
|
||||
seller.call(f'/operator/quotes/{uv_q}/register', {'origin': 'atendimento', 'method': 'pix'}, expected=403)
|
||||
# Financeiro (Dropstar, 2026-10-30): the board, Pagamentos, Números and
|
||||
# Cotações, and cancels an order with its reason; moves nothing.
|
||||
emails['financeiro'] = f'financeiro-{tag}@example.test'
|
||||
admin.call('/operator/users', {'name': 'Contas', 'email': emails['financeiro'], 'role': 'financeiro',
|
||||
'password': PASSWORD})
|
||||
money = signed_in(emails['financeiro'])
|
||||
me = money.call('/operator/me')
|
||||
assert me['can'] == ['cancel', 'payments', 'view'] and me['moves'] == [] and me['reorder'] == [], me
|
||||
money.call('/operator/payment-events')
|
||||
money.call('/operator/stats?days=7')
|
||||
assert str(uv_o) in {o['id'] for o in money.call('/operator/board')['orders']}
|
||||
money.call(f'/operator/orders/{textil_o}/move', {'state': 'tra', 'version': 0, 'reason': ''}, expected=403)
|
||||
money.call(f'/operator/quotes/{uv_q}/discard', {}, expected=403)
|
||||
money.call(f'/operator/payment-events/{uuid4()}/resolve', {'note': 'Pago'}, expected=403)
|
||||
money.call(f'/operator/orders/{textil_o}/machine', {'machine_id': None}, expected=403)
|
||||
seller.call('/operator/payment-events', expected=403)
|
||||
with db.connect() as c:
|
||||
gone_q, gone_o = order_fixture(c, owner, 'file')
|
||||
made.append((gone_q, gone_o))
|
||||
seller.call(f'/operator/orders/{gone_o}/cancel', {'note': 'Cliente desistiu'}, expected=403)
|
||||
money.call(f'/operator/orders/{gone_o}/cancel', {'note': 'Cliente desistiu'})
|
||||
# The Revisor releases to Finalizado, and the administrator may too (2026-10-28).
|
||||
assert ['rev', 'fin'] in admin.call('/operator/me')['moves']
|
||||
admin.call('/operator/users', {'name': 'Confere', 'email': emails['revisor'], 'role': 'revisor',
|
||||
|
||||
@@ -117,7 +117,8 @@
|
||||
<p class="faint stats-note">Quem entra no Kanban e o que cada perfil pode fazer. Administrador: tudo, inclusive esta página.
|
||||
Gestão: tudo, menos usuários; no quadro só puxa para trás, com motivo (Correção ou voltar uma etapa). Designer: vê todos os pedidos, aprova e recusa o arquivo final, pede correção.
|
||||
Operador: ligado a uma máquina, vê só os pedidos dela; imprime e passa para a Revisão. Revisor: confere a folha impressa e libera para Finalizado; o Administrador também pode liberar.
|
||||
Vendedor: só consulta. Retrabalho: a Gestão abre, com a causa; o Administrador autoriza.</p>
|
||||
Vendedor: só consulta. Financeiro: vê o quadro, Pagamentos, Números e Cotações e cancela pedido, com o motivo; não move card nem mexe em arquivo.
|
||||
Retrabalho: a Gestão abre, com a causa; o Administrador autoriza.</p>
|
||||
<section class="statbox"><table class="log"><thead><tr><th scope="col">Nome</th><th scope="col">Perfil</th><th scope="col">Máquinas</th><th scope="col">Último acesso</th><th scope="col"></th></tr></thead><tbody id="users-list"></tbody></table></section>
|
||||
<div class="pagehead"><h2>Máquinas</h2><button class="btn" id="new-machine" type="button">Nova máquina</button></div>
|
||||
<p class="faint stats-note">Cada pedido vai para a máquina do produto com menos metros em aberto, dentro do limite. No pedido dá para trocar.</p>
|
||||
|
||||
@@ -43,14 +43,16 @@ let quoteQuery='', quoteProduct='', quoteLayout='', quoteFlag='', quoteTimer=nul
|
||||
// The signed-in operator and what their profile allows (app/core/auth.py).
|
||||
let ME=null;
|
||||
const may=cap=>!!ME?.can?.includes(cap);
|
||||
const ROLE_NAMES={superadmin:'Superadmin',admin:'Administrador',gestao:'Gestão',designer:'Designer',operador:'Operador',revisor:'Revisor',vendedor:'Vendedor'};
|
||||
const ROLE_NAMES={superadmin:'Superadmin',admin:'Administrador',gestao:'Gestão',designer:'Designer',operador:'Operador',revisor:'Revisor',vendedor:'Vendedor',financeiro:'Financeiro'};
|
||||
// Which moves this profile makes, and which columns' order it sets: the
|
||||
// server's own list (app/core/auth.py MOVES), never worked out here.
|
||||
const mayMove=(from,to)=>!!ME?.moves?.some(([a,b])=>a===from&&b===to);
|
||||
const mayReorder=state=>!!ME?.reorder?.includes(state);
|
||||
// Which tabs each capability opens.
|
||||
const TAB_NEEDS={quotes:o=>may('manage')||ME?.role==='vendedor',payments:()=>may('manage'),
|
||||
stats:()=>may('manage')||ME?.role==='vendedor',integrations:()=>may('manage')||may('print'),users:()=>may('users')};
|
||||
// Vendedor and Financeiro consult Cotações and Números without acting there.
|
||||
const consults=()=>['vendedor','financeiro'].includes(ME?.role);
|
||||
const TAB_NEEDS={quotes:o=>may('manage')||consults(),payments:()=>may('payments'),
|
||||
stats:()=>may('manage')||consults(),integrations:()=>may('manage')||may('print'),users:()=>may('users')};
|
||||
function applyRole(){
|
||||
for(const b of document.querySelectorAll('[data-tab]')){const need=TAB_NEEDS[b.dataset.tab];b.hidden=!!need&&!need();}
|
||||
if(TAB_NEEDS[tab]&&!TAB_NEEDS[tab]())showTab('board');
|
||||
@@ -1083,7 +1085,7 @@ function moves(order){
|
||||
const cancelForm=node('form',undefined,'reason');cancelForm.hidden=true;forms.push(cancelForm);
|
||||
const menu=node('div',undefined,'menu');menu.hidden=true;menu.setAttribute('role','menu');
|
||||
if(isTest(order)){
|
||||
menu.append(button('Excluir pedido de teste',async()=>{
|
||||
if(may('manage'))menu.append(button('Excluir pedido de teste',async()=>{
|
||||
menu.hidden=true;
|
||||
if(!window.confirm('Excluir o pedido de teste #'+order.number+'? Ele some do Kanban, com o histórico.'))return;
|
||||
await api('/orders/'+order.id+'/delete',{});closePanel();say('Pedido de teste #'+order.number+' excluído.');await load();
|
||||
@@ -1091,7 +1093,7 @@ function moves(order){
|
||||
}else{
|
||||
if(may('rework'))menu.append(button('Abrir retrabalho',()=>{menu.hidden=true;reworkForm(order);},'menuitem'));
|
||||
const b=node('button','Cancelar pedido','menuitem bad');b.type='button';
|
||||
b.onclick=()=>{menu.hidden=true;toggle(cancelForm);};menu.append(b);
|
||||
b.onclick=()=>{menu.hidden=true;toggle(cancelForm);};if(may('cancel'))menu.append(b);
|
||||
const why=node('input');why.placeholder='Motivo do cancelamento';why.setAttribute('aria-label','Motivo do cancelamento');why.required=true;why.minLength=3;why.maxLength=1000;
|
||||
const go=node('button','Cancelar pedido #'+order.number,'btn danger');
|
||||
cancelForm.append(node('span','O pedido sai do quadro e fica em "Cancelados", com o pagamento e o histórico. O valor fica como crédito do cliente, no controle financeiro, e o pedido no Tiny se cancela lá.','muted'),why,go);
|
||||
@@ -1103,7 +1105,7 @@ function moves(order){
|
||||
more.setAttribute('aria-haspopup','menu');
|
||||
more.onclick=e=>{e.stopPropagation();menu.hidden=!menu.hidden;
|
||||
if(!menu.hidden)document.addEventListener('click',()=>{menu.hidden=true;},{once:true});};
|
||||
const wrap=node('div',undefined,'morewrap');wrap.append(more,menu);if(may('manage'))row.append(wrap);
|
||||
const wrap=node('div',undefined,'morewrap');wrap.append(more,menu);if(menu.children.length)row.append(wrap);
|
||||
const text=node('textarea');text.placeholder='Motivo da correção';text.setAttribute('aria-label','Motivo da correção');text.maxLength=1000;text.required=true;
|
||||
const sendFix=node('button','Enviar para correção','btn danger');
|
||||
reason.append(text,sendFix);
|
||||
@@ -1551,7 +1553,7 @@ function userForm(u){
|
||||
const name=node('input');name.required=true;name.maxLength=80;name.value=u?.name||'';
|
||||
const email=node('input');email.type='email';email.required=true;email.value=u?.email||'';
|
||||
const role=node('select');
|
||||
const roles=u?.role==='superadmin'?['superadmin']:['admin','gestao','designer','operador','revisor','vendedor'];
|
||||
const roles=u?.role==='superadmin'?['superadmin']:['admin','gestao','designer','operador','revisor','vendedor','financeiro'];
|
||||
for(const r of roles){const o=node('option',ROLE_NAMES[r]);o.value=r;role.append(o);}
|
||||
role.value=u?.role||'operador';role.disabled=u?.role==='superadmin'||u?.email===ME.email;
|
||||
const pass=node('input');pass.type='password';pass.minLength=8;pass.maxLength=128;pass.autocomplete='new-password';
|
||||
@@ -2064,6 +2066,8 @@ function renderIssues(){
|
||||
if(issue.resolved_at){
|
||||
text.append(node('span','Resolvido por '+issue.resolved_by+' em '+when(issue.resolved_at)+': '+issue.resolution));
|
||||
box.append(text);
|
||||
}else if(!may('manage')){
|
||||
text.append(node('span','Aguardando a resolução da Gestão ou do Administrador.','faint'));box.append(text);
|
||||
}else{
|
||||
const form=node('form');const note=node('input');note.placeholder='Resolução';note.setAttribute('aria-label','Resolução');note.required=true;note.minLength=3;note.maxLength=1000;
|
||||
const save=node('button','Registrar resolução','btn warn');form.append(note,save);
|
||||
|
||||
Reference in New Issue
Block a user