@layerfi/components 0.1.99-alpha.3 → 0.1.100
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 +908 -824
- package/dist/esm/index.mjs +739 -654
- package/dist/index.css +4 -3
- package/dist/index.d.ts +68 -60
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -5585,7 +5585,6 @@ __export(index_exports, {
|
|
|
5585
5585
|
ProfitAndLoss: () => ProfitAndLoss,
|
|
5586
5586
|
ProfitAndLossView: () => ProfitAndLossView,
|
|
5587
5587
|
ProjectProfitabilityView: () => ProjectProfitabilityView,
|
|
5588
|
-
Quickbooks: () => Quickbooks,
|
|
5589
5588
|
Reports: () => Reports,
|
|
5590
5589
|
StatementOfCashFlow: () => StatementOfCashFlow,
|
|
5591
5590
|
Tasks: () => Tasks,
|
|
@@ -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.100";
|
|
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,
|
|
@@ -7463,7 +7458,7 @@ function useBankTransactions({
|
|
|
7463
7458
|
|
|
7464
7459
|
// src/hooks/useBankTransactions/useCategorizeBankTransaction.ts
|
|
7465
7460
|
var import_react13 = require("react");
|
|
7466
|
-
var
|
|
7461
|
+
var import_swr4 = require("swr");
|
|
7467
7462
|
var import_mutation = __toESM(require("swr/mutation"));
|
|
7468
7463
|
|
|
7469
7464
|
// src/utils/swr/withSWRKeyTags.ts
|
|
@@ -7474,9 +7469,53 @@ function withSWRKeyTags(key, predicate) {
|
|
|
7474
7469
|
return isStringArray(key.tags) ? predicate(key.tags) : false;
|
|
7475
7470
|
}
|
|
7476
7471
|
|
|
7472
|
+
// src/hooks/bookkeeping/useBankAccounts.ts
|
|
7473
|
+
var import_swr3 = __toESM(require("swr"));
|
|
7474
|
+
var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
|
|
7475
|
+
var getBankAccounts = get(
|
|
7476
|
+
({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
|
|
7477
|
+
);
|
|
7478
|
+
function buildKey3({
|
|
7479
|
+
access_token: accessToken,
|
|
7480
|
+
apiUrl,
|
|
7481
|
+
businessId
|
|
7482
|
+
}) {
|
|
7483
|
+
if (accessToken && apiUrl) {
|
|
7484
|
+
return {
|
|
7485
|
+
accessToken,
|
|
7486
|
+
apiUrl,
|
|
7487
|
+
businessId,
|
|
7488
|
+
tags: [BANK_ACCOUNTS_TAG_KEY]
|
|
7489
|
+
};
|
|
7490
|
+
}
|
|
7491
|
+
}
|
|
7492
|
+
var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
|
|
7493
|
+
var useBankAccounts = () => {
|
|
7494
|
+
var _a, _b;
|
|
7495
|
+
const { businessId } = useLayerContext();
|
|
7496
|
+
const { apiUrl } = useEnvironment();
|
|
7497
|
+
const { data: auth } = useAuth();
|
|
7498
|
+
const { data, error, isLoading } = (0, import_swr3.default)(
|
|
7499
|
+
() => buildKey3(__spreadProps(__spreadValues({}, auth), {
|
|
7500
|
+
apiUrl,
|
|
7501
|
+
businessId
|
|
7502
|
+
})),
|
|
7503
|
+
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getBankAccounts(apiUrl2, accessToken, { params: { businessId: businessId2 } })()
|
|
7504
|
+
);
|
|
7505
|
+
const disconnectedAccountsRequiringNotification = ((_a = data == null ? void 0 : data.data) != null ? _a : []).filter(
|
|
7506
|
+
(account) => requiresNotification(account)
|
|
7507
|
+
).length;
|
|
7508
|
+
return {
|
|
7509
|
+
bankAccounts: (_b = data == null ? void 0 : data.data) != null ? _b : [],
|
|
7510
|
+
isLoading,
|
|
7511
|
+
error,
|
|
7512
|
+
disconnectedAccountsRequiringNotification
|
|
7513
|
+
};
|
|
7514
|
+
};
|
|
7515
|
+
|
|
7477
7516
|
// src/hooks/useBankTransactions/useCategorizeBankTransaction.ts
|
|
7478
7517
|
var CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
|
|
7479
|
-
function
|
|
7518
|
+
function buildKey4({
|
|
7480
7519
|
access_token: accessToken,
|
|
7481
7520
|
apiUrl,
|
|
7482
7521
|
businessId
|
|
@@ -7495,9 +7534,9 @@ function useCategorizeBankTransaction({
|
|
|
7495
7534
|
}) {
|
|
7496
7535
|
const { data: auth } = useAuth();
|
|
7497
7536
|
const { businessId } = useLayerContext();
|
|
7498
|
-
const { mutate } = (0,
|
|
7537
|
+
const { mutate } = (0, import_swr4.useSWRConfig)();
|
|
7499
7538
|
const mutationResponse = (0, import_mutation.default)(
|
|
7500
|
-
() =>
|
|
7539
|
+
() => buildKey4({
|
|
7501
7540
|
access_token: auth == null ? void 0 : auth.access_token,
|
|
7502
7541
|
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
7503
7542
|
businessId
|
|
@@ -7526,7 +7565,7 @@ function useCategorizeBankTransaction({
|
|
|
7526
7565
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
7527
7566
|
void mutate((key) => withSWRKeyTags(
|
|
7528
7567
|
key,
|
|
7529
|
-
(tags) => tags.includes(
|
|
7568
|
+
(tags) => tags.includes(BANK_ACCOUNTS_TAG_KEY) || tags.includes(EXTERNAL_ACCOUNTS_TAG_KEY)
|
|
7530
7569
|
));
|
|
7531
7570
|
void mutateBankTransactions(void 0, { revalidate: true });
|
|
7532
7571
|
return triggerResult;
|
|
@@ -7551,52 +7590,6 @@ function useCategorizeBankTransaction({
|
|
|
7551
7590
|
var import_react14 = require("react");
|
|
7552
7591
|
var import_swr5 = require("swr");
|
|
7553
7592
|
var import_mutation2 = __toESM(require("swr/mutation"));
|
|
7554
|
-
|
|
7555
|
-
// src/hooks/bookkeeping/useBankAccounts.ts
|
|
7556
|
-
var import_swr4 = __toESM(require("swr"));
|
|
7557
|
-
var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
|
|
7558
|
-
var getBankAccounts = get(
|
|
7559
|
-
({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
|
|
7560
|
-
);
|
|
7561
|
-
function buildKey4({
|
|
7562
|
-
access_token: accessToken,
|
|
7563
|
-
apiUrl,
|
|
7564
|
-
businessId
|
|
7565
|
-
}) {
|
|
7566
|
-
if (accessToken && apiUrl) {
|
|
7567
|
-
return {
|
|
7568
|
-
accessToken,
|
|
7569
|
-
apiUrl,
|
|
7570
|
-
businessId,
|
|
7571
|
-
tags: [BANK_ACCOUNTS_TAG_KEY]
|
|
7572
|
-
};
|
|
7573
|
-
}
|
|
7574
|
-
}
|
|
7575
|
-
var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
|
|
7576
|
-
var useBankAccounts = () => {
|
|
7577
|
-
var _a, _b;
|
|
7578
|
-
const { businessId } = useLayerContext();
|
|
7579
|
-
const { apiUrl } = useEnvironment();
|
|
7580
|
-
const { data: auth } = useAuth();
|
|
7581
|
-
const { data, error, isLoading } = (0, import_swr4.default)(
|
|
7582
|
-
() => buildKey4(__spreadProps(__spreadValues({}, auth), {
|
|
7583
|
-
apiUrl,
|
|
7584
|
-
businessId
|
|
7585
|
-
})),
|
|
7586
|
-
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getBankAccounts(apiUrl2, accessToken, { params: { businessId: businessId2 } })()
|
|
7587
|
-
);
|
|
7588
|
-
const disconnectedAccountsRequiringNotification = ((_a = data == null ? void 0 : data.data) != null ? _a : []).filter(
|
|
7589
|
-
(account) => requiresNotification(account)
|
|
7590
|
-
).length;
|
|
7591
|
-
return {
|
|
7592
|
-
bankAccounts: (_b = data == null ? void 0 : data.data) != null ? _b : [],
|
|
7593
|
-
isLoading,
|
|
7594
|
-
error,
|
|
7595
|
-
disconnectedAccountsRequiringNotification
|
|
7596
|
-
};
|
|
7597
|
-
};
|
|
7598
|
-
|
|
7599
|
-
// src/hooks/useBankTransactions/useMatchBankTransaction.ts
|
|
7600
7593
|
var MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
|
|
7601
7594
|
function buildKey5({
|
|
7602
7595
|
access_token: accessToken,
|
|
@@ -14659,17 +14652,22 @@ function LegacyModeProvider({
|
|
|
14659
14652
|
}
|
|
14660
14653
|
|
|
14661
14654
|
// src/hooks/bookkeeping/useBookkeepingStatus.ts
|
|
14662
|
-
var
|
|
14663
|
-
"NOT_PURCHASED"
|
|
14664
|
-
"ACTIVE"
|
|
14665
|
-
"ONBOARDING"
|
|
14666
|
-
"BOOKKEEPING_PAUSED"
|
|
14667
|
-
|
|
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
|
+
}
|
|
14668
14666
|
function constrainToKnownBookkeepingStatus(status) {
|
|
14669
|
-
if (
|
|
14667
|
+
if (isBookkeepingStatus(status)) {
|
|
14670
14668
|
return status;
|
|
14671
14669
|
}
|
|
14672
|
-
return "NOT_PURCHASED"
|
|
14670
|
+
return "NOT_PURCHASED" /* NOT_PURCHASED */;
|
|
14673
14671
|
}
|
|
14674
14672
|
var getBookkeepingStatus = get(({ businessId }) => {
|
|
14675
14673
|
return `/v1/businesses/${businessId}/bookkeeping/status`;
|
|
@@ -14711,26 +14709,29 @@ function useEffectiveBookkeepingStatus() {
|
|
|
14711
14709
|
const { overrideMode } = useLegacyMode();
|
|
14712
14710
|
const { data } = useBookkeepingStatus();
|
|
14713
14711
|
if (overrideMode === "bookkeeping-client") {
|
|
14714
|
-
return "ACTIVE"
|
|
14712
|
+
return "ACTIVE" /* ACTIVE */;
|
|
14715
14713
|
}
|
|
14716
|
-
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 */;
|
|
14717
14715
|
}
|
|
14718
14716
|
|
|
14719
14717
|
// src/utils/bookkeeping/isCategorizationEnabled.ts
|
|
14720
14718
|
function isCategorizationEnabledForStatus(status) {
|
|
14721
14719
|
switch (status) {
|
|
14722
|
-
case "NOT_PURCHASED"
|
|
14723
|
-
case "ONBOARDING"
|
|
14724
|
-
case "BOOKKEEPING_PAUSED"
|
|
14720
|
+
case "NOT_PURCHASED" /* NOT_PURCHASED */:
|
|
14721
|
+
case "ONBOARDING" /* ONBOARDING */:
|
|
14722
|
+
case "BOOKKEEPING_PAUSED" /* BOOKKEEPING_PAUSED */: {
|
|
14725
14723
|
return true;
|
|
14726
|
-
|
|
14724
|
+
}
|
|
14725
|
+
case "ACTIVE" /* ACTIVE */: {
|
|
14727
14726
|
return false;
|
|
14728
|
-
|
|
14727
|
+
}
|
|
14728
|
+
default: {
|
|
14729
14729
|
return safeAssertUnreachable({
|
|
14730
14730
|
value: status,
|
|
14731
14731
|
message: "Unexpected bookkeeping status in `isCategorizationEnabledForStatus`",
|
|
14732
14732
|
fallbackValue: true
|
|
14733
14733
|
});
|
|
14734
|
+
}
|
|
14734
14735
|
}
|
|
14735
14736
|
}
|
|
14736
14737
|
|
|
@@ -15890,6 +15891,116 @@ var SplitTooltipDetails = ({
|
|
|
15890
15891
|
var import_classnames41 = __toESM(require("classnames"));
|
|
15891
15892
|
var import_date_fns17 = require("date-fns");
|
|
15892
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
|
+
|
|
15893
16004
|
// src/utils/date.ts
|
|
15894
16005
|
var monthNames = [
|
|
15895
16006
|
"January",
|
|
@@ -15954,9 +16065,9 @@ function getBookkeepingStatusConfig({
|
|
|
15954
16065
|
const monthName = monthNumber !== void 0 ? getMonthNameFromNumber(monthNumber) : "";
|
|
15955
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.";
|
|
15956
16067
|
switch (status) {
|
|
15957
|
-
case "IN_PROGRESS_AWAITING_BOOKKEEPER"
|
|
15958
|
-
case "NOT_STARTED"
|
|
15959
|
-
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 */: {
|
|
15960
16071
|
return {
|
|
15961
16072
|
label: "Books in progress",
|
|
15962
16073
|
description: `We're working on your ${monthName} books. ${actionPhrase}`,
|
|
@@ -15964,8 +16075,8 @@ function getBookkeepingStatusConfig({
|
|
|
15964
16075
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Clock_default, { size: 12 })
|
|
15965
16076
|
};
|
|
15966
16077
|
}
|
|
15967
|
-
case "IN_PROGRESS_AWAITING_CUSTOMER"
|
|
15968
|
-
case "CLOSED_OPEN_TASKS"
|
|
16078
|
+
case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
|
|
16079
|
+
case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
|
|
15969
16080
|
return {
|
|
15970
16081
|
label: "Action required",
|
|
15971
16082
|
description: `Please respond to the below tasks to help us complete your ${monthName} books.`,
|
|
@@ -15973,7 +16084,7 @@ function getBookkeepingStatusConfig({
|
|
|
15973
16084
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(AlertCircle_default, { size: 12 })
|
|
15974
16085
|
};
|
|
15975
16086
|
}
|
|
15976
|
-
case "CLOSED_COMPLETE"
|
|
16087
|
+
case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
|
|
15977
16088
|
return {
|
|
15978
16089
|
label: "Books completed",
|
|
15979
16090
|
description: `Your ${monthName} books are complete and ready to view!`,
|
|
@@ -15981,7 +16092,7 @@ function getBookkeepingStatusConfig({
|
|
|
15981
16092
|
icon: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(CheckCircle_default, { size: 12 })
|
|
15982
16093
|
};
|
|
15983
16094
|
}
|
|
15984
|
-
case "BOOKKEEPING_NOT_ACTIVE"
|
|
16095
|
+
case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
|
|
15985
16096
|
return;
|
|
15986
16097
|
}
|
|
15987
16098
|
default: {
|
|
@@ -15996,7 +16107,7 @@ function getBookkeepingStatusConfig({
|
|
|
15996
16107
|
|
|
15997
16108
|
// src/components/BookkeepingStatus/BookkeepingStatus.tsx
|
|
15998
16109
|
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
15999
|
-
var
|
|
16110
|
+
var BookkeepingStatus2 = ({ status, text, monthNumber, iconOnly }) => {
|
|
16000
16111
|
if (!status) {
|
|
16001
16112
|
return;
|
|
16002
16113
|
}
|
|
@@ -16021,7 +16132,7 @@ var BookkeepingStatus = ({ status, text, monthNumber, iconOnly }) => {
|
|
|
16021
16132
|
// src/components/BankTransactionList/BankTransactionProcessingInfo.tsx
|
|
16022
16133
|
var import_jsx_runtime123 = require("react/jsx-runtime");
|
|
16023
16134
|
var BankTransactionProcessingInfo = () => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Tooltip, { offset: 12, children: [
|
|
16024
|
-
/* @__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" }) }),
|
|
16025
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." })
|
|
16026
16137
|
] });
|
|
16027
16138
|
|
|
@@ -18123,7 +18234,7 @@ function TransactionsActions({ children }) {
|
|
|
18123
18234
|
|
|
18124
18235
|
// src/hooks/useBankTransactions/useBankTransactionsDownload.ts
|
|
18125
18236
|
var import_mutation6 = __toESM(require("swr/mutation"));
|
|
18126
|
-
function
|
|
18237
|
+
function buildKey13({
|
|
18127
18238
|
access_token: accessToken,
|
|
18128
18239
|
apiUrl,
|
|
18129
18240
|
businessId
|
|
@@ -18141,7 +18252,7 @@ function useBankTransactionsDownload() {
|
|
|
18141
18252
|
const { data } = useAuth();
|
|
18142
18253
|
const { businessId } = useLayerContext();
|
|
18143
18254
|
return (0, import_mutation6.default)(
|
|
18144
|
-
() =>
|
|
18255
|
+
() => buildKey13(__spreadProps(__spreadValues({}, data), {
|
|
18145
18256
|
businessId
|
|
18146
18257
|
})),
|
|
18147
18258
|
({
|
|
@@ -18528,7 +18639,7 @@ var BankTransactionsContent = ({
|
|
|
18528
18639
|
}, [monthlyView, isVisible, isLoading, hasMore]);
|
|
18529
18640
|
(0, import_react82.useEffect)(() => {
|
|
18530
18641
|
if (JSON.stringify(inputFilters) !== JSON.stringify(filters)) {
|
|
18531
|
-
if (effectiveBookkeepingStatus === "ACTIVE") {
|
|
18642
|
+
if (effectiveBookkeepingStatus === "ACTIVE" /* ACTIVE */) {
|
|
18532
18643
|
setFilters(__spreadProps(__spreadValues(__spreadValues({}, filters), inputFilters), {
|
|
18533
18644
|
categorizationStatus: "all" /* all */
|
|
18534
18645
|
}));
|
|
@@ -18699,13 +18810,13 @@ var BankTransactionsContent = ({
|
|
|
18699
18810
|
};
|
|
18700
18811
|
|
|
18701
18812
|
// src/components/Integrations/Integrations.tsx
|
|
18702
|
-
var
|
|
18813
|
+
var import_react91 = require("react");
|
|
18703
18814
|
|
|
18704
18815
|
// src/components/Integrations/IntegrationsContent.tsx
|
|
18705
|
-
var
|
|
18816
|
+
var import_react87 = require("react");
|
|
18706
18817
|
|
|
18707
18818
|
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
|
|
18708
|
-
var
|
|
18819
|
+
var import_react86 = require("react");
|
|
18709
18820
|
|
|
18710
18821
|
// src/icons/QuickbooksIcon.tsx
|
|
18711
18822
|
var import_jsx_runtime153 = require("react/jsx-runtime");
|
|
@@ -18794,214 +18905,326 @@ var Card = ({ children, className }) => {
|
|
|
18794
18905
|
var import_react83 = require("react");
|
|
18795
18906
|
var QuickbooksContext = (0, import_react83.createContext)({
|
|
18796
18907
|
linkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
|
|
18797
|
-
unlinkQuickbooks: () =>
|
|
18798
|
-
throw new Error("QuickbooksContext used without Provider");
|
|
18799
|
-
},
|
|
18908
|
+
unlinkQuickbooks: () => Promise.reject(new Error("QuickbooksContext used without Provider")),
|
|
18800
18909
|
syncFromQuickbooks: () => {
|
|
18801
18910
|
throw new Error("QuickbooksContext used without Provider");
|
|
18802
18911
|
},
|
|
18803
|
-
|
|
18804
|
-
quickbooksIsConnected: false,
|
|
18805
|
-
quickbooksLastSyncedAt: void 0
|
|
18912
|
+
quickbooksConnectionStatus: void 0
|
|
18806
18913
|
});
|
|
18807
18914
|
|
|
18808
18915
|
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumbFooter.tsx
|
|
18809
18916
|
var import_react84 = require("react");
|
|
18810
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
|
|
18811
18935
|
var import_jsx_runtime157 = require("react/jsx-runtime");
|
|
18812
18936
|
var formatLastSyncedAt = (datetime) => {
|
|
18813
18937
|
const parsed = new Date(datetime);
|
|
18814
18938
|
if (!(0, import_date_fns23.isValid)(parsed)) return "";
|
|
18815
18939
|
return `${(0, import_date_fns23.format)(parsed, "MMMM d, yyyy")} at ${(0, import_date_fns23.format)(parsed, "h:mm a")}`;
|
|
18816
18940
|
};
|
|
18817
|
-
var
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
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
|
+
}
|
|
18841
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);
|
|
18842
18977
|
return /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(HStack, { className: "loadingbar", children: [
|
|
18843
18978
|
/* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(VStack, { children: [
|
|
18844
|
-
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Text, { size: "sm" /* sm */, children:
|
|
18845
|
-
/* @__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 })
|
|
18846
18981
|
] }),
|
|
18847
18982
|
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(Spacer, {}),
|
|
18848
|
-
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant:
|
|
18983
|
+
/* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BadgeLoader, { variant: badgeVariant })
|
|
18849
18984
|
] });
|
|
18850
18985
|
};
|
|
18851
18986
|
|
|
18852
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");
|
|
18853
18992
|
var import_jsx_runtime158 = require("react/jsx-runtime");
|
|
18854
|
-
|
|
18855
|
-
const {
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
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"
|
|
18868
19022
|
}
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
children: "Sync"
|
|
18886
|
-
}
|
|
18887
|
-
)
|
|
18888
|
-
] }),
|
|
18889
|
-
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "topbar-logo", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(QuickbooksIcon_default, { size: 28 }) })
|
|
18890
|
-
] }),
|
|
18891
|
-
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(IntegrationsQuickbooksItemThumbFooter, {})
|
|
18892
|
-
] }) });
|
|
18893
|
-
};
|
|
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
|
+
}
|
|
18894
19039
|
|
|
18895
|
-
// src/components/Integrations/
|
|
19040
|
+
// src/components/Integrations/IntegrationsQuickbooksItemThumb/IntegrationsQuickbooksItemThumb.tsx
|
|
18896
19041
|
var import_jsx_runtime159 = require("react/jsx-runtime");
|
|
18897
|
-
var
|
|
18898
|
-
|
|
18899
|
-
|
|
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
|
+
};
|
|
19076
|
+
var IntegrationsQuickbooksItemThumb = () => {
|
|
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)(() => {
|
|
19085
|
+
return [
|
|
19086
|
+
{
|
|
19087
|
+
name: "Unlink account",
|
|
19088
|
+
action: () => {
|
|
19089
|
+
setIsConfirmationModalOpen(true);
|
|
19090
|
+
}
|
|
19091
|
+
}
|
|
19092
|
+
];
|
|
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 }) })
|
|
19116
|
+
] }),
|
|
19117
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksItemThumbFooter, { quickbooksUiState })
|
|
19118
|
+
] }),
|
|
19119
|
+
/* @__PURE__ */ (0, import_jsx_runtime159.jsx)(IntegrationsQuickbooksUnlinkConfirmationModal, { isOpen: isConfirmationModalOpen, onOpenChange: setIsConfirmationModalOpen })
|
|
19120
|
+
] });
|
|
19121
|
+
};
|
|
19122
|
+
|
|
19123
|
+
// src/components/Integrations/IntegrationsContent.tsx
|
|
19124
|
+
var import_jsx_runtime160 = require("react/jsx-runtime");
|
|
19125
|
+
var IntegrationsContent = () => {
|
|
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, {}) });
|
|
18900
19128
|
};
|
|
18901
19129
|
|
|
18902
19130
|
// src/hooks/useQuickbooks/useQuickbooks.ts
|
|
18903
|
-
var
|
|
19131
|
+
var import_react88 = require("react");
|
|
19132
|
+
var import_date_fns24 = require("date-fns");
|
|
18904
19133
|
var useQuickbooks = () => {
|
|
19134
|
+
var _a;
|
|
18905
19135
|
const { businessId } = useLayerContext();
|
|
18906
19136
|
const { apiUrl } = useEnvironment();
|
|
18907
19137
|
const { data: auth } = useAuth();
|
|
18908
|
-
const [
|
|
18909
|
-
const
|
|
18910
|
-
const syncStatusIntervalRef = (0,
|
|
18911
|
-
const
|
|
18912
|
-
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* () {
|
|
18913
19142
|
const newQuickbooksConnectionStatus = (yield Layer.statusOfQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18914
19143
|
params: { businessId }
|
|
18915
19144
|
})()).data;
|
|
18916
19145
|
setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
|
|
18917
19146
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setQuickbooksConnectionStatus]);
|
|
18918
|
-
|
|
18919
|
-
const isSyncing = (yield Layer.statusOfSyncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18920
|
-
params: { businessId }
|
|
18921
|
-
})()).data.is_syncing;
|
|
18922
|
-
const wasSyncing = wasSyncingFromQuickbooksRef.current;
|
|
18923
|
-
wasSyncingFromQuickbooksRef.current = isSyncing;
|
|
18924
|
-
setIsSyncingFromQuickbooks(isSyncing);
|
|
18925
|
-
if (!isSyncing && wasSyncing) {
|
|
18926
|
-
yield fetchQuickbooksConnectionStatus();
|
|
18927
|
-
}
|
|
18928
|
-
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks, fetchQuickbooksConnectionStatus]);
|
|
18929
|
-
(0, import_react87.useEffect)(() => {
|
|
19147
|
+
(0, import_react88.useEffect)(() => {
|
|
18930
19148
|
if (isSyncingFromQuickbooks && syncStatusIntervalRef.current === null) {
|
|
18931
|
-
const interval = window.setInterval(() => void
|
|
19149
|
+
const interval = window.setInterval(() => void fetchQuickbooksConnectionStatus(), 2e3);
|
|
18932
19150
|
syncStatusIntervalRef.current = interval;
|
|
18933
19151
|
return () => clearInterval(interval);
|
|
18934
19152
|
} else if (!isSyncingFromQuickbooks && syncStatusIntervalRef.current) {
|
|
18935
19153
|
clearInterval(syncStatusIntervalRef.current);
|
|
18936
19154
|
syncStatusIntervalRef.current = null;
|
|
18937
19155
|
}
|
|
18938
|
-
}, [
|
|
18939
|
-
(0,
|
|
19156
|
+
}, [fetchQuickbooksConnectionStatus, isSyncingFromQuickbooks]);
|
|
19157
|
+
(0, import_react88.useEffect)(() => {
|
|
18940
19158
|
if (auth == null ? void 0 : auth.access_token) {
|
|
18941
19159
|
void fetchQuickbooksConnectionStatus();
|
|
18942
19160
|
}
|
|
18943
19161
|
}, [auth == null ? void 0 : auth.access_token, fetchQuickbooksConnectionStatus]);
|
|
18944
|
-
const
|
|
18945
|
-
|
|
18946
|
-
|
|
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);
|
|
18947
19173
|
void Layer.syncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18948
19174
|
params: { businessId }
|
|
18949
|
-
});
|
|
18950
|
-
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId,
|
|
18951
|
-
const linkQuickbooks = (0,
|
|
18952
|
-
|
|
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, {
|
|
18953
19179
|
params: { businessId }
|
|
18954
|
-
});
|
|
18955
|
-
return res.data.redirect_url;
|
|
19180
|
+
}).then((res) => res.data.redirect_url);
|
|
18956
19181
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId]);
|
|
18957
|
-
const unlinkQuickbooks = (0,
|
|
18958
|
-
|
|
19182
|
+
const unlinkQuickbooks = (0, import_react88.useCallback)(() => __async(null, null, function* () {
|
|
19183
|
+
return Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18959
19184
|
params: { businessId }
|
|
18960
19185
|
}).then(() => fetchQuickbooksConnectionStatus());
|
|
18961
|
-
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
|
|
19186
|
+
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, fetchQuickbooksConnectionStatus]);
|
|
18962
19187
|
return {
|
|
18963
|
-
isSyncingFromQuickbooks,
|
|
18964
19188
|
syncFromQuickbooks: syncFromQuickbooks2,
|
|
18965
|
-
quickbooksIsConnected: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected,
|
|
18966
|
-
quickbooksLastSyncedAt: quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.last_synced_at,
|
|
18967
19189
|
linkQuickbooks,
|
|
18968
|
-
unlinkQuickbooks
|
|
19190
|
+
unlinkQuickbooks,
|
|
19191
|
+
quickbooksConnectionStatus
|
|
18969
19192
|
};
|
|
18970
19193
|
};
|
|
18971
19194
|
|
|
18972
19195
|
// src/providers/QuickbooksContextProvider/QuickbooksContextProvider.tsx
|
|
18973
|
-
var
|
|
19196
|
+
var import_jsx_runtime161 = require("react/jsx-runtime");
|
|
18974
19197
|
function QuickbooksContextProvider({ children }) {
|
|
18975
19198
|
const quickbooksContextData = useQuickbooks();
|
|
18976
|
-
return /* @__PURE__ */ (0,
|
|
19199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(QuickbooksContext.Provider, { value: quickbooksContextData, children });
|
|
18977
19200
|
}
|
|
18978
19201
|
|
|
18979
19202
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
18980
|
-
var
|
|
19203
|
+
var import_react90 = require("react");
|
|
18981
19204
|
|
|
18982
19205
|
// src/components/ui/DropdownMenu/DropdownMenu.tsx
|
|
18983
19206
|
var import_react_aria_components11 = require("react-aria-components");
|
|
18984
|
-
var
|
|
18985
|
-
var Heading3 = ({ children }) => /* @__PURE__ */ (0,
|
|
18986
|
-
var MenuItem3 = ({ children, onClick, isDisabled }) => /* @__PURE__ */ (0,
|
|
18987
|
-
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 });
|
|
18988
19211
|
var DropdownMenu = ({ children, ariaLabel, slots, slotProps }) => {
|
|
18989
19212
|
var _a;
|
|
18990
19213
|
const { Trigger } = slots;
|
|
18991
19214
|
const width = (_a = slotProps == null ? void 0 : slotProps.Dialog) == null ? void 0 : _a.width;
|
|
18992
|
-
return /* @__PURE__ */ (0,
|
|
18993
|
-
/* @__PURE__ */ (0,
|
|
18994
|
-
/* @__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 }) })
|
|
18995
19218
|
] });
|
|
18996
19219
|
};
|
|
18997
19220
|
|
|
18998
19221
|
// src/icons/Cog.tsx
|
|
18999
|
-
var
|
|
19000
|
-
var
|
|
19222
|
+
var import_react89 = require("react");
|
|
19223
|
+
var import_jsx_runtime163 = require("react/jsx-runtime");
|
|
19001
19224
|
var Cog = (_a) => {
|
|
19002
19225
|
var _b = _a, { size = 12 } = _b, props = __objRest(_b, ["size"]);
|
|
19003
|
-
const id = (0,
|
|
19004
|
-
return /* @__PURE__ */ (0,
|
|
19226
|
+
const id = (0, import_react89.useId)();
|
|
19227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
|
|
19005
19228
|
"svg",
|
|
19006
19229
|
__spreadProps(__spreadValues({
|
|
19007
19230
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -19011,11 +19234,11 @@ var Cog = (_a) => {
|
|
|
19011
19234
|
height: size
|
|
19012
19235
|
}, props), {
|
|
19013
19236
|
children: [
|
|
19014
|
-
/* @__PURE__ */ (0,
|
|
19015
|
-
/* @__PURE__ */ (0,
|
|
19016
|
-
/* @__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" })
|
|
19017
19240
|
] }),
|
|
19018
|
-
/* @__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" }) }) })
|
|
19019
19242
|
]
|
|
19020
19243
|
})
|
|
19021
19244
|
);
|
|
@@ -19023,38 +19246,42 @@ var Cog = (_a) => {
|
|
|
19023
19246
|
var Cog_default = Cog;
|
|
19024
19247
|
|
|
19025
19248
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
19026
|
-
var
|
|
19027
|
-
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: [
|
|
19028
19251
|
"Manage",
|
|
19029
|
-
/* @__PURE__ */ (0,
|
|
19252
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)(Cog_default, { size: 16 })
|
|
19030
19253
|
] });
|
|
19031
19254
|
var IntegrationsConnectMenu = () => {
|
|
19032
|
-
const {
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
const initiateQuickbooksOAuth = (0,
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
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)(
|
|
19041
19268
|
DropdownMenu,
|
|
19042
19269
|
{
|
|
19043
19270
|
ariaLabel: "Connect Integration",
|
|
19044
19271
|
slots: { Trigger: MenuTriggerButton },
|
|
19045
19272
|
slotProps: { Dialog: { width: 280 } },
|
|
19046
19273
|
children: [
|
|
19047
|
-
/* @__PURE__ */ (0,
|
|
19048
|
-
/* @__PURE__ */ (0,
|
|
19049
|
-
/* @__PURE__ */ (0,
|
|
19050
|
-
/* @__PURE__ */ (0,
|
|
19051
|
-
/* @__PURE__ */ (0,
|
|
19052
|
-
/* @__PURE__ */ (0,
|
|
19053
|
-
] }, "quickbooks-connected") : /* @__PURE__ */ (0,
|
|
19054
|
-
/* @__PURE__ */ (0,
|
|
19055
|
-
/* @__PURE__ */ (0,
|
|
19056
|
-
/* @__PURE__ */ (0,
|
|
19057
|
-
/* @__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 })
|
|
19058
19285
|
] }, "connect-quickbooks") })
|
|
19059
19286
|
]
|
|
19060
19287
|
}
|
|
@@ -19062,20 +19289,20 @@ var IntegrationsConnectMenu = () => {
|
|
|
19062
19289
|
};
|
|
19063
19290
|
|
|
19064
19291
|
// src/components/Integrations/Integrations.tsx
|
|
19065
|
-
var
|
|
19292
|
+
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
19066
19293
|
var COMPONENT_NAME3 = "integrations";
|
|
19067
19294
|
var Integrations = (props) => {
|
|
19068
|
-
return /* @__PURE__ */ (0,
|
|
19295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(QuickbooksContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsComponent, __spreadValues({}, props)) });
|
|
19069
19296
|
};
|
|
19070
19297
|
var IntegrationsComponent = ({
|
|
19071
19298
|
elevated,
|
|
19072
19299
|
stringOverrides
|
|
19073
19300
|
}) => {
|
|
19074
|
-
const {
|
|
19075
|
-
const isLoading =
|
|
19076
|
-
return /* @__PURE__ */ (0,
|
|
19077
|
-
/* @__PURE__ */ (0,
|
|
19078
|
-
/* @__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)(
|
|
19079
19306
|
Heading,
|
|
19080
19307
|
{
|
|
19081
19308
|
className: "Layer__linked-accounts__title",
|
|
@@ -19083,61 +19310,26 @@ var IntegrationsComponent = ({
|
|
|
19083
19310
|
children: (stringOverrides == null ? void 0 : stringOverrides.title) || "Integrations"
|
|
19084
19311
|
}
|
|
19085
19312
|
),
|
|
19086
|
-
/* @__PURE__ */ (0,
|
|
19313
|
+
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsConnectMenu, {})
|
|
19087
19314
|
] }),
|
|
19088
|
-
isLoading && /* @__PURE__ */ (0,
|
|
19089
|
-
!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)(
|
|
19090
19317
|
DataState,
|
|
19091
19318
|
{
|
|
19092
19319
|
status: "info" /* info */,
|
|
19093
19320
|
title: "No active integrations"
|
|
19094
19321
|
}
|
|
19095
19322
|
),
|
|
19096
|
-
|
|
19097
|
-
] });
|
|
19098
|
-
};
|
|
19099
|
-
|
|
19100
|
-
// src/components/Quickbooks/Quickbooks.tsx
|
|
19101
|
-
var import_jsx_runtime165 = require("react/jsx-runtime");
|
|
19102
|
-
var Quickbooks = () => {
|
|
19103
|
-
const {
|
|
19104
|
-
syncFromQuickbooks: syncFromQuickbooks2,
|
|
19105
|
-
isSyncingFromQuickbooks,
|
|
19106
|
-
quickbooksIsConnected,
|
|
19107
|
-
linkQuickbooks,
|
|
19108
|
-
unlinkQuickbooks
|
|
19109
|
-
} = useQuickbooks();
|
|
19110
|
-
return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19111
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19112
|
-
"Quickbooks OAuth connection status:",
|
|
19113
|
-
" ",
|
|
19114
|
-
quickbooksIsConnected === void 0 ? "" : quickbooksIsConnected ? "established" : "not connected"
|
|
19115
|
-
] }),
|
|
19116
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("br", {}),
|
|
19117
|
-
quickbooksIsConnected === void 0 && "Loading...",
|
|
19118
|
-
quickbooksIsConnected === false && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
|
|
19119
|
-
"button",
|
|
19120
|
-
{
|
|
19121
|
-
onClick: () => __async(null, null, function* () {
|
|
19122
|
-
const authorizationUrl = yield linkQuickbooks();
|
|
19123
|
-
window.location.href = authorizationUrl;
|
|
19124
|
-
}),
|
|
19125
|
-
children: "Link Quickbooks"
|
|
19126
|
-
}
|
|
19127
|
-
),
|
|
19128
|
-
quickbooksIsConnected === true && (isSyncingFromQuickbooks ? "Syncing data from Quickbooks..." : /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { children: [
|
|
19129
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: syncFromQuickbooks2, children: "Sync Quickbooks" }),
|
|
19130
|
-
/* @__PURE__ */ (0, import_jsx_runtime165.jsx)("button", { onClick: unlinkQuickbooks, children: "Unlink Quickbooks" })
|
|
19131
|
-
] }))
|
|
19323
|
+
(quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(IntegrationsContent, {})
|
|
19132
19324
|
] });
|
|
19133
19325
|
};
|
|
19134
19326
|
|
|
19135
19327
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
19136
|
-
var
|
|
19328
|
+
var import_react119 = require("react");
|
|
19137
19329
|
|
|
19138
19330
|
// src/contexts/ProfitAndLossComparisonContext/ProfitAndLossComparisonContext.tsx
|
|
19139
|
-
var
|
|
19140
|
-
var PNLComparisonContext = (0,
|
|
19331
|
+
var import_react92 = require("react");
|
|
19332
|
+
var PNLComparisonContext = (0, import_react92.createContext)({
|
|
19141
19333
|
data: void 0,
|
|
19142
19334
|
isLoading: true,
|
|
19143
19335
|
isValidating: false,
|
|
@@ -19158,7 +19350,7 @@ var PNLComparisonContext = (0, import_react91.createContext)({
|
|
|
19158
19350
|
});
|
|
19159
19351
|
|
|
19160
19352
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
19161
|
-
var
|
|
19353
|
+
var import_react95 = require("react");
|
|
19162
19354
|
|
|
19163
19355
|
// src/utils/profitAndLossUtils.ts
|
|
19164
19356
|
var doesLineItemQualifies = (item) => {
|
|
@@ -19214,15 +19406,15 @@ var applyShare = (items, total) => {
|
|
|
19214
19406
|
};
|
|
19215
19407
|
|
|
19216
19408
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
19217
|
-
var
|
|
19218
|
-
var
|
|
19219
|
-
var
|
|
19409
|
+
var import_react93 = require("react");
|
|
19410
|
+
var import_date_fns25 = require("date-fns");
|
|
19411
|
+
var import_swr13 = __toESM(require("swr"));
|
|
19220
19412
|
var buildDates = ({ currentDate }) => {
|
|
19221
19413
|
return {
|
|
19222
|
-
startYear: (0,
|
|
19223
|
-
startMonth: (0,
|
|
19224
|
-
endYear: (0,
|
|
19225
|
-
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
|
|
19226
19418
|
};
|
|
19227
19419
|
};
|
|
19228
19420
|
var buildMonthsArray = (startDate, endDate) => {
|
|
@@ -19236,16 +19428,16 @@ var buildMonthsArray = (startDate, endDate) => {
|
|
|
19236
19428
|
return dates;
|
|
19237
19429
|
};
|
|
19238
19430
|
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
19239
|
-
currentDate: (0,
|
|
19431
|
+
currentDate: (0, import_date_fns25.startOfMonth)(Date.now())
|
|
19240
19432
|
}) => {
|
|
19241
19433
|
var _a, _b;
|
|
19242
19434
|
const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
19243
19435
|
const { apiUrl } = useEnvironment();
|
|
19244
19436
|
const { data: auth } = useAuth();
|
|
19245
|
-
const [date, setDate] = (0,
|
|
19246
|
-
const [loaded, setLoaded] = (0,
|
|
19247
|
-
const [data, setData] = (0,
|
|
19248
|
-
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)(() => {
|
|
19249
19441
|
return buildDates({ currentDate: date });
|
|
19250
19442
|
}, [date, businessId, tagFilter, reportingBasis]);
|
|
19251
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(
|
|
@@ -19257,7 +19449,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19257
19449
|
isValidating,
|
|
19258
19450
|
error,
|
|
19259
19451
|
mutate
|
|
19260
|
-
} = (0,
|
|
19452
|
+
} = (0, import_swr13.default)(
|
|
19261
19453
|
queryKey,
|
|
19262
19454
|
Layer.getProfitAndLossSummaries(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19263
19455
|
params: {
|
|
@@ -19272,9 +19464,9 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19272
19464
|
}
|
|
19273
19465
|
})
|
|
19274
19466
|
);
|
|
19275
|
-
(0,
|
|
19467
|
+
(0, import_react93.useEffect)(() => {
|
|
19276
19468
|
const newData = data.slice();
|
|
19277
|
-
const newPeriod = buildMonthsArray((0,
|
|
19469
|
+
const newPeriod = buildMonthsArray((0, import_date_fns25.sub)(date, { years: 1 }), date);
|
|
19278
19470
|
if (newData && newPeriod) {
|
|
19279
19471
|
newPeriod.forEach((x) => {
|
|
19280
19472
|
if (!(newData == null ? void 0 : newData.find(
|
|
@@ -19308,7 +19500,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19308
19500
|
);
|
|
19309
19501
|
}
|
|
19310
19502
|
}, [startYear, startMonth, tagFilter]);
|
|
19311
|
-
(0,
|
|
19503
|
+
(0, import_react93.useEffect)(() => {
|
|
19312
19504
|
var _a2, _b2;
|
|
19313
19505
|
const newData = (_b2 = (_a2 = rawData == null ? void 0 : rawData.data) == null ? void 0 : _a2.months) == null ? void 0 : _b2.slice();
|
|
19314
19506
|
if (data && newData) {
|
|
@@ -19326,7 +19518,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19326
19518
|
);
|
|
19327
19519
|
}
|
|
19328
19520
|
}, [rawData]);
|
|
19329
|
-
(0,
|
|
19521
|
+
(0, import_react93.useEffect)(() => {
|
|
19330
19522
|
if (isLoading && loaded === "initial") {
|
|
19331
19523
|
setLoaded("loading");
|
|
19332
19524
|
return;
|
|
@@ -19336,12 +19528,12 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19336
19528
|
}
|
|
19337
19529
|
}, [data, isLoading]);
|
|
19338
19530
|
const pullData = (date2) => setDate(date2);
|
|
19339
|
-
(0,
|
|
19531
|
+
(0, import_react93.useEffect)(() => {
|
|
19340
19532
|
if (queryKey && (isLoading || isValidating)) {
|
|
19341
19533
|
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
19342
19534
|
}
|
|
19343
19535
|
}, [isLoading, isValidating]);
|
|
19344
|
-
(0,
|
|
19536
|
+
(0, import_react93.useEffect)(() => {
|
|
19345
19537
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
19346
19538
|
mutate();
|
|
19347
19539
|
}
|
|
@@ -19368,17 +19560,17 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19368
19560
|
};
|
|
19369
19561
|
|
|
19370
19562
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
19371
|
-
var
|
|
19372
|
-
var
|
|
19373
|
-
var
|
|
19563
|
+
var import_react94 = require("react");
|
|
19564
|
+
var import_date_fns26 = require("date-fns");
|
|
19565
|
+
var import_swr14 = __toESM(require("swr"));
|
|
19374
19566
|
var useProfitAndLossQuery = ({
|
|
19375
19567
|
startDate,
|
|
19376
19568
|
endDate,
|
|
19377
19569
|
tagFilter,
|
|
19378
19570
|
reportingBasis
|
|
19379
19571
|
} = {
|
|
19380
|
-
startDate: (0,
|
|
19381
|
-
endDate: (0,
|
|
19572
|
+
startDate: (0, import_date_fns26.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
19573
|
+
endDate: (0, import_date_fns26.endOfMonth)(/* @__PURE__ */ new Date())
|
|
19382
19574
|
}) => {
|
|
19383
19575
|
var _a, _b;
|
|
19384
19576
|
const { businessId, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
@@ -19393,7 +19585,7 @@ var useProfitAndLossQuery = ({
|
|
|
19393
19585
|
isValidating,
|
|
19394
19586
|
error: rawError,
|
|
19395
19587
|
mutate
|
|
19396
|
-
} = (0,
|
|
19588
|
+
} = (0, import_swr14.default)(
|
|
19397
19589
|
queryKey,
|
|
19398
19590
|
Layer.getProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19399
19591
|
businessId,
|
|
@@ -19407,12 +19599,12 @@ var useProfitAndLossQuery = ({
|
|
|
19407
19599
|
const refetch = () => {
|
|
19408
19600
|
mutate();
|
|
19409
19601
|
};
|
|
19410
|
-
(0,
|
|
19602
|
+
(0, import_react94.useEffect)(() => {
|
|
19411
19603
|
if (queryKey && (isLoading || isValidating)) {
|
|
19412
19604
|
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
19413
19605
|
}
|
|
19414
19606
|
}, [isLoading, isValidating]);
|
|
19415
|
-
(0,
|
|
19607
|
+
(0, import_react94.useEffect)(() => {
|
|
19416
19608
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
19417
19609
|
refetch();
|
|
19418
19610
|
}
|
|
@@ -19435,16 +19627,16 @@ var useProfitAndLoss = ({
|
|
|
19435
19627
|
}) => {
|
|
19436
19628
|
const { start, end } = useGlobalDateRange();
|
|
19437
19629
|
const { setRange } = useGlobalDateRangeActions();
|
|
19438
|
-
const dateRange = (0,
|
|
19439
|
-
const changeDateRange = (0,
|
|
19630
|
+
const dateRange = (0, import_react95.useMemo)(() => ({ startDate: start, endDate: end }), [start, end]);
|
|
19631
|
+
const changeDateRange = (0, import_react95.useCallback)(
|
|
19440
19632
|
({ startDate: start2, endDate: end2 }) => setRange({ start: start2, end: end2 }),
|
|
19441
19633
|
[setRange]
|
|
19442
19634
|
);
|
|
19443
|
-
const [filters, setFilters] = (0,
|
|
19635
|
+
const [filters, setFilters] = (0, import_react95.useState)({
|
|
19444
19636
|
expenses: void 0,
|
|
19445
19637
|
revenue: void 0
|
|
19446
19638
|
});
|
|
19447
|
-
const [sidebarScope, setSidebarScope] = (0,
|
|
19639
|
+
const [sidebarScope, setSidebarScope] = (0, import_react95.useState)(void 0);
|
|
19448
19640
|
const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
|
|
19449
19641
|
startDate: start,
|
|
19450
19642
|
endDate: end,
|
|
@@ -19471,7 +19663,7 @@ var useProfitAndLoss = ({
|
|
|
19471
19663
|
})
|
|
19472
19664
|
}));
|
|
19473
19665
|
};
|
|
19474
|
-
const { filteredDataRevenue, filteredTotalRevenue } = (0,
|
|
19666
|
+
const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react95.useMemo)(() => {
|
|
19475
19667
|
var _a;
|
|
19476
19668
|
if (!data) {
|
|
19477
19669
|
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
@@ -19523,7 +19715,7 @@ var useProfitAndLoss = ({
|
|
|
19523
19715
|
const withShare = applyShare(sorted, total);
|
|
19524
19716
|
return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
|
|
19525
19717
|
}, [data, start, filters, summaryData]);
|
|
19526
|
-
const { filteredDataExpenses, filteredTotalExpenses } = (0,
|
|
19718
|
+
const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react95.useMemo)(() => {
|
|
19527
19719
|
var _a;
|
|
19528
19720
|
if (!data) {
|
|
19529
19721
|
return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
|
|
@@ -19597,10 +19789,10 @@ var useProfitAndLoss = ({
|
|
|
19597
19789
|
};
|
|
19598
19790
|
|
|
19599
19791
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19600
|
-
var
|
|
19792
|
+
var import_react96 = require("react");
|
|
19601
19793
|
|
|
19602
19794
|
// src/hooks/useProfitAndLossComparison/utils.ts
|
|
19603
|
-
var
|
|
19795
|
+
var import_date_fns27 = require("date-fns");
|
|
19604
19796
|
|
|
19605
19797
|
// src/utils/array/range.ts
|
|
19606
19798
|
function range2(start, end) {
|
|
@@ -19658,12 +19850,12 @@ function prepareFiltersBody(compareOptions) {
|
|
|
19658
19850
|
return isArrayWithAtLeastOne(allFilters) ? allFilters : void 0;
|
|
19659
19851
|
}
|
|
19660
19852
|
function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
|
|
19661
|
-
const adjustedStartDate = (0,
|
|
19853
|
+
const adjustedStartDate = (0, import_date_fns27.startOfMonth)(dateRange.startDate);
|
|
19662
19854
|
const rawPeriods = range2(0, comparePeriods).map((index) => {
|
|
19663
|
-
const currentPeriod = (0,
|
|
19855
|
+
const currentPeriod = (0, import_date_fns27.subMonths)(adjustedStartDate, index);
|
|
19664
19856
|
return {
|
|
19665
|
-
year: (0,
|
|
19666
|
-
month: (0,
|
|
19857
|
+
year: (0, import_date_fns27.getYear)(currentPeriod),
|
|
19858
|
+
month: (0, import_date_fns27.getMonth)(currentPeriod) + 1
|
|
19667
19859
|
};
|
|
19668
19860
|
});
|
|
19669
19861
|
const sortedPeriods = rawPeriods.sort((a, b) => {
|
|
@@ -19681,11 +19873,11 @@ function preparePeriodsBodyForMonths(dateRange, comparePeriods) {
|
|
|
19681
19873
|
};
|
|
19682
19874
|
}
|
|
19683
19875
|
function preparePeriodsBodyForYears(dateRange, comparePeriods) {
|
|
19684
|
-
const adjustedStartDate = (0,
|
|
19876
|
+
const adjustedStartDate = (0, import_date_fns27.startOfYear)(dateRange.startDate);
|
|
19685
19877
|
const rawPeriods = range2(0, comparePeriods).map((index) => {
|
|
19686
|
-
const currentPeriod = (0,
|
|
19878
|
+
const currentPeriod = (0, import_date_fns27.subYears)(adjustedStartDate, index);
|
|
19687
19879
|
return {
|
|
19688
|
-
year: (0,
|
|
19880
|
+
year: (0, import_date_fns27.getYear)(currentPeriod)
|
|
19689
19881
|
};
|
|
19690
19882
|
});
|
|
19691
19883
|
const sortedPeriods = rawPeriods.sort((a, b) => {
|
|
@@ -19720,14 +19912,14 @@ function preparePeriodsBody(dateRange, comparePeriods, rangeDisplayMode) {
|
|
|
19720
19912
|
}
|
|
19721
19913
|
|
|
19722
19914
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19723
|
-
var
|
|
19915
|
+
var import_swr15 = __toESM(require("swr"));
|
|
19724
19916
|
var COMPARE_MODES_SUPPORTING_MULTI_PERIOD = ["monthPicker", "yearPicker"];
|
|
19725
19917
|
var isNotOnlyNoneTag = (compareOptions) => {
|
|
19726
19918
|
return Boolean(
|
|
19727
19919
|
compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
|
|
19728
19920
|
);
|
|
19729
19921
|
};
|
|
19730
|
-
function
|
|
19922
|
+
function buildKey14({
|
|
19731
19923
|
access_token: accessToken,
|
|
19732
19924
|
apiUrl,
|
|
19733
19925
|
businessId,
|
|
@@ -19751,15 +19943,15 @@ function useProfitAndLossComparison({
|
|
|
19751
19943
|
comparisonConfig
|
|
19752
19944
|
}) {
|
|
19753
19945
|
var _a, _b;
|
|
19754
|
-
const [comparePeriods, setComparePeriods] = (0,
|
|
19755
|
-
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)(
|
|
19756
19948
|
(comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
|
|
19757
19949
|
);
|
|
19758
19950
|
const { rangeDisplayMode, start, end } = useGlobalDateRange();
|
|
19759
19951
|
const dateRange = { startDate: start, endDate: end };
|
|
19760
19952
|
const isPeriodsSelectEnabled = COMPARE_MODES_SUPPORTING_MULTI_PERIOD.includes(rangeDisplayMode);
|
|
19761
19953
|
const effectiveComparePeriods = isPeriodsSelectEnabled ? comparePeriods : 1;
|
|
19762
|
-
const compareModeActive = (0,
|
|
19954
|
+
const compareModeActive = (0, import_react96.useMemo)(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
|
|
19763
19955
|
const setSelectedCompareOptions = (values) => {
|
|
19764
19956
|
const options = values.map(
|
|
19765
19957
|
(option) => comparisonConfig == null ? void 0 : comparisonConfig.tagComparisonOptions.find(
|
|
@@ -19777,14 +19969,14 @@ function useProfitAndLossComparison({
|
|
|
19777
19969
|
const { data: auth } = useAuth();
|
|
19778
19970
|
const periods = preparePeriodsBody(dateRange, effectiveComparePeriods, rangeDisplayMode);
|
|
19779
19971
|
const tagFilters = prepareFiltersBody(selectedCompareOptions);
|
|
19780
|
-
const queryKey =
|
|
19972
|
+
const queryKey = buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
19781
19973
|
businessId,
|
|
19782
19974
|
periods,
|
|
19783
19975
|
tagFilters,
|
|
19784
19976
|
reportingBasis,
|
|
19785
19977
|
compareModeActive
|
|
19786
19978
|
}));
|
|
19787
|
-
const { data, isLoading, isValidating } = (0,
|
|
19979
|
+
const { data, isLoading, isValidating } = (0, import_swr15.default)(
|
|
19788
19980
|
queryKey,
|
|
19789
19981
|
() => __async(null, null, function* () {
|
|
19790
19982
|
const response = yield Layer.compareProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -19832,7 +20024,7 @@ function useProfitAndLossComparison({
|
|
|
19832
20024
|
}
|
|
19833
20025
|
|
|
19834
20026
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
19835
|
-
var
|
|
20027
|
+
var import_react97 = require("react");
|
|
19836
20028
|
|
|
19837
20029
|
// src/icons/BarChart2.tsx
|
|
19838
20030
|
var import_jsx_runtime166 = require("react/jsx-runtime");
|
|
@@ -19942,7 +20134,7 @@ var Indicator = ({
|
|
|
19942
20134
|
|
|
19943
20135
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
19944
20136
|
var import_classnames53 = __toESM(require("classnames"));
|
|
19945
|
-
var
|
|
20137
|
+
var import_date_fns28 = require("date-fns");
|
|
19946
20138
|
var import_recharts = require("recharts");
|
|
19947
20139
|
var import_jsx_runtime169 = require("react/jsx-runtime");
|
|
19948
20140
|
var getChartWindow = ({
|
|
@@ -19950,46 +20142,46 @@ var getChartWindow = ({
|
|
|
19950
20142
|
currentYear,
|
|
19951
20143
|
currentMonth
|
|
19952
20144
|
}) => {
|
|
19953
|
-
const today = (0,
|
|
19954
|
-
const yearAgo = (0,
|
|
19955
|
-
const current = (0,
|
|
19956
|
-
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) {
|
|
19957
20149
|
return chartWindow;
|
|
19958
20150
|
}
|
|
19959
|
-
if ((0,
|
|
20151
|
+
if ((0, import_date_fns28.differenceInMonths)((0, import_date_fns28.startOfMonth)(chartWindow.start), current) === 0) {
|
|
19960
20152
|
return {
|
|
19961
|
-
start: (0,
|
|
19962
|
-
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 }))
|
|
19963
20155
|
};
|
|
19964
20156
|
}
|
|
19965
|
-
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) {
|
|
19966
20158
|
return {
|
|
19967
|
-
start: (0,
|
|
19968
|
-
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 }))
|
|
19969
20161
|
};
|
|
19970
20162
|
}
|
|
19971
|
-
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) {
|
|
19972
20164
|
return {
|
|
19973
|
-
start: (0,
|
|
19974
|
-
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 }))
|
|
19975
20167
|
};
|
|
19976
20168
|
}
|
|
19977
20169
|
if (current >= yearAgo) {
|
|
19978
20170
|
return {
|
|
19979
|
-
start: (0,
|
|
19980
|
-
end: (0,
|
|
20171
|
+
start: (0, import_date_fns28.startOfMonth)(yearAgo),
|
|
20172
|
+
end: (0, import_date_fns28.endOfMonth)(today)
|
|
19981
20173
|
};
|
|
19982
20174
|
}
|
|
19983
20175
|
if (Number(current) > Number(chartWindow.end)) {
|
|
19984
20176
|
return {
|
|
19985
|
-
start: (0,
|
|
19986
|
-
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)
|
|
19987
20179
|
};
|
|
19988
20180
|
}
|
|
19989
|
-
if ((0,
|
|
20181
|
+
if ((0, import_date_fns28.differenceInMonths)(current, (0, import_date_fns28.startOfMonth)(chartWindow.start)) < 0) {
|
|
19990
20182
|
return {
|
|
19991
|
-
start: (0,
|
|
19992
|
-
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 }))
|
|
19993
20185
|
};
|
|
19994
20186
|
}
|
|
19995
20187
|
return chartWindow;
|
|
@@ -20015,41 +20207,41 @@ var ProfitAndLossChart = ({
|
|
|
20015
20207
|
tagFilter = void 0
|
|
20016
20208
|
}) => {
|
|
20017
20209
|
var _c, _d, _e, _f, _g, _h;
|
|
20018
|
-
const [compactView, setCompactView] = (0,
|
|
20210
|
+
const [compactView, setCompactView] = (0, import_react97.useState)(false);
|
|
20019
20211
|
const barSize = compactView ? 10 : 20;
|
|
20020
20212
|
const { getColor, business } = useLayerContext();
|
|
20021
20213
|
const { start, end, rangeDisplayMode } = useGlobalDateRange();
|
|
20022
20214
|
const { setMonth } = useGlobalDateRangeActions();
|
|
20023
20215
|
const showIndicator = rangeDisplayMode === "monthPicker";
|
|
20024
|
-
const dateRange = (0,
|
|
20025
|
-
const [localDateRange, setLocalDateRange] = (0,
|
|
20026
|
-
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)({
|
|
20027
20219
|
width: 0,
|
|
20028
20220
|
height: 0,
|
|
20029
20221
|
x: 0
|
|
20030
20222
|
});
|
|
20031
|
-
const [barAnimActive, setBarAnimActive] = (0,
|
|
20032
|
-
const [chartWindow, setChartWindow] = (0,
|
|
20033
|
-
start: (0,
|
|
20034
|
-
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())
|
|
20035
20227
|
});
|
|
20036
|
-
const selectionMonth = (0,
|
|
20228
|
+
const selectionMonth = (0, import_react97.useMemo)(
|
|
20037
20229
|
() => ({
|
|
20038
20230
|
year: localDateRange.startDate.getFullYear(),
|
|
20039
20231
|
month: localDateRange.startDate.getMonth()
|
|
20040
20232
|
}),
|
|
20041
20233
|
[localDateRange]
|
|
20042
20234
|
);
|
|
20043
|
-
(0,
|
|
20235
|
+
(0, import_react97.useEffect)(() => {
|
|
20044
20236
|
if (Number(dateRange.startDate) !== Number(localDateRange.startDate) || Number(dateRange.endDate) !== Number(localDateRange.endDate)) {
|
|
20045
20237
|
setLocalDateRange(dateRange);
|
|
20046
20238
|
}
|
|
20047
20239
|
}, [dateRange]);
|
|
20048
20240
|
const { data, loaded, pullData } = useProfitAndLossLTM({
|
|
20049
|
-
currentDate: (0,
|
|
20241
|
+
currentDate: (0, import_date_fns28.startOfMonth)(Date.now()),
|
|
20050
20242
|
tagFilter
|
|
20051
20243
|
});
|
|
20052
|
-
const anyData = (0,
|
|
20244
|
+
const anyData = (0, import_react97.useMemo)(() => {
|
|
20053
20245
|
return Boolean(
|
|
20054
20246
|
data == null ? void 0 : data.find(
|
|
20055
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
|
|
@@ -20057,33 +20249,33 @@ var ProfitAndLossChart = ({
|
|
|
20057
20249
|
);
|
|
20058
20250
|
}, [data]);
|
|
20059
20251
|
const { data: linkedAccounts } = useLinkedAccounts();
|
|
20060
|
-
const isSyncing = (0,
|
|
20252
|
+
const isSyncing = (0, import_react97.useMemo)(
|
|
20061
20253
|
() => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
|
|
20062
20254
|
[linkedAccounts]
|
|
20063
20255
|
);
|
|
20064
|
-
const loadingValue = (0,
|
|
20065
|
-
(0,
|
|
20256
|
+
const loadingValue = (0, import_react97.useMemo)(() => getLoadingValue(data), [data]);
|
|
20257
|
+
(0, import_react97.useEffect)(() => {
|
|
20066
20258
|
if (loaded === "complete" && data) {
|
|
20067
20259
|
const foundCurrent = data.find(
|
|
20068
|
-
(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)
|
|
20069
20261
|
);
|
|
20070
20262
|
if (!foundCurrent) {
|
|
20071
|
-
const newDate = (0,
|
|
20263
|
+
const newDate = (0, import_date_fns28.startOfMonth)(localDateRange.startDate);
|
|
20072
20264
|
pullData(newDate);
|
|
20073
20265
|
return;
|
|
20074
20266
|
}
|
|
20075
20267
|
const foundBefore = data.find(
|
|
20076
|
-
(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 }))
|
|
20077
20269
|
);
|
|
20078
20270
|
if (!foundBefore) {
|
|
20079
|
-
const newDate = (0,
|
|
20080
|
-
(0,
|
|
20271
|
+
const newDate = (0, import_date_fns28.startOfMonth)(
|
|
20272
|
+
(0, import_date_fns28.sub)(localDateRange.startDate, { months: 1 })
|
|
20081
20273
|
);
|
|
20082
20274
|
pullData(newDate);
|
|
20083
20275
|
}
|
|
20084
20276
|
}
|
|
20085
20277
|
}, [localDateRange]);
|
|
20086
|
-
(0,
|
|
20278
|
+
(0, import_react97.useEffect)(() => {
|
|
20087
20279
|
const newChartWindow = getChartWindow({
|
|
20088
20280
|
chartWindow,
|
|
20089
20281
|
currentYear: localDateRange.startDate.getFullYear(),
|
|
@@ -20093,14 +20285,14 @@ var ProfitAndLossChart = ({
|
|
|
20093
20285
|
setChartWindow(newChartWindow);
|
|
20094
20286
|
}
|
|
20095
20287
|
}, [localDateRange]);
|
|
20096
|
-
(0,
|
|
20288
|
+
(0, import_react97.useEffect)(() => {
|
|
20097
20289
|
if (loaded === "complete") {
|
|
20098
20290
|
setTimeout(() => {
|
|
20099
20291
|
setBarAnimActive(false);
|
|
20100
20292
|
}, 2e3);
|
|
20101
20293
|
}
|
|
20102
20294
|
}, [loaded]);
|
|
20103
|
-
const getMonthName = (pnl) => pnl ? (0,
|
|
20295
|
+
const getMonthName = (pnl) => pnl ? (0, import_date_fns28.format)(
|
|
20104
20296
|
new Date(pnl.year, pnl.month - 1, 1),
|
|
20105
20297
|
compactView ? "LLLLL" : "LLL"
|
|
20106
20298
|
) : "";
|
|
@@ -20120,15 +20312,15 @@ var ProfitAndLossChart = ({
|
|
|
20120
20312
|
loading: (pnl == null ? void 0 : pnl.isLoading) ? loadingValue : 0,
|
|
20121
20313
|
loadingExpenses: (pnl == null ? void 0 : pnl.isLoading) ? -loadingValue : 0
|
|
20122
20314
|
});
|
|
20123
|
-
const theData = (0,
|
|
20315
|
+
const theData = (0, import_react97.useMemo)(() => {
|
|
20124
20316
|
var _a;
|
|
20125
20317
|
if (loaded !== "complete" || loaded === "complete" && !anyData) {
|
|
20126
20318
|
const loadingData = [];
|
|
20127
20319
|
const today = Date.now();
|
|
20128
20320
|
for (let i = 11; i >= 0; i--) {
|
|
20129
|
-
const currentDate = (0,
|
|
20321
|
+
const currentDate = (0, import_date_fns28.sub)(today, { months: i });
|
|
20130
20322
|
loadingData.push({
|
|
20131
|
-
name: (0,
|
|
20323
|
+
name: (0, import_date_fns28.format)(currentDate, compactView ? "LLLLL" : "LLL"),
|
|
20132
20324
|
revenue: 0,
|
|
20133
20325
|
revenueUncategorized: 0,
|
|
20134
20326
|
totalExpensesInverse: 0,
|
|
@@ -20158,18 +20350,18 @@ var ProfitAndLossChart = ({
|
|
|
20158
20350
|
}
|
|
20159
20351
|
return x;
|
|
20160
20352
|
})) == null ? void 0 : _a.filter(
|
|
20161
|
-
(x) => (0,
|
|
20162
|
-
(0,
|
|
20353
|
+
(x) => (0, import_date_fns28.differenceInMonths)(
|
|
20354
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
20163
20355
|
chartWindow.start
|
|
20164
|
-
) >= 0 && (0,
|
|
20165
|
-
(0,
|
|
20356
|
+
) >= 0 && (0, import_date_fns28.differenceInMonths)(
|
|
20357
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
20166
20358
|
chartWindow.start
|
|
20167
|
-
) < 12 && (0,
|
|
20359
|
+
) < 12 && (0, import_date_fns28.differenceInMonths)(
|
|
20168
20360
|
chartWindow.end,
|
|
20169
|
-
(0,
|
|
20170
|
-
) >= 0 && (0,
|
|
20361
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
20362
|
+
) >= 0 && (0, import_date_fns28.differenceInMonths)(
|
|
20171
20363
|
chartWindow.end,
|
|
20172
|
-
(0,
|
|
20364
|
+
(0, import_date_fns28.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
20173
20365
|
) <= 12
|
|
20174
20366
|
).map((x) => summarizePnL(x));
|
|
20175
20367
|
}, [selectionMonth, chartWindow, data, loaded, compactView]);
|
|
@@ -20651,7 +20843,7 @@ var ProfitAndLossChart = ({
|
|
|
20651
20843
|
};
|
|
20652
20844
|
|
|
20653
20845
|
// src/components/ProfitAndLossCompareOptions/ProfitAndLossCompareOptions.tsx
|
|
20654
|
-
var
|
|
20846
|
+
var import_react98 = require("react");
|
|
20655
20847
|
var import_jsx_runtime170 = require("react/jsx-runtime");
|
|
20656
20848
|
var selectStyles = {
|
|
20657
20849
|
valueContainer: (styles) => {
|
|
@@ -20691,9 +20883,9 @@ var ProfitAndLossCompareOptions = () => {
|
|
|
20691
20883
|
compareOptions,
|
|
20692
20884
|
selectedCompareOptions,
|
|
20693
20885
|
comparisonConfig
|
|
20694
|
-
} = (0,
|
|
20886
|
+
} = (0, import_react98.useContext)(ProfitAndLoss.ComparisonContext);
|
|
20695
20887
|
const { rangeDisplayMode } = useGlobalDateRange();
|
|
20696
|
-
const periods = (0,
|
|
20888
|
+
const periods = (0, import_react98.useMemo)(
|
|
20697
20889
|
() => comparePeriods !== 0 ? comparePeriods : 1,
|
|
20698
20890
|
[comparePeriods]
|
|
20699
20891
|
);
|
|
@@ -20786,7 +20978,7 @@ function DatePickerModeSelector({
|
|
|
20786
20978
|
}
|
|
20787
20979
|
|
|
20788
20980
|
// src/providers/GlobalDateStore/useGlobalDateRangePicker.ts
|
|
20789
|
-
var
|
|
20981
|
+
var import_react99 = require("react");
|
|
20790
20982
|
function useGlobalDateRangePicker({
|
|
20791
20983
|
allowedDatePickerModes,
|
|
20792
20984
|
defaultDatePickerMode,
|
|
@@ -20803,7 +20995,7 @@ function useGlobalDateRangePicker({
|
|
|
20803
20995
|
DEFAULT_ALLOWED_PICKER_MODES
|
|
20804
20996
|
);
|
|
20805
20997
|
const desiredRangeMode = allowedDateRangePickerModes.includes(rangeDisplayMode) ? rangeDisplayMode : allowedDateRangePickerModes[0];
|
|
20806
|
-
const { dateFormat, selected } = (0,
|
|
20998
|
+
const { dateFormat, selected } = (0, import_react99.useMemo)(() => {
|
|
20807
20999
|
if (rangeDisplayMode === "monthPicker") {
|
|
20808
21000
|
return {
|
|
20809
21001
|
selected: start,
|
|
@@ -20823,7 +21015,7 @@ function useGlobalDateRangePicker({
|
|
|
20823
21015
|
end,
|
|
20824
21016
|
rangeDisplayMode
|
|
20825
21017
|
]);
|
|
20826
|
-
const { setSelected } = (0,
|
|
21018
|
+
const { setSelected } = (0, import_react99.useMemo)(() => {
|
|
20827
21019
|
if (desiredRangeMode === "monthPicker") {
|
|
20828
21020
|
return {
|
|
20829
21021
|
setSelected: ({ start: start2 }) => {
|
|
@@ -20903,10 +21095,10 @@ var ProfitAndLossDatePicker = ({
|
|
|
20903
21095
|
};
|
|
20904
21096
|
|
|
20905
21097
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
20906
|
-
var
|
|
21098
|
+
var import_react101 = require("react");
|
|
20907
21099
|
|
|
20908
21100
|
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
20909
|
-
var
|
|
21101
|
+
var import_react100 = require("react");
|
|
20910
21102
|
|
|
20911
21103
|
// src/config/charts.ts
|
|
20912
21104
|
var DEFAULT_CHART_COLOR_TYPE = [
|
|
@@ -21191,7 +21383,7 @@ var DetailedChart = ({
|
|
|
21191
21383
|
isLoading,
|
|
21192
21384
|
showDatePicker = true
|
|
21193
21385
|
}) => {
|
|
21194
|
-
const chartData = (0,
|
|
21386
|
+
const chartData = (0, import_react100.useMemo)(() => {
|
|
21195
21387
|
if (!filteredData) {
|
|
21196
21388
|
return [];
|
|
21197
21389
|
}
|
|
@@ -21542,7 +21734,7 @@ var Filters = ({
|
|
|
21542
21734
|
};
|
|
21543
21735
|
|
|
21544
21736
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
21545
|
-
var
|
|
21737
|
+
var import_date_fns29 = require("date-fns");
|
|
21546
21738
|
var import_jsx_runtime177 = require("react/jsx-runtime");
|
|
21547
21739
|
var ProfitAndLossDetailedCharts = ({
|
|
21548
21740
|
scope,
|
|
@@ -21563,16 +21755,16 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21563
21755
|
sidebarScope,
|
|
21564
21756
|
setSidebarScope,
|
|
21565
21757
|
setFilterTypes
|
|
21566
|
-
} = (0,
|
|
21758
|
+
} = (0, import_react101.useContext)(ProfitAndLoss.Context);
|
|
21567
21759
|
const theScope = scope ? scope : sidebarScope;
|
|
21568
21760
|
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
21569
21761
|
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
21570
|
-
const [hoveredItem, setHoveredItem] = (0,
|
|
21762
|
+
const [hoveredItem, setHoveredItem] = (0, import_react101.useState)();
|
|
21571
21763
|
return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts", children: [
|
|
21572
21764
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("header", { className: "Layer__profit-and-loss-detailed-charts__header", children: [
|
|
21573
21765
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
|
|
21574
21766
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
|
|
21575
|
-
/* @__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") }),
|
|
21576
21768
|
showDatePicker && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(ProfitAndLossDatePicker, {})
|
|
21577
21769
|
] }),
|
|
21578
21770
|
!hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
|
|
@@ -21589,7 +21781,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21589
21781
|
!hideClose && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(BackButton, { onClick: () => setSidebarScope(void 0) }),
|
|
21590
21782
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__head", children: [
|
|
21591
21783
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title", children: humanizeTitle(theScope) }),
|
|
21592
|
-
/* @__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") })
|
|
21593
21785
|
] })
|
|
21594
21786
|
] }),
|
|
21595
21787
|
/* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "Layer__profit-and-loss-detailed-charts__content", children: [
|
|
@@ -21636,7 +21828,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
21636
21828
|
};
|
|
21637
21829
|
|
|
21638
21830
|
// src/components/ProfitAndLossDownloadButton/ProfitAndLossDownloadButton.tsx
|
|
21639
|
-
var
|
|
21831
|
+
var import_react102 = require("react");
|
|
21640
21832
|
var import_jsx_runtime178 = require("react/jsx-runtime");
|
|
21641
21833
|
var ProfitAndLossDownloadButton = ({
|
|
21642
21834
|
stringOverrides,
|
|
@@ -21644,15 +21836,15 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21644
21836
|
moneyFormat,
|
|
21645
21837
|
view
|
|
21646
21838
|
}) => {
|
|
21647
|
-
const { dateRange, tagFilter } = (0,
|
|
21648
|
-
const { getProfitAndLossComparisonCsv } = (0,
|
|
21839
|
+
const { dateRange, tagFilter } = (0, import_react102.useContext)(ProfitAndLoss.Context);
|
|
21840
|
+
const { getProfitAndLossComparisonCsv } = (0, import_react102.useContext)(
|
|
21649
21841
|
ProfitAndLoss.ComparisonContext
|
|
21650
21842
|
);
|
|
21651
21843
|
const { businessId } = useLayerContext();
|
|
21652
21844
|
const { apiUrl } = useEnvironment();
|
|
21653
21845
|
const { data: auth } = useAuth();
|
|
21654
|
-
const [requestFailed, setRequestFailed] = (0,
|
|
21655
|
-
const [isDownloading, setIsDownloading] = (0,
|
|
21846
|
+
const [requestFailed, setRequestFailed] = (0, import_react102.useState)(false);
|
|
21847
|
+
const [isDownloading, setIsDownloading] = (0, import_react102.useState)(false);
|
|
21656
21848
|
const handleClick = () => __async(null, null, function* () {
|
|
21657
21849
|
var _a;
|
|
21658
21850
|
setIsDownloading(true);
|
|
@@ -21696,7 +21888,7 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21696
21888
|
};
|
|
21697
21889
|
|
|
21698
21890
|
// src/components/ProfitAndLossHeader/ProfitAndLossHeader.tsx
|
|
21699
|
-
var
|
|
21891
|
+
var import_react104 = require("react");
|
|
21700
21892
|
|
|
21701
21893
|
// src/components/SyncingBadge/SyncingBadge.tsx
|
|
21702
21894
|
var import_jsx_runtime179 = require("react/jsx-runtime");
|
|
@@ -21713,120 +21905,13 @@ var SyncingBadge = () => {
|
|
|
21713
21905
|
};
|
|
21714
21906
|
|
|
21715
21907
|
// src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
|
|
21716
|
-
var
|
|
21717
|
-
|
|
21718
|
-
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21719
|
-
var import_swr15 = __toESM(require("swr"));
|
|
21720
|
-
|
|
21721
|
-
// src/utils/bookkeeping/bookkeepingStatusFilters.ts
|
|
21722
|
-
function isActiveBookkeepingStatus(status) {
|
|
21723
|
-
return status === "ACTIVE" || status === "ONBOARDING";
|
|
21724
|
-
}
|
|
21725
|
-
function isActiveOrPausedBookkeepingStatus(status) {
|
|
21726
|
-
return isActiveBookkeepingStatus(status) || status === "BOOKKEEPING_PAUSED";
|
|
21727
|
-
}
|
|
21728
|
-
|
|
21729
|
-
// src/utils/bookkeeping/tasks/bookkeepingTasksFilters.ts
|
|
21730
|
-
function isIncompleteTask(task) {
|
|
21731
|
-
const { status } = task;
|
|
21732
|
-
return status === "TODO";
|
|
21733
|
-
}
|
|
21734
|
-
function getIncompleteTasks(tasks) {
|
|
21735
|
-
return tasks.filter((task) => isIncompleteTask(task));
|
|
21736
|
-
}
|
|
21737
|
-
function isUserVisibleTask(task) {
|
|
21738
|
-
const { status } = task;
|
|
21739
|
-
return status !== "COMPLETED" && status !== "ARCHIVED";
|
|
21740
|
-
}
|
|
21741
|
-
function getUserVisibleTasks(tasks) {
|
|
21742
|
-
return tasks.filter((task) => isUserVisibleTask(task));
|
|
21743
|
-
}
|
|
21744
|
-
function isCompletedTask(task) {
|
|
21745
|
-
const { status } = task;
|
|
21746
|
-
return status === "USER_MARKED_COMPLETED" || status === "COMPLETED" || status === "ARCHIVED";
|
|
21747
|
-
}
|
|
21748
|
-
function getCompletedTasks(tasks) {
|
|
21749
|
-
return tasks.filter((task) => isCompletedTask(task));
|
|
21750
|
-
}
|
|
21751
|
-
|
|
21752
|
-
// src/utils/bookkeeping/periods/getFilteredBookkeepingPeriods.ts
|
|
21753
|
-
function isActiveBookkeepingPeriod(period) {
|
|
21754
|
-
return period.status !== "BOOKKEEPING_NOT_ACTIVE";
|
|
21755
|
-
}
|
|
21756
|
-
|
|
21757
|
-
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21758
|
-
var BOOKKEEPING_PERIOD_STATUSES = [
|
|
21759
|
-
"BOOKKEEPING_NOT_ACTIVE",
|
|
21760
|
-
"NOT_STARTED",
|
|
21761
|
-
"IN_PROGRESS_AWAITING_BOOKKEEPER",
|
|
21762
|
-
"IN_PROGRESS_AWAITING_CUSTOMER",
|
|
21763
|
-
"CLOSING_IN_REVIEW",
|
|
21764
|
-
"CLOSED_OPEN_TASKS",
|
|
21765
|
-
"CLOSED_COMPLETE"
|
|
21766
|
-
];
|
|
21767
|
-
function constrainToKnownBookkeepingPeriodStatus(status) {
|
|
21768
|
-
if (BOOKKEEPING_PERIOD_STATUSES.includes(status)) {
|
|
21769
|
-
return status;
|
|
21770
|
-
}
|
|
21771
|
-
return "BOOKKEEPING_NOT_ACTIVE";
|
|
21772
|
-
}
|
|
21773
|
-
var getBookkeepingPeriods = get(({ businessId }) => {
|
|
21774
|
-
return `/v1/businesses/${businessId}/bookkeeping/periods`;
|
|
21775
|
-
});
|
|
21776
|
-
var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
|
|
21777
|
-
function buildKey14({
|
|
21778
|
-
access_token: accessToken,
|
|
21779
|
-
apiUrl,
|
|
21780
|
-
businessId,
|
|
21781
|
-
isActiveOrPaused
|
|
21782
|
-
}) {
|
|
21783
|
-
if (accessToken && apiUrl && isActiveOrPaused) {
|
|
21784
|
-
return {
|
|
21785
|
-
accessToken,
|
|
21786
|
-
apiUrl,
|
|
21787
|
-
businessId,
|
|
21788
|
-
tags: [BOOKKEEPING_TAG_KEY, BOOKKEEPING_PERIODS_TAG_KEY]
|
|
21789
|
-
};
|
|
21790
|
-
}
|
|
21791
|
-
}
|
|
21792
|
-
function useBookkeepingPeriods() {
|
|
21793
|
-
const { data: auth } = useAuth();
|
|
21794
|
-
const { businessId } = useLayerContext();
|
|
21795
|
-
const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
|
|
21796
|
-
const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
|
|
21797
|
-
const swrResponse = (0, import_swr15.default)(
|
|
21798
|
-
() => buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
21799
|
-
businessId,
|
|
21800
|
-
isActiveOrPaused
|
|
21801
|
-
})),
|
|
21802
|
-
({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingPeriods(
|
|
21803
|
-
apiUrl,
|
|
21804
|
-
accessToken,
|
|
21805
|
-
{ params: { businessId: businessId2 } }
|
|
21806
|
-
)().then(
|
|
21807
|
-
({ data: { periods } }) => periods.map((period) => __spreadProps(__spreadValues({}, period), {
|
|
21808
|
-
status: constrainToKnownBookkeepingPeriodStatus(period.status),
|
|
21809
|
-
tasks: getUserVisibleTasks(period.tasks)
|
|
21810
|
-
})).filter((period) => isActiveBookkeepingPeriod(period))
|
|
21811
|
-
)
|
|
21812
|
-
);
|
|
21813
|
-
return new Proxy(swrResponse, {
|
|
21814
|
-
get(target, prop) {
|
|
21815
|
-
if (prop === "isLoading") {
|
|
21816
|
-
return isLoadingBookkeepingStatus || swrResponse.isLoading;
|
|
21817
|
-
}
|
|
21818
|
-
return Reflect.get(target, prop);
|
|
21819
|
-
}
|
|
21820
|
-
});
|
|
21821
|
-
}
|
|
21822
|
-
|
|
21823
|
-
// src/hooks/bookkeeping/periods/useActiveBookkeepingPeriod.ts
|
|
21908
|
+
var import_react103 = require("react");
|
|
21824
21909
|
function useActiveBookkeepingPeriod() {
|
|
21825
21910
|
const { date } = useGlobalDate();
|
|
21826
21911
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
21827
21912
|
const currentMonth = date.getMonth() + 1;
|
|
21828
21913
|
const currentYear = date.getFullYear();
|
|
21829
|
-
const activePeriod = (0,
|
|
21914
|
+
const activePeriod = (0, import_react103.useMemo)(
|
|
21830
21915
|
() => data == null ? void 0 : data.find((period) => currentYear === period.year && currentMonth === period.month),
|
|
21831
21916
|
[data, currentMonth, currentYear]
|
|
21832
21917
|
);
|
|
@@ -21845,7 +21930,7 @@ var ProfitAndLossHeader = ({
|
|
|
21845
21930
|
const { data: linkedAccounts } = useLinkedAccounts();
|
|
21846
21931
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
21847
21932
|
const activePeriodStatus = activePeriod == null ? void 0 : activePeriod.status;
|
|
21848
|
-
const isSyncing = (0,
|
|
21933
|
+
const isSyncing = (0, import_react104.useMemo)(
|
|
21849
21934
|
() => Boolean(linkedAccounts == null ? void 0 : linkedAccounts.some((item) => item.is_syncing)),
|
|
21850
21935
|
[linkedAccounts]
|
|
21851
21936
|
);
|
|
@@ -21853,20 +21938,20 @@ var ProfitAndLossHeader = ({
|
|
|
21853
21938
|
/* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("span", { className: "Layer__component-header__title-wrapper Layer__profit-and-loss__header", children: [
|
|
21854
21939
|
/* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Heading, { size: "secondary" /* secondary */, className: headingClassName, align: "left", children: text || "Profit & Loss" }),
|
|
21855
21940
|
isSyncing && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SyncingBadge, {}),
|
|
21856
|
-
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 }) })
|
|
21857
21942
|
] }),
|
|
21858
21943
|
withDatePicker && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ProfitAndLoss.DatePicker, {})
|
|
21859
21944
|
] });
|
|
21860
21945
|
};
|
|
21861
21946
|
|
|
21862
21947
|
// src/components/ProfitAndLossReport/ProfitAndLossReport.tsx
|
|
21863
|
-
var
|
|
21948
|
+
var import_react108 = require("react");
|
|
21864
21949
|
|
|
21865
21950
|
// src/components/Header/Header.tsx
|
|
21866
|
-
var
|
|
21951
|
+
var import_react105 = require("react");
|
|
21867
21952
|
var import_classnames56 = __toESM(require("classnames"));
|
|
21868
21953
|
var import_jsx_runtime181 = require("react/jsx-runtime");
|
|
21869
|
-
var Header3 = (0,
|
|
21954
|
+
var Header3 = (0, import_react105.forwardRef)(
|
|
21870
21955
|
({ className, children, style, sticky, asHeader, rounded }, ref) => {
|
|
21871
21956
|
const baseClassName = (0, import_classnames56.default)(
|
|
21872
21957
|
"Layer__header",
|
|
@@ -21907,7 +21992,7 @@ var HeaderCol = ({ className, children, style, noPadding = false }) => {
|
|
|
21907
21992
|
};
|
|
21908
21993
|
|
|
21909
21994
|
// src/components/Panel/Panel.tsx
|
|
21910
|
-
var
|
|
21995
|
+
var import_react106 = require("react");
|
|
21911
21996
|
var import_classnames59 = __toESM(require("classnames"));
|
|
21912
21997
|
var import_jsx_runtime184 = require("react/jsx-runtime");
|
|
21913
21998
|
var Panel = ({
|
|
@@ -21921,8 +22006,8 @@ var Panel = ({
|
|
|
21921
22006
|
floating = false
|
|
21922
22007
|
}) => {
|
|
21923
22008
|
var _a;
|
|
21924
|
-
const [sidebarHeight, setSidebarHeight] = (0,
|
|
21925
|
-
(0,
|
|
22009
|
+
const [sidebarHeight, setSidebarHeight] = (0, import_react106.useState)(0);
|
|
22010
|
+
(0, import_react106.useEffect)(() => {
|
|
21926
22011
|
var _a2, _b;
|
|
21927
22012
|
if ((_a2 = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _a2.offsetHeight) {
|
|
21928
22013
|
setSidebarHeight((_b = parentRef == null ? void 0 : parentRef.current) == null ? void 0 : _b.offsetHeight);
|
|
@@ -21962,7 +22047,7 @@ var Panel = ({
|
|
|
21962
22047
|
};
|
|
21963
22048
|
|
|
21964
22049
|
// src/components/View/View.tsx
|
|
21965
|
-
var
|
|
22050
|
+
var import_react107 = require("react");
|
|
21966
22051
|
|
|
21967
22052
|
// src/components/ViewHeader/ViewHeader.tsx
|
|
21968
22053
|
var import_classnames60 = __toESM(require("classnames"));
|
|
@@ -21977,7 +22062,7 @@ var ViewHeader = ({ title, className, children }) => {
|
|
|
21977
22062
|
// src/components/View/View.tsx
|
|
21978
22063
|
var import_classnames61 = __toESM(require("classnames"));
|
|
21979
22064
|
var import_jsx_runtime186 = require("react/jsx-runtime");
|
|
21980
|
-
var View = (0,
|
|
22065
|
+
var View = (0, import_react107.forwardRef)(
|
|
21981
22066
|
({
|
|
21982
22067
|
title,
|
|
21983
22068
|
showHeader = true,
|
|
@@ -22028,8 +22113,8 @@ var ProfitAndLossReport = ({
|
|
|
22028
22113
|
view
|
|
22029
22114
|
}) => {
|
|
22030
22115
|
var _a, _b;
|
|
22031
|
-
const { sidebarScope } = (0,
|
|
22032
|
-
const { comparisonConfig } = (0,
|
|
22116
|
+
const { sidebarScope } = (0, import_react108.useContext)(ProfitAndLoss.Context);
|
|
22117
|
+
const { comparisonConfig } = (0, import_react108.useContext)(ProfitAndLoss.ComparisonContext);
|
|
22033
22118
|
return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
|
|
22034
22119
|
View,
|
|
22035
22120
|
{
|
|
@@ -22086,10 +22171,10 @@ var ProfitAndLossReport = ({
|
|
|
22086
22171
|
};
|
|
22087
22172
|
|
|
22088
22173
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
22089
|
-
var
|
|
22174
|
+
var import_react112 = require("react");
|
|
22090
22175
|
|
|
22091
22176
|
// src/components/ProfitAndLossSummaries/internal/ProfitAndLossSummariesList.tsx
|
|
22092
|
-
var
|
|
22177
|
+
var import_react109 = require("react");
|
|
22093
22178
|
var import_jsx_runtime188 = require("react/jsx-runtime");
|
|
22094
22179
|
var LIST_ITEM_CLASS_NAME = "Layer__ProfitAndLossSummariesListItem";
|
|
22095
22180
|
function ProfitAndLossSummariesListItem({
|
|
@@ -22097,7 +22182,7 @@ function ProfitAndLossSummariesListItem({
|
|
|
22097
22182
|
isActive,
|
|
22098
22183
|
onClick
|
|
22099
22184
|
}) {
|
|
22100
|
-
const dataProperties = (0,
|
|
22185
|
+
const dataProperties = (0, import_react109.useMemo)(
|
|
22101
22186
|
() => toDataProperties({ active: isActive, clickable: !!onClick }),
|
|
22102
22187
|
[isActive]
|
|
22103
22188
|
);
|
|
@@ -22108,7 +22193,7 @@ function ProfitAndLossSummariesList({
|
|
|
22108
22193
|
children,
|
|
22109
22194
|
itemCount
|
|
22110
22195
|
}) {
|
|
22111
|
-
const dataProperties = (0,
|
|
22196
|
+
const dataProperties = (0, import_react109.useMemo)(
|
|
22112
22197
|
() => toDataProperties({ ["column-count"]: itemCount }),
|
|
22113
22198
|
[itemCount]
|
|
22114
22199
|
);
|
|
@@ -22201,10 +22286,10 @@ function ProfitAndLossSummariesMiniChart({
|
|
|
22201
22286
|
}
|
|
22202
22287
|
|
|
22203
22288
|
// src/components/ui/Typography/MoneyText.tsx
|
|
22204
|
-
var
|
|
22289
|
+
var import_react110 = require("react");
|
|
22205
22290
|
var import_jsx_runtime190 = require("react/jsx-runtime");
|
|
22206
22291
|
var CLASS_NAME10 = "Layer__MoneyText";
|
|
22207
|
-
var MoneySpan = (0,
|
|
22292
|
+
var MoneySpan = (0, import_react110.forwardRef)(
|
|
22208
22293
|
(_a, ref) => {
|
|
22209
22294
|
var _b = _a, { amount, bold, size } = _b, restProps = __objRest(_b, ["amount", "bold", "size"]);
|
|
22210
22295
|
const dataProperties = toDataProperties({
|
|
@@ -22251,8 +22336,8 @@ function ProfitAndLossSummariesSummary({
|
|
|
22251
22336
|
}
|
|
22252
22337
|
|
|
22253
22338
|
// src/views/AccountingOverview/internal/TransactionsToReview.tsx
|
|
22254
|
-
var
|
|
22255
|
-
var
|
|
22339
|
+
var import_react111 = require("react");
|
|
22340
|
+
var import_date_fns30 = require("date-fns");
|
|
22256
22341
|
var import_jsx_runtime193 = require("react/jsx-runtime");
|
|
22257
22342
|
var CLASS_NAME12 = "Layer__TransactionsToReview";
|
|
22258
22343
|
function TransactionsToReview({
|
|
@@ -22262,23 +22347,23 @@ function TransactionsToReview({
|
|
|
22262
22347
|
variants
|
|
22263
22348
|
}) {
|
|
22264
22349
|
const { size = "sm" } = variants != null ? variants : {};
|
|
22265
|
-
const { dateRange: contextDateRange } = (0,
|
|
22350
|
+
const { dateRange: contextDateRange } = (0, import_react111.useContext)(ProfitAndLoss.Context);
|
|
22266
22351
|
const dateRange = usePnlDateRange ? contextDateRange : void 0;
|
|
22267
|
-
const [toReview, setToReview] = (0,
|
|
22352
|
+
const [toReview, setToReview] = (0, import_react111.useState)(0);
|
|
22268
22353
|
const { data, loaded, error, refetch } = useProfitAndLossLTM({
|
|
22269
|
-
currentDate: dateRange ? dateRange.startDate : (0,
|
|
22354
|
+
currentDate: dateRange ? dateRange.startDate : (0, import_date_fns30.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
22270
22355
|
tagFilter
|
|
22271
22356
|
});
|
|
22272
|
-
(0,
|
|
22357
|
+
(0, import_react111.useEffect)(() => {
|
|
22273
22358
|
checkTransactionsToReview();
|
|
22274
22359
|
}, []);
|
|
22275
|
-
(0,
|
|
22360
|
+
(0, import_react111.useEffect)(() => {
|
|
22276
22361
|
checkTransactionsToReview();
|
|
22277
22362
|
}, [dateRange, loaded]);
|
|
22278
22363
|
const checkTransactionsToReview = () => {
|
|
22279
22364
|
if (data && dateRange) {
|
|
22280
22365
|
const monthTx = data.filter(
|
|
22281
|
-
(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)
|
|
22282
22367
|
);
|
|
22283
22368
|
if (monthTx.length > 0) {
|
|
22284
22369
|
setToReview(monthTx[0].uncategorized_transactions);
|
|
@@ -22353,8 +22438,8 @@ function Internal_ProfitAndLossSummaries({
|
|
|
22353
22438
|
isLoading,
|
|
22354
22439
|
setSidebarScope,
|
|
22355
22440
|
sidebarScope
|
|
22356
|
-
} = (0,
|
|
22357
|
-
const { revenueChartData, expensesChartData } = (0,
|
|
22441
|
+
} = (0, import_react112.useContext)(ProfitAndLoss.Context);
|
|
22442
|
+
const { revenueChartData, expensesChartData } = (0, import_react112.useMemo)(
|
|
22358
22443
|
() => ({
|
|
22359
22444
|
revenueChartData: toMiniChartData({ scope: "revenue", data }),
|
|
22360
22445
|
expensesChartData: toMiniChartData({ scope: "expenses", data })
|
|
@@ -22456,10 +22541,10 @@ function ProfitAndLossSummaries(_a) {
|
|
|
22456
22541
|
}
|
|
22457
22542
|
|
|
22458
22543
|
// src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
|
|
22459
|
-
var
|
|
22544
|
+
var import_react118 = require("react");
|
|
22460
22545
|
|
|
22461
22546
|
// src/contexts/TableContext/TableContext.tsx
|
|
22462
|
-
var
|
|
22547
|
+
var import_react113 = require("react");
|
|
22463
22548
|
var import_jsx_runtime195 = require("react/jsx-runtime");
|
|
22464
22549
|
var defaultValue = {
|
|
22465
22550
|
expandedRows: [],
|
|
@@ -22471,10 +22556,10 @@ var defaultValue = {
|
|
|
22471
22556
|
setExpandedAllRows: () => {
|
|
22472
22557
|
}
|
|
22473
22558
|
};
|
|
22474
|
-
var TableContext = (0,
|
|
22559
|
+
var TableContext = (0, import_react113.createContext)(defaultValue);
|
|
22475
22560
|
var TableProvider = ({ children }) => {
|
|
22476
|
-
const [expandedRows, setExpandedRowsState] = (0,
|
|
22477
|
-
const [expandedAllRows, setExpandedAllRows] = (0,
|
|
22561
|
+
const [expandedRows, setExpandedRowsState] = (0, import_react113.useState)([]);
|
|
22562
|
+
const [expandedAllRows, setExpandedAllRows] = (0, import_react113.useState)(false);
|
|
22478
22563
|
const toggleRow = (rowKey) => {
|
|
22479
22564
|
setExpandedRowsState((prevRows) => {
|
|
22480
22565
|
const rows = [...prevRows];
|
|
@@ -22500,10 +22585,10 @@ var TableProvider = ({ children }) => {
|
|
|
22500
22585
|
};
|
|
22501
22586
|
|
|
22502
22587
|
// src/components/ProfitAndLossTable/ProfitAndLossCompareTable.tsx
|
|
22503
|
-
var
|
|
22588
|
+
var import_react116 = require("react");
|
|
22504
22589
|
|
|
22505
22590
|
// src/hooks/useTableExpandRow/useTableExpandRow.tsx
|
|
22506
|
-
var
|
|
22591
|
+
var import_react114 = require("react");
|
|
22507
22592
|
var useTableExpandRow = () => {
|
|
22508
22593
|
const {
|
|
22509
22594
|
expandedAllRows,
|
|
@@ -22511,7 +22596,7 @@ var useTableExpandRow = () => {
|
|
|
22511
22596
|
expandAllRows,
|
|
22512
22597
|
expandedRows,
|
|
22513
22598
|
setExpandedRows
|
|
22514
|
-
} = (0,
|
|
22599
|
+
} = (0, import_react114.useContext)(TableContext);
|
|
22515
22600
|
const toggleAllRows = () => {
|
|
22516
22601
|
if (expandedAllRows) {
|
|
22517
22602
|
setIsOpen([]);
|
|
@@ -22539,7 +22624,7 @@ var useTableExpandRow = () => {
|
|
|
22539
22624
|
};
|
|
22540
22625
|
|
|
22541
22626
|
// src/utils/profitAndLossComparisonUtils.ts
|
|
22542
|
-
var
|
|
22627
|
+
var import_date_fns31 = require("date-fns");
|
|
22543
22628
|
var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) => {
|
|
22544
22629
|
switch (rangeDisplayMode) {
|
|
22545
22630
|
case "yearPicker":
|
|
@@ -22550,14 +22635,14 @@ var generateComparisonPeriods = (startDate, numberOfPeriods, rangeDisplayMode) =
|
|
|
22550
22635
|
};
|
|
22551
22636
|
var generateComparisonMonths = (startDate, numberOfMonths) => {
|
|
22552
22637
|
return Array.from({ length: numberOfMonths }, (_, index) => {
|
|
22553
|
-
const currentMonth = (0,
|
|
22554
|
-
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") };
|
|
22555
22640
|
});
|
|
22556
22641
|
};
|
|
22557
22642
|
var generateComparisonYears = (startDate, numberOfYears) => {
|
|
22558
22643
|
return Array.from({ length: numberOfYears }, (_, index) => {
|
|
22559
|
-
const currentMonth = (0,
|
|
22560
|
-
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") };
|
|
22561
22646
|
});
|
|
22562
22647
|
};
|
|
22563
22648
|
var getComparisonValue = (name, depth, cellData) => {
|
|
@@ -22732,7 +22817,7 @@ var TableRow = ({
|
|
|
22732
22817
|
};
|
|
22733
22818
|
|
|
22734
22819
|
// src/components/Table/Table.tsx
|
|
22735
|
-
var
|
|
22820
|
+
var import_react115 = require("react");
|
|
22736
22821
|
var import_classnames64 = __toESM(require("classnames"));
|
|
22737
22822
|
var import_jsx_runtime200 = require("react/jsx-runtime");
|
|
22738
22823
|
var Table = ({
|
|
@@ -22741,9 +22826,9 @@ var Table = ({
|
|
|
22741
22826
|
borderCollapse = "separate",
|
|
22742
22827
|
bottomSpacing = true
|
|
22743
22828
|
}) => {
|
|
22744
|
-
const tableRef = (0,
|
|
22745
|
-
const prevChildrenRef = (0,
|
|
22746
|
-
(0,
|
|
22829
|
+
const tableRef = (0, import_react115.useRef)(null);
|
|
22830
|
+
const prevChildrenRef = (0, import_react115.useRef)([]);
|
|
22831
|
+
(0, import_react115.useEffect)(() => {
|
|
22747
22832
|
if (tableRef.current) {
|
|
22748
22833
|
const tbody = tableRef.current.querySelector("tbody");
|
|
22749
22834
|
const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
|
|
@@ -22792,17 +22877,17 @@ var import_jsx_runtime201 = require("react/jsx-runtime");
|
|
|
22792
22877
|
var ProfitAndLossCompareTable = ({
|
|
22793
22878
|
stringOverrides
|
|
22794
22879
|
}) => {
|
|
22795
|
-
const { dateRange } = (0,
|
|
22880
|
+
const { dateRange } = (0, import_react116.useContext)(ProfitAndLoss.Context);
|
|
22796
22881
|
const {
|
|
22797
22882
|
data: comparisonData,
|
|
22798
22883
|
isLoading,
|
|
22799
22884
|
comparePeriods,
|
|
22800
22885
|
selectedCompareOptions
|
|
22801
|
-
} = (0,
|
|
22886
|
+
} = (0, import_react116.useContext)(ProfitAndLoss.ComparisonContext);
|
|
22802
22887
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
22803
22888
|
const { rangeDisplayMode } = useGlobalDateRange();
|
|
22804
22889
|
const { data: bookkeepingPeriods } = useBookkeepingPeriods();
|
|
22805
|
-
(0,
|
|
22890
|
+
(0, import_react116.useEffect)(() => {
|
|
22806
22891
|
setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
|
|
22807
22892
|
}, []);
|
|
22808
22893
|
if (isLoading || comparisonData === void 0) {
|
|
@@ -22826,7 +22911,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22826
22911
|
if (!period) {
|
|
22827
22912
|
return;
|
|
22828
22913
|
}
|
|
22829
|
-
return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
|
|
22914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BookkeepingStatus2, { status: period.status, monthNumber: currentMonth, iconOnly: true });
|
|
22830
22915
|
};
|
|
22831
22916
|
const renderRow = (rowKey, depth, rowDisplayName, lineItem, data) => {
|
|
22832
22917
|
const rowData = data ? data : [];
|
|
@@ -22846,7 +22931,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22846
22931
|
}
|
|
22847
22932
|
const expandable = (lineItem == null ? void 0 : lineItem.line_items) && lineItem.line_items.length > 0 ? true : false;
|
|
22848
22933
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
22849
|
-
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
|
|
22934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(import_react116.Fragment, { children: [
|
|
22850
22935
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(
|
|
22851
22936
|
TableRow,
|
|
22852
22937
|
{
|
|
@@ -22880,7 +22965,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22880
22965
|
return /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(Table, { borderCollapse: "collapse", bottomSpacing: false, children: [
|
|
22881
22966
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableHead, { children: selectedCompareOptions && selectedCompareOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
|
|
22882
22967
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
|
|
22883
|
-
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: [
|
|
22884
22969
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { primary: true, isHeaderCell: true, children: option.displayName }, option.displayName + "-" + i),
|
|
22885
22970
|
comparePeriods && Array.from({ length: comparePeriods - 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }, option.displayName + "-" + index))
|
|
22886
22971
|
] }, option.displayName + "-" + i))
|
|
@@ -22888,7 +22973,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22888
22973
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableBody, { children: [
|
|
22889
22974
|
comparePeriods && /* @__PURE__ */ (0, import_jsx_runtime201.jsxs)(TableRow, { rowKey: "", children: [
|
|
22890
22975
|
/* @__PURE__ */ (0, import_jsx_runtime201.jsx)(TableCell, { isHeaderCell: true }),
|
|
22891
|
-
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(
|
|
22892
22977
|
dateRange.startDate,
|
|
22893
22978
|
comparePeriods,
|
|
22894
22979
|
rangeDisplayMode
|
|
@@ -22896,7 +22981,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22896
22981
|
month.label,
|
|
22897
22982
|
" ",
|
|
22898
22983
|
getBookkeepingPeriodStatus(month.date)
|
|
22899
|
-
] }) }, 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(
|
|
22900
22985
|
dateRange.startDate,
|
|
22901
22986
|
comparePeriods,
|
|
22902
22987
|
rangeDisplayMode
|
|
@@ -22928,7 +23013,7 @@ var ProfitAndLossCompareTable = ({
|
|
|
22928
23013
|
};
|
|
22929
23014
|
|
|
22930
23015
|
// src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
|
|
22931
|
-
var
|
|
23016
|
+
var import_react117 = require("react");
|
|
22932
23017
|
|
|
22933
23018
|
// src/icons/PieChart.tsx
|
|
22934
23019
|
var import_jsx_runtime202 = require("react/jsx-runtime");
|
|
@@ -23027,9 +23112,9 @@ var ProfitAndLossTableComponent = ({
|
|
|
23027
23112
|
data: actualData,
|
|
23028
23113
|
isLoading,
|
|
23029
23114
|
setSidebarScope
|
|
23030
|
-
} = (0,
|
|
23115
|
+
} = (0, import_react117.useContext)(ProfitAndLoss.Context);
|
|
23031
23116
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
23032
|
-
(0,
|
|
23117
|
+
(0, import_react117.useEffect)(() => {
|
|
23033
23118
|
setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
|
|
23034
23119
|
}, []);
|
|
23035
23120
|
const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
|
|
@@ -23049,7 +23134,7 @@ var ProfitAndLossTableComponent = ({
|
|
|
23049
23134
|
const renderLineItem = (lineItem, depth, rowKey, rowIndex, scope, setSidebarScope2, variant) => {
|
|
23050
23135
|
const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
|
|
23051
23136
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
23052
|
-
return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
|
|
23137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_react117.Fragment, { children: [
|
|
23053
23138
|
/* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
|
|
23054
23139
|
TableRow,
|
|
23055
23140
|
{
|
|
@@ -23167,14 +23252,14 @@ var ProfitAndLossTableComponent = ({
|
|
|
23167
23252
|
// src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
|
|
23168
23253
|
var import_jsx_runtime204 = require("react/jsx-runtime");
|
|
23169
23254
|
var ProfitAndLossTableWithProvider = (props) => {
|
|
23170
|
-
const { compareModeActive } = (0,
|
|
23255
|
+
const { compareModeActive } = (0, import_react118.useContext)(ProfitAndLoss.ComparisonContext);
|
|
23171
23256
|
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)) });
|
|
23172
23257
|
};
|
|
23173
23258
|
|
|
23174
23259
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
23175
|
-
var
|
|
23260
|
+
var import_date_fns32 = require("date-fns");
|
|
23176
23261
|
var import_jsx_runtime205 = require("react/jsx-runtime");
|
|
23177
|
-
var PNLContext = (0,
|
|
23262
|
+
var PNLContext = (0, import_react119.createContext)({
|
|
23178
23263
|
data: void 0,
|
|
23179
23264
|
filteredDataRevenue: [],
|
|
23180
23265
|
filteredTotalRevenue: void 0,
|
|
@@ -23184,8 +23269,8 @@ var PNLContext = (0, import_react118.createContext)({
|
|
|
23184
23269
|
isValidating: false,
|
|
23185
23270
|
error: void 0,
|
|
23186
23271
|
dateRange: {
|
|
23187
|
-
startDate: (0,
|
|
23188
|
-
endDate: (0,
|
|
23272
|
+
startDate: (0, import_date_fns32.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
23273
|
+
endDate: (0, import_date_fns32.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23189
23274
|
},
|
|
23190
23275
|
changeDateRange: () => {
|
|
23191
23276
|
},
|
|
@@ -23229,7 +23314,7 @@ ProfitAndLoss.DownloadButton = ProfitAndLossDownloadButton;
|
|
|
23229
23314
|
|
|
23230
23315
|
// src/hooks/balanceSheet/useBalanceSheet.ts
|
|
23231
23316
|
var import_swr16 = __toESM(require("swr"));
|
|
23232
|
-
var
|
|
23317
|
+
var import_date_fns33 = require("date-fns");
|
|
23233
23318
|
function buildKey15({
|
|
23234
23319
|
access_token: accessToken,
|
|
23235
23320
|
apiUrl,
|
|
@@ -23247,7 +23332,7 @@ function buildKey15({
|
|
|
23247
23332
|
}
|
|
23248
23333
|
}
|
|
23249
23334
|
function useBalanceSheet({
|
|
23250
|
-
effectiveDate = (0,
|
|
23335
|
+
effectiveDate = (0, import_date_fns33.endOfDay)(/* @__PURE__ */ new Date())
|
|
23251
23336
|
}) {
|
|
23252
23337
|
const { data: auth } = useAuth();
|
|
23253
23338
|
const { apiUrl } = useEnvironment();
|
|
@@ -23272,12 +23357,12 @@ function useBalanceSheet({
|
|
|
23272
23357
|
}
|
|
23273
23358
|
|
|
23274
23359
|
// src/hooks/useElementViewSize/useElementViewSize.tsx
|
|
23275
|
-
var
|
|
23360
|
+
var import_react120 = require("react");
|
|
23276
23361
|
var useElementViewSize = () => {
|
|
23277
|
-
const containerRef = (0,
|
|
23278
|
-
const [view, setView] = (0,
|
|
23279
|
-
const resizeTimeout = (0,
|
|
23280
|
-
(0,
|
|
23362
|
+
const containerRef = (0, import_react120.useRef)(null);
|
|
23363
|
+
const [view, setView] = (0, import_react120.useState)("desktop");
|
|
23364
|
+
const resizeTimeout = (0, import_react120.useRef)(null);
|
|
23365
|
+
(0, import_react120.useLayoutEffect)(() => {
|
|
23281
23366
|
const element = containerRef == null ? void 0 : containerRef.current;
|
|
23282
23367
|
if (!element) {
|
|
23283
23368
|
return;
|
|
@@ -23346,7 +23431,7 @@ var BalanceSheetExpandAllButton = ({
|
|
|
23346
23431
|
};
|
|
23347
23432
|
|
|
23348
23433
|
// src/components/BalanceSheetTable/BalanceSheetTable.tsx
|
|
23349
|
-
var
|
|
23434
|
+
var import_react121 = require("react");
|
|
23350
23435
|
var import_jsx_runtime208 = require("react/jsx-runtime");
|
|
23351
23436
|
var BalanceSheetTable = ({
|
|
23352
23437
|
data,
|
|
@@ -23355,12 +23440,12 @@ var BalanceSheetTable = ({
|
|
|
23355
23440
|
}) => {
|
|
23356
23441
|
const { isOpen, setIsOpen, expandedAllRows } = useTableExpandRow();
|
|
23357
23442
|
const allRowKeys = [];
|
|
23358
|
-
(0,
|
|
23443
|
+
(0, import_react121.useEffect)(() => {
|
|
23359
23444
|
if (expandedAllRows) {
|
|
23360
23445
|
setIsOpen(allRowKeys, true);
|
|
23361
23446
|
}
|
|
23362
23447
|
}, [expandedAllRows]);
|
|
23363
|
-
(0,
|
|
23448
|
+
(0, import_react121.useEffect)(() => {
|
|
23364
23449
|
setIsOpen(["assets"]);
|
|
23365
23450
|
}, []);
|
|
23366
23451
|
const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
|
|
@@ -23370,7 +23455,7 @@ var BalanceSheetTable = ({
|
|
|
23370
23455
|
if (expandable) {
|
|
23371
23456
|
allRowKeys.push(rowKey);
|
|
23372
23457
|
}
|
|
23373
|
-
return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
|
|
23458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_react121.Fragment, { children: [
|
|
23374
23459
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(
|
|
23375
23460
|
TableRow,
|
|
23376
23461
|
{
|
|
@@ -23421,7 +23506,7 @@ var BalanceSheetTable = ({
|
|
|
23421
23506
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, children: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type" }),
|
|
23422
23507
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableCell, { isHeaderCell: true, align: "right" /* RIGHT */, children: (stringOverrides == null ? void 0 : stringOverrides.totalColumnHeader) || "Total" })
|
|
23423
23508
|
] }) }),
|
|
23424
|
-
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(TableBody, { children: config.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
|
|
23509
|
+
/* @__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(
|
|
23425
23510
|
data[row.lineItem],
|
|
23426
23511
|
0,
|
|
23427
23512
|
row.lineItem,
|
|
@@ -23595,7 +23680,7 @@ var BalanceSheetView = ({
|
|
|
23595
23680
|
};
|
|
23596
23681
|
|
|
23597
23682
|
// src/components/StatementOfCashFlowTable/StatementOfCashFlowTable.tsx
|
|
23598
|
-
var
|
|
23683
|
+
var import_react122 = require("react");
|
|
23599
23684
|
var import_jsx_runtime211 = require("react/jsx-runtime");
|
|
23600
23685
|
var StatementOfCashFlowTable = ({
|
|
23601
23686
|
data,
|
|
@@ -23606,7 +23691,7 @@ var StatementOfCashFlowTable = ({
|
|
|
23606
23691
|
const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
|
|
23607
23692
|
const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
|
|
23608
23693
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
23609
|
-
return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
|
|
23694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(import_react122.Fragment, { children: [
|
|
23610
23695
|
/* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
|
|
23611
23696
|
TableRow,
|
|
23612
23697
|
{
|
|
@@ -23658,7 +23743,7 @@ var StatementOfCashFlowTable = ({
|
|
|
23658
23743
|
] }) }),
|
|
23659
23744
|
/* @__PURE__ */ (0, import_jsx_runtime211.jsx)(TableBody, { children: config.map((row, idx) => {
|
|
23660
23745
|
if (row.type === "line_item") {
|
|
23661
|
-
return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
|
|
23746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_react122.Fragment, { children: data[row.lineItem] && renderLineItem(
|
|
23662
23747
|
data[row.lineItem],
|
|
23663
23748
|
0,
|
|
23664
23749
|
row.lineItem ? row.lineItem : "",
|
|
@@ -23864,7 +23949,7 @@ function StatementOfCashFlowDatePicker({
|
|
|
23864
23949
|
|
|
23865
23950
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
23866
23951
|
var import_swr17 = __toESM(require("swr"));
|
|
23867
|
-
var
|
|
23952
|
+
var import_date_fns34 = require("date-fns");
|
|
23868
23953
|
function buildKey18({
|
|
23869
23954
|
access_token: accessToken,
|
|
23870
23955
|
apiUrl,
|
|
@@ -23884,8 +23969,8 @@ function buildKey18({
|
|
|
23884
23969
|
}
|
|
23885
23970
|
}
|
|
23886
23971
|
function useStatementOfCashFlow({
|
|
23887
|
-
startDate = (0,
|
|
23888
|
-
endDate = (0,
|
|
23972
|
+
startDate = (0, import_date_fns34.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
23973
|
+
endDate = (0, import_date_fns34.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23889
23974
|
}) {
|
|
23890
23975
|
const { data: auth } = useAuth();
|
|
23891
23976
|
const { apiUrl } = useEnvironment();
|
|
@@ -23960,12 +24045,12 @@ var StatementOfCashFlowView = ({
|
|
|
23960
24045
|
};
|
|
23961
24046
|
|
|
23962
24047
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
23963
|
-
var
|
|
24048
|
+
var import_react136 = require("react");
|
|
23964
24049
|
|
|
23965
24050
|
// src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
|
|
23966
|
-
var
|
|
23967
|
-
var
|
|
23968
|
-
var ChartOfAccountsContext = (0,
|
|
24051
|
+
var import_react123 = require("react");
|
|
24052
|
+
var import_date_fns35 = require("date-fns");
|
|
24053
|
+
var ChartOfAccountsContext = (0, import_react123.createContext)(
|
|
23969
24054
|
{
|
|
23970
24055
|
data: void 0,
|
|
23971
24056
|
isLoading: false,
|
|
@@ -23987,8 +24072,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
|
|
|
23987
24072
|
submitForm: () => {
|
|
23988
24073
|
},
|
|
23989
24074
|
dateRange: {
|
|
23990
|
-
startDate: (0,
|
|
23991
|
-
endDate: (0,
|
|
24075
|
+
startDate: (0, import_date_fns35.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
24076
|
+
endDate: (0, import_date_fns35.endOfMonth)(/* @__PURE__ */ new Date())
|
|
23992
24077
|
},
|
|
23993
24078
|
changeDateRange: () => {
|
|
23994
24079
|
}
|
|
@@ -23996,8 +24081,8 @@ var ChartOfAccountsContext = (0, import_react122.createContext)(
|
|
|
23996
24081
|
);
|
|
23997
24082
|
|
|
23998
24083
|
// src/contexts/LedgerAccountsContext/LedgerAccountsContext.tsx
|
|
23999
|
-
var
|
|
24000
|
-
var LedgerAccountsContext = (0,
|
|
24084
|
+
var import_react124 = require("react");
|
|
24085
|
+
var LedgerAccountsContext = (0, import_react124.createContext)({
|
|
24001
24086
|
data: void 0,
|
|
24002
24087
|
entryData: void 0,
|
|
24003
24088
|
isLoading: false,
|
|
@@ -24019,7 +24104,7 @@ var LedgerAccountsContext = (0, import_react123.createContext)({
|
|
|
24019
24104
|
});
|
|
24020
24105
|
|
|
24021
24106
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24022
|
-
var
|
|
24107
|
+
var import_react125 = require("react");
|
|
24023
24108
|
|
|
24024
24109
|
// src/components/ChartOfAccountsForm/constants.ts
|
|
24025
24110
|
var LEDGER_ACCOUNT_TYPES = [
|
|
@@ -24223,7 +24308,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
24223
24308
|
};
|
|
24224
24309
|
|
|
24225
24310
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24226
|
-
var
|
|
24311
|
+
var import_date_fns36 = require("date-fns");
|
|
24227
24312
|
var import_swr18 = __toESM(require("swr"));
|
|
24228
24313
|
var validate = (formData) => {
|
|
24229
24314
|
const errors = [];
|
|
@@ -24307,8 +24392,8 @@ var validateName = (formData) => {
|
|
|
24307
24392
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
24308
24393
|
var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
|
|
24309
24394
|
withDates: false,
|
|
24310
|
-
startDate: (0,
|
|
24311
|
-
endDate: (0,
|
|
24395
|
+
startDate: (0, import_date_fns36.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
24396
|
+
endDate: (0, import_date_fns36.endOfMonth)(/* @__PURE__ */ new Date())
|
|
24312
24397
|
}) => {
|
|
24313
24398
|
const {
|
|
24314
24399
|
businessId,
|
|
@@ -24319,14 +24404,14 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24319
24404
|
} = useLayerContext();
|
|
24320
24405
|
const { apiUrl } = useEnvironment();
|
|
24321
24406
|
const { data: auth } = useAuth();
|
|
24322
|
-
const [form, setForm] = (0,
|
|
24323
|
-
const [sendingForm, setSendingForm] = (0,
|
|
24324
|
-
const [apiError, setApiError] = (0,
|
|
24325
|
-
const [startDate, setStartDate] = (0,
|
|
24326
|
-
initialStartDate != null ? initialStartDate : (0,
|
|
24407
|
+
const [form, setForm] = (0, import_react125.useState)();
|
|
24408
|
+
const [sendingForm, setSendingForm] = (0, import_react125.useState)(false);
|
|
24409
|
+
const [apiError, setApiError] = (0, import_react125.useState)(void 0);
|
|
24410
|
+
const [startDate, setStartDate] = (0, import_react125.useState)(
|
|
24411
|
+
initialStartDate != null ? initialStartDate : (0, import_date_fns36.startOfMonth)(Date.now())
|
|
24327
24412
|
);
|
|
24328
|
-
const [endDate, setEndDate] = (0,
|
|
24329
|
-
initialEndDate != null ? initialEndDate : (0,
|
|
24413
|
+
const [endDate, setEndDate] = (0, import_react125.useState)(
|
|
24414
|
+
initialEndDate != null ? initialEndDate : (0, import_date_fns36.endOfMonth)(Date.now())
|
|
24330
24415
|
);
|
|
24331
24416
|
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()}`;
|
|
24332
24417
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr18.default)(
|
|
@@ -24334,8 +24419,8 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24334
24419
|
Layer.getLedgerAccountBalances(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24335
24420
|
params: {
|
|
24336
24421
|
businessId,
|
|
24337
|
-
startDate: withDates && startDate ? (0,
|
|
24338
|
-
endDate: withDates && endDate ? (0,
|
|
24422
|
+
startDate: withDates && startDate ? (0, import_date_fns36.formatISO)(startDate.valueOf()) : void 0,
|
|
24423
|
+
endDate: withDates && endDate ? (0, import_date_fns36.formatISO)(endDate.valueOf()) : void 0
|
|
24339
24424
|
}
|
|
24340
24425
|
})
|
|
24341
24426
|
);
|
|
@@ -24507,12 +24592,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24507
24592
|
newEndDate && setEndDate(newEndDate);
|
|
24508
24593
|
};
|
|
24509
24594
|
const refetch = () => mutate();
|
|
24510
|
-
(0,
|
|
24595
|
+
(0, import_react125.useEffect)(() => {
|
|
24511
24596
|
if (queryKey && (isLoading || isValidating)) {
|
|
24512
24597
|
read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */, queryKey);
|
|
24513
24598
|
}
|
|
24514
24599
|
}, [isLoading, isValidating]);
|
|
24515
|
-
(0,
|
|
24600
|
+
(0, import_react125.useEffect)(() => {
|
|
24516
24601
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
24517
24602
|
refetch();
|
|
24518
24603
|
}
|
|
@@ -24540,17 +24625,17 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24540
24625
|
// src/hooks/useChartOfAccounts/useCreateChildAccount.tsx
|
|
24541
24626
|
var import_mutation9 = __toESM(require("swr/mutation"));
|
|
24542
24627
|
var import_swr19 = require("swr");
|
|
24543
|
-
var
|
|
24628
|
+
var import_react126 = require("react");
|
|
24544
24629
|
|
|
24545
24630
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
24546
|
-
var
|
|
24631
|
+
var import_react127 = require("react");
|
|
24547
24632
|
var import_swr20 = __toESM(require("swr"));
|
|
24548
24633
|
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
24549
24634
|
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
24550
24635
|
const { apiUrl } = useEnvironment();
|
|
24551
24636
|
const { data: auth } = useAuth();
|
|
24552
|
-
const [accountId, setAccountId] = (0,
|
|
24553
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
24637
|
+
const [accountId, setAccountId] = (0, import_react127.useState)();
|
|
24638
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react127.useState)();
|
|
24554
24639
|
const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
24555
24640
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr20.default)(
|
|
24556
24641
|
queryKey,
|
|
@@ -24579,12 +24664,12 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24579
24664
|
setSelectedEntryId(void 0);
|
|
24580
24665
|
mutateEntryData();
|
|
24581
24666
|
};
|
|
24582
|
-
(0,
|
|
24667
|
+
(0, import_react127.useEffect)(() => {
|
|
24583
24668
|
if (queryKey && (isLoading || isValidating)) {
|
|
24584
24669
|
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
24585
24670
|
}
|
|
24586
24671
|
}, [isLoading, isValidating]);
|
|
24587
|
-
(0,
|
|
24672
|
+
(0, import_react127.useEffect)(() => {
|
|
24588
24673
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
24589
24674
|
refetch();
|
|
24590
24675
|
}
|
|
@@ -24608,7 +24693,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24608
24693
|
};
|
|
24609
24694
|
|
|
24610
24695
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTableWithPanel.tsx
|
|
24611
|
-
var
|
|
24696
|
+
var import_react132 = require("react");
|
|
24612
24697
|
|
|
24613
24698
|
// src/icons/Plus.tsx
|
|
24614
24699
|
var import_jsx_runtime215 = require("react/jsx-runtime");
|
|
@@ -24649,11 +24734,11 @@ var Plus = (_a) => {
|
|
|
24649
24734
|
var Plus_default = Plus;
|
|
24650
24735
|
|
|
24651
24736
|
// src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
|
|
24652
|
-
var
|
|
24653
|
-
var
|
|
24737
|
+
var import_react128 = require("react");
|
|
24738
|
+
var import_date_fns37 = require("date-fns");
|
|
24654
24739
|
var import_jsx_runtime216 = require("react/jsx-runtime");
|
|
24655
24740
|
var ChartOfAccountsDatePicker = () => {
|
|
24656
|
-
const { changeDateRange, dateRange } = (0,
|
|
24741
|
+
const { changeDateRange, dateRange } = (0, import_react128.useContext)(ChartOfAccountsContext);
|
|
24657
24742
|
return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(
|
|
24658
24743
|
DatePicker,
|
|
24659
24744
|
{
|
|
@@ -24662,8 +24747,8 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
24662
24747
|
onChange: (date) => {
|
|
24663
24748
|
if (!Array.isArray(date)) {
|
|
24664
24749
|
changeDateRange({
|
|
24665
|
-
startDate: (0,
|
|
24666
|
-
endDate: (0,
|
|
24750
|
+
startDate: (0, import_date_fns37.startOfMonth)(date),
|
|
24751
|
+
endDate: (0, import_date_fns37.endOfMonth)(date)
|
|
24667
24752
|
});
|
|
24668
24753
|
}
|
|
24669
24754
|
}
|
|
@@ -24672,13 +24757,13 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
24672
24757
|
};
|
|
24673
24758
|
|
|
24674
24759
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
24675
|
-
var
|
|
24760
|
+
var import_react130 = require("react");
|
|
24676
24761
|
|
|
24677
24762
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
24678
|
-
var
|
|
24763
|
+
var import_react129 = require("react");
|
|
24679
24764
|
var useParentOptions = (data) => {
|
|
24680
24765
|
var _a;
|
|
24681
|
-
return (0,
|
|
24766
|
+
return (0, import_react129.useMemo)(
|
|
24682
24767
|
() => 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) => {
|
|
24683
24768
|
return {
|
|
24684
24769
|
label: x.name,
|
|
@@ -24703,9 +24788,9 @@ var ChartOfAccountsForm = ({
|
|
|
24703
24788
|
submitForm,
|
|
24704
24789
|
sendingForm,
|
|
24705
24790
|
apiError
|
|
24706
|
-
} = (0,
|
|
24791
|
+
} = (0, import_react130.useContext)(ChartOfAccountsContext);
|
|
24707
24792
|
const parentOptions = useParentOptions(data);
|
|
24708
|
-
const entry = (0,
|
|
24793
|
+
const entry = (0, import_react130.useMemo)(() => {
|
|
24709
24794
|
if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
|
|
24710
24795
|
return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
|
|
24711
24796
|
(x) => x.id === form.accountId
|
|
@@ -24918,7 +25003,7 @@ var ChartOfAccountsSidebar = ({
|
|
|
24918
25003
|
};
|
|
24919
25004
|
|
|
24920
25005
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
24921
|
-
var
|
|
25006
|
+
var import_react131 = require("react");
|
|
24922
25007
|
|
|
24923
25008
|
// src/icons/Edit2.tsx
|
|
24924
25009
|
var import_jsx_runtime219 = require("react/jsx-runtime");
|
|
@@ -24978,18 +25063,18 @@ var ChartOfAccountsTableContent = ({
|
|
|
24978
25063
|
expandAll,
|
|
24979
25064
|
templateAccountsEditable
|
|
24980
25065
|
}) => {
|
|
24981
|
-
const { setAccountId } = (0,
|
|
24982
|
-
const { editAccount } = (0,
|
|
25066
|
+
const { setAccountId } = (0, import_react131.useContext)(LedgerAccountsContext);
|
|
25067
|
+
const { editAccount } = (0, import_react131.useContext)(ChartOfAccountsContext);
|
|
24983
25068
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
24984
|
-
const [accountsRowKeys, setAccountsRowKeys] = (0,
|
|
24985
|
-
(0,
|
|
25069
|
+
const [accountsRowKeys, setAccountsRowKeys] = (0, import_react131.useState)([]);
|
|
25070
|
+
(0, import_react131.useEffect)(() => {
|
|
24986
25071
|
if (expandAll === "expanded") {
|
|
24987
25072
|
setIsOpen(accountsRowKeys);
|
|
24988
25073
|
} else if (expandAll === "collapsed") {
|
|
24989
25074
|
setIsOpen([]);
|
|
24990
25075
|
}
|
|
24991
25076
|
}, [expandAll]);
|
|
24992
|
-
(0,
|
|
25077
|
+
(0, import_react131.useEffect)(() => {
|
|
24993
25078
|
const defaultExpanded = data.accounts.map(
|
|
24994
25079
|
(account) => "coa-row-" + account.id
|
|
24995
25080
|
);
|
|
@@ -25008,7 +25093,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
25008
25093
|
var _a, _b;
|
|
25009
25094
|
const expandable = !!account.sub_accounts && account.sub_accounts.length > 0;
|
|
25010
25095
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
25011
|
-
return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
|
|
25096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_react131.Fragment, { children: [
|
|
25012
25097
|
/* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
|
|
25013
25098
|
TableRow,
|
|
25014
25099
|
{
|
|
@@ -25184,8 +25269,8 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
25184
25269
|
templateAccountsEditable
|
|
25185
25270
|
}) => {
|
|
25186
25271
|
var _a;
|
|
25187
|
-
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0,
|
|
25188
|
-
const [expandAll, setExpandAll] = (0,
|
|
25272
|
+
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react132.useContext)(ChartOfAccountsContext);
|
|
25273
|
+
const [expandAll, setExpandAll] = (0, import_react132.useState)();
|
|
25189
25274
|
const cumulativeIndex = 0;
|
|
25190
25275
|
const accountsLength = (_a = data == null ? void 0 : data.accounts.length) != null ? _a : 0;
|
|
25191
25276
|
return /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)(
|
|
@@ -25290,10 +25375,10 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
25290
25375
|
};
|
|
25291
25376
|
|
|
25292
25377
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
25293
|
-
var
|
|
25378
|
+
var import_react135 = require("react");
|
|
25294
25379
|
|
|
25295
25380
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
25296
|
-
var
|
|
25381
|
+
var import_react133 = require("react");
|
|
25297
25382
|
|
|
25298
25383
|
// src/utils/journal.ts
|
|
25299
25384
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -25321,21 +25406,21 @@ var lineEntryNumber = (ledgerEntryLine) => {
|
|
|
25321
25406
|
};
|
|
25322
25407
|
|
|
25323
25408
|
// src/components/DateTime/DateTime.tsx
|
|
25324
|
-
var
|
|
25409
|
+
var import_date_fns38 = require("date-fns");
|
|
25325
25410
|
var import_jsx_runtime223 = require("react/jsx-runtime");
|
|
25326
25411
|
var DateTime = ({
|
|
25327
25412
|
value,
|
|
25328
|
-
format:
|
|
25413
|
+
format: format8,
|
|
25329
25414
|
dateFormat,
|
|
25330
25415
|
timeFormat,
|
|
25331
25416
|
onlyDate,
|
|
25332
25417
|
onlyTime
|
|
25333
25418
|
}) => {
|
|
25334
|
-
if (
|
|
25335
|
-
return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0,
|
|
25419
|
+
if (format8) {
|
|
25420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(Text, { className: "Layer__datetime", children: (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), format8) });
|
|
25336
25421
|
}
|
|
25337
|
-
const date = (0,
|
|
25338
|
-
const time = (0,
|
|
25422
|
+
const date = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), dateFormat != null ? dateFormat : DATE_FORMAT);
|
|
25423
|
+
const time = (0, import_date_fns38.format)((0, import_date_fns38.parseISO)(value), timeFormat != null ? timeFormat : TIME_FORMAT);
|
|
25339
25424
|
return /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)(Text, { className: "Layer__datetime", children: [
|
|
25340
25425
|
!onlyTime && /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(
|
|
25341
25426
|
Text,
|
|
@@ -25537,8 +25622,8 @@ var LedgerAccountEntryDetails = ({
|
|
|
25537
25622
|
stringOverrides
|
|
25538
25623
|
}) => {
|
|
25539
25624
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
25540
|
-
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0,
|
|
25541
|
-
const { totalDebit, totalCredit } = (0,
|
|
25625
|
+
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react133.useContext)(LedgerAccountsContext);
|
|
25626
|
+
const { totalDebit, totalCredit } = (0, import_react133.useMemo)(() => {
|
|
25542
25627
|
var _a2;
|
|
25543
25628
|
let totalDebit2 = 0;
|
|
25544
25629
|
let totalCredit2 = 0;
|
|
@@ -25684,9 +25769,9 @@ var LedgerAccountEntryDetails = ({
|
|
|
25684
25769
|
};
|
|
25685
25770
|
|
|
25686
25771
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
25687
|
-
var
|
|
25772
|
+
var import_react134 = require("react");
|
|
25688
25773
|
var import_classnames68 = __toESM(require("classnames"));
|
|
25689
|
-
var
|
|
25774
|
+
var import_date_fns39 = require("date-fns");
|
|
25690
25775
|
var import_jsx_runtime227 = require("react/jsx-runtime");
|
|
25691
25776
|
var LedgerAccountRow = ({
|
|
25692
25777
|
row,
|
|
@@ -25695,9 +25780,9 @@ var LedgerAccountRow = ({
|
|
|
25695
25780
|
view
|
|
25696
25781
|
}) => {
|
|
25697
25782
|
var _a, _b, _c, _d, _e, _f;
|
|
25698
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
25699
|
-
const [showComponent, setShowComponent] = (0,
|
|
25700
|
-
(0,
|
|
25783
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react134.useContext)(LedgerAccountsContext);
|
|
25784
|
+
const [showComponent, setShowComponent] = (0, import_react134.useState)(false);
|
|
25785
|
+
(0, import_react134.useEffect)(() => {
|
|
25701
25786
|
if (initialLoad) {
|
|
25702
25787
|
const timeoutId = setTimeout(() => {
|
|
25703
25788
|
setShowComponent(true);
|
|
@@ -25729,7 +25814,7 @@ var LedgerAccountRow = ({
|
|
|
25729
25814
|
children: [
|
|
25730
25815
|
/* @__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: [
|
|
25731
25816
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
|
|
25732
|
-
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0,
|
|
25817
|
+
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
|
|
25733
25818
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
|
|
25734
25819
|
Text,
|
|
25735
25820
|
{
|
|
@@ -25769,7 +25854,7 @@ var LedgerAccountRow = ({
|
|
|
25769
25854
|
},
|
|
25770
25855
|
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: [
|
|
25771
25856
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "Layer__ledger-account-table__tablet-main-col__date", children: [
|
|
25772
|
-
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0,
|
|
25857
|
+
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Text, { children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }),
|
|
25773
25858
|
/* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
|
|
25774
25859
|
Text,
|
|
25775
25860
|
{
|
|
@@ -25820,7 +25905,7 @@ var LedgerAccountRow = ({
|
|
|
25820
25905
|
}
|
|
25821
25906
|
},
|
|
25822
25907
|
children: [
|
|
25823
|
-
/* @__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,
|
|
25908
|
+
/* @__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) }) }),
|
|
25824
25909
|
/* @__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) }) }),
|
|
25825
25910
|
/* @__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 : "" }) }),
|
|
25826
25911
|
/* @__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)}` }) }),
|
|
@@ -25841,9 +25926,9 @@ var LedgerAccount = ({
|
|
|
25841
25926
|
stringOverrides
|
|
25842
25927
|
}) => {
|
|
25843
25928
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
25844
|
-
const [currentPage, setCurrentPage] = (0,
|
|
25845
|
-
const [initialLoad, setInitialLoad] = (0,
|
|
25846
|
-
const { data: accountData } = (0,
|
|
25929
|
+
const [currentPage, setCurrentPage] = (0, import_react135.useState)(1);
|
|
25930
|
+
const [initialLoad, setInitialLoad] = (0, import_react135.useState)(true);
|
|
25931
|
+
const { data: accountData } = (0, import_react135.useContext)(ChartOfAccountsContext);
|
|
25847
25932
|
const {
|
|
25848
25933
|
data: rawData,
|
|
25849
25934
|
error,
|
|
@@ -25854,8 +25939,8 @@ var LedgerAccount = ({
|
|
|
25854
25939
|
selectedEntryId,
|
|
25855
25940
|
closeSelectedEntry,
|
|
25856
25941
|
refetch
|
|
25857
|
-
} = (0,
|
|
25858
|
-
(0,
|
|
25942
|
+
} = (0, import_react135.useContext)(LedgerAccountsContext);
|
|
25943
|
+
(0, import_react135.useEffect)(() => {
|
|
25859
25944
|
if (!isLoading) {
|
|
25860
25945
|
const timeoutLoad = setTimeout(() => {
|
|
25861
25946
|
setInitialLoad(false);
|
|
@@ -25867,12 +25952,12 @@ var LedgerAccount = ({
|
|
|
25867
25952
|
"Layer__ledger-account__index",
|
|
25868
25953
|
accountId && "open"
|
|
25869
25954
|
);
|
|
25870
|
-
const account = (0,
|
|
25955
|
+
const account = (0, import_react135.useMemo)(() => {
|
|
25871
25956
|
return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
|
|
25872
25957
|
(x) => x.id === accountId
|
|
25873
25958
|
);
|
|
25874
25959
|
}, [accountId]);
|
|
25875
|
-
const data = (0,
|
|
25960
|
+
const data = (0, import_react135.useMemo)(() => {
|
|
25876
25961
|
var _a2;
|
|
25877
25962
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
25878
25963
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
@@ -26010,7 +26095,7 @@ var ChartOfAccountsContent = ({
|
|
|
26010
26095
|
templateAccountsEditable,
|
|
26011
26096
|
showAddAccountButton
|
|
26012
26097
|
}) => {
|
|
26013
|
-
const { accountId } = (0,
|
|
26098
|
+
const { accountId } = (0, import_react136.useContext)(LedgerAccountsContext);
|
|
26014
26099
|
const { view, containerRef } = useElementViewSize();
|
|
26015
26100
|
return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(Container, { name: "chart-of-accounts", ref: containerRef, asWidget, children: accountId ? /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
|
|
26016
26101
|
LedgerAccount,
|
|
@@ -26035,8 +26120,8 @@ var ChartOfAccountsContent = ({
|
|
|
26035
26120
|
};
|
|
26036
26121
|
|
|
26037
26122
|
// src/contexts/JournalContext/JournalContext.tsx
|
|
26038
|
-
var
|
|
26039
|
-
var JournalContext = (0,
|
|
26123
|
+
var import_react137 = require("react");
|
|
26124
|
+
var JournalContext = (0, import_react137.createContext)({
|
|
26040
26125
|
data: void 0,
|
|
26041
26126
|
isLoading: false,
|
|
26042
26127
|
error: void 0,
|
|
@@ -26070,7 +26155,7 @@ var JournalContext = (0, import_react136.createContext)({
|
|
|
26070
26155
|
});
|
|
26071
26156
|
|
|
26072
26157
|
// src/hooks/useJournal/useJournal.tsx
|
|
26073
|
-
var
|
|
26158
|
+
var import_react138 = require("react");
|
|
26074
26159
|
var import_swr21 = __toESM(require("swr"));
|
|
26075
26160
|
var useJournal = () => {
|
|
26076
26161
|
const {
|
|
@@ -26082,11 +26167,11 @@ var useJournal = () => {
|
|
|
26082
26167
|
} = useLayerContext();
|
|
26083
26168
|
const { apiUrl } = useEnvironment();
|
|
26084
26169
|
const { data: auth } = useAuth();
|
|
26085
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
26086
|
-
const [form, setForm] = (0,
|
|
26087
|
-
const [addingEntry, setAddingEntry] = (0,
|
|
26088
|
-
const [sendingForm, setSendingForm] = (0,
|
|
26089
|
-
const [apiError, setApiError] = (0,
|
|
26170
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react138.useState)();
|
|
26171
|
+
const [form, setForm] = (0, import_react138.useState)();
|
|
26172
|
+
const [addingEntry, setAddingEntry] = (0, import_react138.useState)(false);
|
|
26173
|
+
const [sendingForm, setSendingForm] = (0, import_react138.useState)(false);
|
|
26174
|
+
const [apiError, setApiError] = (0, import_react138.useState)(void 0);
|
|
26090
26175
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `journal-lines-${businessId}`;
|
|
26091
26176
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr21.default)(
|
|
26092
26177
|
queryKey,
|
|
@@ -26302,12 +26387,12 @@ var useJournal = () => {
|
|
|
26302
26387
|
params: { businessId, entryId }
|
|
26303
26388
|
});
|
|
26304
26389
|
});
|
|
26305
|
-
(0,
|
|
26390
|
+
(0, import_react138.useEffect)(() => {
|
|
26306
26391
|
if (queryKey && (isLoading || isValidating)) {
|
|
26307
26392
|
read("JOURNAL" /* JOURNAL */, queryKey);
|
|
26308
26393
|
}
|
|
26309
26394
|
}, [isLoading, isValidating]);
|
|
26310
|
-
(0,
|
|
26395
|
+
(0, import_react138.useEffect)(() => {
|
|
26311
26396
|
if (queryKey && hasBeenTouched(queryKey)) {
|
|
26312
26397
|
refetch();
|
|
26313
26398
|
}
|
|
@@ -26339,13 +26424,13 @@ var useJournal = () => {
|
|
|
26339
26424
|
};
|
|
26340
26425
|
|
|
26341
26426
|
// src/components/JournalTable/JournalTableWithPanel.tsx
|
|
26342
|
-
var
|
|
26427
|
+
var import_react144 = require("react");
|
|
26343
26428
|
|
|
26344
26429
|
// src/components/JournalSidebar/JournalSidebar.tsx
|
|
26345
|
-
var
|
|
26430
|
+
var import_react142 = require("react");
|
|
26346
26431
|
|
|
26347
26432
|
// src/components/JournalEntryDetails/JournalEntryDetails.tsx
|
|
26348
|
-
var
|
|
26433
|
+
var import_react139 = require("react");
|
|
26349
26434
|
var import_jsx_runtime230 = require("react/jsx-runtime");
|
|
26350
26435
|
var JournalEntryDetails = () => {
|
|
26351
26436
|
var _a, _b, _c, _d;
|
|
@@ -26357,16 +26442,16 @@ var JournalEntryDetails = () => {
|
|
|
26357
26442
|
selectedEntryId,
|
|
26358
26443
|
reverseEntry,
|
|
26359
26444
|
refetch
|
|
26360
|
-
} = (0,
|
|
26361
|
-
const [reverseEntryProcessing, setReverseEntryProcessing] = (0,
|
|
26362
|
-
const [reverseEntryError, setReverseEntryError] = (0,
|
|
26363
|
-
const entry = (0,
|
|
26445
|
+
} = (0, import_react139.useContext)(JournalContext);
|
|
26446
|
+
const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react139.useState)(false);
|
|
26447
|
+
const [reverseEntryError, setReverseEntryError] = (0, import_react139.useState)();
|
|
26448
|
+
const entry = (0, import_react139.useMemo)(() => {
|
|
26364
26449
|
if (selectedEntryId && data) {
|
|
26365
26450
|
return data.find((x) => x.id === selectedEntryId);
|
|
26366
26451
|
}
|
|
26367
26452
|
return;
|
|
26368
26453
|
}, [data, selectedEntryId]);
|
|
26369
|
-
const sortedLineItems = (0,
|
|
26454
|
+
const sortedLineItems = (0, import_react139.useMemo)(
|
|
26370
26455
|
() => {
|
|
26371
26456
|
var _a2;
|
|
26372
26457
|
return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
|
|
@@ -26544,10 +26629,10 @@ var JournalEntryDetails = () => {
|
|
|
26544
26629
|
};
|
|
26545
26630
|
|
|
26546
26631
|
// src/components/JournalForm/JournalForm.tsx
|
|
26547
|
-
var
|
|
26632
|
+
var import_react141 = require("react");
|
|
26548
26633
|
|
|
26549
26634
|
// src/components/JournalForm/JournalFormEntryLines.tsx
|
|
26550
|
-
var
|
|
26635
|
+
var import_react140 = require("react");
|
|
26551
26636
|
var import_jsx_runtime231 = require("react/jsx-runtime");
|
|
26552
26637
|
function recursiveFlattenCategories(accounts) {
|
|
26553
26638
|
const flattenedResult = accounts.flatMap((a) => {
|
|
@@ -26568,8 +26653,8 @@ var JournalFormEntryLines = ({
|
|
|
26568
26653
|
config
|
|
26569
26654
|
}) => {
|
|
26570
26655
|
const { data: categories } = useCategories({ mode: "ALL" });
|
|
26571
|
-
const { form } = (0,
|
|
26572
|
-
const { flattenedCategories, parentOptions } = (0,
|
|
26656
|
+
const { form } = (0, import_react140.useContext)(JournalContext);
|
|
26657
|
+
const { flattenedCategories, parentOptions } = (0, import_react140.useMemo)(() => {
|
|
26573
26658
|
const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
|
|
26574
26659
|
const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
|
|
26575
26660
|
switch (account.type) {
|
|
@@ -26781,7 +26866,7 @@ var JournalForm = ({
|
|
|
26781
26866
|
changeFormData,
|
|
26782
26867
|
addEntryLine,
|
|
26783
26868
|
removeEntryLine
|
|
26784
|
-
} = (0,
|
|
26869
|
+
} = (0, import_react141.useContext)(JournalContext);
|
|
26785
26870
|
return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
|
|
26786
26871
|
"form",
|
|
26787
26872
|
{
|
|
@@ -26929,7 +27014,7 @@ var JournalSidebar = ({
|
|
|
26929
27014
|
config,
|
|
26930
27015
|
stringOverrides
|
|
26931
27016
|
}) => {
|
|
26932
|
-
const { selectedEntryId } = (0,
|
|
27017
|
+
const { selectedEntryId } = (0, import_react142.useContext)(JournalContext);
|
|
26933
27018
|
if (selectedEntryId !== "new") {
|
|
26934
27019
|
return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(JournalEntryDetails, {});
|
|
26935
27020
|
}
|
|
@@ -26937,8 +27022,8 @@ var JournalSidebar = ({
|
|
|
26937
27022
|
};
|
|
26938
27023
|
|
|
26939
27024
|
// src/components/JournalTable/JournalTable.tsx
|
|
26940
|
-
var
|
|
26941
|
-
var
|
|
27025
|
+
var import_react143 = require("react");
|
|
27026
|
+
var import_date_fns40 = require("date-fns");
|
|
26942
27027
|
var import_jsx_runtime234 = require("react/jsx-runtime");
|
|
26943
27028
|
var accountName = (row) => {
|
|
26944
27029
|
if ("account" in row) {
|
|
@@ -26965,9 +27050,9 @@ var JournalTableContent = ({
|
|
|
26965
27050
|
data,
|
|
26966
27051
|
stringOverrides
|
|
26967
27052
|
}) => {
|
|
26968
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
27053
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react143.useContext)(JournalContext);
|
|
26969
27054
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
26970
|
-
(0,
|
|
27055
|
+
(0, import_react143.useEffect)(() => {
|
|
26971
27056
|
if (data.length > 0) {
|
|
26972
27057
|
setIsOpen(data.map((x) => `journal-row-${x.id}`));
|
|
26973
27058
|
}
|
|
@@ -26975,7 +27060,7 @@ var JournalTableContent = ({
|
|
|
26975
27060
|
const renderJournalRow = (row, index, rowKey, depth) => {
|
|
26976
27061
|
const expandable = !!row.line_items && row.line_items.length > 0;
|
|
26977
27062
|
const expanded = expandable ? isOpen(rowKey) : true;
|
|
26978
|
-
return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
|
|
27063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_react143.Fragment, { children: [
|
|
26979
27064
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
|
|
26980
27065
|
TableRow,
|
|
26981
27066
|
{
|
|
@@ -27005,7 +27090,7 @@ var JournalTableContent = ({
|
|
|
27005
27090
|
children: entryNumber(row)
|
|
27006
27091
|
}
|
|
27007
27092
|
),
|
|
27008
|
-
/* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: row.entry_at && (0,
|
|
27093
|
+
/* @__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) }),
|
|
27009
27094
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsx)(TableCell, { children: humanizeEnum(row.entry_type) }),
|
|
27010
27095
|
/* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(TableCell, { children: [
|
|
27011
27096
|
"(",
|
|
@@ -27151,7 +27236,7 @@ var JournalTableWithPanel = ({
|
|
|
27151
27236
|
stringOverrides,
|
|
27152
27237
|
view
|
|
27153
27238
|
}) => {
|
|
27154
|
-
const [currentPage, setCurrentPage] = (0,
|
|
27239
|
+
const [currentPage, setCurrentPage] = (0, import_react144.useState)(1);
|
|
27155
27240
|
const {
|
|
27156
27241
|
data: rawData,
|
|
27157
27242
|
isLoading,
|
|
@@ -27160,8 +27245,8 @@ var JournalTableWithPanel = ({
|
|
|
27160
27245
|
refetch,
|
|
27161
27246
|
selectedEntryId,
|
|
27162
27247
|
addEntry
|
|
27163
|
-
} = (0,
|
|
27164
|
-
const data = (0,
|
|
27248
|
+
} = (0, import_react144.useContext)(JournalContext);
|
|
27249
|
+
const data = (0, import_react144.useMemo)(() => {
|
|
27165
27250
|
var _a;
|
|
27166
27251
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
27167
27252
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
@@ -27298,7 +27383,7 @@ var TasksHeader = ({
|
|
|
27298
27383
|
};
|
|
27299
27384
|
|
|
27300
27385
|
// src/components/Tasks/TasksList.tsx
|
|
27301
|
-
var
|
|
27386
|
+
var import_react152 = require("react");
|
|
27302
27387
|
|
|
27303
27388
|
// src/icons/SmileIcon.tsx
|
|
27304
27389
|
var import_jsx_runtime239 = require("react/jsx-runtime");
|
|
@@ -27357,7 +27442,7 @@ var SmileIcon = (_a) => {
|
|
|
27357
27442
|
var SmileIcon_default = SmileIcon;
|
|
27358
27443
|
|
|
27359
27444
|
// src/components/Tasks/TasksListItem.tsx
|
|
27360
|
-
var
|
|
27445
|
+
var import_react149 = require("react");
|
|
27361
27446
|
var import_classnames70 = __toESM(require("classnames"));
|
|
27362
27447
|
|
|
27363
27448
|
// src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
|
|
@@ -27415,7 +27500,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
27415
27500
|
}
|
|
27416
27501
|
|
|
27417
27502
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27418
|
-
var
|
|
27503
|
+
var import_react145 = require("react");
|
|
27419
27504
|
function buildKey21({
|
|
27420
27505
|
access_token: accessToken,
|
|
27421
27506
|
apiUrl,
|
|
@@ -27458,7 +27543,7 @@ function useSubmitUserResponseForTask() {
|
|
|
27458
27543
|
}
|
|
27459
27544
|
);
|
|
27460
27545
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27461
|
-
const stableProxiedTrigger = (0,
|
|
27546
|
+
const stableProxiedTrigger = (0, import_react145.useCallback)(
|
|
27462
27547
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27463
27548
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27464
27549
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27485,7 +27570,7 @@ function useSubmitUserResponseForTask() {
|
|
|
27485
27570
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
27486
27571
|
var import_swr23 = require("swr");
|
|
27487
27572
|
var import_mutation13 = __toESM(require("swr/mutation"));
|
|
27488
|
-
var
|
|
27573
|
+
var import_react146 = require("react");
|
|
27489
27574
|
function buildKey22({
|
|
27490
27575
|
access_token: accessToken,
|
|
27491
27576
|
apiUrl,
|
|
@@ -27524,7 +27609,7 @@ function useUploadDocumentsForTask() {
|
|
|
27524
27609
|
}
|
|
27525
27610
|
);
|
|
27526
27611
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27527
|
-
const stableProxiedTrigger = (0,
|
|
27612
|
+
const stableProxiedTrigger = (0, import_react146.useCallback)(
|
|
27528
27613
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27529
27614
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27530
27615
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27551,7 +27636,7 @@ function useUploadDocumentsForTask() {
|
|
|
27551
27636
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
27552
27637
|
var import_swr24 = require("swr");
|
|
27553
27638
|
var import_mutation14 = __toESM(require("swr/mutation"));
|
|
27554
|
-
var
|
|
27639
|
+
var import_react147 = require("react");
|
|
27555
27640
|
function buildKey23({
|
|
27556
27641
|
access_token: accessToken,
|
|
27557
27642
|
apiUrl,
|
|
@@ -27587,7 +27672,7 @@ function useDeleteUploadsOnTask() {
|
|
|
27587
27672
|
}
|
|
27588
27673
|
);
|
|
27589
27674
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27590
|
-
const stableProxiedTrigger = (0,
|
|
27675
|
+
const stableProxiedTrigger = (0, import_react147.useCallback)(
|
|
27591
27676
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27592
27677
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27593
27678
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27614,7 +27699,7 @@ function useDeleteUploadsOnTask() {
|
|
|
27614
27699
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
27615
27700
|
var import_swr25 = require("swr");
|
|
27616
27701
|
var import_mutation15 = __toESM(require("swr/mutation"));
|
|
27617
|
-
var
|
|
27702
|
+
var import_react148 = require("react");
|
|
27618
27703
|
function buildKey24({
|
|
27619
27704
|
access_token: accessToken,
|
|
27620
27705
|
apiUrl,
|
|
@@ -27654,7 +27739,7 @@ function useUpdateTaskUploadDescription() {
|
|
|
27654
27739
|
}
|
|
27655
27740
|
);
|
|
27656
27741
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27657
|
-
const stableProxiedTrigger = (0,
|
|
27742
|
+
const stableProxiedTrigger = (0, import_react148.useCallback)(
|
|
27658
27743
|
(...triggerParameters) => __async(null, null, function* () {
|
|
27659
27744
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27660
27745
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -27685,9 +27770,9 @@ var TasksListItem = ({
|
|
|
27685
27770
|
defaultOpen
|
|
27686
27771
|
}) => {
|
|
27687
27772
|
var _a, _b;
|
|
27688
|
-
const [isOpen, setIsOpen] = (0,
|
|
27689
|
-
const [userResponse, setUserResponse] = (0,
|
|
27690
|
-
const [selectedFiles, setSelectedFiles] = (0,
|
|
27773
|
+
const [isOpen, setIsOpen] = (0, import_react149.useState)(defaultOpen);
|
|
27774
|
+
const [userResponse, setUserResponse] = (0, import_react149.useState)((_a = task.user_response) != null ? _a : "");
|
|
27775
|
+
const [selectedFiles, setSelectedFiles] = (0, import_react149.useState)();
|
|
27691
27776
|
const { trigger: handleSubmitUserResponseForTask } = useSubmitUserResponseForTask();
|
|
27692
27777
|
const { trigger: handleUploadDocumentsForTask } = useUploadDocumentsForTask();
|
|
27693
27778
|
const { trigger: handleDeleteUploadsOnTask } = useDeleteUploadsOnTask();
|
|
@@ -27705,7 +27790,7 @@ var TasksListItem = ({
|
|
|
27705
27790
|
"Layer__tasks-list-item",
|
|
27706
27791
|
isOpen && "Layer__tasks-list-item__expanded"
|
|
27707
27792
|
);
|
|
27708
|
-
(0,
|
|
27793
|
+
(0, import_react149.useEffect)(() => {
|
|
27709
27794
|
setIsOpen(defaultOpen);
|
|
27710
27795
|
}, [defaultOpen]);
|
|
27711
27796
|
const submit = () => __async(null, null, function* () {
|
|
@@ -27720,7 +27805,7 @@ var TasksListItem = ({
|
|
|
27720
27805
|
setIsOpen(false);
|
|
27721
27806
|
setSelectedFiles(void 0);
|
|
27722
27807
|
});
|
|
27723
|
-
const uploadDocumentAction = (0,
|
|
27808
|
+
const uploadDocumentAction = (0, import_react149.useMemo)(() => {
|
|
27724
27809
|
if (task.user_response_type === "UPLOAD_DOCUMENT") {
|
|
27725
27810
|
if (task.status === "TODO") {
|
|
27726
27811
|
if (!selectedFiles) {
|
|
@@ -27865,7 +27950,7 @@ var MobilePanel = ({ header, children, open: open2, onClose, className }) => {
|
|
|
27865
27950
|
};
|
|
27866
27951
|
|
|
27867
27952
|
// src/components/Tasks/TasksListMobile.tsx
|
|
27868
|
-
var
|
|
27953
|
+
var import_react150 = require("react");
|
|
27869
27954
|
var import_jsx_runtime243 = require("react/jsx-runtime");
|
|
27870
27955
|
var MOBILE_SHOW_UNRESOLVED_TASKS_COUNT = 2;
|
|
27871
27956
|
var TasksListMobile = ({
|
|
@@ -27876,7 +27961,7 @@ var TasksListMobile = ({
|
|
|
27876
27961
|
pageSize,
|
|
27877
27962
|
setCurrentPage
|
|
27878
27963
|
}) => {
|
|
27879
|
-
const [showMobilePanel, setShowMobilePanel] = (0,
|
|
27964
|
+
const [showMobilePanel, setShowMobilePanel] = (0, import_react150.useState)(false);
|
|
27880
27965
|
const unresolvedTasks = getIncompleteTasks(sortedTasks).slice(0, MOBILE_SHOW_UNRESOLVED_TASKS_COUNT);
|
|
27881
27966
|
return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)("div", { className: "Layer__tasks-list", children: [
|
|
27882
27967
|
unresolvedTasks.map((task, index) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
|
|
@@ -27924,27 +28009,27 @@ var TasksListMobile = ({
|
|
|
27924
28009
|
};
|
|
27925
28010
|
|
|
27926
28011
|
// src/hooks/array/usePaginatedList.ts
|
|
27927
|
-
var
|
|
28012
|
+
var import_react151 = require("react");
|
|
27928
28013
|
function usePaginatedList(list, pageSize) {
|
|
27929
|
-
const [internalPageIndex, setInternalPageIndex] = (0,
|
|
28014
|
+
const [internalPageIndex, setInternalPageIndex] = (0, import_react151.useState)(0);
|
|
27930
28015
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
27931
28016
|
const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
|
|
27932
|
-
const pageItems = (0,
|
|
28017
|
+
const pageItems = (0, import_react151.useMemo)(() => {
|
|
27933
28018
|
return list.slice(
|
|
27934
28019
|
effectivePageIndex * pageSize,
|
|
27935
28020
|
(effectivePageIndex + 1) * pageSize
|
|
27936
28021
|
);
|
|
27937
28022
|
}, [list, effectivePageIndex, pageSize]);
|
|
27938
|
-
const next = (0,
|
|
28023
|
+
const next = (0, import_react151.useCallback)(() => {
|
|
27939
28024
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
27940
28025
|
}, [effectivePageIndex, pageCount]);
|
|
27941
|
-
const set2 = (0,
|
|
28026
|
+
const set2 = (0, import_react151.useCallback)((pageIndex) => {
|
|
27942
28027
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
27943
28028
|
}, [pageCount]);
|
|
27944
|
-
const previous = (0,
|
|
28029
|
+
const previous = (0, import_react151.useCallback)(() => {
|
|
27945
28030
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
27946
28031
|
}, [effectivePageIndex]);
|
|
27947
|
-
const reset = (0,
|
|
28032
|
+
const reset = (0, import_react151.useCallback)(() => {
|
|
27948
28033
|
setInternalPageIndex(0);
|
|
27949
28034
|
}, []);
|
|
27950
28035
|
return {
|
|
@@ -27972,7 +28057,7 @@ var TasksEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime244.jsxs)("div
|
|
|
27972
28057
|
] });
|
|
27973
28058
|
function TasksList({ pageSize = 8, mobile }) {
|
|
27974
28059
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
27975
|
-
const sortedTasks = (0,
|
|
28060
|
+
const sortedTasks = (0, import_react152.useMemo)(() => {
|
|
27976
28061
|
var _a;
|
|
27977
28062
|
const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
|
|
27978
28063
|
return tasksInPeriod.sort((taskA, taskB) => {
|
|
@@ -28023,7 +28108,7 @@ function TasksList({ pageSize = 8, mobile }) {
|
|
|
28023
28108
|
|
|
28024
28109
|
// src/components/Tasks/TasksPending.tsx
|
|
28025
28110
|
var import_recharts4 = require("recharts");
|
|
28026
|
-
var
|
|
28111
|
+
var import_date_fns41 = require("date-fns");
|
|
28027
28112
|
var import_classnames72 = __toESM(require("classnames"));
|
|
28028
28113
|
|
|
28029
28114
|
// src/components/BookkeepingStatus/BookkeepingStatusDescription.tsx
|
|
@@ -28060,7 +28145,7 @@ var TasksPending = () => {
|
|
|
28060
28145
|
);
|
|
28061
28146
|
return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending", children: [
|
|
28062
28147
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-header", children: [
|
|
28063
|
-
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0,
|
|
28148
|
+
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(Heading, { size: "secondary" /* secondary */, children: (0, import_date_fns41.format)(date, "MMMM yyyy") }),
|
|
28064
28149
|
(activePeriod == null ? void 0 : activePeriod.tasks) && activePeriod.tasks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: "Layer__tasks-pending-bar", children: [
|
|
28065
28150
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(Text, { size: "sm" /* sm */, children: [
|
|
28066
28151
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)("span", { className: taskStatusClassName, children: completedTaskCount }),
|
|
@@ -28100,7 +28185,7 @@ var TasksPending = () => {
|
|
|
28100
28185
|
] }) : null
|
|
28101
28186
|
] }),
|
|
28102
28187
|
/* @__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: [
|
|
28103
|
-
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
|
|
28188
|
+
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(BookkeepingStatus2, { status: activePeriod.status, monthNumber: activePeriod.month }),
|
|
28104
28189
|
/* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
|
|
28105
28190
|
BookkeepingStatusDescription,
|
|
28106
28191
|
{
|
|
@@ -28114,17 +28199,17 @@ var TasksPending = () => {
|
|
|
28114
28199
|
};
|
|
28115
28200
|
|
|
28116
28201
|
// src/components/Tasks/TasksMonthSelector.tsx
|
|
28117
|
-
var
|
|
28118
|
-
var
|
|
28202
|
+
var import_react153 = require("react");
|
|
28203
|
+
var import_date_fns42 = require("date-fns");
|
|
28119
28204
|
|
|
28120
28205
|
// src/components/Tasks/TaskStatusBadge.tsx
|
|
28121
28206
|
var import_pluralize2 = __toESM(require("pluralize"));
|
|
28122
28207
|
var import_jsx_runtime247 = require("react/jsx-runtime");
|
|
28123
28208
|
var buildBadgeConfig = (status, tasksCount) => {
|
|
28124
28209
|
switch (status) {
|
|
28125
|
-
case "IN_PROGRESS_AWAITING_BOOKKEEPER"
|
|
28126
|
-
case "NOT_STARTED"
|
|
28127
|
-
case "CLOSING_IN_REVIEW"
|
|
28210
|
+
case "IN_PROGRESS_AWAITING_BOOKKEEPER" /* IN_PROGRESS_AWAITING_BOOKKEEPER */:
|
|
28211
|
+
case "NOT_STARTED" /* NOT_STARTED */:
|
|
28212
|
+
case "CLOSING_IN_REVIEW" /* CLOSING_IN_REVIEW */: {
|
|
28128
28213
|
return {
|
|
28129
28214
|
color: "info",
|
|
28130
28215
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(Clock_default, { size: 12 }),
|
|
@@ -28132,8 +28217,8 @@ var buildBadgeConfig = (status, tasksCount) => {
|
|
|
28132
28217
|
labelShort: tasksCount ? `${tasksCount}` : void 0
|
|
28133
28218
|
};
|
|
28134
28219
|
}
|
|
28135
|
-
case "IN_PROGRESS_AWAITING_CUSTOMER"
|
|
28136
|
-
case "CLOSED_OPEN_TASKS"
|
|
28220
|
+
case "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */:
|
|
28221
|
+
case "CLOSED_OPEN_TASKS" /* CLOSED_OPEN_TASKS */: {
|
|
28137
28222
|
return {
|
|
28138
28223
|
color: "warning",
|
|
28139
28224
|
label: tasksCount ? (0, import_pluralize2.default)("task", tasksCount, true) : void 0,
|
|
@@ -28141,13 +28226,13 @@ var buildBadgeConfig = (status, tasksCount) => {
|
|
|
28141
28226
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(AlertCircle_default, { size: 12 })
|
|
28142
28227
|
};
|
|
28143
28228
|
}
|
|
28144
|
-
case "CLOSED_COMPLETE"
|
|
28229
|
+
case "CLOSED_COMPLETE" /* CLOSED_COMPLETE */: {
|
|
28145
28230
|
return {
|
|
28146
28231
|
color: "success",
|
|
28147
28232
|
icon: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(CheckCircle_default, { size: 12 })
|
|
28148
28233
|
};
|
|
28149
28234
|
}
|
|
28150
|
-
case "BOOKKEEPING_NOT_ACTIVE"
|
|
28235
|
+
case "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */: {
|
|
28151
28236
|
return;
|
|
28152
28237
|
}
|
|
28153
28238
|
default: {
|
|
@@ -28215,8 +28300,8 @@ var import_jsx_runtime249 = require("react/jsx-runtime");
|
|
|
28215
28300
|
function useActiveYearBookkeepingPeriods() {
|
|
28216
28301
|
const { date } = useGlobalDate();
|
|
28217
28302
|
const { data } = useBookkeepingPeriods();
|
|
28218
|
-
const activeYear = (0,
|
|
28219
|
-
const periodsInActiveYear = (0,
|
|
28303
|
+
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
28304
|
+
const periodsInActiveYear = (0, import_react153.useMemo)(() => {
|
|
28220
28305
|
return data == null ? void 0 : data.filter((period) => period.year === activeYear);
|
|
28221
28306
|
}, [data, activeYear]);
|
|
28222
28307
|
return { periodsInActiveYear };
|
|
@@ -28225,12 +28310,12 @@ function TasksMonthSelector() {
|
|
|
28225
28310
|
const { date } = useGlobalDate();
|
|
28226
28311
|
const { setMonthByPeriod } = useGlobalDatePeriodAlignedActions();
|
|
28227
28312
|
const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
|
|
28228
|
-
const activeMonthNumber = (0,
|
|
28229
|
-
const activeYear = (0,
|
|
28230
|
-
const monthsData = (0,
|
|
28313
|
+
const activeMonthNumber = (0, import_date_fns42.getMonth)(date) + 1;
|
|
28314
|
+
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
28315
|
+
const monthsData = (0, import_react153.useMemo)(() => {
|
|
28231
28316
|
return Array.from({ length: 12 }, (_, index) => {
|
|
28232
28317
|
var _a, _b;
|
|
28233
|
-
const date2 = (0,
|
|
28318
|
+
const date2 = (0, import_date_fns42.set)(
|
|
28234
28319
|
/* @__PURE__ */ new Date(),
|
|
28235
28320
|
{ year: activeYear, month: index, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }
|
|
28236
28321
|
);
|
|
@@ -28241,12 +28326,12 @@ function TasksMonthSelector() {
|
|
|
28241
28326
|
year: activeYear,
|
|
28242
28327
|
month: index + 1,
|
|
28243
28328
|
tasks: [],
|
|
28244
|
-
status: "BOOKKEEPING_NOT_ACTIVE"
|
|
28329
|
+
status: "BOOKKEEPING_NOT_ACTIVE" /* BOOKKEEPING_NOT_ACTIVE */,
|
|
28245
28330
|
disabled: true
|
|
28246
28331
|
};
|
|
28247
28332
|
const total = (_b = (_a = taskData.tasks) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
28248
28333
|
return __spreadValues({
|
|
28249
|
-
monthStr: (0,
|
|
28334
|
+
monthStr: (0, import_date_fns42.format)(date2, "MMM"),
|
|
28250
28335
|
date: date2,
|
|
28251
28336
|
completed: getCompletedTasks(taskData.tasks).length,
|
|
28252
28337
|
total
|
|
@@ -28277,14 +28362,14 @@ var import_classnames74 = __toESM(require("classnames"));
|
|
|
28277
28362
|
var import_pluralize3 = __toESM(require("pluralize"));
|
|
28278
28363
|
|
|
28279
28364
|
// src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
|
|
28280
|
-
var
|
|
28281
|
-
var
|
|
28365
|
+
var import_react154 = require("react");
|
|
28366
|
+
var import_date_fns43 = require("date-fns");
|
|
28282
28367
|
var useBookkeepingYearsStatus = () => {
|
|
28283
28368
|
const { business } = useLayerContext();
|
|
28284
28369
|
const activationDate = getActivationDate(business);
|
|
28285
28370
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
28286
|
-
const yearStatuses = (0,
|
|
28287
|
-
const startYear = (0,
|
|
28371
|
+
const yearStatuses = (0, import_react154.useMemo)(() => {
|
|
28372
|
+
const startYear = (0, import_date_fns43.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
|
|
28288
28373
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
28289
28374
|
const count = currentYear - startYear + 1;
|
|
28290
28375
|
return Array.from({ length: count }, (_, index) => ({ year: startYear + index })).map(({ year }) => {
|
|
@@ -28298,7 +28383,7 @@ var useBookkeepingYearsStatus = () => {
|
|
|
28298
28383
|
};
|
|
28299
28384
|
}).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
|
|
28300
28385
|
}, [activationDate, data]);
|
|
28301
|
-
const earliestIncompletePeriod = (0,
|
|
28386
|
+
const earliestIncompletePeriod = (0, import_react154.useMemo)(
|
|
28302
28387
|
() => [...data != null ? data : []].sort((a, b) => {
|
|
28303
28388
|
if (a.year === b.year) {
|
|
28304
28389
|
return b.month - a.month;
|
|
@@ -28441,10 +28526,10 @@ var TasksPanelNotification = ({
|
|
|
28441
28526
|
};
|
|
28442
28527
|
|
|
28443
28528
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
28444
|
-
var
|
|
28529
|
+
var import_react157 = require("react");
|
|
28445
28530
|
|
|
28446
28531
|
// src/components/Tabs/Tabs.tsx
|
|
28447
|
-
var
|
|
28532
|
+
var import_react155 = require("react");
|
|
28448
28533
|
|
|
28449
28534
|
// src/components/Tabs/Tab.tsx
|
|
28450
28535
|
var import_jsx_runtime252 = require("react/jsx-runtime");
|
|
@@ -28508,12 +28593,12 @@ var Tab = ({
|
|
|
28508
28593
|
// src/components/Tabs/Tabs.tsx
|
|
28509
28594
|
var import_classnames73 = __toESM(require("classnames"));
|
|
28510
28595
|
var import_jsx_runtime253 = require("react/jsx-runtime");
|
|
28511
|
-
var
|
|
28596
|
+
var import_react156 = require("react");
|
|
28512
28597
|
var STARTING_PADDING = 12;
|
|
28513
28598
|
var Tabs = ({ name, options, selected, onChange }) => {
|
|
28514
|
-
const [initialized, setInitialized] = (0,
|
|
28515
|
-
const [thumbPos, setThumbPos] = (0,
|
|
28516
|
-
const [currentWidth, setCurrentWidth] = (0,
|
|
28599
|
+
const [initialized, setInitialized] = (0, import_react155.useState)(false);
|
|
28600
|
+
const [thumbPos, setThumbPos] = (0, import_react155.useState)({ left: 0, width: 0 });
|
|
28601
|
+
const [currentWidth, setCurrentWidth] = (0, import_react155.useState)(0);
|
|
28517
28602
|
const selectedValue = selected || options[0].value;
|
|
28518
28603
|
const baseClassName = (0, import_classnames73.default)(
|
|
28519
28604
|
"Layer__tabs",
|
|
@@ -28548,14 +28633,14 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28548
28633
|
shift2 = shift2 + STARTING_PADDING;
|
|
28549
28634
|
setThumbPos({ left: shift2, width });
|
|
28550
28635
|
};
|
|
28551
|
-
(0,
|
|
28636
|
+
(0, import_react155.useEffect)(() => {
|
|
28552
28637
|
const selectedIndex = getSelectedIndex();
|
|
28553
28638
|
updateSelectPosition(selectedIndex);
|
|
28554
28639
|
setTimeout(() => {
|
|
28555
28640
|
setInitialized(true);
|
|
28556
28641
|
}, 400);
|
|
28557
28642
|
}, []);
|
|
28558
|
-
(0,
|
|
28643
|
+
(0, import_react155.useEffect)(() => {
|
|
28559
28644
|
const selectedIndex = getSelectedIndex();
|
|
28560
28645
|
updateSelectPosition(selectedIndex);
|
|
28561
28646
|
}, [selectedValue, currentWidth]);
|
|
@@ -28571,7 +28656,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28571
28656
|
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: [
|
|
28572
28657
|
options.map((option, index) => {
|
|
28573
28658
|
var _a;
|
|
28574
|
-
return /* @__PURE__ */ (0,
|
|
28659
|
+
return /* @__PURE__ */ (0, import_react156.createElement)(
|
|
28575
28660
|
Tab,
|
|
28576
28661
|
__spreadProps(__spreadValues({}, option), {
|
|
28577
28662
|
key: option.value,
|
|
@@ -28589,7 +28674,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
28589
28674
|
};
|
|
28590
28675
|
|
|
28591
28676
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
28592
|
-
var
|
|
28677
|
+
var import_date_fns44 = require("date-fns");
|
|
28593
28678
|
var import_jsx_runtime254 = require("react/jsx-runtime");
|
|
28594
28679
|
var TasksYearsTabs = () => {
|
|
28595
28680
|
const { date } = useGlobalDate();
|
|
@@ -28597,13 +28682,13 @@ var TasksYearsTabs = () => {
|
|
|
28597
28682
|
const activeYear = date.getFullYear();
|
|
28598
28683
|
const { yearStatuses } = useBookkeepingYearsStatus();
|
|
28599
28684
|
const setCurrentYear = (year) => {
|
|
28600
|
-
const currentMonth = (0,
|
|
28685
|
+
const currentMonth = (0, import_date_fns44.getMonth)(date);
|
|
28601
28686
|
setMonthByPeriod({
|
|
28602
28687
|
monthNumber: currentMonth + 1,
|
|
28603
28688
|
yearNumber: Number(year)
|
|
28604
28689
|
});
|
|
28605
28690
|
};
|
|
28606
|
-
const yearsList = (0,
|
|
28691
|
+
const yearsList = (0, import_react157.useMemo)(() => {
|
|
28607
28692
|
return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
|
|
28608
28693
|
return {
|
|
28609
28694
|
value: `${y.year}`,
|
|
@@ -28611,7 +28696,7 @@ var TasksYearsTabs = () => {
|
|
|
28611
28696
|
badge: !y.completed && y.unresolvedTasks ? /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(
|
|
28612
28697
|
TaskStatusBadge,
|
|
28613
28698
|
{
|
|
28614
|
-
status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" : "CLOSED_COMPLETE"
|
|
28699
|
+
status: y.unresolvedTasks ? "IN_PROGRESS_AWAITING_CUSTOMER" /* IN_PROGRESS_AWAITING_CUSTOMER */ : "CLOSED_COMPLETE" /* CLOSED_COMPLETE */,
|
|
28615
28700
|
tasksCount: y.unresolvedTasks
|
|
28616
28701
|
}
|
|
28617
28702
|
) : null
|
|
@@ -28706,40 +28791,40 @@ function Tasks({
|
|
|
28706
28791
|
}
|
|
28707
28792
|
|
|
28708
28793
|
// src/components/PlatformOnboarding/LinkAccounts.tsx
|
|
28709
|
-
var
|
|
28794
|
+
var import_react161 = require("react");
|
|
28710
28795
|
|
|
28711
28796
|
// src/components/PlatformOnboarding/Steps/LinkAccountsConfirmationStep.tsx
|
|
28712
|
-
var
|
|
28797
|
+
var import_react159 = require("react");
|
|
28713
28798
|
var import_react_form2 = require("@tanstack/react-form");
|
|
28714
28799
|
|
|
28715
28800
|
// src/components/Wizard/Wizard.tsx
|
|
28716
|
-
var
|
|
28801
|
+
var import_react158 = require("react");
|
|
28717
28802
|
var import_jsx_runtime257 = require("react/jsx-runtime");
|
|
28718
28803
|
function useWizardStep({
|
|
28719
28804
|
steps,
|
|
28720
28805
|
onComplete
|
|
28721
28806
|
}) {
|
|
28722
28807
|
const stepCount = steps.length;
|
|
28723
|
-
const [activeStepIndex, setActiveStepIndex] = (0,
|
|
28724
|
-
const next = (0,
|
|
28808
|
+
const [activeStepIndex, setActiveStepIndex] = (0, import_react158.useState)(0);
|
|
28809
|
+
const next = (0, import_react158.useCallback)(() => __async(null, null, function* () {
|
|
28725
28810
|
setActiveStepIndex((stepIndex) => Math.min(stepIndex + 1, stepCount - 1));
|
|
28726
28811
|
if (activeStepIndex === stepCount - 1 && onComplete) {
|
|
28727
28812
|
yield onComplete == null ? void 0 : onComplete();
|
|
28728
28813
|
}
|
|
28729
28814
|
}), [stepCount, activeStepIndex, onComplete]);
|
|
28730
|
-
const previous = (0,
|
|
28815
|
+
const previous = (0, import_react158.useCallback)(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
|
|
28731
28816
|
const effectiveStepIndex = Math.min(activeStepIndex, stepCount - 1);
|
|
28732
28817
|
const currentStep = steps.at(effectiveStepIndex);
|
|
28733
28818
|
return { currentStep, next, previous };
|
|
28734
28819
|
}
|
|
28735
|
-
var WizardContext = (0,
|
|
28820
|
+
var WizardContext = (0, import_react158.createContext)({
|
|
28736
28821
|
next: () => {
|
|
28737
28822
|
},
|
|
28738
28823
|
previous: () => {
|
|
28739
28824
|
}
|
|
28740
28825
|
});
|
|
28741
28826
|
function useWizard() {
|
|
28742
|
-
return (0,
|
|
28827
|
+
return (0, import_react158.useContext)(WizardContext);
|
|
28743
28828
|
}
|
|
28744
28829
|
function Wizard({
|
|
28745
28830
|
Header: Header4,
|
|
@@ -28747,12 +28832,12 @@ function Wizard({
|
|
|
28747
28832
|
onComplete,
|
|
28748
28833
|
children
|
|
28749
28834
|
}) {
|
|
28750
|
-
const childrenArray =
|
|
28835
|
+
const childrenArray = import_react158.Children.toArray(children);
|
|
28751
28836
|
const { currentStep, next, previous } = useWizardStep({
|
|
28752
28837
|
steps: childrenArray,
|
|
28753
28838
|
onComplete
|
|
28754
28839
|
});
|
|
28755
|
-
const value = (0,
|
|
28840
|
+
const value = (0, import_react158.useMemo)(() => ({ next, previous }), [next, previous]);
|
|
28756
28841
|
return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(WizardContext.Provider, { value, children: [
|
|
28757
28842
|
Header4,
|
|
28758
28843
|
currentStep,
|
|
@@ -28793,7 +28878,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28793
28878
|
data: linkedAccounts,
|
|
28794
28879
|
loadingStatus: linkedAccountsLoadingStatus,
|
|
28795
28880
|
refetchAccounts
|
|
28796
|
-
} = (0,
|
|
28881
|
+
} = (0, import_react159.useContext)(LinkedAccountsContext);
|
|
28797
28882
|
const effectiveLinkedAccounts = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
28798
28883
|
const { trigger } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
|
|
28799
28884
|
const { previous, next } = useWizard();
|
|
@@ -28866,7 +28951,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28866
28951
|
}
|
|
28867
28952
|
|
|
28868
28953
|
// src/components/PlatformOnboarding/Steps/LinkAccountsLinkStep.tsx
|
|
28869
|
-
var
|
|
28954
|
+
var import_react160 = require("react");
|
|
28870
28955
|
var import_pluralize4 = __toESM(require("pluralize"));
|
|
28871
28956
|
|
|
28872
28957
|
// src/components/Separator/Separator.tsx
|
|
@@ -28885,7 +28970,7 @@ function LinkAccountsLinkStep() {
|
|
|
28885
28970
|
error,
|
|
28886
28971
|
refetchAccounts,
|
|
28887
28972
|
addConnection
|
|
28888
|
-
} = (0,
|
|
28973
|
+
} = (0, import_react160.useContext)(LinkedAccountsContext);
|
|
28889
28974
|
const { next } = useWizard();
|
|
28890
28975
|
const effectiveAccounts = data != null ? data : [];
|
|
28891
28976
|
return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_jsx_runtime261.Fragment, { children: [
|
|
@@ -28965,7 +29050,7 @@ function LinkAccounts(props) {
|
|
|
28965
29050
|
function LinkAccountsContent({
|
|
28966
29051
|
onComplete
|
|
28967
29052
|
}) {
|
|
28968
|
-
const { data: linkedAccounts, loadingStatus } = (0,
|
|
29053
|
+
const { data: linkedAccounts, loadingStatus } = (0, import_react161.useContext)(LinkedAccountsContext);
|
|
28969
29054
|
const linkedAccountsNeedingConfirmation = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
28970
29055
|
const hideConfirmationStep = loadingStatus === "complete" && linkedAccountsNeedingConfirmation.length === 0;
|
|
28971
29056
|
return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("section", { className: "Layer__link-accounts Layer__component", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
|
|
@@ -28983,7 +29068,7 @@ function LinkAccountsContent({
|
|
|
28983
29068
|
}
|
|
28984
29069
|
|
|
28985
29070
|
// src/components/PlatformOnboarding/PlatformOnboarding.tsx
|
|
28986
|
-
var
|
|
29071
|
+
var import_react166 = require("react");
|
|
28987
29072
|
|
|
28988
29073
|
// src/components/ProgressSteps/ProgressSteps.tsx
|
|
28989
29074
|
var import_jsx_runtime263 = require("react/jsx-runtime");
|
|
@@ -29380,7 +29465,7 @@ function useBusinessPersonnel() {
|
|
|
29380
29465
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
29381
29466
|
var import_mutation16 = __toESM(require("swr/mutation"));
|
|
29382
29467
|
var import_swr27 = require("swr");
|
|
29383
|
-
var
|
|
29468
|
+
var import_react162 = require("react");
|
|
29384
29469
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
29385
29470
|
function buildKey26({
|
|
29386
29471
|
access_token: accessToken,
|
|
@@ -29418,7 +29503,7 @@ function useCreateBusinessPersonnel() {
|
|
|
29418
29503
|
}
|
|
29419
29504
|
);
|
|
29420
29505
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29421
|
-
const stableProxiedTrigger = (0,
|
|
29506
|
+
const stableProxiedTrigger = (0, import_react162.useCallback)(
|
|
29422
29507
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29423
29508
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29424
29509
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29452,7 +29537,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
29452
29537
|
});
|
|
29453
29538
|
|
|
29454
29539
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29455
|
-
var
|
|
29540
|
+
var import_react163 = require("react");
|
|
29456
29541
|
function buildKey27({
|
|
29457
29542
|
access_token: accessToken,
|
|
29458
29543
|
apiUrl,
|
|
@@ -29495,7 +29580,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29495
29580
|
}
|
|
29496
29581
|
);
|
|
29497
29582
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29498
|
-
const stableProxiedTrigger = (0,
|
|
29583
|
+
const stableProxiedTrigger = (0, import_react163.useCallback)(
|
|
29499
29584
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29500
29585
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29501
29586
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29522,7 +29607,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29522
29607
|
// src/hooks/business/useUpdateBusiness.ts
|
|
29523
29608
|
var import_mutation18 = __toESM(require("swr/mutation"));
|
|
29524
29609
|
var import_swr29 = require("swr");
|
|
29525
|
-
var
|
|
29610
|
+
var import_react164 = require("react");
|
|
29526
29611
|
var BUSINESS_TAG_KEY = "business";
|
|
29527
29612
|
function buildKey28({
|
|
29528
29613
|
access_token: accessToken,
|
|
@@ -29560,7 +29645,7 @@ function useUpdateBusiness() {
|
|
|
29560
29645
|
}
|
|
29561
29646
|
);
|
|
29562
29647
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29563
|
-
const stableProxiedTrigger = (0,
|
|
29648
|
+
const stableProxiedTrigger = (0, import_react164.useCallback)(
|
|
29564
29649
|
(...triggerParameters) => __async(null, null, function* () {
|
|
29565
29650
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29566
29651
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -29585,7 +29670,7 @@ function useUpdateBusiness() {
|
|
|
29585
29670
|
}
|
|
29586
29671
|
|
|
29587
29672
|
// src/components/BusinessForm/useBusinessForm.ts
|
|
29588
|
-
var
|
|
29673
|
+
var import_react165 = require("react");
|
|
29589
29674
|
var getPerson = (personnel) => {
|
|
29590
29675
|
const owners = personnel == null ? void 0 : personnel.filter((p) => p.roles.find((x) => x.role === "OWNER"));
|
|
29591
29676
|
if (owners && owners.length > 0) {
|
|
@@ -29596,7 +29681,7 @@ var getPerson = (personnel) => {
|
|
|
29596
29681
|
var useBusinessForm = ({ onSuccess }) => {
|
|
29597
29682
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
29598
29683
|
const { business } = useLayerContext();
|
|
29599
|
-
const [submitError, setSubmitError] = (0,
|
|
29684
|
+
const [submitError, setSubmitError] = (0, import_react165.useState)(void 0);
|
|
29600
29685
|
const { data: personnel } = useBusinessPersonnel();
|
|
29601
29686
|
const person = getPerson(personnel);
|
|
29602
29687
|
const { trigger: createBusinessPersonnel2 } = useCreateBusinessPersonnel();
|
|
@@ -30012,7 +30097,7 @@ var PLATFORM_ONBOARDING_STEPS = [
|
|
|
30012
30097
|
}
|
|
30013
30098
|
];
|
|
30014
30099
|
var PlatformOnboarding = ({ onComplete }) => {
|
|
30015
|
-
const [step, setStep] = (0,
|
|
30100
|
+
const [step, setStep] = (0, import_react166.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
|
|
30016
30101
|
const isFirstStep = PLATFORM_ONBOARDING_STEPS[0].id === step;
|
|
30017
30102
|
const nextStep = () => {
|
|
30018
30103
|
const currentStepIndex = PLATFORM_ONBOARDING_STEPS.findIndex((s) => s.id === step);
|
|
@@ -30174,7 +30259,7 @@ var BookkeepingUpsellBar = ({
|
|
|
30174
30259
|
};
|
|
30175
30260
|
|
|
30176
30261
|
// src/views/BookkeepingOverview/BookkeepingOverview.tsx
|
|
30177
|
-
var
|
|
30262
|
+
var import_react168 = require("react");
|
|
30178
30263
|
|
|
30179
30264
|
// src/views/BookkeepingOverview/internal/BookkeepingProfitAndLossSummariesContainer.tsx
|
|
30180
30265
|
var import_jsx_runtime277 = require("react/jsx-runtime");
|
|
@@ -30189,15 +30274,15 @@ function BookkeepingProfitAndLossSummariesContainer({
|
|
|
30189
30274
|
var import_classnames75 = __toESM(require("classnames"));
|
|
30190
30275
|
|
|
30191
30276
|
// src/views/BookkeepingOverview/useKeepInMobileViewport.tsx
|
|
30192
|
-
var
|
|
30277
|
+
var import_react167 = require("react");
|
|
30193
30278
|
var TASKS_MOBILE_VIEWPORT_WIDTH = 1100;
|
|
30194
30279
|
var useKeepInMobileViewport = () => {
|
|
30195
|
-
const upperContentRef = (0,
|
|
30196
|
-
const targetElementRef = (0,
|
|
30197
|
-
const lastKnownSizeRef = (0,
|
|
30198
|
-
const lastKnownTargetPositionRef = (0,
|
|
30199
|
-
const upperElementInFocus = (0,
|
|
30200
|
-
(0,
|
|
30280
|
+
const upperContentRef = (0, import_react167.useRef)(null);
|
|
30281
|
+
const targetElementRef = (0, import_react167.useRef)(null);
|
|
30282
|
+
const lastKnownSizeRef = (0, import_react167.useRef)(null);
|
|
30283
|
+
const lastKnownTargetPositionRef = (0, import_react167.useRef)(null);
|
|
30284
|
+
const upperElementInFocus = (0, import_react167.useRef)(false);
|
|
30285
|
+
(0, import_react167.useEffect)(() => {
|
|
30201
30286
|
if (!upperContentRef.current || !targetElementRef.current) return;
|
|
30202
30287
|
lastKnownSizeRef.current = upperContentRef.current.getBoundingClientRect().height;
|
|
30203
30288
|
lastKnownTargetPositionRef.current = targetElementRef.current.getBoundingClientRect().top;
|
|
@@ -30254,7 +30339,7 @@ var BookkeepingOverview = ({
|
|
|
30254
30339
|
slotProps
|
|
30255
30340
|
}) => {
|
|
30256
30341
|
var _a, _b, _c, _d, _e, _f;
|
|
30257
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
30342
|
+
const [pnlToggle, setPnlToggle] = (0, import_react168.useState)("expenses");
|
|
30258
30343
|
const [width] = useWindowSize();
|
|
30259
30344
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
30260
30345
|
const { upperContentRef, targetElementRef, upperElementInFocus } = useKeepInMobileViewport();
|
|
@@ -30385,7 +30470,7 @@ var BookkeepingOverview = ({
|
|
|
30385
30470
|
};
|
|
30386
30471
|
|
|
30387
30472
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
30388
|
-
var
|
|
30473
|
+
var import_react169 = require("react");
|
|
30389
30474
|
var import_classnames76 = __toESM(require("classnames"));
|
|
30390
30475
|
var import_jsx_runtime279 = require("react/jsx-runtime");
|
|
30391
30476
|
var AccountingOverview = ({
|
|
@@ -30401,7 +30486,7 @@ var AccountingOverview = ({
|
|
|
30401
30486
|
slotProps
|
|
30402
30487
|
}) => {
|
|
30403
30488
|
var _a, _b, _c, _d, _e;
|
|
30404
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
30489
|
+
const [pnlToggle, setPnlToggle] = (0, import_react169.useState)("expenses");
|
|
30405
30490
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
30406
30491
|
return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
|
|
30407
30492
|
ProfitAndLoss,
|
|
@@ -30568,7 +30653,7 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
30568
30653
|
};
|
|
30569
30654
|
|
|
30570
30655
|
// src/views/GeneralLedger/GeneralLedger.tsx
|
|
30571
|
-
var
|
|
30656
|
+
var import_react170 = require("react");
|
|
30572
30657
|
var import_jsx_runtime281 = require("react/jsx-runtime");
|
|
30573
30658
|
var GeneralLedgerView = ({
|
|
30574
30659
|
title,
|
|
@@ -30577,7 +30662,7 @@ var GeneralLedgerView = ({
|
|
|
30577
30662
|
stringOverrides,
|
|
30578
30663
|
chartOfAccountsOptions
|
|
30579
30664
|
}) => {
|
|
30580
|
-
const [activeTab, setActiveTab] = (0,
|
|
30665
|
+
const [activeTab, setActiveTab] = (0, import_react170.useState)("chartOfAccounts");
|
|
30581
30666
|
return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(ProfitAndLoss, { asContainer: false, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
|
|
30582
30667
|
View,
|
|
30583
30668
|
{
|
|
@@ -30619,7 +30704,7 @@ var GeneralLedgerView = ({
|
|
|
30619
30704
|
};
|
|
30620
30705
|
|
|
30621
30706
|
// src/views/ProjectProfitability/ProjectProfitability.tsx
|
|
30622
|
-
var
|
|
30707
|
+
var import_react171 = require("react");
|
|
30623
30708
|
var import_react_select5 = __toESM(require("react-select"));
|
|
30624
30709
|
var import_jsx_runtime282 = require("react/jsx-runtime");
|
|
30625
30710
|
var ProjectProfitabilityView = ({
|
|
@@ -30629,9 +30714,9 @@ var ProjectProfitabilityView = ({
|
|
|
30629
30714
|
datePickerMode = "monthPicker",
|
|
30630
30715
|
csvMoneyFormat = "DOLLAR_STRING"
|
|
30631
30716
|
}) => {
|
|
30632
|
-
const [activeTab, setActiveTab] = (0,
|
|
30633
|
-
const [tagFilter, setTagFilter] = (0,
|
|
30634
|
-
const [pnlTagFilter, setPnlTagFilter] = (0,
|
|
30717
|
+
const [activeTab, setActiveTab] = (0, import_react171.useState)("overview");
|
|
30718
|
+
const [tagFilter, setTagFilter] = (0, import_react171.useState)(null);
|
|
30719
|
+
const [pnlTagFilter, setPnlTagFilter] = (0, import_react171.useState)(
|
|
30635
30720
|
void 0
|
|
30636
30721
|
);
|
|
30637
30722
|
const isOptionSelected = (option, selectValue) => {
|
|
@@ -30730,7 +30815,7 @@ var ProjectProfitabilityView = ({
|
|
|
30730
30815
|
};
|
|
30731
30816
|
|
|
30732
30817
|
// src/views/Reports/Reports.tsx
|
|
30733
|
-
var
|
|
30818
|
+
var import_react172 = require("react");
|
|
30734
30819
|
var import_jsx_runtime283 = require("react/jsx-runtime");
|
|
30735
30820
|
var getOptions = (enabledReports) => {
|
|
30736
30821
|
return [
|
|
@@ -30758,7 +30843,7 @@ var Reports = ({
|
|
|
30758
30843
|
statementOfCashFlowConfig
|
|
30759
30844
|
}) => {
|
|
30760
30845
|
var _a;
|
|
30761
|
-
const [activeTab, setActiveTab] = (0,
|
|
30846
|
+
const [activeTab, setActiveTab] = (0, import_react172.useState)(enabledReports[0]);
|
|
30762
30847
|
const { view, containerRef } = useElementViewSize();
|
|
30763
30848
|
const options = getOptions(enabledReports);
|
|
30764
30849
|
const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value = enabledReports[0])) == null ? void 0 : _a.label;
|
|
@@ -30820,11 +30905,11 @@ var ReportsPanel = ({
|
|
|
30820
30905
|
};
|
|
30821
30906
|
|
|
30822
30907
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
30823
|
-
var
|
|
30908
|
+
var import_react173 = require("react");
|
|
30824
30909
|
var import_jsx_runtime284 = require("react/jsx-runtime");
|
|
30825
30910
|
var COMPONENT_NAME8 = "profit-and-loss";
|
|
30826
30911
|
var ProfitAndLossView = (props) => {
|
|
30827
|
-
const containerRef = (0,
|
|
30912
|
+
const containerRef = (0, import_react173.useRef)(null);
|
|
30828
30913
|
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)) }) });
|
|
30829
30914
|
};
|
|
30830
30915
|
var ProfitAndLossPanel = (_a) => {
|
|
@@ -30835,7 +30920,7 @@ var ProfitAndLossPanel = (_a) => {
|
|
|
30835
30920
|
"containerRef",
|
|
30836
30921
|
"stringOverrides"
|
|
30837
30922
|
]);
|
|
30838
|
-
const { sidebarScope } = (0,
|
|
30923
|
+
const { sidebarScope } = (0, import_react173.useContext)(ProfitAndLoss.Context);
|
|
30839
30924
|
return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
|
|
30840
30925
|
Panel,
|
|
30841
30926
|
{
|
|
@@ -30866,7 +30951,7 @@ var Components = ({
|
|
|
30866
30951
|
hideTable = false,
|
|
30867
30952
|
stringOverrides
|
|
30868
30953
|
}) => {
|
|
30869
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
30954
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react173.useContext)(
|
|
30870
30955
|
ProfitAndLoss.Context
|
|
30871
30956
|
);
|
|
30872
30957
|
if (!isLoading && error) {
|
|
@@ -30938,7 +31023,6 @@ var Components = ({
|
|
|
30938
31023
|
ProfitAndLoss,
|
|
30939
31024
|
ProfitAndLossView,
|
|
30940
31025
|
ProjectProfitabilityView,
|
|
30941
|
-
Quickbooks,
|
|
30942
31026
|
Reports,
|
|
30943
31027
|
StatementOfCashFlow,
|
|
30944
31028
|
Tasks,
|