@layerfi/components 0.1.11 → 0.1.13

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/dist/esm/index.js CHANGED
@@ -266,6 +266,9 @@ var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/catego
266
266
  var getChartOfAccounts = get(
267
267
  ({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
268
268
  );
269
+ var getLedgerAccountBalances = get(
270
+ ({ businessId }) => `/v1/businesses/${businessId}/ledger/balances`
271
+ );
269
272
  var createAccount = post(
270
273
  ({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
271
274
  );
@@ -308,6 +311,7 @@ var Layer = {
308
311
  getBankTransactions,
309
312
  getCategories,
310
313
  getChartOfAccounts,
314
+ getLedgerAccountBalances,
311
315
  getLedgerAccountsLines,
312
316
  getLedgerAccountsEntry,
313
317
  getProfitAndLoss,
@@ -776,7 +780,6 @@ var debounce = (fnc, timeout = 300) => {
776
780
  }, timeout);
777
781
  };
778
782
  };
779
- var convertToStableName = (name) => name.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "").replace(/\W+/g, " ").split(/ |\B(?=[A-Z])/).map((word) => word.toLowerCase()).join("_");
780
783
 
781
784
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
782
785
  import React48, { useEffect as useEffect6, useRef as useRef11, useState as useState9 } from "react";
@@ -2206,6 +2209,7 @@ import React37 from "react";
2206
2209
  import ReactSelect, {
2207
2210
  components as components2
2208
2211
  } from "react-select";
2212
+ import classNames14 from "classnames";
2209
2213
  var DropdownIndicator2 = (props) => {
2210
2214
  return /* @__PURE__ */ React37.createElement(components2.DropdownIndicator, { ...props }, /* @__PURE__ */ React37.createElement(ChevronDownFill_default, null));
2211
2215
  };
@@ -2217,13 +2221,20 @@ var Select2 = ({
2217
2221
  value,
2218
2222
  onChange,
2219
2223
  disabled,
2220
- placeholder
2224
+ placeholder,
2225
+ isInvalid,
2226
+ errorMessage
2221
2227
  }) => {
2222
- return /* @__PURE__ */ React37.createElement(
2228
+ const baseClassName = classNames14(
2229
+ "Layer__select",
2230
+ isInvalid ? "Layer__select--error" : "",
2231
+ className
2232
+ );
2233
+ return /* @__PURE__ */ React37.createElement(Tooltip, { disabled: !isInvalid || !errorMessage }, /* @__PURE__ */ React37.createElement(TooltipTrigger, { className: "Layer__input-tooltip" }, /* @__PURE__ */ React37.createElement(
2223
2234
  ReactSelect,
2224
2235
  {
2225
2236
  name,
2226
- className: `Layer__select ${className ?? ""}`,
2237
+ className: baseClassName,
2227
2238
  classNamePrefix,
2228
2239
  placeholder: placeholder ?? "Select...",
2229
2240
  options,
@@ -2234,7 +2245,7 @@ var Select2 = ({
2234
2245
  components: { DropdownIndicator: DropdownIndicator2 },
2235
2246
  isDisabled: disabled
2236
2247
  }
2237
- );
2248
+ )), /* @__PURE__ */ React37.createElement(TooltipContent, { className: "Layer__tooltip" }, errorMessage));
2238
2249
  };
2239
2250
 
2240
2251
  // src/components/MatchForm/MatchForm.tsx
@@ -2264,7 +2275,7 @@ var MatchBadge = ({
2264
2275
  };
2265
2276
 
2266
2277
  // src/components/MatchForm/MatchForm.tsx
2267
- import classNames14 from "classnames";
2278
+ import classNames15 from "classnames";
2268
2279
  import { parseISO as parseISO4, format as formatTime3 } from "date-fns";
2269
2280
  var MatchForm = ({
2270
2281
  classNamePrefix,
@@ -2283,7 +2294,7 @@ var MatchForm = ({
2283
2294
  "div",
2284
2295
  {
2285
2296
  key: idx,
2286
- className: classNames14(
2297
+ className: classNames15(
2287
2298
  `${classNamePrefix}__match-row`,
2288
2299
  match.id === selectedMatchId ? `${classNamePrefix}__match-row--selected` : ""
2289
2300
  ),
@@ -2342,12 +2353,12 @@ var MatchForm = ({
2342
2353
 
2343
2354
  // src/components/Textarea/Textarea.tsx
2344
2355
  import React40 from "react";
2345
- import classNames15 from "classnames";
2356
+ import classNames16 from "classnames";
2346
2357
  var Textarea = ({
2347
2358
  className,
2348
2359
  ...props
2349
2360
  }) => {
2350
- const baseClassName = classNames15("Layer__textarea", className);
2361
+ const baseClassName = classNames16("Layer__textarea", className);
2351
2362
  return /* @__PURE__ */ React40.createElement("textarea", { ...props, className: baseClassName });
2352
2363
  };
2353
2364
 
@@ -2356,7 +2367,7 @@ import React41, {
2356
2367
  useEffect as useEffect2,
2357
2368
  useState as useState5
2358
2369
  } from "react";
2359
- import classNames16 from "classnames";
2370
+ import classNames17 from "classnames";
2360
2371
  var Toggle = ({
2361
2372
  name,
2362
2373
  options,
@@ -2373,7 +2384,7 @@ var Toggle = ({
2373
2384
  }
2374
2385
  });
2375
2386
  const selectedValue = selected || options[0].value;
2376
- const baseClassName = classNames16(
2387
+ const baseClassName = classNames17(
2377
2388
  "Layer__toggle",
2378
2389
  `Layer__toggle--${size}`,
2379
2390
  initialized ? "Layer__toggle--initialized" : ""
@@ -2624,7 +2635,7 @@ var Notification = ({
2624
2635
  };
2625
2636
 
2626
2637
  // src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
2627
- import classNames17 from "classnames";
2638
+ import classNames18 from "classnames";
2628
2639
  var hasMatch = (bankTransaction) => {
2629
2640
  return Boolean(
2630
2641
  bankTransaction?.suggested_matches && bankTransaction?.suggested_matches?.length > 0 || bankTransaction?.match
@@ -2877,7 +2888,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2877
2888
  /* @__PURE__ */ React44.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ React44.createElement(
2878
2889
  "div",
2879
2890
  {
2880
- className: classNames17(
2891
+ className: classNames18(
2881
2892
  `${className}__match`,
2882
2893
  `${className}__content-panel`,
2883
2894
  purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
@@ -2899,7 +2910,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2899
2910
  ), /* @__PURE__ */ React44.createElement(
2900
2911
  "div",
2901
2912
  {
2902
- className: classNames17(
2913
+ className: classNames18(
2903
2914
  `${className}__splits`,
2904
2915
  `${className}__content-panel`,
2905
2916
  purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
@@ -3038,7 +3049,7 @@ var SplitTooltipDetails = ({
3038
3049
  };
3039
3050
 
3040
3051
  // src/components/BankTransactionRow/BankTransactionRow.tsx
3041
- import classNames18 from "classnames";
3052
+ import classNames19 from "classnames";
3042
3053
  import { parseISO as parseISO5, format as formatTime4 } from "date-fns";
3043
3054
  var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
3044
3055
  var extractDescriptionForSplit = (category) => {
@@ -3048,7 +3059,15 @@ var extractDescriptionForSplit = (category) => {
3048
3059
  return category.entries.map((c) => c.category.display_name).join(", ");
3049
3060
  };
3050
3061
  var getDefaultSelectedCategory = (bankTransaction) => {
3051
- return hasSuggestions(bankTransaction.categorization_flow) ? mapCategoryToOption(bankTransaction.categorization_flow.suggestions[0]) : bankTransaction.suggested_matches?.length === 1 ? mapSuggestedMatchToOption(bankTransaction.suggested_matches[0]) : void 0;
3062
+ if (bankTransaction.suggested_matches?.[0]) {
3063
+ return mapSuggestedMatchToOption(bankTransaction.suggested_matches?.[0]);
3064
+ }
3065
+ if (hasSuggestions(bankTransaction.categorization_flow)) {
3066
+ return mapCategoryToOption(
3067
+ bankTransaction.categorization_flow.suggestions[0]
3068
+ );
3069
+ }
3070
+ return void 0;
3052
3071
  };
3053
3072
  var clickTimer = Date.now();
3054
3073
  var BankTransactionRow = ({
@@ -3129,7 +3148,7 @@ var BankTransactionRow = ({
3129
3148
  }
3130
3149
  const className = "Layer__bank-transaction-row";
3131
3150
  const openClassName = open ? `${className}--expanded` : "";
3132
- const rowClassName = classNames18(
3151
+ const rowClassName = classNames19(
3133
3152
  className,
3134
3153
  bankTransaction.recently_categorized && editable ? "Layer__bank-transaction-row--removing" : "",
3135
3154
  open ? openClassName : "",
@@ -3203,7 +3222,7 @@ var BankTransactionRow = ({
3203
3222
  /* @__PURE__ */ React46.createElement(
3204
3223
  "td",
3205
3224
  {
3206
- className: classNames18(
3225
+ className: classNames19(
3207
3226
  "Layer__table-cell",
3208
3227
  "Layer__table-cell__category-col",
3209
3228
  `${className}__actions-cell`,
@@ -3358,7 +3377,7 @@ var Assignment = ({ bankTransaction }) => {
3358
3377
  };
3359
3378
 
3360
3379
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
3361
- import classNames19 from "classnames";
3380
+ import classNames20 from "classnames";
3362
3381
  import { parseISO as parseISO7, format as formatTime6 } from "date-fns";
3363
3382
  var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
3364
3383
  var BankTransactionListItem = ({
@@ -3417,7 +3436,7 @@ var BankTransactionListItem = ({
3417
3436
  }
3418
3437
  const className = "Layer__bank-transaction-list-item";
3419
3438
  const openClassName = open ? `${className}--expanded` : "";
3420
- const rowClassName = classNames19(
3439
+ const rowClassName = classNames20(
3421
3440
  className,
3422
3441
  bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
3423
3442
  open ? openClassName : "",
@@ -3724,10 +3743,10 @@ var hslToHex = (hsl) => {
3724
3743
  };
3725
3744
 
3726
3745
  // src/components/Container/Container.tsx
3727
- import classNames20 from "classnames";
3746
+ import classNames21 from "classnames";
3728
3747
  var Container = forwardRef3(
3729
3748
  ({ name, className, children, asWidget, elevated = false }, ref) => {
3730
- const baseClassName = classNames20(
3749
+ const baseClassName = classNames21(
3731
3750
  "Layer__component Layer__component-container",
3732
3751
  `Layer__${name}`,
3733
3752
  elevated && "Layer__component--elevated",
@@ -3742,10 +3761,10 @@ var Container = forwardRef3(
3742
3761
 
3743
3762
  // src/components/Container/Header.tsx
3744
3763
  import React50, { forwardRef as forwardRef4 } from "react";
3745
- import classNames21 from "classnames";
3764
+ import classNames22 from "classnames";
3746
3765
  var Header = forwardRef4(
3747
3766
  ({ className, children, style }, ref) => {
3748
- const baseClassName = classNames21("Layer__component-header", className);
3767
+ const baseClassName = classNames22("Layer__component-header", className);
3749
3768
  return /* @__PURE__ */ React50.createElement("header", { ref, className: baseClassName, style }, children);
3750
3769
  }
3751
3770
  );
@@ -4455,7 +4474,7 @@ var MoreVertical_default = MoreVertical;
4455
4474
 
4456
4475
  // src/components/HoverMenu/HoverMenu.tsx
4457
4476
  import React60, { useEffect as useEffect9, useRef as useRef12, useState as useState12 } from "react";
4458
- import classNames22 from "classnames";
4477
+ import classNames23 from "classnames";
4459
4478
  var HoverMenu = ({
4460
4479
  children,
4461
4480
  config,
@@ -4464,7 +4483,7 @@ var HoverMenu = ({
4464
4483
  }) => {
4465
4484
  const [openMenu, setOpenMenu] = useState12(false);
4466
4485
  const hoverMenuRef = useRef12(null);
4467
- const hoverMenuClassName = classNames22(
4486
+ const hoverMenuClassName = classNames23(
4468
4487
  "Layer__hover-menu",
4469
4488
  openMenu && "Layer__hover-menu--open"
4470
4489
  );
@@ -4827,22 +4846,17 @@ var InstitutionIcon = ({ size = 18, ...props }) => /* @__PURE__ */ React62.creat
4827
4846
  var InstitutionIcon_default = InstitutionIcon;
4828
4847
 
4829
4848
  // src/components/LinkedAccountThumb/LinkedAccountThumb.tsx
4830
- import classNames23 from "classnames";
4831
- var AccountNumber = ({ accountNumber }) => /* @__PURE__ */ React63.createElement("div", { className: "account-number" }, /* @__PURE__ */ React63.createElement(Text, { size: "sm" }, "\u2022\u2022\u2022", accountNumber));
4849
+ import classNames24 from "classnames";
4850
+ var AccountNumber = ({ accountNumber }) => /* @__PURE__ */ React63.createElement("div", { className: "account-number" }, /* @__PURE__ */ React63.createElement(Text, { size: "sm" }, "\u2022\u2022\u2022 ", accountNumber));
4832
4851
  var LinkedAccountThumb = ({
4833
4852
  account,
4834
4853
  asWidget
4835
4854
  }) => {
4836
- const linkedAccountThumbClassName = classNames23(
4855
+ const linkedAccountThumbClassName = classNames24(
4837
4856
  "Layer__linked-account-thumb",
4838
4857
  asWidget && "--as-widget"
4839
4858
  );
4840
- return /* @__PURE__ */ React63.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ React63.createElement("div", { className: "topbar" }, /* @__PURE__ */ React63.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ React63.createElement(Text, { as: "span", className: "account-name" }, account.external_account_name), !asWidget && /* @__PURE__ */ React63.createElement(
4841
- AccountNumber,
4842
- {
4843
- accountNumber: "TODO"
4844
- }
4845
- ), /* @__PURE__ */ React63.createElement(
4859
+ return /* @__PURE__ */ React63.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ React63.createElement("div", { className: "topbar" }, /* @__PURE__ */ React63.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ React63.createElement(Text, { as: "span", className: "account-name" }, account.external_account_name), !asWidget && account.mask && /* @__PURE__ */ React63.createElement(AccountNumber, { accountNumber: account.mask }), /* @__PURE__ */ React63.createElement(
4846
4860
  Text,
4847
4861
  {
4848
4862
  as: "span",
@@ -4850,7 +4864,15 @@ var LinkedAccountThumb = ({
4850
4864
  size: "sm"
4851
4865
  },
4852
4866
  account.institution?.name
4853
- )), /* @__PURE__ */ React63.createElement("div", { className: "topbar-logo" }, !account.institution?.logo && /* @__PURE__ */ React63.createElement(InstitutionIcon_default, null))), !asWidget && /* @__PURE__ */ React63.createElement("div", { className: "middlebar" }, /* @__PURE__ */ React63.createElement(
4867
+ )), /* @__PURE__ */ React63.createElement("div", { className: "topbar-logo" }, account.logo_base64 != void 0 ? /* @__PURE__ */ React63.createElement(
4868
+ "img",
4869
+ {
4870
+ width: 28,
4871
+ height: 28,
4872
+ src: `data:image/png;base64,${account.logo_base64}`,
4873
+ alt: account.institution?.name
4874
+ }
4875
+ ) : /* @__PURE__ */ React63.createElement(InstitutionIcon_default, null))), !asWidget && /* @__PURE__ */ React63.createElement("div", { className: "middlebar" }, /* @__PURE__ */ React63.createElement(
4854
4876
  Text,
4855
4877
  {
4856
4878
  as: "span",
@@ -4870,12 +4892,12 @@ var LinkedAccountThumb = ({
4870
4892
  className: "account-balance-text",
4871
4893
  size: "sm"
4872
4894
  },
4873
- "General ledger balance"
4895
+ "Ledger balance"
4874
4896
  ), /* @__PURE__ */ React63.createElement(Text, { as: "span", className: "account-balance" }, "$", centsToDollars(account.current_ledger_balance))));
4875
4897
  };
4876
4898
 
4877
4899
  // src/components/LinkedAccounts/LinkedAccounts.tsx
4878
- import classNames24 from "classnames";
4900
+ import classNames25 from "classnames";
4879
4901
  var COMPONENT_NAME2 = "linked-accounts";
4880
4902
  var LinkedAccounts = ({ asWidget, elevated }) => {
4881
4903
  const {
@@ -4892,7 +4914,7 @@ var LinkedAccounts = ({ asWidget, elevated }) => {
4892
4914
  { name: "Renew link", action: renewLinkAccount },
4893
4915
  { name: "Unlink", action: unlinkAccount }
4894
4916
  ];
4895
- const linkedAccountsNewAccountClassName = classNames24(
4917
+ const linkedAccountsNewAccountClassName = classNames25(
4896
4918
  "Layer__linked-accounts__new-account",
4897
4919
  asWidget && "--as-widget"
4898
4920
  );
@@ -6069,7 +6091,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElem
6069
6091
  var SortArrows_default = SortArrows;
6070
6092
 
6071
6093
  // src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
6072
- import classNames25 from "classnames";
6094
+ import classNames26 from "classnames";
6073
6095
  var DetailedTable = ({
6074
6096
  filteredData,
6075
6097
  sidebarScope,
@@ -6079,7 +6101,7 @@ var DetailedTable = ({
6079
6101
  setHoveredItem
6080
6102
  }) => {
6081
6103
  const buildColClass = (column) => {
6082
- return classNames25(
6104
+ return classNames26(
6083
6105
  "Layer__sortable-col",
6084
6106
  sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
6085
6107
  );
@@ -6114,7 +6136,7 @@ var DetailedTable = ({
6114
6136
  "tr",
6115
6137
  {
6116
6138
  key: `pl-side-table-item-${idx}`,
6117
- className: classNames25(
6139
+ className: classNames26(
6118
6140
  "Layer__profit-and-loss-detailed-table__row",
6119
6141
  hoveredItem && hoveredItem === item.display_name ? "active" : ""
6120
6142
  ),
@@ -6245,13 +6267,13 @@ import React76, { useContext as useContext5, useMemo as useMemo6 } from "react";
6245
6267
 
6246
6268
  // src/components/SkeletonLoader/SkeletonLoader.tsx
6247
6269
  import React74 from "react";
6248
- import classNames26 from "classnames";
6270
+ import classNames27 from "classnames";
6249
6271
  var SkeletonLoader = ({
6250
6272
  height,
6251
6273
  width,
6252
6274
  className
6253
6275
  }) => {
6254
- const baseClassName = classNames26(
6276
+ const baseClassName = classNames27(
6255
6277
  "Layer__skeleton-loader Layer__anim--skeleton-loading",
6256
6278
  className
6257
6279
  );
@@ -6295,7 +6317,7 @@ var MiniChart = ({ data }) => {
6295
6317
  };
6296
6318
 
6297
6319
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
6298
- import classNames27 from "classnames";
6320
+ import classNames28 from "classnames";
6299
6321
  var CHART_PLACEHOLDER = [
6300
6322
  {
6301
6323
  name: "placeholder",
@@ -6351,7 +6373,7 @@ var ProfitAndLossSummaries = ({
6351
6373
  /* @__PURE__ */ React76.createElement(
6352
6374
  "div",
6353
6375
  {
6354
- className: classNames27(
6376
+ className: classNames28(
6355
6377
  "Layer__profit-and-loss-summaries__summary",
6356
6378
  actionable && "Layer__actionable",
6357
6379
  "Layer__profit-and-loss-summaries__summary--income",
@@ -6373,7 +6395,7 @@ var ProfitAndLossSummaries = ({
6373
6395
  /* @__PURE__ */ React76.createElement(
6374
6396
  "div",
6375
6397
  {
6376
- className: classNames27(
6398
+ className: classNames28(
6377
6399
  "Layer__profit-and-loss-summaries__summary",
6378
6400
  actionable && "Layer__actionable",
6379
6401
  "Layer__profit-and-loss-summaries__summary--expenses",
@@ -6397,7 +6419,7 @@ var ProfitAndLossSummaries = ({
6397
6419
  /* @__PURE__ */ React76.createElement(
6398
6420
  "div",
6399
6421
  {
6400
- className: classNames27(
6422
+ className: classNames28(
6401
6423
  "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
6402
6424
  actionable && "Layer__actionable"
6403
6425
  )
@@ -6588,7 +6610,7 @@ var empty_profit_and_loss_report_default = {
6588
6610
  };
6589
6611
 
6590
6612
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
6591
- import classNames28 from "classnames";
6613
+ import classNames29 from "classnames";
6592
6614
  var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
6593
6615
  const {
6594
6616
  data: actualData,
@@ -6600,7 +6622,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
6600
6622
  return /* @__PURE__ */ React79.createElement(
6601
6623
  "div",
6602
6624
  {
6603
- className: classNames28(
6625
+ className: classNames29(
6604
6626
  "Layer__profit-and-loss-table__loader-container",
6605
6627
  asContainer && "Layer__component-container"
6606
6628
  )
@@ -6611,7 +6633,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
6611
6633
  return /* @__PURE__ */ React79.createElement(React79.Fragment, null, /* @__PURE__ */ React79.createElement(
6612
6634
  "div",
6613
6635
  {
6614
- className: classNames28(
6636
+ className: classNames29(
6615
6637
  "Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
6616
6638
  asContainer && "Layer__component-container"
6617
6639
  )
@@ -6765,7 +6787,7 @@ import React82, { useContext as useContext7, useRef as useRef14 } from "react";
6765
6787
 
6766
6788
  // src/components/Panel/Panel.tsx
6767
6789
  import React81, { useEffect as useEffect12, useState as useState18 } from "react";
6768
- import classNames29 from "classnames";
6790
+ import classNames30 from "classnames";
6769
6791
  var Panel = ({
6770
6792
  children,
6771
6793
  className,
@@ -6783,7 +6805,7 @@ var Panel = ({
6783
6805
  return /* @__PURE__ */ React81.createElement(
6784
6806
  "div",
6785
6807
  {
6786
- className: classNames29(
6808
+ className: classNames30(
6787
6809
  "Layer__panel",
6788
6810
  className,
6789
6811
  sidebarIsOpen && "Layer__panel--open"
@@ -6865,6 +6887,209 @@ import React96, { createContext as createContext3, useContext as useContext14, u
6865
6887
 
6866
6888
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
6867
6889
  import { useState as useState19 } from "react";
6890
+
6891
+ // src/components/ChartOfAccountsForm/constants.ts
6892
+ var LEDGER_ACCOUNT_TYPES = [
6893
+ {
6894
+ value: "ASSET",
6895
+ label: "Assets"
6896
+ },
6897
+ {
6898
+ value: "LIABILITY",
6899
+ label: "Liabilities"
6900
+ },
6901
+ {
6902
+ value: "EQUITY",
6903
+ label: "Equities"
6904
+ },
6905
+ {
6906
+ value: "REVENUE",
6907
+ label: "Revenue"
6908
+ },
6909
+ {
6910
+ value: "EXPENSE",
6911
+ label: "Expenses"
6912
+ }
6913
+ ];
6914
+ var DEFAULT_ACCOUNT_TYPE_DIRECTION = {
6915
+ ASSET: "DEBIT" /* DEBIT */,
6916
+ LIABILITY: "CREDIT" /* CREDIT */,
6917
+ EQUITY: "CREDIT" /* CREDIT */,
6918
+ REVENUE: "CREDIT" /* CREDIT */,
6919
+ EXPENSE: "DEBIT" /* DEBIT */
6920
+ };
6921
+ var NORMALITY_OPTIONS = [
6922
+ {
6923
+ value: "DEBIT" /* DEBIT */,
6924
+ label: "Debit"
6925
+ },
6926
+ {
6927
+ value: "CREDIT" /* CREDIT */,
6928
+ label: "Credit"
6929
+ }
6930
+ ];
6931
+ var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
6932
+ {
6933
+ value: "BANK_ACCOUNTS",
6934
+ label: "Bank Accounts"
6935
+ },
6936
+ {
6937
+ value: "ACCOUNTS_RECEIVABLE",
6938
+ label: "Accounts Receivable"
6939
+ },
6940
+ {
6941
+ value: "INVENTORY",
6942
+ label: "Inventory"
6943
+ },
6944
+ {
6945
+ value: "PAYMENT_PROCESSOR_CLEARING_ACCOUNT",
6946
+ label: "Payment Processor Clearing Accounts"
6947
+ },
6948
+ {
6949
+ value: "FIXED_ASSET",
6950
+ label: "Fixed Assets"
6951
+ },
6952
+ {
6953
+ value: "CASH",
6954
+ label: "Cash"
6955
+ },
6956
+ {
6957
+ value: "UNDEPOSITED_FUNDS",
6958
+ label: "Undeposited Funds"
6959
+ }
6960
+ ];
6961
+ var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
6962
+ {
6963
+ value: "LIABILITY",
6964
+ label: "Liabilities"
6965
+ },
6966
+ {
6967
+ value: "ACCOUNTS_PAYABLE",
6968
+ label: "Accounts Payable"
6969
+ },
6970
+ {
6971
+ value: "CREDIT_CARD",
6972
+ label: "Credit Cards"
6973
+ },
6974
+ {
6975
+ value: "SHAREHOLDER_LOAN",
6976
+ label: "Shareholder Loans"
6977
+ },
6978
+ {
6979
+ value: "PAYROLL_LIABILITY",
6980
+ label: "Payroll Liabilities"
6981
+ },
6982
+ {
6983
+ value: "SALES_TAXES_PAYABLE",
6984
+ label: "Sales Taxes Payable"
6985
+ },
6986
+ {
6987
+ value: "LINE_OF_CREDIT",
6988
+ label: "Lines of Credit"
6989
+ },
6990
+ {
6991
+ value: "NOTES_PAYABLE",
6992
+ label: "Notes Payable"
6993
+ },
6994
+ {
6995
+ value: "TIPS",
6996
+ label: "Tips"
6997
+ },
6998
+ {
6999
+ value: "UNEARNED_REVENUE",
7000
+ label: "Unearned Revenue"
7001
+ },
7002
+ {
7003
+ value: "UNDEPOSITED_OUTFLOWS",
7004
+ label: "Undeposited Outflows"
7005
+ }
7006
+ ];
7007
+ var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
7008
+ {
7009
+ value: "CONTRIBUTIONS",
7010
+ label: "Contributions"
7011
+ },
7012
+ {
7013
+ value: "DISTRIBUTIONS",
7014
+ label: "Distributions"
7015
+ },
7016
+ {
7017
+ value: "COMMON_STOCK",
7018
+ label: "Common Stock"
7019
+ },
7020
+ {
7021
+ value: "ADDITIONAL_PAID_IN_CAPITAL",
7022
+ label: "Additional Paid In Capital"
7023
+ },
7024
+ {
7025
+ value: "RETAINED_EARNINGS",
7026
+ label: "Retained Earnings"
7027
+ },
7028
+ {
7029
+ value: "ACCUMULATED_ADJUSTMENTS",
7030
+ label: "Accumulated Adjustments"
7031
+ },
7032
+ {
7033
+ value: "OPENING_BALANCE_EQUITY",
7034
+ label: "Opening Balance Equity"
7035
+ }
7036
+ ];
7037
+ var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
7038
+ {
7039
+ value: "SALES",
7040
+ label: "Sales"
7041
+ },
7042
+ {
7043
+ value: "UNCATEGORIZED_REVENUE",
7044
+ label: "Uncategorized Revenue"
7045
+ },
7046
+ {
7047
+ value: "RETURNS_ALLOWANCES",
7048
+ label: "Returns & Allowances"
7049
+ }
7050
+ ];
7051
+ var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
7052
+ {
7053
+ value: "COGS",
7054
+ label: "COGS"
7055
+ },
7056
+ {
7057
+ value: "OPERATING_EXPENSES",
7058
+ label: "Operating Expenses"
7059
+ },
7060
+ {
7061
+ value: "PAYROLL",
7062
+ label: "Payroll"
7063
+ },
7064
+ {
7065
+ value: "TAXES_LICENSES",
7066
+ label: "Taxes & Licenses"
7067
+ },
7068
+ {
7069
+ value: "BAD_DEBT",
7070
+ label: "Bad Debt"
7071
+ },
7072
+ {
7073
+ value: "CHARITABLE_CONTRIBUTIONS",
7074
+ label: "Charitable Contributions"
7075
+ }
7076
+ ];
7077
+ var LEDGER_ACCOUNT_SUBTYPES = [
7078
+ ...ASSET_LEDGER_ACCOUNT_SUBTYPES,
7079
+ ...LIABILITY_LEDGER_ACCOUNT_SUBTYPES,
7080
+ ...EQUITY_LEDGER_ACCOUNT_SUBTYPES,
7081
+ ...REVENUE_LEDGER_ACCOUNT_SUBTYPES,
7082
+ ...EXPENSE_LEDGER_ACCOUNT_SUBTYPES
7083
+ ];
7084
+ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
7085
+ ASSET: ASSET_LEDGER_ACCOUNT_SUBTYPES,
7086
+ LIABILITY: LIABILITY_LEDGER_ACCOUNT_SUBTYPES,
7087
+ EQUITY: EQUITY_LEDGER_ACCOUNT_SUBTYPES,
7088
+ REVENUE: REVENUE_LEDGER_ACCOUNT_SUBTYPES,
7089
+ EXPENSE: EXPENSE_LEDGER_ACCOUNT_SUBTYPES
7090
+ };
7091
+
7092
+ // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
6868
7093
  import useSWR6 from "swr";
6869
7094
  var validate = (formData) => {
6870
7095
  const errors = [];
@@ -6872,20 +7097,67 @@ var validate = (formData) => {
6872
7097
  if (nameError) {
6873
7098
  errors.push(nameError);
6874
7099
  }
7100
+ const normalityError = validateNormality(formData);
7101
+ if (normalityError) {
7102
+ errors.push(normalityError);
7103
+ }
7104
+ const typeError = validateType(formData);
7105
+ if (typeError) {
7106
+ errors.push(typeError);
7107
+ }
6875
7108
  return errors;
6876
7109
  };
6877
7110
  var revalidateField = (fieldName, formData) => {
6878
7111
  switch (fieldName) {
6879
- case "name":
7112
+ case "name": {
6880
7113
  const nameError = validateName(formData);
6881
7114
  if (nameError) {
6882
7115
  return (formData?.errors || []).filter((x) => x.field !== fieldName).concat([nameError]);
6883
7116
  }
6884
7117
  return (formData?.errors || []).filter((x) => x.field !== fieldName);
7118
+ }
7119
+ case "normality": {
7120
+ const normalityError = validateNormality(formData);
7121
+ if (normalityError) {
7122
+ return (formData?.errors || []).filter((x) => x.field !== fieldName).concat([normalityError]);
7123
+ }
7124
+ return (formData?.errors || []).filter((x) => x.field !== fieldName);
7125
+ }
7126
+ case "type": {
7127
+ const typeError = validateType(formData);
7128
+ if (typeError) {
7129
+ return (formData?.errors || []).filter((x) => x.field !== fieldName).concat([typeError]);
7130
+ }
7131
+ return (formData?.errors || []).filter((x) => x.field !== fieldName);
7132
+ }
6885
7133
  default:
6886
7134
  return formData?.errors;
6887
7135
  }
6888
7136
  };
7137
+ var validateType = (formData) => {
7138
+ if (!formData?.data.type?.value) {
7139
+ return {
7140
+ field: "type",
7141
+ message: "Must be selected"
7142
+ };
7143
+ }
7144
+ return;
7145
+ };
7146
+ var validateNormality = (formData) => {
7147
+ const stringValueNormality = formData?.data.normality?.value?.toString();
7148
+ if (stringValueNormality === void 0) {
7149
+ return {
7150
+ field: "normality",
7151
+ message: "Must be selected"
7152
+ };
7153
+ } else if (!["DEBIT", "CREDIT"].includes(stringValueNormality)) {
7154
+ return {
7155
+ field: "normality",
7156
+ message: "Must be selected"
7157
+ };
7158
+ }
7159
+ return;
7160
+ };
6889
7161
  var validateName = (formData) => {
6890
7162
  if (!formData?.data.name?.trim()) {
6891
7163
  return {
@@ -6903,7 +7175,7 @@ var useChartOfAccounts = () => {
6903
7175
  const [apiError, setApiError] = useState19(void 0);
6904
7176
  const { data, isLoading, isValidating, error, mutate } = useSWR6(
6905
7177
  businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
6906
- Layer.getChartOfAccounts(apiUrl, auth?.access_token, {
7178
+ Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
6907
7179
  params: { businessId }
6908
7180
  })
6909
7181
  );
@@ -6926,14 +7198,8 @@ var useChartOfAccounts = () => {
6926
7198
  const update = async (accountData, accountId) => {
6927
7199
  setSendingForm(true);
6928
7200
  setApiError(void 0);
6929
- const stable_name = convertToStableName(accountData.name);
6930
7201
  const newAccountData = {
6931
- ...accountData,
6932
- stable_name,
6933
- pnl_category: "INCOME",
6934
- //this field will be deprecated soon, but is still required
6935
- always_show_in_pnl: false
6936
- //this field will be deprecated soon, but is still required
7202
+ ...accountData
6937
7203
  };
6938
7204
  try {
6939
7205
  await Layer.updateAccount(apiUrl, auth?.access_token, {
@@ -6962,12 +7228,14 @@ var useChartOfAccounts = () => {
6962
7228
  }
6963
7229
  const data2 = {
6964
7230
  name: form.data.name ?? "",
6965
- normality: form.data.subType?.value,
7231
+ stable_name: form.data.stable_name,
6966
7232
  parent_id: form.data.parent ? {
6967
7233
  type: "AccountId",
6968
7234
  id: form.data.parent.value
6969
7235
  } : void 0,
6970
- description: form.data.type?.value.toString() ?? ""
7236
+ account_type: form.data.type.value.toString(),
7237
+ account_subtype: form.data.subType?.value.toString(),
7238
+ normality: form.data.normality?.value
6971
7239
  };
6972
7240
  if (form.action === "new") {
6973
7241
  create(data2);
@@ -6984,12 +7252,9 @@ var useChartOfAccounts = () => {
6984
7252
  data: {
6985
7253
  parent: void 0,
6986
7254
  name: void 0,
6987
- type: {
6988
- value: "assets",
6989
- label: "Assets"
6990
- },
6991
- subType: void 0,
6992
- category: void 0
7255
+ type: void 0,
7256
+ normality: void 0,
7257
+ subType: void 0
6993
7258
  }
6994
7259
  });
6995
7260
  const editAccount = (id) => {
@@ -7009,13 +7274,19 @@ var useChartOfAccounts = () => {
7009
7274
  value: parent.id,
7010
7275
  label: parent.name
7011
7276
  } : void 0,
7277
+ stable_name: found.stable_name,
7012
7278
  name: found.name,
7013
7279
  type: {
7014
- value: "assets",
7015
- label: "Assets"
7280
+ value: found.account_type.value,
7281
+ label: found.account_type.display_name
7016
7282
  },
7017
- subType: void 0,
7018
- category: void 0
7283
+ subType: found.account_subtype ? {
7284
+ value: found.account_subtype?.value,
7285
+ label: found.account_subtype?.display_name
7286
+ } : void 0,
7287
+ normality: NORMALITY_OPTIONS.find(
7288
+ (normalityOption) => normalityOption.value == found.normality
7289
+ )
7019
7290
  }
7020
7291
  });
7021
7292
  };
@@ -7024,13 +7295,41 @@ var useChartOfAccounts = () => {
7024
7295
  if (!form) {
7025
7296
  return;
7026
7297
  }
7027
- const newFormData = {
7298
+ let newFormData = {
7028
7299
  ...form,
7029
7300
  data: {
7030
7301
  ...form.data,
7031
7302
  [fieldName]: value
7032
7303
  }
7033
7304
  };
7305
+ if (fieldName === "parent") {
7306
+ const allAccounts = flattenAccounts(data?.data?.accounts || []);
7307
+ const foundParent = allAccounts?.find(
7308
+ (x) => x.id === value.value
7309
+ );
7310
+ if (foundParent) {
7311
+ newFormData = {
7312
+ ...newFormData,
7313
+ data: {
7314
+ ...newFormData.data,
7315
+ /* Inherit the parent's type */
7316
+ type: {
7317
+ value: foundParent.account_type.value,
7318
+ label: foundParent.account_type.display_name
7319
+ },
7320
+ /* If the parent has a subtype, inherit it */
7321
+ subType: foundParent.account_subtype ? {
7322
+ value: foundParent.account_subtype?.value,
7323
+ label: foundParent.account_subtype?.display_name
7324
+ } : void 0,
7325
+ /* Inherit the parent's normality */
7326
+ normality: NORMALITY_OPTIONS.find(
7327
+ (normalityOption) => normalityOption.value == foundParent.normality
7328
+ )
7329
+ }
7330
+ };
7331
+ }
7332
+ }
7034
7333
  const errors = revalidateField(fieldName, newFormData);
7035
7334
  setForm({
7036
7335
  ...newFormData,
@@ -7135,7 +7434,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React83.createElement(
7135
7434
  var Edit2_default = Edit2;
7136
7435
 
7137
7436
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
7138
- import classNames30 from "classnames";
7437
+ import classNames31 from "classnames";
7139
7438
  var INDENTATION = 24;
7140
7439
  var MOBILE_INDENTATION = 12;
7141
7440
  var EXPANDED_STYLE = {
@@ -7184,7 +7483,7 @@ var ChartOfAccountsRow = ({
7184
7483
  }, cumulativeIndex * 50);
7185
7484
  return () => clearTimeout(timeoutId);
7186
7485
  }, []);
7187
- const baseClass = classNames30(
7486
+ const baseClass = classNames31(
7188
7487
  "Layer__table-row",
7189
7488
  isOpen ? "Layer__table-row--expanded" : "Layer__table-row--collapsed",
7190
7489
  !expanded && "Layer__table-row--hidden",
@@ -7192,11 +7491,11 @@ var ChartOfAccountsRow = ({
7192
7491
  form?.accountId === account.id && "Layer__table-row--active",
7193
7492
  !showComponent && "Layer__table-row--anim-starting-state"
7194
7493
  );
7195
- const desktopRowClass = classNames30(
7494
+ const desktopRowClass = classNames31(
7196
7495
  baseClass,
7197
7496
  "Layer__chart-of-accounts__row---desktop"
7198
7497
  );
7199
- const mobileRowClass = classNames30(
7498
+ const mobileRowClass = classNames31(
7200
7499
  baseClass,
7201
7500
  "Layer__chart-of-accounts__row---mobile"
7202
7501
  );
@@ -7237,7 +7536,7 @@ var ChartOfAccountsRow = ({
7237
7536
  className: "Layer__table-cell-content Layer__mobile--hidden",
7238
7537
  style
7239
7538
  },
7240
- account.normality
7539
+ account.account_type?.display_name
7241
7540
  ), /* @__PURE__ */ React84.createElement(
7242
7541
  "span",
7243
7542
  {
@@ -7252,9 +7551,9 @@ var ChartOfAccountsRow = ({
7252
7551
  },
7253
7552
  account.normality
7254
7553
  ),
7255
- /* @__PURE__ */ React84.createElement(Text, { className: "Layer__coa__subtype--mobile" }, "Sub-Type")
7554
+ /* @__PURE__ */ React84.createElement(Text, { className: "Layer__coa__subtype--mobile" }, account.account_subtype?.display_name)
7256
7555
  )),
7257
- /* @__PURE__ */ React84.createElement("td", { className: "Layer__table-cell Layer__coa__subtype Layer__mobile--hidden" }, /* @__PURE__ */ React84.createElement("span", { className: "Layer__table-cell-content", style }, "Sub-Type")),
7556
+ /* @__PURE__ */ React84.createElement("td", { className: "Layer__table-cell Layer__coa__subtype Layer__mobile--hidden" }, /* @__PURE__ */ React84.createElement("span", { className: "Layer__table-cell-content", style }, account.account_subtype?.display_name)),
7258
7557
  /* @__PURE__ */ React84.createElement("td", { className: "Layer__table-cell Layer__coa__balance" }, /* @__PURE__ */ React84.createElement(
7259
7558
  "span",
7260
7559
  {
@@ -7356,18 +7655,6 @@ import React87 from "react";
7356
7655
  // src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
7357
7656
  import React86, { useContext as useContext9, useMemo as useMemo8 } from "react";
7358
7657
 
7359
- // src/components/ChartOfAccountsForm/constants.ts
7360
- var SUB_TYPE_OPTIONS = [
7361
- {
7362
- value: "DEBIT" /* DEBIT */,
7363
- label: "Debit"
7364
- },
7365
- {
7366
- value: "CREDIT" /* CREDIT */,
7367
- label: "Credit"
7368
- }
7369
- ];
7370
-
7371
7658
  // src/components/ChartOfAccountsForm/useParentOptions.ts
7372
7659
  import { useMemo as useMemo7 } from "react";
7373
7660
  var useParentOptions = (data) => useMemo7(
@@ -7471,25 +7758,31 @@ var ChartOfAccountsForm = () => {
7471
7758
  )), /* @__PURE__ */ React86.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ React86.createElement(
7472
7759
  Select2,
7473
7760
  {
7474
- options: [],
7475
- disabled: true,
7761
+ options: LEDGER_ACCOUNT_TYPES,
7476
7762
  value: form?.data.type,
7477
- onChange: (sel) => changeFormData("type", sel)
7763
+ onChange: (sel) => changeFormData("type", sel),
7764
+ isInvalid: Boolean(form?.errors?.find((x) => x.field === "type")),
7765
+ errorMessage: form?.errors?.find((x) => x.field === "type")?.message,
7766
+ disabled: sendingForm || form.action === "edit" || form.data.parent !== void 0
7478
7767
  }
7479
7768
  )), /* @__PURE__ */ React86.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ React86.createElement(
7480
7769
  Select2,
7481
7770
  {
7482
- options: SUB_TYPE_OPTIONS,
7771
+ options: form?.data.type?.value !== void 0 ? LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE[form?.data.type?.value] : LEDGER_ACCOUNT_SUBTYPES,
7483
7772
  value: form?.data.subType,
7484
7773
  onChange: (sel) => changeFormData("subType", sel),
7485
7774
  disabled: sendingForm
7486
7775
  }
7487
- )), /* @__PURE__ */ React86.createElement(InputGroup, { name: "category", label: "Category", inline: true }, /* @__PURE__ */ React86.createElement(
7776
+ )), /* @__PURE__ */ React86.createElement(InputGroup, { name: "normality", label: "Normality", inline: true }, /* @__PURE__ */ React86.createElement(
7488
7777
  Select2,
7489
7778
  {
7490
- options: [],
7491
- value: form?.data.category,
7492
- onChange: (sel) => changeFormData("category", sel),
7779
+ options: NORMALITY_OPTIONS,
7780
+ value: form?.data.normality,
7781
+ isInvalid: Boolean(
7782
+ form?.errors?.find((x) => x.field === "normality")
7783
+ ),
7784
+ errorMessage: form?.errors?.find((x) => x.field === "normality")?.message,
7785
+ onChange: (sel) => changeFormData("normality", sel),
7493
7786
  disabled: sendingForm
7494
7787
  }
7495
7788
  )))
@@ -7583,9 +7876,9 @@ import React93, { useContext as useContext11, useMemo as useMemo9 } from "react"
7583
7876
 
7584
7877
  // src/components/Card/Card.tsx
7585
7878
  import React89 from "react";
7586
- import classNames31 from "classnames";
7879
+ import classNames32 from "classnames";
7587
7880
  var Card = ({ children, className }) => {
7588
- return /* @__PURE__ */ React89.createElement("div", { className: classNames31("Layer__card", className) }, children);
7881
+ return /* @__PURE__ */ React89.createElement("div", { className: classNames32("Layer__card", className) }, children);
7589
7882
  };
7590
7883
 
7591
7884
  // src/components/DateTime/DateTime.tsx
@@ -7627,14 +7920,14 @@ var DateTime = ({
7627
7920
 
7628
7921
  // src/components/DetailsList/DetailsList.tsx
7629
7922
  import React91 from "react";
7630
- import classNames32 from "classnames";
7923
+ import classNames33 from "classnames";
7631
7924
  var DetailsList = ({
7632
7925
  title,
7633
7926
  children,
7634
7927
  className,
7635
7928
  actions
7636
7929
  }) => {
7637
- return /* @__PURE__ */ React91.createElement("div", { className: classNames32("Layer__details-list", className) }, title && /* @__PURE__ */ React91.createElement(Header, null, /* @__PURE__ */ React91.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ React91.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ React91.createElement("ul", { className: "Layer__details-list__list" }, children));
7930
+ return /* @__PURE__ */ React91.createElement("div", { className: classNames33("Layer__details-list", className) }, title && /* @__PURE__ */ React91.createElement(Header, null, /* @__PURE__ */ React91.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ React91.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ React91.createElement("ul", { className: "Layer__details-list__list" }, children));
7638
7931
  };
7639
7932
 
7640
7933
  // src/components/DetailsList/DetailsListItem.tsx
@@ -7654,6 +7947,40 @@ var DetailsListItem = ({
7654
7947
  };
7655
7948
 
7656
7949
  // src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
7950
+ var SourceDetailView = ({ source }) => {
7951
+ switch (source.type) {
7952
+ case "Transaction_Ledger_Entry_Source": {
7953
+ const transactionSource = source;
7954
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Account name" }, transactionSource.account_name), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Date" }, /* @__PURE__ */ React93.createElement(DateTime, { value: transactionSource.date })), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(transactionSource.amount)}`), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Direction" }, transactionSource.direction), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Counterparty" }, transactionSource.counterparty));
7955
+ }
7956
+ case "Invoice_Ledger_Entry_Source": {
7957
+ const invoiceSource = source;
7958
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Invoice number" }, invoiceSource.invoice_number), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Recipient name" }, invoiceSource.recipient_name), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Date" }, /* @__PURE__ */ React93.createElement(DateTime, { value: invoiceSource.date })), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(invoiceSource.amount)}`));
7959
+ }
7960
+ case "Manual_Ledger_Entry_Source": {
7961
+ const manualSource = source;
7962
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Memo" }, manualSource.memo), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Created by" }, manualSource.created_by));
7963
+ }
7964
+ case "Invoice_Payment_Ledger_Entry_Source": {
7965
+ const invoicePaymentSource = source;
7966
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Invoice number" }, invoicePaymentSource.invoice_number), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(invoicePaymentSource.amount)}`));
7967
+ }
7968
+ case "Refund_Ledger_Entry_Source": {
7969
+ const refundSource = source;
7970
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(refundSource.refunded_to_customer_amount)}`), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Recipient name" }, refundSource.recipient_name));
7971
+ }
7972
+ case "Opening_Balance_Ledger_Entry_Source": {
7973
+ const openingBalanceSource = source;
7974
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Account name" }, openingBalanceSource.account_name));
7975
+ }
7976
+ case "Payout_Ledger_Entry_Source": {
7977
+ const payoutSource = source;
7978
+ return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(payoutSource.paid_out_amount)}`), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Processor" }, payoutSource.processor));
7979
+ }
7980
+ default:
7981
+ return null;
7982
+ }
7983
+ };
7657
7984
  var LedgerAccountEntryDetails = () => {
7658
7985
  const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = useContext11(LedgerAccountsContext);
7659
7986
  const { totalDebit, totalCredit } = useMemo9(() => {
@@ -7681,16 +8008,24 @@ var LedgerAccountEntryDetails = () => {
7681
8008
  }
7682
8009
  )
7683
8010
  },
7684
- /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Source", isLoading: isLoadingEntry }, /* @__PURE__ */ React93.createElement(Badge, null, "Invoice")),
7685
- /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Number", isLoading: isLoadingEntry }, "1234"),
7686
- /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, "May 5, 2023"),
7687
- /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Account", isLoading: isLoadingEntry }, "89 8888 7656 6666 0000 6765")
7688
- ), /* @__PURE__ */ React93.createElement(DetailsList, { title: "Journal Entry #123", className: "Layer__border-top" }, /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Entry type", isLoading: isLoadingEntry }, humanizeEnum(entryData?.entry_type ?? "")), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, entryData?.entry_at && /* @__PURE__ */ React93.createElement(DateTime, { value: entryData?.entry_at })), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Creation date", isLoading: isLoadingEntry }, entryData?.date && /* @__PURE__ */ React93.createElement(DateTime, { value: entryData?.date })), /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Reversal", isLoading: isLoadingEntry }, "Journal Entry #79 TBD")), !isLoadingEntry && !errorEntry ? /* @__PURE__ */ React93.createElement("div", { className: "Layer__ledger-account__entry-details__line-items" }, /* @__PURE__ */ React93.createElement(Card, null, /* @__PURE__ */ React93.createElement("table", { className: "Layer__table Layer__ledger-account__entry-details__table" }, /* @__PURE__ */ React93.createElement("thead", null, /* @__PURE__ */ React93.createElement("tr", null, /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header" }, "Line items"), /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"))), /* @__PURE__ */ React93.createElement("tbody", null, entryData?.line_items?.map((item) => /* @__PURE__ */ React93.createElement("tr", { key: `ledger-line-item-${item.id}` }, /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell" }, item.account?.name || ""), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "DEBIT" /* DEBIT */ && /* @__PURE__ */ React93.createElement(Badge, { variant: "warning" /* WARNING */ }, "$", centsToDollars(item.amount || 0))), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "CREDIT" /* CREDIT */ && /* @__PURE__ */ React93.createElement(Badge, { variant: "success" /* SUCCESS */ }, "$", centsToDollars(item.amount || 0))))), /* @__PURE__ */ React93.createElement("tr", { className: "Layer__table Layer__ledger-account__entry-details__table__total-row" }, /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell" }, "Total"), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalDebit || 0)), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalCredit || 0))))))) : null);
8011
+ /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Source", isLoading: isLoadingEntry }, /* @__PURE__ */ React93.createElement(Badge, null, entryData?.source?.entity_name)),
8012
+ entryData?.source?.display_description && /* @__PURE__ */ React93.createElement(SourceDetailView, { source: entryData?.source })
8013
+ ), /* @__PURE__ */ React93.createElement(
8014
+ DetailsList,
8015
+ {
8016
+ title: `Journal Entry ${entryData?.id.substring(0, 5)}`,
8017
+ className: "Layer__border-top"
8018
+ },
8019
+ /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Entry type", isLoading: isLoadingEntry }, humanizeEnum(entryData?.entry_type ?? "")),
8020
+ /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, entryData?.entry_at && /* @__PURE__ */ React93.createElement(DateTime, { value: entryData?.entry_at })),
8021
+ /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Creation date", isLoading: isLoadingEntry }, entryData?.date && /* @__PURE__ */ React93.createElement(DateTime, { value: entryData?.date })),
8022
+ entryData?.reversal_id && /* @__PURE__ */ React93.createElement(DetailsListItem, { label: "Reversal", isLoading: isLoadingEntry }, entryData?.reversal_id.substring(0, 5))
8023
+ ), !isLoadingEntry && !errorEntry ? /* @__PURE__ */ React93.createElement("div", { className: "Layer__ledger-account__entry-details__line-items" }, /* @__PURE__ */ React93.createElement(Card, null, /* @__PURE__ */ React93.createElement("table", { className: "Layer__table Layer__ledger-account__entry-details__table" }, /* @__PURE__ */ React93.createElement("thead", null, /* @__PURE__ */ React93.createElement("tr", null, /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header" }, "Line items"), /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ React93.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"))), /* @__PURE__ */ React93.createElement("tbody", null, entryData?.line_items?.map((item) => /* @__PURE__ */ React93.createElement("tr", { key: `ledger-line-item-${item.id}` }, /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell" }, item.account?.name || ""), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "DEBIT" /* DEBIT */ && /* @__PURE__ */ React93.createElement(Badge, { variant: "warning" /* WARNING */ }, "$", centsToDollars(item.amount || 0))), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "CREDIT" /* CREDIT */ && /* @__PURE__ */ React93.createElement(Badge, { variant: "success" /* SUCCESS */ }, "$", centsToDollars(item.amount || 0))))), /* @__PURE__ */ React93.createElement("tr", { className: "Layer__table Layer__ledger-account__entry-details__table__total-row" }, /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell" }, "Total"), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalDebit || 0)), /* @__PURE__ */ React93.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalCredit || 0))))))) : null);
7689
8024
  };
7690
8025
 
7691
8026
  // src/components/LedgerAccount/LedgerAccountRow.tsx
7692
8027
  import React94, { useContext as useContext12, useEffect as useEffect14, useState as useState22 } from "react";
7693
- import classNames33 from "classnames";
8028
+ import classNames34 from "classnames";
7694
8029
  import { parseISO as parseISO10, format as formatTime8 } from "date-fns";
7695
8030
  var LedgerAccountRow = ({
7696
8031
  row,
@@ -7714,7 +8049,7 @@ var LedgerAccountRow = ({
7714
8049
  return /* @__PURE__ */ React94.createElement(
7715
8050
  "tr",
7716
8051
  {
7717
- className: classNames33(
8052
+ className: classNames34(
7718
8053
  "Layer__table-row",
7719
8054
  row.entry_id === selectedEntryId && "Layer__table-row--active",
7720
8055
  initialLoad && "initial-load",
@@ -7733,21 +8068,21 @@ var LedgerAccountRow = ({
7733
8068
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ React94.createElement(Text, null, row.date && formatTime8(parseISO10(row.date), DATE_FORMAT)), /* @__PURE__ */ React94.createElement(
7734
8069
  Text,
7735
8070
  {
7736
- weight: "bold" /* bold */,
8071
+ weight: "normal" /* normal */,
7737
8072
  className: "Layer__ledger_account-table__journal-id"
7738
8073
  },
7739
- "#123"
7740
- )), /* @__PURE__ */ React94.createElement(Text, null, "Invoice (TBD null)"))),
8074
+ row.entry_id.substring(0, 5)
8075
+ )), /* @__PURE__ */ React94.createElement(Text, null, row.source?.display_description ?? ""))),
7741
8076
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
7742
8077
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
7743
- /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, "$X,XXX.XX"))
8078
+ /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, `$${centsToDollars(row.running_balance)}`))
7744
8079
  );
7745
8080
  }
7746
8081
  if (view === "mobile") {
7747
8082
  return /* @__PURE__ */ React94.createElement(
7748
8083
  "tr",
7749
8084
  {
7750
- className: classNames33(
8085
+ className: classNames34(
7751
8086
  "Layer__table-row",
7752
8087
  row.entry_id === selectedEntryId && "Layer__table-row--active",
7753
8088
  initialLoad && "initial-load",
@@ -7766,17 +8101,17 @@ var LedgerAccountRow = ({
7766
8101
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ React94.createElement(Text, null, row.date && formatTime8(parseISO10(row.date), DATE_FORMAT)), /* @__PURE__ */ React94.createElement(
7767
8102
  Text,
7768
8103
  {
7769
- weight: "bold" /* bold */,
8104
+ weight: "normal" /* normal */,
7770
8105
  className: "Layer__ledger_account-table__journal-id"
7771
8106
  },
7772
- "#123"
7773
- )), /* @__PURE__ */ React94.createElement(Text, null, "Invoice (TBD null)"), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balances-mobile" }, /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Debit"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, " ", row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Credit"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Running balance"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, "$X,XXX.XX")))))
8107
+ row.entry_id.substring(0, 5)
8108
+ )), /* @__PURE__ */ React94.createElement(Text, null, row.source?.display_description ?? ""), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balances-mobile" }, /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Debit"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, " ", row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Credit"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ React94.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Running balance"), /* @__PURE__ */ React94.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, `$${centsToDollars(row.running_balance)}`)))))
7774
8109
  );
7775
8110
  }
7776
8111
  return /* @__PURE__ */ React94.createElement(
7777
8112
  "tr",
7778
8113
  {
7779
- className: classNames33(
8114
+ className: classNames34(
7780
8115
  "Layer__table-row",
7781
8116
  row.entry_id === selectedEntryId && "Layer__table-row--active",
7782
8117
  initialLoad && "initial-load",
@@ -7793,16 +8128,16 @@ var LedgerAccountRow = ({
7793
8128
  }
7794
8129
  },
7795
8130
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, row.date && formatTime8(parseISO10(row.date), DATE_FORMAT))),
7796
- /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, "#123")),
7797
- /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, "Invoice (TBD null)")),
8131
+ /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, row.entry_id.substring(0, 5))),
8132
+ /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content" }, row.source?.display_description ?? "")),
7798
8133
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
7799
8134
  /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
7800
- /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, "$X,XXX.XX"))
8135
+ /* @__PURE__ */ React94.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ React94.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, `$${centsToDollars(row.running_balance)}`))
7801
8136
  );
7802
8137
  };
7803
8138
 
7804
8139
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
7805
- import classNames34 from "classnames";
8140
+ import classNames35 from "classnames";
7806
8141
  var LedgerAccount = ({
7807
8142
  containerRef,
7808
8143
  pageSize = 15,
@@ -7830,7 +8165,7 @@ var LedgerAccount = ({
7830
8165
  return () => clearTimeout(timeoutLoad);
7831
8166
  }
7832
8167
  }, [isLoading]);
7833
- const baseClassName = classNames34(
8168
+ const baseClassName = classNames35(
7834
8169
  "Layer__ledger-account__index",
7835
8170
  accountId && "open"
7836
8171
  );