Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/docs/expense-substantiation.md
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 19 minutes ago History
expense-substantiation.md · 10.1 KB · 184 lines

Expenses that hold up in an audit

What app-finance asks for before an expense, a business trip or a fringe benefit is on the books, why, and which of it is yours to set.

This is not tax advice. It describes what the software records and refuses. The US federal rules it is shaped around are named below so you can look them up and take them to your accountant; they are summarised, hedged, and may have changed. Every percentage, threshold and rate the box applies is operator data -- a row you can read and edit, with its source beside it -- and none of it is a constant in code. If a number is wrong for your business, change the row.

What an auditor asks for

For travel, meals, gifts and vehicle use, US federal law asks for more than "we spent it": IRC section 274(d) disallows those expenses unless the taxpayer substantiates, by adequate records or sufficient evidence, the amount, the time and place, the business purpose and, for meals and entertainment, the business relationship of the people present. Treasury Regulation 1.274-5 says what adequate records are, and generally requires documentary evidence (a receipt) for lodging whatever it cost and for any other expenditure of $75 or more. IRS Publication 463 (Travel, Gift, and Car Expenses) walks through it, including the mileage log a vehicle needs instead of a receipt.

An employer that reimburses employees under an accountable plan (Treas. Reg. 1.62-2) keeps those reimbursements out of wages only when the expense has a business connection, is substantiated within a reasonable period, and any excess is returned. The regulation's safe harbour for "reasonable" is 60 days to substantiate and 120 days to return an excess. Whether your plan is accountable is a question for your accountant; the box counts what is late.

What app-finance records against each of those:

The auditor's questionWhere the answer livesWhat refuses a missing answer
How much, and whenexpenses.amount_cents, incurred_onrequired, validation.min 1 (every writer)
Whereexpenses.location; mileage_logs.from_place / to_placerequired on the log
What business it was forexpenses.business_purpose; mileage_logs.business_purposerequired_when the category says so (expenses); required (mileage)
Who was there, and their relationshipexpenses.attendeesrequired_when the category says so
The receiptexpenses.receipt_scan_id -> the scan (app-intake) -> its stored imagerequired_when the amount is over the category's threshold
Who approved itexpenses.approved_by / approved_at (someone other than the claimant)the hook refuses self-approval
How much is deductibleexpenses.deductible_bps / deductible_cents, stamped at approvalthe category_stamps locked check
The milesmileage_logs odometer readings and milesthe mileage_rules locked check

Expense categories

expense_categories is the policy, one row per kind of spending:

FieldMeans
deductible_bpsthe share treated as deductible, in basis points (10000 all, 5000 half, 0 none)
requires_business_purposecannot be submitted or approved without a purpose
requires_attendeescannot be submitted or approved without attendees
receipt_required_over_centsa linked receipt is required when the amount is strictly over this; 7499 means from $75.00, 0 means always, blank means never
account_idthe expense account it is booked to when the expense names none
activeinactive categories cannot be chosen any more
noteswhere the numbers came from, and when somebody last checked

A starter set is seeded, each row citing its source and saying "check with your accountant": client meals (50%, purpose and attendees, receipt over $74.99 -- IRC 274(k) and (n); the 100% restaurant exception covered 2021-2022 only), travel lodging (100%, receipt always), travel transport (100%), travel meals (50%), office supplies (100%), entertainment (0% -- IRC 274(a) after the 2017 amendments) and personal-vehicle mileage (100%, no receipt: the log is the evidence). Finance (role:finance) and admins edit them; everybody signed in can read them.

How a category binds an expense

When an expense is created, recategorised, re-priced, submitted or approved, the category's requirements and deductible share are stamped onto it: receipt_required, purpose_required, attendees_required, deductible_bps, deductible_cents (amount x basis points / 10000, rounded half-up once). Then:

  • required_when turns the stamped flags into refusals while the expense is

submitted, approved or billed -- declared, and enforced for every writer.

  • The category_stamps locked check refuses, inside the write lock and for

every writer, stamps that disagree with the category at that moment. The hook stamps writes that come through the API; a writer below it (an import, action_confirm_scan, the mileage handler) stamps with object_expense_rules.category_stamps, the same function.

  • Approval freezes the stamps with the rest of the expense (locked_when).

