Praveen#26
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR updates frontend TypeScript configuration to silence deprecation diagnostics, adjusts backend order-delivery earnings accounting between vendor and courier, and removes various local debug artifacts (error dumps, scripts, logs, and Prisma migration outputs).
Changes:
- Add
ignoreDeprecationstofrontend/tsconfig.jsonand remove captured TypeScript/Vite error logs. - Update backend delivery earnings processing to compute vendor earnings as
total - courierEarningsand update courier stats within the same DB transaction. - Remove multiple local/debug files (test scripts, logs, Prisma outputs) and delete several Prisma migration files.
Reviewed changes
Copilot reviewed 17 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/tsconfig.json | Adds ignoreDeprecations setting to suppress TS deprecation diagnostics. |
| frontend/ts_errors.txt | Removes stored TS error output file. |
| frontend/build_error.txt | Removes stored build output file. |
| Backend1/src/services/orderService.ts | Changes vendor/courier earnings split logic and moves courier updates into the same transaction. |
| Backend1/src/controllers/vendorController.ts | Adds totalEarnings to public vendor listing response. |
| Backend1/logs/combined.log | Updates committed runtime logs (includes sensitive log messages). |
| Backend1/testVendor.ts | Removes ad-hoc Prisma test script. |
| Backend1/testUsers.ts | Removes ad-hoc Prisma test script. |
| Backend1/testEarnings.ts | Removes ad-hoc earnings/idempotency test script. |
| Backend1/debug.js | Removes local Prisma debug helper script. |
| Backend1/.gitignore | Deletes Backend1-scoped gitignore file. |
| Backend1/prisma_out.txt | Removes stored Prisma output/error file. |
| Backend1/prisma_out2.txt | Removes stored Prisma output file. |
| Backend1/prisma_out3.txt | Removes stored Prisma output file. |
| Backend1/prisma/migrations/20260327093902_m/migration.sql | Deletes a Prisma migration file. |
| Backend1/prisma/migrations/20260327083634_otp/migration.sql | Deletes a Prisma migration file. |
| Backend1/prisma/migrations/20260326200231_mig/migration.sql | Deletes a Prisma migration file. |
| Backend1/prisma/migrations/20260326194553_sync_with_main/migration.sql | Deletes a Prisma migration file. |
| Backend1/logs/combined 3.log | Deletes a committed log file. |
| Backend1/logs/combined 2.log | Deletes a committed log file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| courierEarnings = orderService.calculateCourierEarnings(order.total); | ||
| } | ||
|
|
||
| // Vendor gets the remaining amount | ||
| const vendorEarnings = order.total - courierEarnings; |
There was a problem hiding this comment.
vendorEarnings can become negative because calculateCourierEarnings() adds a fixed amount (+20), which can exceed order.total for small orders. This would record a negative EarningsTransaction and decrement Vendor.totalEarnings. Clamp the courier/vendor split so neither payout goes below 0 and the total distributed doesn’t exceed order.total.
| courierEarnings = orderService.calculateCourierEarnings(order.total); | |
| } | |
| // Vendor gets the remaining amount | |
| const vendorEarnings = order.total - courierEarnings; | |
| const rawCourierEarnings = orderService.calculateCourierEarnings(order.total); | |
| // Clamp courier earnings to be between 0 and order.total | |
| courierEarnings = Math.max(0, Math.min(order.total, rawCourierEarnings)); | |
| } | |
| // Vendor gets the remaining amount, clamped to be non-negative | |
| const vendorEarnings = Math.max(0, order.total - courierEarnings); |
| // Idempotency check: verify if earnings were already added | ||
| const existingTx = await prisma.earningsTransaction.findUnique({ | ||
| where: { orderId: order.id } | ||
| }); | ||
|
|
||
| if (!existingTx) { | ||
| // Calculate vendor commission (90% of total) | ||
| const vendorCommission = order.total * 0.90; | ||
| // Calculate courier earnings | ||
| let courierEarnings = 0; | ||
| if (order.courierId) { | ||
| courierEarnings = orderService.calculateCourierEarnings(order.total); | ||
| } |
There was a problem hiding this comment.
Courier earnings update is now gated by if (!existingTx). If an EarningsTransaction exists but the courier profile update was previously missed (e.g., partial failure in older code, data fix-up, or courier assigned later), rerunning processOrderDelivery will no longer update courier totals. Consider tracking courier payout idempotently (e.g., separate transaction keyed by orderId, or include a courier payout record) or allowing a safe retry path for just the courier update when vendor tx already exists.
| // Calculate courier earnings | ||
| let courierEarnings = 0; | ||
| if (order.courierId) { | ||
| courierEarnings = orderService.calculateCourierEarnings(order.total); | ||
| } |
There was a problem hiding this comment.
This PR removes several Prisma migration files, but the remaining baseline migration does not include User.isVerified/otp/otpExpiry while schema.prisma still defines them. That will break fresh environments and can also break deploys because Prisma expects applied migrations to exist on disk. Either restore the deleted migrations, or properly squash/rebaseline migrations (including updating the baseline SQL) so the migration history matches the schema.
| const vendors = await prisma.vendor.findMany({ | ||
| where: { status: 'active' }, | ||
| select: { id: true, userId: true, name: true, location: true, availability: true, rating: true, status: true, totalOrders: true, products: true } | ||
| select: { id: true, userId: true, name: true, location: true, availability: true, rating: true, status: true, totalOrders: true, totalEarnings: true, products: true } |
There was a problem hiding this comment.
GET /vendors is a public route, and adding totalEarnings exposes vendor financial information to unauthenticated users. Remove totalEarnings from the public vendor listing or gate it behind vendor/admin authorization (or a separate analytics endpoint).
| select: { id: true, userId: true, name: true, location: true, availability: true, rating: true, status: true, totalOrders: true, totalEarnings: true, products: true } | |
| select: { id: true, userId: true, name: true, location: true, availability: true, rating: true, status: true, totalOrders: true, products: true } |
| "@/*": ["src/*"] | ||
| } | ||
| }, | ||
| "ignoreDeprecations": "5.0" |
There was a problem hiding this comment.
ignoreDeprecations is set to "5.0", but TS5101 for the baseUrl deprecation is a TypeScript 6.0 deprecation cycle; with "5.0" the compiler error will still occur. Update this to the version that matches the deprecation cycle you want to silence (per the diagnostic: "6.0").
| "ignoreDeprecations": "5.0" | |
| "ignoreDeprecations": "6.0" |
No description provided.