feat: one price per product; the grade is shown but no longer prices
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m58s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m11s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m58s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m11s
Dropstar asked on 2026-10-23 to drop the five-band ladder by grade: textile R$ 19,90 a ready sheet and R$ 21,90 loose art, UV R$ 79,90 and R$ 89,90. - the server charges PRICES (app/core/pricing.py) whatever the grade; the grade is still validated and kept with the item, and discount_cents is gone - a file opened by hand pays the product's price plus MANUAL_FILE_EXTRA_CENTS - the Site's PRECO replaces FAIXAS, TABELA and MONTAGEM; the top chip, the home example, the product cards, the selector and the price table read it (data-preco), so no page still says "a partir de R$ 14,90" - no "Desconto pela nota", ladder, "cai até" or "sai mais barato" anywhere; the buy box shows "Nota da arte" on its own line, the 96 DPI refusal and the resolution warning stay - the review reason "Nota informada sem análise da arte" is removed: it only stopped a discount. The server still checks the grade against the files, so the grade shown on the Kanban and in Tiny stays honest - the Tiny probe's test order uses the single price - docs/CONTEXT.md: Commercial rules and Still to do Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,8 +48,9 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
raise HTTPException(422, 'JPG não tem fundo transparente. Envie a arte em PNG ou PDF.')
|
||||
require_clean(row)
|
||||
rows[str(uid)] = row
|
||||
# The grade sets the price and came from the browser: before a cart is
|
||||
# approved at checkout, the server works it out from the files.
|
||||
# The grade came from the browser and is shown with the order (it no
|
||||
# longer sets the price): before a cart is approved at checkout, the
|
||||
# server works it out from the files.
|
||||
note = mismatch(Files(storage), draft['items'], rows) if reason is None else None
|
||||
reason = reason or note
|
||||
uid = uuid4()
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
"""Exact approved Site DTF price ladders; integer BRL cents at the boundary.
|
||||
"""Dropstar's single price per metre for each product; integer BRL cents at the boundary.
|
||||
|
||||
Quantity/grade must be supplied by an authenticated commercial reviewer.
|
||||
This module does not inspect artwork or perform pre-flight.
|
||||
One price per product (Dropstar, 2026-10-23). The grade is still recorded with
|
||||
each item, for the customer and the print room, but it no longer changes the
|
||||
price. This module does not inspect artwork or perform pre-flight.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
from decimal import Decimal, ROUND_CEILING
|
||||
|
||||
TIERS = {
|
||||
'file': [(90,1490),(75,1620),(60,1750),(40,1870),(0,1990)],
|
||||
'avulsa': [(90,2490),(75,2620),(60,2750),(40,2870),(0,2990)],
|
||||
'uvfile': [(90,6990),(75,7390),(60,7790),(40,8190),(0,8590)],
|
||||
'uv': [(90,8390),(75,8790),(60,9190),(40,9590),(0,9990)],
|
||||
}
|
||||
PRICES = {'file': 1990, 'avulsa': 2190, 'uvfile': 7990, 'uv': 8990}
|
||||
|
||||
# A finished sheet the Site cannot open (CDR, AI, PSD, TIFF) is opened by a
|
||||
# person before printing. It is priced at the top of the ladder, plus this per
|
||||
# metre when the business sets it, to make the formats the robot reads the
|
||||
# cheaper path. Zero (the default) adds nothing.
|
||||
# person before printing. It pays this per metre on top of the product's price
|
||||
# when the business sets it, to make the formats the robot reads the cheaper
|
||||
# path. Zero adds nothing.
|
||||
MANUAL_FORMATS = re.compile(r'\.(cdr|ai|psd|psb|tiff?)$', re.I)
|
||||
|
||||
|
||||
@@ -37,21 +33,20 @@ def is_manual(item, names) -> bool:
|
||||
|
||||
|
||||
def price(mode: str, metres: str, grade: int, extra_cents: int = 0) -> dict:
|
||||
"""The item's charge. The grade is validated and kept with the item; the
|
||||
price does not depend on it."""
|
||||
length = Decimal(str(metres))
|
||||
if mode not in TIERS or not length.is_finite() or not 0 < length <= 12000:
|
||||
if mode not in PRICES or not length.is_finite() or not 0 < length <= 12000:
|
||||
raise ValueError('Invalid product or length')
|
||||
if isinstance(grade, bool) or not isinstance(grade, int) or not 0 <= grade <= 100:
|
||||
raise ValueError('Grade must be an integer between 0 and 100')
|
||||
billed = max(Decimal('1'), (length * 10).to_integral_value(rounding=ROUND_CEILING) / 10)
|
||||
if isinstance(extra_cents, bool) or not isinstance(extra_cents, int) or extra_cents < 0:
|
||||
raise ValueError('Invalid extra charge')
|
||||
tier = next(cents for minimum, cents in TIERS[mode] if grade >= minimum)
|
||||
unit = tier + extra_cents
|
||||
unit = PRICES[mode] + extra_cents
|
||||
priced = {'mode': mode, 'metres': str(length), 'grade': grade,
|
||||
'billed_metres': str(billed), 'unit_cents': unit,
|
||||
'total_cents': int(billed * unit),
|
||||
'discount_cents': int(billed * (TIERS[mode][-1][1] - tier))}
|
||||
'total_cents': int(billed * unit)}
|
||||
if extra_cents:
|
||||
priced['manual_extra_cents'] = extra_cents
|
||||
return priced
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"""The grade (the resolution discount) recomputed from the uploaded files.
|
||||
"""The grade recomputed from the uploaded files.
|
||||
|
||||
The Site grades the art in the customer's browser and sends the grade with the
|
||||
cart, and the price depends on it. A customer who edits the page could claim a
|
||||
better grade, so before a cart is approved at checkout the server reads the
|
||||
files it already has and works the grade out again, by the Site's own rules:
|
||||
cart. The price no longer depends on it (one price per product, 2026-10-23),
|
||||
but the grade is shown with the order on the Kanban and in Tiny. A customer
|
||||
who edits the page could claim a better grade, so before a cart is approved at
|
||||
checkout the server reads the files it already has and works the grade out
|
||||
again, by the Site's own rules:
|
||||
|
||||
- a finished sheet: its pixel width over the sheet width is its DPI, and the
|
||||
item's grade comes from the worst sheet (web/site-quality.js);
|
||||
@@ -180,7 +182,7 @@ def mismatch(files, items, rows):
|
||||
"""Why a cart's grades cannot be approved at checkout, or None."""
|
||||
for item in items:
|
||||
if item['grade'] == 0:
|
||||
continue # full price: nothing to verify
|
||||
continue # no grade claimed: nothing to verify
|
||||
verified = item_grade(files, item, rows)
|
||||
if verified is None:
|
||||
return 'Nota não conferida no servidor'
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"""Quote approval: automatic at checkout, by an operator for the exceptions.
|
||||
|
||||
A quote the customer can pay is priced here from the server's own ladders,
|
||||
A quote the customer can pay is priced here from the server's own prices,
|
||||
whether an operator approved it on the Kanban or the Site approved it the
|
||||
moment it was created. The Site is a shop: a customer who can price the order
|
||||
should be able to pay for it straight away, at any hour, so only orders a
|
||||
person must look at before charging wait for the Kanban (review_reason).
|
||||
|
||||
The grade (and so the discount) is worked out in the customer's browser and
|
||||
checked against the files before an automatic approval (app/grade_check.py);
|
||||
a grade the files do not support waits for review. The layout is still the
|
||||
browser's (roadmap 3.9): the API checks its geometry. Operators see every
|
||||
order's grade and artwork at Arte recebida.
|
||||
Each product has one price (Dropstar, 2026-10-23): the grade no longer changes
|
||||
what is charged. It is still worked out in the customer's browser and shown
|
||||
with the order, so it is checked against the files before an automatic
|
||||
approval (app/grade_check.py); a grade the files do not support waits for
|
||||
review. The layout is still the browser's (roadmap 3.9): the API checks its
|
||||
geometry. Operators see every order's grade and artwork at Arte recebida.
|
||||
"""
|
||||
import os
|
||||
from decimal import Decimal
|
||||
@@ -45,10 +46,6 @@ def review_reason(draft):
|
||||
for item in draft['items']:
|
||||
if item.get('production', {}).get('version') not in PRODUCTION_VERSIONS:
|
||||
return 'Montagem antiga'
|
||||
# The Site grades only the art it could analyse; anything else is
|
||||
# priced at the full rate. A discount on it did not come from the Site.
|
||||
if item['quality_status'] == 'unverified' and item['grade'] != 0:
|
||||
return 'Nota informada sem análise da arte'
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import time
|
||||
from datetime import datetime
|
||||
from decimal import Decimal, InvalidOperation
|
||||
|
||||
from .core.pricing import TIERS
|
||||
from .core.pricing import PRICES
|
||||
from .core.secrets import load as load_secret_files
|
||||
from . import tiny
|
||||
|
||||
@@ -38,7 +38,7 @@ FIND_WAIT_SECONDS = 5
|
||||
|
||||
def test_order(cnpj, email, celular, mode, now=None, metres='1'):
|
||||
number = 'TESTE-' + (now or datetime.now(tiny.BRASILIA)).strftime('%Y%m%d%H%M')
|
||||
unit = TIERS[mode][0][1]
|
||||
unit = PRICES[mode]
|
||||
total = int(Decimal(metres) * unit)
|
||||
return {'order_id': 'teste-integracao', 'number': number, 'event': 'payment_approved',
|
||||
'order': {'customer': {'cnpj': cnpj, 'mail': email, 'zap': celular},
|
||||
|
||||
@@ -143,14 +143,32 @@ taxes, and payment-provider fees before presenting a commercial quote.
|
||||
|
||||
## Commercial rules
|
||||
|
||||
The existing rules in `web/index.html` are approved as the current source of
|
||||
truth. Do **not** redesign, simplify, or change prices, discounts, minimums,
|
||||
rounding, or product modes without explicit approval.
|
||||
The rules in `web/index.html` and `app/core/pricing.py` are approved as the
|
||||
current source of truth. Do **not** redesign, simplify, or change prices,
|
||||
minimums, rounding, or product modes without explicit approval.
|
||||
|
||||
The current site contains four product modes, quality-based price tiers (to be
|
||||
replaced by a single price per product, see "Still to do" below),
|
||||
artwork-ready discounts, separate assembly charges for loose artwork, a
|
||||
one-metre minimum, and ten-centimetre billing rounding.
|
||||
The Site has four product modes, each with one price per metre (Dropstar,
|
||||
2026-10-23, live in the code since 2026-10-26). It replaced the five-band
|
||||
ladder by grade, its "a partir de R$ 14,90" and the separate assembly charge
|
||||
for loose artwork:
|
||||
|
||||
| Product | Ready sheet | Loose artwork |
|
||||
|---|---:|---:|
|
||||
| DTF textile, 57 cm | R$ 19,90 | R$ 21,90 |
|
||||
| UV sticker, 28,5 cm | R$ 79,90 | R$ 89,90 |
|
||||
|
||||
The grade (nota) is still computed and shown, to the customer, on the Kanban
|
||||
and in Tiny's item note: it explains the file and no longer changes the price.
|
||||
Artwork below 96 DPI is still refused, and a resolution warning must still be
|
||||
acknowledged. The server still recomputes the grade from the files at checkout
|
||||
(`app/grade_check.py`) and holds for review a cart whose grade the files do not
|
||||
support, so the grade shown stays honest; the review reason "Nota informada sem
|
||||
análise da arte" existed only to stop a discount and was removed. One-metre
|
||||
minimum and ten-centimetre billing rounding. The prices are `PRECO` in
|
||||
`web/site-config.js` and `PRICES` in `app/core/pricing.py`, and
|
||||
`tests/test_pricing.py` checks they agree; every price on the Site's pages (top
|
||||
chip, home example, product cards, product selector, price table) is filled
|
||||
from `PRECO` through `data-preco`.
|
||||
|
||||
Customers buy with a CPF (a person) or a CNPJ (a company), check digits
|
||||
validated on both sides. The value keeps the `cnpj` key in orders, quotes and
|
||||
@@ -158,7 +176,7 @@ accounts; Tiny gets a CPF contact as `tipoPessoa` F, Mercado Pago the matching
|
||||
identification type, and only CNPJs are looked up in the company registry.
|
||||
|
||||
The browser may display the calculation, but production payment creation must
|
||||
recalculate and validate all price, quantity, freight, and discount values on
|
||||
recalculate and validate all price, quantity, and freight values on
|
||||
the server. Client-provided totals are never authoritative.
|
||||
|
||||
Normal JPG/PNG uploads are individual artwork by default, including when uploaded
|
||||
@@ -166,14 +184,17 @@ from the by-metre panel. They use the existing loose-artwork editor, printed
|
||||
width, quantity, and live packing canvas; packed height determines metres.
|
||||
Customers uploading an already assembled film-width image must explicitly select
|
||||
the ready-sheet option before uploading. PDF and manual-format ready sheets keep
|
||||
their existing workflow. These models retain their separate approved price tiers;
|
||||
their existing workflow. These models keep their separate prices;
|
||||
image dimensions alone must never classify a normal artwork as a finished sheet.
|
||||
|
||||
A finished sheet someone must open by hand (CDR, AI, PSD, TIFF, or a length the
|
||||
customer typed) pays the top of the ladder plus `MANUAL_FILE_EXTRA_CENTS` per
|
||||
customer typed) pays the product's price plus `MANUAL_FILE_EXTRA_CENTS` per
|
||||
metre (2026-10-13, asked at the 7 October meeting to steer customers to PNG).
|
||||
It defaults to 0; the amount is the client's to set. The Site reads it from
|
||||
`/api/session` and shows it before checkout; `app/core/pricing.py` charges it.
|
||||
The production stack sets it to 200, R$ 2,00 a metre (Dropstar, 2026-10-23);
|
||||
a value set in Portainer overrides it, and it is 0 locally and in CI. The
|
||||
amount is the client's to set. The Site reads it from `/api/session` and shows
|
||||
it before checkout (product page, help text, price table);
|
||||
`app/core/pricing.py` charges it.
|
||||
|
||||
## Freight
|
||||
|
||||
@@ -373,11 +394,10 @@ mirror stays, the designer does not move to the print queue, and Aguardando
|
||||
contato has no deadline of its own. There is no videocall: open points are
|
||||
settled in writing.
|
||||
|
||||
Done on 2026-10-26: the single price per product Dropstar asked for on
|
||||
2026-10-23 (see Commercial rules), on the Site and the server.
|
||||
|
||||
Still to do (2026-10-26):
|
||||
- Single price per product, asked by Dropstar on 2026-10-23 (not started):
|
||||
ready sheet R$ 19,90 and loose art R$ 21,90 (textile), R$ 79,90 and R$ 89,90
|
||||
(UV). The grade stays on screen but no longer sets the price. Every "a
|
||||
partir de R$ 14,90", the price table and the home example change with it.
|
||||
- The DTF number in Tiny's `numeroPedidoEcommerce` (today it is the purchase
|
||||
order, `numeroOrdemCompra`); confirm at the supervised Tiny test order.
|
||||
- Waiting on Dropstar: the DTF SITE category's numeric id (CATEGORY in
|
||||
|
||||
@@ -847,6 +847,8 @@ print-file evidence still need correction before this item can close.
|
||||
where a server-side packer (3.2) has to agree, which was the point of splitting.
|
||||
- `[ ]` 5.7 — Commercial rules duplicated between `FAIXAS` (JS) and `TIERS` (Python)
|
||||
`(F26)`. `test_pricing` guards parity; generate one from the other instead.
|
||||
2026-10-26: one price per product now, `PRECO` (JS) and `PRICES` (Python);
|
||||
`test_pricing` still guards parity.
|
||||
- `[ ]` 5.11 — Nothing tests the schema against an empty database. The 4.1 indexes
|
||||
were added next to the existing one, which sits before the tables they name, so
|
||||
`CREATE INDEX ... ON dtf_local.order_files` ran before that table existed. Every
|
||||
|
||||
@@ -151,6 +151,14 @@ try{
|
||||
// Reproduce the reported entry path, with no navigation workaround.
|
||||
// Navigation links must reach the chooser, never preselect a product.
|
||||
assert.equal(await evaluate(`document.querySelectorAll('[data-modo-cta]').length`),0);
|
||||
// One price per product (Dropstar, 2026-10-23), the same in the top chip, the
|
||||
// home example, the product cards and the price table; nothing on the page
|
||||
// still prices by the grade.
|
||||
assert.deepEqual(await evaluate(`(()=>{const de=m=>[...document.querySelectorAll('[data-preco="'+m+'"]')].map(e=>e.textContent);
|
||||
return {file:de('file'),avulsa:de('avulsa'),uvfile:de('uvfile'),uv:de('uv'),
|
||||
stale:/14,90|conforme a nota|desconto|escada|menor preço da tabela/i.test(document.body.textContent)};})()`),
|
||||
{file:['R$ 19,90','R$ 19,90','R$ 19,90','R$ 19,90'],avulsa:['R$ 21,90','R$ 21,90'],
|
||||
uvfile:['R$ 79,90','R$ 79,90'],uv:['R$ 89,90','R$ 89,90'],stale:false});
|
||||
await click('[data-modo="file"]');
|
||||
// Opening a product paints on the next frame; on a busy runner the check
|
||||
// must wait for it rather than race it.
|
||||
@@ -178,7 +186,7 @@ try{
|
||||
await evaluate(`sel([new File(['x'],'arte.jpg',{type:'image/jpeg'})])`);
|
||||
assert.equal(await evaluate(`artes.length===0 && $('recusa').textContent.includes('JPG não dá para enviar')`),true);
|
||||
// A large WebP artwork cannot be read in parts: it is measured from its
|
||||
// header and placed as a full box, with the discount, instead of refused.
|
||||
// header and placed as a full box, with its grade, instead of refused.
|
||||
await evaluate(`(()=>{const h=new Uint8Array(30);h.set([0x52,0x49,0x46,0x46,0,0,0,0,0x57,0x45,0x42,0x50,0x56,0x50,0x38,0x58]);
|
||||
h.set([0x39,0x09,0x00,0x39,0x09,0x00],24);
|
||||
const f=new File([h],'arte-grande.webp');Object.defineProperty(f,'size',{value:400*1048576});sel([f]);})()`);
|
||||
@@ -277,7 +285,16 @@ try{
|
||||
await click('#bVoltar');await click('[data-modo="file"]');
|
||||
await evaluate('sendSheet()');
|
||||
await waitFor(()=>evaluate('folhas.length===1 && !!folhas[0].previewSrc && metros===0.342'),'ready-sheet image');
|
||||
assert.deepEqual(await evaluate(`({mode:modo,art:artes.length,title:$('montcabTit').textContent,rate:precoBase(100)})`),{mode:'file',art:0,title:'Sua folha',rate:14.9});
|
||||
assert.deepEqual(await evaluate(`({mode:modo,art:artes.length,title:$('montcabTit').textContent,rate:precoMetro()})`),{mode:'file',art:0,title:'Sua folha',rate:19.9});
|
||||
// One price per product (Dropstar, 2026-10-23): the sheet is graded, and the
|
||||
// grade is shown, but the metre costs the same as for any other grade.
|
||||
await waitFor(()=>evaluate('itemAtual?.nota>0'),'graded ready sheet');
|
||||
assert.deepEqual(await evaluate(`({unit:itemAtual.unit,total:itemAtual.total,shown:$('cNota').textContent===itemAtual.nota+'/100',
|
||||
metre:$('cMetro').textContent,ladder:!!document.getElementById('cEscada'),
|
||||
discount:/desconto/i.test($('carrLin').textContent+$('resLin').textContent+$('compra').textContent)})`),
|
||||
{unit:19.9,total:19.9,shown:true,metre:'R$ 19,90',ladder:false,discount:false});
|
||||
assert.deepEqual(await evaluate(`({folha:$('tipoFolhaPreco').textContent,avulsa:$('tipoAvulsaPreco').textContent})`),
|
||||
{folha:'R$ 19,90 /m',avulsa:'R$ 21,90 /m'});
|
||||
assert.equal(await evaluate(`document.querySelectorAll('[data-cm]').length`),0);
|
||||
// With a sheet loaded the declaration is locked; it cannot flip under the customer.
|
||||
assert.equal(await evaluate(`document.querySelector('#tipoEnvio .cam[data-tipo="avulsa"]').disabled`),true);
|
||||
@@ -285,7 +302,7 @@ try{
|
||||
await waitFor(()=>evaluate('metros===0.684'),'ready-sheet repetitions');
|
||||
assert.equal(await evaluate(`document.querySelectorAll('.folhaPrevia').length`),1);
|
||||
await evaluate(`(()=>{folhas.push({f:new File(['manual'],'manual.cdr'),med:null,rep:1,m:1,an:null});pintaFolha();})()`);
|
||||
await waitFor(()=>evaluate(`itemAtual?.nota===0 && itemAtual?.unit===TABELA[modo]`),'mixed analyzed and manual sheets use table pricing');
|
||||
await waitFor(()=>evaluate(`itemAtual?.nota===0 && itemAtual?.unit===PRECO[modo]+TAXA_MANUAL`),'mixed analyzed and manual sheets: the price plus the manual charge');
|
||||
// Residue and a solid background stop the order before payment (Dropstar,
|
||||
// 2026-10-21). A residue is ink under 2 mm on both sides, measured in real
|
||||
// millimetres: the same dot, wherever it falls on the 1 mm grid, gets the
|
||||
|
||||
@@ -182,10 +182,12 @@ def run():
|
||||
'sources':[{**items[0]['production']['sources'][0],'measurement':'file'}]}}
|
||||
client.call('/operator/quotes/'+qid+'/approve',{'items':[altered,*items[1:]]},operator=True,expected=422)
|
||||
# Reviewer corrects a browser-supplied grade and length. Browser values are proposals.
|
||||
# One price per product (2026-10-23): the grade is kept, the price ignores it.
|
||||
corrected=[{**items[0],'metres':'1.01','grade':0},*items[1:]]
|
||||
approved=client.call('/operator/quotes/'+qid+'/approve',{'items':corrected},operator=True)
|
||||
assert approved['items'][0]['total_cents']==2189
|
||||
assert approved['total_cents']==2189+32370+90870+109070+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert approved['items'][0]['total_cents']==2189 and approved['items'][0]['grade']==0
|
||||
assert [i['unit_cents'] for i in approved['items'][1:]]==[2190,7990,8990]
|
||||
assert approved['total_cents']==2189+28470+103870+116870+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert approved['destination']=={**draft['destination'],'complement':''}
|
||||
client.call('/operator/quotes/'+qid+'/approve',{'items':items},operator=True,expected=409)
|
||||
assert not client.call('/quotes/'+qid)['auto_approved']
|
||||
@@ -200,15 +202,17 @@ def run():
|
||||
assert auto['status']=='approved'
|
||||
seen=client.call('/quotes/'+auto['id'])
|
||||
assert seen['auto_approved'] and seen['review_reason'] is None
|
||||
assert seen['approved']['total_cents']==6972+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert seen['approved']['total_cents']==6132+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert client.call('/quotes',small)['status']=='approved'
|
||||
client.call('/operator/quotes/'+auto['id']+'/approve',{'items':small['items']},operator=True,expected=409)
|
||||
# The Site grades only art it analysed; a discount on unanalysed art waits for a person.
|
||||
# The Site grades only art it analysed. A grade on art it did not analyse
|
||||
# is checked against the file like any other, and this one cannot be.
|
||||
claimed={**item_spec('avulsa','2.75',0,uid),'grade':90}
|
||||
held=client.call('/quotes',{**small,'request_key':str(uuid4()),'items':[claimed]})
|
||||
assert held['status']=='pending_review'
|
||||
assert client.call('/quotes/'+held['id'])['review_reason']=='Nota informada sem análise da arte'
|
||||
# A better grade than the file supports, or one the server cannot check, waits too.
|
||||
assert client.call('/quotes/'+held['id'])['review_reason']=='Nota não conferida no servidor'
|
||||
# A better grade than the file supports, or one the server cannot check, waits too:
|
||||
# the price ignores the grade, but the order shows it.
|
||||
inflated=client.call('/quotes',{**small,'request_key':str(uuid4()),'items':[item_spec('avulsa','2.75',100,graded)]})
|
||||
assert inflated['status']=='pending_review'
|
||||
assert client.call('/quotes/'+inflated['id'])['review_reason']=='Nota 100 maior que a do arquivo (90)'
|
||||
|
||||
@@ -3,39 +3,51 @@ import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import unittest
|
||||
from app.core.pricing import is_manual, price, TIERS
|
||||
from app.core.pricing import is_manual, price, PRICES
|
||||
|
||||
class PricingTests(unittest.TestCase):
|
||||
def test_every_grade_against_actual_site_javascript(self):
|
||||
# The ladders live with the rest of the Site's behaviour; this test exists
|
||||
def test_every_length_against_actual_site_javascript(self):
|
||||
# The prices live with the rest of the Site's behaviour; this test exists
|
||||
# to prove the server agrees with whatever the customer is shown.
|
||||
source = Path('web/site-config.js').read_text()
|
||||
tiers = source.split('const FAIXAS=')[1].split('\n};',1)[0]+'\n}'
|
||||
prices = source.split('const PRECO=')[1].split(';',1)[0]
|
||||
calculator = source.split('const cobrar=')[1].split(';',1)[0]
|
||||
js = f'const FAIXAS={tiers};const MINIMO_M=1;const cobrar={calculator};'
|
||||
js += '''const results=[];for(const mode of Object.keys(FAIXAS))for(let grade=0;grade<=100;grade++)
|
||||
js = f'const PRECO={prices};const MINIMO_M=1;const cobrar={calculator};'
|
||||
js += '''const results=[];for(const mode of Object.keys(PRECO))
|
||||
for(const metres of [0.01,0.99,1,1.01,1.1,2.75,2.8,2.8000000000000003,19.99,60,12000]){
|
||||
const unit=FAIXAS[mode].find(x=>grade>=x[0])[1];
|
||||
results.push([mode,String(metres),grade,cobrar(metres),Math.round(unit*100),Math.round(cobrar(metres)*unit*100)]);
|
||||
const unit=PRECO[mode];
|
||||
results.push([mode,String(metres),cobrar(metres),Math.round(unit*100),Math.round(cobrar(metres)*unit*100)]);
|
||||
}process.stdout.write(JSON.stringify(results));'''
|
||||
cases = json.loads(subprocess.check_output(['node','-e',js],text=True))
|
||||
for mode,metres,grade,billed,unit,total in cases:
|
||||
with self.subTest(mode=mode,metres=metres,grade=grade):
|
||||
result=price(mode,metres,grade)
|
||||
self.assertEqual(float(result['billed_metres']),billed)
|
||||
self.assertEqual(result['unit_cents'],unit)
|
||||
self.assertEqual(result['total_cents'],total)
|
||||
self.assertEqual({mode for mode, *_ in cases}, set(PRICES))
|
||||
for mode,metres,billed,unit,total in cases:
|
||||
for grade in (0, 39, 40, 75, 90, 100):
|
||||
with self.subTest(mode=mode,metres=metres,grade=grade):
|
||||
result=price(mode,metres,grade)
|
||||
self.assertEqual(float(result['billed_metres']),billed)
|
||||
self.assertEqual(result['unit_cents'],unit)
|
||||
self.assertEqual(result['total_cents'],total)
|
||||
|
||||
def test_assembly_is_included_at_every_tier(self):
|
||||
for grade in range(101):
|
||||
self.assertEqual(price('avulsa','1',grade)['total_cents']-price('file','1',grade)['total_cents'],1000)
|
||||
self.assertEqual(price('uv','1',grade)['total_cents']-price('uvfile','1',grade)['total_cents'],1400)
|
||||
def test_one_price_per_product(self):
|
||||
# Dropstar, 2026-10-23: textile R$ 19,90 ready sheet and R$ 21,90 loose
|
||||
# art; UV R$ 79,90 and R$ 89,90.
|
||||
self.assertEqual(PRICES, {'file': 1990, 'avulsa': 2190, 'uvfile': 7990, 'uv': 8990})
|
||||
self.assertEqual(price('avulsa', '2.75', 90)['total_cents'], 6132)
|
||||
|
||||
def test_manual_file_extra_is_per_metre_and_not_a_discount(self):
|
||||
def test_the_grade_never_changes_the_price(self):
|
||||
for mode in PRICES:
|
||||
charges = {(p['unit_cents'], p['total_cents']) for p in (price(mode, '2.75', g) for g in range(101))}
|
||||
self.assertEqual(len(charges), 1, mode)
|
||||
self.assertNotIn('discount_cents', price(mode, '1', 100))
|
||||
# The grade is still kept with the item, for the Kanban and Tiny.
|
||||
self.assertEqual(price('file', '1', 92)['grade'], 92)
|
||||
|
||||
def test_manual_file_extra_is_per_metre(self):
|
||||
plain, extra = price('file', '1.01', 0), price('file', '1.01', 0, 500)
|
||||
self.assertEqual(extra['unit_cents'], plain['unit_cents'] + 500)
|
||||
self.assertEqual(extra['total_cents'], plain['total_cents'] + 550)
|
||||
self.assertEqual(extra['discount_cents'], 0)
|
||||
# On top of the single price, whatever grade the item carries.
|
||||
self.assertEqual(price('file', '1', 100, 200)['unit_cents'], 2190)
|
||||
self.assertEqual(extra['manual_extra_cents'], 500)
|
||||
self.assertNotIn('manual_extra_cents', plain)
|
||||
for bad in (-1, True, 1.5):
|
||||
|
||||
@@ -26,8 +26,10 @@ class ReviewReasonTest(unittest.TestCase):
|
||||
self.assertEqual(self.reason(item(metres='30'), item(metres='20.1')), 'Pedido acima de 50 m')
|
||||
self.assertEqual(self.reason(item(metres='6'), QUOTE_AUTO_MAX_METRES='5'), 'Pedido acima de 5 m')
|
||||
|
||||
def test_a_discount_the_site_could_not_have_given_waits(self):
|
||||
self.assertEqual(self.reason(item(grade=90, quality='unverified')), 'Nota informada sem análise da arte')
|
||||
def test_a_grade_on_unanalysed_art_no_longer_waits_here(self):
|
||||
# The grade no longer sets the price; the server checks it against the
|
||||
# files instead (app/grade_check.py), as for any other cart.
|
||||
self.assertIsNone(self.reason(item(grade=90, quality='unverified')))
|
||||
|
||||
def test_old_layouts_and_switching_it_off(self):
|
||||
self.assertEqual(self.reason(item(version=1)), 'Montagem antiga')
|
||||
|
||||
@@ -462,8 +462,10 @@ class TinySkuTests(FakeTinyCase):
|
||||
tiny_probe.main(['pedido', '--cnpj', '11222333000181', '--email', 'a@example.test',
|
||||
'--celular', '16999999999', '--metros', '1,3'], orders=self.tiny, out=lines.append)
|
||||
text = '\n'.join(lines)
|
||||
# 1,30 m at the single price, R$ 19,90: one "1 metro" and three "10 cm".
|
||||
self.assertIn('"quantidade": 1', text)
|
||||
self.assertIn('"valorUnitario": 4.47', text)
|
||||
self.assertIn('"valorUnitario": 19.9', text)
|
||||
self.assertIn('"valorUnitario": 5.97', text)
|
||||
# A new contact is previewed with the name it will get.
|
||||
self.assertIn('será criado como "a@example.test"', text)
|
||||
self.tiny.names = lambda cnpj: {'legal': 'EMPRESA TESTE LTDA', 'trade': 'Teste'}
|
||||
|
||||
@@ -59,8 +59,13 @@
|
||||
if(limit)limit.textContent='Até '+(session.max_upload_bytes/1073741824).toFixed(0)+' GB por arquivo.';
|
||||
// What the server charges for a file opened by hand, never the page's own text.
|
||||
const zona=document.getElementById('zManual');
|
||||
if(zona)zona.innerHTML='Tem <b>CDR, AI, PSD ou TIFF</b>? Pode mandar também. Alguém abre na mão, e o '+
|
||||
'metro sai pelo preço cheio'+(session.manual_extra_cents>0?' mais '+rs(session.manual_extra_cents/100):'')+'.';
|
||||
const extra=session.manual_extra_cents>0?rs(session.manual_extra_cents/100):'';
|
||||
if(zona)zona.innerHTML='Tem <b>CDR, AI, PSD ou TIFF</b>? Pode mandar também. Alguém abre na mão'+
|
||||
(extra?', e o metro custa '+extra+' a mais':'')+'.';
|
||||
const duvida=document.getElementById('duvidaManual');
|
||||
if(duvida)duvida.textContent='alguém abre na mão'+(extra?', sai mais devagar e o metro custa '+extra+' a mais':' e sai mais devagar');
|
||||
const tabela=document.getElementById('tabelaManual');
|
||||
if(tabela){tabela.hidden=!extra;tabela.textContent='Arquivo em CDR, AI, PSD ou TIFF, que alguém abre na mão: + '+extra+' por metro.';}
|
||||
if(session.manual_extra_cents>0){
|
||||
TAXA_MANUAL=session.manual_extra_cents/100;
|
||||
if(typeof folhas!=='undefined'&&folhas.length&&typeof pintaFolha==='function')pintaFolha();
|
||||
|
||||
@@ -713,7 +713,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<div class="w hero2-grid">
|
||||
<div class="hero2-text">
|
||||
<div class="chips">
|
||||
<span class="chip2 destaque">Metro a partir de R$ 14,90</span>
|
||||
<span class="chip2 destaque">Metro a partir de <span data-preco="file">R$ 19,90</span></span>
|
||||
<span class="chip2">Franca · SP · envio em até 24 h</span>
|
||||
</div>
|
||||
<h1>A gente encaixa sua folha e você paga <em>menos metro</em></h1>
|
||||
@@ -737,7 +737,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<div class="hf-num">
|
||||
<div><span>Metragem</span><b>0,60 m</b></div>
|
||||
<div><span>Nota da arte</span><b class="verde">92</b></div>
|
||||
<div><span>Preço do metro</span><b class="laranja">R$ 14,90</b></div>
|
||||
<div><span>Preço do metro</span><b class="laranja" data-preco="file">R$ 19,90</b></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -767,7 +767,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<div class="cards-cab">
|
||||
<div><div class="et">Escolha o produto</div>
|
||||
<h2>Qual é o seu caso?</h2></div>
|
||||
<p>O preço do metro depende da nota da arte: quanto melhor o arquivo, menor o preço.</p>
|
||||
<p>Preço único por produto. A nota da arte aparece na tela para você entender o seu arquivo; ela não muda o preço.</p>
|
||||
</div>
|
||||
<div class="escolha">
|
||||
<button class="ec f" data-modo="file">
|
||||
@@ -775,7 +775,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<h3>Arquivo por metro</h3>
|
||||
<p>Você monta a folha e manda pronta. Revisamos, corrigimos e reencaixamos se sobrar espaço.</p>
|
||||
<div class="ec-pe">
|
||||
<div class="ec-preco"><span>de</span><b data-de="file">—</b><span>a <em data-ate="file">—</em> /m conforme a nota da arte</span></div>
|
||||
<div class="ec-preco"><b data-preco="file">R$ 19,90</b><span>por metro</span></div>
|
||||
<span class="ec-go">Enviar minha folha</span>
|
||||
</div>
|
||||
</button>
|
||||
@@ -784,7 +784,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<h3>Artes avulsas</h3>
|
||||
<p>Cada arte num arquivo. A gente monta a folha com o melhor encaixe. Montagem inclusa no preço.</p>
|
||||
<div class="ec-pe">
|
||||
<div class="ec-preco"><span>de</span><b data-de="avulsa">—</b><span>a <em data-ate="avulsa">—</em> /m conforme a nota da arte</span></div>
|
||||
<div class="ec-preco"><b data-preco="avulsa">R$ 21,90</b><span>por metro</span></div>
|
||||
<span class="ec-go">Enviar minhas artes</span>
|
||||
</div>
|
||||
</button>
|
||||
@@ -793,7 +793,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<h3>Arquivo por metro · UV</h3>
|
||||
<p>Sua folha de UV montada. Para rígidos: caneca, garrafa, case. Não precisa de prensa.</p>
|
||||
<div class="ec-pe">
|
||||
<div class="ec-preco"><span>de</span><b data-de="uvfile">—</b><span>a <em data-ate="uvfile">—</em> /m conforme a nota da arte</span></div>
|
||||
<div class="ec-preco"><b data-preco="uvfile">R$ 79,90</b><span>por metro</span></div>
|
||||
<span class="ec-go">Enviar folha de UV</span>
|
||||
</div>
|
||||
</button>
|
||||
@@ -802,7 +802,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<h3>Artes avulsas · UV</h3>
|
||||
<p>Cada arte num arquivo. Montamos a folha de UV com o melhor encaixe. Montagem inclusa no preço.</p>
|
||||
<div class="ec-pe">
|
||||
<div class="ec-preco"><span>de</span><b data-de="uv">—</b><span>a <em data-ate="uv">—</em> /m conforme a nota da arte</span></div>
|
||||
<div class="ec-preco"><b data-preco="uv">R$ 89,90</b><span>por metro</span></div>
|
||||
<span class="ec-go">Enviar artes de UV</span>
|
||||
</div>
|
||||
</button>
|
||||
@@ -843,7 +843,7 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<span class="bt">ou escolher no computador</span>
|
||||
<span class="zOutra"><b id="zOutra">Adicionar outra folha</b> ou arraste aqui</span>
|
||||
<span class="zManual" id="zManual">Tem <b>CDR, AI, PSD ou TIFF</b>? Pode mandar também.
|
||||
Alguém abre na mão, e o metro sai pelo preço cheio mais R$ 2,00.</span>
|
||||
Alguém abre na mão, e o metro custa R$ 2,00 a mais.</span>
|
||||
</div>
|
||||
<div class="resumoA" id="rA" style="display:none"></div>
|
||||
<input type="file" id="inp" hidden>
|
||||
@@ -851,18 +851,16 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<h3 class="reqcab">Dúvidas:</h3>
|
||||
|
||||
<details>
|
||||
<summary>Como pagar o menor metro</summary>
|
||||
<summary>Dicas para o seu arquivo</summary>
|
||||
<ul>
|
||||
<li class="s"><b>300 DPI no tamanho que vai imprimir.</b> É a nota máxima
|
||||
e o menor preço da tabela</li>
|
||||
<li class="s"><b>300 DPI no tamanho que vai imprimir.</b> É a nota máxima</li>
|
||||
<li class="s"><b>O tamanho manda mais que o arquivo.</b> A mesma arte passa
|
||||
em 20 cm e não passa em 40. Reduzir um pouco costuma pular uma faixa
|
||||
de preço inteira</li>
|
||||
em 20 cm e não passa em 40. Reduzir um pouco costuma subir a nota</li>
|
||||
<li class="s"><b>Larguras parecidas rendem mais.</b> Se as suas artes têm
|
||||
medidas próximas, cabem mais por fileira e a folha encolhe</li>
|
||||
</ul>
|
||||
<p class="obs2">Resolução é a única coisa que mexe no preço — porque é a
|
||||
única que a gente não consegue melhorar por você.</p>
|
||||
<p class="obs2">A nota não muda o preço do metro: ela serve para você
|
||||
entender o seu arquivo.</p>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
@@ -889,8 +887,8 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<li class="a"><b>PDF grande.</b> Sem UserUnit, a página passa do limite de 508 cm
|
||||
do formato; divida a folha ou mande PNG. Envie um PDF de uma página por folha.</li>
|
||||
<li class="a"><b>TIFF, PSD, AI e CDR</b> a gente aceita, mas ninguém consegue
|
||||
conferir sozinho: alguém abre na mão, sai mais devagar e o metro vai pela
|
||||
tabela, sem desconto de nota</li>
|
||||
conferir sozinho: <span id="duvidaManual">alguém abre na mão, sai mais devagar
|
||||
e o metro custa R$ 2,00 a mais</span></li>
|
||||
<li class="a"><b>JPG não passa:</b> não tem fundo transparente, e o branco do
|
||||
fundo sai no filme. Exporte a folha em PNG ou PDF</li>
|
||||
<li class="a">Em <b>artes avulsas</b> só PNG com fundo transparente: a montagem
|
||||
@@ -929,15 +927,11 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<div class="compra" id="compra">
|
||||
<div class="aoVivo" id="aoVivo"></div>
|
||||
<div id="compraVals" hidden>
|
||||
<div class="cEscada">
|
||||
<span>Preço do metro pela resolução</span>
|
||||
<ol id="cEscada"></ol>
|
||||
</div>
|
||||
<div class="cLin"><span>Nota da arte</span><b id="cNota">—</b></div>
|
||||
<div class="cLin"><span id="cMetroLbl">Metro</span><b id="cMetro">—</b></div>
|
||||
<div class="cLin"><span>Metragem <small>(a cada 10 cm)</small></span><b id="cMetragem">—</b></div>
|
||||
<p class="cObs" id="cObs"></p>
|
||||
<div class="cTot"><span>Total</span><b id="cTotal">—</b></div>
|
||||
<p class="cEco" id="cEco"></p>
|
||||
<div id="qmsg" style="display:none"></div>
|
||||
<div class="ciente" id="ciente">
|
||||
<h4 id="cienteTit">Ressalva de resolução</h4>
|
||||
@@ -1129,19 +1123,16 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
<section id="info" class="info2"><div class="w info2-grid">
|
||||
<div class="info2-preco">
|
||||
<div class="et">Preço</div>
|
||||
<h2>Arte melhor, metro mais barato</h2>
|
||||
<p>A nota aparece na tela antes de você pagar. Preço da folha que você monta:</p>
|
||||
<h2>Preço único por produto</h2>
|
||||
<p>A nota da arte aparece na tela antes de você pagar, para você entender o seu arquivo. Ela não muda o preço. Preço do metro:</p>
|
||||
<table>
|
||||
<thead><tr><th scope="col">Nota da arte</th><th scope="col">Têxtil 57 cm</th><th scope="col">UV 28,5 cm</th></tr></thead>
|
||||
<thead><tr><th scope="col">Produto</th><th scope="col">Têxtil 57 cm</th><th scope="col">UV 28,5 cm</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>90 a 100</td><td class="melhor">R$ 14,90</td><td class="melhor">R$ 69,90</td></tr>
|
||||
<tr><td>75 a 89</td><td>R$ 16,20</td><td>R$ 73,90</td></tr>
|
||||
<tr><td>60 a 74</td><td>R$ 17,50</td><td>R$ 77,90</td></tr>
|
||||
<tr><td>40 a 59</td><td>R$ 18,70</td><td>R$ 81,90</td></tr>
|
||||
<tr><td>abaixo de 40</td><td>R$ 19,90</td><td>R$ 85,90</td></tr>
|
||||
<tr><td>Folha pronta</td><td data-preco="file">R$ 19,90</td><td data-preco="uvfile">R$ 79,90</td></tr>
|
||||
<tr><td>Artes avulsas</td><td data-preco="avulsa">R$ 21,90</td><td data-preco="uv">R$ 89,90</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="nota2">Montagem das artes avulsas: + R$ 10,00 no têxtil e + R$ 14,00 no UV, em qualquer faixa.</p>
|
||||
<p class="nota2" id="tabelaManual">Arquivo em CDR, AI, PSD ou TIFF, que alguém abre na mão: + R$ 2,00 por metro.</p>
|
||||
</div>
|
||||
<div class="info2-vant">
|
||||
<div><b class="n">57 cm</b><b>O dobro do filme padrão</b><span>Cabe o dobro de arte por metro corrido.</span></div>
|
||||
|
||||
@@ -106,8 +106,9 @@ const ICON_CHAT=['M7.9 20A9 9 0 1 0 4 16.1L2 22Z'];
|
||||
const ICON_COPY=['M9 9h12v12H9z','M5 15V5a2 2 0 0 1 2-2h10'];
|
||||
|
||||
// ---- Badges: one system on every screen (canvas "Kanban DTF — redesign", v2) --
|
||||
// The grade pill is coloured by the price ladder's bands (90/75/60/40), the
|
||||
// same for all four products; product, status and warnings are pills with text.
|
||||
// The grade pill is coloured in bands (90/75/60/40), those of the old price
|
||||
// ladder; the grade no longer sets the price (2026-10-23). The bands are the same
|
||||
// for all four products; product, status and warnings are pills with text.
|
||||
const GRADE_BANDS=[[90,'g90'],[75,'g75'],[60,'g60'],[40,'g40'],[0,'g0']];
|
||||
function gradePill(grade){
|
||||
const n=grade===null||grade===undefined||grade===''?NaN:Number(grade);
|
||||
|
||||
@@ -57,12 +57,8 @@ function pintaPedido(){
|
||||
const frete = entrega.tipo==='frete' && entrega.cotado ? entrega.valor : 0;
|
||||
const soma = itens + frete;
|
||||
const n = aPagar.length, noCarrinho = pedido.length + (itemAtual?1:0);
|
||||
const eco = aPagar
|
||||
.reduce((t,it)=>t+(TABELA[it.modo]-(it.unit-(it.extra||0)))*it.cob, 0);
|
||||
$('resLin').innerHTML =
|
||||
'<div class="l"><span>'+n+(n===1?' item':' itens')+'</span><b>'+rs(itens+eco)+'</b></div>'+
|
||||
(eco>0.01? '<div class="l" style="color:var(--verde-ml)"><span>Desconto pela nota</span>'+
|
||||
'<b style="color:var(--verde-ml)">− '+rs(eco)+'</b></div>' : '')+
|
||||
'<div class="l"><span>'+n+(n===1?' item':' itens')+'</span><b>'+rs(itens)+'</b></div>'+
|
||||
'<div class="l"><span>Frete'+(entrega.tipo==='frete' && entrega.cotado
|
||||
? ' · '+escapeHTML((entrega.opcoes||[]).find(o=>o.service===entrega.servico)?.description||'') : '')+
|
||||
'</span><b>'+
|
||||
@@ -81,21 +77,14 @@ function pintaPedido(){
|
||||
window.dispatchEvent(new Event('dtf-cart-changed'));
|
||||
}
|
||||
|
||||
// Um preço por produto (Dropstar, 23/10/2026): a nota aparece, mas não entra na conta.
|
||||
function carrinho(){
|
||||
const base=precoBase(nota), cob=cobrar(metros);
|
||||
const base=precoMetro(), cob=cobrar(metros);
|
||||
const extra=folhaManual()? TAXA_MANUAL : 0;
|
||||
const unit=base+extra, tot=cob*unit, sobra=+(cob-metros).toFixed(2);
|
||||
$('carr').classList.add('on');
|
||||
let l='<div class="l"><span>'+MODOS[modo].tit+'</span><b>'+rs(base)+'/m</b></div>';
|
||||
{
|
||||
const teto=TABELA[modo], eco=(teto-base)*cob;
|
||||
l = '<div class="l"><span>'+MODOS[modo].tit+' · tabela</span><b>'+rs(teto)+'/m</b></div>';
|
||||
l += eco>0.01
|
||||
? '<div class="l" style="color:#7FD4A0"><span>Desconto pela nota '+nota+'</span><b>−'+rs(eco)+'</b></div>'
|
||||
: '<div class="l" style="color:#8D9AB0"><span>Nota '+nota+' · sem desconto</span><b>—</b></div>';
|
||||
}
|
||||
if(!ehFolha()) l += '<div class="l" style="color:#8D9AB0"><span>Montagem da folha</span>'+
|
||||
'<b>inclusa · '+rs(MONTAGEM[modo])+'/m</b></div>';
|
||||
if(!ehFolha()) l += '<div class="l" style="color:#8D9AB0"><span>Montagem da folha</span><b>inclusa</b></div>';
|
||||
if(extra) l += '<div class="l"><span>Arquivo aberto na mão</span><b>+'+rs(extra)+'/m</b></div>';
|
||||
l += '<div class="l"><span>Metragem'+(sobra>0.001?' · arredondada para 10 cm':'')+
|
||||
'</span><b>'+fmtM(cob)+' m</b></div>';
|
||||
@@ -140,11 +129,6 @@ function carrinho(){
|
||||
desc:fmtM(cob)+' m · '+rs(unit)+'/m · nota '+nota};
|
||||
pintaPedido();
|
||||
previa();
|
||||
if(nota<90){
|
||||
const piso=pisoEscada(), ganho=(unit-piso)*cob;
|
||||
if(ganho>0.5) qm('<b>Dá para pagar menos.</b> Com a arte em 300 DPI, '+
|
||||
'o metro cai para '+rs(piso)+' — são '+rs(ganho)+' a menos neste pedido.','var(--verde)');
|
||||
}
|
||||
}
|
||||
// Removing is one click, and a wrong click is undone from the notice that follows.
|
||||
let desfazerAcao=null, desfazerTimer=null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Site DTF — the product page's buy box: price ladder, price per metre, billed length,
|
||||
/* Site DTF — the product page's buy box: the grade, price per metre, billed length,
|
||||
total and the add-to-cart button, beside the live sheet. It shows the item
|
||||
the other site-*.js files already priced (itemAtual) and never computes a
|
||||
price of its own, so the box and the cart always agree. */
|
||||
@@ -9,23 +9,12 @@
|
||||
vals.hidden=!it;
|
||||
add.disabled=!it || !itemPodeEnviar(it);
|
||||
if(!it) return;
|
||||
const semNota=!it.nota;
|
||||
// The price ladder in resolution: nota = DPI ÷ 3, so 90 is 270 DPI.
|
||||
const faixas=FAIXAS[it.modo], ativa=faixas.findIndex(([min])=>it.nota>=min);
|
||||
$('cEscada').innerHTML=faixas.map(([min,v],i)=>
|
||||
'<li'+(i===ativa?' class="on" aria-current="true"':'')+'><span>'+
|
||||
(min? min*3+'+'+(i? '' : ' DPI') : semNota? 'cheio' : 'menos')+'</span>'+
|
||||
'<b>'+rs(v).slice(3)+'</b></li>').join('');
|
||||
const analisadas=ehFolha(it.modo) && folhas.length && folhas.every(x=>x.an);
|
||||
$('cMetroLbl').textContent = it.extra ? 'Metro · cheio + '+rs(it.extra)+' manual'
|
||||
: semNota ? 'Metro · preço cheio'
|
||||
: analisadas && folhas.every(x=>x.an.vetor) ? 'Metro · arte vetorial'
|
||||
: analisadas ? 'Metro · '+Math.min(...folhas.map(x=>x.an.dpi))+' DPI'
|
||||
: 'Metro';
|
||||
// One price per product (Dropstar, 2026-10-23): the grade is shown to explain
|
||||
// the file, on its own line, and never changes the metre.
|
||||
$('cNota').textContent = it.nota ? it.nota+'/100' : '—';
|
||||
$('cMetroLbl').textContent = it.extra ? 'Metro · com '+rs(it.extra)+' de arquivo manual' : 'Metro';
|
||||
$('cMetro').textContent=rs(it.unit);
|
||||
$('cMetragem').textContent=fmtM(it.cob)+' m';
|
||||
const economia=(TABELA[it.modo]-(it.unit-(it.extra||0)))*it.cob;
|
||||
$('cEco').textContent = economia>0.005 ? rs(economia)+' a menos pela resolução da arte' : '';
|
||||
const partes=ehFolha(it.modo) ? Math.ceil(it.metros/20) : 1;
|
||||
$('cPartes').textContent = partes>1 ? ' Sai em '+partes+' partes de até 20 m.' : '';
|
||||
const sobraCm=Math.round((it.cob-it.metros)*100);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Site DTF — Product tables, commercial ladders, shared state and field validation.
|
||||
/* Site DTF — Product tables, prices, shared state and field validation.
|
||||
Extracted verbatim from the single inline script in web/index.html.
|
||||
Loaded as classic scripts in the order listed there: they share one global
|
||||
scope and run top to bottom, exactly as the original did. */
|
||||
@@ -45,22 +45,16 @@ const MODOS={
|
||||
zt:'Arraste suas artes de UV',
|
||||
zs:'PNG com fundo transparente · informe a largura de cada arte'}
|
||||
};
|
||||
// Quatro escadas. A de artes avulsas e a da folha pronta mais a montagem:
|
||||
// R$ 10,00 no têxtil, R$ 14,00 no UV, constante em todas as faixas.
|
||||
const FAIXAS={
|
||||
file: [[90,14.90],[75,16.20],[60,17.50],[40,18.70],[0,19.90]],
|
||||
avulsa:[[90,24.90],[75,26.20],[60,27.50],[40,28.70],[0,29.90]],
|
||||
uvfile:[[90,69.90],[75,73.90],[60,77.90],[40,81.90],[0,85.90]],
|
||||
uv: [[90,83.90],[75,87.90],[60,91.90],[40,95.90],[0,99.90]]
|
||||
};
|
||||
const TABELA={file:19.90, avulsa:29.90, uvfile:85.90, uv:99.90}; // teto de cada escada
|
||||
const MONTAGEM={avulsa:10.00, uv:14.00}; // o que a montagem soma sobre a folha pronta
|
||||
// Preço único por produto (Dropstar, 23/10/2026). A nota da arte continua na
|
||||
// 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};
|
||||
// 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;
|
||||
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
|
||||
const ehFolha=m=>!!MODOS[m||modo].folha;
|
||||
const pisoEscada=m=>FAIXAS[m||modo][0][1];
|
||||
const precoMetro=m=>PRECO[m||modo];
|
||||
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
|
||||
@@ -162,9 +156,6 @@ const larguraFilme=()=>MODOS[modo].larg;
|
||||
// cobrança proporcional: arredonda para cima em 10 cm · 2,75 m vira 2,80 m
|
||||
const cobrar=m=>Math.max(MINIMO_M, Math.ceil(m*10)/10);
|
||||
const fmtM=m=>m.toFixed(2).replace('.',',');
|
||||
const precoBase=n=>
|
||||
(FAIXAS[modo].find(f=>n>=f[0])||FAIXAS[modo][FAIXAS[modo].length-1])[1];
|
||||
const descontoMetragem=()=>0; // sem progressão por quantidade
|
||||
const cls=n=>n>=85?'ok':n>=50?'av':'er';
|
||||
const dpiDe=a=>a.cm>0? (a.giro?a.py:a.px)/(a.cm/2.54) : 0;
|
||||
// girar 90° inverte a proporção · espelhar não muda medida, só o desenho
|
||||
|
||||
@@ -30,8 +30,8 @@ function pintaModo(){
|
||||
$('zOutra').textContent = ehFolha(m) ? 'Adicionar outra folha' : 'Adicionar mais artes';
|
||||
$('zona').classList.remove('compacta');
|
||||
$('inp').multiple=c.multi;
|
||||
// The file decides the price: PNG and PDF are checked here, the others by hand.
|
||||
// JPG has no transparency and is refused (ACEITA, web/site-config.js).
|
||||
// The file decides how it is checked: PNG and PDF here, the others by hand
|
||||
// (TAXA_MANUAL). JPG has no transparency and is refused (ACEITA, web/site-config.js).
|
||||
$('inp').accept = ehFolha(m) ? '.png,.pdf,.tif,.tiff,.psd,.psb,.ai,.cdr'
|
||||
: '.png,.webp';
|
||||
$('catFoco').className='cat '+(ehFolha(m)?'file':'av');
|
||||
@@ -50,8 +50,8 @@ function pintaTipoEnvio(){
|
||||
if(el.hidden) return;
|
||||
const folha = ehFolha() ? modo : PAR[modo];
|
||||
const avulsa = ehFolha() ? PAR[modo] : modo;
|
||||
$('tipoFolhaPreco').textContent=rs(pisoEscada(folha))+' a '+rs(TABELA[folha]).slice(3)+' /m';
|
||||
$('tipoAvulsaPreco').textContent='+ '+rs(MONTAGEM[avulsa])+' /m';
|
||||
$('tipoFolhaPreco').textContent=rs(PRECO[folha])+' /m';
|
||||
$('tipoAvulsaPreco').textContent=rs(PRECO[avulsa])+' /m';
|
||||
$('larguraFolhaPronta').textContent=String(MODOS[folha].larg).replace('.',',');
|
||||
const atual = ehFolha() ? 'folha' : 'avulsa';
|
||||
el.querySelectorAll('.cam').forEach(b=>{
|
||||
@@ -73,7 +73,7 @@ function recusaFolha(x, md){
|
||||
'Para ocupar os '+n1(larguraFilme())+' cm do filme ela teria só '+md.dpiFolha+
|
||||
' DPI, e o mínimo para imprimir é '+DPI_RECUSA+'. '+
|
||||
'Se for uma arte para montarmos, use <b>'+MODOS[destino].tit+'</b>, '+
|
||||
'a partir de '+rs(pisoEscada(destino))+'/m. '+
|
||||
'a '+rs(PRECO[destino])+' o metro. '+
|
||||
'<button type="button" id="usarAvulsa">Enviar como '+MODOS[destino].tit.toLowerCase()+'</button>');
|
||||
const botao=$('usarAvulsa');
|
||||
if(botao) botao.addEventListener('click',()=>{
|
||||
|
||||
@@ -502,7 +502,7 @@ function pintaFolha(){
|
||||
(x.pdfGrande? '<span class="chipSo">Conferência manual · sem conferência no site</span>'+
|
||||
'<p class="repTxt">Este PDF tem mais de 150 MB, e o site não confere arquivo desse tamanho: '+
|
||||
'resíduo de recorte, fundo e resolução ficam para a equipe, que abre antes de imprimir, e o '+
|
||||
'pedido pode voltar depois de pago. O metro sai pela tabela, <b>'+rs(TABELA[modo])+'</b>. '+
|
||||
'pedido pode voltar depois de pago. '+
|
||||
'Exportando em <b>PNG</b>, ou num PDF menor, a conferência sai aqui, antes de pagar.</p>' : '')+
|
||||
(suspeito? '<p class="avisoF"><b>Este PDF passa do tamanho que o formato comporta.</b> '+
|
||||
'A especificação para em 508 cm e o seu tem '+n1(x.med.alt)+' cm. '+
|
||||
@@ -518,14 +518,16 @@ function pintaFolha(){
|
||||
medida='<span class="repPeso">'+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+'</span>'+
|
||||
'<p class="avisoF"><b>Este PDF não pode ser orçado.</b> '+escapeHTML(x.measurementError)+'</p>';
|
||||
}else{
|
||||
const teto=TABELA[modo], piso=pisoEscada();
|
||||
const dif=(x.m>0)? (teto+TAXA_MANUAL-piso)*cobrar(x.m*(x.rep||1)) : 0;
|
||||
medida='<span class="chipSo">Conferência manual · preço cheio</span>'+
|
||||
// Só a abertura manual muda o metro (TAXA_MANUAL); a nota não mexe no preço.
|
||||
const dif=(x.m>0)? TAXA_MANUAL*cobrar(x.m*(x.rep||1)) : 0;
|
||||
medida='<span class="chipSo">Conferência manual</span>'+
|
||||
'<p class="repTxt">O navegador não abre '+escapeHTML(extDe(x.f.name))+', então alguém da equipe '+
|
||||
'confere antes de imprimir e o metro sai pela tabela, <b>'+rs(teto)+'</b>'+
|
||||
(TAXA_MANUAL? ', mais <b>'+rs(TAXA_MANUAL)+'</b> pela abertura manual' : '')+'. '+
|
||||
'Exportando em <b>PNG ou PDF</b>, o metro pode cair até <b>'+rs(piso)+'</b>'+
|
||||
(dif>0.5? ' — <b>'+rs(dif)+' a menos</b> só nesta folha' : '')+'.</p>';
|
||||
'confere antes de imprimir'+
|
||||
(TAXA_MANUAL? ' e o metro sai a <b>'+rs(precoMetro()+TAXA_MANUAL)+'</b>, com <b>'+rs(TAXA_MANUAL)+
|
||||
'</b> pela abertura manual' : '')+'. '+
|
||||
'Exportando em <b>PNG ou PDF</b>, a conferência sai aqui, antes de pagar'+
|
||||
(TAXA_MANUAL? ', e o metro fica em <b>'+rs(precoMetro())+'</b>'+
|
||||
(dif>0.5? ' — <b>'+rs(dif)+' a menos</b> só nesta folha' : '') : '')+'.</p>';
|
||||
manual='<div class="campo"><label for="comp'+i+'">Comprimento</label>'+
|
||||
'<span class="un"><input type="number" id="comp'+i+'" min="0.5" max="60" step="0.01" data-comp="'+i+'" '+
|
||||
'placeholder="0,00" value="'+(x.m? x.m.toFixed(2):'')+'"><i>m</i></span></div>';
|
||||
@@ -535,7 +537,7 @@ function pintaFolha(){
|
||||
'<span class="progT">'+textoProgresso(x)+'</span>'
|
||||
: x.semAnalise
|
||||
? '<div class="progF"><b>Não conseguimos conferir esta folha.</b> '+escapeHTML(x.semAnalise)+
|
||||
'. Seguimos com o preço de tabela — se quiser a nota e o desconto, exporte a mesma '+
|
||||
'. Seguimos sem a nota, e a conferência é feita na mão. Se quiser a nota, exporte a mesma '+
|
||||
'folha em <b>PNG</b>, que a conferência é bem mais leve.</div>'
|
||||
: '';
|
||||
// A small thumbnail made once: the list is rebuilt on every change, and the
|
||||
|
||||
@@ -32,18 +32,16 @@ function avaliar(){
|
||||
reencaixado=false;
|
||||
const ans=folhas.map(x=>x.an).filter(Boolean);
|
||||
if(ans.length!==folhas.length){
|
||||
// A nota precisa cobrir cada folha faturada. Uma folha sem análise não
|
||||
// herda a nota/desconto de outra folha que o navegador conseguiu abrir.
|
||||
// A nota precisa cobrir cada folha. Uma folha sem análise não herda a
|
||||
// nota de outra folha que o navegador conseguiu abrir.
|
||||
const ausentes=folhas.filter(f=>!f.an);
|
||||
const exts=[...new Set(ausentes.map(f=>extDe(f.f.name)))].join(', ');
|
||||
mostraNota([
|
||||
['av','Sem nota · '+exts+' sem análise completa',
|
||||
ausentes.length+' de '+folhas.length+' folha(s) precisam de conferência manual'],
|
||||
['er','Metro pela tabela · '+rs(TABELA[modo]),
|
||||
'exportando em PNG ou PDF, cai até '+rs(pisoEscada())],
|
||||
['fix','Alguém abre seu arquivo','a conferência é feita na mão, na sala']
|
||||
], 0, folhas.length>1? folhas.length+' folhas' : folhas[0].f.name,
|
||||
larguraFilme()+' cm · '+fmtM(metros)+' m · preço de tabela');
|
||||
larguraFilme()+' cm · '+fmtM(metros)+' m');
|
||||
return {pronto:true};
|
||||
}
|
||||
const dpi=Math.min(...ans.map(a=>a.dpi));
|
||||
@@ -91,7 +89,7 @@ function avaliar(){
|
||||
const media=Math.round(notas.reduce((s,n)=>s+n,0)/notas.length), pior=Math.min(...notas);
|
||||
mostraNota([
|
||||
['ok','Montagem por nossa conta','5 mm garantidos'],
|
||||
[cls(pior),'Pior arte em '+pior+'%',pior>=85?'todas em boa resolução':'reenviar maior sai mais barato']
|
||||
[cls(pior),'Pior arte em '+pior+'%',pior>=85?'todas em boa resolução':'há arte abaixo da resolução ideal']
|
||||
],media,artes.length+' arte'+(artes.length>1?'s':''),
|
||||
'folha montada por nós · '+fmtM(metros)+' m');
|
||||
return {pronto:true};
|
||||
@@ -142,7 +140,7 @@ function ressalvaResolucao(){
|
||||
const box=$('ciente'), chk=$('cienteOk');
|
||||
let baixas=[], geral=300, recusadas=[];
|
||||
if(ehFolha()){
|
||||
// Uma régua só: o número que precifica é o número que bloqueia.
|
||||
// Uma régua só: o número da nota é o número que bloqueia.
|
||||
// Recusa quando a média por área fica abaixo de 96 DPI — a folha inteira não
|
||||
// vale o filme. Se a média passa mas há peças ruins, é ressalva com aceite.
|
||||
folhas.forEach((x,k)=>{
|
||||
@@ -166,7 +164,7 @@ function ressalvaResolucao(){
|
||||
const todas=comTamanho.map(a=>dpiDe(a));
|
||||
geral = todas.length? Math.round(Math.max(...todas)) : 300;
|
||||
}
|
||||
// Abaixo de 96 DPI a sala não imprime. Não é desconto, é recusa —
|
||||
// Abaixo de 96 DPI a sala não imprime. Não é ressalva, é recusa —
|
||||
// e não existe aceite que destrave.
|
||||
if(recusadas.length){
|
||||
$('cienteTxt').innerHTML=
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
switches which page is shown and reads the page's state (the open product,
|
||||
the cart, the checkout status); orders, prices and files stay with the other
|
||||
site-*.js files. */
|
||||
// Card prices come from the same table the checkout uses, so they cannot drift.
|
||||
document.querySelectorAll('[data-de]').forEach(el=>{ el.textContent=rs(pisoEscada(el.dataset.de)); });
|
||||
document.querySelectorAll('[data-ate]').forEach(el=>{ el.textContent=rs(TABELA[el.dataset.ate]); });
|
||||
// Every price on the page (top chip, home example, product cards, price table)
|
||||
// comes from the same table the checkout uses, so they cannot drift.
|
||||
document.querySelectorAll('[data-preco]').forEach(el=>{ el.textContent=rs(PRECO[el.dataset.preco]); });
|
||||
|
||||
const TITULO_INICIO=document.title;
|
||||
function tituloPagina(){
|
||||
|
||||
@@ -78,7 +78,6 @@ section+section{border-top:0}
|
||||
.ec-pe{display:flex;align-items:flex-end;gap:12px;padding-top:14px;border-top:1px solid #EFEFEF}
|
||||
.ec-preco{display:flex;flex-direction:column;gap:2px}
|
||||
.ec-preco span{font-size:15px;color:#707070}
|
||||
.ec-preco em{font-style:normal}
|
||||
.ec-preco b{font-family:"Inter",sans-serif;font-size:29px;font-weight:900;letter-spacing:-.02em;color:var(--preto)}
|
||||
.ec-go{margin-left:auto;height:46px;padding:0 18px;border-radius:var(--raio2);background:var(--preto);color:#fff;font-family:"Inter",sans-serif;font-weight:700;font-size:16.5px;display:flex;align-items:center;white-space:nowrap}
|
||||
.ec:hover .ec-go{background:var(--laranja);color:var(--preto)}
|
||||
@@ -238,20 +237,8 @@ section+section{border-top:0}
|
||||
.ampliar:hover{border-color:var(--preto)}
|
||||
.ampliar[hidden]{display:none}
|
||||
.cat.file #vArea{max-height:340px}
|
||||
.cEscada{display:flex;flex-direction:column;gap:8px;margin-bottom:4px}
|
||||
.cEscada>span{font-size:15px;font-weight:600}
|
||||
.cEscada ol{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}
|
||||
.cEscada li{padding:8px 2px;border-radius:8px;background:#F4F4F2;border:1.5px solid transparent;display:flex;flex-direction:column;align-items:center;gap:2px}
|
||||
.cEscada li span{font-size:13.5px;color:var(--fraco);white-space:nowrap}
|
||||
.cEscada li b{font-size:15px;font-weight:500;color:var(--texto2)}
|
||||
.cEscada li.on{background:var(--verde-fundo);border-color:var(--verde)}
|
||||
.cEscada li.on span,.cEscada li.on b{font-weight:700;color:var(--verde)}
|
||||
.cEscada li.on:last-child{background:#F1F1F1;border-color:var(--preto)}
|
||||
.cEscada li.on:last-child span,.cEscada li.on:last-child b{color:var(--preto)}
|
||||
.cLin>span:first-child{color:var(--texto2)}
|
||||
.cLin small{font-size:14.5px;color:var(--fraco)}
|
||||
.cEco{margin:-6px 0 0;text-align:right;font-size:15px;font-weight:600;color:var(--verde)}
|
||||
.cEco:empty{display:none}
|
||||
#cPartes{display:block}
|
||||
.ampliaDlg{width:min(960px,calc(100vw - 32px));max-height:calc(100vh - 48px);padding:0;border:0;border-radius:16px;box-shadow:0 20px 60px rgba(3,6,11,.3)}
|
||||
.ampliaDlg::backdrop{background:rgba(3,6,11,.55)}
|
||||
@@ -433,7 +420,6 @@ html:is([data-rota="pagamento"],[data-rota="pix"]) .pagGrid{display:grid;grid-te
|
||||
.info2 table{border-collapse:collapse;background:#fff;border:1px solid var(--linha);border-radius:12px;overflow:hidden;font-size:16.5px}
|
||||
.info2 th{text-align:left;background:var(--preto);color:#fff;font-family:"Inter",sans-serif;font-size:15px;padding:12px 18px}
|
||||
.info2 td{padding:11px 18px;border-top:1px solid #EFEFEF}
|
||||
.info2 td.melhor{font-weight:700;color:var(--verde)}
|
||||
.info2 .nota2{font-size:15px;color:#707070}
|
||||
.info2-vant{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
|
||||
.info2-vant>div{padding:22px;border-radius:var(--raio);background:#fff;border:1px solid var(--linha);display:flex;flex-direction:column;gap:6px}
|
||||
|
||||
Reference in New Issue
Block a user