Editing a category later restates nothing already approved: last year's report says what last year's policy said.

An expense with no category carries no stamps and no new requirement -- every expense written before app-finance 0.19.0 is one. The report calls its amount unclassified rather than guessing.

The receipt

receipt_scan_id points at a scan in app-intake: the photographed or emailed document, whose stored image is the evidence. It is a relation with requires: update, so you can only cite a receipt you may act on, and it is unique: one receipt substantiates one expense. Confirming a scan (action_confirm_scan) links it automatically and takes the category, purpose, attendees and place. Approvers (role:manager) and finance may read scans. The old free-text receipt_ref stays readable for what was recorded before; the requirement reads only the link.

The deductible report

GET /objects/action_expense_report?from=2025-01-01&to=2025-12-31&period=month|quarter|year[&format=csv]

Approved and billed expenses in the range, by period of incurred_on and category: count, amount, deductible, non-deductible and unclassified cents, plus by_category, by_period, totals and gaps -- every expense on the books missing what its stamps required, an approver, or a category. In every row deductible + non-deductible + unclassified = amount. Each caller sees the expenses they may read: a claimant their own, managers and finance the company's.

Accountable-plan timing

Two queues on the home page, counted for each viewer:

  • Expenses missing a receipt / a business purpose -- drafts whose

category requires one that is not there yet. They cannot be submitted until it is.

  • Expense claims past the accountable-plan window -- drafts and

submitted claims whose incurred_on is at least expenses.accountable_plan_days days ago (an app-settings row; 60 when unset). The wording says "check with your accountant": being late does not by itself make a reimbursement taxable, and the box does not decide that.

Mileage

  • vehicles -- ownership personal (the driver's own; business miles are

reimbursed per mile) or business (the company's; trips are logged as evidence of business use and reimburse nothing).

  • mileage_rates -- one row per calendar year: rate_hundredths_cent (7000 is

70 cents a mile, 6550 is 65.5), source_url, source_date. Nothing is seeded. The IRS announces the business standard mileage rate each year (and has changed it mid-year); look it up, or set your own reimbursement policy, and record where it came from. Approving a trip in a year with no row is refused, naming the year.

  • mileage_logs -- vehicle, date, odometer at start and end (or the miles),

from, to, business purpose; all required. The miles are worked out from the readings. Refused for every writer: an end reading at or below the start, miles that disagree with the readings, a range overlapping another live trip in the same vehicle (ranges are half-open: a trip may start where the last ended), and an approval not stamped with the year's rate.

Approving a log (somebody other than the driver) stamps the rate and the reimbursement (miles x rate / 100, half-up once). For a personal vehicle, system_mileage_expenses then creates one approved, personally-paid, unbillable expense in the mileage category (generated_from mileage_logs/{id}, unique -- replays create nothing more), owed to the driver. Its journal is posted by system_expense_books when the change-log replay (DBBASIC_ENABLE_CHANGE_DISPATCH) delivers it. Rejecting an approved log rejects that expense, and the books reverse.

Reimbursing above the IRS rate generally makes the excess wages; reimbursing below it is a policy choice. Commuting is not business mileage. Ask your accountant.

Fringe benefits

fringe_benefits is a register, not a calculator: employee, benefit type (the kinds IRS Publication 15-B discusses), period, value_cents, taxable yes/no with no default, valuation_method and source. Finance and admins only -- it is pay information about named people, and the recorder loses access when they leave finance. GET /objects/action_fringe_export?from=&to=[&format=csv] hands the rows whose period overlaps the range to a payroll provider as recorded, with formula-looking cells quoted. Nothing computes a value or withholding. Personal use of a business vehicle is the usual entry; its mileage log is the source to cite.

Year-end checklist

  1. Every expense category's numbers checked against its source, and notes

dated.

  1. Every year with trips has a mileage_rates row with a source.
  2. The deductible report for the year has no gaps, or each one is

explained (a pre-0.19.0 expense categorised by hand, a receipt attached).

  1. No claims left in the accountable-plan queue, or each one explained.
  2. The fringe-benefit export reconciled with what payroll reported.
  3. All of it taken to your accountant, who decides what it means.

tests/test_audit_year_end.py runs this for a made-up year and checks every number by hand.