Implement honest accounting post-job completion, calculating actual costs, adding margin, and enabling automatic refunds for overpayments via a new endpoint. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 418bf6f8-212b-4bb0-a7a5-8231a061da4e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: c6386de2-d5f4-47cc-a557-73416f09e118 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9f85e954-647c-46a5-90a7-396e495a805a/418bf6f8-212b-4bb0-a7a5-8231a061da4e/sPDHkg8 Replit-Helium-Checkpoint-Created: true
14 lines
919 B
SQL
14 lines
919 B
SQL
-- Migration: Add refund/honest-accounting columns to jobs table
|
|
-- Users are refunded the overpayment (work invoice amount - actual cost) after job completion.
|
|
|
|
ALTER TABLE jobs
|
|
ADD COLUMN IF NOT EXISTS actual_amount_sats INTEGER,
|
|
ADD COLUMN IF NOT EXISTS refund_amount_sats INTEGER,
|
|
ADD COLUMN IF NOT EXISTS refund_state TEXT,
|
|
ADD COLUMN IF NOT EXISTS refund_payment_hash TEXT;
|
|
|
|
COMMENT ON COLUMN jobs.actual_amount_sats IS 'Actual charge in sats (raw token cost + DO infra + margin), computed post-execution using the locked BTC price';
|
|
COMMENT ON COLUMN jobs.refund_amount_sats IS 'Overpayment in sats to return to the user (work_amount_sats - actual_amount_sats, clamped >= 0)';
|
|
COMMENT ON COLUMN jobs.refund_state IS 'Refund lifecycle: not_applicable | pending | paid';
|
|
COMMENT ON COLUMN jobs.refund_payment_hash IS 'Payment hash of the outgoing Lightning refund payment once sent';
|