Functional Weave
Code in Python

property.floor-area@1.0.2

README.md

2,714 bytes · view raw

# property.floor-area

The floor area of a property from its room measurements, as estate agents'
floor plans and EPCs quote it: every room's length × width, their total, and
the total in both square metres and square feet.

`floorArea([{name: "Lounge", length: "4", width: "3"}, {name: "Bed", length: "2.5", width: "2"}], "m", 2)`
gives rooms of 12 and 5 m², a total of 17 m², and 182.99 sq ft.

## Why decimal text

Dimensions are read as exact decimals, never floats, so 4.1 × 3.3 is 13.53,
not 13.529999999999999. Each room's area and the total are exact (up to six
decimal places, from dimensions with up to three), and the only rounding is
the final one to `decimals` places in each unit, done by `units.convert`
with the exact definition 1 ft = 0.3048 m (1 sq ft = 0.09290304 m²). The
total is rounded once, not the rooms: rounding each room first and adding can
be off in the last place.

## Edge cases and limits

- Rooms are rectangles. An L-shaped room is two entries; a bay is its own
  entry; deduct nothing, since the function never subtracts.
- Dimensions are greater than 0 and below 1000 of the unit, with at most 3
  decimal places (a millimetre in metres), and there may be at most 1000
  rooms. An empty list is an error, as is a room of zero size.
- Feet and inches must be converted to decimal feet first (10 ft 6 in is
  "10.5").
- This is the area of the rooms measured, not a RICS gross internal area:
  walls, stairs and circulation space count only if they are measured in.

1.0.1 fixes Python accepting a trailing newline in a room's length or width; adds tests.

## Before you rely on this

**Not professional advice.** This capability calculates property figures from published rules. It is a software component for developers, not legal or financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a conveyancer or tax adviser review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.

**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified conveyancer or tax adviser has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.

1.0.2 marks it unreviewed. The code and the tests are unchanged.