feat: products and prices from the database, edited in the Kanban's Site tab (front 8.1)

Gestão and the administrators switch each product on and off and set its
price from a start date; a price that has started is history and cannot
change, a scheduled one can be cancelled. The Site and the server read
the current price; with no row the code's prices and TREATMENT_CENTS
still apply, so nothing changes until someone sets one. A switched-off
product disappears from the Site and new quotes with it are refused.
Approved quotes and paid orders keep their price.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 13:50:45 -03:00
parent 4219db8215
commit c88d81588e
20 changed files with 550 additions and 35 deletions

View File

@@ -55,6 +55,20 @@ class PricingTests(unittest.TestCase):
for bad in (-1, True, 1.5):
with self.assertRaises(ValueError):price('file', '1', 0, bad)
def test_the_catalog_price_replaces_the_table_price(self):
# The Kanban's Site tab sets the price in the database (front 8); the
# minimum and the ten-centimetre rounding stay the Site's.
priced = price('avulsa', '2.75', 90, unit_cents=1234)
self.assertEqual(price('avulsa', '2.75', 90)['unit_cents'], PRICES['avulsa'])
self.assertEqual(priced['unit_cents'], 1234)
self.assertEqual(priced['billed_metres'], '2.8')
self.assertEqual(priced['total_cents'], 3455)
# A hand-opened sheet still pays the extra on top of the new price.
extra = price('file', '1.01', 0, 500, unit_cents=1234)
self.assertEqual(extra['unit_cents'], 1734)
self.assertEqual(extra['billed_metres'], '1.1')
self.assertEqual(extra['total_cents'], 1907)
def test_which_items_are_opened_by_hand(self):
def item(kind, measurement, uid='u1'):
return {'production': {'sources': [{'kind': kind, 'measurement': measurement, 'upload_id': uid}]}}