@layerfi/components 0.1.35 → 0.1.37

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
@@ -146,9 +146,11 @@ var getBalanceSheet = get(
146
146
  var getBankTransactions = get(
147
147
  ({
148
148
  businessId,
149
+ cursor,
150
+ categorized,
149
151
  sortBy = "date",
150
152
  sortOrder = "DESC"
151
- }) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
153
+ }) => `/v1/businesses/${businessId}/bank-transactions?${cursor ? `cursor=${cursor}&` : ""}${categorized !== void 0 && categorized !== "" ? `categorized=${categorized}&` : ""}sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
152
154
  );
153
155
  var categorizeBankTransaction = put(
154
156
  ({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
@@ -612,6 +614,25 @@ import React6 from "react";
612
614
 
613
615
  // src/contexts/BankTransactionsContext/BankTransactionsContext.tsx
614
616
  import { createContext as createContext3, useContext as useContext4 } from "react";
617
+
618
+ // src/types/bank_transactions.ts
619
+ var Direction = /* @__PURE__ */ ((Direction3) => {
620
+ Direction3["CREDIT"] = "CREDIT";
621
+ Direction3["DEBIT"] = "DEBIT";
622
+ return Direction3;
623
+ })(Direction || {});
624
+ var DisplayState = /* @__PURE__ */ ((DisplayState2) => {
625
+ DisplayState2["review"] = "review";
626
+ DisplayState2["categorized"] = "categorized";
627
+ return DisplayState2;
628
+ })(DisplayState || {});
629
+
630
+ // src/types/categories.ts
631
+ function hasSuggestions(categorization) {
632
+ return categorization.suggestions !== void 0 && categorization.suggestions.length > 0;
633
+ }
634
+
635
+ // src/contexts/BankTransactionsContext/BankTransactionsContext.tsx
615
636
  var BankTransactionsContext = createContext3({
616
637
  data: void 0,
617
638
  isLoading: false,
@@ -629,26 +650,18 @@ var BankTransactionsContext = createContext3({
629
650
  pagination: void 0
630
651
  },
631
652
  updateOneLocal: () => void 0,
653
+ removeAfterCategorize: () => void 0,
632
654
  activate: () => void 0,
633
- display: "review" /* review */
655
+ display: "review" /* review */,
656
+ fetchMore: () => {
657
+ },
658
+ hasMore: false
634
659
  });
635
660
  var useBankTransactionsContext = () => useContext4(BankTransactionsContext);
636
661
 
637
662
  // src/hooks/useBankTransactions/useBankTransactions.tsx
638
663
  import { useEffect as useEffect2, useMemo as useMemo2, useState as useState4 } from "react";
639
664
 
640
- // src/types/bank_transactions.ts
641
- var Direction = /* @__PURE__ */ ((Direction3) => {
642
- Direction3["CREDIT"] = "CREDIT";
643
- Direction3["DEBIT"] = "DEBIT";
644
- return Direction3;
645
- })(Direction || {});
646
-
647
- // src/types/categories.ts
648
- function hasSuggestions(categorization) {
649
- return categorization.suggestions !== void 0 && categorization.suggestions.length > 0;
650
- }
651
-
652
665
  // src/components/BankTransactions/constants.ts
653
666
  var CategorizedCategories = [
654
667
  "CATEGORIZED" /* CATEGORIZED */,
@@ -669,7 +682,7 @@ var filterVisibility = (scope, bankTransaction) => {
669
682
  const inReview = ReviewCategories.includes(
670
683
  bankTransaction.categorization_status
671
684
  );
672
- return scope === "TO_REVIEW" /* TO_REVIEW */ && inReview || scope === "CATEGORIZED" /* CATEGORIZED */ && categorized;
685
+ return scope === "review" /* review */ && inReview || scope === "categorized" /* categorized */ && categorized;
673
686
  };
674
687
  var isCategorized = (bankTransaction) => CategorizedCategories.includes(bankTransaction.categorization_status);
675
688
 
@@ -718,7 +731,7 @@ var applyCategorizationStatusFilter = (data, filter) => {
718
731
  return data;
719
732
  }
720
733
  return data?.filter(
721
- (tx) => filterVisibility(filter, tx) || filter === "TO_REVIEW" /* TO_REVIEW */ && tx.recently_categorized || filter === "CATEGORIZED" /* CATEGORIZED */ && tx.recently_categorized
734
+ (tx) => filterVisibility(filter, tx) || filter === "review" /* review */ && tx.recently_categorized || filter === "categorized" /* categorized */ && tx.recently_categorized
722
735
  );
723
736
  };
724
737
  var appplyDateRangeFilter = (data, filter) => {
@@ -737,8 +750,8 @@ var appplyDateRangeFilter = (data, filter) => {
737
750
  };
738
751
 
739
752
  // src/hooks/useBankTransactions/useBankTransactions.tsx
740
- import useSWR from "swr";
741
- var useBankTransactions = () => {
753
+ import useSWRInfinite from "swr/infinite";
754
+ var useBankTransactions = (params) => {
742
755
  const {
743
756
  auth,
744
757
  businessId,
@@ -749,36 +762,82 @@ var useBankTransactions = () => {
749
762
  syncTimestamps,
750
763
  hasBeenTouched
751
764
  } = useLayerContext();
752
- const [loadingStatus, setLoadingStatus] = useState4("initial");
753
- const [filters, setTheFilters] = useState4();
754
- const [active, setActive] = useState4(false);
765
+ const { scope = void 0 } = params ?? {};
766
+ const [filters, setTheFilters] = useState4(
767
+ scope ? { categorizationStatus: scope } : void 0
768
+ );
755
769
  const display = useMemo2(() => {
756
- if (filters?.categorizationStatus === "TO_REVIEW" /* TO_REVIEW */) {
770
+ if (filters?.categorizationStatus === "review" /* review */) {
757
771
  return "review" /* review */;
758
772
  }
759
773
  return "categorized" /* categorized */;
760
774
  }, [filters?.categorizationStatus]);
761
- const queryKey = useMemo2(() => {
762
- if (!active) {
763
- return false;
764
- }
765
- return businessId && auth?.access_token && `bank-transactions-${businessId}`;
766
- }, [businessId, auth?.access_token, active]);
775
+ const [active, setActive] = useState4(false);
776
+ const [loadingStatus, setLoadingStatus] = useState4("initial");
777
+ const getKey = (_index, prevData) => {
778
+ if (!auth?.access_token || !active) {
779
+ return [false, void 0];
780
+ }
781
+ if (!prevData?.meta?.pagination?.cursor) {
782
+ return [
783
+ businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}`,
784
+ void 0
785
+ ];
786
+ }
787
+ return [
788
+ businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}-${prevData.meta.pagination.cursor}`,
789
+ prevData.meta.pagination.cursor
790
+ ];
791
+ };
767
792
  const {
768
- data: responseData,
793
+ data: rawResponseData,
769
794
  isLoading,
770
795
  isValidating,
771
796
  error: responseError,
772
- mutate
773
- } = useSWR(
774
- queryKey,
775
- Layer.getBankTransactions(apiUrl, auth?.access_token, {
776
- params: { businessId }
777
- })
797
+ mutate,
798
+ size,
799
+ setSize
800
+ } = useSWRInfinite(
801
+ getKey,
802
+ async ([query, nextCursor]) => {
803
+ if (auth?.access_token) {
804
+ return Layer.getBankTransactions(apiUrl, auth?.access_token, {
805
+ params: {
806
+ businessId,
807
+ cursor: nextCursor,
808
+ categorized: filters?.categorizationStatus ? filters?.categorizationStatus === "categorized" /* categorized */ ? "true" : "false" : ""
809
+ }
810
+ }).call(false);
811
+ }
812
+ return {};
813
+ },
814
+ {
815
+ initialSize: 1,
816
+ revalidateFirstPage: false
817
+ }
778
818
  );
819
+ const data = useMemo2(() => {
820
+ if (rawResponseData && rawResponseData.length > 0) {
821
+ return rawResponseData?.map((x) => x?.data).flat().filter((x) => !!x);
822
+ }
823
+ return void 0;
824
+ }, [rawResponseData]);
825
+ const lastMetadata = useMemo2(() => {
826
+ if (rawResponseData && rawResponseData.length > 0) {
827
+ return rawResponseData[rawResponseData.length - 1].meta;
828
+ }
829
+ return void 0;
830
+ }, [rawResponseData]);
831
+ const hasMore = useMemo2(() => {
832
+ if (rawResponseData && rawResponseData.length > 0) {
833
+ const lastElement = rawResponseData[rawResponseData.length - 1];
834
+ return Boolean(lastElement.meta?.pagination?.cursor && lastElement.meta?.pagination?.has_more);
835
+ }
836
+ return false;
837
+ }, [rawResponseData]);
779
838
  const accountsList = useMemo2(
780
- () => collectAccounts(responseData?.data),
781
- [responseData]
839
+ () => data ? collectAccounts(data) : [],
840
+ [data]
782
841
  );
783
842
  useEffect2(() => {
784
843
  if (isLoading && loadingStatus === "initial") {
@@ -799,13 +858,11 @@ var useBankTransactions = () => {
799
858
  ...value ?? {}
800
859
  });
801
860
  };
802
- const {
803
- data = void 0,
804
- meta: metadata = {},
805
- error = void 0
806
- } = responseData || {};
807
861
  const filteredData = useMemo2(() => {
808
862
  let filtered = data;
863
+ if (!filtered) {
864
+ return;
865
+ }
809
866
  if (filters?.amount?.min || filters?.amount?.max) {
810
867
  filtered = applyAmountFilter(filtered, filters.amount);
811
868
  }
@@ -825,7 +882,7 @@ var useBankTransactions = () => {
825
882
  filtered = appplyDateRangeFilter(filtered, filters?.dateRange);
826
883
  }
827
884
  return filtered;
828
- }, [filters, responseData]);
885
+ }, [filters, data]);
829
886
  const categorize = (id, newCategory, notify) => {
830
887
  const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
831
888
  if (foundBT) {
@@ -898,14 +955,31 @@ var useBankTransactions = () => {
898
955
  }).finally(() => touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */));
899
956
  };
900
957
  const updateOneLocal = (newBankTransaction) => {
901
- const updatedData = data?.map(
902
- (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
903
- );
904
- mutate({ data: updatedData }, { revalidate: false });
958
+ const updatedData = rawResponseData?.map((page) => {
959
+ return {
960
+ ...page,
961
+ data: page.data?.map((bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt)
962
+ };
963
+ });
964
+ mutate(updatedData, { revalidate: false });
965
+ };
966
+ const removeAfterCategorize = (bankTransaction) => {
967
+ const updatedData = rawResponseData?.map((page) => {
968
+ return {
969
+ ...page,
970
+ data: page.data?.filter((bt) => bt.id !== bankTransaction.id)
971
+ };
972
+ });
973
+ mutate(updatedData, { revalidate: false });
905
974
  };
906
975
  const refetch = () => {
907
976
  mutate();
908
977
  };
978
+ const fetchMore = () => {
979
+ if (hasMore) {
980
+ setSize(size + 1);
981
+ }
982
+ };
909
983
  useEffect2(() => {
910
984
  if (isLoading || isValidating) {
911
985
  read("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
@@ -918,20 +992,23 @@ var useBankTransactions = () => {
918
992
  }, [syncTimestamps]);
919
993
  return {
920
994
  data: filteredData,
921
- metadata,
995
+ metadata: lastMetadata,
922
996
  loadingStatus,
923
997
  isLoading,
924
998
  isValidating,
925
999
  refetch,
926
- error: responseError || error,
1000
+ error: responseError,
927
1001
  categorize,
928
1002
  match,
929
1003
  updateOneLocal,
1004
+ removeAfterCategorize,
930
1005
  filters,
931
1006
  setFilters,
932
1007
  accountsList,
933
1008
  activate,
934
- display
1009
+ display,
1010
+ fetchMore,
1011
+ hasMore
935
1012
  };
936
1013
  };
937
1014
 
@@ -1184,7 +1261,7 @@ var hslToHex = (hsl) => {
1184
1261
 
1185
1262
  // src/providers/LayerProvider/LayerProvider.tsx
1186
1263
  import { add, isBefore } from "date-fns";
1187
- import useSWR2, { SWRConfig } from "swr";
1264
+ import useSWR, { SWRConfig } from "swr";
1188
1265
  var reducer = (state, action) => {
1189
1266
  switch (action.type) {
1190
1267
  case "LayerContext.setAuth" /* setAuth */:
@@ -1224,10 +1301,20 @@ var LayerEnvironment = {
1224
1301
  scope: "https://api.layerfi.com/production",
1225
1302
  apiUrl: "https://api.layerfi.com"
1226
1303
  },
1304
+ sandbox: {
1305
+ url: "https://auth.layerfi.com/oauth2/token",
1306
+ scope: "https://sandbox.layerfi.com/sandbox",
1307
+ apiUrl: "https://sandbox.layerfi.com"
1308
+ },
1227
1309
  staging: {
1228
1310
  url: "https://auth.layerfi.com/oauth2/token",
1229
1311
  scope: "https://sandbox.layerfi.com/sandbox",
1230
1312
  apiUrl: "https://sandbox.layerfi.com"
1313
+ },
1314
+ internalStaging: {
1315
+ url: "https://auth.layerfi.com/oauth2/token",
1316
+ scope: "https://sandbox.layerfi.com/sandbox",
1317
+ apiUrl: "https://staging.layerfi.com"
1231
1318
  }
1232
1319
  };
1233
1320
  var LayerProvider = ({
@@ -1269,7 +1356,7 @@ var LayerProvider = ({
1269
1356
  toasts: []
1270
1357
  });
1271
1358
  const { touch, syncTimestamps, read, readTimestamps, hasBeenTouched } = useDataSync();
1272
- const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR2(
1359
+ const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR(
1273
1360
  businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && isBefore(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
1274
1361
  Layer.authenticate({
1275
1362
  appId,
@@ -1304,7 +1391,7 @@ var LayerProvider = ({
1304
1391
  });
1305
1392
  }
1306
1393
  }, [businessAccessToken, auth?.access_token]);
1307
- useSWR2(
1394
+ useSWR(
1308
1395
  businessId && state.auth?.access_token && `categories-${businessId}`,
1309
1396
  Layer.getCategories(apiUrl, state.auth?.access_token, {
1310
1397
  params: { businessId }
@@ -1321,7 +1408,7 @@ var LayerProvider = ({
1321
1408
  }
1322
1409
  }
1323
1410
  );
1324
- useSWR2(
1411
+ useSWR(
1325
1412
  businessId && state?.auth?.access_token && `business-${businessId}`,
1326
1413
  Layer.getBusiness(apiUrl, state?.auth?.access_token, {
1327
1414
  params: { businessId }
@@ -1489,7 +1576,7 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1489
1576
  external_account_source: "PLAID",
1490
1577
  balance: 435121,
1491
1578
  at: "2024-04-03T13:00:00Z",
1492
- created_at: "2024-04-06T16:44:35.715458Z"
1579
+ created_at: "2024-04-06T22:47:59.715458Z"
1493
1580
  },
1494
1581
  current_ledger_balance: 373717,
1495
1582
  institution: {
@@ -1499,7 +1586,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1499
1586
  connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
1500
1587
  connection_external_id: "11111",
1501
1588
  connection_needs_repair_as_of: null,
1502
- requires_user_confirmation_as_of: null
1589
+ requires_user_confirmation_as_of: null,
1590
+ is_syncing: true
1503
1591
  },
1504
1592
  {
1505
1593
  id: "f98ec50a-c370-484d-a35b-d00207436075",
@@ -1522,7 +1610,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1522
1610
  connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
1523
1611
  connection_external_id: "11111",
1524
1612
  connection_needs_repair_as_of: null,
1525
- requires_user_confirmation_as_of: null
1613
+ requires_user_confirmation_as_of: null,
1614
+ is_syncing: false
1526
1615
  },
1527
1616
  {
1528
1617
  id: "843f1748-fdaa-422d-a73d-2489a40c8dc7",
@@ -1545,7 +1634,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1545
1634
  connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
1546
1635
  connection_external_id: "11111",
1547
1636
  connection_needs_repair_as_of: "2024-03-06T16:44:35.715458Z",
1548
- requires_user_confirmation_as_of: null
1637
+ requires_user_confirmation_as_of: null,
1638
+ is_syncing: false
1549
1639
  },
1550
1640
  {
1551
1641
  id: "8f430e29-e339-4d71-a08a-fce469c7a7c1",
@@ -1568,12 +1658,13 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1568
1658
  connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
1569
1659
  connection_external_id: "11111",
1570
1660
  connection_needs_repair_as_of: null,
1571
- requires_user_confirmation_as_of: "2024-03-06T16:44:35.715458Z"
1661
+ requires_user_confirmation_as_of: "2024-03-06T16:44:35.715458Z",
1662
+ is_syncing: false
1572
1663
  }
1573
1664
  ];
1574
1665
 
1575
1666
  // src/hooks/useLinkedAccounts/useLinkedAccounts.ts
1576
- import useSWR3 from "swr";
1667
+ import useSWR2 from "swr";
1577
1668
  var DEBUG = true;
1578
1669
  var USE_MOCK_RESPONSE_DATA = false;
1579
1670
  var useLinkedAccounts = () => {
@@ -1597,7 +1688,7 @@ var useLinkedAccounts = () => {
1597
1688
  isValidating,
1598
1689
  error: responseError,
1599
1690
  mutate
1600
- } = useSWR3(
1691
+ } = useSWR2(
1601
1692
  businessId && auth?.access_token && `linked-accounts-${businessId}`,
1602
1693
  Layer.getLinkedAccounts(apiUrl, auth?.access_token, {
1603
1694
  params: { businessId }
@@ -2118,15 +2209,13 @@ var countTransactionsToReview = ({
2118
2209
  };
2119
2210
  return transactions.filter((tx) => {
2120
2211
  try {
2121
- return filterVisibility("TO_REVIEW" /* TO_REVIEW */, tx) && isWithinInterval(parseISO2(tx.date), dateRangeInterval);
2212
+ return filterVisibility("review" /* review */, tx) && isWithinInterval(parseISO2(tx.date), dateRangeInterval);
2122
2213
  } catch (_err) {
2123
2214
  return false;
2124
2215
  }
2125
2216
  }).length;
2126
2217
  }
2127
- return transactions.filter(
2128
- (tx) => filterVisibility("TO_REVIEW" /* TO_REVIEW */, tx)
2129
- ).length;
2218
+ return transactions.filter((tx) => filterVisibility("review" /* review */, tx)).length;
2130
2219
  }
2131
2220
  return 0;
2132
2221
  };
@@ -3204,7 +3293,9 @@ var ConnectAccount = ({
3204
3293
  onTransactionsToReviewClick
3205
3294
  }) => {
3206
3295
  const { addConnection } = useContext5(LinkedAccountsContext);
3207
- const { data, isLoading } = useBankTransactions();
3296
+ const { data, isLoading } = useBankTransactions({
3297
+ scope: "review" /* review */
3298
+ });
3208
3299
  const transactionsToReview = useMemo3(
3209
3300
  () => countTransactionsToReview({ transactions: data }),
3210
3301
  [data, isLoading]
@@ -3820,15 +3911,21 @@ var LinkedAccountThumb = ({
3820
3911
  }) => {
3821
3912
  const linkedAccountThumbClassName = classNames19(
3822
3913
  "Layer__linked-account-thumb",
3823
- asWidget && "--as-widget"
3914
+ asWidget && "--as-widget",
3915
+ account.is_syncing && "--is-syncing",
3916
+ account.is_syncing && "skeleton-loader"
3917
+ );
3918
+ const linkedAccountInfoClassName = classNames19(
3919
+ "topbar",
3920
+ account.is_syncing && "--is-syncing"
3824
3921
  );
3825
- let balance;
3922
+ let bankBalance;
3826
3923
  if (pillConfig) {
3827
- balance = /* @__PURE__ */ React53.createElement(LinkedAccountPill, { text: pillConfig.text, config: pillConfig.config });
3924
+ bankBalance = /* @__PURE__ */ React53.createElement(LinkedAccountPill, { text: pillConfig.text, config: pillConfig.config });
3828
3925
  } else {
3829
- balance = /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, "$", centsToDollars(account.latest_balance_timestamp?.balance));
3926
+ bankBalance = /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.latest_balance_timestamp?.balance)}`);
3830
3927
  }
