feat: progressive price bands per product (front 8.2)
A price may carry up to five bands, "from N m, R$ Y": the order's total billed metres of that product chooses one price for its whole quantity, the manual-file extra still on top. Bands start and become history with their price row. The Site charges the same band for the cart, shows "Faltam X m para R$ Y o metro" and lists the bands under the price table; the Kanban's Site tab edits them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,10 @@ const MODOS={
|
||||
// tela, para o cliente entender o arquivo dele, mas não mexe no preço.
|
||||
// O servidor cobra o mesmo (app/core/pricing.py, conferido em tests/test_pricing.py).
|
||||
const PRECO={file:19.90, avulsa:21.90, uvfile:79.90, uv:89.90};
|
||||
// Faixas por metragem (front 8.2): o preço do metro depende do total do
|
||||
// produto no pedido, não de cada item. Vem do servidor (/api/session), que
|
||||
// cobra o mesmo (app/catalog.py band_price).
|
||||
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;
|
||||
@@ -65,6 +69,21 @@ let TAXA_TRATAMENTO=0;
|
||||
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
|
||||
const ehFolha=m=>!!MODOS[m||modo].folha;
|
||||
const precoMetro=m=>PRECO[m||modo];
|
||||
// Uma faixa vale quando o total do produto no pedido chega à metragem dela;
|
||||
// a mais alta alcançada manda no preço de todos os itens daquele produto.
|
||||
function precoNaMetragem(m, metros){
|
||||
const bands=FAIXAS[m]||[];
|
||||
let alta=null;
|
||||
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];
|
||||
}
|
||||
// A próxima faixa à frente, para o aviso de quanto falta.
|
||||
function proximaFaixa(m, metros){
|
||||
const bands=FAIXAS[m]||[];
|
||||
let proxima=null;
|
||||
for(const band of bands) if(Number(band.from_metres)>metros && (!proxima || Number(band.from_metres)<Number(proxima.from_metres))) proxima=band;
|
||||
return proxima;
|
||||
}
|
||||
const MINIMO_M=1, GAP_CM=0.5, RODAPE_CM=5;
|
||||
const RENDERIZA=/[.](png|jpe?g|webp|gif|bmp)$/i;
|
||||
// Folha pronta: dá para medir PNG e PDF. PSD, AI, TIFF e CDR entram, mas
|
||||
|
||||
Reference in New Issue
Block a user