@layerfi/components 0.1.117 → 0.1.118-alpha
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 +457 -402
- package/dist/esm/index.mjs +458 -403
- package/dist/index.css +13 -12
- package/dist/index.d.ts +10 -6
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -54,12 +54,12 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
54
54
|
import { createContext, useState, useContext, useMemo, useEffect, forwardRef, useCallback, useRef, isValidElement, cloneElement, useLayoutEffect, memo, useId, Children, useImperativeHandle, createElement, Component, Fragment as Fragment$1, useReducer } from "react";
|
|
55
55
|
import { createStore, useStore } from "zustand";
|
|
56
56
|
import { usePlaidLink } from "react-plaid-link";
|
|
57
|
-
import { formatISO, differenceInDays, isWithinInterval, parseISO, endOfDay, startOfMonth, endOfMonth, min, max, differenceInCalendarMonths, format, isValid, startOfYear, subMonths, getYear, getMonth, subYears, differenceInCalendarYears, sub, differenceInMonths, add, startOfDay,
|
|
57
|
+
import { formatISO, differenceInDays, isWithinInterval, parseISO, endOfDay, startOfMonth, endOfMonth, min, max, differenceInCalendarMonths, format, isValid, startOfYear, subMonths, getYear, getMonth, subYears, differenceInCalendarYears, sub, differenceInMonths, add, startOfDay, isEqual, addYears, endOfYear, subQuarters, addQuarters, endOfQuarter, startOfQuarter, addMonths, set, startOfToday, endOfYesterday, formatDate as formatDate$1 } from "date-fns";
|
|
58
|
+
import { Schema, pipe, BigDecimal, Option, Effect } from "effect";
|
|
58
59
|
import { fromDate, getLocalTimeZone, DateFormatter, CalendarDate, ZonedDateTime, toCalendarDate, today, parseDate } from "@internationalized/date";
|
|
59
60
|
import useSWR, { unstable_serialize, useSWRConfig, SWRConfig } from "swr";
|
|
60
61
|
import classNames from "classnames";
|
|
61
62
|
import { Schema as Schema$1, pipe as pipe$1 } from "effect/index";
|
|
62
|
-
import { Schema, pipe, BigDecimal, Option, Effect } from "effect";
|
|
63
63
|
import { debounce, uniqBy, merge, uniqueId } from "lodash-es";
|
|
64
64
|
import useSWRInfinite from "swr/infinite";
|
|
65
65
|
import { useStoreWithEqualityFn } from "zustand/traditional";
|
|
@@ -149,6 +149,13 @@ function toSnakeCase(input) {
|
|
|
149
149
|
const segments = (_a = input.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)) != null ? _a : [];
|
|
150
150
|
return segments.map((segment) => segment.toLowerCase()).join("_");
|
|
151
151
|
}
|
|
152
|
+
Schema.Union(
|
|
153
|
+
Schema.Date,
|
|
154
|
+
Schema.String,
|
|
155
|
+
Schema.Array(Schema.String),
|
|
156
|
+
Schema.Number,
|
|
157
|
+
Schema.Boolean
|
|
158
|
+
);
|
|
152
159
|
function toDefinedSearchParameters(input) {
|
|
153
160
|
const definedParameterPairs = Object.entries(input).flatMap(([key, value]) => {
|
|
154
161
|
if (value === null || value === void 0) {
|
|
@@ -202,7 +209,7 @@ class ErrorHandlerClass {
|
|
|
202
209
|
}
|
|
203
210
|
const errorHandler = new ErrorHandlerClass();
|
|
204
211
|
const reportError = (payload) => errorHandler.onError(payload);
|
|
205
|
-
const version = "0.1.
|
|
212
|
+
const version = "0.1.118-alpha";
|
|
206
213
|
const pkg = {
|
|
207
214
|
version
|
|
208
215
|
};
|
|
@@ -3182,10 +3189,6 @@ function clampToPresentOrPast(date, cutoff = endOfDay(/* @__PURE__ */ new Date()
|
|
|
3182
3189
|
return min([date, cutoff]);
|
|
3183
3190
|
}
|
|
3184
3191
|
const RANGE_MODE_LOOKUP = {
|
|
3185
|
-
date: {
|
|
3186
|
-
getStartDate: ({ startDate }) => startOfMonth(startDate),
|
|
3187
|
-
getEndDate: ({ endDate }) => clampToPresentOrPast(endOfDay(endDate))
|
|
3188
|
-
},
|
|
3189
3192
|
full: {
|
|
3190
3193
|
getStartDate: ({ startDate }) => startDate,
|
|
3191
3194
|
getEndDate: ({ endDate }) => clampToPresentOrPast(endOfDay(endDate))
|
|
@@ -3212,8 +3215,8 @@ function buildStore$2() {
|
|
|
3212
3215
|
return next;
|
|
3213
3216
|
};
|
|
3214
3217
|
const setDate = ({ date }) => {
|
|
3215
|
-
const s = RANGE_MODE_LOOKUP.
|
|
3216
|
-
const e = RANGE_MODE_LOOKUP.
|
|
3218
|
+
const s = RANGE_MODE_LOOKUP.month.getStartDate({ startDate: date });
|
|
3219
|
+
const e = RANGE_MODE_LOOKUP.full.getEndDate({ endDate: date });
|
|
3217
3220
|
return apply({ startDate: s, endDate: e });
|
|
3218
3221
|
};
|
|
3219
3222
|
const setDateRange = withCorrectedRange(({ startDate, endDate }) => {
|
|
@@ -3226,30 +3229,11 @@ function buildStore$2() {
|
|
|
3226
3229
|
const e = RANGE_MODE_LOOKUP.month.getEndDate({ endDate: startDate });
|
|
3227
3230
|
return apply({ startDate: s, endDate: e });
|
|
3228
3231
|
};
|
|
3229
|
-
const setRangeWithExplicitDisplayMode = ({
|
|
3230
|
-
startDate,
|
|
3231
|
-
endDate,
|
|
3232
|
-
displayMode
|
|
3233
|
-
}) => {
|
|
3234
|
-
switch (displayMode) {
|
|
3235
|
-
case "date":
|
|
3236
|
-
return setDate({ date: endDate });
|
|
3237
|
-
case "full":
|
|
3238
|
-
return setDateRange({ startDate, endDate });
|
|
3239
|
-
case "month":
|
|
3240
|
-
return setMonth({ startDate });
|
|
3241
|
-
default:
|
|
3242
|
-
unsafeAssertUnreachable({
|
|
3243
|
-
message: "Invalid `displayMode`"
|
|
3244
|
-
});
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
3232
|
return {
|
|
3248
3233
|
startDate: startOfMonth(now),
|
|
3249
3234
|
endDate: clampToPresentOrPast(endOfMonth(now)),
|
|
3250
3235
|
actions: {
|
|
3251
3236
|
setDate,
|
|
3252
|
-
setRangeWithExplicitDisplayMode,
|
|
3253
3237
|
setDateRange,
|
|
3254
3238
|
setMonth,
|
|
3255
3239
|
setMonthByPeriod: ({ monthNumber, yearNumber }) => {
|
|
@@ -3261,10 +3245,17 @@ function buildStore$2() {
|
|
|
3261
3245
|
});
|
|
3262
3246
|
}
|
|
3263
3247
|
const GlobalDateStoreContext = createContext(buildStore$2());
|
|
3264
|
-
|
|
3248
|
+
const getEffectiveDateForMode = (mode, { date }) => {
|
|
3249
|
+
const rangeModifierForMode = RANGE_MODE_LOOKUP[mode];
|
|
3250
|
+
return { date: rangeModifierForMode.getEndDate({ endDate: date }) };
|
|
3251
|
+
};
|
|
3252
|
+
function useGlobalDate({ dateSelectionMode = "full" } = {}) {
|
|
3265
3253
|
const store = useContext(GlobalDateStoreContext);
|
|
3266
|
-
const
|
|
3267
|
-
return
|
|
3254
|
+
const rawDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
|
|
3255
|
+
return useMemo(
|
|
3256
|
+
() => getEffectiveDateForMode(dateSelectionMode, { date: rawDate }),
|
|
3257
|
+
[dateSelectionMode, rawDate]
|
|
3258
|
+
);
|
|
3268
3259
|
}
|
|
3269
3260
|
function useGlobalDateActions() {
|
|
3270
3261
|
const store = useContext(GlobalDateStoreContext);
|
|
@@ -3278,28 +3269,23 @@ const getEffectiveDateRangeForMode = (mode, { startDate, endDate }) => {
|
|
|
3278
3269
|
endDate: rangeModifierForMode.getEndDate({ endDate })
|
|
3279
3270
|
};
|
|
3280
3271
|
};
|
|
3281
|
-
function useGlobalDateRange({
|
|
3272
|
+
function useGlobalDateRange({ dateSelectionMode }) {
|
|
3282
3273
|
const store = useContext(GlobalDateStoreContext);
|
|
3283
3274
|
const rawStartDate = useStoreWithDateSelected(store, ({ startDate }) => startDate);
|
|
3284
3275
|
const rawEndDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
|
|
3285
3276
|
return useMemo(
|
|
3286
3277
|
() => getEffectiveDateRangeForMode(
|
|
3287
|
-
|
|
3278
|
+
dateSelectionMode,
|
|
3288
3279
|
{ startDate: rawStartDate, endDate: rawEndDate }
|
|
3289
3280
|
),
|
|
3290
|
-
[
|
|
3281
|
+
[dateSelectionMode, rawEndDate, rawStartDate]
|
|
3291
3282
|
);
|
|
3292
3283
|
}
|
|
3293
3284
|
function useGlobalDateRangeActions() {
|
|
3294
3285
|
const store = useContext(GlobalDateStoreContext);
|
|
3295
|
-
const setRangeWithExplicitDisplayMode = useStore(
|
|
3296
|
-
store,
|
|
3297
|
-
({ actions: { setRangeWithExplicitDisplayMode: setRangeWithExplicitDisplayMode2 } }) => setRangeWithExplicitDisplayMode2
|
|
3298
|
-
);
|
|
3299
3286
|
const setDateRange = useStore(store, ({ actions: { setDateRange: setDateRange2 } }) => setDateRange2);
|
|
3300
3287
|
const setMonth = useStore(store, ({ actions: { setMonth: setMonth2 } }) => setMonth2);
|
|
3301
3288
|
return {
|
|
3302
|
-
setRangeWithExplicitDisplayMode,
|
|
3303
3289
|
setDateRange,
|
|
3304
3290
|
setMonth
|
|
3305
3291
|
};
|
|
@@ -3317,7 +3303,7 @@ function GlobalDateStoreProvider({
|
|
|
3317
3303
|
}
|
|
3318
3304
|
const useBankTransactionsFilters = (params) => {
|
|
3319
3305
|
const dateFilterMode = (params == null ? void 0 : params.applyGlobalDateRange) ? BankTransactionsDateFilterMode.GlobalDateRange : (params == null ? void 0 : params.monthlyView) ? BankTransactionsDateFilterMode.MonthlyView : void 0;
|
|
3320
|
-
const globalDateRange = useGlobalDateRange({
|
|
3306
|
+
const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
3321
3307
|
const defaultDateRange = {
|
|
3322
3308
|
startDate: startOfMonth(/* @__PURE__ */ new Date()),
|
|
3323
3309
|
endDate: endOfMonth(/* @__PURE__ */ new Date())
|
|
@@ -11278,6 +11264,10 @@ const InvoicePaymentLedgerEntrySourceSchema = Schema.Struct({
|
|
|
11278
11264
|
Schema.propertySignature(Schema.String),
|
|
11279
11265
|
Schema.fromKey("invoice_id")
|
|
11280
11266
|
),
|
|
11267
|
+
invoicePaymentId: pipe(
|
|
11268
|
+
Schema.propertySignature(Schema.String),
|
|
11269
|
+
Schema.fromKey("invoice_payment_id")
|
|
11270
|
+
),
|
|
11281
11271
|
invoiceNumber: pipe(
|
|
11282
11272
|
Schema.propertySignature(Schema.NullOr(Schema.String)),
|
|
11283
11273
|
Schema.fromKey("invoice_number")
|
|
@@ -11740,6 +11730,10 @@ const BillPaymentLedgerEntrySourceSchema = Schema.Struct({
|
|
|
11740
11730
|
Schema.optional(Schema.NullOr(Schema.String)),
|
|
11741
11731
|
Schema.fromKey("external_id")
|
|
11742
11732
|
),
|
|
11733
|
+
billPaymentId: pipe(
|
|
11734
|
+
Schema.propertySignature(Schema.String),
|
|
11735
|
+
Schema.fromKey("bill_payment_id")
|
|
11736
|
+
),
|
|
11743
11737
|
billId: pipe(
|
|
11744
11738
|
Schema.propertySignature(Schema.String),
|
|
11745
11739
|
Schema.fromKey("bill_id")
|
|
@@ -11865,7 +11859,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
|
|
|
11865
11859
|
baseMetadata.id = ledgerEntrySource.manualEntryId;
|
|
11866
11860
|
break;
|
|
11867
11861
|
case "Invoice_Payment_Ledger_Entry_Source":
|
|
11868
|
-
baseMetadata.id = ledgerEntrySource.
|
|
11862
|
+
baseMetadata.id = ledgerEntrySource.invoicePaymentId;
|
|
11869
11863
|
baseMetadata.entityName = EntityName.InvoicePayment;
|
|
11870
11864
|
if (ledgerEntrySource.invoiceIdentifiers) {
|
|
11871
11865
|
baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.invoiceIdentifiers.map((identifier) => ({
|
|
@@ -11971,7 +11965,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
|
|
|
11971
11965
|
baseMetadata.entityName = EntityName.Bill;
|
|
11972
11966
|
break;
|
|
11973
11967
|
case "Bill_Payment_Ledger_Entry_Source":
|
|
11974
|
-
baseMetadata.id = ledgerEntrySource.
|
|
11968
|
+
baseMetadata.id = ledgerEntrySource.billPaymentId;
|
|
11975
11969
|
baseMetadata.entityName = EntityName.BillPayment;
|
|
11976
11970
|
if (ledgerEntrySource.billIdentifiers) {
|
|
11977
11971
|
baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.billIdentifiers.map((identifier) => ({
|
|
@@ -12706,11 +12700,13 @@ const CSS_PREFIX$1 = "Layer__UI__Table";
|
|
|
12706
12700
|
const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
|
|
12707
12701
|
const Table$1 = forwardRef(
|
|
12708
12702
|
(_rb, ref) => {
|
|
12709
|
-
var _sb = _rb, { children, className } = _sb, restProps = __objRest(_sb, ["children", "className"]);
|
|
12703
|
+
var _sb = _rb, { children, className, nonAria, slot } = _sb, restProps = __objRest(_sb, ["children", "className", "nonAria", "slot"]);
|
|
12704
|
+
const TableComponent = nonAria ? "table" : Table$2;
|
|
12710
12705
|
return /* @__PURE__ */ jsx(
|
|
12711
|
-
|
|
12706
|
+
TableComponent,
|
|
12712
12707
|
__spreadProps(__spreadValues({
|
|
12713
|
-
className: getClassName("Table", className)
|
|
12708
|
+
className: getClassName("Table", className),
|
|
12709
|
+
slot: slot != null ? slot : void 0
|
|
12714
12710
|
}, restProps), {
|
|
12715
12711
|
ref,
|
|
12716
12712
|
children
|
|
@@ -12720,9 +12716,10 @@ const Table$1 = forwardRef(
|
|
|
12720
12716
|
);
|
|
12721
12717
|
Table$1.displayName = "Table";
|
|
12722
12718
|
const TableHeaderInner = (_tb, ref) => {
|
|
12723
|
-
var _ub = _tb, { children, className, hideHeader } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader"]);
|
|
12719
|
+
var _ub = _tb, { children, className, hideHeader, nonAria } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader", "nonAria"]);
|
|
12720
|
+
const TableHeaderComponent = nonAria ? "thead" : TableHeader$1;
|
|
12724
12721
|
return /* @__PURE__ */ jsx(
|
|
12725
|
-
|
|
12722
|
+
TableHeaderComponent,
|
|
12726
12723
|
__spreadProps(__spreadValues({
|
|
12727
12724
|
className: getClassName("TableHeader", className, hideHeader)
|
|
12728
12725
|
}, restProps), {
|
|
@@ -12734,9 +12731,10 @@ const TableHeaderInner = (_tb, ref) => {
|
|
|
12734
12731
|
const TableHeader = forwardRef(TableHeaderInner);
|
|
12735
12732
|
TableHeader.displayName = "TableHeader";
|
|
12736
12733
|
const TableBodyInner = (_vb, ref) => {
|
|
12737
|
-
var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
|
|
12734
|
+
var _wb = _vb, { children, className, nonAria } = _wb, restProps = __objRest(_wb, ["children", "className", "nonAria"]);
|
|
12735
|
+
const TableBodyComponent = nonAria ? "tbody" : TableBody$2;
|
|
12738
12736
|
return /* @__PURE__ */ jsx(
|
|
12739
|
-
|
|
12737
|
+
TableBodyComponent,
|
|
12740
12738
|
__spreadProps(__spreadValues({
|
|
12741
12739
|
className: getClassName("TableBody", className)
|
|
12742
12740
|
}, restProps), {
|
|
@@ -12748,14 +12746,16 @@ const TableBodyInner = (_vb, ref) => {
|
|
|
12748
12746
|
const TableBody$1 = forwardRef(TableBodyInner);
|
|
12749
12747
|
TableBody$1.displayName = "TableBody";
|
|
12750
12748
|
const RowInner = (_xb, ref) => {
|
|
12751
|
-
var _yb = _xb, { children, className, depth = 0 } = _yb, restProps = __objRest(_yb, ["children", "className", "depth"]);
|
|
12749
|
+
var _yb = _xb, { children, className, depth = 0, nonAria, id } = _yb, restProps = __objRest(_yb, ["children", "className", "depth", "nonAria", "id"]);
|
|
12752
12750
|
const dataProperties = toDataProperties({ depth });
|
|
12751
|
+
const RowComponent = nonAria ? "tr" : Row$1;
|
|
12753
12752
|
return /* @__PURE__ */ jsx(
|
|
12754
|
-
|
|
12753
|
+
RowComponent,
|
|
12755
12754
|
__spreadProps(__spreadValues(__spreadValues({
|
|
12756
12755
|
className: getClassName("Row", className)
|
|
12757
12756
|
}, restProps), dataProperties), {
|
|
12758
12757
|
ref,
|
|
12758
|
+
id: id == null ? void 0 : id.toString(),
|
|
12759
12759
|
children: withRenderProp(children, (node) => node)
|
|
12760
12760
|
})
|
|
12761
12761
|
);
|
|
@@ -12764,14 +12764,18 @@ const Row = forwardRef(RowInner);
|
|
|
12764
12764
|
Row.displayName = "Row";
|
|
12765
12765
|
const Column = forwardRef(
|
|
12766
12766
|
(_zb, ref) => {
|
|
12767
|
-
var _Ab = _zb, { children, className, textAlign = "left" } = _Ab, restProps = __objRest(_Ab, ["children", "className", "textAlign"]);
|
|
12767
|
+
var _Ab = _zb, { children, className, nonAria, id, textAlign = "left", colSpan = 1 } = _Ab, restProps = __objRest(_Ab, ["children", "className", "nonAria", "id", "textAlign", "colSpan"]);
|
|
12768
12768
|
const dataProperties = toDataProperties({ "text-align": textAlign });
|
|
12769
|
+
const columnClassName = getClassName("Column", className);
|
|
12770
|
+
const ColumnComponent = nonAria ? "th" : Column$1;
|
|
12769
12771
|
return /* @__PURE__ */ jsx(
|
|
12770
|
-
|
|
12772
|
+
ColumnComponent,
|
|
12771
12773
|
__spreadProps(__spreadValues(__spreadValues({
|
|
12772
|
-
className:
|
|
12774
|
+
className: columnClassName
|
|
12773
12775
|
}, restProps), dataProperties), {
|
|
12774
12776
|
ref,
|
|
12777
|
+
id: id == null ? void 0 : id.toString(),
|
|
12778
|
+
colSpan,
|
|
12775
12779
|
children: withRenderProp(children, (node) => node)
|
|
12776
12780
|
})
|
|
12777
12781
|
);
|
|
@@ -12780,19 +12784,44 @@ const Column = forwardRef(
|
|
|
12780
12784
|
Column.displayName = "Column";
|
|
12781
12785
|
const Cell = forwardRef(
|
|
12782
12786
|
(_Bb, ref) => {
|
|
12783
|
-
var _Cb = _Bb, { children, className } = _Cb, restProps = __objRest(_Cb, ["children", "className"]);
|
|
12787
|
+
var _Cb = _Bb, { children, className, nonAria, id } = _Cb, restProps = __objRest(_Cb, ["children", "className", "nonAria", "id"]);
|
|
12788
|
+
const CellComponent = nonAria ? "td" : Cell$1;
|
|
12784
12789
|
return /* @__PURE__ */ jsx(
|
|
12785
|
-
|
|
12790
|
+
CellComponent,
|
|
12786
12791
|
__spreadProps(__spreadValues({
|
|
12787
12792
|
className: getClassName("Cell", className)
|
|
12788
12793
|
}, restProps), {
|
|
12789
12794
|
ref,
|
|
12795
|
+
id: id == null ? void 0 : id.toString(),
|
|
12790
12796
|
children: withRenderProp(children, (node) => node)
|
|
12791
12797
|
})
|
|
12792
12798
|
);
|
|
12793
12799
|
}
|
|
12794
12800
|
);
|
|
12795
12801
|
Cell.displayName = "Cell";
|
|
12802
|
+
const isLeafColumn = (col) => {
|
|
12803
|
+
return "cell" in col;
|
|
12804
|
+
};
|
|
12805
|
+
const getColumnDefs = (columnConfig) => {
|
|
12806
|
+
const columnHelper = createColumnHelper();
|
|
12807
|
+
return columnConfig.map((col) => {
|
|
12808
|
+
if (isLeafColumn(col)) {
|
|
12809
|
+
return columnHelper.display({
|
|
12810
|
+
id: col.id,
|
|
12811
|
+
header: () => col.header,
|
|
12812
|
+
cell: ({ row }) => col.cell(row),
|
|
12813
|
+
meta: {
|
|
12814
|
+
isRowHeader: col.isRowHeader || false
|
|
12815
|
+
}
|
|
12816
|
+
});
|
|
12817
|
+
}
|
|
12818
|
+
return columnHelper.group({
|
|
12819
|
+
id: col.id,
|
|
12820
|
+
header: () => col.header,
|
|
12821
|
+
columns: getColumnDefs(col.columns)
|
|
12822
|
+
});
|
|
12823
|
+
});
|
|
12824
|
+
};
|
|
12796
12825
|
const Loader = ({ children, size = 28 }) => {
|
|
12797
12826
|
return /* @__PURE__ */ jsxs("span", { className: "Layer__loader", children: [
|
|
12798
12827
|
/* @__PURE__ */ jsx(Loader$1, { size, className: "Layer__anim--rotating" }),
|
|
@@ -12828,19 +12857,8 @@ const VirtualizedDataTable = ({
|
|
|
12828
12857
|
const calculatedHeight = actualRowCount * rowHeight + HEADER_HEIGHT + 1;
|
|
12829
12858
|
return Math.min(height, calculatedHeight);
|
|
12830
12859
|
}, [data, height, rowHeight, shrinkHeightToFitRows]);
|
|
12831
|
-
const columnHelper = createColumnHelper();
|
|
12832
|
-
const columns = Object.values(columnConfig);
|
|
12833
12860
|
const tableData = data != null ? data : EMPTY_ARRAY$2;
|
|
12834
|
-
const columnDefs =
|
|
12835
|
-
return columnHelper.display({
|
|
12836
|
-
id: col.id,
|
|
12837
|
-
header: () => col.header,
|
|
12838
|
-
cell: ({ row }) => col.cell(row.original),
|
|
12839
|
-
meta: {
|
|
12840
|
-
isRowHeader: col.isRowHeader || false
|
|
12841
|
-
}
|
|
12842
|
-
});
|
|
12843
|
-
});
|
|
12861
|
+
const columnDefs = getColumnDefs(columnConfig);
|
|
12844
12862
|
const table2 = useReactTable({
|
|
12845
12863
|
data: tableData,
|
|
12846
12864
|
columns: columnDefs,
|
|
@@ -12938,43 +12956,34 @@ const AffectedTransactionsTable = ({
|
|
|
12938
12956
|
isLoading = false,
|
|
12939
12957
|
isError = false
|
|
12940
12958
|
}) => {
|
|
12941
|
-
const columnConfig = useMemo(() =>
|
|
12942
|
-
|
|
12943
|
-
"Date"
|
|
12944
|
-
/* Date */
|
|
12945
|
-
]: {
|
|
12959
|
+
const columnConfig = useMemo(() => [
|
|
12960
|
+
{
|
|
12946
12961
|
id: "Date",
|
|
12947
12962
|
header: "Date",
|
|
12948
12963
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
12949
12964
|
DateTime,
|
|
12950
12965
|
{
|
|
12951
|
-
valueAsDate: row.date,
|
|
12966
|
+
valueAsDate: row.original.date,
|
|
12952
12967
|
onlyDate: true,
|
|
12953
12968
|
slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
|
|
12954
12969
|
}
|
|
12955
12970
|
)
|
|
12956
12971
|
},
|
|
12957
|
-
|
|
12958
|
-
"Description"
|
|
12959
|
-
/* Description */
|
|
12960
|
-
]: {
|
|
12972
|
+
{
|
|
12961
12973
|
id: "Description",
|
|
12962
12974
|
header: "Description",
|
|
12963
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { withTooltip: true, children: row.counterpartyName || row.description || "-" }),
|
|
12975
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { withTooltip: true, children: row.original.counterpartyName || row.original.description || "-" }),
|
|
12964
12976
|
isRowHeader: true
|
|
12965
12977
|
},
|
|
12966
|
-
|
|
12967
|
-
"Amount"
|
|
12968
|
-
/* Amount */
|
|
12969
|
-
]: {
|
|
12978
|
+
{
|
|
12970
12979
|
id: "Amount",
|
|
12971
12980
|
header: "Amount",
|
|
12972
12981
|
cell: (row) => {
|
|
12973
|
-
const amount = row.direction === BankTransactionDirection.Credit ? row.amount : -row.amount;
|
|
12982
|
+
const amount = row.original.direction === BankTransactionDirection.Credit ? row.original.amount : -row.original.amount;
|
|
12974
12983
|
return /* @__PURE__ */ jsx(MoneySpan, { amount });
|
|
12975
12984
|
}
|
|
12976
12985
|
}
|
|
12977
|
-
|
|
12986
|
+
], []);
|
|
12978
12987
|
return /* @__PURE__ */ jsx(VStack, { className: "Layer__AffectedTransactionsTable", children: /* @__PURE__ */ jsx(
|
|
12979
12988
|
VirtualizedDataTable,
|
|
12980
12989
|
{
|
|
@@ -16350,7 +16359,7 @@ const ExpandedBankTransactionRow = ({
|
|
|
16350
16359
|
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
16351
16360
|
children: isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16352
16361
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
16353
|
-
/* @__PURE__ */ jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", children: [
|
|
16362
|
+
/* @__PURE__ */ jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", pbe: "md", children: [
|
|
16354
16363
|
categorizationEnabled && /* @__PURE__ */ jsx(HStack, { pi: "md", pbe: "md", pbs: "3xs", children: /* @__PURE__ */ jsx(
|
|
16355
16364
|
Toggle,
|
|
16356
16365
|
{
|
|
@@ -17008,7 +17017,7 @@ const BankTransactionsListItem = ({
|
|
|
17008
17017
|
onValidityChange: setIsExpandedRowValid
|
|
17009
17018
|
}
|
|
17010
17019
|
) }, `expanded-${bankTransaction.id}`) }),
|
|
17011
|
-
categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md",
|
|
17020
|
+
categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md", pbe: "md", justify: "end", children: [
|
|
17012
17021
|
!openExpandedRow && /* @__PURE__ */ jsx(
|
|
17013
17022
|
BankTransactionCategoryComboBox,
|
|
17014
17023
|
{
|
|
@@ -17477,20 +17486,37 @@ const BankTransactionsMobileListBusinessForm = ({
|
|
|
17477
17486
|
)
|
|
17478
17487
|
] });
|
|
17479
17488
|
};
|
|
17480
|
-
var
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
return
|
|
17484
|
-
})(
|
|
17489
|
+
var PersonalStableName = /* @__PURE__ */ ((PersonalStableName2) => {
|
|
17490
|
+
PersonalStableName2["CREDIT"] = "CONTRIBUTIONS";
|
|
17491
|
+
PersonalStableName2["DEBIT"] = "PERSONAL_EXPENSES";
|
|
17492
|
+
return PersonalStableName2;
|
|
17493
|
+
})(PersonalStableName || {});
|
|
17494
|
+
var LegacyPersonalCategories = /* @__PURE__ */ ((LegacyPersonalCategories2) => {
|
|
17495
|
+
LegacyPersonalCategories2["INCOME"] = "PERSONAL_INFLOWS";
|
|
17496
|
+
LegacyPersonalCategories2["EXPENSES"] = "PERSONAL_EXPENSES";
|
|
17497
|
+
return LegacyPersonalCategories2;
|
|
17498
|
+
})(LegacyPersonalCategories || {});
|
|
17485
17499
|
const isAlreadyAssigned = (bankTransaction) => {
|
|
17486
17500
|
if (bankTransaction.categorization_status === CategorizationStatus.MATCHED || (bankTransaction == null ? void 0 : bankTransaction.categorization_status) === CategorizationStatus.SPLIT) {
|
|
17487
17501
|
return false;
|
|
17488
17502
|
}
|
|
17489
|
-
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
)
|
|
17503
|
+
if (!bankTransaction.category) {
|
|
17504
|
+
return false;
|
|
17505
|
+
}
|
|
17506
|
+
const category = bankTransaction.category;
|
|
17507
|
+
if (category.type === "Account" && "stable_name" in category) {
|
|
17508
|
+
const stableName = category.stable_name;
|
|
17509
|
+
if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
|
|
17510
|
+
return true;
|
|
17511
|
+
}
|
|
17512
|
+
}
|
|
17513
|
+
if (category.type === "Exclusion") {
|
|
17514
|
+
const displayName = category.display_name;
|
|
17515
|
+
if (Object.values(LegacyPersonalCategories).includes(displayName)) {
|
|
17516
|
+
return true;
|
|
17517
|
+
}
|
|
17518
|
+
}
|
|
17519
|
+
return false;
|
|
17494
17520
|
};
|
|
17495
17521
|
const BankTransactionsMobileListPersonalForm = ({
|
|
17496
17522
|
bankTransaction,
|
|
@@ -17519,8 +17545,8 @@ const BankTransactionsMobileListPersonalForm = ({
|
|
|
17519
17545
|
{
|
|
17520
17546
|
type: "Category",
|
|
17521
17547
|
category: {
|
|
17522
|
-
type: "
|
|
17523
|
-
|
|
17548
|
+
type: "StableName",
|
|
17549
|
+
stableName: isCredit(bankTransaction) ? PersonalStableName.CREDIT : PersonalStableName.DEBIT
|
|
17524
17550
|
}
|
|
17525
17551
|
},
|
|
17526
17552
|
true
|
|
@@ -18058,9 +18084,24 @@ const BankTransactionsMobileListItemExpandedRow = ({
|
|
|
18058
18084
|
)
|
|
18059
18085
|
] });
|
|
18060
18086
|
};
|
|
18087
|
+
const isPersonalCategory = (category) => {
|
|
18088
|
+
if (!category) {
|
|
18089
|
+
return false;
|
|
18090
|
+
}
|
|
18091
|
+
if (category.type === "Account" && "stable_name" in category) {
|
|
18092
|
+
const stableName = category.stable_name;
|
|
18093
|
+
if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
|
|
18094
|
+
return true;
|
|
18095
|
+
}
|
|
18096
|
+
}
|
|
18097
|
+
if (category.type === "Exclusion") {
|
|
18098
|
+
return true;
|
|
18099
|
+
}
|
|
18100
|
+
return false;
|
|
18101
|
+
};
|
|
18061
18102
|
const getInitialPurpose = (bankTransaction) => {
|
|
18062
18103
|
if (bankTransaction.category) {
|
|
18063
|
-
if (bankTransaction.category
|
|
18104
|
+
if (isPersonalCategory(bankTransaction.category)) {
|
|
18064
18105
|
return Purpose.personal;
|
|
18065
18106
|
}
|
|
18066
18107
|
if (bankTransaction.categorization_status === CategorizationStatus.SPLIT) {
|
|
@@ -18593,43 +18634,56 @@ function useArchiveCategorizationRule() {
|
|
|
18593
18634
|
});
|
|
18594
18635
|
}
|
|
18595
18636
|
const DataTable = ({
|
|
18596
|
-
columnConfig,
|
|
18597
|
-
data,
|
|
18598
18637
|
isLoading,
|
|
18599
18638
|
isError,
|
|
18600
18639
|
componentName,
|
|
18601
18640
|
ariaLabel,
|
|
18602
18641
|
slots,
|
|
18603
18642
|
hideHeader,
|
|
18604
|
-
dependencies
|
|
18643
|
+
dependencies,
|
|
18644
|
+
data,
|
|
18645
|
+
headerGroups,
|
|
18646
|
+
numColumns
|
|
18605
18647
|
}) => {
|
|
18606
|
-
const
|
|
18648
|
+
const nonAria = headerGroups.length > 1;
|
|
18607
18649
|
const { EmptyState: EmptyState2, ErrorState: ErrorState2 } = slots;
|
|
18608
18650
|
const isEmptyTable = (data == null ? void 0 : data.length) === 0;
|
|
18609
18651
|
const renderTableBody = useMemo(() => {
|
|
18610
18652
|
if (isError) {
|
|
18611
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18653
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(ErrorState2, {}) }) });
|
|
18612
18654
|
}
|
|
18613
18655
|
if (isLoading) {
|
|
18614
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18656
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(Loader, {}) }) });
|
|
18615
18657
|
}
|
|
18616
18658
|
if (isEmptyTable) {
|
|
18617
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18659
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(EmptyState2, {}) }) });
|
|
18618
18660
|
}
|
|
18619
|
-
|
|
18661
|
+
return /* @__PURE__ */ jsx(Fragment, { children: data == null ? void 0 : data.map((row) => /* @__PURE__ */ jsx(Row, { depth: row.depth, nonAria, children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
|
|
18620
18662
|
Cell,
|
|
18621
18663
|
{
|
|
18622
|
-
className: `Layer__UI__Table-Cell__${componentName}--${
|
|
18623
|
-
|
|
18664
|
+
className: `Layer__UI__Table-Cell__${componentName}--${cell.column.id}`,
|
|
18665
|
+
nonAria,
|
|
18666
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
18624
18667
|
},
|
|
18625
|
-
`${row.id}-${
|
|
18626
|
-
)) }, row.id);
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18668
|
+
`${row.id}-${cell.id}`
|
|
18669
|
+
)) }, row.id)) });
|
|
18670
|
+
}, [isError, isLoading, isEmptyTable, data, nonAria, numColumns, ErrorState2, EmptyState2, componentName]);
|
|
18671
|
+
return /* @__PURE__ */ jsxs(Table$1, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, nonAria, children: [
|
|
18672
|
+
/* @__PURE__ */ jsx(TableHeader, { hideHeader, nonAria, children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx(Row, { nonAria, children: headerGroup.headers.map((header) => {
|
|
18673
|
+
var _a;
|
|
18674
|
+
return /* @__PURE__ */ jsx(
|
|
18675
|
+
Column,
|
|
18676
|
+
{
|
|
18677
|
+
isRowHeader: (_a = header.column.columnDef.meta) == null ? void 0 : _a.isRowHeader,
|
|
18678
|
+
className: `Layer__UI__Table-Column__${componentName}--${header.id}`,
|
|
18679
|
+
nonAria,
|
|
18680
|
+
colSpan: header.colSpan,
|
|
18681
|
+
children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "function" ? header.column.columnDef.header(header.getContext()) : header.column.columnDef.header
|
|
18682
|
+
},
|
|
18683
|
+
header.id
|
|
18684
|
+
);
|
|
18685
|
+
}) }, headerGroup.id)) }),
|
|
18686
|
+
/* @__PURE__ */ jsx(TableBody$1, { dependencies, nonAria, children: renderTableBody })
|
|
18633
18687
|
] });
|
|
18634
18688
|
};
|
|
18635
18689
|
var Dots = /* @__PURE__ */ ((Dots2) => {
|
|
@@ -18783,15 +18837,7 @@ function PaginatedTable({
|
|
|
18783
18837
|
var _a;
|
|
18784
18838
|
const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
|
|
18785
18839
|
const [pagination, setPagination] = useState({ pageIndex: initialPage, pageSize });
|
|
18786
|
-
const
|
|
18787
|
-
const columns = Object.values(columnConfig);
|
|
18788
|
-
const columnDefs = columns.map((col) => {
|
|
18789
|
-
return columnHelper.display({
|
|
18790
|
-
id: col.id,
|
|
18791
|
-
header: () => col.header,
|
|
18792
|
-
cell: ({ row }) => col.cell(row.original)
|
|
18793
|
-
});
|
|
18794
|
-
});
|
|
18840
|
+
const columnDefs = getColumnDefs(columnConfig);
|
|
18795
18841
|
const table2 = useReactTable({
|
|
18796
18842
|
data: data != null ? data : [],
|
|
18797
18843
|
columns: columnDefs,
|
|
@@ -18806,21 +18852,23 @@ function PaginatedTable({
|
|
|
18806
18852
|
autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
|
|
18807
18853
|
});
|
|
18808
18854
|
const { rows } = table2.getRowModel();
|
|
18809
|
-
const rowData = useMemo(() => rows.map((r) => r.original), [rows]);
|
|
18810
18855
|
const onPageChange = useCallback((page) => {
|
|
18811
18856
|
table2.setPageIndex(page - 1);
|
|
18812
18857
|
}, [table2]);
|
|
18858
|
+
const headerGroups = table2.getHeaderGroups();
|
|
18859
|
+
const numColumns = table2.getVisibleLeafColumns().length;
|
|
18813
18860
|
return /* @__PURE__ */ jsxs(VStack, { children: [
|
|
18814
18861
|
/* @__PURE__ */ jsx(
|
|
18815
18862
|
DataTable,
|
|
18816
18863
|
{
|
|
18817
18864
|
ariaLabel,
|
|
18818
|
-
|
|
18819
|
-
data:
|
|
18865
|
+
numColumns,
|
|
18866
|
+
data: rows,
|
|
18820
18867
|
isLoading,
|
|
18821
18868
|
isError,
|
|
18822
18869
|
componentName,
|
|
18823
|
-
slots
|
|
18870
|
+
slots,
|
|
18871
|
+
headerGroups
|
|
18824
18872
|
}
|
|
18825
18873
|
),
|
|
18826
18874
|
!isError && !isLoading && /* @__PURE__ */ jsx(
|
|
@@ -18910,34 +18958,25 @@ const CategorizationRulesTable = () => {
|
|
|
18910
18958
|
spacing: true
|
|
18911
18959
|
}
|
|
18912
18960
|
), [refetch]);
|
|
18913
|
-
const columnConfig = useMemo(() =>
|
|
18914
|
-
|
|
18915
|
-
"Counterparty"
|
|
18916
|
-
/* Counterparty */
|
|
18917
|
-
]: {
|
|
18961
|
+
const columnConfig = useMemo(() => [
|
|
18962
|
+
{
|
|
18918
18963
|
id: "Counterparty",
|
|
18919
18964
|
header: "Counterparty",
|
|
18920
18965
|
cell: (row) => {
|
|
18921
18966
|
var _a2;
|
|
18922
|
-
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: (_a2 = row.counterpartyFilter) == null ? void 0 : _a2.name });
|
|
18967
|
+
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: (_a2 = row.original.counterpartyFilter) == null ? void 0 : _a2.name });
|
|
18923
18968
|
}
|
|
18924
18969
|
},
|
|
18925
|
-
|
|
18926
|
-
"Category"
|
|
18927
|
-
/* Category */
|
|
18928
|
-
]: {
|
|
18970
|
+
{
|
|
18929
18971
|
id: "Category",
|
|
18930
18972
|
header: "Category",
|
|
18931
18973
|
cell: (row) => {
|
|
18932
|
-
const accountIdentifier = row.category;
|
|
18974
|
+
const accountIdentifier = row.original.category;
|
|
18933
18975
|
return accountIdentifier && /* @__PURE__ */ jsx(CategoryDisplay, { accountIdentifier, options: options2 });
|
|
18934
18976
|
},
|
|
18935
18977
|
isRowHeader: true
|
|
18936
18978
|
},
|
|
18937
|
-
|
|
18938
|
-
"Delete"
|
|
18939
|
-
/* Delete */
|
|
18940
|
-
]: {
|
|
18979
|
+
{
|
|
18941
18980
|
id: "Delete",
|
|
18942
18981
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
18943
18982
|
Button,
|
|
@@ -18945,7 +18984,7 @@ const CategorizationRulesTable = () => {
|
|
|
18945
18984
|
inset: true,
|
|
18946
18985
|
icon: true,
|
|
18947
18986
|
onPress: () => {
|
|
18948
|
-
setSelectedRule(row);
|
|
18987
|
+
setSelectedRule(row.original);
|
|
18949
18988
|
setShowDeletionConfirmationModal(true);
|
|
18950
18989
|
},
|
|
18951
18990
|
"aria-label": "Delete rule",
|
|
@@ -18954,7 +18993,7 @@ const CategorizationRulesTable = () => {
|
|
|
18954
18993
|
}
|
|
18955
18994
|
)
|
|
18956
18995
|
}
|
|
18957
|
-
|
|
18996
|
+
], [options2]);
|
|
18958
18997
|
return /* @__PURE__ */ jsxs(Container, { name: "CategorizationRulesTable", children: [
|
|
18959
18998
|
/* @__PURE__ */ jsx(
|
|
18960
18999
|
PaginatedTable,
|
|
@@ -21072,7 +21111,7 @@ const DatePicker = ({
|
|
|
21072
21111
|
const getIsDateInvalid = (date, { minDate, maxDate }) => {
|
|
21073
21112
|
if (date === null) return "Cannot select empty date";
|
|
21074
21113
|
if (minDate && date.compare(minDate) < 0) return "Cannot select date before the business activation date";
|
|
21075
|
-
if (maxDate && date.compare(maxDate) > 0) return "Cannot select date
|
|
21114
|
+
if (maxDate && date.compare(maxDate) > 0) return "Cannot select date in the future";
|
|
21076
21115
|
return null;
|
|
21077
21116
|
};
|
|
21078
21117
|
const useDatePickerState = ({ date, setDate, minDate = null, maxDate = null }) => {
|
|
@@ -21590,8 +21629,8 @@ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
|
|
|
21590
21629
|
};
|
|
21591
21630
|
const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
|
|
21592
21631
|
var _a;
|
|
21593
|
-
const [
|
|
21594
|
-
const dateRange = useGlobalDateRange({
|
|
21632
|
+
const [dateSelectionMode, setDateSelectionMode] = useState("month");
|
|
21633
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
21595
21634
|
const [filters, setFilters] = useState({
|
|
21596
21635
|
expenses: void 0,
|
|
21597
21636
|
revenue: void 0
|
|
@@ -21650,8 +21689,8 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
|
|
|
21650
21689
|
dateRange,
|
|
21651
21690
|
selectedLineItem,
|
|
21652
21691
|
setSelectedLineItem,
|
|
21653
|
-
|
|
21654
|
-
|
|
21692
|
+
setDateSelectionMode,
|
|
21693
|
+
dateSelectionMode
|
|
21655
21694
|
};
|
|
21656
21695
|
};
|
|
21657
21696
|
function isArrayWithAtLeastOne(list) {
|
|
@@ -21838,9 +21877,9 @@ const ProfitAndLossContext = createContext({
|
|
|
21838
21877
|
selectedLineItem: null,
|
|
21839
21878
|
setSelectedLineItem: () => {
|
|
21840
21879
|
},
|
|
21841
|
-
|
|
21880
|
+
setDateSelectionMode: () => {
|
|
21842
21881
|
},
|
|
21843
|
-
|
|
21882
|
+
dateSelectionMode: "month"
|
|
21844
21883
|
});
|
|
21845
21884
|
const isNotOnlyNoneTag = (compareOptions) => {
|
|
21846
21885
|
return Boolean(
|
|
@@ -21872,8 +21911,8 @@ function useProfitAndLossComparison({
|
|
|
21872
21911
|
}) {
|
|
21873
21912
|
var _a;
|
|
21874
21913
|
const [comparisonPeriodMode, setComparisonPeriodMode] = useState(DateGroupBy.AllTime);
|
|
21875
|
-
const {
|
|
21876
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
21914
|
+
const { dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
21915
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
21877
21916
|
const comparePeriods = useMemo(() => {
|
|
21878
21917
|
if (!comparisonPeriodMode || comparisonPeriodMode === DateGroupBy.AllTime) {
|
|
21879
21918
|
return 1;
|
|
@@ -21886,7 +21925,7 @@ function useProfitAndLossComparison({
|
|
|
21886
21925
|
const [selectedCompareOptions, setSelectedCompareOptionsState] = useState(
|
|
21887
21926
|
(comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
|
|
21888
21927
|
);
|
|
21889
|
-
const dateRange = useGlobalDateRange({
|
|
21928
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
21890
21929
|
const compareModeActive = useMemo(() => comparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [comparePeriods, selectedCompareOptions]);
|
|
21891
21930
|
const setSelectedCompareOptions = (values) => {
|
|
21892
21931
|
const options2 = values.map(
|
|
@@ -22234,7 +22273,7 @@ const ProfitAndLossChart = ({
|
|
|
22234
22273
|
const [compactView, setCompactView] = useState(false);
|
|
22235
22274
|
const barSize = compactView ? 10 : 20;
|
|
22236
22275
|
const { getColor, business } = useLayerContext();
|
|
22237
|
-
const dateRange = useGlobalDateRange({
|
|
22276
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
22238
22277
|
const { setMonth } = useGlobalDateRangeActions();
|
|
22239
22278
|
const [customCursorSize, setCustomCursorSize] = useState({
|
|
22240
22279
|
width: 0,
|
|
@@ -22867,14 +22906,19 @@ const BackButton = (_Ec) => {
|
|
|
22867
22906
|
const baseClassName2 = classNames("Layer__btn", "Layer__back-btn", className);
|
|
22868
22907
|
return /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({}, props), { className: baseClassName2, children: textOnly ? "Back" : /* @__PURE__ */ jsx(BackArrow, { size: 16 }) }));
|
|
22869
22908
|
};
|
|
22870
|
-
|
|
22909
|
+
function useGlobalDatePickerBounds() {
|
|
22871
22910
|
const rawActivationDate = useBusinessActivationDate();
|
|
22872
|
-
const
|
|
22911
|
+
const minDate = useMemo(() => rawActivationDate ? startOfDay(rawActivationDate) : null, [rawActivationDate]);
|
|
22912
|
+
const maxDate = useMemo(() => endOfDay(/* @__PURE__ */ new Date()), []);
|
|
22913
|
+
return useMemo(() => ({ minDate, maxDate }), [minDate, maxDate]);
|
|
22914
|
+
}
|
|
22915
|
+
const GlobalMonthPicker = ({ truncateMonth }) => {
|
|
22916
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
22873
22917
|
const { setMonth } = useGlobalDateRangeActions();
|
|
22874
|
-
const { date } = useGlobalDate();
|
|
22918
|
+
const { date } = useGlobalDate({ dateSelectionMode: "month" });
|
|
22875
22919
|
const dateZdt = useMemo(() => convertDateToZonedDateTime(date), [date]);
|
|
22876
|
-
const minDateZdt = useMemo(() =>
|
|
22877
|
-
const maxDateZdt = useMemo(() => convertDateToZonedDateTime(
|
|
22920
|
+
const minDateZdt = useMemo(() => minDate ? convertDateToZonedDateTime(minDate) : null, [minDate]);
|
|
22921
|
+
const maxDateZdt = useMemo(() => convertDateToZonedDateTime(maxDate), [maxDate]);
|
|
22878
22922
|
const onChange = useCallback((val) => {
|
|
22879
22923
|
setMonth({ startDate: val.toDate() });
|
|
22880
22924
|
}, [setMonth]);
|
|
@@ -24181,30 +24225,24 @@ const ProfitAndLossDetailReport = ({
|
|
|
24181
24225
|
total: runningBalance
|
|
24182
24226
|
};
|
|
24183
24227
|
}, [data == null ? void 0 : data.lines]);
|
|
24184
|
-
const columnConfig = useMemo(() =>
|
|
24185
|
-
|
|
24186
|
-
"Date"
|
|
24187
|
-
/* Date */
|
|
24188
|
-
]: {
|
|
24228
|
+
const columnConfig = useMemo(() => [
|
|
24229
|
+
{
|
|
24189
24230
|
id: "Date",
|
|
24190
24231
|
header: (stringOverrides == null ? void 0 : stringOverrides.dateColumnHeader) || "Date",
|
|
24191
24232
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
24192
24233
|
DateTime,
|
|
24193
24234
|
{
|
|
24194
|
-
value: row.date,
|
|
24235
|
+
value: row.original.date,
|
|
24195
24236
|
onlyDate: true,
|
|
24196
24237
|
slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
|
|
24197
24238
|
}
|
|
24198
24239
|
)
|
|
24199
24240
|
},
|
|
24200
|
-
|
|
24201
|
-
"Type"
|
|
24202
|
-
/* Type */
|
|
24203
|
-
]: {
|
|
24241
|
+
{
|
|
24204
24242
|
id: "Type",
|
|
24205
24243
|
header: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type",
|
|
24206
24244
|
cell: (row) => {
|
|
24207
|
-
const { source } = row;
|
|
24245
|
+
const { source } = row.original;
|
|
24208
24246
|
return source ? /* @__PURE__ */ jsx(
|
|
24209
24247
|
Button,
|
|
24210
24248
|
{
|
|
@@ -24215,10 +24253,7 @@ const ProfitAndLossDetailReport = ({
|
|
|
24215
24253
|
) : "-";
|
|
24216
24254
|
}
|
|
24217
24255
|
},
|
|
24218
|
-
|
|
24219
|
-
"Account"
|
|
24220
|
-
/* Account */
|
|
24221
|
-
]: {
|
|
24256
|
+
{
|
|
24222
24257
|
id: "Account",
|
|
24223
24258
|
header: (stringOverrides == null ? void 0 : stringOverrides.accountColumnHeader) || "Account",
|
|
24224
24259
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
@@ -24227,14 +24262,11 @@ const ProfitAndLossDetailReport = ({
|
|
|
24227
24262
|
as: "span",
|
|
24228
24263
|
withDeprecatedTooltip: TextUseTooltip.whenTruncated,
|
|
24229
24264
|
ellipsis: true,
|
|
24230
|
-
children: row.account.name || "-"
|
|
24265
|
+
children: row.original.account.name || "-"
|
|
24231
24266
|
}
|
|
24232
24267
|
)
|
|
24233
24268
|
},
|
|
24234
|
-
|
|
24235
|
-
"Description"
|
|
24236
|
-
/* Description */
|
|
24237
|
-
]: {
|
|
24269
|
+
{
|
|
24238
24270
|
id: "Description",
|
|
24239
24271
|
header: (stringOverrides == null ? void 0 : stringOverrides.descriptionColumnHeader) || "Description",
|
|
24240
24272
|
cell: (row) => {
|
|
@@ -24245,33 +24277,27 @@ const ProfitAndLossDetailReport = ({
|
|
|
24245
24277
|
as: "span",
|
|
24246
24278
|
withDeprecatedTooltip: TextUseTooltip.whenTruncated,
|
|
24247
24279
|
ellipsis: true,
|
|
24248
|
-
children: ((_a = row.source) == null ? void 0 : _a.displayDescription) || row.account.accountSubtype.displayName || "-"
|
|
24280
|
+
children: ((_a = row.original.source) == null ? void 0 : _a.displayDescription) || row.original.account.accountSubtype.displayName || "-"
|
|
24249
24281
|
}
|
|
24250
24282
|
);
|
|
24251
24283
|
},
|
|
24252
24284
|
isRowHeader: true
|
|
24253
24285
|
},
|
|
24254
|
-
|
|
24255
|
-
"Amount"
|
|
24256
|
-
/* Amount */
|
|
24257
|
-
]: {
|
|
24286
|
+
{
|
|
24258
24287
|
id: "Amount",
|
|
24259
24288
|
header: (stringOverrides == null ? void 0 : stringOverrides.amountColumnHeader) || "Amount",
|
|
24260
24289
|
cell: (row) => {
|
|
24261
|
-
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.direction === Direction.CREDIT ? row.amount : -row.amount });
|
|
24290
|
+
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.direction === Direction.CREDIT ? row.original.amount : -row.original.amount });
|
|
24262
24291
|
}
|
|
24263
24292
|
},
|
|
24264
|
-
|
|
24265
|
-
"Balance"
|
|
24266
|
-
/* Balance */
|
|
24267
|
-
]: {
|
|
24293
|
+
{
|
|
24268
24294
|
id: "Balance",
|
|
24269
24295
|
header: (stringOverrides == null ? void 0 : stringOverrides.balanceColumnHeader) || "Balance",
|
|
24270
24296
|
cell: (row) => {
|
|
24271
|
-
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.runningBalance });
|
|
24297
|
+
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.runningBalance });
|
|
24272
24298
|
}
|
|
24273
24299
|
}
|
|
24274
|
-
|
|
24300
|
+
], [stringOverrides, handleSourceClick]);
|
|
24275
24301
|
const Header3 = useCallback(() => {
|
|
24276
24302
|
return /* @__PURE__ */ jsx(
|
|
24277
24303
|
DetailReportBreadcrumb,
|
|
@@ -24591,7 +24617,7 @@ const options$3 = Object.values(dateSelectionOptionConfig).filter((opt) => opt.v
|
|
|
24591
24617
|
const DateSelectionComboBox = () => {
|
|
24592
24618
|
const [lastPreset, setLastPreset] = useState(null);
|
|
24593
24619
|
const { business } = useLayerContext();
|
|
24594
|
-
const dateRange = useGlobalDateRange({
|
|
24620
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
24595
24621
|
const { setDateRange } = useGlobalDateRangeActions();
|
|
24596
24622
|
const selectedPreset = presetForDateRange(dateRange, lastPreset, getActivationDate(business));
|
|
24597
24623
|
const selectedOption = dateSelectionOptionConfig[selectedPreset != null ? selectedPreset : DatePreset.Custom];
|
|
@@ -24614,10 +24640,10 @@ const DateSelectionComboBox = () => {
|
|
|
24614
24640
|
}
|
|
24615
24641
|
);
|
|
24616
24642
|
};
|
|
24617
|
-
const
|
|
24618
|
-
const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({
|
|
24643
|
+
const GlobalDateRangePicker = () => {
|
|
24644
|
+
const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
24619
24645
|
const { setDateRange: setGlobalDateRange } = useGlobalDateRangeActions();
|
|
24620
|
-
const {
|
|
24646
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
24621
24647
|
const {
|
|
24622
24648
|
localDate: localStartDate,
|
|
24623
24649
|
onChange: onChangeStartDate,
|
|
@@ -24649,6 +24675,39 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
|
|
|
24649
24675
|
const next = { startDate: localStartDate.toDate(), endDate: localEndDate.toDate() };
|
|
24650
24676
|
setGlobalDateRange(next);
|
|
24651
24677
|
}, [startDateInvalid, endDateInvalid, localStartDate, localEndDate, setGlobalDateRange]);
|
|
24678
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24679
|
+
/* @__PURE__ */ jsx(
|
|
24680
|
+
DatePicker,
|
|
24681
|
+
{
|
|
24682
|
+
label: "Start Date",
|
|
24683
|
+
showLabel: false,
|
|
24684
|
+
date: localStartDate,
|
|
24685
|
+
onChange: onChangeStartDate,
|
|
24686
|
+
minDate: minStartDate,
|
|
24687
|
+
maxDate: maxStartDate,
|
|
24688
|
+
isInvalid: startDateInvalid,
|
|
24689
|
+
errorText: startDateErrorText,
|
|
24690
|
+
onBlur: onBlurStartDate
|
|
24691
|
+
}
|
|
24692
|
+
),
|
|
24693
|
+
/* @__PURE__ */ jsx(
|
|
24694
|
+
DatePicker,
|
|
24695
|
+
{
|
|
24696
|
+
label: "End Date",
|
|
24697
|
+
showLabel: false,
|
|
24698
|
+
date: localEndDate,
|
|
24699
|
+
onChange: onChangeEndDate,
|
|
24700
|
+
minDate: minEndDate,
|
|
24701
|
+
maxDate: maxEndDate,
|
|
24702
|
+
isInvalid: endDateInvalid,
|
|
24703
|
+
errorText: endDateErrorText,
|
|
24704
|
+
onBlur: onBlurEndDate
|
|
24705
|
+
}
|
|
24706
|
+
)
|
|
24707
|
+
] });
|
|
24708
|
+
};
|
|
24709
|
+
const DateRangeSelection = () => {
|
|
24710
|
+
const { value } = useSizeClass();
|
|
24652
24711
|
return /* @__PURE__ */ jsxs(
|
|
24653
24712
|
HStack,
|
|
24654
24713
|
{
|
|
@@ -24657,34 +24716,7 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
|
|
|
24657
24716
|
}),
|
|
24658
24717
|
children: [
|
|
24659
24718
|
/* @__PURE__ */ jsx(DateSelectionComboBox, {}),
|
|
24660
|
-
/* @__PURE__ */ jsx(
|
|
24661
|
-
DatePicker,
|
|
24662
|
-
{
|
|
24663
|
-
label: "Start Date",
|
|
24664
|
-
showLabel: false,
|
|
24665
|
-
date: localStartDate,
|
|
24666
|
-
onChange: onChangeStartDate,
|
|
24667
|
-
minDate: minStartDate,
|
|
24668
|
-
maxDate: maxStartDate,
|
|
24669
|
-
isInvalid: startDateInvalid,
|
|
24670
|
-
errorText: startDateErrorText,
|
|
24671
|
-
onBlur: onBlurStartDate
|
|
24672
|
-
}
|
|
24673
|
-
),
|
|
24674
|
-
/* @__PURE__ */ jsx(
|
|
24675
|
-
DatePicker,
|
|
24676
|
-
{
|
|
24677
|
-
label: "End Date",
|
|
24678
|
-
showLabel: false,
|
|
24679
|
-
date: localEndDate,
|
|
24680
|
-
onChange: onChangeEndDate,
|
|
24681
|
-
minDate: minEndDate,
|
|
24682
|
-
maxDate: maxEndDate,
|
|
24683
|
-
isInvalid: endDateInvalid,
|
|
24684
|
-
errorText: endDateErrorText,
|
|
24685
|
-
onBlur: onBlurEndDate
|
|
24686
|
-
}
|
|
24687
|
-
)
|
|
24719
|
+
/* @__PURE__ */ jsx(GlobalDateRangePicker, {})
|
|
24688
24720
|
]
|
|
24689
24721
|
}
|
|
24690
24722
|
);
|
|
@@ -25009,7 +25041,7 @@ const ProfitAndLossCompareOptions = () => {
|
|
|
25009
25041
|
comparisonPeriodMode,
|
|
25010
25042
|
setComparisonPeriodMode
|
|
25011
25043
|
} = useContext(ProfitAndLossComparisonContext);
|
|
25012
|
-
const {
|
|
25044
|
+
const { dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25013
25045
|
const tagComparisonSelectOptions = compareOptions.map(
|
|
25014
25046
|
(tagComparisonOption) => {
|
|
25015
25047
|
return {
|
|
@@ -25022,7 +25054,7 @@ const ProfitAndLossCompareOptions = () => {
|
|
|
25022
25054
|
return null;
|
|
25023
25055
|
}
|
|
25024
25056
|
return /* @__PURE__ */ jsxs(HStack, { align: "center", gap: "xs", children: [
|
|
25025
|
-
|
|
25057
|
+
dateSelectionMode === "full" && /* @__PURE__ */ jsx(DateGroupByComboBox, { value: comparisonPeriodMode, onValueChange: setComparisonPeriodMode }),
|
|
25026
25058
|
/* @__PURE__ */ jsx(
|
|
25027
25059
|
MultiSelect,
|
|
25028
25060
|
{
|
|
@@ -25197,7 +25229,7 @@ const useTableExpandRow = () => {
|
|
|
25197
25229
|
const ProfitAndLossCompareTable = ({
|
|
25198
25230
|
stringOverrides
|
|
25199
25231
|
}) => {
|
|
25200
|
-
const { dateRange,
|
|
25232
|
+
const { dateRange, dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25201
25233
|
const {
|
|
25202
25234
|
data: comparisonData,
|
|
25203
25235
|
isLoading,
|
|
@@ -25214,7 +25246,7 @@ const ProfitAndLossCompareTable = ({
|
|
|
25214
25246
|
return /* @__PURE__ */ jsx("div", { className: "Layer__profit-and-loss-table__loader-container", children: /* @__PURE__ */ jsx(Loader, {}) });
|
|
25215
25247
|
}
|
|
25216
25248
|
const getBookkeepingPeriodStatus = (date) => {
|
|
25217
|
-
if (!bookkeepingPeriods ||
|
|
25249
|
+
if (!bookkeepingPeriods || dateSelectionMode !== "month") {
|
|
25218
25250
|
return;
|
|
25219
25251
|
}
|
|
25220
25252
|
const currentMonth = date.getMonth() + 1;
|
|
@@ -25643,11 +25675,11 @@ const ProfitAndLossReport = ({
|
|
|
25643
25675
|
hideHeader
|
|
25644
25676
|
}) => {
|
|
25645
25677
|
var _a;
|
|
25646
|
-
const { selectedLineItem, setSelectedLineItem,
|
|
25678
|
+
const { selectedLineItem, setSelectedLineItem, setDateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25647
25679
|
const { comparisonConfig } = useContext(ProfitAndLossComparisonContext);
|
|
25648
25680
|
useEffect(() => {
|
|
25649
|
-
|
|
25650
|
-
}, [dateSelectionMode,
|
|
25681
|
+
setDateSelectionMode(dateSelectionMode);
|
|
25682
|
+
}, [dateSelectionMode, setDateSelectionMode]);
|
|
25651
25683
|
const breadcrumbIndexMap = useMemo(() => {
|
|
25652
25684
|
if (!selectedLineItem) return {};
|
|
25653
25685
|
return selectedLineItem.breadcrumbPath.reduce((acc, item, index) => {
|
|
@@ -25994,7 +26026,7 @@ function Internal_ProfitAndLossSummaries({
|
|
|
25994
26026
|
setSidebarScope,
|
|
25995
26027
|
sidebarScope
|
|
25996
26028
|
} = useContext(ProfitAndLossContext);
|
|
25997
|
-
const { startDate, endDate: _endDate } = useGlobalDateRange({
|
|
26029
|
+
const { startDate, endDate: _endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
25998
26030
|
const previousMonthStart = sub(startDate, { months: 1 });
|
|
25999
26031
|
const { data: previousData } = useProfitAndLossSummaries({
|
|
26000
26032
|
startYear: previousMonthStart.getFullYear(),
|
|
@@ -26501,18 +26533,16 @@ const BalanceSheetTable = ({
|
|
|
26501
26533
|
] });
|
|
26502
26534
|
};
|
|
26503
26535
|
const GlobalDatePicker = () => {
|
|
26504
|
-
const { date } = useGlobalDate();
|
|
26536
|
+
const { date } = useGlobalDate({ dateSelectionMode: "full" });
|
|
26505
26537
|
const { setDate: setGlobalDate } = useGlobalDateActions();
|
|
26506
|
-
const
|
|
26507
|
-
const activationDate = useMemo(() => rawActivationDate ? startOfDay(rawActivationDate) : null, [rawActivationDate]);
|
|
26508
|
-
const maxDate = useMemo(() => endOfDay(/* @__PURE__ */ new Date()), []);
|
|
26538
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
26509
26539
|
const setDate = useCallback((date2) => {
|
|
26510
26540
|
setGlobalDate({ date: date2 });
|
|
26511
26541
|
}, [setGlobalDate]);
|
|
26512
26542
|
const { localDate, onChange, minDateZdt, maxDateZdt, errorText, onBlur, isInvalid } = useDatePickerState({
|
|
26513
26543
|
date,
|
|
26514
26544
|
setDate,
|
|
26515
|
-
minDate
|
|
26545
|
+
minDate,
|
|
26516
26546
|
maxDate
|
|
26517
26547
|
});
|
|
26518
26548
|
return /* @__PURE__ */ jsx(
|
|
@@ -26547,7 +26577,7 @@ const DateSelection = () => {
|
|
|
26547
26577
|
};
|
|
26548
26578
|
const CombinedDateSelection = ({ mode }) => {
|
|
26549
26579
|
if (mode === "month") {
|
|
26550
|
-
return /* @__PURE__ */ jsx(
|
|
26580
|
+
return /* @__PURE__ */ jsx(GlobalMonthPicker, {});
|
|
26551
26581
|
}
|
|
26552
26582
|
return /* @__PURE__ */ jsx(DateSelection, {});
|
|
26553
26583
|
};
|
|
@@ -26567,7 +26597,7 @@ const BalanceSheetView = ({
|
|
|
26567
26597
|
stringOverrides,
|
|
26568
26598
|
dateSelectionMode = "full"
|
|
26569
26599
|
}) => {
|
|
26570
|
-
const { date: effectiveDate } = useGlobalDate();
|
|
26600
|
+
const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
|
|
26571
26601
|
const { data, isLoading } = useBalanceSheet({ effectiveDate });
|
|
26572
26602
|
const { view, containerRef } = useElementViewSize();
|
|
26573
26603
|
if (asWidget) {
|
|
@@ -26882,7 +26912,7 @@ const StatementOfCashFlowView = ({
|
|
|
26882
26912
|
stringOverrides,
|
|
26883
26913
|
dateSelectionMode = "full"
|
|
26884
26914
|
}) => {
|
|
26885
|
-
const dateRange = useGlobalDateRange({
|
|
26915
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
26886
26916
|
const { data, isLoading } = useStatementOfCashFlow(dateRange);
|
|
26887
26917
|
const { view, containerRef } = useElementViewSize();
|
|
26888
26918
|
return /* @__PURE__ */ jsx(TableProvider, { children: /* @__PURE__ */ jsx(
|
|
@@ -27548,7 +27578,7 @@ const useChartOfAccounts = ({ withDates = false } = {}) => {
|
|
|
27548
27578
|
const { businessId } = useLayerContext();
|
|
27549
27579
|
const { apiUrl } = useEnvironment();
|
|
27550
27580
|
const { data: auth } = useAuth();
|
|
27551
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
27581
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
27552
27582
|
const [form, setForm] = useState();
|
|
27553
27583
|
const [sendingForm, setSendingForm] = useState(false);
|
|
27554
27584
|
const [apiError, setApiError] = useState(void 0);
|
|
@@ -35530,56 +35560,38 @@ const AmountCell = ({ invoice }) => {
|
|
|
35530
35560
|
}
|
|
35531
35561
|
}
|
|
35532
35562
|
};
|
|
35533
|
-
const getColumnConfig$1 = (onSelectInvoice) =>
|
|
35534
|
-
|
|
35535
|
-
"SentAt"
|
|
35536
|
-
/* SentAt */
|
|
35537
|
-
]: {
|
|
35563
|
+
const getColumnConfig$1 = (onSelectInvoice) => [
|
|
35564
|
+
{
|
|
35538
35565
|
id: "SentAt",
|
|
35539
35566
|
header: "Sent Date",
|
|
35540
|
-
cell: (row) => row.sentAt ? formatDate(row.sentAt) : null
|
|
35567
|
+
cell: (row) => row.original.sentAt ? formatDate(row.original.sentAt) : null
|
|
35541
35568
|
},
|
|
35542
|
-
|
|
35543
|
-
"InvoiceNo"
|
|
35544
|
-
/* InvoiceNo */
|
|
35545
|
-
]: {
|
|
35569
|
+
{
|
|
35546
35570
|
id: "InvoiceNo",
|
|
35547
35571
|
header: "No.",
|
|
35548
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: row.invoiceNumber }),
|
|
35572
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: row.original.invoiceNumber }),
|
|
35549
35573
|
isRowHeader: true
|
|
35550
35574
|
},
|
|
35551
|
-
|
|
35552
|
-
"Customer"
|
|
35553
|
-
/* Customer */
|
|
35554
|
-
]: {
|
|
35575
|
+
{
|
|
35555
35576
|
id: "Customer",
|
|
35556
35577
|
header: "Customer",
|
|
35557
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: getCustomerName(row.customer) })
|
|
35578
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: getCustomerName(row.original.customer) })
|
|
35558
35579
|
},
|
|
35559
|
-
|
|
35560
|
-
"Total"
|
|
35561
|
-
/* Total */
|
|
35562
|
-
]: {
|
|
35580
|
+
{
|
|
35563
35581
|
id: "Total",
|
|
35564
35582
|
header: "Amount",
|
|
35565
|
-
cell: (row) => /* @__PURE__ */ jsx(AmountCell, { invoice: row })
|
|
35583
|
+
cell: (row) => /* @__PURE__ */ jsx(AmountCell, { invoice: row.original })
|
|
35566
35584
|
},
|
|
35567
|
-
|
|
35568
|
-
"Status"
|
|
35569
|
-
/* Status */
|
|
35570
|
-
]: {
|
|
35585
|
+
{
|
|
35571
35586
|
id: "Status",
|
|
35572
35587
|
header: "Status",
|
|
35573
|
-
cell: (row) => /* @__PURE__ */ jsx(InvoiceStatusCell, { invoice: row })
|
|
35588
|
+
cell: (row) => /* @__PURE__ */ jsx(InvoiceStatusCell, { invoice: row.original })
|
|
35574
35589
|
},
|
|
35575
|
-
|
|
35576
|
-
"Expand"
|
|
35577
|
-
/* Expand */
|
|
35578
|
-
]: {
|
|
35590
|
+
{
|
|
35579
35591
|
id: "Expand",
|
|
35580
|
-
cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
|
|
35592
|
+
cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row.original), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
|
|
35581
35593
|
}
|
|
35582
|
-
|
|
35594
|
+
];
|
|
35583
35595
|
const UNPAID_STATUSES$1 = [InvoiceStatus.Sent, InvoiceStatus.PartiallyPaid];
|
|
35584
35596
|
const getStatusFilterParams = (statusFilter) => {
|
|
35585
35597
|
switch (statusFilter) {
|
|
@@ -38289,15 +38301,72 @@ Schema.Union(
|
|
|
38289
38301
|
DateQueryParamsSchema,
|
|
38290
38302
|
DateRangeQueryParamsSchema
|
|
38291
38303
|
);
|
|
38304
|
+
const unifiedReportColumnFields = {
|
|
38305
|
+
columnKey: pipe(
|
|
38306
|
+
Schema.propertySignature(Schema.String),
|
|
38307
|
+
Schema.fromKey("column_key")
|
|
38308
|
+
),
|
|
38309
|
+
displayName: pipe(
|
|
38310
|
+
Schema.propertySignature(Schema.String),
|
|
38311
|
+
Schema.fromKey("display_name")
|
|
38312
|
+
)
|
|
38313
|
+
};
|
|
38314
|
+
const UnifiedReportColumnSchema = Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportColumnFields), {
|
|
38315
|
+
columns: Schema.optional(
|
|
38316
|
+
Schema.Array(
|
|
38317
|
+
Schema.suspend(() => UnifiedReportColumnSchema)
|
|
38318
|
+
)
|
|
38319
|
+
)
|
|
38320
|
+
}));
|
|
38321
|
+
const UnifiedCellValueAmountSchema = Schema.Struct({
|
|
38322
|
+
type: Schema.Literal("Amount"),
|
|
38323
|
+
value: Schema.Number
|
|
38324
|
+
});
|
|
38325
|
+
const UnifiedCellValueEmptySchema = Schema.Struct({
|
|
38326
|
+
type: Schema.Literal("Empty")
|
|
38327
|
+
});
|
|
38328
|
+
const UnifiedCellValueUnknownSchema = Schema.Struct({
|
|
38329
|
+
type: Schema.String,
|
|
38330
|
+
value: Schema.optional(Schema.Unknown)
|
|
38331
|
+
});
|
|
38332
|
+
const UnifiedCellValueSchema = Schema.Union(
|
|
38333
|
+
UnifiedCellValueAmountSchema,
|
|
38334
|
+
UnifiedCellValueEmptySchema,
|
|
38335
|
+
UnifiedCellValueUnknownSchema
|
|
38336
|
+
);
|
|
38337
|
+
const isAmountCellValue = (value) => value.type === "Amount";
|
|
38338
|
+
const isEmptyCellValue = (value) => value.type === "Empty";
|
|
38339
|
+
const UnifiedReportCellSchema = Schema.Struct({
|
|
38340
|
+
value: UnifiedCellValueSchema
|
|
38341
|
+
});
|
|
38342
|
+
const unifiedReportRowFields = {
|
|
38343
|
+
rowKey: pipe(
|
|
38344
|
+
Schema.propertySignature(Schema.String),
|
|
38345
|
+
Schema.fromKey("row_key")
|
|
38346
|
+
),
|
|
38347
|
+
displayName: pipe(
|
|
38348
|
+
Schema.propertySignature(Schema.String),
|
|
38349
|
+
Schema.fromKey("display_name")
|
|
38350
|
+
),
|
|
38351
|
+
cells: Schema.Record({
|
|
38352
|
+
key: Schema.String,
|
|
38353
|
+
value: Schema.NullishOr(UnifiedReportCellSchema)
|
|
38354
|
+
})
|
|
38355
|
+
};
|
|
38356
|
+
const UnifiedReportRowSchema = Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportRowFields), {
|
|
38357
|
+
rows: Schema.optional(
|
|
38358
|
+
Schema.Array(
|
|
38359
|
+
Schema.suspend(() => UnifiedReportRowSchema)
|
|
38360
|
+
)
|
|
38361
|
+
)
|
|
38362
|
+
}));
|
|
38292
38363
|
const UnifiedReportSchema = Schema.Struct({
|
|
38293
38364
|
businessId: pipe(
|
|
38294
38365
|
Schema.propertySignature(Schema.UUID),
|
|
38295
38366
|
Schema.fromKey("business_id")
|
|
38296
38367
|
),
|
|
38297
|
-
|
|
38298
|
-
|
|
38299
|
-
Schema.fromKey("line_items")
|
|
38300
|
-
)
|
|
38368
|
+
columns: Schema.Array(UnifiedReportColumnSchema),
|
|
38369
|
+
rows: Schema.Array(UnifiedReportRowSchema)
|
|
38301
38370
|
});
|
|
38302
38371
|
var UnifiedReportDateVariant = /* @__PURE__ */ ((UnifiedReportDateVariant2) => {
|
|
38303
38372
|
UnifiedReportDateVariant2["Date"] = "Date";
|
|
@@ -38319,10 +38388,10 @@ function useUnifiedReportDateVariant() {
|
|
|
38319
38388
|
const report = useStore(store, (state) => state.report);
|
|
38320
38389
|
return reportToDateVariantMap[report];
|
|
38321
38390
|
}
|
|
38322
|
-
function useUnifiedReportWithDateParams() {
|
|
38391
|
+
function useUnifiedReportWithDateParams({ dateSelectionMode }) {
|
|
38323
38392
|
const store = useContext(UnifiedReportStoreContext);
|
|
38324
|
-
const { date: effectiveDate } = useGlobalDate();
|
|
38325
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
38393
|
+
const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
|
|
38394
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode });
|
|
38326
38395
|
const report = useStore(store, (state) => state.report);
|
|
38327
38396
|
const dateVariant = reportToDateVariantMap[report];
|
|
38328
38397
|
switch (dateVariant) {
|
|
@@ -38382,33 +38451,13 @@ function ExpandableDataTable({
|
|
|
38382
38451
|
ariaLabel,
|
|
38383
38452
|
slots,
|
|
38384
38453
|
hideHeader,
|
|
38385
|
-
getSubRows: getSubRows2
|
|
38454
|
+
getSubRows: getSubRows2,
|
|
38455
|
+
getRowId
|
|
38386
38456
|
}) {
|
|
38387
|
-
const columnHelper = createColumnHelper();
|
|
38388
|
-
const columns = Object.values(columnConfig);
|
|
38389
38457
|
const { expanded, setExpanded } = useContext(ExpandableDataTableContext);
|
|
38390
|
-
const columnDefs = columns.map((col) => {
|
|
38391
|
-
return columnHelper.display({
|
|
38392
|
-
id: col.id,
|
|
38393
|
-
header: () => col.header,
|
|
38394
|
-
cell: ({ row }) => col.cell(row)
|
|
38395
|
-
});
|
|
38396
|
-
});
|
|
38397
|
-
const table2 = useReactTable({
|
|
38398
|
-
data: data != null ? data : EMPTY_ARRAY,
|
|
38399
|
-
columns: columnDefs,
|
|
38400
|
-
getSubRows: getSubRows2,
|
|
38401
|
-
getCoreRowModel: getCoreRowModel(),
|
|
38402
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
38403
|
-
state: { expanded },
|
|
38404
|
-
onExpandedChange: setExpanded,
|
|
38405
|
-
autoResetPageIndex: false,
|
|
38406
|
-
getRowId: (row) => row.id
|
|
38407
|
-
});
|
|
38408
|
-
const { rows } = table2.getExpandedRowModel();
|
|
38409
38458
|
const wrappedColumnConfig = useMemo(() => {
|
|
38410
|
-
|
|
38411
|
-
|
|
38459
|
+
const [first, ...rest] = columnConfig;
|
|
38460
|
+
if (!first || !isLeafColumn(first)) return columnConfig;
|
|
38412
38461
|
const originalFirstCell = first.cell;
|
|
38413
38462
|
const firstWithChevron = __spreadProps(__spreadValues({}, first), {
|
|
38414
38463
|
cell: (row) => {
|
|
@@ -38421,26 +38470,37 @@ function ExpandableDataTable({
|
|
|
38421
38470
|
] }) });
|
|
38422
38471
|
}
|
|
38423
38472
|
});
|
|
38424
|
-
return
|
|
38425
|
-
|
|
38426
|
-
|
|
38427
|
-
|
|
38428
|
-
|
|
38429
|
-
|
|
38430
|
-
|
|
38473
|
+
return [firstWithChevron, ...rest];
|
|
38474
|
+
}, [columnConfig]);
|
|
38475
|
+
const columnDefs = getColumnDefs(wrappedColumnConfig);
|
|
38476
|
+
const table2 = useReactTable({
|
|
38477
|
+
data: data != null ? data : EMPTY_ARRAY,
|
|
38478
|
+
columns: columnDefs,
|
|
38479
|
+
getSubRows: getSubRows2,
|
|
38480
|
+
getCoreRowModel: getCoreRowModel(),
|
|
38481
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
38482
|
+
state: { expanded },
|
|
38483
|
+
onExpandedChange: setExpanded,
|
|
38484
|
+
autoResetPageIndex: false,
|
|
38485
|
+
getRowId
|
|
38486
|
+
});
|
|
38487
|
+
const { rows } = table2.getExpandedRowModel();
|
|
38431
38488
|
const dependencies = useMemo(() => [expanded], [expanded]);
|
|
38489
|
+
const headerGroups = table2.getHeaderGroups();
|
|
38490
|
+
const numColumns = table2.getVisibleLeafColumns().length;
|
|
38432
38491
|
return /* @__PURE__ */ jsx(
|
|
38433
38492
|
DataTable,
|
|
38434
38493
|
{
|
|
38435
38494
|
ariaLabel,
|
|
38436
|
-
|
|
38495
|
+
numColumns,
|
|
38437
38496
|
data: rows,
|
|
38438
38497
|
isLoading,
|
|
38439
38498
|
isError,
|
|
38440
38499
|
componentName,
|
|
38441
38500
|
slots,
|
|
38442
38501
|
hideHeader,
|
|
38443
|
-
dependencies
|
|
38502
|
+
dependencies,
|
|
38503
|
+
headerGroups
|
|
38444
38504
|
}
|
|
38445
38505
|
);
|
|
38446
38506
|
}
|
|
@@ -38472,10 +38532,6 @@ const getUnifiedReport = get((_md) => {
|
|
|
38472
38532
|
const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
|
|
38473
38533
|
return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
|
|
38474
38534
|
});
|
|
38475
|
-
const addIdToLineItem = (li) => __spreadProps(__spreadValues({}, li), {
|
|
38476
|
-
id: li.name,
|
|
38477
|
-
lineItems: li.lineItems.map(addIdToLineItem)
|
|
38478
|
-
});
|
|
38479
38535
|
class UnifiedReportSWRResponse {
|
|
38480
38536
|
constructor(swrResponse) {
|
|
38481
38537
|
__publicField(this, "swrResponse");
|
|
@@ -38510,45 +38566,64 @@ function useUnifiedReport(_od) {
|
|
|
38510
38566
|
}), dateParams)),
|
|
38511
38567
|
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getUnifiedReport(apiUrl2, accessToken, {
|
|
38512
38568
|
params: __spreadValues({ businessId: businessId2, report }, dateParams)
|
|
38513
|
-
})().then(
|
|
38514
|
-
({ data }) => Schema.decodeUnknownPromise(UnifiedReportSchema)(data).then((rep) => __spreadProps(__spreadValues({}, rep), {
|
|
38515
|
-
lineItems: rep.lineItems.map(addIdToLineItem)
|
|
38516
|
-
}))
|
|
38517
|
-
)
|
|
38569
|
+
})().then(({ data }) => Schema.decodeUnknownPromise(UnifiedReportSchema)(data))
|
|
38518
38570
|
);
|
|
38519
38571
|
return new UnifiedReportSWRResponse(swrResponse);
|
|
38520
38572
|
}
|
|
38521
38573
|
const COMPONENT_NAME$2 = "UnifiedReport";
|
|
38522
|
-
const
|
|
38523
|
-
|
|
38524
|
-
|
|
38525
|
-
|
|
38526
|
-
|
|
38527
|
-
|
|
38528
|
-
|
|
38574
|
+
const makeLeafColumn = (col) => ({
|
|
38575
|
+
id: col.columnKey,
|
|
38576
|
+
header: col.displayName,
|
|
38577
|
+
cell: (row) => {
|
|
38578
|
+
var _a;
|
|
38579
|
+
const cellValue = (_a = row.original.cells[col.columnKey]) == null ? void 0 : _a.value;
|
|
38580
|
+
if (!cellValue || isEmptyCellValue(cellValue)) {
|
|
38581
|
+
return null;
|
|
38582
|
+
}
|
|
38583
|
+
if (isAmountCellValue(cellValue)) {
|
|
38584
|
+
return /* @__PURE__ */ jsx(MoneySpan, { ellipsis: true, amount: cellValue.value });
|
|
38585
|
+
}
|
|
38586
|
+
if (isEmptyCellValue(cellValue)) {
|
|
38587
|
+
return null;
|
|
38588
|
+
}
|
|
38589
|
+
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: String(cellValue.value) });
|
|
38590
|
+
}
|
|
38591
|
+
});
|
|
38592
|
+
const makeGroupColumn = (col) => ({
|
|
38593
|
+
id: col.columnKey,
|
|
38594
|
+
header: col.displayName,
|
|
38595
|
+
columns: buildNestedColumnConfig(col.columns)
|
|
38596
|
+
});
|
|
38597
|
+
const isGroupColumn = (col) => col.columns !== void 0 && col.columns.length > 0;
|
|
38598
|
+
const buildNestedColumnConfig = (columns) => {
|
|
38599
|
+
return columns.map((col) => {
|
|
38600
|
+
if (isGroupColumn(col)) {
|
|
38601
|
+
return makeGroupColumn(col);
|
|
38602
|
+
}
|
|
38603
|
+
return makeLeafColumn(col);
|
|
38604
|
+
});
|
|
38605
|
+
};
|
|
38606
|
+
const buildColumnConfig = (columns) => {
|
|
38607
|
+
const displayNameColumn = {
|
|
38608
|
+
id: "displayName",
|
|
38609
|
+
header: "",
|
|
38529
38610
|
cell: (row) => /* @__PURE__ */ jsx(Span, { weight: row.depth === 0 ? "bold" : "normal", ellipsis: true, children: row.original.displayName }),
|
|
38530
38611
|
isRowHeader: true
|
|
38531
|
-
}
|
|
38532
|
-
[
|
|
38533
|
-
"Value"
|
|
38534
|
-
/* Value */
|
|
38535
|
-
]: {
|
|
38536
|
-
id: "Value",
|
|
38537
|
-
header: "Amount",
|
|
38538
|
-
cell: (row) => /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.value })
|
|
38539
|
-
}
|
|
38612
|
+
};
|
|
38613
|
+
return [displayNameColumn, ...buildNestedColumnConfig(columns)];
|
|
38540
38614
|
};
|
|
38541
|
-
const getSubRows = (
|
|
38542
|
-
const UnifiedReportTable = () => {
|
|
38543
|
-
const _a = useUnifiedReportWithDateParams(), { report } = _a, dateParams = __objRest(_a, ["report"]);
|
|
38615
|
+
const getSubRows = (row) => row.rows ? asMutable(row.rows) : void 0;
|
|
38616
|
+
const UnifiedReportTable = ({ dateSelectionMode }) => {
|
|
38617
|
+
const _a = useUnifiedReportWithDateParams({ dateSelectionMode }), { report } = _a, dateParams = __objRest(_a, ["report"]);
|
|
38544
38618
|
const { data, isLoading, isError, refetch } = useUnifiedReport(__spreadValues({ report }, dateParams));
|
|
38545
38619
|
const { setExpanded } = useContext(ExpandableDataTableContext);
|
|
38546
|
-
const
|
|
38620
|
+
const mutableRows = (data == null ? void 0 : data.rows) ? asMutable(data.rows) : void 0;
|
|
38621
|
+
const columnConfig = useMemo(() => data ? buildColumnConfig(data.columns) : [], [data]);
|
|
38547
38622
|
useEffect(() => {
|
|
38548
|
-
if (
|
|
38549
|
-
setExpanded(Object.fromEntries(
|
|
38623
|
+
if (mutableRows !== void 0) {
|
|
38624
|
+
setExpanded(Object.fromEntries(mutableRows.map((d) => [d.rowKey, true])));
|
|
38550
38625
|
}
|
|
38551
|
-
}, [
|
|
38626
|
+
}, [mutableRows, setExpanded]);
|
|
38552
38627
|
const UnifiedReportEmptyState = useCallback(() => {
|
|
38553
38628
|
return /* @__PURE__ */ jsx(
|
|
38554
38629
|
DataState,
|
|
@@ -38576,17 +38651,17 @@ const UnifiedReportTable = () => {
|
|
|
38576
38651
|
ExpandableDataTable,
|
|
38577
38652
|
{
|
|
38578
38653
|
ariaLabel: "Report",
|
|
38579
|
-
data:
|
|
38654
|
+
data: mutableRows,
|
|
38580
38655
|
isLoading: data === void 0 || isLoading,
|
|
38581
38656
|
isError,
|
|
38582
|
-
columnConfig
|
|
38657
|
+
columnConfig,
|
|
38583
38658
|
componentName: COMPONENT_NAME$2,
|
|
38584
38659
|
slots: {
|
|
38585
38660
|
ErrorState: UnifiedReportErrorState,
|
|
38586
38661
|
EmptyState: UnifiedReportEmptyState
|
|
38587
38662
|
},
|
|
38588
38663
|
getSubRows,
|
|
38589
|
-
|
|
38664
|
+
getRowId: (row) => row.rowKey
|
|
38590
38665
|
}
|
|
38591
38666
|
);
|
|
38592
38667
|
};
|
|
@@ -38665,10 +38740,10 @@ function downloadReport(apiUrl, accessToken, businessId, unifiedReportParams) {
|
|
|
38665
38740
|
});
|
|
38666
38741
|
}
|
|
38667
38742
|
}
|
|
38668
|
-
function useUnifiedReportDownload({ onSuccess }
|
|
38743
|
+
function useUnifiedReportDownload({ dateSelectionMode, onSuccess }) {
|
|
38669
38744
|
const { data: auth } = useAuth();
|
|
38670
38745
|
const { businessId } = useLayerContext();
|
|
38671
|
-
const reportWithDateParams = useUnifiedReportWithDateParams();
|
|
38746
|
+
const reportWithDateParams = useUnifiedReportWithDateParams({ dateSelectionMode });
|
|
38672
38747
|
const rawMutationResponse = useSWRMutation(
|
|
38673
38748
|
() => buildKey$a(__spreadProps(__spreadValues({}, auth), {
|
|
38674
38749
|
businessId,
|
|
@@ -38685,9 +38760,10 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
|
|
|
38685
38760
|
);
|
|
38686
38761
|
return new DownloadUnifiedReportSWRResponse(rawMutationResponse);
|
|
38687
38762
|
}
|
|
38688
|
-
function UnifiedReportDownloadButton() {
|
|
38763
|
+
function UnifiedReportDownloadButton({ dateSelectionMode }) {
|
|
38689
38764
|
const { invisibleDownloadRef, triggerInvisibleDownload } = useInvisibleDownload();
|
|
38690
38765
|
const { trigger, isMutating, isError } = useUnifiedReportDownload({
|
|
38766
|
+
dateSelectionMode,
|
|
38691
38767
|
onSuccess: ({ presignedUrl }) => triggerInvisibleDownload({ url: presignedUrl })
|
|
38692
38768
|
});
|
|
38693
38769
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -38709,7 +38785,7 @@ function UnifiedReportDownloadButton() {
|
|
|
38709
38785
|
/* @__PURE__ */ jsx(InvisibleDownload, { ref: invisibleDownloadRef })
|
|
38710
38786
|
] });
|
|
38711
38787
|
}
|
|
38712
|
-
const UnifiedReportTableHeader = () => {
|
|
38788
|
+
const UnifiedReportTableHeader = ({ dateSelectionMode }) => {
|
|
38713
38789
|
const dateVariant = useUnifiedReportDateVariant();
|
|
38714
38790
|
const { expanded, setExpanded } = useContext(ExpandableDataTableContext);
|
|
38715
38791
|
const shouldCollapse = expanded === true;
|
|
@@ -38721,17 +38797,17 @@ const UnifiedReportTableHeader = () => {
|
|
|
38721
38797
|
}
|
|
38722
38798
|
}, [setExpanded, shouldCollapse]);
|
|
38723
38799
|
return /* @__PURE__ */ jsxs(HStack, { fluid: true, justify: "space-between", align: "center", className: "Layer__UnifiedReport__Header", children: [
|
|
38724
|
-
/* @__PURE__ */ jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsx(
|
|
38800
|
+
/* @__PURE__ */ jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsx(CombinedDateRangeSelection, { mode: dateSelectionMode }) : /* @__PURE__ */ jsx(CombinedDateSelection, { mode: dateSelectionMode }) }),
|
|
38725
38801
|
/* @__PURE__ */ jsxs(HStack, { pi: "md", className: "Layer__UnifiedReport__Header__SecondaryActions", children: [
|
|
38726
38802
|
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: onClickExpandOrCollapse, children: shouldCollapse ? "Collapse All" : "Expand All" }),
|
|
38727
|
-
/* @__PURE__ */ jsx(UnifiedReportDownloadButton, {})
|
|
38803
|
+
/* @__PURE__ */ jsx(UnifiedReportDownloadButton, { dateSelectionMode })
|
|
38728
38804
|
] })
|
|
38729
38805
|
] });
|
|
38730
38806
|
};
|
|
38731
|
-
const UnifiedReport = () => {
|
|
38807
|
+
const UnifiedReport = ({ dateSelectionMode }) => {
|
|
38732
38808
|
return /* @__PURE__ */ jsx(Container, { name: "UnifiedReport", children: /* @__PURE__ */ jsx(UnifiedReportStoreProvider, { children: /* @__PURE__ */ jsxs(ExpandableDataTableProvider, { children: [
|
|
38733
|
-
/* @__PURE__ */ jsx(UnifiedReportTableHeader, {}),
|
|
38734
|
-
/* @__PURE__ */ jsx(UnifiedReportTable, {})
|
|
38809
|
+
/* @__PURE__ */ jsx(UnifiedReportTableHeader, { dateSelectionMode }),
|
|
38810
|
+
/* @__PURE__ */ jsx(UnifiedReportTable, { dateSelectionMode })
|
|
38735
38811
|
] }) }) });
|
|
38736
38812
|
};
|
|
38737
38813
|
const AccountingOverview = ({
|
|
@@ -42474,80 +42550,59 @@ const TripsTableHeaderMenu = () => {
|
|
|
42474
42550
|
);
|
|
42475
42551
|
};
|
|
42476
42552
|
const COMPONENT_NAME = "TripsTable";
|
|
42477
|
-
const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) =>
|
|
42478
|
-
|
|
42479
|
-
"TripDate"
|
|
42480
|
-
/* TripDate */
|
|
42481
|
-
]: {
|
|
42553
|
+
const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => [
|
|
42554
|
+
{
|
|
42482
42555
|
id: "TripDate",
|
|
42483
42556
|
header: "Date",
|
|
42484
|
-
cell: (row) => formatCalendarDate(row.tripDate)
|
|
42557
|
+
cell: (row) => formatCalendarDate(row.original.tripDate)
|
|
42485
42558
|
},
|
|
42486
|
-
|
|
42487
|
-
"Vehicle"
|
|
42488
|
-
/* Vehicle */
|
|
42489
|
-
]: {
|
|
42559
|
+
{
|
|
42490
42560
|
id: "Vehicle",
|
|
42491
42561
|
header: "Vehicle",
|
|
42492
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.vehicle) }),
|
|
42562
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.original.vehicle) }),
|
|
42493
42563
|
isRowHeader: true
|
|
42494
42564
|
},
|
|
42495
|
-
|
|
42496
|
-
"Distance"
|
|
42497
|
-
/* Distance */
|
|
42498
|
-
]: {
|
|
42565
|
+
{
|
|
42499
42566
|
id: "Distance",
|
|
42500
42567
|
header: "Distance",
|
|
42501
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { align: "right", children: formatDistance(row.distance) })
|
|
42568
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { align: "right", children: formatDistance(row.original.distance) })
|
|
42502
42569
|
},
|
|
42503
|
-
|
|
42504
|
-
"Purpose"
|
|
42505
|
-
/* Purpose */
|
|
42506
|
-
]: {
|
|
42570
|
+
{
|
|
42507
42571
|
id: "Purpose",
|
|
42508
42572
|
header: "Purpose",
|
|
42509
|
-
cell: (row) => getPurposeLabel(row.purpose)
|
|
42573
|
+
cell: (row) => getPurposeLabel(row.original.purpose)
|
|
42510
42574
|
},
|
|
42511
|
-
|
|
42512
|
-
"Address"
|
|
42513
|
-
/* Address */
|
|
42514
|
-
]: {
|
|
42575
|
+
{
|
|
42515
42576
|
id: "Address",
|
|
42516
42577
|
header: "Address",
|
|
42517
42578
|
cell: (row) => {
|
|
42518
42579
|
return /* @__PURE__ */ jsxs(VStack, { gap: "3xs", overflow: "auto", children: [
|
|
42519
|
-
row.startAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42580
|
+
row.original.startAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42520
42581
|
/* @__PURE__ */ jsx("strong", { children: "Start:" }),
|
|
42521
42582
|
" ",
|
|
42522
|
-
row.startAddress
|
|
42583
|
+
row.original.startAddress
|
|
42523
42584
|
] }),
|
|
42524
|
-
row.endAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42585
|
+
row.original.endAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42525
42586
|
/* @__PURE__ */ jsx("strong", { children: "End:" }),
|
|
42526
42587
|
" ",
|
|
42527
|
-
row.endAddress
|
|
42588
|
+
row.original.endAddress
|
|
42528
42589
|
] })
|
|
42529
42590
|
] });
|
|
42530
42591
|
}
|
|
42531
42592
|
},
|
|
42532
|
-
|
|
42533
|
-
"Description"
|
|
42534
|
-
/* Description */
|
|
42535
|
-
]: {
|
|
42593
|
+
{
|
|
42536
42594
|
id: "Description",
|
|
42537
42595
|
header: "Description",
|
|
42538
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
|
|
42596
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.original.description })
|
|
42539
42597
|
},
|
|
42540
|
-
|
|
42541
|
-
"Actions"
|
|
42542
|
-
/* Actions */
|
|
42543
|
-
]: {
|
|
42598
|
+
{
|
|
42544
42599
|
id: "Actions",
|
|
42545
42600
|
cell: (row) => /* @__PURE__ */ jsxs(HStack, { gap: "3xs", children: [
|
|
42546
|
-
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
|
|
42547
|
-
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
|
|
42601
|
+
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row.original), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
|
|
42602
|
+
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row.original), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
|
|
42548
42603
|
] })
|
|
42549
42604
|
}
|
|
42550
|
-
|
|
42605
|
+
];
|
|
42551
42606
|
const TripsTable = () => {
|
|
42552
42607
|
var _a;
|
|
42553
42608
|
const [isTripDrawerOpen, setIsTripDrawerOpen] = useState(false);
|
|
@@ -44030,7 +44085,7 @@ const BusinessProvider = ({
|
|
|
44030
44085
|
hasBeenTouched,
|
|
44031
44086
|
resetCaches
|
|
44032
44087
|
} = useDataSync();
|
|
44033
|
-
const globalDateRange = useGlobalDateRange({
|
|
44088
|
+
const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
44034
44089
|
const { setDateRange } = useGlobalDateRangeActions();
|
|
44035
44090
|
const dateRange = useMemo(() => ({
|
|
44036
44091
|
range: globalDateRange,
|