@layerfi/components 0.1.99 → 0.1.101
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/cjs/index.cjs +863 -773
- package/dist/esm/index.mjs +706 -615
- package/dist/index.css +107 -108
- package/dist/index.d.ts +70 -62
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -5575,6 +5575,7 @@ __export(index_exports, {
|
|
|
5575
5575
|
Direction: () => Direction,
|
|
5576
5576
|
DisplayState: () => DisplayState,
|
|
5577
5577
|
GeneralLedgerView: () => GeneralLedgerView,
|
|
5578
|
+
Integrations: () => Integrations,
|
|
5578
5579
|
Journal: () => Journal,
|
|
5579
5580
|
LayerProvider: () => LayerProvider,
|
|
5580
5581
|
LinkAccounts: () => LinkAccounts,
|
|
@@ -5584,11 +5585,9 @@ __export(index_exports, {
|
|
|
5584
5585
|
ProfitAndLoss: () => ProfitAndLoss,
|
|
5585
5586
|
ProfitAndLossView: () => ProfitAndLossView,
|
|
5586
5587
|
ProjectProfitabilityView: () => ProjectProfitabilityView,
|
|
5587
|
-
Quickbooks: () => Quickbooks,
|
|
5588
5588
|
Reports: () => Reports,
|
|
5589
5589
|
StatementOfCashFlow: () => StatementOfCashFlow,
|
|
5590
5590
|
Tasks: () => Tasks,
|
|
5591
|
-
unstable_Integrations: () => unstable_Integrations,
|
|
5592
5591
|
useBankTransactionsContext: () => useBankTransactionsContext,
|
|
5593
5592
|
useDataSync: () => useDataSync,
|
|
5594
5593
|
useLayerContext: () => useLayerContext
|
|
@@ -5602,7 +5601,7 @@ var import_react18 = require("react");
|
|
|
5602
5601
|
var import_react16 = require("react");
|
|
5603
5602
|
|
|
5604
5603
|
// package.json
|
|
5605
|
-
var version = "0.1.
|
|
5604
|
+
var version = "0.1.101";
|
|
5606
5605
|
|
|
5607
5606
|
// src/models/APIError.ts
|
|
5608
5607
|
var APIError = class _APIError extends Error {
|
|
@@ -6009,9 +6008,6 @@ var profitAndLossComparisonCsv = post(
|
|
|
6009
6008
|
|
|
6010
6009
|
// src/api/layer/quickbooks.ts
|
|
6011
6010
|
var syncFromQuickbooks = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/sync-from`);
|
|
6012
|
-
var statusOfSyncFromQuickbooks = get(
|
|
6013
|
-
({ businessId }) => `/v1/businesses/${businessId}/quickbooks/sync-from/status`
|
|
6014
|
-
);
|
|
6015
6011
|
var initQuickbooksOAuth = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/authorize`);
|
|
6016
6012
|
var unlinkQuickbooksConnection = post(({ businessId }) => `/v1/businesses/${businessId}/quickbooks/unlink`);
|
|
6017
6013
|
var statusOfQuickbooksConnection = get(
|
|
@@ -6085,7 +6081,6 @@ var Layer = {
|
|
|
6085
6081
|
updateOpeningBalance,
|
|
6086
6082
|
getStatementOfCashFlow,
|
|
6087
6083
|
syncFromQuickbooks,
|
|
6088
|
-
statusOfSyncFromQuickbooks,
|
|
6089
6084
|
statusOfQuickbooksConnection,
|
|
6090
6085
|
initQuickbooksOAuth,
|
|
6091
6086
|
unlinkQuickbooksConnection,
|
|
@@ -14657,17 +14652,22 @@ function LegacyModeProvider({
|
|
|
14657
14652
|
}
|
|
14658
14653
|
|
|
14659
14654
|
// src/hooks/bookkeeping/useBookkeepingStatus.ts
|
|
14660
|
-
var
|
|
14661
|
-
"NOT_PURCHASED"
|
|
14662
|
-
"ACTIVE"
|
|
14663
|
-
"ONBOARDING"
|
|
14664
|
-
"BOOKKEEPING_PAUSED"
|
|
14665
|
-
|
|
14655
|
+
var BookkeepingStatus = /* @__PURE__ */ ((BookkeepingStatus3) => {
|
|
14656
|
+
BookkeepingStatus3["NOT_PURCHASED"] = "NOT_PURCHASED";
|
|
14657
|
+
BookkeepingStatus3["ACTIVE"] = "ACTIVE";
|
|
14658
|
+
BookkeepingStatus3["ONBOARDING"] = "ONBOARDING";
|
|
14659
|
+
BookkeepingStatus3["BOOKKEEPING_PAUSED"] = "BOOKKEEPING_PAUSED";
|
|
14660
|
+
return BookkeepingStatus3;
|
|
14661
|
+
})(BookkeepingStatus || {});
|
|
14662
|
+
var BOOKKEEPING_STATUSES = Object.values(BookkeepingStatus);
|
|
14663
|
+
function isBookkeepingStatus(status) {
|
|
14664
|
+
return BOOKKEEPING_STATUSES.includes(status);
|
|
14665
|
+
}
|
|
14666
14666
|
function constrainToKnownBookkeepingStatus(status) {
|
|
14667
|
-
if (
|
|
14667
|
+
if (isBookkeepingStatus(status)) {
|
|
14668
14668
|
return status;
|
|
14669
14669
|
}
|
|
14670
|
-
return "NOT_PURCHASED"
|
|
14670
|
+
return "NOT_PURCHASED" /* NOT_PURCHASED */;
|
|
14671
14671
|
}
|
|
14672
14672
|
var getBookkeepingStatus = get(({ businessId }) => {
|
|
14673
14673
|
return `/v1/businesses/${businessId}/bookkeeping/status`;
|
|
@@ -14709,26 +14709,29 @@ function useEffectiveBookkeepingStatus() {
|
|
|
14709
14709
|
const { overrideMode } = useLegacyMode();
|
|
14710
14710
|
const { data } = useBookkeepingStatus();
|
|
14711
14711
|
if (overrideMode === "bookkeeping-client") {
|
|
14712
|
-
return "ACTIVE"
|
|
14712
|
+
return "ACTIVE" /* ACTIVE */;
|
|
14713
14713
|
}
|
|
14714
|
-
return (_a = data == null ? void 0 : data.status) != null ? _a : "NOT_PURCHASED"
|
|
14714
|
+
return (_a = data == null ? void 0 : data.status) != null ? _a : "NOT_PURCHASED" /* NOT_PURCHASED */;
|
|
14715
14715
|
}
|
|
14716
14716
|
|
|
14717
14717
|
// src/utils/bookkeeping/isCategorizationEnabled.ts
|
|
14718
14718
|
function isCategorizationEnabledForStatus(status) {
|
|
14719
14719
|
switch (status) {
|
|
14720
|
-
case "NOT_PURCHASED"
|
|
14721
|
-
case "ONBOARDING"
|
|
14722
|
-
case "BOOKKEEPING_PAUSED"
|
|
14720
|
+
case "NOT_PURCHASED" /* NOT_PURCHASED */:
|
|
14721
|
+
case "ONBOARDING" /* ONBOARDING */:
|
|
14722
|
+
case "BOOKKEEPING_PAUSED" /* BOOKKEEPING_PAUSED */: {
|
|
14723
14723
|
return true;
|
|
14724
|
-
|
|
14724
|
+
}
|
|
14725
|
+
case "ACTIVE" /* ACTIVE */: {
|
|
14725
14726
|
return false;
|
|
14726
|
-
|
|
14727
|
+
}
|
|
14728
|
+
default: {
|
|
14727
14729
|
return safeAssertUnreachable({
|
|
14728
14730
|
value: status,
|
|
14729
14731
|
message: "Unexpected bookkeeping status in `isCategorizationEnabledForStatus`",
|
|
14730
14732
|
fallbackValue: true
|
|
14731
14733
|
});
|
|
14734
|
+
}
|
|
14732
14735
|
}
|
|
14733
14736
|
}
|
|
14734
14737
|
|
|
@@ -15888,6 +15891,116 @@ var SplitTooltipDetails = ({
|
|
|
15888
15891
|
var import_classnames41 = __toESM(require("classnames"));
|
|
15889
15892
|
var import_date_fns17 = require("date-fns");
|
|
15890
15893
|
|
|
15894
|
+
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
15895
|
+
var import_swr12 = __toESM(require("swr"));
|
|
15896
|
+
|
|
15897
|
+
// src/utils/bookkeeping/bookkeepingStatusFilters.ts
|
|
15898
|
+
function isActiveBookkeepingStatus(status) {
|
|
15899
|
+
return status === "ACTIVE" /* ACTIVE */ || status === "ONBOARDING" /* ONBOARDING */;
|
|
15900
|
+
}
|
|
15901
|
+
function isActiveOrPausedBookkeepingStatus(status) {
|
|
15902
|
+
return isActiveBookkeepingStatus(status) || status === "BOOKKEEPING_PAUSED" /* BOOKKEEPING_PAUSED */;
|
|
15903
|
+
}
|
|
15904
|
+
|
|
15905
|
+
// src/utils/bookkeeping/tasks/bookkeepingTasksFilters.ts
|
|
15906
|
+
function isIncompleteTask(task) {
|
|
15907
|
+
const { status } = task;
|
|
15908
|
+
return status === "TODO";
|
|
15909
|
+
}
|
|
15910
|
+
function getIncompleteTasks(tasks) {
|
|
15911
|
+
return tasks.filter((task) => isIncompleteTask(task));
|
|
15912
|
+
}
|
|
15913
|
+
function isUserVisibleTask(task) {
|
|
15914
|
+
const { status } = task;
|
|
15915
|
+
return status !== "COMPLETED" && status !== "ARCHIVED";
|
|
15916
|
+
}
|
|
15917
|
+
function getUserVisibleTasks(tasks) {
|
|
15918
|
+
return tasks.filter((task) => isUserVisibleTask(task));
|
|
15919
|
+
}
|
|
15920
|
+
function isCompletedTask(task) {
|
|
15921
|
+
const { status } = task;
|
|
15922
|
+
return status === "USER_MARKED_COMPLETED" || status === "COMPLETED" || status === "ARCHIVED";
|
|
15923
|
+
}
|
|
15924
|
+
function getCompletedTasks(tasks) {
|
|
15925
|
+
return tasks.filter((task) => isCompletedTask(task));
|
|
15926
|
+
}
|
|
15927
|
+
|
|
15928
|
+
// src/utils/bookkeeping/periods/getFilteredBookkeepingPeriods.ts
|
|
15929
|
+
function isActiveBookkeepingPeriod(period) {
|
|
15930
|
+
return period.status !== "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */;
|
|
15931
|
+
}
|
|
15932
|
+
|
|
15933
|
+
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
15934
|
+
var BookkeepingPeriodStatus = /* @__PURE__ */ ((BookkeepingPeriodStatus2) => {
|
|
15935
|
+
BookkeepingPeriodStatus2["BOOKKEEPING_NOT_ACTIVE"] = "BOOKKEEPING_NOT_ACTIVE";
|
|
15936
|
+
BookkeepingPeriodStatus2["NOT_STARTED"] = "NOT_STARTED";
|
|
15937
|
+
BookkeepingPeriodStatus2["IN_PROGRESS_AWAITING_BOOKKEEPER"] = "IN_PROGRESS_AWAITING_BOOKKEEPER";
|
|
15938
|
+
BookkeepingPeriodStatus2["IN_PROGRESS_AWAITING_CUSTOMER"] = "IN_PROGRESS_AWAITING_CUSTOMER";
|
|
15939
|
+
BookkeepingPeriodStatus2["CLOSING_IN_REVIEW"] = "CLOSING_IN_REVIEW";
|
|
15940
|
+
BookkeepingPeriodStatus2["CLOSED_OPEN_TASKS"] = "CLOSED_OPEN_TASKS";
|
|
15941
|
+
BookkeepingPeriodStatus2["CLOSED_COMPLETE"] = "CLOSED_COMPLETE";
|
|
15942
|
+
return BookkeepingPeriodStatus2;
|
|
15943
|
+
})(BookkeepingPeriodStatus || {});
|
|
15944
|
+
var BOOKKEEPING_PERIOD_STATUSES = Object.values(BookkeepingPeriodStatus);
|
|
15945
|
+
function isBookkeepingPeriodStatus(status) {
|
|
15946
|
+
return BOOKKEEPING_PERIOD_STATUSES.includes(status);
|
|
15947
|
+
}
|
|
15948
|
+
function constrainToKnownBookkeepingPeriodStatus(status) {
|
|
15949
|
+
if (isBookkeepingPeriodStatus(status)) {
|
|
15950
|
+
return status;
|
|
15951
|
+
}
|
|
15952
|
+
return "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */;
|
|
15953
|
+
}
|
|
15954
|
+
var getBookkeepingPeriods = get(({ businessId }) => {
|
|
15955
|
+
return `/v1/businesses/${businessId}/bookkeeping/periods`;
|
|
15956
|
+
});
|
|
15957
|
+
var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
|
|
15958
|
+
function buildKey12({
|
|
15959
|
+
access_token: accessToken,
|
|
15960
|
+
apiUrl,
|
|
15961
|
+
businessId,
|
|
15962
|
+
isActiveOrPaused
|
|
15963
|
+
}) {
|
|
15964
|
+
if (accessToken && apiUrl && isActiveOrPaused) {
|
|
15965
|
+
return {
|
|
15966
|
+
accessToken,
|
|
15967
|
+
apiUrl,
|
|
15968
|
+
businessId,
|
|
15969
|
+
tags: [BOOKKEEPING_TAG_KEY, BOOKKEEPING_PERIODS_TAG_KEY]
|
|
15970
|
+
};
|
|
15971
|
+
}
|
|
15972
|
+
}
|
|
15973
|
+
function useBookkeepingPeriods() {
|
|
15974
|
+
const { data: auth } = useAuth();
|
|
15975
|
+
const { businessId } = useLayerContext();
|
|
15976
|
+
const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
|
|
15977
|
+
const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
|
|
15978
|
+
const swrResponse = (0, import_swr12.default)(
|
|
15979
|
+
() => buildKey12(__spreadProps(__spreadValues({}, auth), {
|
|
15980
|
+
businessId,
|
|
15981
|
+
isActiveOrPaused
|
|
15982
|
+
})),
|
|
15983
|
+
({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingPeriods(
|
|
15984
|
+
apiUrl,
|
|
15985
|
+
accessToken,
|
|
15986
|
+
{ params: { businessId: businessId2 } }
|
|
15987
|
+
)().then(
|
|
15988
|
+
({ data: { periods } }) => periods.map((period) => __spreadProps(__spreadValues({}, period), {
|
|
15989
|
+
status: constrainToKnownBookkeepingPeriodStatus(period.status),
|
|
15990
|
+
tasks: getUserVisibleTasks(period.tasks)
|
|
15991
|
+
})).filter((period) => isActiveBookkeepingPeriod(period))
|
|
15992
|
+
)
|
|
15993
|
+
);
|
|
15994
|
+
return new Proxy(swrResponse, {
|
|
15995
|
+
get(target, prop) {
|
|
15996
|
+
if (prop === "isLoading") {
|
|
15997
|
+
return isLoadingBookkeepingStatus || swrResponse.isLoading;
|
|
15998
|
+
}
|
|
15999
|
+
return Reflect.get(target, prop);
|
|
16000
|
+
}
|
|
16001
|
+
});
|
|
16002
|
+
}
|
|
16003
|
+
|
|
15891
16004
|
// src/utils/date.ts
|
|
15892
16005
|
var monthNames = [
|
|
15893
16006
|
"January",
|
|
@@ -15952,9 +16065,9 @@ function getBookkeepingStatusConfig({
|
|
|
15952
16065
|
const monthName = monthNumber !== void 0 ? getMonthNameFromNumber(monthNumber) : "";
|
|
15953
16066
|
const actionPhrase = incompleteTasksCount !== void 0 && incompleteTasksCount > 0 ? `Please complete the ${(0, import_pluralize.default)("open task", incompleteTasksCount, true)}.` : "No action is needed from you right now.";
|
|
15954
16067
|
switch (status) {
|
|
15955
|
-
case "IN_PROGRESS_AWAITING_BOOKKEEPER"
|
|
15956
|
-
case "NOT_STARTED"
|
|
15957
|
-
case "CLOSING_IN_REVIEW"
|
|
16068
|
+
case "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */:
|
|
16069
|
+
case "NOT_STARTED" /* NOT_STARTED */:
|
|
16070
|
+
case "CLOSING_IN_REVIEW" /* CLOSING_IN_REVIEW */: {
|
|
15958
16071
|
return {
|
|
15959
16072
|
label: "Books in progress",
|
|
15960
16073
|
description: `We're working on your ${monthName} books. ${actionPhrase}`,
|
|
@@ -15962,8 +16075,8 @@ function getBookkeepingStatusConfig({
|
|
|
15962
16075
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Clock_default, { size: 12 })
|
|
15963
16076
|
};
|
|
15964
16077
|
}
|
|
15965
|
-
case "IN_PROGRESS_AWAITING_CUSTOMER"
|
|
15966
|
-
case "CLOSED_OPEN_TASKS"
|
|
16078
|
+
case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
|
|
16079
|
+
case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
|
|
15967
16080
|
return {
|
|
15968
16081
|
label: "Action required",
|
|
15969
16082
|
description: `Please respond to the below tasks to help us complete your ${monthName} books.`,
|
|
@@ -15971,7 +16084,7 @@ function getBookkeepingStatusConfig({
|
|
|
15971
16084
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(AlertCircle_default, { size: 12 })
|
|
15972
16085
|
};
|
|
15973
16086
|
}
|
|
15974
|
-
case "CLOSED_COMPLETE"
|
|
16087
|
+
case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
|
|
15975
16088
|
return {
|
|
15976
16089
|
label: "Books completed",
|
|
15977
16090
|
description: `Your ${monthName} books are complete and ready to view!`,
|
|
@@ -15979,7 +16092,7 @@ function getBookkeepingStatusConfig({
|
|
|
15979
16092
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(CheckCircle_default, { size: 12 })
|
|
15980
16093
|
};
|
|
15981
16094
|
}
|
|
15982
|
-
case "BOOKKEEPING_NOT_ACTIVE"
|
|
16095
|
+
case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
|
|
15983
16096
|
return;
|
|
15984
16097
|
}
|
|
15985
16098
|
default: {
|
|
@@ -15994,7 +16107,7 @@ function getBookkeepingStatusConfig({
|
|
|
15994
16107
|
|
|
15995
16108
|
// src/components/BookkeepingStatus/BookkeepingStatus.tsx
|
|
15996
16109
|
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
15997
|
-
var
|
|
16110
|
+
var BookkeepingStatus2 = ({ status, text, monthNumber, iconOnly }) => {
|
|
15998
16111
|
if (!status) {
|
|
15999
16112
|
return;
|
|
16000
16113
|
}
|
|
@@ -16019,7 +16132,7 @@ var BookkeepingStatus = ({ status, text, monthNumber, iconOnly }) => {
|
|
|
16019
16132
|
// src/components/BankTransactionList/BankTransactionProcessingInfo.tsx
|
|
16020
16133
|
var import_jsx_runtime123 = require("react/jsx-runtime");
|
|
16021
16134
|
var BankTransactionProcessingInfo = () => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Tooltip, { offset: 12, children: [
|
|
16022
|
-
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
16135
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(BookkeepingStatus2, { status: "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */, text: "Processing" }) }),
|
|
16023
16136
|
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(TooltipContent, { className: "Layer__tooltip", width: "md", children: "Our team will review and categorize this transaction. We'll reach out if we have any questions about it." })
|
|
16024
16137
|
] });
|
|
16025
16138
|
|
|
@@ -18121,7 +18234,7 @@ function TransactionsActions({ children }) {
|
|
|
18121
18234
|
|
|
18122
18235
|
// src/hooks/useBankTransactions/useBankTransactionsDownload.ts
|
|
18123
18236
|
var import_mutation6 = __toESM(require("swr/mutation"));
|
|
18124
|
-
function
|
|
18237
|
+
function buildKey13({
|
|
18125
18238
|
access_token: accessToken,
|
|
18126
18239
|
apiUrl,
|
|
18127
18240
|
businessId
|
|
@@ -18139,7 +18252,7 @@ function useBankTransactionsDownload() {
|
|
|
18139
18252
|
const { data } = useAuth();
|
|
18140
18253
|
const { businessId } = useLayerContext();
|
|
18141
18254
|
return (0, import_mutation6.default)(
|
|
18142
|
-
() =>
|
|
18255
|
+
() => buildKey13(__spreadProps(__spreadValues({}, data), {
|
|
18143
18256
|
businessId
|
|
18144
18257
|
})),
|
|
18145
18258
|
({
|
|
@@ -18526,7 +18639,7 @@ var BankTransactionsContent = ({
|
|
|
18526
18639
|
}, [monthlyView, isVisible, isLoading, hasMore]);
|
|
18527
18640
|
(0, import_react82.useEffect)(() => {
|
|
18528
18641
|
if (JSON.stringify(inputFilters) !== JSON.stringify(filters)) {
|
|
18529
|
-
if (effectiveBookkeepingStatus === "ACTIVE") {
|
|
18642
|
+
if (effectiveBookkeepingStatus === "ACTIVE" /* ACTIVE */) {
|
|
18530
18643
|
setFilters(__spreadProps(__spreadValues(__spreadValues({}, filters), inputFilters), {
|
|
18531
18644
|
categorizationStatus: "all" /* all */
|
|
18532
18645
|
}));
|
|
@@ -18697,13 +18810,13 @@ var BankTransactionsContent = ({
|
|
|
18697
18810
|
};
|
|
18698
18811
|
|
|
18699
18812
|
// src/components/Integrations/Integrations.tsx
|
|
18700
|
-
var
|
|
18813
|
+
var import_react91 = require("react");
|
|
18701
18814
|
|
|
18702
18815
|
// src/components/Integrations/IntegrationsContent.tsx
|
|
18703
|
-
var
|
|
18816
|
+
var import_react87 = require("react");
|
|
18704
18817
|
|
|
18705
18818
|
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
|
|
18706
|
-
var
|
|
18819
|
+
var import_react86 = require("react");
|
|
18707
18820
|
|
|
18708
18821
|
// src/icons/QuickbooksIcon.tsx
|
|
18709
18822
|
var import_jsx_runtime153 = require("react/jsx-runtime");
|
|
@@ -18792,214 +18905,326 @@ var Card = ({ children, className }) => {
|
|
|
18792
18905
|
var import_react83 = require("react");
|
|
18793
18906
|
var QuickbooksContext = (0, import_react83.createContext)({
|
|
18794
18907
|
linkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
|
|
18795
|
-
unlinkQuickbooks: () =>
|
|
18796
|
-
throw new Error("QuickbooksContext used without Provider");
|
|
18797
|
-
},
|
|
18908
|
+
unlinkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
|
|
18798
18909
|
syncFromQuickbooks: () => {
|
|
18799
18910
|
throw new Error("QuickbooksContext used without Provider");
|
|
18800
18911
|
},
|
|
18801
|
-
|
|
18802
|
-
quickbooksIsConnected: false,
|
|
18803
|
-
quickbooksLastSyncedAt: void 0
|
|
18912
|
+
quickbooksConnectionStatus: void 0
|
|
18804
18913
|
});
|
|
18805
18914
|
|
|
18806
18915
|
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumbFooter.tsx
|
|
18807
18916
|
var import_react84 = require("react");
|
|
18808
18917
|
var import_date_fns23 = require("date-fns");
|
|
18918
|
+
|
|
18919
|
+
// src/components/Integrations/IntegrationsQuickbooksItemThumb/utils.ts
|
|
18920
|
+
var getQuickbooksConnectionSyncUiState = (quickbooksConnectionStatus) => {
|
|
18921
|
+
var _a;
|
|
18922
|
+
const isSyncing = (_a = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_syncing) != null ? _a : false;
|
|
18923
|
+
const lastSyncedAt = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_synced_at;
|
|
18924
|
+
const syncFailed = (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_sync_status) === "SYNC_FAILURE" /* SYNC_FAILURE */;
|
|
18925
|
+
if (isSyncing) {
|
|
18926
|
+
return "Syncing" /* Syncing */;
|
|
18927
|
+
}
|
|
18928
|
+
if (lastSyncedAt) {
|
|
18929
|
+
return syncFailed ? "SyncFailed" /* SyncFailed */ : "SyncSuccess" /* SyncSuccess */;
|
|
18930
|
+
}
|
|
18931
|
+
return "Connected" /* Connected */;
|
|
18932
|
+
};
|
|
18933
|
+
|
|
18934
|
+
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumbFooter.tsx
|
|
18809
18935
|
var import_jsx_runtime157 = require("react/jsx-runtime");
|
|
18810
18936
|
var formatLastSyncedAt = (datetime) => {
|
|
18811
18937
|
const parsed = new Date(datetime);
|
|
18812
18938
|
if (!(0, import_date_fns23.isValid)(parsed)) return "";
|
|
18813
18939
|
return `${(0, import_date_fns23.format)(parsed, "MMMM d, yyyy")} at ${(0, import_date_fns23.format)(parsed, "h:mm a")}`;
|
|
18814
18940
|
};
|
|
18815
|
-
var
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18941
|
+
var getFooterConfig = (quickbooksUiState, lastSyncedAt) => {
|
|
18942
|
+
switch (quickbooksUiState) {
|
|
18943
|
+
case "Syncing" /* Syncing */: {
|
|
18944
|
+
return {
|
|
18945
|
+
title: "Syncing account data",
|
|
18946
|
+
description: "This may take up to 5 minutes",
|
|
18947
|
+
badgeVariant: "info"
|
|
18948
|
+
};
|
|
18949
|
+
}
|
|
18950
|
+
case "SyncFailed" /* SyncFailed */: {
|
|
18951
|
+
return {
|
|
18952
|
+
title: "Last sync failed at",
|
|
18953
|
+
description: formatLastSyncedAt(lastSyncedAt),
|
|
18954
|
+
badgeVariant: "error"
|
|
18955
|
+
};
|
|
18956
|
+
}
|
|
18957
|
+
case "SyncSuccess" /* SyncSuccess */: {
|
|
18958
|
+
return {
|
|
18959
|
+
title: "Last synced on",
|
|
18960
|
+
description: formatLastSyncedAt(lastSyncedAt),
|
|
18961
|
+
badgeVariant: "success"
|
|
18962
|
+
};
|
|
18963
|
+
}
|
|
18964
|
+
case "Connected" /* Connected */:
|
|
18965
|
+
default: {
|
|
18966
|
+
return {
|
|
18967
|
+
title: "Connected to QuickBooks",
|
|
18968
|
+
badgeVariant: "success"
|
|
18969
|
+
};
|
|
18970
|
+
}
|
|
18839
18971
|
}
|
|
18972
|
+
};
|
|
18973
|
+
var IntegrationsQuickbooksItemThumbFooter = ({ quickbooksUiState }) => {
|
|
18974
|
+
const { quickbooksConnectionStatus } = (0, import_react84.useContext)(QuickbooksContext);
|
|
18975
|
+
if (!quickbooksConnectionStatus) return null;
|
|
18976
|
+
const { title, description, badgeVariant } = getFooterConfig(quickbooksUiState, quickbooksConnectionStatus.last_synced_at);
|
|
18840
18977
|
return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(HStack, { className: "loadingbar", children: [
|
|
18841
18978
|
/* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(VStack, { children: [
|
|
18842
|
-
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children:
|
|
18843
|
-
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children:
|
|
18979
|
+
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children: title }),
|
|
18980
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, className: "syncing-data-description", children: description })
|
|
18844
18981
|
] }),
|
|
18845
18982
|
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Spacer, {}),
|
|
18846
|
-
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant:
|
|
18983
|
+
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: badgeVariant })
|
|
18847
18984
|
] });
|
|
18848
18985
|
};
|
|
18849
18986
|
|
|
18850
18987
|
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
|
|
18988
|
+
var import_lucide_react6 = require("lucide-react");
|
|
18989
|
+
|
|
18990
|
+
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksUnlinkConfirmationModal.tsx
|
|
18991
|
+
var import_react85 = require("react");
|
|
18851
18992
|
var import_jsx_runtime158 = require("react/jsx-runtime");
|
|
18993
|
+
function IntegrationsQuickbooksUnlinkConfirmationModalContent({ onClose }) {
|
|
18994
|
+
const { unlinkQuickbooks } = (0, import_react85.useContext)(QuickbooksContext);
|
|
18995
|
+
const [isProcessing, setIsProcessing] = (0, import_react85.useState)(false);
|
|
18996
|
+
const [hasFailed, setHasFailed] = (0, import_react85.useState)(false);
|
|
18997
|
+
const unlinkErrorText = "Unlink failed. Check connection and retry in few seconds.";
|
|
18998
|
+
const onClickUnlinkQuickbooks = (0, import_react85.useCallback)(() => {
|
|
18999
|
+
setIsProcessing(true);
|
|
19000
|
+
unlinkQuickbooks().then(() => {
|
|
19001
|
+
onClose();
|
|
19002
|
+
}).catch(() => {
|
|
19003
|
+
setHasFailed(true);
|
|
19004
|
+
setIsProcessing(false);
|
|
19005
|
+
});
|
|
19006
|
+
}, [unlinkQuickbooks, onClose]);
|
|
19007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
|
|
19008
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalContextBar, { onClose }),
|
|
19009
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalHeading, { pbe: "2xs", children: "Unlink QuickBooks" }),
|
|
19010
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalContent, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(P, { children: "Please confirm that you want to unlink QuickBooks." }) }),
|
|
19011
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ModalActions, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(HStack, { gap: "md", children: [
|
|
19012
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Spacer, {}),
|
|
19013
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Button, { variant: "secondary" /* secondary */, onClick: onClose, children: "Cancel" }),
|
|
19014
|
+
!hasFailed ? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
19015
|
+
Button,
|
|
19016
|
+
{
|
|
19017
|
+
variant: "primary" /* primary */,
|
|
19018
|
+
onClick: onClickUnlinkQuickbooks,
|
|
19019
|
+
isProcessing,
|
|
19020
|
+
disabled: isProcessing,
|
|
19021
|
+
children: "Unlink QuickBooks"
|
|
19022
|
+
}
|
|
19023
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
19024
|
+
RetryButton,
|
|
19025
|
+
{
|
|
19026
|
+
onClick: onClickUnlinkQuickbooks,
|
|
19027
|
+
processing: isProcessing,
|
|
19028
|
+
disabled: isProcessing,
|
|
19029
|
+
error: unlinkErrorText,
|
|
19030
|
+
children: "Retry Unlink QuickBooks"
|
|
19031
|
+
}
|
|
19032
|
+
)
|
|
19033
|
+
] }) })
|
|
19034
|
+
] });
|
|
19035
|
+
}
|
|
19036
|
+
function IntegrationsQuickbooksUnlinkConfirmationModal({ isOpen, onOpenChange }) {
|
|
19037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(Modal, { flexBlock: true, isOpen, onOpenChange, children: ({ close: close2 }) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(IntegrationsQuickbooksUnlinkConfirmationModalContent, { onClose: close2 }) });
|
|
19038
|
+
}
|
|
19039
|
+
|
|
19040
|
+
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
|
|
19041
|
+
var import_jsx_runtime159 = require("react/jsx-runtime");
|
|
19042
|
+
var getBadgeConfig = (quickbooksUiState, hasSynced) => {
|
|
19043
|
+
if (!hasSynced) {
|
|
19044
|
+
return {
|
|
19045
|
+
variant: "info" /* INFO */,
|
|
19046
|
+
text: "Sync",
|
|
19047
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RefreshCcw_default, { size: 12 })
|
|
19048
|
+
};
|
|
19049
|
+
}
|
|
19050
|
+
switch (quickbooksUiState) {
|
|
19051
|
+
case "SyncFailed" /* SyncFailed */: {
|
|
19052
|
+
return {
|
|
19053
|
+
variant: "error" /* ERROR */,
|
|
19054
|
+
text: "Retry Sync",
|
|
19055
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_lucide_react6.AlertCircle, { size: 12 })
|
|
19056
|
+
};
|
|
19057
|
+
}
|
|
19058
|
+
case "Connected" /* Connected */:
|
|
19059
|
+
case "SyncSuccess" /* SyncSuccess */: {
|
|
19060
|
+
return {
|
|
19061
|
+
variant: "success" /* SUCCESS */,
|
|
19062
|
+
text: "Synced",
|
|
19063
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_lucide_react6.CheckIcon, { size: 12 })
|
|
19064
|
+
};
|
|
19065
|
+
}
|
|
19066
|
+
default:
|
|
19067
|
+
case "Syncing" /* Syncing */: {
|
|
19068
|
+
return {
|
|
19069
|
+
variant: "info" /* INFO */,
|
|
19070
|
+
text: "Sync",
|
|
19071
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RefreshCcw_default, { size: 12 })
|
|
19072
|
+
};
|
|
19073
|
+
}
|
|
19074
|
+
}
|
|
19075
|
+
};
|
|
18852
19076
|
var IntegrationsQuickbooksItemThumb = () => {
|
|
18853
|
-
const {
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
19077
|
+
const { quickbooksConnectionStatus, syncFromQuickbooks: syncFromQuickbooks2 } = (0, import_react86.useContext)(QuickbooksContext);
|
|
19078
|
+
const [hasSynced, setHasSynced] = (0, import_react86.useState)(false);
|
|
19079
|
+
const [isConfirmationModalOpen, setIsConfirmationModalOpen] = (0, import_react86.useState)(false);
|
|
19080
|
+
const onSync = (0, import_react86.useCallback)(() => {
|
|
19081
|
+
setHasSynced(true);
|
|
19082
|
+
syncFromQuickbooks2();
|
|
19083
|
+
}, [syncFromQuickbooks2]);
|
|
19084
|
+
const menuConfig = (0, import_react86.useMemo)(() => {
|
|
18859
19085
|
return [
|
|
18860
19086
|
{
|
|
18861
19087
|
name: "Unlink account",
|
|
18862
19088
|
action: () => {
|
|
18863
|
-
|
|
18864
|
-
unlinkQuickbooks();
|
|
18865
|
-
}
|
|
19089
|
+
setIsConfirmationModalOpen(true);
|
|
18866
19090
|
}
|
|
18867
19091
|
}
|
|
18868
19092
|
];
|
|
18869
|
-
}, [
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
19093
|
+
}, []);
|
|
19094
|
+
if (!quickbooksConnectionStatus) return null;
|
|
19095
|
+
const quickbooksUiState = getQuickbooksConnectionSyncUiState(quickbooksConnectionStatus);
|
|
19096
|
+
const badgeConfig = getBadgeConfig(quickbooksUiState, hasSynced);
|
|
19097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(LinkedAccountOptions, { config: menuConfig, children: [
|
|
19098
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(Card, { className: "Layer__linked-account-thumb Layer__integrations-quickbooks-item-thumb", children: [
|
|
19099
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { className: "topbar", children: [
|
|
19100
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(HStack, { gap: "xs", children: [
|
|
19101
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)(Text, { size: "md" /* md */, children: "QuickBooks" }),
|
|
19102
|
+
quickbooksUiState === "Syncing" /* Syncing */ ? /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(BadgeLoader, { variant: "info" /* INFO */ }) : /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
|
|
19103
|
+
Badge,
|
|
19104
|
+
{
|
|
19105
|
+
"aria-role": "button",
|
|
19106
|
+
icon: badgeConfig.icon,
|
|
19107
|
+
variant: badgeConfig.variant,
|
|
19108
|
+
onClick: onSync,
|
|
19109
|
+
size: "small" /* SMALL */,
|
|
19110
|
+
hoverable: true,
|
|
19111
|
+
children: badgeConfig.text
|
|
19112
|
+
}
|
|
19113
|
+
)
|
|
19114
|
+
] }),
|
|
19115
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)("div", { className: "topbar-logo", children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(QuickbooksIcon_default, { size: 28 }) })
|
|
18886
19116
|
] }),
|
|
18887
|
-
/* @__PURE__ */ (0,
|
|
19117
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksItemThumbFooter, { quickbooksUiState })
|
|
18888
19118
|
] }),
|
|
18889
|
-
/* @__PURE__ */ (0,
|
|
18890
|
-
] })
|
|
19119
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksUnlinkConfirmationModal, { isOpen: isConfirmationModalOpen, onOpenChange: setIsConfirmationModalOpen })
|
|
19120
|
+
] });
|
|
18891
19121
|
};
|
|
18892
19122
|
|
|
18893
19123
|
// src/components/Integrations/IntegrationsContent.tsx
|
|
18894
|
-
var
|
|
19124
|
+
var import_jsx_runtime160 = require("react/jsx-runtime");
|
|
18895
19125
|
var IntegrationsContent = () => {
|
|
18896
|
-
const {
|
|
18897
|
-
return /* @__PURE__ */ (0,
|
|
19126
|
+
const { quickbooksConnectionStatus } = (0, import_react87.useContext)(QuickbooksContext);
|
|
19127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "Layer__linked-accounts__list", children: (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(IntegrationsQuickbooksItemThumb, {}) });
|
|
18898
19128
|
};
|
|
18899
19129
|
|
|
18900
19130
|
// src/hooks/useQuickbooks/useQuickbooks.ts
|
|
18901
|
-
var
|
|
19131
|
+
var import_react88 = require("react");
|
|
19132
|
+
var import_date_fns24 = require("date-fns");
|
|
18902
19133
|
var useQuickbooks = () => {
|
|
19134
|
+
var _a;
|
|
18903
19135
|
const { businessId } = useLayerContext();
|
|
18904
19136
|
const { apiUrl } = useEnvironment();
|
|
18905
19137
|
const { data: auth } = useAuth();
|
|
18906
|
-
const [
|
|
18907
|
-
const
|
|
18908
|
-
const syncStatusIntervalRef = (0,
|
|
18909
|
-
const
|
|
18910
|
-
const fetchQuickbooksConnectionStatus = (0, import_react87.useCallback)(() => __async(null, null, function* () {
|
|
19138
|
+
const [quickbooksConnectionStatus, setQuickbooksConnectionStatus] = (0, import_react88.useState)(void 0);
|
|
19139
|
+
const isSyncingFromQuickbooks = (_a = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_syncing) != null ? _a : false;
|
|
19140
|
+
const syncStatusIntervalRef = (0, import_react88.useRef)(null);
|
|
19141
|
+
const fetchQuickbooksConnectionStatus = (0, import_react88.useCallback)(() => __async(null, null, function* () {
|
|
18911
19142
|
const newQuickbooksConnectionStatus = (yield Layer.statusOfQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18912
19143
|
params: { businessId }
|
|
18913
19144
|
})()).data;
|
|
18914
19145
|
setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
|
|
18915
19146
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setQuickbooksConnectionStatus]);
|
|
18916
|
-
|
|
18917
|
-
const isSyncing = (yield Layer.statusOfSyncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18918
|
-
params: { businessId }
|
|
18919
|
-
})()).data.is_syncing;
|
|
18920
|
-
const wasSyncing = wasSyncingFromQuickbooksRef.current;
|
|
18921
|
-
wasSyncingFromQuickbooksRef.current = isSyncing;
|
|
18922
|
-
setIsSyncingFromQuickbooks(isSyncing);
|
|
18923
|
-
if (!isSyncing && wasSyncing) {
|
|
18924
|
-
yield fetchQuickbooksConnectionStatus();
|
|
18925
|
-
}
|
|
18926
|
-
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks, fetchQuickbooksConnectionStatus]);
|
|
18927
|
-
(0, import_react87.useEffect)(() => {
|
|
19147
|
+
(0, import_react88.useEffect)(() => {
|
|
18928
19148
|
if (isSyncingFromQuickbooks && syncStatusIntervalRef.current === null) {
|
|
18929
|
-
const interval = window.setInterval(() => void
|
|
19149
|
+
const interval = window.setInterval(() => void fetchQuickbooksConnectionStatus(), 2e3);
|
|
18930
19150
|
syncStatusIntervalRef.current = interval;
|
|
18931
19151
|
return () => clearInterval(interval);
|
|
18932
19152
|
} else if (!isSyncingFromQuickbooks && syncStatusIntervalRef.current) {
|
|
18933
19153
|
clearInterval(syncStatusIntervalRef.current);
|
|
18934
19154
|
syncStatusIntervalRef.current = null;
|
|
18935
19155
|
}
|
|
18936
|
-
}, [
|
|
18937
|
-
(0,
|
|
19156
|
+
}, [fetchQuickbooksConnectionStatus, isSyncingFromQuickbooks]);
|
|
19157
|
+
(0, import_react88.useEffect)(() => {
|
|
18938
19158
|
if (auth == null ? void 0 : auth.access_token) {
|
|
18939
19159
|
void fetchQuickbooksConnectionStatus();
|
|
18940
19160
|
}
|
|
18941
19161
|
}, [auth == null ? void 0 : auth.access_token, fetchQuickbooksConnectionStatus]);
|
|
18942
|
-
const
|
|
18943
|
-
|
|
18944
|
-
|
|
19162
|
+
const handleSyncError = (0, import_react88.useCallback)(() => {
|
|
19163
|
+
setQuickbooksConnectionStatus({
|
|
19164
|
+
is_connected: true,
|
|
19165
|
+
is_syncing: false,
|
|
19166
|
+
last_sync_status: "SYNC_FAILURE" /* SYNC_FAILURE */,
|
|
19167
|
+
last_synced_at: (0, import_date_fns24.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd'T'HH:mm:ss")
|
|
19168
|
+
});
|
|
19169
|
+
}, []);
|
|
19170
|
+
const syncFromQuickbooks2 = (0, import_react88.useCallback)(() => {
|
|
19171
|
+
const newQuickbooksConnectionStatus = quickbooksConnectionStatus ? __spreadProps(__spreadValues({}, quickbooksConnectionStatus), { is_syncing: true }) : void 0;
|
|
19172
|
+
setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
|
|
18945
19173
|
void Layer.syncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18946
19174
|
params: { businessId }
|
|
18947
|
-
});
|
|
18948
|
-
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId,
|
|
18949
|
-
const linkQuickbooks = (0,
|
|
18950
|
-
|
|
19175
|
+
}).catch(handleSyncError);
|
|
19176
|
+
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, quickbooksConnectionStatus, handleSyncError]);
|
|
19177
|
+
const linkQuickbooks = (0, import_react88.useCallback)(() => __async(null, null, function* () {
|
|
19178
|
+
return Layer.initQuickbooksOAuth(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18951
19179
|
params: { businessId }
|
|
18952
|
-
});
|
|
18953
|
-
return res.data.redirect_url;
|
|
19180
|
+
}).then((res) => res.data.redirect_url);
|
|
18954
19181
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId]);
|
|
18955
|
-
const unlinkQuickbooks = (0,
|
|
18956
|
-
|
|
19182
|
+
const unlinkQuickbooks = (0, import_react88.useCallback)(() => __async(null, null, function* () {
|
|
19183
|
+
return Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18957
19184
|
params: { businessId }
|
|
18958
19185
|
}).then(() => fetchQuickbooksConnectionStatus());
|
|
18959
|
-
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
|
|
19186
|
+
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
|
|
18960
19187
|
return {
|
|
18961
|
-
isSyncingFromQuickbooks,
|
|
18962
19188
|
syncFromQuickbooks: syncFromQuickbooks2,
|
|
18963
|
-
quickbooksIsConnected: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected,
|
|
18964
|
-
quickbooksLastSyncedAt: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_synced_at,
|
|
18965
19189
|
linkQuickbooks,
|
|
18966
|
-
unlinkQuickbooks
|
|
19190
|
+
unlinkQuickbooks,
|
|
19191
|
+
quickbooksConnectionStatus
|
|
18967
19192
|
};
|
|
18968
19193
|
};
|
|
18969
19194
|
|
|
18970
19195
|
// src/providers/QuickbooksContextProvider/QuickbooksContextProvider.tsx
|
|
18971
|
-
var
|
|
19196
|
+
var import_jsx_runtime161 = require("react/jsx-runtime");
|
|
18972
19197
|
function QuickbooksContextProvider({ children }) {
|
|
18973
19198
|
const quickbooksContextData = useQuickbooks();
|
|
18974
|
-
return /* @__PURE__ */ (0,
|
|
19199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(QuickbooksContext.Provider, { value: quickbooksContextData, children });
|
|
18975
19200
|
}
|
|
18976
19201
|
|
|
18977
19202
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
18978
|
-
var
|
|
19203
|
+
var import_react90 = require("react");
|
|
18979
19204
|
|
|
18980
19205
|
// src/components/ui/DropdownMenu/DropdownMenu.tsx
|
|
18981
19206
|
var import_react_aria_components11 = require("react-aria-components");
|
|
18982
|
-
var
|
|
18983
|
-
var Heading3 = ({ children }) => /* @__PURE__ */ (0,
|
|
18984
|
-
var MenuItem3 = ({ children, onClick, isDisabled }) => /* @__PURE__ */ (0,
|
|
18985
|
-
var MenuList = ({ children }) => /* @__PURE__ */ (0,
|
|
19207
|
+
var import_jsx_runtime162 = require("react/jsx-runtime");
|
|
19208
|
+
var Heading3 = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Text, { size: "sm" /* sm */, weight: "bold" /* bold */, className: "Layer__dropdown-menu__menu-item__heading", children }) });
|
|
19209
|
+
var MenuItem3 = ({ children, onClick, isDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.MenuItem, { onAction: onClick, isDisabled, className: "Layer__dropdown-menu__menu-item", children });
|
|
19210
|
+
var MenuList = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Menu, { className: "Layer__dropdown-menu__menu-list", children });
|
|
18986
19211
|
var DropdownMenu = ({ children, ariaLabel, slots, slotProps }) => {
|
|
18987
19212
|
var _a;
|
|
18988
19213
|
const { Trigger } = slots;
|
|
18989
19214
|
const width = (_a = slotProps == null ? void 0 : slotProps.Dialog) == null ? void 0 : _a.width;
|
|
18990
|
-
return /* @__PURE__ */ (0,
|
|
18991
|
-
/* @__PURE__ */ (0,
|
|
18992
|
-
/* @__PURE__ */ (0,
|
|
19215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_react_aria_components11.MenuTrigger, { children: [
|
|
19216
|
+
/* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Trigger, { "aria-label": "Menu" }),
|
|
19217
|
+
/* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Popover, { placement: "bottom right", className: "Layer__dropdown-menu__popover Layer__variables", children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_react_aria_components11.Dialog, { className: "Layer__dropdown-menu__menu", "aria-label": ariaLabel, style: { width }, children }) })
|
|
18993
19218
|
] });
|
|
18994
19219
|
};
|
|
18995
19220
|
|
|
18996
19221
|
// src/icons/Cog.tsx
|
|
18997
|
-
var
|
|
18998
|
-
var
|
|
19222
|
+
var import_react89 = require("react");
|
|
19223
|
+
var import_jsx_runtime163 = require("react/jsx-runtime");
|
|
18999
19224
|
var Cog = (_a) => {
|
|
19000
19225
|
var _b = _a, { size = 12 } = _b, props = __objRest(_b, ["size"]);
|
|
19001
|
-
const id = (0,
|
|
19002
|
-
return /* @__PURE__ */ (0,
|
|
19226
|
+
const id = (0, import_react89.useId)();
|
|
19227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
|
|
19003
19228
|
"svg",
|
|
19004
19229
|
__spreadProps(__spreadValues({
|
|
19005
19230
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -19009,11 +19234,11 @@ var Cog = (_a) => {
|
|
|
19009
19234
|
height: size
|
|
19010
19235
|
}, props), {
|
|
19011
19236
|
children: [
|
|
19012
|
-
/* @__PURE__ */ (0,
|
|
19013
|
-
/* @__PURE__ */ (0,
|
|
19014
|
-
/* @__PURE__ */ (0,
|
|
19237
|
+
/* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("g", { clipPath: "url(#clip0_6610_12208)", children: [
|
|
19238
|
+
/* @__PURE__ */ (0, import_jsx_runtime163.jsx)("path", { d: "M6 7.5C6.82843 7.5 7.5 6.82843 7.5 6C7.5 5.17157 6.82843 4.5 6 4.5C5.17157 4.5 4.5 5.17157 4.5 6C4.5 6.82843 5.17157 7.5 6 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
19239
|
+
/* @__PURE__ */ (0, import_jsx_runtime163.jsx)("path", { d: "M9.7 7.5C9.63344 7.65081 9.61359 7.8181 9.643 7.98029C9.67241 8.14249 9.74973 8.29216 9.865 8.41L9.895 8.44C9.98798 8.53287 10.0617 8.64316 10.1121 8.76456C10.1624 8.88596 10.1883 9.01608 10.1883 9.1475C10.1883 9.27892 10.1624 9.40904 10.1121 9.53044C10.0617 9.65184 9.98798 9.76213 9.895 9.855C9.80213 9.94798 9.69184 10.0217 9.57044 10.0721C9.44904 10.1224 9.31892 10.1483 9.1875 10.1483C9.05608 10.1483 8.92596 10.1224 8.80456 10.0721C8.68316 10.0217 8.57287 9.94798 8.48 9.855L8.45 9.825C8.33216 9.70973 8.18249 9.63241 8.02029 9.603C7.8581 9.57359 7.69081 9.59344 7.54 9.66C7.39212 9.72338 7.26599 9.82862 7.17715 9.96277C7.08832 10.0969 7.04064 10.2541 7.04 10.415V10.5C7.04 10.7652 6.93464 11.0196 6.74711 11.2071C6.55957 11.3946 6.30522 11.5 6.04 11.5C5.77478 11.5 5.52043 11.3946 5.33289 11.2071C5.14536 11.0196 5.04 10.7652 5.04 10.5V10.455C5.03613 10.2895 4.98256 10.129 4.88626 9.99435C4.78995 9.8597 4.65537 9.75714 4.5 9.7C4.34919 9.63344 4.1819 9.61359 4.01971 9.643C3.85751 9.67241 3.70784 9.74973 3.59 9.865L3.56 9.895C3.46713 9.98798 3.35684 10.0617 3.23544 10.1121C3.11404 10.1624 2.98392 10.1883 2.8525 10.1883C2.72108 10.1883 2.59096 10.1624 2.46956 10.1121C2.34816 10.0617 2.23787 9.98798 2.145 9.895C2.05202 9.80213 1.97826 9.69184 1.92794 9.57044C1.87762 9.44904 1.85171 9.31892 1.85171 9.1875C1.85171 9.05608 1.87762 8.92596 1.92794 8.80456C1.97826 8.68316 2.05202 8.57287 2.145 8.48L2.175 8.45C2.29027 8.33216 2.36759 8.18249 2.397 8.02029C2.42641 7.8581 2.40656 7.69081 2.34 7.54C2.27662 7.39212 2.17138 7.26599 2.03723 7.17715C1.90309 7.08832 1.74589 7.04064 1.585 7.04H1.5C1.23478 7.04 0.98043 6.93464 0.792893 6.74711C0.605357 6.55957 0.5 6.30522 0.5 6.04C0.5 5.77478 0.605357 5.52043 0.792893 5.33289C0.98043 5.14536 1.23478 5.04 1.5 5.04H1.545C1.7105 5.03613 1.871 4.98256 2.00565 4.88626C2.1403 4.78995 2.24286 4.65537 2.3 4.5C2.36656 4.34919 2.38641 4.1819 2.357 4.01971C2.32759 3.85751 2.25027 3.70784 2.135 3.59L2.105 3.56C2.01202 3.46713 1.93826 3.35684 1.88794 3.23544C1.83762 3.11404 1.81171 2.98392 1.81171 2.8525C1.81171 2.72108 1.83762 2.59096 1.88794 2.46956C1.93826 2.34816 2.01202 2.23787 2.105 2.145C2.19787 2.05202 2.30816 1.97826 2.42956 1.92794C2.55096 1.87762 2.68108 1.85171 2.8125 1.85171C2.94392 1.85171 3.07404 1.87762 3.19544 1.92794C3.31684 1.97826 3.42713 2.05202 3.52 2.145L3.55 2.175C3.66784 2.29027 3.81751 2.36759 3.97971 2.397C4.1419 2.42641 4.30919 2.40656 4.46 2.34H4.5C4.64788 2.27662 4.77401 2.17138 4.86285 2.03723C4.95168 1.90309 4.99936 1.74589 5 1.585V1.5C5 1.23478 5.10536 0.98043 5.29289 0.792893C5.48043 0.605357 5.73478 0.5 6 0.5C6.26522 0.5 6.51957 0.605357 6.70711 0.792893C6.89464 0.98043 7 1.23478 7 1.5V1.545C7.00064 1.70589 7.04832 1.86309 7.13715 1.99723C7.22599 2.13138 7.35212 2.23662 7.5 2.3C7.65081 2.36656 7.8181 2.38641 7.98029 2.357C8.14249 2.32759 8.29216 2.25027 8.41 2.135L8.44 2.105C8.53287 2.01202 8.64316 1.93826 8.76456 1.88794C8.88596 1.83762 9.01608 1.81171 9.1475 1.81171C9.27892 1.81171 9.40904 1.83762 9.53044 1.88794C9.65184 1.93826 9.76213 2.01202 9.855 2.105C9.94798 2.19787 10.0217 2.30816 10.0721 2.42956C10.1224 2.55096 10.1483 2.68108 10.1483 2.8125C10.1483 2.94392 10.1224 3.07404 10.0721 3.19544C10.0217 3.31684 9.94798 3.42713 9.855 3.52L9.825 3.55C9.70973 3.66784 9.63241 3.81751 9.603 3.97971C9.57359 4.1419 9.59344 4.30919 9.66 4.46V4.5C9.72338 4.64788 9.82862 4.77401 9.96277 4.86285C10.0969 4.95168 10.2541 4.99936 10.415 5H10.5C10.7652 5 11.0196 5.10536 11.2071 5.29289C11.3946 5.48043 11.5 5.73478 11.5 6C11.5 6.26522 11.3946 6.51957 11.2071 6.70711C11.0196 6.89464 10.7652 7 10.5 7H10.455C10.2941 7.00064 10.1369 7.04832 10.0028 7.13715C9.86862 7.22599 9.76338 7.35212 9.7 7.5Z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
19015
19240
|
] }),
|
|
19016
|
-
/* @__PURE__ */ (0,
|
|
19241
|
+
/* @__PURE__ */ (0, import_jsx_runtime163.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("clipPath", { id, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("rect", { width: "12", height: "12", fill: "white" }) }) })
|
|
19017
19242
|
]
|
|
19018
19243
|
})
|
|
19019
19244
|
);
|
|
@@ -19021,38 +19246,42 @@ var Cog = (_a) => {
|
|
|
19021
19246
|
var Cog_default = Cog;
|
|
19022
19247
|
|
|
19023
19248
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
19024
|
-
var
|
|
19025
|
-
var MenuTriggerButton = () => /* @__PURE__ */ (0,
|
|
19249
|
+
var import_jsx_runtime164 = require("react/jsx-runtime");
|
|
19250
|
+
var MenuTriggerButton = () => /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(Button2, { variant: "ghost", children: [
|
|
19026
19251
|
"Manage",
|
|
19027
|
-
/* @__PURE__ */ (0,
|
|
19252
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Cog_default, { size: 16 })
|
|
19028
19253
|
] });
|
|
19029
19254
|
var IntegrationsConnectMenu = () => {
|
|
19030
|
-
const {
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
const initiateQuickbooksOAuth = (0,
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19255
|
+
const { addToast } = useLayerContext();
|
|
19256
|
+
const { quickbooksConnectionStatus, linkQuickbooks } = (0, import_react90.useContext)(QuickbooksContext);
|
|
19257
|
+
const quickbooksIsConnected = quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected;
|
|
19258
|
+
const [isLinkQuickbooksError, setIsLinkQuickbooksError] = (0, import_react90.useState)(false);
|
|
19259
|
+
const initiateQuickbooksOAuth = (0, import_react90.useCallback)(() => {
|
|
19260
|
+
linkQuickbooks().then((res) => {
|
|
19261
|
+
window.location.href = res;
|
|
19262
|
+
}).catch(() => {
|
|
19263
|
+
setIsLinkQuickbooksError(true);
|
|
19264
|
+
addToast({ content: "Failed to connect QuickBooks", type: "error" });
|
|
19265
|
+
});
|
|
19266
|
+
}, [linkQuickbooks, addToast]);
|
|
19267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
|
|
19039
19268
|
DropdownMenu,
|
|
19040
19269
|
{
|
|
19041
19270
|
ariaLabel: "Connect Integration",
|
|
19042
19271
|
slots: { Trigger: MenuTriggerButton },
|
|
19043
19272
|
slotProps: { Dialog: { width: 280 } },
|
|
19044
19273
|
children: [
|
|
19045
|
-
/* @__PURE__ */ (0,
|
|
19046
|
-
/* @__PURE__ */ (0,
|
|
19047
|
-
/* @__PURE__ */ (0,
|
|
19048
|
-
/* @__PURE__ */ (0,
|
|
19049
|
-
/* @__PURE__ */ (0,
|
|
19050
|
-
/* @__PURE__ */ (0,
|
|
19051
|
-
] }, "quickbooks-connected") : /* @__PURE__ */ (0,
|
|
19052
|
-
/* @__PURE__ */ (0,
|
|
19053
|
-
/* @__PURE__ */ (0,
|
|
19054
|
-
/* @__PURE__ */ (0,
|
|
19055
|
-
/* @__PURE__ */ (0,
|
|
19274
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Heading3, { children: "Integrations" }),
|
|
19275
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(MenuList, { children: quickbooksIsConnected ? /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(MenuItem3, { isDisabled: true, children: [
|
|
19276
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(QuickbooksIcon_default, { size: 20 }),
|
|
19277
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Text, { size: "sm" /* sm */, children: "QuickBooks connected" }),
|
|
19278
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Spacer, {}),
|
|
19279
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Check_default, { size: 16 })
|
|
19280
|
+
] }, "quickbooks-connected") : /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(MenuItem3, { onClick: initiateQuickbooksOAuth, children: [
|
|
19281
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(QuickbooksIcon_default, { size: 20 }),
|
|
19282
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Text, __spreadProps(__spreadValues({}, isLinkQuickbooksError && { status: "error" }), { size: "sm" /* sm */, children: isLinkQuickbooksError ? "Retry Connect QuickBooks" : "Connect QuickBooks" })),
|
|
19283
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Spacer, {}),
|
|
19284
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Link_default, { size: 12 })
|
|
19056
19285
|
] }, "connect-quickbooks") })
|
|
19057
19286
|
]
|
|
19058
19287
|
}
|
|
@@ -19060,20 +19289,20 @@ var IntegrationsConnectMenu = () => {
|
|
|
19060
19289
|
};
|
|
19061
19290
|
|
|
19062
19291
|
// src/components/Integrations/Integrations.tsx
|
|
19063
|
-
var
|
|
19292
|
+
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
19064
19293
|
var COMPONENT_NAME3 = "integrations";
|
|
19065
|
-
var
|
|
19066
|
-
return /* @__PURE__ */ (0,
|
|
19294
|
+
var Integrations = (props) => {
|
|
19295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(QuickbooksContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsComponent, __spreadValues({}, props)) });
|
|
19067
19296
|
};
|
|
19068
19297
|
var IntegrationsComponent = ({
|
|
19069
19298
|
elevated,
|
|
19070
19299
|
stringOverrides
|
|
19071
19300
|
}) => {
|
|
19072
|
-
const {
|
|
19073
|
-
const isLoading =
|
|
19074
|
-
return /* @__PURE__ */ (0,
|
|
19075
|
-
/* @__PURE__ */ (0,
|
|
19076
|
-
/* @__PURE__ */ (0,
|
|
19301
|
+
const { quickbooksConnectionStatus } = (0, import_react91.useContext)(QuickbooksContext);
|
|
19302
|
+
const isLoading = quickbooksConnectionStatus === void 0;
|
|
19303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(Container, { name: COMPONENT_NAME3, elevated, children: [
|
|
19304
|
+
/* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(Header, { className: "Layer__linked-accounts__header", children: [
|
|
19305
|
+
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
|
|
19077
19306
|
Heading,
|
|
19078
19307
|
{
|
|
19079
19308
|
className: "Layer__linked-accounts__title",
|
|
@@ -19081,61 +19310,26 @@ var IntegrationsComponent = ({
|
|
|
19081
19310
|
children: (stringOverrides == null ? void 0 : stringOverrides.title) || "Integrations"
|
|
19082
19311
|
}
|
|
19083
19312
|
),
|
|
19084
|
-
/* @__PURE__ */ (0,
|
|
19313
|
+
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsConnectMenu, {})
|
|
19085
19314
|
] }),
|
|
19086
|
-
isLoading && /* @__PURE__ */ (0,
|
|
19087
|
-
!isLoading && !
|
|
19315
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { className: "Layer__linked-accounts__loader-container", children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(Loader2, {}) }),
|
|
19316
|
+
!isLoading && !quickbooksConnectionStatus.is_connected && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
|
|
19088
19317
|
DataState,
|
|
19089
19318
|
{
|
|
19090
19319
|
status: "info" /* info */,
|
|
19091
19320
|
title: "No active integrations"
|
|
19092
19321
|
}
|
|
19093
19322
|
),
|
|
19094
|
-
|
|
19095
|
-
] });
|
|
19096
|
-
};
|
|
19097
|
-
|
|
19098
|
-
// src/components/Quickbooks/Quickbooks.tsx
|
|
19099
|
-
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
19100
|
-
var Quickbooks = () => {
|
|
19101
|
-
const {
|
|
19102
|
-
syncFromQuickbooks: syncFromQuickbooks2,
|
|
19103
|
-
isSyncingFromQuickbooks,
|
|
19104
|
-
quickbooksIsConnected,
|
|
19105
|
-
linkQuickbooks,
|
|
19106
|
-
unlinkQuickbooks
|
|
19107
|
-
} = useQuickbooks();
|
|
19108
|
-
return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19109
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19110
|
-
"Quickbooks OAuth connection status:",
|
|
19111
|
-
" ",
|
|
19112
|
-
quickbooksIsConnected === void 0 ? "" : quickbooksIsConnected ? "established" : "not connected"
|
|
19113
|
-
] }),
|
|
19114
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("br", {}),
|
|
19115
|
-
quickbooksIsConnected === void 0 && "Loading...",
|
|
19116
|
-
quickbooksIsConnected === false && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
|
|
19117
|
-
"button",
|
|
19118
|
-
{
|
|
19119
|
-
onClick: () => __async(null, null, function* () {
|
|
19120
|
-
const authorizationUrl = yield linkQuickbooks();
|
|
19121
|
-
window.location.href = authorizationUrl;
|
|
19122
|
-
}),
|
|
19123
|
-
children: "Link Quickbooks"
|
|
19124
|
-
}
|
|
19125
|
-
),
|
|
19126
|
-
quickbooksIsConnected === true && (isSyncingFromQuickbooks ? "Syncing data from Quickbooks..." : /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19127
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: syncFromQuickbooks2, children: "Sync Quickbooks" }),
|
|
19128
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: unlinkQuickbooks, children: "Unlink Quickbooks" })
|
|
19129
|
-
] }))
|
|
19323
|
+
(quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsContent, {})
|
|
19130
19324
|
] });
|
|
19131
19325
|
};
|
|
19132
19326
|
|
|
19133
19327
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
19134
|
-
var
|
|
19328
|
+
var import_react119 = require("react");
|
|
19135
19329
|
|
|
19136
19330
|
// src/contexts/ProfitAndLossComparisonContext/ProfitAndLossComparisonContext.tsx
|
|
19137
|
-
var
|
|
19138
|
-
var PNLComparisonContext = (0,
|
|
19331
|
+
var import_react92 = require("react");
|
|
19332
|
+
var PNLComparisonContext = (0, import_react92.createContext)({
|
|
19139
19333
|
data: void 0,
|
|
19140
19334
|
isLoading: true,
|
|
19141
19335
|
isValidating: false,
|
|
@@ -19156,7 +19350,7 @@ var PNLComparisonContext = (0, import_react91.createContext)({
|
|
|
19156
19350
|
});
|
|
19157
19351
|
|
|
19158
19352
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
19159
|
-
var
|
|
19353
|
+
var import_react95 = require("react");
|
|
19160
19354
|
|
|
19161
19355
|
// src/utils/profitAndLossUtils.ts
|
|
19162
19356
|
var doesLineItemQualifies = (item) => {
|
|
@@ -19212,15 +19406,15 @@ var applyShare = (items, total) => {
|
|
|
19212
19406
|
};
|
|
19213
19407
|
|
|
19214
19408
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
19215
|
-
var
|
|
19216
|
-
var
|
|
19217
|
-
var
|
|
19409
|
+
var import_react93 = require("react");
|
|
19410
|
+
var import_date_fns25 = require("date-fns");
|
|
19411
|
+
var import_swr13 = __toESM(require("swr"));
|
|
19218
19412
|
var buildDates = ({ currentDate }) => {
|
|
19219
19413
|
return {
|
|
19220
|
-
startYear: (0,
|
|
19221
|
-
startMonth: (0,
|
|
19222
|
-
endYear: (0,
|
|
19223
|
-
endMonth: (0,
|
|
19414
|
+
startYear: (0, import_date_fns25.startOfMonth)(currentDate).getFullYear() - 1,
|
|
19415
|
+
startMonth: (0, import_date_fns25.startOfMonth)(currentDate).getMonth() + 1,
|
|
19416
|
+
endYear: (0, import_date_fns25.startOfMonth)(currentDate).getFullYear(),
|
|
19417
|
+
endMonth: (0, import_date_fns25.startOfMonth)(currentDate).getMonth() + 1
|
|
19224
19418
|
};
|
|
19225
19419
|
};
|
|
19226
19420
|
var buildMonthsArray = (startDate, endDate) => {
|
|
@@ -19234,16 +19428,16 @@ var buildMonthsArray = (startDate, endDate) => {
|
|
|
19234
19428
|
return dates;
|
|
19235
19429
|
};
|
|
19236
19430
|
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
19237
|
-
currentDate: (0,
|
|
19431
|
+
currentDate: (0, import_date_fns25.startOfMonth)(Date.now())
|
|
19238
19432
|
}) => {
|
|
19239
19433
|
var _a, _b;
|
|
19240
19434
|
const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
19241
19435
|
const { apiUrl } = useEnvironment();
|
|
19242
19436
|
const { data: auth } = useAuth();
|
|
19243
|
-
const [date, setDate] = (0,
|
|
19244
|
-
const [loaded, setLoaded] = (0,
|
|
19245
|
-
const [data, setData] = (0,
|
|
19246
|
-
const { startYear, startMonth, endYear, endMonth } = (0,
|
|
19437
|
+
const [date, setDate] = (0, import_react93.useState)(currentDate);
|
|
19438
|
+
const [loaded, setLoaded] = (0, import_react93.useState)("initial");
|
|
19439
|
+
const [data, setData] = (0, import_react93.useState)([]);
|
|
19440
|
+
const { startYear, startMonth, endYear, endMonth } = (0, import_react93.useMemo)(() => {
|
|
19247
19441
|
return buildDates({ currentDate: date });
|
|
19248
19442
|
}, [date, businessId, tagFilter, reportingBasis]);
|
|
19249
19443
|
const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && (auth == null ? void 0 : auth.access_token) && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter == null ? void 0 : tagFilter.key}-${(_a = tagFilter == null ? void 0 : tagFilter.values) == null ? void 0 : _a.join(
|
|
@@ -19255,7 +19449,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19255
19449
|
isValidating,
|
|
19256
19450
|
error,
|
|
19257
19451
|
mutate
|
|
19258
|
-
} = (0,
|
|
19452
|
+
} = (0, import_swr13.default)(
|
|
19259
19453
|
queryKey,
|
|
19260
19454
|
Layer.getProfitAndLossSummaries(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19261
19455
|
params: {
|
|
@@ -19270,9 +19464,9 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19270
19464
|
}
|
|
19271
19465
|
})
|
|
19272
19466
|
);
|
|
19273
|
-
(0,
|
|
19467
|
+
(0, import_react93.useEffect)(() => {
|
|
19274
19468
|
const newData = data.slice();
|
|
19275
|
-
const newPeriod = buildMonthsArray((0,
|
|
19469
|
+
const newPeriod = buildMonthsArray((0, import_date_fns25.sub)(date, { years: 1 }), date);
|
|
19276
19470
|
if (newData && newPeriod) {
|
|
19277
19471
|
newPeriod.forEach((x) => {
|
|
19278
19472
|
if (!(newData == null ? void 0 : newData.find(
|
|
@@ -19306,7 +19500,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19306
19500
|
);
|
|
19307
19501
|
}
|
|
19308
19502
|
}, [startYear, startMonth, tagFilter]);
|
|
19309
|
-
(0,
|
|
19503
|
+
(0, import_react93.useEffect)(() => {
|
|
19310
19504
|
var _a2, _b2;
|
|
19311
19505
|
const newData = (_b2 = (_a2 = rawData == null ? void 0 : rawData.data) == null ? void 0 : _a2.months) == null ? void 0 : _b2.slice();
|
|
19312
19506
|
if (data && newData) {
|
|
@@ -19324,7 +19518,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19324
19518
|
);
|
|
19325
19519
|
}
|
|
19326
19520
|
}, [rawData]);
|
|
19327
|
-
(0,
|
|
19521
|
+
(0, import_react93.useEffect)(() => {
|
|
19328
19522
|
if (isLoading && loaded === "initial") {
|
|
19329
19523
|
setLoaded("loading");
|
|
19330
19524
|
return;
|
|
@@ -19334,12 +19528,12 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19334
19528
|
}
|
|
19335
19529
|
}, [data, isLoading]);
|
|
19336
19530
|
const pullData = (date2) => setDate(date2);
|
|
19337
|
-
(0,
|
|
19531
|
+
(0, import_react93.useEffect)(() => {
|
|
19338
19532
|
if (queryKey && (isLoading || isValidating)) {
|
|
19339
19533
|
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
19340
19534
|
}
|
|
19341
19535
|
}, [isLoading, isValidating]);
|
|
19342
|
-
(0,
|
|
19536
|
+
(0, import_react93.useEffect)(() => {
|
|
19343
19537
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
19344
19538
|
mutate();
|
|
19345
19539
|
}
|
|
@@ -19366,17 +19560,17 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19366
19560
|
};
|
|
19367
19561
|
|
|
19368
19562
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
19369
|
-
var
|
|
19370
|
-
var
|
|
19371
|
-
var
|
|
19563
|
+
var import_react94 = require("react");
|
|
19564
|
+
var import_date_fns26 = require("date-fns");
|
|
19565
|
+
var import_swr14 = __toESM(require("swr"));
|
|
19372
19566
|
var useProfitAndLossQuery = ({
|
|
19373
19567
|
startDate,
|
|
19374
19568
|
endDate,
|
|
19375
19569
|
tagFilter,
|
|
19376
19570
|
reportingBasis
|
|
19377
19571
|
} = {
|
|
19378
|
-
startDate: (0,
|
|
19379
|
-
endDate: (0,
|
|
19572
|
+
startDate: (0, import_date_fns26.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
19573
|
+
endDate: (0, import_date_fns26.endOfMonth)(/* @__PURE__ */ new Date())
|
|
19380
19574
|
}) => {
|
|
19381
19575
|
var _a, _b;
|
|
19382
19576
|
const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
@@ -19391,7 +19585,7 @@ var useProfitAndLossQuery = ({
|
|
|
19391
19585
|
isValidating,
|
|
19392
19586
|
error: rawError,
|
|
19393
19587
|
mutate
|
|
19394
|
-
} = (0,
|
|
19588
|
+
} = (0, import_swr14.default)(
|
|
19395
19589
|
queryKey,
|
|
19396
19590
|
Layer.getProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19397
19591
|
businessId,
|
|
@@ -19405,12 +19599,12 @@ var useProfitAndLossQuery = ({
|
|
|
19405
19599
|
const refetch = () => {
|
|
19406
19600
|
mutate();
|
|
19407
19601
|
};
|
|
19408
|
-
(0,
|
|
19602
|
+
(0, import_react94.useEffect)(() => {
|
|
19409
19603
|
if (queryKey && (isLoading || isValidating)) {
|
|
19410
19604
|
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
19411
19605
|
}
|
|
19412
19606
|
}, [isLoading, isValidating]);
|
|
19413
|
-
(0,
|
|
19607
|
+
(0, import_react94.useEffect)(() => {
|
|
19414
19608
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
19415
19609
|
refetch();
|
|
19416
19610
|
}
|
|
@@ -19433,16 +19627,16 @@ var useProfitAndLoss = ({
|
|
|
19433
19627
|
}) => {
|
|
19434
19628
|
const { start, end } = useGlobalDateRange();
|
|
19435
19629
|
const { setRange } = useGlobalDateRangeActions();
|
|
19436
|
-
const dateRange = (0,
|
|
19437
|
-
const changeDateRange = (0,
|
|
19630
|
+
const dateRange = (0, import_react95.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
|
|
19631
|
+
const changeDateRange = (0, import_react95.useCallback)(
|
|
19438
19632
|
({ startDate: start2, endDate: end2 }) => setRange({ start: start2, end: end2 }),
|
|
19439
19633
|
[setRange]
|
|
19440
19634
|
);
|
|
19441
|
-
const [filters, setFilters] = (0,
|
|
19635
|
+
const [filters, setFilters] = (0, import_react95.useState)({
|
|
19442
19636
|
expenses: void 0,
|
|
19443
19637
|
revenue: void 0
|
|
19444
19638
|
});
|
|
19445
|
-
const [sidebarScope, setSidebarScope] = (0,
|
|
19639
|
+
const [sidebarScope, setSidebarScope] = (0, import_react95.useState)(void 0);
|
|
19446
19640
|
const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
|
|
19447
19641
|
startDate: start,
|
|
19448
19642
|
endDate: end,
|
|
@@ -19469,7 +19663,7 @@ var useProfitAndLoss = ({
|
|
|
19469
19663
|
})
|
|
19470
19664
|
}));
|
|
19471
19665
|
};
|
|
19472
|
-
const { filteredDataRevenue, filteredTotalRevenue } = (0,
|
|
19666
|
+
const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react95.useMemo)(() => {
|
|
19473
19667
|
var _a;
|
|
19474
19668
|
if (!data) {
|
|
19475
19669
|
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
@@ -19521,7 +19715,7 @@ var useProfitAndLoss = ({
|
|
|
19521
19715
|
const withShare = applyShare(sorted, total);
|
|
19522
19716
|
return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
|
|
19523
19717
|
}, [data, start, filters, summaryData]);
|
|
19524
|
-
const { filteredDataExpenses, filteredTotalExpenses } = (0,
|
|
19718
|
+
const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react95.useMemo)(() => {
|
|
19525
19719
|
var _a;
|
|
19526
19720
|
if (!data) {
|
|
19527
19721
|
return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
|
|
@@ -19595,10 +19789,10 @@ var useProfitAndLoss = ({
|
|
|
19595
19789
|
};
|
|
19596
19790
|
|
|
19597
19791
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19598
|
-
var
|
|
19792
|
+
var import_react96 = require("react");
|
|
19599
19793
|
|
|
19600
19794
|
// src/hooks/useProfitAndLossComparison/utils.ts
|
|
19601
|
-
var
|
|
19795
|
+
var import_date_fns27 = require("date-fns");
|
|
19602
19796
|
|
|
19603
19797
|
// src/utils/array/range.ts
|
|
19604
19798
|
function range2(start, end) {
|
|
@@ -19656,12 +19850,12 @@ function prepareFiltersBody(compareOptions) {
|
|
|
19656
19850
|
return isArrayWithAtLeastOne(allFilters) ? allFilters : void 0;
|
|
19657
19851
|
}
|
|
19658
19852
|
function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
|
|
19659
|
-
const adjustedStartDate = (0,
|
|
19853
|
+
const adjustedStartDate = (0, import_date_fns27.startOfMonth)(dateRange.startDate);
|
|
19660
19854
|
const rawPeriods = range2(0, comparePeriods).map((index) => {
|
|
19661
|
-
const currentPeriod = (0,
|
|
19855
|
+
const currentPeriod = (0, import_date_fns27.subMonths)(adjustedStartDate, index);
|
|
19662
19856
|
return {
|
|
19663
|
-
year: (0,
|
|
19664
|
-
month: (0,
|
|
19857
|
+
year: (0, import_date_fns27.getYear)(currentPeriod),
|
|
19858
|
+
month: (0, import_date_fns27.getMonth)(currentPeriod) + 1
|
|
19665
19859
|
};
|
|
19666
19860
|
});
|
|
19667
19861
|
const sortedPeriods = rawPeriods.sort((a, b) => {
|
|
@@ -19679,11 +19873,11 @@ function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
|
|
|
19679
19873
|
};
|
|
19680
19874
|
}
|
|
19681
19875
|
function preparePeriodsBodyForYears(dateRange, comparePeriods) {
|
|
19682
|
-
const adjustedStartDate = (0,
|
|
19876
|
+
const adjustedStartDate = (0, import_date_fns27.startOfYear)(dateRange.startDate);
|
|
19683
19877
|
const rawPeriods = range2(0, comparePeriods).map((index) => {
|
|
19684
|
-
const currentPeriod = (0,
|
|
19878
|
+
const currentPeriod = (0, import_date_fns27.subYears)(adjustedStartDate, index);
|
|
19685
19879
|
return {
|
|
19686
|
-
year: (0,
|
|
19880
|
+
year: (0, import_date_fns27.getYear)(currentPeriod)
|
|
19687
19881
|
};
|
|
19688
19882
|
});
|
|
19689
19883
|
const sortedPeriods = rawPeriods.sort((a, b) => {
|
|
@@ -19718,14 +19912,14 @@ function preparePeriodsBody(dateRange, comparePeriods, rangeDisplayMode) {
|
|
|
19718
19912
|
}
|
|
19719
19913
|
|
|
19720
19914
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19721
|
-
var
|
|
19915
|
+
var import_swr15 = __toESM(require("swr"));
|
|
19722
19916
|
var COMPARE_MODES_SUPPORTING_MULTI_PERIOD = ["monthPicker", "yearPicker"];
|
|
19723
19917
|
var isNotOnlyNoneTag = (compareOptions) => {
|
|
19724
19918
|
return Boolean(
|
|
19725
19919
|
compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
|
|
19726
19920
|
);
|
|
19727
19921
|
};
|
|
19728
|
-
function
|
|
19922
|
+
function buildKey14({
|
|
19729
19923
|
access_token: accessToken,
|
|
19730
19924
|
apiUrl,
|
|
19731
19925
|
businessId,
|
|
@@ -19749,15 +19943,15 @@ function useProfitAndLossComparison({
|
|
|
19749
19943
|
comparisonConfig
|
|
19750
19944
|
}) {
|
|
19751
19945
|
var _a, _b;
|
|
19752
|
-
const [comparePeriods, setComparePeriods] = (0,
|
|
19753
|
-
const [selectedCompareOptions, setSelectedCompareOptionsState] = (0,
|
|
19946
|
+
const [comparePeriods, setComparePeriods] = (0, import_react96.useState)((_a = comparisonConfig == null ? void 0 : comparisonConfig.defaultPeriods) != null ? _a : 1);
|
|
19947
|
+
const [selectedCompareOptions, setSelectedCompareOptionsState] = (0, import_react96.useState)(
|
|
19754
19948
|
(comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
|
|
19755
19949
|
);
|
|
19756
19950
|
const { rangeDisplayMode, start, end } = useGlobalDateRange();
|
|
19757
19951
|
const dateRange = { startDate: start, endDate: end };
|
|
19758
19952
|
const isPeriodsSelectEnabled = COMPARE_MODES_SUPPORTING_MULTI_PERIOD.includes(rangeDisplayMode);
|
|
19759
19953
|
const effectiveComparePeriods = isPeriodsSelectEnabled ? comparePeriods : 1;
|
|
19760
|
-
const compareModeActive = (0,
|
|
19954
|
+
const compareModeActive = (0, import_react96.useMemo)(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
|
|
19761
19955
|
const setSelectedCompareOptions = (values) => {
|
|
19762
19956
|
const options = values.map(
|
|
19763
19957
|
(option) => comparisonConfig == null ? void 0 : comparisonConfig.tagComparisonOptions.find(
|
|
@@ -19775,14 +19969,14 @@ function useProfitAndLossComparison({
|
|
|
19775
19969
|
const { data: auth } = useAuth();
|
|
19776
19970
|
const periods = preparePeriodsBody(dateRange, effectiveComparePeriods, rangeDisplayMode);
|
|
19777
19971
|
const tagFilters = prepareFiltersBody(selectedCompareOptions);
|
|
19778
|
-
const queryKey =
|
|
19972
|
+
const queryKey = buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
19779
19973
|
businessId,
|
|
19780
19974
|
periods,
|
|
19781
19975
|
tagFilters,
|
|
19782
19976
|
reportingBasis,
|
|
19783
19977
|
compareModeActive
|
|
19784
19978
|
}));
|
|
19785
|
-
const { data, isLoading, isValidating } = (0,
|
|
19979
|
+
const { data, isLoading, isValidating } = (0, import_swr15.default)(
|
|
19786
19980
|
queryKey,
|
|
19787
19981
|
() => __async(null, null, function* () {
|
|
19788
19982
|
const response = yield Layer.compareProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -19830,7 +20024,7 @@ function useProfitAndLossComparison({
|
|
|
19830
20024
|
}
|
|
19831
20025
|
|
|
19832
20026
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
19833
|
-
var
|
|
20027
|
+
var import_react97 = require("react");
|
|
19834
20028
|
|
|
19835
20029
|
// src/icons/BarChart2.tsx
|
|
19836
20030
|
var import_jsx_runtime166 = require("react/jsx-runtime");
|
|
@@ -19940,7 +20134,7 @@ var Indicator = ({
|
|
|
19940
20134
|
|
|
19941
20135
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
19942
20136
|
var import_classnames53 = __toESM(require("classnames"));
|
|
19943
|
-
var
|
|
20137
|
+
var import_date_fns28 = require("date-fns");
|
|
19944
20138
|
var import_recharts = require("recharts");
|
|
19945
20139
|
var import_jsx_runtime169 = require("react/jsx-runtime");
|
|
19946
20140
|
var getChartWindow = ({
|
|
@@ -19948,46 +20142,46 @@ var getChartWindow = ({
|
|
|
19948
20142
|
currentYear,
|
|
19949
20143
|
currentMonth
|
|
19950
20144
|
}) => {
|
|
19951
|
-
const today = (0,
|
|
19952
|
-
const yearAgo = (0,
|
|
19953
|
-
const current = (0,
|
|
19954
|
-
if ((0,
|
|
20145
|
+
const today = (0, import_date_fns28.startOfMonth)(Date.now());
|
|
20146
|
+
const yearAgo = (0, import_date_fns28.sub)(today, { months: 11 });
|
|
20147
|
+
const current = (0, import_date_fns28.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
|
|
20148
|
+
if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.end), current) > 1) {
|
|
19955
20149
|
return chartWindow;
|
|
19956
20150
|
}
|
|
19957
|
-
if ((0,
|
|
20151
|
+
if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.start), current) === 0) {
|
|
19958
20152
|
return {
|
|
19959
|
-
start: (0,
|
|
19960
|
-
end: (0,
|
|
20153
|
+
start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 1 })),
|
|
20154
|
+
end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 11 }))
|
|
19961
20155
|
};
|
|
19962
20156
|
}
|
|
19963
|
-
if ((0,
|
|
20157
|
+
if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.endOfMonth)(chartWindow.end), (0, import_date_fns28.endOfMonth)(current)) === 1 && (0, import_date_fns28.differenceInMonths)(today, current) >= 1) {
|
|
19964
20158
|
return {
|
|
19965
|
-
start: (0,
|
|
19966
|
-
end: (0,
|
|
20159
|
+
start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 10 })),
|
|
20160
|
+
end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 2 }))
|
|
19967
20161
|
};
|
|
19968
20162
|
}
|
|
19969
|
-
if ((0,
|
|
20163
|
+
if ((0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(chartWindow.end)) === 0 && (0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(today)) > 0) {
|
|
19970
20164
|
return {
|
|
19971
|
-
start: (0,
|
|
19972
|
-
end: (0,
|
|
20165
|
+
start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 11 })),
|
|
20166
|
+
end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 1 }))
|
|
19973
20167
|
};
|
|
19974
20168
|
}
|
|
19975
20169
|
if (current >= yearAgo) {
|
|
19976
20170
|
return {
|
|
19977
|
-
start: (0,
|
|
19978
|
-
end: (0,
|
|
20171
|
+
start: (0, import_date_fns28.startOfMonth)(yearAgo),
|
|
20172
|
+
end: (0, import_date_fns28.endOfMonth)(today)
|
|
19979
20173
|
};
|
|
19980
20174
|
}
|
|
19981
20175
|
if (Number(current) > Number(chartWindow.end)) {
|
|
19982
20176
|
return {
|
|
19983
|
-
start: (0,
|
|
19984
|
-
end: (0,
|
|
20177
|
+
start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(current, { months: 12 })),
|
|
20178
|
+
end: (0, import_date_fns28.endOfMonth)(current)
|
|
19985
20179
|
};
|
|
19986
20180
|
}
|
|
19987
|
-
if ((0,
|
|
20181
|
+
if ((0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(chartWindow.start)) < 0) {
|
|
19988
20182
|
return {
|
|
19989
|
-
start: (0,
|
|
19990
|
-
end: (0,
|
|
20183
|
+
start: (0, import_date_fns28.startOfMonth)(current),
|
|
20184
|
+
end: (0, import_date_fns28.endOfMonth)((0, import_date_fns28.add)(current, { months: 11 }))
|
|
19991
20185
|
};
|
|
19992
20186
|
}
|
|
19993
20187
|
return chartWindow;
|
|
@@ -20013,41 +20207,41 @@ var ProfitAndLossChart = ({
|
|
|
20013
20207
|
tagFilter = void 0
|
|
20014
20208
|
}) => {
|
|
20015
20209
|
var _c, _d, _e, _f, _g, _h;
|
|
20016
|
-
const [compactView, setCompactView] = (0,
|
|
20210
|
+
const [compactView, setCompactView] = (0, import_react97.useState)(false);
|
|
20017
20211
|
const barSize = compactView ? 10 : 20;
|
|
20018
20212
|
const { getColor, business } = useLayerContext();
|
|
20019
20213
|
const { start, end, rangeDisplayMode } = useGlobalDateRange();
|
|
20020
20214
|
const { setMonth } = useGlobalDateRangeActions();
|
|
20021
20215
|
const showIndicator = rangeDisplayMode === "monthPicker";
|
|
20022
|
-
const dateRange = (0,
|
|
20023
|
-
const [localDateRange, setLocalDateRange] = (0,
|
|
20024
|
-
const [customCursorSize, setCustomCursorSize] = (0,
|
|
20216
|
+
const dateRange = (0, import_react97.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
|
|
20217
|
+
const [localDateRange, setLocalDateRange] = (0, import_react97.useState)(dateRange);
|
|
20218
|
+
const [customCursorSize, setCustomCursorSize] = (0, import_react97.useState)({
|
|
20025
20219
|
width: 0,
|
|
20026
20220
|
height: 0,
|
|
20027
20221
|
x: 0
|
|
20028
20222
|
});
|
|
20029
|
-
const [barAnimActive, setBarAnimActive] = (0,
|
|
20030
|
-
const [chartWindow, setChartWindow] = (0,
|
|
20031
|
-
start: (0,
|
|
20032
|
-
end: (0,
|
|
20223
|
+
const [barAnimActive, setBarAnimActive] = (0, import_react97.useState)(true);
|
|
20224
|
+
const [chartWindow, setChartWindow] = (0, import_react97.useState)({
|
|
20225
|
+
start: (0, import_date_fns28.startOfMonth)((0, import_date_fns28.sub)(Date.now(), { months: 11 })),
|
|
20226
|
+
end: (0, import_date_fns28.endOfMonth)(Date.now())
|
|
20033
20227
|
});
|
|
20034
|
-
const selectionMonth = (0,
|
|
20228
|
+
const selectionMonth = (0, import_react97.useMemo)(
|
|
20035
20229
|
() => ({
|
|
20036
20230
|
year: localDateRange.startDate.getFullYear(),
|
|
20037
20231
|
month: localDateRange.startDate.getMonth()
|
|
20038
20232
|
}),
|
|
20039
20233
|
[localDateRange]
|
|
20040
20234
|
);
|
|
20041
|
-
(0,
|
|
20235
|
+
(0, import_react97.useEffect)(() => {
|
|
20042
20236
|
if (Number(dateRange.startDate) !== Number(localDateRange.startDate) || Number(dateRange.endDate) !== Number(localDateRange.endDate)) {
|
|
20043
20237
|
setLocalDateRange(dateRange);
|
|
20044
20238
|
}
|
|
20045
20239
|
}, [dateRange]);
|
|
20046
20240
|
const { data, loaded, pullData } = useProfitAndLossLTM({
|
|
20047
|
-
currentDate: (0,
|
|
20241
|
+
currentDate: (0, import_date_fns28.startOfMonth)(Date.now()),
|
|
20048
20242
|
tagFilter
|
|
20049
20243
|
});
|
|
20050
|
-
const anyData = (0,
|
|
20244
|
+
const anyData = (0, import_react97.useMemo)(() => {
|
|
20051
20245
|
return Boolean(
|
|
20052
20246
|
data == null ? void 0 : data.find(
|
|
20053
20247
|
(x) => x.income !== 0 || x.costOfGoodsSold !== 0 || x.grossProfit !== 0 || x.operatingExpenses !== 0 || x.profitBeforeTaxes !== 0 || x.taxes !== 0 || x.totalExpenses !== 0 || x.uncategorizedInflows !== 0 || x.uncategorizedOutflows !== 0
|
|
@@ -20055,33 +20249,33 @@ var ProfitAndLossChart = ({
|
|
|
20055
20249
|
);
|
|
20056
20250
|
}, [data]);
|
|
20057
20251
|
const { data: linkedAccounts } = useLinkedAccounts();
|
|
20058
|
-
const isSyncing = (0,
|
|
20252
|
+
const isSyncing = (0, import_react97.useMemo)(
|
|
20059
20253
|
() => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
|
|
20060
20254
|
[linkedAccounts]
|
|
20061
20255
|
);
|
|
20062
|
-
const loadingValue = (0,
|
|
20063
|
-
(0,
|
|
20256
|
+
const loadingValue = (0, import_react97.useMemo)(() => getLoadingValue(data), [data]);
|
|
20257
|
+
(0, import_react97.useEffect)(() => {
|
|
20064
20258
|
if (loaded === "complete" && data) {
|
|
20065
20259
|
const foundCurrent = data.find(
|
|
20066
|
-
(x) => Number((0,
|
|
20260
|
+
(x) => Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
|
|
20067
20261
|
);
|
|
20068
20262
|
if (!foundCurrent) {
|
|
20069
|
-
const newDate = (0,
|
|
20263
|
+
const newDate = (0, import_date_fns28.startOfMonth)(localDateRange.startDate);
|
|
20070
20264
|
pullData(newDate);
|
|
20071
20265
|
return;
|
|
20072
20266
|
}
|
|
20073
20267
|
const foundBefore = data.find(
|
|
20074
|
-
(x) => Number((0,
|
|
20268
|
+
(x) => Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number((0, import_date_fns28.sub)(localDateRange.startDate, { months: 1 })) && Number((0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number((0, import_date_fns28.sub)(localDateRange.endDate, { months: 1 }))
|
|
20075
20269
|
);
|
|
20076
20270
|
if (!foundBefore) {
|
|
20077
|
-
const newDate = (0,
|
|
20078
|
-
(0,
|
|
20271
|
+
const newDate = (0, import_date_fns28.startOfMonth)(
|
|
20272
|
+
(0, import_date_fns28.sub)(localDateRange.startDate, { months: 1 })
|
|
20079
20273
|
);
|
|
20080
20274
|
pullData(newDate);
|
|
20081
20275
|
}
|
|
20082
20276
|
}
|
|
20083
20277
|
}, [localDateRange]);
|
|
20084
|
-
(0,
|
|
20278
|
+
(0, import_react97.useEffect)(() => {
|
|
20085
20279
|
const newChartWindow = getChartWindow({
|
|
20086
20280
|
chartWindow,
|
|
20087
20281
|
currentYear: localDateRange.startDate.getFullYear(),
|
|
@@ -20091,14 +20285,14 @@ var ProfitAndLossChart = ({
|
|
|
20091
20285
|
setChartWindow(newChartWindow);
|
|
20092
20286
|
}
|
|
20093
20287
|
}, [localDateRange]);
|
|
20094
|
-
(0,
|
|
20288
|
+
(0, import_react97.useEffect)(() => {
|
|
20095
20289
|
if (loaded === "complete") {
|
|
20096
20290
|
setTimeout(() => {
|
|
20097
20291
|
setBarAnimActive(false);
|
|
20098
20292
|
}, 2e3);
|
|
20099
20293
|
}
|
|
20100
20294
|
}, [loaded]);
|
|
20101
|
-
const getMonthName = (pnl) => pnl ? (0,
|
|
20295
|
+
const getMonthName = (pnl) => pnl ? (0, import_date_fns28.format)(
|
|
20102
20296
|
new Date(pnl.year, pnl.month - 1, 1),
|
|
20103
20297
|
compactView ? "LLLLL" : "LLL"
|
|
20104
20298
|
) : "";
|
|
@@ -20118,15 +20312,15 @@ var ProfitAndLossChart = ({
|
|
|
20118
20312
|
loading: (pnl == null ? void 0 : pnl.isLoading) ? loadingValue : 0,
|
|
20119
20313
|
loadingExpenses: (pnl == null ? void 0 : pnl.isLoading) ? -loadingValue : 0
|
|
20120
20314
|
});
|
|
20121
|
-
const theData = (0,
|
|
20315
|
+
const theData = (0, import_react97.useMemo)(() => {
|
|
20122
20316
|
var _a;
|
|
20123
20317
|
if (loaded !== "complete" || loaded === "complete" && !anyData) {
|
|
20124
20318
|
const loadingData = [];
|
|
20125
20319
|
const today = Date.now();
|
|
20126
20320
|
for (let i = 11; i >= 0; i--) {
|
|
20127
|
-
const currentDate = (0,
|
|
20321
|
+
const currentDate = (0, import_date_fns28.sub)(today, { months: i });
|
|
20128
20322
|
loadingData.push({
|
|
20129
|
-
name: (0,
|
|
20323
|
+
name: (0, import_date_fns28.format)(currentDate, compactView ? "LLLLL" : "LLL"),
|
|
20130
20324
|
revenue: 0,
|
|
20131
20325
|
revenueUncategorized: 0,
|
|
20132
20326
|
totalExpensesInverse: 0,
|
|
@@ -20156,18 +20350,18 @@ var ProfitAndLossChart = ({
|
|
|
20156
20350
|
}
|
|
20157
20351
|
return x;
|
|
20158
20352
|
})) == null ? void 0 : _a.filter(
|
|
20159
|
-
(x) => (0,
|
|
20160
|
-
(0,
|
|
20353
|
+
(x) => (0, import_date_fns28.differenceInMonths)(
|
|
20354
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
20161
20355
|
chartWindow.start
|
|
20162
|
-
) >= 0 && (0,
|
|
20163
|
-
(0,
|
|
20356
|
+
) >= 0 && (0, import_date_fns28.differenceInMonths)(
|
|
20357
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
20164
20358
|
chartWindow.start
|
|
20165
|
-
) < 12 && (0,
|
|
20359
|
+
) < 12 && (0, import_date_fns28.differenceInMonths)(
|
|
20166
20360
|
chartWindow.end,
|
|
20167
|
-
(0,
|
|
20168
|
-
) >= 0 && (0,
|
|
20361
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
20362
|
+
) >= 0 && (0, import_date_fns28.differenceInMonths)(
|
|
20169
20363
|
chartWindow.end,
|
|
20170
|
-
(0,
|
|
20364
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
20171
20365
|
) <= 12
|
|
20172
20366
|
).map((x) => summarizePnL(x));
|
|
20173
20367
|
}, [selectionMonth, chartWindow, data, loaded, compactView]);
|
|
@@ -20649,7 +20843,7 @@ var ProfitAndLossChart = ({
|
|
|
20649
20843
|
};
|
|
20650
20844
|
|
|
20651
20845
|
// src/components/ProfitAndLossCompareOptions/ProfitAndLossCompareOptions.tsx
|
|
20652
|
-
var
|
|
20846
|
+
var import_react98 = require("react");
|
|
20653
20847
|
var import_jsx_runtime170 = require("react/jsx-runtime");
|
|
20654
20848
|
var selectStyles = {
|
|
20655
20849
|
valueContainer: (styles) => {
|
|
@@ -20689,9 +20883,9 @@ var ProfitAndLossCompareOptions = () => {
|
|
|
20689
20883
|
compareOptions,
|
|
20690
20884
|
selectedCompareOptions,
|
|
20691
20885
|
comparisonConfig
|
|
20692
|
-
} = (0,
|
|
20886
|
+
} = (0, import_react98.useContext)(ProfitAndLoss.ComparisonContext);
|
|
20693
20887
|
const { rangeDisplayMode } = useGlobalDateRange();
|
|
20694
|
-
const periods = (0,
|
|
20888
|
+
const periods = (0, import_react98.useMemo)(
|
|
20695
20889
|
() => comparePeriods !== 0 ? comparePeriods : 1,
|
|
20696
20890
|
[comparePeriods]
|
|
20697
20891
|
);
|
|
@@ -20784,7 +20978,7 @@ function DatePickerModeSelector({
|
|
|
20784
20978
|
}
|
|
20785
20979
|
|
|
20786
20980
|
// src/providers/GlobalDateStore/useGlobalDateRangePicker.ts
|
|
20787
|
-
var
|
|
20981
|
+
var import_react99 = require("react");
|
|
20788
20982
|
function useGlobalDateRangePicker({
|
|
20789
20983
|
allowedDatePickerModes,
|
|
20790
20984
|
defaultDatePickerMode,
|
|
@@ -20801,7 +20995,7 @@ function useGlobalDateRangePicker({
|
|
|
20801
20995
|
DEFAULT_ALLOWED_PICKER_MODES
|
|
20802
20996
|
);
|
|
20803
20997
|
const desiredRangeMode = allowedDateRangePickerModes.includes(rangeDisplayMode) ? rangeDisplayMode : allowedDateRangePickerModes[0];
|
|
20804
|
-
const { dateFormat, selected } = (0,
|
|
20998
|
+
const { dateFormat, selected } = (0, import_react99.useMemo)(() => {
|
|
20805
20999
|
if (rangeDisplayMode === "monthPicker") {
|
|
20806
21000
|
return {
|
|
20807
21001
|
selected: start,
|
|
@@ -20821,7 +21015,7 @@ function useGlobalDateRangePicker({
|
|
|
20821
21015
|
end,
|
|
20822
21016
|
rangeDisplayMode
|
|
20823
21017
|
]);
|
|
20824
|
-
const { setSelected } = (0,
|
|
21018
|
+
const { setSelected } = (0, import_react99.useMemo)(() => {
|
|
20825
21019
|
if (desiredRangeMode === "monthPicker") {
|
|
20826
21020
|
return {
|
|
20827
21021
|
setSelected: ({ start: start2 }) => {
|
|
@@ -20901,10 +21095,10 @@ var ProfitAndLossDatePicker = ({
|
|
|
20901
21095
|
};
|
|
20902
21096
|
|
|
20903
21097
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
20904
|
-
var
|
|
21098
|
+
var import_react101 = require("react");
|
|
20905
21099
|
|
|
20906
21100
|
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
20907
|
-
var
|
|
21101
|
+
var import_react100 = require("react");
|
|
20908
21102
|
|
|
20909
21103
|
// src/config/charts.ts
|
|
20910
21104
|
var DEFAULT_CHART_COLOR_TYPE = [
|
|
@@ -21189,7 +21383,7 @@ var DetailedChart = ({
|
|
|
21189
21383
|
isLoading,
|
|
21190
21384
|
showDatePicker = true
|
|
21191
21385
|
}) => {
|
|
21192
|
-
const chartData = (0,
|
|
21386
|
+
const chartData = (0, import_react100.useMemo)(() => {
|
|
21193
21387
|
if (!filteredData) {
|
|
21194
21388
|
return [];
|
|
21195
21389
|
}
|
|
@@ -21540,7 +21734,7 @@ var Filters = ({
|
|
|
21540
21734
|
};
|
|
21541
21735
|
|
|
21542
21736
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
21543
|
-
var
|
|
21737
|
+
var import_date_fns29 = require("date-fns");
|
|
21544
21738
|
var import_jsx_runtime177 = require("react/jsx-runtime");
|
|
21545
21739
|
var ProfitAndLossDetailedCharts = ({
|
|
21546
21740
|
scope,
|
|
@@ -21561,16 +21755,16 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21561
21755
|
sidebarScope,
|
|
21562
21756
|
setSidebarScope,
|
|
21563
21757
|
setFilterTypes
|
|
21564
|
-
} = (0,
|
|
21758
|
+
} = (0, import_react101.useContext)(ProfitAndLoss.Context);
|
|
21565
21759
|
const theScope = scope ? scope : sidebarScope;
|
|
21566
21760
|
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
21567
21761
|
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
21568
|
-
const [hoveredItem, setHoveredItem] = (0,
|
|
21762
|
+
const [hoveredItem, setHoveredItem] = (0, import_react101.useState)();
|
|
21569
21763
|
return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts", children: [
|
|
21570
21764
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("header", { className: "Layer__profit-and-loss-detailed-charts__header", children: [
|
|
21571
21765
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
|
|
21572
21766
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
|
|
21573
|
-
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0,
|
|
21767
|
+
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns29.format)(dateRange.startDate, "LLLL, y") }),
|
|
21574
21768
|
showDatePicker && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(ProfitAndLossDatePicker, {})
|
|
21575
21769
|
] }),
|
|
21576
21770
|
!hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
|
|
@@ -21587,7 +21781,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21587
21781
|
!hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(BackButton, { onClick: () => setSidebarScope(void 0) }),
|
|
21588
21782
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
|
|
21589
21783
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
|
|
21590
|
-
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0,
|
|
21784
|
+
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "sm" /* sm */, className: "date", children: (0, import_date_fns29.format)(dateRange.startDate, "LLLL, y") })
|
|
21591
21785
|
] })
|
|
21592
21786
|
] }),
|
|
21593
21787
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__content", children: [
|
|
@@ -21634,7 +21828,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21634
21828
|
};
|
|
21635
21829
|
|
|
21636
21830
|
// src/components/ProfitAndLossDownloadButton/ProfitAndLossDownloadButton.tsx
|
|
21637
|
-
var
|
|
21831
|
+
var import_react102 = require("react");
|
|
21638
21832
|
var import_jsx_runtime178 = require("react/jsx-runtime");
|
|
21639
21833
|
var ProfitAndLossDownloadButton = ({
|
|
21640
21834
|
stringOverrides,
|
|
@@ -21642,15 +21836,15 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21642
21836
|
moneyFormat,
|
|
21643
21837
|
view
|
|
21644
21838
|
}) => {
|
|
21645
|
-
const { dateRange, tagFilter } = (0,
|
|
21646
|
-
const { getProfitAndLossComparisonCsv } = (0,
|
|
21839
|
+
const { dateRange, tagFilter } = (0, import_react102.useContext)(ProfitAndLoss.Context);
|
|
21840
|
+
const { getProfitAndLossComparisonCsv } = (0, import_react102.useContext)(
|
|
21647
21841
|
ProfitAndLoss.ComparisonContext
|
|
21648
21842
|
);
|
|
21649
21843
|
const { businessId } = useLayerContext();
|
|
21650
21844
|
const { apiUrl } = useEnvironment();
|
|
21651
21845
|
const { data: auth } = useAuth();
|
|
21652
|
-
const [requestFailed, setRequestFailed] = (0,
|
|
21653
|
-
const [isDownloading, setIsDownloading] = (0,
|
|
21846
|
+
const [requestFailed, setRequestFailed] = (0, import_react102.useState)(false);
|
|
21847
|
+
const [isDownloading, setIsDownloading] = (0, import_react102.useState)(false);
|
|
21654
21848
|
const handleClick = () => __async(null, null, function* () {
|
|
21655
21849
|
var _a;
|
|
21656
21850
|
setIsDownloading(true);
|
|
@@ -21694,7 +21888,7 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21694
21888
|
};
|
|
21695
21889
|
|
|
21696
21890
|
// src/components/ProfitAndLossHeader/ProfitAndLossHeader.tsx
|
|
21697
|
-
var
|
|
21891
|
+
var import_react104 = require("react");
|
|
21698
21892
|
|
|
21699
21893
|
// src/components/SyncingBadge/SyncingBadge.tsx
|
|
21700
21894
|
var import_jsx_runtime179 = require("react/jsx-runtime");
|
|
@@ -21711,120 +21905,13 @@ var SyncingBadge = () => {
|
|
|
21711
21905
|
};
|
|
21712
21906
|
|
|
21713
21907
|
// src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
|
|
21714
|
-
var
|
|
21715
|
-
|
|
21716
|
-
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21717
|
-
var import_swr15 = __toESM(require("swr"));
|
|
21718
|
-
|
|
21719
|
-
// src/utils/bookkeeping/bookkeepingStatusFilters.ts
|
|
21720
|
-
function isActiveBookkeepingStatus(status) {
|
|
21721
|
-
return status === "ACTIVE" || status === "ONBOARDING";
|
|
21722
|
-
}
|
|
21723
|
-
function isActiveOrPausedBookkeepingStatus(status) {
|
|
21724
|
-
return isActiveBookkeepingStatus(status) || status === "BOOKKEEPING_PAUSED";
|
|
21725
|
-
}
|
|
21726
|
-
|
|
21727
|
-
// src/utils/bookkeeping/tasks/bookkeepingTasksFilters.ts
|
|
21728
|
-
function isIncompleteTask(task) {
|
|
21729
|
-
const { status } = task;
|
|
21730
|
-
return status === "TODO";
|
|
21731
|
-
}
|
|
21732
|
-
function getIncompleteTasks(tasks) {
|
|
21733
|
-
return tasks.filter((task) => isIncompleteTask(task));
|
|
21734
|
-
}
|
|
21735
|
-
function isUserVisibleTask(task) {
|
|
21736
|
-
const { status } = task;
|
|
21737
|
-
return status !== "COMPLETED" && status !== "ARCHIVED";
|
|
21738
|
-
}
|
|
21739
|
-
function getUserVisibleTasks(tasks) {
|
|
21740
|
-
return tasks.filter((task) => isUserVisibleTask(task));
|
|
21741
|
-
}
|
|
21742
|
-
function isCompletedTask(task) {
|
|
21743
|
-
const { status } = task;
|
|
21744
|
-
return status === "USER_MARKED_COMPLETED" || status === "COMPLETED" || status === "ARCHIVED";
|
|
21745
|
-
}
|
|
21746
|
-
function getCompletedTasks(tasks) {
|
|
21747
|
-
return tasks.filter((task) => isCompletedTask(task));
|
|
21748
|
-
}
|
|
21749
|
-
|
|
21750
|
-
// src/utils/bookkeeping/periods/getFilteredBookkeepingPeriods.ts
|
|
21751
|
-
function isActiveBookkeepingPeriod(period) {
|
|
21752
|
-
return period.status !== "BOOKKEEPING_NOT_ACTIVE";
|
|
21753
|
-
}
|
|
21754
|
-
|
|
21755
|
-
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21756
|
-
var BOOKKEEPING_PERIOD_STATUSES = [
|
|
21757
|
-
"BOOKKEEPING_NOT_ACTIVE",
|
|
21758
|
-
"NOT_STARTED",
|
|
21759
|
-
"IN_PROGRESS_AWAITING_BOOKKEEPER",
|
|
21760
|
-
"IN_PROGRESS_AWAITING_CUSTOMER",
|
|
21761
|
-
"CLOSING_IN_REVIEW",
|
|
21762
|
-
"CLOSED_OPEN_TASKS",
|
|
21763
|
-
"CLOSED_COMPLETE"
|
|
21764
|
-
];
|
|
21765
|
-
function constrainToKnownBookkeepingPeriodStatus(status) {
|
|
21766
|
-
if (BOOKKEEPING_PERIOD_STATUSES.includes(status)) {
|
|
21767
|
-
return status;
|
|
21768
|
-
}
|
|
21769
|
-
return "BOOKKEEPING_NOT_ACTIVE";
|
|
21770
|
-
}
|
|
21771
|
-
var getBookkeepingPeriods = get(({ businessId }) => {
|
|
21772
|
-
return `/v1/businesses/${businessId}/bookkeeping/periods`;
|
|
21773
|
-
});
|
|
21774
|
-
var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
|
|
21775
|
-
function buildKey14({
|
|
21776
|
-
access_token: accessToken,
|
|
21777
|
-
apiUrl,
|
|
21778
|
-
businessId,
|
|
21779
|
-
isActiveOrPaused
|
|
21780
|
-
}) {
|
|
21781
|
-
if (accessToken && apiUrl && isActiveOrPaused) {
|
|
21782
|
-
return {
|
|
21783
|
-
accessToken,
|
|
21784
|
-
apiUrl,
|
|
21785
|
-
businessId,
|
|
21786
|
-
tags: [BOOKKEEPING_TAG_KEY, BOOKKEEPING_PERIODS_TAG_KEY]
|
|
21787
|
-
};
|
|
21788
|
-
}
|
|
21789
|
-
}
|
|
21790
|
-
function useBookkeepingPeriods() {
|
|
21791
|
-
const { data: auth } = useAuth();
|
|
21792
|
-
const { businessId } = useLayerContext();
|
|
21793
|
-
const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
|
|
21794
|
-
const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
|
|
21795
|
-
const swrResponse = (0, import_swr15.default)(
|
|
21796
|
-
() => buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
21797
|
-
businessId,
|
|
21798
|
-
isActiveOrPaused
|
|
21799
|
-
})),
|
|
21800
|
-
({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingPeriods(
|
|
21801
|
-
apiUrl,
|
|
21802
|
-
accessToken,
|
|
21803
|
-
{ params: { businessId: businessId2 } }
|
|
21804
|
-
)().then(
|
|
21805
|
-
({ data: { periods } }) => periods.map((period) => __spreadProps(__spreadValues({}, period), {
|
|
21806
|
-
status: constrainToKnownBookkeepingPeriodStatus(period.status),
|
|
21807
|
-
tasks: getUserVisibleTasks(period.tasks)
|
|
21808
|
-
})).filter((period) => isActiveBookkeepingPeriod(period))
|
|
21809
|
-
)
|
|
21810
|
-
);
|
|
21811
|
-
return new Proxy(swrResponse, {
|
|
21812
|
-
get(target, prop) {
|
|
21813
|
-
if (prop === "isLoading") {
|
|
21814
|
-
return isLoadingBookkeepingStatus || swrResponse.isLoading;
|
|
21815
|
-
}
|
|
21816
|
-
return Reflect.get(target, prop);
|
|
21817
|
-
}
|
|
21818
|
-
});
|
|
21819
|
-
}
|
|
21820
|
-
|
|
21821
|
-
// src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
|
|
21908
|
+
var import_react103 = require("react");
|
|
21822
21909
|
function useActiveBookkeepingPeriod() {
|
|
21823
21910
|
const { date } = useGlobalDate();
|
|
21824
21911
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
21825
21912
|
const currentMonth = date.getMonth() + 1;
|
|
21826
21913
|
const currentYear = date.getFullYear();
|
|
21827
|
-
const activePeriod = (0,
|
|
21914
|
+
const activePeriod = (0, import_react103.useMemo)(
|
|
21828
21915
|
() => data == null ? void 0 : data.find((period) => currentYear === period.year && currentMonth === period.month),
|
|
21829
21916
|
[data, currentMonth, currentYear]
|
|
21830
21917
|
);
|
|
@@ -21843,7 +21930,7 @@ var ProfitAndLossHeader = ({
|
|
|
21843
21930
|
const { data: linkedAccounts } = useLinkedAccounts();
|
|
21844
21931
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
21845
21932
|
const activePeriodStatus = activePeriod == null ? void 0 : activePeriod.status;
|
|
21846
|
-
const isSyncing = (0,
|
|
21933
|
+
const isSyncing = (0, import_react104.useMemo)(
|
|
21847
21934
|
() => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
|
|
21848
21935
|
[linkedAccounts]
|
|
21849
21936
|
);
|
|
@@ -21851,20 +21938,20 @@ var ProfitAndLossHeader = ({
|
|
|
21851
21938
|
/* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("span", { className: "Layer__component-header__title-wrapper Layer__profit-and-loss__header", children: [
|
|
21852
21939
|
/* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Heading, { size: "secondary" /* secondary */, className: headingClassName, align: "left", children: text || "Profit & Loss" }),
|
|
21853
21940
|
isSyncing && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SyncingBadge, {}),
|
|
21854
|
-
withStatus && activePeriodStatus && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("span", { className: "Layer__profit-and-loss-header__bookkeeping-status", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
|
|
21941
|
+
withStatus && activePeriodStatus && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("span", { className: "Layer__profit-and-loss-header__bookkeeping-status", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(BookkeepingStatus2, { status: activePeriodStatus, monthNumber: activePeriod.month }) })
|
|
21855
21942
|
] }),
|
|
21856
21943
|
withDatePicker && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ProfitAndLoss.DatePicker, {})
|
|
21857
21944
|
] });
|
|
21858
21945
|
};
|
|
21859
21946
|
|
|
21860
21947
|
// src/components/ProfitAndLossReport/ProfitAndLossReport.tsx
|
|
21861
|
-
var
|
|
21948
|
+
var import_react108 = require("react");
|
|
21862
21949
|
|
|
21863
21950
|
// src/components/Header/Header.tsx
|
|
21864
|
-
var
|
|
21951
|
+
var import_react105 = require("react");
|
|
21865
21952
|
var import_classnames56 = __toESM(require("classnames"));
|
|
21866
21953
|
var import_jsx_runtime181 = require("react/jsx-runtime");
|
|
21867
|
-
var Header3 = (0,
|
|
21954
|
+
var Header3 = (0, import_react105.forwardRef)(
|
|
21868
21955
|
({ className, children, style, sticky, asHeader, rounded }, ref) => {
|
|
21869
21956
|
const baseClassName = (0, import_classnames56.default)(
|
|
21870
21957
|
"Layer__header",
|
|
@@ -21905,7 +21992,7 @@ var HeaderCol = ({ className, children, style, noPadding = false }) => {
|
|
|
21905
21992
|
};
|
|
21906
21993
|
|
|
21907
21994
|
// src/components/Panel/Panel.tsx
|
|
21908
|
-
var
|
|
21995
|
+
var import_react106 = require("react");
|
|
21909
21996
|
var import_classnames59 = __toESM(require("classnames"));
|
|
21910
21997
|
var import_jsx_runtime184 = require("react/jsx-runtime");
|
|
21911
21998
|
var Panel = ({
|
|
@@ -21919,8 +22006,8 @@ var Panel = ({
|
|
|
21919
22006
|
floating = false
|
|
21920
22007
|
}) => {
|
|
21921
22008
|
var _a;
|
|
21922
|
-
const [sidebarHeight, setSidebarHeight] = (0,
|
|
21923
|
-
(0,
|
|
22009
|
+
const [sidebarHeight, setSidebarHeight] = (0, import_react106.useState)(0);
|
|
22010
|
+
(0, import_react106.useEffect)(() => {
|
|
21924
22011
|
var _a2, _b;
|
|
21925
22012
|
if ((_a2 = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _a2.offsetHeight) {
|
|
21926
22013
|
setSidebarHeight((_b = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _b.offsetHeight);
|
|
@@ -21960,7 +22047,7 @@ var Panel = ({
|
|
|
21960
22047
|
};
|
|
21961
22048
|
|
|
21962
22049
|
// src/components/View/View.tsx
|
|
21963
|
-
var
|
|
22050
|
+
var import_react107 = require("react");
|
|
21964
22051
|
|
|
21965
22052
|
// src/components/ViewHeader/ViewHeader.tsx
|
|
21966
22053
|
var import_classnames60 = __toESM(require("classnames"));
|
|
@@ -21975,7 +22062,7 @@ var ViewHeader = ({ title, className, children }) => {
|
|
|
21975
22062
|
// src/components/View/View.tsx
|
|
21976
22063
|
var import_classnames61 = __toESM(require("classnames"));
|
|
21977
22064
|
var import_jsx_runtime186 = require("react/jsx-runtime");
|
|
21978
|
-
var View = (0,
|
|
22065
|
+
var View = (0, import_react107.forwardRef)(
|
|
21979
22066
|
({
|
|
21980
22067
|
title,
|
|
21981
22068
|
showHeader = true,
|
|
@@ -22026,8 +22113,8 @@ var ProfitAndLossReport = ({
|
|
|
22026
22113
|
view
|
|
22027
22114
|
}) => {
|
|
22028
22115
|
var _a, _b;
|
|
22029
|
-
const { sidebarScope } = (0,
|
|
22030
|
-
const { comparisonConfig } = (0,
|
|
22116
|
+
const { sidebarScope } = (0, import_react108.useContext)(ProfitAndLoss.Context);
|
|
22117
|
+
const { comparisonConfig } = (0, import_react108.useContext)(ProfitAndLoss.ComparisonContext);
|
|
22031
22118
|
return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
|
|
22032
22119
|
View,
|
|
22033
22120
|
{
|
|
@@ -22084,10 +22171,10 @@ var ProfitAndLossReport = ({
|
|
|
22084
22171
|
};
|
|
22085
22172
|
|
|
22086
22173
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
22087
|
-
var
|
|
22174
|
+
var import_react112 = require("react");
|
|
22088
22175
|
|
|
22089
22176
|
// src/components/ProfitAndLossSummaries/internal/ProfitAndLossSummariesList.tsx
|
|
22090
|
-
var
|
|
22177
|
+
var import_react109 = require("react");
|
|
22091
22178
|
var import_jsx_runtime188 = require("react/jsx-runtime");
|
|
22092
22179
|
var LIST_ITEM_CLASS_NAME = "Layer__ProfitAndLossSummariesListItem";
|
|
22093
22180
|
function ProfitAndLossSummariesListItem({
|
|
@@ -22095,7 +22182,7 @@ function ProfitAndLossSummariesListItem({
|
|
|
22095
22182
|
isActive,
|
|
22096
22183
|
onClick
|
|
22097
22184
|
}) {
|
|
22098
|
-
const dataProperties = (0,
|
|
22185
|
+
const dataProperties = (0, import_react109.useMemo)(
|
|
22099
22186
|
() => toDataProperties({ active: isActive, clickable: !!onClick }),
|
|
22100
22187
|
[isActive]
|
|
22101
22188
|
);
|
|
@@ -22106,7 +22193,7 @@ function ProfitAndLossSummariesList({
|
|
|
22106
22193
|
children,
|
|
22107
22194
|
itemCount
|
|
22108
22195
|
}) {
|
|
22109
|
-
const dataProperties = (0,
|
|
22196
|
+
const dataProperties = (0, import_react109.useMemo)(
|
|
22110
22197
|
() => toDataProperties({ ["column-count"]: itemCount }),
|
|
22111
22198
|
[itemCount]
|
|
22112
22199
|
);
|
|
@@ -22199,10 +22286,10 @@ function ProfitAndLossSummariesMiniChart({
|
|
|
22199
22286
|
}
|
|
22200
22287
|
|
|
22201
22288
|
// src/components/ui/Typography/MoneyText.tsx
|
|
22202
|
-
var
|
|
22289
|
+
var import_react110 = require("react");
|
|
22203
22290
|
var import_jsx_runtime190 = require("react/jsx-runtime");
|
|
22204
22291
|
var CLASS_NAME10 = "Layer__MoneyText";
|
|
22205
|
-
var MoneySpan = (0,
|
|
22292
|
+
var MoneySpan = (0, import_react110.forwardRef)(
|
|
22206
22293
|
(_a, ref) => {
|
|
22207
22294
|
var _b = _a, { amount, bold, size } = _b, restProps = __objRest(_b, ["amount", "bold", "size"]);
|
|
22208
22295
|
const dataProperties = toDataProperties({
|
|
@@ -22249,8 +22336,8 @@ function ProfitAndLossSummariesSummary({
|
|
|
22249
22336
|
}
|
|
22250
22337
|
|
|
22251
22338
|
// src/views/AccountingOverview/internal/TransactionsToReview.tsx
|
|
22252
|
-
var
|
|
22253
|
-
var
|
|
22339
|
+
var import_react111 = require("react");
|
|
22340
|
+
var import_date_fns30 = require("date-fns");
|
|
22254
22341
|
var import_jsx_runtime193 = require("react/jsx-runtime");
|
|
22255
22342
|
var CLASS_NAME12 = "Layer__TransactionsToReview";
|
|
22256
22343
|
function TransactionsToReview({
|
|
@@ -22260,23 +22347,23 @@ function TransactionsToReview({
|
|
|
22260
22347
|
variants
|
|
22261
22348
|
}) {
|
|
22262
22349
|
const { size = "sm" } = variants != null ? variants : {};
|
|
22263
|
-
const { dateRange: contextDateRange } = (0,
|
|
22350
|
+
const { dateRange: contextDateRange } = (0, import_react111.useContext)(ProfitAndLoss.Context);
|
|
22264
22351
|
const dateRange = usePnlDateRange ? contextDateRange : void 0;
|
|
22265
|
-
const [toReview, setToReview] = (0,
|
|
22352
|
+
const [toReview, setToReview] = (0, import_react111.useState)(0);
|
|
22266
22353
|
const { data, loaded, error, refetch } = useProfitAndLossLTM({
|
|
22267
|
-
currentDate: dateRange ? dateRange.startDate : (0,
|
|
22354
|
+
currentDate: dateRange ? dateRange.startDate : (0, import_date_fns30.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
22268
22355
|
tagFilter
|
|
22269
22356
|
});
|
|
22270
|
-
(0,
|
|
22357
|
+
(0, import_react111.useEffect)(() => {
|
|
22271
22358
|
checkTransactionsToReview();
|
|
22272
22359
|
}, []);
|
|
22273
|
-
(0,
|
|
22360
|
+
(0, import_react111.useEffect)(() => {
|
|
22274
22361
|
checkTransactionsToReview();
|
|
22275
22362
|
}, [dateRange, loaded]);
|
|
22276
22363
|
const checkTransactionsToReview = () => {
|
|
22277
22364
|
if (data && dateRange) {
|
|
22278
22365
|
const monthTx = data.filter(
|
|
22279
|
-
(x) => x.month - 1 === (0,
|
|
22366
|
+
(x) => x.month - 1 === (0, import_date_fns30.getMonth)(dateRange.startDate) && x.year === (0, import_date_fns30.getYear)(dateRange.startDate)
|
|
22280
22367
|
);
|
|
22281
22368
|
if (monthTx.length > 0) {
|
|
22282
22369
|
setToReview(monthTx[0].uncategorized_transactions);
|
|
@@ -22351,8 +22438,8 @@ function Internal_ProfitAndLossSummaries({
|
|
|
22351
22438
|
isLoading,
|
|
22352
22439
|
setSidebarScope,
|
|
22353
22440
|
sidebarScope
|
|
22354
|
-
} = (0,
|
|
22355
|
-
const { revenueChartData, expensesChartData } = (0,
|
|
22441
|
+
} = (0, import_react112.useContext)(ProfitAndLoss.Context);
|
|
22442
|
+
const { revenueChartData, expensesChartData } = (0, import_react112.useMemo)(
|
|
22356
22443
|
() => ({
|
|
22357
22444
|
revenueChartData: toMiniChartData({ scope: "revenue", data }),
|
|
22358
22445
|
expensesChartData: toMiniChartData({ scope: "expenses", data })
|
|
@@ -22454,10 +22541,10 @@ function ProfitAndLossSummaries(_a) {
|
|
|
22454
22541
|
}
|
|
22455
22542
|
|
|
22456
22543
|
// src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
|
|
22457
|
-
var
|
|
22544
|
+
var import_react118 = require("react");
|
|
22458
22545
|
|
|
22459
22546
|
// src/contexts/TableContext/TableContext.tsx
|
|
22460
|
-
var
|
|
22547
|
+
var import_react113 = require("react");
|
|
22461
22548
|
var import_jsx_runtime195 = require("react/jsx-runtime");
|
|
22462
22549
|
var defaultValue = {
|
|
22463
22550
|
expandedRows: [],
|
|
@@ -22469,10 +22556,10 @@ var defaultValue = {
|
|
|
22469
22556
|
setExpandedAllRows: () => {
|
|
22470
22557
|
}
|
|
22471
22558
|
};
|
|
22472
|
-
var TableContext = (0,
|
|
22559
|
+
var TableContext = (0, import_react113.createContext)(defaultValue);
|
|
22473
22560
|
var TableProvider = ({ children }) => {
|
|
22474
|
-
const [expandedRows, setExpandedRowsState] = (0,
|
|
22475
|
-
const [expandedAllRows, setExpandedAllRows] = (0,
|
|
22561
|
+
const [expandedRows, setExpandedRowsState] = (0, import_react113.useState)([]);
|
|
22562
|
+
const [expandedAllRows, setExpandedAllRows] = (0, import_react113.useState)(false);
|
|
22476
22563
|
const toggleRow = (rowKey) => {
|
|
22477
22564
|
setExpandedRowsState((prevRows) => {
|
|
22478
22565
|
const rows = [...prevRows];
|
|
@@ -22498,10 +22585,10 @@ var TableProvider = ({ children }) => {
|
|
|
22498
22585
|
};
|
|
22499
22586
|
|
|
22500
22587
|
// src/components/ProfitAndLossTable/ProfitAndLossCompareTable.tsx
|
|
22501
|
-
var
|
|
22588
|
+
var import_react116 = require("react");
|
|
22502
22589
|
|
|
22503
22590
|
// src/hooks/useTableExpandRow/useTableExpandRow.tsx
|
|
22504
|
-
var
|
|
22591
|
+
var import_react114 = require("react");
|
|
22505
22592
|
var useTableExpandRow = () => {
|
|
22506
22593
|
const {
|
|
22507
22594
|
expandedAllRows,
|
|
@@ -22509,7 +22596,7 @@ var useTableExpandRow = () => {
|
|
|
22509
22596
|
expandAllRows,
|
|
22510
22597
|
expandedRows,
|
|
22511
22598
|
setExpandedRows
|
|
22512
|
-
} = (0,
|
|
22599
|
+
} = (0, import_react114.useContext)(TableContext);
|
|
22513
22600
|
const toggleAllRows = () => {
|
|
22514
22601
|
if (expandedAllRows) {
|
|
22515
22602
|
setIsOpen([]);
|
|
@@ -22537,7 +22624,7 @@ var useTableExpandRow = () => {
|
|
|
22537
22624
|
};
|
|
22538
22625
|
|
|
22539
22626
|
// src/utils/profitAndLossComparisonUtils.ts
|
|
22540
|
-
var
|
|
22627
|
+
var import_date_fns31 = require("date-fns");
|
|
22541
22628
|
var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) => {
|
|
22542
22629
|
switch (rangeDisplayMode) {
|
|
22543
22630
|
case "yearPicker":
|
|
@@ -22548,14 +22635,14 @@ var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) =
|
|
|
22548
22635
|
};
|
|
22549
22636
|
var generateComparisonMonths = (startDate, numberOfMonths) => {
|
|
22550
22637
|
return Array.from({ length: numberOfMonths }, (_, index) => {
|
|
22551
|
-
const currentMonth = (0,
|
|
22552
|
-
return { date: currentMonth, label: (0,
|
|
22638
|
+
const currentMonth = (0, import_date_fns31.subMonths)(startDate, numberOfMonths - index - 1);
|
|
22639
|
+
return { date: currentMonth, label: (0, import_date_fns31.format)(currentMonth, "MMM") };
|
|
22553
22640
|
});
|
|
22554
22641
|
};
|
|
22555
22642
|
var generateComparisonYears = (startDate, numberOfYears) => {
|
|
22556
22643
|
return Array.from({ length: numberOfYears }, (_, index) => {
|
|
22557
|
-
const currentMonth = (0,
|
|
22558
|
-
return { date: currentMonth, label: (0,
|
|
22644
|
+
const currentMonth = (0, import_date_fns31.subYears)(startDate, numberOfYears - index - 1);
|
|
22645
|
+
return { date: currentMonth, label: (0, import_date_fns31.format)(currentMonth, "yyyy") };
|
|
22559
22646
|
});
|
|
22560
22647
|
};
|
|
22561
22648
|
var getComparisonValue = (name, depth, cellData) => {
|
|
@@ -22730,7 +22817,7 @@ var TableRow = ({
|
|
|
22730
22817
|
};
|
|
22731
22818
|
|
|
22732
22819
|
// src/components/Table/Table.tsx
|
|
22733
|
-
var
|
|
22820
|
+
var import_react115 = require("react");
|
|
22734
22821
|
var import_classnames64 = __toESM(require("classnames"));
|
|
22735
22822
|
var import_jsx_runtime200 = require("react/jsx-runtime");
|
|
22736
22823
|
var Table = ({
|
|
@@ -22739,9 +22826,9 @@ var Table = ({
|
|
|
22739
22826
|
borderCollapse = "separate",
|
|
22740
22827
|
bottomSpacing = true
|
|
22741
22828
|
}) => {
|
|
22742
|
-
const tableRef = (0,
|
|
22743
|
-
const prevChildrenRef = (0,
|
|
22744
|
-
(0,
|
|
22829
|
+
const tableRef = (0, import_react115.useRef)(null);
|
|
22830
|
+
const prevChildrenRef = (0, import_react115.useRef)([]);
|
|
22831
|
+
(0, import_react115.useEffect)(() => {
|
|
22745
22832
|
if (tableRef.current) {
|
|
22746
22833
|
const tbody = tableRef.current.querySelector("tbody");
|
|
22747
22834
|
const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
|
|
@@ -22790,17 +22877,17 @@ var import_jsx_runtime201 = require("react/jsx-runtime");
|
|
|
22790
22877
|
var ProfitAndLossCompareTable = ({
|
|
22791
22878
|
stringOverrides
|
|
22792
22879
|
}) => {
|
|
22793
|
-
const { dateRange } = (0,
|
|
22880
|
+
const { dateRange } = (0, import_react116.useContext)(ProfitAndLoss.Context);
|
|
22794
22881
|
const {
|
|
22795
22882
|
data: comparisonData,
|
|
22796
22883
|
isLoading,
|
|
22797
22884
|
comparePeriods,
|
|
22798
22885
|
selectedCompareOptions
|
|
22799
|
-
} = (0,
|
|
22886
|
+
} = (0, import_react116.useContext)(ProfitAndLoss.ComparisonContext);
|
|
22800
22887
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
22801
22888
|
const { rangeDisplayMode } = useGlobalDateRange();
|
|
22802
22889
|
const { data: bookkeepingPeriods } = useBookkeepingPeriods();
|
|
22803
|
-
(0,
|
|
22890
|
+
(0, import_react116.useEffect)(() => {
|
|
22804
22891
|
setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
|
|
22805
22892
|
}, []);
|
|
22806
22893
|
if (isLoading || comparisonData === void 0) {
|
|
@@ -22824,7 +22911,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22824
22911
|
if (!period) {
|
|
22825
22912
|
return;
|
|
22826
22913
|
}
|
|
22827
|
-
return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
|
|
22914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BookkeepingStatus2, { status: period.status, monthNumber: currentMonth, iconOnly: true });
|
|
22828
22915
|
};
|
|
22829
22916
|
const renderRow = (rowKey, depth, rowDisplayName, lineItem, data) => {
|
|
22830
22917
|
const rowData = data ? data : [];
|
|
@@ -22844,7 +22931,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22844
22931
|
}
|
|
22845
22932
|
const expandable = (lineItem == null ? void 0 : lineItem.line_items) && lineItem.line_items.length > 0 ? true : false;
|
|
22846
22933
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
22847
|
-
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
|
|
22934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react116.Fragment, { children: [
|
|
22848
22935
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
|
|
22849
22936
|
TableRow,
|
|
22850
22937
|
{
|
|
@@ -22878,7 +22965,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22878
22965
|
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(Table, { borderCollapse: "collapse", bottomSpacing: false, children: [
|
|
22879
22966
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableHead, { children: selectedCompareOptions && selectedCompareOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
|
|
22880
22967
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
|
|
22881
|
-
selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
|
|
22968
|
+
selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react116.Fragment, { children: [
|
|
22882
22969
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { primary: true, isHeaderCell: true, children: option.displayName }, option.displayName + "-" + i),
|
|
22883
22970
|
comparePeriods && Array.from({ length: comparePeriods - 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }, option.displayName + "-" + index))
|
|
22884
22971
|
] }, option.displayName + "-" + i))
|
|
@@ -22886,7 +22973,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22886
22973
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableBody, { children: [
|
|
22887
22974
|
comparePeriods && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
|
|
22888
22975
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
|
|
22889
|
-
selectedCompareOptions && selectedCompareOptions.length > 0 ? selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
|
|
22976
|
+
selectedCompareOptions && selectedCompareOptions.length > 0 ? selectedCompareOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react116.Fragment, { children: generateComparisonPeriods(
|
|
22890
22977
|
dateRange.startDate,
|
|
22891
22978
|
comparePeriods,
|
|
22892
22979
|
rangeDisplayMode
|
|
@@ -22894,7 +22981,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22894
22981
|
month.label,
|
|
22895
22982
|
" ",
|
|
22896
22983
|
getBookkeepingPeriodStatus(month.date)
|
|
22897
|
-
] }) }, option.displayName + "-" + index)) }, option.displayName + "-" + i)) : /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
|
|
22984
|
+
] }) }, option.displayName + "-" + index)) }, option.displayName + "-" + i)) : /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(import_react116.Fragment, { children: generateComparisonPeriods(
|
|
22898
22985
|
dateRange.startDate,
|
|
22899
22986
|
comparePeriods,
|
|
22900
22987
|
rangeDisplayMode
|
|
@@ -22926,7 +23013,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22926
23013
|
};
|
|
22927
23014
|
|
|
22928
23015
|
// src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
|
|
22929
|
-
var
|
|
23016
|
+
var import_react117 = require("react");
|
|
22930
23017
|
|
|
22931
23018
|
// src/icons/PieChart.tsx
|
|
22932
23019
|
var import_jsx_runtime202 = require("react/jsx-runtime");
|
|
@@ -23025,9 +23112,9 @@ var ProfitAndLossTableComponent = ({
|
|
|
23025
23112
|
data: actualData,
|
|
23026
23113
|
isLoading,
|
|
23027
23114
|
setSidebarScope
|
|
23028
|
-
} = (0,
|
|
23115
|
+
} = (0, import_react117.useContext)(ProfitAndLoss.Context);
|
|
23029
23116
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
23030
|
-
(0,
|
|
23117
|
+
(0, import_react117.useEffect)(() => {
|
|
23031
23118
|
setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
|
|
23032
23119
|
}, []);
|
|
23033
23120
|
const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
|
|
@@ -23047,7 +23134,7 @@ var ProfitAndLossTableComponent = ({
|
|
|
23047
23134
|
const renderLineItem = (lineItem, depth, rowKey, rowIndex, scope, setSidebarScope2, variant) => {
|
|
23048
23135
|
const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
|
|
23049
23136
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
23050
|
-
return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
|
|
23137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_react117.Fragment, { children: [
|
|
23051
23138
|
/* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
|
|
23052
23139
|
TableRow,
|
|
23053
23140
|
{
|
|
@@ -23120,8 +23207,8 @@ var ProfitAndLossTableComponent = ({
|
|
|
23120
23207
|
0,
|
|
23121
23208
|
"gross_profit",
|
|
23122
23209
|
2,
|
|
23123
|
-
|
|
23124
|
-
|
|
23210
|
+
void 0,
|
|
23211
|
+
void 0,
|
|
23125
23212
|
"summation"
|
|
23126
23213
|
),
|
|
23127
23214
|
renderLineItem(
|
|
@@ -23140,11 +23227,17 @@ var ProfitAndLossTableComponent = ({
|
|
|
23140
23227
|
0,
|
|
23141
23228
|
"profit_before_taxes",
|
|
23142
23229
|
4,
|
|
23143
|
-
|
|
23144
|
-
|
|
23230
|
+
void 0,
|
|
23231
|
+
void 0,
|
|
23145
23232
|
"summation"
|
|
23146
23233
|
),
|
|
23147
|
-
renderLineItem(
|
|
23234
|
+
renderLineItem(
|
|
23235
|
+
data.taxes,
|
|
23236
|
+
0,
|
|
23237
|
+
"taxes",
|
|
23238
|
+
5,
|
|
23239
|
+
"expenses"
|
|
23240
|
+
),
|
|
23148
23241
|
renderLineItem(
|
|
23149
23242
|
{
|
|
23150
23243
|
value: data.net_profit,
|
|
@@ -23165,14 +23258,14 @@ var ProfitAndLossTableComponent = ({
|
|
|
23165
23258
|
// src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
|
|
23166
23259
|
var import_jsx_runtime204 = require("react/jsx-runtime");
|
|
23167
23260
|
var ProfitAndLossTableWithProvider = (props) => {
|
|
23168
|
-
const { compareModeActive } = (0,
|
|
23261
|
+
const { compareModeActive } = (0, import_react118.useContext)(ProfitAndLoss.ComparisonContext);
|
|
23169
23262
|
return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(TableProvider, { children: compareModeActive ? /* @__PURE__ */ (0, import_jsx_runtime204.jsx)("div", { className: "Layer__compare__table__wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(ProfitAndLossCompareTable, __spreadValues({}, props)) }) : /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(ProfitAndLossTableComponent, __spreadValues({}, props)) });
|
|
23170
23263
|
};
|
|
23171
23264
|
|
|
23172
23265
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
23173
|
-
var
|
|
23266
|
+
var import_date_fns32 = require("date-fns");
|
|
23174
23267
|
var import_jsx_runtime205 = require("react/jsx-runtime");
|
|
23175
|
-
var PNLContext = (0,
|
|
23268
|
+
var PNLContext = (0, import_react119.createContext)({
|
|
23176
23269
|
data: void 0,
|
|
23177
23270
|
filteredDataRevenue: [],
|
|
23178
23271
|
filteredTotalRevenue: void 0,
|
|
@@ -23182,8 +23275,8 @@ var PNLContext = (0, import_react118.createContext)({
|
|
|
23182
23275
|
isValidating: false,
|
|
23183
23276
|
error: void 0,
|
|
23184
23277
|
dateRange: {
|
|
23185
|
-
startDate: (0,
|
|
23186
|
-
endDate: (0,
|
|
23278
|
+
startDate: (0, import_date_fns32.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
23279
|
+
endDate: (0, import_date_fns32.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23187
23280
|
},
|
|
23188
23281
|
changeDateRange: () => {
|
|
23189
23282
|
},
|
|
@@ -23227,7 +23320,7 @@ ProfitAndLoss.DownloadButton = ProfitAndLossDownloadButton;
|
|
|
23227
23320
|
|
|
23228
23321
|
// src/hooks/balanceSheet/useBalanceSheet.ts
|
|
23229
23322
|
var import_swr16 = __toESM(require("swr"));
|
|
23230
|
-
var
|
|
23323
|
+
var import_date_fns33 = require("date-fns");
|
|
23231
23324
|
function buildKey15({
|
|
23232
23325
|
access_token: accessToken,
|
|
23233
23326
|
apiUrl,
|
|
@@ -23245,7 +23338,7 @@ function buildKey15({
|
|
|
23245
23338
|
}
|
|
23246
23339
|
}
|
|
23247
23340
|
function useBalanceSheet({
|
|
23248
|
-
effectiveDate = (0,
|
|
23341
|
+
effectiveDate = (0, import_date_fns33.endOfDay)(/* @__PURE__ */ new Date())
|
|
23249
23342
|
}) {
|
|
23250
23343
|
const { data: auth } = useAuth();
|
|
23251
23344
|
const { apiUrl } = useEnvironment();
|
|
@@ -23270,12 +23363,12 @@ function useBalanceSheet({
|
|
|
23270
23363
|
}
|
|
23271
23364
|
|
|
23272
23365
|
// src/hooks/useElementViewSize/useElementViewSize.tsx
|
|
23273
|
-
var
|
|
23366
|
+
var import_react120 = require("react");
|
|
23274
23367
|
var useElementViewSize = () => {
|
|
23275
|
-
const containerRef = (0,
|
|
23276
|
-
const [view, setView] = (0,
|
|
23277
|
-
const resizeTimeout = (0,
|
|
23278
|
-
(0,
|
|
23368
|
+
const containerRef = (0, import_react120.useRef)(null);
|
|
23369
|
+
const [view, setView] = (0, import_react120.useState)("desktop");
|
|
23370
|
+
const resizeTimeout = (0, import_react120.useRef)(null);
|
|
23371
|
+
(0, import_react120.useLayoutEffect)(() => {
|
|
23279
23372
|
const element = containerRef == null ? void 0 : containerRef.current;
|
|
23280
23373
|
if (!element) {
|
|
23281
23374
|
return;
|
|
@@ -23344,7 +23437,7 @@ var BalanceSheetExpandAllButton = ({
|
|
|
23344
23437
|
};
|
|
23345
23438
|
|
|
23346
23439
|
// src/components/BalanceSheetTable/BalanceSheetTable.tsx
|
|
23347
|
-
var
|
|
23440
|
+
var import_react121 = require("react");
|
|
23348
23441
|
var import_jsx_runtime208 = require("react/jsx-runtime");
|
|
23349
23442
|
var BalanceSheetTable = ({
|
|
23350
23443
|
data,
|
|
@@ -23353,12 +23446,12 @@ var BalanceSheetTable = ({
|
|
|
23353
23446
|
}) => {
|
|
23354
23447
|
const { isOpen, setIsOpen, expandedAllRows } = useTableExpandRow();
|
|
23355
23448
|
const allRowKeys = [];
|
|
23356
|
-
(0,
|
|
23449
|
+
(0, import_react121.useEffect)(() => {
|
|
23357
23450
|
if (expandedAllRows) {
|
|
23358
23451
|
setIsOpen(allRowKeys, true);
|
|
23359
23452
|
}
|
|
23360
23453
|
}, [expandedAllRows]);
|
|
23361
|
-
(0,
|
|
23454
|
+
(0, import_react121.useEffect)(() => {
|
|
23362
23455
|
setIsOpen(["assets"]);
|
|
23363
23456
|
}, []);
|
|
23364
23457
|
const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
|
|
@@ -23368,7 +23461,7 @@ var BalanceSheetTable = ({
|
|
|
23368
23461
|
if (expandable) {
|
|
23369
23462
|
allRowKeys.push(rowKey);
|
|
23370
23463
|
}
|
|
23371
|
-
return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
|
|
23464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_react121.Fragment, { children: [
|
|
23372
23465
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
|
|
23373
23466
|
TableRow,
|
|
23374
23467
|
{
|
|
@@ -23419,7 +23512,7 @@ var BalanceSheetTable = ({
|
|
|
23419
23512
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, children: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type" }),
|
|
23420
23513
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, align: "right" /* RIGHT */, children: (stringOverrides == null ? void 0 : stringOverrides.totalColumnHeader) || "Total" })
|
|
23421
23514
|
] }) }),
|
|
23422
|
-
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableBody, { children: config.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
|
|
23515
|
+
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableBody, { children: config.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_react121.Fragment, { children: data[row.lineItem] && renderLineItem(
|
|
23423
23516
|
data[row.lineItem],
|
|
23424
23517
|
0,
|
|
23425
23518
|
row.lineItem,
|
|
@@ -23593,7 +23686,7 @@ var BalanceSheetView = ({
|
|
|
23593
23686
|
};
|
|
23594
23687
|
|
|
23595
23688
|
// src/components/StatementOfCashFlowTable/StatementOfCashFlowTable.tsx
|
|
23596
|
-
var
|
|
23689
|
+
var import_react122 = require("react");
|
|
23597
23690
|
var import_jsx_runtime211 = require("react/jsx-runtime");
|
|
23598
23691
|
var StatementOfCashFlowTable = ({
|
|
23599
23692
|
data,
|
|
@@ -23604,7 +23697,7 @@ var StatementOfCashFlowTable = ({
|
|
|
23604
23697
|
const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
|
|
23605
23698
|
const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
|
|
23606
23699
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
23607
|
-
return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
|
|
23700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(import_react122.Fragment, { children: [
|
|
23608
23701
|
/* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
|
|
23609
23702
|
TableRow,
|
|
23610
23703
|
{
|
|
@@ -23656,7 +23749,7 @@ var StatementOfCashFlowTable = ({
|
|
|
23656
23749
|
] }) }),
|
|
23657
23750
|
/* @__PURE__ */ (0, import_jsx_runtime211.jsx)(TableBody, { children: config.map((row, idx) => {
|
|
23658
23751
|
if (row.type === "line_item") {
|
|
23659
|
-
return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
|
|
23752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_react122.Fragment, { children: data[row.lineItem] && renderLineItem(
|
|
23660
23753
|
data[row.lineItem],
|
|
23661
23754
|
0,
|
|
23662
23755
|
row.lineItem ? row.lineItem : "",
|
|
@@ -23835,9 +23928,7 @@ function StatementOfCashFlowDatePicker({
|
|
|
23835
23928
|
selected,
|
|
23836
23929
|
onChange: (dates) => {
|
|
23837
23930
|
if (dates instanceof Date) {
|
|
23838
|
-
|
|
23839
|
-
setSelected({ start: dates, end: dates });
|
|
23840
|
-
}
|
|
23931
|
+
setSelected({ start: dates, end: dates });
|
|
23841
23932
|
return;
|
|
23842
23933
|
}
|
|
23843
23934
|
const [start, end] = dates;
|
|
@@ -23862,7 +23953,7 @@ function StatementOfCashFlowDatePicker({
|
|
|
23862
23953
|
|
|
23863
23954
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
23864
23955
|
var import_swr17 = __toESM(require("swr"));
|
|
23865
|
-
var
|
|
23956
|
+
var import_date_fns34 = require("date-fns");
|
|
23866
23957
|
function buildKey18({
|
|
23867
23958
|
access_token: accessToken,
|
|
23868
23959
|
apiUrl,
|
|
@@ -23882,8 +23973,8 @@ function buildKey18({
|
|
|
23882
23973
|
}
|
|
23883
23974
|
}
|
|
23884
23975
|
function useStatementOfCashFlow({
|
|
23885
|
-
startDate = (0,
|
|
23886
|
-
endDate = (0,
|
|
23976
|
+
startDate = (0, import_date_fns34.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
23977
|
+
endDate = (0, import_date_fns34.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23887
23978
|
}) {
|
|
23888
23979
|
const { data: auth } = useAuth();
|
|
23889
23980
|
const { apiUrl } = useEnvironment();
|
|
@@ -23958,12 +24049,12 @@ var StatementOfCashFlowView = ({
|
|
|
23958
24049
|
};
|
|
23959
24050
|
|
|
23960
24051
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
23961
|
-
var
|
|
24052
|
+
var import_react136 = require("react");
|
|
23962
24053
|
|
|
23963
24054
|
// src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
|
|
23964
|
-
var
|
|
23965
|
-
var
|
|
23966
|
-
var ChartOfAccountsContext = (0,
|
|
24055
|
+
var import_react123 = require("react");
|
|
24056
|
+
var import_date_fns35 = require("date-fns");
|
|
24057
|
+
var ChartOfAccountsContext = (0, import_react123.createContext)(
|
|
23967
24058
|
{
|
|
23968
24059
|
data: void 0,
|
|
23969
24060
|
isLoading: false,
|
|
@@ -23985,8 +24076,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
|
|
|
23985
24076
|
submitForm: () => {
|
|
23986
24077
|
},
|
|
23987
24078
|
dateRange: {
|
|
23988
|
-
startDate: (0,
|
|
23989
|
-
endDate: (0,
|
|
24079
|
+
startDate: (0, import_date_fns35.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
24080
|
+
endDate: (0, import_date_fns35.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23990
24081
|
},
|
|
23991
24082
|
changeDateRange: () => {
|
|
23992
24083
|
}
|
|
@@ -23994,8 +24085,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
|
|
|
23994
24085
|
);
|
|
23995
24086
|
|
|
23996
24087
|
// src/contexts/LedgerAccountsContext/LedgerAccountsContext.tsx
|
|
23997
|
-
var
|
|
23998
|
-
var LedgerAccountsContext = (0,
|
|
24088
|
+
var import_react124 = require("react");
|
|
24089
|
+
var LedgerAccountsContext = (0, import_react124.createContext)({
|
|
23999
24090
|
data: void 0,
|
|
24000
24091
|
entryData: void 0,
|
|
24001
24092
|
isLoading: false,
|
|
@@ -24017,7 +24108,7 @@ var LedgerAccountsContext = (0, import_react123.createContext)({
|
|
|
24017
24108
|
});
|
|
24018
24109
|
|
|
24019
24110
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24020
|
-
var
|
|
24111
|
+
var import_react125 = require("react");
|
|
24021
24112
|
|
|
24022
24113
|
// src/components/ChartOfAccountsForm/constants.ts
|
|
24023
24114
|
var LEDGER_ACCOUNT_TYPES = [
|
|
@@ -24221,7 +24312,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
24221
24312
|
};
|
|
24222
24313
|
|
|
24223
24314
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24224
|
-
var
|
|
24315
|
+
var import_date_fns36 = require("date-fns");
|
|
24225
24316
|
var import_swr18 = __toESM(require("swr"));
|
|
24226
24317
|
var validate = (formData) => {
|
|
24227
24318
|
const errors = [];
|
|
@@ -24305,8 +24396,8 @@ var validateName = (formData) => {
|
|
|
24305
24396
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
24306
24397
|
var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
|
|
24307
24398
|
withDates: false,
|
|
24308
|
-
startDate: (0,
|
|
24309
|
-
endDate: (0,
|
|
24399
|
+
startDate: (0, import_date_fns36.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
24400
|
+
endDate: (0, import_date_fns36.endOfMonth)(/* @__PURE__ */ new Date())
|
|
24310
24401
|
}) => {
|
|
24311
24402
|
const {
|
|
24312
24403
|
businessId,
|
|
@@ -24317,14 +24408,14 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24317
24408
|
} = useLayerContext();
|
|
24318
24409
|
const { apiUrl } = useEnvironment();
|
|
24319
24410
|
const { data: auth } = useAuth();
|
|
24320
|
-
const [form, setForm] = (0,
|
|
24321
|
-
const [sendingForm, setSendingForm] = (0,
|
|
24322
|
-
const [apiError, setApiError] = (0,
|
|
24323
|
-
const [startDate, setStartDate] = (0,
|
|
24324
|
-
initialStartDate != null ? initialStartDate : (0,
|
|
24411
|
+
const [form, setForm] = (0, import_react125.useState)();
|
|
24412
|
+
const [sendingForm, setSendingForm] = (0, import_react125.useState)(false);
|
|
24413
|
+
const [apiError, setApiError] = (0, import_react125.useState)(void 0);
|
|
24414
|
+
const [startDate, setStartDate] = (0, import_react125.useState)(
|
|
24415
|
+
initialStartDate != null ? initialStartDate : (0, import_date_fns36.startOfMonth)(Date.now())
|
|
24325
24416
|
);
|
|
24326
|
-
const [endDate, setEndDate] = (0,
|
|
24327
|
-
initialEndDate != null ? initialEndDate : (0,
|
|
24417
|
+
const [endDate, setEndDate] = (0, import_react125.useState)(
|
|
24418
|
+
initialEndDate != null ? initialEndDate : (0, import_date_fns36.endOfMonth)(Date.now())
|
|
24328
24419
|
);
|
|
24329
24420
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `chart-of-accounts-${businessId}-${startDate == null ? void 0 : startDate.valueOf()}-${endDate == null ? void 0 : endDate.valueOf()}`;
|
|
24330
24421
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr18.default)(
|
|
@@ -24332,8 +24423,8 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24332
24423
|
Layer.getLedgerAccountBalances(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24333
24424
|
params: {
|
|
24334
24425
|
businessId,
|
|
24335
|
-
startDate: withDates && startDate ? (0,
|
|
24336
|
-
endDate: withDates && endDate ? (0,
|
|
24426
|
+
startDate: withDates && startDate ? (0, import_date_fns36.formatISO)(startDate.valueOf()) : void 0,
|
|
24427
|
+
endDate: withDates && endDate ? (0, import_date_fns36.formatISO)(endDate.valueOf()) : void 0
|
|
24337
24428
|
}
|
|
24338
24429
|
})
|
|
24339
24430
|
);
|
|
@@ -24505,12 +24596,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24505
24596
|
newEndDate && setEndDate(newEndDate);
|
|
24506
24597
|
};
|
|
24507
24598
|
const refetch = () => mutate();
|
|
24508
|
-
(0,
|
|
24599
|
+
(0, import_react125.useEffect)(() => {
|
|
24509
24600
|
if (queryKey && (isLoading || isValidating)) {
|
|
24510
24601
|
read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */, queryKey);
|
|
24511
24602
|
}
|
|
24512
24603
|
}, [isLoading, isValidating]);
|
|
24513
|
-
(0,
|
|
24604
|
+
(0, import_react125.useEffect)(() => {
|
|
24514
24605
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
24515
24606
|
refetch();
|
|
24516
24607
|
}
|
|
@@ -24538,17 +24629,17 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24538
24629
|
// src/hooks/useChartOfAccounts/useCreateChildAccount.tsx
|
|
24539
24630
|
var import_mutation9 = __toESM(require("swr/mutation"));
|
|
24540
24631
|
var import_swr19 = require("swr");
|
|
24541
|
-
var
|
|
24632
|
+
var import_react126 = require("react");
|
|
24542
24633
|
|
|
24543
24634
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
24544
|
-
var
|
|
24635
|
+
var import_react127 = require("react");
|
|
24545
24636
|
var import_swr20 = __toESM(require("swr"));
|
|
24546
24637
|
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
24547
24638
|
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
24548
24639
|
const { apiUrl } = useEnvironment();
|
|
24549
24640
|
const { data: auth } = useAuth();
|
|
24550
|
-
const [accountId, setAccountId] = (0,
|
|
24551
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
24641
|
+
const [accountId, setAccountId] = (0, import_react127.useState)();
|
|
24642
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react127.useState)();
|
|
24552
24643
|
const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
24553
24644
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr20.default)(
|
|
24554
24645
|
queryKey,
|
|
@@ -24577,12 +24668,12 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24577
24668
|
setSelectedEntryId(void 0);
|
|
24578
24669
|
mutateEntryData();
|
|
24579
24670
|
};
|
|
24580
|
-
(0,
|
|
24671
|
+
(0, import_react127.useEffect)(() => {
|
|
24581
24672
|
if (queryKey && (isLoading || isValidating)) {
|
|
24582
24673
|
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
24583
24674
|
}
|
|
24584
24675
|
}, [isLoading, isValidating]);
|
|
24585
|
-
(0,
|
|
24676
|
+
(0, import_react127.useEffect)(() => {
|
|
24586
24677
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
24587
24678
|
refetch();
|
|
24588
24679
|
}
|
|
@@ -24606,7 +24697,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24606
24697
|
};
|
|
24607
24698
|
|
|
24608
24699
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTableWithPanel.tsx
|
|
24609
|
-
var
|
|
24700
|
+
var import_react132 = require("react");
|
|
24610
24701
|
|
|
24611
24702
|
// src/icons/Plus.tsx
|
|
24612
24703
|
var import_jsx_runtime215 = require("react/jsx-runtime");
|
|
@@ -24647,11 +24738,11 @@ var Plus = (_a) => {
|
|
|
24647
24738
|
var Plus_default = Plus;
|
|
24648
24739
|
|
|
24649
24740
|
// src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
|
|
24650
|
-
var
|
|
24651
|
-
var
|
|
24741
|
+
var import_react128 = require("react");
|
|
24742
|
+
var import_date_fns37 = require("date-fns");
|
|
24652
24743
|
var import_jsx_runtime216 = require("react/jsx-runtime");
|
|
24653
24744
|
var ChartOfAccountsDatePicker = () => {
|
|
24654
|
-
const { changeDateRange, dateRange } = (0,
|
|
24745
|
+
const { changeDateRange, dateRange } = (0, import_react128.useContext)(ChartOfAccountsContext);
|
|
24655
24746
|
return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(
|
|
24656
24747
|
DatePicker,
|
|
24657
24748
|
{
|
|
@@ -24660,8 +24751,8 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
24660
24751
|
onChange: (date) => {
|
|
24661
24752
|
if (!Array.isArray(date)) {
|
|
24662
24753
|
changeDateRange({
|
|
24663
|
-
startDate: (0,
|
|
24664
|
-
endDate: (0,
|
|
24754
|
+
startDate: (0, import_date_fns37.startOfMonth)(date),
|
|
24755
|
+
endDate: (0, import_date_fns37.endOfMonth)(date)
|
|
24665
24756
|
});
|
|
24666
24757
|
}
|
|
24667
24758
|
}
|
|
@@ -24670,13 +24761,13 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
24670
24761
|
};
|
|
24671
24762
|
|
|
24672
24763
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
24673
|
-
var
|
|
24764
|
+
var import_react130 = require("react");
|
|
24674
24765
|
|
|
24675
24766
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
24676
|
-
var
|
|
24767
|
+
var import_react129 = require("react");
|
|
24677
24768
|
var useParentOptions = (data) => {
|
|
24678
24769
|
var _a;
|
|
24679
|
-
return (0,
|
|
24770
|
+
return (0, import_react129.useMemo)(
|
|
24680
24771
|
() => flattenAccounts((data == null ? void 0 : data.accounts) || []).sort((a, b) => (a == null ? void 0 : a.name) && (b == null ? void 0 : b.name) ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
24681
24772
|
return {
|
|
24682
24773
|
label: x.name,
|
|
@@ -24701,9 +24792,9 @@ var ChartOfAccountsForm = ({
|
|
|
24701
24792
|
submitForm,
|
|
24702
24793
|
sendingForm,
|
|
24703
24794
|
apiError
|
|
24704
|
-
} = (0,
|
|
24795
|
+
} = (0, import_react130.useContext)(ChartOfAccountsContext);
|
|
24705
24796
|
const parentOptions = useParentOptions(data);
|
|
24706
|
-
const entry = (0,
|
|
24797
|
+
const entry = (0, import_react130.useMemo)(() => {
|
|
24707
24798
|
if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
|
|
24708
24799
|
return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
|
|
24709
24800
|
(x) => x.id === form.accountId
|
|
@@ -24916,7 +25007,7 @@ var ChartOfAccountsSidebar = ({
|
|
|
24916
25007
|
};
|
|
24917
25008
|
|
|
24918
25009
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
24919
|
-
var
|
|
25010
|
+
var import_react131 = require("react");
|
|
24920
25011
|
|
|
24921
25012
|
// src/icons/Edit2.tsx
|
|
24922
25013
|
var import_jsx_runtime219 = require("react/jsx-runtime");
|
|
@@ -24976,18 +25067,18 @@ var ChartOfAccountsTableContent = ({
|
|
|
24976
25067
|
expandAll,
|
|
24977
25068
|
templateAccountsEditable
|
|
24978
25069
|
}) => {
|
|
24979
|
-
const { setAccountId } = (0,
|
|
24980
|
-
const { editAccount } = (0,
|
|
25070
|
+
const { setAccountId } = (0, import_react131.useContext)(LedgerAccountsContext);
|
|
25071
|
+
const { editAccount } = (0, import_react131.useContext)(ChartOfAccountsContext);
|
|
24981
25072
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
24982
|
-
const [accountsRowKeys, setAccountsRowKeys] = (0,
|
|
24983
|
-
(0,
|
|
25073
|
+
const [accountsRowKeys, setAccountsRowKeys] = (0, import_react131.useState)([]);
|
|
25074
|
+
(0, import_react131.useEffect)(() => {
|
|
24984
25075
|
if (expandAll === "expanded") {
|
|
24985
25076
|
setIsOpen(accountsRowKeys);
|
|
24986
25077
|
} else if (expandAll === "collapsed") {
|
|
24987
25078
|
setIsOpen([]);
|
|
24988
25079
|
}
|
|
24989
25080
|
}, [expandAll]);
|
|
24990
|
-
(0,
|
|
25081
|
+
(0, import_react131.useEffect)(() => {
|
|
24991
25082
|
const defaultExpanded = data.accounts.map(
|
|
24992
25083
|
(account) => "coa-row-" + account.id
|
|
24993
25084
|
);
|
|
@@ -25006,7 +25097,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
25006
25097
|
var _a, _b;
|
|
25007
25098
|
const expandable = !!account.sub_accounts && account.sub_accounts.length > 0;
|
|
25008
25099
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
25009
|
-
return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
|
|
25100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_react131.Fragment, { children: [
|
|
25010
25101
|
/* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
|
|
25011
25102
|
TableRow,
|
|
25012
25103
|
{
|
|
@@ -25182,8 +25273,8 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
25182
25273
|
templateAccountsEditable
|
|
25183
25274
|
}) => {
|
|
25184
25275
|
var _a;
|
|
25185
|
-
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0,
|
|
25186
|
-
const [expandAll, setExpandAll] = (0,
|
|
25276
|
+
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react132.useContext)(ChartOfAccountsContext);
|
|
25277
|
+
const [expandAll, setExpandAll] = (0, import_react132.useState)();
|
|
25187
25278
|
const cumulativeIndex = 0;
|
|
25188
25279
|
const accountsLength = (_a = data == null ? void 0 : data.accounts.length) != null ? _a : 0;
|
|
25189
25280
|
return /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)(
|
|
@@ -25288,10 +25379,10 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
25288
25379
|
};
|
|
25289
25380
|
|
|
25290
25381
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
25291
|
-
var
|
|
25382
|
+
var import_react135 = require("react");
|
|
25292
25383
|
|
|
25293
25384
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
25294
|
-
var
|
|
25385
|
+
var import_react133 = require("react");
|
|
25295
25386
|
|
|
25296
25387
|
// src/utils/journal.ts
|
|
25297
25388
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -25319,21 +25410,21 @@ var lineEntryNumber = (ledgerEntryLine) => {
|
|
|
25319
25410
|
};
|
|
25320
25411
|
|
|
25321
25412
|
// src/components/DateTime/DateTime.tsx
|
|
25322
|
-
var
|
|
25413
|
+
var import_date_fns38 = require("date-fns");
|
|
25323
25414
|
var import_jsx_runtime223 = require("react/jsx-runtime");
|
|
25324
25415
|
var DateTime = ({
|
|
25325
25416
|
value,
|
|
25326
|
-
format:
|
|
25417
|
+
format: format8,
|
|
25327
25418
|
dateFormat,
|
|
25328
25419
|
timeFormat,
|
|
25329
25420
|
onlyDate,
|
|
25330
25421
|
onlyTime
|
|
25331
25422
|
}) => {
|
|
25332
|
-
if (
|
|
25333
|
-
return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0,
|
|
25423
|
+
if (format8) {
|
|
25424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), format8) });
|
|
25334
25425
|
}
|
|
25335
|
-
const date = (0,
|
|
25336
|
-
const time = (0,
|
|
25426
|
+
const date = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), dateFormat != null ? dateFormat : DATE_FORMAT);
|
|
25427
|
+
const time = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), timeFormat != null ? timeFormat : TIME_FORMAT);
|
|
25337
25428
|
return /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)(Text, { className: "Layer__datetime", children: [
|
|
25338
25429
|
!onlyTime && /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(
|
|
25339
25430
|
Text,
|
|
@@ -25535,8 +25626,8 @@ var LedgerAccountEntryDetails = ({
|
|
|
25535
25626
|
stringOverrides
|
|
25536
25627
|
}) => {
|
|
25537
25628
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
25538
|
-
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0,
|
|
25539
|
-
const { totalDebit, totalCredit } = (0,
|
|
25629
|
+
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react133.useContext)(LedgerAccountsContext);
|
|
25630
|
+
const { totalDebit, totalCredit } = (0, import_react133.useMemo)(() => {
|
|
25540
25631
|
var _a2;
|
|
25541
25632
|
let totalDebit2 = 0;
|
|
25542
25633
|
let totalCredit2 = 0;
|
|
@@ -25682,9 +25773,9 @@ var LedgerAccountEntryDetails = ({
|
|
|
25682
25773
|
};
|
|
25683
25774
|
|
|
25684
25775
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
25685
|
-
var
|
|
25776
|
+
var import_react134 = require("react");
|
|
25686
25777
|
var import_classnames68 = __toESM(require("classnames"));
|
|
25687
|
-
var
|
|
25778
|
+
var import_date_fns39 = require("date-fns");
|
|
25688
25779
|
var import_jsx_runtime227 = require("react/jsx-runtime");
|
|
25689
25780
|
var LedgerAccountRow = ({
|
|
25690
25781
|
row,
|
|
@@ -25693,9 +25784,9 @@ var LedgerAccountRow = ({
|
|
|
25693
25784
|
view
|
|
25694
25785
|
}) => {
|
|
25695
25786
|
var _a, _b, _c, _d, _e, _f;
|
|
25696
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
25697
|
-
const [showComponent, setShowComponent] = (0,
|
|
25698
|
-
(0,
|
|
25787
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react134.useContext)(LedgerAccountsContext);
|
|
25788
|
+
const [showComponent, setShowComponent] = (0, import_react134.useState)(false);
|
|
25789
|
+
(0, import_react134.useEffect)(() => {
|
|
25699
25790
|
if (initialLoad) {
|
|
25700
25791
|
const timeoutId = setTimeout(() => {
|
|
25701
25792
|
setShowComponent(true);
|
|
@@ -25727,7 +25818,7 @@ var LedgerAccountRow = ({
|
|
|
25727
25818
|
children: [
|
|
25728
25819
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("span", { className: "Layer__table-cell-content", children: [
|
|
25729
25820
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
|
|
25730
|
-
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0,
|
|
25821
|
+
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
|
|
25731
25822
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
|
|
25732
25823
|
Text,
|
|
25733
25824
|
{
|
|
@@ -25767,7 +25858,7 @@ var LedgerAccountRow = ({
|
|
|
25767
25858
|
},
|
|
25768
25859
|
children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("span", { className: "Layer__table-cell-content", children: [
|
|
25769
25860
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
|
|
25770
|
-
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0,
|
|
25861
|
+
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
|
|
25771
25862
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
|
|
25772
25863
|
Text,
|
|
25773
25864
|
{
|
|
@@ -25818,7 +25909,7 @@ var LedgerAccountRow = ({
|
|
|
25818
25909
|
}
|
|
25819
25910
|
},
|
|
25820
25911
|
children: [
|
|
25821
|
-
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0,
|
|
25912
|
+
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }) }),
|
|
25822
25913
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
|
|
25823
25914
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content", children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }) }),
|
|
25824
25915
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
@@ -25839,9 +25930,9 @@ var LedgerAccount = ({
|
|
|
25839
25930
|
stringOverrides
|
|
25840
25931
|
}) => {
|
|
25841
25932
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
25842
|
-
const [currentPage, setCurrentPage] = (0,
|
|
25843
|
-
const [initialLoad, setInitialLoad] = (0,
|
|
25844
|
-
const { data: accountData } = (0,
|
|
25933
|
+
const [currentPage, setCurrentPage] = (0, import_react135.useState)(1);
|
|
25934
|
+
const [initialLoad, setInitialLoad] = (0, import_react135.useState)(true);
|
|
25935
|
+
const { data: accountData } = (0, import_react135.useContext)(ChartOfAccountsContext);
|
|
25845
25936
|
const {
|
|
25846
25937
|
data: rawData,
|
|
25847
25938
|
error,
|
|
@@ -25852,8 +25943,8 @@ var LedgerAccount = ({
|
|
|
25852
25943
|
selectedEntryId,
|
|
25853
25944
|
closeSelectedEntry,
|
|
25854
25945
|
refetch
|
|
25855
|
-
} = (0,
|
|
25856
|
-
(0,
|
|
25946
|
+
} = (0, import_react135.useContext)(LedgerAccountsContext);
|
|
25947
|
+
(0, import_react135.useEffect)(() => {
|
|
25857
25948
|
if (!isLoading) {
|
|
25858
25949
|
const timeoutLoad = setTimeout(() => {
|
|
25859
25950
|
setInitialLoad(false);
|
|
@@ -25865,12 +25956,12 @@ var LedgerAccount = ({
|
|
|
25865
25956
|
"Layer__ledger-account__index",
|
|
25866
25957
|
accountId && "open"
|
|
25867
25958
|
);
|
|
25868
|
-
const account = (0,
|
|
25959
|
+
const account = (0, import_react135.useMemo)(() => {
|
|
25869
25960
|
return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
|
|
25870
25961
|
(x) => x.id === accountId
|
|
25871
25962
|
);
|
|
25872
25963
|
}, [accountId]);
|
|
25873
|
-
const data = (0,
|
|
25964
|
+
const data = (0, import_react135.useMemo)(() => {
|
|
25874
25965
|
var _a2;
|
|
25875
25966
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
25876
25967
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
@@ -26008,7 +26099,7 @@ var ChartOfAccountsContent = ({
|
|
|
26008
26099
|
templateAccountsEditable,
|
|
26009
26100
|
showAddAccountButton
|
|
26010
26101
|
}) => {
|
|
26011
|
-
const { accountId } = (0,
|
|
26102
|
+
const { accountId } = (0, import_react136.useContext)(LedgerAccountsContext);
|
|
26012
26103
|
const { view, containerRef } = useElementViewSize();
|
|
26013
26104
|
return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(Container, { name: "chart-of-accounts", ref: containerRef, asWidget, children: accountId ? /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
|
|
26014
26105
|
LedgerAccount,
|
|
@@ -26033,8 +26124,8 @@ var ChartOfAccountsContent = ({
|
|
|
26033
26124
|
};
|
|
26034
26125
|
|
|
26035
26126
|
// src/contexts/JournalContext/JournalContext.tsx
|
|
26036
|
-
var
|
|
26037
|
-
var JournalContext = (0,
|
|
26127
|
+
var import_react137 = require("react");
|
|
26128
|
+
var JournalContext = (0, import_react137.createContext)({
|
|
26038
26129
|
data: void 0,
|
|
26039
26130
|
isLoading: false,
|
|
26040
26131
|
error: void 0,
|
|
@@ -26068,7 +26159,7 @@ var JournalContext = (0, import_react136.createContext)({
|
|
|
26068
26159
|
});
|
|
26069
26160
|
|
|
26070
26161
|
// src/hooks/useJournal/useJournal.tsx
|
|
26071
|
-
var
|
|
26162
|
+
var import_react138 = require("react");
|
|
26072
26163
|
var import_swr21 = __toESM(require("swr"));
|
|
26073
26164
|
var useJournal = () => {
|
|
26074
26165
|
const {
|
|
@@ -26080,11 +26171,11 @@ var useJournal = () => {
|
|
|
26080
26171
|
} = useLayerContext();
|
|
26081
26172
|
const { apiUrl } = useEnvironment();
|
|
26082
26173
|
const { data: auth } = useAuth();
|
|
26083
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
26084
|
-
const [form, setForm] = (0,
|
|
26085
|
-
const [addingEntry, setAddingEntry] = (0,
|
|
26086
|
-
const [sendingForm, setSendingForm] = (0,
|
|
26087
|
-
const [apiError, setApiError] = (0,
|
|
26174
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react138.useState)();
|
|
26175
|
+
const [form, setForm] = (0, import_react138.useState)();
|
|
26176
|
+
const [addingEntry, setAddingEntry] = (0, import_react138.useState)(false);
|
|
26177
|
+
const [sendingForm, setSendingForm] = (0, import_react138.useState)(false);
|
|
26178
|
+
const [apiError, setApiError] = (0, import_react138.useState)(void 0);
|
|
26088
26179
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `journal-lines-${businessId}`;
|
|
26089
26180
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr21.default)(
|
|
26090
26181
|
queryKey,
|
|
@@ -26300,12 +26391,12 @@ var useJournal = () => {
|
|
|
26300
26391
|
params: { businessId, entryId }
|
|
26301
26392
|
});
|
|
26302
26393
|
});
|
|
26303
|
-
(0,
|
|
26394
|
+
(0, import_react138.useEffect)(() => {
|
|
26304
26395
|
if (queryKey && (isLoading || isValidating)) {
|
|
26305
26396
|
read("JOURNAL" /* JOURNAL */, queryKey);
|
|
26306
26397
|
}
|
|
26307
26398
|
}, [isLoading, isValidating]);
|
|
26308
|
-
(0,
|
|
26399
|
+
(0, import_react138.useEffect)(() => {
|
|
26309
26400
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
26310
26401
|
refetch();
|
|
26311
26402
|
}
|
|
@@ -26337,13 +26428,13 @@ var useJournal = () => {
|
|
|
26337
26428
|
};
|
|
26338
26429
|
|
|
26339
26430
|
// src/components/JournalTable/JournalTableWithPanel.tsx
|
|
26340
|
-
var
|
|
26431
|
+
var import_react144 = require("react");
|
|
26341
26432
|
|
|
26342
26433
|
// src/components/JournalSidebar/JournalSidebar.tsx
|
|
26343
|
-
var
|
|
26434
|
+
var import_react142 = require("react");
|
|
26344
26435
|
|
|
26345
26436
|
// src/components/JournalEntryDetails/JournalEntryDetails.tsx
|
|
26346
|
-
var
|
|
26437
|
+
var import_react139 = require("react");
|
|
26347
26438
|
var import_jsx_runtime230 = require("react/jsx-runtime");
|
|
26348
26439
|
var JournalEntryDetails = () => {
|
|
26349
26440
|
var _a, _b, _c, _d;
|
|
@@ -26355,16 +26446,16 @@ var JournalEntryDetails = () => {
|
|
|
26355
26446
|
selectedEntryId,
|
|
26356
26447
|
reverseEntry,
|
|
26357
26448
|
refetch
|
|
26358
|
-
} = (0,
|
|
26359
|
-
const [reverseEntryProcessing, setReverseEntryProcessing] = (0,
|
|
26360
|
-
const [reverseEntryError, setReverseEntryError] = (0,
|
|
26361
|
-
const entry = (0,
|
|
26449
|
+
} = (0, import_react139.useContext)(JournalContext);
|
|
26450
|
+
const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react139.useState)(false);
|
|
26451
|
+
const [reverseEntryError, setReverseEntryError] = (0, import_react139.useState)();
|
|
26452
|
+
const entry = (0, import_react139.useMemo)(() => {
|
|
26362
26453
|
if (selectedEntryId && data) {
|
|
26363
26454
|
return data.find((x) => x.id === selectedEntryId);
|
|
26364
26455
|
}
|
|
26365
26456
|
return;
|
|
26366
26457
|
}, [data, selectedEntryId]);
|
|
26367
|
-
const sortedLineItems = (0,
|
|
26458
|
+
const sortedLineItems = (0, import_react139.useMemo)(
|
|
26368
26459
|
() => {
|
|
26369
26460
|
var _a2;
|
|
26370
26461
|
return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
|
|
@@ -26542,10 +26633,10 @@ var JournalEntryDetails = () => {
|
|
|
26542
26633
|
};
|
|
26543
26634
|
|
|
26544
26635
|
// src/components/JournalForm/JournalForm.tsx
|
|
26545
|
-
var
|
|
26636
|
+
var import_react141 = require("react");
|
|
26546
26637
|
|
|
26547
26638
|
// src/components/JournalForm/JournalFormEntryLines.tsx
|
|
26548
|
-
var
|
|
26639
|
+
var import_react140 = require("react");
|
|
26549
26640
|
var import_jsx_runtime231 = require("react/jsx-runtime");
|
|
26550
26641
|
function recursiveFlattenCategories(accounts) {
|
|
26551
26642
|
const flattenedResult = accounts.flatMap((a) => {
|
|
@@ -26566,8 +26657,8 @@ var JournalFormEntryLines = ({
|
|
|
26566
26657
|
config
|
|
26567
26658
|
}) => {
|
|
26568
26659
|
const { data: categories } = useCategories({ mode: "ALL" });
|
|
26569
|
-
const { form } = (0,
|
|
26570
|
-
const { flattenedCategories, parentOptions } = (0,
|
|
26660
|
+
const { form } = (0, import_react140.useContext)(JournalContext);
|
|
26661
|
+
const { flattenedCategories, parentOptions } = (0, import_react140.useMemo)(() => {
|
|
26571
26662
|
const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
|
|
26572
26663
|
const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
|
|
26573
26664
|
switch (account.type) {
|
|
@@ -26779,7 +26870,7 @@ var JournalForm = ({
|
|
|
26779
26870
|
changeFormData,
|
|
26780
26871
|
addEntryLine,
|
|
26781
26872
|
removeEntryLine
|
|
26782
|
-
} = (0,
|
|
26873
|
+
} = (0, import_react141.useContext)(JournalContext);
|
|
26783
26874
|
return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
|
|
26784
26875
|
"form",
|
|
26785
26876
|
{
|
|
@@ -26927,7 +27018,7 @@ var JournalSidebar = ({
|
|
|
26927
27018
|
config,
|
|
26928
27019
|
stringOverrides
|
|
26929
27020
|
}) => {
|
|
26930
|
-
const { selectedEntryId } = (0,
|
|
27021
|
+
const { selectedEntryId } = (0, import_react142.useContext)(JournalContext);
|
|
26931
27022
|
if (selectedEntryId !== "new") {
|
|
26932
27023
|
return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(JournalEntryDetails, {});
|
|
26933
27024
|
}
|
|
@@ -26935,8 +27026,8 @@ var JournalSidebar = ({
|
|
|
26935
27026
|
};
|
|
26936
27027
|
|
|
26937
27028
|
// src/components/JournalTable/JournalTable.tsx
|
|
26938
|
-
var
|
|
26939
|
-
var
|
|
27029
|
+
var import_react143 = require("react");
|
|
27030
|
+
var import_date_fns40 = require("date-fns");
|
|
26940
27031
|
var import_jsx_runtime234 = require("react/jsx-runtime");
|
|
26941
27032
|
var accountName = (row) => {
|
|
26942
27033
|
if ("account" in row) {
|
|
@@ -26963,9 +27054,9 @@ var JournalTableContent = ({
|
|
|
26963
27054
|
data,
|
|
26964
27055
|
stringOverrides
|
|
26965
27056
|
}) => {
|
|
26966
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
27057
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react143.useContext)(JournalContext);
|
|
26967
27058
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
26968
|
-
(0,
|
|
27059
|
+
(0, import_react143.useEffect)(() => {
|
|
26969
27060
|
if (data.length > 0) {
|
|
26970
27061
|
setIsOpen(data.map((x) => `journal-row-${x.id}`));
|
|
26971
27062
|
}
|
|
@@ -26973,7 +27064,7 @@ var JournalTableContent = ({
|
|
|
26973
27064
|
const renderJournalRow = (row, index, rowKey, depth) => {
|
|
26974
27065
|
const expandable = !!row.line_items && row.line_items.length > 0;
|
|
26975
27066
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
26976
|
-
return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
|
|
27067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_react143.Fragment, { children: [
|
|
26977
27068
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
|
|
26978
27069
|
TableRow,
|
|
26979
27070
|
{
|
|
@@ -27003,7 +27094,7 @@ var JournalTableContent = ({
|
|
|
27003
27094
|
children: entryNumber(row)
|
|
27004
27095
|
}
|
|
27005
27096
|
),
|
|
27006
|
-
/* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: row.entry_at && (0,
|
|
27097
|
+
/* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: row.entry_at && (0, import_date_fns40.format)((0, import_date_fns40.parseISO)(row.entry_at), DATE_FORMAT) }),
|
|
27007
27098
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: humanizeEnum(row.entry_type) }),
|
|
27008
27099
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(TableCell, { children: [
|
|
27009
27100
|
"(",
|
|
@@ -27149,7 +27240,7 @@ var JournalTableWithPanel = ({
|
|
|
27149
27240
|
stringOverrides,
|
|
27150
27241
|
view
|
|
27151
27242
|
}) => {
|
|
27152
|
-
const [currentPage, setCurrentPage] = (0,
|
|
27243
|
+
const [currentPage, setCurrentPage] = (0, import_react144.useState)(1);
|
|
27153
27244
|
const {
|
|
27154
27245
|
data: rawData,
|
|
27155
27246
|
isLoading,
|
|
@@ -27158,8 +27249,8 @@ var JournalTableWithPanel = ({
|
|
|
27158
27249
|
refetch,
|
|
27159
27250
|
selectedEntryId,
|
|
27160
27251
|
addEntry
|
|
27161
|
-
} = (0,
|
|
27162
|
-
const data = (0,
|
|
27252
|
+
} = (0, import_react144.useContext)(JournalContext);
|
|
27253
|
+
const data = (0, import_react144.useMemo)(() => {
|
|
27163
27254
|
var _a;
|
|
27164
27255
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
27165
27256
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
@@ -27296,7 +27387,7 @@ var TasksHeader = ({
|
|
|
27296
27387
|
};
|
|
27297
27388
|
|
|
27298
27389
|
// src/components/Tasks/TasksList.tsx
|
|
27299
|
-
var
|
|
27390
|
+
var import_react152 = require("react");
|
|
27300
27391
|
|
|
27301
27392
|
// src/icons/SmileIcon.tsx
|
|
27302
27393
|
var import_jsx_runtime239 = require("react/jsx-runtime");
|
|
@@ -27355,7 +27446,7 @@ var SmileIcon = (_a) => {
|
|
|
27355
27446
|
var SmileIcon_default = SmileIcon;
|
|
27356
27447
|
|
|
27357
27448
|
// src/components/Tasks/TasksListItem.tsx
|
|
27358
|
-
var
|
|
27449
|
+
var import_react149 = require("react");
|
|
27359
27450
|
var import_classnames70 = __toESM(require("classnames"));
|
|
27360
27451
|
|
|
27361
27452
|
// src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
|
|
@@ -27413,7 +27504,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
27413
27504
|
}
|
|
27414
27505
|
|
|
27415
27506
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27416
|
-
var
|
|
27507
|
+
var import_react145 = require("react");
|
|
27417
27508
|
function buildKey21({
|
|
27418
27509
|
access_token: accessToken,
|
|
27419
27510
|
apiUrl,
|
|
@@ -27456,7 +27547,7 @@ function useSubmitUserResponseForTask() {
|
|
|
27456
27547
|
}
|
|
27457
27548
|
);
|
|
27458
27549
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27459
|
-
const stableProxiedTrigger = (0,
|
|
27550
|
+
const stableProxiedTrigger = (0, import_react145.useCallback)(
|
|
27460
27551
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27461
27552
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27462
27553
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27483,7 +27574,7 @@ function useSubmitUserResponseForTask() {
|
|
|
27483
27574
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
27484
27575
|
var import_swr23 = require("swr");
|
|
27485
27576
|
var import_mutation13 = __toESM(require("swr/mutation"));
|
|
27486
|
-
var
|
|
27577
|
+
var import_react146 = require("react");
|
|
27487
27578
|
function buildKey22({
|
|
27488
27579
|
access_token: accessToken,
|
|
27489
27580
|
apiUrl,
|
|
@@ -27522,7 +27613,7 @@ function useUploadDocumentsForTask() {
|
|
|
27522
27613
|
}
|
|
27523
27614
|
);
|
|
27524
27615
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27525
|
-
const stableProxiedTrigger = (0,
|
|
27616
|
+
const stableProxiedTrigger = (0, import_react146.useCallback)(
|
|
27526
27617
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27527
27618
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27528
27619
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27549,7 +27640,7 @@ function useUploadDocumentsForTask() {
|
|
|
27549
27640
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
27550
27641
|
var import_swr24 = require("swr");
|
|
27551
27642
|
var import_mutation14 = __toESM(require("swr/mutation"));
|
|
27552
|
-
var
|
|
27643
|
+
var import_react147 = require("react");
|
|
27553
27644
|
function buildKey23({
|
|
27554
27645
|
access_token: accessToken,
|
|
27555
27646
|
apiUrl,
|
|
@@ -27585,7 +27676,7 @@ function useDeleteUploadsOnTask() {
|
|
|
27585
27676
|
}
|
|
27586
27677
|
);
|
|
27587
27678
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27588
|
-
const stableProxiedTrigger = (0,
|
|
27679
|
+
const stableProxiedTrigger = (0, import_react147.useCallback)(
|
|
27589
27680
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27590
27681
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27591
27682
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27612,7 +27703,7 @@ function useDeleteUploadsOnTask() {
|
|
|
27612
27703
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
27613
27704
|
var import_swr25 = require("swr");
|
|
27614
27705
|
var import_mutation15 = __toESM(require("swr/mutation"));
|
|
27615
|
-
var
|
|
27706
|
+
var import_react148 = require("react");
|
|
27616
27707
|
function buildKey24({
|
|
27617
27708
|
access_token: accessToken,
|
|
27618
27709
|
apiUrl,
|
|
@@ -27652,7 +27743,7 @@ function useUpdateTaskUploadDescription() {
|
|
|
27652
27743
|
}
|
|
27653
27744
|
);
|
|
27654
27745
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27655
|
-
const stableProxiedTrigger = (0,
|
|
27746
|
+
const stableProxiedTrigger = (0, import_react148.useCallback)(
|
|
27656
27747
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27657
27748
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27658
27749
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27683,9 +27774,9 @@ var TasksListItem = ({
|
|
|
27683
27774
|
defaultOpen
|
|
27684
27775
|
}) => {
|
|
27685
27776
|
var _a, _b;
|
|
27686
|
-
const [isOpen, setIsOpen] = (0,
|
|
27687
|
-
const [userResponse, setUserResponse] = (0,
|
|
27688
|
-
const [selectedFiles, setSelectedFiles] = (0,
|
|
27777
|
+
const [isOpen, setIsOpen] = (0, import_react149.useState)(defaultOpen);
|
|
27778
|
+
const [userResponse, setUserResponse] = (0, import_react149.useState)((_a = task.user_response) != null ? _a : "");
|
|
27779
|
+
const [selectedFiles, setSelectedFiles] = (0, import_react149.useState)();
|
|
27689
27780
|
const { trigger: handleSubmitUserResponseForTask } = useSubmitUserResponseForTask();
|
|
27690
27781
|
const { trigger: handleUploadDocumentsForTask } = useUploadDocumentsForTask();
|
|
27691
27782
|
const { trigger: handleDeleteUploadsOnTask } = useDeleteUploadsOnTask();
|
|
@@ -27703,7 +27794,7 @@ var TasksListItem = ({
|
|
|
27703
27794
|
"Layer__tasks-list-item",
|
|
27704
27795
|
isOpen && "Layer__tasks-list-item__expanded"
|
|
27705
27796
|
);
|
|
27706
|
-
(0,
|
|
27797
|
+
(0, import_react149.useEffect)(() => {
|
|
27707
27798
|
setIsOpen(defaultOpen);
|
|
27708
27799
|
}, [defaultOpen]);
|
|
27709
27800
|
const submit = () => __async(null, null, function* () {
|
|
@@ -27718,7 +27809,7 @@ var TasksListItem = ({
|
|
|
27718
27809
|
setIsOpen(false);
|
|
27719
27810
|
setSelectedFiles(void 0);
|
|
27720
27811
|
});
|
|
27721
|
-
const uploadDocumentAction = (0,
|
|
27812
|
+
const uploadDocumentAction = (0, import_react149.useMemo)(() => {
|
|
27722
27813
|
if (task.user_response_type === "UPLOAD_DOCUMENT") {
|
|
27723
27814
|
if (task.status === "TODO") {
|
|
27724
27815
|
if (!selectedFiles) {
|
|
@@ -27863,7 +27954,7 @@ var MobilePanel = ({ header, children, open: open2, onClose, className }) => {
|
|
|
27863
27954
|
};
|
|
27864
27955
|
|
|
27865
27956
|
// src/components/Tasks/TasksListMobile.tsx
|
|
27866
|
-
var
|
|
27957
|
+
var import_react150 = require("react");
|
|
27867
27958
|
var import_jsx_runtime243 = require("react/jsx-runtime");
|
|
27868
27959
|
var MOBILE_SHOW_UNRESOLVED_TASKS_COUNT = 2;
|
|
27869
27960
|
var TasksListMobile = ({
|
|
@@ -27874,7 +27965,7 @@ var TasksListMobile = ({
|
|
|
27874
27965
|
pageSize,
|
|
27875
27966
|
setCurrentPage
|
|
27876
27967
|
}) => {
|
|
27877
|
-
const [showMobilePanel, setShowMobilePanel] = (0,
|
|
27968
|
+
const [showMobilePanel, setShowMobilePanel] = (0, import_react150.useState)(false);
|
|
27878
27969
|
const unresolvedTasks = getIncompleteTasks(sortedTasks).slice(0, MOBILE_SHOW_UNRESOLVED_TASKS_COUNT);
|
|
27879
27970
|
return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)("div", { className: "Layer__tasks-list", children: [
|
|
27880
27971
|
unresolvedTasks.map((task, index) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
|
|
@@ -27922,27 +28013,27 @@ var TasksListMobile = ({
|
|
|
27922
28013
|
};
|
|
27923
28014
|
|
|
27924
28015
|
// src/hooks/array/usePaginatedList.ts
|
|
27925
|
-
var
|
|
28016
|
+
var import_react151 = require("react");
|
|
27926
28017
|
function usePaginatedList(list, pageSize) {
|
|
27927
|
-
const [internalPageIndex, setInternalPageIndex] = (0,
|
|
28018
|
+
const [internalPageIndex, setInternalPageIndex] = (0, import_react151.useState)(0);
|
|
27928
28019
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
27929
28020
|
const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
|
|
27930
|
-
const pageItems = (0,
|
|
28021
|
+
const pageItems = (0, import_react151.useMemo)(() => {
|
|
27931
28022
|
return list.slice(
|
|
27932
28023
|
effectivePageIndex * pageSize,
|
|
27933
28024
|
(effectivePageIndex + 1) * pageSize
|
|
27934
28025
|
);
|
|
27935
28026
|
}, [list, effectivePageIndex, pageSize]);
|
|
27936
|
-
const next = (0,
|
|
28027
|
+
const next = (0, import_react151.useCallback)(() => {
|
|
27937
28028
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
27938
28029
|
}, [effectivePageIndex, pageCount]);
|
|
27939
|
-
const set2 = (0,
|
|
28030
|
+
const set2 = (0, import_react151.useCallback)((pageIndex) => {
|
|
27940
28031
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
27941
28032
|
}, [pageCount]);
|
|
27942
|
-
const previous = (0,
|
|
28033
|
+
const previous = (0, import_react151.useCallback)(() => {
|
|
27943
28034
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
27944
28035
|
}, [effectivePageIndex]);
|
|
27945
|
-
const reset = (0,
|
|
28036
|
+
const reset = (0, import_react151.useCallback)(() => {
|
|
27946
28037
|
setInternalPageIndex(0);
|
|
27947
28038
|
}, []);
|
|
27948
28039
|
return {
|
|
@@ -27970,7 +28061,7 @@ var TasksEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime244.jsxs)("div
|
|
|
27970
28061
|
] });
|
|
27971
28062
|
function TasksList({ pageSize = 8, mobile }) {
|
|
27972
28063
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
27973
|
-
const sortedTasks = (0,
|
|
28064
|
+
const sortedTasks = (0, import_react152.useMemo)(() => {
|
|
27974
28065
|
var _a;
|
|
27975
28066
|
const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
|
|
27976
28067
|
return tasksInPeriod.sort((taskA, taskB) => {
|
|
@@ -28021,7 +28112,7 @@ function TasksList({ pageSize = 8, mobile }) {
|
|
|
28021
28112
|
|
|
28022
28113
|
// src/components/Tasks/TasksPending.tsx
|
|
28023
28114
|
var import_recharts4 = require("recharts");
|
|
28024
|
-
var
|
|
28115
|
+
var import_date_fns41 = require("date-fns");
|
|
28025
28116
|
var import_classnames72 = __toESM(require("classnames"));
|
|
28026
28117
|
|
|
28027
28118
|
// src/components/BookkeepingStatus/BookkeepingStatusDescription.tsx
|
|
@@ -28058,7 +28149,7 @@ var TasksPending = () => {
|
|
|
28058
28149
|
);
|
|
28059
28150
|
return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending", children: [
|
|
28060
28151
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-header", children: [
|
|
28061
|
-
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0,
|
|
28152
|
+
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0, import_date_fns41.format)(date, "MMMM yyyy") }),
|
|
28062
28153
|
(activePeriod == null ? void 0 : activePeriod.tasks) && activePeriod.tasks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-bar", children: [
|
|
28063
28154
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(Text, { size: "sm" /* sm */, children: [
|
|
28064
28155
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)("span", { className: taskStatusClassName, children: completedTaskCount }),
|
|
@@ -28098,7 +28189,7 @@ var TasksPending = () => {
|
|
|
28098
28189
|
] }) : null
|
|
28099
28190
|
] }),
|
|
28100
28191
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: "Layer__tasks-pending-main", children: activePeriod && /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(import_jsx_runtime246.Fragment, { children: [
|
|
28101
|
-
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
|
|
28192
|
+
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(BookkeepingStatus2, { status: activePeriod.status, monthNumber: activePeriod.month }),
|
|
28102
28193
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
|
|
28103
28194
|
BookkeepingStatusDescription,
|
|
28104
28195
|
{
|
|
@@ -28112,17 +28203,17 @@ var TasksPending = () => {
|
|
|
28112
28203
|
};
|
|
28113
28204
|
|
|
28114
28205
|
// src/components/Tasks/TasksMonthSelector.tsx
|
|
28115
|
-
var
|
|
28116
|
-
var
|
|
28206
|
+
var import_react153 = require("react");
|
|
28207
|
+
var import_date_fns42 = require("date-fns");
|
|
28117
28208
|
|
|
28118
28209
|
// src/components/Tasks/TaskStatusBadge.tsx
|
|
28119
28210
|
var import_pluralize2 = __toESM(require("pluralize"));
|
|
28120
28211
|
var import_jsx_runtime247 = require("react/jsx-runtime");
|
|
28121
28212
|
var buildBadgeConfig = (status, tasksCount) => {
|
|
28122
28213
|
switch (status) {
|
|
28123
|
-
case "IN_PROGRESS_AWAITING_BOOKKEEPER"
|
|
28124
|
-
case "NOT_STARTED"
|
|
28125
|
-
case "CLOSING_IN_REVIEW"
|
|
28214
|
+
case "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */:
|
|
28215
|
+
case "NOT_STARTED" /* NOT_STARTED */:
|
|
28216
|
+
case "CLOSING_IN_REVIEW" /* CLOSING_IN_REVIEW */: {
|
|
28126
28217
|
return {
|
|
28127
28218
|
color: "info",
|
|
28128
28219
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(Clock_default, { size: 12 }),
|
|
@@ -28130,8 +28221,8 @@ var buildBadgeConfig = (status, tasksCount) => {
|
|
|
28130
28221
|
labelShort: tasksCount ? `${tasksCount}` : void 0
|
|
28131
28222
|
};
|
|
28132
28223
|
}
|
|
28133
|
-
case "IN_PROGRESS_AWAITING_CUSTOMER"
|
|
28134
|
-
case "CLOSED_OPEN_TASKS"
|
|
28224
|
+
case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
|
|
28225
|
+
case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
|
|
28135
28226
|
return {
|
|
28136
28227
|
color: "warning",
|
|
28137
28228
|
label: tasksCount ? (0, import_pluralize2.default)("task", tasksCount, true) : void 0,
|
|
@@ -28139,13 +28230,13 @@ var buildBadgeConfig = (status, tasksCount) => {
|
|
|
28139
28230
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(AlertCircle_default, { size: 12 })
|
|
28140
28231
|
};
|
|
28141
28232
|
}
|
|
28142
|
-
case "CLOSED_COMPLETE"
|
|
28233
|
+
case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
|
|
28143
28234
|
return {
|
|
28144
28235
|
color: "success",
|
|
28145
28236
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(CheckCircle_default, { size: 12 })
|
|
28146
28237
|
};
|
|
28147
28238
|
}
|
|
28148
|
-
case "BOOKKEEPING_NOT_ACTIVE"
|
|
28239
|
+
case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
|
|
28149
28240
|
return;
|
|
28150
28241
|
}
|
|
28151
28242
|
default: {
|
|
@@ -28213,8 +28304,8 @@ var import_jsx_runtime249 = require("react/jsx-runtime");
|
|
|
28213
28304
|
function useActiveYearBookkeepingPeriods() {
|
|
28214
28305
|
const { date } = useGlobalDate();
|
|
28215
28306
|
const { data } = useBookkeepingPeriods();
|
|
28216
|
-
const activeYear = (0,
|
|
28217
|
-
const periodsInActiveYear = (0,
|
|
28307
|
+
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
28308
|
+
const periodsInActiveYear = (0, import_react153.useMemo)(() => {
|
|
28218
28309
|
return data == null ? void 0 : data.filter((period) => period.year === activeYear);
|
|
28219
28310
|
}, [data, activeYear]);
|
|
28220
28311
|
return { periodsInActiveYear };
|
|
@@ -28223,12 +28314,12 @@ function TasksMonthSelector() {
|
|
|
28223
28314
|
const { date } = useGlobalDate();
|
|
28224
28315
|
const { setMonthByPeriod } = useGlobalDatePeriodAlignedActions();
|
|
28225
28316
|
const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
|
|
28226
|
-
const activeMonthNumber = (0,
|
|
28227
|
-
const activeYear = (0,
|
|
28228
|
-
const monthsData = (0,
|
|
28317
|
+
const activeMonthNumber = (0, import_date_fns42.getMonth)(date) + 1;
|
|
28318
|
+
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
28319
|
+
const monthsData = (0, import_react153.useMemo)(() => {
|
|
28229
28320
|
return Array.from({ length: 12 }, (_, index) => {
|
|
28230
28321
|
var _a, _b;
|
|
28231
|
-
const date2 = (0,
|
|
28322
|
+
const date2 = (0, import_date_fns42.set)(
|
|
28232
28323
|
/* @__PURE__ */ new Date(),
|
|
28233
28324
|
{ year: activeYear, month: index, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }
|
|
28234
28325
|
);
|
|
@@ -28239,12 +28330,12 @@ function TasksMonthSelector() {
|
|
|
28239
28330
|
year: activeYear,
|
|
28240
28331
|
month: index + 1,
|
|
28241
28332
|
tasks: [],
|
|
28242
|
-
status: "BOOKKEEPING_NOT_ACTIVE"
|
|
28333
|
+
status: "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */,
|
|
28243
28334
|
disabled: true
|
|
28244
28335
|
};
|
|
28245
28336
|
const total = (_b = (_a = taskData.tasks) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
28246
28337
|
return __spreadValues({
|
|
28247
|
-
monthStr: (0,
|
|
28338
|
+
monthStr: (0, import_date_fns42.format)(date2, "MMM"),
|
|
28248
28339
|
date: date2,
|
|
28249
28340
|
completed: getCompletedTasks(taskData.tasks).length,
|
|
28250
28341
|
total
|
|
@@ -28275,14 +28366,14 @@ var import_classnames74 = __toESM(require("classnames"));
|
|
|
28275
28366
|
var import_pluralize3 = __toESM(require("pluralize"));
|
|
28276
28367
|
|
|
28277
28368
|
// src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
|
|
28278
|
-
var
|
|
28279
|
-
var
|
|
28369
|
+
var import_react154 = require("react");
|
|
28370
|
+
var import_date_fns43 = require("date-fns");
|
|
28280
28371
|
var useBookkeepingYearsStatus = () => {
|
|
28281
28372
|
const { business } = useLayerContext();
|
|
28282
28373
|
const activationDate = getActivationDate(business);
|
|
28283
28374
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
28284
|
-
const yearStatuses = (0,
|
|
28285
|
-
const startYear = (0,
|
|
28375
|
+
const yearStatuses = (0, import_react154.useMemo)(() => {
|
|
28376
|
+
const startYear = (0, import_date_fns43.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
|
|
28286
28377
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
28287
28378
|
const count = currentYear - startYear + 1;
|
|
28288
28379
|
return Array.from({ length: count }, (_, index) => ({ year: startYear + index })).map(({ year }) => {
|
|
@@ -28296,7 +28387,7 @@ var useBookkeepingYearsStatus = () => {
|
|
|
28296
28387
|
};
|
|
28297
28388
|
}).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
|
|
28298
28389
|
}, [activationDate, data]);
|
|
28299
|
-
const earliestIncompletePeriod = (0,
|
|
28390
|
+
const earliestIncompletePeriod = (0, import_react154.useMemo)(
|
|
28300
28391
|
() => [...data != null ? data : []].sort((a, b) => {
|
|
28301
28392
|
if (a.year === b.year) {
|
|
28302
28393
|
return b.month - a.month;
|
|
@@ -28439,10 +28530,10 @@ var TasksPanelNotification = ({
|
|
|
28439
28530
|
};
|
|
28440
28531
|
|
|
28441
28532
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
28442
|
-
var
|
|
28533
|
+
var import_react157 = require("react");
|
|
28443
28534
|
|
|
28444
28535
|
// src/components/Tabs/Tabs.tsx
|
|
28445
|
-
var
|
|
28536
|
+
var import_react155 = require("react");
|
|
28446
28537
|
|
|
28447
28538
|
// src/components/Tabs/Tab.tsx
|
|
28448
28539
|
var import_jsx_runtime252 = require("react/jsx-runtime");
|
|
@@ -28506,12 +28597,12 @@ var Tab = ({
|
|
|
28506
28597
|
// src/components/Tabs/Tabs.tsx
|
|
28507
28598
|
var import_classnames73 = __toESM(require("classnames"));
|
|
28508
28599
|
var import_jsx_runtime253 = require("react/jsx-runtime");
|
|
28509
|
-
var
|
|
28600
|
+
var import_react156 = require("react");
|
|
28510
28601
|
var STARTING_PADDING = 12;
|
|
28511
28602
|
var Tabs = ({ name, options, selected, onChange }) => {
|
|
28512
|
-
const [initialized, setInitialized] = (0,
|
|
28513
|
-
const [thumbPos, setThumbPos] = (0,
|
|
28514
|
-
const [currentWidth, setCurrentWidth] = (0,
|
|
28603
|
+
const [initialized, setInitialized] = (0, import_react155.useState)(false);
|
|
28604
|
+
const [thumbPos, setThumbPos] = (0, import_react155.useState)({ left: 0, width: 0 });
|
|
28605
|
+
const [currentWidth, setCurrentWidth] = (0, import_react155.useState)(0);
|
|
28515
28606
|
const selectedValue = selected || options[0].value;
|
|
28516
28607
|
const baseClassName = (0, import_classnames73.default)(
|
|
28517
28608
|
"Layer__tabs",
|
|
@@ -28546,14 +28637,14 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28546
28637
|
shift2 = shift2 + STARTING_PADDING;
|
|
28547
28638
|
setThumbPos({ left: shift2, width });
|
|
28548
28639
|
};
|
|
28549
|
-
(0,
|
|
28640
|
+
(0, import_react155.useEffect)(() => {
|
|
28550
28641
|
const selectedIndex = getSelectedIndex();
|
|
28551
28642
|
updateSelectPosition(selectedIndex);
|
|
28552
28643
|
setTimeout(() => {
|
|
28553
28644
|
setInitialized(true);
|
|
28554
28645
|
}, 400);
|
|
28555
28646
|
}, []);
|
|
28556
|
-
(0,
|
|
28647
|
+
(0, import_react155.useEffect)(() => {
|
|
28557
28648
|
const selectedIndex = getSelectedIndex();
|
|
28558
28649
|
updateSelectPosition(selectedIndex);
|
|
28559
28650
|
}, [selectedValue, currentWidth]);
|
|
@@ -28569,7 +28660,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28569
28660
|
return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)("div", { className: baseClassName, ref: elementRef, children: [
|
|
28570
28661
|
options.map((option, index) => {
|
|
28571
28662
|
var _a;
|
|
28572
|
-
return /* @__PURE__ */ (0,
|
|
28663
|
+
return /* @__PURE__ */ (0, import_react156.createElement)(
|
|
28573
28664
|
Tab,
|
|
28574
28665
|
__spreadProps(__spreadValues({}, option), {
|
|
28575
28666
|
key: option.value,
|
|
@@ -28587,7 +28678,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28587
28678
|
};
|
|
28588
28679
|
|
|
28589
28680
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
28590
|
-
var
|
|
28681
|
+
var import_date_fns44 = require("date-fns");
|
|
28591
28682
|
var import_jsx_runtime254 = require("react/jsx-runtime");
|
|
28592
28683
|
var TasksYearsTabs = () => {
|
|
28593
28684
|
const { date } = useGlobalDate();
|
|
@@ -28595,13 +28686,13 @@ var TasksYearsTabs = () => {
|
|
|
28595
28686
|
const activeYear = date.getFullYear();
|
|
28596
28687
|
const { yearStatuses } = useBookkeepingYearsStatus();
|
|
28597
28688
|
const setCurrentYear = (year) => {
|
|
28598
|
-
const currentMonth = (0,
|
|
28689
|
+
const currentMonth = (0, import_date_fns44.getMonth)(date);
|
|
28599
28690
|
setMonthByPeriod({
|
|
28600
28691
|
monthNumber: currentMonth + 1,
|
|
28601
28692
|
yearNumber: Number(year)
|
|
28602
28693
|
});
|
|
28603
28694
|
};
|
|
28604
|
-
const yearsList = (0,
|
|
28695
|
+
const yearsList = (0, import_react157.useMemo)(() => {
|
|
28605
28696
|
return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
|
|
28606
28697
|
return {
|
|
28607
28698
|
value: `${y.year}`,
|
|
@@ -28609,7 +28700,7 @@ var TasksYearsTabs = () => {
|
|
|
28609
28700
|
badge: !y.completed && y.unresolvedTasks ? /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(
|
|
28610
28701
|
TaskStatusBadge,
|
|
28611
28702
|
{
|
|
28612
|
-
status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" : "CLOSED_COMPLETE"
|
|
28703
|
+
status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */ : "CLOSED_COMPLETE" /* CLOSED_COMPLETE */,
|
|
28613
28704
|
tasksCount: y.unresolvedTasks
|
|
28614
28705
|
}
|
|
28615
28706
|
) : null
|
|
@@ -28704,40 +28795,40 @@ function Tasks({
|
|
|
28704
28795
|
}
|
|
28705
28796
|
|
|
28706
28797
|
// src/components/PlatformOnboarding/LinkAccounts.tsx
|
|
28707
|
-
var
|
|
28798
|
+
var import_react161 = require("react");
|
|
28708
28799
|
|
|
28709
28800
|
// src/components/PlatformOnboarding/Steps/LinkAccountsConfirmationStep.tsx
|
|
28710
|
-
var
|
|
28801
|
+
var import_react159 = require("react");
|
|
28711
28802
|
var import_react_form2 = require("@tanstack/react-form");
|
|
28712
28803
|
|
|
28713
28804
|
// src/components/Wizard/Wizard.tsx
|
|
28714
|
-
var
|
|
28805
|
+
var import_react158 = require("react");
|
|
28715
28806
|
var import_jsx_runtime257 = require("react/jsx-runtime");
|
|
28716
28807
|
function useWizardStep({
|
|
28717
28808
|
steps,
|
|
28718
28809
|
onComplete
|
|
28719
28810
|
}) {
|
|
28720
28811
|
const stepCount = steps.length;
|
|
28721
|
-
const [activeStepIndex, setActiveStepIndex] = (0,
|
|
28722
|
-
const next = (0,
|
|
28812
|
+
const [activeStepIndex, setActiveStepIndex] = (0, import_react158.useState)(0);
|
|
28813
|
+
const next = (0, import_react158.useCallback)(() => __async(null, null, function* () {
|
|
28723
28814
|
setActiveStepIndex((stepIndex) => Math.min(stepIndex + 1, stepCount - 1));
|
|
28724
28815
|
if (activeStepIndex === stepCount - 1 && onComplete) {
|
|
28725
28816
|
yield onComplete == null ? void 0 : onComplete();
|
|
28726
28817
|
}
|
|
28727
28818
|
}), [stepCount, activeStepIndex, onComplete]);
|
|
28728
|
-
const previous = (0,
|
|
28819
|
+
const previous = (0, import_react158.useCallback)(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
|
|
28729
28820
|
const effectiveStepIndex = Math.min(activeStepIndex, stepCount - 1);
|
|
28730
28821
|
const currentStep = steps.at(effectiveStepIndex);
|
|
28731
28822
|
return { currentStep, next, previous };
|
|
28732
28823
|
}
|
|
28733
|
-
var WizardContext = (0,
|
|
28824
|
+
var WizardContext = (0, import_react158.createContext)({
|
|
28734
28825
|
next: () => {
|
|
28735
28826
|
},
|
|
28736
28827
|
previous: () => {
|
|
28737
28828
|
}
|
|
28738
28829
|
});
|
|
28739
28830
|
function useWizard() {
|
|
28740
|
-
return (0,
|
|
28831
|
+
return (0, import_react158.useContext)(WizardContext);
|
|
28741
28832
|
}
|
|
28742
28833
|
function Wizard({
|
|
28743
28834
|
Header: Header4,
|
|
@@ -28745,12 +28836,12 @@ function Wizard({
|
|
|
28745
28836
|
onComplete,
|
|
28746
28837
|
children
|
|
28747
28838
|
}) {
|
|
28748
|
-
const childrenArray =
|
|
28839
|
+
const childrenArray = import_react158.Children.toArray(children);
|
|
28749
28840
|
const { currentStep, next, previous } = useWizardStep({
|
|
28750
28841
|
steps: childrenArray,
|
|
28751
28842
|
onComplete
|
|
28752
28843
|
});
|
|
28753
|
-
const value = (0,
|
|
28844
|
+
const value = (0, import_react158.useMemo)(() => ({ next, previous }), [next, previous]);
|
|
28754
28845
|
return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(WizardContext.Provider, { value, children: [
|
|
28755
28846
|
Header4,
|
|
28756
28847
|
currentStep,
|
|
@@ -28791,7 +28882,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28791
28882
|
data: linkedAccounts,
|
|
28792
28883
|
loadingStatus: linkedAccountsLoadingStatus,
|
|
28793
28884
|
refetchAccounts
|
|
28794
|
-
} = (0,
|
|
28885
|
+
} = (0, import_react159.useContext)(LinkedAccountsContext);
|
|
28795
28886
|
const effectiveLinkedAccounts = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
28796
28887
|
const { trigger } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
|
|
28797
28888
|
const { previous, next } = useWizard();
|
|
@@ -28864,7 +28955,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28864
28955
|
}
|
|
28865
28956
|
|
|
28866
28957
|
// src/components/PlatformOnboarding/Steps/LinkAccountsLinkStep.tsx
|
|
28867
|
-
var
|
|
28958
|
+
var import_react160 = require("react");
|
|
28868
28959
|
var import_pluralize4 = __toESM(require("pluralize"));
|
|
28869
28960
|
|
|
28870
28961
|
// src/components/Separator/Separator.tsx
|
|
@@ -28883,7 +28974,7 @@ function LinkAccountsLinkStep() {
|
|
|
28883
28974
|
error,
|
|
28884
28975
|
refetchAccounts,
|
|
28885
28976
|
addConnection
|
|
28886
|
-
} = (0,
|
|
28977
|
+
} = (0, import_react160.useContext)(LinkedAccountsContext);
|
|
28887
28978
|
const { next } = useWizard();
|
|
28888
28979
|
const effectiveAccounts = data != null ? data : [];
|
|
28889
28980
|
return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_jsx_runtime261.Fragment, { children: [
|
|
@@ -28963,7 +29054,7 @@ function LinkAccounts(props) {
|
|
|
28963
29054
|
function LinkAccountsContent({
|
|
28964
29055
|
onComplete
|
|
28965
29056
|
}) {
|
|
28966
|
-
const { data: linkedAccounts, loadingStatus } = (0,
|
|
29057
|
+
const { data: linkedAccounts, loadingStatus } = (0, import_react161.useContext)(LinkedAccountsContext);
|
|
28967
29058
|
const linkedAccountsNeedingConfirmation = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
28968
29059
|
const hideConfirmationStep = loadingStatus === "complete" && linkedAccountsNeedingConfirmation.length === 0;
|
|
28969
29060
|
return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("section", { className: "Layer__link-accounts Layer__component", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
|
|
@@ -28981,7 +29072,7 @@ function LinkAccountsContent({
|
|
|
28981
29072
|
}
|
|
28982
29073
|
|
|
28983
29074
|
// src/components/PlatformOnboarding/PlatformOnboarding.tsx
|
|
28984
|
-
var
|
|
29075
|
+
var import_react166 = require("react");
|
|
28985
29076
|
|
|
28986
29077
|
// src/components/ProgressSteps/ProgressSteps.tsx
|
|
28987
29078
|
var import_jsx_runtime263 = require("react/jsx-runtime");
|
|
@@ -29378,7 +29469,7 @@ function useBusinessPersonnel() {
|
|
|
29378
29469
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
29379
29470
|
var import_mutation16 = __toESM(require("swr/mutation"));
|
|
29380
29471
|
var import_swr27 = require("swr");
|
|
29381
|
-
var
|
|
29472
|
+
var import_react162 = require("react");
|
|
29382
29473
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
29383
29474
|
function buildKey26({
|
|
29384
29475
|
access_token: accessToken,
|
|
@@ -29416,7 +29507,7 @@ function useCreateBusinessPersonnel() {
|
|
|
29416
29507
|
}
|
|
29417
29508
|
);
|
|
29418
29509
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29419
|
-
const stableProxiedTrigger = (0,
|
|
29510
|
+
const stableProxiedTrigger = (0, import_react162.useCallback)(
|
|
29420
29511
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29421
29512
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29422
29513
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29450,7 +29541,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
29450
29541
|
});
|
|
29451
29542
|
|
|
29452
29543
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29453
|
-
var
|
|
29544
|
+
var import_react163 = require("react");
|
|
29454
29545
|
function buildKey27({
|
|
29455
29546
|
access_token: accessToken,
|
|
29456
29547
|
apiUrl,
|
|
@@ -29493,7 +29584,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29493
29584
|
}
|
|
29494
29585
|
);
|
|
29495
29586
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29496
|
-
const stableProxiedTrigger = (0,
|
|
29587
|
+
const stableProxiedTrigger = (0, import_react163.useCallback)(
|
|
29497
29588
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29498
29589
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29499
29590
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29520,7 +29611,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29520
29611
|
// src/hooks/business/useUpdateBusiness.ts
|
|
29521
29612
|
var import_mutation18 = __toESM(require("swr/mutation"));
|
|
29522
29613
|
var import_swr29 = require("swr");
|
|
29523
|
-
var
|
|
29614
|
+
var import_react164 = require("react");
|
|
29524
29615
|
var BUSINESS_TAG_KEY = "business";
|
|
29525
29616
|
function buildKey28({
|
|
29526
29617
|
access_token: accessToken,
|
|
@@ -29558,7 +29649,7 @@ function useUpdateBusiness() {
|
|
|
29558
29649
|
}
|
|
29559
29650
|
);
|
|
29560
29651
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29561
|
-
const stableProxiedTrigger = (0,
|
|
29652
|
+
const stableProxiedTrigger = (0, import_react164.useCallback)(
|
|
29562
29653
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29563
29654
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29564
29655
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29583,7 +29674,7 @@ function useUpdateBusiness() {
|
|
|
29583
29674
|
}
|
|
29584
29675
|
|
|
29585
29676
|
// src/components/BusinessForm/useBusinessForm.ts
|
|
29586
|
-
var
|
|
29677
|
+
var import_react165 = require("react");
|
|
29587
29678
|
var getPerson = (personnel) => {
|
|
29588
29679
|
const owners = personnel == null ? void 0 : personnel.filter((p) => p.roles.find((x) => x.role === "OWNER"));
|
|
29589
29680
|
if (owners && owners.length > 0) {
|
|
@@ -29594,7 +29685,7 @@ var getPerson = (personnel) => {
|
|
|
29594
29685
|
var useBusinessForm = ({ onSuccess }) => {
|
|
29595
29686
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
29596
29687
|
const { business } = useLayerContext();
|
|
29597
|
-
const [submitError, setSubmitError] = (0,
|
|
29688
|
+
const [submitError, setSubmitError] = (0, import_react165.useState)(void 0);
|
|
29598
29689
|
const { data: personnel } = useBusinessPersonnel();
|
|
29599
29690
|
const person = getPerson(personnel);
|
|
29600
29691
|
const { trigger: createBusinessPersonnel2 } = useCreateBusinessPersonnel();
|
|
@@ -30010,7 +30101,7 @@ var PLATFORM_ONBOARDING_STEPS = [
|
|
|
30010
30101
|
}
|
|
30011
30102
|
];
|
|
30012
30103
|
var PlatformOnboarding = ({ onComplete }) => {
|
|
30013
|
-
const [step, setStep] = (0,
|
|
30104
|
+
const [step, setStep] = (0, import_react166.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
|
|
30014
30105
|
const isFirstStep = PLATFORM_ONBOARDING_STEPS[0].id === step;
|
|
30015
30106
|
const nextStep = () => {
|
|
30016
30107
|
const currentStepIndex = PLATFORM_ONBOARDING_STEPS.findIndex((s) => s.id === step);
|
|
@@ -30172,7 +30263,7 @@ var BookkeepingUpsellBar = ({
|
|
|
30172
30263
|
};
|
|
30173
30264
|
|
|
30174
30265
|
// src/views/BookkeepingOverview/BookkeepingOverview.tsx
|
|
30175
|
-
var
|
|
30266
|
+
var import_react168 = require("react");
|
|
30176
30267
|
|
|
30177
30268
|
// src/views/BookkeepingOverview/internal/BookkeepingProfitAndLossSummariesContainer.tsx
|
|
30178
30269
|
var import_jsx_runtime277 = require("react/jsx-runtime");
|
|
@@ -30187,15 +30278,15 @@ function BookkeepingProfitAndLossSummariesContainer({
|
|
|
30187
30278
|
var import_classnames75 = __toESM(require("classnames"));
|
|
30188
30279
|
|
|
30189
30280
|
// src/views/BookkeepingOverview/useKeepInMobileViewport.tsx
|
|
30190
|
-
var
|
|
30281
|
+
var import_react167 = require("react");
|
|
30191
30282
|
var TASKS_MOBILE_VIEWPORT_WIDTH = 1100;
|
|
30192
30283
|
var useKeepInMobileViewport = () => {
|
|
30193
|
-
const upperContentRef = (0,
|
|
30194
|
-
const targetElementRef = (0,
|
|
30195
|
-
const lastKnownSizeRef = (0,
|
|
30196
|
-
const lastKnownTargetPositionRef = (0,
|
|
30197
|
-
const upperElementInFocus = (0,
|
|
30198
|
-
(0,
|
|
30284
|
+
const upperContentRef = (0, import_react167.useRef)(null);
|
|
30285
|
+
const targetElementRef = (0, import_react167.useRef)(null);
|
|
30286
|
+
const lastKnownSizeRef = (0, import_react167.useRef)(null);
|
|
30287
|
+
const lastKnownTargetPositionRef = (0, import_react167.useRef)(null);
|
|
30288
|
+
const upperElementInFocus = (0, import_react167.useRef)(false);
|
|
30289
|
+
(0, import_react167.useEffect)(() => {
|
|
30199
30290
|
if (!upperContentRef.current || !targetElementRef.current) return;
|
|
30200
30291
|
lastKnownSizeRef.current = upperContentRef.current.getBoundingClientRect().height;
|
|
30201
30292
|
lastKnownTargetPositionRef.current = targetElementRef.current.getBoundingClientRect().top;
|
|
@@ -30252,7 +30343,7 @@ var BookkeepingOverview = ({
|
|
|
30252
30343
|
slotProps
|
|
30253
30344
|
}) => {
|
|
30254
30345
|
var _a, _b, _c, _d, _e, _f;
|
|
30255
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
30346
|
+
const [pnlToggle, setPnlToggle] = (0, import_react168.useState)("expenses");
|
|
30256
30347
|
const [width] = useWindowSize();
|
|
30257
30348
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
30258
30349
|
const { upperContentRef, targetElementRef, upperElementInFocus } = useKeepInMobileViewport();
|
|
@@ -30383,7 +30474,7 @@ var BookkeepingOverview = ({
|
|
|
30383
30474
|
};
|
|
30384
30475
|
|
|
30385
30476
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
30386
|
-
var
|
|
30477
|
+
var import_react169 = require("react");
|
|
30387
30478
|
var import_classnames76 = __toESM(require("classnames"));
|
|
30388
30479
|
var import_jsx_runtime279 = require("react/jsx-runtime");
|
|
30389
30480
|
var AccountingOverview = ({
|
|
@@ -30399,7 +30490,7 @@ var AccountingOverview = ({
|
|
|
30399
30490
|
slotProps
|
|
30400
30491
|
}) => {
|
|
30401
30492
|
var _a, _b, _c, _d, _e;
|
|
30402
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
30493
|
+
const [pnlToggle, setPnlToggle] = (0, import_react169.useState)("expenses");
|
|
30403
30494
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
30404
30495
|
return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
|
|
30405
30496
|
ProfitAndLoss,
|
|
@@ -30566,7 +30657,7 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
30566
30657
|
};
|
|
30567
30658
|
|
|
30568
30659
|
// src/views/GeneralLedger/GeneralLedger.tsx
|
|
30569
|
-
var
|
|
30660
|
+
var import_react170 = require("react");
|
|
30570
30661
|
var import_jsx_runtime281 = require("react/jsx-runtime");
|
|
30571
30662
|
var GeneralLedgerView = ({
|
|
30572
30663
|
title,
|
|
@@ -30575,7 +30666,7 @@ var GeneralLedgerView = ({
|
|
|
30575
30666
|
stringOverrides,
|
|
30576
30667
|
chartOfAccountsOptions
|
|
30577
30668
|
}) => {
|
|
30578
|
-
const [activeTab, setActiveTab] = (0,
|
|
30669
|
+
const [activeTab, setActiveTab] = (0, import_react170.useState)("chartOfAccounts");
|
|
30579
30670
|
return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(ProfitAndLoss, { asContainer: false, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
|
|
30580
30671
|
View,
|
|
30581
30672
|
{
|
|
@@ -30617,7 +30708,7 @@ var GeneralLedgerView = ({
|
|
|
30617
30708
|
};
|
|
30618
30709
|
|
|
30619
30710
|
// src/views/ProjectProfitability/ProjectProfitability.tsx
|
|
30620
|
-
var
|
|
30711
|
+
var import_react171 = require("react");
|
|
30621
30712
|
var import_react_select5 = __toESM(require("react-select"));
|
|
30622
30713
|
var import_jsx_runtime282 = require("react/jsx-runtime");
|
|
30623
30714
|
var ProjectProfitabilityView = ({
|
|
@@ -30627,9 +30718,9 @@ var ProjectProfitabilityView = ({
|
|
|
30627
30718
|
datePickerMode = "monthPicker",
|
|
30628
30719
|
csvMoneyFormat = "DOLLAR_STRING"
|
|
30629
30720
|
}) => {
|
|
30630
|
-
const [activeTab, setActiveTab] = (0,
|
|
30631
|
-
const [tagFilter, setTagFilter] = (0,
|
|
30632
|
-
const [pnlTagFilter, setPnlTagFilter] = (0,
|
|
30721
|
+
const [activeTab, setActiveTab] = (0, import_react171.useState)("overview");
|
|
30722
|
+
const [tagFilter, setTagFilter] = (0, import_react171.useState)(null);
|
|
30723
|
+
const [pnlTagFilter, setPnlTagFilter] = (0, import_react171.useState)(
|
|
30633
30724
|
void 0
|
|
30634
30725
|
);
|
|
30635
30726
|
const isOptionSelected = (option, selectValue) => {
|
|
@@ -30728,7 +30819,7 @@ var ProjectProfitabilityView = ({
|
|
|
30728
30819
|
};
|
|
30729
30820
|
|
|
30730
30821
|
// src/views/Reports/Reports.tsx
|
|
30731
|
-
var
|
|
30822
|
+
var import_react172 = require("react");
|
|
30732
30823
|
var import_jsx_runtime283 = require("react/jsx-runtime");
|
|
30733
30824
|
var getOptions = (enabledReports) => {
|
|
30734
30825
|
return [
|
|
@@ -30756,7 +30847,7 @@ var Reports = ({
|
|
|
30756
30847
|
statementOfCashFlowConfig
|
|
30757
30848
|
}) => {
|
|
30758
30849
|
var _a;
|
|
30759
|
-
const [activeTab, setActiveTab] = (0,
|
|
30850
|
+
const [activeTab, setActiveTab] = (0, import_react172.useState)(enabledReports[0]);
|
|
30760
30851
|
const { view, containerRef } = useElementViewSize();
|
|
30761
30852
|
const options = getOptions(enabledReports);
|
|
30762
30853
|
const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value = enabledReports[0])) == null ? void 0 : _a.label;
|
|
@@ -30818,11 +30909,11 @@ var ReportsPanel = ({
|
|
|
30818
30909
|
};
|
|
30819
30910
|
|
|
30820
30911
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
30821
|
-
var
|
|
30912
|
+
var import_react173 = require("react");
|
|
30822
30913
|
var import_jsx_runtime284 = require("react/jsx-runtime");
|
|
30823
30914
|
var COMPONENT_NAME8 = "profit-and-loss";
|
|
30824
30915
|
var ProfitAndLossView = (props) => {
|
|
30825
|
-
const containerRef = (0,
|
|
30916
|
+
const containerRef = (0, import_react173.useRef)(null);
|
|
30826
30917
|
return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Container, { name: COMPONENT_NAME8, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ProfitAndLoss, { children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
|
|
30827
30918
|
};
|
|
30828
30919
|
var ProfitAndLossPanel = (_a) => {
|
|
@@ -30833,7 +30924,7 @@ var ProfitAndLossPanel = (_a) => {
|
|
|
30833
30924
|
"containerRef",
|
|
30834
30925
|
"stringOverrides"
|
|
30835
30926
|
]);
|
|
30836
|
-
const { sidebarScope } = (0,
|
|
30927
|
+
const { sidebarScope } = (0, import_react173.useContext)(ProfitAndLoss.Context);
|
|
30837
30928
|
return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
|
|
30838
30929
|
Panel,
|
|
30839
30930
|
{
|
|
@@ -30864,7 +30955,7 @@ var Components = ({
|
|
|
30864
30955
|
hideTable = false,
|
|
30865
30956
|
stringOverrides
|
|
30866
30957
|
}) => {
|
|
30867
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
30958
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react173.useContext)(
|
|
30868
30959
|
ProfitAndLoss.Context
|
|
30869
30960
|
);
|
|
30870
30961
|
if (!isLoading && error) {
|
|
@@ -30926,6 +31017,7 @@ var Components = ({
|
|
|
30926
31017
|
Direction,
|
|
30927
31018
|
DisplayState,
|
|
30928
31019
|
GeneralLedgerView,
|
|
31020
|
+
Integrations,
|
|
30929
31021
|
Journal,
|
|
30930
31022
|
LayerProvider,
|
|
30931
31023
|
LinkAccounts,
|
|
@@ -30935,11 +31027,9 @@ var Components = ({
|
|
|
30935
31027
|
ProfitAndLoss,
|
|
30936
31028
|
ProfitAndLossView,
|
|
30937
31029
|
ProjectProfitabilityView,
|
|
30938
|
-
Quickbooks,
|
|
30939
31030
|
Reports,
|
|
30940
31031
|
StatementOfCashFlow,
|
|
30941
31032
|
Tasks,
|
|
30942
|
-
unstable_Integrations,
|
|
30943
31033
|
useBankTransactionsContext,
|
|
30944
31034
|
useDataSync,
|
|
30945
31035
|
useLayerContext
|