Skip to content

Billable rates (1/3): data model + validation - #932

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1788260560-billable-rates-data-model
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1788260560-billable-rates-data-model

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Bottom layer of a 3-PR stack adding billable rates and billed amounts to client reports. This PR only introduces the storage and validation primitives — nothing reads or writes them yet, so behavior is unchanged.

  • clients.billing_rate DECIMAL(10,2) NOT NULL DEFAULT 0 and work_entries.billable INTEGER NOT NULL DEFAULT 1 in backend/src/database/init.js. The defaults are what make this layer non-breaking: existing rows/inserts get rate 0 (amount 0) and are billable, which is the behavior PR 2 will compute against. The DB is in-memory and rebuilt per process, so there is no migration.
  • billingRate on the Joi client schemas: clientSchema defaults it to 0, updateClientSchema deliberately does not default it — a default on a partial-update schema would re-write the rate to 0 on every PUT that omits it.
  • .strict() on the rate rules: without it this Joi version coerces 12.345 to 12.35 instead of rejecting it, so precision(2) alone would silently round client input.
  • billable is intentionally absent from the work-entry schemas: the API does not accept it yet, and the column default covers every insert.

Stack: PR 1 (this) → PR #933 (service/API: billingRate in clients CRUD, totalAmount in reports, amount column in CSV/PDF) → PR #934 (UI).

Testing

cd backend && npm test (171 tests) with coverage above the backend/jest.config.js thresholds. New cases cover the rate default, the rejections (negative, over max, non-numeric, >2 decimals), the no-default-on-update behavior, and the two column definitions in the CREATE TABLE statements.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/af51f484897545a8bc1df69511f47ed4
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/af51f484897545a8bc1df69511f47ed4?variant=devin
Requested by: @sumitshatwara

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant