From 8ba30e057c9b80d2c959207f7a89c7e1241e207f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Thu, 26 Nov 2026 12:53:11 -0300 Subject: [PATCH] feat: 8 mm of clear film between the copies and sheets of a ready sheet, billed (Marcus, 2026-11-26) The Site stacked a ready sheet's copies with nothing between them (#81's were 0,3 mm apart). Now 8 mm separates each copy and each sheet from the next, and the metres include it, as Marcus confirmed. A new cart without the gap is refused with the reason; a quote made before is still reviewed. Co-Authored-By: Claude Opus 5.5 (1M context) --- .gitea/workflows/deploy.yml | 2 +- app/core/models.py | 19 +++++++++++++++ tests/artwork_browser_test.mjs | 3 ++- tests/test_sheet_gap.py | 43 ++++++++++++++++++++++++++++++++++ tests/upload_limits_test.py | 8 ++++--- web/site-cart.js | 2 ++ web/site-config.js | 8 ++++++- 7 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 tests/test_sheet_gap.py diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 0d080b8..eb636c9 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -101,7 +101,7 @@ jobs: # the generator's geometry. The provider suites use a fake transport: they # prove the documented contract, not the integration. - name: Print-file geometry and provider adapters - run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_printpng tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_moves tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html tests.test_layout_rules tests.test_proof_cut tests.test_proof_render tests.test_sheet_trim tests.test_one_machine tests.test_profiles tests.test_prumo tests.test_speed tests.test_printpng_validate tests.test_machine_log tests.test_machine_stats tests.test_label tests.test_observability tests.test_worker_drain tests.test_db_outage tests.test_health -v + run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_printpng tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_moves tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html tests.test_layout_rules tests.test_proof_cut tests.test_proof_render tests.test_sheet_trim tests.test_one_machine tests.test_profiles tests.test_sheet_gap tests.test_prumo tests.test_speed tests.test_printpng_validate tests.test_machine_log tests.test_machine_stats tests.test_label tests.test_observability tests.test_worker_drain tests.test_db_outage tests.test_health -v - name: Runtime and retention regressions run: | diff --git a/app/core/models.py b/app/core/models.py index 8b0951e..d21a1db 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -166,6 +166,24 @@ class Split(StrictModel): UV_MODES = ('uvfile', 'uv') +SHEET_MODES = ('file', 'uvfile', 'premium') +# Clear film between the copies of a ready sheet, and between its sheets, for +# cutting; billed like the rest (Marcus, 2026-11-26). +SHEET_GAP_CM = Decimal('0.8') +SHEET_GAP_CHANGED = ('O espaço entre as cópias da folha pronta passou a ser de 8 mm. ' + 'Remova este item do carrinho e adicione de novo.') + + +def check_sheet_gaps(items): + """A ready sheet's copies and sheets are SHEET_GAP_CM apart. Only a new + cart is held to it: a quote made before still goes through review.""" + for item in items: + if item.mode not in SHEET_MODES: + continue + placements = sorted(item.production.placements, key=lambda p: p.y_cm) + for above, below in zip(placements, placements[1:]): + if below.y_cm < above.y_cm + above.length_cm + SHEET_GAP_CM - Decimal('0.02'): + raise ValueError(SHEET_GAP_CHANGED) ONE_MACHINE = ('Esse produto é impresso em outra máquina e precisa de um pedido separado. ' 'Finalize este pedido e faça um novo com ele.') @@ -323,6 +341,7 @@ class QuoteRequest(StrictModel): def splits_complete(self): check_splits(self.items) check_one_machine(self.items) + check_sheet_gaps(self.items) return self @model_validator(mode='after') diff --git a/tests/artwork_browser_test.mjs b/tests/artwork_browser_test.mjs index 4333df4..4cf605f 100644 --- a/tests/artwork_browser_test.mjs +++ b/tests/artwork_browser_test.mjs @@ -347,7 +347,8 @@ try{ // 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); await evaluate(`(()=>{const el=$('lista').querySelector('[data-repf]');el.value=2;el.dispatchEvent(new Event('change',{bubbles:true}));})()`); - await waitFor(()=>evaluate('Math.abs(metros-2*folhas[0].m)<0.0001 && folhas[0].m<0.2'),'ready-sheet repetitions'); + // Two copies and the 8 mm between them (Marcus, 2026-11-26). + await waitFor(()=>evaluate('Math.abs(metros-(2*folhas[0].m+0.008))<0.0001 && folhas[0].m<0.2'),'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===PRECO[modo]+TAXA_MANUAL`),'mixed analyzed and manual sheets: the price plus the manual charge'); diff --git a/tests/test_sheet_gap.py b/tests/test_sheet_gap.py new file mode 100644 index 0000000..d585599 --- /dev/null +++ b/tests/test_sheet_gap.py @@ -0,0 +1,43 @@ +"""8 mm of clear film between the copies of a ready sheet (Marcus, 2026-11-26): +a new cart must carry it; a quote made before is still reviewed. + +Run from the repository root: python3 -m unittest tests.test_sheet_gap -v. +""" +import unittest +from uuid import uuid4 + +from app.core.models import SHEET_GAP_CHANGED, Item, check_sheet_gaps + + +def sheet(copies=3, gap=0.8, mode='file'): + upload = str(uuid4()) + width = 27 if mode == 'uvfile' else 57 + length = 20 + placements = [{'source_index': 0, 'copy_index': i, 'x_cm': 0, 'y_cm': round(i * (length + gap), 4), + 'width_cm': width, 'length_cm': length, 'rotation_degrees': 0, 'mirrored': False} + for i in range(copies)] + height = round(copies * length + (copies - 1) * gap, 4) + return Item.model_validate({ + 'mode': mode, 'metres': str(height / 100), 'grade': 100, 'uploads': [upload], + 'quality_status': 'ok', 'quality_acknowledged': False, + 'production': {'version': 3, 'film_width_cm': width, 'height_cm': height, + 'sources': [{'upload_id': upload, 'kind': 'sheet', 'width_cm': width, + 'length_cm': length, 'copies': copies, 'measurement': 'file'}], + 'placements': placements}}) + + +class SheetGapTests(unittest.TestCase): + def test_copies_8_mm_apart_pass(self): + check_sheet_gaps([sheet()]) + check_sheet_gaps([sheet(copies=1, gap=0)]) + check_sheet_gaps([sheet(mode='uvfile')]) + + def test_copies_without_the_gap_are_refused_with_the_reason(self): + for gap in (0, 0.03, 0.5): + with self.assertRaises(ValueError) as caught: + check_sheet_gaps([sheet(gap=gap)]) + self.assertEqual(str(caught.exception), SHEET_GAP_CHANGED) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/upload_limits_test.py b/tests/upload_limits_test.py index d3778db..795c6f2 100644 --- a/tests/upload_limits_test.py +++ b/tests/upload_limits_test.py @@ -24,9 +24,11 @@ TOO_MANY = 'Este item tem mais de 200 arquivos. Divida em dois itens.' def item_with(uploads): - """One ready-sheet item: one source per upload, stacked in a row.""" + """One ready-sheet item: one source per upload, stacked in a row, 8 mm + apart (models.SHEET_GAP_CM).""" count = len(uploads) - height = count * 0.3 + step = 0.25 + 0.8 + height = round(count * step - 0.8, 4) return { 'mode': 'file', 'metres': round(height / 100, 4), 'grade': 100, 'uploads': uploads, 'production': { @@ -35,7 +37,7 @@ def item_with(uploads): 'copies': 1, 'rotation_degrees': 0, 'mirrored': False, 'measurement': 'file'} for uid in uploads], 'placements': [{'source_index': index, 'copy_index': 0, 'x_cm': 0, - 'y_cm': round(index * 0.3, 4), 'width_cm': 0.5, 'length_cm': 0.25, + 'y_cm': round(index * step, 4), 'width_cm': 0.5, 'length_cm': 0.25, 'rotation_degrees': 0, 'mirrored': False} for index in range(count)]}, 'quality_status': 'ok', 'quality_acknowledged': False, 'residue_accepted': 0} diff --git a/web/site-cart.js b/web/site-cart.js index b65b311..65f5bcc 100644 --- a/web/site-cart.js +++ b/web/site-cart.js @@ -307,6 +307,8 @@ function carrinho(){ const placements=[]; sources.forEach((source,source_index)=>{ for(let copy_index=0;copy_indexfolhas.reduce((t,x)=>t+(x.m||0)*(x.rep||1),0); +// Entre uma cópia e outra da folha pronta, e entre uma folha e outra, 8 mm de +// filme limpo para o recorte; entram na metragem cobrada (Marcus, 26/11/2026). +const MARGEM_FOLHA_CM=0.8; +const folhaTotalM=()=>{ + const copias=folhas.reduce((t,x)=>t+(x.m>0?(x.rep||1):0),0); + return folhas.reduce((t,x)=>t+(x.m||0)*(x.rep||1),0)+Math.max(0,copias-1)*MARGEM_FOLHA_CM/100; +}; // O cliente declara o que está mandando escolhendo o produto, em vez de o site // adivinhar pelo formato do arquivo. A declaração de folha montada é conferida na // medição: uma imagem sem pixel para ocupar a largura do filme não é uma folha.