Functional Weave
Code in Rust

Suites · legal

Legal practice

Practice software for a law firm in England and Wales: conflict checks, limitation and court deadlines, time billing, client account retainers, disbursements, court fees and statutory interest.

71 capabilities (34 core, 37 optional) and 15 gaps, in build order. Put each line in the file that calls it, then fune build.

England and Wales: limitation periods, CPR deadlines, court fees and statutory interest follow its rules. Not legal advice; a qualified lawyer must check every deadline the app computes.

Calculates tax from published rules; it is not tax advice. Have an accountant check how the app uses it before anyone files a return.

1. Client intake

Check for conflicts before taking a matter on.

legal.conflict-name-match core Unreviewed
Fuzzy-matches a new client or party against existing names, best first, for a person to review.
Fuzzy-match a name against existing clients and parties for a conflict check: normalised, token-sorted Jaro-Winkler.
fune!(legal.conflict-name-match@^1);  // then call conflict_name_match(…)
  • aml-checks Identity and anti-money-laundering checks on new clients through a provider.

2. Deadlines

Never miss a limitation date or a court deadline.

legal.limitation-date core Unreviewed
The last day to bring a claim under the Limitation Act 1980, by claim type.
The last day to bring a claim under the Limitation Act 1980, by claim type, from the date it accrued.
fune!(legal.limitation-date@^1);  // then call limitation_date(…)
legal.court-deadline core Unreviewed
A deadline under CPR 2.8: clear days, and short periods skipping weekends and bank holidays.
A deadline in days under CPR 2.8: clear days, short periods skip weekends and bank holidays, court-closed days.
fune!(legal.court-deadline@^1);  // then call court_deadline(…)
  • diary-reminders The matter diary, reminders and escalation when a deadline approaches.

3. Time and billing

Record time and bill it.

legal.time-billing core Unreviewed
Fees from time entries rounded to 6-minute units at each fee earner's hourly rate.
Fees from time entries: each rounded to 6-minute (or other) units and priced at the fee earner's hourly rate.
fune!(legal.time-billing@^1);  // then call time_billing(…)
time.round-to-increment core
Rounds minutes to the 6-minute unit for entries recorded by hand.
Round a duration in minutes to a billing increment such as 6 or 15 minutes, up, down or to nearest.
fune!(time.round-to-increment@^1);  // then call round_to_increment(…)
finance.invoice.calculate core
Totals the bill and its VAT by rate.
Calculate a complete invoice: line nets, VAT per line, totals and a VAT summary grouped by rate.
fune!(finance.invoice.calculate@^1);  // then call calculate_invoice(…)
professional.wip-valuation optional
Values unbilled time at cost or charge-out rates.
Value unbilled time (work in progress) at cost or charge-out rates, less a write-down percentage.
fune!(professional.wip-valuation@^1);  // then call wip_valuation(…)
professional.utilisation optional
Billable utilisation and realisation per fee earner.
Billable utilisation and billing, collection and overall realisation rates, in basis points.
fune!(professional.utilisation@^1);  // then call utilisation_rates(…)

4. Client account

Handle money held for clients.

legal.retainer-drawdown core Unreviewed
Applies money held on account to bills in order: what each takes, what stays due, what is left.
Apply money held on account in client account to bills in order: what each bill takes, what stays due, what is left.
fune!(legal.retainer-drawdown@^1);  // then call retainer_drawdown(…)
  • client-ledger The client account ledger and three-way reconciliation the SRA Accounts Rules require.

5. Disbursements and court costs

Charge costs paid out for the client correctly.

legal.disbursements-vat core Unreviewed
Whether a cost passed on is a disbursement outside VAT or a recharge with VAT, per HMRC Notice 700.
Whether a cost passed to a client is a VAT disbursement (outside scope) or a recharge (VAT due), per HMRC Notice 700.
fune!(legal.disbursements-vat@^1);  // then call disbursement_vat(…)
legal.court-fee optional Unreviewed
The court fee to issue a money claim, by claim value on a date.
The court fee to issue a money claim in England and Wales, from the claim value bands in force on a date.
fune!(legal.court-fee@^1);  // then call court_fee(…)

6. Interest on debts and judgments

Add the interest a claim or judgment carries.

