@holaluz/pomada
Advanced tools
Comparing version 1.3.0-beta.1 to 1.3.0-beta.2
@@ -7,6 +7,6 @@ import { CupsError } from '../../cups/domain/cups-error'; | ||
products: ProductName[]; | ||
consumption: ValueByPeriod; | ||
currentPower: ValueByPeriod; | ||
optimizedPower: ValueByPeriod; | ||
desiredPower: ValueByPeriod; | ||
consumption?: ValueByPeriod; | ||
currentPower?: ValueByPeriod; | ||
optimizedPower?: ValueByPeriod; | ||
desiredPower?: ValueByPeriod; | ||
}; | ||
@@ -13,0 +13,0 @@ declare type GetProductPricesCallbacks = { |
@@ -8,8 +8,9 @@ "use strict"; | ||
// Gets the fee, energy and power price of an Holaluz product, for the consumption and powers provided. | ||
// If no consumption or currentPower is provided, it will only return energy prices. | ||
async function getProductPrices({ products, consumption, currentPower, optimizedPower, desiredPower, }, { onSuccess, onError }) { | ||
const productPrices = products.map((p) => ({ | ||
name: p, | ||
fee: 0, | ||
})); | ||
await Promise.all([ | ||
// Gets energy/power prices | ||
const requests = [ | ||
...productPrices.map(async (product) => { | ||
@@ -27,3 +28,6 @@ if (product.name === product_name_1.ProductName.fair) | ||
}), | ||
...productPrices.map(async (product) => { | ||
]; | ||
// If we are checking prices for a consumption, gets monthly fee per product | ||
if (consumption && currentPower && optimizedPower && desiredPower) { | ||
requests.push(...productPrices.map(async (product) => { | ||
const targetPower = product.name === product_name_1.ProductName.fair ? optimizedPower : desiredPower; | ||
@@ -37,4 +41,5 @@ const feeResult = await get_fee_of_product_1.getFeeOfProduct(product.name, consumption, currentPower, targetPower); | ||
throw feeResult.getFail(); | ||
}), | ||
]) | ||
})); | ||
} | ||
await Promise.all(requests) | ||
.then(() => onSuccess(productPrices)) | ||
@@ -41,0 +46,0 @@ .catch((e) => onError(e)); |
@@ -5,5 +5,5 @@ import { ValueByPeriod } from '../../period/domain/value-by-period'; | ||
name: ProductName; | ||
fee: Number; | ||
fee?: Number; | ||
energy?: ValueByPeriod; | ||
power?: ValueByPeriod; | ||
} |
export declare enum ProductName { | ||
classic = "CL_1P_20TD", | ||
classicThreePrices = "CL_3P_20TD", | ||
fair = "TJ_3P_20TD" | ||
} |
@@ -7,4 +7,5 @@ "use strict"; | ||
ProductName["classic"] = "CL_1P_20TD"; | ||
ProductName["classicThreePrices"] = "CL_3P_20TD"; | ||
ProductName["fair"] = "TJ_3P_20TD"; | ||
})(ProductName = exports.ProductName || (exports.ProductName = {})); | ||
//# sourceMappingURL=product-name.js.map |
{ | ||
"name": "@holaluz/pomada", | ||
"version": "1.3.0-beta.1", | ||
"version": "1.3.0-beta.2", | ||
"description": "Holaluz shared FE business logic repository", | ||
@@ -5,0 +5,0 @@ "author": "Holaluz", |
@@ -30,2 +30,3 @@ # Pomada | ||
desiredPower: supplyPoint.optimizedPower, | ||
optimizedPower: supplyPoint.optimizedPower, | ||
}, | ||
@@ -32,0 +33,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36692
509
65
0