@widergy/utilitygo-smart-bill-web 3.0.4 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/Advice/index.js +1 -1
  3. package/dist/components/Amount/index.js +24 -20
  4. package/dist/components/Banner/index.js +4 -2
  5. package/dist/components/BarChart/index.js +10 -8
  6. package/dist/components/BillCalculation/components/ConceptCard/index.js +21 -14
  7. package/dist/components/BillCalculation/components/Glossary/index.js +1 -1
  8. package/dist/components/BillCalculation/index.js +13 -9
  9. package/dist/components/BillCalculation/utils.js +12 -13
  10. package/dist/components/BillSummary/components/BilledConcepts/components/Concept/index.js +30 -23
  11. package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/index.js +2 -2
  12. package/dist/components/BillSummary/components/BilledConcepts/index.js +15 -16
  13. package/dist/components/BillSummary/components/BilledConcepts/utils.js +11 -10
  14. package/dist/components/BillSummary/index.js +5 -6
  15. package/dist/components/ConsumptionComparison/components/ComparisonTable/components/DataLine/index.js +9 -5
  16. package/dist/components/ConsumptionComparison/components/ComparisonTable/components/Season/index.js +1 -1
  17. package/dist/components/ConsumptionComparison/components/ComparisonTable/constants.js +6 -8
  18. package/dist/components/ConsumptionComparison/components/ComparisonTable/index.js +2 -2
  19. package/dist/components/ConsumptionComparison/components/ComparisonTable/utils.js +15 -14
  20. package/dist/components/ConsumptionComparison/components/ConsumptionAdvice/index.js +2 -2
  21. package/dist/components/ConsumptionComparison/components/PercentageComparison/index.js +3 -3
  22. package/dist/components/ConsumptionComparison/components/PercentageComparison/utils.js +1 -1
  23. package/dist/components/ConsumptionComparison/index.js +2 -3
  24. package/dist/components/ConsumptionEnergyDetails/components/ConsumptionEnergyComparison/index.js +51 -50
  25. package/dist/components/ConsumptionEnergyDetails/components/ConsumptionInDaysLabel/index.js +23 -19
  26. package/dist/components/ConsumptionEnergyDetails/components/EnergyTotalConsumption/index.js +3 -3
  27. package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/index.js +3 -3
  28. package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/utils.js +1 -1
  29. package/dist/components/ConsumptionEnergyDetails/index.js +24 -22
  30. package/dist/components/ConsumptionIncluded/components/TimelineRow/components/Card/index.js +15 -12
  31. package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderConsumption/index.js +3 -3
  32. package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderSettlement/index.js +3 -3
  33. package/dist/components/ConsumptionIncluded/components/TimelineRow/index.js +9 -9
  34. package/dist/components/ConsumptionIncluded/index.js +1 -1
  35. package/dist/components/ConsumptionIncluded/utils.js +47 -65
  36. package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/components/ReadingRow/index.js +22 -18
  37. package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/index.js +37 -30
  38. package/dist/components/ConsumptionPeriod/components/HistoryGraph/index.js +1 -1
  39. package/dist/components/ConsumptionPeriod/components/Reading/index.js +35 -26
  40. package/dist/components/ConsumptionPeriod/index.js +24 -18
  41. package/dist/components/Date/index.js +17 -13
  42. package/dist/components/DebtState/index.js +9 -6
  43. package/dist/components/IconAndDetails/index.js +22 -17
  44. package/dist/components/Magnitude/index.js +14 -8
  45. package/dist/components/Magnitude/utils.js +1 -1
  46. package/dist/components/MainBillData/components/BillAlert/components/BillParticularConditions/index.js +3 -3
  47. package/dist/components/MainBillData/components/BillAlert/index.js +8 -6
  48. package/dist/components/MainBillData/components/BillBody/components/ClientData/index.js +38 -29
  49. package/dist/components/MainBillData/components/BillBody/components/Consumption/index.js +2 -2
  50. package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/index.js +34 -28
  51. package/dist/components/MainBillData/components/BillBody/index.js +15 -13
  52. package/dist/components/MainBillData/components/BillHeader/components/TypeAndNumber/index.js +11 -7
  53. package/dist/components/MainBillData/components/BillHeader/index.js +19 -15
  54. package/dist/components/MainBillData/index.js +3 -4
  55. package/dist/components/Period/index.js +42 -35
  56. package/dist/components/PowerProgresBar/components/PowerConsumption/index.js +7 -4
  57. package/dist/components/PowerProgresBar/index.js +2 -2
  58. package/dist/components/RateAndCategory/index.js +12 -8
  59. package/dist/components/RatesDefinition/components/BillRate/components/RatePrices/index.js +1 -1
  60. package/dist/components/RatesDefinition/components/BillRate/index.js +2 -2
  61. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/Category/index.js +2 -2
  62. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/components/IndicatorLabel/index.js +3 -3
  63. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/index.js +2 -2
  64. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/utils.js +2 -2
  65. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Legend/index.js +1 -1
  66. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Stages/index.js +2 -2
  67. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/index.js +1 -1
  68. package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/utils.js +5 -5
  69. package/dist/components/RatesDefinition/components/CategoryByConsumption/index.js +1 -1
  70. package/dist/components/RatesDefinition/components/PurchasedRate/index.js +2 -2
  71. package/dist/components/RatesDefinition/index.js +1 -1
  72. package/dist/components/SmartBillSummary/constants.js +25 -0
  73. package/dist/components/SmartBillSummary/index.js +70 -0
  74. package/dist/components/SmartBillSummary/styles.module.scss +48 -0
  75. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/constants.js +9 -0
  76. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +90 -0
  77. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/styles.module.scss +55 -0
  78. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/utils.js +32 -0
  79. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/constants.js +13 -0
  80. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/index.js +78 -0
  81. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/styles.module.scss +43 -0
  82. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/constants.js +9 -0
  83. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/index.js +68 -0
  84. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/styles.module.scss +43 -0
  85. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/utils.js +35 -0
  86. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/index.js +72 -0
  87. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/styles.module.scss +29 -0
  88. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/utils.js +71 -0
  89. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/index.js +64 -0
  90. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/styles.module.scss +22 -0
  91. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/utils.js +56 -0
  92. package/dist/components/SmartBillSummary/tabs/Consumptions/index.js +54 -0
  93. package/dist/components/SmartBillSummary/tabs/Consumptions/styles.module.scss +31 -0
  94. package/dist/components/SmartBillSummary/utils.js +30 -0
  95. package/dist/components/StyledAmount/constants.js +1 -1
  96. package/dist/components/StyledAmount/index.js +18 -13
  97. package/dist/components/WithContextApi/index.js +2 -2
  98. package/dist/components/WithContextApi/layout.js +2 -3
  99. package/dist/components/WithSeason/index.js +2 -2
  100. package/dist/constants/deviceSizes.js +1 -1
  101. package/dist/constants/testsIds.js +136 -0
  102. package/dist/index.js +15 -1
  103. package/dist/shared/Context/index.js +1 -1
  104. package/dist/shared/constants/tabs.js +11 -0
  105. package/dist/shared/utils/billCalculation.js +5 -6
  106. package/dist/shared/utils/consumptions.js +9 -20
  107. package/dist/shared/utils/periods.js +2 -5
  108. package/dist/utils.js +1 -1
  109. package/package.json +1 -1
