feat: add subcontractor AP models (timesheet, payable, vendor accounts) #13

Merged
john merged 1 commit from feat/subcon-ap into dev 2026-08-01 23:36:23 +00:00
Owner

Summary

Add subcontractor Accounts Payable (AP) models to haskos-finance — timesheet tracking, outbound payments, and vendor bank accounts.

What's new

3 Models

  • Timesheet — period, days/hours, rate, amount, status state machine (received → validated → approved → paid)
  • Payable — outbound payment record (we pay subcontractors), with FK to timesheet + vendor account
  • VendorPaymentAccount — subcontractor bank details (mirrors existing PaymentAccount for AR)

15 API Endpoints

  • /timesheets — CRUD + /validate + /approve state transitions
  • /payables — CRUD + /record-payment state transition
  • /vendor-payment-accounts — CRUD with entity_id filter

All endpoints carry finance:read / finance:write scope enforcement (matching PR #12).

Migration

  • 002_add_ap_models.py — creates 3 tables with indexes and FKs

Context

This is the data layer for subcontractor timesheet and AP processing. The agentic flow:

  1. Register contractor as kernel entity
  2. Create NDA + agreement in haskos-legal (DocuSeal signing)
  3. Store vendor bank details (this PR)
  4. Monthly: create timesheet → validate → approve → create payable → record payment

Spec Drift Callouts

  • Scope enforcement added to match the dev branch state (PR #12 merged since task was specified)
  • Write role is contributor (not operator like existing payment_accounts) — intentional for agent-driven flow
## Summary Add subcontractor Accounts Payable (AP) models to haskos-finance — timesheet tracking, outbound payments, and vendor bank accounts. ## What's new ### 3 Models - **Timesheet** — period, days/hours, rate, amount, status state machine (received → validated → approved → paid) - **Payable** — outbound payment record (we pay subcontractors), with FK to timesheet + vendor account - **VendorPaymentAccount** — subcontractor bank details (mirrors existing PaymentAccount for AR) ### 15 API Endpoints - `/timesheets` — CRUD + `/validate` + `/approve` state transitions - `/payables` — CRUD + `/record-payment` state transition - `/vendor-payment-accounts` — CRUD with entity_id filter All endpoints carry `finance:read` / `finance:write` scope enforcement (matching PR #12). ### Migration - `002_add_ap_models.py` — creates 3 tables with indexes and FKs ## Context This is the data layer for subcontractor timesheet and AP processing. The agentic flow: 1. Register contractor as kernel entity 2. Create NDA + agreement in haskos-legal (DocuSeal signing) 3. Store vendor bank details (this PR) 4. Monthly: create timesheet → validate → approve → create payable → record payment ## Spec Drift Callouts - Scope enforcement added to match the dev branch state (PR #12 merged since task was specified) - Write role is `contributor` (not `operator` like existing payment_accounts) — intentional for agent-driven flow
feat: add subcontractor AP models (timesheet, payable, vendor accounts)
All checks were successful
CI / Detect Changes (pull_request) Successful in 5s
CI / Backend (pull_request) Successful in 5s
CI / Docker Build (pull_request) Successful in 24s
CI / Deploy (pull_request) Has been skipped
f4c2f120fa
Adds accounts-payable tracking for subcontractors alongside the existing
receivables (invoice) side of the finance stage app.

Models:
- Timesheet - subcon timesheet per period, received/validated/approved/paid
- Payable - outbound payment record, FK to timesheet + vendor bank account
- VendorPaymentAccount - vendor/subcon bank accounts, keyed by kernel entity

API (tag "ap"), all 15 endpoints gated by finance:read / finance:write per
the convention landed in #12:
- /timesheets  CRUD + /validate + /approve
- /payables    CRUD + /record-payment
- /vendor-payment-accounts  CRUD

Migration 002 (c81f4a2e7d95) creates all three tables with raw SQL,
matching the 001 pattern.

Verified against a scratch Postgres: migration applies clean, alembic has a
single head, compare_metadata reports no model/migration drift for the three
new tables, and all 15 endpoints were exercised end-to-end through ASGI
(happy path, 404/400 guards, and scope denial for gateway callers).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NpdHZDYwNiwXNEQUkAdWdN
john merged commit 71790f0749 into dev 2026-08-01 23:36:23 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
haskytech/haskos-finance!13
No description provided.