@layerfi/components 0.1.42 → 0.1.44

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.
package/.eslintrc.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  ecmaVersion: 'latest',
19
19
  sourceType: 'module',
20
20
  },
21
- plugins: ['react', '@typescript-eslint', 'prettier'],
21
+ plugins: ['react', '@typescript-eslint', 'prettier', 'import'],
22
22
  rules: {
23
23
  'prettier/prettier': 'error',
24
24
  indent: ['off', 2, { SwitchCase: 1 }],
@@ -37,4 +37,17 @@ module.exports = {
37
37
  },
38
38
  ],
39
39
  },
40
+ overrides: [
41
+ {
42
+ files: ['*.tsx'],
43
+ rules: {
44
+ 'no-restricted-imports': [
45
+ 'error',
46
+ {
47
+ patterns: ['*.css'],
48
+ },
49
+ ],
50
+ },
51
+ },
52
+ ],
40
53
  }
package/dist/esm/index.js CHANGED
@@ -5361,7 +5361,8 @@ var MatchForm = ({
5361
5361
  bankTransaction,
5362
5362
  selectedMatchId,
5363
5363
  setSelectedMatchId,
5364
- matchFormError
5364
+ matchFormError,
5365
+ readOnly = false
5365
5366
  }) => {
5366
5367
  return /* @__PURE__ */ React75.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ React75.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ React75.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ React75.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ React75.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ React75.createElement(
5367
5368
  "div",
@@ -5378,6 +5379,9 @@ var MatchForm = ({
5378
5379
  match.id === selectedMatchId ? `${classNamePrefix}__match-row--selected` : ""
5379
5380
  ),
5380
5381
  onClick: () => {
5382
+ if (readOnly === true) {
5383
+ return;
5384
+ }
5381
5385
  if (selectedMatchId === match.id) {
5382
5386
  setSelectedMatchId(void 0);
5383
5387
  return;
@@ -5789,6 +5793,7 @@ var ExpandedBankTransactionRow = forwardRef5(
5789
5793
  submitBtnText = "Save",
5790
5794
  containerWidth,
5791
5795
  showDescriptions,
5796
+ mode,
5792
5797
  showReceiptUploads,
5793
5798
  hardRefreshPnlOnCategorize
5794
5799
  }, ref) => {
@@ -5861,7 +5866,7 @@ var ExpandedBankTransactionRow = forwardRef5(
5861
5866
  };
5862
5867
  const sanitizeNumberInput = (input) => {
5863
5868
  let sanitized = input.replace(/[^0-9.]/g, "");
5864
- let parts = sanitized.split(".");
5869
+ const parts = sanitized.split(".");
5865
5870
  if (parts.length > 2) {
5866
5871
  sanitized = parts[0] + "." + parts.slice(1).join("");
5867
5872
  }
@@ -6051,7 +6056,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6051
6056
  style: { height },
6052
6057
  onTransitionEnd: handleTransitionEnd
6053
6058
  },
6054
- shouldHide ? null : /* @__PURE__ */ React80.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ React80.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React80.createElement(
6059
+ shouldHide ? null : /* @__PURE__ */ React80.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, categorizationEnabled(mode) ? /* @__PURE__ */ React80.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React80.createElement(
6055
6060
  Toggle,
6056
6061
  {
6057
6062
  name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
@@ -6071,7 +6076,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6071
6076
  selected: purpose,
6072
6077
  onChange: onChangePurpose
6073
6078
  }
6074
- )), /* @__PURE__ */ React80.createElement(
6079
+ )) : /* @__PURE__ */ React80.createElement(React80.Fragment, null), /* @__PURE__ */ React80.createElement(
6075
6080
  "div",
6076
6081
  {
6077
6082
  className: `${className}__content`,
@@ -6092,6 +6097,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6092
6097
  classNamePrefix: className,
6093
6098
  bankTransaction,
6094
6099
  selectedMatchId,
6100
+ readOnly: !categorizationEnabled(mode),
6095
6101
  setSelectedMatchId: (id) => {
6096
6102
  setMatchFormError(void 0);
6097
6103
  setSelectedMatchId(id);
@@ -6119,7 +6125,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6119
6125
  {
6120
6126
  type: "text",
6121
6127
  name: `split-${index}${asListItem ? "-li" : ""}`,
6122
- disabled: index === 0,
6128
+ disabled: index === 0 || !categorizationEnabled(mode),
6123
6129
  onChange: updateAmounts(index),
6124
6130
  value: split.inputValue,
6125
6131
  onBlur,
@@ -6141,7 +6147,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6141
6147
  value: split.category,
6142
6148
  onChange: (value) => changeCategory(index, value),
6143
6149
  className: "Layer__category-menu--full",
6144
- disabled: bankTransaction.processing,
6150
+ disabled: bankTransaction.processing || !categorizationEnabled(mode),
6145
6151
  excludeMatches: true
6146
6152
  }
6147
6153
  ),
@@ -6169,7 +6175,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6169
6175
  )
6170
6176
  )}`
6171
6177
  }
6172
- ), /* @__PURE__ */ React80.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ React80.createElement(
6178
+ ), categorizationEnabled(mode) ? /* @__PURE__ */ React80.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ React80.createElement(
6173
6179
  TextButton,
6174
6180
  {
6175
6181
  onClick: addSplit,
@@ -6185,7 +6191,7 @@ var ExpandedBankTransactionRow = forwardRef5(
6185
6191
  disabled: rowState.splits.length > 5
6186
6192
  },
6187
6193
  "Split"
6188
- ))))
6194
+ )) : /* @__PURE__ */ React80.createElement(React80.Fragment, null)))
6189
6195
  )),
6190
6196
  showDescriptions && /* @__PURE__ */ React80.createElement(
6191
6197
  InputGroup,
@@ -6305,6 +6311,7 @@ var BankTransactionRow = ({
6305
6311
  editable,
6306
6312
  dateFormat,
6307
6313
  bankTransaction,
6314
+ mode,
6308
6315
  removeTransaction,
6309
6316
  containerWidth,
6310
6317
  initialLoad,
@@ -6524,7 +6531,7 @@ var BankTransactionRow = ({
6524
6531
  /* @__PURE__ */ React82.createElement("span", null, "Unsaved"),
6525
6532
  /* @__PURE__ */ React82.createElement(AlertCircle_default, { size: 12 })
6526
6533
  ) : null,
6527
- !categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ React82.createElement(
6534
+ !categorized && (open || !open && !showRetry) || categorizationEnabled(mode) && categorized && open ? /* @__PURE__ */ React82.createElement(
6528
6535
  SubmitButton,
6529
6536
  {
6530
6537
  onClick: () => {
@@ -6561,6 +6568,7 @@ var BankTransactionRow = ({
6561
6568
  bankTransaction,
6562
6569
  categorized,
6563
6570
  isOpen: open,
6571
+ mode,
6564
6572
  close: () => setOpen(false),
6565
6573
  containerWidth,
6566
6574
  showDescriptions,
@@ -6615,6 +6623,7 @@ var BankTransactionListItem = ({
6615
6623
  dateFormat,
6616
6624
  bankTransaction,
6617
6625
  editable,
6626
+ mode,
6618
6627
  showDescriptions,
6619
6628
  showReceiptUploads,
6620
6629
  hardRefreshPnlOnCategorize,
@@ -6710,6 +6719,7 @@ var BankTransactionListItem = ({
6710
6719
  ref: expandedRowRef,
6711
6720
  bankTransaction,
6712
6721
  isOpen: open,
6722
+ mode,
6713
6723
  close: () => setOpen(false),
6714
6724
  categorized,
6715
6725
  asListItem: true,
@@ -6765,6 +6775,7 @@ var BankTransactionList = ({
6765
6775
  bankTransactions,
6766
6776
  editable,
6767
6777
  removeTransaction,
6778
+ mode,
6768
6779
  containerWidth,
6769
6780
  showDescriptions = false,
6770
6781
  showReceiptUploads = false,
@@ -6779,6 +6790,7 @@ var BankTransactionList = ({
6779
6790
  key: bankTransaction.id,
6780
6791
  dateFormat: DATE_FORMAT,
6781
6792
  bankTransaction,
6793
+ mode,
6782
6794
  editable,
6783
6795
  removeTransaction,
6784
6796
  containerWidth,
@@ -7287,6 +7299,7 @@ var BankTransactionMobileListItem = ({
7287
7299
  bankTransaction,
7288
7300
  removeTransaction,
7289
7301
  editable,
7302
+ mode,
7290
7303
  initialLoad,
7291
7304
  hardRefreshPnlOnCategorize = false
7292
7305
  }) => {
@@ -7377,31 +7390,29 @@ var BankTransactionMobileListItem = ({
7377
7390
  open ? openClassName : "",
7378
7391
  showComponent ? "show" : ""
7379
7392
  );
7380
- return /* @__PURE__ */ React92.createElement(
7381
- "li",
7393
+ return /* @__PURE__ */ React92.createElement("li", { ref: itemRef, className: rowClassName, "data-item": bankTransaction.id }, /* @__PURE__ */ React92.createElement(
7394
+ "span",
7382
7395
  {
7383
- ref: itemRef,
7384
- className: rowClassName,
7385
- "data-item": bankTransaction.id
7396
+ className: `${className}__heading`,
7397
+ onClick: toggleOpen,
7398
+ role: "button",
7399
+ style: { height: headingHeight }
7386
7400
  },
7387
- /* @__PURE__ */ React92.createElement(
7401
+ /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__content`, ref: headingRowRef }, /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__heading__tx-name` }, bankTransaction.counterparty_name ?? bankTransaction.description), /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__heading__account-name` }, categorized && bankTransaction.categorization_status ? getAssignedValue2(bankTransaction) : null, !categorized && bankTransaction.account_name), categorized && open && /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__categorized-name` }, bankTransaction.account_name)), /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__amount` }, /* @__PURE__ */ React92.createElement(
7388
7402
  "span",
7389
7403
  {
7390
- className: `${className}__heading`,
7391
- onClick: toggleOpen,
7392
- role: "button",
7393
- style: { height: headingHeight }
7404
+ className: `${className}__amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
7394
7405
  },
7395
- /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__content`, ref: headingRowRef }, /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__heading__tx-name` }, bankTransaction.counterparty_name ?? bankTransaction.description), /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__heading__account-name` }, categorized && bankTransaction.categorization_status ? getAssignedValue2(bankTransaction) : null, !categorized && bankTransaction.account_name), categorized && open && /* @__PURE__ */ React92.createElement(Text, { as: "span", className: `${className}__categorized-name` }, bankTransaction.account_name)), /* @__PURE__ */ React92.createElement("div", { className: `${className}__heading__amount` }, /* @__PURE__ */ React92.createElement(
7396
- "span",
7397
- {
7398
- className: `${className}__amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
7399
- },
7400
- isCredit(bankTransaction) ? "+$" : " $",
7401
- centsToDollars(bankTransaction.amount)
7402
- ), /* @__PURE__ */ React92.createElement("span", { className: `${className}__heading__date` }, formatTime8(parseISO10(bankTransaction.date), DATE_FORMAT2))))
7403
- ),
7404
- /* @__PURE__ */ React92.createElement("div", { className: `${className}__expanded-row`, style: { height: !open || removeAnim ? 0 : height } }, open && /* @__PURE__ */ React92.createElement(
7406
+ isCredit(bankTransaction) ? "+$" : " $",
7407
+ centsToDollars(bankTransaction.amount)
7408
+ ), /* @__PURE__ */ React92.createElement("span", { className: `${className}__heading__date` }, formatTime8(parseISO10(bankTransaction.date), DATE_FORMAT2))))
7409
+ ), categorizationEnabled(mode) ? /* @__PURE__ */ React92.createElement(
7410
+ "div",
7411
+ {
7412
+ className: `${className}__expanded-row`,
7413
+ style: { height: !open || removeAnim ? 0 : height }
7414
+ },
7415
+ open && /* @__PURE__ */ React92.createElement(
7405
7416
  "div",
7406
7417
  {
7407
7418
  className: `${className}__expanded-row__content`,
@@ -7416,17 +7427,20 @@ var BankTransactionMobileListItem = ({
7416
7427
  {
7417
7428
  value: "business",
7418
7429
  label: "Business",
7419
- style: { minWidth: 84 }
7430
+ style: { minWidth: 84 },
7431
+ disabled: categorizationEnabled(mode)
7420
7432
  },
7421
7433
  {
7422
7434
  value: "personal",
7423
7435
  label: "Personal",
7424
- style: { minWidth: 84 }
7436
+ style: { minWidth: 84 },
7437
+ disabled: categorizationEnabled(mode)
7425
7438
  },
7426
7439
  {
7427
7440
  value: "more",
7428
7441
  label: "More",
7429
- style: { minWidth: 84 }
7442
+ style: { minWidth: 84 },
7443
+ disabled: categorizationEnabled(mode)
7430
7444
  }
7431
7445
  ],
7432
7446
  selected: purpose,
@@ -7441,8 +7455,8 @@ var BankTransactionMobileListItem = ({
7441
7455
  hardRefreshPnlOnCategorize
7442
7456
  }
7443
7457
  )
7444
- ))
7445
- );
7458
+ )
7459
+ ) : /* @__PURE__ */ React92.createElement(React92.Fragment, null));
7446
7460
  };
7447
7461
 
7448
7462
  // src/components/BankTransactionMobileList/BankTransactionMobileList.tsx
@@ -7451,6 +7465,7 @@ var BankTransactionMobileList = ({
7451
7465
  removeTransaction,
7452
7466
  editable,
7453
7467
  initialLoad,
7468
+ mode,
7454
7469
  hardRefreshPnlOnCategorize
7455
7470
  }) => {
7456
7471
  const transactionToOpenContextData = useTransactionToOpen();
@@ -7459,6 +7474,7 @@ var BankTransactionMobileList = ({
7459
7474
  BankTransactionMobileListItem,
7460
7475
  {
7461
7476
  index,
7477
+ mode,
7462
7478
  key: bankTransaction.id,
7463
7479
  bankTransaction,
7464
7480
  editable,
@@ -7598,6 +7614,7 @@ var BankTransactionsTable = ({
7598
7614
  editable,
7599
7615
  isLoading,
7600
7616
  bankTransactions,
7617
+ mode,
7601
7618
  initialLoad,
7602
7619
  containerWidth,
7603
7620
  removeTransaction,
@@ -7626,6 +7643,7 @@ var BankTransactionsTable = ({
7626
7643
  initialLoad,
7627
7644
  index,
7628
7645
  editable,
7646
+ mode,
7629
7647
  key: bankTransaction.id,
7630
7648
  dateFormat: DATE_FORMAT,
7631
7649
  bankTransaction,
@@ -7928,7 +7946,6 @@ var isDateAllowedToBrowse = (date, business) => {
7928
7946
  // src/components/DatePicker/DatePicker.tsx
7929
7947
  import React105, { useEffect as useEffect19, useRef as useRef13, useState as useState24 } from "react";
7930
7948
  import ReactDatePicker from "react-datepicker";
7931
- import "react-datepicker/dist/react-datepicker.css";
7932
7949
 
7933
7950
  // src/components/DatePicker/DatePickerOptions.tsx
7934
7951
  import React104 from "react";
@@ -8522,12 +8539,12 @@ var BankTransactionsHeader = ({
8522
8539
  minDate: getEarliestDateToBrowse(business)
8523
8540
  }
8524
8541
  ) : null),
8525
- /* @__PURE__ */ React108.createElement("div", { className: "Layer__header__actions-wrapper" }, !categorizedOnly && !(mobileComponent == "mobileList" && listView) && categorizeView && /* @__PURE__ */ React108.createElement("div", { className: "Layer__header__actions" }, /* @__PURE__ */ React108.createElement(
8542
+ /* @__PURE__ */ React108.createElement("div", { className: "Layer__header__actions-wrapper" }, /* @__PURE__ */ React108.createElement("div", { className: "Layer__header__actions" }, /* @__PURE__ */ React108.createElement(
8526
8543
  DownloadButton,
8527
8544
  {
8528
8545
  downloadButtonTextOverride: stringOverrides?.downloadButton
8529
8546
  }
8530
- ), /* @__PURE__ */ React108.createElement(
8547
+ ), !categorizedOnly && !(mobileComponent == "mobileList" && listView) && categorizeView && /* @__PURE__ */ React108.createElement(
8531
8548
  Toggle,
8532
8549
  {
8533
8550
  name: "bank-transaction-display",
@@ -8628,6 +8645,12 @@ import { endOfMonth as endOfMonth3, parseISO as parseISO12, startOfMonth as star
8628
8645
  var COMPONENT_NAME2 = "bank-transactions";
8629
8646
  var TEST_EMPTY_STATE = false;
8630
8647
  var POLL_INTERVAL = 1e4;
8648
+ var categorizationEnabled = (mode) => {
8649
+ if (mode === "bookkeeping-client") {
8650
+ return false;
8651
+ }
8652
+ return true;
8653
+ };
8631
8654
  var BankTransactions = ({
8632
8655
  onError,
8633
8656
  ...props
@@ -8637,8 +8660,7 @@ var BankTransactions = ({
8637
8660
  var BankTransactionsContent = ({
8638
8661
  asWidget = false,
8639
8662
  pageSize = 20,
8640
- categorizedOnly = false,
8641
- categorizeView = true,
8663
+ mode = "self-serve",
8642
8664
  showDescriptions = false,
8643
8665
  showReceiptUploads = false,
8644
8666
  hardRefreshPnlOnCategorize = false,
@@ -8654,6 +8676,7 @@ var BankTransactionsContent = ({
8654
8676
  startDate: startOfMonth5(/* @__PURE__ */ new Date()),
8655
8677
  endDate: endOfMonth3(/* @__PURE__ */ new Date())
8656
8678
  });
8679
+ const categorizeView = categorizationEnabled(mode);
8657
8680
  const {
8658
8681
  activate,
8659
8682
  data,
@@ -8713,7 +8736,7 @@ var BankTransactionsContent = ({
8713
8736
  ...inputFilters,
8714
8737
  categorizationStatus: "review" /* review */
8715
8738
  });
8716
- } else if (!filters?.categorizationStatus && categorizedOnly) {
8739
+ } else if (!filters?.categorizationStatus && !categorizationEnabled(mode)) {
8717
8740
  setFilters({
8718
8741
  ...filters,
8719
8742
  ...inputFilters,
@@ -8726,12 +8749,12 @@ var BankTransactionsContent = ({
8726
8749
  setFilters({
8727
8750
  categorizationStatus: "review" /* review */
8728
8751
  });
8729
- } else if (!filters?.categorizationStatus && categorizedOnly) {
8752
+ } else if (!filters?.categorizationStatus && !categorizationEnabled(mode)) {
8730
8753
  setFilters({
8731
8754
  categorizationStatus: "categorized" /* categorized */
8732
8755
  });
8733
8756
  }
8734
- }, [inputFilters, categorizeView, categorizedOnly]);
8757
+ }, [inputFilters, categorizeView, mode]);
8735
8758
  useEffect21(() => {
8736
8759
  if (loadingStatus === "complete") {
8737
8760
  const timeoutLoad = setTimeout(() => {
@@ -8794,7 +8817,7 @@ var BankTransactionsContent = ({
8794
8817
  {
8795
8818
  shiftStickyHeader,
8796
8819
  asWidget,
8797
- categorizedOnly,
8820
+ categorizedOnly: !categorizationEnabled(mode),
8798
8821
  categorizeView,
8799
8822
  display,
8800
8823
  onCategorizationDisplayChange,
@@ -8816,6 +8839,7 @@ var BankTransactionsContent = ({
8816
8839
  isLoading,
8817
8840
  isSyncing,
8818
8841
  bankTransactions,
8842
+ mode,
8819
8843
  initialLoad,
8820
8844
  containerWidth,
8821
8845
  removeTransaction,
@@ -8831,6 +8855,7 @@ var BankTransactionsContent = ({
8831
8855
  !isLoading && listView && mobileComponent !== "mobileList" ? /* @__PURE__ */ React111.createElement(
8832
8856
  BankTransactionList,
8833
8857
  {
8858
+ mode,
8834
8859
  bankTransactions,
8835
8860
  editable,
8836
8861
  removeTransaction,
@@ -8844,6 +8869,7 @@ var BankTransactionsContent = ({
8844
8869
  {
8845
8870
  bankTransactions,
8846
8871
  editable,
8872
+ mode,
8847
8873
  removeTransaction,
8848
8874
  initialLoad,
8849
8875
  hardRefreshPnlOnCategorize
@@ -9466,9 +9492,9 @@ var ProfitAndLossChart = ({
9466
9492
  name: getMonthName(pnl),
9467
9493
  revenue: pnl?.income || 0,
9468
9494
  revenueUncategorized: pnl?.uncategorizedInflows || 0,
9469
- expenses: -(pnl?.operatingExpenses || 0),
9495
+ expenses: -(pnl?.totalExpenses || 0),
9470
9496
  expensesUncategorized: -(pnl?.uncategorizedOutflows || 0),
9471
- operatingExpensesInverse: pnl?.operatingExpensesInverse || 0,
9497
+ totalExpensesInverse: pnl?.totalExpensesInverse || 0,
9472
9498
  uncategorizedOutflowsInverse: pnl?.uncategorizedOutflowsInverse || 0,
9473
9499
  netProfit: pnl?.netProfit || 0,
9474
9500
  selected: !!pnl && pnl.month === selectionMonth.month + 1 && pnl.year === selectionMonth.year,
@@ -9488,7 +9514,7 @@ var ProfitAndLossChart = ({
9488
9514
  name: format(currentDate, compactView ? "LLLLL" : "LLL"),
9489
9515
  revenue: 0,
9490
9516
  revenueUncategorized: 0,
9491
- operatingExpensesInverse: 0,
9517
+ totalExpensesInverse: 0,
9492
9518
  uncategorizedOutflowsInverse: 0,
9493
9519
  expenses: 0,
9494
9520
  expensesUncategorized: 0,
@@ -9508,9 +9534,9 @@ var ProfitAndLossChart = ({
9508
9534
  if (totalExpenses < 0 || x.uncategorizedOutflows < 0) {
9509
9535
  return {
9510
9536
  ...x,
9511
- operatingExpenses: totalExpenses < 0 ? 0 : totalExpenses,
9537
+ totalExpenses: totalExpenses < 0 ? 0 : totalExpenses,
9512
9538
  uncategorizedOutflows: x.uncategorizedOutflows < 0 ? 0 : x.uncategorizedOutflows,
9513
- operatingExpensesInverse: totalExpenses < 0 ? -totalExpenses : 0,
9539
+ totalExpensesInverse: totalExpenses < 0 ? -totalExpenses : 0,
9514
9540
  uncategorizedOutflowsInverse: x.uncategorizedOutflows < 0 ? -x.uncategorizedOutflows : 0
9515
9541
  };
9516
9542
  }
@@ -9806,7 +9832,7 @@ var ProfitAndLossChart = ({
9806
9832
  /* @__PURE__ */ React114.createElement(
9807
9833
  Bar,
9808
9834
  {
9809
- dataKey: "operatingExpensesInverse",
9835
+ dataKey: "totalExpensesInverse",
9810
9836
  barSize,
9811
9837
  isAnimationActive: barAnimActive,
9812
9838
  animationDuration: 100,
@@ -10919,17 +10945,18 @@ var ProfitAndLossRow = ({
10919
10945
  variant,
10920
10946
  lineItem,
10921
10947
  depth = 0,
10922
- maxDepth = 1,
10948
+ maxDepth = 8,
10923
10949
  direction = "DEBIT" /* DEBIT */,
10924
10950
  lockExpanded = false,
10925
10951
  scope,
10926
- setSidebarScope
10952
+ setSidebarScope,
10953
+ defaultExpanded = false
10927
10954
  }) => {
10928
10955
  if (!lineItem) {
10929
10956
  return null;
10930
10957
  }
10931
10958
  const { value, display_name, line_items } = lineItem;
10932
- const [expanded, setExpanded] = useState34(true);
10959
+ const [expanded, setExpanded] = useState34(lockExpanded || defaultExpanded);
10933
10960
  const amount = value ?? 0;
10934
10961
  const amountString = centsToDollars(Math.abs(amount));
10935
10962
  const labelClasses = [
@@ -10964,7 +10991,10 @@ var ProfitAndLossRow = ({
10964
10991
  "div",
10965
10992
  {
10966
10993
  className: labelClasses.join(" "),
10967
- onClick: () => !lockExpanded && toggleExpanded()
10994
+ onClick: () => !lockExpanded && toggleExpanded(),
10995
+ style: {
10996
+ paddingLeft: depth === 0 && !hasChildren ? 28 : 16 * (depth + 1) + 2
10997
+ }
10968
10998
  },
10969
10999
  /* @__PURE__ */ React125.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ React125.createElement(
10970
11000
  ChevronDownFill_default,
@@ -11052,7 +11082,11 @@ var empty_profit_and_loss_report_default = {
11052
11082
 
11053
11083
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
11054
11084
  import classNames45 from "classnames";
11055
- var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11085
+ var ProfitAndLossTable = ({
11086
+ lockExpanded,
11087
+ asContainer,
11088
+ stringOverrides
11089
+ }) => {
11056
11090
  const {
11057
11091
  data: actualData,
11058
11092
  isLoading,
@@ -11087,7 +11121,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11087
11121
  direction: "CREDIT" /* CREDIT */,
11088
11122
  lockExpanded,
11089
11123
  scope: "revenue",
11090
- setSidebarScope
11124
+ setSidebarScope,
11125
+ defaultExpanded: true
11091
11126
  }
11092
11127
  ),
11093
11128
  /* @__PURE__ */ React126.createElement(
@@ -11097,7 +11132,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11097
11132
  direction: "DEBIT" /* DEBIT */,
11098
11133
  lockExpanded,
11099
11134
  scope: "expenses",
11100
- setSidebarScope
11135
+ setSidebarScope,
11136
+ defaultExpanded: true
11101
11137
  }
11102
11138
  ),
11103
11139
  /* @__PURE__ */ React126.createElement(
@@ -11111,7 +11147,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11111
11147
  direction: "CREDIT" /* CREDIT */,
11112
11148
  lockExpanded,
11113
11149
  scope: "revenue",
11114
- setSidebarScope
11150
+ setSidebarScope,
11151
+ defaultExpanded: true
11115
11152
  }
11116
11153
  ),
11117
11154
  /* @__PURE__ */ React126.createElement(
@@ -11121,7 +11158,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11121
11158
  direction: "DEBIT" /* DEBIT */,
11122
11159
  lockExpanded,
11123
11160
  scope: "expenses",
11124
- setSidebarScope
11161
+ setSidebarScope,
11162
+ defaultExpanded: true
11125
11163
  }
11126
11164
  ),
11127
11165
  /* @__PURE__ */ React126.createElement(
@@ -11135,7 +11173,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11135
11173
  direction: "CREDIT" /* CREDIT */,
11136
11174
  lockExpanded,
11137
11175
  scope: "revenue",
11138
- setSidebarScope
11176
+ setSidebarScope,
11177
+ defaultExpanded: true
11139
11178
  }
11140
11179
  ),
11141
11180
  /* @__PURE__ */ React126.createElement(
@@ -11145,7 +11184,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer, stringOverrides }) => {
11145
11184
  direction: "DEBIT" /* DEBIT */,
11146
11185
  lockExpanded,
11147
11186
  scope: "expenses",
11148
- setSidebarScope
11187
+ setSidebarScope,
11188
+ defaultExpanded: true
11149
11189
  }
11150
11190
  ),
11151
11191
  /* @__PURE__ */ React126.createElement(
@@ -15435,7 +15475,7 @@ var BankTransactionsWithLinkedAccounts = ({
15435
15475
  showLedgerBalance = true,
15436
15476
  showUnlinkItem = false,
15437
15477
  showBreakConnection = false,
15438
- categorizedOnly = false,
15478
+ mode = "self-serve",
15439
15479
  hardRefreshPnlOnCategorize = false,
15440
15480
  showDescriptions,
15441
15481
  showReceiptUploads,
@@ -15458,7 +15498,7 @@ var BankTransactionsWithLinkedAccounts = ({
15458
15498
  showDescriptions,
15459
15499
  showReceiptUploads,
15460
15500
  mobileComponent,
15461
- categorizedOnly,
15501
+ mode,
15462
15502
  hardRefreshPnlOnCategorize,
15463
15503
  stringOverrides: stringOverrides?.bankTransactions
15464
15504
  }
@@ -15502,7 +15542,9 @@ var GeneralLedgerView = ({
15502
15542
 
15503
15543
  // src/views/Reports/Reports.tsx
15504
15544
  import React182, { useContext as useContext38, useRef as useRef16, useState as useState58 } from "react";
15505
- var DownloadButton2 = ({ stringOverrides }) => {
15545
+ var DownloadButton2 = ({
15546
+ stringOverrides
15547
+ }) => {
15506
15548
  const { dateRange } = useContext38(ProfitAndLoss.Context);
15507
15549
  const { auth, businessId, apiUrl } = useLayerContext();
15508
15550
  const [requestFailed, setRequestFailed] = useState58(false);
@@ -15550,33 +15592,64 @@ var DownloadButton2 = ({ stringOverrides }) => {
15550
15592
  stringOverrides?.downloadButtonText || "Download"
15551
15593
  );
15552
15594
  };
15553
- var Reports = ({ title, stringOverrides }) => {
15595
+ var getOptions = (enabledReports) => {
15596
+ return [
15597
+ enabledReports.includes("profitAndLoss") ? {
15598
+ value: "profitAndLoss",
15599
+ label: "Profit & Loss"
15600
+ } : null,
15601
+ enabledReports.includes("balanceSheet") ? {
15602
+ value: "balanceSheet",
15603
+ label: "Balance Sheet"
15604
+ } : null,
15605
+ enabledReports.includes("statementOfCashFlow") ? {
15606
+ value: "statementOfCashFlow",
15607
+ label: "Statement of Cash Flow"
15608
+ } : null
15609
+ ].filter((o) => !!o);
15610
+ };
15611
+ var Reports = ({
15612
+ title,
15613
+ stringOverrides,
15614
+ enabledReports = ["profitAndLoss", "balanceSheet", "statementOfCashFlow"]
15615
+ }) => {
15554
15616
  const containerRef = useRef16(null);
15555
- const [activeTab, setActiveTab] = useState58("profitAndLoss");
15556
- return /* @__PURE__ */ React182.createElement(View, { title: stringOverrides?.title || title || "Reports" }, /* @__PURE__ */ React182.createElement("div", { className: "Layer__component Layer__header__actions" }, /* @__PURE__ */ React182.createElement(
15617
+ const [activeTab, setActiveTab] = useState58(enabledReports[0]);
15618
+ const options = getOptions(enabledReports);
15619
+ const defaultTitle = enabledReports.length > 1 ? "Reports" : options.find((option) => option.value = enabledReports[0])?.label;
15620
+ return /* @__PURE__ */ React182.createElement(View, { title: stringOverrides?.title || title || defaultTitle }, enabledReports.length > 1 && /* @__PURE__ */ React182.createElement("div", { className: "Layer__component Layer__header__actions" }, /* @__PURE__ */ React182.createElement(
15557
15621
  Toggle,
15558
15622
  {
15559
15623
  name: "reports-tabs",
15560
- options: [
15561
- { value: "profitAndLoss", label: "Profit & loss" },
15562
- { value: "balanceSheet", label: "Balance sheet" },
15563
- {
15564
- value: "statementOfCashFlow",
15565
- label: "Statement of Cash Flow"
15566
- }
15567
- ],
15624
+ options,
15568
15625
  selected: activeTab,
15569
15626
  onChange: (opt) => setActiveTab(opt.target.value)
15570
15627
  }
15571
- )), /* @__PURE__ */ React182.createElement(Container, { name: "reports", ref: containerRef }, /* @__PURE__ */ React182.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React182.createElement(ReportsPanel, { containerRef, openReport: activeTab, stringOverrides }))));
15628
+ )), /* @__PURE__ */ React182.createElement(Container, { name: "reports", ref: containerRef }, /* @__PURE__ */ React182.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React182.createElement(
15629
+ ReportsPanel,
15630
+ {
15631
+ containerRef,
15632
+ openReport: activeTab,
15633
+ stringOverrides
15634
+ }
15635
+ ))));
15572
15636
  };
15573
- var ReportsPanel = ({ containerRef, openReport, stringOverrides }) => {
15637
+ var ReportsPanel = ({
15638
+ containerRef,
15639
+ openReport,
15640
+ stringOverrides
15641
+ }) => {
15574
15642
  const { sidebarScope } = useContext38(ProfitAndLoss.Context);
15575
15643
  return /* @__PURE__ */ React182.createElement(React182.Fragment, null, openReport === "profitAndLoss" && /* @__PURE__ */ React182.createElement(
15576
15644
  View,
15577
15645
  {
15578
15646
  type: "panel",
15579
- headerControls: /* @__PURE__ */ React182.createElement(React182.Fragment, null, /* @__PURE__ */ React182.createElement(ProfitAndLoss.DatePicker, null), /* @__PURE__ */ React182.createElement(DownloadButton2, { stringOverrides: stringOverrides?.downloadButton }))
15647
+ headerControls: /* @__PURE__ */ React182.createElement(React182.Fragment, null, /* @__PURE__ */ React182.createElement(ProfitAndLoss.DatePicker, null), /* @__PURE__ */ React182.createElement(
15648
+ DownloadButton2,
15649
+ {
15650
+ stringOverrides: stringOverrides?.downloadButton
15651
+ }
15652
+ ))
15580
15653
  },
15581
15654
  /* @__PURE__ */ React182.createElement(
15582
15655
  Panel,
@@ -15599,7 +15672,12 @@ var ReportsPanel = ({ containerRef, openReport, stringOverrides }) => {
15599
15672
  }
15600
15673
  )
15601
15674
  )
15602
- ), openReport === "balanceSheet" && /* @__PURE__ */ React182.createElement(BalanceSheet, { stringOverrides: stringOverrides?.balanceSheet }), openReport === "statementOfCashFlow" && /* @__PURE__ */ React182.createElement(StatementOfCashFlow, { stringOverrides: stringOverrides?.statementOfCashflow }));
15675
+ ), openReport === "balanceSheet" && /* @__PURE__ */ React182.createElement(BalanceSheet, { stringOverrides: stringOverrides?.balanceSheet }), openReport === "statementOfCashFlow" && /* @__PURE__ */ React182.createElement(
15676
+ StatementOfCashFlow,
15677
+ {
15678
+ stringOverrides: stringOverrides?.statementOfCashflow
15679
+ }
15680
+ ));
15603
15681
  };
15604
15682
 
15605
15683
  // src/components/ProfitAndLossView/ProfitAndLossView.tsx