feat: delivery areas drawn on a map (plan 6R.G)
An area is a list of postcodes, a shape drawn on a map or a circle around a point. The fee engine (both copies, byte-identical) matches a shape only by the customer's pin, then postcodes; point-in-polygon (edges inside) and haversine circles; shared cases in fee_cases.json. - Alembic 0053: delivery_areas.kind / geometry, orders.online_lat / lng - /api/connect/fees: areas with kind + geometry (validated: 3-200 corners, 50 m - 50 km), the venue's place (PUT /venue-point, setting venue.location, sent to the cloud as fees.venue_point), preview by lat / lng - manager: DeliveryMap (Leaflet + OpenStreetMap tiles): draw / move / remove corners, circles, the venue on the map, an overview, test an order by a point - pulled online orders keep the pin; the site re-checks the fee with it; the counter links the pin to a map - tests: backend (shapes, venue point, pinned orders), manager logic, e2e manager.mjs and order_app.mjs 6R.G blocks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,9 @@ test('moving rules and the test form', () => {
|
||||
assert.deepEqual(moveRule(rules, 2, -1), [2, 1, 3])
|
||||
assert.deepEqual(moveRule(rules, 3, 1), [1, 2, 3])
|
||||
assert.deepEqual(previewBody({ sales_point: 'online_delivery', where: 'postcode', area_id: '1', postcode: ' 24131 ', subtotal: '12,5', items: '3', day: 'now', time: '' }),
|
||||
{ sales_point: 'online_delivery', area_id: null, postcode: '24131', subtotal: 12.5, items: 3, weekday: null, time: null })
|
||||
{ sales_point: 'online_delivery', area_id: null, postcode: '24131', lat: null, lng: null, subtotal: 12.5, items: 3, weekday: null, time: null })
|
||||
assert.deepEqual(previewBody({ sales_point: 'online_delivery', where: 'area', area_id: '2', postcode: '', subtotal: '', items: '', day: '5', time: '23:30' }),
|
||||
{ sales_point: 'online_delivery', area_id: 2, postcode: null, subtotal: 0, items: 0, weekday: 5, time: '23:30' })
|
||||
{ sales_point: 'online_delivery', area_id: 2, postcode: null, lat: null, lng: null, subtotal: 0, items: 0, weekday: 5, time: '23:30' })
|
||||
})
|
||||
|
||||
test('online ordering settings: hours per day, any time, numbers', async () => {
|
||||
@@ -75,3 +75,26 @@ test('table bookings online: settings round trip (S.6)', async () => {
|
||||
assert.deepEqual(orderingBody({ ...form, res: { ...form.res, anyTime: true, party_max: '' } }).reservations,
|
||||
{ ...reservations, hours: {}, party_max: 10 })
|
||||
})
|
||||
|
||||
test('6R.G: an area form for each kind, and what keeps it from saving', async () => {
|
||||
const { areaBody, areaProblem, distanceText } = await import('../src/pages/online/feesLogic.js')
|
||||
assert.deepEqual(areaBody({ name: ' Centre ', codes: '24100, 24131' }), { name: 'Centre', kind: 'postcodes', is_active: true, postcodes: ['24100', '24131'] })
|
||||
const sq = [[37, 22], [37, 22.1], [37.1, 22.1]]
|
||||
assert.deepEqual(areaBody({ name: 'Drawn', kind: 'polygon', corners: sq, codes: '1' }), { name: 'Drawn', kind: 'polygon', is_active: true, postcodes: [], geometry: sq })
|
||||
assert.deepEqual(areaBody({ name: 'Ring', kind: 'circle', circle: { center: [37, 22], radius_m: 1500 }, active: false }).geometry, { center: [37, 22], radius_m: 1500 })
|
||||
assert.equal(areaProblem({ name: ' ' }), 'name')
|
||||
assert.equal(areaProblem({ name: 'x', kind: 'polygon', corners: sq.slice(0, 2) }), 'corners')
|
||||
assert.equal(areaProblem({ name: 'x', kind: 'polygon', corners: sq }), null)
|
||||
assert.equal(areaProblem({ name: 'x', kind: 'circle', circle: { radius_m: 500 } }), 'centre')
|
||||
assert.equal(areaProblem({ name: 'x', kind: 'circle', circle: { center: [37, 22], radius_m: 20 } }), 'radius')
|
||||
assert.equal(areaProblem({ name: 'x', kind: 'circle', circle: { center: [37, 22], radius_m: null } }), 'radius')
|
||||
assert.equal(distanceText(800), '800 m')
|
||||
assert.equal(distanceText(2549), '2.5 km')
|
||||
})
|
||||
|
||||
test('6R.G: a test order by a point on the map', () => {
|
||||
const body = previewBody({ sales_point: 'online_delivery', where: 'point', point: [37.05, 22.05], area_id: 3, postcode: '1', subtotal: '10', items: '1', day: 'now' })
|
||||
assert.deepEqual([body.lat, body.lng, body.area_id, body.postcode], [37.05, 22.05, null, null])
|
||||
const none = previewBody({ sales_point: 'online_delivery', where: 'area', area_id: '', postcode: '', subtotal: '10', items: '1', day: 'now' })
|
||||
assert.deepEqual([none.lat, none.lng], [null, null])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user