@layerfi/components 0.1.36 → 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 }
@@ -1577,7 +1664,7 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
1577
1664
  ];
1578
1665
 
1579
1666
  // src/hooks/useLinkedAccounts/useLinkedAccounts.ts
1580
- import useSWR3 from "swr";
1667
+ import useSWR2 from "swr";
1581
1668
  var DEBUG = true;
1582
1669
  var USE_MOCK_RESPONSE_DATA = false;
1583
1670
  var useLinkedAccounts = () => {
@@ -1601,7 +1688,7 @@ var useLinkedAccounts = () => {
1601
1688
  isValidating,
1602
1689
  error: responseError,
1603
1690
  mutate
1604
- } = useSWR3(
1691
+ } = useSWR2(
1605
1692
  businessId && auth?.access_token && `linked-accounts-${businessId}`,
1606
1693
  Layer.getLinkedAccounts(apiUrl, auth?.access_token, {
1607
1694
  params: { businessId }
@@ -2122,15 +2209,13 @@ var countTransactionsToReview = ({
2122
2209
  };
2123
2210
  return transactions.filter((tx) => {
2124
2211
  try {
2125
- return filterVisibility("TO_REVIEW" /* TO_REVIEW */, tx) && isWithinInterval(parseISO2(tx.date), dateRangeInterval);
2212
+ return filterVisibility("review" /* review */, tx) && isWithinInterval(parseISO2(tx.date), dateRangeInterval);
2126
2213
  } catch (_err) {
2127
2214
  return false;
2128
2215
  }
2129
2216
  }).length;
2130
2217
  }
2131
- return transactions.filter(
2132
- (tx) => filterVisibility("TO_REVIEW" /* TO_REVIEW */, tx)
2133
- ).length;
2218
+ return transactions.filter((tx) => filterVisibility("review" /* review */, tx)).length;
2134
2219
  }
2135
2220
  return 0;
2136
2221
  };
@@ -3208,7 +3293,9 @@ var ConnectAccount = ({
3208
3293
  onTransactionsToReviewClick
3209
3294
  }) => {
3210
3295
  const { addConnection } = useContext5(LinkedAccountsContext);
3211
- const { data, isLoading } = useBankTransactions();
3296
+ const { data, isLoading } = useBankTransactions({
3297
+ scope: "review" /* review */
3298
+ });
3212
3299
  const transactionsToReview = useMemo3(
3213
3300
  () => countTransactionsToReview({ transactions: data }),
3214
3301
  [data, isLoading]
@@ -3824,15 +3911,21 @@ var LinkedAccountThumb = ({
3824
3911
  }) => {
3825
3912
  const linkedAccountThumbClassName = classNames19(
3826
3913
  "Layer__linked-account-thumb",
3827
- 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"
3828
3921
  );
3829
3922
  let bankBalance;
3830
3923
  if (pillConfig) {
3831
3924
  bankBalance = /* @__PURE__ */ React53.createElement(LinkedAccountPill, { text: pillConfig.text, config: pillConfig.config });
3832
3925
  } else {
3833
- bankBalance = /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, account.is_syncing ? "Syncing..." : `${centsToDollars(account.latest_balance_timestamp?.balance)}`);
3926
+ bankBalance = /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.latest_balance_timestamp?.balance)}`);
3834
3927
  }
3835
- 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: "div", 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(
3836
3929
  Text,
3837
3930
  {
3838
3931
  as: "span",
@@ -3848,7 +3941,7 @@ var LinkedAccountThumb = ({
3848
3941
  src: `data:image/png;base64,${account.institution.logo}`,
3849
3942
  alt: account.institution?.name
3850
3943
  }
3851
- ) : /* @__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(
3852
3945
  Text,
3853
3946
  {
3854
3947
  as: "span",
@@ -3864,7 +3957,7 @@ var LinkedAccountThumb = ({
3864
3957
  size: "sm"
3865
3958
  },
3866
3959
  "Ledger balance"
3867
- ), /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, account.is_syncing ? "Syncing..." : `${centsToDollars(account.current_ledger_balance)}`)));
3960
+ ), /* @__PURE__ */ React53.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.current_ledger_balance)}`))));
3868
3961
  };
3869
3962
 
3870
3963
  // src/components/LinkedAccounts/LinkedAccountsContent.tsx
@@ -5572,9 +5665,20 @@ var ExpandedBankTransactionRow = forwardRef5(
5572
5665
  });
5573
5666
  setSplitFormError(void 0);
