Skip to content

Fix reversal business dates in Accounting - #31

Open
belchertechnologiesllc wants to merge 5 commits into
mainfrom
fix/reversal-local-business-date
Open

Fix reversal business dates in Accounting#31
belchertechnologiesllc wants to merge 5 commits into
mainfrom
fix/reversal-local-business-date

Conversation

@belchertechnologiesllc

@belchertechnologiesllc belchertechnologiesllc commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a canonical membership business timezone (America/Chicago for the current membership)
  • make new reversal effective dates use the membership-local business date instead of UTC current_date
  • make historical Accounting compare reversal, approval, and void timestamps using the membership business timezone
  • preserve existing append-only reversal rows physically unchanged
  • add regression coverage for the Aug 7 use / Aug 8 reversal scenario

Root cause

Supabase/Postgres runs in UTC. The production reversal was created/approved shortly after 00:00 UTC on Aug 9, while it was still Aug 8 in Missouri. The reversal row therefore received effective_date = 2026-08-09, and the historical Accounting function also cast approved_at to a UTC date. The current grant/unit balances were correct, but the Aug 8 historical Accounting snapshot excluded the reversal.

Deployment status

  • ✅ hosted Supabase migration applied successfully
  • ✅ hosted migration version is 20260809001548_fix_reversal_business_dates
  • ✅ repository migration filename synchronized to hosted Supabase
  • ✅ existing reversal ledger row remains physically unchanged at stored effective_date = 2026-08-09

Validation

  • ✅ production data inspection confirms source use is approved -1 and reversal is approved +1
  • ✅ live grant reconciliation remains at 6 Incentive Stays
  • ✅ live unit balance remains ~2 for Belcher with ledger delta 0
  • ✅ exact Accounting page RPC now returns Aug 8 Belcher ledger_delta = 0 and full allocated position
  • ✅ Aug 7 historical Accounting still shows Belcher -1 / ~1 remaining
  • ✅ Aug 8 and Aug 9 historical Accounting show Belcher 0 / ~2 remaining
  • ✅ new reversal effective dates use membership-local business date
  • ✅ checked-in 6-assertion regression suite completed through assertion 6 inside rollback
  • ✅ rollback left no test transaction rows behind
  • ✅ Netlify deploy-preview build passed on synchronized branch

Security

  • reversal RPC remains authenticated-only and retains its existing admin authorization checks
  • Supabase advisor still reports pre-existing project-wide SECURITY DEFINER exposure warnings and leaked-password protection being disabled; no new anonymous execute grant was introduced by this fix

Safety

  • production database fix is live
  • existing ledger history was not rewritten
  • branch is ready to merge

@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for bbtpalaceelite ready!

Name Link
🔨 Latest commit a102aac
🔍 Latest deploy log https://app.netlify.com/projects/bbtpalaceelite/deploys/6a77c72782011c00087682b5
😎 Deploy Preview https://deploy-preview-31--bbtpalaceelite.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@belchertechnologiesllc
belchertechnologiesllc marked this pull request as ready for review August 9, 2026 00:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a102aacd6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +34 to +37
select set_config(
'request.jwt.claim.sub',
(select user_id::text from public.unit_users where role = 'admin' and revoked_at is null limit 1),
true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create an admin fixture before invoking authenticated RPCs

On a fresh database built from these migrations, no Auth user or unit_users row is seeded, and the earlier pgTAP suites create their users inside transactions that are rolled back. This subquery therefore returns NULL, leaving auth.uid() unset, so approve_benefit_transaction later aborts with Authentication is required; the Aug. 7/Aug. 8 assertions also depend on hosted ledger rows that no migration creates. As a result, supabase db test cannot complete on a clean checkout; create the admin and historical transaction/reversal fixtures within this test transaction.

Useful? React with 👍 / 👎.

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