3831
- return /* @__PURE__ */ React53.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ React53.createElement("div", { className: "topbar" }, /* @__PURE__ */ React53.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-name" }, account.external_account_name), !asWidget && account.mask && /* @__PURE__ */ React53.createElement(AccountNumber, { accountNumber: account.mask }), /* @__PURE__ */ React53.createElement(
3928
+ return /* @__PURE__ */ React53.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ React53.createElement("div", { className: linkedAccountInfoClassName }, /* @__PURE__ */ React53.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ React53.createElement(Text, { as: "div", className: "account-name" }, account.external_account_name), !asWidget && account.mask && /* @__PURE__ */ React53.createElement(AccountNumber, { accountNumber: account.mask }), /* @__PURE__ */ React53.createElement(
3832
3929
  Text,
3833
3930
  {
3834
3931
  as: "span",
@@ -3844,7 +3941,7 @@ var LinkedAccountThumb = ({
3844
3941
  src: `data:image/png;base64,${account.institution.logo}`,
3845
3942
  alt: account.institution?.name
3846
3943
  }
3847
- ) : /* @__PURE__ */ React53.createElement(InstitutionIcon_default, null))), !asWidget && /* @__PURE__ */ React53.createElement("div", { className: "middlebar" }, /* @__PURE__ */ React53.createElement(
3944
+ ) : /* @__PURE__ */ React53.createElement(InstitutionIcon_default, null))), account.is_syncing ? /* @__PURE__ */ React53.createElement("div", { className: "loadingbar" }, /* @__PURE__ */ React53.createElement("div", { className: "loading-text Layer__text--sm" }, /* @__PURE__ */ React53.createElement("div", null, "Syncing account data"), /* @__PURE__ */ React53.createElement("div", { className: "syncing-data-description" }, "This may take up to 5 minutes")), /* @__PURE__ */ React53.createElement("div", { className: "loading-wrapper" }, /* @__PURE__ */ React53.createElement(Loader_default, { size: 11, className: "Layer__anim--rotating" }))) : /* @__PURE__ */ React53.createElement(React53.Fragment, null, !asWidget && /* @__PURE__ */ React53.createElement("div", { className: "middlebar" }, /* @__PURE__ */ React53.createElement(
3848
3945
  Text,
3849
3946
  {
3850
3947
  as: "span",
@@ -3852,7 +3949,7 @@ var LinkedAccountThumb = ({
3852
3949
  size: "sm"
3853
3950
  },
3854
3951
  "Bank balance"
3855
- ), balance), showLedgerBalance && /* @__PURE__ */ React53.createElement("div", { className: "bottombar" }, asWidget && account.mask ? /* @__PURE__ */ React53.createElement(AccountNumber, { accountNumber: account.mask }) : /* @__PURE__ */ React53.createElement(
3952
+ ), bankBalance), showLedgerBalance && /* @__PURE__ */ React53.createElement("div", { className: "bottombar" }, asWidget && account.mask ? /* @__PURE__ */ React53.createElement(AccountNumber, { accountNumber: account.mask }) : /* @__PURE__ */ React53.createElement(
3856
3953
  Text,
3857
3954
  {
3858
3955
  as: "span",
@@ -3860,7 +3957,7 @@ var LinkedAccountThumb = ({
3860
3957
  size: "sm"
3861
3958
  },
3862
3959
  "Ledger balance"
3863
- ), /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, "$", centsToDollars(account.current_ledger_balance))));
3960
+ ), /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.current_ledger_balance)}`))));
3864
3961
  };
3865
3962
 
3866
3963
  // src/components/LinkedAccounts/LinkedAccountsContent.tsx
@@ -5568,9 +5665,20 @@ var ExpandedBankTransactionRow = forwardRef5(
5568
5665
  });
5569
5666
  setSplitFormError(void 0);
5570
5667
  };
5668
+ const sanitizeNumberInput = (input) => {
5669
+ let sanitized = input.replace(/[^0-9.]/g, "");
5670
+ let parts = sanitized.split(".");
5671
+ if (parts.length > 2) {
5672
+ sanitized = parts[0] + "." + parts.slice(1).join("");
5673
+ }
5674
+ if (parts.length === 2) {
5675
+ sanitized = parts[0] + "." + parts[1].slice(0, 2);
5676
+ }
5677
+ return sanitized;
5678
+ };
5571
5679
  const updateAmounts = (rowNumber) => (event) => {
5572
- const newAmount = dollarsToCents(event.target.value) || 0;
5573
- const newDisplaying = event.target.value;
5680
+ const newDisplaying = sanitizeNumberInput(event.target.value);
5681
+ const newAmount = Number(newDisplaying);
5574
5682
  const splitTotal = rowState.splits.reduce((sum, split, index) => {
5575
5683
  const amount = index === 0 ? 0 : index === rowNumber ? newAmount : split.amount;
5576
5684
  return sum + amount;
@@ -6007,7 +6115,6 @@ var BankTransactionRow = ({
6007
6115
  }) => {
6008
6116
  const expandedRowRef = useRef10(null);
6009
6117
  const [showRetry, setShowRetry] = useState14(false);
6010
- const [removed, setRemoved] = useState14(false);
6011
6118
  const {
6012
6119
  filters,
6013
6120
  categorize: categorizeBankTransaction2,
@@ -6048,6 +6155,13 @@ var BankTransactionRow = ({
6048
6155
  setShowRetry(true);
6049
6156
  }
6050
6157
  }, [bankTransaction.error]);
6158
+ useEffect11(() => {
6159
+ if (editable && bankTransaction.recently_categorized) {
6160
+ setTimeout(() => {
6161
+ removeTransaction(bankTransaction);
6162
+ }, 300);
6163
+ }
6164
+ }, [bankTransaction.recently_categorized]);
6051
6165
  const save = async () => {
6052
6166
  if (open && expandedRowRef?.current) {
6053
6167
  expandedRowRef?.current?.save();
@@ -6070,9 +6184,6 @@ var BankTransactionRow = ({
6070
6184
  });
6071
6185
  setOpen(false);
6072
6186
  };
6073
- if (removed) {
6074
- return null;
6075
- }
6076
6187
  const categorized = isCategorized(bankTransaction);
6077
6188
  const className = "Layer__bank-transaction-row";
6078
6189
  const openClassName = open ? `${className}--expanded` : "";
@@ -6083,178 +6194,160 @@ var BankTransactionRow = ({
6083
6194
  initialLoad ? "initial-load" : "",
6084
6195
  showComponent ? "show" : ""
6085
6196
  );
6086
- return /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6087
- "tr",
6197
+ return /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement("tr", { className: rowClassName }, /* @__PURE__ */ React81.createElement(
6198
+ "td",
6088
6199
  {
6089
- className: rowClassName,
6090
- onTransitionEnd: ({ propertyName }) => {
6091
- if (propertyName === "top") {
6092
- if (editable) {
6093
- setRemoved(true);
6094
- removeTransaction(bankTransaction.id);
6095
- }
6200
+ className: "Layer__table-cell Layer__bank-transaction-table__date-col",
6201
+ ...openRow
6202
+ },
6203
+ /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, formatTime5(parseISO7(bankTransaction.date), dateFormat))
6204
+ ), /* @__PURE__ */ React81.createElement(
6205
+ "td",
6206
+ {
6207
+ className: "Layer__table-cell Layer__bank-transactions__tx-col",
6208
+ ...openRow
6209
+ },
6210
+ /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6211
+ Text,
6212
+ {
6213
+ as: "span",
6214
+ className: "Layer__bank-transactions__tx-text",
6215
+ withTooltip: "whenTruncated" /* whenTruncated */,
6216
+ tooltipOptions: {
6217
+ contentClassName: "Layer__bank-transactions__tx-tooltip"
6096
6218
  }
6097
- }
6219
+ },
6220
+ bankTransaction.counterparty_name ?? bankTransaction.description
6221
+ ))
6222
+ ), /* @__PURE__ */ React81.createElement(
6223
+ "td",
6224
+ {
6225
+ className: "Layer__table-cell Layer__bank-transactions__account-col",
6226
+ ...openRow
6098
6227
  },
6099
- /* @__PURE__ */ React81.createElement(
6100
- "td",
6228
+ /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6229
+ Text,
6101
6230
  {
6102
- className: "Layer__table-cell Layer__bank-transaction-table__date-col",
6103
- ...openRow
6231
+ as: "span",
6232
+ className: "Layer__bank-transactions__account-text",
6233
+ withTooltip: "whenTruncated" /* whenTruncated */
6104
6234
  },
6105
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, formatTime5(parseISO7(bankTransaction.date), dateFormat))
6106
- ),
6235
+ bankTransaction.account_name ?? ""
6236
+ ))
6237
+ ), /* @__PURE__ */ React81.createElement(
6238
+ "td",
6239
+ {
6240
+ className: `Layer__table-cell Layer__table-cell__amount-col Layer__bank-transactions__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`,
6241
+ ...openRow
6242
+ },
6243
+ /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
6244
+ ), /* @__PURE__ */ React81.createElement(
6245
+ "td",
6246
+ {
6247
+ className: classNames33(
6248
+ "Layer__table-cell",
6249
+ "Layer__table-cell__category-col",
6250
+ `${className}__actions-cell`,
6251
+ `${className}__actions-cell--${open ? "open" : "close"}`
6252
+ )
6253
+ },
6107
6254
  /* @__PURE__ */ React81.createElement(
6108
- "td",
6255
+ "span",
6109
6256
  {
6110
- className: "Layer__table-cell Layer__bank-transactions__tx-col",
6111
- ...openRow
6257
+ className: `${className}__actions-container Layer__table-cell-content`
6112
6258
  },
6113
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6114
- Text,
6259
+ !categorized && !open ? /* @__PURE__ */ React81.createElement(
6260
+ CategorySelect,
6115
6261
  {
6116
- as: "span",
6117
- className: "Layer__bank-transactions__tx-text",
6118
- withTooltip: "whenTruncated" /* whenTruncated */,
6119
- tooltipOptions: {
6120
- contentClassName: "Layer__bank-transactions__tx-tooltip"
6121
- }
6262
+ bankTransaction,
6263
+ name: `category-${bankTransaction.id}`,
6264
+ value: selectedCategory,
6265
+ onChange: (category) => {
6266
+ setSelectedCategory(category);
6267
+ setShowRetry(false);
6268
+ },
6269
+ disabled: bankTransaction.processing
6270
+ }
6271
+ ) : null,
6272
+ categorized && !open ? /* @__PURE__ */ React81.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6273
+ Badge,
6274
+ {
6275
+ icon: /* @__PURE__ */ React81.createElement(Scissors_default, { size: 11 }),
6276
+ tooltip: /* @__PURE__ */ React81.createElement(
6277
+ SplitTooltipDetails,
6278
+ {
6279
+ classNamePrefix: className,
6280
+ category: bankTransaction.category
6281
+ }
6282
+ )
6122
6283
  },
6123
- bankTransaction.counterparty_name ?? bankTransaction.description
6124
- ))
6125
- ),
6126
- /* @__PURE__ */ React81.createElement(
6127
- "td",
6128
- {
6129
- className: "Layer__table-cell Layer__bank-transactions__account-col",
6130
- ...openRow
6131
- },
6132
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6284
+ "Split"
6285
+ ), /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6286
+ MatchBadge,
6287
+ {
6288
+ classNamePrefix: className,
6289
+ bankTransaction,
6290
+ dateFormat
6291
+ }
6292
+ ), /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, `${formatTime5(
6293
+ parseISO7(bankTransaction.match.bank_transaction.date),
6294
+ dateFormat
6295
+ )}, ${bankTransaction.match?.details?.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
6296
+ !categorized && !open && showRetry ? /* @__PURE__ */ React81.createElement(
6297
+ RetryButton,
6298
+ {
6299
+ onClick: () => {
6300
+ if (!bankTransaction.processing) {
6301
+ save();
6302
+ }
6303
+ },
6304
+ className: "Layer__bank-transaction__retry-btn",
6305
+ processing: bankTransaction.processing,
6306
+ error: "Approval failed. Check connection and retry in few seconds."
6307
+ },
6308
+ "Retry"
6309
+ ) : null,
6310
+ open && bankTransaction.error ? /* @__PURE__ */ React81.createElement(
6133
6311
  Text,
6134
6312
  {
6135
6313
  as: "span",
6136
- className: "Layer__bank-transactions__account-text",
6137
- withTooltip: "whenTruncated" /* whenTruncated */
6314
+ size: "md" /* md */,
6315
+ className: "Layer__unsaved-info"
6138
6316
  },
6139
- bankTransaction.account_name ?? ""
6140
- ))
6141
- ),
6142
- /* @__PURE__ */ React81.createElement(
6143
- "td",
6144
- {
6145
- className: `Layer__table-cell Layer__table-cell__amount-col Layer__bank-transactions__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`,
6146
- ...openRow
6147
- },
6148
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
6149
- ),
6150
- /* @__PURE__ */ React81.createElement(
6151
- "td",
6152
- {
6153
- className: classNames33(
6154
- "Layer__table-cell",
6155
- "Layer__table-cell__category-col",
6156
- `${className}__actions-cell`,
6157
- `${className}__actions-cell--${open ? "open" : "close"}`
6158
- )
6159
- },
6160
- /* @__PURE__ */ React81.createElement(
6161
- "span",
6317
+ /* @__PURE__ */ React81.createElement("span", null, "Unsaved"),
6318
+ /* @__PURE__ */ React81.createElement(AlertCircle_default, { size: 12 })
6319
+ ) : null,
6320
+ !categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ React81.createElement(
6321
+ SubmitButton,
6162
6322
  {
6163
- className: `${className}__actions-container Layer__table-cell-content`
6164
- },
6165
- !categorized && !open ? /* @__PURE__ */ React81.createElement(
6166
- CategorySelect,
6167
- {
6168
- bankTransaction,
6169
- name: `category-${bankTransaction.id}`,
6170
- value: selectedCategory,
6171
- onChange: (category) => {
6172
- setSelectedCategory(category);
6173
- setShowRetry(false);
6174
- },
6175
- disabled: bankTransaction.processing
6176
- }
6177
- ) : null,
6178
- categorized && !open ? /* @__PURE__ */ React81.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6179
- Badge,
6180
- {
6181
- icon: /* @__PURE__ */ React81.createElement(Scissors_default, { size: 11 }),
6182
- tooltip: /* @__PURE__ */ React81.createElement(
6183
- SplitTooltipDetails,
6184
- {
6185
- classNamePrefix: className,
6186
- category: bankTransaction.category
6187
- }
6188
- )
6189
- },
6190
- "Split"
6191
- ), /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6192
- MatchBadge,
6193
- {
6194
- classNamePrefix: className,
6195
- bankTransaction,
6196
- dateFormat
6197
- }
6198
- ), /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, `${formatTime5(
6199
- parseISO7(bankTransaction.match.bank_transaction.date),
6200
- dateFormat
6201
- )}, ${bankTransaction.match?.details?.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
6202
- !categorized && !open && showRetry ? /* @__PURE__ */ React81.createElement(
6203
- RetryButton,
6204
- {
6205
- onClick: () => {
6206
- if (!bankTransaction.processing) {
6207
- save();
6208
- }
6209
- },
6210
- className: "Layer__bank-transaction__retry-btn",
6211
- processing: bankTransaction.processing,
6212
- error: "Approval failed. Check connection and retry in few seconds."
6213
- },
6214
- "Retry"
6215
- ) : null,
6216
- open && bankTransaction.error ? /* @__PURE__ */ React81.createElement(
6217
- Text,
6218
- {
6219
- as: "span",
6220
- size: "md" /* md */,
6221
- className: "Layer__unsaved-info"
6222
- },
6223
- /* @__PURE__ */ React81.createElement("span", null, "Unsaved"),
6224
- /* @__PURE__ */ React81.createElement(AlertCircle_default, { size: 12 })
6225
- ) : null,
6226
- !categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ React81.createElement(
6227
- SubmitButton,
6228
- {
6229
- onClick: () => {
6230
- if (!bankTransaction.processing) {
6231
- save();
6232
- }
6233
- },
6234
- className: "Layer__bank-transaction__submit-btn",
6235
- processing: bankTransaction.processing,
6236
- active: open,
6237
- action: categorized ? "save" /* SAVE */ : "update" /* UPDATE */
6323
+ onClick: () => {
6324
+ if (!bankTransaction.processing) {
6325
+ save();
6326
+ }
6238
6327
  },
6239
- categorized ? "Update" : "Approve"
6240
- ) : null,
6241
- /* @__PURE__ */ React81.createElement(
6242
- IconButton,
6243
- {
6244
- onClick: toggleOpen,
6245
- className: "Layer__bank-transaction-row__expand-button",
6246
- active: open,
6247
- icon: /* @__PURE__ */ React81.createElement(
6248
- ChevronDownFill_default,
6249
- {
6250
- className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
6251
- }
6252
- )
6253
- }
6254
- )
6328
+ className: "Layer__bank-transaction__submit-btn",
6329
+ processing: bankTransaction.processing,
6330
+ active: open,
6331
+ action: categorized ? "save" /* SAVE */ : "update" /* UPDATE */
6332
+ },
6333
+ categorized ? "Update" : "Approve"
6334
+ ) : null,
6335
+ /* @__PURE__ */ React81.createElement(
6336
+ IconButton,
6337
+ {
6338
+ onClick: toggleOpen,
6339
+ className: "Layer__bank-transaction-row__expand-button",
6340
+ active: open,
6341
+ icon: /* @__PURE__ */ React81.createElement(
6342
+ ChevronDownFill_default,
6343
+ {
6344
+ className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
6345
+ }
6346
+ )
6347
+ }
6255
6348
  )
6256
6349
  )
6257
- ), /* @__PURE__ */ React81.createElement("tr", null, /* @__PURE__ */ React81.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ React81.createElement(
6350
+ )), /* @__PURE__ */ React81.createElement("tr", null, /* @__PURE__ */ React81.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ React81.createElement(
6258
6351
  ExpandedBankTransactionRow,
6259
6352
  {
6260
6353
  ref: expandedRowRef,
@@ -6316,11 +6409,11 @@ var BankTransactionListItem = ({
6316
6409
  editable,
6317
6410
  showDescriptions,
6318
6411
  showReceiptUploads,
6319
- containerWidth
6412
+ containerWidth,
6413
+ removeTransaction
6320
6414
  }) => {
6321
6415
  const expandedRowRef = useRef11(null);
6322
6416
  const [showRetry, setShowRetry] = useState15(false);
6323
- const [removed, setRemoved] = useState15(false);
6324
6417
  const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactionsContext();
6325
6418
  const [selectedCategory, setSelectedCategory] = useState15(
6326
6419
  getDefaultSelectedCategory(bankTransaction)
@@ -6342,6 +6435,13 @@ var BankTransactionListItem = ({
6342
6435
  setShowRetry(true);
6343
6436
  }
6344
6437
  }, [bankTransaction.error]);
6438
+ useEffect12(() => {
6439
+ if (editable && bankTransaction.recently_categorized) {
6440
+ setTimeout(() => {
6441
+ removeTransaction(bankTransaction);
6442
+ }, 300);
6443
+ }
6444
+ }, [bankTransaction.recently_categorized]);
6345
6445
  const save = () => {
6346
6446
  if (open && expandedRowRef?.current) {
6347
6447
  expandedRowRef?.current?.save();
@@ -6359,9 +6459,6 @@ var BankTransactionListItem = ({
6359
6459
  category: getCategorizePayload(selectedCategory)
6360
6460
  });
6361
6461
  };
6362
- if (removed) {
6363
- return null;
6364
- }
6365
6462
  const categorized = isCategorized(bankTransaction);
6366
6463
  const className = "Layer__bank-transaction-list-item";
6367
6464
  const openClassName = open ? `${className}--expanded` : "";
@@ -6560,7 +6657,15 @@ var BusinessForm = ({ bankTransaction }) => {
6560
6657
  onClick: onCategorySelect,
6561
6658
  selected: selectedCategory
6562
6659
  }
6563
- ), options.length === 0 ? /* @__PURE__ */ React85.createElement(Button, { onClick: openDrawer, fullWidth: true }, "Select category") : null, options.length > 0 ? /* @__PURE__ */ React85.createElement(
6660
+ ), options.length === 0 ? /* @__PURE__ */ React85.createElement(
6661
+ Button,
6662
+ {
6663
+ onClick: openDrawer,
6664
+ fullWidth: true,
6665
+ variant: "secondary" /* secondary */
6666
+ },
6667
+ "Select category"
6668
+ ) : null, options.length > 0 ? /* @__PURE__ */ React85.createElement(
6564
6669
  Button,
6565
6670
  {
6566
6671
  onClick: save,
@@ -6981,8 +7086,12 @@ var BankTransactionMobileListItem = ({
6981
7086
  }, [transactionIdToOpen]);
6982
7087
  useEffect17(() => {
6983
7088
  if (!removeAnim && bankTransaction.recently_categorized) {
6984
- setRemoveAnim(true);
6985
- openNext();
7089
+ if (editable) {
7090
+ setRemoveAnim(true);
7091
+ openNext();
7092
+ } else {
7093
+ close();
7094
+ }
6986
7095
  }
6987
7096
  }, [
6988
7097
  bankTransaction.recently_categorized,
@@ -7009,6 +7118,13 @@ var BankTransactionMobileListItem = ({
7009
7118
  setShowComponent(true);
7010
7119
  }
7011
7120
  }, []);
7121
+ useEffect17(() => {
7122
+ if (editable && bankTransaction.recently_categorized) {
7123
+ setTimeout(() => {
7124
+ removeTransaction(bankTransaction);
7125
+ }, 300);
7126
+ }
7127
+ }, [bankTransaction.recently_categorized]);
7012
7128
  const onChangePurpose = (event) => setPurpose(event.target.value);
7013
7129
  const categorized = isCategorized(bankTransaction);
7014
7130
  const className = "Layer__bank-transaction-mobile-list-item";
@@ -7024,18 +7140,7 @@ var BankTransactionMobileListItem = ({
7024
7140
  {
7025
7141
  ref: itemRef,
7026
7142
  className: rowClassName,
7027
- "data-item": bankTransaction.id,
7028
- onTransitionEnd: ({ propertyName }) => {
7029
- if (propertyName === "opacity") {
7030
- close();
7031
- if (editable) {
7032
- setRemoveAnim(false);
7033
- setTimeout(() => {
7034
- removeTransaction(bankTransaction.id);
7035
- }, 500);
7036
- }
7037
- }
7038
- }
7143
+ "data-item": bankTransaction.id
7039
7144
  },
7040
7145
  /* @__PURE__ */ React91.createElement(
7041
7146
  "span",
@@ -7054,7 +7159,7 @@ var BankTransactionMobileListItem = ({
7054
7159
  centsToDollars(bankTransaction.amount)
7055
7160
  ), /* @__PURE__ */ React91.createElement("span", { className: `${className}__heading__date` }, formatTime8(parseISO10(bankTransaction.date), DATE_FORMAT2))))
7056
7161
  ),
7057
- /* @__PURE__ */ React91.createElement("div", { className: `${className}__expanded-row`, style: { height } }, open && /* @__PURE__ */ React91.createElement(
7162
+ /* @__PURE__ */ React91.createElement("div", { className: `${className}__expanded-row`, style: { height: !open || removeAnim ? 0 : height } }, open && /* @__PURE__ */ React91.createElement(
7058
7163
  "div",
7059
7164
  {
7060
7165
  className: `${className}__expanded-row__content`,
@@ -7280,7 +7385,9 @@ var Pagination = ({
7280
7385
  totalCount,
7281
7386
  siblingCount = 1,
7282
7387
  currentPage,
7283
- pageSize
7388
+ pageSize,
7389
+ hasMore,
7390
+ fetchMore
7284
7391
  }) => {
7285
7392
  const paginationRange = usePagination({
7286
7393
  currentPage,
@@ -7329,12 +7436,23 @@ var Pagination = ({
7329
7436
  onClick: () => {
7330
7437
  if (typeof pageNumber === "number") {
7331
7438
  onPageChange(pageNumber);
7439
+ if (pageNumber === lastPage && hasMore && fetchMore) {
7440
+ fetchMore();
7441
+ }
7332
7442
  }
7333
7443
  }
7334
7444
  },
7335
7445
  pageNumber
7336
7446
  );
7337
- }), /* @__PURE__ */ React97.createElement(
7447
+ }), hasMore && fetchMore ? /* @__PURE__ */ React97.createElement(
7448
+ "li",
7449
+ {
7450
+ key: `page-has-more`,
7451
+ className: "Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--next",
7452
+ onClick: fetchMore
7453
+ },
7454
+ "..."
7455
+ ) : null, /* @__PURE__ */ React97.createElement(
7338
7456
  "li",
7339
7457
  {
7340
7458
  key: `page-last`,
@@ -7396,7 +7514,7 @@ var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React98.createE
7396
7514
  var DownloadCloud_default = DownloadCloud;
7397
7515
 
7398
7516
  // src/utils/business.ts
7399
- import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth as startOfMonth2 } from "date-fns";
7517
+ import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth } from "date-fns";
7400
7518
  var getActivationDate = (business) => {
7401
7519
  try {
7402
7520
  if (business && business.activation_at) {
@@ -7410,7 +7528,7 @@ var getActivationDate = (business) => {
7410
7528
  var getEarliestDateToBrowse = (business) => {
7411
7529
  const activationDate = getActivationDate(business);
7412
7530
  if (activationDate) {
7413
- return startOfMonth2(activationDate);
7531
+ return startOfMonth(activationDate);
7414
7532
  }
7415
7533
  return;
7416
7534
  };
@@ -7422,7 +7540,7 @@ var isDateAllowedToBrowse = (date, business) => {
7422
7540
  if (!activationDate) {
7423
7541
  return true;
7424
7542
  }
7425
- return differenceInCalendarMonths(startOfMonth2(date), activationDate) >= 0;
7543
+ return differenceInCalendarMonths(startOfMonth(date), activationDate) >= 0;
7426
7544
  };
7427
7545
 
7428
7546
  // src/components/DatePicker/DatePicker.tsx
@@ -7433,13 +7551,15 @@ import "react-datepicker/dist/react-datepicker.css";
7433
7551
  // src/components/DatePicker/DatePickerOptions.tsx
7434
7552
  import React99 from "react";
7435
7553
  import {
7436
- endOfMonth as endOfMonth2,
7554
+ endOfMonth,
7437
7555
  endOfQuarter,
7438
7556
  endOfYear,
7439
- startOfMonth as startOfMonth3,
7557
+ startOfMonth as startOfMonth2,
7440
7558
  startOfQuarter,
7441
7559
  startOfYear,
7442
- subMonths
7560
+ subMonths,
7561
+ subQuarters,
7562
+ subYears
7443
7563
  } from "date-fns";
7444
7564
  var DatePickerOptions = ({
7445
7565
  options,
@@ -7455,8 +7575,8 @@ var DatePickerOptions = ({
7455
7575
  key: option,
7456
7576
  onClick: () => {
7457
7577
  setSelectedDate([
7458
- startOfMonth3(/* @__PURE__ */ new Date()),
7459
- endOfMonth2(/* @__PURE__ */ new Date())
7578
+ startOfMonth2(/* @__PURE__ */ new Date()),
7579
+ endOfMonth(/* @__PURE__ */ new Date())
7460
7580
  ]);
7461
7581
  }
7462
7582
  },
@@ -7469,8 +7589,8 @@ var DatePickerOptions = ({
7469
7589
  key: option,
7470
7590
  onClick: () => {
7471
7591
  setSelectedDate([
7472
- startOfMonth3(subMonths(/* @__PURE__ */ new Date(), 1)),
7473
- endOfMonth2(subMonths(/* @__PURE__ */ new Date(), 1))
7592
+ startOfMonth2(subMonths(/* @__PURE__ */ new Date(), 1)),
7593
+ endOfMonth(subMonths(/* @__PURE__ */ new Date(), 1))
7474
7594
  ]);
7475
7595
  }
7476
7596
  },
@@ -7490,6 +7610,21 @@ var DatePickerOptions = ({
7490
7610
  },
7491
7611
  "This quarter"
7492
7612
  );
7613
+ case "last-quarter":
7614
+ return /* @__PURE__ */ React99.createElement(
7615
+ TextButton,
7616
+ {
7617
+ key: option,
7618
+ onClick: () => {
7619
+ const lastQuarter = subQuarters(/* @__PURE__ */ new Date(), 1);
7620
+ setSelectedDate([
7621
+ startOfQuarter(lastQuarter),
7622
+ endOfQuarter(lastQuarter)
7623
+ ]);
7624
+ }
7625
+ },
7626
+ "Last quarter"
7627
+ );
7493
7628
  case "this-year":
7494
7629
  return /* @__PURE__ */ React99.createElement(
7495
7630
  TextButton,
@@ -7501,11 +7636,30 @@ var DatePickerOptions = ({
7501
7636
  },
7502
7637
  "This year"
7503
7638
  );
7639
+ case "last-year":
7640
+ return /* @__PURE__ */ React99.createElement(
7641
+ TextButton,
7642
+ {
7643
+ key: option,
7644
+ onClick: () => {
7645
+ const lastYear = subYears(/* @__PURE__ */ new Date(), 1);
7646
+ setSelectedDate([startOfYear(lastYear), endOfYear(lastYear)]);
7647
+ }
7648
+ },
7649
+ "Last year"
7650
+ );
7504
7651
  }
7505
7652
  return /* @__PURE__ */ React99.createElement(React99.Fragment, null);
7506
7653
  };
7507
7654
  if (options.length === 0) {
7508
- const allOptions = ["this-month", "last-month", "this-quarter", "this-year"];
7655
+ const allOptions = [
7656
+ "this-month",
7657
+ "last-month",
7658
+ "this-quarter",
7659
+ "last-quarter",
7660
+ "this-year",
7661
+ "last-year"
7662
+ ];
7509
7663
  allOptions.forEach((option) => {
7510
7664
  optionsComponents.push(getOptionComponent(option));
7511
7665
  });
@@ -7522,6 +7676,20 @@ var DatePickerOptions = ({
7522
7676
 
7523
7677
  // src/components/DatePicker/DatePicker.tsx
7524
7678
  import classNames37 from "classnames";
7679
+ var getDefaultRangeDate = (date, mode, selected) => {
7680
+ try {
7681
+ if (isRangeMode(mode) && selected) {
7682
+ if (date === "end") {
7683
+ return selected[1];
7684
+ }
7685
+ return selected[0];
7686
+ }
7687
+ return null;
7688
+ } catch (_err) {
7689
+ return null;
7690
+ }
7691
+ };
7692
+ var isRangeMode = (mode) => mode === "dayRangePicker" || mode === "monthRangePicker";
7525
7693
  var DatePicker = ({
7526
7694
  selected,
7527
7695
  onChange,
@@ -7540,10 +7708,29 @@ var DatePicker = ({
7540
7708
  }) => {
7541
7709
  const [updatePickerDate, setPickerDate] = useState23(false);
7542
7710
  const [selectedDates, setSelectedDates] = useState23(selected);
7711
+ const [startDate, setStartDate] = useState23(
7712
+ getDefaultRangeDate("start", mode, selected) ?? /* @__PURE__ */ new Date()
7713
+ );
7714
+ const [endDate, setEndDate] = useState23(
7715
+ getDefaultRangeDate("end", mode, selected)
7716
+ );
7543
7717
  useEffect18(() => {
7544
- setPickerDate(true);
7545
- if (selected !== selectedDates) {
7546
- setSelectedDates(selected);
7718
+ try {
7719
+ setPickerDate(true);
7720
+ if (!isRangeMode(mode) && selected !== selectedDates) {
7721
+ setSelectedDates(selected);
7722
+ return;
7723
+ }
7724
+ if (isRangeMode(mode) && Array.isArray(selected)) {
7725
+ if (startDate !== selected[0]) {
7726
+ setStartDate(selected[0]);
7727
+ }
7728
+ if (endDate !== selected[1]) {
7729
+ setEndDate(selected[1]);
7730
+ }
7731
+ }
7732
+ } catch (_err) {
7733
+ return;
7547
7734
  }
7548
7735
  }, [selected]);
7549
7736
  useEffect18(() => {
@@ -7553,6 +7740,11 @@ var DatePicker = ({
7553
7740
  setPickerDate(false);
7554
7741
  }
7555
7742
  }, [selectedDates]);
7743
+ useEffect18(() => {
7744
+ if (isRangeMode(mode)) {
7745
+ setSelectedDates([startDate, endDate]);
7746
+ }
7747
+ }, [startDate, endDate]);
7556
7748
  const wrapperClassNames = classNames37(
7557
7749
  "Layer__datepicker__wrapper",
7558
7750
  mode === "timePicker" && "Layer__datepicker__time__wrapper"
@@ -7571,6 +7763,12 @@ var DatePicker = ({
7571
7763
  popperClassName
7572
7764
  );
7573
7765
  const handleDateChange = (date) => {
7766
+ if (isRangeMode(mode)) {
7767
+ const [start, end] = date;
7768
+ setStartDate(start);
7769
+ setEndDate(end);
7770
+ return;
7771
+ }
7574
7772
  setSelectedDates(date);
7575
7773
  };
7576
7774
  const isCurrentDate = () => {
@@ -7596,15 +7794,15 @@ var DatePicker = ({
7596
7794
  ReactDatePicker,
7597
7795
  {
7598
7796
  wrapperClassName: datePickerWrapperClassNames,
7599
- startDate: mode === "dayRangePicker" || mode === "monthRangePicker" ? selectedDates[0] : void 0,
7600
- endDate: mode === "dayRangePicker" || mode === "monthRangePicker" ? selectedDates[1] : void 0,
7797
+ startDate: isRangeMode(mode) ? startDate : void 0,
7798
+ endDate: isRangeMode(mode) ? endDate : void 0,
7601
7799
  selected: mode !== "dayRangePicker" && mode !== "monthRangePicker" ? selectedDates : void 0,
7602
7800
  onChange: handleDateChange,
7603
7801
  calendarClassName: calendarClassNames,
7604
7802
  popperClassName: popperClassNames,
7605
7803
  enableTabLoop: false,
7606
7804
  popperPlacement: "bottom-start",
7607
- selectsRange: mode === "dayRangePicker" || mode === "monthRangePicker",
7805
+ selectsRange: isRangeMode(mode),
7608
7806
  showMonthYearPicker: mode === "monthPicker" || mode === "monthRangePicker",
7609
7807
  dateFormat,
7610
7808
  renderDayContents: (day) => /* @__PURE__ */ React100.createElement("span", { className: "Layer__datepicker__day-contents" }, day),
@@ -7613,6 +7811,7 @@ var DatePicker = ({
7613
7811
  showTimeSelect: mode === "timePicker",
7614
7812
  showTimeSelectOnly: mode === "timePicker",
7615
7813
  minDate,
7814
+ maxDate: /* @__PURE__ */ new Date(),
7616
7815
  ...props
7617
7816
  },
7618
7817
  mode === "dayRangePicker" && /* @__PURE__ */ React100.createElement(
@@ -7750,7 +7949,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
7750
7949
 
7751
7950
  // src/components/BankTransactions/BankTransactionsHeader.tsx
7752
7951
  import classNames39 from "classnames";
7753
- import { endOfMonth as endOfMonth3, startOfMonth as startOfMonth4 } from "date-fns";
7952
+ import { endOfMonth as endOfMonth2, startOfMonth as startOfMonth3 } from "date-fns";
7754
7953
  var DownloadButton = () => {
7755
7954
  const { auth, businessId, apiUrl } = useLayerContext();
7756
7955
  const [requestFailed, setRequestFailed] = useState25(false);
@@ -7835,8 +8034,8 @@ var BankTransactionsHeader = ({
7835
8034
  onChange: (date) => {
7836
8035
  if (!Array.isArray(date)) {
7837
8036
  setDateRange({
7838
- startDate: startOfMonth4(date),
7839
- endDate: endOfMonth3(date)
8037
+ startDate: startOfMonth3(date),
8038
+ endDate: endOfMonth2(date)
7840
8039
  });
7841
8040
  }
7842
8041
  },
@@ -7909,19 +8108,30 @@ var Inbox_default = Inbox;
7909
8108
  // src/components/BankTransactions/DataStates.tsx
7910
8109
  var DataStates = ({
7911
8110
  bankTransactions,
8111
+ transactionsLoading,
7912
8112
  isLoading,
7913
8113
  isValidating,
7914
8114
  error,
7915
8115
  refetch,
7916
8116
  editable
7917
8117
  }) => {
8118
+ let title;
8119
+ let description;
8120
+ if (transactionsLoading) {
8121
+ title = "Data sync in progress";
8122
+ description = "Check back later to review your transactions";
8123
+ } else {
8124
+ title = editable ? "You are up to date with transactions!" : "You have no categorized transactions";
8125
+ description = editable ? "All uncategorized transaction will be displayed here" : "All transaction will be displayed here once reviewed";
8126
+ }
8127
+ const showRefreshButton = transactionsLoading || bankTransactions?.length;
7918
8128
  return /* @__PURE__ */ React105.createElement(React105.Fragment, null, !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ React105.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React105.createElement(
7919
8129
  DataState,
7920
8130
  {
7921
- status: "allDone" /* allDone */,
7922
- title: editable ? "You are up to date with transactions!" : "You have no categorized transactions",
7923
- description: editable ? "All uncategorized transaction will be displayed here" : "All transaction will be displayed here once reviewed",
7924
- onRefresh: () => refetch(),
8131
+ status: transactionsLoading ? "info" /* info */ : "allDone" /* allDone */,
8132
+ title,
8133
+ description,
8134
+ onRefresh: showRefreshButton ? refetch : void 0,
7925
8135
  isLoading: isValidating,
7926
8136
  icon: !editable ? /* @__PURE__ */ React105.createElement(Inbox_default, null) : void 0
7927
8137
  }
@@ -7931,15 +8141,16 @@ var DataStates = ({
7931
8141
  status: "failed" /* failed */,
7932
8142
  title: "Something went wrong",
7933
8143
  description: "We couldn\u2019t load your data.",
7934
- onRefresh: () => refetch(),
8144
+ onRefresh: refetch,
7935
8145
  isLoading: isValidating
7936
8146
  }
7937
8147
  )) : null);
7938
8148
  };
7939
8149
 
7940
8150
  // src/components/BankTransactions/BankTransactions.tsx
7941
- import { endOfMonth as endOfMonth4, parseISO as parseISO12, startOfMonth as startOfMonth5 } from "date-fns";
8151
+ import { endOfMonth as endOfMonth3, parseISO as parseISO12, startOfMonth as startOfMonth4 } from "date-fns";
7942
8152
  var COMPONENT_NAME2 = "bank-transactions";
8153
+ var TEST_EMPTY_STATE = false;
7943
8154
  var BankTransactions = ({
7944
8155
  onError,
7945
8156
  ...props
@@ -7948,7 +8159,7 @@ var BankTransactions = ({
7948
8159
  };
7949
8160
  var BankTransactionsContent = ({
7950
8161
  asWidget = false,
7951
- pageSize = 15,
8162
+ pageSize = 20,
7952
8163
  categorizedOnly = false,
7953
8164
  categorizeView = true,
7954
8165
  showDescriptions = false,
@@ -7959,11 +8170,10 @@ var BankTransactionsContent = ({
7959
8170
  hideHeader = false
7960
8171
  }) => {
7961
8172
  const [currentPage, setCurrentPage] = useState26(1);
7962
- const [removedTxs, setRemovedTxs] = useState26([]);
7963
8173
  const [initialLoad, setInitialLoad] = useState26(true);
7964
8174
  const [dateRange, setDateRange] = useState26({
7965
- startDate: startOfMonth5(/* @__PURE__ */ new Date()),
7966
- endDate: endOfMonth4(/* @__PURE__ */ new Date())
8175
+ startDate: startOfMonth4(/* @__PURE__ */ new Date()),
8176
+ endDate: endOfMonth3(/* @__PURE__ */ new Date())
7967
8177
  });
7968
8178
  const {
7969
8179
  activate,
@@ -7975,9 +8185,12 @@ var BankTransactionsContent = ({
7975
8185
  refetch,
7976
8186
  setFilters,
7977
8187
  filters,
7978
- accountsList,
7979
- display
8188
+ display,
8189
+ hasMore,
8190
+ fetchMore,
8191
+ removeAfterCategorize
7980
8192
  } = useBankTransactionsContext();
8193
+ const { data: linkedAccounts } = useLinkedAccounts();
7981
8194
  useEffect20(() => {
7982
8195
  activate();
7983
8196
  }, []);
@@ -7987,24 +8200,24 @@ var BankTransactionsContent = ({
7987
8200
  setFilters({
7988
8201
  ...filters,
7989
8202
  ...inputFilters,
7990
- categorizationStatus: "TO_REVIEW" /* TO_REVIEW */
8203
+ categorizationStatus: "review" /* review */
7991
8204
  });
7992
8205
  } else if (!filters?.categorizationStatus && categorizedOnly) {
7993
8206
  setFilters({
7994
8207
  ...filters,
7995
8208
  ...inputFilters,
7996
- categorizationStatus: "CATEGORIZED" /* CATEGORIZED */
8209
+ categorizationStatus: "categorized" /* categorized */
7997
8210
  });
7998
8211
  } else {
7999
8212
  setFilters({ ...filters, ...inputFilters });
8000
8213
  }
8001
8214
  } else if (!filters?.categorizationStatus && categorizeView) {
8002
8215
  setFilters({
8003
- categorizationStatus: "TO_REVIEW" /* TO_REVIEW */
8216
+ categorizationStatus: "review" /* review */
8004
8217
  });
8005
8218
  } else if (!filters?.categorizationStatus && categorizedOnly) {
8006
8219
  setFilters({
8007
- categorizationStatus: "CATEGORIZED" /* CATEGORIZED */
8220
+ categorizationStatus: "categorized" /* categorized */
8008
8221
  });
8009
8222
  }
8010
8223
  }, [inputFilters, categorizeView, categorizedOnly]);
@@ -8016,7 +8229,7 @@ var BankTransactionsContent = ({
8016
8229
  return () => clearTimeout(timeoutLoad);
8017
8230
  }
8018
8231
  }, [loadingStatus]);
8019
- const bankTransactions = useMemo6(() => {
8232
+ const bankTransactions = TEST_EMPTY_STATE ? [] : useMemo6(() => {
8020
8233
  if (monthlyView) {
8021
8234
  return data?.filter(
8022
8235
  (x) => parseISO12(x.date) >= dateRange.startDate && parseISO12(x.date) <= dateRange.endDate
@@ -8025,10 +8238,10 @@ var BankTransactionsContent = ({
8025
8238
  const firstPageIndex = (currentPage - 1) * pageSize;
8026
8239
  const lastPageIndex = firstPageIndex + pageSize;
8027
8240
  return data?.slice(firstPageIndex, lastPageIndex);
8028
- }, [currentPage, data, removedTxs, dateRange]);
8241
+ }, [currentPage, data, dateRange]);
8029
8242
  const onCategorizationDisplayChange = (event) => {
8030
8243
  setFilters({
8031
- categorizationStatus: event.target.value === "categorized" /* categorized */ ? "CATEGORIZED" /* CATEGORIZED */ : "TO_REVIEW" /* TO_REVIEW */
8244
+ categorizationStatus: event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
8032
8245
  });
8033
8246
  setCurrentPage(1);
8034
8247
  };
@@ -8037,11 +8250,7 @@ var BankTransactionsContent = ({
8037
8250
  const [listView, setListView] = useState26(false);
8038
8251
  const [containerWidth, setContainerWidth] = useState26(0);
8039
8252
  const debounceContainerWidth = debounce(setContainerWidth, 500);
8040
- const removeTransaction = (id) => {
8041
- const newTxs = removedTxs.slice();
8042
- newTxs.push(id);
8043
- setRemovedTxs(newTxs);
8044
- };
8253
+ const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
8045
8254
  const containerRef = useElementSize((_el, _en, size) => {
8046
8255
  if (size?.height && size?.height >= 90) {
8047
8256
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -8122,6 +8331,9 @@ var BankTransactionsContent = ({
8122
8331
  {
8123
8332
  bankTransactions,
8124
8333
  isLoading,
8334
+ transactionsLoading: Boolean(
8335
+ linkedAccounts?.some((item) => item.is_syncing)
8336
+ ),
8125
8337
  isValidating,
8126
8338
  error,
8127
8339
  refetch,
@@ -8134,7 +8346,9 @@ var BankTransactionsContent = ({
8134
8346
  currentPage,
8135
8347
  totalCount: data?.length || 0,
8136
8348
  pageSize,
8137
- onPageChange: (page) => setCurrentPage(page)
8349
+ onPageChange: (page) => setCurrentPage(page),
8350
+ fetchMore,
8351
+ hasMore
8138
8352
  }
8139
8353
  ))
8140
8354
  );
@@ -8293,16 +8507,16 @@ var applyShare = (items, total) => {
8293
8507
 
8294
8508
  // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8295
8509
  import { useEffect as useEffect22 } from "react";
8296
- import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5, formatISO } from "date-fns";
8297
- import useSWR4 from "swr";
8510
+ import { startOfMonth as startOfMonth5, endOfMonth as endOfMonth4, formatISO } from "date-fns";
8511
+ import useSWR3 from "swr";
8298
8512
  var useProfitAndLossQuery = ({
8299
8513
  startDate,
8300
8514
  endDate,
8301
8515
  tagFilter,
8302
8516
  reportingBasis
8303
8517
  } = {
8304
- startDate: startOfMonth6(/* @__PURE__ */ new Date()),
8305
- endDate: endOfMonth5(/* @__PURE__ */ new Date())
8518
+ startDate: startOfMonth5(/* @__PURE__ */ new Date()),
8519
+ endDate: endOfMonth4(/* @__PURE__ */ new Date())
8306
8520
  }) => {
8307
8521
  const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
8308
8522
  const {
@@ -8311,7 +8525,7 @@ var useProfitAndLossQuery = ({
8311
8525
  isValidating,
8312
8526
  error: rawError,
8313
8527
  mutate
8314
- } = useSWR4(
8528
+ } = useSWR3(
8315
8529
  businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
8316
8530
  ","
8317
8531
  )}-${reportingBasis}`,
