@layerfi/components 0.1.104 → 0.1.105
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 +427 -240
- package/dist/esm/index.mjs +310 -123
- package/dist/index.css +23 -23
- package/dist/index.d.ts +56 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -3899,7 +3899,7 @@ var require_lodash = __commonJS({
|
|
|
3899
3899
|
result2.placeholder = curryRight.placeholder;
|
|
3900
3900
|
return result2;
|
|
3901
3901
|
}
|
|
3902
|
-
function
|
|
3902
|
+
function debounce6(func, wait, options) {
|
|
3903
3903
|
var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
3904
3904
|
if (typeof func != "function") {
|
|
3905
3905
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
@@ -4079,7 +4079,7 @@ var require_lodash = __commonJS({
|
|
|
4079
4079
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4080
4080
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4081
4081
|
}
|
|
4082
|
-
return
|
|
4082
|
+
return debounce6(func, wait, {
|
|
4083
4083
|
"leading": leading,
|
|
4084
4084
|
"maxWait": wait,
|
|
4085
4085
|
"trailing": trailing
|
|
@@ -5093,7 +5093,7 @@ var require_lodash = __commonJS({
|
|
|
5093
5093
|
lodash.create = create;
|
|
5094
5094
|
lodash.curry = curry;
|
|
5095
5095
|
lodash.curryRight = curryRight;
|
|
5096
|
-
lodash.debounce =
|
|
5096
|
+
lodash.debounce = debounce6;
|
|
5097
5097
|
lodash.defaults = defaults;
|
|
5098
5098
|
lodash.defaultsDeep = defaultsDeep;
|
|
5099
5099
|
lodash.defer = defer;
|
|
@@ -5602,7 +5602,7 @@ var import_react12 = require("react");
|
|
|
5602
5602
|
var import_react10 = require("react");
|
|
5603
5603
|
|
|
5604
5604
|
// package.json
|
|
5605
|
-
var version = "0.1.
|
|
5605
|
+
var version = "0.1.105";
|
|
5606
5606
|
|
|
5607
5607
|
// src/models/APIError.ts
|
|
5608
5608
|
var APIError = class _APIError extends Error {
|
|
@@ -27431,7 +27431,7 @@ var StatementOfCashFlowView = ({
|
|
|
27431
27431
|
};
|
|
27432
27432
|
|
|
27433
27433
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
27434
|
-
var
|
|
27434
|
+
var import_react171 = require("react");
|
|
27435
27435
|
|
|
27436
27436
|
// src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
|
|
27437
27437
|
var import_react157 = require("react");
|
|
@@ -27486,6 +27486,9 @@ var LedgerAccountsContext = (0, import_react158.createContext)({
|
|
|
27486
27486
|
setSelectedEntryId: () => {
|
|
27487
27487
|
},
|
|
27488
27488
|
closeSelectedEntry: () => {
|
|
27489
|
+
},
|
|
27490
|
+
hasMore: false,
|
|
27491
|
+
fetchMore: () => {
|
|
27489
27492
|
}
|
|
27490
27493
|
});
|
|
27491
27494
|
|
|
@@ -28126,25 +28129,187 @@ var import_swr23 = require("swr");
|
|
|
28126
28129
|
var import_react160 = require("react");
|
|
28127
28130
|
|
|
28128
28131
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
28129
|
-
var
|
|
28132
|
+
var import_react162 = require("react");
|
|
28130
28133
|
var import_swr24 = __toESM(require("swr"));
|
|
28131
|
-
|
|
28132
|
-
|
|
28134
|
+
|
|
28135
|
+
// src/features/ledger/accounts/[ledgerAccountId]/api/useListLedgerAccountLines.ts
|
|
28136
|
+
var import_infinite4 = __toESM(require("swr/infinite"));
|
|
28137
|
+
var import_react161 = require("react");
|
|
28138
|
+
var import_lodash4 = __toESM(require_lodash());
|
|
28139
|
+
var LIST_LEDGER_ACCOUNT_LINES_TAG_KEY = "#list-ledger-account-lines";
|
|
28140
|
+
var listLedgerAccountLines = get(({
|
|
28141
|
+
businessId,
|
|
28142
|
+
accountId,
|
|
28143
|
+
include_entries_before_activation,
|
|
28144
|
+
include_child_account_lines,
|
|
28145
|
+
start_date,
|
|
28146
|
+
end_date,
|
|
28147
|
+
sort_by,
|
|
28148
|
+
sort_order,
|
|
28149
|
+
cursor,
|
|
28150
|
+
limit,
|
|
28151
|
+
show_total_count
|
|
28152
|
+
}) => {
|
|
28153
|
+
const parameters = toDefinedSearchParameters({
|
|
28154
|
+
include_entries_before_activation,
|
|
28155
|
+
include_child_account_lines,
|
|
28156
|
+
start_date,
|
|
28157
|
+
end_date,
|
|
28158
|
+
sort_by,
|
|
28159
|
+
sort_order,
|
|
28160
|
+
cursor,
|
|
28161
|
+
limit,
|
|
28162
|
+
show_total_count
|
|
28163
|
+
});
|
|
28164
|
+
return `/v1/businesses/${businessId}/ledger/accounts/${accountId}/lines?${parameters}`;
|
|
28165
|
+
});
|
|
28166
|
+
function keyLoader4(previousPageData, {
|
|
28167
|
+
access_token: accessToken,
|
|
28168
|
+
apiUrl,
|
|
28169
|
+
businessId,
|
|
28170
|
+
accountId,
|
|
28171
|
+
include_entries_before_activation,
|
|
28172
|
+
include_child_account_lines,
|
|
28173
|
+
start_date,
|
|
28174
|
+
end_date,
|
|
28175
|
+
sort_by,
|
|
28176
|
+
sort_order,
|
|
28177
|
+
limit,
|
|
28178
|
+
show_total_count
|
|
28179
|
+
}) {
|
|
28180
|
+
var _a;
|
|
28181
|
+
if (accessToken && apiUrl && accountId) {
|
|
28182
|
+
return {
|
|
28183
|
+
accessToken,
|
|
28184
|
+
apiUrl,
|
|
28185
|
+
businessId,
|
|
28186
|
+
accountId,
|
|
28187
|
+
cursor: (_a = previousPageData == null ? void 0 : previousPageData.meta) == null ? void 0 : _a.pagination.cursor,
|
|
28188
|
+
include_entries_before_activation,
|
|
28189
|
+
include_child_account_lines,
|
|
28190
|
+
start_date,
|
|
28191
|
+
end_date,
|
|
28192
|
+
sort_by,
|
|
28193
|
+
sort_order,
|
|
28194
|
+
limit,
|
|
28195
|
+
show_total_count,
|
|
28196
|
+
tags: [LIST_LEDGER_ACCOUNT_LINES_TAG_KEY]
|
|
28197
|
+
};
|
|
28198
|
+
}
|
|
28199
|
+
}
|
|
28200
|
+
function useListLedgerAccountLines({
|
|
28201
|
+
accountId,
|
|
28202
|
+
include_entries_before_activation,
|
|
28203
|
+
include_child_account_lines,
|
|
28204
|
+
start_date,
|
|
28205
|
+
end_date,
|
|
28206
|
+
sort_by,
|
|
28207
|
+
sort_order,
|
|
28208
|
+
limit,
|
|
28209
|
+
show_total_count
|
|
28210
|
+
}) {
|
|
28211
|
+
const { businessId } = useLayerContext();
|
|
28133
28212
|
const { apiUrl } = useEnvironment();
|
|
28134
28213
|
const { data: auth } = useAuth();
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
28141
|
-
params: {
|
|
28214
|
+
return (0, import_infinite4.default)(
|
|
28215
|
+
(index, previousPageData) => keyLoader4(
|
|
28216
|
+
previousPageData,
|
|
28217
|
+
__spreadProps(__spreadValues({}, auth), {
|
|
28218
|
+
apiUrl,
|
|
28142
28219
|
businessId,
|
|
28143
28220
|
accountId,
|
|
28144
|
-
|
|
28221
|
+
include_entries_before_activation,
|
|
28222
|
+
include_child_account_lines,
|
|
28223
|
+
start_date,
|
|
28224
|
+
end_date,
|
|
28225
|
+
sort_by,
|
|
28226
|
+
sort_order,
|
|
28227
|
+
limit,
|
|
28228
|
+
show_total_count
|
|
28229
|
+
})
|
|
28230
|
+
),
|
|
28231
|
+
({
|
|
28232
|
+
accessToken,
|
|
28233
|
+
apiUrl: apiUrl2,
|
|
28234
|
+
businessId: businessId2,
|
|
28235
|
+
accountId: accountId2,
|
|
28236
|
+
cursor,
|
|
28237
|
+
include_entries_before_activation: include_entries_before_activation2,
|
|
28238
|
+
include_child_account_lines: include_child_account_lines2,
|
|
28239
|
+
start_date: start_date2,
|
|
28240
|
+
end_date: end_date2,
|
|
28241
|
+
sort_by: sort_by2,
|
|
28242
|
+
sort_order: sort_order2,
|
|
28243
|
+
limit: limit2,
|
|
28244
|
+
show_total_count: show_total_count2
|
|
28245
|
+
}) => listLedgerAccountLines(
|
|
28246
|
+
apiUrl2,
|
|
28247
|
+
accessToken,
|
|
28248
|
+
{
|
|
28249
|
+
params: {
|
|
28250
|
+
businessId: businessId2,
|
|
28251
|
+
accountId: accountId2,
|
|
28252
|
+
cursor,
|
|
28253
|
+
include_entries_before_activation: include_entries_before_activation2,
|
|
28254
|
+
include_child_account_lines: include_child_account_lines2,
|
|
28255
|
+
start_date: start_date2,
|
|
28256
|
+
end_date: end_date2,
|
|
28257
|
+
sort_by: sort_by2,
|
|
28258
|
+
sort_order: sort_order2,
|
|
28259
|
+
limit: limit2,
|
|
28260
|
+
show_total_count: show_total_count2
|
|
28261
|
+
}
|
|
28145
28262
|
}
|
|
28146
|
-
|
|
28263
|
+
)(),
|
|
28264
|
+
{
|
|
28265
|
+
keepPreviousData: true,
|
|
28266
|
+
revalidateAll: false,
|
|
28267
|
+
revalidateFirstPage: false,
|
|
28268
|
+
initialSize: 1
|
|
28269
|
+
}
|
|
28147
28270
|
);
|
|
28271
|
+
}
|
|
28272
|
+
|
|
28273
|
+
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
28274
|
+
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
28275
|
+
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
28276
|
+
const { apiUrl } = useEnvironment();
|
|
28277
|
+
const { data: auth } = useAuth();
|
|
28278
|
+
const [accountId, setAccountId] = (0, import_react162.useState)();
|
|
28279
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react162.useState)();
|
|
28280
|
+
const {
|
|
28281
|
+
data: paginatedData,
|
|
28282
|
+
isLoading: paginationIsLoading,
|
|
28283
|
+
isValidating: paginationIsValidating,
|
|
28284
|
+
error: paginationError,
|
|
28285
|
+
mutate,
|
|
28286
|
+
size,
|
|
28287
|
+
setSize
|
|
28288
|
+
} = useListLedgerAccountLines({
|
|
28289
|
+
accountId: accountId || "",
|
|
28290
|
+
include_child_account_lines: true,
|
|
28291
|
+
sort_by: "entry_at",
|
|
28292
|
+
sort_order: "DESC",
|
|
28293
|
+
limit: 150
|
|
28294
|
+
});
|
|
28295
|
+
const shouldFetch = Boolean(accountId);
|
|
28296
|
+
const data = (0, import_react162.useMemo)(() => {
|
|
28297
|
+
if (!paginatedData || !shouldFetch) return void 0;
|
|
28298
|
+
return paginatedData.flatMap((page) => page.data);
|
|
28299
|
+
}, [paginatedData, shouldFetch, showReversalEntries]);
|
|
28300
|
+
const hasMore = (0, import_react162.useMemo)(() => {
|
|
28301
|
+
var _a, _b;
|
|
28302
|
+
if (!shouldFetch || !paginatedData || paginatedData.length === 0) return false;
|
|
28303
|
+
const lastPage = paginatedData[paginatedData.length - 1];
|
|
28304
|
+
return Boolean(
|
|
28305
|
+
((_a = lastPage.meta) == null ? void 0 : _a.pagination.cursor) && ((_b = lastPage.meta) == null ? void 0 : _b.pagination.has_more)
|
|
28306
|
+
);
|
|
28307
|
+
}, [paginatedData, shouldFetch]);
|
|
28308
|
+
const fetchMore = (0, import_react162.useCallback)(() => {
|
|
28309
|
+
if (hasMore && shouldFetch) {
|
|
28310
|
+
setSize(size + 1);
|
|
28311
|
+
}
|
|
28312
|
+
}, [hasMore, setSize, size, shouldFetch]);
|
|
28148
28313
|
const {
|
|
28149
28314
|
data: entryData,
|
|
28150
28315
|
mutate: mutateEntryData,
|
|
@@ -28162,36 +28327,41 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
28162
28327
|
setSelectedEntryId(void 0);
|
|
28163
28328
|
void mutateEntryData();
|
|
28164
28329
|
};
|
|
28165
|
-
(0,
|
|
28166
|
-
|
|
28330
|
+
const queryKey = (0, import_react162.useMemo)(() => {
|
|
28331
|
+
return businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
28332
|
+
}, [businessId, accountId, auth == null ? void 0 : auth.access_token]);
|
|
28333
|
+
(0, import_react162.useEffect)(() => {
|
|
28334
|
+
if (queryKey && shouldFetch && (paginationIsLoading || paginationIsValidating)) {
|
|
28167
28335
|
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
28168
28336
|
}
|
|
28169
|
-
}, [
|
|
28170
|
-
(0,
|
|
28171
|
-
if (queryKey && hasBeenTouched(queryKey)) {
|
|
28337
|
+
}, [paginationIsLoading, paginationIsValidating, shouldFetch]);
|
|
28338
|
+
(0, import_react162.useEffect)(() => {
|
|
28339
|
+
if (queryKey && shouldFetch && hasBeenTouched(queryKey)) {
|
|
28172
28340
|
void refetch();
|
|
28173
28341
|
}
|
|
28174
|
-
}, [syncTimestamps, accountId]);
|
|
28342
|
+
}, [syncTimestamps, accountId, shouldFetch]);
|
|
28175
28343
|
return {
|
|
28176
|
-
data
|
|
28344
|
+
data,
|
|
28177
28345
|
entryData: entryData == null ? void 0 : entryData.data,
|
|
28178
|
-
isLoading,
|
|
28346
|
+
isLoading: shouldFetch ? paginationIsLoading : false,
|
|
28179
28347
|
isLoadingEntry,
|
|
28180
|
-
isValidating,
|
|
28181
|
-
isValdiatingEntry,
|
|
28182
|
-
error,
|
|
28348
|
+
isValidating: shouldFetch ? paginationIsValidating : false,
|
|
28349
|
+
isValidatingEntry: isValdiatingEntry,
|
|
28350
|
+
error: shouldFetch ? paginationError : void 0,
|
|
28183
28351
|
errorEntry,
|
|
28184
28352
|
refetch,
|
|
28185
28353
|
accountId,
|
|
28186
28354
|
setAccountId,
|
|
28187
28355
|
selectedEntryId,
|
|
28188
28356
|
setSelectedEntryId,
|
|
28189
|
-
closeSelectedEntry
|
|
28357
|
+
closeSelectedEntry,
|
|
28358
|
+
hasMore,
|
|
28359
|
+
fetchMore
|
|
28190
28360
|
};
|
|
28191
28361
|
};
|
|
28192
28362
|
|
|
28193
28363
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTableWithPanel.tsx
|
|
28194
|
-
var
|
|
28364
|
+
var import_react167 = require("react");
|
|
28195
28365
|
|
|
28196
28366
|
// src/icons/Plus.tsx
|
|
28197
28367
|
var import_jsx_runtime242 = require("react/jsx-runtime");
|
|
@@ -28232,11 +28402,11 @@ var Plus = (_a) => {
|
|
|
28232
28402
|
var Plus_default = Plus;
|
|
28233
28403
|
|
|
28234
28404
|
// src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
|
|
28235
|
-
var
|
|
28405
|
+
var import_react163 = require("react");
|
|
28236
28406
|
var import_date_fns37 = require("date-fns");
|
|
28237
28407
|
var import_jsx_runtime243 = require("react/jsx-runtime");
|
|
28238
28408
|
var ChartOfAccountsDatePicker = () => {
|
|
28239
|
-
const { changeDateRange, dateRange } = (0,
|
|
28409
|
+
const { changeDateRange, dateRange } = (0, import_react163.useContext)(ChartOfAccountsContext);
|
|
28240
28410
|
return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
|
|
28241
28411
|
DatePicker,
|
|
28242
28412
|
{
|
|
@@ -28255,13 +28425,13 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
28255
28425
|
};
|
|
28256
28426
|
|
|
28257
28427
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
28258
|
-
var
|
|
28428
|
+
var import_react165 = require("react");
|
|
28259
28429
|
|
|
28260
28430
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
28261
|
-
var
|
|
28431
|
+
var import_react164 = require("react");
|
|
28262
28432
|
var useParentOptions = (data) => {
|
|
28263
28433
|
var _a;
|
|
28264
|
-
return (0,
|
|
28434
|
+
return (0, import_react164.useMemo)(
|
|
28265
28435
|
() => 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) => {
|
|
28266
28436
|
return {
|
|
28267
28437
|
label: x.name,
|
|
@@ -28286,9 +28456,9 @@ var ChartOfAccountsForm = ({
|
|
|
28286
28456
|
submitForm,
|
|
28287
28457
|
sendingForm,
|
|
28288
28458
|
apiError
|
|
28289
|
-
} = (0,
|
|
28459
|
+
} = (0, import_react165.useContext)(ChartOfAccountsContext);
|
|
28290
28460
|
const parentOptions = useParentOptions(data);
|
|
28291
|
-
const entry = (0,
|
|
28461
|
+
const entry = (0, import_react165.useMemo)(() => {
|
|
28292
28462
|
if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
|
|
28293
28463
|
return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
|
|
28294
28464
|
(x) => x.id === form.accountId
|
|
@@ -28501,7 +28671,7 @@ var ChartOfAccountsSidebar = ({
|
|
|
28501
28671
|
};
|
|
28502
28672
|
|
|
28503
28673
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
28504
|
-
var
|
|
28674
|
+
var import_react166 = require("react");
|
|
28505
28675
|
|
|
28506
28676
|
// src/icons/Edit2.tsx
|
|
28507
28677
|
var import_jsx_runtime246 = require("react/jsx-runtime");
|
|
@@ -28721,11 +28891,11 @@ var ChartOfAccountsTableContent = ({
|
|
|
28721
28891
|
expandAll,
|
|
28722
28892
|
templateAccountsEditable
|
|
28723
28893
|
}) => {
|
|
28724
|
-
const { setAccountId } = (0,
|
|
28725
|
-
const { editAccount } = (0,
|
|
28726
|
-
const [toggledKeys, setToggledKeys] = (0,
|
|
28727
|
-
const sortedAccounts = (0,
|
|
28728
|
-
const allRowKeys = (0,
|
|
28894
|
+
const { setAccountId } = (0, import_react166.useContext)(LedgerAccountsContext);
|
|
28895
|
+
const { editAccount } = (0, import_react166.useContext)(ChartOfAccountsContext);
|
|
28896
|
+
const [toggledKeys, setToggledKeys] = (0, import_react166.useState)({});
|
|
28897
|
+
const sortedAccounts = (0, import_react166.useMemo)(() => sortAccountsRecursive(data.accounts), [data.accounts]);
|
|
28898
|
+
const allRowKeys = (0, import_react166.useMemo)(() => {
|
|
28729
28899
|
const keys = [];
|
|
28730
28900
|
const collect = (accounts) => {
|
|
28731
28901
|
for (const account of accounts) {
|
|
@@ -28739,7 +28909,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
28739
28909
|
collect(data.accounts);
|
|
28740
28910
|
return keys;
|
|
28741
28911
|
}, [data.accounts]);
|
|
28742
|
-
(0,
|
|
28912
|
+
(0, import_react166.useEffect)(() => {
|
|
28743
28913
|
if (expandAll === void 0) return;
|
|
28744
28914
|
setToggledKeys(
|
|
28745
28915
|
Object.fromEntries(
|
|
@@ -28747,10 +28917,10 @@ var ChartOfAccountsTableContent = ({
|
|
|
28747
28917
|
)
|
|
28748
28918
|
);
|
|
28749
28919
|
}, [expandAll]);
|
|
28750
|
-
(0,
|
|
28920
|
+
(0, import_react166.useEffect)(() => {
|
|
28751
28921
|
setToggledKeys({});
|
|
28752
28922
|
}, [searchQuery]);
|
|
28753
|
-
const filteredAccounts = (0,
|
|
28923
|
+
const filteredAccounts = (0, import_react166.useMemo)(() => {
|
|
28754
28924
|
if (!searchQuery) return sortedAccounts;
|
|
28755
28925
|
return filterAccounts(sortedAccounts, searchQuery.toLowerCase());
|
|
28756
28926
|
}, [searchQuery, sortedAccounts]);
|
|
@@ -28782,7 +28952,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
28782
28952
|
e.stopPropagation();
|
|
28783
28953
|
setAccountId(account.id);
|
|
28784
28954
|
};
|
|
28785
|
-
return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(
|
|
28955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(import_react166.Fragment, { children: [
|
|
28786
28956
|
/* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(
|
|
28787
28957
|
TableRow,
|
|
28788
28958
|
{
|
|
@@ -28991,8 +29161,8 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
28991
29161
|
stringOverrides,
|
|
28992
29162
|
templateAccountsEditable
|
|
28993
29163
|
}) => {
|
|
28994
|
-
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0,
|
|
28995
|
-
const [expandAll, setExpandAll] = (0,
|
|
29164
|
+
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react167.useContext)(ChartOfAccountsContext);
|
|
29165
|
+
const [expandAll, setExpandAll] = (0, import_react167.useState)();
|
|
28996
29166
|
const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: "" });
|
|
28997
29167
|
return /* @__PURE__ */ (0, import_jsx_runtime249.jsxs)(
|
|
28998
29168
|
Panel,
|
|
@@ -29085,10 +29255,10 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
29085
29255
|
};
|
|
29086
29256
|
|
|
29087
29257
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
29088
|
-
var
|
|
29258
|
+
var import_react170 = require("react");
|
|
29089
29259
|
|
|
29090
29260
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
29091
|
-
var
|
|
29261
|
+
var import_react168 = require("react");
|
|
29092
29262
|
|
|
29093
29263
|
// src/utils/journal.ts
|
|
29094
29264
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -29332,8 +29502,8 @@ var LedgerAccountEntryDetails = ({
|
|
|
29332
29502
|
stringOverrides
|
|
29333
29503
|
}) => {
|
|
29334
29504
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
29335
|
-
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0,
|
|
29336
|
-
const { totalDebit, totalCredit } = (0,
|
|
29505
|
+
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react168.useContext)(LedgerAccountsContext);
|
|
29506
|
+
const { totalDebit, totalCredit } = (0, import_react168.useMemo)(() => {
|
|
29337
29507
|
var _a2;
|
|
29338
29508
|
let totalDebit2 = 0;
|
|
29339
29509
|
let totalCredit2 = 0;
|
|
@@ -29479,7 +29649,7 @@ var LedgerAccountEntryDetails = ({
|
|
|
29479
29649
|
};
|
|
29480
29650
|
|
|
29481
29651
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
29482
|
-
var
|
|
29652
|
+
var import_react169 = require("react");
|
|
29483
29653
|
var import_classnames75 = __toESM(require("classnames"));
|
|
29484
29654
|
var import_date_fns39 = require("date-fns");
|
|
29485
29655
|
var import_jsx_runtime254 = require("react/jsx-runtime");
|
|
@@ -29488,8 +29658,8 @@ var LedgerAccountRow = ({
|
|
|
29488
29658
|
index,
|
|
29489
29659
|
view
|
|
29490
29660
|
}) => {
|
|
29491
|
-
var _a, _b, _c, _d, _e, _f;
|
|
29492
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
29661
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
29662
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react169.useContext)(LedgerAccountsContext);
|
|
29493
29663
|
if (view === "tablet") {
|
|
29494
29664
|
return /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)(
|
|
29495
29665
|
"tr",
|
|
@@ -29519,7 +29689,8 @@ var LedgerAccountRow = ({
|
|
|
29519
29689
|
}
|
|
29520
29690
|
)
|
|
29521
29691
|
] }),
|
|
29522
|
-
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" })
|
|
29692
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" }),
|
|
29693
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { weight: "normal" /* normal */, children: (_d = (_c = row.account) == null ? void 0 : _c.name) != null ? _d : "" })
|
|
29523
29694
|
] }) }),
|
|
29524
29695
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29525
29696
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
@@ -29556,7 +29727,8 @@ var LedgerAccountRow = ({
|
|
|
29556
29727
|
}
|
|
29557
29728
|
)
|
|
29558
29729
|
] }),
|
|
29559
|
-
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (
|
|
29730
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }),
|
|
29731
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { weight: "normal" /* normal */, children: (_h = (_g = row.account) == null ? void 0 : _g.name) != null ? _h : "" }),
|
|
29560
29732
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsxs)("div", { className: "Layer__ledger_account-table__balances-mobile", children: [
|
|
29561
29733
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsxs)("div", { className: "Layer__ledger_account-table__balance-item", children: [
|
|
29562
29734
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__ledger_account-table__balances-mobile__label", children: "Debit" }),
|
|
@@ -29596,7 +29768,8 @@ var LedgerAccountRow = ({
|
|
|
29596
29768
|
children: [
|
|
29597
29769
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }) }),
|
|
29598
29770
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
|
|
29599
|
-
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (
|
|
29771
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (_j = (_i = row.source) == null ? void 0 : _i.display_description) != null ? _j : "" }) }),
|
|
29772
|
+
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (_l = (_k = row.account) == null ? void 0 : _k.name) != null ? _l : "" }) }),
|
|
29600
29773
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29601
29774
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29602
29775
|
/* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: `$${centsToDollars(row.running_balance)}` }) })
|
|
@@ -29615,8 +29788,8 @@ var LedgerAccount = ({
|
|
|
29615
29788
|
stringOverrides
|
|
29616
29789
|
}) => {
|
|
29617
29790
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29618
|
-
const [currentPage, setCurrentPage] = (0,
|
|
29619
|
-
const { data: accountData } = (0,
|
|
29791
|
+
const [currentPage, setCurrentPage] = (0, import_react170.useState)(1);
|
|
29792
|
+
const { data: accountData } = (0, import_react170.useContext)(ChartOfAccountsContext);
|
|
29620
29793
|
const {
|
|
29621
29794
|
data: rawData,
|
|
29622
29795
|
error,
|
|
@@ -29626,23 +29799,36 @@ var LedgerAccount = ({
|
|
|
29626
29799
|
setAccountId,
|
|
29627
29800
|
selectedEntryId,
|
|
29628
29801
|
closeSelectedEntry,
|
|
29629
|
-
refetch
|
|
29630
|
-
|
|
29802
|
+
refetch,
|
|
29803
|
+
hasMore,
|
|
29804
|
+
fetchMore
|
|
29805
|
+
} = (0, import_react170.useContext)(LedgerAccountsContext);
|
|
29631
29806
|
const baseClassName = (0, import_classnames76.default)(
|
|
29632
29807
|
"Layer__ledger-account__index",
|
|
29633
29808
|
accountId && "open"
|
|
29634
29809
|
);
|
|
29635
|
-
const account = (0,
|
|
29810
|
+
const account = (0, import_react170.useMemo)(() => {
|
|
29636
29811
|
return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
|
|
29637
29812
|
(x) => x.id === accountId
|
|
29638
29813
|
);
|
|
29639
29814
|
}, [accountId]);
|
|
29640
|
-
const data = (0,
|
|
29815
|
+
const data = (0, import_react170.useMemo)(() => {
|
|
29641
29816
|
var _a2;
|
|
29817
|
+
if (!rawData) return void 0;
|
|
29642
29818
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
29643
29819
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
29644
29820
|
return (_a2 = rawData == null ? void 0 : rawData.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))) == null ? void 0 : _a2.slice(firstPageIndex, lastPageIndex);
|
|
29645
|
-
}, [rawData, currentPage]);
|
|
29821
|
+
}, [rawData, currentPage, pageSize]);
|
|
29822
|
+
const handlePageChange = (page) => {
|
|
29823
|
+
setCurrentPage(page);
|
|
29824
|
+
if (rawData) {
|
|
29825
|
+
const requestedItemIndex = (page - 1) * pageSize + pageSize - 1;
|
|
29826
|
+
const lastAvailableIndex = rawData.length - 1;
|
|
29827
|
+
if (requestedItemIndex > lastAvailableIndex && hasMore) {
|
|
29828
|
+
fetchMore();
|
|
29829
|
+
}
|
|
29830
|
+
}
|
|
29831
|
+
};
|
|
29646
29832
|
const close2 = () => {
|
|
29647
29833
|
setAccountId(void 0);
|
|
29648
29834
|
closeSelectedEntry();
|
|
@@ -29700,17 +29886,16 @@ var LedgerAccount = ({
|
|
|
29700
29886
|
view === "desktop" && /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
|
|
29701
29887
|
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_b = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _b.dateColumnHeader) || "Date" }),
|
|
29702
29888
|
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_c = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _c.journalIdColumnHeader) || "Journal id #" }),
|
|
29703
|
-
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" })
|
|
29889
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" }),
|
|
29890
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_e = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _e.accountColumnHeader) || "Account" })
|
|
29704
29891
|
] }),
|
|
29705
29892
|
view !== "mobile" && /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
|
|
29706
|
-
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29707
|
-
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29708
|
-
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29893
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_f = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _f.debitColumnHeader) || "Debit" }),
|
|
29894
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_g = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _g.creditColumnHeader) || "Credit" }),
|
|
29895
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_h = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _h.runningBalanceColumnHeader) || "Running balance" })
|
|
29709
29896
|
] })
|
|
29710
29897
|
] }) }),
|
|
29711
|
-
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("tbody", { children:
|
|
29712
|
-
(entry) => !entry.entry_reversal_of && !entry.entry_reversed_by
|
|
29713
|
-
)) == null ? void 0 : _h.map((x, index) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
|
|
29898
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)("tbody", { children: data == null ? void 0 : data.map((x, index) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
|
|
29714
29899
|
LedgerAccountRow,
|
|
29715
29900
|
{
|
|
29716
29901
|
row: x,
|
|
@@ -29726,7 +29911,9 @@ var LedgerAccount = ({
|
|
|
29726
29911
|
currentPage,
|
|
29727
29912
|
totalCount: (rawData == null ? void 0 : rawData.length) || 0,
|
|
29728
29913
|
pageSize,
|
|
29729
|
-
onPageChange:
|
|
29914
|
+
onPageChange: handlePageChange,
|
|
29915
|
+
hasMore,
|
|
29916
|
+
fetchMore
|
|
29730
29917
|
}
|
|
29731
29918
|
),
|
|
29732
29919
|
error ? /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "Layer__table-state-container", children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
|
|
@@ -29774,7 +29961,7 @@ var ChartOfAccountsContent = ({
|
|
|
29774
29961
|
templateAccountsEditable,
|
|
29775
29962
|
showAddAccountButton
|
|
29776
29963
|
}) => {
|
|
29777
|
-
const { accountId } = (0,
|
|
29964
|
+
const { accountId } = (0, import_react171.useContext)(LedgerAccountsContext);
|
|
29778
29965
|
const { view, containerRef } = useElementViewSize();
|
|
29779
29966
|
return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(Container, { name: "chart-of-accounts", ref: containerRef, asWidget, children: accountId ? /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(
|
|
29780
29967
|
LedgerAccount,
|
|
@@ -29799,8 +29986,8 @@ var ChartOfAccountsContent = ({
|
|
|
29799
29986
|
};
|
|
29800
29987
|
|
|
29801
29988
|
// src/contexts/JournalContext/JournalContext.tsx
|
|
29802
|
-
var
|
|
29803
|
-
var JournalContext = (0,
|
|
29989
|
+
var import_react172 = require("react");
|
|
29990
|
+
var JournalContext = (0, import_react172.createContext)({
|
|
29804
29991
|
refetch: () => {
|
|
29805
29992
|
},
|
|
29806
29993
|
setSelectedEntryId: () => {
|
|
@@ -29831,12 +30018,12 @@ var JournalContext = (0, import_react171.createContext)({
|
|
|
29831
30018
|
});
|
|
29832
30019
|
|
|
29833
30020
|
// src/hooks/useJournal/useJournal.tsx
|
|
29834
|
-
var
|
|
30021
|
+
var import_react174 = require("react");
|
|
29835
30022
|
|
|
29836
30023
|
// src/features/ledger/entries/api/useListLedgerEntries.ts
|
|
29837
|
-
var
|
|
29838
|
-
var
|
|
29839
|
-
var
|
|
30024
|
+
var import_infinite5 = __toESM(require("swr/infinite"));
|
|
30025
|
+
var import_react173 = require("react");
|
|
30026
|
+
var import_lodash5 = __toESM(require_lodash());
|
|
29840
30027
|
var LIST_LEDGER_ENTRIES_TAG_KEY = "#list-ledger-entries";
|
|
29841
30028
|
var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, show_total_count }) => {
|
|
29842
30029
|
const parameters = toDefinedSearchParameters({
|
|
@@ -29848,7 +30035,7 @@ var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, s
|
|
|
29848
30035
|
});
|
|
29849
30036
|
return `/v1/businesses/${businessId}/ledger/entries?${parameters}`;
|
|
29850
30037
|
});
|
|
29851
|
-
function
|
|
30038
|
+
function keyLoader5(previousPageData, {
|
|
29852
30039
|
access_token: accessToken,
|
|
29853
30040
|
apiUrl,
|
|
29854
30041
|
businessId,
|
|
@@ -29881,8 +30068,8 @@ function useListLedgerEntries({
|
|
|
29881
30068
|
const { businessId } = useLayerContext();
|
|
29882
30069
|
const { apiUrl } = useEnvironment();
|
|
29883
30070
|
const { data: auth } = useAuth();
|
|
29884
|
-
return (0,
|
|
29885
|
-
(index, previousPageData) =>
|
|
30071
|
+
return (0, import_infinite5.default)(
|
|
30072
|
+
(index, previousPageData) => keyLoader5(
|
|
29886
30073
|
previousPageData,
|
|
29887
30074
|
__spreadProps(__spreadValues({}, auth), {
|
|
29888
30075
|
apiUrl,
|
|
@@ -29933,11 +30120,11 @@ var useJournal = () => {
|
|
|
29933
30120
|
} = useLayerContext();
|
|
29934
30121
|
const { apiUrl } = useEnvironment();
|
|
29935
30122
|
const { data: auth } = useAuth();
|
|
29936
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
29937
|
-
const [form, setForm] = (0,
|
|
29938
|
-
const [addingEntry, setAddingEntry] = (0,
|
|
29939
|
-
const [sendingForm, setSendingForm] = (0,
|
|
29940
|
-
const [apiError, setApiError] = (0,
|
|
30123
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react174.useState)();
|
|
30124
|
+
const [form, setForm] = (0, import_react174.useState)();
|
|
30125
|
+
const [addingEntry, setAddingEntry] = (0, import_react174.useState)(false);
|
|
30126
|
+
const [sendingForm, setSendingForm] = (0, import_react174.useState)(false);
|
|
30127
|
+
const [apiError, setApiError] = (0, import_react174.useState)(void 0);
|
|
29941
30128
|
const {
|
|
29942
30129
|
data: paginatedData,
|
|
29943
30130
|
isLoading,
|
|
@@ -29951,11 +30138,11 @@ var useJournal = () => {
|
|
|
29951
30138
|
sort_order: "DESC",
|
|
29952
30139
|
limit: 150
|
|
29953
30140
|
});
|
|
29954
|
-
const data = (0,
|
|
30141
|
+
const data = (0, import_react174.useMemo)(() => {
|
|
29955
30142
|
if (!paginatedData) return void 0;
|
|
29956
30143
|
return paginatedData.flatMap((page) => page.data);
|
|
29957
30144
|
}, [paginatedData]);
|
|
29958
|
-
const hasMore = (0,
|
|
30145
|
+
const hasMore = (0, import_react174.useMemo)(() => {
|
|
29959
30146
|
var _a, _b;
|
|
29960
30147
|
if (paginatedData && paginatedData.length > 0) {
|
|
29961
30148
|
const lastPage = paginatedData[paginatedData.length - 1];
|
|
@@ -29965,7 +30152,7 @@ var useJournal = () => {
|
|
|
29965
30152
|
}
|
|
29966
30153
|
return false;
|
|
29967
30154
|
}, [paginatedData]);
|
|
29968
|
-
const fetchMore = (0,
|
|
30155
|
+
const fetchMore = (0, import_react174.useCallback)(() => {
|
|
29969
30156
|
if (hasMore) {
|
|
29970
30157
|
setSize(size + 1);
|
|
29971
30158
|
}
|
|
@@ -30210,13 +30397,13 @@ var useJournal = () => {
|
|
|
30210
30397
|
};
|
|
30211
30398
|
|
|
30212
30399
|
// src/components/JournalTable/JournalTableWithPanel.tsx
|
|
30213
|
-
var
|
|
30400
|
+
var import_react180 = require("react");
|
|
30214
30401
|
|
|
30215
30402
|
// src/components/JournalSidebar/JournalSidebar.tsx
|
|
30216
|
-
var
|
|
30403
|
+
var import_react178 = require("react");
|
|
30217
30404
|
|
|
30218
30405
|
// src/components/JournalEntryDetails/JournalEntryDetails.tsx
|
|
30219
|
-
var
|
|
30406
|
+
var import_react175 = require("react");
|
|
30220
30407
|
var import_jsx_runtime257 = require("react/jsx-runtime");
|
|
30221
30408
|
var JournalEntryDetails = () => {
|
|
30222
30409
|
var _a, _b, _c, _d;
|
|
@@ -30228,16 +30415,16 @@ var JournalEntryDetails = () => {
|
|
|
30228
30415
|
selectedEntryId,
|
|
30229
30416
|
reverseEntry,
|
|
30230
30417
|
refetch
|
|
30231
|
-
} = (0,
|
|
30232
|
-
const [reverseEntryProcessing, setReverseEntryProcessing] = (0,
|
|
30233
|
-
const [reverseEntryError, setReverseEntryError] = (0,
|
|
30234
|
-
const entry = (0,
|
|
30418
|
+
} = (0, import_react175.useContext)(JournalContext);
|
|
30419
|
+
const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react175.useState)(false);
|
|
30420
|
+
const [reverseEntryError, setReverseEntryError] = (0, import_react175.useState)();
|
|
30421
|
+
const entry = (0, import_react175.useMemo)(() => {
|
|
30235
30422
|
if (selectedEntryId && data) {
|
|
30236
30423
|
return data.find((x) => x.id === selectedEntryId);
|
|
30237
30424
|
}
|
|
30238
30425
|
return;
|
|
30239
30426
|
}, [data, selectedEntryId]);
|
|
30240
|
-
const sortedLineItems = (0,
|
|
30427
|
+
const sortedLineItems = (0, import_react175.useMemo)(
|
|
30241
30428
|
() => {
|
|
30242
30429
|
var _a2;
|
|
30243
30430
|
return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
|
|
@@ -30415,10 +30602,10 @@ var JournalEntryDetails = () => {
|
|
|
30415
30602
|
};
|
|
30416
30603
|
|
|
30417
30604
|
// src/components/JournalForm/JournalForm.tsx
|
|
30418
|
-
var
|
|
30605
|
+
var import_react177 = require("react");
|
|
30419
30606
|
|
|
30420
30607
|
// src/components/JournalForm/JournalFormEntryLines.tsx
|
|
30421
|
-
var
|
|
30608
|
+
var import_react176 = require("react");
|
|
30422
30609
|
var import_jsx_runtime258 = require("react/jsx-runtime");
|
|
30423
30610
|
function recursiveFlattenCategories(accounts) {
|
|
30424
30611
|
const flattenedResult = accounts.flatMap((a) => {
|
|
@@ -30439,8 +30626,8 @@ var JournalFormEntryLines = ({
|
|
|
30439
30626
|
config
|
|
30440
30627
|
}) => {
|
|
30441
30628
|
const { data: categories } = useCategories({ mode: "ALL" });
|
|
30442
|
-
const { form } = (0,
|
|
30443
|
-
const { flattenedCategories, parentOptions } = (0,
|
|
30629
|
+
const { form } = (0, import_react176.useContext)(JournalContext);
|
|
30630
|
+
const { flattenedCategories, parentOptions } = (0, import_react176.useMemo)(() => {
|
|
30444
30631
|
const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
|
|
30445
30632
|
const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
|
|
30446
30633
|
switch (account.type) {
|
|
@@ -30651,7 +30838,7 @@ var JournalForm = ({
|
|
|
30651
30838
|
changeFormData,
|
|
30652
30839
|
addEntryLine,
|
|
30653
30840
|
removeEntryLine
|
|
30654
|
-
} = (0,
|
|
30841
|
+
} = (0, import_react177.useContext)(JournalContext);
|
|
30655
30842
|
return /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)(
|
|
30656
30843
|
"form",
|
|
30657
30844
|
{
|
|
@@ -30799,7 +30986,7 @@ var JournalSidebar = ({
|
|
|
30799
30986
|
config,
|
|
30800
30987
|
stringOverrides
|
|
30801
30988
|
}) => {
|
|
30802
|
-
const { selectedEntryId } = (0,
|
|
30989
|
+
const { selectedEntryId } = (0, import_react178.useContext)(JournalContext);
|
|
30803
30990
|
if (selectedEntryId !== "new") {
|
|
30804
30991
|
return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(JournalEntryDetails, {});
|
|
30805
30992
|
}
|
|
@@ -30807,7 +30994,7 @@ var JournalSidebar = ({
|
|
|
30807
30994
|
};
|
|
30808
30995
|
|
|
30809
30996
|
// src/components/JournalTable/JournalTable.tsx
|
|
30810
|
-
var
|
|
30997
|
+
var import_react179 = require("react");
|
|
30811
30998
|
var import_date_fns40 = require("date-fns");
|
|
30812
30999
|
var import_jsx_runtime261 = require("react/jsx-runtime");
|
|
30813
31000
|
var accountName = (row) => {
|
|
@@ -30835,9 +31022,9 @@ var JournalTableContent = ({
|
|
|
30835
31022
|
data,
|
|
30836
31023
|
stringOverrides
|
|
30837
31024
|
}) => {
|
|
30838
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
31025
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react179.useContext)(JournalContext);
|
|
30839
31026
|
const { isOpen, setIsOpen } = useTableExpandRow();
|
|
30840
|
-
(0,
|
|
31027
|
+
(0, import_react179.useLayoutEffect)(() => {
|
|
30841
31028
|
if (data.length > 0) {
|
|
30842
31029
|
setIsOpen(data.map((x) => `journal-row-${x.id}`));
|
|
30843
31030
|
}
|
|
@@ -30845,7 +31032,7 @@ var JournalTableContent = ({
|
|
|
30845
31032
|
const renderJournalRow = (row, index, rowKey, depth) => {
|
|
30846
31033
|
const expandable = !!row.line_items && row.line_items.length > 0;
|
|
30847
31034
|
const expanded = !expandable || isOpen(rowKey);
|
|
30848
|
-
return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(
|
|
31035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_react179.Fragment, { children: [
|
|
30849
31036
|
/* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(
|
|
30850
31037
|
TableRow,
|
|
30851
31038
|
{
|
|
@@ -31021,7 +31208,7 @@ var JournalTableWithPanel = ({
|
|
|
31021
31208
|
stringOverrides,
|
|
31022
31209
|
view
|
|
31023
31210
|
}) => {
|
|
31024
|
-
const [currentPage, setCurrentPage] = (0,
|
|
31211
|
+
const [currentPage, setCurrentPage] = (0, import_react180.useState)(1);
|
|
31025
31212
|
const {
|
|
31026
31213
|
data: rawData,
|
|
31027
31214
|
isLoading,
|
|
@@ -31032,8 +31219,8 @@ var JournalTableWithPanel = ({
|
|
|
31032
31219
|
addEntry,
|
|
31033
31220
|
hasMore,
|
|
31034
31221
|
fetchMore
|
|
31035
|
-
} = (0,
|
|
31036
|
-
const data = (0,
|
|
31222
|
+
} = (0, import_react180.useContext)(JournalContext);
|
|
31223
|
+
const data = (0, import_react180.useMemo)(
|
|
31037
31224
|
() => {
|
|
31038
31225
|
if (!rawData) return void 0;
|
|
31039
31226
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
@@ -31179,7 +31366,7 @@ var TasksHeader = ({
|
|
|
31179
31366
|
};
|
|
31180
31367
|
|
|
31181
31368
|
// src/components/Tasks/TasksList.tsx
|
|
31182
|
-
var
|
|
31369
|
+
var import_react188 = require("react");
|
|
31183
31370
|
|
|
31184
31371
|
// src/icons/SmileIcon.tsx
|
|
31185
31372
|
var import_jsx_runtime266 = require("react/jsx-runtime");
|
|
@@ -31238,7 +31425,7 @@ var SmileIcon = (_a) => {
|
|
|
31238
31425
|
var SmileIcon_default = SmileIcon;
|
|
31239
31426
|
|
|
31240
31427
|
// src/components/Tasks/TasksListItem.tsx
|
|
31241
|
-
var
|
|
31428
|
+
var import_react185 = require("react");
|
|
31242
31429
|
var import_classnames77 = __toESM(require("classnames"));
|
|
31243
31430
|
|
|
31244
31431
|
// src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
|
|
@@ -31296,7 +31483,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
31296
31483
|
}
|
|
31297
31484
|
|
|
31298
31485
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
31299
|
-
var
|
|
31486
|
+
var import_react181 = require("react");
|
|
31300
31487
|
function buildKey29({
|
|
31301
31488
|
access_token: accessToken,
|
|
31302
31489
|
apiUrl,
|
|
@@ -31339,7 +31526,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31339
31526
|
}
|
|
31340
31527
|
);
|
|
31341
31528
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31342
|
-
const stableProxiedTrigger = (0,
|
|
31529
|
+
const stableProxiedTrigger = (0, import_react181.useCallback)(
|
|
31343
31530
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31344
31531
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31345
31532
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31366,7 +31553,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31366
31553
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
31367
31554
|
var import_swr26 = require("swr");
|
|
31368
31555
|
var import_mutation19 = __toESM(require("swr/mutation"));
|
|
31369
|
-
var
|
|
31556
|
+
var import_react182 = require("react");
|
|
31370
31557
|
function buildKey30({
|
|
31371
31558
|
access_token: accessToken,
|
|
31372
31559
|
apiUrl,
|
|
@@ -31405,7 +31592,7 @@ function useUploadDocumentsForTask() {
|
|
|
31405
31592
|
}
|
|
31406
31593
|
);
|
|
31407
31594
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31408
|
-
const stableProxiedTrigger = (0,
|
|
31595
|
+
const stableProxiedTrigger = (0, import_react182.useCallback)(
|
|
31409
31596
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31410
31597
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31411
31598
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31432,7 +31619,7 @@ function useUploadDocumentsForTask() {
|
|
|
31432
31619
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
31433
31620
|
var import_swr27 = require("swr");
|
|
31434
31621
|
var import_mutation20 = __toESM(require("swr/mutation"));
|
|
31435
|
-
var
|
|
31622
|
+
var import_react183 = require("react");
|
|
31436
31623
|
function buildKey31({
|
|
31437
31624
|
access_token: accessToken,
|
|
31438
31625
|
apiUrl,
|
|
@@ -31468,7 +31655,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31468
31655
|
}
|
|
31469
31656
|
);
|
|
31470
31657
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31471
|
-
const stableProxiedTrigger = (0,
|
|
31658
|
+
const stableProxiedTrigger = (0, import_react183.useCallback)(
|
|
31472
31659
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31473
31660
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31474
31661
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31495,7 +31682,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31495
31682
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
31496
31683
|
var import_swr28 = require("swr");
|
|
31497
31684
|
var import_mutation21 = __toESM(require("swr/mutation"));
|
|
31498
|
-
var
|
|
31685
|
+
var import_react184 = require("react");
|
|
31499
31686
|
function buildKey32({
|
|
31500
31687
|
access_token: accessToken,
|
|
31501
31688
|
apiUrl,
|
|
@@ -31535,7 +31722,7 @@ function useUpdateTaskUploadDescription() {
|
|
|
31535
31722
|
}
|
|
31536
31723
|
);
|
|
31537
31724
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31538
|
-
const stableProxiedTrigger = (0,
|
|
31725
|
+
const stableProxiedTrigger = (0, import_react184.useCallback)(
|
|
31539
31726
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31540
31727
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31541
31728
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31566,9 +31753,9 @@ var TasksListItem = ({
|
|
|
31566
31753
|
defaultOpen
|
|
31567
31754
|
}) => {
|
|
31568
31755
|
var _a, _b;
|
|
31569
|
-
const [isOpen, setIsOpen] = (0,
|
|
31570
|
-
const [userResponse, setUserResponse] = (0,
|
|
31571
|
-
const [selectedFiles, setSelectedFiles] = (0,
|
|
31756
|
+
const [isOpen, setIsOpen] = (0, import_react185.useState)(defaultOpen);
|
|
31757
|
+
const [userResponse, setUserResponse] = (0, import_react185.useState)((_a = task.user_response) != null ? _a : "");
|
|
31758
|
+
const [selectedFiles, setSelectedFiles] = (0, import_react185.useState)();
|
|
31572
31759
|
const { trigger: handleSubmitUserResponseForTask } = useSubmitUserResponseForTask();
|
|
31573
31760
|
const { trigger: handleUploadDocumentsForTask } = useUploadDocumentsForTask();
|
|
31574
31761
|
const { trigger: handleDeleteUploadsOnTask } = useDeleteUploadsOnTask();
|
|
@@ -31586,7 +31773,7 @@ var TasksListItem = ({
|
|
|
31586
31773
|
"Layer__tasks-list-item",
|
|
31587
31774
|
isOpen && "Layer__tasks-list-item__expanded"
|
|
31588
31775
|
);
|
|
31589
|
-
(0,
|
|
31776
|
+
(0, import_react185.useEffect)(() => {
|
|
31590
31777
|
setIsOpen(defaultOpen);
|
|
31591
31778
|
}, [defaultOpen]);
|
|
31592
31779
|
const submit = () => __async(null, null, function* () {
|
|
@@ -31601,7 +31788,7 @@ var TasksListItem = ({
|
|
|
31601
31788
|
setIsOpen(false);
|
|
31602
31789
|
setSelectedFiles(void 0);
|
|
31603
31790
|
});
|
|
31604
|
-
const uploadDocumentAction = (0,
|
|
31791
|
+
const uploadDocumentAction = (0, import_react185.useMemo)(() => {
|
|
31605
31792
|
if (task.user_response_type === "UPLOAD_DOCUMENT") {
|
|
31606
31793
|
if (task.status === "TODO") {
|
|
31607
31794
|
if (!selectedFiles) {
|
|
@@ -31746,7 +31933,7 @@ var MobilePanel = ({ header, children, open: open2, onClose, className }) => {
|
|
|
31746
31933
|
};
|
|
31747
31934
|
|
|
31748
31935
|
// src/components/Tasks/TasksListMobile.tsx
|
|
31749
|
-
var
|
|
31936
|
+
var import_react186 = require("react");
|
|
31750
31937
|
var import_jsx_runtime270 = require("react/jsx-runtime");
|
|
31751
31938
|
var MOBILE_SHOW_UNRESOLVED_TASKS_COUNT = 2;
|
|
31752
31939
|
var TasksListMobile = ({
|
|
@@ -31757,7 +31944,7 @@ var TasksListMobile = ({
|
|
|
31757
31944
|
pageSize,
|
|
31758
31945
|
setCurrentPage
|
|
31759
31946
|
}) => {
|
|
31760
|
-
const [showMobilePanel, setShowMobilePanel] = (0,
|
|
31947
|
+
const [showMobilePanel, setShowMobilePanel] = (0, import_react186.useState)(false);
|
|
31761
31948
|
const unresolvedTasks = getIncompleteTasks(sortedTasks).slice(0, MOBILE_SHOW_UNRESOLVED_TASKS_COUNT);
|
|
31762
31949
|
return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)("div", { className: "Layer__tasks-list", children: [
|
|
31763
31950
|
unresolvedTasks.map((task, index) => /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
|
|
@@ -31805,27 +31992,27 @@ var TasksListMobile = ({
|
|
|
31805
31992
|
};
|
|
31806
31993
|
|
|
31807
31994
|
// src/hooks/array/usePaginatedList.ts
|
|
31808
|
-
var
|
|
31995
|
+
var import_react187 = require("react");
|
|
31809
31996
|
function usePaginatedList(list, pageSize) {
|
|
31810
|
-
const [internalPageIndex, setInternalPageIndex] = (0,
|
|
31997
|
+
const [internalPageIndex, setInternalPageIndex] = (0, import_react187.useState)(0);
|
|
31811
31998
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
31812
31999
|
const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
|
|
31813
|
-
const pageItems = (0,
|
|
32000
|
+
const pageItems = (0, import_react187.useMemo)(() => {
|
|
31814
32001
|
return list.slice(
|
|
31815
32002
|
effectivePageIndex * pageSize,
|
|
31816
32003
|
(effectivePageIndex + 1) * pageSize
|
|
31817
32004
|
);
|
|
31818
32005
|
}, [list, effectivePageIndex, pageSize]);
|
|
31819
|
-
const next = (0,
|
|
32006
|
+
const next = (0, import_react187.useCallback)(() => {
|
|
31820
32007
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
31821
32008
|
}, [effectivePageIndex, pageCount]);
|
|
31822
|
-
const set2 = (0,
|
|
32009
|
+
const set2 = (0, import_react187.useCallback)((pageIndex) => {
|
|
31823
32010
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
31824
32011
|
}, [pageCount]);
|
|
31825
|
-
const previous = (0,
|
|
32012
|
+
const previous = (0, import_react187.useCallback)(() => {
|
|
31826
32013
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
31827
32014
|
}, [effectivePageIndex]);
|
|
31828
|
-
const reset = (0,
|
|
32015
|
+
const reset = (0, import_react187.useCallback)(() => {
|
|
31829
32016
|
setInternalPageIndex(0);
|
|
31830
32017
|
}, []);
|
|
31831
32018
|
return {
|
|
@@ -31853,7 +32040,7 @@ var TasksEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)("div
|
|
|
31853
32040
|
] });
|
|
31854
32041
|
function TasksList({ pageSize = 8, mobile }) {
|
|
31855
32042
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
31856
|
-
const sortedTasks = (0,
|
|
32043
|
+
const sortedTasks = (0, import_react188.useMemo)(() => {
|
|
31857
32044
|
var _a;
|
|
31858
32045
|
const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
|
|
31859
32046
|
return tasksInPeriod.sort((taskA, taskB) => {
|
|
@@ -31995,7 +32182,7 @@ var TasksPending = () => {
|
|
|
31995
32182
|
};
|
|
31996
32183
|
|
|
31997
32184
|
// src/components/Tasks/TasksMonthSelector.tsx
|
|
31998
|
-
var
|
|
32185
|
+
var import_react189 = require("react");
|
|
31999
32186
|
var import_date_fns42 = require("date-fns");
|
|
32000
32187
|
|
|
32001
32188
|
// src/components/Tasks/TaskStatusBadge.tsx
|
|
@@ -32097,7 +32284,7 @@ function useActiveYearBookkeepingPeriods() {
|
|
|
32097
32284
|
const { date } = useGlobalDate();
|
|
32098
32285
|
const { data } = useBookkeepingPeriods();
|
|
32099
32286
|
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
32100
|
-
const periodsInActiveYear = (0,
|
|
32287
|
+
const periodsInActiveYear = (0, import_react189.useMemo)(() => {
|
|
32101
32288
|
return data == null ? void 0 : data.filter((period) => period.year === activeYear);
|
|
32102
32289
|
}, [data, activeYear]);
|
|
32103
32290
|
return { periodsInActiveYear };
|
|
@@ -32108,7 +32295,7 @@ function TasksMonthSelector() {
|
|
|
32108
32295
|
const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
|
|
32109
32296
|
const activeMonthNumber = (0, import_date_fns42.getMonth)(date) + 1;
|
|
32110
32297
|
const activeYear = (0, import_date_fns42.getYear)(date);
|
|
32111
|
-
const monthsData = (0,
|
|
32298
|
+
const monthsData = (0, import_react189.useMemo)(() => {
|
|
32112
32299
|
return Array.from({ length: 12 }, (_, index) => {
|
|
32113
32300
|
var _a, _b;
|
|
32114
32301
|
const date2 = (0, import_date_fns42.set)(
|
|
@@ -32158,13 +32345,13 @@ var import_classnames81 = __toESM(require("classnames"));
|
|
|
32158
32345
|
var import_pluralize4 = __toESM(require("pluralize"));
|
|
32159
32346
|
|
|
32160
32347
|
// src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
|
|
32161
|
-
var
|
|
32348
|
+
var import_react190 = require("react");
|
|
32162
32349
|
var import_date_fns43 = require("date-fns");
|
|
32163
32350
|
var useBookkeepingYearsStatus = () => {
|
|
32164
32351
|
const { business } = useLayerContext();
|
|
32165
32352
|
const activationDate = getActivationDate(business);
|
|
32166
32353
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
32167
|
-
const yearStatuses = (0,
|
|
32354
|
+
const yearStatuses = (0, import_react190.useMemo)(() => {
|
|
32168
32355
|
const startYear = (0, import_date_fns43.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
|
|
32169
32356
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
32170
32357
|
const count = currentYear - startYear + 1;
|
|
@@ -32179,7 +32366,7 @@ var useBookkeepingYearsStatus = () => {
|
|
|
32179
32366
|
};
|
|
32180
32367
|
}).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
|
|
32181
32368
|
}, [activationDate, data]);
|
|
32182
|
-
const earliestIncompletePeriod = (0,
|
|
32369
|
+
const earliestIncompletePeriod = (0, import_react190.useMemo)(
|
|
32183
32370
|
() => [...data != null ? data : []].sort((a, b) => {
|
|
32184
32371
|
if (a.year === b.year) {
|
|
32185
32372
|
return b.month - a.month;
|
|
@@ -32322,10 +32509,10 @@ var TasksPanelNotification = ({
|
|
|
32322
32509
|
};
|
|
32323
32510
|
|
|
32324
32511
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
32325
|
-
var
|
|
32512
|
+
var import_react193 = require("react");
|
|
32326
32513
|
|
|
32327
32514
|
// src/components/Tabs/Tabs.tsx
|
|
32328
|
-
var
|
|
32515
|
+
var import_react191 = require("react");
|
|
32329
32516
|
|
|
32330
32517
|
// src/components/Tabs/Tab.tsx
|
|
32331
32518
|
var import_jsx_runtime279 = require("react/jsx-runtime");
|
|
@@ -32389,12 +32576,12 @@ var Tab = ({
|
|
|
32389
32576
|
// src/components/Tabs/Tabs.tsx
|
|
32390
32577
|
var import_classnames80 = __toESM(require("classnames"));
|
|
32391
32578
|
var import_jsx_runtime280 = require("react/jsx-runtime");
|
|
32392
|
-
var
|
|
32579
|
+
var import_react192 = require("react");
|
|
32393
32580
|
var STARTING_PADDING = 12;
|
|
32394
32581
|
var Tabs = ({ name, options, selected, onChange }) => {
|
|
32395
|
-
const [initialized, setInitialized] = (0,
|
|
32396
|
-
const [thumbPos, setThumbPos] = (0,
|
|
32397
|
-
const [currentWidth, setCurrentWidth] = (0,
|
|
32582
|
+
const [initialized, setInitialized] = (0, import_react191.useState)(false);
|
|
32583
|
+
const [thumbPos, setThumbPos] = (0, import_react191.useState)({ left: 0, width: 0 });
|
|
32584
|
+
const [currentWidth, setCurrentWidth] = (0, import_react191.useState)(0);
|
|
32398
32585
|
const selectedValue = selected || options[0].value;
|
|
32399
32586
|
const baseClassName = (0, import_classnames80.default)(
|
|
32400
32587
|
"Layer__tabs",
|
|
@@ -32429,14 +32616,14 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
32429
32616
|
shift2 = shift2 + STARTING_PADDING;
|
|
32430
32617
|
setThumbPos({ left: shift2, width });
|
|
32431
32618
|
};
|
|
32432
|
-
(0,
|
|
32619
|
+
(0, import_react191.useEffect)(() => {
|
|
32433
32620
|
const selectedIndex = getSelectedIndex();
|
|
32434
32621
|
updateSelectPosition(selectedIndex);
|
|
32435
32622
|
setTimeout(() => {
|
|
32436
32623
|
setInitialized(true);
|
|
32437
32624
|
}, 400);
|
|
32438
32625
|
}, []);
|
|
32439
|
-
(0,
|
|
32626
|
+
(0, import_react191.useEffect)(() => {
|
|
32440
32627
|
const selectedIndex = getSelectedIndex();
|
|
32441
32628
|
updateSelectPosition(selectedIndex);
|
|
32442
32629
|
}, [selectedValue, currentWidth]);
|
|
@@ -32452,7 +32639,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
32452
32639
|
return /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)("div", { className: baseClassName, ref: elementRef, children: [
|
|
32453
32640
|
options.map((option, index) => {
|
|
32454
32641
|
var _a;
|
|
32455
|
-
return /* @__PURE__ */ (0,
|
|
32642
|
+
return /* @__PURE__ */ (0, import_react192.createElement)(
|
|
32456
32643
|
Tab,
|
|
32457
32644
|
__spreadProps(__spreadValues({}, option), {
|
|
32458
32645
|
key: option.value,
|
|
@@ -32484,7 +32671,7 @@ var TasksYearsTabs = () => {
|
|
|
32484
32671
|
yearNumber: Number(year)
|
|
32485
32672
|
});
|
|
32486
32673
|
};
|
|
32487
|
-
const yearsList = (0,
|
|
32674
|
+
const yearsList = (0, import_react193.useMemo)(() => {
|
|
32488
32675
|
return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
|
|
32489
32676
|
return {
|
|
32490
32677
|
value: `${y.year}`,
|
|
@@ -32587,10 +32774,10 @@ function Tasks({
|
|
|
32587
32774
|
}
|
|
32588
32775
|
|
|
32589
32776
|
// src/components/PlatformOnboarding/LinkAccounts.tsx
|
|
32590
|
-
var
|
|
32777
|
+
var import_react196 = require("react");
|
|
32591
32778
|
|
|
32592
32779
|
// src/components/PlatformOnboarding/Steps/LinkAccountsConfirmationStep.tsx
|
|
32593
|
-
var
|
|
32780
|
+
var import_react194 = require("react");
|
|
32594
32781
|
var import_react_form3 = require("@tanstack/react-form");
|
|
32595
32782
|
|
|
32596
32783
|
// src/components/PlatformOnboarding/Container/LinkAccountsListContainer.tsx
|
|
@@ -32626,7 +32813,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
32626
32813
|
data: linkedAccounts,
|
|
32627
32814
|
loadingStatus: linkedAccountsLoadingStatus,
|
|
32628
32815
|
refetchAccounts
|
|
32629
|
-
} = (0,
|
|
32816
|
+
} = (0, import_react194.useContext)(LinkedAccountsContext);
|
|
32630
32817
|
const effectiveLinkedAccounts = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
32631
32818
|
const { trigger } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
|
|
32632
32819
|
const { previous, next } = useWizard();
|
|
@@ -32699,7 +32886,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
32699
32886
|
}
|
|
32700
32887
|
|
|
32701
32888
|
// src/components/PlatformOnboarding/Steps/LinkAccountsLinkStep.tsx
|
|
32702
|
-
var
|
|
32889
|
+
var import_react195 = require("react");
|
|
32703
32890
|
var import_pluralize5 = __toESM(require("pluralize"));
|
|
32704
32891
|
var import_jsx_runtime286 = require("react/jsx-runtime");
|
|
32705
32892
|
function LinkAccountsLinkStep() {
|
|
@@ -32709,7 +32896,7 @@ function LinkAccountsLinkStep() {
|
|
|
32709
32896
|
error,
|
|
32710
32897
|
refetchAccounts,
|
|
32711
32898
|
addConnection
|
|
32712
|
-
} = (0,
|
|
32899
|
+
} = (0, import_react195.useContext)(LinkedAccountsContext);
|
|
32713
32900
|
const { next } = useWizard();
|
|
32714
32901
|
const effectiveAccounts = data != null ? data : [];
|
|
32715
32902
|
return /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_jsx_runtime286.Fragment, { children: [
|
|
@@ -32789,7 +32976,7 @@ function LinkAccounts(props) {
|
|
|
32789
32976
|
function LinkAccountsContent({
|
|
32790
32977
|
onComplete
|
|
32791
32978
|
}) {
|
|
32792
|
-
const { data: linkedAccounts, loadingStatus } = (0,
|
|
32979
|
+
const { data: linkedAccounts, loadingStatus } = (0, import_react196.useContext)(LinkedAccountsContext);
|
|
32793
32980
|
const linkedAccountsNeedingConfirmation = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
|
|
32794
32981
|
const hideConfirmationStep = loadingStatus === "complete" && linkedAccountsNeedingConfirmation.length === 0;
|
|
32795
32982
|
return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)("section", { className: "Layer__link-accounts Layer__component", children: /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
|
|
@@ -32807,7 +32994,7 @@ function LinkAccountsContent({
|
|
|
32807
32994
|
}
|
|
32808
32995
|
|
|
32809
32996
|
// src/components/PlatformOnboarding/PlatformOnboarding.tsx
|
|
32810
|
-
var
|
|
32997
|
+
var import_react201 = require("react");
|
|
32811
32998
|
|
|
32812
32999
|
// src/components/ProgressSteps/ProgressSteps.tsx
|
|
32813
33000
|
var import_jsx_runtime288 = require("react/jsx-runtime");
|
|
@@ -33190,7 +33377,7 @@ function useBusinessPersonnel() {
|
|
|
33190
33377
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
33191
33378
|
var import_mutation22 = __toESM(require("swr/mutation"));
|
|
33192
33379
|
var import_swr30 = require("swr");
|
|
33193
|
-
var
|
|
33380
|
+
var import_react197 = require("react");
|
|
33194
33381
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
33195
33382
|
function buildKey34({
|
|
33196
33383
|
access_token: accessToken,
|
|
@@ -33228,7 +33415,7 @@ function useCreateBusinessPersonnel() {
|
|
|
33228
33415
|
}
|
|
33229
33416
|
);
|
|
33230
33417
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33231
|
-
const stableProxiedTrigger = (0,
|
|
33418
|
+
const stableProxiedTrigger = (0, import_react197.useCallback)(
|
|
33232
33419
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33233
33420
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33234
33421
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33262,7 +33449,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
33262
33449
|
});
|
|
33263
33450
|
|
|
33264
33451
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
33265
|
-
var
|
|
33452
|
+
var import_react198 = require("react");
|
|
33266
33453
|
function buildKey35({
|
|
33267
33454
|
access_token: accessToken,
|
|
33268
33455
|
apiUrl,
|
|
@@ -33305,7 +33492,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33305
33492
|
}
|
|
33306
33493
|
);
|
|
33307
33494
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33308
|
-
const stableProxiedTrigger = (0,
|
|
33495
|
+
const stableProxiedTrigger = (0, import_react198.useCallback)(
|
|
33309
33496
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33310
33497
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33311
33498
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33332,7 +33519,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33332
33519
|
// src/hooks/business/useUpdateBusiness.ts
|
|
33333
33520
|
var import_mutation24 = __toESM(require("swr/mutation"));
|
|
33334
33521
|
var import_swr32 = require("swr");
|
|
33335
|
-
var
|
|
33522
|
+
var import_react199 = require("react");
|
|
33336
33523
|
var BUSINESS_TAG_KEY = "business";
|
|
33337
33524
|
function buildKey36({
|
|
33338
33525
|
access_token: accessToken,
|
|
@@ -33370,7 +33557,7 @@ function useUpdateBusiness() {
|
|
|
33370
33557
|
}
|
|
33371
33558
|
);
|
|
33372
33559
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33373
|
-
const stableProxiedTrigger = (0,
|
|
33560
|
+
const stableProxiedTrigger = (0, import_react199.useCallback)(
|
|
33374
33561
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33375
33562
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33376
33563
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33395,7 +33582,7 @@ function useUpdateBusiness() {
|
|
|
33395
33582
|
}
|
|
33396
33583
|
|
|
33397
33584
|
// src/components/BusinessForm/useBusinessForm.ts
|
|
33398
|
-
var
|
|
33585
|
+
var import_react200 = require("react");
|
|
33399
33586
|
var getPerson = (personnel) => {
|
|
33400
33587
|
const owners = personnel == null ? void 0 : personnel.filter((p) => p.roles.find((x) => x.role === "OWNER"));
|
|
33401
33588
|
if (owners && owners.length > 0) {
|
|
@@ -33406,7 +33593,7 @@ var getPerson = (personnel) => {
|
|
|
33406
33593
|
var useBusinessForm = ({ onSuccess }) => {
|
|
33407
33594
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
33408
33595
|
const { business } = useLayerContext();
|
|
33409
|
-
const [submitError, setSubmitError] = (0,
|
|
33596
|
+
const [submitError, setSubmitError] = (0, import_react200.useState)(void 0);
|
|
33410
33597
|
const { data: personnel } = useBusinessPersonnel();
|
|
33411
33598
|
const person = getPerson(personnel);
|
|
33412
33599
|
const { trigger: createBusinessPersonnel2 } = useCreateBusinessPersonnel();
|
|
@@ -33822,7 +34009,7 @@ var PLATFORM_ONBOARDING_STEPS = [
|
|
|
33822
34009
|
}
|
|
33823
34010
|
];
|
|
33824
34011
|
var PlatformOnboarding = ({ onComplete }) => {
|
|
33825
|
-
const [step, setStep] = (0,
|
|
34012
|
+
const [step, setStep] = (0, import_react201.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
|
|
33826
34013
|
const isFirstStep = PLATFORM_ONBOARDING_STEPS[0].id === step;
|
|
33827
34014
|
const nextStep = () => {
|
|
33828
34015
|
const currentStepIndex = PLATFORM_ONBOARDING_STEPS.findIndex((s) => s.id === step);
|
|
@@ -33984,7 +34171,7 @@ var BookkeepingUpsellBar = ({
|
|
|
33984
34171
|
};
|
|
33985
34172
|
|
|
33986
34173
|
// src/views/BookkeepingOverview/BookkeepingOverview.tsx
|
|
33987
|
-
var
|
|
34174
|
+
var import_react203 = require("react");
|
|
33988
34175
|
|
|
33989
34176
|
// src/views/BookkeepingOverview/internal/BookkeepingProfitAndLossSummariesContainer.tsx
|
|
33990
34177
|
var import_jsx_runtime302 = require("react/jsx-runtime");
|
|
@@ -33999,15 +34186,15 @@ function BookkeepingProfitAndLossSummariesContainer({
|
|
|
33999
34186
|
var import_classnames82 = __toESM(require("classnames"));
|
|
34000
34187
|
|
|
34001
34188
|
// src/views/BookkeepingOverview/useKeepInMobileViewport.tsx
|
|
34002
|
-
var
|
|
34189
|
+
var import_react202 = require("react");
|
|
34003
34190
|
var TASKS_MOBILE_VIEWPORT_WIDTH = 1100;
|
|
34004
34191
|
var useKeepInMobileViewport = () => {
|
|
34005
|
-
const upperContentRef = (0,
|
|
34006
|
-
const targetElementRef = (0,
|
|
34007
|
-
const lastKnownSizeRef = (0,
|
|
34008
|
-
const lastKnownTargetPositionRef = (0,
|
|
34009
|
-
const upperElementInFocus = (0,
|
|
34010
|
-
(0,
|
|
34192
|
+
const upperContentRef = (0, import_react202.useRef)(null);
|
|
34193
|
+
const targetElementRef = (0, import_react202.useRef)(null);
|
|
34194
|
+
const lastKnownSizeRef = (0, import_react202.useRef)(null);
|
|
34195
|
+
const lastKnownTargetPositionRef = (0, import_react202.useRef)(null);
|
|
34196
|
+
const upperElementInFocus = (0, import_react202.useRef)(false);
|
|
34197
|
+
(0, import_react202.useEffect)(() => {
|
|
34011
34198
|
if (!upperContentRef.current || !targetElementRef.current) return;
|
|
34012
34199
|
lastKnownSizeRef.current = upperContentRef.current.getBoundingClientRect().height;
|
|
34013
34200
|
lastKnownTargetPositionRef.current = targetElementRef.current.getBoundingClientRect().top;
|
|
@@ -34064,7 +34251,7 @@ var BookkeepingOverview = ({
|
|
|
34064
34251
|
slotProps
|
|
34065
34252
|
}) => {
|
|
34066
34253
|
var _a, _b, _c, _d, _e, _f;
|
|
34067
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
34254
|
+
const [pnlToggle, setPnlToggle] = (0, import_react203.useState)("expenses");
|
|
34068
34255
|
const [width] = useWindowSize();
|
|
34069
34256
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
34070
34257
|
const { upperContentRef, targetElementRef, upperElementInFocus } = useKeepInMobileViewport();
|
|
@@ -34195,7 +34382,7 @@ var BookkeepingOverview = ({
|
|
|
34195
34382
|
};
|
|
34196
34383
|
|
|
34197
34384
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
34198
|
-
var
|
|
34385
|
+
var import_react204 = require("react");
|
|
34199
34386
|
var import_classnames83 = __toESM(require("classnames"));
|
|
34200
34387
|
var import_jsx_runtime304 = require("react/jsx-runtime");
|
|
34201
34388
|
var AccountingOverview = ({
|
|
@@ -34211,7 +34398,7 @@ var AccountingOverview = ({
|
|
|
34211
34398
|
slotProps
|
|
34212
34399
|
}) => {
|
|
34213
34400
|
var _a, _b, _c, _d, _e;
|
|
34214
|
-
const [pnlToggle, setPnlToggle] = (0,
|
|
34401
|
+
const [pnlToggle, setPnlToggle] = (0, import_react204.useState)("expenses");
|
|
34215
34402
|
const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
|
|
34216
34403
|
return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
|
|
34217
34404
|
ProfitAndLoss,
|
|
@@ -34382,7 +34569,7 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
34382
34569
|
};
|
|
34383
34570
|
|
|
34384
34571
|
// src/views/GeneralLedger/GeneralLedger.tsx
|
|
34385
|
-
var
|
|
34572
|
+
var import_react205 = require("react");
|
|
34386
34573
|
var import_jsx_runtime306 = require("react/jsx-runtime");
|
|
34387
34574
|
var GeneralLedgerView = ({
|
|
34388
34575
|
title,
|
|
@@ -34391,7 +34578,7 @@ var GeneralLedgerView = ({
|
|
|
34391
34578
|
stringOverrides,
|
|
34392
34579
|
chartOfAccountsOptions
|
|
34393
34580
|
}) => {
|
|
34394
|
-
const [activeTab, setActiveTab] = (0,
|
|
34581
|
+
const [activeTab, setActiveTab] = (0, import_react205.useState)("chartOfAccounts");
|
|
34395
34582
|
return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ProfitAndLoss, { asContainer: false, children: /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(
|
|
34396
34583
|
View,
|
|
34397
34584
|
{
|
|
@@ -34433,7 +34620,7 @@ var GeneralLedgerView = ({
|
|
|
34433
34620
|
};
|
|
34434
34621
|
|
|
34435
34622
|
// src/views/ProjectProfitability/ProjectProfitability.tsx
|
|
34436
|
-
var
|
|
34623
|
+
var import_react206 = require("react");
|
|
34437
34624
|
var import_react_select6 = __toESM(require("react-select"));
|
|
34438
34625
|
var import_jsx_runtime307 = require("react/jsx-runtime");
|
|
34439
34626
|
var ProjectProfitabilityView = ({
|
|
@@ -34443,9 +34630,9 @@ var ProjectProfitabilityView = ({
|
|
|
34443
34630
|
datePickerMode = "monthPicker",
|
|
34444
34631
|
csvMoneyFormat = "DOLLAR_STRING"
|
|
34445
34632
|
}) => {
|
|
34446
|
-
const [activeTab, setActiveTab] = (0,
|
|
34447
|
-
const [tagFilter, setTagFilter] = (0,
|
|
34448
|
-
const [pnlTagFilter, setPnlTagFilter] = (0,
|
|
34633
|
+
const [activeTab, setActiveTab] = (0, import_react206.useState)("overview");
|
|
34634
|
+
const [tagFilter, setTagFilter] = (0, import_react206.useState)(null);
|
|
34635
|
+
const [pnlTagFilter, setPnlTagFilter] = (0, import_react206.useState)(
|
|
34449
34636
|
void 0
|
|
34450
34637
|
);
|
|
34451
34638
|
const isOptionSelected = (option, selectValue) => {
|
|
@@ -34544,26 +34731,26 @@ var ProjectProfitabilityView = ({
|
|
|
34544
34731
|
};
|
|
34545
34732
|
|
|
34546
34733
|
// src/contexts/BillsContext.tsx
|
|
34547
|
-
var
|
|
34734
|
+
var import_react209 = require("react");
|
|
34548
34735
|
|
|
34549
34736
|
// src/hooks/useBills.tsx
|
|
34550
|
-
var
|
|
34737
|
+
var import_react207 = require("react");
|
|
34551
34738
|
var import_date_fns45 = require("date-fns");
|
|
34552
|
-
var
|
|
34739
|
+
var import_infinite6 = __toESM(require("swr/infinite"));
|
|
34553
34740
|
var PAGE_SIZE = 20;
|
|
34554
34741
|
var useBills = () => {
|
|
34555
34742
|
const { businessId } = useLayerContext();
|
|
34556
34743
|
const { data: auth } = useAuth();
|
|
34557
34744
|
const { apiUrl } = useEnvironment();
|
|
34558
|
-
const [status, setStatus] = (0,
|
|
34559
|
-
const [vendor, setVendor] = (0,
|
|
34560
|
-
const [billInDetails, setBillInDetails] = (0,
|
|
34561
|
-
const [showBillInDetails, setShowBillInDetails] = (0,
|
|
34562
|
-
const [dateRange, setDateRange] = (0,
|
|
34745
|
+
const [status, setStatus] = (0, import_react207.useState)("UNPAID");
|
|
34746
|
+
const [vendor, setVendor] = (0, import_react207.useState)(null);
|
|
34747
|
+
const [billInDetails, setBillInDetails] = (0, import_react207.useState)();
|
|
34748
|
+
const [showBillInDetails, setShowBillInDetails] = (0, import_react207.useState)(false);
|
|
34749
|
+
const [dateRange, setDateRange] = (0, import_react207.useState)({
|
|
34563
34750
|
startDate: (0, import_date_fns45.sub)((0, import_date_fns45.startOfMonth)(/* @__PURE__ */ new Date()), { years: 1 }),
|
|
34564
34751
|
endDate: (0, import_date_fns45.endOfMonth)(/* @__PURE__ */ new Date())
|
|
34565
34752
|
});
|
|
34566
|
-
const [currentPage, setCurrentPage] = (0,
|
|
34753
|
+
const [currentPage, setCurrentPage] = (0, import_react207.useState)(1);
|
|
34567
34754
|
const openBillDetails = (bill) => {
|
|
34568
34755
|
setBillInDetails(bill);
|
|
34569
34756
|
setShowBillInDetails(true);
|
|
@@ -34596,7 +34783,7 @@ var useBills = () => {
|
|
|
34596
34783
|
size,
|
|
34597
34784
|
setSize,
|
|
34598
34785
|
mutate
|
|
34599
|
-
} = (0,
|
|
34786
|
+
} = (0, import_infinite6.default)(
|
|
34600
34787
|
getKey,
|
|
34601
34788
|
(_0) => __async(null, [_0], function* ([_query, nextCursor]) {
|
|
34602
34789
|
if (auth == null ? void 0 : auth.access_token) {
|
|
@@ -34618,24 +34805,24 @@ var useBills = () => {
|
|
|
34618
34805
|
revalidateFirstPage: false
|
|
34619
34806
|
}
|
|
34620
34807
|
);
|
|
34621
|
-
const data = (0,
|
|
34808
|
+
const data = (0, import_react207.useMemo)(() => {
|
|
34622
34809
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34623
34810
|
return rawResponseData == null ? void 0 : rawResponseData.map((x) => x == null ? void 0 : x.data).flat().filter((x) => !!x);
|
|
34624
34811
|
}
|
|
34625
34812
|
return void 0;
|
|
34626
34813
|
}, [rawResponseData]);
|
|
34627
|
-
const paginatedData = (0,
|
|
34814
|
+
const paginatedData = (0, import_react207.useMemo)(() => {
|
|
34628
34815
|
const firstPageIndex = (currentPage - 1) * PAGE_SIZE;
|
|
34629
34816
|
const lastPageIndex = firstPageIndex + PAGE_SIZE;
|
|
34630
34817
|
return data == null ? void 0 : data.slice(firstPageIndex, lastPageIndex);
|
|
34631
34818
|
}, [currentPage, data]);
|
|
34632
|
-
const lastMetadata = (0,
|
|
34819
|
+
const lastMetadata = (0, import_react207.useMemo)(() => {
|
|
34633
34820
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34634
34821
|
return rawResponseData[rawResponseData.length - 1].meta;
|
|
34635
34822
|
}
|
|
34636
34823
|
return void 0;
|
|
34637
34824
|
}, [rawResponseData]);
|
|
34638
|
-
const hasMore = (0,
|
|
34825
|
+
const hasMore = (0, import_react207.useMemo)(() => {
|
|
34639
34826
|
var _a, _b, _c, _d;
|
|
34640
34827
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34641
34828
|
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
@@ -34680,7 +34867,7 @@ var useBills = () => {
|
|
|
34680
34867
|
};
|
|
34681
34868
|
|
|
34682
34869
|
// src/components/Bills/useBillsRecordPayment.ts
|
|
34683
|
-
var
|
|
34870
|
+
var import_react208 = require("react");
|
|
34684
34871
|
var import_mutation25 = __toESM(require("swr/mutation"));
|
|
34685
34872
|
function buildKey37({
|
|
34686
34873
|
access_token: accessToken,
|
|
@@ -34703,13 +34890,13 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34703
34890
|
const { data: auth } = useAuth();
|
|
34704
34891
|
const { apiUrl } = useEnvironment();
|
|
34705
34892
|
const { billInDetails, openBillDetails } = useBillsContext();
|
|
34706
|
-
const [showRecordPaymentForm, setShowRecordPaymentForm] = (0,
|
|
34707
|
-
const [bulkSelectionActive, setBulkSelectionActive] = (0,
|
|
34708
|
-
const [vendor, setVendorState] = (0,
|
|
34709
|
-
const [paymentDate, setPaymentDate] = (0,
|
|
34710
|
-
const [paymentMethod, setPaymentMethod] = (0,
|
|
34711
|
-
const [billsToPay, setBillsToPay] = (0,
|
|
34712
|
-
const [dataSaved, setDataSaved] = (0,
|
|
34893
|
+
const [showRecordPaymentForm, setShowRecordPaymentForm] = (0, import_react208.useState)(false);
|
|
34894
|
+
const [bulkSelectionActive, setBulkSelectionActive] = (0, import_react208.useState)(false);
|
|
34895
|
+
const [vendor, setVendorState] = (0, import_react208.useState)();
|
|
34896
|
+
const [paymentDate, setPaymentDate] = (0, import_react208.useState)(/* @__PURE__ */ new Date());
|
|
34897
|
+
const [paymentMethod, setPaymentMethod] = (0, import_react208.useState)("ACH");
|
|
34898
|
+
const [billsToPay, setBillsToPay] = (0, import_react208.useState)([]);
|
|
34899
|
+
const [dataSaved, setDataSaved] = (0, import_react208.useState)(false);
|
|
34713
34900
|
const openBulkSelection = () => {
|
|
34714
34901
|
setBulkSelectionActive(true);
|
|
34715
34902
|
};
|
|
@@ -34723,7 +34910,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34723
34910
|
setVendor(void 0);
|
|
34724
34911
|
setBulkSelectionActive(false);
|
|
34725
34912
|
};
|
|
34726
|
-
(0,
|
|
34913
|
+
(0, import_react208.useEffect)(() => {
|
|
34727
34914
|
if (vendor && billsToPay.length === 0) {
|
|
34728
34915
|
setVendor(void 0);
|
|
34729
34916
|
}
|
|
@@ -34792,7 +34979,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34792
34979
|
setBillsToPay([{ bill, amount: (_b = convertFromCents((_a = bill.outstanding_balance) != null ? _a : 0)) == null ? void 0 : _b.toString() }]);
|
|
34793
34980
|
setShowRecordPaymentForm(true);
|
|
34794
34981
|
};
|
|
34795
|
-
const payload = (0,
|
|
34982
|
+
const payload = (0, import_react208.useMemo)(() => {
|
|
34796
34983
|
const filteredBillsToPay = billsToPay.filter((item) => {
|
|
34797
34984
|
var _a;
|
|
34798
34985
|
return item.amount && ((_a = item.bill) == null ? void 0 : _a.id);
|
|
@@ -34936,7 +35123,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34936
35123
|
// src/contexts/BillsContext.tsx
|
|
34937
35124
|
var import_date_fns46 = require("date-fns");
|
|
34938
35125
|
var import_jsx_runtime308 = require("react/jsx-runtime");
|
|
34939
|
-
var BillsContext = (0,
|
|
35126
|
+
var BillsContext = (0, import_react209.createContext)({
|
|
34940
35127
|
data: [],
|
|
34941
35128
|
paginatedData: [],
|
|
34942
35129
|
currentPage: 1,
|
|
@@ -34967,7 +35154,7 @@ var BillsContext = (0, import_react208.createContext)({
|
|
|
34967
35154
|
refetch: () => {
|
|
34968
35155
|
}
|
|
34969
35156
|
});
|
|
34970
|
-
var BillsRecordPaymentContext = (0,
|
|
35157
|
+
var BillsRecordPaymentContext = (0, import_react209.createContext)({
|
|
34971
35158
|
billsToPay: [],
|
|
34972
35159
|
setBill: () => {
|
|
34973
35160
|
},
|
|
@@ -35011,8 +35198,8 @@ var BillsRecordPaymentContext = (0, import_react208.createContext)({
|
|
|
35011
35198
|
isLoading: false,
|
|
35012
35199
|
apiError: void 0
|
|
35013
35200
|
});
|
|
35014
|
-
var useBillsContext = () => (0,
|
|
35015
|
-
var useBillsRecordPaymentContext = () => (0,
|
|
35201
|
+
var useBillsContext = () => (0, import_react209.useContext)(BillsContext);
|
|
35202
|
+
var useBillsRecordPaymentContext = () => (0, import_react209.useContext)(BillsRecordPaymentContext);
|
|
35016
35203
|
var BillsProvider = ({ children }) => {
|
|
35017
35204
|
const bills = useBills();
|
|
35018
35205
|
return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BillsContext.Provider, { value: bills, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BillContextWithRecordPayment, { children }) });
|
|
@@ -35024,14 +35211,14 @@ var BillContextWithRecordPayment = ({ children }) => {
|
|
|
35024
35211
|
};
|
|
35025
35212
|
|
|
35026
35213
|
// src/components/Bills/useBillForm.ts
|
|
35027
|
-
var
|
|
35214
|
+
var import_react210 = require("react");
|
|
35028
35215
|
var import_react_form5 = require("@tanstack/react-form");
|
|
35029
35216
|
var useBillForm = (bill) => {
|
|
35030
35217
|
var _a, _b, _c, _d;
|
|
35031
35218
|
const { businessId, addToast } = useLayerContext();
|
|
35032
35219
|
const { apiUrl } = useEnvironment();
|
|
35033
35220
|
const { data: auth } = useAuth();
|
|
35034
|
-
const [submitError, setSubmitError] = (0,
|
|
35221
|
+
const [submitError, setSubmitError] = (0, import_react210.useState)(void 0);
|
|
35035
35222
|
const { openBillDetails, refetch } = useBillsContext();
|
|
35036
35223
|
const form = (0, import_react_form5.useForm)({
|
|
35037
35224
|
defaultValues: {
|
|
@@ -35124,7 +35311,7 @@ var useBillForm = (bill) => {
|
|
|
35124
35311
|
var import_date_fns49 = require("date-fns");
|
|
35125
35312
|
|
|
35126
35313
|
// src/components/Bills/BillsPaymentRecorded.tsx
|
|
35127
|
-
var
|
|
35314
|
+
var import_react211 = require("react");
|
|
35128
35315
|
|
|
35129
35316
|
// src/components/Input/StaticValue.tsx
|
|
35130
35317
|
var import_classnames84 = __toESM(require("classnames"));
|
|
@@ -35170,11 +35357,11 @@ var BillsPaymentRecorded = ({
|
|
|
35170
35357
|
vendor,
|
|
35171
35358
|
payRemainingBalance
|
|
35172
35359
|
} = useBillsRecordPaymentContext();
|
|
35173
|
-
const totalPaid = (0,
|
|
35360
|
+
const totalPaid = (0, import_react211.useMemo)(
|
|
35174
35361
|
() => billsToPay.reduce((acc, record) => acc + (record.amount !== void 0 ? Number(record.amount) : 0), 0),
|
|
35175
35362
|
[billsToPay]
|
|
35176
35363
|
);
|
|
35177
|
-
const anyUnpaid = (0,
|
|
35364
|
+
const anyUnpaid = (0, import_react211.useMemo)(
|
|
35178
35365
|
() => billsToPay.some((record) => {
|
|
35179
35366
|
var _a2;
|
|
35180
35367
|
return ((_a2 = record.bill) == null ? void 0 : _a2.status) !== "PAID";
|
|
@@ -35231,7 +35418,7 @@ var BillsPaymentRecorded = ({
|
|
|
35231
35418
|
};
|
|
35232
35419
|
|
|
35233
35420
|
// src/components/Bills/BillsRecordPayment.tsx
|
|
35234
|
-
var
|
|
35421
|
+
var import_react212 = require("react");
|
|
35235
35422
|
var import_date_fns47 = require("date-fns");
|
|
35236
35423
|
|
|
35237
35424
|
// src/components/Bills/useUnpaidBillsByVendor.ts
|
|
@@ -35314,7 +35501,7 @@ var BillsRecordPayment = ({
|
|
|
35314
35501
|
apiError
|
|
35315
35502
|
} = useBillsRecordPaymentContext();
|
|
35316
35503
|
const { data: rawAvailableBills } = useUnpaidBillsByVendor({ vendorId: vendor == null ? void 0 : vendor.id });
|
|
35317
|
-
const availableBills = (0,
|
|
35504
|
+
const availableBills = (0, import_react212.useMemo)(
|
|
35318
35505
|
() => rawAvailableBills == null ? void 0 : rawAvailableBills.filter((b) => !billsToPay.find((x) => {
|
|
35319
35506
|
var _a2;
|
|
35320
35507
|
return ((_a2 = x.bill) == null ? void 0 : _a2.id) === b.id;
|
|
@@ -35506,7 +35693,7 @@ var BillsSidebar = () => {
|
|
|
35506
35693
|
};
|
|
35507
35694
|
|
|
35508
35695
|
// src/contexts/VendorsContext.tsx
|
|
35509
|
-
var
|
|
35696
|
+
var import_react213 = require("react");
|
|
35510
35697
|
|
|
35511
35698
|
// src/hooks/useVendors.ts
|
|
35512
35699
|
var import_swr34 = __toESM(require("swr"));
|
|
@@ -35531,10 +35718,10 @@ var useVendors = () => {
|
|
|
35531
35718
|
|
|
35532
35719
|
// src/contexts/VendorsContext.tsx
|
|
35533
35720
|
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
35534
|
-
var VendorsContext = (0,
|
|
35721
|
+
var VendorsContext = (0, import_react213.createContext)({
|
|
35535
35722
|
data: []
|
|
35536
35723
|
});
|
|
35537
|
-
var useVendorsContext = () => (0,
|
|
35724
|
+
var useVendorsContext = () => (0, import_react213.useContext)(VendorsContext);
|
|
35538
35725
|
var VendorsProvider = ({ children }) => {
|
|
35539
35726
|
const vendors = useVendors();
|
|
35540
35727
|
return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(VendorsContext.Provider, { value: vendors, children });
|
|
@@ -35640,7 +35827,7 @@ var BillSummaryPaid = ({ bill }) => {
|
|
|
35640
35827
|
};
|
|
35641
35828
|
|
|
35642
35829
|
// src/components/Bills/BillSummaryUnpaid.tsx
|
|
35643
|
-
var
|
|
35830
|
+
var import_react214 = require("react");
|
|
35644
35831
|
var import_date_fns48 = require("date-fns");
|
|
35645
35832
|
var import_jsx_runtime316 = require("react/jsx-runtime");
|
|
35646
35833
|
function buildDifference(due_at) {
|
|
@@ -35668,7 +35855,7 @@ function buildDifference(due_at) {
|
|
|
35668
35855
|
};
|
|
35669
35856
|
}
|
|
35670
35857
|
var BillSummaryUnpaid = ({ bill }) => {
|
|
35671
|
-
const difference = (0,
|
|
35858
|
+
const difference = (0, import_react214.useMemo)(() => buildDifference(bill.due_at), [bill.due_at]);
|
|
35672
35859
|
return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)("div", { className: "Layer__bill-details__summary", children: [
|
|
35673
35860
|
/* @__PURE__ */ (0, import_jsx_runtime316.jsxs)("div", { children: [
|
|
35674
35861
|
/* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
|
|
@@ -36061,13 +36248,13 @@ var BillsDetails = ({
|
|
|
36061
36248
|
};
|
|
36062
36249
|
|
|
36063
36250
|
// src/components/Bills/BillsTableWithPanel.tsx
|
|
36064
|
-
var
|
|
36251
|
+
var import_react217 = require("react");
|
|
36065
36252
|
|
|
36066
36253
|
// src/components/Bills/BillsTable.tsx
|
|
36067
|
-
var
|
|
36254
|
+
var import_react216 = require("react");
|
|
36068
36255
|
|
|
36069
36256
|
// src/components/DueStatus/DueStatus.tsx
|
|
36070
|
-
var
|
|
36257
|
+
var import_react215 = require("react");
|
|
36071
36258
|
var import_date_fns50 = require("date-fns");
|
|
36072
36259
|
var import_jsx_runtime319 = require("react/jsx-runtime");
|
|
36073
36260
|
var dueStatusTitle = (daysDiff, paid) => {
|
|
@@ -36132,7 +36319,7 @@ var getDiff = (refDate) => {
|
|
|
36132
36319
|
return (0, import_date_fns50.differenceInDays)(today, d);
|
|
36133
36320
|
};
|
|
36134
36321
|
var DueStatus = ({ dueDate, paidAt, size = "md" }) => {
|
|
36135
|
-
const date = (0,
|
|
36322
|
+
const date = (0, import_react215.useMemo)(() => {
|
|
36136
36323
|
try {
|
|
36137
36324
|
const diff = getDiff(paidAt ? paidAt : dueDate);
|
|
36138
36325
|
if (diff === null) {
|
|
@@ -36228,7 +36415,7 @@ var BillsTableContent = ({
|
|
|
36228
36415
|
"Layer__bills-table__actions-col",
|
|
36229
36416
|
status === "PAID" ? "Layer__bills-table__actions-col--narrow" : ""
|
|
36230
36417
|
);
|
|
36231
|
-
return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
|
|
36418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_react216.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(TableRow, { rowKey: rowKey + "-" + index, variant: "main", children: [
|
|
36232
36419
|
/* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(TableCell, { primary: true, nowrap: true, className: "Layer__bills-table__vendor-col", children: [
|
|
36233
36420
|
bulkSelectionActive && status === "UNPAID" && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
|
|
36234
36421
|
CheckboxWithTooltip,
|
|
@@ -36460,11 +36647,11 @@ var BillsTableWithPanel = ({
|
|
|
36460
36647
|
setVendor: setRecordPaymentVendor
|
|
36461
36648
|
} = useBillsRecordPaymentContext();
|
|
36462
36649
|
const { isDesktop, isMobile } = useSizeClass();
|
|
36463
|
-
const totalCount = (0,
|
|
36650
|
+
const totalCount = (0, import_react217.useMemo)(() => {
|
|
36464
36651
|
var _a;
|
|
36465
36652
|
return (_a = rawData == null ? void 0 : rawData.length) != null ? _a : 0;
|
|
36466
36653
|
}, [rawData]);
|
|
36467
|
-
const anyBillToPaySelected = (0,
|
|
36654
|
+
const anyBillToPaySelected = (0, import_react217.useMemo)(() => {
|
|
36468
36655
|
return billsToPay.length > 0;
|
|
36469
36656
|
}, [billsToPay]);
|
|
36470
36657
|
return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(
|
|
@@ -36658,7 +36845,7 @@ var BillsViewContent = ({
|
|
|
36658
36845
|
};
|
|
36659
36846
|
|
|
36660
36847
|
// src/views/Reports/Reports.tsx
|
|
36661
|
-
var
|
|
36848
|
+
var import_react218 = require("react");
|
|
36662
36849
|
var import_jsx_runtime327 = require("react/jsx-runtime");
|
|
36663
36850
|
var getOptions = (enabledReports) => {
|
|
36664
36851
|
return [
|
|
@@ -36686,7 +36873,7 @@ var Reports = ({
|
|
|
36686
36873
|
statementOfCashFlowConfig
|
|
36687
36874
|
}) => {
|
|
36688
36875
|
var _a;
|
|
36689
|
-
const [activeTab, setActiveTab] = (0,
|
|
36876
|
+
const [activeTab, setActiveTab] = (0, import_react218.useState)(enabledReports[0]);
|
|
36690
36877
|
const { view, containerRef } = useElementViewSize();
|
|
36691
36878
|
const options = getOptions(enabledReports);
|
|
36692
36879
|
const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value = enabledReports[0])) == null ? void 0 : _a.label;
|
|
@@ -36745,11 +36932,11 @@ var ReportsPanel = ({
|
|
|
36745
36932
|
};
|
|
36746
36933
|
|
|
36747
36934
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
36748
|
-
var
|
|
36935
|
+
var import_react219 = require("react");
|
|
36749
36936
|
var import_jsx_runtime328 = require("react/jsx-runtime");
|
|
36750
36937
|
var COMPONENT_NAME9 = "profit-and-loss";
|
|
36751
36938
|
var ProfitAndLossView = (props) => {
|
|
36752
|
-
const containerRef = (0,
|
|
36939
|
+
const containerRef = (0, import_react219.useRef)(null);
|
|
36753
36940
|
return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(Container, { name: COMPONENT_NAME9, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(ProfitAndLoss, { children: /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
|
|
36754
36941
|
};
|
|
36755
36942
|
var ProfitAndLossPanel = (_a) => {
|
|
@@ -36760,7 +36947,7 @@ var ProfitAndLossPanel = (_a) => {
|
|
|
36760
36947
|
"containerRef",
|
|
36761
36948
|
"stringOverrides"
|
|
36762
36949
|
]);
|
|
36763
|
-
const { sidebarScope } = (0,
|
|
36950
|
+
const { sidebarScope } = (0, import_react219.useContext)(ProfitAndLoss.Context);
|
|
36764
36951
|
return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(
|
|
36765
36952
|
Panel,
|
|
36766
36953
|
{
|
|
@@ -36791,7 +36978,7 @@ var Components = ({
|
|
|
36791
36978
|
hideTable = false,
|
|
36792
36979
|
stringOverrides
|
|
36793
36980
|
}) => {
|
|
36794
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
36981
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react219.useContext)(
|
|
36795
36982
|
ProfitAndLoss.Context
|
|
36796
36983
|
);
|
|
36797
36984
|
if (!isLoading && error) {
|