Skip to content

fix: resolve commission_rate schema mismatch causing silent default on project creation - #17

Open
azlaan428 wants to merge 31 commits into
evuventures:stagfrom
azlaan428:fix/commission-rate-schema
Open

fix: resolve commission_rate schema mismatch causing silent default on project creation#17
azlaan428 wants to merge 31 commits into
evuventures:stagfrom
azlaan428:fix/commission-rate-schema

Conversation

@azlaan428

Copy link
Copy Markdown
Member

Problem

Closes #10

Project creation was silently ignoring the actual commission rate and always saving the schema default (20%) instead.

Root Cause

The Mongoose model (models/project.js) defines the field as commisson_rate (typo, missing an "i"). Every part of the codebase that reads or writes this field — EditProject.tsx, the PUT handler, commission/route.js, invoice/route.js, stat/route.js — already uses that exact spelling and is internally consistent.

The one exception was the POST handler in app/api/project/route.js, which saved the field as commission_rate (correct spelling). Since Mongoose runs in strict mode by default, it silently dropped that field on every new project and fell back to the schema default of 20%, regardless of the sales person's actual contracted rate.

Changes

  • app/api/project/route.js: renamed commission_ratecommisson_rate in the POST handler so project creation matches the schema and every other consumer.
  • models/project.js:
    • Removed an incorrect import (import { string } from "sharp/lib/is") that was being used in place of Mongoose's built-in String type for clientName, email, phone, and address. Fixed those four fields to use type: String.
    • Added min: 0, max: 100 bounds to commisson_rate to prevent invalid data from being saved.

Testing

I wasn't able to test this end-to-end locally — there's no .env/dev environment configuration available yet, so I can't connect to a database or run the app fully. The fix is based on tracing every read/write of this field across the codebase to confirm the schema, frontend, and other API routes all agree on commisson_rate, and that the POST handler was the sole outlier.

Would appreciate a DB-backed test (create a project, confirm the saved rate matches the sales person's contract rate rather than defaulting to 20%) before merging.

wordspherellc and others added 30 commits June 8, 2025 17:17
fixed issues and developed CI/CD pipeline
Update ci.yaml
fix: ci.yml workflow
…key to each iterated element (security debt)
Fix type checking issues // Just the Import several bugs //
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

@azlaan428 is attempting to deploy a commit to the evu Team on Vercel.

A member of the Team first needs to authorize it.

@DebojitxBhatt
DebojitxBhatt force-pushed the stag branch 2 times, most recently from d323586 to 839a400 Compare August 9, 2026 08:59
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.

4 participants