@@ -8,17 +8,16 @@ var _string = require("@widergy/web-utils/lib/string");
8
8
  var _periodicities = require("../constants/periodicities");
9
9
  var _periods = require("./periods");
10
10
  const titleMapper = (billData, texts) => {
11
- var _currentPeriod$settle, _currentPeriod$settle2, _currentPeriod$settle3;
12
11
  const currentPeriod = (0, _periods.getCurrentPeriod)(billData);
13
- const periodicity = currentPeriod === null || currentPeriod === void 0 || (_currentPeriod$settle = currentPeriod.settlements) === null || _currentPeriod$settle === void 0 ? void 0 : _currentPeriod$settle.periodicity;
14
- const currentSettlement = (currentPeriod === null || currentPeriod === void 0 || (_currentPeriod$settle2 = currentPeriod.settlements) === null || _currentPeriod$settle2 === void 0 || (_currentPeriod$settle2 = _currentPeriod$settle2.current) === null || _currentPeriod$settle2 === void 0 ? void 0 : _currentPeriod$settle2.number) || '-';
15
- const totalSettlements = (currentPeriod === null || currentPeriod === void 0 || (_currentPeriod$settle3 = currentPeriod.settlements) === null || _currentPeriod$settle3 === void 0 ? void 0 : _currentPeriod$settle3.total_settlements) || '-';
16
- const periodYear = (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.year) || '-';
12
+ const periodicity = currentPeriod?.settlements?.periodicity;
13
+ const currentSettlement = currentPeriod?.settlements?.current?.number || '-';
14
+ const totalSettlements = currentPeriod?.settlements?.total_settlements || '-';
15
+ const periodYear = currentPeriod?.year || '-';
17
16
  return {
18
17
  periodicity: (0, _string.stringToCompareWithoutAccentsInclusive)(periodicity, _periodicities.PERIODICITY.BIMONTHLY) ? texts.Base.bimester : '-',
19
18
  currentSettlement,
20
19
  totalSettlements,
21
- periodNumber: (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.number) || '-',
20
+ periodNumber: currentPeriod?.number || '-',
22
21
  periodYear
23
22
  };
24
23
  };
