@zeniai/client-epic-state 4.19.96-beta3ND → 4.19.96-beta5ND

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.
@@ -1,4 +1 @@
1
- import { Currency } from './amount';
2
1
  export declare const isUsdCurrency: (currencyCode: string) => currencyCode is "USD";
3
- /** Default home-currency fallback when tenant/report currency is unset. */
4
- export declare const defaultCustomerCurrency: Currency;
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultCustomerCurrency = exports.isUsdCurrency = void 0;
3
+ exports.isUsdCurrency = void 0;
4
4
  const isUsdCurrency = (currencyCode) => {
5
5
  return currencyCode === 'USD';
6
6
  };
7
7
  exports.isUsdCurrency = isUsdCurrency;
8
- /** Default home-currency fallback when tenant/report currency is unset. */
9
- exports.defaultCustomerCurrency = {
10
- currencyCode: 'USD',
11
- currencySymbol: '$',
12
- };
@@ -1,3 +1,4 @@
1
+ import { Currency } from '../../commonStateTypes/amount';
1
2
  import { ID } from '../../commonStateTypes/common';
2
3
  import { ZeniDate } from '../../zeniDayJS';
3
4
  import { ZeniUrl as Url } from '../../zeniUrl';
@@ -46,3 +47,4 @@ export interface Customer extends CustomerBase {
46
47
  export interface CustomerState {
47
48
  byCustomerId: Record<ID, Customer>;
48
49
  }
50
+ export declare const defaultCustomerCurrency: Currency;
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultCustomerCurrency = void 0;
4
+ exports.defaultCustomerCurrency = {
5
+ currencyCode: 'USD',
6
+ currencySymbol: '$',
7
+ };
@@ -1,8 +1,3 @@
1
1
  export const isUsdCurrency = (currencyCode) => {
2
2
  return currencyCode === 'USD';
3
3
  };
4
- /** Default home-currency fallback when tenant/report currency is unset. */
5
- export const defaultCustomerCurrency = {
6
- currencyCode: 'USD',
7
- currencySymbol: '$',
8
- };
@@ -1 +1,4 @@
1
- export {};
1
+ export const defaultCustomerCurrency = {
2
+ currencyCode: 'USD',
3
+ currencySymbol: '$',
4
+ };
package/lib/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { isAllowedValueWithCode, isAllowedValueWithID, } from './commonStateTypes/allowedValue';
2
2
  import { toAmount } from './commonStateTypes/amount';
3
- import { defaultCustomerCurrency } from './commonStateTypes/currencyHelper';
4
3
  import { getTimeframeTickTag, isIncompleteMonthPresentInTimeframeTick, } from './commonStateTypes/bookCloseDateHelper';
5
4
  import { toCOABalanceTimeframe, } from './commonStateTypes/coaBalance/coaBalance';
6
5
  import { isCalculatedBalanceType, toCOABalanceType, toCOABalanceTypeStrict, } from './commonStateTypes/coaBalance/coaBalanceType';
@@ -41,6 +40,7 @@ import { getControllersName, getFirstControllerEmail, getFirstControllerId, } fr
41
40
  import { getCompanyByCompanyId, getCompanyInfoForAllCockpitCompaniesInState, getControllersForCompany, } from './entity/company/companySelector';
42
41
  import { ALL_ACCOUNTING_CONNECTION_CREATION_MODES, isCompanyEligibleForTreasury, } from './entity/company/companyStateTypes';
43
42
  import { updateCompaniesHealth, updateCompanyHealth, } from './entity/companyHealthMetric/companyHealthMetricReducer';
43
+ import { defaultCustomerCurrency, } from './entity/customer/customerState';
44
44
  import { CustomerIncomeTrend } from './entity/customerIncome/customerIncomeTrend';
45
45
  import { getDepositAccountLimitForChargeCardByDepositAccountId } from './entity/depositAccount/depositAccountSelector';
46
46
  import { mapAttachmentFilePayloadToFile, mapAttachmentFileToAttachmentFilePayload, mapFilePayloadToFile, removeAttachmentFiles, updateAttachmentFiles, updateFiles, } from './entity/file/fileReducer';
@@ -3,7 +3,7 @@ import { mapReportPayloadV2ToReportV2 } from '../../../commonPayloadTypes/v2/vie
3
3
  import { getAgingBalancesKey, toAgingPeriod, } from '../../../commonStateTypes/agingBalance/agingBalance';
4
4
  import { getNestedCustomerHierarchy } from '../../../commonStateTypes/customerView/getNestedCustomerHierarchy';
5
5
  import { toCustomer } from '../../../entity/customer/customerPayload';
6
- import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
6
+ import { defaultCustomerCurrency } from '../../../entity/customer/customerState';
7
7
  import { dateNow } from '../../../zeniDayJS';
8
8
  import { toArAgingDataByCustomerId, toArAgingTotals, } from './arAgingPayload';
9
9
  export const inititalUIState = {
@@ -1,8 +1,8 @@
1
1
  import { createSelector } from '@reduxjs/toolkit';
2
2
  import orderBy from 'lodash/orderBy';
3
3
  import { getAgingBalancesKey, } from '../../../commonStateTypes/agingBalance/agingBalance';
4
- import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
5
4
  import { getCustomer } from '../../../entity/customer/customerSelector';
5
+ import { defaultCustomerCurrency, } from '../../../entity/customer/customerState';
6
6
  export const getArAgingReport = createSelector((state) => state.arAgingState, (state) => state.customerState, (arAgingState, customerState) => {
7
7
  const { reportId, reportTitle, fetchState, uiState, firstMonthOfFY, agingPeriods, } = arAgingState;
8
8
  const { searchString, sortOrder, sortKey, selectedDate } = uiState;
@@ -1,8 +1,11 @@
1
1
  import { toAmountWC } from '../../commonStateTypes/amount';
2
- import { getSummationFreeRangeTotalBalance } from '../../commonStateTypes/coaBalance/additionalBalances/getSummationBalance';
3
2
  import { reduceFetchStateParallelTimeframes } from '../../commonStateTypes/reduceFetchState';
4
- import { defaultCustomerCurrency } from '../../commonStateTypes/currencyHelper';
5
3
  import { getSectionClassesViewReport } from '../../entity/sectionClassesViewV2/sectionClassesViewSelector';
4
+ /** If `ProfitAndLossClassesViewState.currency` is unset (e.g. tests). */
5
+ const FALLBACK_REPORT_CURRENCY = {
6
+ currencyCode: 'USD',
7
+ currencySymbol: '$',
8
+ };
6
9
  export const profitAndLossHorizontalIdsInOrder = [
7
10
  'income',
8
11
  'cogs',
@@ -46,7 +49,7 @@ export const getProfitAndLossClassesHorizontalView = (filter, accountState, clas
46
49
  const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, filter.classesToFilterOut);
47
50
  const sections = {};
48
51
  const calculatedSections = {};
49
- let reportCurrency = defaultCustomerCurrency;
52
+ let reportCurrency = FALLBACK_REPORT_CURRENCY;
50
53
  if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
51
54
  // Get section reports using existing selector infrastructure
52
55
  const sectionReports = {};
@@ -54,7 +57,7 @@ export const getProfitAndLossClassesHorizontalView = (filter, accountState, clas
54
57
  sectionReports[sectionId] = getSectionClassesViewReport(accountState, classState, sectionsState, { reportId, sectionId }, filter);
55
58
  });
56
59
  reportCurrency =
57
- profitAndLossClassesViewState.currency ?? defaultCustomerCurrency;
60
+ profitAndLossClassesViewState.currency ?? FALLBACK_REPORT_CURRENCY;
58
61
  // Pivot each section from class→account to account→class
59
62
  HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
60
63
  const sectionReport = sectionReports[sectionId];
@@ -250,15 +253,17 @@ function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap, de
250
253
  });
251
254
  }
252
255
  /**
253
- * Total `balance.amount` for the current COA slice (same aggregation as
254
- * `getSummationFreeRangeTotalBalance`, used for class totals and account rows).
256
+ * Total amount for the current report slice. `balances` is already narrowed by
257
+ * `getCOABalances` / `sliceCOABalances` to the selected range; summing matches
258
+ * multi-period selections and avoids mismatches when `thisPeriod` does not
259
+ * align with a row (e.g. slice fallback) or when several period rows are shown.
255
260
  */
256
261
  function sumBalancesInSlice(balances) {
257
- if (balances.length === 0) {
258
- return 0;
262
+ let sum = 0;
263
+ for (const bal of balances) {
264
+ sum += bal.balance?.amount ?? 0;
259
265
  }
260
- const summed = getSummationFreeRangeTotalBalance([...balances]);
261
- return summed?.balance.amount ?? 0;
266
+ return sum;
262
267
  }
263
268
  /**
264
269
  * Compute a calculated section by adding or subtracting two sets of class totals.
package/lib/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { NestedAccountHierarchyForReport, NestedAccountID, NestedAccountIDHierar
2
2
  import { AgingBalance, AgingPeriod } from './commonStateTypes/agingBalance/agingBalance';
3
3
  import { AllowedValue, AllowedValueWithCode, AllowedValueWithID, isAllowedValueWithCode, isAllowedValueWithID } from './commonStateTypes/allowedValue';
4
4
  import { Amount, Currency, toAmount } from './commonStateTypes/amount';
5
- import { defaultCustomerCurrency } from './commonStateTypes/currencyHelper';
6
5
  import { AnimationFileName } from './commonStateTypes/animations';
7
6
  import { Balance, BalanceChange } from './commonStateTypes/balance';
8
7
  import { BalanceKind, BalancesTimeseries, TrendTimeseries } from './commonStateTypes/balanceTimeseries';
@@ -71,7 +70,7 @@ import { AdditionalChurnFactor, AdditionalChurnFactors, CompanyHealthMetric, Com
71
70
  import { ConnectedAccount } from './entity/connectedAccount/connectedAccount';
72
71
  import { Country } from './entity/countryList/countryListState';
73
72
  import { CountryWithCurrency } from './entity/currency/currency';
74
- import { Customer, CustomerBase } from './entity/customer/customerState';
73
+ import { Customer, CustomerBase, defaultCustomerCurrency } from './entity/customer/customerState';
75
74
  import { CustomerIncomeTrend } from './entity/customerIncome/customerIncomeTrend';
76
75
  import { CustomerSatisfactionInfo } from './entity/customerSatisfaction/customerSatisfactionSelectorReducerTypes';
77
76
  import { CustomerRatingCodeType, TeamRatingCodeType } from './entity/customerSatisfaction/customerSatisfactionState';
package/lib/index.js CHANGED
@@ -74,8 +74,6 @@ Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get
74
74
  Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
75
75
  const amount_1 = require("./commonStateTypes/amount");
76
76
  Object.defineProperty(exports, "toAmount", { enumerable: true, get: function () { return amount_1.toAmount; } });
77
- const currencyHelper_1 = require("./commonStateTypes/currencyHelper");
78
- Object.defineProperty(exports, "defaultCustomerCurrency", { enumerable: true, get: function () { return currencyHelper_1.defaultCustomerCurrency; } });
79
77
  const bookCloseDateHelper_1 = require("./commonStateTypes/bookCloseDateHelper");
80
78
  Object.defineProperty(exports, "getTimeframeTickTag", { enumerable: true, get: function () { return bookCloseDateHelper_1.getTimeframeTickTag; } });
81
79
  Object.defineProperty(exports, "isIncompleteMonthPresentInTimeframeTick", { enumerable: true, get: function () { return bookCloseDateHelper_1.isIncompleteMonthPresentInTimeframeTick; } });
@@ -209,6 +207,8 @@ Object.defineProperty(exports, "isCompanyEligibleForTreasury", { enumerable: tru
209
207
  const companyHealthMetricReducer_1 = require("./entity/companyHealthMetric/companyHealthMetricReducer");
210
208
  Object.defineProperty(exports, "updateCompaniesHealth", { enumerable: true, get: function () { return companyHealthMetricReducer_1.updateCompaniesHealth; } });
211
209
  Object.defineProperty(exports, "updateCompanyHealth", { enumerable: true, get: function () { return companyHealthMetricReducer_1.updateCompanyHealth; } });
210
+ const customerState_1 = require("./entity/customer/customerState");
211
+ Object.defineProperty(exports, "defaultCustomerCurrency", { enumerable: true, get: function () { return customerState_1.defaultCustomerCurrency; } });
212
212
  const customerIncomeTrend_1 = require("./entity/customerIncome/customerIncomeTrend");
213
213
  Object.defineProperty(exports, "CustomerIncomeTrend", { enumerable: true, get: function () { return customerIncomeTrend_1.CustomerIncomeTrend; } });
214
214
  const depositAccountSelector_1 = require("./entity/depositAccount/depositAccountSelector");