fix: include batteryRentPending in rental interface and sanitize pending rent calculation

This commit is contained in:
sazzadulalambd
2026-05-16 15:28:33 +06:00
parent adbcded611
commit ce4bbfaf81

View File

@@ -36,6 +36,7 @@ interface Rental {
batteryId?: string; batteryId?: string;
batteryName?: string; batteryName?: string;
batteryRent?: number; batteryRent?: number;
batteryRentPending?: number;
type: RentalType; type: RentalType;
status: RentalStatus; status: RentalStatus;
startDate: string; startDate: string;
@@ -702,7 +703,7 @@ export default function RentalsPage() {
? Math.round(batteryRent / 4) ? Math.round(batteryRent / 4)
: batteryRent; : batteryRent;
const totalRent = bikeRent + batteryRentAdjusted; const totalRent = bikeRent + batteryRentAdjusted;
const due = rental.pendingRent + rental.batteryRentPending || 0; const due = (rental.pendingRent || 0) + (rental.batteryRentPending || 0);
const penalty = rental.penaltyAmount || 0; const penalty = rental.penaltyAmount || 0;
const totalDue = due + penalty; const totalDue = due + penalty;
const periodLabel = rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo'; const periodLabel = rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo';