feat: Ajuste Fino priced per art, with the offer under each Prumo warning (Marcus 10/11, point 1)

The designer treatment becomes Ajuste Fino, priced per art with a batch
band set in the Site tab (e.g. R$ 9,90, from 10 arts R$ 6,90). Under each
art the Prumo warns about, the Site offers 'Quer que um designer resolva?
Ajuste Fino'; the cart keeps 'Ajuste Fino em todas as artes'. The server
counts the chosen arts, Tiny gets the line with that quantity, the card
shows 'Ajuste Fino · N artes'. Old carts asking the treatment for the
whole order keep working.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 14:21:14 -03:00
parent 07515abbd8
commit dedcbb6aad
26 changed files with 423 additions and 107 deletions

View File

@@ -66,8 +66,11 @@ const FAIXAS={};
// Folha que alguém abre na mão (CDR, AI, PSD, TIFF): R$ a mais por metro.
// Vem do servidor (/api/session), que cobra o mesmo; zero não soma nada.
let TAXA_MANUAL=0;
// Fixed price of the designer treatment, set by the server (TREATMENT_CENTS).
// Ajuste Fino, per art, set by the server (TREATMENT_CENTS).
let TAXA_TRATAMENTO=0;
// Ajuste Fino for every art of the cart: the general switch, or true when
// the grade rule requires it. Individual choices live on the art objects.
let ajusteTudo=false;
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
const ehFolha=m=>!!MODOS[m||modo].folha;
const precoMetro=m=>PRECO[m||modo];
@@ -79,6 +82,16 @@ function precoNaMetragem(m, metros){
for(const band of bands) if(metros>=Number(band.from_metres) && (!alta || Number(band.from_metres)>=Number(alta.from_metres))) alta=band;
return alta ? alta.unit_cents/100 : PRECO[m];
}
// Ajuste Fino: the price of one art when the order has n arts. Below the first
// band it is the base, then the highest band reached, as app/catalog.py does.
function precoAjuste(n, base = TAXA_TRATAMENTO, bands = FAIXAS.tratamento) {
let price = base, best = null;
for (const band of bands || []) {
const start = Number(band.from_metres);
if (n >= start && (best === null || start >= best)) { best = start; price = band.unit_cents / 100; }
}
return price;
}
// A próxima faixa à frente, para o aviso de quanto falta.
function proximaFaixa(m, metros){
const bands=FAIXAS[m]||[];