@@ -5,39 +5,28 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getTotalConsumption = exports.getRemainingConsumption = exports.getDailyConsumption = exports.getCurrentConsumption = exports.getConsumptionHistoryData = exports.consumptionDataMapper = void 0;
7
7
  var _dayjs = _interopRequireDefault(require("dayjs"));
8
- var _lodash = _interopRequireDefault(require("lodash"));
8
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
9
9
  var _string = require("@widergy/web-utils/lib/string");
10
10
  var _consumptions = require("../constants/consumptions");
11
11
  var _periods = require("./periods");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- const getCurrentConsumption = (period, energyType) => {
14
- var _period$settlements;
15
- return (period === null || period === void 0 || (_period$settlements = period.settlements) === null || _period$settlements === void 0 || (_period$settlements = _period$settlements.current) === null || _period$settlements === void 0 || (_period$settlements = _period$settlements.consumptions) === null || _period$settlements === void 0 ? void 0 : _period$settlements.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyType))) || {};
16
- };
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const getCurrentConsumption = (period, energyType) => period?.settlements?.current?.consumptions?.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyType)) || {};
17
14
  exports.getCurrentConsumption = getCurrentConsumption;
18
15
  const getRemainingConsumption = (period, energyType) => {
19
- var _period$settlements2;
20
- const remaining = (period === null || period === void 0 || (_period$settlements2 = period.settlements) === null || _period$settlements2 === void 0 || (_period$settlements2 = _period$settlements2.remaining) === null || _period$settlements2 === void 0 || (_period$settlements2 = _period$settlements2[0]) === null || _period$settlements2 === void 0 ? void 0 : _period$settlements2.consumptions) || [];
16
+ const remaining = period?.settlements?.remaining?.[0]?.consumptions || [];
21
17
  return remaining.find(item => (0, _string.stringToCompareWithoutAccentsInclusive)(item.magnitude, energyType)) || {};
22
18
  };
23
19
  exports.getRemainingConsumption = getRemainingConsumption;
24
- const getTotalConsumption = (period, energyOrPowerType) => {
25
- var _period$consumptions;
26
- return (period === null || period === void 0 || (_period$consumptions = period.consumptions) === null || _period$consumptions === void 0 ? void 0 : _period$consumptions.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.type, _consumptions.CONSUMPTION_TYPES.TOTAL) && (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyOrPowerType))) || {};
27
- };
20
+ const getTotalConsumption = (period, energyOrPowerType) => period?.consumptions?.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.type, _consumptions.CONSUMPTION_TYPES.TOTAL) && (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyOrPowerType)) || {};
28
21
  exports.getTotalConsumption = getTotalConsumption;
29
- const getDailyConsumption = (period, energyType) => {
30
- var _period$consumptions2;
31
- return (period === null || period === void 0 || (_period$consumptions2 = period.consumptions) === null || _period$consumptions2 === void 0 ? void 0 : _period$consumptions2.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.type, _consumptions.CONSUMPTION_TYPES.DAILY) && (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyType))) || {};
32
- };
22
+ const getDailyConsumption = (period, energyType) => period?.consumptions?.find(consumption => (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.type, _consumptions.CONSUMPTION_TYPES.DAILY) && (0, _string.stringToCompareWithoutAccentsInclusive)(consumption.magnitude, energyType)) || {};
33
23
  exports.getDailyConsumption = getDailyConsumption;