legal.statutory-interest optional Unreviewed
Statutory interest on a judgment debt (8% simple) or a late commercial debt.
Statutory interest on a judgment debt (8% simple, daily) or a late commercial debt, England and Wales.
fune!(legal.statutory-interest@^1);  // then call statutory_interest(…)
finance.late-payment-interest optional
Late Payment Act interest and fixed compensation on unpaid business invoices.
UK statutory late payment interest (8% over Bank Rate) and fixed compensation under the Late Payment Act 1998.
fune!(finance.late-payment-interest@^1);  // then call late_payment_interest(…)

7. Amounts from money-basics

Hold money as currency-tagged integer minor units and do plain arithmetic on it safely.

money.amount core
The Money type ({ minor, currency }) every other money capability takes and returns.
A currency-tagged monetary amount held in integer minor units.
fune!(money.amount@^1);  // then call money(…)
money.add core
Adds and subtracts amounts, refusing to mix currencies by accident.
Add, subtract and negate monetary amounts, refusing to mix currencies.
fune!(money.add@^1);  // then call add_money(…)
money.sum core
Totals a list of amounts, with an explicit currency for an empty list.
Total a list of monetary amounts, with an explicit currency for the empty case.
fune!(money.sum@^1);  // then call sum_money(…)
money.compare core
Compares, mins, maxes and clamps amounts of one currency without unwrapping them.
Compare two amounts of one currency, refusing to compare across currencies; min, max and clamp too.
fune!(money.compare@^2);  // then call compare_money, min_money, max_money, clamp_money

8. Rates and rounding from money-basics

Apply percentages and divide amounts with the rounding stated, never a float.

money.apply-rate core
Applies a basis-point rate (VAT, discount, commission) to an amount with explicit rounding.
Apply a rate expressed in basis points to a monetary amount, with an explicit rounding mode.
fune!(money.apply-rate@^1);  // then call apply_rate(…)
math.round-div core
Integer division with a named rounding mode, for any money maths the others do not cover.
Integer division with an explicit rounding mode, for money arithmetic that must not drift.
fune!(math.round-div@^1);  // then call round_div(…)
math.basis-points optional
Converts "12.5%" to and from basis points exactly, for rates typed in by users.
Convert a rate between percent, basis points and a plain ratio exactly, as decimal text or integer basis points.
fune!(math.basis-points@^2);  // then call convert_rate, to_basis_points, from_basis_points
math.percent-change optional
Percentage change between two figures in basis points, for "up 4.2% on last month".
Percentage change from one value to another, in basis points, with an explicit rounding mode.
fune!(math.percent-change@^1);  // then call percent_change(…)
math.rational optional
Exact fractions for rates that must not drift across many steps.
Exact fraction arithmetic, always reduced, for rates and ratios that must not drift.
fune!(math.rational@^2);  // then call calculate_rational, rational, add_rational, subtract_rational, multiply_rational, divide_rational, compare_rational, rational_to_integer
math.round-div-big optional
Rounded division on numbers past 2^53, for very large totals.
Divide two integers of any size with an explicit rounding mode, on decimal strings, for exact money sums past 2^53.
fune!(math.round-div-big@^1);  // then call round_div_big(…)

9. Splitting from money-basics

Divide an amount between people, periods or lines so the parts add back to the whole.

money.allocate core
Splits an amount by ratios (60/40, by quantity) without losing or inventing a penny.
Split an amount across ratios without losing or inventing a single minor unit.
fune!(money.allocate@^1);  // then call allocate(…)
money.split-even optional
Splits an amount into n near-equal parts that sum exactly, for instalments or shares.
Split an amount into n near-equal parts that add back up to exactly the whole.
fune!(money.split-even@^1);  // then call split_even(…)

10. Display and input from money-basics

Show amounts to people and read what they type.

money.format core
Renders an amount as text with the currency's real number of decimal places.
Render a monetary amount as text, using the currency's real minor-unit precision.
fune!(money.format@^1);  // then call format_money(…)
money.parse optional
Reads "£1,234.50" or "1.234,50 €" typed by a user into minor units, strictly.
Parse "£1,234.50" or "1.234,50 €" into integer minor units, strictly: no guessing, no rounding.
fune!(money.parse@^1);  // then call parse_money(…)
money.currency-digits optional
How many decimal places each ISO 4217 currency has, for input boxes and validation.
How many decimal places a currency's minor unit has, from the ISO 4217 list.
fune!(money.currency-digits@^1);  // then call currency_digits(…)

11. Other currencies from money-basics

Convert between currencies at a rate you hold.

money.convert optional
Converts an amount at a supplied exact rate with explicit rounding.
Convert an amount to another currency at a supplied exact rate, with an explicit rounding mode.
fune!(money.convert@^1);  // then call convert_money(…)

