@layerfi/components 0.1.36 → 0.1.38
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/.idea/codeStyles/Project.xml +61 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/layer-react.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/dist/esm/index.js +789 -416
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +55 -35
- package/dist/index.js +700 -327
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +553 -58
- package/dist/styles/index.css.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,10 +33,12 @@ __export(src_exports, {
|
|
|
33
33
|
AccountingOverview: () => AccountingOverview,
|
|
34
34
|
BalanceSheet: () => BalanceSheet,
|
|
35
35
|
BankTransactions: () => BankTransactions,
|
|
36
|
+
BankTransactionsProvider: () => BankTransactionsProvider,
|
|
36
37
|
BankTransactionsWithLinkedAccounts: () => BankTransactionsWithLinkedAccounts,
|
|
37
38
|
BookkeepingOverview: () => BookkeepingOverview,
|
|
38
39
|
BookkeepingUpsellBar: () => BookkeepingUpsellBar,
|
|
39
40
|
ChartOfAccounts: () => ChartOfAccounts,
|
|
41
|
+
DisplayState: () => DisplayState,
|
|
40
42
|
GeneralLedgerView: () => GeneralLedgerView,
|
|
41
43
|
Journal: () => Journal,
|
|
42
44
|
LayerProvider: () => LayerProvider,
|
|
@@ -201,9 +203,11 @@ var getBalanceSheet = get(
|
|
|
201
203
|
var getBankTransactions = get(
|
|
202
204
|
({
|
|
203
205
|
businessId,
|
|
206
|
+
cursor,
|
|
207
|
+
categorized,
|
|
204
208
|
sortBy = "date",
|
|
205
209
|
sortOrder = "DESC"
|
|
206
|
-
}) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
|
|
210
|
+
}) => `/v1/businesses/${businessId}/bank-transactions?${cursor ? `cursor=${cursor}&` : ""}${categorized !== void 0 && categorized !== "" ? `categorized=${categorized}&` : ""}sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
|
|
207
211
|
);
|
|
208
212
|
var categorizeBankTransaction = put(
|
|
209
213
|
({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
|
|
@@ -450,9 +454,9 @@ function useSizeClass() {
|
|
|
450
454
|
const [width] = useWindowSize();
|
|
451
455
|
const sizeClass = (0, import_react2.useMemo)(() => {
|
|
452
456
|
switch (true) {
|
|
453
|
-
case width
|
|
457
|
+
case width <= BREAKPOINTS.MOBILE:
|
|
454
458
|
return "mobile";
|
|
455
|
-
case width
|
|
459
|
+
case width <= BREAKPOINTS.TABLET:
|
|
456
460
|
return "tablet";
|
|
457
461
|
default:
|
|
458
462
|
return "desktop";
|
|
@@ -604,8 +608,25 @@ var DEPENDENCIES = {
|
|
|
604
608
|
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: ALL_TOUCHABLE
|
|
605
609
|
};
|
|
606
610
|
var useDataSync = () => {
|
|
607
|
-
const
|
|
608
|
-
const [
|
|
611
|
+
const initialTimestamp = Date.now();
|
|
612
|
+
const [syncTimestamps, setSyncTimestamps] = (0, import_react7.useState)({
|
|
613
|
+
["BALANCE_SHEET" /* BALANCE_SHEET */]: initialTimestamp,
|
|
614
|
+
["CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */]: initialTimestamp,
|
|
615
|
+
["JOURNAL" /* JOURNAL */]: initialTimestamp,
|
|
616
|
+
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: initialTimestamp,
|
|
617
|
+
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: initialTimestamp,
|
|
618
|
+
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: initialTimestamp,
|
|
619
|
+
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp
|
|
620
|
+
});
|
|
621
|
+
const [readTimestamps, setReadTimestamps] = (0, import_react7.useState)({
|
|
622
|
+
["BALANCE_SHEET" /* BALANCE_SHEET */]: initialTimestamp,
|
|
623
|
+
["CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */]: initialTimestamp,
|
|
624
|
+
["JOURNAL" /* JOURNAL */]: initialTimestamp,
|
|
625
|
+
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: initialTimestamp,
|
|
626
|
+
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: initialTimestamp,
|
|
627
|
+
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: initialTimestamp,
|
|
628
|
+
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp
|
|
629
|
+
});
|
|
609
630
|
const touch = (model) => {
|
|
610
631
|
setSyncTimestamps({
|
|
611
632
|
...syncTimestamps,
|
|
@@ -667,6 +688,25 @@ var import_react11 = __toESM(require("react"));
|
|
|
667
688
|
|
|
668
689
|
// src/contexts/BankTransactionsContext/BankTransactionsContext.tsx
|
|
669
690
|
var import_react9 = require("react");
|
|
691
|
+
|
|
692
|
+
// src/types/bank_transactions.ts
|
|
693
|
+
var Direction = /* @__PURE__ */ ((Direction3) => {
|
|
694
|
+
Direction3["CREDIT"] = "CREDIT";
|
|
695
|
+
Direction3["DEBIT"] = "DEBIT";
|
|
696
|
+
return Direction3;
|
|
697
|
+
})(Direction || {});
|
|
698
|
+
var DisplayState = /* @__PURE__ */ ((DisplayState2) => {
|
|
699
|
+
DisplayState2["review"] = "review";
|
|
700
|
+
DisplayState2["categorized"] = "categorized";
|
|
701
|
+
return DisplayState2;
|
|
702
|
+
})(DisplayState || {});
|
|
703
|
+
|
|
704
|
+
// src/types/categories.ts
|
|
705
|
+
function hasSuggestions(categorization) {
|
|
706
|
+
return categorization.suggestions !== void 0 && categorization.suggestions.length > 0;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/contexts/BankTransactionsContext/BankTransactionsContext.tsx
|
|
670
710
|
var BankTransactionsContext = (0, import_react9.createContext)({
|
|
671
711
|
data: void 0,
|
|
672
712
|
isLoading: false,
|
|
@@ -684,26 +724,18 @@ var BankTransactionsContext = (0, import_react9.createContext)({
|
|
|
684
724
|
pagination: void 0
|
|
685
725
|
},
|
|
686
726
|
updateOneLocal: () => void 0,
|
|
727
|
+
removeAfterCategorize: () => void 0,
|
|
687
728
|
activate: () => void 0,
|
|
688
|
-
display: "review" /* review
|
|
729
|
+
display: "review" /* review */,
|
|
730
|
+
fetchMore: () => {
|
|
731
|
+
},
|
|
732
|
+
hasMore: false
|
|
689
733
|
});
|
|
690
734
|
var useBankTransactionsContext = () => (0, import_react9.useContext)(BankTransactionsContext);
|
|
691
735
|
|
|
692
736
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
693
737
|
var import_react10 = require("react");
|
|
694
738
|
|
|
695
|
-
// src/types/bank_transactions.ts
|
|
696
|
-
var Direction = /* @__PURE__ */ ((Direction3) => {
|
|
697
|
-
Direction3["CREDIT"] = "CREDIT";
|
|
698
|
-
Direction3["DEBIT"] = "DEBIT";
|
|
699
|
-
return Direction3;
|
|
700
|
-
})(Direction || {});
|
|
701
|
-
|
|
702
|
-
// src/types/categories.ts
|
|
703
|
-
function hasSuggestions(categorization) {
|
|
704
|
-
return categorization.suggestions !== void 0 && categorization.suggestions.length > 0;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
739
|
// src/components/BankTransactions/constants.ts
|
|
708
740
|
var CategorizedCategories = [
|
|
709
741
|
"CATEGORIZED" /* CATEGORIZED */,
|
|
@@ -724,7 +756,7 @@ var filterVisibility = (scope, bankTransaction) => {
|
|
|
724
756
|
const inReview = ReviewCategories.includes(
|
|
725
757
|
bankTransaction.categorization_status
|
|
726
758
|
);
|
|
727
|
-
return scope === "
|
|
759
|
+
return scope === "review" /* review */ && inReview || scope === "categorized" /* categorized */ && categorized;
|
|
728
760
|
};
|
|
729
761
|
var isCategorized = (bankTransaction) => CategorizedCategories.includes(bankTransaction.categorization_status);
|
|
730
762
|
|
|
@@ -773,7 +805,7 @@ var applyCategorizationStatusFilter = (data, filter) => {
|
|
|
773
805
|
return data;
|
|
774
806
|
}
|
|
775
807
|
return data?.filter(
|
|
776
|
-
(tx) => filterVisibility(filter, tx) || filter === "
|
|
808
|
+
(tx) => filterVisibility(filter, tx) || filter === "review" /* review */ && tx.recently_categorized || filter === "categorized" /* categorized */ && tx.recently_categorized
|
|
777
809
|
);
|
|
778
810
|
};
|
|
779
811
|
var appplyDateRangeFilter = (data, filter) => {
|
|
@@ -792,8 +824,8 @@ var appplyDateRangeFilter = (data, filter) => {
|
|
|
792
824
|
};
|
|
793
825
|
|
|
794
826
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
795
|
-
var
|
|
796
|
-
var useBankTransactions = () => {
|
|
827
|
+
var import_infinite = __toESM(require("swr/infinite"));
|
|
828
|
+
var useBankTransactions = (params) => {
|
|
797
829
|
const {
|
|
798
830
|
auth,
|
|
799
831
|
businessId,
|
|
@@ -804,36 +836,82 @@ var useBankTransactions = () => {
|
|
|
804
836
|
syncTimestamps,
|
|
805
837
|
hasBeenTouched
|
|
806
838
|
} = useLayerContext();
|
|
807
|
-
const
|
|
808
|
-
const [filters, setTheFilters] = (0, import_react10.useState)(
|
|
809
|
-
|
|
839
|
+
const { scope = void 0 } = params ?? {};
|
|
840
|
+
const [filters, setTheFilters] = (0, import_react10.useState)(
|
|
841
|
+
scope ? { categorizationStatus: scope } : void 0
|
|
842
|
+
);
|
|
810
843
|
const display = (0, import_react10.useMemo)(() => {
|
|
811
|
-
if (filters?.categorizationStatus === "
|
|
844
|
+
if (filters?.categorizationStatus === "review" /* review */) {
|
|
812
845
|
return "review" /* review */;
|
|
813
846
|
}
|
|
814
847
|
return "categorized" /* categorized */;
|
|
815
848
|
}, [filters?.categorizationStatus]);
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
849
|
+
const [active, setActive] = (0, import_react10.useState)(false);
|
|
850
|
+
const [loadingStatus, setLoadingStatus] = (0, import_react10.useState)("initial");
|
|
851
|
+
const getKey = (_index, prevData) => {
|
|
852
|
+
if (!auth?.access_token || !active) {
|
|
853
|
+
return [false, void 0];
|
|
854
|
+
}
|
|
855
|
+
if (!prevData?.meta?.pagination?.cursor) {
|
|
856
|
+
return [
|
|
857
|
+
businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}`,
|
|
858
|
+
void 0
|
|
859
|
+
];
|
|
860
|
+
}
|
|
861
|
+
return [
|
|
862
|
+
businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}-${prevData.meta.pagination.cursor}`,
|
|
863
|
+
prevData.meta.pagination.cursor
|
|
864
|
+
];
|
|
865
|
+
};
|
|
822
866
|
const {
|
|
823
|
-
data:
|
|
867
|
+
data: rawResponseData,
|
|
824
868
|
isLoading,
|
|
825
869
|
isValidating,
|
|
826
870
|
error: responseError,
|
|
827
|
-
mutate
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
871
|
+
mutate,
|
|
872
|
+
size,
|
|
873
|
+
setSize
|
|
874
|
+
} = (0, import_infinite.default)(
|
|
875
|
+
getKey,
|
|
876
|
+
async ([query, nextCursor]) => {
|
|
877
|
+
if (auth?.access_token) {
|
|
878
|
+
return Layer.getBankTransactions(apiUrl, auth?.access_token, {
|
|
879
|
+
params: {
|
|
880
|
+
businessId,
|
|
881
|
+
cursor: nextCursor,
|
|
882
|
+
categorized: filters?.categorizationStatus ? filters?.categorizationStatus === "categorized" /* categorized */ ? "true" : "false" : ""
|
|
883
|
+
}
|
|
884
|
+
}).call(false);
|
|
885
|
+
}
|
|
886
|
+
return {};
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
initialSize: 1,
|
|
890
|
+
revalidateFirstPage: false
|
|
891
|
+
}
|
|
833
892
|
);
|
|
893
|
+
const data = (0, import_react10.useMemo)(() => {
|
|
894
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
895
|
+
return rawResponseData?.map((x) => x?.data).flat().filter((x) => !!x);
|
|
896
|
+
}
|
|
897
|
+
return void 0;
|
|
898
|
+
}, [rawResponseData]);
|
|
899
|
+
const lastMetadata = (0, import_react10.useMemo)(() => {
|
|
900
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
901
|
+
return rawResponseData[rawResponseData.length - 1].meta;
|
|
902
|
+
}
|
|
903
|
+
return void 0;
|
|
904
|
+
}, [rawResponseData]);
|
|
905
|
+
const hasMore = (0, import_react10.useMemo)(() => {
|
|
906
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
907
|
+
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
908
|
+
return Boolean(lastElement.meta?.pagination?.cursor && lastElement.meta?.pagination?.has_more);
|
|
909
|
+
}
|
|
910
|
+
return false;
|
|
911
|
+
}, [rawResponseData]);
|
|
834
912
|
const accountsList = (0, import_react10.useMemo)(
|
|
835
|
-
() => collectAccounts(
|
|
836
|
-
[
|
|
913
|
+
() => data ? collectAccounts(data) : [],
|
|
914
|
+
[data]
|
|
837
915
|
);
|
|
838
916
|
(0, import_react10.useEffect)(() => {
|
|
839
917
|
if (isLoading && loadingStatus === "initial") {
|
|
@@ -854,13 +932,11 @@ var useBankTransactions = () => {
|
|
|
854
932
|
...value ?? {}
|
|
855
933
|
});
|
|
856
934
|
};
|
|
857
|
-
const {
|
|
858
|
-
data = void 0,
|
|
859
|
-
meta: metadata = {},
|
|
860
|
-
error = void 0
|
|
861
|
-
} = responseData || {};
|
|
862
935
|
const filteredData = (0, import_react10.useMemo)(() => {
|
|
863
936
|
let filtered = data;
|
|
937
|
+
if (!filtered) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
864
940
|
if (filters?.amount?.min || filters?.amount?.max) {
|
|
865
941
|
filtered = applyAmountFilter(filtered, filters.amount);
|
|
866
942
|
}
|
|
@@ -880,7 +956,7 @@ var useBankTransactions = () => {
|
|
|
880
956
|
filtered = appplyDateRangeFilter(filtered, filters?.dateRange);
|
|
881
957
|
}
|
|
882
958
|
return filtered;
|
|
883
|
-
}, [filters,
|
|
959
|
+
}, [filters, data]);
|
|
884
960
|
const categorize = (id, newCategory, notify) => {
|
|
885
961
|
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
886
962
|
if (foundBT) {
|
|
@@ -953,14 +1029,31 @@ var useBankTransactions = () => {
|
|
|
953
1029
|
}).finally(() => touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */));
|
|
954
1030
|
};
|
|
955
1031
|
const updateOneLocal = (newBankTransaction) => {
|
|
956
|
-
const updatedData =
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1032
|
+
const updatedData = rawResponseData?.map((page) => {
|
|
1033
|
+
return {
|
|
1034
|
+
...page,
|
|
1035
|
+
data: page.data?.map((bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt)
|
|
1036
|
+
};
|
|
1037
|
+
});
|
|
1038
|
+
mutate(updatedData, { revalidate: false });
|
|
1039
|
+
};
|
|
1040
|
+
const removeAfterCategorize = (bankTransaction) => {
|
|
1041
|
+
const updatedData = rawResponseData?.map((page) => {
|
|
1042
|
+
return {
|
|
1043
|
+
...page,
|
|
1044
|
+
data: page.data?.filter((bt) => bt.id !== bankTransaction.id)
|
|
1045
|
+
};
|
|
1046
|
+
});
|
|
1047
|
+
mutate(updatedData, { revalidate: false });
|
|
960
1048
|
};
|
|
961
1049
|
const refetch = () => {
|
|
962
1050
|
mutate();
|
|
963
1051
|
};
|
|
1052
|
+
const fetchMore = () => {
|
|
1053
|
+
if (hasMore) {
|
|
1054
|
+
setSize(size + 1);
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
964
1057
|
(0, import_react10.useEffect)(() => {
|
|
965
1058
|
if (isLoading || isValidating) {
|
|
966
1059
|
read("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
@@ -973,20 +1066,23 @@ var useBankTransactions = () => {
|
|
|
973
1066
|
}, [syncTimestamps]);
|
|
974
1067
|
return {
|
|
975
1068
|
data: filteredData,
|
|
976
|
-
metadata,
|
|
1069
|
+
metadata: lastMetadata,
|
|
977
1070
|
loadingStatus,
|
|
978
1071
|
isLoading,
|
|
979
1072
|
isValidating,
|
|
980
1073
|
refetch,
|
|
981
|
-
error: responseError
|
|
1074
|
+
error: responseError,
|
|
982
1075
|
categorize,
|
|
983
1076
|
match,
|
|
984
1077
|
updateOneLocal,
|
|
1078
|
+
removeAfterCategorize,
|
|
985
1079
|
filters,
|
|
986
1080
|
setFilters,
|
|
987
1081
|
accountsList,
|
|
988
1082
|
activate,
|
|
989
|
-
display
|
|
1083
|
+
display,
|
|
1084
|
+
fetchMore,
|
|
1085
|
+
hasMore
|
|
990
1086
|
};
|
|
991
1087
|
};
|
|
992
1088
|
|
|
@@ -1239,7 +1335,7 @@ var hslToHex = (hsl) => {
|
|
|
1239
1335
|
|
|
1240
1336
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
1241
1337
|
var import_date_fns2 = require("date-fns");
|
|
1242
|
-
var
|
|
1338
|
+
var import_swr = __toESM(require("swr"));
|
|
1243
1339
|
var reducer = (state, action) => {
|
|
1244
1340
|
switch (action.type) {
|
|
1245
1341
|
case "LayerContext.setAuth" /* setAuth */:
|
|
@@ -1279,10 +1375,20 @@ var LayerEnvironment = {
|
|
|
1279
1375
|
scope: "https://api.layerfi.com/production",
|
|
1280
1376
|
apiUrl: "https://api.layerfi.com"
|
|
1281
1377
|
},
|
|
1378
|
+
sandbox: {
|
|
1379
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1380
|
+
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1381
|
+
apiUrl: "https://sandbox.layerfi.com"
|
|
1382
|
+
},
|
|
1282
1383
|
staging: {
|
|
1283
1384
|
url: "https://auth.layerfi.com/oauth2/token",
|
|
1284
1385
|
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1285
1386
|
apiUrl: "https://sandbox.layerfi.com"
|
|
1387
|
+
},
|
|
1388
|
+
internalStaging: {
|
|
1389
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1390
|
+
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1391
|
+
apiUrl: "https://staging.layerfi.com"
|
|
1286
1392
|
}
|
|
1287
1393
|
};
|
|
1288
1394
|
var LayerProvider = ({
|
|
@@ -1324,7 +1430,7 @@ var LayerProvider = ({
|
|
|
1324
1430
|
toasts: []
|
|
1325
1431
|
});
|
|
1326
1432
|
const { touch, syncTimestamps, read, readTimestamps, hasBeenTouched } = useDataSync();
|
|
1327
|
-
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0,
|
|
1433
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr.default)(
|
|
1328
1434
|
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns2.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
1329
1435
|
Layer.authenticate({
|
|
1330
1436
|
appId,
|
|
@@ -1359,7 +1465,7 @@ var LayerProvider = ({
|
|
|
1359
1465
|
});
|
|
1360
1466
|
}
|
|
1361
1467
|
}, [businessAccessToken, auth?.access_token]);
|
|
1362
|
-
(0,
|
|
1468
|
+
(0, import_swr.default)(
|
|
1363
1469
|
businessId && state.auth?.access_token && `categories-${businessId}`,
|
|
1364
1470
|
Layer.getCategories(apiUrl, state.auth?.access_token, {
|
|
1365
1471
|
params: { businessId }
|
|
@@ -1376,7 +1482,7 @@ var LayerProvider = ({
|
|
|
1376
1482
|
}
|
|
1377
1483
|
}
|
|
1378
1484
|
);
|
|
1379
|
-
(0,
|
|
1485
|
+
(0, import_swr.default)(
|
|
1380
1486
|
businessId && state?.auth?.access_token && `business-${businessId}`,
|
|
1381
1487
|
Layer.getBusiness(apiUrl, state?.auth?.access_token, {
|
|
1382
1488
|
params: { businessId }
|
|
@@ -1465,7 +1571,7 @@ var LayerProvider = ({
|
|
|
1465
1571
|
payload: { onboardingStep: value }
|
|
1466
1572
|
});
|
|
1467
1573
|
const drawerContextData = useDrawer();
|
|
1468
|
-
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1574
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_swr.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react12.default.createElement(
|
|
1469
1575
|
LayerContext.Provider,
|
|
1470
1576
|
{
|
|
1471
1577
|
value: {
|
|
@@ -1632,7 +1738,7 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
|
|
|
1632
1738
|
];
|
|
1633
1739
|
|
|
1634
1740
|
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
1635
|
-
var
|
|
1741
|
+
var import_swr2 = __toESM(require("swr"));
|
|
1636
1742
|
var DEBUG = true;
|
|
1637
1743
|
var USE_MOCK_RESPONSE_DATA = false;
|
|
1638
1744
|
var useLinkedAccounts = () => {
|
|
@@ -1656,7 +1762,7 @@ var useLinkedAccounts = () => {
|
|
|
1656
1762
|
isValidating,
|
|
1657
1763
|
error: responseError,
|
|
1658
1764
|
mutate
|
|
1659
|
-
} = (0,
|
|
1765
|
+
} = (0, import_swr2.default)(
|
|
1660
1766
|
businessId && auth?.access_token && `linked-accounts-${businessId}`,
|
|
1661
1767
|
Layer.getLinkedAccounts(apiUrl, auth?.access_token, {
|
|
1662
1768
|
params: { businessId }
|
|
@@ -2177,15 +2283,13 @@ var countTransactionsToReview = ({
|
|
|
2177
2283
|
};
|
|
2178
2284
|
return transactions.filter((tx) => {
|
|
2179
2285
|
try {
|
|
2180
|
-
return filterVisibility("
|
|
2286
|
+
return filterVisibility("review" /* review */, tx) && (0, import_date_fns3.isWithinInterval)((0, import_date_fns3.parseISO)(tx.date), dateRangeInterval);
|
|
2181
2287
|
} catch (_err) {
|
|
2182
2288
|
return false;
|
|
2183
2289
|
}
|
|
2184
2290
|
}).length;
|
|
2185
2291
|
}
|
|
2186
|
-
return transactions.filter(
|
|
2187
|
-
(tx) => filterVisibility("TO_REVIEW" /* TO_REVIEW */, tx)
|
|
2188
|
-
).length;
|
|
2292
|
+
return transactions.filter((tx) => filterVisibility("review" /* review */, tx)).length;
|
|
2189
2293
|
}
|
|
2190
2294
|
return 0;
|
|
2191
2295
|
};
|
|
@@ -3245,7 +3349,9 @@ var ConnectAccount = ({
|
|
|
3245
3349
|
onTransactionsToReviewClick
|
|
3246
3350
|
}) => {
|
|
3247
3351
|
const { addConnection } = (0, import_react38.useContext)(LinkedAccountsContext);
|
|
3248
|
-
const { data, isLoading } = useBankTransactions(
|
|
3352
|
+
const { data, isLoading } = useBankTransactions({
|
|
3353
|
+
scope: "review" /* review */
|
|
3354
|
+
});
|
|
3249
3355
|
const transactionsToReview = (0, import_react38.useMemo)(
|
|
3250
3356
|
() => countTransactionsToReview({ transactions: data }),
|
|
3251
3357
|
[data, isLoading]
|
|
@@ -3861,15 +3967,21 @@ var LinkedAccountThumb = ({
|
|
|
3861
3967
|
}) => {
|
|
3862
3968
|
const linkedAccountThumbClassName = (0, import_classnames19.default)(
|
|
3863
3969
|
"Layer__linked-account-thumb",
|
|
3864
|
-
asWidget && "--as-widget"
|
|
3970
|
+
asWidget && "--as-widget",
|
|
3971
|
+
account.is_syncing && "--is-syncing",
|
|
3972
|
+
account.is_syncing && "skeleton-loader"
|
|
3973
|
+
);
|
|
3974
|
+
const linkedAccountInfoClassName = (0, import_classnames19.default)(
|
|
3975
|
+
"topbar",
|
|
3976
|
+
account.is_syncing && "--is-syncing"
|
|
3865
3977
|
);
|
|
3866
3978
|
let bankBalance;
|
|
3867
3979
|
if (pillConfig) {
|
|
3868
3980
|
bankBalance = /* @__PURE__ */ import_react46.default.createElement(LinkedAccountPill, { text: pillConfig.text, config: pillConfig.config });
|
|
3869
3981
|
} else {
|
|
3870
|
-
bankBalance = /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-balance" },
|
|
3982
|
+
bankBalance = /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.latest_balance_timestamp?.balance)}`);
|
|
3871
3983
|
}
|
|
3872
|
-
return /* @__PURE__ */ import_react46.default.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ import_react46.default.createElement("div", { className:
|
|
3984
|
+
return /* @__PURE__ */ import_react46.default.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ import_react46.default.createElement("div", { className: linkedAccountInfoClassName }, /* @__PURE__ */ import_react46.default.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ import_react46.default.createElement(Text, { as: "div", className: "account-name" }, account.external_account_name), !asWidget && account.mask && /* @__PURE__ */ import_react46.default.createElement(AccountNumber, { accountNumber: account.mask }), /* @__PURE__ */ import_react46.default.createElement(
|
|
3873
3985
|
Text,
|
|
3874
3986
|
{
|
|
3875
3987
|
as: "span",
|
|
@@ -3885,7 +3997,7 @@ var LinkedAccountThumb = ({
|
|
|
3885
3997
|
src: `data:image/png;base64,${account.institution.logo}`,
|
|
3886
3998
|
alt: account.institution?.name
|
|
3887
3999
|
}
|
|
3888
|
-
) : /* @__PURE__ */ import_react46.default.createElement(InstitutionIcon_default, null))), !asWidget && /* @__PURE__ */ import_react46.default.createElement("div", { className: "middlebar" }, /* @__PURE__ */ import_react46.default.createElement(
|
|
4000
|
+
) : /* @__PURE__ */ import_react46.default.createElement(InstitutionIcon_default, null))), account.is_syncing ? /* @__PURE__ */ import_react46.default.createElement("div", { className: "loadingbar" }, /* @__PURE__ */ import_react46.default.createElement("div", { className: "loading-text Layer__text--sm" }, /* @__PURE__ */ import_react46.default.createElement("div", null, "Syncing account data"), /* @__PURE__ */ import_react46.default.createElement("div", { className: "syncing-data-description" }, "This may take up to 5 minutes")), /* @__PURE__ */ import_react46.default.createElement("div", { className: "loading-wrapper" }, /* @__PURE__ */ import_react46.default.createElement(Loader_default, { size: 11, className: "Layer__anim--rotating" }))) : /* @__PURE__ */ import_react46.default.createElement(import_react46.default.Fragment, null, !asWidget && /* @__PURE__ */ import_react46.default.createElement("div", { className: "middlebar" }, /* @__PURE__ */ import_react46.default.createElement(
|
|
3889
4001
|
Text,
|
|
3890
4002
|
{
|
|
3891
4003
|
as: "span",
|
|
@@ -3901,7 +4013,7 @@ var LinkedAccountThumb = ({
|
|
|
3901
4013
|
size: "sm"
|
|
3902
4014
|
},
|
|
3903
4015
|
"Ledger balance"
|
|
3904
|
-
), /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-balance" },
|
|
4016
|
+
), /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-balance" }, `${centsToDollars(account.current_ledger_balance)}`))));
|
|
3905
4017
|
};
|
|
3906
4018
|
|
|
3907
4019
|
// src/components/LinkedAccounts/LinkedAccountsContent.tsx
|
|
@@ -5595,9 +5707,20 @@ var ExpandedBankTransactionRow = (0, import_react65.forwardRef)(
|
|
|
5595
5707
|
});
|
|
5596
5708
|
setSplitFormError(void 0);
|
|
5597
5709
|
};
|
|
5710
|
+
const sanitizeNumberInput = (input) => {
|
|
5711
|
+
let sanitized = input.replace(/[^0-9.]/g, "");
|
|
5712
|
+
let parts = sanitized.split(".");
|
|
5713
|
+
if (parts.length > 2) {
|
|
5714
|
+
sanitized = parts[0] + "." + parts.slice(1).join("");
|
|
5715
|
+
}
|
|
5716
|
+
if (parts.length === 2) {
|
|
5717
|
+
sanitized = parts[0] + "." + parts[1].slice(0, 2);
|
|
5718
|
+
}
|
|
5719
|
+
return sanitized;
|
|
5720
|
+
};
|
|
5598
5721
|
const updateAmounts = (rowNumber) => (event) => {
|
|
5599
|
-
const
|
|
5600
|
-
const
|
|
5722
|
+
const newDisplaying = sanitizeNumberInput(event.target.value);
|
|
5723
|
+
const newAmount = Number(newDisplaying);
|
|
5601
5724
|
const splitTotal = rowState.splits.reduce((sum, split, index) => {
|
|
5602
5725
|
const amount = index === 0 ? 0 : index === rowNumber ? newAmount : split.amount;
|
|
5603
5726
|
return sum + amount;
|
|
@@ -6034,7 +6157,6 @@ var BankTransactionRow = ({
|
|
|
6034
6157
|
}) => {
|
|
6035
6158
|
const expandedRowRef = (0, import_react67.useRef)(null);
|
|
6036
6159
|
const [showRetry, setShowRetry] = (0, import_react67.useState)(false);
|
|
6037
|
-
const [removed, setRemoved] = (0, import_react67.useState)(false);
|
|
6038
6160
|
const {
|
|
6039
6161
|
filters,
|
|
6040
6162
|
categorize: categorizeBankTransaction2,
|
|
@@ -6075,6 +6197,13 @@ var BankTransactionRow = ({
|
|
|
6075
6197
|
setShowRetry(true);
|
|
6076
6198
|
}
|
|
6077
6199
|
}, [bankTransaction.error]);
|
|
6200
|
+
(0, import_react67.useEffect)(() => {
|
|
6201
|
+
if (editable && bankTransaction.recently_categorized) {
|
|
6202
|
+
setTimeout(() => {
|
|
6203
|
+
removeTransaction(bankTransaction);
|
|
6204
|
+
}, 300);
|
|
6205
|
+
}
|
|
6206
|
+
}, [bankTransaction.recently_categorized]);
|
|
6078
6207
|
const save = async () => {
|
|
6079
6208
|
if (open && expandedRowRef?.current) {
|
|
6080
6209
|
expandedRowRef?.current?.save();
|
|
@@ -6097,9 +6226,6 @@ var BankTransactionRow = ({
|
|
|
6097
6226
|
});
|
|
6098
6227
|
setOpen(false);
|
|
6099
6228
|
};
|
|
6100
|
-
if (removed) {
|
|
6101
|
-
return null;
|
|
6102
|
-
}
|
|
6103
6229
|
const categorized = isCategorized(bankTransaction);
|
|
6104
6230
|
const className = "Layer__bank-transaction-row";
|
|
6105
6231
|
const openClassName = open ? `${className}--expanded` : "";
|
|
@@ -6110,178 +6236,160 @@ var BankTransactionRow = ({
|
|
|
6110
6236
|
initialLoad ? "initial-load" : "",
|
|
6111
6237
|
showComponent ? "show" : ""
|
|
6112
6238
|
);
|
|
6113
|
-
return /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement(
|
|
6114
|
-
"
|
|
6239
|
+
return /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement("tr", { className: rowClassName }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6240
|
+
"td",
|
|
6115
6241
|
{
|
|
6116
|
-
className:
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6242
|
+
className: "Layer__table-cell Layer__bank-transaction-table__date-col",
|
|
6243
|
+
...openRow
|
|
6244
|
+
},
|
|
6245
|
+
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns8.format)((0, import_date_fns8.parseISO)(bankTransaction.date), dateFormat))
|
|
6246
|
+
), /* @__PURE__ */ import_react67.default.createElement(
|
|
6247
|
+
"td",
|
|
6248
|
+
{
|
|
6249
|
+
className: "Layer__table-cell Layer__bank-transactions__tx-col",
|
|
6250
|
+
...openRow
|
|
6251
|
+
},
|
|
6252
|
+
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6253
|
+
Text,
|
|
6254
|
+
{
|
|
6255
|
+
as: "span",
|
|
6256
|
+
className: "Layer__bank-transactions__tx-text",
|
|
6257
|
+
withTooltip: "whenTruncated" /* whenTruncated */,
|
|
6258
|
+
tooltipOptions: {
|
|
6259
|
+
contentClassName: "Layer__bank-transactions__tx-tooltip"
|
|
6123
6260
|
}
|
|
6124
|
-
}
|
|
6261
|
+
},
|
|
6262
|
+
bankTransaction.counterparty_name ?? bankTransaction.description
|
|
6263
|
+
))
|
|
6264
|
+
), /* @__PURE__ */ import_react67.default.createElement(
|
|
6265
|
+
"td",
|
|
6266
|
+
{
|
|
6267
|
+
className: "Layer__table-cell Layer__bank-transactions__account-col",
|
|
6268
|
+
...openRow
|
|
6125
6269
|
},
|
|
6126
|
-
/* @__PURE__ */ import_react67.default.createElement(
|
|
6127
|
-
|
|
6270
|
+
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6271
|
+
Text,
|
|
6128
6272
|
{
|
|
6129
|
-
|
|
6130
|
-
|
|
6273
|
+
as: "span",
|
|
6274
|
+
className: "Layer__bank-transactions__account-text",
|
|
6275
|
+
withTooltip: "whenTruncated" /* whenTruncated */
|
|
6131
6276
|
},
|
|
6132
|
-
|
|
6133
|
-
)
|
|
6277
|
+
bankTransaction.account_name ?? ""
|
|
6278
|
+
))
|
|
6279
|
+
), /* @__PURE__ */ import_react67.default.createElement(
|
|
6280
|
+
"td",
|
|
6281
|
+
{
|
|
6282
|
+
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"}`,
|
|
6283
|
+
...openRow
|
|
6284
|
+
},
|
|
6285
|
+
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
6286
|
+
), /* @__PURE__ */ import_react67.default.createElement(
|
|
6287
|
+
"td",
|
|
6288
|
+
{
|
|
6289
|
+
className: (0, import_classnames33.default)(
|
|
6290
|
+
"Layer__table-cell",
|
|
6291
|
+
"Layer__table-cell__category-col",
|
|
6292
|
+
`${className}__actions-cell`,
|
|
6293
|
+
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
6294
|
+
)
|
|
6295
|
+
},
|
|
6134
6296
|
/* @__PURE__ */ import_react67.default.createElement(
|
|
6135
|
-
"
|
|
6297
|
+
"span",
|
|
6136
6298
|
{
|
|
6137
|
-
className:
|
|
6138
|
-
...openRow
|
|
6299
|
+
className: `${className}__actions-container Layer__table-cell-content`
|
|
6139
6300
|
},
|
|
6140
|
-
|
|
6141
|
-
|
|
6301
|
+
!categorized && !open ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6302
|
+
CategorySelect,
|
|
6142
6303
|
{
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6304
|
+
bankTransaction,
|
|
6305
|
+
name: `category-${bankTransaction.id}`,
|
|
6306
|
+
value: selectedCategory,
|
|
6307
|
+
onChange: (category) => {
|
|
6308
|
+
setSelectedCategory(category);
|
|
6309
|
+
setShowRetry(false);
|
|
6310
|
+
},
|
|
6311
|
+
disabled: bankTransaction.processing
|
|
6312
|
+
}
|
|
6313
|
+
) : null,
|
|
6314
|
+
categorized && !open ? /* @__PURE__ */ import_react67.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement(
|
|
6315
|
+
Badge,
|
|
6316
|
+
{
|
|
6317
|
+
icon: /* @__PURE__ */ import_react67.default.createElement(Scissors_default, { size: 11 }),
|
|
6318
|
+
tooltip: /* @__PURE__ */ import_react67.default.createElement(
|
|
6319
|
+
SplitTooltipDetails,
|
|
6320
|
+
{
|
|
6321
|
+
classNamePrefix: className,
|
|
6322
|
+
category: bankTransaction.category
|
|
6323
|
+
}
|
|
6324
|
+
)
|
|
6149
6325
|
},
|
|
6150
|
-
|
|
6151
|
-
))
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
},
|
|
6159
|
-
|
|
6326
|
+
"Split"
|
|
6327
|
+
), /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement(
|
|
6328
|
+
MatchBadge,
|
|
6329
|
+
{
|
|
6330
|
+
classNamePrefix: className,
|
|
6331
|
+
bankTransaction,
|
|
6332
|
+
dateFormat
|
|
6333
|
+
}
|
|
6334
|
+
), /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns8.format)(
|
|
6335
|
+
(0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
6336
|
+
dateFormat
|
|
6337
|
+
)}, ${bankTransaction.match?.details?.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
6338
|
+
!categorized && !open && showRetry ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6339
|
+
RetryButton,
|
|
6340
|
+
{
|
|
6341
|
+
onClick: () => {
|
|
6342
|
+
if (!bankTransaction.processing) {
|
|
6343
|
+
save();
|
|
6344
|
+
}
|
|
6345
|
+
},
|
|
6346
|
+
className: "Layer__bank-transaction__retry-btn",
|
|
6347
|
+
processing: bankTransaction.processing,
|
|
6348
|
+
error: "Approval failed. Check connection and retry in few seconds."
|
|
6349
|
+
},
|
|
6350
|
+
"Retry"
|
|
6351
|
+
) : null,
|
|
6352
|
+
open && bankTransaction.error ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6160
6353
|
Text,
|
|
6161
6354
|
{
|
|
6162
6355
|
as: "span",
|
|
6163
|
-
|
|
6164
|
-
|
|
6356
|
+
size: "md" /* md */,
|
|
6357
|
+
className: "Layer__unsaved-info"
|
|
6165
6358
|
},
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
{
|
|
6172
|
-
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"}`,
|
|
6173
|
-
...openRow
|
|
6174
|
-
},
|
|
6175
|
-
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
6176
|
-
),
|
|
6177
|
-
/* @__PURE__ */ import_react67.default.createElement(
|
|
6178
|
-
"td",
|
|
6179
|
-
{
|
|
6180
|
-
className: (0, import_classnames33.default)(
|
|
6181
|
-
"Layer__table-cell",
|
|
6182
|
-
"Layer__table-cell__category-col",
|
|
6183
|
-
`${className}__actions-cell`,
|
|
6184
|
-
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
6185
|
-
)
|
|
6186
|
-
},
|
|
6187
|
-
/* @__PURE__ */ import_react67.default.createElement(
|
|
6188
|
-
"span",
|
|
6359
|
+
/* @__PURE__ */ import_react67.default.createElement("span", null, "Unsaved"),
|
|
6360
|
+
/* @__PURE__ */ import_react67.default.createElement(AlertCircle_default, { size: 12 })
|
|
6361
|
+
) : null,
|
|
6362
|
+
!categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6363
|
+
SubmitButton,
|
|
6189
6364
|
{
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
{
|
|
6195
|
-
bankTransaction,
|
|
6196
|
-
name: `category-${bankTransaction.id}`,
|
|
6197
|
-
value: selectedCategory,
|
|
6198
|
-
onChange: (category) => {
|
|
6199
|
-
setSelectedCategory(category);
|
|
6200
|
-
setShowRetry(false);
|
|
6201
|
-
},
|
|
6202
|
-
disabled: bankTransaction.processing
|
|
6203
|
-
}
|
|
6204
|
-
) : null,
|
|
6205
|
-
categorized && !open ? /* @__PURE__ */ import_react67.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement(
|
|
6206
|
-
Badge,
|
|
6207
|
-
{
|
|
6208
|
-
icon: /* @__PURE__ */ import_react67.default.createElement(Scissors_default, { size: 11 }),
|
|
6209
|
-
tooltip: /* @__PURE__ */ import_react67.default.createElement(
|
|
6210
|
-
SplitTooltipDetails,
|
|
6211
|
-
{
|
|
6212
|
-
classNamePrefix: className,
|
|
6213
|
-
category: bankTransaction.category
|
|
6214
|
-
}
|
|
6215
|
-
)
|
|
6216
|
-
},
|
|
6217
|
-
"Split"
|
|
6218
|
-
), /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, /* @__PURE__ */ import_react67.default.createElement(
|
|
6219
|
-
MatchBadge,
|
|
6220
|
-
{
|
|
6221
|
-
classNamePrefix: className,
|
|
6222
|
-
bankTransaction,
|
|
6223
|
-
dateFormat
|
|
6224
|
-
}
|
|
6225
|
-
), /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns8.format)(
|
|
6226
|
-
(0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
6227
|
-
dateFormat
|
|
6228
|
-
)}, ${bankTransaction.match?.details?.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react67.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
6229
|
-
!categorized && !open && showRetry ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6230
|
-
RetryButton,
|
|
6231
|
-
{
|
|
6232
|
-
onClick: () => {
|
|
6233
|
-
if (!bankTransaction.processing) {
|
|
6234
|
-
save();
|
|
6235
|
-
}
|
|
6236
|
-
},
|
|
6237
|
-
className: "Layer__bank-transaction__retry-btn",
|
|
6238
|
-
processing: bankTransaction.processing,
|
|
6239
|
-
error: "Approval failed. Check connection and retry in few seconds."
|
|
6240
|
-
},
|
|
6241
|
-
"Retry"
|
|
6242
|
-
) : null,
|
|
6243
|
-
open && bankTransaction.error ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6244
|
-
Text,
|
|
6245
|
-
{
|
|
6246
|
-
as: "span",
|
|
6247
|
-
size: "md" /* md */,
|
|
6248
|
-
className: "Layer__unsaved-info"
|
|
6249
|
-
},
|
|
6250
|
-
/* @__PURE__ */ import_react67.default.createElement("span", null, "Unsaved"),
|
|
6251
|
-
/* @__PURE__ */ import_react67.default.createElement(AlertCircle_default, { size: 12 })
|
|
6252
|
-
) : null,
|
|
6253
|
-
!categorized && (open || !open && !showRetry) || categorized && open ? /* @__PURE__ */ import_react67.default.createElement(
|
|
6254
|
-
SubmitButton,
|
|
6255
|
-
{
|
|
6256
|
-
onClick: () => {
|
|
6257
|
-
if (!bankTransaction.processing) {
|
|
6258
|
-
save();
|
|
6259
|
-
}
|
|
6260
|
-
},
|
|
6261
|
-
className: "Layer__bank-transaction__submit-btn",
|
|
6262
|
-
processing: bankTransaction.processing,
|
|
6263
|
-
active: open,
|
|
6264
|
-
action: categorized ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
6365
|
+
onClick: () => {
|
|
6366
|
+
if (!bankTransaction.processing) {
|
|
6367
|
+
save();
|
|
6368
|
+
}
|
|
6265
6369
|
},
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6370
|
+
className: "Layer__bank-transaction__submit-btn",
|
|
6371
|
+
processing: bankTransaction.processing,
|
|
6372
|
+
active: open,
|
|
6373
|
+
action: categorized ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
6374
|
+
},
|
|
6375
|
+
categorized ? "Update" : "Approve"
|
|
6376
|
+
) : null,
|
|
6377
|
+
/* @__PURE__ */ import_react67.default.createElement(
|
|
6378
|
+
IconButton,
|
|
6379
|
+
{
|
|
6380
|
+
onClick: toggleOpen,
|
|
6381
|
+
className: "Layer__bank-transaction-row__expand-button",
|
|
6382
|
+
active: open,
|
|
6383
|
+
icon: /* @__PURE__ */ import_react67.default.createElement(
|
|
6384
|
+
ChevronDownFill_default,
|
|
6385
|
+
{
|
|
6386
|
+
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
6387
|
+
}
|
|
6388
|
+
)
|
|
6389
|
+
}
|
|
6282
6390
|
)
|
|
6283
6391
|
)
|
|
6284
|
-
), /* @__PURE__ */ import_react67.default.createElement("tr", null, /* @__PURE__ */ import_react67.default.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6392
|
+
)), /* @__PURE__ */ import_react67.default.createElement("tr", null, /* @__PURE__ */ import_react67.default.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6285
6393
|
ExpandedBankTransactionRow,
|
|
6286
6394
|
{
|
|
6287
6395
|
ref: expandedRowRef,
|
|
@@ -6343,11 +6451,11 @@ var BankTransactionListItem = ({
|
|
|
6343
6451
|
editable,
|
|
6344
6452
|
showDescriptions,
|
|
6345
6453
|
showReceiptUploads,
|
|
6346
|
-
containerWidth
|
|
6454
|
+
containerWidth,
|
|
6455
|
+
removeTransaction
|
|
6347
6456
|
}) => {
|
|
6348
6457
|
const expandedRowRef = (0, import_react69.useRef)(null);
|
|
6349
6458
|
const [showRetry, setShowRetry] = (0, import_react69.useState)(false);
|
|
6350
|
-
const [removed, setRemoved] = (0, import_react69.useState)(false);
|
|
6351
6459
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactionsContext();
|
|
6352
6460
|
const [selectedCategory, setSelectedCategory] = (0, import_react69.useState)(
|
|
6353
6461
|
getDefaultSelectedCategory(bankTransaction)
|
|
@@ -6369,6 +6477,13 @@ var BankTransactionListItem = ({
|
|
|
6369
6477
|
setShowRetry(true);
|
|
6370
6478
|
}
|
|
6371
6479
|
}, [bankTransaction.error]);
|
|
6480
|
+
(0, import_react69.useEffect)(() => {
|
|
6481
|
+
if (editable && bankTransaction.recently_categorized) {
|
|
6482
|
+
setTimeout(() => {
|
|
6483
|
+
removeTransaction(bankTransaction);
|
|
6484
|
+
}, 300);
|
|
6485
|
+
}
|
|
6486
|
+
}, [bankTransaction.recently_categorized]);
|
|
6372
6487
|
const save = () => {
|
|
6373
6488
|
if (open && expandedRowRef?.current) {
|
|
6374
6489
|
expandedRowRef?.current?.save();
|
|
@@ -6386,9 +6501,6 @@ var BankTransactionListItem = ({
|
|
|
6386
6501
|
category: getCategorizePayload(selectedCategory)
|
|
6387
6502
|
});
|
|
6388
6503
|
};
|
|
6389
|
-
if (removed) {
|
|
6390
|
-
return null;
|
|
6391
|
-
}
|
|
6392
6504
|
const categorized = isCategorized(bankTransaction);
|
|
6393
6505
|
const className = "Layer__bank-transaction-list-item";
|
|
6394
6506
|
const openClassName = open ? `${className}--expanded` : "";
|
|
@@ -6587,7 +6699,15 @@ var BusinessForm = ({ bankTransaction }) => {
|
|
|
6587
6699
|
onClick: onCategorySelect,
|
|
6588
6700
|
selected: selectedCategory
|
|
6589
6701
|
}
|
|
6590
|
-
), options.length === 0 ? /* @__PURE__ */ import_react71.default.createElement(
|
|
6702
|
+
), options.length === 0 ? /* @__PURE__ */ import_react71.default.createElement(
|
|
6703
|
+
Button,
|
|
6704
|
+
{
|
|
6705
|
+
onClick: openDrawer,
|
|
6706
|
+
fullWidth: true,
|
|
6707
|
+
variant: "secondary" /* secondary */
|
|
6708
|
+
},
|
|
6709
|
+
"Select category"
|
|
6710
|
+
) : null, options.length > 0 ? /* @__PURE__ */ import_react71.default.createElement(
|
|
6591
6711
|
Button,
|
|
6592
6712
|
{
|
|
6593
6713
|
onClick: save,
|
|
@@ -7008,8 +7128,12 @@ var BankTransactionMobileListItem = ({
|
|
|
7008
7128
|
}, [transactionIdToOpen]);
|
|
7009
7129
|
(0, import_react78.useEffect)(() => {
|
|
7010
7130
|
if (!removeAnim && bankTransaction.recently_categorized) {
|
|
7011
|
-
|
|
7012
|
-
|
|
7131
|
+
if (editable) {
|
|
7132
|
+
setRemoveAnim(true);
|
|
7133
|
+
openNext();
|
|
7134
|
+
} else {
|
|
7135
|
+
close();
|
|
7136
|
+
}
|
|
7013
7137
|
}
|
|
7014
7138
|
}, [
|
|
7015
7139
|
bankTransaction.recently_categorized,
|
|
@@ -7036,6 +7160,13 @@ var BankTransactionMobileListItem = ({
|
|
|
7036
7160
|
setShowComponent(true);
|
|
7037
7161
|
}
|
|
7038
7162
|
}, []);
|
|
7163
|
+
(0, import_react78.useEffect)(() => {
|
|
7164
|
+
if (editable && bankTransaction.recently_categorized) {
|
|
7165
|
+
setTimeout(() => {
|
|
7166
|
+
removeTransaction(bankTransaction);
|
|
7167
|
+
}, 300);
|
|
7168
|
+
}
|
|
7169
|
+
}, [bankTransaction.recently_categorized]);
|
|
7039
7170
|
const onChangePurpose = (event) => setPurpose(event.target.value);
|
|
7040
7171
|
const categorized = isCategorized(bankTransaction);
|
|
7041
7172
|
const className = "Layer__bank-transaction-mobile-list-item";
|
|
@@ -7051,18 +7182,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7051
7182
|
{
|
|
7052
7183
|
ref: itemRef,
|
|
7053
7184
|
className: rowClassName,
|
|
7054
|
-
"data-item": bankTransaction.id
|
|
7055
|
-
onTransitionEnd: ({ propertyName }) => {
|
|
7056
|
-
if (propertyName === "opacity") {
|
|
7057
|
-
close();
|
|
7058
|
-
if (editable) {
|
|
7059
|
-
setRemoveAnim(false);
|
|
7060
|
-
setTimeout(() => {
|
|
7061
|
-
removeTransaction(bankTransaction.id);
|
|
7062
|
-
}, 500);
|
|
7063
|
-
}
|
|
7064
|
-
}
|
|
7065
|
-
}
|
|
7185
|
+
"data-item": bankTransaction.id
|
|
7066
7186
|
},
|
|
7067
7187
|
/* @__PURE__ */ import_react78.default.createElement(
|
|
7068
7188
|
"span",
|
|
@@ -7081,7 +7201,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7081
7201
|
centsToDollars(bankTransaction.amount)
|
|
7082
7202
|
), /* @__PURE__ */ import_react78.default.createElement("span", { className: `${className}__heading__date` }, (0, import_date_fns11.format)((0, import_date_fns11.parseISO)(bankTransaction.date), DATE_FORMAT2))))
|
|
7083
7203
|
),
|
|
7084
|
-
/* @__PURE__ */ import_react78.default.createElement("div", { className: `${className}__expanded-row`, style: { height } }, open && /* @__PURE__ */ import_react78.default.createElement(
|
|
7204
|
+
/* @__PURE__ */ import_react78.default.createElement("div", { className: `${className}__expanded-row`, style: { height: !open || removeAnim ? 0 : height } }, open && /* @__PURE__ */ import_react78.default.createElement(
|
|
7085
7205
|
"div",
|
|
7086
7206
|
{
|
|
7087
7207
|
className: `${className}__expanded-row__content`,
|
|
@@ -7307,7 +7427,9 @@ var Pagination = ({
|
|
|
7307
7427
|
totalCount,
|
|
7308
7428
|
siblingCount = 1,
|
|
7309
7429
|
currentPage,
|
|
7310
|
-
pageSize
|
|
7430
|
+
pageSize,
|
|
7431
|
+
hasMore,
|
|
7432
|
+
fetchMore
|
|
7311
7433
|
}) => {
|
|
7312
7434
|
const paginationRange = usePagination({
|
|
7313
7435
|
currentPage,
|
|
@@ -7356,12 +7478,23 @@ var Pagination = ({
|
|
|
7356
7478
|
onClick: () => {
|
|
7357
7479
|
if (typeof pageNumber === "number") {
|
|
7358
7480
|
onPageChange(pageNumber);
|
|
7481
|
+
if (pageNumber === lastPage && hasMore && fetchMore) {
|
|
7482
|
+
fetchMore();
|
|
7483
|
+
}
|
|
7359
7484
|
}
|
|
7360
7485
|
}
|
|
7361
7486
|
},
|
|
7362
7487
|
pageNumber
|
|
7363
7488
|
);
|
|
7364
|
-
}), /* @__PURE__ */ import_react84.default.createElement(
|
|
7489
|
+
}), hasMore && fetchMore ? /* @__PURE__ */ import_react84.default.createElement(
|
|
7490
|
+
"li",
|
|
7491
|
+
{
|
|
7492
|
+
key: `page-has-more`,
|
|
7493
|
+
className: "Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--next",
|
|
7494
|
+
onClick: fetchMore
|
|
7495
|
+
},
|
|
7496
|
+
"..."
|
|
7497
|
+
) : null, /* @__PURE__ */ import_react84.default.createElement(
|
|
7365
7498
|
"li",
|
|
7366
7499
|
{
|
|
7367
7500
|
key: `page-last`,
|
|
@@ -7509,6 +7642,21 @@ var DatePickerOptions = ({
|
|
|
7509
7642
|
},
|
|
7510
7643
|
"This quarter"
|
|
7511
7644
|
);
|
|
7645
|
+
case "last-quarter":
|
|
7646
|
+
return /* @__PURE__ */ import_react85.default.createElement(
|
|
7647
|
+
TextButton,
|
|
7648
|
+
{
|
|
7649
|
+
key: option,
|
|
7650
|
+
onClick: () => {
|
|
7651
|
+
const lastQuarter = (0, import_date_fns13.subQuarters)(/* @__PURE__ */ new Date(), 1);
|
|
7652
|
+
setSelectedDate([
|
|
7653
|
+
(0, import_date_fns13.startOfQuarter)(lastQuarter),
|
|
7654
|
+
(0, import_date_fns13.endOfQuarter)(lastQuarter)
|
|
7655
|
+
]);
|
|
7656
|
+
}
|
|
7657
|
+
},
|
|
7658
|
+
"Last quarter"
|
|
7659
|
+
);
|
|
7512
7660
|
case "this-year":
|
|
7513
7661
|
return /* @__PURE__ */ import_react85.default.createElement(
|
|
7514
7662
|
TextButton,
|
|
@@ -7520,11 +7668,30 @@ var DatePickerOptions = ({
|
|
|
7520
7668
|
},
|
|
7521
7669
|
"This year"
|
|
7522
7670
|
);
|
|
7671
|
+
case "last-year":
|
|
7672
|
+
return /* @__PURE__ */ import_react85.default.createElement(
|
|
7673
|
+
TextButton,
|
|
7674
|
+
{
|
|
7675
|
+
key: option,
|
|
7676
|
+
onClick: () => {
|
|
7677
|
+
const lastYear = (0, import_date_fns13.subYears)(/* @__PURE__ */ new Date(), 1);
|
|
7678
|
+
setSelectedDate([(0, import_date_fns13.startOfYear)(lastYear), (0, import_date_fns13.endOfYear)(lastYear)]);
|
|
7679
|
+
}
|
|
7680
|
+
},
|
|
7681
|
+
"Last year"
|
|
7682
|
+
);
|
|
7523
7683
|
}
|
|
7524
7684
|
return /* @__PURE__ */ import_react85.default.createElement(import_react85.default.Fragment, null);
|
|
7525
7685
|
};
|
|
7526
7686
|
if (options.length === 0) {
|
|
7527
|
-
const allOptions = [
|
|
7687
|
+
const allOptions = [
|
|
7688
|
+
"this-month",
|
|
7689
|
+
"last-month",
|
|
7690
|
+
"this-quarter",
|
|
7691
|
+
"last-quarter",
|
|
7692
|
+
"this-year",
|
|
7693
|
+
"last-year"
|
|
7694
|
+
];
|
|
7528
7695
|
allOptions.forEach((option) => {
|
|
7529
7696
|
optionsComponents.push(getOptionComponent(option));
|
|
7530
7697
|
});
|
|
@@ -7541,11 +7708,25 @@ var DatePickerOptions = ({
|
|
|
7541
7708
|
|
|
7542
7709
|
// src/components/DatePicker/DatePicker.tsx
|
|
7543
7710
|
var import_classnames38 = __toESM(require("classnames"));
|
|
7711
|
+
var getDefaultRangeDate = (date, mode, selected) => {
|
|
7712
|
+
try {
|
|
7713
|
+
if (isRangeMode(mode) && selected) {
|
|
7714
|
+
if (date === "end") {
|
|
7715
|
+
return selected[1];
|
|
7716
|
+
}
|
|
7717
|
+
return selected[0];
|
|
7718
|
+
}
|
|
7719
|
+
return null;
|
|
7720
|
+
} catch (_err) {
|
|
7721
|
+
return null;
|
|
7722
|
+
}
|
|
7723
|
+
};
|
|
7724
|
+
var isRangeMode = (mode) => mode === "dayRangePicker" || mode === "monthRangePicker";
|
|
7544
7725
|
var DatePicker = ({
|
|
7545
7726
|
selected,
|
|
7546
7727
|
onChange,
|
|
7547
7728
|
mode = "dayPicker",
|
|
7548
|
-
dateFormat = mode === "monthPicker" || mode === "monthRangePicker" ? "
|
|
7729
|
+
dateFormat = mode === "monthPicker" || mode === "monthRangePicker" ? "MMM, yyyy" : mode === "timePicker" ? "h:mm aa" : "MMM d, yyyy",
|
|
7549
7730
|
timeIntervals = 15,
|
|
7550
7731
|
timeCaption,
|
|
7551
7732
|
placeholderText,
|
|
@@ -7554,15 +7735,38 @@ var DatePicker = ({
|
|
|
7554
7735
|
calendarClassName,
|
|
7555
7736
|
popperClassName,
|
|
7556
7737
|
minDate,
|
|
7738
|
+
maxDate = /* @__PURE__ */ new Date(),
|
|
7557
7739
|
currentDateOption = true,
|
|
7740
|
+
navigateArrows = mode === "monthPicker",
|
|
7558
7741
|
...props
|
|
7559
7742
|
}) => {
|
|
7743
|
+
const pickerRef = (0, import_react86.useRef)(null);
|
|
7560
7744
|
const [updatePickerDate, setPickerDate] = (0, import_react86.useState)(false);
|
|
7561
7745
|
const [selectedDates, setSelectedDates] = (0, import_react86.useState)(selected);
|
|
7746
|
+
const { isDesktop } = useSizeClass();
|
|
7747
|
+
const [startDate, setStartDate] = (0, import_react86.useState)(
|
|
7748
|
+
getDefaultRangeDate("start", mode, selected) ?? /* @__PURE__ */ new Date()
|
|
7749
|
+
);
|
|
7750
|
+
const [endDate, setEndDate] = (0, import_react86.useState)(
|
|
7751
|
+
getDefaultRangeDate("end", mode, selected)
|
|
7752
|
+
);
|
|
7562
7753
|
(0, import_react86.useEffect)(() => {
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7754
|
+
try {
|
|
7755
|
+
setPickerDate(true);
|
|
7756
|
+
if (!isRangeMode(mode) && selected !== selectedDates) {
|
|
7757
|
+
setSelectedDates(selected);
|
|
7758
|
+
return;
|
|
7759
|
+
}
|
|
7760
|
+
if (isRangeMode(mode) && Array.isArray(selected)) {
|
|
7761
|
+
if (startDate !== selected[0]) {
|
|
7762
|
+
setStartDate(selected[0]);
|
|
7763
|
+
}
|
|
7764
|
+
if (endDate !== selected[1]) {
|
|
7765
|
+
setEndDate(selected[1]);
|
|
7766
|
+
}
|
|
7767
|
+
}
|
|
7768
|
+
} catch (_err) {
|
|
7769
|
+
return;
|
|
7566
7770
|
}
|
|
7567
7771
|
}, [selected]);
|
|
7568
7772
|
(0, import_react86.useEffect)(() => {
|
|
@@ -7572,9 +7776,15 @@ var DatePicker = ({
|
|
|
7572
7776
|
setPickerDate(false);
|
|
7573
7777
|
}
|
|
7574
7778
|
}, [selectedDates]);
|
|
7779
|
+
(0, import_react86.useEffect)(() => {
|
|
7780
|
+
if (isRangeMode(mode)) {
|
|
7781
|
+
setSelectedDates([startDate, endDate]);
|
|
7782
|
+
}
|
|
7783
|
+
}, [startDate, endDate]);
|
|
7575
7784
|
const wrapperClassNames = (0, import_classnames38.default)(
|
|
7576
7785
|
"Layer__datepicker__wrapper",
|
|
7577
|
-
mode === "timePicker" && "Layer__datepicker__time__wrapper"
|
|
7786
|
+
mode === "timePicker" && "Layer__datepicker__time__wrapper",
|
|
7787
|
+
navigateArrows && "Layer__datepicker__wrapper--arrows"
|
|
7578
7788
|
);
|
|
7579
7789
|
const datePickerWrapperClassNames = (0, import_classnames38.default)(
|
|
7580
7790
|
"Layer__datepicker",
|
|
@@ -7587,9 +7797,16 @@ var DatePicker = ({
|
|
|
7587
7797
|
);
|
|
7588
7798
|
const popperClassNames = (0, import_classnames38.default)(
|
|
7589
7799
|
"Layer__datepicker__popper",
|
|
7800
|
+
mode === "timePicker" && "Layer__datepicker__time__popper",
|
|
7590
7801
|
popperClassName
|
|
7591
7802
|
);
|
|
7592
7803
|
const handleDateChange = (date) => {
|
|
7804
|
+
if (isRangeMode(mode)) {
|
|
7805
|
+
const [start, end] = date;
|
|
7806
|
+
setStartDate(start);
|
|
7807
|
+
setEndDate(end);
|
|
7808
|
+
return;
|
|
7809
|
+
}
|
|
7593
7810
|
setSelectedDates(date);
|
|
7594
7811
|
};
|
|
7595
7812
|
const isCurrentDate = () => {
|
|
@@ -7611,28 +7828,77 @@ var DatePicker = ({
|
|
|
7611
7828
|
);
|
|
7612
7829
|
}
|
|
7613
7830
|
};
|
|
7831
|
+
const isTodayOrAfter = Boolean(
|
|
7832
|
+
selectedDates instanceof Date && selectedDates >= /* @__PURE__ */ new Date()
|
|
7833
|
+
);
|
|
7834
|
+
const isBeforeMinDate = Boolean(
|
|
7835
|
+
minDate && selectedDates instanceof Date && selectedDates <= minDate
|
|
7836
|
+
);
|
|
7837
|
+
const changeDate = (value) => {
|
|
7838
|
+
if (mode === "dayPicker") {
|
|
7839
|
+
setSelectedDates(
|
|
7840
|
+
new Date(
|
|
7841
|
+
selectedDates.setDate(
|
|
7842
|
+
selectedDates.getDate() + value
|
|
7843
|
+
)
|
|
7844
|
+
)
|
|
7845
|
+
);
|
|
7846
|
+
} else if (mode === "monthPicker") {
|
|
7847
|
+
setSelectedDates(
|
|
7848
|
+
new Date(
|
|
7849
|
+
selectedDates.setMonth(
|
|
7850
|
+
selectedDates.getMonth() + value
|
|
7851
|
+
)
|
|
7852
|
+
)
|
|
7853
|
+
);
|
|
7854
|
+
}
|
|
7855
|
+
};
|
|
7614
7856
|
return /* @__PURE__ */ import_react86.default.createElement("div", { className: wrapperClassNames }, /* @__PURE__ */ import_react86.default.createElement(
|
|
7615
7857
|
import_react_datepicker.default,
|
|
7616
7858
|
{
|
|
7859
|
+
ref: pickerRef,
|
|
7617
7860
|
wrapperClassName: datePickerWrapperClassNames,
|
|
7618
|
-
startDate: mode
|
|
7619
|
-
endDate: mode
|
|
7861
|
+
startDate: isRangeMode(mode) ? startDate : void 0,
|
|
7862
|
+
endDate: isRangeMode(mode) ? endDate : void 0,
|
|
7620
7863
|
selected: mode !== "dayRangePicker" && mode !== "monthRangePicker" ? selectedDates : void 0,
|
|
7621
7864
|
onChange: handleDateChange,
|
|
7622
7865
|
calendarClassName: calendarClassNames,
|
|
7623
7866
|
popperClassName: popperClassNames,
|
|
7624
7867
|
enableTabLoop: false,
|
|
7625
7868
|
popperPlacement: "bottom-start",
|
|
7626
|
-
selectsRange: mode
|
|
7869
|
+
selectsRange: isRangeMode(mode),
|
|
7627
7870
|
showMonthYearPicker: mode === "monthPicker" || mode === "monthRangePicker",
|
|
7628
7871
|
dateFormat,
|
|
7629
7872
|
renderDayContents: (day) => /* @__PURE__ */ import_react86.default.createElement("span", { className: "Layer__datepicker__day-contents" }, day),
|
|
7630
7873
|
timeIntervals,
|
|
7631
7874
|
timeCaption,
|
|
7875
|
+
timeFormat: "h mm aa",
|
|
7632
7876
|
showTimeSelect: mode === "timePicker",
|
|
7633
7877
|
showTimeSelectOnly: mode === "timePicker",
|
|
7634
7878
|
minDate,
|
|
7635
|
-
maxDate
|
|
7879
|
+
maxDate,
|
|
7880
|
+
withPortal: !isDesktop,
|
|
7881
|
+
onCalendarOpen: () => {
|
|
7882
|
+
if (!isDesktop) {
|
|
7883
|
+
setTimeout(() => {
|
|
7884
|
+
document.getElementById("Layer__datepicker__portal")?.classList.remove("Layer__datepicker__portal--closed");
|
|
7885
|
+
document.getElementById("Layer__datepicker__portal")?.classList.add("Layer__datepicker__portal--opened");
|
|
7886
|
+
}, 10);
|
|
7887
|
+
}
|
|
7888
|
+
},
|
|
7889
|
+
onCalendarClose: () => {
|
|
7890
|
+
if (!isDesktop) {
|
|
7891
|
+
document.getElementById("Layer__datepicker__portal")?.classList.add("Layer__datepicker__portal--closed");
|
|
7892
|
+
document.getElementById("Layer__datepicker__portal")?.classList.remove("Layer__datepicker__portal--opened");
|
|
7893
|
+
}
|
|
7894
|
+
},
|
|
7895
|
+
portalId: "Layer__datepicker__portal",
|
|
7896
|
+
onFocus: (e) => e.target.readOnly = true,
|
|
7897
|
+
onInputClick: () => {
|
|
7898
|
+
if (pickerRef.current && !isDesktop) {
|
|
7899
|
+
pickerRef.current.setOpen(!pickerRef.current.isCalendarOpen);
|
|
7900
|
+
}
|
|
7901
|
+
},
|
|
7636
7902
|
...props
|
|
7637
7903
|
},
|
|
7638
7904
|
mode === "dayRangePicker" && /* @__PURE__ */ import_react86.default.createElement(
|
|
@@ -7642,7 +7908,39 @@ var DatePicker = ({
|
|
|
7642
7908
|
setSelectedDate: setSelectedDates
|
|
7643
7909
|
}
|
|
7644
7910
|
)
|
|
7645
|
-
),
|
|
7911
|
+
), navigateArrows && !isDesktop && /* @__PURE__ */ import_react86.default.createElement(import_react86.default.Fragment, null, /* @__PURE__ */ import_react86.default.createElement(
|
|
7912
|
+
Button,
|
|
7913
|
+
{
|
|
7914
|
+
"aria-label": "Previous Date",
|
|
7915
|
+
className: (0, import_classnames38.default)(
|
|
7916
|
+
"Layer__datepicker__prev-button",
|
|
7917
|
+
isBeforeMinDate && "Layer__datepicker__button--disabled"
|
|
7918
|
+
),
|
|
7919
|
+
onClick: () => changeDate(-1),
|
|
7920
|
+
variant: "secondary" /* secondary */,
|
|
7921
|
+
disabled: isBeforeMinDate
|
|
7922
|
+
},
|
|
7923
|
+
/* @__PURE__ */ import_react86.default.createElement(ChevronLeft_default, { className: "Layer__datepicker__button-icon", size: 16 })
|
|
7924
|
+
), /* @__PURE__ */ import_react86.default.createElement(
|
|
7925
|
+
Button,
|
|
7926
|
+
{
|
|
7927
|
+
"aria-label": "Next Date",
|
|
7928
|
+
variant: "secondary" /* secondary */,
|
|
7929
|
+
className: (0, import_classnames38.default)(
|
|
7930
|
+
"Layer__datepicker__next-button",
|
|
7931
|
+
isTodayOrAfter ? "Layer__datepicker__button--disabled" : void 0
|
|
7932
|
+
),
|
|
7933
|
+
onClick: () => changeDate(1),
|
|
7934
|
+
disabled: isTodayOrAfter
|
|
7935
|
+
},
|
|
7936
|
+
/* @__PURE__ */ import_react86.default.createElement(
|
|
7937
|
+
ChevronRight_default,
|
|
7938
|
+
{
|
|
7939
|
+
className: "Layer__datepicker__button-icon",
|
|
7940
|
+
size: 16
|
|
7941
|
+
}
|
|
7942
|
+
)
|
|
7943
|
+
)), currentDateOption && (mode === "dayPicker" || mode === "monthPicker") && /* @__PURE__ */ import_react86.default.createElement(
|
|
7646
7944
|
Button,
|
|
7647
7945
|
{
|
|
7648
7946
|
className: "Layer__datepicker__current-button",
|
|
@@ -7929,19 +8227,30 @@ var Inbox_default = Inbox;
|
|
|
7929
8227
|
// src/components/BankTransactions/DataStates.tsx
|
|
7930
8228
|
var DataStates = ({
|
|
7931
8229
|
bankTransactions,
|
|
8230
|
+
transactionsLoading,
|
|
7932
8231
|
isLoading,
|
|
7933
8232
|
isValidating,
|
|
7934
8233
|
error,
|
|
7935
8234
|
refetch,
|
|
7936
8235
|
editable
|
|
7937
8236
|
}) => {
|
|
8237
|
+
let title;
|
|
8238
|
+
let description;
|
|
8239
|
+
if (transactionsLoading) {
|
|
8240
|
+
title = "Data sync in progress";
|
|
8241
|
+
description = "Check back later to review your transactions";
|
|
8242
|
+
} else {
|
|
8243
|
+
title = editable ? "You are up to date with transactions!" : "You have no categorized transactions";
|
|
8244
|
+
description = editable ? "All uncategorized transaction will be displayed here" : "All transaction will be displayed here once reviewed";
|
|
8245
|
+
}
|
|
8246
|
+
const showRefreshButton = transactionsLoading || bankTransactions?.length;
|
|
7938
8247
|
return /* @__PURE__ */ import_react90.default.createElement(import_react90.default.Fragment, null, !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react90.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react90.default.createElement(
|
|
7939
8248
|
DataState,
|
|
7940
8249
|
{
|
|
7941
|
-
status: "allDone" /* allDone */,
|
|
7942
|
-
title
|
|
7943
|
-
description
|
|
7944
|
-
onRefresh:
|
|
8250
|
+
status: transactionsLoading ? "info" /* info */ : "allDone" /* allDone */,
|
|
8251
|
+
title,
|
|
8252
|
+
description,
|
|
8253
|
+
onRefresh: showRefreshButton ? refetch : void 0,
|
|
7945
8254
|
isLoading: isValidating,
|
|
7946
8255
|
icon: !editable ? /* @__PURE__ */ import_react90.default.createElement(Inbox_default, null) : void 0
|
|
7947
8256
|
}
|
|
@@ -7951,7 +8260,7 @@ var DataStates = ({
|
|
|
7951
8260
|
status: "failed" /* failed */,
|
|
7952
8261
|
title: "Something went wrong",
|
|
7953
8262
|
description: "We couldn\u2019t load your data.",
|
|
7954
|
-
onRefresh:
|
|
8263
|
+
onRefresh: refetch,
|
|
7955
8264
|
isLoading: isValidating
|
|
7956
8265
|
}
|
|
7957
8266
|
)) : null);
|
|
@@ -7960,6 +8269,7 @@ var DataStates = ({
|
|
|
7960
8269
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
7961
8270
|
var import_date_fns15 = require("date-fns");
|
|
7962
8271
|
var COMPONENT_NAME2 = "bank-transactions";
|
|
8272
|
+
var TEST_EMPTY_STATE = false;
|
|
7963
8273
|
var BankTransactions = ({
|
|
7964
8274
|
onError,
|
|
7965
8275
|
...props
|
|
@@ -7968,7 +8278,7 @@ var BankTransactions = ({
|
|
|
7968
8278
|
};
|
|
7969
8279
|
var BankTransactionsContent = ({
|
|
7970
8280
|
asWidget = false,
|
|
7971
|
-
pageSize =
|
|
8281
|
+
pageSize = 20,
|
|
7972
8282
|
categorizedOnly = false,
|
|
7973
8283
|
categorizeView = true,
|
|
7974
8284
|
showDescriptions = false,
|
|
@@ -7979,7 +8289,6 @@ var BankTransactionsContent = ({
|
|
|
7979
8289
|
hideHeader = false
|
|
7980
8290
|
}) => {
|
|
7981
8291
|
const [currentPage, setCurrentPage] = (0, import_react91.useState)(1);
|
|
7982
|
-
const [removedTxs, setRemovedTxs] = (0, import_react91.useState)([]);
|
|
7983
8292
|
const [initialLoad, setInitialLoad] = (0, import_react91.useState)(true);
|
|
7984
8293
|
const [dateRange, setDateRange] = (0, import_react91.useState)({
|
|
7985
8294
|
startDate: (0, import_date_fns15.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
@@ -7995,9 +8304,12 @@ var BankTransactionsContent = ({
|
|
|
7995
8304
|
refetch,
|
|
7996
8305
|
setFilters,
|
|
7997
8306
|
filters,
|
|
7998
|
-
|
|
7999
|
-
|
|
8307
|
+
display,
|
|
8308
|
+
hasMore,
|
|
8309
|
+
fetchMore,
|
|
8310
|
+
removeAfterCategorize
|
|
8000
8311
|
} = useBankTransactionsContext();
|
|
8312
|
+
const { data: linkedAccounts } = useLinkedAccounts();
|
|
8001
8313
|
(0, import_react91.useEffect)(() => {
|
|
8002
8314
|
activate();
|
|
8003
8315
|
}, []);
|
|
@@ -8007,24 +8319,24 @@ var BankTransactionsContent = ({
|
|
|
8007
8319
|
setFilters({
|
|
8008
8320
|
...filters,
|
|
8009
8321
|
...inputFilters,
|
|
8010
|
-
categorizationStatus: "
|
|
8322
|
+
categorizationStatus: "review" /* review */
|
|
8011
8323
|
});
|
|
8012
8324
|
} else if (!filters?.categorizationStatus && categorizedOnly) {
|
|
8013
8325
|
setFilters({
|
|
8014
8326
|
...filters,
|
|
8015
8327
|
...inputFilters,
|
|
8016
|
-
categorizationStatus: "
|
|
8328
|
+
categorizationStatus: "categorized" /* categorized */
|
|
8017
8329
|
});
|
|
8018
8330
|
} else {
|
|
8019
8331
|
setFilters({ ...filters, ...inputFilters });
|
|
8020
8332
|
}
|
|
8021
8333
|
} else if (!filters?.categorizationStatus && categorizeView) {
|
|
8022
8334
|
setFilters({
|
|
8023
|
-
categorizationStatus: "
|
|
8335
|
+
categorizationStatus: "review" /* review */
|
|
8024
8336
|
});
|
|
8025
8337
|
} else if (!filters?.categorizationStatus && categorizedOnly) {
|
|
8026
8338
|
setFilters({
|
|
8027
|
-
categorizationStatus: "
|
|
8339
|
+
categorizationStatus: "categorized" /* categorized */
|
|
8028
8340
|
});
|
|
8029
8341
|
}
|
|
8030
8342
|
}, [inputFilters, categorizeView, categorizedOnly]);
|
|
@@ -8036,7 +8348,7 @@ var BankTransactionsContent = ({
|
|
|
8036
8348
|
return () => clearTimeout(timeoutLoad);
|
|
8037
8349
|
}
|
|
8038
8350
|
}, [loadingStatus]);
|
|
8039
|
-
const bankTransactions = (0, import_react91.useMemo)(() => {
|
|
8351
|
+
const bankTransactions = TEST_EMPTY_STATE ? [] : (0, import_react91.useMemo)(() => {
|
|
8040
8352
|
if (monthlyView) {
|
|
8041
8353
|
return data?.filter(
|
|
8042
8354
|
(x) => (0, import_date_fns15.parseISO)(x.date) >= dateRange.startDate && (0, import_date_fns15.parseISO)(x.date) <= dateRange.endDate
|
|
@@ -8045,10 +8357,10 @@ var BankTransactionsContent = ({
|
|
|
8045
8357
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
8046
8358
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
8047
8359
|
return data?.slice(firstPageIndex, lastPageIndex);
|
|
8048
|
-
}, [currentPage, data,
|
|
8360
|
+
}, [currentPage, data, dateRange]);
|
|
8049
8361
|
const onCategorizationDisplayChange = (event) => {
|
|
8050
8362
|
setFilters({
|
|
8051
|
-
categorizationStatus: event.target.value === "categorized" /* categorized */ ? "
|
|
8363
|
+
categorizationStatus: event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
|
|
8052
8364
|
});
|
|
8053
8365
|
setCurrentPage(1);
|
|
8054
8366
|
};
|
|
@@ -8057,11 +8369,7 @@ var BankTransactionsContent = ({
|
|
|
8057
8369
|
const [listView, setListView] = (0, import_react91.useState)(false);
|
|
8058
8370
|
const [containerWidth, setContainerWidth] = (0, import_react91.useState)(0);
|
|
8059
8371
|
const debounceContainerWidth = debounce(setContainerWidth, 500);
|
|
8060
|
-
const removeTransaction = (
|
|
8061
|
-
const newTxs = removedTxs.slice();
|
|
8062
|
-
newTxs.push(id);
|
|
8063
|
-
setRemovedTxs(newTxs);
|
|
8064
|
-
};
|
|
8372
|
+
const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
|
|
8065
8373
|
const containerRef = useElementSize((_el, _en, size) => {
|
|
8066
8374
|
if (size?.height && size?.height >= 90) {
|
|
8067
8375
|
const newShift = -Math.floor(size.height / 2) + 6;
|
|
@@ -8104,7 +8412,7 @@ var BankTransactionsContent = ({
|
|
|
8104
8412
|
setDateRange: (v) => setDateRange(v)
|
|
8105
8413
|
}
|
|
8106
8414
|
),
|
|
8107
|
-
!listView && /* @__PURE__ */ import_react91.default.createElement(
|
|
8415
|
+
!listView && /* @__PURE__ */ import_react91.default.createElement("div", { className: "Layer__bank-transactions__table-wrapper" }, /* @__PURE__ */ import_react91.default.createElement(
|
|
8108
8416
|
BankTransactionsTable,
|
|
8109
8417
|
{
|
|
8110
8418
|
categorizeView,
|
|
@@ -8117,7 +8425,7 @@ var BankTransactionsContent = ({
|
|
|
8117
8425
|
showDescriptions,
|
|
8118
8426
|
showReceiptUploads
|
|
8119
8427
|
}
|
|
8120
|
-
),
|
|
8428
|
+
)),
|
|
8121
8429
|
isLoading && !bankTransactions ? /* @__PURE__ */ import_react91.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react91.default.createElement(Loader2, null)) : null,
|
|
8122
8430
|
!isLoading && listView && mobileComponent !== "mobileList" ? /* @__PURE__ */ import_react91.default.createElement(
|
|
8123
8431
|
BankTransactionList,
|
|
@@ -8142,6 +8450,9 @@ var BankTransactionsContent = ({
|
|
|
8142
8450
|
{
|
|
8143
8451
|
bankTransactions,
|
|
8144
8452
|
isLoading,
|
|
8453
|
+
transactionsLoading: Boolean(
|
|
8454
|
+
linkedAccounts?.some((item) => item.is_syncing)
|
|
8455
|
+
),
|
|
8145
8456
|
isValidating,
|
|
8146
8457
|
error,
|
|
8147
8458
|
refetch,
|
|
@@ -8154,7 +8465,9 @@ var BankTransactionsContent = ({
|
|
|
8154
8465
|
currentPage,
|
|
8155
8466
|
totalCount: data?.length || 0,
|
|
8156
8467
|
pageSize,
|
|
8157
|
-
onPageChange: (page) => setCurrentPage(page)
|
|
8468
|
+
onPageChange: (page) => setCurrentPage(page),
|
|
8469
|
+
fetchMore,
|
|
8470
|
+
hasMore
|
|
8158
8471
|
}
|
|
8159
8472
|
))
|
|
8160
8473
|
);
|
|
@@ -8314,7 +8627,7 @@ var applyShare = (items, total) => {
|
|
|
8314
8627
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
8315
8628
|
var import_react94 = require("react");
|
|
8316
8629
|
var import_date_fns16 = require("date-fns");
|
|
8317
|
-
var
|
|
8630
|
+
var import_swr3 = __toESM(require("swr"));
|
|
8318
8631
|
var useProfitAndLossQuery = ({
|
|
8319
8632
|
startDate,
|
|
8320
8633
|
endDate,
|
|
@@ -8331,7 +8644,7 @@ var useProfitAndLossQuery = ({
|
|
|
8331
8644
|
isValidating,
|
|
8332
8645
|
error: rawError,
|
|
8333
8646
|
mutate
|
|
8334
|
-
} = (0,
|
|
8647
|
+
} = (0, import_swr3.default)(
|
|
8335
8648
|
businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
8336
8649
|
","
|
|
8337
8650
|
)}-${reportingBasis}`,
|
|
@@ -8524,7 +8837,7 @@ var import_react98 = __toESM(require("react"));
|
|
|
8524
8837
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
8525
8838
|
var import_react96 = require("react");
|
|
8526
8839
|
var import_date_fns18 = require("date-fns");
|
|
8527
|
-
var
|
|
8840
|
+
var import_swr4 = __toESM(require("swr"));
|
|
8528
8841
|
var buildDates = ({ currentDate }) => {
|
|
8529
8842
|
return {
|
|
8530
8843
|
startYear: (0, import_date_fns18.startOfMonth)(currentDate).getFullYear() - 1,
|
|
@@ -8559,7 +8872,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
8559
8872
|
isValidating,
|
|
8560
8873
|
error,
|
|
8561
8874
|
mutate
|
|
8562
|
-
} = (0,
|
|
8875
|
+
} = (0, import_swr4.default)(
|
|
8563
8876
|
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(
|
|
8564
8877
|
","
|
|
8565
8878
|
)}-${reportingBasis}`,
|
|
@@ -8598,6 +8911,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
8598
8911
|
totalExpenses: 0,
|
|
8599
8912
|
uncategorizedInflows: 0,
|
|
8600
8913
|
uncategorizedOutflows: 0,
|
|
8914
|
+
uncategorized_transactions: 0,
|
|
8601
8915
|
isLoading: true
|
|
8602
8916
|
});
|
|
8603
8917
|
}
|
|
@@ -8648,12 +8962,16 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
8648
8962
|
mutate();
|
|
8649
8963
|
}
|
|
8650
8964
|
}, [syncTimestamps]);
|
|
8965
|
+
const refetch = () => {
|
|
8966
|
+
mutate();
|
|
8967
|
+
};
|
|
8651
8968
|
return {
|
|
8652
8969
|
data,
|
|
8653
8970
|
isLoading,
|
|
8654
8971
|
loaded,
|
|
8655
8972
|
error,
|
|
8656
|
-
pullData
|
|
8973
|
+
pullData,
|
|
8974
|
+
refetch
|
|
8657
8975
|
};
|
|
8658
8976
|
};
|
|
8659
8977
|
|
|
@@ -8864,8 +9182,10 @@ var ProfitAndLossChart = () => {
|
|
|
8864
9182
|
name: getMonthName(pnl),
|
|
8865
9183
|
revenue: pnl?.income || 0,
|
|
8866
9184
|
revenueUncategorized: pnl?.uncategorizedInflows || 0,
|
|
8867
|
-
expenses: -
|
|
8868
|
-
expensesUncategorized: -
|
|
9185
|
+
expenses: -(pnl?.operatingExpenses || 0),
|
|
9186
|
+
expensesUncategorized: -(pnl?.uncategorizedOutflows || 0),
|
|
9187
|
+
operatingExpensesInverse: pnl?.operatingExpensesInverse || 0,
|
|
9188
|
+
uncategorizedOutflowsInverse: pnl?.uncategorizedOutflowsInverse || 0,
|
|
8869
9189
|
netProfit: pnl?.netProfit || 0,
|
|
8870
9190
|
selected: !!pnl && pnl.month === selectionMonth.month + 1 && pnl.year === selectionMonth.year,
|
|
8871
9191
|
year: pnl?.year,
|
|
@@ -8884,6 +9204,8 @@ var ProfitAndLossChart = () => {
|
|
|
8884
9204
|
name: (0, import_date_fns19.format)(currentDate, compactView ? "LLLLL" : "LLL"),
|
|
8885
9205
|
revenue: 0,
|
|
8886
9206
|
revenueUncategorized: 0,
|
|
9207
|
+
operatingExpensesInverse: 0,
|
|
9208
|
+
uncategorizedOutflowsInverse: 0,
|
|
8887
9209
|
expenses: 0,
|
|
8888
9210
|
expensesUncategorized: 0,
|
|
8889
9211
|
netProfit: 0,
|
|
@@ -8897,7 +9219,18 @@ var ProfitAndLossChart = () => {
|
|
|
8897
9219
|
}
|
|
8898
9220
|
return loadingData;
|
|
8899
9221
|
}
|
|
8900
|
-
return data?.
|
|
9222
|
+
return data?.map((x) => {
|
|
9223
|
+
if (x.operatingExpenses < 0 || x.uncategorizedOutflows < 0) {
|
|
9224
|
+
return {
|
|
9225
|
+
...x,
|
|
9226
|
+
operatingExpenses: x.operatingExpenses < 0 ? 0 : x.operatingExpenses,
|
|
9227
|
+
uncategorizedOutflows: x.uncategorizedOutflows < 0 ? 0 : x.uncategorizedOutflows,
|
|
9228
|
+
operatingExpensesInverse: x.operatingExpenses < 0 ? -x.operatingExpenses : 0,
|
|
9229
|
+
uncategorizedOutflowsInverse: x.uncategorizedOutflows < 0 ? -x.uncategorizedOutflows : 0
|
|
9230
|
+
};
|
|
9231
|
+
}
|
|
9232
|
+
return x;
|
|
9233
|
+
})?.filter(
|
|
8901
9234
|
(x) => (0, import_date_fns19.differenceInMonths)(
|
|
8902
9235
|
(0, import_date_fns19.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
8903
9236
|
chartWindow.start
|
|
@@ -9184,6 +9517,22 @@ var ProfitAndLossChart = () => {
|
|
|
9184
9517
|
stackId: "expenses"
|
|
9185
9518
|
}
|
|
9186
9519
|
),
|
|
9520
|
+
/* @__PURE__ */ import_react98.default.createElement(
|
|
9521
|
+
import_recharts.Bar,
|
|
9522
|
+
{
|
|
9523
|
+
dataKey: "operatingExpensesInverse",
|
|
9524
|
+
barSize,
|
|
9525
|
+
isAnimationActive: barAnimActive,
|
|
9526
|
+
animationDuration: 100,
|
|
9527
|
+
radius: [2, 2, 0, 0],
|
|
9528
|
+
className: "Layer__profit-and-loss-chart__bar--expenses",
|
|
9529
|
+
xAxisId: "revenue",
|
|
9530
|
+
stackId: "revenue"
|
|
9531
|
+
},
|
|
9532
|
+
theData?.map((entry) => {
|
|
9533
|
+
return /* @__PURE__ */ import_react98.default.createElement(import_recharts.Cell, { key: entry.name, fill: "url(#layer-bar-stripe-pattern-dark)" });
|
|
9534
|
+
})
|
|
9535
|
+
),
|
|
9187
9536
|
/* @__PURE__ */ import_react98.default.createElement(
|
|
9188
9537
|
import_recharts.Bar,
|
|
9189
9538
|
{
|
|
@@ -9219,6 +9568,22 @@ var ProfitAndLossChart = () => {
|
|
|
9219
9568
|
);
|
|
9220
9569
|
})
|
|
9221
9570
|
),
|
|
9571
|
+
/* @__PURE__ */ import_react98.default.createElement(
|
|
9572
|
+
import_recharts.Bar,
|
|
9573
|
+
{
|
|
9574
|
+
dataKey: "uncategorizedOutflowsInverse",
|
|
9575
|
+
barSize,
|
|
9576
|
+
isAnimationActive: barAnimActive,
|
|
9577
|
+
animationDuration: 100,
|
|
9578
|
+
radius: [2, 2, 0, 0],
|
|
9579
|
+
className: "Layer__profit-and-loss-chart__bar--expenses-uncategorized",
|
|
9580
|
+
xAxisId: "revenue",
|
|
9581
|
+
stackId: "revenue"
|
|
9582
|
+
},
|
|
9583
|
+
theData?.map((entry) => {
|
|
9584
|
+
return /* @__PURE__ */ import_react98.default.createElement(import_recharts.Cell, { key: entry.name, fill: "url(#layer-bar-stripe-pattern-dark)" });
|
|
9585
|
+
})
|
|
9586
|
+
),
|
|
9222
9587
|
/* @__PURE__ */ import_react98.default.createElement(
|
|
9223
9588
|
import_recharts.Bar,
|
|
9224
9589
|
{
|
|
@@ -10605,11 +10970,11 @@ var TableProvider = ({ children }) => {
|
|
|
10605
10970
|
// src/hooks/useBalanceSheet/useBalanceSheet.tsx
|
|
10606
10971
|
var import_react112 = require("react");
|
|
10607
10972
|
var import_date_fns23 = require("date-fns");
|
|
10608
|
-
var
|
|
10973
|
+
var import_swr5 = __toESM(require("swr"));
|
|
10609
10974
|
var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
10610
10975
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
10611
10976
|
const dateString = (0, import_date_fns23.format)((0, import_date_fns23.startOfDay)(date), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
10612
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
10977
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr5.default)(
|
|
10613
10978
|
businessId && dateString && auth?.access_token && `balance-sheet-${businessId}-${dateString}`,
|
|
10614
10979
|
Layer.getBalanceSheet(apiUrl, auth?.access_token, {
|
|
10615
10980
|
params: {
|
|
@@ -11054,7 +11419,7 @@ var StatementOfCashFlowContext = (0, import_react126.createContext)({
|
|
|
11054
11419
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
11055
11420
|
var import_react127 = require("react");
|
|
11056
11421
|
var import_date_fns25 = require("date-fns");
|
|
11057
|
-
var
|
|
11422
|
+
var import_swr6 = __toESM(require("swr"));
|
|
11058
11423
|
var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
|
|
11059
11424
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
11060
11425
|
const startDateString = (0, import_date_fns25.format)(
|
|
@@ -11062,7 +11427,7 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
|
|
|
11062
11427
|
"yyyy-MM-dd'T'HH:mm:ssXXX"
|
|
11063
11428
|
);
|
|
11064
11429
|
const endDateString = (0, import_date_fns25.format)((0, import_date_fns25.startOfDay)(endDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11065
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
11430
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr6.default)(
|
|
11066
11431
|
businessId && startDateString && endDateString && auth?.access_token && `statement-of-cash-${businessId}-${startDateString}-${endDateString}`,
|
|
11067
11432
|
Layer.getStatementOfCashFlow(apiUrl, auth?.access_token, {
|
|
11068
11433
|
params: {
|
|
@@ -11503,7 +11868,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
11503
11868
|
|
|
11504
11869
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
11505
11870
|
var import_date_fns28 = require("date-fns");
|
|
11506
|
-
var
|
|
11871
|
+
var import_swr7 = __toESM(require("swr"));
|
|
11507
11872
|
var validate = (formData) => {
|
|
11508
11873
|
const errors = [];
|
|
11509
11874
|
const nameError = validateName(formData);
|
|
@@ -11604,7 +11969,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
11604
11969
|
const [endDate, setEndDate] = (0, import_react132.useState)(
|
|
11605
11970
|
initialEndDate ?? (0, import_date_fns28.endOfMonth)(Date.now())
|
|
11606
11971
|
);
|
|
11607
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
11972
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr7.default)(
|
|
11608
11973
|
businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`,
|
|
11609
11974
|
Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
|
|
11610
11975
|
params: {
|
|
@@ -11813,12 +12178,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
11813
12178
|
|
|
11814
12179
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
11815
12180
|
var import_react133 = require("react");
|
|
11816
|
-
var
|
|
12181
|
+
var import_swr8 = __toESM(require("swr"));
|
|
11817
12182
|
var useLedgerAccounts = () => {
|
|
11818
12183
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
11819
12184
|
const [accountId, setAccountId] = (0, import_react133.useState)();
|
|
11820
12185
|
const [selectedEntryId, setSelectedEntryId] = (0, import_react133.useState)();
|
|
11821
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
12186
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr8.default)(
|
|
11822
12187
|
businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
|
|
11823
12188
|
Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
|
|
11824
12189
|
params: { businessId, accountId }
|
|
@@ -11830,7 +12195,7 @@ var useLedgerAccounts = () => {
|
|
|
11830
12195
|
isLoading: isLoadingEntry,
|
|
11831
12196
|
isValidating: isValdiatingEntry,
|
|
11832
12197
|
error: errorEntry
|
|
11833
|
-
} = (0,
|
|
12198
|
+
} = (0, import_swr8.default)(
|
|
11834
12199
|
businessId && selectedEntryId && auth?.access_token && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
|
|
11835
12200
|
Layer.getLedgerAccountsEntry(apiUrl, auth?.access_token, {
|
|
11836
12201
|
params: { businessId, entryId: selectedEntryId }
|
|
@@ -12920,7 +13285,7 @@ var getAccountIdentifierPayload = (journalLineItem) => {
|
|
|
12920
13285
|
};
|
|
12921
13286
|
|
|
12922
13287
|
// src/hooks/useJournal/useJournal.tsx
|
|
12923
|
-
var
|
|
13288
|
+
var import_swr9 = __toESM(require("swr"));
|
|
12924
13289
|
var useJournal = () => {
|
|
12925
13290
|
const {
|
|
12926
13291
|
auth,
|
|
@@ -12936,7 +13301,7 @@ var useJournal = () => {
|
|
|
12936
13301
|
const [addingEntry, setAddingEntry] = (0, import_react149.useState)(false);
|
|
12937
13302
|
const [sendingForm, setSendingForm] = (0, import_react149.useState)(false);
|
|
12938
13303
|
const [apiError, setApiError] = (0, import_react149.useState)(void 0);
|
|
12939
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
13304
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr9.default)(
|
|
12940
13305
|
businessId && auth?.access_token && `journal-lines-${businessId}`,
|
|
12941
13306
|
Layer.getJournal(apiUrl, auth?.access_token, {
|
|
12942
13307
|
params: { businessId }
|
|
@@ -13835,11 +14200,11 @@ var TasksContext = (0, import_react157.createContext)({
|
|
|
13835
14200
|
|
|
13836
14201
|
// src/hooks/useTasks/useTasks.tsx
|
|
13837
14202
|
var import_react158 = require("react");
|
|
13838
|
-
var
|
|
14203
|
+
var import_swr10 = __toESM(require("swr"));
|
|
13839
14204
|
var useTasks = () => {
|
|
13840
14205
|
const [loadedStatus, setLoadedStatus] = (0, import_react158.useState)("initial");
|
|
13841
14206
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
13842
|
-
const { data, isLoading, isValidating, error, mutate } = (0,
|
|
14207
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr10.default)(
|
|
13843
14208
|
businessId && auth?.access_token && `tasks-${businessId}`,
|
|
13844
14209
|
Layer.getTasks(apiUrl, auth?.access_token, {
|
|
13845
14210
|
params: { businessId }
|
|
@@ -14484,27 +14849,33 @@ var NotificationCard = ({
|
|
|
14484
14849
|
};
|
|
14485
14850
|
|
|
14486
14851
|
// src/components/TransactionToReviewCard/TransactionToReviewCard.tsx
|
|
14852
|
+
var import_date_fns34 = require("date-fns");
|
|
14487
14853
|
var TransactionToReviewCard = ({
|
|
14488
14854
|
onClick,
|
|
14489
14855
|
usePnlDateRange
|
|
14490
14856
|
}) => {
|
|
14491
|
-
const {
|
|
14492
|
-
data,
|
|
14493
|
-
isLoading,
|
|
14494
|
-
loadingStatus,
|
|
14495
|
-
error,
|
|
14496
|
-
refetch,
|
|
14497
|
-
activate: activateBankTransactions
|
|
14498
|
-
} = useBankTransactionsContext();
|
|
14499
14857
|
const { dateRange: contextDateRange } = (0, import_react169.useContext)(ProfitAndLoss.Context);
|
|
14500
14858
|
const dateRange = usePnlDateRange ? contextDateRange : void 0;
|
|
14859
|
+
const [toReview, setToReview] = (0, import_react169.useState)(0);
|
|
14860
|
+
const { data, loaded, error, refetch } = useProfitAndLossLTM({
|
|
14861
|
+
currentDate: dateRange ? dateRange.startDate : (0, import_date_fns34.startOfMonth)(/* @__PURE__ */ new Date())
|
|
14862
|
+
});
|
|
14501
14863
|
(0, import_react169.useEffect)(() => {
|
|
14502
|
-
|
|
14864
|
+
checkTransactionsToReview();
|
|
14503
14865
|
}, []);
|
|
14504
|
-
|
|
14505
|
-
()
|
|
14506
|
-
|
|
14507
|
-
)
|
|
14866
|
+
(0, import_react169.useEffect)(() => {
|
|
14867
|
+
checkTransactionsToReview();
|
|
14868
|
+
}, [dateRange, loaded]);
|
|
14869
|
+
const checkTransactionsToReview = () => {
|
|
14870
|
+
if (data && dateRange) {
|
|
14871
|
+
const monthTx = data.filter(
|
|
14872
|
+
(x) => x.month - 1 === (0, import_date_fns34.getMonth)(dateRange.startDate) && x.year === (0, import_date_fns34.getYear)(dateRange.startDate)
|
|
14873
|
+
);
|
|
14874
|
+
if (monthTx.length > 0) {
|
|
14875
|
+
setToReview(monthTx[0].uncategorized_transactions);
|
|
14876
|
+
}
|
|
14877
|
+
}
|
|
14878
|
+
};
|
|
14508
14879
|
return /* @__PURE__ */ import_react169.default.createElement(
|
|
14509
14880
|
NotificationCard,
|
|
14510
14881
|
{
|
|
@@ -14512,8 +14883,8 @@ var TransactionToReviewCard = ({
|
|
|
14512
14883
|
onClick: () => onClick && onClick()
|
|
14513
14884
|
},
|
|
14514
14885
|
/* @__PURE__ */ import_react169.default.createElement(Text, { size: "sm" /* sm */ }, "Transactions to review"),
|
|
14515
|
-
|
|
14516
|
-
|
|
14886
|
+
loaded === "initial" || loaded === "loading" ? /* @__PURE__ */ import_react169.default.createElement(BadgeLoader, null) : null,
|
|
14887
|
+
loaded === "complete" && error ? /* @__PURE__ */ import_react169.default.createElement(
|
|
14517
14888
|
Badge,
|
|
14518
14889
|
{
|
|
14519
14890
|
variant: "error" /* ERROR */,
|
|
@@ -14523,7 +14894,7 @@ var TransactionToReviewCard = ({
|
|
|
14523
14894
|
},
|
|
14524
14895
|
"Refresh"
|
|
14525
14896
|
) : null,
|
|
14526
|
-
|
|
14897
|
+
loaded === "complete" && !error && toReview > 0 ? /* @__PURE__ */ import_react169.default.createElement(
|
|
14527
14898
|
Badge,
|
|
14528
14899
|
{
|
|
14529
14900
|
variant: "warning" /* WARNING */,
|
|
@@ -14533,7 +14904,7 @@ var TransactionToReviewCard = ({
|
|
|
14533
14904
|
toReview,
|
|
14534
14905
|
" pending"
|
|
14535
14906
|
) : null,
|
|
14536
|
-
|
|
14907
|
+
loaded === "complete" && !error && toReview === 0 ? /* @__PURE__ */ import_react169.default.createElement(
|
|
14537
14908
|
Badge,
|
|
14538
14909
|
{
|
|
14539
14910
|
variant: "success" /* SUCCESS */,
|
|
@@ -14821,10 +15192,12 @@ var Components = ({
|
|
|
14821
15192
|
AccountingOverview,
|
|
14822
15193
|
BalanceSheet,
|
|
14823
15194
|
BankTransactions,
|
|
15195
|
+
BankTransactionsProvider,
|
|
14824
15196
|
BankTransactionsWithLinkedAccounts,
|
|
14825
15197
|
BookkeepingOverview,
|
|
14826
15198
|
BookkeepingUpsellBar,
|
|
14827
15199
|
ChartOfAccounts,
|
|
15200
|
+
DisplayState,
|
|
14828
15201
|
GeneralLedgerView,
|
|
14829
15202
|
Journal,
|
|
14830
15203
|
LayerProvider,
|