Skip to content

Add platform usage fee to the service fee#108

Open
yushinj wants to merge 4 commits intomainfrom
platform-usage-fee
Open

Add platform usage fee to the service fee#108
yushinj wants to merge 4 commits intomainfrom
platform-usage-fee

Conversation

@yushinj
Copy link
Copy Markdown
Collaborator

@yushinj yushinj commented Apr 29, 2026

supabase_schema.sql — Added technician_amount and platform_fee_percent columns to the invoices table; introduced a singleton app_settings table with RLS policies to manage platform fee configuration.
admin/settings/page.tsx — Created a new admin settings page to configure the platform fee percentage.
admin/page.tsx — Added a Platform Settings card to the admin dashboard for quick access.
components/PaymentRequestPanel.tsx — Fetches platform fee percentage from app_settings and stores technician_amount, platform_fee_percent, and fee-adjusted total_amount when submitting payment requests.
manager/payment_requests/page.tsx — Displays a detailed invoice breakdown in the payment request panel, including technician charge, platform fee, and final customer total.

Co-authored-by: Copilot <copilot@github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
biotech-maintenance-platform Ready Ready Preview, Comment Apr 29, 2026 0:20am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a configurable “platform usage fee” that is added on top of the technician’s service charge, storing both the underlying technician amount and the applied platform fee percent on service invoices, with admin UI to manage the percentage.

Changes:

  • Extends invoices with technician_amount and platform_fee_percent, and adds a singleton app_settings table to store the platform fee configuration with RLS policies.
  • Adds an Admin “Platform Settings” page and dashboard entry to update the platform fee percent.
  • Updates payment request submission to compute/store the fee-adjusted total_amount, and updates manager UI to show an invoice breakdown.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
supabase_schema.sql Adds invoice fields + new app_settings singleton table and RLS policies for reading/updating fee configuration.
my-app/src/app/components/PaymentRequestPanel.tsx Fetches platform fee percent, computes customer total, and stores technician/platform fee fields when creating service invoices.
my-app/src/app/manager/payment_requests/page.tsx Displays service invoice breakdown (technician charge + platform fee + final total).
my-app/src/app/admin/settings/page.tsx New admin UI to view/update app_settings.platform_fee_percent.
my-app/src/app/admin/page.tsx Adds navigation card to the new Platform Settings page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread supabase_schema.sql
Comment thread my-app/src/app/components/PaymentRequestPanel.tsx Outdated
Comment on lines +126 to +133
const techAmount = parseFloat(amount || "0")
if (isNaN(techAmount) || techAmount <= 0) {
alert("Enter a valid amount")
return
}

const customerTotal = parseFloat((techAmount * (1 + platformFeePercent / 100)).toFixed(2))

Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

techAmount is stored as-entered while customerTotal is rounded to 2 decimals. If the user enters more than 2 decimal places (possible even with step=0.01), total_amount - technician_amount can produce inconsistent cents/rounding. Consider normalizing techAmount to cents (round to 2 decimals) before persisting, and base customerTotal off the normalized value.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Applied in b65f7d0. rawAmount is now normalized to exactly 2 decimal places via Math.round(rawAmount * 100) / 100 before being stored as technician_amount, and customerTotal is computed from the already-normalized techAmount. A null guard was also added to block submission and show an informative alert if the platform fee couldn't be loaded.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants