Compare commits
2 Commits
9f5c81a14e
...
0dd5746f60
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dd5746f60 | |||
|
|
fdc34aee2f |
@@ -18,7 +18,8 @@ export class MaintenanceRepository {
|
|||||||
subtypes: row.subtypes,
|
subtypes: row.subtypes,
|
||||||
date: row.date,
|
date: row.date,
|
||||||
odometerReading: row.odometer_reading,
|
odometerReading: row.odometer_reading,
|
||||||
cost: row.cost,
|
// node-postgres returns numeric/decimal columns as strings; coerce to honor the number type.
|
||||||
|
cost: row.cost != null ? Number(row.cost) : undefined,
|
||||||
shopName: row.shop_name,
|
shopName: row.shop_name,
|
||||||
notes: row.notes,
|
notes: row.notes,
|
||||||
receiptDocumentId: row.receipt_document_id,
|
receiptDocumentId: row.receipt_document_id,
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ export class OwnershipCostsRepository {
|
|||||||
vehicleId: row.vehicle_id,
|
vehicleId: row.vehicle_id,
|
||||||
documentId: row.document_id,
|
documentId: row.document_id,
|
||||||
costType: row.cost_type,
|
costType: row.cost_type,
|
||||||
amount: row.amount,
|
// node-postgres returns numeric/decimal columns as strings; coerce to honor the number type.
|
||||||
|
amount: Number(row.amount),
|
||||||
description: row.description,
|
description: row.description,
|
||||||
periodStart: row.period_start,
|
periodStart: row.period_start,
|
||||||
periodEnd: row.period_end,
|
periodEnd: row.period_end,
|
||||||
|
|||||||
@@ -115,16 +115,16 @@ export const MaintenanceRecordsList: React.FC<MaintenanceRecordsListProps> = ({
|
|||||||
{categoryDisplay} ({subtypeCount})
|
{categoryDisplay} ({subtypeCount})
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack direction="row" spacing={1} flexWrap="wrap" sx={{ mt: 1 }}>
|
<Stack direction="row" spacing={1} flexWrap="wrap" sx={{ mt: 1 }}>
|
||||||
{record.odometerReading && (
|
{record.odometerReading != null && (
|
||||||
<Chip
|
<Chip
|
||||||
label={`${Number(record.odometerReading).toLocaleString()} miles`}
|
label={`${record.odometerReading.toLocaleString()} miles`}
|
||||||
size="small"
|
size="small"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{record.cost && (
|
{record.cost != null && (
|
||||||
<Chip
|
<Chip
|
||||||
label={`$${Number(record.cost).toFixed(2)}`}
|
label={`$${record.cost.toFixed(2)}`}
|
||||||
size="small"
|
size="small"
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
|||||||
@@ -142,9 +142,7 @@ export const VehicleDetailMobile: React.FC<VehicleDetailMobileProps> = ({
|
|||||||
secondaryParts.push(new Date(rec.date).toLocaleDateString());
|
secondaryParts.push(new Date(rec.date).toLocaleDateString());
|
||||||
secondaryParts.push('Maintenance');
|
secondaryParts.push('Maintenance');
|
||||||
const secondary = secondaryParts.join(' • ');
|
const secondary = secondaryParts.join(' • ');
|
||||||
// Backend returns numeric/decimal columns as strings via node-postgres; coerce.
|
const amount = typeof rec.cost === 'number' ? `$${rec.cost.toFixed(2)}` : undefined;
|
||||||
const costNum = rec.cost != null ? Number(rec.cost) : NaN;
|
|
||||||
const amount = Number.isFinite(costNum) ? `$${costNum.toFixed(2)}` : undefined;
|
|
||||||
list.push({
|
list.push({
|
||||||
id: rec.id,
|
id: rec.id,
|
||||||
type: 'Maintenance',
|
type: 'Maintenance',
|
||||||
|
|||||||
@@ -148,9 +148,7 @@ export const VehicleDetailPage: React.FC = () => {
|
|||||||
if (subtypeText) parts.push(subtypeText);
|
if (subtypeText) parts.push(subtypeText);
|
||||||
if (rec.shopName) parts.push(rec.shopName);
|
if (rec.shopName) parts.push(rec.shopName);
|
||||||
const summary = parts.join(' • ');
|
const summary = parts.join(' • ');
|
||||||
// Backend returns numeric/decimal columns as strings via node-postgres; coerce.
|
const amount = typeof rec.cost === 'number' ? `$${rec.cost.toFixed(2)}` : undefined;
|
||||||
const costNum = rec.cost != null ? Number(rec.cost) : NaN;
|
|
||||||
const amount = Number.isFinite(costNum) ? `$${costNum.toFixed(2)}` : undefined;
|
|
||||||
list.push({ id: rec.id, type: 'Maintenance', date: rec.date, summary, amount });
|
list.push({ id: rec.id, type: 'Maintenance', date: rec.date, summary, amount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user