ARC imports: record Buildium decision votes + richer decision notes; PDF spacing

- Buildium API exposes no ARC comment threads or member votes (verified live);
  surface the final decision instead: vote row dated to the actual decision,
  decision_notes 'Approved by X on date (via Buildium)'
- record_buildium_arc_vote RPC bypasses the finalized-ARC write lock that was
  silently swallowing import votes; 69 existing imports backfilled
- Application Record PDF: paragraph break between comments and decision notes

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 14:26:48 -04:00
parent ff65c8a656
commit c1fad194f7
3 changed files with 22 additions and 19 deletions
@@ -261,6 +261,7 @@ Deno.serve(async (req) => {
const buildiumAssocId: string | null = p._arc_buildium_association_id || null;
const buildiumArcId: string | null = p.buildium_arc_request_id || null;
const deciderName: string | null = p._arc_decider_name || null;
const deciderDate: string | null = p._arc_decider_date || null;
const clean = stripPrivate(p);
@@ -288,21 +289,16 @@ Deno.serve(async (req) => {
? "approve"
: (decisionRaw.includes("den") || decisionRaw.includes("reject") ? "deny" : null);
if (appId && voteDir) {
const voterName = `${deciderName || "Buildium"} (Buildium)`;
await supabase
.from("entity_votes")
.delete()
.eq("entity_type", "arc_application")
.eq("entity_id", appId)
.is("user_id", null)
.ilike("voter_name", "% (Buildium)");
const { error: voteErr } = await supabase.from("entity_votes").insert({
entity_type: "arc_application",
entity_id: appId,
vote: voteDir,
user_id: null,
voter_name: voterName,
recorded_by: null,
// Finalized ARC apps are write-locked (prevent_writes_on_locked_arc),
// and Buildium imports arrive already finalized — so the vote goes
// through the import RPC, which bypasses the lock for this one write.
const { error: voteErr } = await supabase.rpc("record_buildium_arc_vote", {
p_application_id: appId,
p_vote: voteDir,
p_voter_name: `${deciderName || "Buildium"} (Buildium)`,
// Date the vote when the decision was actually made in Buildium,
// not when the import ran.
p_vote_date: deciderDate,
});
if (voteErr) console.warn(`ARC vote record failed for ${appId}: ${voteErr.message}`);
}