Conversation
Co-authored-by: Copilot <copilot@github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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
invoiceswithtechnician_amountandplatform_fee_percent, and adds a singletonapp_settingstable 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.
| 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)) | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
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>
…form fee is unavailable Agent-Logs-Url: https://github.com/gordon-cs/Biotech-Maintenance-Platform/sessions/e032075e-c327-41c9-9fff-877d004160b4 Co-authored-by: yushinj <149107617+yushinj@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gordon-cs/Biotech-Maintenance-Platform/sessions/e032075e-c327-41c9-9fff-877d004160b4 Co-authored-by: yushinj <149107617+yushinj@users.noreply.github.com>
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.