34
- const formatPeriod = period => period.number && period.year && "".concat(period.number, "/").concat((0, _dayjs.default)(period.year, 'YYYY').format('YY'));
24
+ const formatPeriod = period => period.number && period.year && `${period.number}/${(0, _dayjs.default)(period.year, 'YYYY').format('YY')}`;
35
25
  const getConsumptionHistoryData = (billDataParameter, energyType, showPeriodsInChronologicalOrder) => {
36
- var _billData$periods;
37
- const billData = _lodash.default.cloneDeep(billDataParameter);
26
+ const billData = (0, _cloneDeep.default)(billDataParameter);
38
27
  const currentPeriod = (0, _periods.getCurrentPeriod)(billData);
39
28
  const lastYearPeriod = (0, _periods.getLastYearPeriod)(billData);
40
- const otherPeriods = billData === null || billData === void 0 || (_billData$periods = billData.periods) === null || _billData$periods === void 0 ? void 0 : _billData$periods.filter(period => !(0, _periods.areSamePeriods)(period, currentPeriod) && !(0, _periods.areSamePeriods)(period, lastYearPeriod) && period.consumptions).sort(_periods.comparePeriods);
29
+ const otherPeriods = billData?.periods?.filter(period => !(0, _periods.areSamePeriods)(period, currentPeriod) && !(0, _periods.areSamePeriods)(period, lastYearPeriod) && period.consumptions).sort(_periods.comparePeriods);
41
30
  const periods = [...(lastYearPeriod.consumptions && showPeriodsInChronologicalOrder ? [lastYearPeriod] : []), ...otherPeriods, ...(currentPeriod.consumptions ? [currentPeriod] : []), ...(lastYearPeriod.consumptions && !showPeriodsInChronologicalOrder ? [lastYearPeriod] : [])].filter(period => getTotalConsumption(period, energyType).value === 0 || getTotalConsumption(period, energyType).value).map(period => ({
42
31
  period: formatPeriod(period),
43
32
  consumption: getTotalConsumption(period, energyType).value,
@@ -9,7 +9,7 @@ const getCurrentPeriod = billData => (0, _seamlessImmutable.getIn)(billData, ['p
9
9
  exports.getCurrentPeriod = getCurrentPeriod;
10
10
  const getLastYearPeriod = billData => {
11
11
  const currentPeriod = getCurrentPeriod(billData);
12
- const lastYear = "".concat(parseInt(currentPeriod.year, 10) - 1);
12
+ const lastYear = `${parseInt(currentPeriod.year, 10) - 1}`;
13
13
  return (0, _seamlessImmutable.getIn)(billData, ['periods'], []).find(period => period.number === currentPeriod.number && period.year === lastYear) || {};
14
14
  };
15
15
  exports.getLastYearPeriod = getLastYearPeriod;
@@ -35,8 +35,5 @@ const comparePeriods = (period1, period2) => {
35
35
  return 0;
36
36
  };
37
37
  exports.comparePeriods = comparePeriods;
38
- const getSavingsPercentage = period => {
39
- var _period$additional_in;
40
- return period === null || period === void 0 || (_period$additional_in = period.additional_information) === null || _period$additional_in === void 0 ? void 0 : _period$additional_in.savings_percentage;
41
- };
38
+ const getSavingsPercentage = period => period?.additional_information?.savings_percentage;
42
39
  exports.getSavingsPercentage = getSavingsPercentage;
package/dist/utils.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.stringOrDash = exports.numberOrDash = exports.formatNumber = void 0;
7
7
  var _numeral = _interopRequireDefault(require("config/numeral"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  const formatNumber = value => (0, _numeral.default)(value).format('0.[00]');
10
10
  exports.formatNumber = formatNumber;
11
11
  const numberOrDash = function (number) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/utilitygo-smart-bill-web",
3
- "version": "3.0.4",
3
+ "version": "3.2.0",
4
4
  "description": "UtilityGO SmartBill Web",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",