12. Calendar arithmetic from dates-basics

Move and measure ISO dates exactly, with no date library and no clock reads.

dates.add-days core
Shifts a date by whole days, for due dates and windows.
Shift an ISO date by a whole number of days, forwards or backwards, with exact calendar arithmetic.
fune!(dates.add-days@^1);  // then call add_days(…)
dates.add-months core
Adds months clamping to month end, so 31 January plus a month is the end of February.
Add calendar months to an ISO date, clamping to the month end: 31 Jan + 1 month is 28 or 29 Feb.
fune!(dates.add-months@^1);  // then call add_months(…)
dates.days-between core
Signed calendar days between two dates, for ages of invoices and stays.
Calendar days from one ISO date to another, signed: negative when the second date is earlier.
fune!(dates.days-between@^1);  // then call days_between(…)
dates.month-boundaries core
First and last day of a date's month, for monthly periods and statements.
The first day, last day and length of the calendar month containing a date.
fune!(dates.month-boundaries@^1);  // then call month_boundaries(…)
dates.day-of-week core
ISO weekday of a date, for weekend rules and opening hours.
The ISO 8601 day of the week for a date: 1 is Monday through 7 is Sunday.
fune!(dates.day-of-week@^1);  // then call day_of_week(…)
dates.is-leap-year optional
Whether a year is a leap year, for 365/366-day calculations.
Whether a year is a Gregorian leap year: every 4th, except centuries, except every 400th.
fune!(dates.is-leap-year@^1);  // then call is_leap_year(…)
dates.overlap optional
Days two date ranges share, for prorating and clash checks.
Days two date ranges have in common, with the end of each range stated as inclusive or exclusive.
fune!(dates.overlap@^1);  // then call overlap_days(…)
dates.age optional
Age in whole years on a date, handling 29 February birthdays.
Age in whole years on a given date, with 29 February birthdays ageing on 1 March in other years.
fune!(dates.age@^1);  // then call age(…)

13. Periods and reporting dates from dates-basics

Put dates into the periods reports are grouped by.

dates.quarter core
Calendar and fiscal quarter of a date for any year-start month.
Calendar quarter and fiscal quarter of a date, with the fiscal year and quarter date ranges, for any start month.
fune!(dates.quarter@^1);  // then call quarter(…)
dates.week-number optional
ISO week number and week-year, for weekly reports.
ISO 8601 week number and week-numbering year of a date: weeks start Monday, week 1 holds the first Thursday.
fune!(dates.week-number@^1);  // then call week_number(…)
dates.day-count-fraction optional
Year fraction by ACT/365F, ACT/360, 30/360 or ACT/ACT, for interest periods.
Year fraction between two dates by ACT/365F, ACT/360, 30/360, 30E/360 or ACT/ACT ISDA, as an exact fraction.
fune!(dates.day-count-fraction@^1);  // then call day_count_fraction(…)

14. Working days and holidays from dates-basics

Skip weekends and public holidays when counting or adding days.

dates.bank-holidays core
UK bank holidays for a region and year, as gov.uk publishes them.
UK bank and public holidays for a region and year, as published by gov.uk, including one-off holidays.
fune!(dates.bank-holidays@^1);  // then call bank_holidays(…)
dates.add-business-days core
Moves a date by working days, skipping weekends and a holiday list.
Move a date forward or back by working days, skipping weekends and a caller-supplied holiday list.
fune!(dates.add-business-days@^1);  // then call add_business_days(…)
dates.business-days-between core
Working days between two dates, for SLAs and notice periods.
Working days between two dates, excluding weekends and a caller-supplied holiday list.
fune!(dates.business-days-between@^1);  // then call business_days_between(…)

15. Repeating schedules from dates-basics

Generate the dates of something that repeats.

dates.recurrence optional
The next n dates of a rule: monthly on the 31st, last Friday, every two weeks.
The next n dates of a repeating rule: monthly on a day, last weekday of the month, every k days or weeks, yearly.
fune!(dates.recurrence@^1);  // then call recurrence(…)

16. Times and durations from dates-basics

Work with times of day, durations and timestamps.

