@layerfi/components 0.1.12 → 0.1.14
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 +1002 -362
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +83 -7
- package/dist/index.js +1262 -622
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +23 -2
- package/dist/styles/index.css.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -827,7 +827,6 @@ var debounce = (fnc, timeout = 300) => {
|
|
|
827
827
|
}, timeout);
|
|
828
828
|
};
|
|
829
829
|
};
|
|
830
|
-
var convertToStableName = (name) => name.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "").replace(/\W+/g, " ").split(/ |\B(?=[A-Z])/).map((word) => word.toLowerCase()).join("_");
|
|
831
830
|
|
|
832
831
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
833
832
|
var import_react36 = __toESM(require("react"));
|
|
@@ -2230,6 +2229,7 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
2230
2229
|
// src/components/Input/Select.tsx
|
|
2231
2230
|
var import_react26 = __toESM(require("react"));
|
|
2232
2231
|
var import_react_select2 = __toESM(require("react-select"));
|
|
2232
|
+
var import_classnames14 = __toESM(require("classnames"));
|
|
2233
2233
|
var DropdownIndicator2 = (props) => {
|
|
2234
2234
|
return /* @__PURE__ */ import_react26.default.createElement(import_react_select2.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react26.default.createElement(ChevronDownFill_default, null));
|
|
2235
2235
|
};
|
|
@@ -2241,13 +2241,20 @@ var Select2 = ({
|
|
|
2241
2241
|
value,
|
|
2242
2242
|
onChange,
|
|
2243
2243
|
disabled,
|
|
2244
|
-
placeholder
|
|
2244
|
+
placeholder,
|
|
2245
|
+
isInvalid,
|
|
2246
|
+
errorMessage
|
|
2245
2247
|
}) => {
|
|
2246
|
-
|
|
2248
|
+
const baseClassName = (0, import_classnames14.default)(
|
|
2249
|
+
"Layer__select",
|
|
2250
|
+
isInvalid ? "Layer__select--error" : "",
|
|
2251
|
+
className
|
|
2252
|
+
);
|
|
2253
|
+
return /* @__PURE__ */ import_react26.default.createElement(Tooltip, { disabled: !isInvalid || !errorMessage }, /* @__PURE__ */ import_react26.default.createElement(TooltipTrigger, { className: "Layer__input-tooltip" }, /* @__PURE__ */ import_react26.default.createElement(
|
|
2247
2254
|
import_react_select2.default,
|
|
2248
2255
|
{
|
|
2249
2256
|
name,
|
|
2250
|
-
className:
|
|
2257
|
+
className: baseClassName,
|
|
2251
2258
|
classNamePrefix,
|
|
2252
2259
|
placeholder: placeholder ?? "Select...",
|
|
2253
2260
|
options,
|
|
@@ -2258,7 +2265,7 @@ var Select2 = ({
|
|
|
2258
2265
|
components: { DropdownIndicator: DropdownIndicator2 },
|
|
2259
2266
|
isDisabled: disabled
|
|
2260
2267
|
}
|
|
2261
|
-
);
|
|
2268
|
+
)), /* @__PURE__ */ import_react26.default.createElement(TooltipContent, { className: "Layer__tooltip" }, errorMessage));
|
|
2262
2269
|
};
|
|
2263
2270
|
|
|
2264
2271
|
// src/components/MatchForm/MatchForm.tsx
|
|
@@ -2288,7 +2295,7 @@ var MatchBadge = ({
|
|
|
2288
2295
|
};
|
|
2289
2296
|
|
|
2290
2297
|
// src/components/MatchForm/MatchForm.tsx
|
|
2291
|
-
var
|
|
2298
|
+
var import_classnames15 = __toESM(require("classnames"));
|
|
2292
2299
|
var import_date_fns6 = require("date-fns");
|
|
2293
2300
|
var MatchForm = ({
|
|
2294
2301
|
classNamePrefix,
|
|
@@ -2307,7 +2314,7 @@ var MatchForm = ({
|
|
|
2307
2314
|
"div",
|
|
2308
2315
|
{
|
|
2309
2316
|
key: idx,
|
|
2310
|
-
className: (0,
|
|
2317
|
+
className: (0, import_classnames15.default)(
|
|
2311
2318
|
`${classNamePrefix}__match-row`,
|
|
2312
2319
|
match.id === selectedMatchId ? `${classNamePrefix}__match-row--selected` : ""
|
|
2313
2320
|
),
|
|
@@ -2366,18 +2373,18 @@ var MatchForm = ({
|
|
|
2366
2373
|
|
|
2367
2374
|
// src/components/Textarea/Textarea.tsx
|
|
2368
2375
|
var import_react29 = __toESM(require("react"));
|
|
2369
|
-
var
|
|
2376
|
+
var import_classnames16 = __toESM(require("classnames"));
|
|
2370
2377
|
var Textarea = ({
|
|
2371
2378
|
className,
|
|
2372
2379
|
...props
|
|
2373
2380
|
}) => {
|
|
2374
|
-
const baseClassName = (0,
|
|
2381
|
+
const baseClassName = (0, import_classnames16.default)("Layer__textarea", className);
|
|
2375
2382
|
return /* @__PURE__ */ import_react29.default.createElement("textarea", { ...props, className: baseClassName });
|
|
2376
2383
|
};
|
|
2377
2384
|
|
|
2378
2385
|
// src/components/Toggle/Toggle.tsx
|
|
2379
2386
|
var import_react30 = __toESM(require("react"));
|
|
2380
|
-
var
|
|
2387
|
+
var import_classnames17 = __toESM(require("classnames"));
|
|
2381
2388
|
var Toggle = ({
|
|
2382
2389
|
name,
|
|
2383
2390
|
options,
|
|
@@ -2394,7 +2401,7 @@ var Toggle = ({
|
|
|
2394
2401
|
}
|
|
2395
2402
|
});
|
|
2396
2403
|
const selectedValue = selected || options[0].value;
|
|
2397
|
-
const baseClassName = (0,
|
|
2404
|
+
const baseClassName = (0, import_classnames17.default)(
|
|
2398
2405
|
"Layer__toggle",
|
|
2399
2406
|
`Layer__toggle--${size}`,
|
|
2400
2407
|
initialized ? "Layer__toggle--initialized" : ""
|
|
@@ -2645,7 +2652,7 @@ var Notification = ({
|
|
|
2645
2652
|
};
|
|
2646
2653
|
|
|
2647
2654
|
// src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
|
|
2648
|
-
var
|
|
2655
|
+
var import_classnames18 = __toESM(require("classnames"));
|
|
2649
2656
|
var hasMatch = (bankTransaction) => {
|
|
2650
2657
|
return Boolean(
|
|
2651
2658
|
bankTransaction?.suggested_matches && bankTransaction?.suggested_matches?.length > 0 || bankTransaction?.match
|
|
@@ -2898,7 +2905,7 @@ var ExpandedBankTransactionRow = (0, import_react32.forwardRef)(
|
|
|
2898
2905
|
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2899
2906
|
"div",
|
|
2900
2907
|
{
|
|
2901
|
-
className: (0,
|
|
2908
|
+
className: (0, import_classnames18.default)(
|
|
2902
2909
|
`${className}__match`,
|
|
2903
2910
|
`${className}__content-panel`,
|
|
2904
2911
|
purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
|
|
@@ -2920,7 +2927,7 @@ var ExpandedBankTransactionRow = (0, import_react32.forwardRef)(
|
|
|
2920
2927
|
), /* @__PURE__ */ import_react32.default.createElement(
|
|
2921
2928
|
"div",
|
|
2922
2929
|
{
|
|
2923
|
-
className: (0,
|
|
2930
|
+
className: (0, import_classnames18.default)(
|
|
2924
2931
|
`${className}__splits`,
|
|
2925
2932
|
`${className}__content-panel`,
|
|
2926
2933
|
purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
|
|
@@ -3059,7 +3066,7 @@ var SplitTooltipDetails = ({
|
|
|
3059
3066
|
};
|
|
3060
3067
|
|
|
3061
3068
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
3062
|
-
var
|
|
3069
|
+
var import_classnames19 = __toESM(require("classnames"));
|
|
3063
3070
|
var import_date_fns7 = require("date-fns");
|
|
3064
3071
|
var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
3065
3072
|
var extractDescriptionForSplit = (category) => {
|
|
@@ -3158,7 +3165,7 @@ var BankTransactionRow = ({
|
|
|
3158
3165
|
}
|
|
3159
3166
|
const className = "Layer__bank-transaction-row";
|
|
3160
3167
|
const openClassName = open ? `${className}--expanded` : "";
|
|
3161
|
-
const rowClassName = (0,
|
|
3168
|
+
const rowClassName = (0, import_classnames19.default)(
|
|
3162
3169
|
className,
|
|
3163
3170
|
bankTransaction.recently_categorized && editable ? "Layer__bank-transaction-row--removing" : "",
|
|
3164
3171
|
open ? openClassName : "",
|
|
@@ -3232,7 +3239,7 @@ var BankTransactionRow = ({
|
|
|
3232
3239
|
/* @__PURE__ */ import_react34.default.createElement(
|
|
3233
3240
|
"td",
|
|
3234
3241
|
{
|
|
3235
|
-
className: (0,
|
|
3242
|
+
className: (0, import_classnames19.default)(
|
|
3236
3243
|
"Layer__table-cell",
|
|
3237
3244
|
"Layer__table-cell__category-col",
|
|
3238
3245
|
`${className}__actions-cell`,
|
|
@@ -3387,7 +3394,7 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
3387
3394
|
};
|
|
3388
3395
|
|
|
3389
3396
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
3390
|
-
var
|
|
3397
|
+
var import_classnames20 = __toESM(require("classnames"));
|
|
3391
3398
|
var import_date_fns9 = require("date-fns");
|
|
3392
3399
|
var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
3393
3400
|
var BankTransactionListItem = ({
|
|
@@ -3446,7 +3453,7 @@ var BankTransactionListItem = ({
|
|
|
3446
3453
|
}
|
|
3447
3454
|
const className = "Layer__bank-transaction-list-item";
|
|
3448
3455
|
const openClassName = open ? `${className}--expanded` : "";
|
|
3449
|
-
const rowClassName = (0,
|
|
3456
|
+
const rowClassName = (0, import_classnames20.default)(
|
|
3450
3457
|
className,
|
|
3451
3458
|
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
3452
3459
|
open ? openClassName : "",
|
|
@@ -3753,10 +3760,10 @@ var hslToHex = (hsl) => {
|
|
|
3753
3760
|
};
|
|
3754
3761
|
|
|
3755
3762
|
// src/components/Container/Container.tsx
|
|
3756
|
-
var
|
|
3763
|
+
var import_classnames21 = __toESM(require("classnames"));
|
|
3757
3764
|
var Container = (0, import_react37.forwardRef)(
|
|
3758
3765
|
({ name, className, children, asWidget, elevated = false }, ref) => {
|
|
3759
|
-
const baseClassName = (0,
|
|
3766
|
+
const baseClassName = (0, import_classnames21.default)(
|
|
3760
3767
|
"Layer__component Layer__component-container",
|
|
3761
3768
|
`Layer__${name}`,
|
|
3762
3769
|
elevated && "Layer__component--elevated",
|
|
@@ -3771,10 +3778,10 @@ var Container = (0, import_react37.forwardRef)(
|
|
|
3771
3778
|
|
|
3772
3779
|
// src/components/Container/Header.tsx
|
|
3773
3780
|
var import_react38 = __toESM(require("react"));
|
|
3774
|
-
var
|
|
3781
|
+
var import_classnames22 = __toESM(require("classnames"));
|
|
3775
3782
|
var Header = (0, import_react38.forwardRef)(
|
|
3776
3783
|
({ className, children, style }, ref) => {
|
|
3777
|
-
const baseClassName = (0,
|
|
3784
|
+
const baseClassName = (0, import_classnames22.default)("Layer__component-header", className);
|
|
3778
3785
|
return /* @__PURE__ */ import_react38.default.createElement("header", { ref, className: baseClassName, style }, children);
|
|
3779
3786
|
}
|
|
3780
3787
|
);
|
|
@@ -3922,7 +3929,7 @@ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React54.createEl
|
|
|
3922
3929
|
var ChevronRight_default = ChavronRight;
|
|
3923
3930
|
|
|
3924
3931
|
// src/components/Pagination/Pagination.tsx
|
|
3925
|
-
var
|
|
3932
|
+
var import_classnames23 = __toESM(require("classnames"));
|
|
3926
3933
|
var Pagination = ({
|
|
3927
3934
|
onPageChange,
|
|
3928
3935
|
totalCount,
|
|
@@ -3947,7 +3954,7 @@ var Pagination = ({
|
|
|
3947
3954
|
"li",
|
|
3948
3955
|
{
|
|
3949
3956
|
key: `page-prev`,
|
|
3950
|
-
className: (0,
|
|
3957
|
+
className: (0, import_classnames23.default)(
|
|
3951
3958
|
"Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--previous",
|
|
3952
3959
|
{
|
|
3953
3960
|
disabled: currentPage === 1
|
|
@@ -3971,7 +3978,7 @@ var Pagination = ({
|
|
|
3971
3978
|
"li",
|
|
3972
3979
|
{
|
|
3973
3980
|
key: `page-${pageNumber}`,
|
|
3974
|
-
className: (0,
|
|
3981
|
+
className: (0, import_classnames23.default)("Layer__pagination-item", {
|
|
3975
3982
|
selected: pageNumber === currentPage
|
|
3976
3983
|
}),
|
|
3977
3984
|
onClick: () => {
|
|
@@ -3986,7 +3993,7 @@ var Pagination = ({
|
|
|
3986
3993
|
"li",
|
|
3987
3994
|
{
|
|
3988
3995
|
key: `page-last`,
|
|
3989
|
-
className: (0,
|
|
3996
|
+
className: (0, import_classnames23.default)(
|
|
3990
3997
|
"Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--next",
|
|
3991
3998
|
{
|
|
3992
3999
|
disabled: currentPage === lastPage
|
|
@@ -4325,7 +4332,7 @@ var useLinkedAccounts = () => {
|
|
|
4325
4332
|
const exchangePublicToken = async (publicToken, metadata) => {
|
|
4326
4333
|
await Layer.exchangePlaidPublicToken(apiUrl, auth?.access_token, {
|
|
4327
4334
|
params: { businessId },
|
|
4328
|
-
body: { public_token: publicToken,
|
|
4335
|
+
body: { public_token: publicToken, institution: metadata.institution }
|
|
4329
4336
|
});
|
|
4330
4337
|
refetchAccounts();
|
|
4331
4338
|
};
|
|
@@ -4484,7 +4491,7 @@ var MoreVertical_default = MoreVertical;
|
|
|
4484
4491
|
|
|
4485
4492
|
// src/components/HoverMenu/HoverMenu.tsx
|
|
4486
4493
|
var import_react47 = __toESM(require("react"));
|
|
4487
|
-
var
|
|
4494
|
+
var import_classnames24 = __toESM(require("classnames"));
|
|
4488
4495
|
var HoverMenu = ({
|
|
4489
4496
|
children,
|
|
4490
4497
|
config,
|
|
@@ -4493,7 +4500,7 @@ var HoverMenu = ({
|
|
|
4493
4500
|
}) => {
|
|
4494
4501
|
const [openMenu, setOpenMenu] = (0, import_react47.useState)(false);
|
|
4495
4502
|
const hoverMenuRef = (0, import_react47.useRef)(null);
|
|
4496
|
-
const hoverMenuClassName = (0,
|
|
4503
|
+
const hoverMenuClassName = (0, import_classnames24.default)(
|
|
4497
4504
|
"Layer__hover-menu",
|
|
4498
4505
|
openMenu && "Layer__hover-menu--open"
|
|
4499
4506
|
);
|
|
@@ -4856,13 +4863,13 @@ var InstitutionIcon = ({ size = 18, ...props }) => /* @__PURE__ */ React62.creat
|
|
|
4856
4863
|
var InstitutionIcon_default = InstitutionIcon;
|
|
4857
4864
|
|
|
4858
4865
|
// src/components/LinkedAccountThumb/LinkedAccountThumb.tsx
|
|
4859
|
-
var
|
|
4866
|
+
var import_classnames25 = __toESM(require("classnames"));
|
|
4860
4867
|
var AccountNumber = ({ accountNumber }) => /* @__PURE__ */ import_react49.default.createElement("div", { className: "account-number" }, /* @__PURE__ */ import_react49.default.createElement(Text, { size: "sm" }, "\u2022\u2022\u2022 ", accountNumber));
|
|
4861
4868
|
var LinkedAccountThumb = ({
|
|
4862
4869
|
account,
|
|
4863
4870
|
asWidget
|
|
4864
4871
|
}) => {
|
|
4865
|
-
const linkedAccountThumbClassName = (0,
|
|
4872
|
+
const linkedAccountThumbClassName = (0, import_classnames25.default)(
|
|
4866
4873
|
"Layer__linked-account-thumb",
|
|
4867
4874
|
asWidget && "--as-widget"
|
|
4868
4875
|
);
|
|
@@ -4907,7 +4914,7 @@ var LinkedAccountThumb = ({
|
|
|
4907
4914
|
};
|
|
4908
4915
|
|
|
4909
4916
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4910
|
-
var
|
|
4917
|
+
var import_classnames26 = __toESM(require("classnames"));
|
|
4911
4918
|
var COMPONENT_NAME2 = "linked-accounts";
|
|
4912
4919
|
var LinkedAccounts = ({ asWidget, elevated }) => {
|
|
4913
4920
|
const {
|
|
@@ -4924,7 +4931,7 @@ var LinkedAccounts = ({ asWidget, elevated }) => {
|
|
|
4924
4931
|
{ name: "Renew link", action: renewLinkAccount },
|
|
4925
4932
|
{ name: "Unlink", action: unlinkAccount }
|
|
4926
4933
|
];
|
|
4927
|
-
const linkedAccountsNewAccountClassName = (0,
|
|
4934
|
+
const linkedAccountsNewAccountClassName = (0, import_classnames26.default)(
|
|
4928
4935
|
"Layer__linked-accounts__new-account",
|
|
4929
4936
|
asWidget && "--as-widget"
|
|
4930
4937
|
);
|
|
@@ -4967,7 +4974,7 @@ var LinkedAccounts = ({ asWidget, elevated }) => {
|
|
|
4967
4974
|
};
|
|
4968
4975
|
|
|
4969
4976
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4970
|
-
var
|
|
4977
|
+
var import_react65 = __toESM(require("react"));
|
|
4971
4978
|
|
|
4972
4979
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4973
4980
|
var import_react51 = require("react");
|
|
@@ -5025,12 +5032,12 @@ var applyShare = (items, total) => {
|
|
|
5025
5032
|
});
|
|
5026
5033
|
};
|
|
5027
5034
|
|
|
5028
|
-
// src/hooks/useProfitAndLoss/
|
|
5035
|
+
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
5029
5036
|
var import_date_fns10 = require("date-fns");
|
|
5030
5037
|
var import_swr5 = __toESM(require("swr"));
|
|
5031
|
-
var
|
|
5032
|
-
startDate
|
|
5033
|
-
endDate
|
|
5038
|
+
var useProfitAndLossQuery = ({
|
|
5039
|
+
startDate,
|
|
5040
|
+
endDate,
|
|
5034
5041
|
tagFilter,
|
|
5035
5042
|
reportingBasis
|
|
5036
5043
|
} = {
|
|
@@ -5038,17 +5045,6 @@ var useProfitAndLoss = ({
|
|
|
5038
5045
|
endDate: (0, import_date_fns10.endOfMonth)(/* @__PURE__ */ new Date())
|
|
5039
5046
|
}) => {
|
|
5040
5047
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5041
|
-
const [startDate, setStartDate] = (0, import_react51.useState)(
|
|
5042
|
-
initialStartDate || (0, import_date_fns10.startOfMonth)(Date.now())
|
|
5043
|
-
);
|
|
5044
|
-
const [endDate, setEndDate] = (0, import_react51.useState)(
|
|
5045
|
-
initialEndDate || (0, import_date_fns10.endOfMonth)(Date.now())
|
|
5046
|
-
);
|
|
5047
|
-
const [filters, setFilters] = (0, import_react51.useState)({
|
|
5048
|
-
expenses: void 0,
|
|
5049
|
-
revenue: void 0
|
|
5050
|
-
});
|
|
5051
|
-
const [sidebarScope, setSidebarScope] = (0, import_react51.useState)(void 0);
|
|
5052
5048
|
const {
|
|
5053
5049
|
data: rawData,
|
|
5054
5050
|
isLoading,
|
|
@@ -5062,15 +5058,83 @@ var useProfitAndLoss = ({
|
|
|
5062
5058
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
5063
5059
|
params: {
|
|
5064
5060
|
businessId,
|
|
5065
|
-
startDate: (0, import_date_fns10.formatISO)(startDate),
|
|
5066
|
-
endDate: (0, import_date_fns10.formatISO)(endDate),
|
|
5061
|
+
startDate: (0, import_date_fns10.formatISO)(startDate.valueOf()),
|
|
5062
|
+
endDate: (0, import_date_fns10.formatISO)(endDate.valueOf()),
|
|
5067
5063
|
tagKey: tagFilter?.key,
|
|
5068
5064
|
tagValues: tagFilter?.values?.join(","),
|
|
5069
5065
|
reportingBasis
|
|
5070
5066
|
}
|
|
5071
5067
|
})
|
|
5072
5068
|
);
|
|
5073
|
-
const
|
|
5069
|
+
const refetch = () => {
|
|
5070
|
+
mutate();
|
|
5071
|
+
};
|
|
5072
|
+
return {
|
|
5073
|
+
startDate,
|
|
5074
|
+
endDate,
|
|
5075
|
+
data: rawData?.data,
|
|
5076
|
+
isLoading,
|
|
5077
|
+
isValidating,
|
|
5078
|
+
error: rawError,
|
|
5079
|
+
refetch
|
|
5080
|
+
};
|
|
5081
|
+
};
|
|
5082
|
+
|
|
5083
|
+
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
5084
|
+
var import_date_fns11 = require("date-fns");
|
|
5085
|
+
var useProfitAndLoss = ({
|
|
5086
|
+
startDate: initialStartDate,
|
|
5087
|
+
endDate: initialEndDate,
|
|
5088
|
+
tagFilter,
|
|
5089
|
+
reportingBasis,
|
|
5090
|
+
fetchMultipleMonths = false
|
|
5091
|
+
} = {
|
|
5092
|
+
startDate: (0, import_date_fns11.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
5093
|
+
endDate: (0, import_date_fns11.endOfMonth)(/* @__PURE__ */ new Date())
|
|
5094
|
+
}) => {
|
|
5095
|
+
const [startDate, setStartDate] = (0, import_react51.useState)(
|
|
5096
|
+
initialStartDate || (0, import_date_fns11.startOfMonth)(Date.now())
|
|
5097
|
+
);
|
|
5098
|
+
const [endDate, setEndDate] = (0, import_react51.useState)(
|
|
5099
|
+
initialEndDate || (0, import_date_fns11.endOfMonth)(Date.now())
|
|
5100
|
+
);
|
|
5101
|
+
const [filters, setFilters] = (0, import_react51.useState)({
|
|
5102
|
+
expenses: void 0,
|
|
5103
|
+
revenue: void 0
|
|
5104
|
+
});
|
|
5105
|
+
const [sidebarScope, setSidebarScope] = (0, import_react51.useState)(void 0);
|
|
5106
|
+
const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
|
|
5107
|
+
startDate,
|
|
5108
|
+
endDate,
|
|
5109
|
+
tagFilter,
|
|
5110
|
+
reportingBasis
|
|
5111
|
+
});
|
|
5112
|
+
const changeDateRange = ({
|
|
5113
|
+
startDate: newStartDate,
|
|
5114
|
+
endDate: newEndDate
|
|
5115
|
+
}) => {
|
|
5116
|
+
newStartDate && setStartDate(newStartDate);
|
|
5117
|
+
newEndDate && setEndDate(newEndDate);
|
|
5118
|
+
};
|
|
5119
|
+
const sortBy = (scope, field, direction) => {
|
|
5120
|
+
setFilters({
|
|
5121
|
+
...filters,
|
|
5122
|
+
[scope]: {
|
|
5123
|
+
...filters[scope],
|
|
5124
|
+
sortBy: field,
|
|
5125
|
+
sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
|
|
5126
|
+
}
|
|
5127
|
+
});
|
|
5128
|
+
};
|
|
5129
|
+
const setFilterTypes = (scope, types) => {
|
|
5130
|
+
setFilters({
|
|
5131
|
+
...filters,
|
|
5132
|
+
[scope]: {
|
|
5133
|
+
...filters[scope],
|
|
5134
|
+
types
|
|
5135
|
+
}
|
|
5136
|
+
});
|
|
5137
|
+
};
|
|
5074
5138
|
const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react51.useMemo)(() => {
|
|
5075
5139
|
if (!data) {
|
|
5076
5140
|
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
@@ -5145,35 +5209,6 @@ var useProfitAndLoss = ({
|
|
|
5145
5209
|
const withShare = applyShare(sorted, total);
|
|
5146
5210
|
return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
|
|
5147
5211
|
}, [data, startDate, filters, sidebarScope]);
|
|
5148
|
-
const changeDateRange = ({
|
|
5149
|
-
startDate: newStartDate,
|
|
5150
|
-
endDate: newEndDate
|
|
5151
|
-
}) => {
|
|
5152
|
-
newStartDate && setStartDate(newStartDate);
|
|
5153
|
-
newEndDate && setEndDate(newEndDate);
|
|
5154
|
-
};
|
|
5155
|
-
const refetch = () => {
|
|
5156
|
-
mutate();
|
|
5157
|
-
};
|
|
5158
|
-
const sortBy = (scope, field, direction) => {
|
|
5159
|
-
setFilters({
|
|
5160
|
-
...filters,
|
|
5161
|
-
[scope]: {
|
|
5162
|
-
...filters[scope],
|
|
5163
|
-
sortBy: field,
|
|
5164
|
-
sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
|
|
5165
|
-
}
|
|
5166
|
-
});
|
|
5167
|
-
};
|
|
5168
|
-
const setFilterTypes = (scope, types) => {
|
|
5169
|
-
setFilters({
|
|
5170
|
-
...filters,
|
|
5171
|
-
[scope]: {
|
|
5172
|
-
...filters[scope],
|
|
5173
|
-
types
|
|
5174
|
-
}
|
|
5175
|
-
});
|
|
5176
|
-
};
|
|
5177
5212
|
return {
|
|
5178
5213
|
data,
|
|
5179
5214
|
filteredDataRevenue,
|
|
@@ -5182,7 +5217,7 @@ var useProfitAndLoss = ({
|
|
|
5182
5217
|
filteredTotalExpenses,
|
|
5183
5218
|
isLoading,
|
|
5184
5219
|
isValidating,
|
|
5185
|
-
error
|
|
5220
|
+
error,
|
|
5186
5221
|
dateRange: { startDate, endDate },
|
|
5187
5222
|
refetch,
|
|
5188
5223
|
changeDateRange,
|
|
@@ -5195,7 +5230,350 @@ var useProfitAndLoss = ({
|
|
|
5195
5230
|
};
|
|
5196
5231
|
|
|
5197
5232
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
5198
|
-
var
|
|
5233
|
+
var import_react54 = __toESM(require("react"));
|
|
5234
|
+
|
|
5235
|
+
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
5236
|
+
var import_react52 = require("react");
|
|
5237
|
+
var import_date_fns12 = require("date-fns");
|
|
5238
|
+
var buildDates = ({ currentDate }) => {
|
|
5239
|
+
const list = [];
|
|
5240
|
+
for (let i = 11; i > 0; i--) {
|
|
5241
|
+
const startDateWithOffset = (0, import_date_fns12.startOfMonth)((0, import_date_fns12.sub)(currentDate, { months: i }));
|
|
5242
|
+
const endDateWithOffset = (0, import_date_fns12.endOfMonth)((0, import_date_fns12.sub)(currentDate, { months: i }));
|
|
5243
|
+
list.push({
|
|
5244
|
+
startDate: startDateWithOffset,
|
|
5245
|
+
endDate: endDateWithOffset
|
|
5246
|
+
});
|
|
5247
|
+
}
|
|
5248
|
+
list.push({
|
|
5249
|
+
startDate: (0, import_date_fns12.startOfMonth)(currentDate),
|
|
5250
|
+
endDate: (0, import_date_fns12.endOfMonth)(currentDate)
|
|
5251
|
+
});
|
|
5252
|
+
return list;
|
|
5253
|
+
};
|
|
5254
|
+
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
5255
|
+
currentDate: /* @__PURE__ */ new Date()
|
|
5256
|
+
}) => {
|
|
5257
|
+
const { businessId } = useLayerContext();
|
|
5258
|
+
const [loaded, setLoaded] = (0, import_react52.useState)("initial");
|
|
5259
|
+
const dates = (0, import_react52.useMemo)(() => {
|
|
5260
|
+
return buildDates({ currentDate });
|
|
5261
|
+
}, [currentDate, businessId, tagFilter, reportingBasis]);
|
|
5262
|
+
const {
|
|
5263
|
+
data: data0,
|
|
5264
|
+
isLoading: isLoading0,
|
|
5265
|
+
error: error0,
|
|
5266
|
+
startDate: startDate0,
|
|
5267
|
+
endDate: endDate0
|
|
5268
|
+
} = useProfitAndLossQuery({
|
|
5269
|
+
startDate: dates[0].startDate,
|
|
5270
|
+
endDate: dates[0].endDate,
|
|
5271
|
+
tagFilter,
|
|
5272
|
+
reportingBasis
|
|
5273
|
+
});
|
|
5274
|
+
const {
|
|
5275
|
+
data: data1,
|
|
5276
|
+
isLoading: isLoading1,
|
|
5277
|
+
error: error1,
|
|
5278
|
+
startDate: startDate1,
|
|
5279
|
+
endDate: endDate1
|
|
5280
|
+
} = useProfitAndLossQuery({
|
|
5281
|
+
startDate: dates[1].startDate,
|
|
5282
|
+
endDate: dates[1].endDate,
|
|
5283
|
+
tagFilter,
|
|
5284
|
+
reportingBasis
|
|
5285
|
+
});
|
|
5286
|
+
const {
|
|
5287
|
+
data: data2,
|
|
5288
|
+
isLoading: isLoading2,
|
|
5289
|
+
error: error2,
|
|
5290
|
+
startDate: startDate2,
|
|
5291
|
+
endDate: endDate2
|
|
5292
|
+
} = useProfitAndLossQuery({
|
|
5293
|
+
startDate: dates[2].startDate,
|
|
5294
|
+
endDate: dates[2].endDate,
|
|
5295
|
+
tagFilter,
|
|
5296
|
+
reportingBasis
|
|
5297
|
+
});
|
|
5298
|
+
const {
|
|
5299
|
+
data: data3,
|
|
5300
|
+
isLoading: isLoading3,
|
|
5301
|
+
error: error3,
|
|
5302
|
+
startDate: startDate3,
|
|
5303
|
+
endDate: endDate3
|
|
5304
|
+
} = useProfitAndLossQuery({
|
|
5305
|
+
startDate: dates[3].startDate,
|
|
5306
|
+
endDate: dates[3].endDate,
|
|
5307
|
+
tagFilter,
|
|
5308
|
+
reportingBasis
|
|
5309
|
+
});
|
|
5310
|
+
const {
|
|
5311
|
+
data: data4,
|
|
5312
|
+
isLoading: isLoading4,
|
|
5313
|
+
error: error4,
|
|
5314
|
+
startDate: startDate4,
|
|
5315
|
+
endDate: endDate4
|
|
5316
|
+
} = useProfitAndLossQuery({
|
|
5317
|
+
startDate: dates[4].startDate,
|
|
5318
|
+
endDate: dates[4].endDate,
|
|
5319
|
+
tagFilter,
|
|
5320
|
+
reportingBasis
|
|
5321
|
+
});
|
|
5322
|
+
const {
|
|
5323
|
+
data: data5,
|
|
5324
|
+
isLoading: isLoading5,
|
|
5325
|
+
error: error5,
|
|
5326
|
+
startDate: startDate5,
|
|
5327
|
+
endDate: endDate5
|
|
5328
|
+
} = useProfitAndLossQuery({
|
|
5329
|
+
startDate: dates[5].startDate,
|
|
5330
|
+
endDate: dates[5].endDate,
|
|
5331
|
+
tagFilter,
|
|
5332
|
+
reportingBasis
|
|
5333
|
+
});
|
|
5334
|
+
const {
|
|
5335
|
+
data: data6,
|
|
5336
|
+
isLoading: isLoading6,
|
|
5337
|
+
error: error6,
|
|
5338
|
+
startDate: startDate6,
|
|
5339
|
+
endDate: endDate6
|
|
5340
|
+
} = useProfitAndLossQuery({
|
|
5341
|
+
startDate: dates[6].startDate,
|
|
5342
|
+
endDate: dates[6].endDate,
|
|
5343
|
+
tagFilter,
|
|
5344
|
+
reportingBasis
|
|
5345
|
+
});
|
|
5346
|
+
const {
|
|
5347
|
+
data: data7,
|
|
5348
|
+
isLoading: isLoading7,
|
|
5349
|
+
error: error7,
|
|
5350
|
+
startDate: startDate7,
|
|
5351
|
+
endDate: endDate7
|
|
5352
|
+
} = useProfitAndLossQuery({
|
|
5353
|
+
startDate: dates[7].startDate,
|
|
5354
|
+
endDate: dates[7].endDate,
|
|
5355
|
+
tagFilter,
|
|
5356
|
+
reportingBasis
|
|
5357
|
+
});
|
|
5358
|
+
const {
|
|
5359
|
+
data: data8,
|
|
5360
|
+
isLoading: isLoading8,
|
|
5361
|
+
error: error8,
|
|
5362
|
+
startDate: startDate8,
|
|
5363
|
+
endDate: endDate8
|
|
5364
|
+
} = useProfitAndLossQuery({
|
|
5365
|
+
startDate: dates[8].startDate,
|
|
5366
|
+
endDate: dates[8].endDate,
|
|
5367
|
+
tagFilter,
|
|
5368
|
+
reportingBasis
|
|
5369
|
+
});
|
|
5370
|
+
const {
|
|
5371
|
+
data: data9,
|
|
5372
|
+
isLoading: isLoading9,
|
|
5373
|
+
error: error9,
|
|
5374
|
+
startDate: startDate9,
|
|
5375
|
+
endDate: endDate9
|
|
5376
|
+
} = useProfitAndLossQuery({
|
|
5377
|
+
startDate: dates[9].startDate,
|
|
5378
|
+
endDate: dates[9].endDate,
|
|
5379
|
+
tagFilter,
|
|
5380
|
+
reportingBasis
|
|
5381
|
+
});
|
|
5382
|
+
const {
|
|
5383
|
+
data: data10,
|
|
5384
|
+
isLoading: isLoading10,
|
|
5385
|
+
error: error10,
|
|
5386
|
+
startDate: startDate10,
|
|
5387
|
+
endDate: endDate10
|
|
5388
|
+
} = useProfitAndLossQuery({
|
|
5389
|
+
startDate: dates[10].startDate,
|
|
5390
|
+
endDate: dates[10].endDate,
|
|
5391
|
+
tagFilter,
|
|
5392
|
+
reportingBasis
|
|
5393
|
+
});
|
|
5394
|
+
const {
|
|
5395
|
+
data: data11,
|
|
5396
|
+
isLoading: isLoading11,
|
|
5397
|
+
error: error11,
|
|
5398
|
+
startDate: startDate11,
|
|
5399
|
+
endDate: endDate11
|
|
5400
|
+
} = useProfitAndLossQuery({
|
|
5401
|
+
startDate: dates[11].startDate,
|
|
5402
|
+
endDate: dates[11].endDate,
|
|
5403
|
+
tagFilter,
|
|
5404
|
+
reportingBasis
|
|
5405
|
+
});
|
|
5406
|
+
const { data, isLoading, error } = (0, import_react52.useMemo)(() => {
|
|
5407
|
+
return {
|
|
5408
|
+
data: [
|
|
5409
|
+
{
|
|
5410
|
+
data: data0,
|
|
5411
|
+
isLoading: isLoading0,
|
|
5412
|
+
error: error0,
|
|
5413
|
+
startDate: startDate0,
|
|
5414
|
+
endDate: endDate0
|
|
5415
|
+
},
|
|
5416
|
+
{
|
|
5417
|
+
data: data1,
|
|
5418
|
+
isLoading: isLoading1,
|
|
5419
|
+
error: error1,
|
|
5420
|
+
startDate: startDate1,
|
|
5421
|
+
endDate: endDate1
|
|
5422
|
+
},
|
|
5423
|
+
{
|
|
5424
|
+
data: data2,
|
|
5425
|
+
isLoading: isLoading2,
|
|
5426
|
+
error: error2,
|
|
5427
|
+
startDate: startDate2,
|
|
5428
|
+
endDate: endDate2
|
|
5429
|
+
},
|
|
5430
|
+
{
|
|
5431
|
+
data: data3,
|
|
5432
|
+
isLoading: isLoading3,
|
|
5433
|
+
error: error3,
|
|
5434
|
+
startDate: startDate3,
|
|
5435
|
+
endDate: endDate3
|
|
5436
|
+
},
|
|
5437
|
+
{
|
|
5438
|
+
data: data4,
|
|
5439
|
+
isLoading: isLoading4,
|
|
5440
|
+
error: error4,
|
|
5441
|
+
startDate: startDate4,
|
|
5442
|
+
endDate: endDate4
|
|
5443
|
+
},
|
|
5444
|
+
{
|
|
5445
|
+
data: data5,
|
|
5446
|
+
isLoading: isLoading5,
|
|
5447
|
+
error: error5,
|
|
5448
|
+
startDate: startDate5,
|
|
5449
|
+
endDate: endDate5
|
|
5450
|
+
},
|
|
5451
|
+
{
|
|
5452
|
+
data: data6,
|
|
5453
|
+
isLoading: isLoading6,
|
|
5454
|
+
error: error6,
|
|
5455
|
+
startDate: startDate6,
|
|
5456
|
+
endDate: endDate6
|
|
5457
|
+
},
|
|
5458
|
+
{
|
|
5459
|
+
data: data7,
|
|
5460
|
+
isLoading: isLoading7,
|
|
5461
|
+
error: error7,
|
|
5462
|
+
startDate: startDate7,
|
|
5463
|
+
endDate: endDate7
|
|
5464
|
+
},
|
|
5465
|
+
{
|
|
5466
|
+
data: data8,
|
|
5467
|
+
isLoading: isLoading8,
|
|
5468
|
+
error: error8,
|
|
5469
|
+
startDate: startDate8,
|
|
5470
|
+
endDate: endDate8
|
|
5471
|
+
},
|
|
5472
|
+
{
|
|
5473
|
+
data: data9,
|
|
5474
|
+
isLoading: isLoading9,
|
|
5475
|
+
error: error9,
|
|
5476
|
+
startDate: startDate9,
|
|
5477
|
+
endDate: endDate9
|
|
5478
|
+
},
|
|
5479
|
+
{
|
|
5480
|
+
data: data10,
|
|
5481
|
+
isLoading: isLoading10,
|
|
5482
|
+
error: error10,
|
|
5483
|
+
startDate: startDate10,
|
|
5484
|
+
endDate: endDate10
|
|
5485
|
+
},
|
|
5486
|
+
{
|
|
5487
|
+
data: data11,
|
|
5488
|
+
isLoading: isLoading11,
|
|
5489
|
+
error: error11,
|
|
5490
|
+
startDate: startDate11,
|
|
5491
|
+
endDate: endDate11
|
|
5492
|
+
}
|
|
5493
|
+
],
|
|
5494
|
+
error: [
|
|
5495
|
+
error0,
|
|
5496
|
+
error1,
|
|
5497
|
+
error2,
|
|
5498
|
+
error3,
|
|
5499
|
+
error4,
|
|
5500
|
+
error5,
|
|
5501
|
+
error6,
|
|
5502
|
+
error7,
|
|
5503
|
+
error8,
|
|
5504
|
+
error9,
|
|
5505
|
+
error10,
|
|
5506
|
+
error11
|
|
5507
|
+
].find((x) => !!x),
|
|
5508
|
+
isLoading: [
|
|
5509
|
+
isLoading0,
|
|
5510
|
+
isLoading1,
|
|
5511
|
+
isLoading2,
|
|
5512
|
+
isLoading3,
|
|
5513
|
+
isLoading4,
|
|
5514
|
+
isLoading5,
|
|
5515
|
+
isLoading6,
|
|
5516
|
+
isLoading7,
|
|
5517
|
+
isLoading8,
|
|
5518
|
+
isLoading9,
|
|
5519
|
+
isLoading10,
|
|
5520
|
+
isLoading11
|
|
5521
|
+
].find((x) => !!x)
|
|
5522
|
+
};
|
|
5523
|
+
}, [
|
|
5524
|
+
data0,
|
|
5525
|
+
data1,
|
|
5526
|
+
data2,
|
|
5527
|
+
data3,
|
|
5528
|
+
data4,
|
|
5529
|
+
data5,
|
|
5530
|
+
data6,
|
|
5531
|
+
data7,
|
|
5532
|
+
data8,
|
|
5533
|
+
data9,
|
|
5534
|
+
data10,
|
|
5535
|
+
data11,
|
|
5536
|
+
isLoading0,
|
|
5537
|
+
isLoading1,
|
|
5538
|
+
isLoading2,
|
|
5539
|
+
isLoading3,
|
|
5540
|
+
isLoading4,
|
|
5541
|
+
isLoading5,
|
|
5542
|
+
isLoading6,
|
|
5543
|
+
isLoading7,
|
|
5544
|
+
isLoading8,
|
|
5545
|
+
isLoading9,
|
|
5546
|
+
isLoading10,
|
|
5547
|
+
isLoading11,
|
|
5548
|
+
error0,
|
|
5549
|
+
error1,
|
|
5550
|
+
error2,
|
|
5551
|
+
error3,
|
|
5552
|
+
error4,
|
|
5553
|
+
error5,
|
|
5554
|
+
error6,
|
|
5555
|
+
error7,
|
|
5556
|
+
error8,
|
|
5557
|
+
error9,
|
|
5558
|
+
error10,
|
|
5559
|
+
error11
|
|
5560
|
+
]);
|
|
5561
|
+
(0, import_react52.useEffect)(() => {
|
|
5562
|
+
if (isLoading && loaded === "initial") {
|
|
5563
|
+
setLoaded("loading");
|
|
5564
|
+
return;
|
|
5565
|
+
}
|
|
5566
|
+
if (!isLoading && data && !data.find((x) => !x.data && !x.error)) {
|
|
5567
|
+
setLoaded("complete");
|
|
5568
|
+
}
|
|
5569
|
+
}, [data, isLoading]);
|
|
5570
|
+
return {
|
|
5571
|
+
data,
|
|
5572
|
+
isLoading,
|
|
5573
|
+
loaded,
|
|
5574
|
+
error
|
|
5575
|
+
};
|
|
5576
|
+
};
|
|
5199
5577
|
|
|
5200
5578
|
// src/utils/format.ts
|
|
5201
5579
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
@@ -5236,211 +5614,188 @@ var humanizeEnum = (text) => {
|
|
|
5236
5614
|
};
|
|
5237
5615
|
|
|
5238
5616
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
5239
|
-
var
|
|
5617
|
+
var import_react53 = __toESM(require("react"));
|
|
5240
5618
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
5241
5619
|
var Indicator = ({
|
|
5242
|
-
viewBox = {},
|
|
5243
5620
|
className,
|
|
5244
5621
|
animateFrom,
|
|
5245
|
-
setAnimateFrom
|
|
5622
|
+
setAnimateFrom,
|
|
5623
|
+
customCursorSize,
|
|
5624
|
+
setCustomCursorSize,
|
|
5625
|
+
viewBox = {}
|
|
5246
5626
|
}) => {
|
|
5247
5627
|
if (!className?.match(/selected/)) {
|
|
5248
5628
|
return null;
|
|
5249
5629
|
}
|
|
5630
|
+
const [opacityIndicator, setOpacityIndicator] = (0, import_react53.useState)(0);
|
|
5250
5631
|
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
5251
5632
|
const margin = width > 12 ? 4 : 1;
|
|
5252
5633
|
const boxWidth = width * 2 + margin;
|
|
5253
5634
|
const multiplier = width > 12 ? 1.2 : 1;
|
|
5254
5635
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
5255
|
-
const borderRadius =
|
|
5256
|
-
|
|
5636
|
+
const borderRadius = 6;
|
|
5637
|
+
const rectWidth = `${boxWidth * multiplier}px`;
|
|
5638
|
+
const rectHeight = "calc(100% - 38px)";
|
|
5639
|
+
(0, import_react53.useEffect)(() => {
|
|
5640
|
+
if (Math.abs(animateTo - animateFrom) < 30) {
|
|
5641
|
+
setOpacityIndicator(0);
|
|
5642
|
+
}
|
|
5257
5643
|
setAnimateFrom(animateTo);
|
|
5644
|
+
setTimeout(() => {
|
|
5645
|
+
setOpacityIndicator(1);
|
|
5646
|
+
}, 200);
|
|
5258
5647
|
}, [animateTo]);
|
|
5648
|
+
const rectRef = (ref) => {
|
|
5649
|
+
if (ref) {
|
|
5650
|
+
const refRectWidth = ref.getBoundingClientRect().width;
|
|
5651
|
+
const refRectHeight = ref.getBoundingClientRect().height;
|
|
5652
|
+
if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
|
|
5653
|
+
setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
};
|
|
5259
5657
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
5260
|
-
return /* @__PURE__ */
|
|
5658
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
5261
5659
|
"rect",
|
|
5262
5660
|
{
|
|
5661
|
+
ref: rectRef,
|
|
5263
5662
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
5264
5663
|
rx: borderRadius,
|
|
5265
5664
|
ry: borderRadius,
|
|
5266
5665
|
style: {
|
|
5267
|
-
width:
|
|
5666
|
+
width: rectWidth,
|
|
5268
5667
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
5269
5668
|
x: actualX - xOffset,
|
|
5270
|
-
y:
|
|
5271
|
-
height:
|
|
5669
|
+
y: 1,
|
|
5670
|
+
height: rectHeight,
|
|
5671
|
+
opacity: opacityIndicator
|
|
5272
5672
|
}
|
|
5273
5673
|
}
|
|
5274
5674
|
);
|
|
5275
5675
|
};
|
|
5276
5676
|
|
|
5277
5677
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
5278
|
-
var
|
|
5678
|
+
var import_classnames27 = __toESM(require("classnames"));
|
|
5679
|
+
var import_date_fns13 = require("date-fns");
|
|
5279
5680
|
var import_recharts = require("recharts");
|
|
5280
5681
|
var barGap = 4;
|
|
5281
5682
|
var barSize = 20;
|
|
5282
5683
|
var ProfitAndLossChart = () => {
|
|
5283
5684
|
const { getColor } = useLayerContext();
|
|
5284
|
-
const { changeDateRange, dateRange } = (0,
|
|
5285
|
-
const
|
|
5685
|
+
const { changeDateRange, dateRange } = (0, import_react54.useContext)(ProfitAndLoss.Context);
|
|
5686
|
+
const [customCursorSize, setCustomCursorSize] = (0, import_react54.useState)({
|
|
5687
|
+
width: 0,
|
|
5688
|
+
height: 0,
|
|
5689
|
+
x: 0
|
|
5690
|
+
});
|
|
5691
|
+
const [barAnimActive, setBarAnimActive] = (0, import_react54.useState)(true);
|
|
5286
5692
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
5287
5693
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
5288
|
-
const
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
})?.data
|
|
5300
|
-
);
|
|
5301
|
-
monthData.push(
|
|
5302
|
-
useProfitAndLoss({
|
|
5303
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 9 })),
|
|
5304
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 9 }))
|
|
5305
|
-
})?.data
|
|
5306
|
-
);
|
|
5307
|
-
monthData.push(
|
|
5308
|
-
useProfitAndLoss({
|
|
5309
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 8 })),
|
|
5310
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 8 }))
|
|
5311
|
-
})?.data
|
|
5312
|
-
);
|
|
5313
|
-
monthData.push(
|
|
5314
|
-
useProfitAndLoss({
|
|
5315
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 7 })),
|
|
5316
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 7 }))
|
|
5317
|
-
})?.data
|
|
5318
|
-
);
|
|
5319
|
-
monthData.push(
|
|
5320
|
-
useProfitAndLoss({
|
|
5321
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 6 })),
|
|
5322
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 6 }))
|
|
5323
|
-
})?.data
|
|
5324
|
-
);
|
|
5325
|
-
monthData.push(
|
|
5326
|
-
useProfitAndLoss({
|
|
5327
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 5 })),
|
|
5328
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 5 }))
|
|
5329
|
-
})?.data
|
|
5330
|
-
);
|
|
5331
|
-
monthData.push(
|
|
5332
|
-
useProfitAndLoss({
|
|
5333
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 4 })),
|
|
5334
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 4 }))
|
|
5335
|
-
})?.data
|
|
5336
|
-
);
|
|
5337
|
-
monthData.push(
|
|
5338
|
-
useProfitAndLoss({
|
|
5339
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 3 })),
|
|
5340
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 3 }))
|
|
5341
|
-
})?.data
|
|
5342
|
-
);
|
|
5343
|
-
monthData.push(
|
|
5344
|
-
useProfitAndLoss({
|
|
5345
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 2 })),
|
|
5346
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 2 }))
|
|
5347
|
-
})?.data
|
|
5348
|
-
);
|
|
5349
|
-
monthData.push(
|
|
5350
|
-
useProfitAndLoss({
|
|
5351
|
-
startDate: (0, import_date_fns11.startOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 1 })),
|
|
5352
|
-
endDate: (0, import_date_fns11.endOfMonth)((0, import_date_fns11.sub)(thisMonth, { months: 1 }))
|
|
5353
|
-
})?.data
|
|
5354
|
-
);
|
|
5355
|
-
monthData.push(
|
|
5356
|
-
useProfitAndLoss({
|
|
5357
|
-
startDate: thisMonth,
|
|
5358
|
-
endDate: (0, import_date_fns11.endOfMonth)(thisMonth)
|
|
5359
|
-
})?.data
|
|
5360
|
-
);
|
|
5361
|
-
const getMonthName = (pnl) => pnl ? (0, import_date_fns11.format)((0, import_date_fns11.parseISO)(pnl.start_date), "LLL") : "";
|
|
5694
|
+
const { data, loaded } = useProfitAndLossLTM({
|
|
5695
|
+
currentDate: (0, import_date_fns13.startOfMonth)(Date.now())
|
|
5696
|
+
});
|
|
5697
|
+
(0, import_react54.useEffect)(() => {
|
|
5698
|
+
if (loaded === "complete") {
|
|
5699
|
+
setTimeout(() => {
|
|
5700
|
+
setBarAnimActive(false);
|
|
5701
|
+
}, 1e3);
|
|
5702
|
+
}
|
|
5703
|
+
}, [loaded]);
|
|
5704
|
+
const getMonthName = (pnl) => pnl ? (0, import_date_fns13.format)((0, import_date_fns13.parseISO)(pnl.start_date), "LLL") : "";
|
|
5362
5705
|
const summarizePnL = (pnl) => ({
|
|
5363
5706
|
name: getMonthName(pnl),
|
|
5364
5707
|
revenue: pnl?.income.value || 0,
|
|
5365
5708
|
expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
|
|
5366
5709
|
netProfit: pnl?.net_profit || 0,
|
|
5367
|
-
selected: !!pnl && (0,
|
|
5710
|
+
selected: !!pnl && (0, import_date_fns13.parseISO)(pnl.start_date).getMonth() >= startSelectionMonth && (0, import_date_fns13.parseISO)(pnl.end_date).getMonth() <= endSelectionMonth
|
|
5368
5711
|
});
|
|
5369
5712
|
const onClick = ({ activeTooltipIndex }) => {
|
|
5370
|
-
const selection =
|
|
5371
|
-
if (selection) {
|
|
5372
|
-
const { start_date
|
|
5713
|
+
const selection = data[activeTooltipIndex || -1];
|
|
5714
|
+
if (selection && selection.data) {
|
|
5715
|
+
const { start_date, end_date } = selection.data;
|
|
5373
5716
|
changeDateRange({
|
|
5374
|
-
startDate: (0,
|
|
5375
|
-
endDate: (0,
|
|
5717
|
+
startDate: (0, import_date_fns13.parseISO)(start_date),
|
|
5718
|
+
endDate: (0, import_date_fns13.parseISO)(end_date)
|
|
5376
5719
|
});
|
|
5377
5720
|
}
|
|
5378
5721
|
};
|
|
5379
|
-
const CustomTooltip = ({
|
|
5380
|
-
active,
|
|
5381
|
-
payload,
|
|
5382
|
-
label
|
|
5383
|
-
}) => {
|
|
5722
|
+
const CustomTooltip = ({ active, payload }) => {
|
|
5384
5723
|
if (active && payload && payload.length) {
|
|
5385
5724
|
const netProfit = payload[0].payload.netProfit ?? 0;
|
|
5386
5725
|
const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
|
|
5387
|
-
return /* @__PURE__ */
|
|
5726
|
+
return /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__chart__tooltip" }, loaded !== "complete" ? /* @__PURE__ */ import_react54.default.createElement(Text, null, "Loading...") : /* @__PURE__ */ import_react54.default.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ import_react54.default.createElement("li", null, /* @__PURE__ */ import_react54.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ import_react54.default.createElement("li", null, /* @__PURE__ */ import_react54.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ import_react54.default.createElement("li", null, /* @__PURE__ */ import_react54.default.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ import_react54.default.createElement(
|
|
5727
|
+
"span",
|
|
5728
|
+
{
|
|
5729
|
+
className: `Layer__chart__tooltip-value ${netProfitClass}`
|
|
5730
|
+
},
|
|
5731
|
+
"$",
|
|
5732
|
+
centsToDollars(netProfit)
|
|
5733
|
+
))));
|
|
5388
5734
|
}
|
|
5389
5735
|
return null;
|
|
5390
5736
|
};
|
|
5391
5737
|
const CustomizedCursor = (props) => {
|
|
5392
|
-
const { x,
|
|
5393
|
-
|
|
5738
|
+
const { x, y } = props;
|
|
5739
|
+
const { width, height } = customCursorSize;
|
|
5740
|
+
const offsetX = width * 0.1;
|
|
5741
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
5394
5742
|
import_recharts.Rectangle,
|
|
5395
5743
|
{
|
|
5396
|
-
fill:
|
|
5744
|
+
fill: "#F7F8FA",
|
|
5397
5745
|
stroke: "none",
|
|
5398
|
-
x: x +
|
|
5399
|
-
y
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5746
|
+
x: x + offsetX,
|
|
5747
|
+
y,
|
|
5748
|
+
width,
|
|
5749
|
+
height,
|
|
5750
|
+
radius: 6,
|
|
5403
5751
|
className: "Layer__chart__tooltip-cursor"
|
|
5404
5752
|
}
|
|
5405
5753
|
);
|
|
5406
5754
|
};
|
|
5407
|
-
const
|
|
5408
|
-
(
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5755
|
+
const theData = (0, import_react54.useMemo)(() => {
|
|
5756
|
+
if (loaded !== "complete") {
|
|
5757
|
+
return data?.map((x) => ({
|
|
5758
|
+
name: (0, import_date_fns13.format)(x.startDate, "LLL"),
|
|
5759
|
+
revenue: 1,
|
|
5760
|
+
expenses: 1,
|
|
5761
|
+
netProfit: 0,
|
|
5762
|
+
selected: false
|
|
5763
|
+
}));
|
|
5764
|
+
}
|
|
5765
|
+
return data?.map((x) => summarizePnL(x.data));
|
|
5766
|
+
}, [startSelectionMonth, endSelectionMonth, loaded]);
|
|
5767
|
+
const [animateFrom, setAnimateFrom] = (0, import_react54.useState)(-1);
|
|
5768
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
5417
5769
|
import_recharts.ResponsiveContainer,
|
|
5418
5770
|
{
|
|
5419
|
-
className:
|
|
5771
|
+
className: (0, import_classnames27.default)(
|
|
5772
|
+
"Layer__chart-container",
|
|
5773
|
+
loaded !== "complete" && "Layer__chart-container--loading"
|
|
5774
|
+
),
|
|
5420
5775
|
width: "100%",
|
|
5421
5776
|
height: "100%",
|
|
5422
5777
|
minHeight: 200
|
|
5423
5778
|
},
|
|
5424
|
-
/* @__PURE__ */
|
|
5779
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5425
5780
|
import_recharts.BarChart,
|
|
5426
5781
|
{
|
|
5427
5782
|
margin: { left: 12, right: 12, bottom: 12 },
|
|
5428
|
-
data,
|
|
5783
|
+
data: theData,
|
|
5429
5784
|
onClick,
|
|
5430
5785
|
barGap,
|
|
5431
5786
|
className: "Layer__profit-and-loss-chart"
|
|
5432
5787
|
},
|
|
5433
|
-
/* @__PURE__ */
|
|
5788
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5434
5789
|
import_recharts.Tooltip,
|
|
5435
5790
|
{
|
|
5436
5791
|
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
5437
|
-
content: /* @__PURE__ */
|
|
5438
|
-
cursor: /* @__PURE__ */
|
|
5792
|
+
content: /* @__PURE__ */ import_react54.default.createElement(CustomTooltip, null),
|
|
5793
|
+
cursor: /* @__PURE__ */ import_react54.default.createElement(CustomizedCursor, null),
|
|
5439
5794
|
animationDuration: 100,
|
|
5440
5795
|
animationEasing: "ease-out"
|
|
5441
5796
|
}
|
|
5442
5797
|
),
|
|
5443
|
-
/* @__PURE__ */
|
|
5798
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5444
5799
|
import_recharts.CartesianGrid,
|
|
5445
5800
|
{
|
|
5446
5801
|
vertical: false,
|
|
@@ -5448,12 +5803,12 @@ var ProfitAndLossChart = () => {
|
|
|
5448
5803
|
strokeDasharray: "5 5"
|
|
5449
5804
|
}
|
|
5450
5805
|
),
|
|
5451
|
-
/* @__PURE__ */
|
|
5806
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5452
5807
|
import_recharts.Legend,
|
|
5453
5808
|
{
|
|
5454
|
-
verticalAlign: "
|
|
5809
|
+
verticalAlign: "bottom",
|
|
5455
5810
|
align: "left",
|
|
5456
|
-
wrapperStyle: {
|
|
5811
|
+
wrapperStyle: { bottom: 0 },
|
|
5457
5812
|
payload: [
|
|
5458
5813
|
{
|
|
5459
5814
|
value: "Revenue",
|
|
@@ -5468,46 +5823,50 @@ var ProfitAndLossChart = () => {
|
|
|
5468
5823
|
]
|
|
5469
5824
|
}
|
|
5470
5825
|
),
|
|
5471
|
-
/* @__PURE__ */
|
|
5472
|
-
/* @__PURE__ */
|
|
5826
|
+
/* @__PURE__ */ import_react54.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
5827
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5473
5828
|
import_recharts.Bar,
|
|
5474
5829
|
{
|
|
5475
5830
|
dataKey: "revenue",
|
|
5476
5831
|
barSize,
|
|
5477
|
-
isAnimationActive:
|
|
5832
|
+
isAnimationActive: barAnimActive,
|
|
5478
5833
|
radius: [2, 2, 0, 0],
|
|
5479
5834
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
5480
5835
|
},
|
|
5481
|
-
/* @__PURE__ */
|
|
5836
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5482
5837
|
import_recharts.LabelList,
|
|
5483
5838
|
{
|
|
5484
|
-
content: /* @__PURE__ */
|
|
5839
|
+
content: /* @__PURE__ */ import_react54.default.createElement(
|
|
5485
5840
|
Indicator,
|
|
5486
5841
|
{
|
|
5842
|
+
setCustomCursorSize: (width, height, x) => setCustomCursorSize({ width, height, x }),
|
|
5843
|
+
customCursorSize,
|
|
5487
5844
|
animateFrom,
|
|
5488
5845
|
setAnimateFrom
|
|
5489
5846
|
}
|
|
5490
5847
|
)
|
|
5491
5848
|
}
|
|
5492
5849
|
),
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5850
|
+
theData?.map((entry) => {
|
|
5851
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
5852
|
+
import_recharts.Cell,
|
|
5853
|
+
{
|
|
5854
|
+
key: entry.name,
|
|
5855
|
+
className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
|
|
5856
|
+
}
|
|
5857
|
+
);
|
|
5858
|
+
})
|
|
5500
5859
|
),
|
|
5501
|
-
/* @__PURE__ */
|
|
5860
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5502
5861
|
import_recharts.Bar,
|
|
5503
5862
|
{
|
|
5504
5863
|
dataKey: "expenses",
|
|
5505
5864
|
barSize,
|
|
5506
|
-
isAnimationActive:
|
|
5865
|
+
isAnimationActive: barAnimActive,
|
|
5507
5866
|
radius: [2, 2, 0, 0],
|
|
5508
5867
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
5509
5868
|
},
|
|
5510
|
-
|
|
5869
|
+
theData.map((entry) => /* @__PURE__ */ import_react54.default.createElement(
|
|
5511
5870
|
import_recharts.Cell,
|
|
5512
5871
|
{
|
|
5513
5872
|
key: entry.name,
|
|
@@ -5520,19 +5879,19 @@ var ProfitAndLossChart = () => {
|
|
|
5520
5879
|
};
|
|
5521
5880
|
|
|
5522
5881
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5882
|
+
var import_react55 = __toESM(require("react"));
|
|
5883
|
+
var import_date_fns14 = require("date-fns");
|
|
5525
5884
|
var ProfitAndLossDatePicker = () => {
|
|
5526
|
-
const { changeDateRange, dateRange } = (0,
|
|
5527
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5528
|
-
const [localDate, setLocalDate] = (0,
|
|
5529
|
-
const [nextOpacity, setNextOpacity] = (0,
|
|
5530
|
-
const [currentOpacity, setCurrentOpacity] = (0,
|
|
5531
|
-
const [transformStyle, setTransformStyle] = (0,
|
|
5885
|
+
const { changeDateRange, dateRange } = (0, import_react55.useContext)(ProfitAndLoss.Context);
|
|
5886
|
+
const [isAnimating, setIsAnimating] = (0, import_react55.useState)(false);
|
|
5887
|
+
const [localDate, setLocalDate] = (0, import_react55.useState)(dateRange.startDate);
|
|
5888
|
+
const [nextOpacity, setNextOpacity] = (0, import_react55.useState)(0);
|
|
5889
|
+
const [currentOpacity, setCurrentOpacity] = (0, import_react55.useState)(1);
|
|
5890
|
+
const [transformStyle, setTransformStyle] = (0, import_react55.useState)({
|
|
5532
5891
|
transform: "translateX(33%)",
|
|
5533
5892
|
transition: "ease"
|
|
5534
5893
|
});
|
|
5535
|
-
(0,
|
|
5894
|
+
(0, import_react55.useEffect)(() => {
|
|
5536
5895
|
if (dateRange.startDate !== localDate && !isAnimating) {
|
|
5537
5896
|
setLocalDate(dateRange.startDate);
|
|
5538
5897
|
setTransformStyle({ transform: "translateX(33%)", transition: "none" });
|
|
@@ -5543,13 +5902,13 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5543
5902
|
return;
|
|
5544
5903
|
setIsAnimating(true);
|
|
5545
5904
|
setNextOpacity(1);
|
|
5546
|
-
const newDate = (0,
|
|
5905
|
+
const newDate = (0, import_date_fns14.add)(localDate, { months: monthsToAdd });
|
|
5547
5906
|
if (monthsToAdd === -1) {
|
|
5548
5907
|
setCurrentOpacity(0);
|
|
5549
5908
|
}
|
|
5550
5909
|
changeDateRange({
|
|
5551
|
-
startDate: (0,
|
|
5552
|
-
endDate: (0,
|
|
5910
|
+
startDate: (0, import_date_fns14.startOfMonth)(newDate),
|
|
5911
|
+
endDate: (0, import_date_fns14.endOfMonth)(newDate)
|
|
5553
5912
|
});
|
|
5554
5913
|
const translateXValue = monthsToAdd > 0 ? "0%" : "66%";
|
|
5555
5914
|
setTransformStyle({
|
|
@@ -5567,67 +5926,67 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5567
5926
|
setCurrentOpacity(1);
|
|
5568
5927
|
}, 300);
|
|
5569
5928
|
};
|
|
5570
|
-
const currentLabel = (0,
|
|
5571
|
-
const prevLabel = (0,
|
|
5572
|
-
const nextLabel = (0,
|
|
5573
|
-
return /* @__PURE__ */
|
|
5929
|
+
const currentLabel = (0, import_date_fns14.format)(localDate, "LLLL, y");
|
|
5930
|
+
const prevLabel = (0, import_date_fns14.format)((0, import_date_fns14.add)(localDate, { months: -1 }), "LLLL, y");
|
|
5931
|
+
const nextLabel = (0, import_date_fns14.format)((0, import_date_fns14.add)(localDate, { months: 1 }), "LLLL, y");
|
|
5932
|
+
return /* @__PURE__ */ import_react55.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react55.default.createElement(
|
|
5574
5933
|
"div",
|
|
5575
5934
|
{
|
|
5576
|
-
className: "Layer__profit-and-loss-date-
|
|
5935
|
+
className: "Layer__profit-and-loss-date-picker__labels-container",
|
|
5936
|
+
style: transformStyle
|
|
5577
5937
|
},
|
|
5578
|
-
/* @__PURE__ */
|
|
5938
|
+
/* @__PURE__ */ import_react55.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, prevLabel),
|
|
5939
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5579
5940
|
"span",
|
|
5580
5941
|
{
|
|
5581
5942
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
5582
5943
|
style: { opacity: currentOpacity }
|
|
5583
5944
|
},
|
|
5584
5945
|
currentLabel
|
|
5585
|
-
),
|
|
5946
|
+
),
|
|
5947
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5586
5948
|
"span",
|
|
5587
5949
|
{
|
|
5588
5950
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
5589
5951
|
style: { opacity: nextOpacity }
|
|
5590
5952
|
},
|
|
5591
5953
|
nextLabel
|
|
5592
|
-
)
|
|
5593
|
-
|
|
5594
|
-
|
|
5954
|
+
)
|
|
5955
|
+
), /* @__PURE__ */ import_react55.default.createElement(
|
|
5956
|
+
"button",
|
|
5957
|
+
{
|
|
5958
|
+
"aria-label": "View Previous Month",
|
|
5959
|
+
className: "Layer__profit-and-loss-date-picker__button",
|
|
5960
|
+
onClick: () => change(-1),
|
|
5961
|
+
disabled: isAnimating
|
|
5962
|
+
},
|
|
5963
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5964
|
+
ChevronLeft_default,
|
|
5595
5965
|
{
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
"button",
|
|
5966
|
+
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5967
|
+
size: 16
|
|
5968
|
+
}
|
|
5969
|
+
)
|
|
5970
|
+
), /* @__PURE__ */ import_react55.default.createElement(
|
|
5971
|
+
"button",
|
|
5972
|
+
{
|
|
5973
|
+
"aria-label": "View Next Month",
|
|
5974
|
+
className: "Layer__profit-and-loss-date-picker__button",
|
|
5975
|
+
onClick: () => change(1),
|
|
5976
|
+
disabled: isAnimating
|
|
5977
|
+
},
|
|
5978
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5979
|
+
ChevronRight_default,
|
|
5611
5980
|
{
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
/* @__PURE__ */ import_react54.default.createElement(
|
|
5618
|
-
ChevronRight_default,
|
|
5619
|
-
{
|
|
5620
|
-
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5621
|
-
size: 16
|
|
5622
|
-
}
|
|
5623
|
-
)
|
|
5624
|
-
),
|
|
5625
|
-
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-date-picker__effect-blur" })
|
|
5626
|
-
);
|
|
5981
|
+
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5982
|
+
size: 16
|
|
5983
|
+
}
|
|
5984
|
+
)
|
|
5985
|
+
), /* @__PURE__ */ import_react55.default.createElement("div", { className: "Layer__profit-and-loss-date-picker__effect-blur" }));
|
|
5627
5986
|
};
|
|
5628
5987
|
|
|
5629
5988
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5630
|
-
var
|
|
5989
|
+
var import_react59 = __toESM(require("react"));
|
|
5631
5990
|
|
|
5632
5991
|
// src/icons/X.tsx
|
|
5633
5992
|
var React68 = __toESM(require("react"));
|
|
@@ -5663,7 +6022,7 @@ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React68.createElement(
|
|
|
5663
6022
|
var X_default = X;
|
|
5664
6023
|
|
|
5665
6024
|
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5666
|
-
var
|
|
6025
|
+
var import_react56 = __toESM(require("react"));
|
|
5667
6026
|
|
|
5668
6027
|
// src/config/charts.ts
|
|
5669
6028
|
var INACTIVE_OPACITY_LEVELS = [
|
|
@@ -5762,7 +6121,7 @@ var DetailedChart = ({
|
|
|
5762
6121
|
date,
|
|
5763
6122
|
isLoading
|
|
5764
6123
|
}) => {
|
|
5765
|
-
const chartData = (0,
|
|
6124
|
+
const chartData = (0, import_react56.useMemo)(() => {
|
|
5766
6125
|
if (!filteredData) {
|
|
5767
6126
|
return [];
|
|
5768
6127
|
}
|
|
@@ -5780,7 +6139,7 @@ var DetailedChart = ({
|
|
|
5780
6139
|
});
|
|
5781
6140
|
}, [filteredData, isLoading]);
|
|
5782
6141
|
const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
|
|
5783
|
-
return /* @__PURE__ */
|
|
6142
|
+
return /* @__PURE__ */ import_react56.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react56.default.createElement("div", { className: "header--tablet" }, /* @__PURE__ */ import_react56.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react56.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react56.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react56.default.createElement(import_recharts2.ResponsiveContainer, null, /* @__PURE__ */ import_react56.default.createElement(import_recharts2.PieChart, null, !isLoading && !noValue ? /* @__PURE__ */ import_react56.default.createElement(
|
|
5784
6143
|
import_recharts2.Pie,
|
|
5785
6144
|
{
|
|
5786
6145
|
data: chartData,
|
|
@@ -5805,7 +6164,7 @@ var DetailedChart = ({
|
|
|
5805
6164
|
fill = void 0;
|
|
5806
6165
|
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5807
6166
|
}
|
|
5808
|
-
return /* @__PURE__ */
|
|
6167
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5809
6168
|
import_recharts2.Cell,
|
|
5810
6169
|
{
|
|
5811
6170
|
key: `cell-${index}`,
|
|
@@ -5817,7 +6176,7 @@ var DetailedChart = ({
|
|
|
5817
6176
|
}
|
|
5818
6177
|
);
|
|
5819
6178
|
}),
|
|
5820
|
-
/* @__PURE__ */
|
|
6179
|
+
/* @__PURE__ */ import_react56.default.createElement(
|
|
5821
6180
|
import_recharts2.Label,
|
|
5822
6181
|
{
|
|
5823
6182
|
position: "center",
|
|
@@ -5838,7 +6197,7 @@ var DetailedChart = ({
|
|
|
5838
6197
|
if (hoveredItem) {
|
|
5839
6198
|
text = hoveredItem;
|
|
5840
6199
|
}
|
|
5841
|
-
return /* @__PURE__ */
|
|
6200
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5842
6201
|
import_recharts2.Text,
|
|
5843
6202
|
{
|
|
5844
6203
|
...positioningProps,
|
|
@@ -5849,7 +6208,7 @@ var DetailedChart = ({
|
|
|
5849
6208
|
}
|
|
5850
6209
|
}
|
|
5851
6210
|
),
|
|
5852
|
-
/* @__PURE__ */
|
|
6211
|
+
/* @__PURE__ */ import_react56.default.createElement(
|
|
5853
6212
|
import_recharts2.Label,
|
|
5854
6213
|
{
|
|
5855
6214
|
position: "center",
|
|
@@ -5872,7 +6231,7 @@ var DetailedChart = ({
|
|
|
5872
6231
|
(x) => x.display_name === hoveredItem
|
|
5873
6232
|
)?.value;
|
|
5874
6233
|
}
|
|
5875
|
-
return /* @__PURE__ */
|
|
6234
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5876
6235
|
import_recharts2.Text,
|
|
5877
6236
|
{
|
|
5878
6237
|
...positioningProps,
|
|
@@ -5883,7 +6242,7 @@ var DetailedChart = ({
|
|
|
5883
6242
|
}
|
|
5884
6243
|
}
|
|
5885
6244
|
),
|
|
5886
|
-
/* @__PURE__ */
|
|
6245
|
+
/* @__PURE__ */ import_react56.default.createElement(
|
|
5887
6246
|
import_recharts2.Label,
|
|
5888
6247
|
{
|
|
5889
6248
|
position: "center",
|
|
@@ -5902,7 +6261,7 @@ var DetailedChart = ({
|
|
|
5902
6261
|
verticalAnchor: "middle"
|
|
5903
6262
|
};
|
|
5904
6263
|
if (hoveredItem) {
|
|
5905
|
-
return /* @__PURE__ */
|
|
6264
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5906
6265
|
import_recharts2.Text,
|
|
5907
6266
|
{
|
|
5908
6267
|
...positioningProps,
|
|
@@ -5919,7 +6278,7 @@ var DetailedChart = ({
|
|
|
5919
6278
|
}
|
|
5920
6279
|
}
|
|
5921
6280
|
)
|
|
5922
|
-
) : null, !isLoading && noValue ? /* @__PURE__ */
|
|
6281
|
+
) : null, !isLoading && noValue ? /* @__PURE__ */ import_react56.default.createElement(
|
|
5923
6282
|
import_recharts2.Pie,
|
|
5924
6283
|
{
|
|
5925
6284
|
data: [{ name: "Total", value: 1 }],
|
|
@@ -5934,7 +6293,7 @@ var DetailedChart = ({
|
|
|
5934
6293
|
animationDuration: 200,
|
|
5935
6294
|
animationEasing: "ease-in-out"
|
|
5936
6295
|
},
|
|
5937
|
-
/* @__PURE__ */
|
|
6296
|
+
/* @__PURE__ */ import_react56.default.createElement(
|
|
5938
6297
|
import_recharts2.Label,
|
|
5939
6298
|
{
|
|
5940
6299
|
position: "center",
|
|
@@ -5955,7 +6314,7 @@ var DetailedChart = ({
|
|
|
5955
6314
|
if (hoveredItem) {
|
|
5956
6315
|
text = hoveredItem;
|
|
5957
6316
|
}
|
|
5958
|
-
return /* @__PURE__ */
|
|
6317
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5959
6318
|
import_recharts2.Text,
|
|
5960
6319
|
{
|
|
5961
6320
|
...positioningProps,
|
|
@@ -5966,7 +6325,7 @@ var DetailedChart = ({
|
|
|
5966
6325
|
}
|
|
5967
6326
|
}
|
|
5968
6327
|
),
|
|
5969
|
-
/* @__PURE__ */
|
|
6328
|
+
/* @__PURE__ */ import_react56.default.createElement(
|
|
5970
6329
|
import_recharts2.Label,
|
|
5971
6330
|
{
|
|
5972
6331
|
position: "center",
|
|
@@ -5989,7 +6348,7 @@ var DetailedChart = ({
|
|
|
5989
6348
|
(x) => x.display_name === hoveredItem
|
|
5990
6349
|
)?.value;
|
|
5991
6350
|
}
|
|
5992
|
-
return /* @__PURE__ */
|
|
6351
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5993
6352
|
import_recharts2.Text,
|
|
5994
6353
|
{
|
|
5995
6354
|
...positioningProps,
|
|
@@ -6000,7 +6359,7 @@ var DetailedChart = ({
|
|
|
6000
6359
|
}
|
|
6001
6360
|
}
|
|
6002
6361
|
)
|
|
6003
|
-
) : null, isLoading ? /* @__PURE__ */
|
|
6362
|
+
) : null, isLoading ? /* @__PURE__ */ import_react56.default.createElement(
|
|
6004
6363
|
import_recharts2.Pie,
|
|
6005
6364
|
{
|
|
6006
6365
|
data: [{ name: "loading...", value: 1 }],
|
|
@@ -6019,7 +6378,7 @@ var DetailedChart = ({
|
|
|
6019
6378
|
};
|
|
6020
6379
|
|
|
6021
6380
|
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
6022
|
-
var
|
|
6381
|
+
var import_react57 = __toESM(require("react"));
|
|
6023
6382
|
|
|
6024
6383
|
// src/icons/SortArrows.tsx
|
|
6025
6384
|
var React70 = __toESM(require("react"));
|
|
@@ -6033,7 +6392,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElem
|
|
|
6033
6392
|
width: size,
|
|
6034
6393
|
height: size
|
|
6035
6394
|
},
|
|
6036
|
-
/* @__PURE__ */ React70.createElement("g", {
|
|
6395
|
+
/* @__PURE__ */ React70.createElement("g", { clipPath: "url(#clip0_1758_75388)" }, /* @__PURE__ */ React70.createElement(
|
|
6037
6396
|
"path",
|
|
6038
6397
|
{
|
|
6039
6398
|
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
@@ -6083,7 +6442,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElem
|
|
|
6083
6442
|
var SortArrows_default = SortArrows;
|
|
6084
6443
|
|
|
6085
6444
|
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
6086
|
-
var
|
|
6445
|
+
var import_classnames28 = __toESM(require("classnames"));
|
|
6087
6446
|
var DetailedTable = ({
|
|
6088
6447
|
filteredData,
|
|
6089
6448
|
sidebarScope,
|
|
@@ -6093,52 +6452,52 @@ var DetailedTable = ({
|
|
|
6093
6452
|
setHoveredItem
|
|
6094
6453
|
}) => {
|
|
6095
6454
|
const buildColClass = (column) => {
|
|
6096
|
-
return (0,
|
|
6455
|
+
return (0, import_classnames28.default)(
|
|
6097
6456
|
"Layer__sortable-col",
|
|
6098
6457
|
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
6099
6458
|
);
|
|
6100
6459
|
};
|
|
6101
|
-
return /* @__PURE__ */
|
|
6460
|
+
return /* @__PURE__ */ import_react57.default.createElement("div", { className: "details-container" }, /* @__PURE__ */ import_react57.default.createElement("div", { className: "table" }, /* @__PURE__ */ import_react57.default.createElement("table", null, /* @__PURE__ */ import_react57.default.createElement("thead", null, /* @__PURE__ */ import_react57.default.createElement("tr", null, /* @__PURE__ */ import_react57.default.createElement(
|
|
6102
6461
|
"th",
|
|
6103
6462
|
{
|
|
6104
6463
|
className: buildColClass("category"),
|
|
6105
6464
|
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
6106
6465
|
},
|
|
6107
6466
|
"Expense/Sale ",
|
|
6108
|
-
/* @__PURE__ */
|
|
6109
|
-
), /* @__PURE__ */
|
|
6467
|
+
/* @__PURE__ */ import_react57.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6468
|
+
), /* @__PURE__ */ import_react57.default.createElement(
|
|
6110
6469
|
"th",
|
|
6111
6470
|
{
|
|
6112
6471
|
className: buildColClass("type"),
|
|
6113
6472
|
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
6114
6473
|
},
|
|
6115
6474
|
"Type ",
|
|
6116
|
-
/* @__PURE__ */
|
|
6117
|
-
), /* @__PURE__ */
|
|
6475
|
+
/* @__PURE__ */ import_react57.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6476
|
+
), /* @__PURE__ */ import_react57.default.createElement("th", null), /* @__PURE__ */ import_react57.default.createElement(
|
|
6118
6477
|
"th",
|
|
6119
6478
|
{
|
|
6120
6479
|
className: buildColClass("value"),
|
|
6121
6480
|
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
6122
6481
|
},
|
|
6123
6482
|
"Value ",
|
|
6124
|
-
/* @__PURE__ */
|
|
6125
|
-
))), /* @__PURE__ */
|
|
6483
|
+
/* @__PURE__ */ import_react57.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6484
|
+
))), /* @__PURE__ */ import_react57.default.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
6126
6485
|
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
6127
|
-
return /* @__PURE__ */
|
|
6486
|
+
return /* @__PURE__ */ import_react57.default.createElement(
|
|
6128
6487
|
"tr",
|
|
6129
6488
|
{
|
|
6130
6489
|
key: `pl-side-table-item-${idx}`,
|
|
6131
|
-
className: (0,
|
|
6490
|
+
className: (0, import_classnames28.default)(
|
|
6132
6491
|
"Layer__profit-and-loss-detailed-table__row",
|
|
6133
6492
|
hoveredItem && hoveredItem === item.display_name ? "active" : ""
|
|
6134
6493
|
),
|
|
6135
6494
|
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
6136
6495
|
onMouseLeave: () => setHoveredItem(void 0)
|
|
6137
6496
|
},
|
|
6138
|
-
/* @__PURE__ */
|
|
6139
|
-
/* @__PURE__ */
|
|
6140
|
-
/* @__PURE__ */
|
|
6141
|
-
/* @__PURE__ */
|
|
6497
|
+
/* @__PURE__ */ import_react57.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
6498
|
+
/* @__PURE__ */ import_react57.default.createElement("td", { className: "type-col" }, item.type),
|
|
6499
|
+
/* @__PURE__ */ import_react57.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
6500
|
+
/* @__PURE__ */ import_react57.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react57.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react57.default.createElement(
|
|
6142
6501
|
"div",
|
|
6143
6502
|
{
|
|
6144
6503
|
className: "share-icon",
|
|
@@ -6153,7 +6512,7 @@ var DetailedTable = ({
|
|
|
6153
6512
|
};
|
|
6154
6513
|
|
|
6155
6514
|
// src/components/ProfitAndLossDetailedCharts/Filters.tsx
|
|
6156
|
-
var
|
|
6515
|
+
var import_react58 = __toESM(require("react"));
|
|
6157
6516
|
var import_react_select3 = __toESM(require("react-select"));
|
|
6158
6517
|
var Filters = ({
|
|
6159
6518
|
filteredData,
|
|
@@ -6161,7 +6520,7 @@ var Filters = ({
|
|
|
6161
6520
|
filters,
|
|
6162
6521
|
setFilterTypes
|
|
6163
6522
|
}) => {
|
|
6164
|
-
return /* @__PURE__ */
|
|
6523
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react58.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react58.default.createElement(
|
|
6165
6524
|
import_react_select3.default,
|
|
6166
6525
|
{
|
|
6167
6526
|
className: "Layer__select type-select",
|
|
@@ -6183,15 +6542,15 @@ var Filters = ({
|
|
|
6183
6542
|
);
|
|
6184
6543
|
},
|
|
6185
6544
|
components: {
|
|
6186
|
-
DropdownIndicator: (props) => /* @__PURE__ */
|
|
6187
|
-
Placeholder: (props) => /* @__PURE__ */
|
|
6545
|
+
DropdownIndicator: (props) => /* @__PURE__ */ import_react58.default.createElement(import_react_select3.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react58.default.createElement(ChevronDown_default, null)),
|
|
6546
|
+
Placeholder: (props) => /* @__PURE__ */ import_react58.default.createElement(import_react_select3.components.Placeholder, { ...props }, /* @__PURE__ */ import_react58.default.createElement("div", { className: "Layer__select__multi-all-placeholder-badge" }, "All"))
|
|
6188
6547
|
}
|
|
6189
6548
|
}
|
|
6190
6549
|
));
|
|
6191
6550
|
};
|
|
6192
6551
|
|
|
6193
6552
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
6194
|
-
var
|
|
6553
|
+
var import_date_fns15 = require("date-fns");
|
|
6195
6554
|
var ProfitAndLossDetailedCharts = ({
|
|
6196
6555
|
scope,
|
|
6197
6556
|
hideClose = false,
|
|
@@ -6209,20 +6568,20 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6209
6568
|
sidebarScope,
|
|
6210
6569
|
setSidebarScope,
|
|
6211
6570
|
setFilterTypes
|
|
6212
|
-
} = (0,
|
|
6571
|
+
} = (0, import_react59.useContext)(ProfitAndLoss.Context);
|
|
6213
6572
|
const theScope = scope ? scope : sidebarScope;
|
|
6214
6573
|
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
6215
6574
|
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
6216
|
-
const [hoveredItem, setHoveredItem] = (0,
|
|
6217
|
-
return /* @__PURE__ */
|
|
6575
|
+
const [hoveredItem, setHoveredItem] = (0, import_react59.useState)();
|
|
6576
|
+
return /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react59.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react59.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react59.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns15.format)(dateRange.startDate, "LLLL, y")), showDatePicker && /* @__PURE__ */ import_react59.default.createElement(ProfitAndLossDatePicker, null)), !hideClose && /* @__PURE__ */ import_react59.default.createElement(
|
|
6218
6577
|
Button,
|
|
6219
6578
|
{
|
|
6220
|
-
rightIcon: /* @__PURE__ */
|
|
6579
|
+
rightIcon: /* @__PURE__ */ import_react59.default.createElement(X_default, null),
|
|
6221
6580
|
iconOnly: true,
|
|
6222
6581
|
onClick: () => setSidebarScope(void 0),
|
|
6223
6582
|
variant: "secondary" /* secondary */
|
|
6224
6583
|
}
|
|
6225
|
-
)), /* @__PURE__ */
|
|
6584
|
+
)), /* @__PURE__ */ import_react59.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ import_react59.default.createElement(BackButton, { onClick: () => setSidebarScope(void 0) })), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react59.default.createElement(
|
|
6226
6585
|
DetailedChart,
|
|
6227
6586
|
{
|
|
6228
6587
|
filteredData: data,
|
|
@@ -6233,7 +6592,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6233
6592
|
date: dateRange.startDate,
|
|
6234
6593
|
isLoading
|
|
6235
6594
|
}
|
|
6236
|
-
), /* @__PURE__ */
|
|
6595
|
+
), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ import_react59.default.createElement(
|
|
6237
6596
|
Filters,
|
|
6238
6597
|
{
|
|
6239
6598
|
filteredData: data,
|
|
@@ -6241,7 +6600,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6241
6600
|
filters,
|
|
6242
6601
|
setFilterTypes
|
|
6243
6602
|
}
|
|
6244
|
-
), /* @__PURE__ */
|
|
6603
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
6245
6604
|
DetailedTable,
|
|
6246
6605
|
{
|
|
6247
6606
|
filteredData: data,
|
|
@@ -6255,28 +6614,28 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6255
6614
|
};
|
|
6256
6615
|
|
|
6257
6616
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6258
|
-
var
|
|
6617
|
+
var import_react62 = __toESM(require("react"));
|
|
6259
6618
|
|
|
6260
6619
|
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
6261
|
-
var
|
|
6262
|
-
var
|
|
6620
|
+
var import_react60 = __toESM(require("react"));
|
|
6621
|
+
var import_classnames29 = __toESM(require("classnames"));
|
|
6263
6622
|
var SkeletonLoader = ({
|
|
6264
6623
|
height,
|
|
6265
6624
|
width,
|
|
6266
6625
|
className
|
|
6267
6626
|
}) => {
|
|
6268
|
-
const baseClassName = (0,
|
|
6627
|
+
const baseClassName = (0, import_classnames29.default)(
|
|
6269
6628
|
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
6270
6629
|
className
|
|
6271
6630
|
);
|
|
6272
|
-
return /* @__PURE__ */
|
|
6631
|
+
return /* @__PURE__ */ import_react60.default.createElement("div", { className: baseClassName, style: { width, height } });
|
|
6273
6632
|
};
|
|
6274
6633
|
|
|
6275
6634
|
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
6276
|
-
var
|
|
6635
|
+
var import_react61 = __toESM(require("react"));
|
|
6277
6636
|
var import_recharts3 = require("recharts");
|
|
6278
6637
|
var MiniChart = ({ data }) => {
|
|
6279
|
-
return /* @__PURE__ */
|
|
6638
|
+
return /* @__PURE__ */ import_react61.default.createElement(import_recharts3.PieChart, { width: 48, height: 48, className: "mini-chart" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
6280
6639
|
import_recharts3.Pie,
|
|
6281
6640
|
{
|
|
6282
6641
|
data,
|
|
@@ -6295,7 +6654,7 @@ var MiniChart = ({ data }) => {
|
|
|
6295
6654
|
},
|
|
6296
6655
|
data.map((entry, index) => {
|
|
6297
6656
|
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
6298
|
-
return /* @__PURE__ */
|
|
6657
|
+
return /* @__PURE__ */ import_react61.default.createElement(
|
|
6299
6658
|
import_recharts3.Cell,
|
|
6300
6659
|
{
|
|
6301
6660
|
key: `cell-${index}`,
|
|
@@ -6309,7 +6668,7 @@ var MiniChart = ({ data }) => {
|
|
|
6309
6668
|
};
|
|
6310
6669
|
|
|
6311
6670
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6312
|
-
var
|
|
6671
|
+
var import_classnames30 = __toESM(require("classnames"));
|
|
6313
6672
|
var CHART_PLACEHOLDER = [
|
|
6314
6673
|
{
|
|
6315
6674
|
name: "placeholder",
|
|
@@ -6346,26 +6705,27 @@ var ProfitAndLossSummaries = ({
|
|
|
6346
6705
|
isLoading,
|
|
6347
6706
|
setSidebarScope,
|
|
6348
6707
|
sidebarScope
|
|
6349
|
-
} = (0,
|
|
6350
|
-
const
|
|
6351
|
-
|
|
6708
|
+
} = (0, import_react62.useContext)(ProfitAndLoss.Context);
|
|
6709
|
+
const dataItem = Array.isArray(storedData) ? storedData[storedData.length - 1] : storedData;
|
|
6710
|
+
const expensesChartData = (0, import_react62.useMemo)(() => {
|
|
6711
|
+
return buildMiniChartData("expenses", dataItem);
|
|
6352
6712
|
}, [storedData]);
|
|
6353
|
-
const revenueChartData = (0,
|
|
6354
|
-
return buildMiniChartData("revenue",
|
|
6713
|
+
const revenueChartData = (0, import_react62.useMemo)(() => {
|
|
6714
|
+
return buildMiniChartData("revenue", dataItem);
|
|
6355
6715
|
}, [storedData]);
|
|
6356
|
-
const data =
|
|
6716
|
+
const data = dataItem ? dataItem : { income: { value: NaN }, net_profit: NaN };
|
|
6357
6717
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6358
6718
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6359
6719
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6360
|
-
return /* @__PURE__ */
|
|
6720
|
+
return /* @__PURE__ */ import_react62.default.createElement(
|
|
6361
6721
|
"div",
|
|
6362
6722
|
{
|
|
6363
6723
|
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
6364
6724
|
},
|
|
6365
|
-
/* @__PURE__ */
|
|
6725
|
+
/* @__PURE__ */ import_react62.default.createElement(
|
|
6366
6726
|
"div",
|
|
6367
6727
|
{
|
|
6368
|
-
className: (0,
|
|
6728
|
+
className: (0, import_classnames30.default)(
|
|
6369
6729
|
"Layer__profit-and-loss-summaries__summary",
|
|
6370
6730
|
actionable && "Layer__actionable",
|
|
6371
6731
|
"Layer__profit-and-loss-summaries__summary--income",
|
|
@@ -6375,8 +6735,8 @@ var ProfitAndLossSummaries = ({
|
|
|
6375
6735
|
actionable && setSidebarScope("revenue");
|
|
6376
6736
|
}
|
|
6377
6737
|
},
|
|
6378
|
-
/* @__PURE__ */
|
|
6379
|
-
/* @__PURE__ */
|
|
6738
|
+
/* @__PURE__ */ import_react62.default.createElement(MiniChart, { data: revenueChartData }),
|
|
6739
|
+
/* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react62.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react62.default.createElement(SkeletonLoader, null)) : /* @__PURE__ */ import_react62.default.createElement(
|
|
6380
6740
|
"span",
|
|
6381
6741
|
{
|
|
6382
6742
|
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
@@ -6384,10 +6744,10 @@ var ProfitAndLossSummaries = ({
|
|
|
6384
6744
|
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
6385
6745
|
))
|
|
6386
6746
|
),
|
|
6387
|
-
/* @__PURE__ */
|
|
6747
|
+
/* @__PURE__ */ import_react62.default.createElement(
|
|
6388
6748
|
"div",
|
|
6389
6749
|
{
|
|
6390
|
-
className: (0,
|
|
6750
|
+
className: (0, import_classnames30.default)(
|
|
6391
6751
|
"Layer__profit-and-loss-summaries__summary",
|
|
6392
6752
|
actionable && "Layer__actionable",
|
|
6393
6753
|
"Layer__profit-and-loss-summaries__summary--expenses",
|
|
@@ -6397,8 +6757,8 @@ var ProfitAndLossSummaries = ({
|
|
|
6397
6757
|
actionable && setSidebarScope("expenses");
|
|
6398
6758
|
}
|
|
6399
6759
|
},
|
|
6400
|
-
/* @__PURE__ */
|
|
6401
|
-
/* @__PURE__ */
|
|
6760
|
+
/* @__PURE__ */ import_react62.default.createElement(MiniChart, { data: expensesChartData }),
|
|
6761
|
+
/* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react62.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react62.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react62.default.createElement(
|
|
6402
6762
|
"span",
|
|
6403
6763
|
{
|
|
6404
6764
|
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
@@ -6408,15 +6768,15 @@ var ProfitAndLossSummaries = ({
|
|
|
6408
6768
|
)
|
|
6409
6769
|
))
|
|
6410
6770
|
),
|
|
6411
|
-
/* @__PURE__ */
|
|
6771
|
+
/* @__PURE__ */ import_react62.default.createElement(
|
|
6412
6772
|
"div",
|
|
6413
6773
|
{
|
|
6414
|
-
className: (0,
|
|
6774
|
+
className: (0, import_classnames30.default)(
|
|
6415
6775
|
"Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
|
|
6416
6776
|
actionable && "Layer__actionable"
|
|
6417
6777
|
)
|
|
6418
6778
|
},
|
|
6419
|
-
/* @__PURE__ */
|
|
6779
|
+
/* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react62.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react62.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react62.default.createElement(
|
|
6420
6780
|
"span",
|
|
6421
6781
|
{
|
|
6422
6782
|
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
@@ -6428,10 +6788,10 @@ var ProfitAndLossSummaries = ({
|
|
|
6428
6788
|
};
|
|
6429
6789
|
|
|
6430
6790
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
6431
|
-
var
|
|
6791
|
+
var import_react64 = __toESM(require("react"));
|
|
6432
6792
|
|
|
6433
6793
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
6434
|
-
var
|
|
6794
|
+
var import_react63 = __toESM(require("react"));
|
|
6435
6795
|
|
|
6436
6796
|
// src/icons/PieChart.tsx
|
|
6437
6797
|
var React77 = __toESM(require("react"));
|
|
@@ -6480,7 +6840,7 @@ var ProfitAndLossRow = ({
|
|
|
6480
6840
|
return null;
|
|
6481
6841
|
}
|
|
6482
6842
|
const { value, display_name, line_items } = lineItem;
|
|
6483
|
-
const [expanded, setExpanded] = (0,
|
|
6843
|
+
const [expanded, setExpanded] = (0, import_react63.useState)(true);
|
|
6484
6844
|
const amount = value ?? 0;
|
|
6485
6845
|
const amountString = centsToDollars(Math.abs(amount));
|
|
6486
6846
|
const labelClasses = [
|
|
@@ -6511,20 +6871,20 @@ var ProfitAndLossRow = ({
|
|
|
6511
6871
|
);
|
|
6512
6872
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
6513
6873
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
6514
|
-
return /* @__PURE__ */
|
|
6874
|
+
return /* @__PURE__ */ import_react63.default.createElement(import_react63.default.Fragment, null, /* @__PURE__ */ import_react63.default.createElement(
|
|
6515
6875
|
"div",
|
|
6516
6876
|
{
|
|
6517
6877
|
className: labelClasses.join(" "),
|
|
6518
6878
|
onClick: () => !lockExpanded && toggleExpanded()
|
|
6519
6879
|
},
|
|
6520
|
-
/* @__PURE__ */
|
|
6880
|
+
/* @__PURE__ */ import_react63.default.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ import_react63.default.createElement(
|
|
6521
6881
|
ChevronDownFill_default,
|
|
6522
6882
|
{
|
|
6523
6883
|
size: 16,
|
|
6524
6884
|
className: "Layer__profit-and-loss-row__label__chevron"
|
|
6525
6885
|
}
|
|
6526
|
-
) : null, /* @__PURE__ */
|
|
6527
|
-
setSidebarScope && /* @__PURE__ */
|
|
6886
|
+
) : null, /* @__PURE__ */ import_react63.default.createElement(Text, null, display_name)),
|
|
6887
|
+
setSidebarScope && /* @__PURE__ */ import_react63.default.createElement(
|
|
6528
6888
|
"span",
|
|
6529
6889
|
{
|
|
6530
6890
|
className: "Layer__profit-and-loss-row__detailed-chart-btn",
|
|
@@ -6533,14 +6893,14 @@ var ProfitAndLossRow = ({
|
|
|
6533
6893
|
setSidebarScope && setSidebarScope(scope ?? "expenses");
|
|
6534
6894
|
}
|
|
6535
6895
|
},
|
|
6536
|
-
/* @__PURE__ */
|
|
6896
|
+
/* @__PURE__ */ import_react63.default.createElement(PieChart_default, null)
|
|
6537
6897
|
)
|
|
6538
|
-
), /* @__PURE__ */
|
|
6898
|
+
), /* @__PURE__ */ import_react63.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react63.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react63.default.createElement(
|
|
6539
6899
|
"div",
|
|
6540
6900
|
{
|
|
6541
6901
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
6542
6902
|
},
|
|
6543
|
-
/* @__PURE__ */
|
|
6903
|
+
/* @__PURE__ */ import_react63.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react63.default.createElement(
|
|
6544
6904
|
ProfitAndLossRow,
|
|
6545
6905
|
{
|
|
6546
6906
|
key: line_item.display_name,
|
|
@@ -6602,35 +6962,36 @@ var empty_profit_and_loss_report_default = {
|
|
|
6602
6962
|
};
|
|
6603
6963
|
|
|
6604
6964
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
6605
|
-
var
|
|
6965
|
+
var import_classnames31 = __toESM(require("classnames"));
|
|
6606
6966
|
var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
6607
6967
|
const {
|
|
6608
6968
|
data: actualData,
|
|
6609
6969
|
isLoading,
|
|
6610
6970
|
setSidebarScope
|
|
6611
|
-
} = (0,
|
|
6612
|
-
const
|
|
6971
|
+
} = (0, import_react64.useContext)(ProfitAndLoss.Context);
|
|
6972
|
+
const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
|
|
6973
|
+
const data = !currentData || isLoading ? empty_profit_and_loss_report_default : currentData;
|
|
6613
6974
|
if (isLoading || actualData === void 0) {
|
|
6614
|
-
return /* @__PURE__ */
|
|
6975
|
+
return /* @__PURE__ */ import_react64.default.createElement(
|
|
6615
6976
|
"div",
|
|
6616
6977
|
{
|
|
6617
|
-
className: (0,
|
|
6978
|
+
className: (0, import_classnames31.default)(
|
|
6618
6979
|
"Layer__profit-and-loss-table__loader-container",
|
|
6619
6980
|
asContainer && "Layer__component-container"
|
|
6620
6981
|
)
|
|
6621
6982
|
},
|
|
6622
|
-
/* @__PURE__ */
|
|
6983
|
+
/* @__PURE__ */ import_react64.default.createElement(Loader2, null)
|
|
6623
6984
|
);
|
|
6624
6985
|
}
|
|
6625
|
-
return /* @__PURE__ */
|
|
6986
|
+
return /* @__PURE__ */ import_react64.default.createElement(import_react64.default.Fragment, null, /* @__PURE__ */ import_react64.default.createElement(
|
|
6626
6987
|
"div",
|
|
6627
6988
|
{
|
|
6628
|
-
className: (0,
|
|
6989
|
+
className: (0, import_classnames31.default)(
|
|
6629
6990
|
"Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
|
|
6630
6991
|
asContainer && "Layer__component-container"
|
|
6631
6992
|
)
|
|
6632
6993
|
},
|
|
6633
|
-
/* @__PURE__ */
|
|
6994
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6634
6995
|
ProfitAndLossRow,
|
|
6635
6996
|
{
|
|
6636
6997
|
lineItem: data.income,
|
|
@@ -6640,7 +7001,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6640
7001
|
setSidebarScope
|
|
6641
7002
|
}
|
|
6642
7003
|
),
|
|
6643
|
-
/* @__PURE__ */
|
|
7004
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6644
7005
|
ProfitAndLossRow,
|
|
6645
7006
|
{
|
|
6646
7007
|
lineItem: data.cost_of_goods_sold,
|
|
@@ -6650,7 +7011,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6650
7011
|
setSidebarScope
|
|
6651
7012
|
}
|
|
6652
7013
|
),
|
|
6653
|
-
/* @__PURE__ */
|
|
7014
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6654
7015
|
ProfitAndLossRow,
|
|
6655
7016
|
{
|
|
6656
7017
|
lineItem: {
|
|
@@ -6664,7 +7025,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6664
7025
|
setSidebarScope
|
|
6665
7026
|
}
|
|
6666
7027
|
),
|
|
6667
|
-
/* @__PURE__ */
|
|
7028
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6668
7029
|
ProfitAndLossRow,
|
|
6669
7030
|
{
|
|
6670
7031
|
lineItem: data.expenses,
|
|
@@ -6674,7 +7035,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6674
7035
|
setSidebarScope
|
|
6675
7036
|
}
|
|
6676
7037
|
),
|
|
6677
|
-
/* @__PURE__ */
|
|
7038
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6678
7039
|
ProfitAndLossRow,
|
|
6679
7040
|
{
|
|
6680
7041
|
lineItem: {
|
|
@@ -6688,7 +7049,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6688
7049
|
setSidebarScope
|
|
6689
7050
|
}
|
|
6690
7051
|
),
|
|
6691
|
-
/* @__PURE__ */
|
|
7052
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6692
7053
|
ProfitAndLossRow,
|
|
6693
7054
|
{
|
|
6694
7055
|
lineItem: data.taxes,
|
|
@@ -6698,7 +7059,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6698
7059
|
setSidebarScope
|
|
6699
7060
|
}
|
|
6700
7061
|
),
|
|
6701
|
-
/* @__PURE__ */
|
|
7062
|
+
/* @__PURE__ */ import_react64.default.createElement(
|
|
6702
7063
|
ProfitAndLossRow,
|
|
6703
7064
|
{
|
|
6704
7065
|
lineItem: {
|
|
@@ -6710,14 +7071,14 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6710
7071
|
lockExpanded
|
|
6711
7072
|
}
|
|
6712
7073
|
)
|
|
6713
|
-
), data.other_outflows || data.personal_expenses ? /* @__PURE__ */
|
|
7074
|
+
), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react64.default.createElement(
|
|
6714
7075
|
ProfitAndLossRow,
|
|
6715
7076
|
{
|
|
6716
7077
|
lineItem: data.other_outflows,
|
|
6717
7078
|
direction: "DEBIT" /* DEBIT */,
|
|
6718
7079
|
lockExpanded
|
|
6719
7080
|
}
|
|
6720
|
-
), /* @__PURE__ */
|
|
7081
|
+
), /* @__PURE__ */ import_react64.default.createElement(
|
|
6721
7082
|
ProfitAndLossRow,
|
|
6722
7083
|
{
|
|
6723
7084
|
lineItem: data.personal_expenses,
|
|
@@ -6728,8 +7089,8 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6728
7089
|
};
|
|
6729
7090
|
|
|
6730
7091
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
6731
|
-
var
|
|
6732
|
-
var PNLContext = (0,
|
|
7092
|
+
var import_date_fns16 = require("date-fns");
|
|
7093
|
+
var PNLContext = (0, import_react65.createContext)({
|
|
6733
7094
|
data: void 0,
|
|
6734
7095
|
filteredDataRevenue: [],
|
|
6735
7096
|
filteredTotalRevenue: void 0,
|
|
@@ -6739,8 +7100,8 @@ var PNLContext = (0, import_react64.createContext)({
|
|
|
6739
7100
|
isValidating: false,
|
|
6740
7101
|
error: void 0,
|
|
6741
7102
|
dateRange: {
|
|
6742
|
-
startDate: (0,
|
|
6743
|
-
endDate: (0,
|
|
7103
|
+
startDate: (0, import_date_fns16.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
7104
|
+
endDate: (0, import_date_fns16.endOfMonth)(/* @__PURE__ */ new Date())
|
|
6744
7105
|
},
|
|
6745
7106
|
changeDateRange: () => {
|
|
6746
7107
|
},
|
|
@@ -6765,7 +7126,7 @@ var ProfitAndLoss = ({
|
|
|
6765
7126
|
asContainer = true
|
|
6766
7127
|
}) => {
|
|
6767
7128
|
const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
|
|
6768
|
-
return /* @__PURE__ */
|
|
7129
|
+
return /* @__PURE__ */ import_react65.default.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ import_react65.default.createElement(Container, { name: "profit-and-loss" }, children) : children);
|
|
6769
7130
|
};
|
|
6770
7131
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
6771
7132
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -6775,11 +7136,11 @@ ProfitAndLoss.Table = ProfitAndLossTable;
|
|
|
6775
7136
|
ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
|
|
6776
7137
|
|
|
6777
7138
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
6778
|
-
var
|
|
7139
|
+
var import_react67 = __toESM(require("react"));
|
|
6779
7140
|
|
|
6780
7141
|
// src/components/Panel/Panel.tsx
|
|
6781
|
-
var
|
|
6782
|
-
var
|
|
7142
|
+
var import_react66 = __toESM(require("react"));
|
|
7143
|
+
var import_classnames32 = __toESM(require("classnames"));
|
|
6783
7144
|
var Panel = ({
|
|
6784
7145
|
children,
|
|
6785
7146
|
className,
|
|
@@ -6788,23 +7149,23 @@ var Panel = ({
|
|
|
6788
7149
|
sidebarIsOpen,
|
|
6789
7150
|
parentRef
|
|
6790
7151
|
}) => {
|
|
6791
|
-
const [sidebarHeight, setSidebarHeight] = (0,
|
|
6792
|
-
(0,
|
|
7152
|
+
const [sidebarHeight, setSidebarHeight] = (0, import_react66.useState)(0);
|
|
7153
|
+
(0, import_react66.useEffect)(() => {
|
|
6793
7154
|
if (parentRef?.current?.offsetHeight) {
|
|
6794
7155
|
setSidebarHeight(parentRef?.current?.offsetHeight - 1);
|
|
6795
7156
|
}
|
|
6796
7157
|
}, [parentRef?.current?.offsetHeight, sidebarIsOpen]);
|
|
6797
|
-
return /* @__PURE__ */
|
|
7158
|
+
return /* @__PURE__ */ import_react66.default.createElement(
|
|
6798
7159
|
"div",
|
|
6799
7160
|
{
|
|
6800
|
-
className: (0,
|
|
7161
|
+
className: (0, import_classnames32.default)(
|
|
6801
7162
|
"Layer__panel",
|
|
6802
7163
|
className,
|
|
6803
7164
|
sidebarIsOpen && "Layer__panel--open"
|
|
6804
7165
|
)
|
|
6805
7166
|
},
|
|
6806
|
-
/* @__PURE__ */
|
|
6807
|
-
sidebar && /* @__PURE__ */
|
|
7167
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__panel__content" }, header, children),
|
|
7168
|
+
sidebar && /* @__PURE__ */ import_react66.default.createElement(
|
|
6808
7169
|
"div",
|
|
6809
7170
|
{
|
|
6810
7171
|
className: "Layer__panel__sidebar",
|
|
@@ -6812,7 +7173,7 @@ var Panel = ({
|
|
|
6812
7173
|
maxHeight: sidebarHeight > 0 && sidebarIsOpen ? sidebarHeight : 0
|
|
6813
7174
|
}
|
|
6814
7175
|
},
|
|
6815
|
-
/* @__PURE__ */
|
|
7176
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__panel__sidebar-content" }, sidebar)
|
|
6816
7177
|
)
|
|
6817
7178
|
);
|
|
6818
7179
|
};
|
|
@@ -6820,34 +7181,34 @@ var Panel = ({
|
|
|
6820
7181
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
6821
7182
|
var COMPONENT_NAME3 = "profit-and-loss";
|
|
6822
7183
|
var ProfitAndLossView = (props) => {
|
|
6823
|
-
const containerRef = (0,
|
|
6824
|
-
return /* @__PURE__ */
|
|
7184
|
+
const containerRef = (0, import_react67.useRef)(null);
|
|
7185
|
+
return /* @__PURE__ */ import_react67.default.createElement(Container, { name: COMPONENT_NAME3, ref: containerRef }, /* @__PURE__ */ import_react67.default.createElement(ProfitAndLoss, null, /* @__PURE__ */ import_react67.default.createElement(ProfitAndLossPanel, { containerRef, ...props })));
|
|
6825
7186
|
};
|
|
6826
7187
|
var ProfitAndLossPanel = ({
|
|
6827
7188
|
containerRef,
|
|
6828
7189
|
...props
|
|
6829
7190
|
}) => {
|
|
6830
|
-
const { sidebarScope } = (0,
|
|
6831
|
-
return /* @__PURE__ */
|
|
7191
|
+
const { sidebarScope } = (0, import_react67.useContext)(ProfitAndLoss.Context);
|
|
7192
|
+
return /* @__PURE__ */ import_react67.default.createElement(
|
|
6832
7193
|
Panel,
|
|
6833
7194
|
{
|
|
6834
|
-
sidebar: /* @__PURE__ */
|
|
7195
|
+
sidebar: /* @__PURE__ */ import_react67.default.createElement(ProfitAndLossDetailedCharts, null),
|
|
6835
7196
|
sidebarIsOpen: Boolean(sidebarScope),
|
|
6836
7197
|
parentRef: containerRef
|
|
6837
7198
|
},
|
|
6838
|
-
/* @__PURE__ */
|
|
6839
|
-
/* @__PURE__ */
|
|
7199
|
+
/* @__PURE__ */ import_react67.default.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ import_react67.default.createElement(Heading, { className: "Layer__profit-and-loss__title" }, "Profit & Loss")),
|
|
7200
|
+
/* @__PURE__ */ import_react67.default.createElement(Components, { ...props })
|
|
6840
7201
|
);
|
|
6841
7202
|
};
|
|
6842
7203
|
var Components = ({
|
|
6843
7204
|
hideChart = false,
|
|
6844
7205
|
hideTable = false
|
|
6845
7206
|
}) => {
|
|
6846
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
7207
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react67.useContext)(
|
|
6847
7208
|
ProfitAndLoss.Context
|
|
6848
7209
|
);
|
|
6849
7210
|
if (!isLoading && error) {
|
|
6850
|
-
return /* @__PURE__ */
|
|
7211
|
+
return /* @__PURE__ */ import_react67.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6851
7212
|
DataState,
|
|
6852
7213
|
{
|
|
6853
7214
|
status: "failed" /* failed */,
|
|
@@ -6858,27 +7219,230 @@ var Components = ({
|
|
|
6858
7219
|
}
|
|
6859
7220
|
));
|
|
6860
7221
|
}
|
|
6861
|
-
return /* @__PURE__ */
|
|
7222
|
+
return /* @__PURE__ */ import_react67.default.createElement(import_react67.default.Fragment, null, !hideChart && /* @__PURE__ */ import_react67.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6862
7223
|
"div",
|
|
6863
7224
|
{
|
|
6864
7225
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
|
|
6865
7226
|
},
|
|
6866
|
-
/* @__PURE__ */
|
|
6867
|
-
/* @__PURE__ */
|
|
6868
|
-
), /* @__PURE__ */
|
|
7227
|
+
/* @__PURE__ */ import_react67.default.createElement(ProfitAndLoss.DatePicker, null),
|
|
7228
|
+
/* @__PURE__ */ import_react67.default.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
7229
|
+
), /* @__PURE__ */ import_react67.default.createElement(
|
|
6869
7230
|
"div",
|
|
6870
7231
|
{
|
|
6871
7232
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
|
|
6872
7233
|
},
|
|
6873
|
-
/* @__PURE__ */
|
|
6874
|
-
)), !hideTable && /* @__PURE__ */
|
|
7234
|
+
/* @__PURE__ */ import_react67.default.createElement(ProfitAndLoss.Chart, null)
|
|
7235
|
+
)), !hideTable && /* @__PURE__ */ import_react67.default.createElement(ProfitAndLoss.Table, null));
|
|
6875
7236
|
};
|
|
6876
7237
|
|
|
6877
7238
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
6878
|
-
var
|
|
7239
|
+
var import_react82 = __toESM(require("react"));
|
|
7240
|
+
|
|
7241
|
+
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
7242
|
+
var import_react68 = require("react");
|
|
7243
|
+
|
|
7244
|
+
// src/components/ChartOfAccountsForm/constants.ts
|
|
7245
|
+
var LEDGER_ACCOUNT_TYPES = [
|
|
7246
|
+
{
|
|
7247
|
+
value: "ASSET",
|
|
7248
|
+
label: "Assets"
|
|
7249
|
+
},
|
|
7250
|
+
{
|
|
7251
|
+
value: "LIABILITY",
|
|
7252
|
+
label: "Liabilities"
|
|
7253
|
+
},
|
|
7254
|
+
{
|
|
7255
|
+
value: "EQUITY",
|
|
7256
|
+
label: "Equities"
|
|
7257
|
+
},
|
|
7258
|
+
{
|
|
7259
|
+
value: "REVENUE",
|
|
7260
|
+
label: "Revenue"
|
|
7261
|
+
},
|
|
7262
|
+
{
|
|
7263
|
+
value: "EXPENSE",
|
|
7264
|
+
label: "Expenses"
|
|
7265
|
+
}
|
|
7266
|
+
];
|
|
7267
|
+
var DEFAULT_ACCOUNT_TYPE_DIRECTION = {
|
|
7268
|
+
ASSET: "DEBIT" /* DEBIT */,
|
|
7269
|
+
LIABILITY: "CREDIT" /* CREDIT */,
|
|
7270
|
+
EQUITY: "CREDIT" /* CREDIT */,
|
|
7271
|
+
REVENUE: "CREDIT" /* CREDIT */,
|
|
7272
|
+
EXPENSE: "DEBIT" /* DEBIT */
|
|
7273
|
+
};
|
|
7274
|
+
var NORMALITY_OPTIONS = [
|
|
7275
|
+
{
|
|
7276
|
+
value: "DEBIT" /* DEBIT */,
|
|
7277
|
+
label: "Debit"
|
|
7278
|
+
},
|
|
7279
|
+
{
|
|
7280
|
+
value: "CREDIT" /* CREDIT */,
|
|
7281
|
+
label: "Credit"
|
|
7282
|
+
}
|
|
7283
|
+
];
|
|
7284
|
+
var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
|
|
7285
|
+
{
|
|
7286
|
+
value: "BANK_ACCOUNTS",
|
|
7287
|
+
label: "Bank Accounts"
|
|
7288
|
+
},
|
|
7289
|
+
{
|
|
7290
|
+
value: "ACCOUNTS_RECEIVABLE",
|
|
7291
|
+
label: "Accounts Receivable"
|
|
7292
|
+
},
|
|
7293
|
+
{
|
|
7294
|
+
value: "INVENTORY",
|
|
7295
|
+
label: "Inventory"
|
|
7296
|
+
},
|
|
7297
|
+
{
|
|
7298
|
+
value: "PAYMENT_PROCESSOR_CLEARING_ACCOUNT",
|
|
7299
|
+
label: "Payment Processor Clearing Accounts"
|
|
7300
|
+
},
|
|
7301
|
+
{
|
|
7302
|
+
value: "FIXED_ASSET",
|
|
7303
|
+
label: "Fixed Assets"
|
|
7304
|
+
},
|
|
7305
|
+
{
|
|
7306
|
+
value: "CASH",
|
|
7307
|
+
label: "Cash"
|
|
7308
|
+
},
|
|
7309
|
+
{
|
|
7310
|
+
value: "UNDEPOSITED_FUNDS",
|
|
7311
|
+
label: "Undeposited Funds"
|
|
7312
|
+
}
|
|
7313
|
+
];
|
|
7314
|
+
var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
7315
|
+
{
|
|
7316
|
+
value: "LIABILITY",
|
|
7317
|
+
label: "Liabilities"
|
|
7318
|
+
},
|
|
7319
|
+
{
|
|
7320
|
+
value: "ACCOUNTS_PAYABLE",
|
|
7321
|
+
label: "Accounts Payable"
|
|
7322
|
+
},
|
|
7323
|
+
{
|
|
7324
|
+
value: "CREDIT_CARD",
|
|
7325
|
+
label: "Credit Cards"
|
|
7326
|
+
},
|
|
7327
|
+
{
|
|
7328
|
+
value: "SHAREHOLDER_LOAN",
|
|
7329
|
+
label: "Shareholder Loans"
|
|
7330
|
+
},
|
|
7331
|
+
{
|
|
7332
|
+
value: "PAYROLL_LIABILITY",
|
|
7333
|
+
label: "Payroll Liabilities"
|
|
7334
|
+
},
|
|
7335
|
+
{
|
|
7336
|
+
value: "SALES_TAXES_PAYABLE",
|
|
7337
|
+
label: "Sales Taxes Payable"
|
|
7338
|
+
},
|
|
7339
|
+
{
|
|
7340
|
+
value: "LINE_OF_CREDIT",
|
|
7341
|
+
label: "Lines of Credit"
|
|
7342
|
+
},
|
|
7343
|
+
{
|
|
7344
|
+
value: "NOTES_PAYABLE",
|
|
7345
|
+
label: "Notes Payable"
|
|
7346
|
+
},
|
|
7347
|
+
{
|
|
7348
|
+
value: "TIPS",
|
|
7349
|
+
label: "Tips"
|
|
7350
|
+
},
|
|
7351
|
+
{
|
|
7352
|
+
value: "UNEARNED_REVENUE",
|
|
7353
|
+
label: "Unearned Revenue"
|
|
7354
|
+
},
|
|
7355
|
+
{
|
|
7356
|
+
value: "UNDEPOSITED_OUTFLOWS",
|
|
7357
|
+
label: "Undeposited Outflows"
|
|
7358
|
+
}
|
|
7359
|
+
];
|
|
7360
|
+
var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
7361
|
+
{
|
|
7362
|
+
value: "CONTRIBUTIONS",
|
|
7363
|
+
label: "Contributions"
|
|
7364
|
+
},
|
|
7365
|
+
{
|
|
7366
|
+
value: "DISTRIBUTIONS",
|
|
7367
|
+
label: "Distributions"
|
|
7368
|
+
},
|
|
7369
|
+
{
|
|
7370
|
+
value: "COMMON_STOCK",
|
|
7371
|
+
label: "Common Stock"
|
|
7372
|
+
},
|
|
7373
|
+
{
|
|
7374
|
+
value: "ADDITIONAL_PAID_IN_CAPITAL",
|
|
7375
|
+
label: "Additional Paid In Capital"
|
|
7376
|
+
},
|
|
7377
|
+
{
|
|
7378
|
+
value: "RETAINED_EARNINGS",
|
|
7379
|
+
label: "Retained Earnings"
|
|
7380
|
+
},
|
|
7381
|
+
{
|
|
7382
|
+
value: "ACCUMULATED_ADJUSTMENTS",
|
|
7383
|
+
label: "Accumulated Adjustments"
|
|
7384
|
+
},
|
|
7385
|
+
{
|
|
7386
|
+
value: "OPENING_BALANCE_EQUITY",
|
|
7387
|
+
label: "Opening Balance Equity"
|
|
7388
|
+
}
|
|
7389
|
+
];
|
|
7390
|
+
var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
7391
|
+
{
|
|
7392
|
+
value: "SALES",
|
|
7393
|
+
label: "Sales"
|
|
7394
|
+
},
|
|
7395
|
+
{
|
|
7396
|
+
value: "UNCATEGORIZED_REVENUE",
|
|
7397
|
+
label: "Uncategorized Revenue"
|
|
7398
|
+
},
|
|
7399
|
+
{
|
|
7400
|
+
value: "RETURNS_ALLOWANCES",
|
|
7401
|
+
label: "Returns & Allowances"
|
|
7402
|
+
}
|
|
7403
|
+
];
|
|
7404
|
+
var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
7405
|
+
{
|
|
7406
|
+
value: "COGS",
|
|
7407
|
+
label: "COGS"
|
|
7408
|
+
},
|
|
7409
|
+
{
|
|
7410
|
+
value: "OPERATING_EXPENSES",
|
|
7411
|
+
label: "Operating Expenses"
|
|
7412
|
+
},
|
|
7413
|
+
{
|
|
7414
|
+
value: "PAYROLL",
|
|
7415
|
+
label: "Payroll"
|
|
7416
|
+
},
|
|
7417
|
+
{
|
|
7418
|
+
value: "TAXES_LICENSES",
|
|
7419
|
+
label: "Taxes & Licenses"
|
|
7420
|
+
},
|
|
7421
|
+
{
|
|
7422
|
+
value: "BAD_DEBT",
|
|
7423
|
+
label: "Bad Debt"
|
|
7424
|
+
},
|
|
7425
|
+
{
|
|
7426
|
+
value: "CHARITABLE_CONTRIBUTIONS",
|
|
7427
|
+
label: "Charitable Contributions"
|
|
7428
|
+
}
|
|
7429
|
+
];
|
|
7430
|
+
var LEDGER_ACCOUNT_SUBTYPES = [
|
|
7431
|
+
...ASSET_LEDGER_ACCOUNT_SUBTYPES,
|
|
7432
|
+
...LIABILITY_LEDGER_ACCOUNT_SUBTYPES,
|
|
7433
|
+
...EQUITY_LEDGER_ACCOUNT_SUBTYPES,
|
|
7434
|
+
...REVENUE_LEDGER_ACCOUNT_SUBTYPES,
|
|
7435
|
+
...EXPENSE_LEDGER_ACCOUNT_SUBTYPES
|
|
7436
|
+
];
|
|
7437
|
+
var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
7438
|
+
ASSET: ASSET_LEDGER_ACCOUNT_SUBTYPES,
|
|
7439
|
+
LIABILITY: LIABILITY_LEDGER_ACCOUNT_SUBTYPES,
|
|
7440
|
+
EQUITY: EQUITY_LEDGER_ACCOUNT_SUBTYPES,
|
|
7441
|
+
REVENUE: REVENUE_LEDGER_ACCOUNT_SUBTYPES,
|
|
7442
|
+
EXPENSE: EXPENSE_LEDGER_ACCOUNT_SUBTYPES
|
|
7443
|
+
};
|
|
6879
7444
|
|
|
6880
7445
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
6881
|
-
var import_react67 = require("react");
|
|
6882
7446
|
var import_swr6 = __toESM(require("swr"));
|
|
6883
7447
|
var validate = (formData) => {
|
|
6884
7448
|
const errors = [];
|
|
@@ -6886,6 +7450,14 @@ var validate = (formData) => {
|
|
|
6886
7450
|
if (nameError) {
|
|
6887
7451
|
errors.push(nameError);
|
|
6888
7452
|
}
|
|
7453
|
+
const normalityError = validateNormality(formData);
|
|
7454
|
+
if (normalityError) {
|
|
7455
|
+
errors.push(normalityError);
|
|
7456
|
+
}
|
|
7457
|
+
const typeError = validateType(formData);
|
|
7458
|
+
if (typeError) {
|
|
7459
|
+
errors.push(typeError);
|
|
7460
|
+
}
|
|
6889
7461
|
return errors;
|
|
6890
7462
|
};
|
|
6891
7463
|
var revalidateField = (fieldName, formData) => {
|
|
@@ -6897,10 +7469,48 @@ var revalidateField = (fieldName, formData) => {
|
|
|
6897
7469
|
}
|
|
6898
7470
|
return (formData?.errors || []).filter((x) => x.field !== fieldName);
|
|
6899
7471
|
}
|
|
7472
|
+
case "normality": {
|
|
7473
|
+
const normalityError = validateNormality(formData);
|
|
7474
|
+
if (normalityError) {
|
|
7475
|
+
return (formData?.errors || []).filter((x) => x.field !== fieldName).concat([normalityError]);
|
|
7476
|
+
}
|
|
7477
|
+
return (formData?.errors || []).filter((x) => x.field !== fieldName);
|
|
7478
|
+
}
|
|
7479
|
+
case "type": {
|
|
7480
|
+
const typeError = validateType(formData);
|
|
7481
|
+
if (typeError) {
|
|
7482
|
+
return (formData?.errors || []).filter((x) => x.field !== fieldName).concat([typeError]);
|
|
7483
|
+
}
|
|
7484
|
+
return (formData?.errors || []).filter((x) => x.field !== fieldName);
|
|
7485
|
+
}
|
|
6900
7486
|
default:
|
|
6901
7487
|
return formData?.errors;
|
|
6902
7488
|
}
|
|
6903
7489
|
};
|
|
7490
|
+
var validateType = (formData) => {
|
|
7491
|
+
if (!formData?.data.type?.value) {
|
|
7492
|
+
return {
|
|
7493
|
+
field: "type",
|
|
7494
|
+
message: "Must be selected"
|
|
7495
|
+
};
|
|
7496
|
+
}
|
|
7497
|
+
return;
|
|
7498
|
+
};
|
|
7499
|
+
var validateNormality = (formData) => {
|
|
7500
|
+
const stringValueNormality = formData?.data.normality?.value?.toString();
|
|
7501
|
+
if (stringValueNormality === void 0) {
|
|
7502
|
+
return {
|
|
7503
|
+
field: "normality",
|
|
7504
|
+
message: "Must be selected"
|
|
7505
|
+
};
|
|
7506
|
+
} else if (!["DEBIT", "CREDIT"].includes(stringValueNormality)) {
|
|
7507
|
+
return {
|
|
7508
|
+
field: "normality",
|
|
7509
|
+
message: "Must be selected"
|
|
7510
|
+
};
|
|
7511
|
+
}
|
|
7512
|
+
return;
|
|
7513
|
+
};
|
|
6904
7514
|
var validateName = (formData) => {
|
|
6905
7515
|
if (!formData?.data.name?.trim()) {
|
|
6906
7516
|
return {
|
|
@@ -6913,9 +7523,9 @@ var validateName = (formData) => {
|
|
|
6913
7523
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
6914
7524
|
var useChartOfAccounts = () => {
|
|
6915
7525
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
6916
|
-
const [form, setForm] = (0,
|
|
6917
|
-
const [sendingForm, setSendingForm] = (0,
|
|
6918
|
-
const [apiError, setApiError] = (0,
|
|
7526
|
+
const [form, setForm] = (0, import_react68.useState)();
|
|
7527
|
+
const [sendingForm, setSendingForm] = (0, import_react68.useState)(false);
|
|
7528
|
+
const [apiError, setApiError] = (0, import_react68.useState)(void 0);
|
|
6919
7529
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr6.default)(
|
|
6920
7530
|
businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
|
|
6921
7531
|
Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
|
|
@@ -6941,14 +7551,8 @@ var useChartOfAccounts = () => {
|
|
|
6941
7551
|
const update = async (accountData, accountId) => {
|
|
6942
7552
|
setSendingForm(true);
|
|
6943
7553
|
setApiError(void 0);
|
|
6944
|
-
const stable_name = convertToStableName(accountData.name);
|
|
6945
7554
|
const newAccountData = {
|
|
6946
|
-
...accountData
|
|
6947
|
-
stable_name,
|
|
6948
|
-
pnl_category: "INCOME",
|
|
6949
|
-
//this field will be deprecated soon, but is still required
|
|
6950
|
-
always_show_in_pnl: false
|
|
6951
|
-
//this field will be deprecated soon, but is still required
|
|
7555
|
+
...accountData
|
|
6952
7556
|
};
|
|
6953
7557
|
try {
|
|
6954
7558
|
await Layer.updateAccount(apiUrl, auth?.access_token, {
|
|
@@ -6977,13 +7581,14 @@ var useChartOfAccounts = () => {
|
|
|
6977
7581
|
}
|
|
6978
7582
|
const data2 = {
|
|
6979
7583
|
name: form.data.name ?? "",
|
|
6980
|
-
|
|
7584
|
+
stable_name: form.data.stable_name,
|
|
6981
7585
|
parent_id: form.data.parent ? {
|
|
6982
7586
|
type: "AccountId",
|
|
6983
7587
|
id: form.data.parent.value
|
|
6984
7588
|
} : void 0,
|
|
6985
7589
|
account_type: form.data.type.value.toString(),
|
|
6986
|
-
account_subtype: form.data.subType?.value.toString()
|
|
7590
|
+
account_subtype: form.data.subType?.value.toString(),
|
|
7591
|
+
normality: form.data.normality?.value
|
|
6987
7592
|
};
|
|
6988
7593
|
if (form.action === "new") {
|
|
6989
7594
|
create(data2);
|
|
@@ -7000,10 +7605,8 @@ var useChartOfAccounts = () => {
|
|
|
7000
7605
|
data: {
|
|
7001
7606
|
parent: void 0,
|
|
7002
7607
|
name: void 0,
|
|
7003
|
-
type:
|
|
7004
|
-
|
|
7005
|
-
label: "Assets"
|
|
7006
|
-
},
|
|
7608
|
+
type: void 0,
|
|
7609
|
+
normality: void 0,
|
|
7007
7610
|
subType: void 0
|
|
7008
7611
|
}
|
|
7009
7612
|
});
|
|
@@ -7024,12 +7627,19 @@ var useChartOfAccounts = () => {
|
|
|
7024
7627
|
value: parent.id,
|
|
7025
7628
|
label: parent.name
|
|
7026
7629
|
} : void 0,
|
|
7630
|
+
stable_name: found.stable_name,
|
|
7027
7631
|
name: found.name,
|
|
7028
7632
|
type: {
|
|
7029
|
-
value:
|
|
7030
|
-
label:
|
|
7633
|
+
value: found.account_type.value,
|
|
7634
|
+
label: found.account_type.display_name
|
|
7031
7635
|
},
|
|
7032
|
-
subType:
|
|
7636
|
+
subType: found.account_subtype ? {
|
|
7637
|
+
value: found.account_subtype?.value,
|
|
7638
|
+
label: found.account_subtype?.display_name
|
|
7639
|
+
} : void 0,
|
|
7640
|
+
normality: NORMALITY_OPTIONS.find(
|
|
7641
|
+
(normalityOption) => normalityOption.value == found.normality
|
|
7642
|
+
)
|
|
7033
7643
|
}
|
|
7034
7644
|
});
|
|
7035
7645
|
};
|
|
@@ -7038,13 +7648,41 @@ var useChartOfAccounts = () => {
|
|
|
7038
7648
|
if (!form) {
|
|
7039
7649
|
return;
|
|
7040
7650
|
}
|
|
7041
|
-
|
|
7651
|
+
let newFormData = {
|
|
7042
7652
|
...form,
|
|
7043
7653
|
data: {
|
|
7044
7654
|
...form.data,
|
|
7045
7655
|
[fieldName]: value
|
|
7046
7656
|
}
|
|
7047
7657
|
};
|
|
7658
|
+
if (fieldName === "parent") {
|
|
7659
|
+
const allAccounts = flattenAccounts(data?.data?.accounts || []);
|
|
7660
|
+
const foundParent = allAccounts?.find(
|
|
7661
|
+
(x) => x.id === value.value
|
|
7662
|
+
);
|
|
7663
|
+
if (foundParent) {
|
|
7664
|
+
newFormData = {
|
|
7665
|
+
...newFormData,
|
|
7666
|
+
data: {
|
|
7667
|
+
...newFormData.data,
|
|
7668
|
+
/* Inherit the parent's type */
|
|
7669
|
+
type: {
|
|
7670
|
+
value: foundParent.account_type.value,
|
|
7671
|
+
label: foundParent.account_type.display_name
|
|
7672
|
+
},
|
|
7673
|
+
/* If the parent has a subtype, inherit it */
|
|
7674
|
+
subType: foundParent.account_subtype ? {
|
|
7675
|
+
value: foundParent.account_subtype?.value,
|
|
7676
|
+
label: foundParent.account_subtype?.display_name
|
|
7677
|
+
} : void 0,
|
|
7678
|
+
/* Inherit the parent's normality */
|
|
7679
|
+
normality: NORMALITY_OPTIONS.find(
|
|
7680
|
+
(normalityOption) => normalityOption.value == foundParent.normality
|
|
7681
|
+
)
|
|
7682
|
+
}
|
|
7683
|
+
};
|
|
7684
|
+
}
|
|
7685
|
+
}
|
|
7048
7686
|
const errors = revalidateField(fieldName, newFormData);
|
|
7049
7687
|
setForm({
|
|
7050
7688
|
...newFormData,
|
|
@@ -7071,12 +7709,12 @@ var useChartOfAccounts = () => {
|
|
|
7071
7709
|
};
|
|
7072
7710
|
|
|
7073
7711
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
7074
|
-
var
|
|
7712
|
+
var import_react69 = require("react");
|
|
7075
7713
|
var import_swr7 = __toESM(require("swr"));
|
|
7076
7714
|
var useLedgerAccounts = () => {
|
|
7077
7715
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
7078
|
-
const [accountId, setAccountId] = (0,
|
|
7079
|
-
const [selectedEntryId, setSelectedEntryId] = (0,
|
|
7716
|
+
const [accountId, setAccountId] = (0, import_react69.useState)();
|
|
7717
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react69.useState)();
|
|
7080
7718
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr7.default)(
|
|
7081
7719
|
businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
|
|
7082
7720
|
Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
|
|
@@ -7119,10 +7757,10 @@ var useLedgerAccounts = () => {
|
|
|
7119
7757
|
};
|
|
7120
7758
|
|
|
7121
7759
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
7122
|
-
var
|
|
7760
|
+
var import_react74 = __toESM(require("react"));
|
|
7123
7761
|
|
|
7124
7762
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
7125
|
-
var
|
|
7763
|
+
var import_react70 = __toESM(require("react"));
|
|
7126
7764
|
|
|
7127
7765
|
// src/icons/Edit2.tsx
|
|
7128
7766
|
var React83 = __toESM(require("react"));
|
|
@@ -7149,7 +7787,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React83.createElement(
|
|
|
7149
7787
|
var Edit2_default = Edit2;
|
|
7150
7788
|
|
|
7151
7789
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
7152
|
-
var
|
|
7790
|
+
var import_classnames33 = __toESM(require("classnames"));
|
|
7153
7791
|
var INDENTATION = 24;
|
|
7154
7792
|
var MOBILE_INDENTATION = 12;
|
|
7155
7793
|
var EXPANDED_STYLE = {
|
|
@@ -7180,10 +7818,10 @@ var ChartOfAccountsRow = ({
|
|
|
7180
7818
|
acountsLength,
|
|
7181
7819
|
view
|
|
7182
7820
|
}) => {
|
|
7183
|
-
const { form, editAccount } = (0,
|
|
7184
|
-
const { setAccountId } = (0,
|
|
7821
|
+
const { form, editAccount } = (0, import_react70.useContext)(ChartOfAccountsContext);
|
|
7822
|
+
const { setAccountId } = (0, import_react70.useContext)(LedgerAccountsContext);
|
|
7185
7823
|
const baseStyle = view === "desktop" ? EXPANDED_STYLE : EXPANDED_MOBILE_STYLE;
|
|
7186
|
-
const [isOpen, setIsOpen] = (0,
|
|
7824
|
+
const [isOpen, setIsOpen] = (0, import_react70.useState)(defaultOpen);
|
|
7187
7825
|
const style = expanded ? {
|
|
7188
7826
|
...baseStyle,
|
|
7189
7827
|
transitionDelay: `${15 * index}ms`
|
|
@@ -7191,14 +7829,14 @@ var ChartOfAccountsRow = ({
|
|
|
7191
7829
|
...COLLAPSED_STYLE,
|
|
7192
7830
|
transitionDelay: `${acountsLength - 15 * index}ms`
|
|
7193
7831
|
};
|
|
7194
|
-
const [showComponent, setShowComponent] = (0,
|
|
7195
|
-
(0,
|
|
7832
|
+
const [showComponent, setShowComponent] = (0, import_react70.useState)(false);
|
|
7833
|
+
(0, import_react70.useEffect)(() => {
|
|
7196
7834
|
const timeoutId = setTimeout(() => {
|
|
7197
7835
|
setShowComponent(true);
|
|
7198
7836
|
}, cumulativeIndex * 50);
|
|
7199
7837
|
return () => clearTimeout(timeoutId);
|
|
7200
7838
|
}, []);
|
|
7201
|
-
const baseClass = (0,
|
|
7839
|
+
const baseClass = (0, import_classnames33.default)(
|
|
7202
7840
|
"Layer__table-row",
|
|
7203
7841
|
isOpen ? "Layer__table-row--expanded" : "Layer__table-row--collapsed",
|
|
7204
7842
|
!expanded && "Layer__table-row--hidden",
|
|
@@ -7206,15 +7844,15 @@ var ChartOfAccountsRow = ({
|
|
|
7206
7844
|
form?.accountId === account.id && "Layer__table-row--active",
|
|
7207
7845
|
!showComponent && "Layer__table-row--anim-starting-state"
|
|
7208
7846
|
);
|
|
7209
|
-
const desktopRowClass = (0,
|
|
7847
|
+
const desktopRowClass = (0, import_classnames33.default)(
|
|
7210
7848
|
baseClass,
|
|
7211
7849
|
"Layer__chart-of-accounts__row---desktop"
|
|
7212
7850
|
);
|
|
7213
|
-
const mobileRowClass = (0,
|
|
7851
|
+
const mobileRowClass = (0, import_classnames33.default)(
|
|
7214
7852
|
baseClass,
|
|
7215
7853
|
"Layer__chart-of-accounts__row---mobile"
|
|
7216
7854
|
);
|
|
7217
|
-
return /* @__PURE__ */
|
|
7855
|
+
return /* @__PURE__ */ import_react70.default.createElement(import_react70.default.Fragment, null, view === "desktop" && /* @__PURE__ */ import_react70.default.createElement(
|
|
7218
7856
|
"tr",
|
|
7219
7857
|
{
|
|
7220
7858
|
className: desktopRowClass,
|
|
@@ -7224,7 +7862,7 @@ var ChartOfAccountsRow = ({
|
|
|
7224
7862
|
setAccountId(account.id);
|
|
7225
7863
|
}
|
|
7226
7864
|
},
|
|
7227
|
-
/* @__PURE__ */
|
|
7865
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell Layer__coa__name" }, /* @__PURE__ */ import_react70.default.createElement("span", { className: "Layer__table-cell-content", style }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7228
7866
|
"span",
|
|
7229
7867
|
{
|
|
7230
7868
|
className: "Layer__table-cell-content-indentation",
|
|
@@ -7232,7 +7870,7 @@ var ChartOfAccountsRow = ({
|
|
|
7232
7870
|
paddingLeft: INDENTATION * depth + 16
|
|
7233
7871
|
}
|
|
7234
7872
|
},
|
|
7235
|
-
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */
|
|
7873
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react70.default.createElement(
|
|
7236
7874
|
ChevronDownFill_default,
|
|
7237
7875
|
{
|
|
7238
7876
|
size: 16,
|
|
@@ -7243,22 +7881,22 @@ var ChartOfAccountsRow = ({
|
|
|
7243
7881
|
}
|
|
7244
7882
|
}
|
|
7245
7883
|
),
|
|
7246
|
-
/* @__PURE__ */
|
|
7884
|
+
/* @__PURE__ */ import_react70.default.createElement("span", { className: "Layer__coa__name__text" }, account.name)
|
|
7247
7885
|
))),
|
|
7248
|
-
/* @__PURE__ */
|
|
7886
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell Layer__coa__type" }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7249
7887
|
"span",
|
|
7250
7888
|
{
|
|
7251
7889
|
className: "Layer__table-cell-content Layer__mobile--hidden",
|
|
7252
7890
|
style
|
|
7253
7891
|
},
|
|
7254
7892
|
account.account_type?.display_name
|
|
7255
|
-
), /* @__PURE__ */
|
|
7893
|
+
), /* @__PURE__ */ import_react70.default.createElement(
|
|
7256
7894
|
"span",
|
|
7257
7895
|
{
|
|
7258
7896
|
className: "Layer__table-cell-content Layer__desktop--hidden",
|
|
7259
7897
|
style
|
|
7260
7898
|
},
|
|
7261
|
-
/* @__PURE__ */
|
|
7899
|
+
/* @__PURE__ */ import_react70.default.createElement(
|
|
7262
7900
|
Text,
|
|
7263
7901
|
{
|
|
7264
7902
|
weight: "bold" /* bold */,
|
|
@@ -7266,10 +7904,10 @@ var ChartOfAccountsRow = ({
|
|
|
7266
7904
|
},
|
|
7267
7905
|
account.normality
|
|
7268
7906
|
),
|
|
7269
|
-
/* @__PURE__ */
|
|
7907
|
+
/* @__PURE__ */ import_react70.default.createElement(Text, { className: "Layer__coa__subtype--mobile" }, account.account_subtype?.display_name)
|
|
7270
7908
|
)),
|
|
7271
|
-
/* @__PURE__ */
|
|
7272
|
-
/* @__PURE__ */
|
|
7909
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell Layer__coa__subtype Layer__mobile--hidden" }, /* @__PURE__ */ import_react70.default.createElement("span", { className: "Layer__table-cell-content", style }, account.account_subtype?.display_name)),
|
|
7910
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell Layer__coa__balance" }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7273
7911
|
"span",
|
|
7274
7912
|
{
|
|
7275
7913
|
className: "Layer__table-cell-content Layer__table-cell--amount",
|
|
@@ -7278,11 +7916,11 @@ var ChartOfAccountsRow = ({
|
|
|
7278
7916
|
"$",
|
|
7279
7917
|
centsToDollars(Math.abs(account.balance || 0))
|
|
7280
7918
|
)),
|
|
7281
|
-
/* @__PURE__ */
|
|
7919
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell Layer__coa__actions" }, /* @__PURE__ */ import_react70.default.createElement("span", { className: "Layer__table-cell-content", style }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7282
7920
|
Button,
|
|
7283
7921
|
{
|
|
7284
7922
|
variant: "secondary" /* secondary */,
|
|
7285
|
-
rightIcon: /* @__PURE__ */
|
|
7923
|
+
rightIcon: /* @__PURE__ */ import_react70.default.createElement(Edit2_default, { size: 12 }),
|
|
7286
7924
|
iconOnly: true,
|
|
7287
7925
|
onClick: (e) => {
|
|
7288
7926
|
e.preventDefault();
|
|
@@ -7292,7 +7930,7 @@ var ChartOfAccountsRow = ({
|
|
|
7292
7930
|
},
|
|
7293
7931
|
"Edit"
|
|
7294
7932
|
)))
|
|
7295
|
-
), view === "mobile" || view === "tablet" ? /* @__PURE__ */
|
|
7933
|
+
), view === "mobile" || view === "tablet" ? /* @__PURE__ */ import_react70.default.createElement(
|
|
7296
7934
|
"tr",
|
|
7297
7935
|
{
|
|
7298
7936
|
className: mobileRowClass,
|
|
@@ -7302,7 +7940,7 @@ var ChartOfAccountsRow = ({
|
|
|
7302
7940
|
setAccountId(account.id);
|
|
7303
7941
|
}
|
|
7304
7942
|
},
|
|
7305
|
-
/* @__PURE__ */
|
|
7943
|
+
/* @__PURE__ */ import_react70.default.createElement("td", { className: "Layer__table-cell", colSpan: 5 }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7306
7944
|
"span",
|
|
7307
7945
|
{
|
|
7308
7946
|
className: "Layer__table-cell-content Layer__table-cell-content-indentation",
|
|
@@ -7311,7 +7949,7 @@ var ChartOfAccountsRow = ({
|
|
|
7311
7949
|
...style
|
|
7312
7950
|
}
|
|
7313
7951
|
},
|
|
7314
|
-
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */
|
|
7952
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react70.default.createElement(
|
|
7315
7953
|
ChevronDownFill_default,
|
|
7316
7954
|
{
|
|
7317
7955
|
size: 16,
|
|
@@ -7322,14 +7960,14 @@ var ChartOfAccountsRow = ({
|
|
|
7322
7960
|
}
|
|
7323
7961
|
}
|
|
7324
7962
|
),
|
|
7325
|
-
/* @__PURE__ */
|
|
7963
|
+
/* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content" }, /* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__top-row" }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7326
7964
|
Text,
|
|
7327
7965
|
{
|
|
7328
7966
|
as: "span",
|
|
7329
7967
|
className: "Layer__chart-of-accounts__mobile-row-content__name"
|
|
7330
7968
|
},
|
|
7331
7969
|
account.name
|
|
7332
|
-
), /* @__PURE__ */
|
|
7970
|
+
), /* @__PURE__ */ import_react70.default.createElement(
|
|
7333
7971
|
TextButton,
|
|
7334
7972
|
{
|
|
7335
7973
|
onClick: (e) => {
|
|
@@ -7339,7 +7977,7 @@ var ChartOfAccountsRow = ({
|
|
|
7339
7977
|
}
|
|
7340
7978
|
},
|
|
7341
7979
|
"Edit"
|
|
7342
|
-
)), /* @__PURE__ */
|
|
7980
|
+
)), /* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__bottom-row" }, /* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__types" }, /* @__PURE__ */ import_react70.default.createElement(Text, { as: "span" }, account.normality), /* @__PURE__ */ import_react70.default.createElement("span", { className: "Layer__chart-of-accounts__mobile-row-content__separator" }), /* @__PURE__ */ import_react70.default.createElement(Text, { as: "span" }, "Sub-Type")), /* @__PURE__ */ import_react70.default.createElement(
|
|
7343
7981
|
Text,
|
|
7344
7982
|
{
|
|
7345
7983
|
as: "span",
|
|
@@ -7349,7 +7987,7 @@ var ChartOfAccountsRow = ({
|
|
|
7349
7987
|
centsToDollars(Math.abs(account.balance || 0))
|
|
7350
7988
|
)))
|
|
7351
7989
|
))
|
|
7352
|
-
) : null, (account.sub_accounts || []).map((subAccount, idx) => /* @__PURE__ */
|
|
7990
|
+
) : null, (account.sub_accounts || []).map((subAccount, idx) => /* @__PURE__ */ import_react70.default.createElement(
|
|
7353
7991
|
ChartOfAccountsRow,
|
|
7354
7992
|
{
|
|
7355
7993
|
key: subAccount.id,
|
|
@@ -7365,26 +8003,14 @@ var ChartOfAccountsRow = ({
|
|
|
7365
8003
|
};
|
|
7366
8004
|
|
|
7367
8005
|
// src/components/ChartOfAccountsSidebar/ChartOfAccountsSidebar.tsx
|
|
7368
|
-
var
|
|
8006
|
+
var import_react73 = __toESM(require("react"));
|
|
7369
8007
|
|
|
7370
8008
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
7371
|
-
var
|
|
7372
|
-
|
|
7373
|
-
// src/components/ChartOfAccountsForm/constants.ts
|
|
7374
|
-
var SUB_TYPE_OPTIONS = [
|
|
7375
|
-
{
|
|
7376
|
-
value: "DEBIT" /* DEBIT */,
|
|
7377
|
-
label: "Debit"
|
|
7378
|
-
},
|
|
7379
|
-
{
|
|
7380
|
-
value: "CREDIT" /* CREDIT */,
|
|
7381
|
-
label: "Credit"
|
|
7382
|
-
}
|
|
7383
|
-
];
|
|
8009
|
+
var import_react72 = __toESM(require("react"));
|
|
7384
8010
|
|
|
7385
8011
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
7386
|
-
var
|
|
7387
|
-
var useParentOptions = (data) => (0,
|
|
8012
|
+
var import_react71 = require("react");
|
|
8013
|
+
var useParentOptions = (data) => (0, import_react71.useMemo)(
|
|
7388
8014
|
() => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
7389
8015
|
return {
|
|
7390
8016
|
label: x.name,
|
|
@@ -7404,9 +8030,9 @@ var ChartOfAccountsForm = () => {
|
|
|
7404
8030
|
submitForm,
|
|
7405
8031
|
sendingForm,
|
|
7406
8032
|
apiError
|
|
7407
|
-
} = (0,
|
|
8033
|
+
} = (0, import_react72.useContext)(ChartOfAccountsContext);
|
|
7408
8034
|
const parentOptions = useParentOptions(data);
|
|
7409
|
-
const entry = (0,
|
|
8035
|
+
const entry = (0, import_react72.useMemo)(() => {
|
|
7410
8036
|
if (form?.action === "edit" && form.accountId) {
|
|
7411
8037
|
return flattenAccounts(data?.accounts || []).find(
|
|
7412
8038
|
(x) => x.id === form.accountId
|
|
@@ -7417,7 +8043,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7417
8043
|
if (!form) {
|
|
7418
8044
|
return;
|
|
7419
8045
|
}
|
|
7420
|
-
return /* @__PURE__ */
|
|
8046
|
+
return /* @__PURE__ */ import_react72.default.createElement(
|
|
7421
8047
|
"form",
|
|
7422
8048
|
{
|
|
7423
8049
|
className: "Layer__form",
|
|
@@ -7426,7 +8052,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7426
8052
|
submitForm();
|
|
7427
8053
|
}
|
|
7428
8054
|
},
|
|
7429
|
-
/* @__PURE__ */
|
|
8055
|
+
/* @__PURE__ */ import_react72.default.createElement("div", { className: "Layer__chart-of-accounts__sidebar__header" }, /* @__PURE__ */ import_react72.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, form?.action === "edit" ? "Edit" : "Add New", " Account"), /* @__PURE__ */ import_react72.default.createElement("div", { className: "actions" }, /* @__PURE__ */ import_react72.default.createElement(
|
|
7430
8056
|
Button,
|
|
7431
8057
|
{
|
|
7432
8058
|
type: "button",
|
|
@@ -7435,7 +8061,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7435
8061
|
disabled: sendingForm
|
|
7436
8062
|
},
|
|
7437
8063
|
"Cancel"
|
|
7438
|
-
), apiError && /* @__PURE__ */
|
|
8064
|
+
), apiError && /* @__PURE__ */ import_react72.default.createElement(
|
|
7439
8065
|
RetryButton,
|
|
7440
8066
|
{
|
|
7441
8067
|
type: "submit",
|
|
@@ -7444,7 +8070,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7444
8070
|
disabled: sendingForm
|
|
7445
8071
|
},
|
|
7446
8072
|
"Retry"
|
|
7447
|
-
), !apiError && /* @__PURE__ */
|
|
8073
|
+
), !apiError && /* @__PURE__ */ import_react72.default.createElement(
|
|
7448
8074
|
SubmitButton,
|
|
7449
8075
|
{
|
|
7450
8076
|
type: "submit",
|
|
@@ -7454,7 +8080,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7454
8080
|
},
|
|
7455
8081
|
"Save"
|
|
7456
8082
|
))),
|
|
7457
|
-
apiError && /* @__PURE__ */
|
|
8083
|
+
apiError && /* @__PURE__ */ import_react72.default.createElement(
|
|
7458
8084
|
Text,
|
|
7459
8085
|
{
|
|
7460
8086
|
size: "sm" /* sm */,
|
|
@@ -7462,8 +8088,8 @@ var ChartOfAccountsForm = () => {
|
|
|
7462
8088
|
},
|
|
7463
8089
|
apiError
|
|
7464
8090
|
),
|
|
7465
|
-
entry && /* @__PURE__ */
|
|
7466
|
-
/* @__PURE__ */
|
|
8091
|
+
entry && /* @__PURE__ */ import_react72.default.createElement("div", { className: "Layer__chart-of-accounts__form-edit-entry" }, /* @__PURE__ */ import_react72.default.createElement(Text, { weight: "bold" /* bold */ }, entry.name), /* @__PURE__ */ import_react72.default.createElement(Text, { weight: "bold" /* bold */ }, "$", centsToDollars(entry.balance || 0))),
|
|
8092
|
+
/* @__PURE__ */ import_react72.default.createElement("div", { className: "Layer__chart-of-accounts__form" }, /* @__PURE__ */ import_react72.default.createElement(InputGroup, { name: "parent", label: "Parent", inline: true }, /* @__PURE__ */ import_react72.default.createElement(
|
|
7467
8093
|
Select2,
|
|
7468
8094
|
{
|
|
7469
8095
|
options: parentOptions,
|
|
@@ -7471,7 +8097,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7471
8097
|
onChange: (sel) => changeFormData("parent", sel),
|
|
7472
8098
|
disabled: sendingForm
|
|
7473
8099
|
}
|
|
7474
|
-
)), /* @__PURE__ */
|
|
8100
|
+
)), /* @__PURE__ */ import_react72.default.createElement(InputGroup, { name: "name", label: "Name", inline: true }, /* @__PURE__ */ import_react72.default.createElement(
|
|
7475
8101
|
Input,
|
|
7476
8102
|
{
|
|
7477
8103
|
name: "name",
|
|
@@ -7482,22 +8108,36 @@ var ChartOfAccountsForm = () => {
|
|
|
7482
8108
|
disabled: sendingForm,
|
|
7483
8109
|
onChange: (e) => changeFormData("name", e.target.value)
|
|
7484
8110
|
}
|
|
7485
|
-
)), /* @__PURE__ */
|
|
8111
|
+
)), /* @__PURE__ */ import_react72.default.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ import_react72.default.createElement(
|
|
7486
8112
|
Select2,
|
|
7487
8113
|
{
|
|
7488
|
-
options:
|
|
7489
|
-
disabled: true,
|
|
8114
|
+
options: LEDGER_ACCOUNT_TYPES,
|
|
7490
8115
|
value: form?.data.type,
|
|
7491
|
-
onChange: (sel) => changeFormData("type", sel)
|
|
8116
|
+
onChange: (sel) => changeFormData("type", sel),
|
|
8117
|
+
isInvalid: Boolean(form?.errors?.find((x) => x.field === "type")),
|
|
8118
|
+
errorMessage: form?.errors?.find((x) => x.field === "type")?.message,
|
|
8119
|
+
disabled: sendingForm || form.action === "edit" || form.data.parent !== void 0
|
|
7492
8120
|
}
|
|
7493
|
-
)), /* @__PURE__ */
|
|
8121
|
+
)), /* @__PURE__ */ import_react72.default.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ import_react72.default.createElement(
|
|
7494
8122
|
Select2,
|
|
7495
8123
|
{
|
|
7496
|
-
options:
|
|
8124
|
+
options: form?.data.type?.value !== void 0 ? LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE[form?.data.type?.value] : LEDGER_ACCOUNT_SUBTYPES,
|
|
7497
8125
|
value: form?.data.subType,
|
|
7498
8126
|
onChange: (sel) => changeFormData("subType", sel),
|
|
7499
8127
|
disabled: sendingForm
|
|
7500
8128
|
}
|
|
8129
|
+
)), /* @__PURE__ */ import_react72.default.createElement(InputGroup, { name: "normality", label: "Normality", inline: true }, /* @__PURE__ */ import_react72.default.createElement(
|
|
8130
|
+
Select2,
|
|
8131
|
+
{
|
|
8132
|
+
options: NORMALITY_OPTIONS,
|
|
8133
|
+
value: form?.data.normality,
|
|
8134
|
+
isInvalid: Boolean(
|
|
8135
|
+
form?.errors?.find((x) => x.field === "normality")
|
|
8136
|
+
),
|
|
8137
|
+
errorMessage: form?.errors?.find((x) => x.field === "normality")?.message,
|
|
8138
|
+
onChange: (sel) => changeFormData("normality", sel),
|
|
8139
|
+
disabled: sendingForm
|
|
8140
|
+
}
|
|
7501
8141
|
)))
|
|
7502
8142
|
);
|
|
7503
8143
|
};
|
|
@@ -7506,7 +8146,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7506
8146
|
var ChartOfAccountsSidebar = ({
|
|
7507
8147
|
parentRef: _parentRef
|
|
7508
8148
|
}) => {
|
|
7509
|
-
return /* @__PURE__ */
|
|
8149
|
+
return /* @__PURE__ */ import_react73.default.createElement(ChartOfAccountsForm, null);
|
|
7510
8150
|
};
|
|
7511
8151
|
|
|
7512
8152
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
@@ -7515,29 +8155,29 @@ var ChartOfAccountsTable = ({
|
|
|
7515
8155
|
view,
|
|
7516
8156
|
containerRef
|
|
7517
8157
|
}) => {
|
|
7518
|
-
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0,
|
|
8158
|
+
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react74.useContext)(ChartOfAccountsContext);
|
|
7519
8159
|
let cumulativeIndex = 0;
|
|
7520
8160
|
const accountsLength = data?.accounts.length ?? 0;
|
|
7521
|
-
return /* @__PURE__ */
|
|
8161
|
+
return /* @__PURE__ */ import_react74.default.createElement(
|
|
7522
8162
|
Panel,
|
|
7523
8163
|
{
|
|
7524
|
-
sidebar: /* @__PURE__ */
|
|
8164
|
+
sidebar: /* @__PURE__ */ import_react74.default.createElement(ChartOfAccountsSidebar, { parentRef: containerRef }),
|
|
7525
8165
|
sidebarIsOpen: Boolean(form),
|
|
7526
8166
|
parentRef: containerRef
|
|
7527
8167
|
},
|
|
7528
|
-
/* @__PURE__ */
|
|
8168
|
+
/* @__PURE__ */ import_react74.default.createElement(Header, { className: `Layer__${COMPONENT_NAME4}__header` }, /* @__PURE__ */ import_react74.default.createElement(Heading, { className: `Layer__${COMPONENT_NAME4}__title` }, "Chart of Accounts"), /* @__PURE__ */ import_react74.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__actions` }, /* @__PURE__ */ import_react74.default.createElement(
|
|
7529
8169
|
Button,
|
|
7530
8170
|
{
|
|
7531
8171
|
variant: "secondary" /* secondary */,
|
|
7532
8172
|
disabled: isLoading,
|
|
7533
|
-
rightIcon: /* @__PURE__ */
|
|
8173
|
+
rightIcon: /* @__PURE__ */ import_react74.default.createElement(DownloadCloud_default, { size: 12 })
|
|
7534
8174
|
},
|
|
7535
8175
|
"Download"
|
|
7536
|
-
), /* @__PURE__ */
|
|
7537
|
-
/* @__PURE__ */
|
|
8176
|
+
), /* @__PURE__ */ import_react74.default.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))),
|
|
8177
|
+
/* @__PURE__ */ import_react74.default.createElement("table", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react74.default.createElement("thead", null, /* @__PURE__ */ import_react74.default.createElement("tr", { className: "Layer__table-row--header" }, /* @__PURE__ */ import_react74.default.createElement("th", { className: "Layer__table-header Layer__coa__name" }, "Name"), /* @__PURE__ */ import_react74.default.createElement("th", { className: "Layer__table-header Layer__coa__type" }, "Type"), /* @__PURE__ */ import_react74.default.createElement("th", { className: "Layer__table-header Layer__coa__subtype Layer__mobile--hidden" }, "Sub-Type"), /* @__PURE__ */ import_react74.default.createElement("th", { className: "Layer__table-header Layer__coa__balance" }, "Balance"), /* @__PURE__ */ import_react74.default.createElement("th", { className: "Layer__table-header Layer__coa__actions" }))), /* @__PURE__ */ import_react74.default.createElement("tbody", null, !error && data?.accounts.map((account, idx) => {
|
|
7538
8178
|
const currentCumulativeIndex = cumulativeIndex;
|
|
7539
8179
|
cumulativeIndex = (account.sub_accounts?.length || 0) + cumulativeIndex + 1;
|
|
7540
|
-
return /* @__PURE__ */
|
|
8180
|
+
return /* @__PURE__ */ import_react74.default.createElement(
|
|
7541
8181
|
ChartOfAccountsRow,
|
|
7542
8182
|
{
|
|
7543
8183
|
key: account.id,
|
|
@@ -7552,7 +8192,7 @@ var ChartOfAccountsTable = ({
|
|
|
7552
8192
|
}
|
|
7553
8193
|
);
|
|
7554
8194
|
}))),
|
|
7555
|
-
error ? /* @__PURE__ */
|
|
8195
|
+
error ? /* @__PURE__ */ import_react74.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react74.default.createElement(
|
|
7556
8196
|
DataState,
|
|
7557
8197
|
{
|
|
7558
8198
|
status: "failed" /* failed */,
|
|
@@ -7562,8 +8202,8 @@ var ChartOfAccountsTable = ({
|
|
|
7562
8202
|
isLoading: isValidating || isLoading
|
|
7563
8203
|
}
|
|
7564
8204
|
)) : null,
|
|
7565
|
-
(!data || isLoading) && !error ? /* @__PURE__ */
|
|
7566
|
-
!isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */
|
|
8205
|
+
(!data || isLoading) && !error ? /* @__PURE__ */ import_react74.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ import_react74.default.createElement(Loader2, null)) : null,
|
|
8206
|
+
!isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ import_react74.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react74.default.createElement(
|
|
7567
8207
|
DataState,
|
|
7568
8208
|
{
|
|
7569
8209
|
status: "info" /* info */,
|
|
@@ -7577,21 +8217,21 @@ var ChartOfAccountsTable = ({
|
|
|
7577
8217
|
};
|
|
7578
8218
|
|
|
7579
8219
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
7580
|
-
var
|
|
8220
|
+
var import_react81 = __toESM(require("react"));
|
|
7581
8221
|
|
|
7582
8222
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
7583
|
-
var
|
|
8223
|
+
var import_react79 = __toESM(require("react"));
|
|
7584
8224
|
|
|
7585
8225
|
// src/components/Card/Card.tsx
|
|
7586
|
-
var
|
|
7587
|
-
var
|
|
8226
|
+
var import_react75 = __toESM(require("react"));
|
|
8227
|
+
var import_classnames34 = __toESM(require("classnames"));
|
|
7588
8228
|
var Card = ({ children, className }) => {
|
|
7589
|
-
return /* @__PURE__ */
|
|
8229
|
+
return /* @__PURE__ */ import_react75.default.createElement("div", { className: (0, import_classnames34.default)("Layer__card", className) }, children);
|
|
7590
8230
|
};
|
|
7591
8231
|
|
|
7592
8232
|
// src/components/DateTime/DateTime.tsx
|
|
7593
|
-
var
|
|
7594
|
-
var
|
|
8233
|
+
var import_react76 = __toESM(require("react"));
|
|
8234
|
+
var import_date_fns17 = require("date-fns");
|
|
7595
8235
|
var DateTime = ({
|
|
7596
8236
|
value,
|
|
7597
8237
|
format: format7,
|
|
@@ -7601,11 +8241,11 @@ var DateTime = ({
|
|
|
7601
8241
|
onlyTime
|
|
7602
8242
|
}) => {
|
|
7603
8243
|
if (format7) {
|
|
7604
|
-
return /* @__PURE__ */
|
|
8244
|
+
return /* @__PURE__ */ import_react76.default.createElement(Text, { className: "Layer__datetime" }, (0, import_date_fns17.format)((0, import_date_fns17.parseISO)(value), format7));
|
|
7605
8245
|
}
|
|
7606
|
-
const date = (0,
|
|
7607
|
-
const time = (0,
|
|
7608
|
-
return /* @__PURE__ */
|
|
8246
|
+
const date = (0, import_date_fns17.format)((0, import_date_fns17.parseISO)(value), dateFormat ?? DATE_FORMAT);
|
|
8247
|
+
const time = (0, import_date_fns17.format)((0, import_date_fns17.parseISO)(value), timeFormat ?? TIME_FORMAT);
|
|
8248
|
+
return /* @__PURE__ */ import_react76.default.createElement(Text, { className: "Layer__datetime" }, !onlyTime && /* @__PURE__ */ import_react76.default.createElement(
|
|
7609
8249
|
Text,
|
|
7610
8250
|
{
|
|
7611
8251
|
as: "span",
|
|
@@ -7614,7 +8254,7 @@ var DateTime = ({
|
|
|
7614
8254
|
className: "Layer__datetime__date"
|
|
7615
8255
|
},
|
|
7616
8256
|
date
|
|
7617
|
-
), !onlyDate && /* @__PURE__ */
|
|
8257
|
+
), !onlyDate && /* @__PURE__ */ import_react76.default.createElement(
|
|
7618
8258
|
Text,
|
|
7619
8259
|
{
|
|
7620
8260
|
as: "span",
|
|
@@ -7627,22 +8267,22 @@ var DateTime = ({
|
|
|
7627
8267
|
};
|
|
7628
8268
|
|
|
7629
8269
|
// src/components/DetailsList/DetailsList.tsx
|
|
7630
|
-
var
|
|
7631
|
-
var
|
|
8270
|
+
var import_react77 = __toESM(require("react"));
|
|
8271
|
+
var import_classnames35 = __toESM(require("classnames"));
|
|
7632
8272
|
var DetailsList = ({
|
|
7633
8273
|
title,
|
|
7634
8274
|
children,
|
|
7635
8275
|
className,
|
|
7636
8276
|
actions
|
|
7637
8277
|
}) => {
|
|
7638
|
-
return /* @__PURE__ */
|
|
8278
|
+
return /* @__PURE__ */ import_react77.default.createElement("div", { className: (0, import_classnames35.default)("Layer__details-list", className) }, title && /* @__PURE__ */ import_react77.default.createElement(Header, null, /* @__PURE__ */ import_react77.default.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ import_react77.default.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ import_react77.default.createElement("ul", { className: "Layer__details-list__list" }, children));
|
|
7639
8279
|
};
|
|
7640
8280
|
|
|
7641
8281
|
// src/components/DetailsList/DetailsListItem.tsx
|
|
7642
|
-
var
|
|
8282
|
+
var import_react78 = __toESM(require("react"));
|
|
7643
8283
|
var renderValue = (value) => {
|
|
7644
8284
|
if (typeof value === "string") {
|
|
7645
|
-
return /* @__PURE__ */
|
|
8285
|
+
return /* @__PURE__ */ import_react78.default.createElement(Text, { weight: "bold" /* bold */, size: "sm" /* sm */ }, value);
|
|
7646
8286
|
}
|
|
7647
8287
|
return value;
|
|
7648
8288
|
};
|
|
@@ -7651,7 +8291,7 @@ var DetailsListItem = ({
|
|
|
7651
8291
|
children,
|
|
7652
8292
|
isLoading
|
|
7653
8293
|
}) => {
|
|
7654
|
-
return /* @__PURE__ */
|
|
8294
|
+
return /* @__PURE__ */ import_react78.default.createElement("li", { className: "Layer__details-list-item" }, /* @__PURE__ */ import_react78.default.createElement("label", { className: "Layer__details-list-item__label" }, label), /* @__PURE__ */ import_react78.default.createElement("span", { className: "Layer__details-list-item__value" }, isLoading ? /* @__PURE__ */ import_react78.default.createElement(SkeletonLoader, null) : renderValue(children)));
|
|
7655
8295
|
};
|
|
7656
8296
|
|
|
7657
8297
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
@@ -7659,39 +8299,39 @@ var SourceDetailView = ({ source }) => {
|
|
|
7659
8299
|
switch (source.type) {
|
|
7660
8300
|
case "Transaction_Ledger_Entry_Source": {
|
|
7661
8301
|
const transactionSource = source;
|
|
7662
|
-
return /* @__PURE__ */
|
|
8302
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Account name" }, transactionSource.account_name), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Date" }, /* @__PURE__ */ import_react79.default.createElement(DateTime, { value: transactionSource.date })), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(transactionSource.amount)}`), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Direction" }, transactionSource.direction), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Counterparty" }, transactionSource.counterparty));
|
|
7663
8303
|
}
|
|
7664
8304
|
case "Invoice_Ledger_Entry_Source": {
|
|
7665
8305
|
const invoiceSource = source;
|
|
7666
|
-
return /* @__PURE__ */
|
|
8306
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Invoice number" }, invoiceSource.invoice_number), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Recipient name" }, invoiceSource.recipient_name), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Date" }, /* @__PURE__ */ import_react79.default.createElement(DateTime, { value: invoiceSource.date })), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(invoiceSource.amount)}`));
|
|
7667
8307
|
}
|
|
7668
8308
|
case "Manual_Ledger_Entry_Source": {
|
|
7669
8309
|
const manualSource = source;
|
|
7670
|
-
return /* @__PURE__ */
|
|
8310
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Memo" }, manualSource.memo), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Created by" }, manualSource.created_by));
|
|
7671
8311
|
}
|
|
7672
8312
|
case "Invoice_Payment_Ledger_Entry_Source": {
|
|
7673
8313
|
const invoicePaymentSource = source;
|
|
7674
|
-
return /* @__PURE__ */
|
|
8314
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Invoice number" }, invoicePaymentSource.invoice_number), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(invoicePaymentSource.amount)}`));
|
|
7675
8315
|
}
|
|
7676
8316
|
case "Refund_Ledger_Entry_Source": {
|
|
7677
8317
|
const refundSource = source;
|
|
7678
|
-
return /* @__PURE__ */
|
|
8318
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(refundSource.refunded_to_customer_amount)}`), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Recipient name" }, refundSource.recipient_name));
|
|
7679
8319
|
}
|
|
7680
8320
|
case "Opening_Balance_Ledger_Entry_Source": {
|
|
7681
8321
|
const openingBalanceSource = source;
|
|
7682
|
-
return /* @__PURE__ */
|
|
8322
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Account name" }, openingBalanceSource.account_name));
|
|
7683
8323
|
}
|
|
7684
8324
|
case "Payout_Ledger_Entry_Source": {
|
|
7685
8325
|
const payoutSource = source;
|
|
7686
|
-
return /* @__PURE__ */
|
|
8326
|
+
return /* @__PURE__ */ import_react79.default.createElement(import_react79.default.Fragment, null, /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Amount" }, `$${centsToDollars(payoutSource.paid_out_amount)}`), /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Processor" }, payoutSource.processor));
|
|
7687
8327
|
}
|
|
7688
8328
|
default:
|
|
7689
8329
|
return null;
|
|
7690
8330
|
}
|
|
7691
8331
|
};
|
|
7692
8332
|
var LedgerAccountEntryDetails = () => {
|
|
7693
|
-
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0,
|
|
7694
|
-
const { totalDebit, totalCredit } = (0,
|
|
8333
|
+
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react79.useContext)(LedgerAccountsContext);
|
|
8334
|
+
const { totalDebit, totalCredit } = (0, import_react79.useMemo)(() => {
|
|
7695
8335
|
let totalDebit2 = 0;
|
|
7696
8336
|
let totalCredit2 = 0;
|
|
7697
8337
|
entryData?.line_items?.forEach((item) => {
|
|
@@ -7703,47 +8343,47 @@ var LedgerAccountEntryDetails = () => {
|
|
|
7703
8343
|
});
|
|
7704
8344
|
return { totalDebit: totalDebit2, totalCredit: totalCredit2 };
|
|
7705
8345
|
}, [entryData]);
|
|
7706
|
-
return /* @__PURE__ */
|
|
8346
|
+
return /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger-account__entry-details" }, /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger-account__entry-details__back-btn" }, /* @__PURE__ */ import_react79.default.createElement(BackButton, { onClick: () => closeSelectedEntry() })), /* @__PURE__ */ import_react79.default.createElement(
|
|
7707
8347
|
DetailsList,
|
|
7708
8348
|
{
|
|
7709
8349
|
title: "Transaction source",
|
|
7710
|
-
actions: /* @__PURE__ */
|
|
8350
|
+
actions: /* @__PURE__ */ import_react79.default.createElement(
|
|
7711
8351
|
IconButton,
|
|
7712
8352
|
{
|
|
7713
|
-
icon: /* @__PURE__ */
|
|
8353
|
+
icon: /* @__PURE__ */ import_react79.default.createElement(X_default, null),
|
|
7714
8354
|
onClick: () => closeSelectedEntry(),
|
|
7715
8355
|
className: "Layer__hidden-sm Layer__hidden-xs"
|
|
7716
8356
|
}
|
|
7717
8357
|
)
|
|
7718
8358
|
},
|
|
7719
|
-
/* @__PURE__ */
|
|
7720
|
-
entryData?.source?.display_description && /* @__PURE__ */
|
|
7721
|
-
), /* @__PURE__ */
|
|
8359
|
+
/* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Source", isLoading: isLoadingEntry }, /* @__PURE__ */ import_react79.default.createElement(Badge, null, entryData?.source?.entity_name)),
|
|
8360
|
+
entryData?.source?.display_description && /* @__PURE__ */ import_react79.default.createElement(SourceDetailView, { source: entryData?.source })
|
|
8361
|
+
), /* @__PURE__ */ import_react79.default.createElement(
|
|
7722
8362
|
DetailsList,
|
|
7723
8363
|
{
|
|
7724
8364
|
title: `Journal Entry ${entryData?.id.substring(0, 5)}`,
|
|
7725
8365
|
className: "Layer__border-top"
|
|
7726
8366
|
},
|
|
7727
|
-
/* @__PURE__ */
|
|
7728
|
-
/* @__PURE__ */
|
|
7729
|
-
/* @__PURE__ */
|
|
7730
|
-
entryData?.reversal_id && /* @__PURE__ */
|
|
7731
|
-
), !isLoadingEntry && !errorEntry ? /* @__PURE__ */
|
|
8367
|
+
/* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Entry type", isLoading: isLoadingEntry }, humanizeEnum(entryData?.entry_type ?? "")),
|
|
8368
|
+
/* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, entryData?.entry_at && /* @__PURE__ */ import_react79.default.createElement(DateTime, { value: entryData?.entry_at })),
|
|
8369
|
+
/* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Creation date", isLoading: isLoadingEntry }, entryData?.date && /* @__PURE__ */ import_react79.default.createElement(DateTime, { value: entryData?.date })),
|
|
8370
|
+
entryData?.reversal_id && /* @__PURE__ */ import_react79.default.createElement(DetailsListItem, { label: "Reversal", isLoading: isLoadingEntry }, entryData?.reversal_id.substring(0, 5))
|
|
8371
|
+
), !isLoadingEntry && !errorEntry ? /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger-account__entry-details__line-items" }, /* @__PURE__ */ import_react79.default.createElement(Card, null, /* @__PURE__ */ import_react79.default.createElement("table", { className: "Layer__table Layer__ledger-account__entry-details__table" }, /* @__PURE__ */ import_react79.default.createElement("thead", null, /* @__PURE__ */ import_react79.default.createElement("tr", null, /* @__PURE__ */ import_react79.default.createElement("th", { className: "Layer__table-header" }, "Line items"), /* @__PURE__ */ import_react79.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react79.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"))), /* @__PURE__ */ import_react79.default.createElement("tbody", null, entryData?.line_items?.map((item) => /* @__PURE__ */ import_react79.default.createElement("tr", { key: `ledger-line-item-${item.id}` }, /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell" }, item.account?.name || ""), /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "DEBIT" /* DEBIT */ && /* @__PURE__ */ import_react79.default.createElement(Badge, { variant: "warning" /* WARNING */ }, "$", centsToDollars(item.amount || 0))), /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "CREDIT" /* CREDIT */ && /* @__PURE__ */ import_react79.default.createElement(Badge, { variant: "success" /* SUCCESS */ }, "$", centsToDollars(item.amount || 0))))), /* @__PURE__ */ import_react79.default.createElement("tr", { className: "Layer__table Layer__ledger-account__entry-details__table__total-row" }, /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell" }, "Total"), /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalDebit || 0)), /* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalCredit || 0))))))) : null);
|
|
7732
8372
|
};
|
|
7733
8373
|
|
|
7734
8374
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
7735
|
-
var
|
|
7736
|
-
var
|
|
7737
|
-
var
|
|
8375
|
+
var import_react80 = __toESM(require("react"));
|
|
8376
|
+
var import_classnames36 = __toESM(require("classnames"));
|
|
8377
|
+
var import_date_fns18 = require("date-fns");
|
|
7738
8378
|
var LedgerAccountRow = ({
|
|
7739
8379
|
row,
|
|
7740
8380
|
index,
|
|
7741
8381
|
initialLoad,
|
|
7742
8382
|
view
|
|
7743
8383
|
}) => {
|
|
7744
|
-
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0,
|
|
7745
|
-
const [showComponent, setShowComponent] = (0,
|
|
7746
|
-
(0,
|
|
8384
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react80.useContext)(LedgerAccountsContext);
|
|
8385
|
+
const [showComponent, setShowComponent] = (0, import_react80.useState)(false);
|
|
8386
|
+
(0, import_react80.useEffect)(() => {
|
|
7747
8387
|
if (initialLoad) {
|
|
7748
8388
|
const timeoutId = setTimeout(() => {
|
|
7749
8389
|
setShowComponent(true);
|
|
@@ -7754,10 +8394,10 @@ var LedgerAccountRow = ({
|
|
|
7754
8394
|
}
|
|
7755
8395
|
}, []);
|
|
7756
8396
|
if (view === "tablet") {
|
|
7757
|
-
return /* @__PURE__ */
|
|
8397
|
+
return /* @__PURE__ */ import_react80.default.createElement(
|
|
7758
8398
|
"tr",
|
|
7759
8399
|
{
|
|
7760
|
-
className: (0,
|
|
8400
|
+
className: (0, import_classnames36.default)(
|
|
7761
8401
|
"Layer__table-row",
|
|
7762
8402
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7763
8403
|
initialLoad && "initial-load",
|
|
@@ -7773,24 +8413,24 @@ var LedgerAccountRow = ({
|
|
|
7773
8413
|
}
|
|
7774
8414
|
}
|
|
7775
8415
|
},
|
|
7776
|
-
/* @__PURE__ */
|
|
8416
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react80.default.createElement(Text, null, row.date && (0, import_date_fns18.format)((0, import_date_fns18.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react80.default.createElement(
|
|
7777
8417
|
Text,
|
|
7778
8418
|
{
|
|
7779
8419
|
weight: "normal" /* normal */,
|
|
7780
8420
|
className: "Layer__ledger_account-table__journal-id"
|
|
7781
8421
|
},
|
|
7782
8422
|
row.entry_id.substring(0, 5)
|
|
7783
|
-
)), /* @__PURE__ */
|
|
7784
|
-
/* @__PURE__ */
|
|
7785
|
-
/* @__PURE__ */
|
|
7786
|
-
/* @__PURE__ */
|
|
8423
|
+
)), /* @__PURE__ */ import_react80.default.createElement(Text, null, row.source?.display_description ?? ""))),
|
|
8424
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
8425
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
8426
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, `$${centsToDollars(row.running_balance)}`))
|
|
7787
8427
|
);
|
|
7788
8428
|
}
|
|
7789
8429
|
if (view === "mobile") {
|
|
7790
|
-
return /* @__PURE__ */
|
|
8430
|
+
return /* @__PURE__ */ import_react80.default.createElement(
|
|
7791
8431
|
"tr",
|
|
7792
8432
|
{
|
|
7793
|
-
className: (0,
|
|
8433
|
+
className: (0, import_classnames36.default)(
|
|
7794
8434
|
"Layer__table-row",
|
|
7795
8435
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7796
8436
|
initialLoad && "initial-load",
|
|
@@ -7806,20 +8446,20 @@ var LedgerAccountRow = ({
|
|
|
7806
8446
|
}
|
|
7807
8447
|
}
|
|
7808
8448
|
},
|
|
7809
|
-
/* @__PURE__ */
|
|
8449
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react80.default.createElement(Text, null, row.date && (0, import_date_fns18.format)((0, import_date_fns18.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react80.default.createElement(
|
|
7810
8450
|
Text,
|
|
7811
8451
|
{
|
|
7812
8452
|
weight: "normal" /* normal */,
|
|
7813
8453
|
className: "Layer__ledger_account-table__journal-id"
|
|
7814
8454
|
},
|
|
7815
8455
|
row.entry_id.substring(0, 5)
|
|
7816
|
-
)), /* @__PURE__ */
|
|
8456
|
+
)), /* @__PURE__ */ import_react80.default.createElement(Text, null, row.source?.display_description ?? ""), /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger_account-table__balances-mobile" }, /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Debit"), /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, " ", row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Credit"), /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Running balance"), /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, `$${centsToDollars(row.running_balance)}`)))))
|
|
7817
8457
|
);
|
|
7818
8458
|
}
|
|
7819
|
-
return /* @__PURE__ */
|
|
8459
|
+
return /* @__PURE__ */ import_react80.default.createElement(
|
|
7820
8460
|
"tr",
|
|
7821
8461
|
{
|
|
7822
|
-
className: (0,
|
|
8462
|
+
className: (0, import_classnames36.default)(
|
|
7823
8463
|
"Layer__table-row",
|
|
7824
8464
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7825
8465
|
initialLoad && "initial-load",
|
|
@@ -7835,25 +8475,25 @@ var LedgerAccountRow = ({
|
|
|
7835
8475
|
}
|
|
7836
8476
|
}
|
|
7837
8477
|
},
|
|
7838
|
-
/* @__PURE__ */
|
|
7839
|
-
/* @__PURE__ */
|
|
7840
|
-
/* @__PURE__ */
|
|
7841
|
-
/* @__PURE__ */
|
|
7842
|
-
/* @__PURE__ */
|
|
7843
|
-
/* @__PURE__ */
|
|
8478
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0, import_date_fns18.format)((0, import_date_fns18.parseISO)(row.date), DATE_FORMAT))),
|
|
8479
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content" }, row.entry_id.substring(0, 5))),
|
|
8480
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content" }, row.source?.display_description ?? "")),
|
|
8481
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
8482
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
8483
|
+
/* @__PURE__ */ import_react80.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react80.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, `$${centsToDollars(row.running_balance)}`))
|
|
7844
8484
|
);
|
|
7845
8485
|
};
|
|
7846
8486
|
|
|
7847
8487
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
7848
|
-
var
|
|
8488
|
+
var import_classnames37 = __toESM(require("classnames"));
|
|
7849
8489
|
var LedgerAccount = ({
|
|
7850
8490
|
containerRef,
|
|
7851
8491
|
pageSize = 15,
|
|
7852
8492
|
view
|
|
7853
8493
|
}) => {
|
|
7854
|
-
const [currentPage, setCurrentPage] = (0,
|
|
7855
|
-
const [initialLoad, setInitialLoad] = (0,
|
|
7856
|
-
const { data: accountData } = (0,
|
|
8494
|
+
const [currentPage, setCurrentPage] = (0, import_react81.useState)(1);
|
|
8495
|
+
const [initialLoad, setInitialLoad] = (0, import_react81.useState)(true);
|
|
8496
|
+
const { data: accountData } = (0, import_react81.useContext)(ChartOfAccountsContext);
|
|
7857
8497
|
const {
|
|
7858
8498
|
data: rawData,
|
|
7859
8499
|
error,
|
|
@@ -7864,8 +8504,8 @@ var LedgerAccount = ({
|
|
|
7864
8504
|
selectedEntryId,
|
|
7865
8505
|
closeSelectedEntry,
|
|
7866
8506
|
refetch
|
|
7867
|
-
} = (0,
|
|
7868
|
-
(0,
|
|
8507
|
+
} = (0, import_react81.useContext)(LedgerAccountsContext);
|
|
8508
|
+
(0, import_react81.useEffect)(() => {
|
|
7869
8509
|
if (!isLoading) {
|
|
7870
8510
|
const timeoutLoad = setTimeout(() => {
|
|
7871
8511
|
setInitialLoad(false);
|
|
@@ -7873,16 +8513,16 @@ var LedgerAccount = ({
|
|
|
7873
8513
|
return () => clearTimeout(timeoutLoad);
|
|
7874
8514
|
}
|
|
7875
8515
|
}, [isLoading]);
|
|
7876
|
-
const baseClassName = (0,
|
|
8516
|
+
const baseClassName = (0, import_classnames37.default)(
|
|
7877
8517
|
"Layer__ledger-account__index",
|
|
7878
8518
|
accountId && "open"
|
|
7879
8519
|
);
|
|
7880
|
-
const entry = (0,
|
|
8520
|
+
const entry = (0, import_react81.useMemo)(() => {
|
|
7881
8521
|
return flattenAccounts(accountData?.accounts || []).find(
|
|
7882
8522
|
(x) => x.id === accountId
|
|
7883
8523
|
);
|
|
7884
8524
|
}, [accountId]);
|
|
7885
|
-
const data = (0,
|
|
8525
|
+
const data = (0, import_react81.useMemo)(() => {
|
|
7886
8526
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
7887
8527
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
7888
8528
|
return rawData?.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))?.slice(firstPageIndex, lastPageIndex);
|
|
@@ -7891,36 +8531,36 @@ var LedgerAccount = ({
|
|
|
7891
8531
|
setAccountId(void 0);
|
|
7892
8532
|
closeSelectedEntry();
|
|
7893
8533
|
};
|
|
7894
|
-
return /* @__PURE__ */
|
|
8534
|
+
return /* @__PURE__ */ import_react81.default.createElement(
|
|
7895
8535
|
Panel,
|
|
7896
8536
|
{
|
|
7897
|
-
sidebar: /* @__PURE__ */
|
|
8537
|
+
sidebar: /* @__PURE__ */ import_react81.default.createElement(LedgerAccountEntryDetails, null),
|
|
7898
8538
|
sidebarIsOpen: Boolean(selectedEntryId),
|
|
7899
8539
|
parentRef: containerRef,
|
|
7900
8540
|
className: "Layer__ledger-account__panel"
|
|
7901
8541
|
},
|
|
7902
|
-
/* @__PURE__ */
|
|
8542
|
+
/* @__PURE__ */ import_react81.default.createElement("div", { className: baseClassName }, /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__ledger-account__header" }, /* @__PURE__ */ import_react81.default.createElement(BackButton, { onClick: close }), /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__ledger-account__title-container" }, /* @__PURE__ */ import_react81.default.createElement(
|
|
7903
8543
|
Text,
|
|
7904
8544
|
{
|
|
7905
8545
|
weight: "bold" /* bold */,
|
|
7906
8546
|
className: "Layer__ledger-account__title"
|
|
7907
8547
|
},
|
|
7908
8548
|
entry?.name ?? ""
|
|
7909
|
-
), /* @__PURE__ */
|
|
8549
|
+
), /* @__PURE__ */ import_react81.default.createElement(
|
|
7910
8550
|
Button,
|
|
7911
8551
|
{
|
|
7912
8552
|
variant: "secondary" /* secondary */,
|
|
7913
|
-
rightIcon: /* @__PURE__ */
|
|
8553
|
+
rightIcon: /* @__PURE__ */ import_react81.default.createElement(DownloadCloud_default, { size: 12 })
|
|
7914
8554
|
},
|
|
7915
8555
|
"Download"
|
|
7916
|
-
)), /* @__PURE__ */
|
|
8556
|
+
)), /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__ledger-account__balance-container" }, /* @__PURE__ */ import_react81.default.createElement(
|
|
7917
8557
|
Text,
|
|
7918
8558
|
{
|
|
7919
8559
|
weight: "bold" /* bold */,
|
|
7920
8560
|
className: "Layer__ledger-account__balance-label"
|
|
7921
8561
|
},
|
|
7922
8562
|
"Current balance"
|
|
7923
|
-
), /* @__PURE__ */
|
|
8563
|
+
), /* @__PURE__ */ import_react81.default.createElement(
|
|
7924
8564
|
Text,
|
|
7925
8565
|
{
|
|
7926
8566
|
weight: "bold" /* bold */,
|
|
@@ -7928,7 +8568,7 @@ var LedgerAccount = ({
|
|
|
7928
8568
|
},
|
|
7929
8569
|
"$",
|
|
7930
8570
|
centsToDollars(entry?.balance || 0)
|
|
7931
|
-
))), /* @__PURE__ */
|
|
8571
|
+
))), /* @__PURE__ */ import_react81.default.createElement("table", { className: "Layer__table Layer__table--hover-effect Layer__ledger-account-table" }, /* @__PURE__ */ import_react81.default.createElement("thead", null, /* @__PURE__ */ import_react81.default.createElement("tr", null, view !== "desktop" && /* @__PURE__ */ import_react81.default.createElement("th", null), view === "desktop" && /* @__PURE__ */ import_react81.default.createElement(import_react81.default.Fragment, null, /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header" }, "Source")), view !== "mobile" && /* @__PURE__ */ import_react81.default.createElement(import_react81.default.Fragment, null, /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ import_react81.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance")))), /* @__PURE__ */ import_react81.default.createElement("tbody", null, data?.map((x, index) => /* @__PURE__ */ import_react81.default.createElement(
|
|
7932
8572
|
LedgerAccountRow,
|
|
7933
8573
|
{
|
|
7934
8574
|
key: x.id,
|
|
@@ -7937,7 +8577,7 @@ var LedgerAccount = ({
|
|
|
7937
8577
|
initialLoad,
|
|
7938
8578
|
view
|
|
7939
8579
|
}
|
|
7940
|
-
)))), data && /* @__PURE__ */
|
|
8580
|
+
)))), data && /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__ledger-account__pagination" }, /* @__PURE__ */ import_react81.default.createElement(
|
|
7941
8581
|
Pagination,
|
|
7942
8582
|
{
|
|
7943
8583
|
currentPage,
|
|
@@ -7945,7 +8585,7 @@ var LedgerAccount = ({
|
|
|
7945
8585
|
pageSize,
|
|
7946
8586
|
onPageChange: (page) => setCurrentPage(page)
|
|
7947
8587
|
}
|
|
7948
|
-
)), error ? /* @__PURE__ */
|
|
8588
|
+
)), error ? /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react81.default.createElement(
|
|
7949
8589
|
DataState,
|
|
7950
8590
|
{
|
|
7951
8591
|
status: "failed" /* failed */,
|
|
@@ -7954,7 +8594,7 @@ var LedgerAccount = ({
|
|
|
7954
8594
|
onRefresh: () => refetch(),
|
|
7955
8595
|
isLoading: isValidating || isLoading
|
|
7956
8596
|
}
|
|
7957
|
-
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */
|
|
8597
|
+
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */ import_react81.default.createElement("div", { className: `Layer__ledger-account__loader-container` }, /* @__PURE__ */ import_react81.default.createElement(Loader2, null)) : null, !isLoading && !error && data?.length === 0 ? /* @__PURE__ */ import_react81.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react81.default.createElement(
|
|
7958
8598
|
DataState,
|
|
7959
8599
|
{
|
|
7960
8600
|
status: "info" /* info */,
|
|
@@ -7967,7 +8607,7 @@ var LedgerAccount = ({
|
|
|
7967
8607
|
};
|
|
7968
8608
|
|
|
7969
8609
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
7970
|
-
var ChartOfAccountsContext = (0,
|
|
8610
|
+
var ChartOfAccountsContext = (0, import_react82.createContext)(
|
|
7971
8611
|
{
|
|
7972
8612
|
data: void 0,
|
|
7973
8613
|
isLoading: false,
|
|
@@ -7992,7 +8632,7 @@ var ChartOfAccountsContext = (0, import_react81.createContext)(
|
|
|
7992
8632
|
}
|
|
7993
8633
|
}
|
|
7994
8634
|
);
|
|
7995
|
-
var LedgerAccountsContext = (0,
|
|
8635
|
+
var LedgerAccountsContext = (0, import_react82.createContext)({
|
|
7996
8636
|
data: void 0,
|
|
7997
8637
|
entryData: void 0,
|
|
7998
8638
|
isLoading: false,
|
|
@@ -8015,11 +8655,11 @@ var LedgerAccountsContext = (0, import_react81.createContext)({
|
|
|
8015
8655
|
var ChartOfAccounts = (props) => {
|
|
8016
8656
|
const chartOfAccountsContextData = useChartOfAccounts();
|
|
8017
8657
|
const ledgerAccountsContextData = useLedgerAccounts();
|
|
8018
|
-
return /* @__PURE__ */
|
|
8658
|
+
return /* @__PURE__ */ import_react82.default.createElement(ChartOfAccountsContext.Provider, { value: chartOfAccountsContextData }, /* @__PURE__ */ import_react82.default.createElement(LedgerAccountsContext.Provider, { value: ledgerAccountsContextData }, /* @__PURE__ */ import_react82.default.createElement(ChartOfAccountsContent, null)));
|
|
8019
8659
|
};
|
|
8020
8660
|
var ChartOfAccountsContent = ({ asWidget }) => {
|
|
8021
|
-
const { accountId } = (0,
|
|
8022
|
-
const [view, setView] = (0,
|
|
8661
|
+
const { accountId } = (0, import_react82.useContext)(LedgerAccountsContext);
|
|
8662
|
+
const [view, setView] = (0, import_react82.useState)("desktop");
|
|
8023
8663
|
const containerRef = useElementSize((_a, _b, { width }) => {
|
|
8024
8664
|
if (width) {
|
|
8025
8665
|
if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
|
|
@@ -8031,12 +8671,12 @@ var ChartOfAccountsContent = ({ asWidget }) => {
|
|
|
8031
8671
|
}
|
|
8032
8672
|
}
|
|
8033
8673
|
});
|
|
8034
|
-
return /* @__PURE__ */
|
|
8674
|
+
return /* @__PURE__ */ import_react82.default.createElement(Container, { name: "chart-of-accounts", ref: containerRef, asWidget }, accountId ? /* @__PURE__ */ import_react82.default.createElement(LedgerAccount, { view, containerRef }) : /* @__PURE__ */ import_react82.default.createElement(ChartOfAccountsTable, { view, containerRef }));
|
|
8035
8675
|
};
|
|
8036
8676
|
|
|
8037
8677
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
8038
|
-
var
|
|
8039
|
-
var
|
|
8678
|
+
var import_react83 = __toESM(require("react"));
|
|
8679
|
+
var import_date_fns19 = require("date-fns");
|
|
8040
8680
|
var import_swr8 = __toESM(require("swr"));
|
|
8041
8681
|
var reducer = (state, action) => {
|
|
8042
8682
|
switch (action.type) {
|
|
@@ -8077,7 +8717,7 @@ var LayerProvider = ({
|
|
|
8077
8717
|
};
|
|
8078
8718
|
const colors = buildColorsPalette(theme);
|
|
8079
8719
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
8080
|
-
const [state, dispatch] = (0,
|
|
8720
|
+
const [state, dispatch] = (0, import_react83.useReducer)(reducer, {
|
|
8081
8721
|
auth: {
|
|
8082
8722
|
access_token: "",
|
|
8083
8723
|
token_type: "",
|
|
@@ -8091,7 +8731,7 @@ var LayerProvider = ({
|
|
|
8091
8731
|
colors
|
|
8092
8732
|
});
|
|
8093
8733
|
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr8.default)(
|
|
8094
|
-
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0,
|
|
8734
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns19.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
8095
8735
|
Layer.authenticate({
|
|
8096
8736
|
appId,
|
|
8097
8737
|
appSecret,
|
|
@@ -8100,7 +8740,7 @@ var LayerProvider = ({
|
|
|
8100
8740
|
}),
|
|
8101
8741
|
defaultSWRConfig
|
|
8102
8742
|
) : { data: void 0 };
|
|
8103
|
-
(0,
|
|
8743
|
+
(0, import_react83.useEffect)(() => {
|
|
8104
8744
|
if (businessAccessToken) {
|
|
8105
8745
|
dispatch({
|
|
8106
8746
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -8109,7 +8749,7 @@ var LayerProvider = ({
|
|
|
8109
8749
|
access_token: businessAccessToken,
|
|
8110
8750
|
token_type: "Bearer",
|
|
8111
8751
|
expires_in: 3600,
|
|
8112
|
-
expires_at: (0,
|
|
8752
|
+
expires_at: (0, import_date_fns19.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
8113
8753
|
}
|
|
8114
8754
|
}
|
|
8115
8755
|
});
|
|
@@ -8119,7 +8759,7 @@ var LayerProvider = ({
|
|
|
8119
8759
|
payload: {
|
|
8120
8760
|
auth: {
|
|
8121
8761
|
...auth,
|
|
8122
|
-
expires_at: (0,
|
|
8762
|
+
expires_at: (0, import_date_fns19.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
8123
8763
|
}
|
|
8124
8764
|
}
|
|
8125
8765
|
});
|
|
@@ -8174,7 +8814,7 @@ var LayerProvider = ({
|
|
|
8174
8814
|
}
|
|
8175
8815
|
return;
|
|
8176
8816
|
};
|
|
8177
|
-
return /* @__PURE__ */
|
|
8817
|
+
return /* @__PURE__ */ import_react83.default.createElement(import_swr8.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react83.default.createElement(
|
|
8178
8818
|
LayerContext.Provider,
|
|
8179
8819
|
{
|
|
8180
8820
|
value: { ...state, setTheme, getColor, setLightColor, setDarkColor, setColors }
|
|
@@ -8184,53 +8824,53 @@ var LayerProvider = ({
|
|
|
8184
8824
|
};
|
|
8185
8825
|
|
|
8186
8826
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
8187
|
-
var
|
|
8827
|
+
var import_react86 = __toESM(require("react"));
|
|
8188
8828
|
|
|
8189
8829
|
// src/components/View/View.tsx
|
|
8190
|
-
var
|
|
8830
|
+
var import_react85 = __toESM(require("react"));
|
|
8191
8831
|
|
|
8192
8832
|
// src/components/ViewHeader/ViewHeader.tsx
|
|
8193
|
-
var
|
|
8833
|
+
var import_react84 = __toESM(require("react"));
|
|
8194
8834
|
var ViewHeader = ({ title, controls }) => {
|
|
8195
|
-
return /* @__PURE__ */
|
|
8835
|
+
return /* @__PURE__ */ import_react84.default.createElement("div", { className: "Layer__view-header" }, /* @__PURE__ */ import_react84.default.createElement("div", { className: "Layer__view-header__content" }, /* @__PURE__ */ import_react84.default.createElement(Heading, null, title), controls && /* @__PURE__ */ import_react84.default.createElement("div", { className: "Layer__view-header__controls" }, controls)));
|
|
8196
8836
|
};
|
|
8197
8837
|
|
|
8198
8838
|
// src/components/View/View.tsx
|
|
8199
8839
|
var View6 = ({ title, children, headerControls }) => {
|
|
8200
8840
|
const { theme } = useLayerContext();
|
|
8201
8841
|
const styles = parseStylesFromThemeConfig(theme);
|
|
8202
|
-
return /* @__PURE__ */
|
|
8842
|
+
return /* @__PURE__ */ import_react85.default.createElement("div", { className: "Layer__view", style: { ...styles } }, /* @__PURE__ */ import_react85.default.createElement(ViewHeader, { title, controls: headerControls }), /* @__PURE__ */ import_react85.default.createElement("div", { className: "Layer__view-main" }, children));
|
|
8203
8843
|
};
|
|
8204
8844
|
|
|
8205
8845
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
8206
8846
|
var AccountingOverview = ({
|
|
8207
8847
|
title = "Accounting overview"
|
|
8208
8848
|
}) => {
|
|
8209
|
-
return /* @__PURE__ */
|
|
8849
|
+
return /* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ import_react86.default.createElement(View6, { title, headerControls: /* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss.DatePicker, null) }, /* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss.Summaries, { actionable: false }), /* @__PURE__ */ import_react86.default.createElement(
|
|
8210
8850
|
Container,
|
|
8211
8851
|
{
|
|
8212
8852
|
name: "accounting-overview-profit-and-loss",
|
|
8213
8853
|
asWidget: true,
|
|
8214
8854
|
elevated: true
|
|
8215
8855
|
},
|
|
8216
|
-
/* @__PURE__ */
|
|
8217
|
-
/* @__PURE__ */
|
|
8218
|
-
), /* @__PURE__ */
|
|
8856
|
+
/* @__PURE__ */ import_react86.default.createElement(Header, null, /* @__PURE__ */ import_react86.default.createElement(Heading, { size: "secondary" /* secondary */ }, "Profit & Loss")),
|
|
8857
|
+
/* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss.Chart, null)
|
|
8858
|
+
), /* @__PURE__ */ import_react86.default.createElement("div", { className: "accounting-overview-profit-and-loss-charts" }, /* @__PURE__ */ import_react86.default.createElement(Container, { name: "accounting-overview-profit-and-loss-chart" }, /* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss.DetailedCharts, { scope: "revenue", hideClose: true })), /* @__PURE__ */ import_react86.default.createElement(Container, { name: "accounting-overview-profit-and-loss-chart" }, /* @__PURE__ */ import_react86.default.createElement(ProfitAndLoss.DetailedCharts, { scope: "expenses", hideClose: true })))));
|
|
8219
8859
|
};
|
|
8220
8860
|
|
|
8221
8861
|
// src/views/BankTransactionsWithLinkedAccounts/BankTransactionsWithLinkedAccounts.tsx
|
|
8222
|
-
var
|
|
8862
|
+
var import_react87 = __toESM(require("react"));
|
|
8223
8863
|
var BankTransactionsWithLinkedAccounts = ({
|
|
8224
8864
|
title = "Bank transactions"
|
|
8225
8865
|
}) => {
|
|
8226
|
-
return /* @__PURE__ */
|
|
8866
|
+
return /* @__PURE__ */ import_react87.default.createElement(View6, { title }, /* @__PURE__ */ import_react87.default.createElement(LinkedAccounts, { elevated: true }), /* @__PURE__ */ import_react87.default.createElement(BankTransactions, { asWidget: true }));
|
|
8227
8867
|
};
|
|
8228
8868
|
|
|
8229
8869
|
// src/views/Reports/Reports.tsx
|
|
8230
|
-
var
|
|
8870
|
+
var import_react88 = __toESM(require("react"));
|
|
8231
8871
|
var Reports = ({ title = "Reports" }) => {
|
|
8232
|
-
const containerRef = (0,
|
|
8233
|
-
return /* @__PURE__ */
|
|
8872
|
+
const containerRef = (0, import_react88.useRef)(null);
|
|
8873
|
+
return /* @__PURE__ */ import_react88.default.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ import_react88.default.createElement(View6, { title, headerControls: /* @__PURE__ */ import_react88.default.createElement(ProfitAndLoss.DatePicker, null) }, /* @__PURE__ */ import_react88.default.createElement(
|
|
8234
8874
|
Toggle,
|
|
8235
8875
|
{
|
|
8236
8876
|
name: "reports-tabs",
|
|
@@ -8248,18 +8888,18 @@ var Reports = ({ title = "Reports" }) => {
|
|
|
8248
8888
|
selected: "profitAndLoss",
|
|
8249
8889
|
onChange: () => null
|
|
8250
8890
|
}
|
|
8251
|
-
), /* @__PURE__ */
|
|
8891
|
+
), /* @__PURE__ */ import_react88.default.createElement(Container, { name: "reports", ref: containerRef }, /* @__PURE__ */ import_react88.default.createElement(ReportsPanel, { containerRef }))));
|
|
8252
8892
|
};
|
|
8253
8893
|
var ReportsPanel = ({ containerRef }) => {
|
|
8254
|
-
const { sidebarScope } = (0,
|
|
8255
|
-
return /* @__PURE__ */
|
|
8894
|
+
const { sidebarScope } = (0, import_react88.useContext)(ProfitAndLoss.Context);
|
|
8895
|
+
return /* @__PURE__ */ import_react88.default.createElement(
|
|
8256
8896
|
Panel,
|
|
8257
8897
|
{
|
|
8258
|
-
sidebar: /* @__PURE__ */
|
|
8898
|
+
sidebar: /* @__PURE__ */ import_react88.default.createElement(ProfitAndLoss.DetailedCharts, null),
|
|
8259
8899
|
sidebarIsOpen: Boolean(sidebarScope),
|
|
8260
8900
|
parentRef: containerRef
|
|
8261
8901
|
},
|
|
8262
|
-
/* @__PURE__ */
|
|
8902
|
+
/* @__PURE__ */ import_react88.default.createElement(ProfitAndLoss.Table, { asContainer: false })
|
|
8263
8903
|
);
|
|
8264
8904
|
};
|
|
8265
8905
|
// Annotate the CommonJS export names for ESM import in node:
|