Skip to content

Praveen#26

Merged
virendrakala merged 2 commits into
mainfrom
Praveen
Mar 27, 2026
Merged

Praveen#26
virendrakala merged 2 commits into
mainfrom
Praveen

Conversation

@virendrakala

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 27, 2026 17:17
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 87d1d0b.
Ensure 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 Files

None

@virendrakala virendrakala merged commit c7466bb into main Mar 27, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

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 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 ignoreDeprecations to frontend/tsconfig.json and remove captured TypeScript/Vite error logs.
  • Update backend delivery earnings processing to compute vendor earnings as total - courierEarnings and 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.

Comment on lines +40 to +44
courierEarnings = orderService.calculateCourierEarnings(order.total);
}

// Vendor gets the remaining amount
const vendorEarnings = order.total - courierEarnings;

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines 31 to +41
// 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);
}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +41
// Calculate courier earnings
let courierEarnings = 0;
if (order.courierId) {
courierEarnings = orderService.calculateCourierEarnings(order.total);
}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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 }

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Suggested change
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 }

Copilot uses AI. Check for mistakes.
Comment thread frontend/tsconfig.json
"@/*": ["src/*"]
}
},
"ignoreDeprecations": "5.0"

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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").

Suggested change
"ignoreDeprecations": "5.0"
"ignoreDeprecations": "6.0"

Copilot uses AI. Check for mistakes.
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