time.duration optional
Parses and adds durations like 1h30m in whole minutes, and formats the total.
Parse durations written as 1h30m, 90m or 01:30, add them up in whole minutes, and format the total.
fune!(time.duration@^1);  // then call duration(…)
time.minutes-between optional
Minutes between two local date-times, across midnight.
Minutes from one local date and time to another, correct across midnight; wall-clock time, no time zones.
fune!(time.minutes-between@^1);  // then call minutes_between(…)
time.iso-to-unix optional
RFC 3339 timestamps to Unix seconds.
An RFC 3339 timestamp with a Z or offset, such as 2026-09-26T13:00:00+01:00, to Unix time in whole seconds.
fune!(time.iso-to-unix@^1);  // then call iso_to_unix(…)
time.unix-to-iso optional
Unix seconds to an ISO 8601 UTC timestamp.
Unix time in seconds to an ISO 8601 UTC timestamp such as 2026-09-26T12:00:00Z, for years 0001 to 9999.
fune!(time.unix-to-iso@^1);  // then call unix_to_iso(…)
time.countdown optional
Seconds left until a moment and a 4:05 style timer text.
Seconds left until a Unix time, whether it has passed, and a timer text like 4:05, for tokens or retry waits.
fune!(time.countdown@^1);  // then call countdown(…)

17. VAT from uk-tax

Work out VAT from the dated rates HMRC publishes.

finance.tax.vat-rate core Unreviewed
The VAT rate in force for a jurisdiction, category and date; the others look it up.
Look up the VAT rate in force for a jurisdiction, category and date.
fune!(finance.tax.vat-rate@^1);  // then call vat_rate(…)
finance.tax.add-vat core Unreviewed
Net to gross: VAT on a net amount at the rate on the date of supply.
Add VAT to a net amount using the rate in force on the date of supply.
fune!(finance.tax.add-vat@^1);  // then call add_vat(…)
finance.tax.remove-vat core Unreviewed
Gross to net: the VAT already inside a VAT-inclusive price.
Extract the VAT already included in a gross amount, using the rate in force on the date of supply.
fune!(finance.tax.remove-vat@^1);  // then call remove_vat(…)
finance.tax.vat-return optional Unreviewed
The nine-box VAT return totals for a period from categorised sales and purchases.
UK nine-box VAT return totals for a period from categorised sales and purchases (VAT Notice 700/12).
fune!(finance.tax.vat-return@^1);  // then call vat_return(…)
finance.tax.vat-flat-rate optional Unreviewed
VAT due under the Flat Rate Scheme by business sector, for small businesses on it.
UK VAT Flat Rate Scheme: VAT due on gross turnover at the sector's dated rate, limited cost rate and first-year 1% off.
fune!(finance.tax.vat-flat-rate@^1);  // then call flat_rate_vat(…)

18. Tax periods from uk-tax

Put dates into the UK periods tax is worked out over.

dates.uk-tax-year core
Which UK tax year (6 April to 5 April) a date falls in.
The UK personal tax year containing a date: 6 April to 5 April, with HMRC's label.
fune!(dates.uk-tax-year@^1);  // then call uk_tax_year(…)

19. Tax identifiers from uk-tax

Check the numbers HMRC and Companies House issue before storing them.

validation.uk-vat-number core
Checks a UK VAT registration number's checksum.
Check a UK VAT registration number against HMRC's mod-97 checksum, including the post-2010 9755 variant.
fune!(validation.uk-vat-number@^1);  // then call is_uk_vat_number(…)
validation.uk-utr optional
Checks a Unique Taxpayer Reference's check digit.
Check an HMRC Unique Taxpayer Reference's modulus 11 check digit, accepting the K and spacing people type.
fune!(validation.uk-utr@^2);  // then call validate_uk_utr(…)
validation.uk-company-number optional
Checks and pads a Companies House company number.
Check a Companies House company number's format and prefix (SC, NI, OC, LP...) and zero-pad it to eight characters.
fune!(validation.uk-company-number@^2);  // then call validate_uk_company_number(…)

20. Contact details from validation-basics

Check and normalise a person's contact details before storing them.

validation.email core
Is an email address plausible, by a documented subset of RFC 5322.
Is this a plausible email address? A documented, pragmatic subset of RFC 5322, not the full grammar.
fune!(validation.email@^1);  // then call is_email(…)
validation.phone-e164 core
Normalises a phone number to +44… E.164 for a default country.
Normalise a phone number to E.164 (+447700900123) using a default country's trunk and dialling prefixes.
fune!(validation.phone-e164@^2);  // then call validate_phone_e164(…)
validation.uk-postcode core
Validates a UK postcode and puts it in canonical form.
Validate a UK postcode and normalise it to canonical upper case with one space before the inward code.
fune!(validation.uk-postcode@^2);  // then call validate_uk_postcode(…)
text.normalise-name optional
Tidies a typed name: spacing and title case with Mc, O' and hyphen rules.
Tidy a personal name: trim, collapse whitespace and title-case, with Mc, Mac, O', hyphen and van/de rules.
fune!(text.normalise-name@^1);  // then call normalise_name(…)
auth.normalise-email optional
Lower-cases an email's domain for storage and lookup.
Trim an email address and lower-case its domain for storage and lookup, or null if it is not a plausible address.
fune!(auth.normalise-email@^1);  // then call normalise_email(…)