5574
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
+ };
5575
5679
  const updateAmounts = (rowNumber) => (event) => {
5576
- const newAmount = dollarsToCents(event.target.value) || 0;
5577
- const newDisplaying = event.target.value;
5680
+ const newDisplaying = sanitizeNumberInput(event.target.value);
5681
+ const newAmount = Number(newDisplaying);
5578
5682
  const splitTotal = rowState.splits.reduce((sum, split, index) => {
5579
5683
  const amount = index === 0 ? 0 : index === rowNumber ? newAmount : split.amount;
5580
5684
  return sum + amount;
@@ -6011,7 +6115,6 @@ var BankTransactionRow = ({
6011
6115
  }) => {
6012
6116
  const expandedRowRef = useRef10(null);
6013
6117
  const [showRetry, setShowRetry] = useState14(false);
6014
- const [removed, setRemoved] = useState14(false);
6015
6118
  const {
6016
6119
  filters,
6017
6120
  categorize: categorizeBankTransaction2,
@@ -6052,6 +6155,13 @@ var BankTransactionRow = ({
6052
6155
  setShowRetry(true);
6053
6156
  }
6054
6157
  }, [bankTransaction.error]);
6158
+ useEffect11(() => {
6159
+ if (editable && bankTransaction.recently_categorized) {
6160
+ setTimeout(() => {
6161
+ removeTransaction(bankTransaction);
6162
+ }, 300);
6163
+ }
6164
+ }, [bankTransaction.recently_categorized]);
6055
6165
  const save = async () => {
6056
6166
  if (open && expandedRowRef?.current) {
6057
6167
  expandedRowRef?.current?.save();
@@ -6074,9 +6184,6 @@ var BankTransactionRow = ({
6074
6184
  });
6075
6185
  setOpen(false);
6076
6186
  };
6077
- if (removed) {
6078
- return null;
6079
- }
6080
6187
  const categorized = isCategorized(bankTransaction);
6081
6188
  const className = "Layer__bank-transaction-row";
6082
6189
  const openClassName = open ? `${className}--expanded` : "";
@@ -6087,178 +6194,160 @@ var BankTransactionRow = ({
6087
6194
  initialLoad ? "initial-load" : "",
6088
6195
  showComponent ? "show" : ""
6089
6196
  );
6090
- return /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement(
6091
- "tr",
6197
+ return /* @__PURE__ */ React81.createElement(React81.Fragment, null, /* @__PURE__ */ React81.createElement("tr", { className: rowClassName }, /* @__PURE__ */ React81.createElement(
6198
+ "td",
6092
6199
  {
6093
- className: rowClassName,
6094
- onTransitionEnd: ({ propertyName }) => {
6095
- if (propertyName === "top") {
6096
- if (editable) {
6097
- setRemoved(true);
6098
- removeTransaction(bankTransaction.id);
6099
- }
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"
6100
6218
  }
6101
- }
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
6102
6227
  },
6103
- /* @__PURE__ */ React81.createElement(
6104
- "td",
6228
+ /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6229
+ Text,
6105
6230
  {
6106
- className: "Layer__table-cell Layer__bank-transaction-table__date-col",
6107
- ...openRow
6231
+ as: "span",
6232
+ className: "Layer__bank-transactions__account-text",
6233
+ withTooltip: "whenTruncated" /* whenTruncated */
6108
6234
  },
6109
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, formatTime5(parseISO7(bankTransaction.date), dateFormat))
6110
- ),
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
+ },
6111
6254
  /* @__PURE__ */ React81.createElement(
6112
- "td",
6255
+ "span",
6113
6256
  {
6114
- className: "Layer__table-cell Layer__bank-transactions__tx-col",
6115
- ...openRow
6257
+ className: `${className}__actions-container Layer__table-cell-content`
6116
6258
  },
6117
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React81.createElement(
6118
- Text,
6259
+ !categorized && !open ? /* @__PURE__ */ React81.createElement(
6260
+ CategorySelect,
6119
6261
  {
6120
- as: "span",
6121
- className: "Layer__bank-transactions__tx-text",
6122
- withTooltip: "whenTruncated" /* whenTruncated */,
6123
- tooltipOptions: {
6124
- contentClassName: "Layer__bank-transactions__tx-tooltip"
6125
- }
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
+ )
6126
6283
  },
6127
- bankTransaction.counterparty_name ?? bankTransaction.description
6128
- ))
6129
- ),
6130
- /* @__PURE__ */ React81.createElement(
6131
- "td",
6132
- {
6133
- className: "Layer__table-cell Layer__bank-transactions__account-col",
6134
- ...openRow
6135
- },
6136
- /* @__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(
6137
6311
  Text,
6138
6312
  {
6139
6313
  as: "span",
6140
- className: "Layer__bank-transactions__account-text",
6141
- withTooltip: "whenTruncated" /* whenTruncated */
6314
+ size: "md" /* md */,
6315
+ className: "Layer__unsaved-info"
6142
6316
  },
6143
- bankTransaction.account_name ?? ""
6144
- ))
6145
- ),
6146
- /* @__PURE__ */ React81.createElement(
6147
- "td",
6148
- {
6149
- 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"}`,
6150
- ...openRow
6151
- },
6152
- /* @__PURE__ */ React81.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
6153
- ),
6154
- /* @__PURE__ */ React81.createElement(
6155
- "td",
6156
- {
6157
- className: classNames33(
6158
- "Layer__table-cell",
6159
- "Layer__table-cell__category-col",
6160
- `${className}__actions-cell`,
6161
- `${className}__actions-cell--${open ? "open" : "close"}`
6162
- )
6163
- },
6164
- /* @__PURE__ */ React81.createElement(
6165
- "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,
6166
6322
  {
6167
- className: `${className}__actions-container Layer__table-cell-content`
6168
- },
6169
- !categorized && !open ? /* @__PURE__ */ React81.createElement(
6170
- CategorySelect,
6171
- {
6172
- bankTransaction,
6173
- name: `category-${bankTransaction.id}`,
6174
- value: selectedCategory,
6175
- onChange: (category) => {
6176
- setSelectedCategory(category);
6177
- setShowRetry(false);
6178
- },
6179
- disabled: bankTransaction.processing
6180
- }
6181
- ) : null,
6182
- 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(
6183
- Badge,
6184
- {
6185
- icon: /* @__PURE__ */ React81.createElement(Scissors_default, { size: 11 }),
6186
- tooltip: /* @__PURE__ */ React81.createElement(
6187
- SplitTooltipDetails,
6188
- {
6189
- classNamePrefix: className,
6190
- category: bankTransaction.category
6191
- }
6192
- )
6193
- },
6194
- "Split"
6195
- ), /* @__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(
6196
- MatchBadge,
6197
- {
6198
- classNamePrefix: className,
6199
- bankTransaction,
6200
- dateFormat
6201
- }
6202
- ), /* @__PURE__ */ React81.createElement("span", { className: `${className}__category-text__text` }, `${formatTime5(
6203
- parseISO7(bankTransaction.match.bank_transaction.date),
6204
- dateFormat
6205
- )}, ${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,
6206
- !categorized && !open && showRetry ? /* @__PURE__ */ React81.createElement(
6207
- RetryButton,
6208
- {
6209
- onClick: () => {
6210
- if (!bankTransaction.processing) {
6211
- save();
6212
- }
6213
- },
6214
- className: "Layer__bank-transaction__retry-btn",
6215
- processing: bankTransaction.processing,
6216
- error: "Approval failed. Check connection and retry in few seconds."
6217
- },
6218
- "Retry"
6219
- ) : null,
6220
- open && bankTransaction.error ? /* @__PURE__ */ React81.createElement(
6221
- Text,
6222
- {
6223
- as: "span",
6224
- size: "md" /* md */,
6225
- className: "Layer__unsaved-info"
6226
- },
6227
- /* @__PURE__ */ React81.createElement("span", null, "Unsaved"),
6228
- /* @__PURE__ */ React81.createElement(AlertCircle_default, { size: 12 })
6229
- ) : null,
6230
- !categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ React81.createElement(
6231
- SubmitButton,
6232
- {
6233
- onClick: () => {
6234
- if (!bankTransaction.processing) {
6235
- save();
6236
- }
6237
- },
6238
- className: "Layer__bank-transaction__submit-btn",
6239
- processing: bankTransaction.processing,
6240
- active: open,
6241
- action: categorized ? "save" /* SAVE */ : "update" /* UPDATE */
6323
+ onClick: () => {
6324
+ if (!bankTransaction.processing) {
6325
+ save();
6326
+ }
6242
6327
  },
6243
- categorized ? "Update" : "Approve"
6244
- ) : null,
6245
- /* @__PURE__ */ React81.createElement(
6246
- IconButton,
6247
- {
6248
- onClick: toggleOpen,
6249
- className: "Layer__bank-transaction-row__expand-button",
6250
- active: open,
6251
- icon: /* @__PURE__ */ React81.createElement(
6252
- ChevronDownFill_default,
6253
- {
6254
- className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
6255
- }
6256
- )
6257
- }
6258
- )
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
+ }
6259
6348
  )
6260
6349
  )
6261
- ), /* @__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(
6262
6351
  ExpandedBankTransactionRow,
6263
6352
  {
6264
6353
  ref: expandedRowRef,
@@ -6320,11 +6409,11 @@ var BankTransactionListItem = ({
6320
6409
  editable,
6321
6410
  showDescriptions,
6322
6411
  showReceiptUploads,
6323
- containerWidth
6412
+ containerWidth,
6413
+ removeTransaction
6324
6414
  }) => {
6325
6415
  const expandedRowRef = useRef11(null);
6326
6416
  const [showRetry, setShowRetry] = useState15(false);
6327
- const [removed, setRemoved] = useState15(false);
6328
6417
  const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactionsContext();
6329
6418
  const [selectedCategory, setSelectedCategory] = useState15(
6330
6419
  getDefaultSelectedCategory(bankTransaction)
@@ -6346,6 +6435,13 @@ var BankTransactionListItem = ({
6346
6435
  setShowRetry(true);
6347
6436
  }
6348
6437
  }, [bankTransaction.error]);
6438
+ useEffect12(() => {
6439
+ if (editable && bankTransaction.recently_categorized) {
6440
+ setTimeout(() => {
6441
+ removeTransaction(bankTransaction);
6442
+ }, 300);
6443
+ }
6444
+ }, [bankTransaction.recently_categorized]);
6349
6445
  const save = () => {
6350
6446
  if (open && expandedRowRef?.current) {
6351
6447
  expandedRowRef?.current?.save();
@@ -6363,9 +6459,6 @@ var BankTransactionListItem = ({
6363
6459
  category: getCategorizePayload(selectedCategory)
6364
6460
  });
6365
6461
  };
6366
- if (removed) {
6367
- return null;
6368
- }
6369
6462
  const categorized = isCategorized(bankTransaction);
6370
6463
  const className = "Layer__bank-transaction-list-item";
6371
6464
  const openClassName = open ? `${className}--expanded` : "";
@@ -6564,7 +6657,15 @@ var BusinessForm = ({ bankTransaction }) => {
6564
6657
  onClick: onCategorySelect,
6565
6658
  selected: selectedCategory
6566
6659
  }
6567
- ), 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(
6568
6669
  Button,
6569
6670
  {
6570
6671
  onClick: save,
@@ -6985,8 +7086,12 @@ var BankTransactionMobileListItem = ({
6985
7086
  }, [transactionIdToOpen]);
6986
7087
  useEffect17(() => {
6987
7088
  if (!removeAnim && bankTransaction.recently_categorized) {
6988
- setRemoveAnim(true);
6989
- openNext();
7089
+ if (editable) {
7090
+ setRemoveAnim(true);
7091
+ openNext();
7092
+ } else {
7093
+ close();
7094
+ }
6990
7095
  }
6991
7096
  }, [
6992
7097
  bankTransaction.recently_categorized,
@@ -7013,6 +7118,13 @@ var BankTransactionMobileListItem = ({
7013
7118
  setShowComponent(true);
7014
7119
  }
7015
7120
  }, []);
7121
+ useEffect17(() => {
7122
+ if (editable && bankTransaction.recently_categorized) {
7123
+ setTimeout(() => {
7124
+ removeTransaction(bankTransaction);
7125
+ }, 300);
7126
+ }
7127
+ }, [bankTransaction.recently_categorized]);
7016
7128
  const onChangePurpose = (event) => setPurpose(event.target.value);
7017
7129
  const categorized = isCategorized(bankTransaction);
7018
7130
  const className = "Layer__bank-transaction-mobile-list-item";
@@ -7028,18 +7140,7 @@ var BankTransactionMobileListItem = ({
7028
7140
  {
7029
7141
  ref: itemRef,
7030
7142
  className: rowClassName,
7031
- "data-item": bankTransaction.id,
7032
- onTransitionEnd: ({ propertyName }) => {
7033
- if (propertyName === "opacity") {
7034
- close();
7035
- if (editable) {
7036
- setRemoveAnim(false);
7037
- setTimeout(() => {
7038
- removeTransaction(bankTransaction.id);
7039
- }, 500);
7040
- }
7041
- }
7042
- }
7143
+ "data-item": bankTransaction.id
7043
7144
  },
7044
7145
  /* @__PURE__ */ React91.createElement(
7045
7146
  "span",
@@ -7058,7 +7159,7 @@ var BankTransactionMobileListItem = ({
7058
7159
  centsToDollars(bankTransaction.amount)
7059
7160
  ), /* @__PURE__ */ React91.createElement("span", { className: `${className}__heading__date` }, formatTime8(parseISO10(bankTransaction.date), DATE_FORMAT2))))
7060
7161
  ),
7061
- /* @__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(
7062
7163
  "div",
7063
7164
  {
7064
7165
  className: `${className}__expanded-row__content`,
@@ -7284,7 +7385,9 @@ var Pagination = ({
7284
7385
  totalCount,
7285
7386
  siblingCount = 1,
7286
7387
  currentPage,
7287
- pageSize
7388
+ pageSize,
7389
+ hasMore,
7390
+ fetchMore
7288
7391
  }) => {
7289
7392
  const paginationRange = usePagination({
7290
7393
  currentPage,
@@ -7333,12 +7436,23 @@ var Pagination = ({
7333
7436
  onClick: () => {
7334
7437
  if (typeof pageNumber === "number") {
7335
7438
  onPageChange(pageNumber);
7439
+ if (pageNumber === lastPage && hasMore && fetchMore) {
7440
+ fetchMore();
7441
+ }
7336
7442
  }
7337
7443
  }
7338
7444
  },
7339
7445
  pageNumber
7340
7446
  );
7341
- }), /* @__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(
7342
7456
  "li",
7343
7457
  {
7344
7458
  key: `page-last`,
@@ -7400,7 +7514,7 @@ var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React98.createE
7400
7514
  var DownloadCloud_default = DownloadCloud;
7401
7515
 
7402
7516
  // src/utils/business.ts
7403
- import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth as startOfMonth2 } from "date-fns";
7517
+ import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth } from "date-fns";
7404
7518
  var getActivationDate = (business) => {
7405
7519
  try {
7406
7520
  if (business && business.activation_at) {
@@ -7414,7 +7528,7 @@ var getActivationDate = (business) => {
7414
7528
  var getEarliestDateToBrowse = (business) => {
7415
7529
  const activationDate = getActivationDate(business);
7416
7530
  if (activationDate) {
7417
- return startOfMonth2(activationDate);
7531
+ return startOfMonth(activationDate);
7418
7532
  }
7419
7533
  return;
7420
7534
  };
@@ -7426,7 +7540,7 @@ var isDateAllowedToBrowse = (date, business) => {
7426
7540
  if (!activationDate) {
7427
7541
  return true;
7428
7542
  }
7429
- return differenceInCalendarMonths(startOfMonth2(date), activationDate) >= 0;
7543
+ return differenceInCalendarMonths(startOfMonth(date), activationDate) >= 0;
7430
7544
  };
7431
7545
 
7432
7546
  // src/components/DatePicker/DatePicker.tsx
@@ -7437,13 +7551,15 @@ import "react-datepicker/dist/react-datepicker.css";
7437
7551
  // src/components/DatePicker/DatePickerOptions.tsx
7438
7552
  import React99 from "react";
7439
7553
  import {
7440
- endOfMonth as endOfMonth2,
7554
+ endOfMonth,
7441
7555
  endOfQuarter,
7442
7556
  endOfYear,
7443
- startOfMonth as startOfMonth3,
7557
+ startOfMonth as startOfMonth2,
7444
7558
  startOfQuarter,
7445
7559
  startOfYear,
7446
- subMonths
7560
+ subMonths,
7561
+ subQuarters,
7562
+ subYears
7447
7563
  } from "date-fns";
7448
7564
  var DatePickerOptions = ({
7449
7565
  options,
@@ -7459,8 +7575,8 @@ var DatePickerOptions = ({
7459
7575
  key: option,
7460
7576
  onClick: () => {
7461
7577
  setSelectedDate([
7462
- startOfMonth3(/* @__PURE__ */ new Date()),
7463
- endOfMonth2(/* @__PURE__ */ new Date())
7578
+ startOfMonth2(/* @__PURE__ */ new Date()),
7579
+ endOfMonth(/* @__PURE__ */ new Date())
7464
7580
  ]);
7465
7581
  }
7466
7582
  },
@@ -7473,8 +7589,8 @@ var DatePickerOptions = ({
7473
7589
  key: option,
7474
7590
  onClick: () => {
7475
7591
  setSelectedDate([
7476
- startOfMonth3(subMonths(/* @__PURE__ */ new Date(), 1)),
7477
- endOfMonth2(subMonths(/* @__PURE__ */ new Date(), 1))
7592
+ startOfMonth2(subMonths(/* @__PURE__ */ new Date(), 1)),
7593
+ endOfMonth(subMonths(/* @__PURE__ */ new Date(), 1))
7478
7594
  ]);
7479
7595
  }
7480
7596
  },
@@ -7494,6 +7610,21 @@ var DatePickerOptions = ({
7494
7610
  },
7495
7611
  "This quarter"
7496
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
+ );
7497
7628
  case "this-year":
7498
7629
  return /* @__PURE__ */ React99.createElement(
7499
7630
  TextButton,
@@ -7505,11 +7636,30 @@ var DatePickerOptions = ({
7505
7636
  },
7506
7637
  "This year"
7507
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
+ );
7508
7651
  }
7509
7652
  return /* @__PURE__ */ React99.createElement(React99.Fragment, null);
7510
7653
  };
7511
7654
  if (options.length === 0) {
7512
- 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
+ ];
7513
7663
  allOptions.forEach((option) => {
7514
7664
  optionsComponents.push(getOptionComponent(option));
7515
7665
  });
@@ -7526,6 +7676,20 @@ var DatePickerOptions = ({
7526
7676
 
7527
7677
  // src/components/DatePicker/DatePicker.tsx
7528
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";
7529
7693
  var DatePicker = ({
7530
7694
  selected,
7531
7695
  onChange,
@@ -7544,10 +7708,29 @@ var DatePicker = ({
7544
7708
  }) => {
7545
7709
  const [updatePickerDate, setPickerDate] = useState23(false);
7546
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
+ );
7547
7717
  useEffect18(() => {
7548
- setPickerDate(true);
7549
- if (selected !== selectedDates) {
7550
- 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;
7551
7734
  }
7552
7735
  }, [selected]);
7553
7736
  useEffect18(() => {
@@ -7557,6 +7740,11 @@ var DatePicker = ({
7557
7740
  setPickerDate(false);
7558
7741
  }
7559
7742
  }, [selectedDates]);
7743
+ useEffect18(() => {
7744
+ if (isRangeMode(mode)) {
7745
+ setSelectedDates([startDate, endDate]);
7746
+ }
7747
+ }, [startDate, endDate]);
7560
7748
  const wrapperClassNames = classNames37(
7561
7749
  "Layer__datepicker__wrapper",
7562
7750
  mode === "timePicker" && "Layer__datepicker__time__wrapper"
@@ -7575,6 +7763,12 @@ var DatePicker = ({
7575
7763
  popperClassName
7576
7764
  );
7577
7765
  const handleDateChange = (date) => {
7766
+ if (isRangeMode(mode)) {
7767
+ const [start, end] = date;
7768
+ setStartDate(start);
7769
+ setEndDate(end);
7770
+ return;
7771
+ }
7578
7772
  setSelectedDates(date);
7579
7773
  };
7580
7774
  const isCurrentDate = () => {
@@ -7600,15 +7794,15 @@ var DatePicker = ({
7600
7794
  ReactDatePicker,
7601
7795
  {
7602
7796
  wrapperClassName: datePickerWrapperClassNames,
7603
- startDate: mode === "dayRangePicker" || mode === "monthRangePicker" ? selectedDates[0] : void 0,
7604
- endDate: mode === "dayRangePicker" || mode === "monthRangePicker" ? selectedDates[1] : void 0,
7797
+ startDate: isRangeMode(mode) ? startDate : void 0,
7798
+ endDate: isRangeMode(mode) ? endDate : void 0,
7605
7799
  selected: mode !== "dayRangePicker" && mode !== "monthRangePicker" ? selectedDates : void 0,
7606
7800
  onChange: handleDateChange,
7607
7801
  calendarClassName: calendarClassNames,
7608
7802
  popperClassName: popperClassNames,
7609
7803
  enableTabLoop: false,
7610
7804
  popperPlacement: "bottom-start",
7611
- selectsRange: mode === "dayRangePicker" || mode === "monthRangePicker",
7805
+ selectsRange: isRangeMode(mode),
7612
7806
  showMonthYearPicker: mode === "monthPicker" || mode === "monthRangePicker",
7613
7807
  dateFormat,
7614
7808
  renderDayContents: (day) => /* @__PURE__ */ React100.createElement("span", { className: "Layer__datepicker__day-contents" }, day),
@@ -7755,7 +7949,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
7755
7949
 
7756
7950
  // src/components/BankTransactions/BankTransactionsHeader.tsx
7757
7951
  import classNames39 from "classnames";
7758
- import { endOfMonth as endOfMonth3, startOfMonth as startOfMonth4 } from "date-fns";
7952
+ import { endOfMonth as endOfMonth2, startOfMonth as startOfMonth3 } from "date-fns";
7759
7953
  var DownloadButton = () => {
7760
7954
  const { auth, businessId, apiUrl } = useLayerContext();
7761
7955
  const [requestFailed, setRequestFailed] = useState25(false);
@@ -7840,8 +8034,8 @@ var BankTransactionsHeader = ({
7840
8034
  onChange: (date) => {
7841
8035
  if (!Array.isArray(date)) {
7842
8036
  setDateRange({
7843
- startDate: startOfMonth4(date),
7844
- endDate: endOfMonth3(date)
8037
+ startDate: startOfMonth3(date),
8038
+ endDate: endOfMonth2(date)
7845
8039
  });
7846
8040
  }
7847
8041
  },
@@ -7914,19 +8108,30 @@ var Inbox_default = Inbox;
7914
8108
  // src/components/BankTransactions/DataStates.tsx
7915
8109
  var DataStates = ({
7916
8110
  bankTransactions,
8111
+ transactionsLoading,
7917
8112
  isLoading,
7918
8113
  isValidating,
7919
8114
  error,
7920
8115
  refetch,
7921
8116
  editable
7922
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;
7923
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(
7924
8129
  DataState,
7925
8130
  {
7926
- status: "allDone" /* allDone */,
7927
- title: editable ? "You are up to date with transactions!" : "You have no categorized transactions",
7928
- description: editable ? "All uncategorized transaction will be displayed here" : "All transaction will be displayed here once reviewed",
7929
- onRefresh: () => refetch(),
8131
+ status: transactionsLoading ? "info" /* info */ : "allDone" /* allDone */,
8132
+ title,
8133
+ description,
8134
+ onRefresh: showRefreshButton ? refetch : void 0,
7930
8135
  isLoading: isValidating,
7931
8136
  icon: !editable ? /* @__PURE__ */ React105.createElement(Inbox_default, null) : void 0
7932
8137
  }
@@ -7936,15 +8141,16 @@ var DataStates = ({
7936
8141
  status: "failed" /* failed */,
7937
8142
  title: "Something went wrong",
7938
8143
  description: "We couldn\u2019t load your data.",
7939
- onRefresh: () => refetch(),
8144
+ onRefresh: refetch,
7940
8145
  isLoading: isValidating
7941
8146
  }
7942
8147
  )) : null);
7943
8148
  };
7944
8149
 
7945
8150
  // src/components/BankTransactions/BankTransactions.tsx
7946
- 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";
7947
8152
  var COMPONENT_NAME2 = "bank-transactions";
8153
+ var TEST_EMPTY_STATE = false;
7948
8154
  var BankTransactions = ({
7949
8155
  onError,
7950
8156
  ...props
@@ -7953,7 +8159,7 @@ var BankTransactions = ({
7953
8159
  };
7954
8160
  var BankTransactionsContent = ({
7955
8161
  asWidget = false,
7956
- pageSize = 15,
8162
+ pageSize = 20,
7957
8163
  categorizedOnly = false,
7958
8164
  categorizeView = true,
7959
8165
  showDescriptions = false,
@@ -7964,11 +8170,10 @@ var BankTransactionsContent = ({
7964
8170
  hideHeader = false
7965
8171
  }) => {
7966
8172
  const [currentPage, setCurrentPage] = useState26(1);
7967
- const [removedTxs, setRemovedTxs] = useState26([]);
7968
8173
  const [initialLoad, setInitialLoad] = useState26(true);
7969
8174
  const [dateRange, setDateRange] = useState26({
7970
- startDate: startOfMonth5(/* @__PURE__ */ new Date()),
7971
- endDate: endOfMonth4(/* @__PURE__ */ new Date())
8175
+ startDate: startOfMonth4(/* @__PURE__ */ new Date()),
8176
+ endDate: endOfMonth3(/* @__PURE__ */ new Date())
7972
8177
  });
7973
8178
  const {
7974
8179
  activate,
@@ -7980,9 +8185,12 @@ var BankTransactionsContent = ({
7980
8185
  refetch,
7981
8186
  setFilters,
7982
8187
  filters,
7983
- accountsList,
7984
- display
8188
+ display,
8189
+ hasMore,
8190
+ fetchMore,
8191
+ removeAfterCategorize
7985
8192
  } = useBankTransactionsContext();
8193
+ const { data: linkedAccounts } = useLinkedAccounts();
7986
8194
  useEffect20(() => {
7987
8195
  activate();
7988
8196
  }, []);
@@ -7992,24 +8200,24 @@ var BankTransactionsContent = ({
7992
8200
  setFilters({
7993
8201
  ...filters,
7994
8202
  ...inputFilters,
7995
- categorizationStatus: "TO_REVIEW" /* TO_REVIEW */
8203
+ categorizationStatus: "review" /* review */
7996
8204
  });
7997
8205
  } else if (!filters?.categorizationStatus && categorizedOnly) {
7998
8206
  setFilters({
7999
8207
  ...filters,
8000
8208
  ...inputFilters,
8001
- categorizationStatus: "CATEGORIZED" /* CATEGORIZED */
8209
+ categorizationStatus: "categorized" /* categorized */
8002
8210
  });
8003
8211
  } else {
8004
8212
  setFilters({ ...filters, ...inputFilters });
8005
8213
  }
8006
8214
  } else if (!filters?.categorizationStatus && categorizeView) {
8007
8215
  setFilters({
8008
- categorizationStatus: "TO_REVIEW" /* TO_REVIEW */
8216
+ categorizationStatus: "review" /* review */
8009
8217
  });
8010
8218
  } else if (!filters?.categorizationStatus && categorizedOnly) {
8011
8219
  setFilters({
8012
- categorizationStatus: "CATEGORIZED" /* CATEGORIZED */
8220
+ categorizationStatus: "categorized" /* categorized */
8013
8221
  });
8014
8222
  }
8015
8223
  }, [inputFilters, categorizeView, categorizedOnly]);
@@ -8021,7 +8229,7 @@ var BankTransactionsContent = ({
8021
8229
  return () => clearTimeout(timeoutLoad);
8022
8230
  }
8023
8231
  }, [loadingStatus]);
8024
- const bankTransactions = useMemo6(() => {
8232
+ const bankTransactions = TEST_EMPTY_STATE ? [] : useMemo6(() => {
8025
8233
  if (monthlyView) {
8026
8234
  return data?.filter(
8027
8235
  (x) => parseISO12(x.date) >= dateRange.startDate && parseISO12(x.date) <= dateRange.endDate
@@ -8030,10 +8238,10 @@ var BankTransactionsContent = ({
8030
8238
  const firstPageIndex = (currentPage - 1) * pageSize;
8031
8239
  const lastPageIndex = firstPageIndex + pageSize;
8032
8240
  return data?.slice(firstPageIndex, lastPageIndex);
8033
- }, [currentPage, data, removedTxs, dateRange]);
8241
+ }, [currentPage, data, dateRange]);
8034
8242
  const onCategorizationDisplayChange = (event) => {
8035
8243
  setFilters({
8036
- categorizationStatus: event.target.value === "categorized" /* categorized */ ? "CATEGORIZED" /* CATEGORIZED */ : "TO_REVIEW" /* TO_REVIEW */
8244
+ categorizationStatus: event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
8037
8245
  });
8038
8246
  setCurrentPage(1);
8039
8247
  };
@@ -8042,11 +8250,7 @@ var BankTransactionsContent = ({
8042
8250
  const [listView, setListView] = useState26(false);
8043
8251
  const [containerWidth, setContainerWidth] = useState26(0);
8044
8252
  const debounceContainerWidth = debounce(setContainerWidth, 500);
8045
- const removeTransaction = (id) => {
8046
- const newTxs = removedTxs.slice();
8047
- newTxs.push(id);
8048
- setRemovedTxs(newTxs);
8049
- };
8253
+ const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
8050
8254
  const containerRef = useElementSize((_el, _en, size) => {
8051
8255
  if (size?.height && size?.height >= 90) {
8052
8256
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -8127,6 +8331,9 @@ var BankTransactionsContent = ({
8127
8331
  {
8128
8332
  bankTransactions,
8129
8333
  isLoading,
8334
+ transactionsLoading: Boolean(
8335
+ linkedAccounts?.some((item) => item.is_syncing)
8336
+ ),
8130
8337
  isValidating,
8131
8338
  error,
8132
8339
  refetch,
@@ -8139,7 +8346,9 @@ var BankTransactionsContent = ({
8139
8346
  currentPage,
8140
8347
  totalCount: data?.length || 0,
8141
8348
  pageSize,
8142
- onPageChange: (page) => setCurrentPage(page)
8349
+ onPageChange: (page) => setCurrentPage(page),
8350
+ fetchMore,
8351
+ hasMore
8143
8352
  }
8144
8353
  ))
8145
8354
  );
@@ -8298,16 +8507,16 @@ var applyShare = (items, total) => {
8298
8507
 
8299
8508
  // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8300
8509
  import { useEffect as useEffect22 } from "react";
8301
- import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5, formatISO } from "date-fns";
8302
- import useSWR4 from "swr";
8510
+ import { startOfMonth as startOfMonth5, endOfMonth as endOfMonth4, formatISO } from "date-fns";
8511
+ import useSWR3 from "swr";
8303
8512
  var useProfitAndLossQuery = ({
8304
8513
  startDate,
8305
8514
  endDate,
8306
8515
  tagFilter,
8307
8516
  reportingBasis
8308
8517
  } = {
8309
- startDate: startOfMonth6(/* @__PURE__ */ new Date()),
8310
- endDate: endOfMonth5(/* @__PURE__ */ new Date())
8518
+ startDate: startOfMonth5(/* @__PURE__ */ new Date()),
8519
+ endDate: endOfMonth4(/* @__PURE__ */ new Date())
8311
8520
  }) => {
8312
8521
  const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
8313
8522
  const {
@@ -8316,7 +8525,7 @@ var useProfitAndLossQuery = ({
8316
8525
  isValidating,
8317
8526
  error: rawError,
8318
8527
  mutate
8319
- } = useSWR4(
8528
+ } = useSWR3(
8320
8529
  businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
8321
8530
  ","
8322
8531
  )}-${reportingBasis}`,
@@ -8356,21 +8565,21 @@ var useProfitAndLossQuery = ({
8356
8565
  };
8357
8566
 
8358
8567
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8359
- import { startOfMonth as startOfMonth7, endOfMonth as endOfMonth6 } from "date-fns";
8568
+ import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5 } from "date-fns";
8360
8569
  var useProfitAndLoss = ({
8361
8570
  startDate: initialStartDate,
8362
8571
  endDate: initialEndDate,
8363
8572
  tagFilter,
8364
8573
  reportingBasis
8365
8574
  } = {
8366
- startDate: startOfMonth7(/* @__PURE__ */ new Date()),
8367
- endDate: endOfMonth6(/* @__PURE__ */ new Date())
8575
+ startDate: startOfMonth6(/* @__PURE__ */ new Date()),
8576
+ endDate: endOfMonth5(/* @__PURE__ */ new Date())
8368
8577
  }) => {
8369
8578
  const [startDate, setStartDate] = useState28(
8370
- initialStartDate || startOfMonth7(Date.now())
8579
+ initialStartDate || startOfMonth6(Date.now())
8371
8580
  );
8372
8581
  const [endDate, setEndDate] = useState28(
8373
- initialEndDate || endOfMonth6(Date.now())
8582
+ initialEndDate || endOfMonth5(Date.now())
8374
8583
  );
8375
8584
  const [filters, setFilters] = useState28({
8376
8585
  expenses: void 0,
@@ -8508,14 +8717,14 @@ import React109, { useContext as useContext12, useEffect as useEffect25, useMemo
8508
8717
 
8509
8718
  // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
8510
8719
  import { useEffect as useEffect23, useMemo as useMemo8, useState as useState29 } from "react";
8511
- import { startOfMonth as startOfMonth8, sub } from "date-fns";
8512
- import useSWR5 from "swr";
8720
+ import { startOfMonth as startOfMonth7, sub } from "date-fns";
8721
+ import useSWR4 from "swr";
8513
8722
  var buildDates = ({ currentDate }) => {
8514
8723
  return {
8515
- startYear: startOfMonth8(currentDate).getFullYear() - 1,
8516
- startMonth: startOfMonth8(currentDate).getMonth() + 1,
8517
- endYear: startOfMonth8(currentDate).getFullYear(),
8518
- 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
8519
8728
  };
8520
8729
  };
8521
8730
  var buildMonthsArray = (startDate, endDate) => {
@@ -8544,7 +8753,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
8544
8753
  isValidating,
8545
8754
  error,
8546
8755
  mutate
8547
- } = useSWR5(
8756
+ } = useSWR4(
8548
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(
8549
8758
  ","
8550
8759
  )}-${reportingBasis}`,
@@ -8707,9 +8916,9 @@ import classNames40 from "classnames";
8707
8916
  import {
8708
8917
  add as add2,
8709
8918
  differenceInMonths,
8710
- endOfMonth as endOfMonth7,
8919
+ endOfMonth as endOfMonth6,
8711
8920
  format,
8712
- startOfMonth as startOfMonth9,
8921
+ startOfMonth as startOfMonth8,
8713
8922
  sub as sub2
8714
8923
  } from "date-fns";
8715
8924
  import {
@@ -8732,46 +8941,46 @@ var getChartWindow = ({
8732
8941
  currentYear,
8733
8942
  currentMonth
8734
8943
  }) => {
8735
- const today = startOfMonth9(Date.now());
8944
+ const today = startOfMonth8(Date.now());
8736
8945
  const yearAgo = sub2(today, { months: 11 });
8737
- const current = startOfMonth9(new Date(currentYear, currentMonth - 1, 1));
8738
- 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) {
8739
8948
  return chartWindow;
8740
8949
  }
8741
- if (differenceInMonths(startOfMonth9(chartWindow.start), current) === 0) {
8950
+ if (differenceInMonths(startOfMonth8(chartWindow.start), current) === 0) {
8742
8951
  return {
8743
- start: startOfMonth9(sub2(current, { months: 1 })),
8744
- end: endOfMonth7(add2(current, { months: 11 }))
8952
+ start: startOfMonth8(sub2(current, { months: 1 })),
8953
+ end: endOfMonth6(add2(current, { months: 11 }))
8745
8954
  };
8746
8955
  }
8747
- 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) {
8748
8957
  return {
8749
- start: startOfMonth9(sub2(current, { months: 10 })),
8750
- end: endOfMonth7(add2(current, { months: 2 }))
8958
+ start: startOfMonth8(sub2(current, { months: 10 })),
8959
+ end: endOfMonth6(add2(current, { months: 2 }))
8751
8960
  };
8752
8961
  }
8753
- 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) {
8754
8963
  return {
8755
- start: startOfMonth9(sub2(current, { months: 11 })),
8756
- end: endOfMonth7(add2(current, { months: 1 }))
8964
+ start: startOfMonth8(sub2(current, { months: 11 })),
8965
+ end: endOfMonth6(add2(current, { months: 1 }))
8757
8966
  };
8758
8967
  }
8759
8968
  if (current >= yearAgo) {
8760
8969
  return {
8761
- start: startOfMonth9(yearAgo),
8762
- end: endOfMonth7(today)
8970
+ start: startOfMonth8(yearAgo),
8971
+ end: endOfMonth6(today)
8763
8972
  };
8764
8973
  }
8765
8974
  if (Number(current) > Number(chartWindow.end)) {
8766
8975
  return {
8767
- start: startOfMonth9(sub2(current, { months: 12 })),
8768
- end: endOfMonth7(current)
8976
+ start: startOfMonth8(sub2(current, { months: 12 })),
8977
+ end: endOfMonth6(current)
8769
8978
  };
8770
8979
  }
8771
- if (differenceInMonths(current, startOfMonth9(chartWindow.start)) < 0) {
8980
+ if (differenceInMonths(current, startOfMonth8(chartWindow.start)) < 0) {
8772
8981
  return {
8773
- start: startOfMonth9(current),
8774
- end: endOfMonth7(add2(current, { months: 11 }))
8982
+ start: startOfMonth8(current),
8983
+ end: endOfMonth6(add2(current, { months: 11 }))
8775
8984
  };
8776
8985
  }
8777
8986
  return chartWindow;
@@ -8805,8 +9014,8 @@ var ProfitAndLossChart = () => {
8805
9014
  });
8806
9015
  const [barAnimActive, setBarAnimActive] = useState31(true);
8807
9016
  const [chartWindow, setChartWindow] = useState31({
8808
- start: startOfMonth9(sub2(Date.now(), { months: 11 })),
8809
- end: endOfMonth7(Date.now())
9017
+ start: startOfMonth8(sub2(Date.now(), { months: 11 })),
9018
+ end: endOfMonth6(Date.now())
8810
9019
  });
8811
9020
  const selectionMonth = useMemo9(
8812
9021
  () => ({
@@ -8821,24 +9030,24 @@ var ProfitAndLossChart = () => {
8821
9030
  }
8822
9031
  }, [dateRange]);
8823
9032
  const { data, loaded, pullData } = useProfitAndLossLTM({
8824
- currentDate: startOfMonth9(Date.now())
9033
+ currentDate: startOfMonth8(Date.now())
8825
9034
  });
8826
9035
  const loadingValue = useMemo9(() => getLoadingValue(data), [data]);
8827
9036
  useEffect25(() => {
8828
9037
  if (loaded === "complete" && data) {
8829
9038
  const foundCurrent = data.find(
8830
- (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)
8831
9040
  );
8832
9041
  if (!foundCurrent) {
8833
- const newDate = startOfMonth9(localDateRange.startDate);
9042
+ const newDate = startOfMonth8(localDateRange.startDate);
8834
9043
  pullData(newDate);
8835
9044
  return;
8836
9045
  }
8837
9046
  const foundBefore = data.find(
8838
- (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 }))
8839
9048
  );
8840
9049
  if (!foundBefore) {
8841
- const newDate = startOfMonth9(
9050
+ const newDate = startOfMonth8(
8842
9051
  sub2(localDateRange.startDate, { months: 1 })
8843
9052
  );
8844
9053
  pullData(newDate);
@@ -8870,8 +9079,10 @@ var ProfitAndLossChart = () => {
8870
9079
  name: getMonthName(pnl),
8871
9080
  revenue: pnl?.income || 0,
8872
9081
  revenueUncategorized: pnl?.uncategorizedInflows || 0,
8873
- expenses: -Math.abs((pnl?.income || 0) - (pnl?.netProfit || 0)),
8874
- 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,
8875
9086
  netProfit: pnl?.netProfit || 0,
8876
9087
  selected: !!pnl && pnl.month === selectionMonth.month + 1 && pnl.year === selectionMonth.year,
8877
9088
  year: pnl?.year,
@@ -8890,6 +9101,8 @@ var ProfitAndLossChart = () => {
8890
9101
  name: format(currentDate, compactView ? "LLLLL" : "LLL"),
8891
9102
  revenue: 0,
8892
9103
  revenueUncategorized: 0,
9104
+ operatingExpensesInverse: 0,
9105
+ uncategorizedOutflowsInverse: 0,
8893
9106
  expenses: 0,
8894
9107
  expensesUncategorized: 0,
8895
9108
  netProfit: 0,
@@ -8903,19 +9116,30 @@ var ProfitAndLossChart = () => {
8903
9116
  }
8904
9117
  return loadingData;
8905
9118
  }
8906
- 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(
8907
9131
  (x) => differenceInMonths(
8908
- startOfMonth9(new Date(x.year, x.month - 1, 1)),
9132
+ startOfMonth8(new Date(x.year, x.month - 1, 1)),
8909
9133
  chartWindow.start
8910
9134
  ) >= 0 && differenceInMonths(
8911
- startOfMonth9(new Date(x.year, x.month - 1, 1)),
9135
+ startOfMonth8(new Date(x.year, x.month - 1, 1)),
8912
9136
  chartWindow.start
8913
9137
  ) < 12 && differenceInMonths(
8914
9138
  chartWindow.end,
8915
- startOfMonth9(new Date(x.year, x.month - 1, 1))
9139
+ startOfMonth8(new Date(x.year, x.month - 1, 1))
8916
9140
  ) >= 0 && differenceInMonths(
8917
9141
  chartWindow.end,
8918
- startOfMonth9(new Date(x.year, x.month - 1, 1))
9142
+ startOfMonth8(new Date(x.year, x.month - 1, 1))
8919
9143
  ) <= 12
8920
9144
  ).map((x) => summarizePnL(x));
8921
9145
  }, [selectionMonth, chartWindow, data, loaded, compactView]);
@@ -8929,7 +9153,7 @@ var ProfitAndLossChart = () => {
8929
9153
  if (isMonthAllowed) {
8930
9154
  changeDateRange({
8931
9155
  startDate: new Date(year, month - 1, 1),
8932
- endDate: endOfMonth7(new Date(year, month - 1, 1))
9156
+ endDate: endOfMonth6(new Date(year, month - 1, 1))
8933
9157
  });
8934
9158
  }
8935
9159
  }
@@ -9190,6 +9414,22 @@ var ProfitAndLossChart = () => {
9190
9414
  stackId: "expenses"
9191
9415
  }
9192
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
+ ),
9193
9433
  /* @__PURE__ */ React109.createElement(
9194
9434
  Bar,
9195
9435
  {
@@ -9225,6 +9465,22 @@ var ProfitAndLossChart = () => {
9225
9465
  );
9226
9466
  })
9227
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
+ ),
9228
9484
  /* @__PURE__ */ React109.createElement(
9229
9485
  Bar,
9230
9486
  {
@@ -9301,7 +9557,7 @@ var ProfitAndLossChart = () => {
9301
9557
 
9302
9558
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
9303
9559
  import React110, { useContext as useContext13 } from "react";
9304
- import { endOfMonth as endOfMonth8, startOfMonth as startOfMonth10 } from "date-fns";
9560
+ import { endOfMonth as endOfMonth7, startOfMonth as startOfMonth9 } from "date-fns";
9305
9561
  var ProfitAndLossDatePicker = () => {
9306
9562
  const { business } = useLayerContext();
9307
9563
  const { changeDateRange, dateRange } = useContext13(ProfitAndLoss.Context);
@@ -9314,8 +9570,8 @@ var ProfitAndLossDatePicker = () => {
9314
9570
  onChange: (date) => {
9315
9571
  if (!Array.isArray(date)) {
9316
9572
  changeDateRange({
9317
- startDate: startOfMonth10(date),
9318
- endDate: endOfMonth8(date)
9573
+ startDate: startOfMonth9(date),
9574
+ endDate: endOfMonth7(date)
9319
9575
  });
9320
9576
  }
9321
9577
  },
@@ -10516,7 +10772,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
10516
10772
  };
10517
10773
 
10518
10774
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
10519
- import { endOfMonth as endOfMonth9, startOfMonth as startOfMonth11 } from "date-fns";
10775
+ import { endOfMonth as endOfMonth8, startOfMonth as startOfMonth10 } from "date-fns";
10520
10776
  var PNLContext = createContext6({
10521
10777
  data: void 0,
10522
10778
  filteredDataRevenue: [],
@@ -10527,8 +10783,8 @@ var PNLContext = createContext6({
10527
10783
  isValidating: false,
10528
10784
  error: void 0,
10529
10785
  dateRange: {
10530
- startDate: startOfMonth11(/* @__PURE__ */ new Date()),
10531
- endDate: endOfMonth9(/* @__PURE__ */ new Date())
10786
+ startDate: startOfMonth10(/* @__PURE__ */ new Date()),
10787
+ endDate: endOfMonth8(/* @__PURE__ */ new Date())
10532
10788
  },
10533
10789
  changeDateRange: () => {
10534
10790
  },
@@ -10618,11 +10874,11 @@ var TableProvider = ({ children }) => {
10618
10874
  // src/hooks/useBalanceSheet/useBalanceSheet.tsx
10619
10875
  import { useEffect as useEffect27 } from "react";
10620
10876
  import { format as format3, startOfDay } from "date-fns";
10621
- import useSWR6 from "swr";
10877
+ import useSWR5 from "swr";
10622
10878
  var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
10623
10879
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
10624
10880
  const dateString = format3(startOfDay(date), "yyyy-MM-dd'T'HH:mm:ssXXX");
10625
- const { data, isLoading, isValidating, error, mutate } = useSWR6(
10881
+ const { data, isLoading, isValidating, error, mutate } = useSWR5(
10626
10882
  businessId && dateString && auth?.access_token && `balance-sheet-${businessId}-${dateString}`,
10627
10883
  Layer.getBalanceSheet(apiUrl, auth?.access_token, {
10628
10884
  params: {
@@ -11067,7 +11323,7 @@ var StatementOfCashFlowContext = createContext9({
11067
11323
  // src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
11068
11324
  import { useEffect as useEffect32 } from "react";
11069
11325
  import { format as format5, startOfDay as startOfDay3 } from "date-fns";
11070
- import useSWR7 from "swr";
11326
+ import useSWR6 from "swr";
11071
11327
  var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
11072
11328
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
11073
11329
  const startDateString = format5(
@@ -11075,7 +11331,7 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
11075
11331
  "yyyy-MM-dd'T'HH:mm:ssXXX"
11076
11332
  );
11077
11333
  const endDateString = format5(startOfDay3(endDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
11078
- const { data, isLoading, isValidating, error, mutate } = useSWR7(
11334
+ const { data, isLoading, isValidating, error, mutate } = useSWR6(
11079
11335
  businessId && startDateString && endDateString && auth?.access_token && `statement-of-cash-${businessId}-${startDateString}-${endDateString}`,
11080
11336
  Layer.getStatementOfCashFlow(apiUrl, auth?.access_token, {
11081
11337
  params: {
@@ -11256,7 +11512,7 @@ import React153, { useContext as useContext25, useState as useState44 } from "re
11256
11512
 
11257
11513
  // src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
11258
11514
  import { createContext as createContext10 } from "react";
11259
- import { endOfMonth as endOfMonth10, startOfMonth as startOfMonth12 } from "date-fns";
11515
+ import { endOfMonth as endOfMonth9, startOfMonth as startOfMonth11 } from "date-fns";
11260
11516
  var ChartOfAccountsContext = createContext10(
11261
11517
  {
11262
11518
  data: void 0,
@@ -11279,8 +11535,8 @@ var ChartOfAccountsContext = createContext10(
11279
11535
  submitForm: () => {
11280
11536
  },
11281
11537
  dateRange: {
11282
- startDate: startOfMonth12(/* @__PURE__ */ new Date()),
11283
- endDate: endOfMonth10(/* @__PURE__ */ new Date())
11538
+ startDate: startOfMonth11(/* @__PURE__ */ new Date()),
11539
+ endDate: endOfMonth9(/* @__PURE__ */ new Date())
11284
11540
  },
11285
11541
  changeDateRange: () => {
11286
11542
  }
@@ -11515,8 +11771,8 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
11515
11771
  };
11516
11772
 
11517
11773
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
11518
- import { endOfMonth as endOfMonth11, formatISO as formatISO2, startOfMonth as startOfMonth13 } from "date-fns";
11519
- import useSWR8 from "swr";
11774
+ import { endOfMonth as endOfMonth10, formatISO as formatISO2, startOfMonth as startOfMonth12 } from "date-fns";
11775
+ import useSWR7 from "swr";
11520
11776
  var validate = (formData) => {
11521
11777
  const errors = [];
11522
11778
  const nameError = validateName(formData);
@@ -11596,8 +11852,8 @@ var validateName = (formData) => {
11596
11852
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
11597
11853
  var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
11598
11854
  withDates: false,
11599
- startDate: startOfMonth13(/* @__PURE__ */ new Date()),
11600
- endDate: endOfMonth11(/* @__PURE__ */ new Date())
11855
+ startDate: startOfMonth12(/* @__PURE__ */ new Date()),
11856
+ endDate: endOfMonth10(/* @__PURE__ */ new Date())
11601
11857
  }) => {
11602
11858
  const {
11603
11859
  auth,
@@ -11612,12 +11868,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
11612
11868
  const [sendingForm, setSendingForm] = useState38(false);
11613
11869
  const [apiError, setApiError] = useState38(void 0);
11614
11870
  const [startDate, setStartDate] = useState38(
11615
- initialStartDate ?? startOfMonth13(Date.now())
11871
+ initialStartDate ?? startOfMonth12(Date.now())
11616
11872
  );
11617
11873
  const [endDate, setEndDate] = useState38(
11618
- initialEndDate ?? endOfMonth11(Date.now())
11874
+ initialEndDate ?? endOfMonth10(Date.now())
11619
11875
  );
11620
- const { data, isLoading, isValidating, error, mutate } = useSWR8(
11876
+ const { data, isLoading, isValidating, error, mutate } = useSWR7(
11621
11877
  businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`,
11622
11878
  Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
11623
11879
  params: {
@@ -11826,12 +12082,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
11826
12082
 
11827
12083
  // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
11828
12084
  import { useEffect as useEffect34, useState as useState39 } from "react";
11829
- import useSWR9 from "swr";
12085
+ import useSWR8 from "swr";
11830
12086
  var useLedgerAccounts = () => {
11831
12087
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
11832
12088
  const [accountId, setAccountId] = useState39();
11833
12089
  const [selectedEntryId, setSelectedEntryId] = useState39();
11834
- const { data, isLoading, isValidating, error, mutate } = useSWR9(
12090
+ const { data, isLoading, isValidating, error, mutate } = useSWR8(
11835
12091
  businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
11836
12092
  Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
11837
12093
  params: { businessId, accountId }
@@ -11843,7 +12099,7 @@ var useLedgerAccounts = () => {
11843
12099
  isLoading: isLoadingEntry,
11844
12100
  isValidating: isValdiatingEntry,
11845
12101
  error: errorEntry
11846
- } = useSWR9(
12102
+ } = useSWR8(
11847
12103
  businessId && selectedEntryId && auth?.access_token && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
11848
12104
  Layer.getLedgerAccountsEntry(apiUrl, auth?.access_token, {
11849
12105
  params: { businessId, entryId: selectedEntryId }
@@ -11887,7 +12143,7 @@ import React145, { useContext as useContext21, useState as useState41 } from "re
11887
12143
 
11888
12144
  // src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
11889
12145
  import React139, { useContext as useContext18 } from "react";
11890
- import { endOfMonth as endOfMonth12, startOfMonth as startOfMonth14 } from "date-fns";
12146
+ import { endOfMonth as endOfMonth11, startOfMonth as startOfMonth13 } from "date-fns";
11891
12147
  var ChartOfAccountsDatePicker = () => {
11892
12148
  const { changeDateRange, dateRange } = useContext18(ChartOfAccountsContext);
11893
12149
  return /* @__PURE__ */ React139.createElement(
@@ -11898,8 +12154,8 @@ var ChartOfAccountsDatePicker = () => {
11898
12154
  onChange: (date) => {
11899
12155
  if (!Array.isArray(date)) {
11900
12156
  changeDateRange({
11901
- startDate: startOfMonth14(date),
11902
- endDate: endOfMonth12(date)
12157
+ startDate: startOfMonth13(date),
12158
+ endDate: endOfMonth11(date)
11903
12159
  });
11904
12160
  }
11905
12161
  }
@@ -12938,7 +13194,7 @@ var getAccountIdentifierPayload = (journalLineItem) => {
12938
13194
  };
12939
13195
 
12940
13196
  // src/hooks/useJournal/useJournal.tsx
12941
- import useSWR10 from "swr";
13197
+ import useSWR9 from "swr";
12942
13198
  var useJournal = () => {
12943
13199
  const {
12944
13200
  auth,
@@ -12954,7 +13210,7 @@ var useJournal = () => {
12954
13210
  const [addingEntry, setAddingEntry] = useState45(false);
12955
13211
  const [sendingForm, setSendingForm] = useState45(false);
12956
13212
  const [apiError, setApiError] = useState45(void 0);
12957
- const { data, isLoading, isValidating, error, mutate } = useSWR10(
13213
+ const { data, isLoading, isValidating, error, mutate } = useSWR9(
12958
13214
  businessId && auth?.access_token && `journal-lines-${businessId}`,
12959
13215
  Layer.getJournal(apiUrl, auth?.access_token, {
12960
13216
  params: { businessId }
@@ -13859,11 +14115,11 @@ var TasksContext = createContext14({
13859
14115
 
13860
14116
  // src/hooks/useTasks/useTasks.tsx
13861
14117
  import { useEffect as useEffect40, useState as useState49 } from "react";
13862
- import useSWR11 from "swr";
14118
+ import useSWR10 from "swr";
13863
14119
  var useTasks = () => {
13864
14120
  const [loadedStatus, setLoadedStatus] = useState49("initial");
13865
14121
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
13866
- const { data, isLoading, isValidating, error, mutate } = useSWR11(
14122
+ const { data, isLoading, isValidating, error, mutate } = useSWR10(
13867
14123
  businessId && auth?.access_token && `tasks-${businessId}`,
13868
14124
  Layer.getTasks(apiUrl, auth?.access_token, {
13869
14125
  params: { businessId }
@@ -14844,10 +15100,12 @@ export {
14844
15100
  AccountingOverview,
14845
15101
  BalanceSheet,
14846
15102
  BankTransactions,
15103
+ BankTransactionsProvider,
14847
15104
  BankTransactionsWithLinkedAccounts,
14848
15105
  BookkeepingOverview,
14849
15106
  BookkeepingUpsellBar,
14850
15107
  ChartOfAccounts,
15108
+ DisplayState,
14851
15109
  GeneralLedgerView,
14852
15110
  Journal,
14853
15111
  LayerProvider,