@@ -8351,21 +8565,21 @@ var useProfitAndLossQuery = ({
8351
8565
  };
8352
8566
 
8353
8567
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8354
- import { startOfMonth as startOfMonth7, endOfMonth as endOfMonth6 } from "date-fns";
8568
+ import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5 } from "date-fns";
8355
8569
  var useProfitAndLoss = ({
8356
8570
  startDate: initialStartDate,
8357
8571
  endDate: initialEndDate,
8358
8572
  tagFilter,
8359
8573
  reportingBasis
8360
8574
  } = {
8361
- startDate: startOfMonth7(/* @__PURE__ */ new Date()),
8362
- endDate: endOfMonth6(/* @__PURE__ */ new Date())
8575
+ startDate: startOfMonth6(/* @__PURE__ */ new Date()),
8576
+ endDate: endOfMonth5(/* @__PURE__ */ new Date())
8363
8577
  }) => {
8364
8578
  const [startDate, setStartDate] = useState28(
8365
- initialStartDate || startOfMonth7(Date.now())
8579
+ initialStartDate || startOfMonth6(Date.now())
8366
8580
  );
8367
8581
  const [endDate, setEndDate] = useState28(
8368
- initialEndDate || endOfMonth6(Date.now())
8582
+ initialEndDate || endOfMonth5(Date.now())
8369
8583
  );
8370
8584
  const [filters, setFilters] = useState28({
8371
8585
  expenses: void 0,
@@ -8503,14 +8717,14 @@ import React109, { useContext as useContext12, useEffect as useEffect25, useMemo
8503
8717
 
8504
8718
  // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
8505
8719
  import { useEffect as useEffect23, useMemo as useMemo8, useState as useState29 } from "react";
8506
- import { startOfMonth as startOfMonth8, sub } from "date-fns";
8507
- import useSWR5 from "swr";
8720
+ import { startOfMonth as startOfMonth7, sub } from "date-fns";
8721
+ import useSWR4 from "swr";
8508
8722
  var buildDates = ({ currentDate }) => {
8509
8723
  return {
8510
- startYear: startOfMonth8(currentDate).getFullYear() - 1,
8511
- startMonth: startOfMonth8(currentDate).getMonth() + 1,
8512
- endYear: startOfMonth8(currentDate).getFullYear(),
8513
- endMonth: startOfMonth8(currentDate).getMonth() + 1
8724
+ startYear: startOfMonth7(currentDate).getFullYear() - 1,
8725
+ startMonth: startOfMonth7(currentDate).getMonth() + 1,
8726
+ endYear: startOfMonth7(currentDate).getFullYear(),
8727
+ endMonth: startOfMonth7(currentDate).getMonth() + 1
8514
8728
  };
8515
8729
  };
8516
8730
  var buildMonthsArray = (startDate, endDate) => {
@@ -8539,7 +8753,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
8539
8753
  isValidating,
8540
8754
  error,
8541
8755
  mutate
8542
- } = useSWR5(
8756
+ } = useSWR4(
8543
8757
  businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
8544
8758
  ","
8545
8759
  )}-${reportingBasis}`,
@@ -8702,9 +8916,9 @@ import classNames40 from "classnames";
8702
8916
  import {
8703
8917
  add as add2,
8704
8918
  differenceInMonths,
8705
- endOfMonth as endOfMonth7,
8919
+ endOfMonth as endOfMonth6,
8706
8920
  format,
8707
- startOfMonth as startOfMonth9,
8921
+ startOfMonth as startOfMonth8,
8708
8922
  sub as sub2
8709
8923
  } from "date-fns";
8710
8924
  import {
@@ -8727,46 +8941,46 @@ var getChartWindow = ({
8727
8941
  currentYear,
8728
8942
  currentMonth
8729
8943
  }) => {
8730
- const today = startOfMonth9(Date.now());
8944
+ const today = startOfMonth8(Date.now());
8731
8945
  const yearAgo = sub2(today, { months: 11 });
8732
- const current = startOfMonth9(new Date(currentYear, currentMonth - 1, 1));
8733
- if (differenceInMonths(startOfMonth9(chartWindow.start), current) < 0 && differenceInMonths(startOfMonth9(chartWindow.end), current) > 1) {
8946
+ const current = startOfMonth8(new Date(currentYear, currentMonth - 1, 1));
8947
+ if (differenceInMonths(startOfMonth8(chartWindow.start), current) < 0 && differenceInMonths(startOfMonth8(chartWindow.end), current) > 1) {
8734
8948
  return chartWindow;
8735
8949
  }
8736
- if (differenceInMonths(startOfMonth9(chartWindow.start), current) === 0) {
8950
+ if (differenceInMonths(startOfMonth8(chartWindow.start), current) === 0) {
8737
8951
  return {
8738
- start: startOfMonth9(sub2(current, { months: 1 })),
8739
- end: endOfMonth7(add2(current, { months: 11 }))
8952
+ start: startOfMonth8(sub2(current, { months: 1 })),
8953
+ end: endOfMonth6(add2(current, { months: 11 }))
8740
8954
  };
8741
8955
  }
8742
- if (differenceInMonths(endOfMonth7(chartWindow.end), endOfMonth7(current)) === 1 && differenceInMonths(today, current) >= 1) {
8956
+ if (differenceInMonths(endOfMonth6(chartWindow.end), endOfMonth6(current)) === 1 && differenceInMonths(today, current) >= 1) {
8743
8957
  return {
8744
- start: startOfMonth9(sub2(current, { months: 10 })),
8745
- end: endOfMonth7(add2(current, { months: 2 }))
8958
+ start: startOfMonth8(sub2(current, { months: 10 })),
8959
+ end: endOfMonth6(add2(current, { months: 2 }))
8746
8960
  };
8747
8961
  }
8748
- if (differenceInMonths(current, startOfMonth9(chartWindow.end)) === 0 && differenceInMonths(current, startOfMonth9(today)) > 0) {
8962
+ if (differenceInMonths(current, startOfMonth8(chartWindow.end)) === 0 && differenceInMonths(current, startOfMonth8(today)) > 0) {
8749
8963
  return {
8750
- start: startOfMonth9(sub2(current, { months: 11 })),
8751
- end: endOfMonth7(add2(current, { months: 1 }))
8964
+ start: startOfMonth8(sub2(current, { months: 11 })),
8965
+ end: endOfMonth6(add2(current, { months: 1 }))
8752
8966
  };
8753
8967
  }
8754
8968
  if (current >= yearAgo) {
8755
8969
  return {
8756
- start: startOfMonth9(yearAgo),
8757
- end: endOfMonth7(today)
8970
+ start: startOfMonth8(yearAgo),
8971
+ end: endOfMonth6(today)
8758
8972
  };
8759
8973
  }
8760
8974
  if (Number(current) > Number(chartWindow.end)) {
8761
8975
  return {
8762
- start: startOfMonth9(sub2(current, { months: 12 })),
8763
- end: endOfMonth7(current)
8976
+ start: startOfMonth8(sub2(current, { months: 12 })),
8977
+ end: endOfMonth6(current)
8764
8978
  };
8765
8979
  }
8766
- if (differenceInMonths(current, startOfMonth9(chartWindow.start)) < 0) {
8980
+ if (differenceInMonths(current, startOfMonth8(chartWindow.start)) < 0) {
8767
8981
  return {
8768
- start: startOfMonth9(current),
8769
- end: endOfMonth7(add2(current, { months: 11 }))
8982
+ start: startOfMonth8(current),
8983
+ end: endOfMonth6(add2(current, { months: 11 }))
8770
8984
  };
8771
8985
  }
8772
8986
  return chartWindow;
@@ -8800,8 +9014,8 @@ var ProfitAndLossChart = () => {
8800
9014
  });
8801
9015
  const [barAnimActive, setBarAnimActive] = useState31(true);
8802
9016
  const [chartWindow, setChartWindow] = useState31({
8803
- start: startOfMonth9(sub2(Date.now(), { months: 11 })),
8804
- end: endOfMonth7(Date.now())
9017
+ start: startOfMonth8(sub2(Date.now(), { months: 11 })),
9018
+ end: endOfMonth6(Date.now())
8805
9019
  });
8806
9020
  const selectionMonth = useMemo9(
8807
9021
  () => ({
@@ -8816,24 +9030,24 @@ var ProfitAndLossChart = () => {
8816
9030
  }
8817
9031
  }, [dateRange]);
8818
9032
  const { data, loaded, pullData } = useProfitAndLossLTM({
8819
- currentDate: startOfMonth9(Date.now())
9033
+ currentDate: startOfMonth8(Date.now())
8820
9034
  });
8821
9035
  const loadingValue = useMemo9(() => getLoadingValue(data), [data]);
8822
9036
  useEffect25(() => {
8823
9037
  if (loaded === "complete" && data) {
8824
9038
  const foundCurrent = data.find(
8825
- (x) => Number(startOfMonth9(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number(startOfMonth9(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
9039
+ (x) => Number(startOfMonth8(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number(startOfMonth8(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
8826
9040
  );
8827
9041
  if (!foundCurrent) {
8828
- const newDate = startOfMonth9(localDateRange.startDate);
9042
+ const newDate = startOfMonth8(localDateRange.startDate);
8829
9043
  pullData(newDate);
8830
9044
  return;
8831
9045
  }
8832
9046
  const foundBefore = data.find(
8833
- (x) => Number(startOfMonth9(new Date(x.year, x.month - 1, 1))) >= Number(sub2(localDateRange.startDate, { months: 1 })) && Number(startOfMonth9(new Date(x.year, x.month - 1, 1))) < Number(sub2(localDateRange.endDate, { months: 1 }))
9047
+ (x) => Number(startOfMonth8(new Date(x.year, x.month - 1, 1))) >= Number(sub2(localDateRange.startDate, { months: 1 })) && Number(startOfMonth8(new Date(x.year, x.month - 1, 1))) < Number(sub2(localDateRange.endDate, { months: 1 }))
8834
9048
  );
8835
9049
  if (!foundBefore) {
8836
- const newDate = startOfMonth9(
9050
+ const newDate = startOfMonth8(
8837
9051
  sub2(localDateRange.startDate, { months: 1 })
8838
9052
  );
8839
9053
  pullData(newDate);
@@ -8865,8 +9079,10 @@ var ProfitAndLossChart = () => {
8865
9079
  name: getMonthName(pnl),
8866
9080
  revenue: pnl?.income || 0,
8867
9081
  revenueUncategorized: pnl?.uncategorizedInflows || 0,
8868
- expenses: -Math.abs((pnl?.income || 0) - (pnl?.netProfit || 0)),
8869
- expensesUncategorized: -Math.abs(pnl?.uncategorizedOutflows || 0),
9082
+ expenses: -(pnl?.operatingExpenses || 0),
9083
+ expensesUncategorized: -(pnl?.uncategorizedOutflows || 0),
9084
+ operatingExpensesInverse: pnl?.operatingExpensesInverse || 0,
9085
+ uncategorizedOutflowsInverse: pnl?.uncategorizedOutflowsInverse || 0,
8870
9086
  netProfit: pnl?.netProfit || 0,
8871
9087
  selected: !!pnl && pnl.month === selectionMonth.month + 1 && pnl.year === selectionMonth.year,
8872
9088
  year: pnl?.year,
@@ -8885,6 +9101,8 @@ var ProfitAndLossChart = () => {
8885
9101
  name: format(currentDate, compactView ? "LLLLL" : "LLL"),
8886
9102
  revenue: 0,
8887
9103
  revenueUncategorized: 0,
9104
+ operatingExpensesInverse: 0,
9105
+ uncategorizedOutflowsInverse: 0,
8888
9106
  expenses: 0,
8889
9107
  expensesUncategorized: 0,
8890
9108
  netProfit: 0,
@@ -8898,19 +9116,30 @@ var ProfitAndLossChart = () => {
8898
9116
  }
8899
9117
  return loadingData;
8900
9118
  }
8901
- return data?.filter(
9119
+ return data?.map((x) => {
9120
+ if (x.operatingExpenses < 0 || x.uncategorizedOutflows < 0) {
9121
+ return {
9122
+ ...x,
9123
+ operatingExpenses: x.operatingExpenses < 0 ? 0 : x.operatingExpenses,
9124
+ uncategorizedOutflows: x.uncategorizedOutflows < 0 ? 0 : x.uncategorizedOutflows,
9125
+ operatingExpensesInverse: x.operatingExpenses < 0 ? -x.operatingExpenses : 0,
9126
+ uncategorizedOutflowsInverse: x.uncategorizedOutflows < 0 ? -x.uncategorizedOutflows : 0
9127
+ };
9128
+ }
9129
+ return x;
9130
+ })?.filter(
8902
9131
  (x) => differenceInMonths(
8903
- startOfMonth9(new Date(x.year, x.month - 1, 1)),
9132
+ startOfMonth8(new Date(x.year, x.month - 1, 1)),
8904
9133
  chartWindow.start
8905
9134
  ) >= 0 && differenceInMonths(
8906
- startOfMonth9(new Date(x.year, x.month - 1, 1)),
9135
+ startOfMonth8(new Date(x.year, x.month - 1, 1)),
8907
9136
  chartWindow.start
8908
9137
  ) < 12 && differenceInMonths(
8909
9138
  chartWindow.end,
8910
- startOfMonth9(new Date(x.year, x.month - 1, 1))
9139
+ startOfMonth8(new Date(x.year, x.month - 1, 1))
8911
9140
  ) >= 0 && differenceInMonths(
8912
9141
  chartWindow.end,
8913
- startOfMonth9(new Date(x.year, x.month - 1, 1))
9142
+ startOfMonth8(new Date(x.year, x.month - 1, 1))
8914
9143
  ) <= 12
8915
9144
  ).map((x) => summarizePnL(x));
8916
9145
  }, [selectionMonth, chartWindow, data, loaded, compactView]);
@@ -8924,7 +9153,7 @@ var ProfitAndLossChart = () => {
8924
9153
  if (isMonthAllowed) {
8925
9154
  changeDateRange({
8926
9155
  startDate: new Date(year, month - 1, 1),
8927
- endDate: endOfMonth7(new Date(year, month - 1, 1))
9156
+ endDate: endOfMonth6(new Date(year, month - 1, 1))
8928
9157
  });
8929
9158
  }
8930
9159
  }
@@ -9185,6 +9414,22 @@ var ProfitAndLossChart = () => {
9185
9414
  stackId: "expenses"
9186
9415
  }
9187
9416
  ),
9417
+ /* @__PURE__ */ React109.createElement(
9418
+ Bar,
9419
+ {
9420
+ dataKey: "operatingExpensesInverse",
9421
+ barSize,
9422
+ isAnimationActive: barAnimActive,
9423
+ animationDuration: 100,
9424
+ radius: [2, 2, 0, 0],
9425
+ className: "Layer__profit-and-loss-chart__bar--expenses",
9426
+ xAxisId: "revenue",
9427
+ stackId: "revenue"
9428
+ },
9429
+ theData?.map((entry) => {
9430
+ return /* @__PURE__ */ React109.createElement(Cell, { key: entry.name, fill: "url(#layer-bar-stripe-pattern-dark)" });
9431
+ })
9432
+ ),
9188
9433
  /* @__PURE__ */ React109.createElement(
9189
9434
  Bar,
9190
9435
  {
@@ -9220,6 +9465,22 @@ var ProfitAndLossChart = () => {
9220
9465
  );
9221
9466
  })
9222
9467
  ),
9468
+ /* @__PURE__ */ React109.createElement(
9469
+ Bar,
9470
+ {
9471
+ dataKey: "uncategorizedOutflowsInverse",
9472
+ barSize,
9473
+ isAnimationActive: barAnimActive,
9474
+ animationDuration: 100,
9475
+ radius: [2, 2, 0, 0],
9476
+ className: "Layer__profit-and-loss-chart__bar--expenses-uncategorized",
9477
+ xAxisId: "revenue",
9478
+ stackId: "revenue"
9479
+ },
9480
+ theData?.map((entry) => {
9481
+ return /* @__PURE__ */ React109.createElement(Cell, { key: entry.name, fill: "url(#layer-bar-stripe-pattern-dark)" });
9482
+ })
9483
+ ),
9223
9484
  /* @__PURE__ */ React109.createElement(
9224
9485
  Bar,
9225
9486
  {
@@ -9296,7 +9557,7 @@ var ProfitAndLossChart = () => {
9296
9557
 
9297
9558
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
9298
9559
  import React110, { useContext as useContext13 } from "react";
9299
- import { endOfMonth as endOfMonth8, startOfMonth as startOfMonth10 } from "date-fns";
9560
+ import { endOfMonth as endOfMonth7, startOfMonth as startOfMonth9 } from "date-fns";
9300
9561
  var ProfitAndLossDatePicker = () => {
9301
9562
  const { business } = useLayerContext();
9302
9563
  const { changeDateRange, dateRange } = useContext13(ProfitAndLoss.Context);
@@ -9309,8 +9570,8 @@ var ProfitAndLossDatePicker = () => {
9309
9570
  onChange: (date) => {
9310
9571
  if (!Array.isArray(date)) {
9311
9572
  changeDateRange({
9312
- startDate: startOfMonth10(date),
9313
- endDate: endOfMonth8(date)
9573
+ startDate: startOfMonth9(date),
9574
+ endDate: endOfMonth7(date)
9314
9575
  });
9315
9576
  }
9316
9577
  },
@@ -10511,7 +10772,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
10511
10772
  };
10512
10773
 
10513
10774
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
10514
- import { endOfMonth as endOfMonth9, startOfMonth as startOfMonth11 } from "date-fns";
10775
+ import { endOfMonth as endOfMonth8, startOfMonth as startOfMonth10 } from "date-fns";
10515
10776
  var PNLContext = createContext6({
10516
10777
  data: void 0,
10517
10778
  filteredDataRevenue: [],
@@ -10522,8 +10783,8 @@ var PNLContext = createContext6({
10522
10783
  isValidating: false,
10523
10784
  error: void 0,
10524
10785
  dateRange: {
10525
- startDate: startOfMonth11(/* @__PURE__ */ new Date()),
10526
- endDate: endOfMonth9(/* @__PURE__ */ new Date())
10786
+ startDate: startOfMonth10(/* @__PURE__ */ new Date()),
10787
+ endDate: endOfMonth8(/* @__PURE__ */ new Date())
10527
10788
  },
10528
10789
  changeDateRange: () => {
10529
10790
  },
@@ -10613,11 +10874,11 @@ var TableProvider = ({ children }) => {
10613
10874
  // src/hooks/useBalanceSheet/useBalanceSheet.tsx
10614
10875
  import { useEffect as useEffect27 } from "react";
10615
10876
  import { format as format3, startOfDay } from "date-fns";
10616
- import useSWR6 from "swr";
10877
+ import useSWR5 from "swr";
10617
10878
  var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
10618
10879
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
10619
10880
  const dateString = format3(startOfDay(date), "yyyy-MM-dd'T'HH:mm:ssXXX");
10620
- const { data, isLoading, isValidating, error, mutate } = useSWR6(
10881
+ const { data, isLoading, isValidating, error, mutate } = useSWR5(
10621
10882
  businessId && dateString && auth?.access_token && `balance-sheet-${businessId}-${dateString}`,
10622
10883
  Layer.getBalanceSheet(apiUrl, auth?.access_token, {
10623
10884
  params: {
@@ -11062,7 +11323,7 @@ var StatementOfCashFlowContext = createContext9({
11062
11323
  // src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
11063
11324
  import { useEffect as useEffect32 } from "react";
11064
11325
  import { format as format5, startOfDay as startOfDay3 } from "date-fns";
11065
- import useSWR7 from "swr";
11326
+ import useSWR6 from "swr";
11066
11327
  var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
11067
11328
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
11068
11329
  const startDateString = format5(
@@ -11070,7 +11331,7 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
11070
11331
  "yyyy-MM-dd'T'HH:mm:ssXXX"
11071
11332
  );
11072
11333
  const endDateString = format5(startOfDay3(endDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
11073
- const { data, isLoading, isValidating, error, mutate } = useSWR7(
11334
+ const { data, isLoading, isValidating, error, mutate } = useSWR6(
11074
11335
  businessId && startDateString && endDateString && auth?.access_token && `statement-of-cash-${businessId}-${startDateString}-${endDateString}`,
11075
11336
  Layer.getStatementOfCashFlow(apiUrl, auth?.access_token, {
11076
11337
  params: {
@@ -11251,7 +11512,7 @@ import React153, { useContext as useContext25, useState as useState44 } from "re
11251
11512
 
11252
11513
  // src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
11253
11514
  import { createContext as createContext10 } from "react";
11254
- import { endOfMonth as endOfMonth10, startOfMonth as startOfMonth12 } from "date-fns";
11515
+ import { endOfMonth as endOfMonth9, startOfMonth as startOfMonth11 } from "date-fns";
11255
11516
  var ChartOfAccountsContext = createContext10(
11256
11517
  {
11257
11518
  data: void 0,
@@ -11274,8 +11535,8 @@ var ChartOfAccountsContext = createContext10(
11274
11535
  submitForm: () => {
11275
11536
  },
11276
11537
  dateRange: {
11277
- startDate: startOfMonth12(/* @__PURE__ */ new Date()),
11278
- endDate: endOfMonth10(/* @__PURE__ */ new Date())
11538
+ startDate: startOfMonth11(/* @__PURE__ */ new Date()),
11539
+ endDate: endOfMonth9(/* @__PURE__ */ new Date())
11279
11540
  },
11280
11541
  changeDateRange: () => {
11281
11542
  }
@@ -11510,8 +11771,8 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
11510
11771
  };
11511
11772
 
11512
11773
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
11513
- import { endOfMonth as endOfMonth11, formatISO as formatISO2, startOfMonth as startOfMonth13 } from "date-fns";
11514
- import useSWR8 from "swr";
11774
+ import { endOfMonth as endOfMonth10, formatISO as formatISO2, startOfMonth as startOfMonth12 } from "date-fns";
11775
+ import useSWR7 from "swr";
11515
11776
  var validate = (formData) => {
11516
11777
  const errors = [];
11517
11778
  const nameError = validateName(formData);
@@ -11591,8 +11852,8 @@ var validateName = (formData) => {
11591
11852
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
11592
11853
  var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
11593
11854
  withDates: false,
11594
- startDate: startOfMonth13(/* @__PURE__ */ new Date()),
11595
- endDate: endOfMonth11(/* @__PURE__ */ new Date())
11855
+ startDate: startOfMonth12(/* @__PURE__ */ new Date()),
11856
+ endDate: endOfMonth10(/* @__PURE__ */ new Date())
11596
11857
  }) => {
11597
11858
  const {
11598
11859
  auth,
@@ -11607,12 +11868,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
11607
11868
  const [sendingForm, setSendingForm] = useState38(false);
11608
11869
  const [apiError, setApiError] = useState38(void 0);
11609
11870
  const [startDate, setStartDate] = useState38(
11610
- initialStartDate ?? startOfMonth13(Date.now())
11871
+ initialStartDate ?? startOfMonth12(Date.now())
11611
11872
  );
11612
11873
  const [endDate, setEndDate] = useState38(
11613
- initialEndDate ?? endOfMonth11(Date.now())
11874
+ initialEndDate ?? endOfMonth10(Date.now())
11614
11875
  );
11615
- const { data, isLoading, isValidating, error, mutate } = useSWR8(
11876
+ const { data, isLoading, isValidating, error, mutate } = useSWR7(
11616
11877
  businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`,
11617
11878
  Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
11618
11879
  params: {
@@ -11821,12 +12082,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
11821
12082
 
11822
12083
  // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
11823
12084
  import { useEffect as useEffect34, useState as useState39 } from "react";
11824
- import useSWR9 from "swr";
12085
+ import useSWR8 from "swr";
11825
12086
  var useLedgerAccounts = () => {
11826
12087
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
11827
12088
  const [accountId, setAccountId] = useState39();
11828
12089
  const [selectedEntryId, setSelectedEntryId] = useState39();
11829
- const { data, isLoading, isValidating, error, mutate } = useSWR9(
12090
+ const { data, isLoading, isValidating, error, mutate } = useSWR8(
11830
12091
  businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
11831
12092
  Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
11832
12093
  params: { businessId, accountId }
@@ -11838,7 +12099,7 @@ var useLedgerAccounts = () => {
11838
12099
  isLoading: isLoadingEntry,
11839
12100
  isValidating: isValdiatingEntry,
11840
12101
  error: errorEntry
11841
- } = useSWR9(
12102
+ } = useSWR8(
11842
12103
  businessId && selectedEntryId && auth?.access_token && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
11843
12104
  Layer.getLedgerAccountsEntry(apiUrl, auth?.access_token, {
11844
12105
  params: { businessId, entryId: selectedEntryId }
@@ -11882,7 +12143,7 @@ import React145, { useContext as useContext21, useState as useState41 } from "re
11882
12143
 
11883
12144
  // src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
11884
12145
  import React139, { useContext as useContext18 } from "react";
11885
- import { endOfMonth as endOfMonth12, startOfMonth as startOfMonth14 } from "date-fns";
12146
+ import { endOfMonth as endOfMonth11, startOfMonth as startOfMonth13 } from "date-fns";
11886
12147
  var ChartOfAccountsDatePicker = () => {
11887
12148
  const { changeDateRange, dateRange } = useContext18(ChartOfAccountsContext);
11888
12149
  return /* @__PURE__ */ React139.createElement(
@@ -11893,8 +12154,8 @@ var ChartOfAccountsDatePicker = () => {
11893
12154
  onChange: (date) => {
11894
12155
  if (!Array.isArray(date)) {
11895
12156
  changeDateRange({
11896
- startDate: startOfMonth14(date),
11897
- endDate: endOfMonth12(date)
12157
+ startDate: startOfMonth13(date),
12158
+ endDate: endOfMonth11(date)
11898
12159
  });
11899
12160
  }
11900
12161
  }
@@ -12933,7 +13194,7 @@ var getAccountIdentifierPayload = (journalLineItem) => {
12933
13194
  };
12934
13195
 
12935
13196
  // src/hooks/useJournal/useJournal.tsx
12936
- import useSWR10 from "swr";
13197
+ import useSWR9 from "swr";
12937
13198
  var useJournal = () => {
12938
13199
  const {
12939
13200
  auth,
@@ -12949,7 +13210,7 @@ var useJournal = () => {
12949
13210
  const [addingEntry, setAddingEntry] = useState45(false);
12950
13211
  const [sendingForm, setSendingForm] = useState45(false);
12951
13212
  const [apiError, setApiError] = useState45(void 0);
12952
- const { data, isLoading, isValidating, error, mutate } = useSWR10(
13213
+ const { data, isLoading, isValidating, error, mutate } = useSWR9(
12953
13214
  businessId && auth?.access_token && `journal-lines-${businessId}`,
12954
13215
  Layer.getJournal(apiUrl, auth?.access_token, {
12955
13216
  params: { businessId }
@@ -13854,11 +14115,11 @@ var TasksContext = createContext14({
13854
14115
 
13855
14116
  // src/hooks/useTasks/useTasks.tsx
13856
14117
  import { useEffect as useEffect40, useState as useState49 } from "react";
13857
- import useSWR11 from "swr";
14118
+ import useSWR10 from "swr";
13858
14119
  var useTasks = () => {
13859
14120
  const [loadedStatus, setLoadedStatus] = useState49("initial");
13860
14121
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
13861
- const { data, isLoading, isValidating, error, mutate } = useSWR11(
14122
+ const { data, isLoading, isValidating, error, mutate } = useSWR10(
13862
14123
  businessId && auth?.access_token && `tasks-${businessId}`,
13863
14124
  Layer.getTasks(apiUrl, auth?.access_token, {
13864
14125
  params: { businessId }
@@ -14839,10 +15100,12 @@ export {
14839
15100
  AccountingOverview,
14840
15101
  BalanceSheet,
14841
15102
  BankTransactions,
15103
+ BankTransactionsProvider,
14842
15104
  BankTransactionsWithLinkedAccounts,
14843
15105
  BookkeepingOverview,
14844
15106
  BookkeepingUpsellBar,
14845
15107
  ChartOfAccounts,
15108
+ DisplayState,
14846
15109
  GeneralLedgerView,
14847
15110
  Journal,
14848
15111
  LayerProvider,