21. Bank details from validation-basics

Check payee and customer bank details before money moves.

validation.iban core
Checks an IBAN's mod-97 checksum and its country's length.
Check an IBAN against the ISO 13616 mod-97-10 checksum and the registered length for its country.
fune!(validation.iban@^1);  // then call is_iban(…)
validation.bic optional
Checks a SWIFT/BIC code's format and splits it.
Check the format of a SWIFT/BIC code (8 or 11 characters) and split it into its parts.
fune!(validation.bic@^1);  // then call validate_bic(…)
validation.uk-sort-code-account optional
Checks a UK sort code and account number by the Vocalink modulus rules, against a table you supply.
Check a UK sort code and account number with the Vocalink/Pay.UK modulus rules, against a table you supply.
fune!(validation.uk-sort-code-account@^3);  // then call validate_uk_sort_code_account(…)
validation.uk-modulus-table optional
Parses Vocalink's VALACDOS and SCSUBTAB files into that table.
Parse Vocalink's VALACDOS.txt and SCSUBTAB.txt into the table UK sort code modulus checking needs.
fune!(validation.uk-modulus-table@^1);  // then call parse_uk_modulus_table(…)

22. Identifiers and check digits from validation-basics

Catch mistyped reference numbers by their check digits.

validation.luhn optional
Luhn mod-10 check, for card numbers and many reference numbers.
Check a digit string against the Luhn mod-10 checksum used by payment cards and many identifiers.
fune!(validation.luhn@^1);  // then call is_luhn(…)
validation.lei optional
Checks a Legal Entity Identifier's check digits.
Check a 20-character Legal Entity Identifier against its ISO 17442 / ISO 7064 MOD 97-10 check digits.
fune!(validation.lei@^1);  // then call validate_lei(…)
validation.gtin optional
Checks an EAN/UPC/GTIN barcode number.
Check an EAN-8, UPC-A, EAN-13 or GTIN-14 barcode number against the GS1 mod-10 check digit.
fune!(validation.gtin@^1);  // then call validate_gtin(…)

23. Displaying sensitive values from validation-basics

Show stored identifiers without exposing them.

text.mask optional
Masks all but the last digits of a card, account or phone number.
Mask all but the last n characters of a card, account or phone number, optionally keeping separators.
fune!(text.mask@^1);  // then call mask(…)

Gaps

What this kind of app usually needs that Functional Weave does not have yet: write these yourself, or use a service.

  • document-management Matter documents, templates and precedents, and e-signature.
  • fx-rate-source Where exchange rates come from: money.convert takes a rate you supply; fetching and storing daily rates (ECB, a provider's API) is yours.
  • money-storage Storing amounts: the database columns (integer minor units plus a currency code) and their migrations are yours.
  • time-zones Time zones and daylight saving: caps works in ISO dates, UTC and wall-clock times; converting with the IANA tz rules is yours.
  • locale-formatting Showing dates in a user's language and format ("3 octobre 2026"): caps returns ISO dates, not localised text.
  • non-uk-holidays Public holidays outside the UK: dates.bank-holidays is UK only; pass another country's list to the working-day functions yourself.
  • mtd-submission Making Tax Digital: submitting the return to HMRC's VAT API (OAuth, fraud-prevention headers, obligations) is yours; caps gives the nine boxes.
  • corporation-tax Corporation tax and self-assessment income tax computations are not in caps.
  • vat-number-lookup Checking that a VAT number is registered (HMRC's lookup API) is network work; caps checks the checksum only.
  • address-lookup Turning a postcode into a list of addresses (Royal Mail PAF or a lookup API) is network work and not in caps.
  • email-deliverability Whether a mailbox exists (MX lookups, a confirmation email): validation.email checks the syntax only.
  • vocalink-data The Vocalink modulus tables themselves: download them from Pay.UK under its terms; caps parses them but does not ship them.