@layerfi/components 0.1.8 → 0.1.9
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/esm/index.js +1458 -842
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +286 -119
- package/dist/index.js +1478 -864
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +456 -171
- package/dist/styles/index.css.map +3 -3
- package/package.json +1 -1
- package/index.d.ts +0 -1309
package/dist/index.js
CHANGED
|
@@ -32,9 +32,9 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
BalanceSheet: () => BalanceSheet,
|
|
34
34
|
BankTransactions: () => BankTransactions,
|
|
35
|
-
ChartOfAccounts: () => ChartOfAccounts,
|
|
36
35
|
Hello: () => Hello,
|
|
37
36
|
LayerProvider: () => LayerProvider,
|
|
37
|
+
LedgerAccounts: () => LedgerAccounts,
|
|
38
38
|
LinkedAccounts: () => LinkedAccounts,
|
|
39
39
|
ProfitAndLoss: () => ProfitAndLoss,
|
|
40
40
|
ProfitAndLossView: () => ProfitAndLossView
|
|
@@ -304,8 +304,8 @@ var matchBankTransaction = put(
|
|
|
304
304
|
// src/api/layer/categories.ts
|
|
305
305
|
var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
|
|
306
306
|
|
|
307
|
-
// src/api/layer/
|
|
308
|
-
var
|
|
307
|
+
// src/api/layer/ledger_accounts.ts
|
|
308
|
+
var getLedgerAccounts = get(
|
|
309
309
|
({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
|
|
310
310
|
);
|
|
311
311
|
var createAccount = post(
|
|
@@ -326,7 +326,7 @@ var Layer = {
|
|
|
326
326
|
getBalanceSheet,
|
|
327
327
|
getBankTransactions,
|
|
328
328
|
getCategories,
|
|
329
|
-
|
|
329
|
+
getLedgerAccounts,
|
|
330
330
|
getProfitAndLoss
|
|
331
331
|
};
|
|
332
332
|
|
|
@@ -371,23 +371,41 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
|
371
371
|
|
|
372
372
|
// src/icons/DownloadCloud.tsx
|
|
373
373
|
var React = __toESM(require("react"));
|
|
374
|
-
var DownloadCloud = (props) => /* @__PURE__ */ React.createElement(
|
|
374
|
+
var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React.createElement(
|
|
375
375
|
"svg",
|
|
376
376
|
{
|
|
377
377
|
xmlns: "http://www.w3.org/2000/svg",
|
|
378
|
-
|
|
379
|
-
height: 24,
|
|
378
|
+
viewBox: "0 0 18 18",
|
|
380
379
|
fill: "none",
|
|
381
|
-
...props
|
|
380
|
+
...props,
|
|
381
|
+
width: size,
|
|
382
|
+
height: size
|
|
382
383
|
},
|
|
383
384
|
/* @__PURE__ */ React.createElement(
|
|
384
385
|
"path",
|
|
385
386
|
{
|
|
386
|
-
|
|
387
|
+
d: "M6 12.75L9 15.75L12 12.75",
|
|
388
|
+
stroke: "currentColor",
|
|
387
389
|
strokeLinecap: "round",
|
|
388
|
-
strokeLinejoin: "round"
|
|
389
|
-
|
|
390
|
-
|
|
390
|
+
strokeLinejoin: "round"
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
/* @__PURE__ */ React.createElement(
|
|
394
|
+
"path",
|
|
395
|
+
{
|
|
396
|
+
d: "M9 9V15.75",
|
|
397
|
+
stroke: "currentColor",
|
|
398
|
+
strokeLinecap: "round",
|
|
399
|
+
strokeLinejoin: "round"
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
/* @__PURE__ */ React.createElement(
|
|
403
|
+
"path",
|
|
404
|
+
{
|
|
405
|
+
d: "M15.66 13.5675C16.3121 13.109 16.801 12.4546 17.056 11.6994C17.3109 10.9441 17.3186 10.1273 17.0778 9.36737C16.837 8.60748 16.3604 7.94407 15.7171 7.47342C15.0737 7.00278 14.2971 6.74938 13.5 6.75H12.555C12.3294 5.87091 11.9074 5.05444 11.3206 4.36206C10.7338 3.66969 9.99762 3.11945 9.16742 2.75277C8.33721 2.38609 7.43464 2.21252 6.52766 2.24514C5.62067 2.27776 4.7329 2.51571 3.93118 2.94107C3.12946 3.36644 2.43468 3.96814 1.89915 4.70087C1.36362 5.43361 1.0013 6.27829 0.839456 7.17132C0.677613 8.06434 0.720468 8.98245 0.964796 9.85652C1.20912 10.7306 1.64856 11.5378 2.25001 12.2175",
|
|
406
|
+
stroke: "currentColor",
|
|
407
|
+
strokeLinecap: "round",
|
|
408
|
+
strokeLinejoin: "round"
|
|
391
409
|
}
|
|
392
410
|
)
|
|
393
411
|
);
|
|
@@ -606,7 +624,7 @@ var BalanceSheet = () => {
|
|
|
606
624
|
};
|
|
607
625
|
|
|
608
626
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
609
|
-
var
|
|
627
|
+
var import_react43 = __toESM(require("react"));
|
|
610
628
|
|
|
611
629
|
// src/config/general.ts
|
|
612
630
|
var DATE_FORMAT = "LLL d, yyyy";
|
|
@@ -762,7 +780,7 @@ var debounce = (fnc, timeout = 300) => {
|
|
|
762
780
|
};
|
|
763
781
|
|
|
764
782
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
765
|
-
var
|
|
783
|
+
var import_react36 = __toESM(require("react"));
|
|
766
784
|
|
|
767
785
|
// src/icons/ChevronDownFill.tsx
|
|
768
786
|
var React8 = __toESM(require("react"));
|
|
@@ -790,7 +808,7 @@ var ChevronDownFill = ({ size = 18, ...props }) => /* @__PURE__ */ React8.create
|
|
|
790
808
|
var ChevronDownFill_default = ChevronDownFill;
|
|
791
809
|
|
|
792
810
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
793
|
-
var
|
|
811
|
+
var import_react34 = __toESM(require("react"));
|
|
794
812
|
|
|
795
813
|
// src/icons/AlertCircle.tsx
|
|
796
814
|
var React9 = __toESM(require("react"));
|
|
@@ -1426,8 +1444,12 @@ var import_classnames4 = __toESM(require("classnames"));
|
|
|
1426
1444
|
var buildRightIcon = ({
|
|
1427
1445
|
processing,
|
|
1428
1446
|
error,
|
|
1429
|
-
action
|
|
1447
|
+
action,
|
|
1448
|
+
noIcon
|
|
1430
1449
|
}) => {
|
|
1450
|
+
if (noIcon) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1431
1453
|
if (processing) {
|
|
1432
1454
|
return /* @__PURE__ */ import_react15.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
|
|
1433
1455
|
}
|
|
@@ -1447,6 +1469,7 @@ var SubmitButton = ({
|
|
|
1447
1469
|
error,
|
|
1448
1470
|
children,
|
|
1449
1471
|
action = "save" /* SAVE */,
|
|
1472
|
+
noIcon,
|
|
1450
1473
|
...props
|
|
1451
1474
|
}) => {
|
|
1452
1475
|
const baseClassName = (0, import_classnames4.default)(
|
|
@@ -1460,7 +1483,7 @@ var SubmitButton = ({
|
|
|
1460
1483
|
className: baseClassName,
|
|
1461
1484
|
variant: "primary" /* primary */,
|
|
1462
1485
|
disabled: processing || disabled,
|
|
1463
|
-
rightIcon: buildRightIcon({ processing, error, action }),
|
|
1486
|
+
rightIcon: buildRightIcon({ processing, error, action, noIcon }),
|
|
1464
1487
|
iconAsPrimary: true
|
|
1465
1488
|
},
|
|
1466
1489
|
children
|
|
@@ -1759,7 +1782,7 @@ var CategorySelect = ({
|
|
|
1759
1782
|
};
|
|
1760
1783
|
|
|
1761
1784
|
// src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
|
|
1762
|
-
var
|
|
1785
|
+
var import_react32 = __toESM(require("react"));
|
|
1763
1786
|
|
|
1764
1787
|
// src/icons/ScissorsFullOpen.tsx
|
|
1765
1788
|
var React26 = __toESM(require("react"));
|
|
@@ -2055,9 +2078,14 @@ var InputGroup = ({
|
|
|
2055
2078
|
label,
|
|
2056
2079
|
name,
|
|
2057
2080
|
className,
|
|
2081
|
+
inline,
|
|
2058
2082
|
children
|
|
2059
2083
|
}) => {
|
|
2060
|
-
const baseClassName = (0, import_classnames12.default)(
|
|
2084
|
+
const baseClassName = (0, import_classnames12.default)(
|
|
2085
|
+
"Layer__input-group",
|
|
2086
|
+
className,
|
|
2087
|
+
inline && "Layer__input-group--inline"
|
|
2088
|
+
);
|
|
2061
2089
|
return /* @__PURE__ */ import_react24.default.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ import_react24.default.createElement(
|
|
2062
2090
|
Text,
|
|
2063
2091
|
{
|
|
@@ -2157,11 +2185,43 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
2157
2185
|
));
|
|
2158
2186
|
};
|
|
2159
2187
|
|
|
2188
|
+
// src/components/Input/Select.tsx
|
|
2189
|
+
var import_react26 = __toESM(require("react"));
|
|
2190
|
+
var import_react_select3 = __toESM(require("react-select"));
|
|
2191
|
+
var DropdownIndicator3 = (props) => {
|
|
2192
|
+
return /* @__PURE__ */ import_react26.default.createElement(import_react_select3.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react26.default.createElement(ChevronDownFill_default, null));
|
|
2193
|
+
};
|
|
2194
|
+
var Select3 = ({
|
|
2195
|
+
name,
|
|
2196
|
+
options,
|
|
2197
|
+
className,
|
|
2198
|
+
classNamePrefix = "Layer__select",
|
|
2199
|
+
value,
|
|
2200
|
+
onChange,
|
|
2201
|
+
disabled
|
|
2202
|
+
}) => {
|
|
2203
|
+
return /* @__PURE__ */ import_react26.default.createElement(
|
|
2204
|
+
import_react_select3.default,
|
|
2205
|
+
{
|
|
2206
|
+
name,
|
|
2207
|
+
className: `Layer__select ${className ?? ""}`,
|
|
2208
|
+
classNamePrefix,
|
|
2209
|
+
options,
|
|
2210
|
+
value,
|
|
2211
|
+
onChange: (newValue) => newValue && onChange(newValue),
|
|
2212
|
+
menuPortalTarget: document.body,
|
|
2213
|
+
styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
|
|
2214
|
+
components: { DropdownIndicator: DropdownIndicator3 },
|
|
2215
|
+
isDisabled: disabled
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2160
2220
|
// src/components/MatchForm/MatchForm.tsx
|
|
2161
|
-
var
|
|
2221
|
+
var import_react28 = __toESM(require("react"));
|
|
2162
2222
|
|
|
2163
2223
|
// src/components/BankTransactionRow/MatchBadge.tsx
|
|
2164
|
-
var
|
|
2224
|
+
var import_react27 = __toESM(require("react"));
|
|
2165
2225
|
var import_date_fns5 = require("date-fns");
|
|
2166
2226
|
var MatchBadge = ({
|
|
2167
2227
|
bankTransaction,
|
|
@@ -2171,11 +2231,11 @@ var MatchBadge = ({
|
|
|
2171
2231
|
}) => {
|
|
2172
2232
|
if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction.match) {
|
|
2173
2233
|
const { date, amount, description } = bankTransaction.match.bank_transaction;
|
|
2174
|
-
return /* @__PURE__ */
|
|
2234
|
+
return /* @__PURE__ */ import_react27.default.createElement(
|
|
2175
2235
|
Badge,
|
|
2176
2236
|
{
|
|
2177
|
-
icon: /* @__PURE__ */
|
|
2178
|
-
tooltip: /* @__PURE__ */
|
|
2237
|
+
icon: /* @__PURE__ */ import_react27.default.createElement(MinimizeTwo_default, { size: 11 }),
|
|
2238
|
+
tooltip: /* @__PURE__ */ import_react27.default.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, (0, import_date_fns5.format)((0, import_date_fns5.parseISO)(date), dateFormat)), /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
|
|
2179
2239
|
},
|
|
2180
2240
|
text
|
|
2181
2241
|
);
|
|
@@ -2193,13 +2253,13 @@ var MatchForm = ({
|
|
|
2193
2253
|
setSelectedMatchId,
|
|
2194
2254
|
matchFormError
|
|
2195
2255
|
}) => {
|
|
2196
|
-
return /* @__PURE__ */
|
|
2256
|
+
return /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ import_react28.default.createElement(
|
|
2197
2257
|
"div",
|
|
2198
2258
|
{
|
|
2199
2259
|
className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
|
|
2200
2260
|
}
|
|
2201
2261
|
)), bankTransaction.suggested_matches?.map((match, idx) => {
|
|
2202
|
-
return /* @__PURE__ */
|
|
2262
|
+
return /* @__PURE__ */ import_react28.default.createElement(
|
|
2203
2263
|
"div",
|
|
2204
2264
|
{
|
|
2205
2265
|
key: idx,
|
|
@@ -2215,15 +2275,15 @@ var MatchForm = ({
|
|
|
2215
2275
|
setSelectedMatchId(match.id);
|
|
2216
2276
|
}
|
|
2217
2277
|
},
|
|
2218
|
-
/* @__PURE__ */
|
|
2278
|
+
/* @__PURE__ */ import_react28.default.createElement(
|
|
2219
2279
|
"div",
|
|
2220
2280
|
{
|
|
2221
2281
|
className: `Layer__nowrap ${classNamePrefix}__match-table__date`
|
|
2222
2282
|
},
|
|
2223
|
-
/* @__PURE__ */
|
|
2224
|
-
/* @__PURE__ */
|
|
2283
|
+
/* @__PURE__ */ import_react28.default.createElement("span", null, (0, import_date_fns6.format)((0, import_date_fns6.parseISO)(match.details.date), DATE_FORMAT)),
|
|
2284
|
+
/* @__PURE__ */ import_react28.default.createElement("span", { className: "amount-next-to-date" }, "$", centsToDollars(match.details.amount))
|
|
2225
2285
|
),
|
|
2226
|
-
/* @__PURE__ */
|
|
2286
|
+
/* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2227
2287
|
Text,
|
|
2228
2288
|
{
|
|
2229
2289
|
className: `${classNamePrefix}__match-table__desc-tooltip`,
|
|
@@ -2231,7 +2291,7 @@ var MatchForm = ({
|
|
|
2231
2291
|
as: "span"
|
|
2232
2292
|
},
|
|
2233
2293
|
match.details.description
|
|
2234
|
-
), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */
|
|
2294
|
+
), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ import_react28.default.createElement("span", { className: "match-badge" }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2235
2295
|
MatchBadge,
|
|
2236
2296
|
{
|
|
2237
2297
|
classNamePrefix,
|
|
@@ -2240,13 +2300,13 @@ var MatchForm = ({
|
|
|
2240
2300
|
text: "Matched"
|
|
2241
2301
|
}
|
|
2242
2302
|
))),
|
|
2243
|
-
/* @__PURE__ */
|
|
2244
|
-
/* @__PURE__ */
|
|
2303
|
+
/* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
|
|
2304
|
+
/* @__PURE__ */ import_react28.default.createElement(
|
|
2245
2305
|
"div",
|
|
2246
2306
|
{
|
|
2247
2307
|
className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
|
|
2248
2308
|
},
|
|
2249
|
-
match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */
|
|
2309
|
+
match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ import_react28.default.createElement(
|
|
2250
2310
|
MatchBadge,
|
|
2251
2311
|
{
|
|
2252
2312
|
classNamePrefix,
|
|
@@ -2257,22 +2317,22 @@ var MatchForm = ({
|
|
|
2257
2317
|
)
|
|
2258
2318
|
)
|
|
2259
2319
|
);
|
|
2260
|
-
}), matchFormError && /* @__PURE__ */
|
|
2320
|
+
}), matchFormError && /* @__PURE__ */ import_react28.default.createElement(ErrorText, null, matchFormError));
|
|
2261
2321
|
};
|
|
2262
2322
|
|
|
2263
2323
|
// src/components/Textarea/Textarea.tsx
|
|
2264
|
-
var
|
|
2324
|
+
var import_react29 = __toESM(require("react"));
|
|
2265
2325
|
var import_classnames14 = __toESM(require("classnames"));
|
|
2266
2326
|
var Textarea = ({
|
|
2267
2327
|
className,
|
|
2268
2328
|
...props
|
|
2269
2329
|
}) => {
|
|
2270
2330
|
const baseClassName = (0, import_classnames14.default)("Layer__textarea", className);
|
|
2271
|
-
return /* @__PURE__ */
|
|
2331
|
+
return /* @__PURE__ */ import_react29.default.createElement("textarea", { ...props, className: baseClassName });
|
|
2272
2332
|
};
|
|
2273
2333
|
|
|
2274
2334
|
// src/components/Toggle/Toggle.tsx
|
|
2275
|
-
var
|
|
2335
|
+
var import_react30 = __toESM(require("react"));
|
|
2276
2336
|
var import_classnames15 = __toESM(require("classnames"));
|
|
2277
2337
|
var Toggle = ({
|
|
2278
2338
|
name,
|
|
@@ -2281,9 +2341,9 @@ var Toggle = ({
|
|
|
2281
2341
|
onChange,
|
|
2282
2342
|
size = "medium" /* medium */
|
|
2283
2343
|
}) => {
|
|
2284
|
-
const [currentWidth, setCurrentWidth] = (0,
|
|
2285
|
-
const [thumbPos, setThumbPos] = (0,
|
|
2286
|
-
const [initialized, setInitialized] = (0,
|
|
2344
|
+
const [currentWidth, setCurrentWidth] = (0, import_react30.useState)(0);
|
|
2345
|
+
const [thumbPos, setThumbPos] = (0, import_react30.useState)({ left: 0, width: 0 });
|
|
2346
|
+
const [initialized, setInitialized] = (0, import_react30.useState)(false);
|
|
2287
2347
|
const toggleRef = useElementSize((a, b, c) => {
|
|
2288
2348
|
if (c.width && c?.width !== currentWidth) {
|
|
2289
2349
|
setCurrentWidth(c.width);
|
|
@@ -2318,14 +2378,14 @@ var Toggle = ({
|
|
|
2318
2378
|
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
|
|
2319
2379
|
setThumbPos({ left: shift2, width });
|
|
2320
2380
|
};
|
|
2321
|
-
(0,
|
|
2381
|
+
(0, import_react30.useEffect)(() => {
|
|
2322
2382
|
const selectedIndex = getSelectedIndex();
|
|
2323
2383
|
updateThumbPosition(selectedIndex);
|
|
2324
2384
|
setTimeout(() => {
|
|
2325
2385
|
setInitialized(true);
|
|
2326
2386
|
}, 400);
|
|
2327
2387
|
}, []);
|
|
2328
|
-
(0,
|
|
2388
|
+
(0, import_react30.useEffect)(() => {
|
|
2329
2389
|
const selectedIndex = getSelectedIndex();
|
|
2330
2390
|
updateThumbPosition(selectedIndex);
|
|
2331
2391
|
}, [currentWidth]);
|
|
@@ -2338,7 +2398,7 @@ var Toggle = ({
|
|
|
2338
2398
|
}
|
|
2339
2399
|
return selectedIndex;
|
|
2340
2400
|
};
|
|
2341
|
-
return /* @__PURE__ */
|
|
2401
|
+
return /* @__PURE__ */ import_react30.default.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ import_react30.default.createElement(
|
|
2342
2402
|
ToggleOption,
|
|
2343
2403
|
{
|
|
2344
2404
|
...option,
|
|
@@ -2350,7 +2410,7 @@ var Toggle = ({
|
|
|
2350
2410
|
disabled: option.disabled ?? false,
|
|
2351
2411
|
index
|
|
2352
2412
|
}
|
|
2353
|
-
)), /* @__PURE__ */
|
|
2413
|
+
)), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
|
|
2354
2414
|
};
|
|
2355
2415
|
var ToggleOption = ({
|
|
2356
2416
|
checked,
|
|
@@ -2364,7 +2424,7 @@ var ToggleOption = ({
|
|
|
2364
2424
|
index
|
|
2365
2425
|
}) => {
|
|
2366
2426
|
if (disabled) {
|
|
2367
|
-
return /* @__PURE__ */
|
|
2427
|
+
return /* @__PURE__ */ import_react30.default.createElement(Tooltip, null, /* @__PURE__ */ import_react30.default.createElement(TooltipTrigger, null, /* @__PURE__ */ import_react30.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2368
2428
|
"input",
|
|
2369
2429
|
{
|
|
2370
2430
|
type: "radio",
|
|
@@ -2375,9 +2435,9 @@ var ToggleOption = ({
|
|
|
2375
2435
|
disabled: disabled ?? false,
|
|
2376
2436
|
"data-idx": index
|
|
2377
2437
|
}
|
|
2378
|
-
), /* @__PURE__ */
|
|
2438
|
+
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)))), /* @__PURE__ */ import_react30.default.createElement(TooltipContent, { className: "Layer__tooltip" }, "We could not find matching transactions"));
|
|
2379
2439
|
}
|
|
2380
|
-
return /* @__PURE__ */
|
|
2440
|
+
return /* @__PURE__ */ import_react30.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2381
2441
|
"input",
|
|
2382
2442
|
{
|
|
2383
2443
|
type: "radio",
|
|
@@ -2388,15 +2448,15 @@ var ToggleOption = ({
|
|
|
2388
2448
|
disabled: disabled ?? false,
|
|
2389
2449
|
"data-idx": index
|
|
2390
2450
|
}
|
|
2391
|
-
), /* @__PURE__ */
|
|
2451
|
+
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)));
|
|
2392
2452
|
};
|
|
2393
2453
|
|
|
2394
2454
|
// src/components/ExpandedBankTransactionRow/APIErrorNotifications.tsx
|
|
2395
|
-
var
|
|
2455
|
+
var import_react31 = __toESM(require("react"));
|
|
2396
2456
|
|
|
2397
2457
|
// src/icons/AlertOctagon.tsx
|
|
2398
|
-
var
|
|
2399
|
-
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
2458
|
+
var React41 = __toESM(require("react"));
|
|
2459
|
+
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React41.createElement(
|
|
2400
2460
|
"svg",
|
|
2401
2461
|
{
|
|
2402
2462
|
viewBox: "0 0 18 18",
|
|
@@ -2406,7 +2466,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2406
2466
|
width: size,
|
|
2407
2467
|
height: size
|
|
2408
2468
|
},
|
|
2409
|
-
/* @__PURE__ */
|
|
2469
|
+
/* @__PURE__ */ React41.createElement(
|
|
2410
2470
|
"path",
|
|
2411
2471
|
{
|
|
2412
2472
|
d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
|
|
@@ -2415,7 +2475,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2415
2475
|
strokeLinejoin: "round"
|
|
2416
2476
|
}
|
|
2417
2477
|
),
|
|
2418
|
-
/* @__PURE__ */
|
|
2478
|
+
/* @__PURE__ */ React41.createElement(
|
|
2419
2479
|
"path",
|
|
2420
2480
|
{
|
|
2421
2481
|
d: "M9 6V9",
|
|
@@ -2424,7 +2484,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2424
2484
|
strokeLinejoin: "round"
|
|
2425
2485
|
}
|
|
2426
2486
|
),
|
|
2427
|
-
/* @__PURE__ */
|
|
2487
|
+
/* @__PURE__ */ React41.createElement(
|
|
2428
2488
|
"path",
|
|
2429
2489
|
{
|
|
2430
2490
|
d: "M9 12H9.0075",
|
|
@@ -2446,7 +2506,7 @@ var APIErrorNotifications = ({
|
|
|
2446
2506
|
bankTransaction,
|
|
2447
2507
|
containerWidth
|
|
2448
2508
|
}) => {
|
|
2449
|
-
const [notifications, setNotifications] = (0,
|
|
2509
|
+
const [notifications, setNotifications] = (0, import_react31.useState)([]);
|
|
2450
2510
|
const pushNotification = (title, message) => {
|
|
2451
2511
|
const timestamp = (/* @__PURE__ */ new Date()).valueOf();
|
|
2452
2512
|
if (notificationsCache.find(
|
|
@@ -2475,18 +2535,18 @@ var APIErrorNotifications = ({
|
|
|
2475
2535
|
);
|
|
2476
2536
|
setNotifications(notificationsCache.concat());
|
|
2477
2537
|
};
|
|
2478
|
-
(0,
|
|
2538
|
+
(0, import_react31.useEffect)(() => {
|
|
2479
2539
|
if (bankTransaction.error) {
|
|
2480
2540
|
pushNotification(ERROR_TITLE, ERROR_MESSAGE);
|
|
2481
2541
|
}
|
|
2482
2542
|
}, [bankTransaction.error]);
|
|
2483
|
-
return /* @__PURE__ */
|
|
2543
|
+
return /* @__PURE__ */ import_react31.default.createElement(
|
|
2484
2544
|
"div",
|
|
2485
2545
|
{
|
|
2486
2546
|
className: "Layer__bank-transactions__notifications",
|
|
2487
2547
|
style: containerWidth ? { left: containerWidth - 324 } : {}
|
|
2488
2548
|
},
|
|
2489
|
-
notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */
|
|
2549
|
+
notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */ import_react31.default.createElement(
|
|
2490
2550
|
Notification,
|
|
2491
2551
|
{
|
|
2492
2552
|
key: notification.timestamp,
|
|
@@ -2500,8 +2560,8 @@ var Notification = ({
|
|
|
2500
2560
|
notification,
|
|
2501
2561
|
deleteNotification
|
|
2502
2562
|
}) => {
|
|
2503
|
-
const [visible, setVisible] = (0,
|
|
2504
|
-
(0,
|
|
2563
|
+
const [visible, setVisible] = (0, import_react31.useState)(false);
|
|
2564
|
+
(0, import_react31.useEffect)(() => {
|
|
2505
2565
|
setVisible(true);
|
|
2506
2566
|
const timer = setTimeout(() => {
|
|
2507
2567
|
hideNotification();
|
|
@@ -2514,20 +2574,20 @@ var Notification = ({
|
|
|
2514
2574
|
deleteNotification(notification.timestamp);
|
|
2515
2575
|
}, FADE_OUT_TIME_WAIT);
|
|
2516
2576
|
};
|
|
2517
|
-
return /* @__PURE__ */
|
|
2577
|
+
return /* @__PURE__ */ import_react31.default.createElement(
|
|
2518
2578
|
"div",
|
|
2519
2579
|
{
|
|
2520
2580
|
className: `Layer__bank-transactions__notification ${visible ? "notification-enter" : "notification-exit"}`,
|
|
2521
2581
|
onClick: hideNotification
|
|
2522
2582
|
},
|
|
2523
|
-
/* @__PURE__ */
|
|
2583
|
+
/* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-content" }, /* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-icon" }, /* @__PURE__ */ import_react31.default.createElement(AlertOctagon_default, { size: 14 })), /* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-text" }, /* @__PURE__ */ import_react31.default.createElement(
|
|
2524
2584
|
Text,
|
|
2525
2585
|
{
|
|
2526
2586
|
as: "span",
|
|
2527
2587
|
className: "Layer__bank-transactions__notification-title"
|
|
2528
2588
|
},
|
|
2529
2589
|
notification.title
|
|
2530
|
-
), /* @__PURE__ */
|
|
2590
|
+
), /* @__PURE__ */ import_react31.default.createElement(
|
|
2531
2591
|
Text,
|
|
2532
2592
|
{
|
|
2533
2593
|
as: "span",
|
|
@@ -2565,7 +2625,7 @@ var validateSplit = (splitData) => {
|
|
|
2565
2625
|
});
|
|
2566
2626
|
return valid;
|
|
2567
2627
|
};
|
|
2568
|
-
var ExpandedBankTransactionRow = (0,
|
|
2628
|
+
var ExpandedBankTransactionRow = (0, import_react32.forwardRef)(
|
|
2569
2629
|
({
|
|
2570
2630
|
bankTransaction,
|
|
2571
2631
|
isOpen = false,
|
|
@@ -2578,20 +2638,20 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2578
2638
|
categorize: categorizeBankTransaction2,
|
|
2579
2639
|
match: matchBankTransaction2
|
|
2580
2640
|
} = useBankTransactions();
|
|
2581
|
-
const [purpose, setPurpose] = (0,
|
|
2641
|
+
const [purpose, setPurpose] = (0, import_react32.useState)(
|
|
2582
2642
|
bankTransaction.category ? "categorize" /* categorize */ : hasMatch(bankTransaction) ? "match" /* match */ : "categorize" /* categorize */
|
|
2583
2643
|
);
|
|
2584
|
-
const [selectedMatchId, setSelectedMatchId] = (0,
|
|
2644
|
+
const [selectedMatchId, setSelectedMatchId] = (0, import_react32.useState)(
|
|
2585
2645
|
isAlreadyMatched(bankTransaction)
|
|
2586
2646
|
);
|
|
2587
|
-
const [matchFormError, setMatchFormError] = (0,
|
|
2588
|
-
const [splitFormError, setSplitFormError] = (0,
|
|
2589
|
-
const [height, setHeight] = (0,
|
|
2590
|
-
const [isOver, setOver] = (0,
|
|
2591
|
-
const bodyRef = (0,
|
|
2592
|
-
const [isLoaded, setIsLoaded] = (0,
|
|
2647
|
+
const [matchFormError, setMatchFormError] = (0, import_react32.useState)();
|
|
2648
|
+
const [splitFormError, setSplitFormError] = (0, import_react32.useState)();
|
|
2649
|
+
const [height, setHeight] = (0, import_react32.useState)(0);
|
|
2650
|
+
const [isOver, setOver] = (0, import_react32.useState)(false);
|
|
2651
|
+
const bodyRef = (0, import_react32.useRef)(null);
|
|
2652
|
+
const [isLoaded, setIsLoaded] = (0, import_react32.useState)(false);
|
|
2593
2653
|
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
2594
|
-
const [rowState, updateRowState] = (0,
|
|
2654
|
+
const [rowState, updateRowState] = (0, import_react32.useState)({
|
|
2595
2655
|
splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
|
|
2596
2656
|
return {
|
|
2597
2657
|
amount: c.amount || 0,
|
|
@@ -2704,7 +2764,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2704
2764
|
}
|
|
2705
2765
|
);
|
|
2706
2766
|
};
|
|
2707
|
-
(0,
|
|
2767
|
+
(0, import_react32.useImperativeHandle)(ref, () => ({
|
|
2708
2768
|
save
|
|
2709
2769
|
}));
|
|
2710
2770
|
const onMatchSubmit = (matchId) => {
|
|
@@ -2716,11 +2776,11 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2716
2776
|
}
|
|
2717
2777
|
matchBankTransaction2(bankTransaction.id, foundMatch.id);
|
|
2718
2778
|
};
|
|
2719
|
-
const getDivHeight = (0,
|
|
2779
|
+
const getDivHeight = (0, import_react32.useCallback)(() => {
|
|
2720
2780
|
const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
|
|
2721
2781
|
return height2 || 0;
|
|
2722
2782
|
}, []);
|
|
2723
|
-
const handleTransitionEnd = (0,
|
|
2783
|
+
const handleTransitionEnd = (0, import_react32.useCallback)(
|
|
2724
2784
|
(e) => {
|
|
2725
2785
|
if (e.propertyName === "height") {
|
|
2726
2786
|
setHeight(isOpen ? "auto" : 0);
|
|
@@ -2731,7 +2791,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2731
2791
|
},
|
|
2732
2792
|
[isOpen]
|
|
2733
2793
|
);
|
|
2734
|
-
(0,
|
|
2794
|
+
(0, import_react32.useEffect)(() => {
|
|
2735
2795
|
if (!isLoaded) {
|
|
2736
2796
|
return;
|
|
2737
2797
|
}
|
|
@@ -2743,20 +2803,20 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2743
2803
|
});
|
|
2744
2804
|
}
|
|
2745
2805
|
}, [getDivHeight, isOpen]);
|
|
2746
|
-
(0,
|
|
2806
|
+
(0, import_react32.useEffect)(() => {
|
|
2747
2807
|
setIsLoaded(true);
|
|
2748
2808
|
setOver(true);
|
|
2749
2809
|
}, []);
|
|
2750
2810
|
const className = "Layer__expanded-bank-transaction-row";
|
|
2751
2811
|
const shouldHide = !isOpen && isOver;
|
|
2752
|
-
return /* @__PURE__ */
|
|
2812
|
+
return /* @__PURE__ */ import_react32.default.createElement(
|
|
2753
2813
|
"span",
|
|
2754
2814
|
{
|
|
2755
2815
|
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
2756
2816
|
style: { height },
|
|
2757
2817
|
onTransitionEnd: handleTransitionEnd
|
|
2758
2818
|
},
|
|
2759
|
-
shouldHide ? null : /* @__PURE__ */
|
|
2819
|
+
shouldHide ? null : /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2760
2820
|
Toggle,
|
|
2761
2821
|
{
|
|
2762
2822
|
name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
|
|
@@ -2775,13 +2835,13 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2775
2835
|
selected: purpose,
|
|
2776
2836
|
onChange: onChangePurpose
|
|
2777
2837
|
}
|
|
2778
|
-
)), /* @__PURE__ */
|
|
2838
|
+
)), /* @__PURE__ */ import_react32.default.createElement(
|
|
2779
2839
|
"div",
|
|
2780
2840
|
{
|
|
2781
2841
|
className: `${className}__content`,
|
|
2782
2842
|
id: `expanded-${bankTransaction.id}`
|
|
2783
2843
|
},
|
|
2784
|
-
/* @__PURE__ */
|
|
2844
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2785
2845
|
"div",
|
|
2786
2846
|
{
|
|
2787
2847
|
className: (0, import_classnames16.default)(
|
|
@@ -2790,7 +2850,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2790
2850
|
purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
|
|
2791
2851
|
)
|
|
2792
2852
|
},
|
|
2793
|
-
/* @__PURE__ */
|
|
2853
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2794
2854
|
MatchForm,
|
|
2795
2855
|
{
|
|
2796
2856
|
classNamePrefix: className,
|
|
@@ -2803,7 +2863,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2803
2863
|
matchFormError
|
|
2804
2864
|
}
|
|
2805
2865
|
))
|
|
2806
|
-
), /* @__PURE__ */
|
|
2866
|
+
), /* @__PURE__ */ import_react32.default.createElement(
|
|
2807
2867
|
"div",
|
|
2808
2868
|
{
|
|
2809
2869
|
className: (0, import_classnames16.default)(
|
|
@@ -2812,13 +2872,13 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2812
2872
|
purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
|
|
2813
2873
|
)
|
|
2814
2874
|
},
|
|
2815
|
-
/* @__PURE__ */
|
|
2875
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ import_react32.default.createElement(
|
|
2816
2876
|
"div",
|
|
2817
2877
|
{
|
|
2818
2878
|
className: `${className}__table-cell--split-entry`,
|
|
2819
2879
|
key: `split-${index}`
|
|
2820
2880
|
},
|
|
2821
|
-
/* @__PURE__ */
|
|
2881
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2822
2882
|
Input,
|
|
2823
2883
|
{
|
|
2824
2884
|
type: "text",
|
|
@@ -2831,12 +2891,12 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2831
2891
|
errorMessage: "Negative values are not allowed"
|
|
2832
2892
|
}
|
|
2833
2893
|
),
|
|
2834
|
-
/* @__PURE__ */
|
|
2894
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2835
2895
|
"div",
|
|
2836
2896
|
{
|
|
2837
2897
|
className: `${className}__table-cell--split-entry__right-col`
|
|
2838
2898
|
},
|
|
2839
|
-
/* @__PURE__ */
|
|
2899
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2840
2900
|
CategoryMenu,
|
|
2841
2901
|
{
|
|
2842
2902
|
bankTransaction,
|
|
@@ -2846,18 +2906,18 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2846
2906
|
className: "Layer__category-menu--full"
|
|
2847
2907
|
}
|
|
2848
2908
|
),
|
|
2849
|
-
index > 0 && /* @__PURE__ */
|
|
2909
|
+
index > 0 && /* @__PURE__ */ import_react32.default.createElement(
|
|
2850
2910
|
Button,
|
|
2851
2911
|
{
|
|
2852
2912
|
className: `${className}__table-cell--split-entry__merge-btn`,
|
|
2853
2913
|
onClick: () => removeSplit(index),
|
|
2854
|
-
rightIcon: /* @__PURE__ */
|
|
2914
|
+
rightIcon: /* @__PURE__ */ import_react32.default.createElement(Trash_default, { size: 18 }),
|
|
2855
2915
|
variant: "secondary" /* secondary */,
|
|
2856
2916
|
iconOnly: true
|
|
2857
2917
|
}
|
|
2858
2918
|
)
|
|
2859
2919
|
)
|
|
2860
|
-
))), splitFormError && /* @__PURE__ */
|
|
2920
|
+
))), splitFormError && /* @__PURE__ */ import_react32.default.createElement(ErrorText, null, splitFormError), /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__total-and-btns` }, rowState.splits.length > 1 && /* @__PURE__ */ import_react32.default.createElement(
|
|
2861
2921
|
Input,
|
|
2862
2922
|
{
|
|
2863
2923
|
disabled: true,
|
|
@@ -2869,43 +2929,43 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2869
2929
|
)
|
|
2870
2930
|
)}`
|
|
2871
2931
|
}
|
|
2872
|
-
), /* @__PURE__ */
|
|
2932
|
+
), /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ import_react32.default.createElement(
|
|
2873
2933
|
TextButton,
|
|
2874
2934
|
{
|
|
2875
2935
|
onClick: addSplit,
|
|
2876
2936
|
disabled: rowState.splits.length > 5
|
|
2877
2937
|
},
|
|
2878
2938
|
"Add new split"
|
|
2879
|
-
) : /* @__PURE__ */
|
|
2939
|
+
) : /* @__PURE__ */ import_react32.default.createElement(
|
|
2880
2940
|
Button,
|
|
2881
2941
|
{
|
|
2882
2942
|
onClick: addSplit,
|
|
2883
|
-
rightIcon: /* @__PURE__ */
|
|
2943
|
+
rightIcon: /* @__PURE__ */ import_react32.default.createElement(ScissorsFullOpen_default, { size: 14 }),
|
|
2884
2944
|
variant: "secondary" /* secondary */,
|
|
2885
2945
|
disabled: rowState.splits.length > 5
|
|
2886
2946
|
},
|
|
2887
2947
|
"Split"
|
|
2888
2948
|
))))
|
|
2889
2949
|
)),
|
|
2890
|
-
/* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2891
2951
|
InputGroup,
|
|
2892
2952
|
{
|
|
2893
2953
|
className: `${className}__description`,
|
|
2894
2954
|
name: "description"
|
|
2895
2955
|
},
|
|
2896
|
-
/* @__PURE__ */
|
|
2956
|
+
/* @__PURE__ */ import_react32.default.createElement(Textarea, { name: "description", placeholder: "Add description" })
|
|
2897
2957
|
),
|
|
2898
|
-
/* @__PURE__ */
|
|
2899
|
-
asListItem ? /* @__PURE__ */
|
|
2958
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react32.default.createElement(FileInput, { text: "Upload receipt" })),
|
|
2959
|
+
asListItem ? /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ import_react32.default.createElement(
|
|
2900
2960
|
Text,
|
|
2901
2961
|
{
|
|
2902
2962
|
as: "span",
|
|
2903
2963
|
size: "md" /* md */,
|
|
2904
2964
|
className: "Layer__unsaved-info"
|
|
2905
2965
|
},
|
|
2906
|
-
/* @__PURE__ */
|
|
2907
|
-
/* @__PURE__ */
|
|
2908
|
-
) : null, /* @__PURE__ */
|
|
2966
|
+
/* @__PURE__ */ import_react32.default.createElement("span", null, "Unsaved"),
|
|
2967
|
+
/* @__PURE__ */ import_react32.default.createElement(AlertCircle_default, { size: 12 })
|
|
2968
|
+
) : null, /* @__PURE__ */ import_react32.default.createElement(
|
|
2909
2969
|
SubmitButton,
|
|
2910
2970
|
{
|
|
2911
2971
|
onClick: () => {
|
|
@@ -2920,7 +2980,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2920
2980
|
},
|
|
2921
2981
|
submitBtnText
|
|
2922
2982
|
)) : null
|
|
2923
|
-
), /* @__PURE__ */
|
|
2983
|
+
), /* @__PURE__ */ import_react32.default.createElement(
|
|
2924
2984
|
APIErrorNotifications,
|
|
2925
2985
|
{
|
|
2926
2986
|
bankTransaction,
|
|
@@ -2932,7 +2992,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2932
2992
|
);
|
|
2933
2993
|
|
|
2934
2994
|
// src/components/BankTransactionRow/SplitTooltipDetails.tsx
|
|
2935
|
-
var
|
|
2995
|
+
var import_react33 = __toESM(require("react"));
|
|
2936
2996
|
var SplitTooltipDetails = ({
|
|
2937
2997
|
classNamePrefix,
|
|
2938
2998
|
category
|
|
@@ -2940,7 +3000,7 @@ var SplitTooltipDetails = ({
|
|
|
2940
3000
|
if (!category.entries) {
|
|
2941
3001
|
return;
|
|
2942
3002
|
}
|
|
2943
|
-
return /* @__PURE__ */
|
|
3003
|
+
return /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ import_react33.default.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ import_react33.default.createElement("li", { key: idx }, /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
|
|
2944
3004
|
};
|
|
2945
3005
|
|
|
2946
3006
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
@@ -2965,14 +3025,14 @@ var BankTransactionRow = ({
|
|
|
2965
3025
|
removeTransaction,
|
|
2966
3026
|
containerWidth
|
|
2967
3027
|
}) => {
|
|
2968
|
-
const expandedRowRef = (0,
|
|
2969
|
-
const [showRetry, setShowRetry] = (0,
|
|
2970
|
-
const [removed, setRemoved] = (0,
|
|
3028
|
+
const expandedRowRef = (0, import_react34.useRef)(null);
|
|
3029
|
+
const [showRetry, setShowRetry] = (0, import_react34.useState)(false);
|
|
3030
|
+
const [removed, setRemoved] = (0, import_react34.useState)(false);
|
|
2971
3031
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
2972
|
-
const [selectedCategory, setSelectedCategory] = (0,
|
|
3032
|
+
const [selectedCategory, setSelectedCategory] = (0, import_react34.useState)(
|
|
2973
3033
|
getDefaultSelectedCategory(bankTransaction)
|
|
2974
3034
|
);
|
|
2975
|
-
const [open, setOpen] = (0,
|
|
3035
|
+
const [open, setOpen] = (0, import_react34.useState)(false);
|
|
2976
3036
|
const toggleOpen = () => {
|
|
2977
3037
|
setShowRetry(false);
|
|
2978
3038
|
setOpen(!open);
|
|
@@ -2988,14 +3048,14 @@ var BankTransactionRow = ({
|
|
|
2988
3048
|
}
|
|
2989
3049
|
}
|
|
2990
3050
|
};
|
|
2991
|
-
const [showComponent, setShowComponent] = (0,
|
|
2992
|
-
(0,
|
|
3051
|
+
const [showComponent, setShowComponent] = (0, import_react34.useState)(false);
|
|
3052
|
+
(0, import_react34.useEffect)(() => {
|
|
2993
3053
|
const timeoutId = setTimeout(() => {
|
|
2994
3054
|
setShowComponent(true);
|
|
2995
3055
|
}, index * 80);
|
|
2996
3056
|
return () => clearTimeout(timeoutId);
|
|
2997
3057
|
}, []);
|
|
2998
|
-
(0,
|
|
3058
|
+
(0, import_react34.useEffect)(() => {
|
|
2999
3059
|
if (bankTransaction.error) {
|
|
3000
3060
|
setShowRetry(true);
|
|
3001
3061
|
}
|
|
@@ -3031,7 +3091,7 @@ var BankTransactionRow = ({
|
|
|
3031
3091
|
open ? openClassName : "",
|
|
3032
3092
|
showComponent ? "show" : ""
|
|
3033
3093
|
);
|
|
3034
|
-
return /* @__PURE__ */
|
|
3094
|
+
return /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3035
3095
|
"tr",
|
|
3036
3096
|
{
|
|
3037
3097
|
className: rowClassName,
|
|
@@ -3042,21 +3102,21 @@ var BankTransactionRow = ({
|
|
|
3042
3102
|
}
|
|
3043
3103
|
}
|
|
3044
3104
|
},
|
|
3045
|
-
/* @__PURE__ */
|
|
3105
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3046
3106
|
"td",
|
|
3047
3107
|
{
|
|
3048
3108
|
className: "Layer__table-cell Layer__bank-transaction-table__date-col",
|
|
3049
3109
|
...openRow
|
|
3050
3110
|
},
|
|
3051
|
-
/* @__PURE__ */
|
|
3111
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns7.format)((0, import_date_fns7.parseISO)(bankTransaction.date), dateFormat))
|
|
3052
3112
|
),
|
|
3053
|
-
/* @__PURE__ */
|
|
3113
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3054
3114
|
"td",
|
|
3055
3115
|
{
|
|
3056
3116
|
className: "Layer__table-cell Layer__bank-transactions__tx-col",
|
|
3057
3117
|
...openRow
|
|
3058
3118
|
},
|
|
3059
|
-
/* @__PURE__ */
|
|
3119
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3060
3120
|
Text,
|
|
3061
3121
|
{
|
|
3062
3122
|
as: "span",
|
|
@@ -3069,13 +3129,13 @@ var BankTransactionRow = ({
|
|
|
3069
3129
|
bankTransaction.counterparty_name ?? bankTransaction.description
|
|
3070
3130
|
))
|
|
3071
3131
|
),
|
|
3072
|
-
/* @__PURE__ */
|
|
3132
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3073
3133
|
"td",
|
|
3074
3134
|
{
|
|
3075
3135
|
className: "Layer__table-cell Layer__bank-transactions__account-col",
|
|
3076
3136
|
...openRow
|
|
3077
3137
|
},
|
|
3078
|
-
/* @__PURE__ */
|
|
3138
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3079
3139
|
Text,
|
|
3080
3140
|
{
|
|
3081
3141
|
as: "span",
|
|
@@ -3085,15 +3145,15 @@ var BankTransactionRow = ({
|
|
|
3085
3145
|
bankTransaction.account_name ?? ""
|
|
3086
3146
|
))
|
|
3087
3147
|
),
|
|
3088
|
-
/* @__PURE__ */
|
|
3148
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3089
3149
|
"td",
|
|
3090
3150
|
{
|
|
3091
3151
|
className: `Layer__table-cell Layer__table-cell__amount-col Layer__bank-transactions__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`,
|
|
3092
3152
|
...openRow
|
|
3093
3153
|
},
|
|
3094
|
-
/* @__PURE__ */
|
|
3154
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
3095
3155
|
),
|
|
3096
|
-
/* @__PURE__ */
|
|
3156
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3097
3157
|
"td",
|
|
3098
3158
|
{
|
|
3099
3159
|
className: (0, import_classnames17.default)(
|
|
@@ -3103,12 +3163,12 @@ var BankTransactionRow = ({
|
|
|
3103
3163
|
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
3104
3164
|
)
|
|
3105
3165
|
},
|
|
3106
|
-
/* @__PURE__ */
|
|
3166
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3107
3167
|
"span",
|
|
3108
3168
|
{
|
|
3109
3169
|
className: `${className}__actions-container Layer__table-cell-content`
|
|
3110
3170
|
},
|
|
3111
|
-
editable && !open ? /* @__PURE__ */
|
|
3171
|
+
editable && !open ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3112
3172
|
CategorySelect,
|
|
3113
3173
|
{
|
|
3114
3174
|
bankTransaction,
|
|
@@ -3121,11 +3181,11 @@ var BankTransactionRow = ({
|
|
|
3121
3181
|
disabled: bankTransaction.processing
|
|
3122
3182
|
}
|
|
3123
3183
|
) : null,
|
|
3124
|
-
!editable && !open ? /* @__PURE__ */
|
|
3184
|
+
!editable && !open ? /* @__PURE__ */ import_react34.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3125
3185
|
Badge,
|
|
3126
3186
|
{
|
|
3127
|
-
icon: /* @__PURE__ */
|
|
3128
|
-
tooltip: /* @__PURE__ */
|
|
3187
|
+
icon: /* @__PURE__ */ import_react34.default.createElement(Scissors_default, { size: 11 }),
|
|
3188
|
+
tooltip: /* @__PURE__ */ import_react34.default.createElement(
|
|
3129
3189
|
SplitTooltipDetails,
|
|
3130
3190
|
{
|
|
3131
3191
|
classNamePrefix: className,
|
|
@@ -3134,18 +3194,18 @@ var BankTransactionRow = ({
|
|
|
3134
3194
|
)
|
|
3135
3195
|
},
|
|
3136
3196
|
"Split"
|
|
3137
|
-
), /* @__PURE__ */
|
|
3197
|
+
), /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3138
3198
|
MatchBadge,
|
|
3139
3199
|
{
|
|
3140
3200
|
classNamePrefix: className,
|
|
3141
3201
|
bankTransaction,
|
|
3142
3202
|
dateFormat
|
|
3143
3203
|
}
|
|
3144
|
-
), /* @__PURE__ */
|
|
3204
|
+
), /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns7.format)(
|
|
3145
3205
|
(0, import_date_fns7.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
3146
3206
|
dateFormat
|
|
3147
|
-
)}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */
|
|
3148
|
-
editable && !open && showRetry ? /* @__PURE__ */
|
|
3207
|
+
)}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
3208
|
+
editable && !open && showRetry ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3149
3209
|
RetryButton,
|
|
3150
3210
|
{
|
|
3151
3211
|
onClick: () => {
|
|
@@ -3159,17 +3219,17 @@ var BankTransactionRow = ({
|
|
|
3159
3219
|
},
|
|
3160
3220
|
"Retry"
|
|
3161
3221
|
) : null,
|
|
3162
|
-
open && bankTransaction.error ? /* @__PURE__ */
|
|
3222
|
+
open && bankTransaction.error ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3163
3223
|
Text,
|
|
3164
3224
|
{
|
|
3165
3225
|
as: "span",
|
|
3166
3226
|
size: "md" /* md */,
|
|
3167
3227
|
className: "Layer__unsaved-info"
|
|
3168
3228
|
},
|
|
3169
|
-
/* @__PURE__ */
|
|
3170
|
-
/* @__PURE__ */
|
|
3229
|
+
/* @__PURE__ */ import_react34.default.createElement("span", null, "Unsaved"),
|
|
3230
|
+
/* @__PURE__ */ import_react34.default.createElement(AlertCircle_default, { size: 12 })
|
|
3171
3231
|
) : null,
|
|
3172
|
-
editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */
|
|
3232
|
+
editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3173
3233
|
SubmitButton,
|
|
3174
3234
|
{
|
|
3175
3235
|
onClick: () => {
|
|
@@ -3184,13 +3244,13 @@ var BankTransactionRow = ({
|
|
|
3184
3244
|
},
|
|
3185
3245
|
editable ? "Approve" : "Update"
|
|
3186
3246
|
) : null,
|
|
3187
|
-
/* @__PURE__ */
|
|
3247
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3188
3248
|
IconButton,
|
|
3189
3249
|
{
|
|
3190
3250
|
onClick: toggleOpen,
|
|
3191
3251
|
className: "Layer__bank-transaction-row__expand-button",
|
|
3192
3252
|
active: open,
|
|
3193
|
-
icon: /* @__PURE__ */
|
|
3253
|
+
icon: /* @__PURE__ */ import_react34.default.createElement(
|
|
3194
3254
|
ChevronDownFill_default,
|
|
3195
3255
|
{
|
|
3196
3256
|
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
@@ -3200,7 +3260,7 @@ var BankTransactionRow = ({
|
|
|
3200
3260
|
)
|
|
3201
3261
|
)
|
|
3202
3262
|
)
|
|
3203
|
-
), /* @__PURE__ */
|
|
3263
|
+
), /* @__PURE__ */ import_react34.default.createElement("tr", null, /* @__PURE__ */ import_react34.default.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3204
3264
|
ExpandedBankTransactionRow,
|
|
3205
3265
|
{
|
|
3206
3266
|
ref: expandedRowRef,
|
|
@@ -3213,11 +3273,11 @@ var BankTransactionRow = ({
|
|
|
3213
3273
|
};
|
|
3214
3274
|
|
|
3215
3275
|
// src/components/BankTransactionListItem/Assignment.tsx
|
|
3216
|
-
var
|
|
3276
|
+
var import_react35 = __toESM(require("react"));
|
|
3217
3277
|
var import_date_fns8 = require("date-fns");
|
|
3218
3278
|
var Assignment = ({ bankTransaction }) => {
|
|
3219
3279
|
if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
|
|
3220
|
-
return /* @__PURE__ */
|
|
3280
|
+
return /* @__PURE__ */ import_react35.default.createElement(import_react35.default.Fragment, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
3221
3281
|
MatchBadge,
|
|
3222
3282
|
{
|
|
3223
3283
|
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
@@ -3225,17 +3285,17 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
3225
3285
|
dateFormat: DATE_FORMAT,
|
|
3226
3286
|
text: "Matched"
|
|
3227
3287
|
}
|
|
3228
|
-
), /* @__PURE__ */
|
|
3288
|
+
), /* @__PURE__ */ import_react35.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${(0, import_date_fns8.format)(
|
|
3229
3289
|
(0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
3230
3290
|
DATE_FORMAT
|
|
3231
3291
|
)}, ${bankTransaction.match.bank_transaction.description}`));
|
|
3232
3292
|
}
|
|
3233
3293
|
if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
|
|
3234
|
-
return /* @__PURE__ */
|
|
3294
|
+
return /* @__PURE__ */ import_react35.default.createElement(import_react35.default.Fragment, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
3235
3295
|
Badge,
|
|
3236
3296
|
{
|
|
3237
|
-
icon: /* @__PURE__ */
|
|
3238
|
-
tooltip: /* @__PURE__ */
|
|
3297
|
+
icon: /* @__PURE__ */ import_react35.default.createElement(Scissors_default, { size: 11 }),
|
|
3298
|
+
tooltip: /* @__PURE__ */ import_react35.default.createElement(
|
|
3239
3299
|
SplitTooltipDetails,
|
|
3240
3300
|
{
|
|
3241
3301
|
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
@@ -3244,9 +3304,9 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
3244
3304
|
)
|
|
3245
3305
|
},
|
|
3246
3306
|
"Split"
|
|
3247
|
-
), /* @__PURE__ */
|
|
3307
|
+
), /* @__PURE__ */ import_react35.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
|
|
3248
3308
|
}
|
|
3249
|
-
return /* @__PURE__ */
|
|
3309
|
+
return /* @__PURE__ */ import_react35.default.createElement(Text, null, bankTransaction?.category?.display_name);
|
|
3250
3310
|
};
|
|
3251
3311
|
|
|
3252
3312
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
@@ -3260,26 +3320,26 @@ var BankTransactionListItem = ({
|
|
|
3260
3320
|
editable,
|
|
3261
3321
|
containerWidth
|
|
3262
3322
|
}) => {
|
|
3263
|
-
const expandedRowRef = (0,
|
|
3264
|
-
const [showRetry, setShowRetry] = (0,
|
|
3265
|
-
const [removed, setRemoved] = (0,
|
|
3323
|
+
const expandedRowRef = (0, import_react36.useRef)(null);
|
|
3324
|
+
const [showRetry, setShowRetry] = (0, import_react36.useState)(false);
|
|
3325
|
+
const [removed, setRemoved] = (0, import_react36.useState)(false);
|
|
3266
3326
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
3267
|
-
const [selectedCategory, setSelectedCategory] = (0,
|
|
3327
|
+
const [selectedCategory, setSelectedCategory] = (0, import_react36.useState)(
|
|
3268
3328
|
getDefaultSelectedCategory(bankTransaction)
|
|
3269
3329
|
);
|
|
3270
|
-
const [open, setOpen] = (0,
|
|
3330
|
+
const [open, setOpen] = (0, import_react36.useState)(false);
|
|
3271
3331
|
const toggleOpen = () => {
|
|
3272
3332
|
setShowRetry(false);
|
|
3273
3333
|
setOpen(!open);
|
|
3274
3334
|
};
|
|
3275
|
-
const [showComponent, setShowComponent] = (0,
|
|
3276
|
-
(0,
|
|
3335
|
+
const [showComponent, setShowComponent] = (0, import_react36.useState)(false);
|
|
3336
|
+
(0, import_react36.useEffect)(() => {
|
|
3277
3337
|
const timeoutId = setTimeout(() => {
|
|
3278
3338
|
setShowComponent(true);
|
|
3279
3339
|
}, index * 80);
|
|
3280
3340
|
return () => clearTimeout(timeoutId);
|
|
3281
3341
|
}, []);
|
|
3282
|
-
(0,
|
|
3342
|
+
(0, import_react36.useEffect)(() => {
|
|
3283
3343
|
if (bankTransaction.error) {
|
|
3284
3344
|
setShowRetry(true);
|
|
3285
3345
|
}
|
|
@@ -3315,26 +3375,26 @@ var BankTransactionListItem = ({
|
|
|
3315
3375
|
open ? openClassName : "",
|
|
3316
3376
|
showComponent ? "show" : ""
|
|
3317
3377
|
);
|
|
3318
|
-
return /* @__PURE__ */
|
|
3378
|
+
return /* @__PURE__ */ import_react36.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react36.default.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-date` }, (0, import_date_fns9.format)((0, import_date_fns9.parseISO)(bankTransaction.date), dateFormat)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ import_react36.default.createElement(
|
|
3319
3379
|
"div",
|
|
3320
3380
|
{
|
|
3321
3381
|
onClick: toggleOpen,
|
|
3322
3382
|
className: "Layer__bank-transaction-row__expand-button"
|
|
3323
3383
|
},
|
|
3324
|
-
/* @__PURE__ */
|
|
3384
|
+
/* @__PURE__ */ import_react36.default.createElement(
|
|
3325
3385
|
ChevronDownFill_default,
|
|
3326
3386
|
{
|
|
3327
3387
|
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
3328
3388
|
}
|
|
3329
3389
|
)
|
|
3330
|
-
)), /* @__PURE__ */
|
|
3390
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__body__name` }, /* @__PURE__ */ import_react36.default.createElement(Text, { as: "span", withTooltip: "whenTruncated" /* whenTruncated */ }, bankTransaction.counterparty_name ?? bankTransaction.description)), /* @__PURE__ */ import_react36.default.createElement(
|
|
3331
3391
|
"span",
|
|
3332
3392
|
{
|
|
3333
3393
|
className: `${className}__amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
|
|
3334
3394
|
},
|
|
3335
3395
|
isCredit2(bankTransaction) ? "+$" : " $",
|
|
3336
3396
|
centsToDollars(bankTransaction.amount)
|
|
3337
|
-
)), /* @__PURE__ */
|
|
3397
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ import_react36.default.createElement(
|
|
3338
3398
|
ExpandedBankTransactionRow,
|
|
3339
3399
|
{
|
|
3340
3400
|
ref: expandedRowRef,
|
|
@@ -3345,7 +3405,7 @@ var BankTransactionListItem = ({
|
|
|
3345
3405
|
submitBtnText: editable ? "Approve" : "Update",
|
|
3346
3406
|
containerWidth
|
|
3347
3407
|
}
|
|
3348
|
-
)), /* @__PURE__ */
|
|
3408
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3349
3409
|
CategorySelect,
|
|
3350
3410
|
{
|
|
3351
3411
|
bankTransaction,
|
|
@@ -3357,7 +3417,7 @@ var BankTransactionListItem = ({
|
|
|
3357
3417
|
},
|
|
3358
3418
|
disabled: bankTransaction.processing
|
|
3359
3419
|
}
|
|
3360
|
-
) : null, !editable ? /* @__PURE__ */
|
|
3420
|
+
) : null, !editable ? /* @__PURE__ */ import_react36.default.createElement(Assignment, { bankTransaction }) : null, editable && !showRetry ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3361
3421
|
SubmitButton,
|
|
3362
3422
|
{
|
|
3363
3423
|
onClick: () => {
|
|
@@ -3370,7 +3430,7 @@ var BankTransactionListItem = ({
|
|
|
3370
3430
|
action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
3371
3431
|
},
|
|
3372
3432
|
editable ? "Approve" : "Update"
|
|
3373
|
-
) : null, editable && showRetry ? /* @__PURE__ */
|
|
3433
|
+
) : null, editable && showRetry ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3374
3434
|
RetryButton,
|
|
3375
3435
|
{
|
|
3376
3436
|
onClick: () => {
|
|
@@ -3383,11 +3443,11 @@ var BankTransactionListItem = ({
|
|
|
3383
3443
|
error: "Approval failed. Check connection and retry in few seconds."
|
|
3384
3444
|
},
|
|
3385
3445
|
"Retry"
|
|
3386
|
-
) : null), bankTransaction.error && showRetry ? /* @__PURE__ */
|
|
3446
|
+
) : null), bankTransaction.error && showRetry ? /* @__PURE__ */ import_react36.default.createElement(ErrorText, null, "Approval failed. Check connection and retry in few seconds.") : null);
|
|
3387
3447
|
};
|
|
3388
3448
|
|
|
3389
3449
|
// src/components/Container/Container.tsx
|
|
3390
|
-
var
|
|
3450
|
+
var import_react37 = __toESM(require("react"));
|
|
3391
3451
|
|
|
3392
3452
|
// src/config/theme.ts
|
|
3393
3453
|
var SHADES = {
|
|
@@ -3616,7 +3676,7 @@ var hslToHex = (hsl) => {
|
|
|
3616
3676
|
|
|
3617
3677
|
// src/components/Container/Container.tsx
|
|
3618
3678
|
var import_classnames19 = __toESM(require("classnames"));
|
|
3619
|
-
var Container = (0,
|
|
3679
|
+
var Container = (0, import_react37.forwardRef)(
|
|
3620
3680
|
({ name, className, children, asWidget }, ref) => {
|
|
3621
3681
|
const baseClassName = (0, import_classnames19.default)(
|
|
3622
3682
|
"Layer__component Layer__component-container",
|
|
@@ -3626,28 +3686,30 @@ var Container = (0, import_react36.forwardRef)(
|
|
|
3626
3686
|
);
|
|
3627
3687
|
const { theme } = useLayerContext();
|
|
3628
3688
|
const styles = parseStylesFromThemeConfig(theme);
|
|
3629
|
-
return /* @__PURE__ */
|
|
3689
|
+
return /* @__PURE__ */ import_react37.default.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
|
|
3630
3690
|
}
|
|
3631
3691
|
);
|
|
3632
3692
|
|
|
3633
3693
|
// src/components/Container/Header.tsx
|
|
3634
|
-
var
|
|
3694
|
+
var import_react38 = __toESM(require("react"));
|
|
3635
3695
|
var import_classnames20 = __toESM(require("classnames"));
|
|
3636
|
-
var Header = (0,
|
|
3696
|
+
var Header = (0, import_react38.forwardRef)(
|
|
3637
3697
|
({ className, children, style }, ref) => {
|
|
3638
3698
|
const baseClassName = (0, import_classnames20.default)("Layer__component-header", className);
|
|
3639
|
-
return /* @__PURE__ */
|
|
3699
|
+
return /* @__PURE__ */ import_react38.default.createElement("header", { ref, className: baseClassName, style }, children);
|
|
3640
3700
|
}
|
|
3641
3701
|
);
|
|
3642
3702
|
|
|
3643
3703
|
// src/components/DataState/DataState.tsx
|
|
3644
|
-
var
|
|
3704
|
+
var import_react39 = __toESM(require("react"));
|
|
3645
3705
|
var getIcon = (status) => {
|
|
3646
3706
|
switch (status) {
|
|
3647
3707
|
case "failed" /* failed */:
|
|
3648
|
-
return /* @__PURE__ */
|
|
3708
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react39.default.createElement(AlertOctagon_default, { size: 12 }));
|
|
3709
|
+
case "info" /* info */:
|
|
3710
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react39.default.createElement(AlertOctagon_default, { size: 12 }));
|
|
3649
3711
|
default:
|
|
3650
|
-
return /* @__PURE__ */
|
|
3712
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react39.default.createElement(CheckCircle_default, { size: 12 }));
|
|
3651
3713
|
}
|
|
3652
3714
|
};
|
|
3653
3715
|
var DataState = ({
|
|
@@ -3657,7 +3719,7 @@ var DataState = ({
|
|
|
3657
3719
|
onRefresh,
|
|
3658
3720
|
isLoading
|
|
3659
3721
|
}) => {
|
|
3660
|
-
return /* @__PURE__ */
|
|
3722
|
+
return /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react39.default.createElement(
|
|
3661
3723
|
Text,
|
|
3662
3724
|
{
|
|
3663
3725
|
as: "span",
|
|
@@ -3666,11 +3728,11 @@ var DataState = ({
|
|
|
3666
3728
|
className: "Layer__data-state__title"
|
|
3667
3729
|
},
|
|
3668
3730
|
title
|
|
3669
|
-
), /* @__PURE__ */
|
|
3731
|
+
), /* @__PURE__ */ import_react39.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react39.default.createElement(
|
|
3670
3732
|
Button,
|
|
3671
3733
|
{
|
|
3672
3734
|
variant: "secondary" /* secondary */,
|
|
3673
|
-
rightIcon: isLoading ? /* @__PURE__ */
|
|
3735
|
+
rightIcon: isLoading ? /* @__PURE__ */ import_react39.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react39.default.createElement(RefreshCcw_default, { size: 12 }),
|
|
3674
3736
|
onClick: onRefresh,
|
|
3675
3737
|
disabled: isLoading
|
|
3676
3738
|
},
|
|
@@ -3679,16 +3741,16 @@ var DataState = ({
|
|
|
3679
3741
|
};
|
|
3680
3742
|
|
|
3681
3743
|
// src/components/Loader/Loader.tsx
|
|
3682
|
-
var
|
|
3744
|
+
var import_react40 = __toESM(require("react"));
|
|
3683
3745
|
var Loader2 = ({ children }) => {
|
|
3684
|
-
return /* @__PURE__ */
|
|
3746
|
+
return /* @__PURE__ */ import_react40.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react40.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
|
|
3685
3747
|
};
|
|
3686
3748
|
|
|
3687
3749
|
// src/components/Pagination/Pagination.tsx
|
|
3688
|
-
var
|
|
3750
|
+
var import_react42 = __toESM(require("react"));
|
|
3689
3751
|
|
|
3690
3752
|
// src/hooks/usePagination/usePagination.ts
|
|
3691
|
-
var
|
|
3753
|
+
var import_react41 = require("react");
|
|
3692
3754
|
var DOTS = "...";
|
|
3693
3755
|
var usePagination = ({
|
|
3694
3756
|
totalCount,
|
|
@@ -3696,7 +3758,7 @@ var usePagination = ({
|
|
|
3696
3758
|
siblingCount = 1,
|
|
3697
3759
|
currentPage
|
|
3698
3760
|
}) => {
|
|
3699
|
-
const paginationRange = (0,
|
|
3761
|
+
const paginationRange = (0, import_react41.useMemo)(() => {
|
|
3700
3762
|
const totalPageCount = Math.ceil(totalCount / pageSize);
|
|
3701
3763
|
const totalPageNumbers = siblingCount + 5;
|
|
3702
3764
|
if (totalPageNumbers >= totalPageCount) {
|
|
@@ -3733,8 +3795,8 @@ var usePagination = ({
|
|
|
3733
3795
|
};
|
|
3734
3796
|
|
|
3735
3797
|
// src/icons/ChevronLeft.tsx
|
|
3736
|
-
var
|
|
3737
|
-
var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3798
|
+
var React52 = __toESM(require("react"));
|
|
3799
|
+
var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createElement(
|
|
3738
3800
|
"svg",
|
|
3739
3801
|
{
|
|
3740
3802
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3744,7 +3806,7 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
|
|
|
3744
3806
|
fill: "none",
|
|
3745
3807
|
...props
|
|
3746
3808
|
},
|
|
3747
|
-
/* @__PURE__ */
|
|
3809
|
+
/* @__PURE__ */ React52.createElement(
|
|
3748
3810
|
"path",
|
|
3749
3811
|
{
|
|
3750
3812
|
d: "M11.25 13.5L6.75 9L11.25 4.5",
|
|
@@ -3757,8 +3819,8 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
|
|
|
3757
3819
|
var ChevronLeft_default = ChevronLeft;
|
|
3758
3820
|
|
|
3759
3821
|
// src/icons/ChevronRight.tsx
|
|
3760
|
-
var
|
|
3761
|
-
var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3822
|
+
var React53 = __toESM(require("react"));
|
|
3823
|
+
var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React53.createElement(
|
|
3762
3824
|
"svg",
|
|
3763
3825
|
{
|
|
3764
3826
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3768,7 +3830,7 @@ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createEl
|
|
|
3768
3830
|
fill: "none",
|
|
3769
3831
|
...props
|
|
3770
3832
|
},
|
|
3771
|
-
/* @__PURE__ */
|
|
3833
|
+
/* @__PURE__ */ React53.createElement(
|
|
3772
3834
|
"path",
|
|
3773
3835
|
{
|
|
3774
3836
|
d: "M6.75 13.5L11.25 9L6.75 4.5",
|
|
@@ -3802,7 +3864,7 @@ var Pagination = ({
|
|
|
3802
3864
|
return;
|
|
3803
3865
|
}
|
|
3804
3866
|
let lastPage = paginationRange[paginationRange.length - 1];
|
|
3805
|
-
return /* @__PURE__ */
|
|
3867
|
+
return /* @__PURE__ */ import_react42.default.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ import_react42.default.createElement(
|
|
3806
3868
|
"li",
|
|
3807
3869
|
{
|
|
3808
3870
|
key: `page-prev`,
|
|
@@ -3814,12 +3876,12 @@ var Pagination = ({
|
|
|
3814
3876
|
),
|
|
3815
3877
|
onClick: () => onPageChange(currentPage - 1)
|
|
3816
3878
|
},
|
|
3817
|
-
/* @__PURE__ */
|
|
3879
|
+
/* @__PURE__ */ import_react42.default.createElement(ChevronLeft_default, { size: 12 })
|
|
3818
3880
|
), paginationRange.map((pageNumber) => {
|
|
3819
3881
|
if (pageNumber === DOTS) {
|
|
3820
|
-
return /* @__PURE__ */
|
|
3882
|
+
return /* @__PURE__ */ import_react42.default.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
|
|
3821
3883
|
}
|
|
3822
|
-
return /* @__PURE__ */
|
|
3884
|
+
return /* @__PURE__ */ import_react42.default.createElement(
|
|
3823
3885
|
"li",
|
|
3824
3886
|
{
|
|
3825
3887
|
key: `page-${pageNumber}`,
|
|
@@ -3834,7 +3896,7 @@ var Pagination = ({
|
|
|
3834
3896
|
},
|
|
3835
3897
|
pageNumber
|
|
3836
3898
|
);
|
|
3837
|
-
}), /* @__PURE__ */
|
|
3899
|
+
}), /* @__PURE__ */ import_react42.default.createElement(
|
|
3838
3900
|
"li",
|
|
3839
3901
|
{
|
|
3840
3902
|
key: `page-last`,
|
|
@@ -3846,7 +3908,7 @@ var Pagination = ({
|
|
|
3846
3908
|
),
|
|
3847
3909
|
onClick: () => onPageChange(currentPage + 1)
|
|
3848
3910
|
},
|
|
3849
|
-
/* @__PURE__ */
|
|
3911
|
+
/* @__PURE__ */ import_react42.default.createElement(ChevronRight_default, { size: 12 })
|
|
3850
3912
|
));
|
|
3851
3913
|
};
|
|
3852
3914
|
|
|
@@ -3873,14 +3935,14 @@ var BankTransactions = ({
|
|
|
3873
3935
|
asWidget = false,
|
|
3874
3936
|
pageSize = 15
|
|
3875
3937
|
}) => {
|
|
3876
|
-
const [display, setDisplay] = (0,
|
|
3877
|
-
const [currentPage, setCurrentPage] = (0,
|
|
3878
|
-
const [removedTxs, setRemovedTxs] = (0,
|
|
3938
|
+
const [display, setDisplay] = (0, import_react43.useState)("review" /* review */);
|
|
3939
|
+
const [currentPage, setCurrentPage] = (0, import_react43.useState)(1);
|
|
3940
|
+
const [removedTxs, setRemovedTxs] = (0, import_react43.useState)([]);
|
|
3879
3941
|
const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
|
|
3880
3942
|
const bankTransactionsByFilter = data?.filter(
|
|
3881
3943
|
(tx) => !removedTxs.includes(tx.id) && filterVisibility(display, tx)
|
|
3882
3944
|
);
|
|
3883
|
-
const bankTransactions = (0,
|
|
3945
|
+
const bankTransactions = (0, import_react43.useMemo)(() => {
|
|
3884
3946
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
3885
3947
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
3886
3948
|
return bankTransactionsByFilter?.slice(firstPageIndex, lastPageIndex);
|
|
@@ -3891,10 +3953,10 @@ var BankTransactions = ({
|
|
|
3891
3953
|
);
|
|
3892
3954
|
setCurrentPage(1);
|
|
3893
3955
|
};
|
|
3894
|
-
const [shiftStickyHeader, setShiftStickyHeader] = (0,
|
|
3956
|
+
const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react43.useState)(0);
|
|
3895
3957
|
const debounceShiftStickyHeader = debounce(setShiftStickyHeader, 500);
|
|
3896
|
-
const [listView, setListView] = (0,
|
|
3897
|
-
const [containerWidth, setContainerWidth] = (0,
|
|
3958
|
+
const [listView, setListView] = (0, import_react43.useState)(false);
|
|
3959
|
+
const [containerWidth, setContainerWidth] = (0, import_react43.useState)(0);
|
|
3898
3960
|
const debounceContainerWidth = debounce(setContainerWidth, 500);
|
|
3899
3961
|
const removeTransaction = (id) => {
|
|
3900
3962
|
const newTxs = removedTxs.slice();
|
|
@@ -3918,7 +3980,7 @@ var BankTransactions = ({
|
|
|
3918
3980
|
debounceContainerWidth(size?.width);
|
|
3919
3981
|
});
|
|
3920
3982
|
const editable = display === "review" /* review */;
|
|
3921
|
-
return /* @__PURE__ */
|
|
3983
|
+
return /* @__PURE__ */ import_react43.default.createElement(
|
|
3922
3984
|
Container,
|
|
3923
3985
|
{
|
|
3924
3986
|
className: editable ? "Layer__bank-transactions--to-review" : "Layer__bank-transactions--categorized",
|
|
@@ -3926,14 +3988,14 @@ var BankTransactions = ({
|
|
|
3926
3988
|
asWidget,
|
|
3927
3989
|
ref: containerRef
|
|
3928
3990
|
},
|
|
3929
|
-
/* @__PURE__ */
|
|
3991
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
3930
3992
|
Header,
|
|
3931
3993
|
{
|
|
3932
3994
|
className: "Layer__bank-transactions__header",
|
|
3933
3995
|
style: { top: shiftStickyHeader }
|
|
3934
3996
|
},
|
|
3935
|
-
/* @__PURE__ */
|
|
3936
|
-
/* @__PURE__ */
|
|
3997
|
+
/* @__PURE__ */ import_react43.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
3998
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
3937
3999
|
Toggle,
|
|
3938
4000
|
{
|
|
3939
4001
|
name: "bank-transaction-display",
|
|
@@ -3946,15 +4008,15 @@ var BankTransactions = ({
|
|
|
3946
4008
|
}
|
|
3947
4009
|
)
|
|
3948
4010
|
),
|
|
3949
|
-
!listView && /* @__PURE__ */
|
|
4011
|
+
!listView && /* @__PURE__ */ import_react43.default.createElement(
|
|
3950
4012
|
"table",
|
|
3951
4013
|
{
|
|
3952
4014
|
width: "100%",
|
|
3953
4015
|
className: "Layer__table Layer__bank-transactions__table with-cell-separators"
|
|
3954
4016
|
},
|
|
3955
|
-
/* @__PURE__ */
|
|
3956
|
-
/* @__PURE__ */
|
|
3957
|
-
(bankTransaction, index) => /* @__PURE__ */
|
|
4017
|
+
/* @__PURE__ */ import_react43.default.createElement("thead", null, /* @__PURE__ */ import_react43.default.createElement("tr", null, /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
|
|
4018
|
+
/* @__PURE__ */ import_react43.default.createElement("tbody", null, !isLoading && bankTransactions?.map(
|
|
4019
|
+
(bankTransaction, index) => /* @__PURE__ */ import_react43.default.createElement(
|
|
3958
4020
|
BankTransactionRow,
|
|
3959
4021
|
{
|
|
3960
4022
|
index,
|
|
@@ -3968,9 +4030,9 @@ var BankTransactions = ({
|
|
|
3968
4030
|
)
|
|
3969
4031
|
))
|
|
3970
4032
|
),
|
|
3971
|
-
isLoading && !bankTransactions ? /* @__PURE__ */
|
|
3972
|
-
!isLoading && listView ? /* @__PURE__ */
|
|
3973
|
-
(bankTransaction, index) => /* @__PURE__ */
|
|
4033
|
+
isLoading && !bankTransactions ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react43.default.createElement(Loader2, null)) : null,
|
|
4034
|
+
!isLoading && listView ? /* @__PURE__ */ import_react43.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map(
|
|
4035
|
+
(bankTransaction, index) => /* @__PURE__ */ import_react43.default.createElement(
|
|
3974
4036
|
BankTransactionListItem,
|
|
3975
4037
|
{
|
|
3976
4038
|
index,
|
|
@@ -3983,7 +4045,7 @@ var BankTransactions = ({
|
|
|
3983
4045
|
}
|
|
3984
4046
|
)
|
|
3985
4047
|
)) : null,
|
|
3986
|
-
!isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */
|
|
4048
|
+
!isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3987
4049
|
DataState,
|
|
3988
4050
|
{
|
|
3989
4051
|
status: "allDone" /* allDone */,
|
|
@@ -3993,7 +4055,7 @@ var BankTransactions = ({
|
|
|
3993
4055
|
isLoading: isValidating
|
|
3994
4056
|
}
|
|
3995
4057
|
)) : null,
|
|
3996
|
-
!isLoading && error ? /* @__PURE__ */
|
|
4058
|
+
!isLoading && error ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3997
4059
|
DataState,
|
|
3998
4060
|
{
|
|
3999
4061
|
status: "failed" /* failed */,
|
|
@@ -4003,7 +4065,7 @@ var BankTransactions = ({
|
|
|
4003
4065
|
isLoading: isValidating
|
|
4004
4066
|
}
|
|
4005
4067
|
)) : null,
|
|
4006
|
-
/* @__PURE__ */
|
|
4068
|
+
/* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
4007
4069
|
Pagination,
|
|
4008
4070
|
{
|
|
4009
4071
|
currentPage,
|
|
@@ -4016,7 +4078,7 @@ var BankTransactions = ({
|
|
|
4016
4078
|
};
|
|
4017
4079
|
|
|
4018
4080
|
// src/components/Hello/Hello.tsx
|
|
4019
|
-
var
|
|
4081
|
+
var import_react44 = __toESM(require("react"));
|
|
4020
4082
|
var import_swr3 = __toESM(require("swr"));
|
|
4021
4083
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
4022
4084
|
var Hello = ({ user }) => {
|
|
@@ -4025,38 +4087,35 @@ var Hello = ({ user }) => {
|
|
|
4025
4087
|
fetcher
|
|
4026
4088
|
);
|
|
4027
4089
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
4028
|
-
return /* @__PURE__ */
|
|
4090
|
+
return /* @__PURE__ */ import_react44.default.createElement(import_react44.default.Fragment, null, /* @__PURE__ */ import_react44.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
4029
4091
|
};
|
|
4030
4092
|
|
|
4031
4093
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4032
|
-
var
|
|
4094
|
+
var import_react47 = __toESM(require("react"));
|
|
4033
4095
|
|
|
4034
4096
|
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
4035
|
-
var
|
|
4097
|
+
var import_react45 = require("react");
|
|
4036
4098
|
var MOCK_DATA = [
|
|
4037
4099
|
{
|
|
4038
|
-
name: "
|
|
4100
|
+
name: "Business Checking",
|
|
4039
4101
|
account: "1234",
|
|
4040
4102
|
amount: 1220620
|
|
4103
|
+
},
|
|
4104
|
+
{
|
|
4105
|
+
name: "Business Savings",
|
|
4106
|
+
account: "5678",
|
|
4107
|
+
amount: 10002062e-1
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
name: "Account",
|
|
4111
|
+
account: "4321",
|
|
4112
|
+
amount: 4400020620
|
|
4041
4113
|
}
|
|
4042
|
-
/* Temporarily removing these to make it match test data (with one account)
|
|
4043
|
-
* we're using in the demo.
|
|
4044
|
-
*/
|
|
4045
|
-
// {
|
|
4046
|
-
// name: 'Business Savings',
|
|
4047
|
-
// account: '5678',
|
|
4048
|
-
// amount: 1000206.2,
|
|
4049
|
-
// },
|
|
4050
|
-
// {
|
|
4051
|
-
// name: 'Account',
|
|
4052
|
-
// account: '4321',
|
|
4053
|
-
// amount: 801.91,
|
|
4054
|
-
// },
|
|
4055
4114
|
];
|
|
4056
4115
|
var useLinkedAccounts = () => {
|
|
4057
4116
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4058
|
-
const [isLoading, setIsLoading] = (0,
|
|
4059
|
-
(0,
|
|
4117
|
+
const [isLoading, setIsLoading] = (0, import_react45.useState)(true);
|
|
4118
|
+
(0, import_react45.useEffect)(() => {
|
|
4060
4119
|
const timer = setTimeout(() => {
|
|
4061
4120
|
setIsLoading(false);
|
|
4062
4121
|
}, 2e3);
|
|
@@ -4082,23 +4141,23 @@ var useLinkedAccounts = () => {
|
|
|
4082
4141
|
};
|
|
4083
4142
|
|
|
4084
4143
|
// src/components/LinkedAccounts/LinkedAccountThumb.tsx
|
|
4085
|
-
var
|
|
4144
|
+
var import_react46 = __toESM(require("react"));
|
|
4086
4145
|
var LinkedAccountThumb = ({ account }) => {
|
|
4087
|
-
return /* @__PURE__ */
|
|
4146
|
+
return /* @__PURE__ */ import_react46.default.createElement("div", { className: "Layer__linked-account-thumb" }, /* @__PURE__ */ import_react46.default.createElement("div", { className: "topbar" }, /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-name" }, account.name), /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-number" }, "\u2022\u2022\u2022", account.account)), /* @__PURE__ */ import_react46.default.createElement("div", { className: "bottombar" }, /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-amount" }, "$", centsToDollars(account.amount))));
|
|
4088
4147
|
};
|
|
4089
4148
|
|
|
4090
4149
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4091
4150
|
var COMPONENT_NAME2 = "linked-accounts";
|
|
4092
4151
|
var LinkedAccounts = () => {
|
|
4093
4152
|
const { data, isLoading, error, isValidating, refetch } = useLinkedAccounts();
|
|
4094
|
-
return /* @__PURE__ */
|
|
4153
|
+
return /* @__PURE__ */ import_react47.default.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ import_react47.default.createElement(Header, { className: "Layer__linked-accounts__header" }, /* @__PURE__ */ import_react47.default.createElement(
|
|
4095
4154
|
Heading,
|
|
4096
4155
|
{
|
|
4097
4156
|
className: "Layer__linked-accounts__title",
|
|
4098
4157
|
size: "secondary" /* secondary */
|
|
4099
4158
|
},
|
|
4100
4159
|
"Linked Accounts"
|
|
4101
|
-
)), isLoading && /* @__PURE__ */
|
|
4160
|
+
)), isLoading && /* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__linked-accounts__loader-container" }, /* @__PURE__ */ import_react47.default.createElement(Loader2, null)), error && !isLoading ? /* @__PURE__ */ import_react47.default.createElement(
|
|
4102
4161
|
DataState,
|
|
4103
4162
|
{
|
|
4104
4163
|
status: "failed" /* failed */,
|
|
@@ -4107,14 +4166,14 @@ var LinkedAccounts = () => {
|
|
|
4107
4166
|
onRefresh: () => refetch(),
|
|
4108
4167
|
isLoading: isValidating
|
|
4109
4168
|
}
|
|
4110
|
-
) : null, !error && !isLoading ? /* @__PURE__ */
|
|
4169
|
+
) : null, !error && !isLoading ? /* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__linked-accounts__list" }, data?.map((account, index) => /* @__PURE__ */ import_react47.default.createElement(LinkedAccountThumb, { account, key: `linked-acc-${index}` }))) : null);
|
|
4111
4170
|
};
|
|
4112
4171
|
|
|
4113
4172
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4114
|
-
var
|
|
4173
|
+
var import_react57 = __toESM(require("react"));
|
|
4115
4174
|
|
|
4116
4175
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4117
|
-
var
|
|
4176
|
+
var import_react48 = require("react");
|
|
4118
4177
|
|
|
4119
4178
|
// src/utils/profitAndLossUtils.ts
|
|
4120
4179
|
var doesLineItemQualifies = (item) => {
|
|
@@ -4183,17 +4242,17 @@ var useProfitAndLoss = ({
|
|
|
4183
4242
|
endDate: (0, import_date_fns10.endOfMonth)(/* @__PURE__ */ new Date())
|
|
4184
4243
|
}) => {
|
|
4185
4244
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4186
|
-
const [startDate, setStartDate] = (0,
|
|
4245
|
+
const [startDate, setStartDate] = (0, import_react48.useState)(
|
|
4187
4246
|
initialStartDate || (0, import_date_fns10.startOfMonth)(Date.now())
|
|
4188
4247
|
);
|
|
4189
|
-
const [endDate, setEndDate] = (0,
|
|
4248
|
+
const [endDate, setEndDate] = (0, import_react48.useState)(
|
|
4190
4249
|
initialEndDate || (0, import_date_fns10.endOfMonth)(Date.now())
|
|
4191
4250
|
);
|
|
4192
|
-
const [filters, setFilters] = (0,
|
|
4251
|
+
const [filters, setFilters] = (0, import_react48.useState)({
|
|
4193
4252
|
expenses: void 0,
|
|
4194
4253
|
revenue: void 0
|
|
4195
4254
|
});
|
|
4196
|
-
const [sidebarScope, setSidebarScope] = (0,
|
|
4255
|
+
const [sidebarScope, setSidebarScope] = (0, import_react48.useState)(void 0);
|
|
4197
4256
|
const {
|
|
4198
4257
|
data: rawData,
|
|
4199
4258
|
isLoading,
|
|
@@ -4216,7 +4275,7 @@ var useProfitAndLoss = ({
|
|
|
4216
4275
|
})
|
|
4217
4276
|
);
|
|
4218
4277
|
const { data, error } = rawData || {};
|
|
4219
|
-
const { filteredData, filteredTotal } = (0,
|
|
4278
|
+
const { filteredData, filteredTotal } = (0, import_react48.useMemo)(() => {
|
|
4220
4279
|
if (!data) {
|
|
4221
4280
|
return { filteredData: [], filteredTotal: void 0 };
|
|
4222
4281
|
}
|
|
@@ -4301,7 +4360,7 @@ var useProfitAndLoss = ({
|
|
|
4301
4360
|
};
|
|
4302
4361
|
|
|
4303
4362
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
4304
|
-
var
|
|
4363
|
+
var import_react50 = __toESM(require("react"));
|
|
4305
4364
|
|
|
4306
4365
|
// src/utils/format.ts
|
|
4307
4366
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
@@ -4339,7 +4398,7 @@ var formatPercent = (value, options) => {
|
|
|
4339
4398
|
};
|
|
4340
4399
|
|
|
4341
4400
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
4342
|
-
var
|
|
4401
|
+
var import_react49 = __toESM(require("react"));
|
|
4343
4402
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
4344
4403
|
var Indicator = ({
|
|
4345
4404
|
viewBox = {},
|
|
@@ -4351,25 +4410,26 @@ var Indicator = ({
|
|
|
4351
4410
|
return null;
|
|
4352
4411
|
}
|
|
4353
4412
|
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
4354
|
-
const
|
|
4355
|
-
const
|
|
4413
|
+
const margin = width > 12 ? 4 : 1;
|
|
4414
|
+
const boxWidth = width * 2 + margin;
|
|
4415
|
+
const multiplier = width > 12 ? 1.2 : 1;
|
|
4356
4416
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
4357
|
-
|
|
4417
|
+
const borderRadius = width > 16 ? 8 : width / 2;
|
|
4418
|
+
(0, import_react49.useEffect)(() => {
|
|
4358
4419
|
setAnimateFrom(animateTo);
|
|
4359
4420
|
}, [animateTo]);
|
|
4360
4421
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
4361
|
-
return /* @__PURE__ */
|
|
4422
|
+
return /* @__PURE__ */ import_react49.default.createElement(
|
|
4362
4423
|
"rect",
|
|
4363
4424
|
{
|
|
4364
4425
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
4365
|
-
rx:
|
|
4366
|
-
ry:
|
|
4426
|
+
rx: borderRadius,
|
|
4427
|
+
ry: borderRadius,
|
|
4367
4428
|
style: {
|
|
4368
4429
|
width: `${boxWidth * multiplier}px`,
|
|
4369
4430
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
4370
4431
|
x: actualX - xOffset,
|
|
4371
4432
|
y: 22,
|
|
4372
|
-
borderRadius: 8,
|
|
4373
4433
|
height: "calc(100% - 38px)"
|
|
4374
4434
|
}
|
|
4375
4435
|
}
|
|
@@ -4383,7 +4443,7 @@ var barGap = 4;
|
|
|
4383
4443
|
var barSize = 20;
|
|
4384
4444
|
var ProfitAndLossChart = () => {
|
|
4385
4445
|
const { getColor } = useLayerContext();
|
|
4386
|
-
const { changeDateRange, dateRange } = (0,
|
|
4446
|
+
const { changeDateRange, dateRange } = (0, import_react50.useContext)(ProfitAndLoss.Context);
|
|
4387
4447
|
const thisMonth = (0, import_date_fns11.startOfMonth)(Date.now());
|
|
4388
4448
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
4389
4449
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
@@ -4465,6 +4525,7 @@ var ProfitAndLossChart = () => {
|
|
|
4465
4525
|
name: getMonthName(pnl),
|
|
4466
4526
|
revenue: pnl?.income.value || 0,
|
|
4467
4527
|
expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
|
|
4528
|
+
netProfit: pnl?.net_profit || 0,
|
|
4468
4529
|
selected: !!pnl && (0, import_date_fns11.parseISO)(pnl.start_date).getMonth() >= startSelectionMonth && (0, import_date_fns11.parseISO)(pnl.end_date).getMonth() <= endSelectionMonth
|
|
4469
4530
|
});
|
|
4470
4531
|
const onClick = ({ activeTooltipIndex }) => {
|
|
@@ -4483,27 +4544,29 @@ var ProfitAndLossChart = () => {
|
|
|
4483
4544
|
label
|
|
4484
4545
|
}) => {
|
|
4485
4546
|
if (active && payload && payload.length) {
|
|
4486
|
-
|
|
4547
|
+
const netProfit = payload[0].payload.netProfit ?? 0;
|
|
4548
|
+
const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
|
|
4549
|
+
return /* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ import_react50.default.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ import_react50.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ import_react50.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ import_react50.default.createElement("span", { className: `Layer__chart__tooltip-value ${netProfitClass}` }, "$", centsToDollars(netProfit)))));
|
|
4487
4550
|
}
|
|
4488
4551
|
return null;
|
|
4489
4552
|
};
|
|
4490
4553
|
const CustomizedCursor = (props) => {
|
|
4491
|
-
const { x,
|
|
4492
|
-
return /* @__PURE__ */
|
|
4554
|
+
const { x, width, height } = props;
|
|
4555
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
4493
4556
|
import_recharts.Rectangle,
|
|
4494
4557
|
{
|
|
4495
|
-
fill: getColor(
|
|
4558
|
+
fill: getColor(900)?.hex ?? "#333",
|
|
4496
4559
|
stroke: "none",
|
|
4497
|
-
x,
|
|
4498
|
-
y,
|
|
4499
|
-
radius:
|
|
4500
|
-
width,
|
|
4501
|
-
height:
|
|
4560
|
+
x: x + width / 2 - 11,
|
|
4561
|
+
y: height + 44,
|
|
4562
|
+
radius: 2,
|
|
4563
|
+
width: 22,
|
|
4564
|
+
height: 2,
|
|
4502
4565
|
className: "Layer__chart__tooltip-cursor"
|
|
4503
4566
|
}
|
|
4504
4567
|
);
|
|
4505
4568
|
};
|
|
4506
|
-
const data = (0,
|
|
4569
|
+
const data = (0, import_react50.useMemo)(
|
|
4507
4570
|
() => monthData.map(summarizePnL),
|
|
4508
4571
|
[
|
|
4509
4572
|
startSelectionMonth,
|
|
@@ -4511,8 +4574,8 @@ var ProfitAndLossChart = () => {
|
|
|
4511
4574
|
...monthData.map((m) => m?.net_profit)
|
|
4512
4575
|
]
|
|
4513
4576
|
);
|
|
4514
|
-
const [animateFrom, setAnimateFrom] = (0,
|
|
4515
|
-
return /* @__PURE__ */
|
|
4577
|
+
const [animateFrom, setAnimateFrom] = (0, import_react50.useState)(-1);
|
|
4578
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
4516
4579
|
import_recharts.ResponsiveContainer,
|
|
4517
4580
|
{
|
|
4518
4581
|
className: "Layer__chart-container",
|
|
@@ -4520,7 +4583,7 @@ var ProfitAndLossChart = () => {
|
|
|
4520
4583
|
height: "100%",
|
|
4521
4584
|
minHeight: 200
|
|
4522
4585
|
},
|
|
4523
|
-
/* @__PURE__ */
|
|
4586
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4524
4587
|
import_recharts.BarChart,
|
|
4525
4588
|
{
|
|
4526
4589
|
margin: { left: 12, right: 12, bottom: 12 },
|
|
@@ -4529,17 +4592,17 @@ var ProfitAndLossChart = () => {
|
|
|
4529
4592
|
barGap,
|
|
4530
4593
|
className: "Layer__profit-and-loss-chart"
|
|
4531
4594
|
},
|
|
4532
|
-
/* @__PURE__ */
|
|
4595
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4533
4596
|
import_recharts.Tooltip,
|
|
4534
4597
|
{
|
|
4535
4598
|
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
4536
|
-
content: /* @__PURE__ */
|
|
4537
|
-
cursor: /* @__PURE__ */
|
|
4599
|
+
content: /* @__PURE__ */ import_react50.default.createElement(CustomTooltip, null),
|
|
4600
|
+
cursor: /* @__PURE__ */ import_react50.default.createElement(CustomizedCursor, null),
|
|
4538
4601
|
animationDuration: 100,
|
|
4539
4602
|
animationEasing: "ease-out"
|
|
4540
4603
|
}
|
|
4541
4604
|
),
|
|
4542
|
-
/* @__PURE__ */
|
|
4605
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4543
4606
|
import_recharts.CartesianGrid,
|
|
4544
4607
|
{
|
|
4545
4608
|
vertical: false,
|
|
@@ -4547,7 +4610,7 @@ var ProfitAndLossChart = () => {
|
|
|
4547
4610
|
strokeDasharray: "5 5"
|
|
4548
4611
|
}
|
|
4549
4612
|
),
|
|
4550
|
-
/* @__PURE__ */
|
|
4613
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4551
4614
|
import_recharts.Legend,
|
|
4552
4615
|
{
|
|
4553
4616
|
verticalAlign: "top",
|
|
@@ -4555,7 +4618,7 @@ var ProfitAndLossChart = () => {
|
|
|
4555
4618
|
wrapperStyle: { top: -24 },
|
|
4556
4619
|
payload: [
|
|
4557
4620
|
{
|
|
4558
|
-
value: "
|
|
4621
|
+
value: "Revenue",
|
|
4559
4622
|
type: "circle",
|
|
4560
4623
|
id: "IncomeLegend"
|
|
4561
4624
|
},
|
|
@@ -4567,20 +4630,20 @@ var ProfitAndLossChart = () => {
|
|
|
4567
4630
|
]
|
|
4568
4631
|
}
|
|
4569
4632
|
),
|
|
4570
|
-
/* @__PURE__ */
|
|
4571
|
-
/* @__PURE__ */
|
|
4633
|
+
/* @__PURE__ */ import_react50.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
4634
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4572
4635
|
import_recharts.Bar,
|
|
4573
4636
|
{
|
|
4574
4637
|
dataKey: "revenue",
|
|
4575
4638
|
barSize,
|
|
4576
4639
|
isAnimationActive: false,
|
|
4577
|
-
radius: [
|
|
4640
|
+
radius: [2, 2, 0, 0],
|
|
4578
4641
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
4579
4642
|
},
|
|
4580
|
-
/* @__PURE__ */
|
|
4643
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4581
4644
|
import_recharts.LabelList,
|
|
4582
4645
|
{
|
|
4583
|
-
content: /* @__PURE__ */
|
|
4646
|
+
content: /* @__PURE__ */ import_react50.default.createElement(
|
|
4584
4647
|
Indicator,
|
|
4585
4648
|
{
|
|
4586
4649
|
animateFrom,
|
|
@@ -4589,7 +4652,7 @@ var ProfitAndLossChart = () => {
|
|
|
4589
4652
|
)
|
|
4590
4653
|
}
|
|
4591
4654
|
),
|
|
4592
|
-
data.map((entry) => /* @__PURE__ */
|
|
4655
|
+
data.map((entry) => /* @__PURE__ */ import_react50.default.createElement(
|
|
4593
4656
|
import_recharts.Cell,
|
|
4594
4657
|
{
|
|
4595
4658
|
key: entry.name,
|
|
@@ -4597,16 +4660,16 @@ var ProfitAndLossChart = () => {
|
|
|
4597
4660
|
}
|
|
4598
4661
|
))
|
|
4599
4662
|
),
|
|
4600
|
-
/* @__PURE__ */
|
|
4663
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4601
4664
|
import_recharts.Bar,
|
|
4602
4665
|
{
|
|
4603
4666
|
dataKey: "expenses",
|
|
4604
4667
|
barSize,
|
|
4605
4668
|
isAnimationActive: false,
|
|
4606
|
-
radius: [
|
|
4669
|
+
radius: [2, 2, 0, 0],
|
|
4607
4670
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
4608
4671
|
},
|
|
4609
|
-
data.map((entry) => /* @__PURE__ */
|
|
4672
|
+
data.map((entry) => /* @__PURE__ */ import_react50.default.createElement(
|
|
4610
4673
|
import_recharts.Cell,
|
|
4611
4674
|
{
|
|
4612
4675
|
key: entry.name,
|
|
@@ -4619,10 +4682,10 @@ var ProfitAndLossChart = () => {
|
|
|
4619
4682
|
};
|
|
4620
4683
|
|
|
4621
4684
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
4622
|
-
var
|
|
4685
|
+
var import_react51 = __toESM(require("react"));
|
|
4623
4686
|
var import_date_fns12 = require("date-fns");
|
|
4624
4687
|
var ProfitAndLossDatePicker = () => {
|
|
4625
|
-
const { changeDateRange, dateRange } = (0,
|
|
4688
|
+
const { changeDateRange, dateRange } = (0, import_react51.useContext)(ProfitAndLoss.Context);
|
|
4626
4689
|
const date = dateRange.startDate;
|
|
4627
4690
|
const label = (0, import_date_fns12.format)(date, "LLLL y");
|
|
4628
4691
|
const change = (duration) => {
|
|
@@ -4634,42 +4697,42 @@ var ProfitAndLossDatePicker = () => {
|
|
|
4634
4697
|
};
|
|
4635
4698
|
const previousMonth = () => change({ months: -1 });
|
|
4636
4699
|
const nextMonth = () => change({ months: 1 });
|
|
4637
|
-
return /* @__PURE__ */
|
|
4700
|
+
return /* @__PURE__ */ import_react51.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react51.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react51.default.createElement(
|
|
4638
4701
|
"button",
|
|
4639
4702
|
{
|
|
4640
4703
|
"aria-label": "View Previous Month",
|
|
4641
4704
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
4642
4705
|
onClick: previousMonth
|
|
4643
4706
|
},
|
|
4644
|
-
/* @__PURE__ */
|
|
4707
|
+
/* @__PURE__ */ import_react51.default.createElement(
|
|
4645
4708
|
ChevronLeft_default,
|
|
4646
4709
|
{
|
|
4647
4710
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
4648
|
-
size:
|
|
4711
|
+
size: 16
|
|
4649
4712
|
}
|
|
4650
4713
|
)
|
|
4651
|
-
), /* @__PURE__ */
|
|
4714
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
4652
4715
|
"button",
|
|
4653
4716
|
{
|
|
4654
4717
|
"aria-label": "View Next Month",
|
|
4655
4718
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
4656
4719
|
onClick: nextMonth
|
|
4657
4720
|
},
|
|
4658
|
-
/* @__PURE__ */
|
|
4721
|
+
/* @__PURE__ */ import_react51.default.createElement(
|
|
4659
4722
|
ChevronRight_default,
|
|
4660
4723
|
{
|
|
4661
4724
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
4662
|
-
size:
|
|
4725
|
+
size: 16
|
|
4663
4726
|
}
|
|
4664
4727
|
)
|
|
4665
4728
|
));
|
|
4666
4729
|
};
|
|
4667
4730
|
|
|
4668
4731
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
4669
|
-
var
|
|
4732
|
+
var import_react54 = __toESM(require("react"));
|
|
4670
4733
|
|
|
4671
4734
|
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
4672
|
-
var
|
|
4735
|
+
var import_react52 = __toESM(require("react"));
|
|
4673
4736
|
var import_classnames22 = __toESM(require("classnames"));
|
|
4674
4737
|
var SkeletonLoader = ({
|
|
4675
4738
|
height,
|
|
@@ -4680,11 +4743,161 @@ var SkeletonLoader = ({
|
|
|
4680
4743
|
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
4681
4744
|
className
|
|
4682
4745
|
);
|
|
4683
|
-
return /* @__PURE__ */
|
|
4746
|
+
return /* @__PURE__ */ import_react52.default.createElement("div", { className: baseClassName, style: { width, height } });
|
|
4747
|
+
};
|
|
4748
|
+
|
|
4749
|
+
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
4750
|
+
var import_react53 = __toESM(require("react"));
|
|
4751
|
+
|
|
4752
|
+
// src/config/charts.ts
|
|
4753
|
+
var INACTIVE_OPACITY_LEVELS = [
|
|
4754
|
+
0.85,
|
|
4755
|
+
0.7,
|
|
4756
|
+
0.66,
|
|
4757
|
+
0.55,
|
|
4758
|
+
0.4,
|
|
4759
|
+
0.33,
|
|
4760
|
+
0.25,
|
|
4761
|
+
0.15
|
|
4762
|
+
];
|
|
4763
|
+
var DEFAULT_CHART_COLORS = [
|
|
4764
|
+
{
|
|
4765
|
+
color: "#7417B3",
|
|
4766
|
+
opacity: 1
|
|
4767
|
+
},
|
|
4768
|
+
{
|
|
4769
|
+
color: "#7417B3",
|
|
4770
|
+
opacity: 0.8
|
|
4771
|
+
},
|
|
4772
|
+
{
|
|
4773
|
+
color: "#7417B3",
|
|
4774
|
+
opacity: 0.6
|
|
4775
|
+
},
|
|
4776
|
+
{
|
|
4777
|
+
color: "#7417B3",
|
|
4778
|
+
opacity: 0.4
|
|
4779
|
+
},
|
|
4780
|
+
{
|
|
4781
|
+
color: "#7417B3",
|
|
4782
|
+
opacity: 0.2
|
|
4783
|
+
},
|
|
4784
|
+
{
|
|
4785
|
+
color: "#7417B3",
|
|
4786
|
+
opacity: 0.1
|
|
4787
|
+
},
|
|
4788
|
+
{
|
|
4789
|
+
color: "#006A80",
|
|
4790
|
+
opacity: 1
|
|
4791
|
+
},
|
|
4792
|
+
{
|
|
4793
|
+
color: "#006A80",
|
|
4794
|
+
opacity: 0.8
|
|
4795
|
+
},
|
|
4796
|
+
{
|
|
4797
|
+
color: "#006A80",
|
|
4798
|
+
opacity: 0.6
|
|
4799
|
+
},
|
|
4800
|
+
{
|
|
4801
|
+
color: "#006A80",
|
|
4802
|
+
opacity: 0.4
|
|
4803
|
+
},
|
|
4804
|
+
{
|
|
4805
|
+
color: "#006A80",
|
|
4806
|
+
opacity: 0.2
|
|
4807
|
+
},
|
|
4808
|
+
{
|
|
4809
|
+
color: "#006A80",
|
|
4810
|
+
opacity: 0.1
|
|
4811
|
+
},
|
|
4812
|
+
{
|
|
4813
|
+
color: "#009930",
|
|
4814
|
+
opacity: 1
|
|
4815
|
+
},
|
|
4816
|
+
{
|
|
4817
|
+
color: "#009930",
|
|
4818
|
+
opacity: 0.8
|
|
4819
|
+
},
|
|
4820
|
+
{
|
|
4821
|
+
color: "#009930",
|
|
4822
|
+
opacity: 0.6
|
|
4823
|
+
},
|
|
4824
|
+
{
|
|
4825
|
+
color: "#009930",
|
|
4826
|
+
opacity: 0.4
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
color: "#009930",
|
|
4830
|
+
opacity: 0.2
|
|
4831
|
+
},
|
|
4832
|
+
{
|
|
4833
|
+
color: "#009930",
|
|
4834
|
+
opacity: 0.1
|
|
4835
|
+
}
|
|
4836
|
+
];
|
|
4837
|
+
|
|
4838
|
+
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
4839
|
+
var import_recharts2 = require("recharts");
|
|
4840
|
+
var MiniChart = ({ data }) => {
|
|
4841
|
+
return /* @__PURE__ */ import_react53.default.createElement(import_recharts2.PieChart, { width: 48, height: 48, className: "mini-chart" }, /* @__PURE__ */ import_react53.default.createElement(
|
|
4842
|
+
import_recharts2.Pie,
|
|
4843
|
+
{
|
|
4844
|
+
data,
|
|
4845
|
+
dataKey: "value",
|
|
4846
|
+
nameKey: "name",
|
|
4847
|
+
cx: "50%",
|
|
4848
|
+
cy: "50%",
|
|
4849
|
+
innerRadius: 10,
|
|
4850
|
+
outerRadius: 16,
|
|
4851
|
+
paddingAngle: 0.2,
|
|
4852
|
+
fill: "#8884d8",
|
|
4853
|
+
width: 24,
|
|
4854
|
+
height: 24,
|
|
4855
|
+
animationDuration: 250,
|
|
4856
|
+
animationEasing: "ease-in-out"
|
|
4857
|
+
},
|
|
4858
|
+
data.map((entry, index) => {
|
|
4859
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
4860
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
4861
|
+
import_recharts2.Cell,
|
|
4862
|
+
{
|
|
4863
|
+
key: `cell-${index}`,
|
|
4864
|
+
className: `Layer__profit-and-loss-detailed-charts__pie`,
|
|
4865
|
+
fill: entry.name === "placeholder" ? "#e6e6e6" : colorConfig.color,
|
|
4866
|
+
opacity: colorConfig.opacity
|
|
4867
|
+
}
|
|
4868
|
+
);
|
|
4869
|
+
})
|
|
4870
|
+
));
|
|
4684
4871
|
};
|
|
4685
4872
|
|
|
4686
4873
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
4687
4874
|
var import_classnames23 = __toESM(require("classnames"));
|
|
4875
|
+
var CHART_PLACEHOLDER = [
|
|
4876
|
+
{
|
|
4877
|
+
name: "placeholder",
|
|
4878
|
+
display_name: "placeholder",
|
|
4879
|
+
value: 1,
|
|
4880
|
+
type: "placeholder",
|
|
4881
|
+
share: 1
|
|
4882
|
+
}
|
|
4883
|
+
];
|
|
4884
|
+
var buildMiniChartData = (scope, data) => {
|
|
4885
|
+
if (!data) {
|
|
4886
|
+
return CHART_PLACEHOLDER;
|
|
4887
|
+
}
|
|
4888
|
+
let items = [];
|
|
4889
|
+
switch (scope) {
|
|
4890
|
+
case "revenue":
|
|
4891
|
+
items = collectRevenueItems(data);
|
|
4892
|
+
break;
|
|
4893
|
+
default:
|
|
4894
|
+
items = collectExpensesItems(data);
|
|
4895
|
+
}
|
|
4896
|
+
if (!items || items.length === 0 || !items.find((x) => Math.abs(x.value) !== 0)) {
|
|
4897
|
+
return CHART_PLACEHOLDER;
|
|
4898
|
+
}
|
|
4899
|
+
return items.slice();
|
|
4900
|
+
};
|
|
4688
4901
|
var ProfitAndLossSummaries = ({
|
|
4689
4902
|
vertical,
|
|
4690
4903
|
revenueLabel = "Revenue"
|
|
@@ -4694,17 +4907,23 @@ var ProfitAndLossSummaries = ({
|
|
|
4694
4907
|
isLoading,
|
|
4695
4908
|
setSidebarScope,
|
|
4696
4909
|
sidebarScope
|
|
4697
|
-
} = (0,
|
|
4910
|
+
} = (0, import_react54.useContext)(ProfitAndLoss.Context);
|
|
4911
|
+
const expensesChartData = (0, import_react54.useMemo)(() => {
|
|
4912
|
+
return buildMiniChartData("expenses", storedData);
|
|
4913
|
+
}, [storedData]);
|
|
4914
|
+
const revenueChartData = (0, import_react54.useMemo)(() => {
|
|
4915
|
+
return buildMiniChartData("revenue", storedData);
|
|
4916
|
+
}, [storedData]);
|
|
4698
4917
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
4699
4918
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4700
4919
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4701
4920
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4702
|
-
return /* @__PURE__ */
|
|
4921
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
4703
4922
|
"div",
|
|
4704
4923
|
{
|
|
4705
4924
|
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
4706
4925
|
},
|
|
4707
|
-
/* @__PURE__ */
|
|
4926
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
4708
4927
|
"div",
|
|
4709
4928
|
{
|
|
4710
4929
|
className: (0, import_classnames23.default)(
|
|
@@ -4714,16 +4933,16 @@ var ProfitAndLossSummaries = ({
|
|
|
4714
4933
|
),
|
|
4715
4934
|
onClick: () => setSidebarScope("revenue")
|
|
4716
4935
|
},
|
|
4717
|
-
/* @__PURE__ */
|
|
4718
|
-
isLoading || storedData === void 0 ? /* @__PURE__ */
|
|
4936
|
+
/* @__PURE__ */ import_react54.default.createElement(MiniChart, { data: revenueChartData }),
|
|
4937
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, null)) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4719
4938
|
"span",
|
|
4720
4939
|
{
|
|
4721
4940
|
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
4722
4941
|
},
|
|
4723
4942
|
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
4724
|
-
)
|
|
4943
|
+
))
|
|
4725
4944
|
),
|
|
4726
|
-
/* @__PURE__ */
|
|
4945
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
4727
4946
|
"div",
|
|
4728
4947
|
{
|
|
4729
4948
|
className: (0, import_classnames23.default)(
|
|
@@ -4733,43 +4952,81 @@ var ProfitAndLossSummaries = ({
|
|
|
4733
4952
|
),
|
|
4734
4953
|
onClick: () => setSidebarScope("expenses")
|
|
4735
4954
|
},
|
|
4736
|
-
/* @__PURE__ */
|
|
4737
|
-
isLoading || storedData === void 0 ? /* @__PURE__ */
|
|
4955
|
+
/* @__PURE__ */ import_react54.default.createElement(MiniChart, { data: expensesChartData }),
|
|
4956
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4738
4957
|
"span",
|
|
4739
4958
|
{
|
|
4740
4959
|
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
4741
4960
|
},
|
|
4742
|
-
centsToDollars(
|
|
4743
|
-
|
|
4961
|
+
centsToDollars(
|
|
4962
|
+
Math.abs((data.income.value ?? 0) - data.net_profit)
|
|
4963
|
+
)
|
|
4964
|
+
))
|
|
4744
4965
|
),
|
|
4745
|
-
/* @__PURE__ */
|
|
4966
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4746
4967
|
"span",
|
|
4747
4968
|
{
|
|
4748
4969
|
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
4749
4970
|
},
|
|
4750
4971
|
centsToDollars(Math.abs(data.net_profit))
|
|
4751
|
-
))
|
|
4972
|
+
)))
|
|
4752
4973
|
);
|
|
4753
4974
|
};
|
|
4754
4975
|
|
|
4755
4976
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
4756
|
-
var
|
|
4977
|
+
var import_react56 = __toESM(require("react"));
|
|
4978
|
+
|
|
4979
|
+
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
4980
|
+
var import_react55 = __toESM(require("react"));
|
|
4981
|
+
|
|
4982
|
+
// src/icons/PieChart.tsx
|
|
4983
|
+
var React65 = __toESM(require("react"));
|
|
4984
|
+
var PieChart2 = ({ size = 12, ...props }) => /* @__PURE__ */ React65.createElement(
|
|
4985
|
+
"svg",
|
|
4986
|
+
{
|
|
4987
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4988
|
+
viewBox: "0 0 12 12",
|
|
4989
|
+
fill: "none",
|
|
4990
|
+
...props,
|
|
4991
|
+
width: size,
|
|
4992
|
+
height: size
|
|
4993
|
+
},
|
|
4994
|
+
/* @__PURE__ */ React65.createElement("g", null, /* @__PURE__ */ React65.createElement(
|
|
4995
|
+
"path",
|
|
4996
|
+
{
|
|
4997
|
+
d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
|
|
4998
|
+
stroke: "currentColor",
|
|
4999
|
+
"stroke-linecap": "round",
|
|
5000
|
+
"stroke-linejoin": "round"
|
|
5001
|
+
}
|
|
5002
|
+
), /* @__PURE__ */ React65.createElement(
|
|
5003
|
+
"path",
|
|
5004
|
+
{
|
|
5005
|
+
d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
|
|
5006
|
+
stroke: "currentColor",
|
|
5007
|
+
"stroke-linecap": "round",
|
|
5008
|
+
"stroke-linejoin": "round"
|
|
5009
|
+
}
|
|
5010
|
+
))
|
|
5011
|
+
);
|
|
5012
|
+
var PieChart_default = PieChart2;
|
|
4757
5013
|
|
|
4758
5014
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
4759
|
-
var import_react53 = __toESM(require("react"));
|
|
4760
5015
|
var ProfitAndLossRow = ({
|
|
4761
5016
|
variant,
|
|
4762
5017
|
lineItem,
|
|
4763
5018
|
depth = 0,
|
|
4764
5019
|
maxDepth = 1,
|
|
4765
5020
|
direction = "DEBIT" /* DEBIT */,
|
|
4766
|
-
lockExpanded = false
|
|
5021
|
+
lockExpanded = false,
|
|
5022
|
+
scope,
|
|
5023
|
+
setSidebarScope
|
|
4767
5024
|
}) => {
|
|
4768
5025
|
if (!lineItem) {
|
|
4769
5026
|
return null;
|
|
4770
5027
|
}
|
|
4771
5028
|
const { value, display_name, line_items } = lineItem;
|
|
4772
|
-
const [expanded, setExpanded] = (0,
|
|
5029
|
+
const [expanded, setExpanded] = (0, import_react55.useState)(true);
|
|
4773
5030
|
const amount = value ?? 0;
|
|
4774
5031
|
const amountString = centsToDollars(Math.abs(amount));
|
|
4775
5032
|
const labelClasses = [
|
|
@@ -4800,20 +5057,36 @@ var ProfitAndLossRow = ({
|
|
|
4800
5057
|
);
|
|
4801
5058
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
4802
5059
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
4803
|
-
return /* @__PURE__ */
|
|
5060
|
+
return /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement(
|
|
4804
5061
|
"div",
|
|
4805
5062
|
{
|
|
4806
5063
|
className: labelClasses.join(" "),
|
|
4807
5064
|
onClick: () => !lockExpanded && toggleExpanded()
|
|
4808
5065
|
},
|
|
4809
|
-
!lockExpanded && variant !== "summation" ? /* @__PURE__ */
|
|
4810
|
-
|
|
4811
|
-
|
|
5066
|
+
/* @__PURE__ */ import_react55.default.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ import_react55.default.createElement(
|
|
5067
|
+
ChevronDownFill_default,
|
|
5068
|
+
{
|
|
5069
|
+
size: 16,
|
|
5070
|
+
className: "Layer__profit-and-loss-row__label__chevron"
|
|
5071
|
+
}
|
|
5072
|
+
) : null, /* @__PURE__ */ import_react55.default.createElement(Text, null, display_name)),
|
|
5073
|
+
setSidebarScope && /* @__PURE__ */ import_react55.default.createElement(
|
|
5074
|
+
"span",
|
|
5075
|
+
{
|
|
5076
|
+
className: "Layer__profit-and-loss-row__detailed-chart-btn",
|
|
5077
|
+
onClick: (e) => {
|
|
5078
|
+
e.stopPropagation();
|
|
5079
|
+
setSidebarScope && setSidebarScope(scope ?? "expenses");
|
|
5080
|
+
}
|
|
5081
|
+
},
|
|
5082
|
+
/* @__PURE__ */ import_react55.default.createElement(PieChart_default, null)
|
|
5083
|
+
)
|
|
5084
|
+
), /* @__PURE__ */ import_react55.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react55.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react55.default.createElement(
|
|
4812
5085
|
"div",
|
|
4813
5086
|
{
|
|
4814
5087
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
4815
5088
|
},
|
|
4816
|
-
/* @__PURE__ */
|
|
5089
|
+
/* @__PURE__ */ import_react55.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react55.default.createElement(
|
|
4817
5090
|
ProfitAndLossRow,
|
|
4818
5091
|
{
|
|
4819
5092
|
key: line_item.display_name,
|
|
@@ -4876,26 +5149,34 @@ var empty_profit_and_loss_report_default = {
|
|
|
4876
5149
|
|
|
4877
5150
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
4878
5151
|
var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
4879
|
-
const {
|
|
5152
|
+
const {
|
|
5153
|
+
data: actualData,
|
|
5154
|
+
isLoading,
|
|
5155
|
+
setSidebarScope
|
|
5156
|
+
} = (0, import_react56.useContext)(ProfitAndLoss.Context);
|
|
4880
5157
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
4881
5158
|
if (isLoading || actualData === void 0) {
|
|
4882
|
-
return /* @__PURE__ */
|
|
5159
|
+
return /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table__loader-container" }, /* @__PURE__ */ import_react56.default.createElement(Loader2, null));
|
|
4883
5160
|
}
|
|
4884
|
-
return /* @__PURE__ */
|
|
5161
|
+
return /* @__PURE__ */ import_react56.default.createElement(import_react56.default.Fragment, null, /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table--main" }, /* @__PURE__ */ import_react56.default.createElement(
|
|
4885
5162
|
ProfitAndLossRow,
|
|
4886
5163
|
{
|
|
4887
5164
|
lineItem: data.income,
|
|
4888
5165
|
direction: "CREDIT" /* CREDIT */,
|
|
4889
|
-
lockExpanded
|
|
5166
|
+
lockExpanded,
|
|
5167
|
+
scope: "revenue",
|
|
5168
|
+
setSidebarScope
|
|
4890
5169
|
}
|
|
4891
|
-
), /* @__PURE__ */
|
|
5170
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4892
5171
|
ProfitAndLossRow,
|
|
4893
5172
|
{
|
|
4894
5173
|
lineItem: data.cost_of_goods_sold,
|
|
4895
5174
|
direction: "DEBIT" /* DEBIT */,
|
|
4896
|
-
lockExpanded
|
|
5175
|
+
lockExpanded,
|
|
5176
|
+
scope: "expenses",
|
|
5177
|
+
setSidebarScope
|
|
4897
5178
|
}
|
|
4898
|
-
), /* @__PURE__ */
|
|
5179
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4899
5180
|
ProfitAndLossRow,
|
|
4900
5181
|
{
|
|
4901
5182
|
lineItem: {
|
|
@@ -4904,16 +5185,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4904
5185
|
},
|
|
4905
5186
|
variant: "summation",
|
|
4906
5187
|
direction: "CREDIT" /* CREDIT */,
|
|
4907
|
-
lockExpanded
|
|
5188
|
+
lockExpanded,
|
|
5189
|
+
scope: "revenue",
|
|
5190
|
+
setSidebarScope
|
|
4908
5191
|
}
|
|
4909
|
-
), /* @__PURE__ */
|
|
5192
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4910
5193
|
ProfitAndLossRow,
|
|
4911
5194
|
{
|
|
4912
5195
|
lineItem: data.expenses,
|
|
4913
5196
|
direction: "DEBIT" /* DEBIT */,
|
|
4914
|
-
lockExpanded
|
|
5197
|
+
lockExpanded,
|
|
5198
|
+
scope: "expenses",
|
|
5199
|
+
setSidebarScope
|
|
4915
5200
|
}
|
|
4916
|
-
), /* @__PURE__ */
|
|
5201
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4917
5202
|
ProfitAndLossRow,
|
|
4918
5203
|
{
|
|
4919
5204
|
lineItem: {
|
|
@@ -4922,16 +5207,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4922
5207
|
},
|
|
4923
5208
|
variant: "summation",
|
|
4924
5209
|
direction: "CREDIT" /* CREDIT */,
|
|
4925
|
-
lockExpanded
|
|
5210
|
+
lockExpanded,
|
|
5211
|
+
scope: "revenue",
|
|
5212
|
+
setSidebarScope
|
|
4926
5213
|
}
|
|
4927
|
-
), /* @__PURE__ */
|
|
5214
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4928
5215
|
ProfitAndLossRow,
|
|
4929
5216
|
{
|
|
4930
5217
|
lineItem: data.taxes,
|
|
4931
5218
|
direction: "DEBIT" /* DEBIT */,
|
|
4932
|
-
lockExpanded
|
|
5219
|
+
lockExpanded,
|
|
5220
|
+
scope: "expenses",
|
|
5221
|
+
setSidebarScope
|
|
4933
5222
|
}
|
|
4934
|
-
), /* @__PURE__ */
|
|
5223
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4935
5224
|
ProfitAndLossRow,
|
|
4936
5225
|
{
|
|
4937
5226
|
lineItem: {
|
|
@@ -4942,26 +5231,26 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4942
5231
|
direction: "CREDIT" /* CREDIT */,
|
|
4943
5232
|
lockExpanded
|
|
4944
5233
|
}
|
|
4945
|
-
)), /* @__PURE__ */
|
|
5234
|
+
)), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react56.default.createElement(
|
|
4946
5235
|
ProfitAndLossRow,
|
|
4947
5236
|
{
|
|
4948
5237
|
lineItem: data.other_outflows,
|
|
4949
5238
|
direction: "DEBIT" /* DEBIT */,
|
|
4950
5239
|
lockExpanded
|
|
4951
5240
|
}
|
|
4952
|
-
), /* @__PURE__ */
|
|
5241
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4953
5242
|
ProfitAndLossRow,
|
|
4954
5243
|
{
|
|
4955
5244
|
lineItem: data.personal_expenses,
|
|
4956
5245
|
direction: "DEBIT" /* DEBIT */,
|
|
4957
5246
|
lockExpanded
|
|
4958
5247
|
}
|
|
4959
|
-
)));
|
|
5248
|
+
)) : null);
|
|
4960
5249
|
};
|
|
4961
5250
|
|
|
4962
5251
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4963
5252
|
var import_date_fns13 = require("date-fns");
|
|
4964
|
-
var PNLContext = (0,
|
|
5253
|
+
var PNLContext = (0, import_react57.createContext)({
|
|
4965
5254
|
data: void 0,
|
|
4966
5255
|
filteredData: [],
|
|
4967
5256
|
filteredTotal: void 0,
|
|
@@ -4990,7 +5279,7 @@ var PNLContext = (0, import_react55.createContext)({
|
|
|
4990
5279
|
});
|
|
4991
5280
|
var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
|
|
4992
5281
|
const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
|
|
4993
|
-
return /* @__PURE__ */
|
|
5282
|
+
return /* @__PURE__ */ import_react57.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react57.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
|
|
4994
5283
|
};
|
|
4995
5284
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
4996
5285
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -4999,15 +5288,218 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
|
4999
5288
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
5000
5289
|
|
|
5001
5290
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
5002
|
-
var
|
|
5291
|
+
var import_react62 = __toESM(require("react"));
|
|
5003
5292
|
|
|
5004
5293
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5005
|
-
var
|
|
5006
|
-
|
|
5294
|
+
var import_react61 = __toESM(require("react"));
|
|
5295
|
+
|
|
5296
|
+
// src/icons/X.tsx
|
|
5297
|
+
var React69 = __toESM(require("react"));
|
|
5298
|
+
var X = ({ size = 18, ...props }) => /* @__PURE__ */ React69.createElement(
|
|
5299
|
+
"svg",
|
|
5300
|
+
{
|
|
5301
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5302
|
+
viewBox: "0 0 18 18",
|
|
5303
|
+
fill: "none",
|
|
5304
|
+
...props,
|
|
5305
|
+
width: size,
|
|
5306
|
+
height: size
|
|
5307
|
+
},
|
|
5308
|
+
/* @__PURE__ */ React69.createElement(
|
|
5309
|
+
"path",
|
|
5310
|
+
{
|
|
5311
|
+
d: "M13.5 4.5L4.5 13.5",
|
|
5312
|
+
stroke: "currentColor",
|
|
5313
|
+
strokeLinecap: "round",
|
|
5314
|
+
strokeLinejoin: "round"
|
|
5315
|
+
}
|
|
5316
|
+
),
|
|
5317
|
+
/* @__PURE__ */ React69.createElement(
|
|
5318
|
+
"path",
|
|
5319
|
+
{
|
|
5320
|
+
d: "M4.5 4.5L13.5 13.5",
|
|
5321
|
+
stroke: "currentColor",
|
|
5322
|
+
strokeLinecap: "round",
|
|
5323
|
+
strokeLinejoin: "round"
|
|
5324
|
+
}
|
|
5325
|
+
)
|
|
5326
|
+
);
|
|
5327
|
+
var X_default = X;
|
|
5328
|
+
|
|
5329
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5330
|
+
var import_react58 = __toESM(require("react"));
|
|
5331
|
+
var import_recharts3 = require("recharts");
|
|
5332
|
+
var DetailedChart = ({
|
|
5333
|
+
filteredData,
|
|
5334
|
+
filteredTotal,
|
|
5335
|
+
hoveredItem,
|
|
5336
|
+
setHoveredItem,
|
|
5337
|
+
sidebarScope,
|
|
5338
|
+
date
|
|
5339
|
+
}) => {
|
|
5340
|
+
const chartData = (0, import_react58.useMemo)(() => {
|
|
5341
|
+
if (!filteredData) {
|
|
5342
|
+
return [];
|
|
5343
|
+
}
|
|
5344
|
+
return filteredData.map((x) => {
|
|
5345
|
+
if (x.hidden) {
|
|
5346
|
+
return {
|
|
5347
|
+
name: x.display_name,
|
|
5348
|
+
value: 0
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
return {
|
|
5352
|
+
name: x.display_name,
|
|
5353
|
+
value: x.value
|
|
5354
|
+
};
|
|
5355
|
+
});
|
|
5356
|
+
}, [filteredData]);
|
|
5357
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react58.default.createElement("div", { className: "header--tablet" }, /* @__PURE__ */ import_react58.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react58.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react58.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react58.default.createElement(import_recharts3.ResponsiveContainer, null, /* @__PURE__ */ import_react58.default.createElement(import_recharts3.PieChart, null, /* @__PURE__ */ import_react58.default.createElement(
|
|
5358
|
+
import_recharts3.Pie,
|
|
5359
|
+
{
|
|
5360
|
+
data: chartData,
|
|
5361
|
+
dataKey: "value",
|
|
5362
|
+
nameKey: "name",
|
|
5363
|
+
cx: "50%",
|
|
5364
|
+
cy: "50%",
|
|
5365
|
+
innerRadius: 105,
|
|
5366
|
+
outerRadius: 120,
|
|
5367
|
+
paddingAngle: 0.5,
|
|
5368
|
+
fill: "#8884d8",
|
|
5369
|
+
animationDuration: 200,
|
|
5370
|
+
animationEasing: "ease-in-out"
|
|
5371
|
+
},
|
|
5372
|
+
chartData.map((entry, index) => {
|
|
5373
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
5374
|
+
let fill = colorConfig.color;
|
|
5375
|
+
let opacity = colorConfig.opacity;
|
|
5376
|
+
let active = true;
|
|
5377
|
+
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5378
|
+
active = false;
|
|
5379
|
+
fill = void 0;
|
|
5380
|
+
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5381
|
+
}
|
|
5382
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5383
|
+
import_recharts3.Cell,
|
|
5384
|
+
{
|
|
5385
|
+
key: `cell-${index}`,
|
|
5386
|
+
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5387
|
+
style: { fill },
|
|
5388
|
+
opacity,
|
|
5389
|
+
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5390
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5391
|
+
}
|
|
5392
|
+
);
|
|
5393
|
+
}),
|
|
5394
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5395
|
+
import_recharts3.Label,
|
|
5396
|
+
{
|
|
5397
|
+
position: "center",
|
|
5398
|
+
value: "Total",
|
|
5399
|
+
className: "pie-center-label-title",
|
|
5400
|
+
content: (props) => {
|
|
5401
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5402
|
+
cx: 0,
|
|
5403
|
+
cy: 0
|
|
5404
|
+
};
|
|
5405
|
+
const positioningProps = {
|
|
5406
|
+
x: cx,
|
|
5407
|
+
y: (cy || 0) - 15,
|
|
5408
|
+
textAnchor: "middle",
|
|
5409
|
+
verticalAnchor: "middle"
|
|
5410
|
+
};
|
|
5411
|
+
let text = "Total";
|
|
5412
|
+
if (hoveredItem) {
|
|
5413
|
+
text = hoveredItem;
|
|
5414
|
+
}
|
|
5415
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5416
|
+
import_recharts3.Text,
|
|
5417
|
+
{
|
|
5418
|
+
...positioningProps,
|
|
5419
|
+
className: "pie-center-label__title"
|
|
5420
|
+
},
|
|
5421
|
+
text
|
|
5422
|
+
);
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
),
|
|
5426
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5427
|
+
import_recharts3.Label,
|
|
5428
|
+
{
|
|
5429
|
+
position: "center",
|
|
5430
|
+
value: "Total",
|
|
5431
|
+
className: "pie-center-label-title",
|
|
5432
|
+
content: (props) => {
|
|
5433
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5434
|
+
cx: 0,
|
|
5435
|
+
cy: 0
|
|
5436
|
+
};
|
|
5437
|
+
const positioningProps = {
|
|
5438
|
+
x: cx,
|
|
5439
|
+
y: (cy || 0) + 5,
|
|
5440
|
+
textAnchor: "middle",
|
|
5441
|
+
verticalAnchor: "middle"
|
|
5442
|
+
};
|
|
5443
|
+
let value = filteredTotal;
|
|
5444
|
+
if (hoveredItem) {
|
|
5445
|
+
value = filteredData.find(
|
|
5446
|
+
(x) => x.display_name === hoveredItem
|
|
5447
|
+
)?.value;
|
|
5448
|
+
}
|
|
5449
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5450
|
+
import_recharts3.Text,
|
|
5451
|
+
{
|
|
5452
|
+
...positioningProps,
|
|
5453
|
+
className: "pie-center-label__value"
|
|
5454
|
+
},
|
|
5455
|
+
`$${centsToDollars(value)}`
|
|
5456
|
+
);
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
),
|
|
5460
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5461
|
+
import_recharts3.Label,
|
|
5462
|
+
{
|
|
5463
|
+
position: "center",
|
|
5464
|
+
value: "Total",
|
|
5465
|
+
className: "pie-center-label-title",
|
|
5466
|
+
content: (props) => {
|
|
5467
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5468
|
+
cx: 0,
|
|
5469
|
+
cy: 0
|
|
5470
|
+
};
|
|
5471
|
+
const positioningProps = {
|
|
5472
|
+
x: cx,
|
|
5473
|
+
y: (cy || 0) + 25,
|
|
5474
|
+
height: 20,
|
|
5475
|
+
textAnchor: "middle",
|
|
5476
|
+
verticalAnchor: "middle"
|
|
5477
|
+
};
|
|
5478
|
+
if (hoveredItem) {
|
|
5479
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5480
|
+
import_recharts3.Text,
|
|
5481
|
+
{
|
|
5482
|
+
...positioningProps,
|
|
5483
|
+
className: "pie-center-label__share"
|
|
5484
|
+
},
|
|
5485
|
+
`${formatPercent(
|
|
5486
|
+
filteredData.find((x) => x.display_name === hoveredItem)?.share
|
|
5487
|
+
)}%`
|
|
5488
|
+
);
|
|
5489
|
+
}
|
|
5490
|
+
return;
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
)
|
|
5494
|
+
)))));
|
|
5495
|
+
};
|
|
5496
|
+
|
|
5497
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
5498
|
+
var import_react59 = __toESM(require("react"));
|
|
5007
5499
|
|
|
5008
5500
|
// src/icons/SortArrows.tsx
|
|
5009
|
-
var
|
|
5010
|
-
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */
|
|
5501
|
+
var React71 = __toESM(require("react"));
|
|
5502
|
+
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React71.createElement(
|
|
5011
5503
|
"svg",
|
|
5012
5504
|
{
|
|
5013
5505
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -5017,7 +5509,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5017
5509
|
width: size,
|
|
5018
5510
|
height: size
|
|
5019
5511
|
},
|
|
5020
|
-
/* @__PURE__ */
|
|
5512
|
+
/* @__PURE__ */ React71.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React71.createElement(
|
|
5021
5513
|
"path",
|
|
5022
5514
|
{
|
|
5023
5515
|
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
@@ -5026,7 +5518,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5026
5518
|
"stroke-linejoin": "round",
|
|
5027
5519
|
className: "desc-arrow"
|
|
5028
5520
|
}
|
|
5029
|
-
), /* @__PURE__ */
|
|
5521
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5030
5522
|
"path",
|
|
5031
5523
|
{
|
|
5032
5524
|
d: "M4 2.5L4 11.1667",
|
|
@@ -5035,7 +5527,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5035
5527
|
"stroke-linejoin": "round",
|
|
5036
5528
|
className: "desc-arrow"
|
|
5037
5529
|
}
|
|
5038
|
-
), /* @__PURE__ */
|
|
5530
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5039
5531
|
"path",
|
|
5040
5532
|
{
|
|
5041
5533
|
d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
|
|
@@ -5044,7 +5536,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5044
5536
|
"stroke-linejoin": "round",
|
|
5045
5537
|
className: "asc-arrow"
|
|
5046
5538
|
}
|
|
5047
|
-
), /* @__PURE__ */
|
|
5539
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5048
5540
|
"path",
|
|
5049
5541
|
{
|
|
5050
5542
|
d: "M8.66663 11.166L8.66663 2.49935",
|
|
@@ -5054,7 +5546,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5054
5546
|
className: "asc-arrow"
|
|
5055
5547
|
}
|
|
5056
5548
|
)),
|
|
5057
|
-
/* @__PURE__ */
|
|
5549
|
+
/* @__PURE__ */ React71.createElement("defs", null, /* @__PURE__ */ React71.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React71.createElement(
|
|
5058
5550
|
"rect",
|
|
5059
5551
|
{
|
|
5060
5552
|
width: "12",
|
|
@@ -5066,121 +5558,119 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5066
5558
|
);
|
|
5067
5559
|
var SortArrows_default = SortArrows;
|
|
5068
5560
|
|
|
5069
|
-
// src/
|
|
5070
|
-
var
|
|
5071
|
-
var
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5561
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
5562
|
+
var import_classnames24 = __toESM(require("classnames"));
|
|
5563
|
+
var DetailedTable = ({
|
|
5564
|
+
filteredData,
|
|
5565
|
+
sidebarScope,
|
|
5566
|
+
filters,
|
|
5567
|
+
sortBy,
|
|
5568
|
+
hoveredItem,
|
|
5569
|
+
setHoveredItem
|
|
5570
|
+
}) => {
|
|
5571
|
+
const buildColClass = (column) => {
|
|
5572
|
+
return (0, import_classnames24.default)(
|
|
5573
|
+
"Layer__sortable-col",
|
|
5574
|
+
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
5575
|
+
);
|
|
5576
|
+
};
|
|
5577
|
+
return /* @__PURE__ */ import_react59.default.createElement("div", { className: "details-container" }, /* @__PURE__ */ import_react59.default.createElement("div", { className: "table" }, /* @__PURE__ */ import_react59.default.createElement("table", null, /* @__PURE__ */ import_react59.default.createElement("thead", null, /* @__PURE__ */ import_react59.default.createElement("tr", null, /* @__PURE__ */ import_react59.default.createElement(
|
|
5578
|
+
"th",
|
|
5083
5579
|
{
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
}
|
|
5089
|
-
),
|
|
5090
|
-
|
|
5091
|
-
"path",
|
|
5580
|
+
className: buildColClass("category"),
|
|
5581
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
5582
|
+
},
|
|
5583
|
+
"Expense/Sale ",
|
|
5584
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5585
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
5586
|
+
"th",
|
|
5092
5587
|
{
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5588
|
+
className: buildColClass("type"),
|
|
5589
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5590
|
+
},
|
|
5591
|
+
"Type ",
|
|
5592
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5593
|
+
), /* @__PURE__ */ import_react59.default.createElement("th", null), /* @__PURE__ */ import_react59.default.createElement(
|
|
5594
|
+
"th",
|
|
5595
|
+
{
|
|
5596
|
+
className: buildColClass("value"),
|
|
5597
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
5598
|
+
},
|
|
5599
|
+
"Value ",
|
|
5600
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5601
|
+
))), /* @__PURE__ */ import_react59.default.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
5602
|
+
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
5603
|
+
return /* @__PURE__ */ import_react59.default.createElement(
|
|
5604
|
+
"tr",
|
|
5605
|
+
{
|
|
5606
|
+
key: `pl-side-table-item-${idx}`,
|
|
5607
|
+
className: (0, import_classnames24.default)(
|
|
5608
|
+
"Layer__profit-and-loss-detailed-table__row",
|
|
5609
|
+
hoveredItem && hoveredItem === item.display_name ? "active" : ""
|
|
5610
|
+
),
|
|
5611
|
+
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
5612
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5613
|
+
},
|
|
5614
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
5615
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "type-col" }, item.type),
|
|
5616
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
5617
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react59.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react59.default.createElement(
|
|
5618
|
+
"div",
|
|
5619
|
+
{
|
|
5620
|
+
className: "share-icon",
|
|
5621
|
+
style: {
|
|
5622
|
+
background: colorConfig.color,
|
|
5623
|
+
opacity: colorConfig.opacity
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
)))
|
|
5627
|
+
);
|
|
5628
|
+
})))));
|
|
5629
|
+
};
|
|
5630
|
+
|
|
5631
|
+
// src/components/ProfitAndLossDetailedCharts/Filters.tsx
|
|
5632
|
+
var import_react60 = __toESM(require("react"));
|
|
5633
|
+
var import_react_select4 = __toESM(require("react-select"));
|
|
5634
|
+
var Filters = ({
|
|
5635
|
+
filteredData,
|
|
5636
|
+
sidebarScope,
|
|
5637
|
+
filters,
|
|
5638
|
+
setFilterTypes
|
|
5639
|
+
}) => {
|
|
5640
|
+
return /* @__PURE__ */ import_react60.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react60.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react60.default.createElement(
|
|
5641
|
+
import_react_select4.default,
|
|
5642
|
+
{
|
|
5643
|
+
className: "Layer__select type-select",
|
|
5644
|
+
classNamePrefix: "Layer__select",
|
|
5645
|
+
value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
|
|
5646
|
+
value: x,
|
|
5647
|
+
label: x
|
|
5648
|
+
})) : [],
|
|
5649
|
+
isMulti: true,
|
|
5650
|
+
isClearable: false,
|
|
5651
|
+
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
5652
|
+
label: x,
|
|
5653
|
+
value: x
|
|
5654
|
+
})),
|
|
5655
|
+
onChange: (selected) => {
|
|
5656
|
+
setFilterTypes(
|
|
5657
|
+
sidebarScope ?? "expenses",
|
|
5658
|
+
selected.map((x) => x.value)
|
|
5659
|
+
);
|
|
5660
|
+
},
|
|
5661
|
+
components: {
|
|
5662
|
+
DropdownIndicator: (props) => /* @__PURE__ */ import_react60.default.createElement(import_react_select4.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react60.default.createElement(ChevronDown_default, null)),
|
|
5663
|
+
Placeholder: (props) => /* @__PURE__ */ import_react60.default.createElement(import_react_select4.components.Placeholder, { ...props }, /* @__PURE__ */ import_react60.default.createElement("div", { className: "Layer__select__multi-all-placeholder-badge" }, "All"))
|
|
5664
|
+
}
|
|
5097
5665
|
}
|
|
5098
|
-
)
|
|
5099
|
-
|
|
5100
|
-
var X_default = X;
|
|
5666
|
+
));
|
|
5667
|
+
};
|
|
5101
5668
|
|
|
5102
5669
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5103
|
-
var
|
|
5670
|
+
var import_classnames25 = __toESM(require("classnames"));
|
|
5104
5671
|
var import_date_fns14 = require("date-fns");
|
|
5105
|
-
var import_recharts2 = require("recharts");
|
|
5106
|
-
var INACTIVE_OPACITY_LEVELS = [0.85, 0.7, 0.66, 0.55, 0.4, 0.33, 0.25, 0.15];
|
|
5107
|
-
var DEFAULT_CHART_COLORS = [
|
|
5108
|
-
{
|
|
5109
|
-
color: "#7417B3",
|
|
5110
|
-
opacity: 1
|
|
5111
|
-
},
|
|
5112
|
-
{
|
|
5113
|
-
color: "#7417B3",
|
|
5114
|
-
opacity: 0.8
|
|
5115
|
-
},
|
|
5116
|
-
{
|
|
5117
|
-
color: "#7417B3",
|
|
5118
|
-
opacity: 0.6
|
|
5119
|
-
},
|
|
5120
|
-
{
|
|
5121
|
-
color: "#7417B3",
|
|
5122
|
-
opacity: 0.4
|
|
5123
|
-
},
|
|
5124
|
-
{
|
|
5125
|
-
color: "#7417B3",
|
|
5126
|
-
opacity: 0.2
|
|
5127
|
-
},
|
|
5128
|
-
{
|
|
5129
|
-
color: "#7417B3",
|
|
5130
|
-
opacity: 0.1
|
|
5131
|
-
},
|
|
5132
|
-
{
|
|
5133
|
-
color: "#006A80",
|
|
5134
|
-
opacity: 1
|
|
5135
|
-
},
|
|
5136
|
-
{
|
|
5137
|
-
color: "#006A80",
|
|
5138
|
-
opacity: 0.8
|
|
5139
|
-
},
|
|
5140
|
-
{
|
|
5141
|
-
color: "#006A80",
|
|
5142
|
-
opacity: 0.6
|
|
5143
|
-
},
|
|
5144
|
-
{
|
|
5145
|
-
color: "#006A80",
|
|
5146
|
-
opacity: 0.4
|
|
5147
|
-
},
|
|
5148
|
-
{
|
|
5149
|
-
color: "#006A80",
|
|
5150
|
-
opacity: 0.2
|
|
5151
|
-
},
|
|
5152
|
-
{
|
|
5153
|
-
color: "#006A80",
|
|
5154
|
-
opacity: 0.1
|
|
5155
|
-
},
|
|
5156
|
-
{
|
|
5157
|
-
color: "#009930",
|
|
5158
|
-
opacity: 1
|
|
5159
|
-
},
|
|
5160
|
-
{
|
|
5161
|
-
color: "#009930",
|
|
5162
|
-
opacity: 0.8
|
|
5163
|
-
},
|
|
5164
|
-
{
|
|
5165
|
-
color: "#009930",
|
|
5166
|
-
opacity: 0.6
|
|
5167
|
-
},
|
|
5168
|
-
{
|
|
5169
|
-
color: "#009930",
|
|
5170
|
-
opacity: 0.4
|
|
5171
|
-
},
|
|
5172
|
-
{
|
|
5173
|
-
color: "#009930",
|
|
5174
|
-
opacity: 0.2
|
|
5175
|
-
},
|
|
5176
|
-
{
|
|
5177
|
-
color: "#009930",
|
|
5178
|
-
opacity: 0.1
|
|
5179
|
-
}
|
|
5180
|
-
];
|
|
5181
5672
|
var ProfitAndLossDetailedCharts = () => {
|
|
5182
5673
|
const {
|
|
5183
|
-
data,
|
|
5184
5674
|
filteredData,
|
|
5185
5675
|
filteredTotal,
|
|
5186
5676
|
sortBy,
|
|
@@ -5190,275 +5680,77 @@ var ProfitAndLossDetailedCharts = () => {
|
|
|
5190
5680
|
sidebarScope,
|
|
5191
5681
|
setSidebarScope,
|
|
5192
5682
|
setFilterTypes
|
|
5193
|
-
} = (0,
|
|
5194
|
-
const [hoveredItem, setHoveredItem] = (0,
|
|
5195
|
-
|
|
5196
|
-
if (!filteredData) {
|
|
5197
|
-
return [];
|
|
5198
|
-
}
|
|
5199
|
-
return filteredData.map((x) => {
|
|
5200
|
-
if (x.hidden) {
|
|
5201
|
-
return {
|
|
5202
|
-
name: x.display_name,
|
|
5203
|
-
value: 0
|
|
5204
|
-
};
|
|
5205
|
-
}
|
|
5206
|
-
return {
|
|
5207
|
-
name: x.display_name,
|
|
5208
|
-
value: x.value
|
|
5209
|
-
};
|
|
5210
|
-
});
|
|
5211
|
-
}, [filteredData]);
|
|
5212
|
-
const buildColClass = (column) => {
|
|
5213
|
-
return (0, import_classnames24.default)(
|
|
5214
|
-
"Layer__sortable-col",
|
|
5215
|
-
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
5216
|
-
);
|
|
5217
|
-
};
|
|
5218
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5683
|
+
} = (0, import_react61.useContext)(ProfitAndLoss.Context);
|
|
5684
|
+
const [hoveredItem, setHoveredItem] = (0, import_react61.useState)();
|
|
5685
|
+
return /* @__PURE__ */ import_react61.default.createElement(
|
|
5219
5686
|
"div",
|
|
5220
5687
|
{
|
|
5221
|
-
className: (0,
|
|
5688
|
+
className: (0, import_classnames25.default)(
|
|
5222
5689
|
"Layer__profit-and-loss__side-panel",
|
|
5223
5690
|
sidebarScope && "open"
|
|
5224
5691
|
)
|
|
5225
5692
|
},
|
|
5226
|
-
/* @__PURE__ */
|
|
5693
|
+
/* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react61.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react61.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react61.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns14.format)(dateRange.startDate, "LLLL, y")), /* @__PURE__ */ import_react61.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react61.default.createElement(
|
|
5227
5694
|
Button,
|
|
5228
5695
|
{
|
|
5229
|
-
rightIcon: /* @__PURE__ */
|
|
5696
|
+
rightIcon: /* @__PURE__ */ import_react61.default.createElement(X_default, null),
|
|
5230
5697
|
iconOnly: true,
|
|
5231
5698
|
onClick: () => setSidebarScope(void 0),
|
|
5232
5699
|
variant: "secondary" /* secondary */
|
|
5233
5700
|
}
|
|
5234
|
-
)), /* @__PURE__ */
|
|
5235
|
-
|
|
5701
|
+
)), /* @__PURE__ */ import_react61.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5702
|
+
Button,
|
|
5236
5703
|
{
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
nameKey: "name",
|
|
5240
|
-
cx: "50%",
|
|
5241
|
-
cy: "50%",
|
|
5242
|
-
innerRadius: 105,
|
|
5243
|
-
outerRadius: 120,
|
|
5244
|
-
paddingAngle: 0.5,
|
|
5245
|
-
fill: "#8884d8"
|
|
5704
|
+
onClick: () => setSidebarScope(void 0),
|
|
5705
|
+
variant: "secondary" /* secondary */
|
|
5246
5706
|
},
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
let opacity = colorConfig.opacity;
|
|
5251
|
-
let active = true;
|
|
5252
|
-
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5253
|
-
active = false;
|
|
5254
|
-
fill = void 0;
|
|
5255
|
-
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5256
|
-
}
|
|
5257
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5258
|
-
import_recharts2.Cell,
|
|
5259
|
-
{
|
|
5260
|
-
key: `cell-${index}`,
|
|
5261
|
-
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5262
|
-
style: { fill },
|
|
5263
|
-
opacity,
|
|
5264
|
-
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5265
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
5266
|
-
}
|
|
5267
|
-
);
|
|
5268
|
-
}),
|
|
5269
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5270
|
-
import_recharts2.Label,
|
|
5271
|
-
{
|
|
5272
|
-
position: "center",
|
|
5273
|
-
value: "Total",
|
|
5274
|
-
className: "pie-center-label-title",
|
|
5275
|
-
content: (props) => {
|
|
5276
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5277
|
-
cx: 0,
|
|
5278
|
-
cy: 0
|
|
5279
|
-
};
|
|
5280
|
-
const positioningProps = {
|
|
5281
|
-
x: cx,
|
|
5282
|
-
y: (cy || 0) - 15,
|
|
5283
|
-
textAnchor: "middle",
|
|
5284
|
-
verticalAnchor: "middle"
|
|
5285
|
-
};
|
|
5286
|
-
let text = "Total";
|
|
5287
|
-
if (hoveredItem) {
|
|
5288
|
-
text = hoveredItem;
|
|
5289
|
-
}
|
|
5290
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5291
|
-
import_recharts2.Text,
|
|
5292
|
-
{
|
|
5293
|
-
...positioningProps,
|
|
5294
|
-
className: "pie-center-label__title"
|
|
5295
|
-
},
|
|
5296
|
-
text
|
|
5297
|
-
);
|
|
5298
|
-
}
|
|
5299
|
-
}
|
|
5300
|
-
),
|
|
5301
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5302
|
-
import_recharts2.Label,
|
|
5303
|
-
{
|
|
5304
|
-
position: "center",
|
|
5305
|
-
value: "Total",
|
|
5306
|
-
className: "pie-center-label-title",
|
|
5307
|
-
content: (props) => {
|
|
5308
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5309
|
-
cx: 0,
|
|
5310
|
-
cy: 0
|
|
5311
|
-
};
|
|
5312
|
-
const positioningProps = {
|
|
5313
|
-
x: cx,
|
|
5314
|
-
y: (cy || 0) + 5,
|
|
5315
|
-
textAnchor: "middle",
|
|
5316
|
-
verticalAnchor: "middle"
|
|
5317
|
-
};
|
|
5318
|
-
let value = filteredTotal;
|
|
5319
|
-
if (hoveredItem) {
|
|
5320
|
-
value = filteredData.find(
|
|
5321
|
-
(x) => x.display_name === hoveredItem
|
|
5322
|
-
)?.value;
|
|
5323
|
-
}
|
|
5324
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5325
|
-
import_recharts2.Text,
|
|
5326
|
-
{
|
|
5327
|
-
...positioningProps,
|
|
5328
|
-
className: "pie-center-label__value"
|
|
5329
|
-
},
|
|
5330
|
-
`$${centsToDollars(value)}`
|
|
5331
|
-
);
|
|
5332
|
-
}
|
|
5333
|
-
}
|
|
5334
|
-
),
|
|
5335
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5336
|
-
import_recharts2.Label,
|
|
5337
|
-
{
|
|
5338
|
-
position: "center",
|
|
5339
|
-
value: "Total",
|
|
5340
|
-
className: "pie-center-label-title",
|
|
5341
|
-
content: (props) => {
|
|
5342
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5343
|
-
cx: 0,
|
|
5344
|
-
cy: 0
|
|
5345
|
-
};
|
|
5346
|
-
const positioningProps = {
|
|
5347
|
-
x: cx,
|
|
5348
|
-
y: (cy || 0) + 25,
|
|
5349
|
-
height: 20,
|
|
5350
|
-
textAnchor: "middle",
|
|
5351
|
-
verticalAnchor: "middle"
|
|
5352
|
-
};
|
|
5353
|
-
if (hoveredItem) {
|
|
5354
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5355
|
-
import_recharts2.Text,
|
|
5356
|
-
{
|
|
5357
|
-
...positioningProps,
|
|
5358
|
-
className: "pie-center-label__share"
|
|
5359
|
-
},
|
|
5360
|
-
`${formatPercent(
|
|
5361
|
-
filteredData.find(
|
|
5362
|
-
(x) => x.display_name === hoveredItem
|
|
5363
|
-
)?.share
|
|
5364
|
-
)}%`
|
|
5365
|
-
);
|
|
5366
|
-
}
|
|
5367
|
-
return;
|
|
5368
|
-
}
|
|
5369
|
-
}
|
|
5370
|
-
)
|
|
5371
|
-
)))), /* @__PURE__ */ import_react56.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react56.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react56.default.createElement(
|
|
5372
|
-
import_react_select3.default,
|
|
5707
|
+
"Back"
|
|
5708
|
+
)), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5709
|
+
DetailedChart,
|
|
5373
5710
|
{
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
isMulti: true,
|
|
5381
|
-
isClearable: false,
|
|
5382
|
-
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
5383
|
-
label: x,
|
|
5384
|
-
value: x
|
|
5385
|
-
})),
|
|
5386
|
-
onChange: (selected) => {
|
|
5387
|
-
setFilterTypes(
|
|
5388
|
-
sidebarScope ?? "expenses",
|
|
5389
|
-
selected.map((x) => x.value)
|
|
5390
|
-
);
|
|
5391
|
-
}
|
|
5711
|
+
filteredData,
|
|
5712
|
+
filteredTotal,
|
|
5713
|
+
hoveredItem,
|
|
5714
|
+
setHoveredItem,
|
|
5715
|
+
sidebarScope,
|
|
5716
|
+
date: dateRange.startDate
|
|
5392
5717
|
}
|
|
5393
|
-
)
|
|
5394
|
-
|
|
5718
|
+
), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5719
|
+
Filters,
|
|
5395
5720
|
{
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
), /* @__PURE__ */
|
|
5402
|
-
|
|
5403
|
-
{
|
|
5404
|
-
className: buildColClass("type"),
|
|
5405
|
-
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5406
|
-
},
|
|
5407
|
-
"Type ",
|
|
5408
|
-
/* @__PURE__ */ import_react56.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5409
|
-
), /* @__PURE__ */ import_react56.default.createElement("th", null), /* @__PURE__ */ import_react56.default.createElement(
|
|
5410
|
-
"th",
|
|
5721
|
+
filteredData,
|
|
5722
|
+
sidebarScope,
|
|
5723
|
+
filters,
|
|
5724
|
+
setFilterTypes
|
|
5725
|
+
}
|
|
5726
|
+
), /* @__PURE__ */ import_react61.default.createElement(
|
|
5727
|
+
DetailedTable,
|
|
5411
5728
|
{
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
"tr",
|
|
5421
|
-
{
|
|
5422
|
-
key: `pl-side-table-item-${idx}`,
|
|
5423
|
-
className: (0, import_classnames24.default)(
|
|
5424
|
-
"Layer__profit-and-loss-detailed-table__row",
|
|
5425
|
-
hoveredItem && hoveredItem !== item.display_name ? "inactive" : ""
|
|
5426
|
-
),
|
|
5427
|
-
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
5428
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
5429
|
-
},
|
|
5430
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
5431
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "type-col" }, item.type),
|
|
5432
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
5433
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react56.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react56.default.createElement(
|
|
5434
|
-
"div",
|
|
5435
|
-
{
|
|
5436
|
-
className: "share-icon",
|
|
5437
|
-
style: {
|
|
5438
|
-
background: colorConfig.color,
|
|
5439
|
-
opacity: colorConfig.opacity
|
|
5440
|
-
}
|
|
5441
|
-
}
|
|
5442
|
-
)))
|
|
5443
|
-
);
|
|
5444
|
-
}))))))
|
|
5729
|
+
filteredData,
|
|
5730
|
+
sidebarScope,
|
|
5731
|
+
filters,
|
|
5732
|
+
sortBy,
|
|
5733
|
+
hoveredItem,
|
|
5734
|
+
setHoveredItem
|
|
5735
|
+
}
|
|
5736
|
+
))))
|
|
5445
5737
|
);
|
|
5446
5738
|
};
|
|
5447
5739
|
|
|
5448
5740
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
5449
5741
|
var COMPONENT_NAME3 = "profit-and-loss";
|
|
5450
5742
|
var ProfitAndLossView = (props) => {
|
|
5451
|
-
return /* @__PURE__ */
|
|
5743
|
+
return /* @__PURE__ */ import_react62.default.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss, null, /* @__PURE__ */ import_react62.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__main-panel` }, /* @__PURE__ */ import_react62.default.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ import_react62.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ import_react62.default.createElement(Components, { ...props })), props.showDetailedCharts !== false && /* @__PURE__ */ import_react62.default.createElement(ProfitAndLossDetailedCharts, null)));
|
|
5452
5744
|
};
|
|
5453
5745
|
var Components = ({
|
|
5454
5746
|
hideChart = false,
|
|
5455
5747
|
hideTable = false
|
|
5456
5748
|
}) => {
|
|
5457
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
5749
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react62.useContext)(
|
|
5458
5750
|
ProfitAndLoss.Context
|
|
5459
5751
|
);
|
|
5460
5752
|
if (!isLoading && error) {
|
|
5461
|
-
return /* @__PURE__ */
|
|
5753
|
+
return /* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react62.default.createElement(
|
|
5462
5754
|
DataState,
|
|
5463
5755
|
{
|
|
5464
5756
|
status: "failed" /* failed */,
|
|
@@ -5469,26 +5761,504 @@ var Components = ({
|
|
|
5469
5761
|
}
|
|
5470
5762
|
));
|
|
5471
5763
|
}
|
|
5472
|
-
return /* @__PURE__ */
|
|
5764
|
+
return /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, !hideChart && /* @__PURE__ */ import_react62.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ import_react62.default.createElement(
|
|
5473
5765
|
"div",
|
|
5474
5766
|
{
|
|
5475
5767
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
|
|
5476
5768
|
},
|
|
5477
|
-
/* @__PURE__ */
|
|
5478
|
-
/* @__PURE__ */
|
|
5479
|
-
), /* @__PURE__ */
|
|
5769
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.DatePicker, null),
|
|
5770
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
5771
|
+
), /* @__PURE__ */ import_react62.default.createElement(
|
|
5480
5772
|
"div",
|
|
5481
5773
|
{
|
|
5482
5774
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
|
|
5483
5775
|
},
|
|
5484
|
-
/* @__PURE__ */
|
|
5485
|
-
)), !hideTable && /* @__PURE__ */
|
|
5776
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Chart, null)
|
|
5777
|
+
)), !hideTable && /* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Table, null));
|
|
5486
5778
|
};
|
|
5487
5779
|
|
|
5488
|
-
// src/
|
|
5489
|
-
var
|
|
5490
|
-
|
|
5780
|
+
// src/components/LedgerAccounts/LedgerAccounts.tsx
|
|
5781
|
+
var import_react68 = __toESM(require("react"));
|
|
5782
|
+
|
|
5783
|
+
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
5784
|
+
var import_react63 = require("react");
|
|
5491
5785
|
var import_swr5 = __toESM(require("swr"));
|
|
5786
|
+
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
5787
|
+
var useLedgerAccounts = () => {
|
|
5788
|
+
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5789
|
+
const [form, setForm] = (0, import_react63.useState)();
|
|
5790
|
+
const [showARForAccountId, setShowARForAccountId] = (0, import_react63.useState)();
|
|
5791
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr5.default)(
|
|
5792
|
+
businessId && auth?.access_token && `ledger-accounts-${businessId}`,
|
|
5793
|
+
Layer.getLedgerAccounts(apiUrl, auth?.access_token, {
|
|
5794
|
+
params: { businessId }
|
|
5795
|
+
})
|
|
5796
|
+
);
|
|
5797
|
+
const create = (newAccount) => {
|
|
5798
|
+
Layer.createAccount(apiUrl, auth?.access_token, {
|
|
5799
|
+
params: { businessId },
|
|
5800
|
+
body: newAccount
|
|
5801
|
+
}).then(({ data: data2 }) => (mutate(), data2));
|
|
5802
|
+
};
|
|
5803
|
+
const submitForm = () => {
|
|
5804
|
+
if (!form || !form.action) {
|
|
5805
|
+
return;
|
|
5806
|
+
}
|
|
5807
|
+
const data2 = {
|
|
5808
|
+
name: form.data.name || "Test name",
|
|
5809
|
+
normality: form.data.subType?.value,
|
|
5810
|
+
parent_id: form.data.parent ? {
|
|
5811
|
+
type: "AccountId",
|
|
5812
|
+
id: form.data.parent.value
|
|
5813
|
+
} : void 0,
|
|
5814
|
+
description: form.data.type?.value.toString() || "Test description"
|
|
5815
|
+
};
|
|
5816
|
+
if (form.action === "new") {
|
|
5817
|
+
create(data2);
|
|
5818
|
+
return;
|
|
5819
|
+
}
|
|
5820
|
+
if (form.action === "edit" && form.accountId) {
|
|
5821
|
+
return;
|
|
5822
|
+
}
|
|
5823
|
+
};
|
|
5824
|
+
const addAccount = () => setForm({
|
|
5825
|
+
action: "new",
|
|
5826
|
+
accountId: void 0,
|
|
5827
|
+
data: {
|
|
5828
|
+
parent: void 0,
|
|
5829
|
+
name: void 0,
|
|
5830
|
+
type: {
|
|
5831
|
+
value: "assets",
|
|
5832
|
+
label: "Assets"
|
|
5833
|
+
},
|
|
5834
|
+
subType: void 0,
|
|
5835
|
+
category: void 0
|
|
5836
|
+
}
|
|
5837
|
+
});
|
|
5838
|
+
const editAccount = (id) => {
|
|
5839
|
+
const allAccounts = flattenAccounts(data?.data?.accounts || []);
|
|
5840
|
+
const found = allAccounts?.find((x) => x.id === id);
|
|
5841
|
+
if (!found) {
|
|
5842
|
+
return;
|
|
5843
|
+
}
|
|
5844
|
+
const parent = allAccounts.find(
|
|
5845
|
+
(x) => x.sub_accounts?.find((el) => el.id === found.id)
|
|
5846
|
+
);
|
|
5847
|
+
setForm({
|
|
5848
|
+
action: "edit",
|
|
5849
|
+
accountId: id,
|
|
5850
|
+
data: {
|
|
5851
|
+
parent: parent ? {
|
|
5852
|
+
value: parent.id,
|
|
5853
|
+
label: parent.name
|
|
5854
|
+
} : void 0,
|
|
5855
|
+
name: found.name,
|
|
5856
|
+
type: {
|
|
5857
|
+
value: "assets",
|
|
5858
|
+
label: "Assets"
|
|
5859
|
+
},
|
|
5860
|
+
subType: void 0,
|
|
5861
|
+
category: void 0
|
|
5862
|
+
}
|
|
5863
|
+
});
|
|
5864
|
+
};
|
|
5865
|
+
const cancelForm = () => setForm(void 0);
|
|
5866
|
+
const changeFormData = (fieldName, value) => {
|
|
5867
|
+
if (!form) {
|
|
5868
|
+
return;
|
|
5869
|
+
}
|
|
5870
|
+
setForm({
|
|
5871
|
+
...form,
|
|
5872
|
+
data: {
|
|
5873
|
+
...form.data,
|
|
5874
|
+
[fieldName]: value
|
|
5875
|
+
}
|
|
5876
|
+
});
|
|
5877
|
+
};
|
|
5878
|
+
const refetch = () => mutate();
|
|
5879
|
+
return {
|
|
5880
|
+
data: data?.data,
|
|
5881
|
+
isLoading,
|
|
5882
|
+
isValidating,
|
|
5883
|
+
error,
|
|
5884
|
+
refetch,
|
|
5885
|
+
create,
|
|
5886
|
+
form,
|
|
5887
|
+
addAccount,
|
|
5888
|
+
editAccount,
|
|
5889
|
+
cancelForm,
|
|
5890
|
+
changeFormData,
|
|
5891
|
+
submitForm,
|
|
5892
|
+
showARForAccountId,
|
|
5893
|
+
setShowARForAccountId
|
|
5894
|
+
};
|
|
5895
|
+
};
|
|
5896
|
+
|
|
5897
|
+
// src/components/AccountsReceivable/AccountsReceivableIndex.tsx
|
|
5898
|
+
var import_react64 = __toESM(require("react"));
|
|
5899
|
+
var import_classnames26 = __toESM(require("classnames"));
|
|
5900
|
+
var import_date_fns15 = require("date-fns");
|
|
5901
|
+
var AccountsReceivable = () => {
|
|
5902
|
+
const { data, showARForAccountId, setShowARForAccountId } = (0, import_react64.useContext)(
|
|
5903
|
+
LedgerAccountsContext
|
|
5904
|
+
);
|
|
5905
|
+
const entry = (0, import_react64.useMemo)(() => {
|
|
5906
|
+
return flattenAccounts(data?.accounts || []).find(
|
|
5907
|
+
(x) => x.id === showARForAccountId
|
|
5908
|
+
);
|
|
5909
|
+
}, [showARForAccountId]);
|
|
5910
|
+
const baseClassName = (0, import_classnames26.default)(
|
|
5911
|
+
"Layer__accounts-receivable__index",
|
|
5912
|
+
showARForAccountId && "open"
|
|
5913
|
+
);
|
|
5914
|
+
const close = () => setShowARForAccountId(void 0);
|
|
5915
|
+
return /* @__PURE__ */ import_react64.default.createElement("div", { className: baseClassName }, /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__header" }, /* @__PURE__ */ import_react64.default.createElement(Button, { onClick: close, variant: "secondary" /* secondary */ }, "Back"), /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__title-container" }, /* @__PURE__ */ import_react64.default.createElement(
|
|
5916
|
+
Text,
|
|
5917
|
+
{
|
|
5918
|
+
weight: "bold" /* bold */,
|
|
5919
|
+
className: "Layer__accounts-receivable__title"
|
|
5920
|
+
},
|
|
5921
|
+
entry?.name || ""
|
|
5922
|
+
), /* @__PURE__ */ import_react64.default.createElement(
|
|
5923
|
+
Button,
|
|
5924
|
+
{
|
|
5925
|
+
variant: "secondary" /* secondary */,
|
|
5926
|
+
rightIcon: /* @__PURE__ */ import_react64.default.createElement(DownloadCloud_default, { size: 12 })
|
|
5927
|
+
},
|
|
5928
|
+
"Download"
|
|
5929
|
+
)), /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__balance-container" }, /* @__PURE__ */ import_react64.default.createElement(
|
|
5930
|
+
Text,
|
|
5931
|
+
{
|
|
5932
|
+
weight: "bold" /* bold */,
|
|
5933
|
+
className: "Layer__accounts-receivable__balance-label"
|
|
5934
|
+
},
|
|
5935
|
+
"Current balance"
|
|
5936
|
+
), /* @__PURE__ */ import_react64.default.createElement(
|
|
5937
|
+
Text,
|
|
5938
|
+
{
|
|
5939
|
+
weight: "bold" /* bold */,
|
|
5940
|
+
className: "Layer__accounts-receivable__balance-value"
|
|
5941
|
+
},
|
|
5942
|
+
"$",
|
|
5943
|
+
centsToDollars(entry?.balance || 0)
|
|
5944
|
+
))), /* @__PURE__ */ import_react64.default.createElement("table", { className: "Layer__table Layer__accounts-receivable-table" }, /* @__PURE__ */ import_react64.default.createElement("thead", null, /* @__PURE__ */ import_react64.default.createElement("tr", null, /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Source"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance"))), /* @__PURE__ */ import_react64.default.createElement("tbody", null, entry?.entries?.map((x) => {
|
|
5945
|
+
return /* @__PURE__ */ import_react64.default.createElement("tr", { key: x.id }, /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, x.createdAt && (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(x.createdAt), DATE_FORMAT))), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, x.direction, " TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")));
|
|
5946
|
+
}))));
|
|
5947
|
+
};
|
|
5948
|
+
|
|
5949
|
+
// src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
|
|
5950
|
+
var import_react65 = __toESM(require("react"));
|
|
5951
|
+
|
|
5952
|
+
// src/icons/ArrowRightCircle.tsx
|
|
5953
|
+
var React77 = __toESM(require("react"));
|
|
5954
|
+
var ArrowRightCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React77.createElement(
|
|
5955
|
+
"svg",
|
|
5956
|
+
{
|
|
5957
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5958
|
+
viewBox: "0 0 18 18",
|
|
5959
|
+
fill: "none",
|
|
5960
|
+
...props,
|
|
5961
|
+
width: size,
|
|
5962
|
+
height: size
|
|
5963
|
+
},
|
|
5964
|
+
/* @__PURE__ */ React77.createElement(
|
|
5965
|
+
"path",
|
|
5966
|
+
{
|
|
5967
|
+
d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
|
|
5968
|
+
stroke: "currentColor",
|
|
5969
|
+
"stroke-linecap": "round",
|
|
5970
|
+
"stroke-linejoin": "round"
|
|
5971
|
+
}
|
|
5972
|
+
),
|
|
5973
|
+
/* @__PURE__ */ React77.createElement(
|
|
5974
|
+
"path",
|
|
5975
|
+
{
|
|
5976
|
+
d: "M9 12L12 9L9 6",
|
|
5977
|
+
stroke: "currentColor",
|
|
5978
|
+
"stroke-linecap": "round",
|
|
5979
|
+
"stroke-linejoin": "round"
|
|
5980
|
+
}
|
|
5981
|
+
),
|
|
5982
|
+
/* @__PURE__ */ React77.createElement(
|
|
5983
|
+
"path",
|
|
5984
|
+
{
|
|
5985
|
+
d: "M6 9H12",
|
|
5986
|
+
stroke: "currentColor",
|
|
5987
|
+
"stroke-linecap": "round",
|
|
5988
|
+
"stroke-linejoin": "round"
|
|
5989
|
+
}
|
|
5990
|
+
)
|
|
5991
|
+
);
|
|
5992
|
+
var ArrowRightCircle_default = ArrowRightCircle;
|
|
5993
|
+
|
|
5994
|
+
// src/icons/Edit2.tsx
|
|
5995
|
+
var React78 = __toESM(require("react"));
|
|
5996
|
+
var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React78.createElement(
|
|
5997
|
+
"svg",
|
|
5998
|
+
{
|
|
5999
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6000
|
+
viewBox: "0 0 18 18",
|
|
6001
|
+
fill: "none",
|
|
6002
|
+
...props,
|
|
6003
|
+
width: size,
|
|
6004
|
+
height: size
|
|
6005
|
+
},
|
|
6006
|
+
/* @__PURE__ */ React78.createElement(
|
|
6007
|
+
"path",
|
|
6008
|
+
{
|
|
6009
|
+
d: "M12.75 2.25C12.947 2.05301 13.1808 1.89676 13.4382 1.79015C13.6956 1.68355 13.9714 1.62868 14.25 1.62868C14.5286 1.62868 14.8044 1.68355 15.0618 1.79015C15.3192 1.89676 15.553 2.05301 15.75 2.25C15.947 2.44698 16.1032 2.68083 16.2098 2.9382C16.3165 3.19557 16.3713 3.47142 16.3713 3.75C16.3713 4.02857 16.3165 4.30442 16.2098 4.56179C16.1032 4.81916 15.947 5.05302 15.75 5.25L5.625 15.375L1.5 16.5L2.625 12.375L12.75 2.25Z",
|
|
6010
|
+
stroke: "currentColor",
|
|
6011
|
+
"stroke-linecap": "round",
|
|
6012
|
+
"stroke-linejoin": "round"
|
|
6013
|
+
}
|
|
6014
|
+
)
|
|
6015
|
+
);
|
|
6016
|
+
var Edit2_default = Edit2;
|
|
6017
|
+
|
|
6018
|
+
// src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
|
|
6019
|
+
var import_classnames27 = __toESM(require("classnames"));
|
|
6020
|
+
var INDENTATION = 12;
|
|
6021
|
+
var LedgerAccountsRow = ({
|
|
6022
|
+
account,
|
|
6023
|
+
depth = 0
|
|
6024
|
+
}) => {
|
|
6025
|
+
const { form, editAccount, setShowARForAccountId } = (0, import_react65.useContext)(
|
|
6026
|
+
LedgerAccountsContext
|
|
6027
|
+
);
|
|
6028
|
+
const [isOpen, setIsOpen] = (0, import_react65.useState)(false);
|
|
6029
|
+
const baseClass = (0, import_classnames27.default)(
|
|
6030
|
+
"Layer__alt-table-row",
|
|
6031
|
+
isOpen ? "Layer__alt-table-row--expanded" : "Layer__alt-table-row--collapsed",
|
|
6032
|
+
`Layer__alt-table-row--depth-${depth}`,
|
|
6033
|
+
form?.accountId === account.id && "active"
|
|
6034
|
+
);
|
|
6035
|
+
return /* @__PURE__ */ import_react65.default.createElement(import_react65.default.Fragment, null, /* @__PURE__ */ import_react65.default.createElement("div", { className: baseClass, onClick: () => setIsOpen(!isOpen) }, /* @__PURE__ */ import_react65.default.createElement(
|
|
6036
|
+
"div",
|
|
6037
|
+
{
|
|
6038
|
+
className: "Layer__alt-table__cell Layer__coa__name",
|
|
6039
|
+
style: { paddingLeft: INDENTATION * depth + 16 }
|
|
6040
|
+
},
|
|
6041
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react65.default.createElement(
|
|
6042
|
+
ChevronDownFill_default,
|
|
6043
|
+
{
|
|
6044
|
+
size: 16,
|
|
6045
|
+
className: "Layer__alt-table__expand-icon"
|
|
6046
|
+
}
|
|
6047
|
+
),
|
|
6048
|
+
/* @__PURE__ */ import_react65.default.createElement("span", { className: "Layer__coa__name__text" }, account.name)
|
|
6049
|
+
), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__type" }, account.normality), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__balance" }, "$", centsToDollars(Math.abs(account.balance || 0))), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__actions" }, /* @__PURE__ */ import_react65.default.createElement(
|
|
6050
|
+
Button,
|
|
6051
|
+
{
|
|
6052
|
+
variant: "secondary" /* secondary */,
|
|
6053
|
+
rightIcon: /* @__PURE__ */ import_react65.default.createElement(Edit2_default, { size: 12 }),
|
|
6054
|
+
onClick: (e) => {
|
|
6055
|
+
e.preventDefault();
|
|
6056
|
+
e.stopPropagation();
|
|
6057
|
+
editAccount(account.id);
|
|
6058
|
+
}
|
|
6059
|
+
},
|
|
6060
|
+
"Edit"
|
|
6061
|
+
), /* @__PURE__ */ import_react65.default.createElement(
|
|
6062
|
+
Button,
|
|
6063
|
+
{
|
|
6064
|
+
variant: "secondary" /* secondary */,
|
|
6065
|
+
rightIcon: /* @__PURE__ */ import_react65.default.createElement(ArrowRightCircle_default, { size: 12 }),
|
|
6066
|
+
onClick: (e) => {
|
|
6067
|
+
e.preventDefault();
|
|
6068
|
+
e.stopPropagation();
|
|
6069
|
+
setShowARForAccountId(account.id);
|
|
6070
|
+
}
|
|
6071
|
+
},
|
|
6072
|
+
"Open"
|
|
6073
|
+
))), isOpen && (account.sub_accounts || []).map((subAccount) => /* @__PURE__ */ import_react65.default.createElement(
|
|
6074
|
+
LedgerAccountsRow,
|
|
6075
|
+
{
|
|
6076
|
+
key: subAccount.id,
|
|
6077
|
+
account: subAccount,
|
|
6078
|
+
depth: depth + 1
|
|
6079
|
+
}
|
|
6080
|
+
)));
|
|
6081
|
+
};
|
|
6082
|
+
|
|
6083
|
+
// src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
|
|
6084
|
+
var import_react67 = __toESM(require("react"));
|
|
6085
|
+
|
|
6086
|
+
// src/components/LedgerAccountsForm/LedgerAccountsForm.tsx
|
|
6087
|
+
var import_react66 = __toESM(require("react"));
|
|
6088
|
+
var SUB_TYPE_OPTIONS = [
|
|
6089
|
+
{
|
|
6090
|
+
value: "DEBIT" /* DEBIT */,
|
|
6091
|
+
label: "Debit"
|
|
6092
|
+
},
|
|
6093
|
+
{
|
|
6094
|
+
value: "CREDIT" /* CREDIT */,
|
|
6095
|
+
label: "Credit"
|
|
6096
|
+
}
|
|
6097
|
+
];
|
|
6098
|
+
var LedgerAccountsForm = () => {
|
|
6099
|
+
const { form, data, changeFormData, cancelForm, submitForm } = (0, import_react66.useContext)(
|
|
6100
|
+
LedgerAccountsContext
|
|
6101
|
+
);
|
|
6102
|
+
const parentOptions = (0, import_react66.useMemo)(
|
|
6103
|
+
() => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
6104
|
+
return {
|
|
6105
|
+
label: x.name,
|
|
6106
|
+
value: x.id
|
|
6107
|
+
};
|
|
6108
|
+
}),
|
|
6109
|
+
[data?.accounts?.length]
|
|
6110
|
+
);
|
|
6111
|
+
const entry = (0, import_react66.useMemo)(() => {
|
|
6112
|
+
if (form?.action === "edit" && form.accountId) {
|
|
6113
|
+
return flattenAccounts(data?.accounts || []).find(
|
|
6114
|
+
(x) => x.id === form.accountId
|
|
6115
|
+
);
|
|
6116
|
+
}
|
|
6117
|
+
return;
|
|
6118
|
+
}, [data, form?.accountId]);
|
|
6119
|
+
console.log(entry);
|
|
6120
|
+
if (!form) {
|
|
6121
|
+
return;
|
|
6122
|
+
}
|
|
6123
|
+
return /* @__PURE__ */ import_react66.default.createElement(
|
|
6124
|
+
"form",
|
|
6125
|
+
{
|
|
6126
|
+
onSubmit: (e) => {
|
|
6127
|
+
e.preventDefault();
|
|
6128
|
+
submitForm();
|
|
6129
|
+
}
|
|
6130
|
+
},
|
|
6131
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__sidebar__header" }, /* @__PURE__ */ import_react66.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, form?.action === "edit" ? "Edit" : "Add New", " Account"), /* @__PURE__ */ import_react66.default.createElement("div", { className: "actions" }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6132
|
+
Button,
|
|
6133
|
+
{
|
|
6134
|
+
type: "button",
|
|
6135
|
+
onClick: cancelForm,
|
|
6136
|
+
variant: "secondary" /* secondary */
|
|
6137
|
+
},
|
|
6138
|
+
"Cancel"
|
|
6139
|
+
), /* @__PURE__ */ import_react66.default.createElement(SubmitButton, { type: "submit", noIcon: true, active: true }, "Save"))),
|
|
6140
|
+
entry && /* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__form-edit-entry" }, /* @__PURE__ */ import_react66.default.createElement(Text, { weight: "bold" /* bold */ }, entry.name), /* @__PURE__ */ import_react66.default.createElement(Text, { weight: "bold" /* bold */ }, "$", centsToDollars(entry.balance || 0))),
|
|
6141
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__form" }, /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "parent", label: "Parent", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6142
|
+
Select3,
|
|
6143
|
+
{
|
|
6144
|
+
options: parentOptions,
|
|
6145
|
+
value: form?.data.parent,
|
|
6146
|
+
onChange: (sel) => changeFormData("parent", sel)
|
|
6147
|
+
}
|
|
6148
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "name", label: "Name", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6149
|
+
Input,
|
|
6150
|
+
{
|
|
6151
|
+
name: "name",
|
|
6152
|
+
value: form?.data.name,
|
|
6153
|
+
onChange: (e) => changeFormData("name", e.target.value)
|
|
6154
|
+
}
|
|
6155
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6156
|
+
Select3,
|
|
6157
|
+
{
|
|
6158
|
+
options: [],
|
|
6159
|
+
disabled: true,
|
|
6160
|
+
value: form?.data.type,
|
|
6161
|
+
onChange: (sel) => changeFormData("type", sel)
|
|
6162
|
+
}
|
|
6163
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6164
|
+
Select3,
|
|
6165
|
+
{
|
|
6166
|
+
options: SUB_TYPE_OPTIONS,
|
|
6167
|
+
value: form?.data.subType,
|
|
6168
|
+
onChange: (sel) => changeFormData("subType", sel)
|
|
6169
|
+
}
|
|
6170
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "category", label: "Category", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6171
|
+
Select3,
|
|
6172
|
+
{
|
|
6173
|
+
options: [],
|
|
6174
|
+
value: form?.data.category,
|
|
6175
|
+
onChange: (sel) => changeFormData("category", sel)
|
|
6176
|
+
}
|
|
6177
|
+
)))
|
|
6178
|
+
);
|
|
6179
|
+
};
|
|
6180
|
+
|
|
6181
|
+
// src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
|
|
6182
|
+
var import_classnames28 = __toESM(require("classnames"));
|
|
6183
|
+
var LedgerAccountsSidebar = () => {
|
|
6184
|
+
const { form } = (0, import_react67.useContext)(LedgerAccountsContext);
|
|
6185
|
+
return /* @__PURE__ */ import_react67.default.createElement(
|
|
6186
|
+
"div",
|
|
6187
|
+
{
|
|
6188
|
+
className: (0, import_classnames28.default)(
|
|
6189
|
+
"Layer__ledger-accounts__sidebar",
|
|
6190
|
+
form ? "open" : ""
|
|
6191
|
+
)
|
|
6192
|
+
},
|
|
6193
|
+
/* @__PURE__ */ import_react67.default.createElement("div", { className: "Layer__ledger-accounts__sidebar-content" }, /* @__PURE__ */ import_react67.default.createElement(LedgerAccountsForm, null))
|
|
6194
|
+
);
|
|
6195
|
+
};
|
|
6196
|
+
|
|
6197
|
+
// src/components/LedgerAccounts/LedgerAccounts.tsx
|
|
6198
|
+
var COMPONENT_NAME4 = "ledger-accounts";
|
|
6199
|
+
var LedgerAccountsContext = (0, import_react68.createContext)({
|
|
6200
|
+
data: void 0,
|
|
6201
|
+
isLoading: false,
|
|
6202
|
+
isValidating: false,
|
|
6203
|
+
error: void 0,
|
|
6204
|
+
refetch: () => {
|
|
6205
|
+
},
|
|
6206
|
+
create: () => {
|
|
6207
|
+
},
|
|
6208
|
+
form: void 0,
|
|
6209
|
+
addAccount: () => {
|
|
6210
|
+
},
|
|
6211
|
+
editAccount: () => {
|
|
6212
|
+
},
|
|
6213
|
+
cancelForm: () => {
|
|
6214
|
+
},
|
|
6215
|
+
changeFormData: () => {
|
|
6216
|
+
},
|
|
6217
|
+
submitForm: () => {
|
|
6218
|
+
},
|
|
6219
|
+
showARForAccountId: void 0,
|
|
6220
|
+
setShowARForAccountId: () => {
|
|
6221
|
+
}
|
|
6222
|
+
});
|
|
6223
|
+
var LedgerAccounts = () => {
|
|
6224
|
+
const contextData = useLedgerAccounts();
|
|
6225
|
+
return /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsContext.Provider, { value: contextData }, /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsContent, null));
|
|
6226
|
+
};
|
|
6227
|
+
var LedgerAccountsContent = () => {
|
|
6228
|
+
const { data, isLoading, addAccount, error, isValidating, refetch } = (0, import_react68.useContext)(LedgerAccountsContext);
|
|
6229
|
+
return /* @__PURE__ */ import_react68.default.createElement(Container, { name: COMPONENT_NAME4 }, /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__main-panel` }, /* @__PURE__ */ import_react68.default.createElement(Header, { className: `Layer__${COMPONENT_NAME4}__header` }, /* @__PURE__ */ import_react68.default.createElement(Heading, { className: `Layer__${COMPONENT_NAME4}__title` }, "Chart of Accounts"), /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__actions` }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6230
|
+
Button,
|
|
6231
|
+
{
|
|
6232
|
+
variant: "secondary" /* secondary */,
|
|
6233
|
+
disabled: isLoading,
|
|
6234
|
+
rightIcon: /* @__PURE__ */ import_react68.default.createElement(DownloadCloud_default, { size: 12 })
|
|
6235
|
+
},
|
|
6236
|
+
"Download"
|
|
6237
|
+
), /* @__PURE__ */ import_react68.default.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))), /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__table` }, /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table-row Layer__alt-table-row--header" }, /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__name" }, "Name"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__type" }, "Type"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__balance" }, "Balance"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__actions" })), error ? /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6238
|
+
DataState,
|
|
6239
|
+
{
|
|
6240
|
+
status: "failed" /* failed */,
|
|
6241
|
+
title: "Something went wrong",
|
|
6242
|
+
description: "We couldn\u2019t load your data.",
|
|
6243
|
+
onRefresh: () => refetch(),
|
|
6244
|
+
isLoading: isValidating || isLoading
|
|
6245
|
+
}
|
|
6246
|
+
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ import_react68.default.createElement(Loader2, null)) : null, !error && data?.accounts.map((account) => /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsRow, { key: account.id, account, depth: 0 })), !isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6247
|
+
DataState,
|
|
6248
|
+
{
|
|
6249
|
+
status: "info" /* info */,
|
|
6250
|
+
title: "Accounts were not found",
|
|
6251
|
+
description: 'New account can be created with "Add Account".',
|
|
6252
|
+
onRefresh: () => refetch(),
|
|
6253
|
+
isLoading: isValidating
|
|
6254
|
+
}
|
|
6255
|
+
)) : null)), /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsSidebar, null), /* @__PURE__ */ import_react68.default.createElement(AccountsReceivable, null));
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6258
|
+
// src/providers/LayerProvider/LayerProvider.tsx
|
|
6259
|
+
var import_react69 = __toESM(require("react"));
|
|
6260
|
+
var import_date_fns16 = require("date-fns");
|
|
6261
|
+
var import_swr6 = __toESM(require("swr"));
|
|
5492
6262
|
var reducer = (state, action) => {
|
|
5493
6263
|
switch (action.type) {
|
|
5494
6264
|
case "LayerContext.setAuth" /* setAuth */:
|
|
@@ -5528,7 +6298,7 @@ var LayerProvider = ({
|
|
|
5528
6298
|
};
|
|
5529
6299
|
const colors = buildColorsPalette(theme);
|
|
5530
6300
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
5531
|
-
const [state, dispatch] = (0,
|
|
6301
|
+
const [state, dispatch] = (0, import_react69.useReducer)(reducer, {
|
|
5532
6302
|
auth: {
|
|
5533
6303
|
access_token: "",
|
|
5534
6304
|
token_type: "",
|
|
@@ -5541,8 +6311,8 @@ var LayerProvider = ({
|
|
|
5541
6311
|
theme,
|
|
5542
6312
|
colors
|
|
5543
6313
|
});
|
|
5544
|
-
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0,
|
|
5545
|
-
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0,
|
|
6314
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr6.default)(
|
|
6315
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns16.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
5546
6316
|
Layer.authenticate({
|
|
5547
6317
|
appId,
|
|
5548
6318
|
appSecret,
|
|
@@ -5551,7 +6321,7 @@ var LayerProvider = ({
|
|
|
5551
6321
|
}),
|
|
5552
6322
|
defaultSWRConfig
|
|
5553
6323
|
) : { data: void 0 };
|
|
5554
|
-
(0,
|
|
6324
|
+
(0, import_react69.useEffect)(() => {
|
|
5555
6325
|
if (businessAccessToken) {
|
|
5556
6326
|
dispatch({
|
|
5557
6327
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -5560,7 +6330,7 @@ var LayerProvider = ({
|
|
|
5560
6330
|
access_token: businessAccessToken,
|
|
5561
6331
|
token_type: "Bearer",
|
|
5562
6332
|
expires_in: 3600,
|
|
5563
|
-
expires_at: (0,
|
|
6333
|
+
expires_at: (0, import_date_fns16.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
5564
6334
|
}
|
|
5565
6335
|
}
|
|
5566
6336
|
});
|
|
@@ -5570,13 +6340,13 @@ var LayerProvider = ({
|
|
|
5570
6340
|
payload: {
|
|
5571
6341
|
auth: {
|
|
5572
6342
|
...auth,
|
|
5573
|
-
expires_at: (0,
|
|
6343
|
+
expires_at: (0, import_date_fns16.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
5574
6344
|
}
|
|
5575
6345
|
}
|
|
5576
6346
|
});
|
|
5577
6347
|
}
|
|
5578
6348
|
}, [businessAccessToken, auth?.access_token]);
|
|
5579
|
-
(0,
|
|
6349
|
+
(0, import_swr6.default)(
|
|
5580
6350
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
5581
6351
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
5582
6352
|
{
|
|
@@ -5601,171 +6371,15 @@ var LayerProvider = ({
|
|
|
5601
6371
|
}
|
|
5602
6372
|
return;
|
|
5603
6373
|
};
|
|
5604
|
-
return /* @__PURE__ */
|
|
5605
|
-
};
|
|
5606
|
-
|
|
5607
|
-
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
5608
|
-
var import_react61 = __toESM(require("react"));
|
|
5609
|
-
|
|
5610
|
-
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
5611
|
-
var import_swr6 = __toESM(require("swr"));
|
|
5612
|
-
var useChartOfAccounts = () => {
|
|
5613
|
-
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5614
|
-
const { data, isLoading, error, mutate } = (0, import_swr6.default)(
|
|
5615
|
-
businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
|
|
5616
|
-
Layer.getChartOfAccounts(apiUrl, auth?.access_token, {
|
|
5617
|
-
params: { businessId }
|
|
5618
|
-
})
|
|
5619
|
-
);
|
|
5620
|
-
const create = (newAccount) => Layer.createAccount(apiUrl, auth?.access_token, {
|
|
5621
|
-
params: { businessId },
|
|
5622
|
-
body: newAccount
|
|
5623
|
-
}).then(({ data: data2 }) => (mutate(), data2));
|
|
5624
|
-
return { data: data?.data, isLoading, error, create };
|
|
5625
|
-
};
|
|
5626
|
-
|
|
5627
|
-
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
5628
|
-
var import_react59 = __toESM(require("react"));
|
|
5629
|
-
var import_react_select4 = __toESM(require("react-select"));
|
|
5630
|
-
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
5631
|
-
var ChartOfAccountsNewForm = () => {
|
|
5632
|
-
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
5633
|
-
const accountOptions = (0, import_react59.useMemo)(
|
|
5634
|
-
() => flattenAccounts(data?.accounts || []).sort(
|
|
5635
|
-
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
5636
|
-
),
|
|
5637
|
-
[data?.accounts?.length]
|
|
5638
|
-
);
|
|
5639
|
-
const [name, setName] = (0, import_react59.useState)("");
|
|
5640
|
-
const [description, setDescription] = (0, import_react59.useState)("");
|
|
5641
|
-
const [normality, setNormality] = (0, import_react59.useState)("DEBIT" /* DEBIT */);
|
|
5642
|
-
const [parentAccount, setParentAccount] = (0, import_react59.useState)(
|
|
5643
|
-
data?.accounts[0]
|
|
5644
|
-
);
|
|
5645
|
-
const save = () => {
|
|
5646
|
-
createAccount2({
|
|
5647
|
-
name,
|
|
5648
|
-
normality,
|
|
5649
|
-
parent_id: {
|
|
5650
|
-
type: "AccountId",
|
|
5651
|
-
id: parentAccount?.id || ""
|
|
5652
|
-
},
|
|
5653
|
-
description
|
|
5654
|
-
});
|
|
5655
|
-
};
|
|
5656
|
-
return /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5657
|
-
"input",
|
|
5658
|
-
{
|
|
5659
|
-
name: "name",
|
|
5660
|
-
value: name,
|
|
5661
|
-
onChange: (event) => setName(event.target.value)
|
|
5662
|
-
}
|
|
5663
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5664
|
-
"input",
|
|
5665
|
-
{
|
|
5666
|
-
name: "description",
|
|
5667
|
-
value: description,
|
|
5668
|
-
onChange: (event) => setDescription(event.target.value)
|
|
5669
|
-
}
|
|
5670
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5671
|
-
import_react_select4.default,
|
|
5672
|
-
{
|
|
5673
|
-
isSearchable: false,
|
|
5674
|
-
onChange: (value) => value && setNormality(value.value),
|
|
5675
|
-
options: [
|
|
5676
|
-
{ label: "Credit", value: "CREDIT" /* CREDIT */ },
|
|
5677
|
-
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
5678
|
-
]
|
|
5679
|
-
}
|
|
5680
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5681
|
-
import_react_select4.default,
|
|
5682
|
-
{
|
|
5683
|
-
isSearchable: true,
|
|
5684
|
-
value: parentAccount,
|
|
5685
|
-
onChange: (value) => value && setParentAccount(value),
|
|
5686
|
-
getOptionLabel: (a) => a.name,
|
|
5687
|
-
getOptionValue: (a) => a.id,
|
|
5688
|
-
options: accountOptions
|
|
5689
|
-
}
|
|
5690
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react59.default.createElement("button", { onClick: save }, "Save")));
|
|
5691
|
-
};
|
|
5692
|
-
|
|
5693
|
-
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
5694
|
-
var import_react60 = __toESM(require("react"));
|
|
5695
|
-
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
5696
|
-
const classNames24 = [
|
|
5697
|
-
"Layer__chart-of-accounts-row__table-cell",
|
|
5698
|
-
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
5699
|
-
];
|
|
5700
|
-
const className = classNames24.filter((id) => id).join(" ");
|
|
5701
|
-
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
5702
|
-
return /* @__PURE__ */ import_react60.default.createElement(import_react60.default.Fragment, null, /* @__PURE__ */ import_react60.default.createElement(
|
|
5703
|
-
"div",
|
|
5704
|
-
{
|
|
5705
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
5706
|
-
},
|
|
5707
|
-
account.name
|
|
5708
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5709
|
-
"div",
|
|
5710
|
-
{
|
|
5711
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
5712
|
-
},
|
|
5713
|
-
"Assets"
|
|
5714
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5715
|
-
"div",
|
|
5716
|
-
{
|
|
5717
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
5718
|
-
},
|
|
5719
|
-
"Cash"
|
|
5720
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5721
|
-
"div",
|
|
5722
|
-
{
|
|
5723
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
5724
|
-
},
|
|
5725
|
-
centsToDollars(Math.abs(account.balance || 0))
|
|
5726
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5727
|
-
"div",
|
|
5728
|
-
{
|
|
5729
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
5730
|
-
},
|
|
5731
|
-
/* @__PURE__ */ import_react60.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
|
|
5732
|
-
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react60.default.createElement(
|
|
5733
|
-
ChartOfAccountsRow,
|
|
5734
|
-
{
|
|
5735
|
-
key: subAccount.id,
|
|
5736
|
-
account: subAccount,
|
|
5737
|
-
depth: depth + 1
|
|
5738
|
-
}
|
|
5739
|
-
)));
|
|
5740
|
-
};
|
|
5741
|
-
|
|
5742
|
-
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
5743
|
-
var ChartOfAccounts = () => {
|
|
5744
|
-
const { data, isLoading } = useChartOfAccounts();
|
|
5745
|
-
const [showingForm, setShowingForm] = (0, import_react61.useState)(false);
|
|
5746
|
-
return /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react61.default.createElement(import_react61.default.Fragment, null, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react61.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react61.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react61.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react61.default.createElement(
|
|
5747
|
-
"button",
|
|
5748
|
-
{
|
|
5749
|
-
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
5750
|
-
onClick: () => setShowingForm(!showingForm)
|
|
5751
|
-
},
|
|
5752
|
-
"Edit Accounts"
|
|
5753
|
-
))), showingForm && /* @__PURE__ */ import_react61.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react61.default.createElement(
|
|
5754
|
-
ChartOfAccountsRow,
|
|
5755
|
-
{
|
|
5756
|
-
key: account.id,
|
|
5757
|
-
account,
|
|
5758
|
-
depth: 0
|
|
5759
|
-
}
|
|
5760
|
-
)))));
|
|
6374
|
+
return /* @__PURE__ */ import_react69.default.createElement(import_swr6.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react69.default.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
|
|
5761
6375
|
};
|
|
5762
6376
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5763
6377
|
0 && (module.exports = {
|
|
5764
6378
|
BalanceSheet,
|
|
5765
6379
|
BankTransactions,
|
|
5766
|
-
ChartOfAccounts,
|
|
5767
6380
|
Hello,
|
|
5768
6381
|
LayerProvider,
|
|
6382
|
+
LedgerAccounts,
|
|
5769
6383
|
LinkedAccounts,
|
|
5770
6384
|
ProfitAndLoss,
|
|
5771
6385
|
ProfitAndLossView
|