Skip to content

Commit 8f15130

Browse files
committed
fix(costcenter): time unit multiplied by multiple times
Signed-off-by: Nixieboluo <[email protected]>
1 parent f09c1cb commit 8f15130

File tree

1 file changed

+9
-4
lines changed
  • frontend/providers/costcenter/src/components/valuation/CalculatorPanel

1 file changed

+9
-4
lines changed

frontend/providers/costcenter/src/components/valuation/CalculatorPanel/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,18 @@ export default function CalculatorPanel({
182182
const memoryAmount = config.resources.memory.val * memoryPrice;
183183
const storagePrice = priceData.find((x) => x.title === 'storage')?.price || 0;
184184
const storageAmount = config.resources.storage * storagePrice;
185-
const networkPrice = priceData.find((x) => x.title === 'network')?.price || 0;
186-
const networkAmount = config.resources.network * networkPrice;
187185

188186
const portPrice = priceData.find((x) => x.title === 'Port')?.price || 0;
189187
const portAmount = config.resources.ports * portPrice;
190-
let amount = cpuAmount + memoryAmount + storageAmount + networkAmount + portAmount;
188+
let amount = cpuAmount + memoryAmount + storageAmount + portAmount;
191189
if (gpuEnabled) {
192190
const gpuPrice = gpuData[config.resources.gpu.idx]?.price || 0;
193191
const gpuAmount = config.resources.gpu.count * gpuPrice;
194192
amount += gpuAmount;
195193
}
196194
amount = Math.floor(amount);
197195
const duration_scale = PRICE_CYCLE_SCALE[config.usage.timeUnit] || 1;
196+
198197
console.log(
199198
'amount: ',
200199
amount,
@@ -209,7 +208,13 @@ export default function CalculatorPanel({
209208
'timeUnit: ',
210209
config.usage.timeUnit
211210
);
212-
amount = amount * config.usage.quantity * duration_scale * config.usage.duration;
211+
212+
amount = amount * config.usage.quantity * config.usage.duration;
213+
214+
const networkPrice = priceData.find((x) => x.title === 'network')?.price || 0;
215+
const networkAmount = config.resources.network * networkPrice;
216+
217+
amount = amount + networkAmount;
213218

214219
return formatMoney(amount).toFixed(6);
215220
}, [

0 commit comments

Comments
 (0)