Round prices UP and change portfolio name to "Puffin Portfolio"
All checks were successful
Build and Push Docker Images / docker (push) Successful in 49s
All checks were successful
Build and Push Docker Images / docker (push) Successful in 49s
Changes:
- Changed portfolio description from "Portfolio {ID}" to "Puffin Portfolio"
- Round pricePerTon UP using Math.ceil() instead of exact decimals
- Round total cost UP using Math.ceil()
Example: $237.19 per ton → $238 per ton
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
09e3c13eaf
commit
9c7e65b894
@ -70,7 +70,7 @@ router.post('/create-session', async (req, res) => {
|
||||
currency: 'usd',
|
||||
product_data: {
|
||||
name: `Carbon Offset - ${tons} tons`,
|
||||
description: `Portfolio ${portfolioId} at $${pricePerTon}/ton`,
|
||||
description: `Puffin Portfolio at $${Math.ceil(pricePerTon)}/ton`,
|
||||
// images: ['https://puffinoffset.com/images/carbon-offset.png'], // Optional: Add your logo when available
|
||||
},
|
||||
unit_amount: baseAmount, // Base amount in cents
|
||||
|
||||
@ -166,8 +166,8 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr
|
||||
|
||||
const renderPortfolioPrice = (portfolio: Portfolio) => {
|
||||
try {
|
||||
// Get the price per ton from the portfolio
|
||||
const pricePerTon = portfolio.pricePerTon || 18; // Default based on Wren Climate Fund average
|
||||
// Get the price per ton from the portfolio and round UP to next whole number
|
||||
const pricePerTon = Math.ceil(portfolio.pricePerTon || 18);
|
||||
return formatCurrency(pricePerTon, currencies.USD);
|
||||
} catch (err) {
|
||||
console.error('Error formatting portfolio price:', err);
|
||||
@ -175,8 +175,9 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr
|
||||
}
|
||||
};
|
||||
|
||||
// Calculate offset cost using the portfolio price
|
||||
const offsetCost = monetaryAmount || (portfolio ? actualOffsetTons * (portfolio.pricePerTon || 18) : 0);
|
||||
// Calculate offset cost using the portfolio price (rounded UP)
|
||||
const roundedPricePerTon = portfolio ? Math.ceil(portfolio.pricePerTon || 18) : 18;
|
||||
const offsetCost = monetaryAmount || (portfolio ? Math.ceil(actualOffsetTons * roundedPricePerTon) : 0);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user