@layerfi/components 0.1.10 → 0.1.11
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 +2149 -1161
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +622 -185
- package/dist/index.js +2205 -1218
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +546 -148
- package/dist/styles/index.css.map +3 -3
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -30,14 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.tsx
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
AccountingOverview: () => AccountingOverview,
|
|
33
34
|
BalanceSheet: () => BalanceSheet,
|
|
34
35
|
BankTransactions: () => BankTransactions,
|
|
36
|
+
BankTransactionsWithLinkedAccounts: () => BankTransactionsWithLinkedAccounts,
|
|
37
|
+
ChartOfAccounts: () => ChartOfAccounts,
|
|
35
38
|
Hello: () => Hello,
|
|
36
39
|
LayerProvider: () => LayerProvider,
|
|
37
|
-
LedgerAccounts: () => LedgerAccounts,
|
|
38
40
|
LinkedAccounts: () => LinkedAccounts,
|
|
39
41
|
ProfitAndLoss: () => ProfitAndLoss,
|
|
40
|
-
ProfitAndLossView: () => ProfitAndLossView
|
|
42
|
+
ProfitAndLossView: () => ProfitAndLossView,
|
|
43
|
+
Reports: () => Reports,
|
|
44
|
+
useLayerContext: () => useLayerContext
|
|
41
45
|
});
|
|
42
46
|
module.exports = __toCommonJS(src_exports);
|
|
43
47
|
|
|
@@ -245,6 +249,7 @@ var request = (verb) => (url) => (baseUrl, accessToken, options) => fetch(`${bas
|
|
|
245
249
|
}).then((res) => handleResponse(res)).catch((error) => handleException(error));
|
|
246
250
|
var post = request("post");
|
|
247
251
|
var put = request("put");
|
|
252
|
+
var deleteRequest = request("delete");
|
|
248
253
|
var handleResponse = async (res) => {
|
|
249
254
|
if (!res.ok) {
|
|
250
255
|
const errors = await tryToReadErrorsFromResponse(res);
|
|
@@ -304,13 +309,8 @@ var matchBankTransaction = put(
|
|
|
304
309
|
// src/api/layer/categories.ts
|
|
305
310
|
var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
|
|
306
311
|
|
|
307
|
-
// src/api/layer/
|
|
308
|
-
var
|
|
309
|
-
({ businessId }) => `/v1/businesses/${businessId}/external-accounts`
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
// src/api/layer/ledger_accounts.ts
|
|
313
|
-
var getLedgerAccounts = get(
|
|
312
|
+
// src/api/layer/chart_of_accounts.ts
|
|
313
|
+
var getChartOfAccounts = get(
|
|
314
314
|
({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
|
|
315
315
|
);
|
|
316
316
|
var createAccount = post(
|
|
@@ -319,6 +319,25 @@ var createAccount = post(
|
|
|
319
319
|
var updateAccount = put(
|
|
320
320
|
({ businessId, accountId }) => `/v1/businesses/${businessId}/ledger/accounts/${accountId}`
|
|
321
321
|
);
|
|
322
|
+
var getLedgerAccountsLines = get(
|
|
323
|
+
({ businessId, accountId }) => `/v1/businesses/${businessId}/ledger/accounts/${accountId}/lines`
|
|
324
|
+
);
|
|
325
|
+
var getLedgerAccountsEntry = get(
|
|
326
|
+
({ businessId, entryId }) => `/v1/businesses/${businessId}/ledger/entries/${entryId}`
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
// src/api/layer/linked_accounts.ts
|
|
330
|
+
var getLinkedAccounts = get(
|
|
331
|
+
({ businessId }) => `/v1/businesses/${businessId}/external-accounts`
|
|
332
|
+
);
|
|
333
|
+
var getPlaidLinkToken = post(({ businessId }) => `/v1/businesses/${businessId}/plaid/link`);
|
|
334
|
+
var exchangePlaidPublicToken = post(({ businessId }) => `/v1/businesses/${businessId}/plaid/link/exchange`);
|
|
335
|
+
var unlinkPlaidItem = deleteRequest(
|
|
336
|
+
({ businessId, plaidItemId }) => `/v1/businesses/${businessId}/plaid/items/${plaidItemId}`
|
|
337
|
+
);
|
|
338
|
+
var unlinkPlaidAccount = post(
|
|
339
|
+
({ businessId, accountId }) => `/v1/businesses/${businessId}/plaid/accounts/${accountId}/archive`
|
|
340
|
+
);
|
|
322
341
|
|
|
323
342
|
// src/api/layer/profit_and_loss.ts
|
|
324
343
|
var getProfitAndLoss = get(
|
|
@@ -335,9 +354,15 @@ var Layer = {
|
|
|
335
354
|
getBalanceSheet,
|
|
336
355
|
getBankTransactions,
|
|
337
356
|
getCategories,
|
|
338
|
-
|
|
357
|
+
getChartOfAccounts,
|
|
358
|
+
getLedgerAccountsLines,
|
|
359
|
+
getLedgerAccountsEntry,
|
|
339
360
|
getProfitAndLoss,
|
|
340
|
-
getLinkedAccounts
|
|
361
|
+
getLinkedAccounts,
|
|
362
|
+
getPlaidLinkToken,
|
|
363
|
+
exchangePlaidPublicToken,
|
|
364
|
+
unlinkPlaidAccount,
|
|
365
|
+
unlinkPlaidItem
|
|
341
366
|
};
|
|
342
367
|
|
|
343
368
|
// src/hooks/useLayerContext/useLayerContext.tsx
|
|
@@ -358,7 +383,10 @@ var LayerContext = (0, import_react.createContext)({
|
|
|
358
383
|
theme: void 0,
|
|
359
384
|
colors: {},
|
|
360
385
|
setTheme: () => void 0,
|
|
361
|
-
getColor: (_shade) => void 0
|
|
386
|
+
getColor: (_shade) => void 0,
|
|
387
|
+
setLightColor: () => void 0,
|
|
388
|
+
setDarkColor: () => void 0,
|
|
389
|
+
setColors: () => void 0
|
|
362
390
|
});
|
|
363
391
|
|
|
364
392
|
// src/hooks/useLayerContext/useLayerContext.tsx
|
|
@@ -638,6 +666,11 @@ var import_react43 = __toESM(require("react"));
|
|
|
638
666
|
|
|
639
667
|
// src/config/general.ts
|
|
640
668
|
var DATE_FORMAT = "LLL d, yyyy";
|
|
669
|
+
var TIME_FORMAT = "p";
|
|
670
|
+
var BREAKPOINTS = {
|
|
671
|
+
TABLET: 760,
|
|
672
|
+
MOBILE: 500
|
|
673
|
+
};
|
|
641
674
|
|
|
642
675
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
643
676
|
var import_swr2 = __toESM(require("swr"));
|
|
@@ -758,7 +791,9 @@ var useElementSize = (callback) => {
|
|
|
758
791
|
const observer = new ResizeObserver((entries) => {
|
|
759
792
|
callback(element, entries[0], {
|
|
760
793
|
width: element.offsetWidth,
|
|
761
|
-
height: element.offsetHeight
|
|
794
|
+
height: element.offsetHeight,
|
|
795
|
+
clientWidth: element.clientWidth,
|
|
796
|
+
clientHeight: element.clientHeight
|
|
762
797
|
});
|
|
763
798
|
});
|
|
764
799
|
observer.observe(element);
|
|
@@ -1559,13 +1594,17 @@ var Badge = ({
|
|
|
1559
1594
|
onClick,
|
|
1560
1595
|
children,
|
|
1561
1596
|
tooltip,
|
|
1562
|
-
size = "medium" /* MEDIUM
|
|
1597
|
+
size = "medium" /* MEDIUM */,
|
|
1598
|
+
variant = "default" /* DEFAULT */,
|
|
1599
|
+
hoverable = false
|
|
1563
1600
|
}) => {
|
|
1564
1601
|
const baseProps = {
|
|
1565
1602
|
className: (0, import_classnames7.default)(
|
|
1566
1603
|
"Layer__badge",
|
|
1604
|
+
hoverable && !tooltip ? "Layer__badge--with-hover" : "",
|
|
1567
1605
|
onClick || tooltip ? "Layer__badge--clickable" : "",
|
|
1568
|
-
`Layer__badge--${size}
|
|
1606
|
+
`Layer__badge--${size}`,
|
|
1607
|
+
`Layer__badge--${variant}`
|
|
1569
1608
|
),
|
|
1570
1609
|
onClick,
|
|
1571
1610
|
children
|
|
@@ -2197,7 +2236,8 @@ var Select2 = ({
|
|
|
2197
2236
|
classNamePrefix = "Layer__select",
|
|
2198
2237
|
value,
|
|
2199
2238
|
onChange,
|
|
2200
|
-
disabled
|
|
2239
|
+
disabled,
|
|
2240
|
+
placeholder
|
|
2201
2241
|
}) => {
|
|
2202
2242
|
return /* @__PURE__ */ import_react26.default.createElement(
|
|
2203
2243
|
import_react_select2.default,
|
|
@@ -2205,6 +2245,7 @@ var Select2 = ({
|
|
|
2205
2245
|
name,
|
|
2206
2246
|
className: `Layer__select ${className ?? ""}`,
|
|
2207
2247
|
classNamePrefix,
|
|
2248
|
+
placeholder: placeholder ?? "Select...",
|
|
2208
2249
|
options,
|
|
2209
2250
|
value,
|
|
2210
2251
|
onChange: (newValue) => newValue && onChange(newValue),
|
|
@@ -2407,6 +2448,7 @@ var Toggle = ({
|
|
|
2407
2448
|
checked: selectedValue === option.value,
|
|
2408
2449
|
onChange: handleChange,
|
|
2409
2450
|
disabled: option.disabled ?? false,
|
|
2451
|
+
disabledMessage: option.disabledMessage,
|
|
2410
2452
|
index
|
|
2411
2453
|
}
|
|
2412
2454
|
)), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
|
|
@@ -2420,6 +2462,7 @@ var ToggleOption = ({
|
|
|
2420
2462
|
size,
|
|
2421
2463
|
leftIcon,
|
|
2422
2464
|
disabled,
|
|
2465
|
+
disabledMessage = "Disabled",
|
|
2423
2466
|
index
|
|
2424
2467
|
}) => {
|
|
2425
2468
|
if (disabled) {
|
|
@@ -2434,7 +2477,7 @@ var ToggleOption = ({
|
|
|
2434
2477
|
disabled: disabled ?? false,
|
|
2435
2478
|
"data-idx": index
|
|
2436
2479
|
}
|
|
2437
|
-
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)))), /* @__PURE__ */ import_react30.default.createElement(TooltipContent, { className: "Layer__tooltip" },
|
|
2480
|
+
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)))), /* @__PURE__ */ import_react30.default.createElement(TooltipContent, { className: "Layer__tooltip" }, disabledMessage));
|
|
2438
2481
|
}
|
|
2439
2482
|
return /* @__PURE__ */ import_react30.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2440
2483
|
"input",
|
|
@@ -2835,7 +2878,8 @@ var ExpandedBankTransactionRow = (0, import_react32.forwardRef)(
|
|
|
2835
2878
|
{
|
|
2836
2879
|
value: "match",
|
|
2837
2880
|
label: "Match",
|
|
2838
|
-
disabled: !hasMatch(bankTransaction)
|
|
2881
|
+
disabled: !hasMatch(bankTransaction),
|
|
2882
|
+
disabledMessage: "We could not find matching transactions"
|
|
2839
2883
|
}
|
|
2840
2884
|
],
|
|
2841
2885
|
selected: purpose,
|
|
@@ -3699,11 +3743,12 @@ var hslToHex = (hsl) => {
|
|
|
3699
3743
|
// src/components/Container/Container.tsx
|
|
3700
3744
|
var import_classnames20 = __toESM(require("classnames"));
|
|
3701
3745
|
var Container = (0, import_react37.forwardRef)(
|
|
3702
|
-
({ name, className, children, asWidget }, ref) => {
|
|
3746
|
+
({ name, className, children, asWidget, elevated = false }, ref) => {
|
|
3703
3747
|
const baseClassName = (0, import_classnames20.default)(
|
|
3704
3748
|
"Layer__component Layer__component-container",
|
|
3705
3749
|
`Layer__${name}`,
|
|
3706
|
-
|
|
3750
|
+
elevated && "Layer__component--elevated",
|
|
3751
|
+
asWidget && "Layer__component--as-widget",
|
|
3707
3752
|
className
|
|
3708
3753
|
);
|
|
3709
3754
|
const { theme } = useLayerContext();
|
|
@@ -4035,7 +4080,14 @@ var BankTransactions = ({
|
|
|
4035
4080
|
className: "Layer__bank-transactions__header",
|
|
4036
4081
|
style: { top: shiftStickyHeader }
|
|
4037
4082
|
},
|
|
4038
|
-
/* @__PURE__ */ import_react43.default.createElement(
|
|
4083
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
4084
|
+
Heading,
|
|
4085
|
+
{
|
|
4086
|
+
className: "Layer__bank-transactions__title",
|
|
4087
|
+
size: asWidget ? "secondary" /* secondary */ : "secondary" /* secondary */
|
|
4088
|
+
},
|
|
4089
|
+
"Transactions"
|
|
4090
|
+
),
|
|
4039
4091
|
!categorizedOnly && /* @__PURE__ */ import_react43.default.createElement(
|
|
4040
4092
|
Toggle,
|
|
4041
4093
|
{
|
|
@@ -4133,15 +4185,20 @@ var Hello = ({ user }) => {
|
|
|
4133
4185
|
};
|
|
4134
4186
|
|
|
4135
4187
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4136
|
-
var
|
|
4188
|
+
var import_react50 = __toESM(require("react"));
|
|
4137
4189
|
|
|
4138
4190
|
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
4139
|
-
var
|
|
4140
|
-
var
|
|
4191
|
+
var import_react45 = require("react");
|
|
4192
|
+
var import_react_plaid_link = require("react-plaid-link");
|
|
4193
|
+
|
|
4194
|
+
// src/hooks/useLinkedAccounts/mockData.ts
|
|
4195
|
+
var LINKED_ACCOUNTS_MOCK_DATA = [
|
|
4141
4196
|
{
|
|
4142
4197
|
id: "1",
|
|
4198
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4199
|
+
external_account_source: "PLAID",
|
|
4143
4200
|
external_account_name: "Citi Double Cash\xAE Card",
|
|
4144
|
-
external_account_number:
|
|
4201
|
+
//external_account_number: '1234',
|
|
4145
4202
|
latest_balance_timestamp: {
|
|
4146
4203
|
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4147
4204
|
external_account_source: "PLAID",
|
|
@@ -4150,13 +4207,19 @@ var MOCK_DATA = [
|
|
|
4150
4207
|
created_at: "2024-04-06T16:44:35.715458Z"
|
|
4151
4208
|
},
|
|
4152
4209
|
current_ledger_balance: 373717,
|
|
4153
|
-
institution:
|
|
4154
|
-
|
|
4210
|
+
institution: {
|
|
4211
|
+
name: "Chase",
|
|
4212
|
+
logo: ""
|
|
4213
|
+
}
|
|
4214
|
+
//connection_id: '0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq',
|
|
4215
|
+
//connection_status: 'OK',
|
|
4155
4216
|
},
|
|
4156
4217
|
{
|
|
4157
4218
|
id: "2",
|
|
4219
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4220
|
+
external_account_source: "PLAID",
|
|
4158
4221
|
external_account_name: "Citi Double Cash\xAE Card",
|
|
4159
|
-
external_account_number:
|
|
4222
|
+
//external_account_number: '1234',
|
|
4160
4223
|
latest_balance_timestamp: {
|
|
4161
4224
|
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4162
4225
|
external_account_source: "PLAID",
|
|
@@ -4165,13 +4228,19 @@ var MOCK_DATA = [
|
|
|
4165
4228
|
created_at: "2024-04-06T16:44:35.715458Z"
|
|
4166
4229
|
},
|
|
4167
4230
|
current_ledger_balance: 373717,
|
|
4168
|
-
institution:
|
|
4169
|
-
|
|
4231
|
+
institution: {
|
|
4232
|
+
name: "Chase",
|
|
4233
|
+
logo: ""
|
|
4234
|
+
}
|
|
4235
|
+
//connection_id: '0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq',
|
|
4236
|
+
//connection_status: 'OK',
|
|
4170
4237
|
},
|
|
4171
4238
|
{
|
|
4172
4239
|
id: "3",
|
|
4240
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4241
|
+
external_account_source: "PLAID",
|
|
4173
4242
|
external_account_name: "Citi Double Cash\xAE Card",
|
|
4174
|
-
external_account_number:
|
|
4243
|
+
//external_account_number: '1234',
|
|
4175
4244
|
latest_balance_timestamp: {
|
|
4176
4245
|
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4177
4246
|
external_account_source: "PLAID",
|
|
@@ -4180,13 +4249,19 @@ var MOCK_DATA = [
|
|
|
4180
4249
|
created_at: "2024-04-06T16:44:35.715458Z"
|
|
4181
4250
|
},
|
|
4182
4251
|
current_ledger_balance: 373717,
|
|
4183
|
-
institution:
|
|
4184
|
-
|
|
4252
|
+
institution: {
|
|
4253
|
+
name: "Chase",
|
|
4254
|
+
logo: ""
|
|
4255
|
+
}
|
|
4256
|
+
//connection_id: '0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq',
|
|
4257
|
+
//connection_status: 'OK',
|
|
4185
4258
|
},
|
|
4186
4259
|
{
|
|
4187
4260
|
id: "4",
|
|
4261
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4262
|
+
external_account_source: "PLAID",
|
|
4188
4263
|
external_account_name: "Citi Double Cash\xAE Card",
|
|
4189
|
-
external_account_number:
|
|
4264
|
+
//external_account_number: '1234',
|
|
4190
4265
|
latest_balance_timestamp: {
|
|
4191
4266
|
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
4192
4267
|
external_account_source: "PLAID",
|
|
@@ -4195,14 +4270,25 @@ var MOCK_DATA = [
|
|
|
4195
4270
|
created_at: "2024-04-06T16:44:35.715458Z"
|
|
4196
4271
|
},
|
|
4197
4272
|
current_ledger_balance: 373717,
|
|
4198
|
-
institution:
|
|
4199
|
-
|
|
4273
|
+
institution: {
|
|
4274
|
+
name: "Chase",
|
|
4275
|
+
logo: ""
|
|
4276
|
+
}
|
|
4277
|
+
//connection_id: '0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq',
|
|
4278
|
+
//connection_status: 'OK',
|
|
4200
4279
|
}
|
|
4201
4280
|
];
|
|
4281
|
+
|
|
4282
|
+
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
4283
|
+
var import_swr4 = __toESM(require("swr"));
|
|
4284
|
+
var DEBUG = true;
|
|
4285
|
+
var USE_MOCK_RESPONSE_DATA = false;
|
|
4286
|
+
var USE_PLAID_SANDBOX = true;
|
|
4202
4287
|
var useLinkedAccounts = () => {
|
|
4203
4288
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4289
|
+
const [linkToken, setLinkToken] = (0, import_react45.useState)(null);
|
|
4204
4290
|
const {
|
|
4205
|
-
|
|
4291
|
+
data: responseData,
|
|
4206
4292
|
isLoading,
|
|
4207
4293
|
isValidating,
|
|
4208
4294
|
error: responseError,
|
|
@@ -4213,27 +4299,80 @@ var useLinkedAccounts = () => {
|
|
|
4213
4299
|
params: { businessId }
|
|
4214
4300
|
})
|
|
4215
4301
|
);
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4302
|
+
(0, import_react45.useEffect)(() => {
|
|
4303
|
+
const getLinkToken = async () => {
|
|
4304
|
+
if (auth?.access_token) {
|
|
4305
|
+
const linkToken2 = (await Layer.getPlaidLinkToken(apiUrl, auth.access_token, {
|
|
4306
|
+
params: { businessId }
|
|
4307
|
+
})).data.link_token;
|
|
4308
|
+
setLinkToken(linkToken2);
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
getLinkToken();
|
|
4312
|
+
}, [setLinkToken, auth?.access_token]);
|
|
4313
|
+
const exchangePublicToken = async (publicToken, metadata) => {
|
|
4314
|
+
await Layer.exchangePlaidPublicToken(apiUrl, auth?.access_token, {
|
|
4315
|
+
params: { businessId },
|
|
4316
|
+
body: { public_token: publicToken, institution_id: metadata.institution }
|
|
4317
|
+
});
|
|
4318
|
+
refetchAccounts();
|
|
4319
|
+
};
|
|
4320
|
+
const { open: plaidLinkStart, ready: plaidLinkReady } = (0, import_react_plaid_link.usePlaidLink)({
|
|
4321
|
+
token: linkToken,
|
|
4322
|
+
onSuccess: exchangePublicToken,
|
|
4323
|
+
env: USE_PLAID_SANDBOX ? "sandbox" : void 0
|
|
4324
|
+
});
|
|
4325
|
+
const mockResponseData = {
|
|
4326
|
+
data: LINKED_ACCOUNTS_MOCK_DATA,
|
|
4327
|
+
meta: {},
|
|
4328
|
+
error: void 0
|
|
4329
|
+
};
|
|
4330
|
+
const addConnection = (source) => {
|
|
4331
|
+
if (source === "PLAID") {
|
|
4332
|
+
linkPlaidItem();
|
|
4333
|
+
} else {
|
|
4334
|
+
console.error(`Connection with source ${source} not yet supported`);
|
|
4335
|
+
}
|
|
4336
|
+
};
|
|
4337
|
+
const removeConnection = (source, connectionId) => {
|
|
4338
|
+
if (source === "PLAID") {
|
|
4339
|
+
unlinkPlaidItem2(connectionId);
|
|
4340
|
+
} else {
|
|
4341
|
+
console.error(`Connection with source ${source} not yet supported`);
|
|
4342
|
+
}
|
|
4343
|
+
};
|
|
4344
|
+
const linkPlaidItem = async () => {
|
|
4345
|
+
DEBUG && console.log("add account...");
|
|
4346
|
+
console.log("plaidLinkReady", plaidLinkReady);
|
|
4347
|
+
plaidLinkReady && plaidLinkStart();
|
|
4348
|
+
};
|
|
4349
|
+
const unlinkPlaidItem2 = (plaidItemId) => {
|
|
4350
|
+
DEBUG && console.log("unlinking plaid item");
|
|
4351
|
+
Layer.unlinkPlaidItem(apiUrl, auth?.access_token, {
|
|
4352
|
+
params: { businessId, plaidItemId }
|
|
4353
|
+
});
|
|
4219
4354
|
};
|
|
4220
|
-
const unlinkAccount = () => {
|
|
4221
|
-
console.log("
|
|
4355
|
+
const unlinkAccount = (plaidAccountId) => {
|
|
4356
|
+
DEBUG && console.log("unlinking account");
|
|
4357
|
+
Layer.unlinkPlaidAccount(apiUrl, auth?.access_token, {
|
|
4358
|
+
params: { businessId, accountId: plaidAccountId }
|
|
4359
|
+
});
|
|
4222
4360
|
};
|
|
4223
4361
|
const renewLinkAccount = () => {
|
|
4224
|
-
console.log("relink account...");
|
|
4362
|
+
DEBUG && console.log("relink account...");
|
|
4225
4363
|
};
|
|
4226
|
-
const
|
|
4227
|
-
console.log("
|
|
4364
|
+
const refetchAccounts = () => {
|
|
4365
|
+
DEBUG && console.log("refetching plaid accounts...");
|
|
4366
|
+
mutate();
|
|
4228
4367
|
};
|
|
4229
4368
|
return {
|
|
4230
|
-
|
|
4231
|
-
data: responseData.data,
|
|
4369
|
+
data: USE_MOCK_RESPONSE_DATA ? mockResponseData.data : responseData?.data.external_accounts,
|
|
4232
4370
|
isLoading,
|
|
4233
4371
|
isValidating,
|
|
4234
4372
|
error: responseError,
|
|
4235
|
-
|
|
4236
|
-
|
|
4373
|
+
addConnection,
|
|
4374
|
+
removeConnection,
|
|
4375
|
+
refetchAccounts,
|
|
4237
4376
|
unlinkAccount,
|
|
4238
4377
|
renewLinkAccount
|
|
4239
4378
|
};
|
|
@@ -4282,12 +4421,12 @@ var PlusIcon = ({ size = 14, ...props }) => /* @__PURE__ */ React58.createElemen
|
|
|
4282
4421
|
var PlusIcon_default = PlusIcon;
|
|
4283
4422
|
|
|
4284
4423
|
// src/components/LinkedAccountOptions/LinkedAccountOptions.tsx
|
|
4285
|
-
var
|
|
4424
|
+
var import_react48 = __toESM(require("react"));
|
|
4286
4425
|
|
|
4287
4426
|
// src/icons/MoreVertical.tsx
|
|
4288
|
-
var
|
|
4427
|
+
var import_react46 = __toESM(require("react"));
|
|
4289
4428
|
var MoreVertical = ({ size = 18, ...props }) => {
|
|
4290
|
-
return /* @__PURE__ */
|
|
4429
|
+
return /* @__PURE__ */ import_react46.default.createElement(
|
|
4291
4430
|
"svg",
|
|
4292
4431
|
{
|
|
4293
4432
|
viewBox: "0 0 16 14",
|
|
@@ -4297,7 +4436,7 @@ var MoreVertical = ({ size = 18, ...props }) => {
|
|
|
4297
4436
|
width: size,
|
|
4298
4437
|
height: size
|
|
4299
4438
|
},
|
|
4300
|
-
/* @__PURE__ */
|
|
4439
|
+
/* @__PURE__ */ import_react46.default.createElement(
|
|
4301
4440
|
"path",
|
|
4302
4441
|
{
|
|
4303
4442
|
d: "M8.66659 8C8.66659 7.63181 8.36811 7.33333 7.99992 7.33333C7.63173 7.33333 7.33325 7.63181 7.33325 8C7.33325 8.36819 7.63173 8.66667 7.99992 8.66667C8.36811 8.66667 8.66659 8.36819 8.66659 8Z",
|
|
@@ -4307,7 +4446,7 @@ var MoreVertical = ({ size = 18, ...props }) => {
|
|
|
4307
4446
|
strokeLinejoin: "round"
|
|
4308
4447
|
}
|
|
4309
4448
|
),
|
|
4310
|
-
/* @__PURE__ */
|
|
4449
|
+
/* @__PURE__ */ import_react46.default.createElement(
|
|
4311
4450
|
"path",
|
|
4312
4451
|
{
|
|
4313
4452
|
d: "M8.66659 3.33333C8.66659 2.96514 8.36811 2.66667 7.99992 2.66667C7.63173 2.66667 7.33325 2.96514 7.33325 3.33333C7.33325 3.70152 7.63173 4 7.99992 4C8.36811 4 8.66659 3.70152 8.66659 3.33333Z",
|
|
@@ -4317,7 +4456,7 @@ var MoreVertical = ({ size = 18, ...props }) => {
|
|
|
4317
4456
|
strokeLinejoin: "round"
|
|
4318
4457
|
}
|
|
4319
4458
|
),
|
|
4320
|
-
/* @__PURE__ */
|
|
4459
|
+
/* @__PURE__ */ import_react46.default.createElement(
|
|
4321
4460
|
"path",
|
|
4322
4461
|
{
|
|
4323
4462
|
d: "M8.66659 12.6667C8.66659 12.2985 8.36811 12 7.99992 12C7.63173 12 7.33325 12.2985 7.33325 12.6667C7.33325 13.0349 7.63173 13.3333 7.99992 13.3333C8.36811 13.3333 8.66659 13.0349 8.66659 12.6667Z",
|
|
@@ -4332,16 +4471,21 @@ var MoreVertical = ({ size = 18, ...props }) => {
|
|
|
4332
4471
|
var MoreVertical_default = MoreVertical;
|
|
4333
4472
|
|
|
4334
4473
|
// src/components/HoverMenu/HoverMenu.tsx
|
|
4335
|
-
var
|
|
4474
|
+
var import_react47 = __toESM(require("react"));
|
|
4336
4475
|
var import_classnames23 = __toESM(require("classnames"));
|
|
4337
|
-
var HoverMenu = ({
|
|
4338
|
-
|
|
4339
|
-
|
|
4476
|
+
var HoverMenu = ({
|
|
4477
|
+
children,
|
|
4478
|
+
config,
|
|
4479
|
+
plaidItemId,
|
|
4480
|
+
accountId
|
|
4481
|
+
}) => {
|
|
4482
|
+
const [openMenu, setOpenMenu] = (0, import_react47.useState)(false);
|
|
4483
|
+
const hoverMenuRef = (0, import_react47.useRef)(null);
|
|
4340
4484
|
const hoverMenuClassName = (0, import_classnames23.default)(
|
|
4341
4485
|
"Layer__hover-menu",
|
|
4342
|
-
openMenu && "--open"
|
|
4486
|
+
openMenu && "Layer__hover-menu--open"
|
|
4343
4487
|
);
|
|
4344
|
-
(0,
|
|
4488
|
+
(0, import_react47.useEffect)(() => {
|
|
4345
4489
|
function handleClickOutside(event) {
|
|
4346
4490
|
if (hoverMenuRef.current && !hoverMenuRef.current.contains(event.target)) {
|
|
4347
4491
|
setOpenMenu(false);
|
|
@@ -4352,14 +4496,14 @@ var HoverMenu = ({ children, config }) => {
|
|
|
4352
4496
|
document.removeEventListener("click", handleClickOutside);
|
|
4353
4497
|
};
|
|
4354
4498
|
}, []);
|
|
4355
|
-
return /* @__PURE__ */
|
|
4499
|
+
return /* @__PURE__ */ import_react47.default.createElement(
|
|
4356
4500
|
"div",
|
|
4357
4501
|
{
|
|
4358
4502
|
className: hoverMenuClassName,
|
|
4359
4503
|
ref: hoverMenuRef,
|
|
4360
4504
|
onMouseLeave: () => setOpenMenu(false)
|
|
4361
4505
|
},
|
|
4362
|
-
/* @__PURE__ */
|
|
4506
|
+
/* @__PURE__ */ import_react47.default.createElement(
|
|
4363
4507
|
"div",
|
|
4364
4508
|
{
|
|
4365
4509
|
className: "Layer__hover-menu__children",
|
|
@@ -4369,17 +4513,17 @@ var HoverMenu = ({ children, config }) => {
|
|
|
4369
4513
|
},
|
|
4370
4514
|
children
|
|
4371
4515
|
),
|
|
4372
|
-
/* @__PURE__ */
|
|
4516
|
+
/* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__hover-menu__list-wrapper" }, /* @__PURE__ */ import_react47.default.createElement("ul", { className: "Layer__hover-menu__list" }, config && config.length > 0 && config.map((item) => /* @__PURE__ */ import_react47.default.createElement(
|
|
4373
4517
|
"li",
|
|
4374
4518
|
{
|
|
4375
4519
|
key: `hover-menu-${item.name}`,
|
|
4376
4520
|
className: "Layer__hover-menu__list-item"
|
|
4377
4521
|
},
|
|
4378
|
-
/* @__PURE__ */
|
|
4522
|
+
/* @__PURE__ */ import_react47.default.createElement(
|
|
4379
4523
|
"button",
|
|
4380
4524
|
{
|
|
4381
4525
|
className: "Layer__hover-menu__list-item-button",
|
|
4382
|
-
onClick: () => item.action()
|
|
4526
|
+
onClick: () => item.action(plaidItemId, accountId)
|
|
4383
4527
|
},
|
|
4384
4528
|
item.name
|
|
4385
4529
|
)
|
|
@@ -4390,13 +4534,23 @@ var HoverMenu = ({ children, config }) => {
|
|
|
4390
4534
|
// src/components/LinkedAccountOptions/LinkedAccountOptions.tsx
|
|
4391
4535
|
var LinkedAccountOptions = ({
|
|
4392
4536
|
children,
|
|
4393
|
-
config
|
|
4537
|
+
config,
|
|
4538
|
+
accountId,
|
|
4539
|
+
plaidItemId
|
|
4394
4540
|
}) => {
|
|
4395
|
-
return /* @__PURE__ */
|
|
4541
|
+
return /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__linked-accounts__options" }, /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__linked-accounts__options-overlay" }, /* @__PURE__ */ import_react48.default.createElement("div", { className: "Layer__linked-accounts__options-overlay-button" }, /* @__PURE__ */ import_react48.default.createElement(
|
|
4542
|
+
HoverMenu,
|
|
4543
|
+
{
|
|
4544
|
+
config,
|
|
4545
|
+
accountId,
|
|
4546
|
+
plaidItemId
|
|
4547
|
+
},
|
|
4548
|
+
/* @__PURE__ */ import_react48.default.createElement(MoreVertical_default, { size: 16 })
|
|
4549
|
+
))), children);
|
|
4396
4550
|
};
|
|
4397
4551
|
|
|
4398
4552
|
// src/components/LinkedAccountThumb/LinkedAccountThumb.tsx
|
|
4399
|
-
var
|
|
4553
|
+
var import_react49 = __toESM(require("react"));
|
|
4400
4554
|
|
|
4401
4555
|
// src/icons/InstitutionIcon.tsx
|
|
4402
4556
|
var React62 = __toESM(require("react"));
|
|
@@ -4691,7 +4845,7 @@ var InstitutionIcon_default = InstitutionIcon;
|
|
|
4691
4845
|
|
|
4692
4846
|
// src/components/LinkedAccountThumb/LinkedAccountThumb.tsx
|
|
4693
4847
|
var import_classnames24 = __toESM(require("classnames"));
|
|
4694
|
-
var AccountNumber = ({ accountNumber }) => /* @__PURE__ */
|
|
4848
|
+
var AccountNumber = ({ accountNumber }) => /* @__PURE__ */ import_react49.default.createElement("div", { className: "account-number" }, /* @__PURE__ */ import_react49.default.createElement(Text, { size: "sm" }, "\u2022\u2022\u2022", accountNumber));
|
|
4695
4849
|
var LinkedAccountThumb = ({
|
|
4696
4850
|
account,
|
|
4697
4851
|
asWidget
|
|
@@ -4700,15 +4854,20 @@ var LinkedAccountThumb = ({
|
|
|
4700
4854
|
"Layer__linked-account-thumb",
|
|
4701
4855
|
asWidget && "--as-widget"
|
|
4702
4856
|
);
|
|
4703
|
-
return /* @__PURE__ */
|
|
4857
|
+
return /* @__PURE__ */ import_react49.default.createElement("div", { className: linkedAccountThumbClassName }, /* @__PURE__ */ import_react49.default.createElement("div", { className: "topbar" }, /* @__PURE__ */ import_react49.default.createElement("div", { className: "topbar-details" }, /* @__PURE__ */ import_react49.default.createElement(Text, { as: "span", className: "account-name" }, account.external_account_name), !asWidget && /* @__PURE__ */ import_react49.default.createElement(
|
|
4858
|
+
AccountNumber,
|
|
4859
|
+
{
|
|
4860
|
+
accountNumber: "TODO"
|
|
4861
|
+
}
|
|
4862
|
+
), /* @__PURE__ */ import_react49.default.createElement(
|
|
4704
4863
|
Text,
|
|
4705
4864
|
{
|
|
4706
4865
|
as: "span",
|
|
4707
4866
|
className: "account-institution",
|
|
4708
4867
|
size: "sm"
|
|
4709
4868
|
},
|
|
4710
|
-
account.institution
|
|
4711
|
-
)), /* @__PURE__ */
|
|
4869
|
+
account.institution?.name
|
|
4870
|
+
)), /* @__PURE__ */ import_react49.default.createElement("div", { className: "topbar-logo" }, !account.institution?.logo && /* @__PURE__ */ import_react49.default.createElement(InstitutionIcon_default, null))), !asWidget && /* @__PURE__ */ import_react49.default.createElement("div", { className: "middlebar" }, /* @__PURE__ */ import_react49.default.createElement(
|
|
4712
4871
|
Text,
|
|
4713
4872
|
{
|
|
4714
4873
|
as: "span",
|
|
@@ -4716,7 +4875,12 @@ var LinkedAccountThumb = ({
|
|
|
4716
4875
|
size: "sm"
|
|
4717
4876
|
},
|
|
4718
4877
|
"Bank balance"
|
|
4719
|
-
), /* @__PURE__ */
|
|
4878
|
+
), /* @__PURE__ */ import_react49.default.createElement(Text, { as: "span", className: "account-balance" }, "$", centsToDollars(account.latest_balance_timestamp.balance))), /* @__PURE__ */ import_react49.default.createElement("div", { className: "bottombar" }, asWidget ? /* @__PURE__ */ import_react49.default.createElement(
|
|
4879
|
+
AccountNumber,
|
|
4880
|
+
{
|
|
4881
|
+
accountNumber: "TODO"
|
|
4882
|
+
}
|
|
4883
|
+
) : /* @__PURE__ */ import_react49.default.createElement(
|
|
4720
4884
|
Text,
|
|
4721
4885
|
{
|
|
4722
4886
|
as: "span",
|
|
@@ -4724,20 +4888,20 @@ var LinkedAccountThumb = ({
|
|
|
4724
4888
|
size: "sm"
|
|
4725
4889
|
},
|
|
4726
4890
|
"General ledger balance"
|
|
4727
|
-
), /* @__PURE__ */
|
|
4891
|
+
), /* @__PURE__ */ import_react49.default.createElement(Text, { as: "span", className: "account-balance" }, "$", centsToDollars(account.current_ledger_balance))));
|
|
4728
4892
|
};
|
|
4729
4893
|
|
|
4730
4894
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4731
4895
|
var import_classnames25 = __toESM(require("classnames"));
|
|
4732
4896
|
var COMPONENT_NAME2 = "linked-accounts";
|
|
4733
|
-
var LinkedAccounts = ({ asWidget }) => {
|
|
4897
|
+
var LinkedAccounts = ({ asWidget, elevated }) => {
|
|
4734
4898
|
const {
|
|
4735
4899
|
data,
|
|
4736
4900
|
isLoading,
|
|
4737
4901
|
error,
|
|
4738
4902
|
isValidating,
|
|
4739
|
-
|
|
4740
|
-
|
|
4903
|
+
refetchAccounts,
|
|
4904
|
+
addConnection,
|
|
4741
4905
|
unlinkAccount,
|
|
4742
4906
|
renewLinkAccount
|
|
4743
4907
|
} = useLinkedAccounts();
|
|
@@ -4749,47 +4913,49 @@ var LinkedAccounts = ({ asWidget }) => {
|
|
|
4749
4913
|
"Layer__linked-accounts__new-account",
|
|
4750
4914
|
asWidget && "--as-widget"
|
|
4751
4915
|
);
|
|
4752
|
-
return /* @__PURE__ */
|
|
4916
|
+
return /* @__PURE__ */ import_react50.default.createElement(Container, { name: COMPONENT_NAME2, elevated }, /* @__PURE__ */ import_react50.default.createElement(Header, { className: "Layer__linked-accounts__header" }, /* @__PURE__ */ import_react50.default.createElement(
|
|
4753
4917
|
Heading,
|
|
4754
4918
|
{
|
|
4755
4919
|
className: "Layer__linked-accounts__title",
|
|
4756
4920
|
size: "secondary" /* secondary */
|
|
4757
4921
|
},
|
|
4758
4922
|
"Linked Accounts"
|
|
4759
|
-
)), isLoading && /* @__PURE__ */
|
|
4923
|
+
)), isLoading && /* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__linked-accounts__loader-container" }, /* @__PURE__ */ import_react50.default.createElement(Loader2, null)), error && !isLoading ? /* @__PURE__ */ import_react50.default.createElement(
|
|
4760
4924
|
DataState,
|
|
4761
4925
|
{
|
|
4762
4926
|
status: "failed" /* failed */,
|
|
4763
4927
|
title: "Something went wrong",
|
|
4764
4928
|
description: "We couldn\u2019t load your data.",
|
|
4765
|
-
onRefresh: () =>
|
|
4929
|
+
onRefresh: () => refetchAccounts(),
|
|
4766
4930
|
isLoading: isValidating
|
|
4767
4931
|
}
|
|
4768
|
-
) : null, !error && !isLoading ? /* @__PURE__ */
|
|
4932
|
+
) : null, !error && !isLoading ? /* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__linked-accounts__list" }, data?.map((account, index) => /* @__PURE__ */ import_react50.default.createElement(
|
|
4769
4933
|
LinkedAccountOptions,
|
|
4770
4934
|
{
|
|
4771
4935
|
key: `linked-acc-${index}`,
|
|
4772
|
-
config: linkedAccountOptionsConfig
|
|
4936
|
+
config: linkedAccountOptionsConfig,
|
|
4937
|
+
accountId: account.external_account_external_id,
|
|
4938
|
+
plaidItemId: "TODO"
|
|
4773
4939
|
},
|
|
4774
|
-
/* @__PURE__ */
|
|
4775
|
-
)), /* @__PURE__ */
|
|
4940
|
+
/* @__PURE__ */ import_react50.default.createElement(LinkedAccountThumb, { account, asWidget })
|
|
4941
|
+
)), /* @__PURE__ */ import_react50.default.createElement(
|
|
4776
4942
|
"div",
|
|
4777
4943
|
{
|
|
4778
4944
|
role: "button",
|
|
4779
4945
|
tabIndex: 0,
|
|
4780
4946
|
"aria-label": "new-account",
|
|
4781
|
-
onClick: () =>
|
|
4947
|
+
onClick: () => addConnection("PLAID"),
|
|
4782
4948
|
className: linkedAccountsNewAccountClassName
|
|
4783
4949
|
},
|
|
4784
|
-
/* @__PURE__ */
|
|
4950
|
+
/* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__linked-accounts__new-account-label" }, /* @__PURE__ */ import_react50.default.createElement(PlusIcon_default, { size: 15 }), /* @__PURE__ */ import_react50.default.createElement(Text, { as: "span", size: "sm" }, "Add Account"))
|
|
4785
4951
|
)) : null);
|
|
4786
4952
|
};
|
|
4787
4953
|
|
|
4788
4954
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4789
|
-
var
|
|
4955
|
+
var import_react64 = __toESM(require("react"));
|
|
4790
4956
|
|
|
4791
4957
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4792
|
-
var
|
|
4958
|
+
var import_react51 = require("react");
|
|
4793
4959
|
|
|
4794
4960
|
// src/utils/profitAndLossUtils.ts
|
|
4795
4961
|
var doesLineItemQualifies = (item) => {
|
|
@@ -4857,17 +5023,17 @@ var useProfitAndLoss = ({
|
|
|
4857
5023
|
endDate: (0, import_date_fns10.endOfMonth)(/* @__PURE__ */ new Date())
|
|
4858
5024
|
}) => {
|
|
4859
5025
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4860
|
-
const [startDate, setStartDate] = (0,
|
|
5026
|
+
const [startDate, setStartDate] = (0, import_react51.useState)(
|
|
4861
5027
|
initialStartDate || (0, import_date_fns10.startOfMonth)(Date.now())
|
|
4862
5028
|
);
|
|
4863
|
-
const [endDate, setEndDate] = (0,
|
|
5029
|
+
const [endDate, setEndDate] = (0, import_react51.useState)(
|
|
4864
5030
|
initialEndDate || (0, import_date_fns10.endOfMonth)(Date.now())
|
|
4865
5031
|
);
|
|
4866
|
-
const [filters, setFilters] = (0,
|
|
5032
|
+
const [filters, setFilters] = (0, import_react51.useState)({
|
|
4867
5033
|
expenses: void 0,
|
|
4868
5034
|
revenue: void 0
|
|
4869
5035
|
});
|
|
4870
|
-
const [sidebarScope, setSidebarScope] = (0,
|
|
5036
|
+
const [sidebarScope, setSidebarScope] = (0, import_react51.useState)(void 0);
|
|
4871
5037
|
const {
|
|
4872
5038
|
data: rawData,
|
|
4873
5039
|
isLoading,
|
|
@@ -4890,13 +5056,50 @@ var useProfitAndLoss = ({
|
|
|
4890
5056
|
})
|
|
4891
5057
|
);
|
|
4892
5058
|
const { data, error } = rawData || {};
|
|
4893
|
-
const {
|
|
5059
|
+
const { filteredDataRevenue, filteredTotalRevenue } = (0, import_react51.useMemo)(() => {
|
|
5060
|
+
if (!data) {
|
|
5061
|
+
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
5062
|
+
}
|
|
5063
|
+
const items = collectRevenueItems(data);
|
|
5064
|
+
const filtered = items.map((x) => {
|
|
5065
|
+
if (filters["revenue"]?.types && filters["revenue"].types.length > 0 && !filters["revenue"]?.types?.includes(x.type)) {
|
|
5066
|
+
return {
|
|
5067
|
+
...x,
|
|
5068
|
+
hidden: true
|
|
5069
|
+
};
|
|
5070
|
+
}
|
|
5071
|
+
return x;
|
|
5072
|
+
});
|
|
5073
|
+
const sorted = filtered.sort((a, b) => {
|
|
5074
|
+
switch (filters["revenue"]?.sortBy) {
|
|
5075
|
+
case "category":
|
|
5076
|
+
if (filters["revenue"]?.sortDirection === "asc") {
|
|
5077
|
+
return a.display_name.localeCompare(b.display_name);
|
|
5078
|
+
}
|
|
5079
|
+
return b.display_name.localeCompare(a.display_name);
|
|
5080
|
+
case "type":
|
|
5081
|
+
if (filters["revenue"]?.sortDirection === "asc") {
|
|
5082
|
+
return a.type.localeCompare(b.type);
|
|
5083
|
+
}
|
|
5084
|
+
return b.type.localeCompare(a.type);
|
|
5085
|
+
default:
|
|
5086
|
+
if (filters["revenue"]?.sortDirection === "asc") {
|
|
5087
|
+
return a.value - b.value;
|
|
5088
|
+
}
|
|
5089
|
+
return b.value - a.value;
|
|
5090
|
+
}
|
|
5091
|
+
});
|
|
5092
|
+
const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
|
|
5093
|
+
const withShare = applyShare(sorted, total);
|
|
5094
|
+
return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
|
|
5095
|
+
}, [data, startDate, filters, sidebarScope]);
|
|
5096
|
+
const { filteredDataExpenses, filteredTotalExpenses } = (0, import_react51.useMemo)(() => {
|
|
4894
5097
|
if (!data) {
|
|
4895
|
-
return {
|
|
5098
|
+
return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
|
|
4896
5099
|
}
|
|
4897
|
-
const items =
|
|
5100
|
+
const items = collectExpensesItems(data);
|
|
4898
5101
|
const filtered = items.map((x) => {
|
|
4899
|
-
if (
|
|
5102
|
+
if (filters["expenses"]?.types && filters["expenses"].types.length > 0 && !filters["expenses"]?.types?.includes(x.type)) {
|
|
4900
5103
|
return {
|
|
4901
5104
|
...x,
|
|
4902
5105
|
hidden: true
|
|
@@ -4905,19 +5108,19 @@ var useProfitAndLoss = ({
|
|
|
4905
5108
|
return x;
|
|
4906
5109
|
});
|
|
4907
5110
|
const sorted = filtered.sort((a, b) => {
|
|
4908
|
-
switch (filters[
|
|
5111
|
+
switch (filters["expenses"]?.sortBy) {
|
|
4909
5112
|
case "category":
|
|
4910
|
-
if (filters[
|
|
5113
|
+
if (filters["expenses"]?.sortDirection === "asc") {
|
|
4911
5114
|
return a.display_name.localeCompare(b.display_name);
|
|
4912
5115
|
}
|
|
4913
5116
|
return b.display_name.localeCompare(a.display_name);
|
|
4914
5117
|
case "type":
|
|
4915
|
-
if (filters[
|
|
5118
|
+
if (filters["expenses"]?.sortDirection === "asc") {
|
|
4916
5119
|
return a.type.localeCompare(b.type);
|
|
4917
5120
|
}
|
|
4918
5121
|
return b.type.localeCompare(a.type);
|
|
4919
5122
|
default:
|
|
4920
|
-
if (filters[
|
|
5123
|
+
if (filters["expenses"]?.sortDirection === "asc") {
|
|
4921
5124
|
return a.value - b.value;
|
|
4922
5125
|
}
|
|
4923
5126
|
return b.value - a.value;
|
|
@@ -4925,7 +5128,7 @@ var useProfitAndLoss = ({
|
|
|
4925
5128
|
});
|
|
4926
5129
|
const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
|
|
4927
5130
|
const withShare = applyShare(sorted, total);
|
|
4928
|
-
return {
|
|
5131
|
+
return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
|
|
4929
5132
|
}, [data, startDate, filters, sidebarScope]);
|
|
4930
5133
|
const changeDateRange = ({
|
|
4931
5134
|
startDate: newStartDate,
|
|
@@ -4958,8 +5161,10 @@ var useProfitAndLoss = ({
|
|
|
4958
5161
|
};
|
|
4959
5162
|
return {
|
|
4960
5163
|
data,
|
|
4961
|
-
|
|
4962
|
-
|
|
5164
|
+
filteredDataRevenue,
|
|
5165
|
+
filteredTotalRevenue,
|
|
5166
|
+
filteredDataExpenses,
|
|
5167
|
+
filteredTotalExpenses,
|
|
4963
5168
|
isLoading,
|
|
4964
5169
|
isValidating,
|
|
4965
5170
|
error: error || rawError,
|
|
@@ -4975,7 +5180,7 @@ var useProfitAndLoss = ({
|
|
|
4975
5180
|
};
|
|
4976
5181
|
|
|
4977
5182
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
4978
|
-
var
|
|
5183
|
+
var import_react53 = __toESM(require("react"));
|
|
4979
5184
|
|
|
4980
5185
|
// src/utils/format.ts
|
|
4981
5186
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
@@ -5011,9 +5216,12 @@ var formatPercent = (value, options) => {
|
|
|
5011
5216
|
...options
|
|
5012
5217
|
});
|
|
5013
5218
|
};
|
|
5219
|
+
var humanizeEnum = (text) => {
|
|
5220
|
+
return capitalizeFirstLetter(text.replace(/_/gi, " ").toLowerCase());
|
|
5221
|
+
};
|
|
5014
5222
|
|
|
5015
5223
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
5016
|
-
var
|
|
5224
|
+
var import_react52 = __toESM(require("react"));
|
|
5017
5225
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
5018
5226
|
var Indicator = ({
|
|
5019
5227
|
viewBox = {},
|
|
@@ -5030,11 +5238,11 @@ var Indicator = ({
|
|
|
5030
5238
|
const multiplier = width > 12 ? 1.2 : 1;
|
|
5031
5239
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
5032
5240
|
const borderRadius = width > 16 ? 8 : width / 2;
|
|
5033
|
-
(0,
|
|
5241
|
+
(0, import_react52.useEffect)(() => {
|
|
5034
5242
|
setAnimateFrom(animateTo);
|
|
5035
5243
|
}, [animateTo]);
|
|
5036
5244
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
5037
|
-
return /* @__PURE__ */
|
|
5245
|
+
return /* @__PURE__ */ import_react52.default.createElement(
|
|
5038
5246
|
"rect",
|
|
5039
5247
|
{
|
|
5040
5248
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
@@ -5058,7 +5266,7 @@ var barGap = 4;
|
|
|
5058
5266
|
var barSize = 20;
|
|
5059
5267
|
var ProfitAndLossChart = () => {
|
|
5060
5268
|
const { getColor } = useLayerContext();
|
|
5061
|
-
const { changeDateRange, dateRange } = (0,
|
|
5269
|
+
const { changeDateRange, dateRange } = (0, import_react53.useContext)(ProfitAndLoss.Context);
|
|
5062
5270
|
const thisMonth = (0, import_date_fns11.startOfMonth)(Date.now());
|
|
5063
5271
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
5064
5272
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
@@ -5161,13 +5369,13 @@ var ProfitAndLossChart = () => {
|
|
|
5161
5369
|
if (active && payload && payload.length) {
|
|
5162
5370
|
const netProfit = payload[0].payload.netProfit ?? 0;
|
|
5163
5371
|
const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
|
|
5164
|
-
return /* @__PURE__ */
|
|
5372
|
+
return /* @__PURE__ */ import_react53.default.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ import_react53.default.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ import_react53.default.createElement("li", null, /* @__PURE__ */ import_react53.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ import_react53.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ import_react53.default.createElement("li", null, /* @__PURE__ */ import_react53.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ import_react53.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ import_react53.default.createElement("li", null, /* @__PURE__ */ import_react53.default.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ import_react53.default.createElement("span", { className: `Layer__chart__tooltip-value ${netProfitClass}` }, "$", centsToDollars(netProfit)))));
|
|
5165
5373
|
}
|
|
5166
5374
|
return null;
|
|
5167
5375
|
};
|
|
5168
5376
|
const CustomizedCursor = (props) => {
|
|
5169
5377
|
const { x, width, height } = props;
|
|
5170
|
-
return /* @__PURE__ */
|
|
5378
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
5171
5379
|
import_recharts.Rectangle,
|
|
5172
5380
|
{
|
|
5173
5381
|
fill: getColor(900)?.hex ?? "#333",
|
|
@@ -5181,7 +5389,7 @@ var ProfitAndLossChart = () => {
|
|
|
5181
5389
|
}
|
|
5182
5390
|
);
|
|
5183
5391
|
};
|
|
5184
|
-
const data = (0,
|
|
5392
|
+
const data = (0, import_react53.useMemo)(
|
|
5185
5393
|
() => monthData.map(summarizePnL),
|
|
5186
5394
|
[
|
|
5187
5395
|
startSelectionMonth,
|
|
@@ -5189,8 +5397,8 @@ var ProfitAndLossChart = () => {
|
|
|
5189
5397
|
...monthData.map((m) => m?.net_profit)
|
|
5190
5398
|
]
|
|
5191
5399
|
);
|
|
5192
|
-
const [animateFrom, setAnimateFrom] = (0,
|
|
5193
|
-
return /* @__PURE__ */
|
|
5400
|
+
const [animateFrom, setAnimateFrom] = (0, import_react53.useState)(-1);
|
|
5401
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
5194
5402
|
import_recharts.ResponsiveContainer,
|
|
5195
5403
|
{
|
|
5196
5404
|
className: "Layer__chart-container",
|
|
@@ -5198,7 +5406,7 @@ var ProfitAndLossChart = () => {
|
|
|
5198
5406
|
height: "100%",
|
|
5199
5407
|
minHeight: 200
|
|
5200
5408
|
},
|
|
5201
|
-
/* @__PURE__ */
|
|
5409
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5202
5410
|
import_recharts.BarChart,
|
|
5203
5411
|
{
|
|
5204
5412
|
margin: { left: 12, right: 12, bottom: 12 },
|
|
@@ -5207,17 +5415,17 @@ var ProfitAndLossChart = () => {
|
|
|
5207
5415
|
barGap,
|
|
5208
5416
|
className: "Layer__profit-and-loss-chart"
|
|
5209
5417
|
},
|
|
5210
|
-
/* @__PURE__ */
|
|
5418
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5211
5419
|
import_recharts.Tooltip,
|
|
5212
5420
|
{
|
|
5213
5421
|
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
5214
|
-
content: /* @__PURE__ */
|
|
5215
|
-
cursor: /* @__PURE__ */
|
|
5422
|
+
content: /* @__PURE__ */ import_react53.default.createElement(CustomTooltip, null),
|
|
5423
|
+
cursor: /* @__PURE__ */ import_react53.default.createElement(CustomizedCursor, null),
|
|
5216
5424
|
animationDuration: 100,
|
|
5217
5425
|
animationEasing: "ease-out"
|
|
5218
5426
|
}
|
|
5219
5427
|
),
|
|
5220
|
-
/* @__PURE__ */
|
|
5428
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5221
5429
|
import_recharts.CartesianGrid,
|
|
5222
5430
|
{
|
|
5223
5431
|
vertical: false,
|
|
@@ -5225,7 +5433,7 @@ var ProfitAndLossChart = () => {
|
|
|
5225
5433
|
strokeDasharray: "5 5"
|
|
5226
5434
|
}
|
|
5227
5435
|
),
|
|
5228
|
-
/* @__PURE__ */
|
|
5436
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5229
5437
|
import_recharts.Legend,
|
|
5230
5438
|
{
|
|
5231
5439
|
verticalAlign: "top",
|
|
@@ -5245,8 +5453,8 @@ var ProfitAndLossChart = () => {
|
|
|
5245
5453
|
]
|
|
5246
5454
|
}
|
|
5247
5455
|
),
|
|
5248
|
-
/* @__PURE__ */
|
|
5249
|
-
/* @__PURE__ */
|
|
5456
|
+
/* @__PURE__ */ import_react53.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
5457
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5250
5458
|
import_recharts.Bar,
|
|
5251
5459
|
{
|
|
5252
5460
|
dataKey: "revenue",
|
|
@@ -5255,10 +5463,10 @@ var ProfitAndLossChart = () => {
|
|
|
5255
5463
|
radius: [2, 2, 0, 0],
|
|
5256
5464
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
5257
5465
|
},
|
|
5258
|
-
/* @__PURE__ */
|
|
5466
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5259
5467
|
import_recharts.LabelList,
|
|
5260
5468
|
{
|
|
5261
|
-
content: /* @__PURE__ */
|
|
5469
|
+
content: /* @__PURE__ */ import_react53.default.createElement(
|
|
5262
5470
|
Indicator,
|
|
5263
5471
|
{
|
|
5264
5472
|
animateFrom,
|
|
@@ -5267,7 +5475,7 @@ var ProfitAndLossChart = () => {
|
|
|
5267
5475
|
)
|
|
5268
5476
|
}
|
|
5269
5477
|
),
|
|
5270
|
-
data.map((entry) => /* @__PURE__ */
|
|
5478
|
+
data.map((entry) => /* @__PURE__ */ import_react53.default.createElement(
|
|
5271
5479
|
import_recharts.Cell,
|
|
5272
5480
|
{
|
|
5273
5481
|
key: entry.name,
|
|
@@ -5275,7 +5483,7 @@ var ProfitAndLossChart = () => {
|
|
|
5275
5483
|
}
|
|
5276
5484
|
))
|
|
5277
5485
|
),
|
|
5278
|
-
/* @__PURE__ */
|
|
5486
|
+
/* @__PURE__ */ import_react53.default.createElement(
|
|
5279
5487
|
import_recharts.Bar,
|
|
5280
5488
|
{
|
|
5281
5489
|
dataKey: "expenses",
|
|
@@ -5284,7 +5492,7 @@ var ProfitAndLossChart = () => {
|
|
|
5284
5492
|
radius: [2, 2, 0, 0],
|
|
5285
5493
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
5286
5494
|
},
|
|
5287
|
-
data.map((entry) => /* @__PURE__ */
|
|
5495
|
+
data.map((entry) => /* @__PURE__ */ import_react53.default.createElement(
|
|
5288
5496
|
import_recharts.Cell,
|
|
5289
5497
|
{
|
|
5290
5498
|
key: entry.name,
|
|
@@ -5297,19 +5505,19 @@ var ProfitAndLossChart = () => {
|
|
|
5297
5505
|
};
|
|
5298
5506
|
|
|
5299
5507
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
5300
|
-
var
|
|
5508
|
+
var import_react54 = __toESM(require("react"));
|
|
5301
5509
|
var import_date_fns12 = require("date-fns");
|
|
5302
5510
|
var ProfitAndLossDatePicker = () => {
|
|
5303
|
-
const { changeDateRange, dateRange } = (0,
|
|
5304
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5305
|
-
const [localDate, setLocalDate] = (0,
|
|
5306
|
-
const [nextOpacity, setNextOpacity] = (0,
|
|
5307
|
-
const [currentOpacity, setCurrentOpacity] = (0,
|
|
5308
|
-
const [transformStyle, setTransformStyle] = (0,
|
|
5511
|
+
const { changeDateRange, dateRange } = (0, import_react54.useContext)(ProfitAndLoss.Context);
|
|
5512
|
+
const [isAnimating, setIsAnimating] = (0, import_react54.useState)(false);
|
|
5513
|
+
const [localDate, setLocalDate] = (0, import_react54.useState)(dateRange.startDate);
|
|
5514
|
+
const [nextOpacity, setNextOpacity] = (0, import_react54.useState)(0);
|
|
5515
|
+
const [currentOpacity, setCurrentOpacity] = (0, import_react54.useState)(1);
|
|
5516
|
+
const [transformStyle, setTransformStyle] = (0, import_react54.useState)({
|
|
5309
5517
|
transform: "translateX(33%)",
|
|
5310
5518
|
transition: "ease"
|
|
5311
5519
|
});
|
|
5312
|
-
(0,
|
|
5520
|
+
(0, import_react54.useEffect)(() => {
|
|
5313
5521
|
if (dateRange.startDate !== localDate && !isAnimating) {
|
|
5314
5522
|
setLocalDate(dateRange.startDate);
|
|
5315
5523
|
setTransformStyle({ transform: "translateX(33%)", transition: "none" });
|
|
@@ -5347,19 +5555,19 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5347
5555
|
const currentLabel = (0, import_date_fns12.format)(localDate, "LLLL, y");
|
|
5348
5556
|
const prevLabel = (0, import_date_fns12.format)((0, import_date_fns12.add)(localDate, { months: -1 }), "LLLL, y");
|
|
5349
5557
|
const nextLabel = (0, import_date_fns12.format)((0, import_date_fns12.add)(localDate, { months: 1 }), "LLLL, y");
|
|
5350
|
-
return /* @__PURE__ */
|
|
5558
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
5351
5559
|
"div",
|
|
5352
5560
|
{
|
|
5353
5561
|
className: "Layer__profit-and-loss-date-picker"
|
|
5354
5562
|
},
|
|
5355
|
-
/* @__PURE__ */
|
|
5563
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-date-picker__labels-container", style: transformStyle }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, prevLabel), /* @__PURE__ */ import_react54.default.createElement(
|
|
5356
5564
|
"span",
|
|
5357
5565
|
{
|
|
5358
5566
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
5359
5567
|
style: { opacity: currentOpacity }
|
|
5360
5568
|
},
|
|
5361
5569
|
currentLabel
|
|
5362
|
-
), /* @__PURE__ */
|
|
5570
|
+
), /* @__PURE__ */ import_react54.default.createElement(
|
|
5363
5571
|
"span",
|
|
5364
5572
|
{
|
|
5365
5573
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
@@ -5367,7 +5575,7 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5367
5575
|
},
|
|
5368
5576
|
nextLabel
|
|
5369
5577
|
)),
|
|
5370
|
-
/* @__PURE__ */
|
|
5578
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5371
5579
|
"button",
|
|
5372
5580
|
{
|
|
5373
5581
|
"aria-label": "View Previous Month",
|
|
@@ -5375,7 +5583,7 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5375
5583
|
onClick: () => change(-1),
|
|
5376
5584
|
disabled: isAnimating
|
|
5377
5585
|
},
|
|
5378
|
-
/* @__PURE__ */
|
|
5586
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5379
5587
|
ChevronLeft_default,
|
|
5380
5588
|
{
|
|
5381
5589
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -5383,7 +5591,7 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5383
5591
|
}
|
|
5384
5592
|
)
|
|
5385
5593
|
),
|
|
5386
|
-
/* @__PURE__ */
|
|
5594
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5387
5595
|
"button",
|
|
5388
5596
|
{
|
|
5389
5597
|
"aria-label": "View Next Month",
|
|
@@ -5391,7 +5599,7 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5391
5599
|
onClick: () => change(1),
|
|
5392
5600
|
disabled: isAnimating
|
|
5393
5601
|
},
|
|
5394
|
-
/* @__PURE__ */
|
|
5602
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
5395
5603
|
ChevronRight_default,
|
|
5396
5604
|
{
|
|
5397
5605
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -5399,29 +5607,47 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5399
5607
|
}
|
|
5400
5608
|
)
|
|
5401
5609
|
),
|
|
5402
|
-
/* @__PURE__ */
|
|
5610
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-date-picker__effect-blur" })
|
|
5403
5611
|
);
|
|
5404
5612
|
};
|
|
5405
5613
|
|
|
5406
|
-
// src/components/
|
|
5407
|
-
var
|
|
5614
|
+
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5615
|
+
var import_react58 = __toESM(require("react"));
|
|
5408
5616
|
|
|
5409
|
-
// src/
|
|
5410
|
-
var
|
|
5411
|
-
var
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5617
|
+
// src/icons/X.tsx
|
|
5618
|
+
var React68 = __toESM(require("react"));
|
|
5619
|
+
var X = ({ size = 18, ...props }) => /* @__PURE__ */ React68.createElement(
|
|
5620
|
+
"svg",
|
|
5621
|
+
{
|
|
5622
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5623
|
+
viewBox: "0 0 18 18",
|
|
5624
|
+
fill: "none",
|
|
5625
|
+
...props,
|
|
5626
|
+
width: size,
|
|
5627
|
+
height: size
|
|
5628
|
+
},
|
|
5629
|
+
/* @__PURE__ */ React68.createElement(
|
|
5630
|
+
"path",
|
|
5631
|
+
{
|
|
5632
|
+
d: "M13.5 4.5L4.5 13.5",
|
|
5633
|
+
stroke: "currentColor",
|
|
5634
|
+
strokeLinecap: "round",
|
|
5635
|
+
strokeLinejoin: "round"
|
|
5636
|
+
}
|
|
5637
|
+
),
|
|
5638
|
+
/* @__PURE__ */ React68.createElement(
|
|
5639
|
+
"path",
|
|
5640
|
+
{
|
|
5641
|
+
d: "M4.5 4.5L13.5 13.5",
|
|
5642
|
+
stroke: "currentColor",
|
|
5643
|
+
strokeLinecap: "round",
|
|
5644
|
+
strokeLinejoin: "round"
|
|
5645
|
+
}
|
|
5646
|
+
)
|
|
5647
|
+
);
|
|
5648
|
+
var X_default = X;
|
|
5423
5649
|
|
|
5424
|
-
// src/components/
|
|
5650
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5425
5651
|
var import_react55 = __toESM(require("react"));
|
|
5426
5652
|
|
|
5427
5653
|
// src/config/charts.ts
|
|
@@ -5510,915 +5736,1103 @@ var DEFAULT_CHART_COLORS = [
|
|
|
5510
5736
|
}
|
|
5511
5737
|
];
|
|
5512
5738
|
|
|
5513
|
-
// src/components/
|
|
5739
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5514
5740
|
var import_recharts2 = require("recharts");
|
|
5515
|
-
var
|
|
5516
|
-
|
|
5741
|
+
var DetailedChart = ({
|
|
5742
|
+
filteredData,
|
|
5743
|
+
filteredTotal,
|
|
5744
|
+
hoveredItem,
|
|
5745
|
+
setHoveredItem,
|
|
5746
|
+
sidebarScope,
|
|
5747
|
+
date,
|
|
5748
|
+
isLoading
|
|
5749
|
+
}) => {
|
|
5750
|
+
const chartData = (0, import_react55.useMemo)(() => {
|
|
5751
|
+
if (!filteredData) {
|
|
5752
|
+
return [];
|
|
5753
|
+
}
|
|
5754
|
+
return filteredData.map((x) => {
|
|
5755
|
+
if (x.hidden) {
|
|
5756
|
+
return {
|
|
5757
|
+
name: x.display_name,
|
|
5758
|
+
value: 0
|
|
5759
|
+
};
|
|
5760
|
+
}
|
|
5761
|
+
return {
|
|
5762
|
+
name: x.display_name,
|
|
5763
|
+
value: x.value
|
|
5764
|
+
};
|
|
5765
|
+
});
|
|
5766
|
+
}, [filteredData, isLoading]);
|
|
5767
|
+
const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
|
|
5768
|
+
return /* @__PURE__ */ import_react55.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react55.default.createElement("div", { className: "header--tablet" }, /* @__PURE__ */ import_react55.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react55.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react55.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react55.default.createElement(import_recharts2.ResponsiveContainer, null, /* @__PURE__ */ import_react55.default.createElement(import_recharts2.PieChart, null, !isLoading && !noValue ? /* @__PURE__ */ import_react55.default.createElement(
|
|
5517
5769
|
import_recharts2.Pie,
|
|
5518
5770
|
{
|
|
5519
|
-
data,
|
|
5771
|
+
data: chartData,
|
|
5520
5772
|
dataKey: "value",
|
|
5521
5773
|
nameKey: "name",
|
|
5522
5774
|
cx: "50%",
|
|
5523
5775
|
cy: "50%",
|
|
5524
|
-
innerRadius:
|
|
5525
|
-
outerRadius:
|
|
5526
|
-
paddingAngle: 0.
|
|
5776
|
+
innerRadius: 105,
|
|
5777
|
+
outerRadius: 120,
|
|
5778
|
+
paddingAngle: 0.5,
|
|
5527
5779
|
fill: "#8884d8",
|
|
5528
|
-
|
|
5529
|
-
height: 24,
|
|
5530
|
-
animationDuration: 250,
|
|
5780
|
+
animationDuration: 200,
|
|
5531
5781
|
animationEasing: "ease-in-out"
|
|
5532
5782
|
},
|
|
5533
|
-
|
|
5783
|
+
chartData.map((entry, index) => {
|
|
5534
5784
|
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
5785
|
+
let fill = colorConfig.color;
|
|
5786
|
+
let opacity = colorConfig.opacity;
|
|
5787
|
+
let active = true;
|
|
5788
|
+
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5789
|
+
active = false;
|
|
5790
|
+
fill = void 0;
|
|
5791
|
+
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5792
|
+
}
|
|
5535
5793
|
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5536
5794
|
import_recharts2.Cell,
|
|
5537
5795
|
{
|
|
5538
5796
|
key: `cell-${index}`,
|
|
5539
|
-
className: `Layer__profit-and-loss-detailed-charts__pie`,
|
|
5540
|
-
|
|
5541
|
-
opacity
|
|
5797
|
+
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5798
|
+
style: { fill },
|
|
5799
|
+
opacity,
|
|
5800
|
+
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5801
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5542
5802
|
}
|
|
5543
5803
|
);
|
|
5544
|
-
})
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
5549
|
-
var import_classnames27 = __toESM(require("classnames"));
|
|
5550
|
-
var CHART_PLACEHOLDER = [
|
|
5551
|
-
{
|
|
5552
|
-
name: "placeholder",
|
|
5553
|
-
display_name: "placeholder",
|
|
5554
|
-
value: 1,
|
|
5555
|
-
type: "placeholder",
|
|
5556
|
-
share: 1
|
|
5557
|
-
}
|
|
5558
|
-
];
|
|
5559
|
-
var buildMiniChartData = (scope, data) => {
|
|
5560
|
-
if (!data) {
|
|
5561
|
-
return CHART_PLACEHOLDER;
|
|
5562
|
-
}
|
|
5563
|
-
let items = [];
|
|
5564
|
-
switch (scope) {
|
|
5565
|
-
case "revenue":
|
|
5566
|
-
items = collectRevenueItems(data);
|
|
5567
|
-
break;
|
|
5568
|
-
default:
|
|
5569
|
-
items = collectExpensesItems(data);
|
|
5570
|
-
}
|
|
5571
|
-
if (!items || items.length === 0 || !items.find((x) => Math.abs(x.value) !== 0)) {
|
|
5572
|
-
return CHART_PLACEHOLDER;
|
|
5573
|
-
}
|
|
5574
|
-
return items.slice();
|
|
5575
|
-
};
|
|
5576
|
-
var ProfitAndLossSummaries = ({
|
|
5577
|
-
vertical,
|
|
5578
|
-
revenueLabel = "Revenue"
|
|
5579
|
-
}) => {
|
|
5580
|
-
const {
|
|
5581
|
-
data: storedData,
|
|
5582
|
-
isLoading,
|
|
5583
|
-
setSidebarScope,
|
|
5584
|
-
sidebarScope
|
|
5585
|
-
} = (0, import_react56.useContext)(ProfitAndLoss.Context);
|
|
5586
|
-
const expensesChartData = (0, import_react56.useMemo)(() => {
|
|
5587
|
-
return buildMiniChartData("expenses", storedData);
|
|
5588
|
-
}, [storedData]);
|
|
5589
|
-
const revenueChartData = (0, import_react56.useMemo)(() => {
|
|
5590
|
-
return buildMiniChartData("revenue", storedData);
|
|
5591
|
-
}, [storedData]);
|
|
5592
|
-
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
5593
|
-
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
5594
|
-
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
5595
|
-
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
5596
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5597
|
-
"div",
|
|
5598
|
-
{
|
|
5599
|
-
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
5600
|
-
},
|
|
5601
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5602
|
-
"div",
|
|
5804
|
+
}),
|
|
5805
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5806
|
+
import_recharts2.Label,
|
|
5603
5807
|
{
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5808
|
+
position: "center",
|
|
5809
|
+
value: "Total",
|
|
5810
|
+
className: "pie-center-label-title",
|
|
5811
|
+
content: (props) => {
|
|
5812
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5813
|
+
cx: 0,
|
|
5814
|
+
cy: 0
|
|
5815
|
+
};
|
|
5816
|
+
const positioningProps = {
|
|
5817
|
+
x: cx,
|
|
5818
|
+
y: (cy || 0) - 15,
|
|
5819
|
+
textAnchor: "middle",
|
|
5820
|
+
verticalAnchor: "middle"
|
|
5821
|
+
};
|
|
5822
|
+
let text = "Total";
|
|
5823
|
+
if (hoveredItem) {
|
|
5824
|
+
text = hoveredItem;
|
|
5825
|
+
}
|
|
5826
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5827
|
+
import_recharts2.Text,
|
|
5828
|
+
{
|
|
5829
|
+
...positioningProps,
|
|
5830
|
+
className: "pie-center-label__title"
|
|
5831
|
+
},
|
|
5832
|
+
text
|
|
5833
|
+
);
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5619
5836
|
),
|
|
5620
|
-
/* @__PURE__ */
|
|
5621
|
-
|
|
5837
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5838
|
+
import_recharts2.Label,
|
|
5622
5839
|
{
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5840
|
+
position: "center",
|
|
5841
|
+
value: "Total",
|
|
5842
|
+
className: "pie-center-label-title",
|
|
5843
|
+
content: (props) => {
|
|
5844
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5845
|
+
cx: 0,
|
|
5846
|
+
cy: 0
|
|
5847
|
+
};
|
|
5848
|
+
const positioningProps = {
|
|
5849
|
+
x: cx,
|
|
5850
|
+
y: (cy || 0) + 5,
|
|
5851
|
+
textAnchor: "middle",
|
|
5852
|
+
verticalAnchor: "middle"
|
|
5853
|
+
};
|
|
5854
|
+
let value = filteredTotal;
|
|
5855
|
+
if (hoveredItem) {
|
|
5856
|
+
value = filteredData.find(
|
|
5857
|
+
(x) => x.display_name === hoveredItem
|
|
5858
|
+
)?.value;
|
|
5859
|
+
}
|
|
5860
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5861
|
+
import_recharts2.Text,
|
|
5862
|
+
{
|
|
5863
|
+
...positioningProps,
|
|
5864
|
+
className: "pie-center-label__value"
|
|
5865
|
+
},
|
|
5866
|
+
`$${centsToDollars(value)}`
|
|
5867
|
+
);
|
|
5868
|
+
}
|
|
5869
|
+
}
|
|
5640
5870
|
),
|
|
5641
|
-
/* @__PURE__ */
|
|
5642
|
-
|
|
5871
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5872
|
+
import_recharts2.Label,
|
|
5643
5873
|
{
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5874
|
+
position: "center",
|
|
5875
|
+
value: "Total",
|
|
5876
|
+
className: "pie-center-label-title",
|
|
5877
|
+
content: (props) => {
|
|
5878
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5879
|
+
cx: 0,
|
|
5880
|
+
cy: 0
|
|
5881
|
+
};
|
|
5882
|
+
const positioningProps = {
|
|
5883
|
+
x: cx,
|
|
5884
|
+
y: (cy || 0) + 25,
|
|
5885
|
+
height: 20,
|
|
5886
|
+
textAnchor: "middle",
|
|
5887
|
+
verticalAnchor: "middle"
|
|
5888
|
+
};
|
|
5889
|
+
if (hoveredItem) {
|
|
5890
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5891
|
+
import_recharts2.Text,
|
|
5892
|
+
{
|
|
5893
|
+
...positioningProps,
|
|
5894
|
+
className: "pie-center-label__share"
|
|
5895
|
+
},
|
|
5896
|
+
`${formatPercent(
|
|
5897
|
+
filteredData.find(
|
|
5898
|
+
(x) => x.display_name === hoveredItem
|
|
5899
|
+
)?.share
|
|
5900
|
+
)}%`
|
|
5901
|
+
);
|
|
5902
|
+
}
|
|
5903
|
+
return;
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
)
|
|
5907
|
+
) : null, !isLoading && noValue ? /* @__PURE__ */ import_react55.default.createElement(
|
|
5908
|
+
import_recharts2.Pie,
|
|
5909
|
+
{
|
|
5910
|
+
data: [{ name: "Total", value: 1 }],
|
|
5911
|
+
dataKey: "value",
|
|
5912
|
+
nameKey: "name",
|
|
5913
|
+
cx: "50%",
|
|
5914
|
+
cy: "50%",
|
|
5915
|
+
innerRadius: 105,
|
|
5916
|
+
outerRadius: 120,
|
|
5917
|
+
paddingAngle: 0,
|
|
5918
|
+
fill: "#F8F8FA",
|
|
5919
|
+
animationDuration: 200,
|
|
5920
|
+
animationEasing: "ease-in-out"
|
|
5921
|
+
},
|
|
5922
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5923
|
+
import_recharts2.Label,
|
|
5924
|
+
{
|
|
5925
|
+
position: "center",
|
|
5926
|
+
value: "Total",
|
|
5927
|
+
className: "pie-center-label-title",
|
|
5928
|
+
content: (props) => {
|
|
5929
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5930
|
+
cx: 0,
|
|
5931
|
+
cy: 0
|
|
5932
|
+
};
|
|
5933
|
+
const positioningProps = {
|
|
5934
|
+
x: cx,
|
|
5935
|
+
y: (cy || 0) - 15,
|
|
5936
|
+
textAnchor: "middle",
|
|
5937
|
+
verticalAnchor: "middle"
|
|
5938
|
+
};
|
|
5939
|
+
let text = "Total";
|
|
5940
|
+
if (hoveredItem) {
|
|
5941
|
+
text = hoveredItem;
|
|
5942
|
+
}
|
|
5943
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5944
|
+
import_recharts2.Text,
|
|
5945
|
+
{
|
|
5946
|
+
...positioningProps,
|
|
5947
|
+
className: "pie-center-label__title"
|
|
5948
|
+
},
|
|
5949
|
+
text
|
|
5950
|
+
);
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5953
|
+
),
|
|
5954
|
+
/* @__PURE__ */ import_react55.default.createElement(
|
|
5955
|
+
import_recharts2.Label,
|
|
5956
|
+
{
|
|
5957
|
+
position: "center",
|
|
5958
|
+
value: "Total",
|
|
5959
|
+
className: "pie-center-label-title",
|
|
5960
|
+
content: (props) => {
|
|
5961
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5962
|
+
cx: 0,
|
|
5963
|
+
cy: 0
|
|
5964
|
+
};
|
|
5965
|
+
const positioningProps = {
|
|
5966
|
+
x: cx,
|
|
5967
|
+
y: (cy || 0) + 5,
|
|
5968
|
+
textAnchor: "middle",
|
|
5969
|
+
verticalAnchor: "middle"
|
|
5970
|
+
};
|
|
5971
|
+
let value = filteredTotal;
|
|
5972
|
+
if (hoveredItem) {
|
|
5973
|
+
value = filteredData.find(
|
|
5974
|
+
(x) => x.display_name === hoveredItem
|
|
5975
|
+
)?.value;
|
|
5976
|
+
}
|
|
5977
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
5978
|
+
import_recharts2.Text,
|
|
5979
|
+
{
|
|
5980
|
+
...positioningProps,
|
|
5981
|
+
className: "pie-center-label__value"
|
|
5982
|
+
},
|
|
5983
|
+
`$${centsToDollars(value)}`
|
|
5984
|
+
);
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
)
|
|
5988
|
+
) : null, isLoading ? /* @__PURE__ */ import_react55.default.createElement(
|
|
5989
|
+
import_recharts2.Pie,
|
|
5990
|
+
{
|
|
5991
|
+
data: [{ name: "loading...", value: 1 }],
|
|
5992
|
+
dataKey: "value",
|
|
5993
|
+
nameKey: "name",
|
|
5994
|
+
cx: "50%",
|
|
5995
|
+
cy: "50%",
|
|
5996
|
+
innerRadius: 105,
|
|
5997
|
+
outerRadius: 120,
|
|
5998
|
+
paddingAngle: 0,
|
|
5999
|
+
fill: "#F8F8FA",
|
|
6000
|
+
animationDuration: 200,
|
|
6001
|
+
animationEasing: "ease-in-out"
|
|
6002
|
+
}
|
|
6003
|
+
) : null))));
|
|
5649
6004
|
};
|
|
5650
6005
|
|
|
5651
|
-
// src/components/
|
|
5652
|
-
var
|
|
5653
|
-
|
|
5654
|
-
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
5655
|
-
var import_react57 = __toESM(require("react"));
|
|
6006
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
6007
|
+
var import_react56 = __toESM(require("react"));
|
|
5656
6008
|
|
|
5657
|
-
// src/icons/
|
|
5658
|
-
var
|
|
5659
|
-
var
|
|
6009
|
+
// src/icons/SortArrows.tsx
|
|
6010
|
+
var React70 = __toESM(require("react"));
|
|
6011
|
+
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElement(
|
|
5660
6012
|
"svg",
|
|
5661
6013
|
{
|
|
5662
6014
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5663
|
-
viewBox: "0 0 12
|
|
6015
|
+
viewBox: "0 0 12 13",
|
|
5664
6016
|
fill: "none",
|
|
5665
6017
|
...props,
|
|
5666
6018
|
width: size,
|
|
5667
6019
|
height: size
|
|
5668
6020
|
},
|
|
5669
|
-
/* @__PURE__ */
|
|
6021
|
+
/* @__PURE__ */ React70.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React70.createElement(
|
|
5670
6022
|
"path",
|
|
5671
6023
|
{
|
|
5672
|
-
d: "
|
|
6024
|
+
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
5673
6025
|
stroke: "currentColor",
|
|
5674
6026
|
strokeLinecap: "round",
|
|
5675
|
-
strokeLinejoin: "round"
|
|
6027
|
+
strokeLinejoin: "round",
|
|
6028
|
+
className: "desc-arrow"
|
|
5676
6029
|
}
|
|
5677
|
-
), /* @__PURE__ */
|
|
6030
|
+
), /* @__PURE__ */ React70.createElement(
|
|
5678
6031
|
"path",
|
|
5679
6032
|
{
|
|
5680
|
-
d: "
|
|
6033
|
+
d: "M4 2.5L4 11.1667",
|
|
5681
6034
|
stroke: "currentColor",
|
|
5682
6035
|
strokeLinecap: "round",
|
|
5683
|
-
strokeLinejoin: "round"
|
|
6036
|
+
strokeLinejoin: "round",
|
|
6037
|
+
className: "desc-arrow"
|
|
5684
6038
|
}
|
|
5685
|
-
)
|
|
5686
|
-
|
|
5687
|
-
var PieChart_default = PieChart2;
|
|
5688
|
-
|
|
5689
|
-
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
5690
|
-
var ProfitAndLossRow = ({
|
|
5691
|
-
variant,
|
|
5692
|
-
lineItem,
|
|
5693
|
-
depth = 0,
|
|
5694
|
-
maxDepth = 1,
|
|
5695
|
-
direction = "DEBIT" /* DEBIT */,
|
|
5696
|
-
lockExpanded = false,
|
|
5697
|
-
scope,
|
|
5698
|
-
setSidebarScope
|
|
5699
|
-
}) => {
|
|
5700
|
-
if (!lineItem) {
|
|
5701
|
-
return null;
|
|
5702
|
-
}
|
|
5703
|
-
const { value, display_name, line_items } = lineItem;
|
|
5704
|
-
const [expanded, setExpanded] = (0, import_react57.useState)(true);
|
|
5705
|
-
const amount = value ?? 0;
|
|
5706
|
-
const amountString = centsToDollars(Math.abs(amount));
|
|
5707
|
-
const labelClasses = [
|
|
5708
|
-
"Layer__profit-and-loss-row",
|
|
5709
|
-
"Layer__profit-and-loss-row__label"
|
|
5710
|
-
];
|
|
5711
|
-
const valueClasses = [
|
|
5712
|
-
"Layer__profit-and-loss-row",
|
|
5713
|
-
"Layer__profit-and-loss-row__value"
|
|
5714
|
-
];
|
|
5715
|
-
const positive = amount === 0 || direction === "CREDIT" /* CREDIT */ && amount > 0 || direction === "DEBIT" /* DEBIT */ && amount < 0;
|
|
5716
|
-
valueClasses.push(
|
|
5717
|
-
positive ? "Layer__profit-and-loss-row__value--amount-positive" : "Layer__profit-and-loss-row__value--amount-negative"
|
|
5718
|
-
);
|
|
5719
|
-
labelClasses.push(`Layer__profit-and-loss-row__label--depth-${depth}`);
|
|
5720
|
-
valueClasses.push(`Layer__profit-and-loss-row__value--depth-${depth}`);
|
|
5721
|
-
variant && labelClasses.push(`Layer__profit-and-loss-row__label--variant-${variant}`);
|
|
5722
|
-
variant && valueClasses.push(`Layer__profit-and-loss-row__value--variant-${variant}`);
|
|
5723
|
-
const toggleExpanded = () => setExpanded(!expanded);
|
|
5724
|
-
const canGoDeeper = depth < maxDepth;
|
|
5725
|
-
const hasChildren = (line_items?.length ?? 0) > 0;
|
|
5726
|
-
const displayChildren = hasChildren && canGoDeeper;
|
|
5727
|
-
labelClasses.push(
|
|
5728
|
-
`Layer__profit-and-loss-row__label--display-children-${displayChildren}`
|
|
5729
|
-
);
|
|
5730
|
-
valueClasses.push(
|
|
5731
|
-
`Layer__profit-and-loss-row__value--display-children-${displayChildren}`
|
|
5732
|
-
);
|
|
5733
|
-
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
5734
|
-
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
5735
|
-
return /* @__PURE__ */ import_react57.default.createElement(import_react57.default.Fragment, null, /* @__PURE__ */ import_react57.default.createElement(
|
|
5736
|
-
"div",
|
|
6039
|
+
), /* @__PURE__ */ React70.createElement(
|
|
6040
|
+
"path",
|
|
5737
6041
|
{
|
|
5738
|
-
|
|
5739
|
-
|
|
6042
|
+
d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
|
|
6043
|
+
stroke: "currentColor",
|
|
6044
|
+
strokeLinecap: "round",
|
|
6045
|
+
strokeLinejoin: "round",
|
|
6046
|
+
className: "asc-arrow"
|
|
6047
|
+
}
|
|
6048
|
+
), /* @__PURE__ */ React70.createElement(
|
|
6049
|
+
"path",
|
|
6050
|
+
{
|
|
6051
|
+
d: "M8.66663 11.166L8.66663 2.49935",
|
|
6052
|
+
stroke: "currentColor",
|
|
6053
|
+
strokeLinecap: "round",
|
|
6054
|
+
strokeLinejoin: "round",
|
|
6055
|
+
className: "asc-arrow"
|
|
6056
|
+
}
|
|
6057
|
+
)),
|
|
6058
|
+
/* @__PURE__ */ React70.createElement("defs", null, /* @__PURE__ */ React70.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React70.createElement(
|
|
6059
|
+
"rect",
|
|
6060
|
+
{
|
|
6061
|
+
width: "12",
|
|
6062
|
+
height: "12",
|
|
6063
|
+
fill: "white",
|
|
6064
|
+
transform: "translate(0 0.5)"
|
|
6065
|
+
}
|
|
6066
|
+
)))
|
|
6067
|
+
);
|
|
6068
|
+
var SortArrows_default = SortArrows;
|
|
6069
|
+
|
|
6070
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
6071
|
+
var import_classnames26 = __toESM(require("classnames"));
|
|
6072
|
+
var DetailedTable = ({
|
|
6073
|
+
filteredData,
|
|
6074
|
+
sidebarScope,
|
|
6075
|
+
filters,
|
|
6076
|
+
sortBy,
|
|
6077
|
+
hoveredItem,
|
|
6078
|
+
setHoveredItem
|
|
6079
|
+
}) => {
|
|
6080
|
+
const buildColClass = (column) => {
|
|
6081
|
+
return (0, import_classnames26.default)(
|
|
6082
|
+
"Layer__sortable-col",
|
|
6083
|
+
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
6084
|
+
);
|
|
6085
|
+
};
|
|
6086
|
+
return /* @__PURE__ */ import_react56.default.createElement("div", { className: "details-container" }, /* @__PURE__ */ import_react56.default.createElement("div", { className: "table" }, /* @__PURE__ */ import_react56.default.createElement("table", null, /* @__PURE__ */ import_react56.default.createElement("thead", null, /* @__PURE__ */ import_react56.default.createElement("tr", null, /* @__PURE__ */ import_react56.default.createElement(
|
|
6087
|
+
"th",
|
|
6088
|
+
{
|
|
6089
|
+
className: buildColClass("category"),
|
|
6090
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
5740
6091
|
},
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
className: "Layer__profit-and-loss-row__label__chevron"
|
|
5746
|
-
}
|
|
5747
|
-
) : null, /* @__PURE__ */ import_react57.default.createElement(Text, null, display_name)),
|
|
5748
|
-
setSidebarScope && /* @__PURE__ */ import_react57.default.createElement(
|
|
5749
|
-
"span",
|
|
5750
|
-
{
|
|
5751
|
-
className: "Layer__profit-and-loss-row__detailed-chart-btn",
|
|
5752
|
-
onClick: (e) => {
|
|
5753
|
-
e.stopPropagation();
|
|
5754
|
-
setSidebarScope && setSidebarScope(scope ?? "expenses");
|
|
5755
|
-
}
|
|
5756
|
-
},
|
|
5757
|
-
/* @__PURE__ */ import_react57.default.createElement(PieChart_default, null)
|
|
5758
|
-
)
|
|
5759
|
-
), /* @__PURE__ */ import_react57.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react57.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react57.default.createElement(
|
|
5760
|
-
"div",
|
|
6092
|
+
"Expense/Sale ",
|
|
6093
|
+
/* @__PURE__ */ import_react56.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6094
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
6095
|
+
"th",
|
|
5761
6096
|
{
|
|
5762
|
-
className:
|
|
6097
|
+
className: buildColClass("type"),
|
|
6098
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5763
6099
|
},
|
|
5764
|
-
|
|
5765
|
-
|
|
6100
|
+
"Type ",
|
|
6101
|
+
/* @__PURE__ */ import_react56.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6102
|
+
), /* @__PURE__ */ import_react56.default.createElement("th", null), /* @__PURE__ */ import_react56.default.createElement(
|
|
6103
|
+
"th",
|
|
6104
|
+
{
|
|
6105
|
+
className: buildColClass("value"),
|
|
6106
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
6107
|
+
},
|
|
6108
|
+
"Value ",
|
|
6109
|
+
/* @__PURE__ */ import_react56.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6110
|
+
))), /* @__PURE__ */ import_react56.default.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
6111
|
+
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
6112
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
6113
|
+
"tr",
|
|
5766
6114
|
{
|
|
5767
|
-
key:
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
6115
|
+
key: `pl-side-table-item-${idx}`,
|
|
6116
|
+
className: (0, import_classnames26.default)(
|
|
6117
|
+
"Layer__profit-and-loss-detailed-table__row",
|
|
6118
|
+
hoveredItem && hoveredItem === item.display_name ? "active" : ""
|
|
6119
|
+
),
|
|
6120
|
+
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
6121
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
6122
|
+
},
|
|
6123
|
+
/* @__PURE__ */ import_react56.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
6124
|
+
/* @__PURE__ */ import_react56.default.createElement("td", { className: "type-col" }, item.type),
|
|
6125
|
+
/* @__PURE__ */ import_react56.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
6126
|
+
/* @__PURE__ */ import_react56.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react56.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react56.default.createElement(
|
|
6127
|
+
"div",
|
|
6128
|
+
{
|
|
6129
|
+
className: "share-icon",
|
|
6130
|
+
style: {
|
|
6131
|
+
background: colorConfig.color,
|
|
6132
|
+
opacity: colorConfig.opacity
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
)))
|
|
6136
|
+
);
|
|
6137
|
+
})))));
|
|
5775
6138
|
};
|
|
5776
6139
|
|
|
5777
|
-
// src/components/
|
|
5778
|
-
var
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
value: NaN,
|
|
5814
|
-
line_items: null
|
|
5815
|
-
},
|
|
5816
|
-
personal_expenses: {
|
|
5817
|
-
name: "PERSONAL",
|
|
5818
|
-
display_name: "Personal expenses",
|
|
5819
|
-
value: NaN,
|
|
5820
|
-
line_items: null
|
|
5821
|
-
},
|
|
5822
|
-
fully_categorized: false
|
|
6140
|
+
// src/components/ProfitAndLossDetailedCharts/Filters.tsx
|
|
6141
|
+
var import_react57 = __toESM(require("react"));
|
|
6142
|
+
var import_react_select3 = __toESM(require("react-select"));
|
|
6143
|
+
var Filters = ({
|
|
6144
|
+
filteredData,
|
|
6145
|
+
sidebarScope,
|
|
6146
|
+
filters,
|
|
6147
|
+
setFilterTypes
|
|
6148
|
+
}) => {
|
|
6149
|
+
return /* @__PURE__ */ import_react57.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react57.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react57.default.createElement(
|
|
6150
|
+
import_react_select3.default,
|
|
6151
|
+
{
|
|
6152
|
+
className: "Layer__select type-select",
|
|
6153
|
+
classNamePrefix: "Layer__select",
|
|
6154
|
+
value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
|
|
6155
|
+
value: x,
|
|
6156
|
+
label: x
|
|
6157
|
+
})) : [],
|
|
6158
|
+
isMulti: true,
|
|
6159
|
+
isClearable: false,
|
|
6160
|
+
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
6161
|
+
label: x,
|
|
6162
|
+
value: x
|
|
6163
|
+
})),
|
|
6164
|
+
onChange: (selected) => {
|
|
6165
|
+
setFilterTypes(
|
|
6166
|
+
sidebarScope ?? "expenses",
|
|
6167
|
+
selected.map((x) => x.value)
|
|
6168
|
+
);
|
|
6169
|
+
},
|
|
6170
|
+
components: {
|
|
6171
|
+
DropdownIndicator: (props) => /* @__PURE__ */ import_react57.default.createElement(import_react_select3.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react57.default.createElement(ChevronDown_default, null)),
|
|
6172
|
+
Placeholder: (props) => /* @__PURE__ */ import_react57.default.createElement(import_react_select3.components.Placeholder, { ...props }, /* @__PURE__ */ import_react57.default.createElement("div", { className: "Layer__select__multi-all-placeholder-badge" }, "All"))
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
));
|
|
5823
6176
|
};
|
|
5824
6177
|
|
|
5825
|
-
// src/components/
|
|
5826
|
-
var
|
|
6178
|
+
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
6179
|
+
var import_date_fns13 = require("date-fns");
|
|
6180
|
+
var ProfitAndLossDetailedCharts = ({
|
|
6181
|
+
scope,
|
|
6182
|
+
hideClose = false,
|
|
6183
|
+
showDatePicker = false
|
|
6184
|
+
}) => {
|
|
5827
6185
|
const {
|
|
5828
|
-
|
|
6186
|
+
filteredDataRevenue,
|
|
6187
|
+
filteredTotalRevenue,
|
|
6188
|
+
filteredDataExpenses,
|
|
6189
|
+
filteredTotalExpenses,
|
|
6190
|
+
sortBy,
|
|
5829
6191
|
isLoading,
|
|
5830
|
-
|
|
6192
|
+
filters,
|
|
6193
|
+
dateRange,
|
|
6194
|
+
sidebarScope,
|
|
6195
|
+
setSidebarScope,
|
|
6196
|
+
setFilterTypes
|
|
5831
6197
|
} = (0, import_react58.useContext)(ProfitAndLoss.Context);
|
|
5832
|
-
const
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5837
|
-
|
|
5838
|
-
{
|
|
5839
|
-
lineItem: data.income,
|
|
5840
|
-
direction: "CREDIT" /* CREDIT */,
|
|
5841
|
-
lockExpanded,
|
|
5842
|
-
scope: "revenue",
|
|
5843
|
-
setSidebarScope
|
|
5844
|
-
}
|
|
5845
|
-
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5846
|
-
ProfitAndLossRow,
|
|
5847
|
-
{
|
|
5848
|
-
lineItem: data.cost_of_goods_sold,
|
|
5849
|
-
direction: "DEBIT" /* DEBIT */,
|
|
5850
|
-
lockExpanded,
|
|
5851
|
-
scope: "expenses",
|
|
5852
|
-
setSidebarScope
|
|
5853
|
-
}
|
|
5854
|
-
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5855
|
-
ProfitAndLossRow,
|
|
5856
|
-
{
|
|
5857
|
-
lineItem: {
|
|
5858
|
-
value: data.gross_profit,
|
|
5859
|
-
display_name: "Gross Profit"
|
|
5860
|
-
},
|
|
5861
|
-
variant: "summation",
|
|
5862
|
-
direction: "CREDIT" /* CREDIT */,
|
|
5863
|
-
lockExpanded,
|
|
5864
|
-
scope: "revenue",
|
|
5865
|
-
setSidebarScope
|
|
5866
|
-
}
|
|
5867
|
-
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5868
|
-
ProfitAndLossRow,
|
|
6198
|
+
const theScope = scope ? scope : sidebarScope;
|
|
6199
|
+
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
6200
|
+
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
6201
|
+
const [hoveredItem, setHoveredItem] = (0, import_react58.useState)();
|
|
6202
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react58.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react58.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react58.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react58.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns13.format)(dateRange.startDate, "LLLL, y")), showDatePicker && /* @__PURE__ */ import_react58.default.createElement(ProfitAndLossDatePicker, null)), !hideClose && /* @__PURE__ */ import_react58.default.createElement(
|
|
6203
|
+
Button,
|
|
5869
6204
|
{
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
setSidebarScope
|
|
6205
|
+
rightIcon: /* @__PURE__ */ import_react58.default.createElement(X_default, null),
|
|
6206
|
+
iconOnly: true,
|
|
6207
|
+
onClick: () => setSidebarScope(void 0),
|
|
6208
|
+
variant: "secondary" /* secondary */
|
|
5875
6209
|
}
|
|
5876
|
-
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5877
|
-
|
|
6210
|
+
)), /* @__PURE__ */ import_react58.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ import_react58.default.createElement(BackButton, { onClick: () => setSidebarScope(void 0) })), /* @__PURE__ */ import_react58.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react58.default.createElement(
|
|
6211
|
+
DetailedChart,
|
|
5878
6212
|
{
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
scope: "revenue",
|
|
5887
|
-
setSidebarScope
|
|
6213
|
+
filteredData: data,
|
|
6214
|
+
filteredTotal: total,
|
|
6215
|
+
hoveredItem,
|
|
6216
|
+
setHoveredItem,
|
|
6217
|
+
sidebarScope: theScope,
|
|
6218
|
+
date: dateRange.startDate,
|
|
6219
|
+
isLoading
|
|
5888
6220
|
}
|
|
5889
|
-
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5890
|
-
|
|
6221
|
+
), /* @__PURE__ */ import_react58.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ import_react58.default.createElement(
|
|
6222
|
+
Filters,
|
|
5891
6223
|
{
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
setSidebarScope
|
|
6224
|
+
filteredData: data,
|
|
6225
|
+
sidebarScope: theScope,
|
|
6226
|
+
filters,
|
|
6227
|
+
setFilterTypes
|
|
5897
6228
|
}
|
|
5898
6229
|
), /* @__PURE__ */ import_react58.default.createElement(
|
|
5899
|
-
|
|
6230
|
+
DetailedTable,
|
|
5900
6231
|
{
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
lockExpanded
|
|
6232
|
+
filteredData: data,
|
|
6233
|
+
sidebarScope: theScope,
|
|
6234
|
+
filters,
|
|
6235
|
+
sortBy,
|
|
6236
|
+
hoveredItem,
|
|
6237
|
+
setHoveredItem
|
|
5908
6238
|
}
|
|
5909
|
-
))
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
6239
|
+
))));
|
|
6240
|
+
};
|
|
6241
|
+
|
|
6242
|
+
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6243
|
+
var import_react61 = __toESM(require("react"));
|
|
6244
|
+
|
|
6245
|
+
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
6246
|
+
var import_react59 = __toESM(require("react"));
|
|
6247
|
+
var import_classnames27 = __toESM(require("classnames"));
|
|
6248
|
+
var SkeletonLoader = ({
|
|
6249
|
+
height,
|
|
6250
|
+
width,
|
|
6251
|
+
className
|
|
6252
|
+
}) => {
|
|
6253
|
+
const baseClassName = (0, import_classnames27.default)(
|
|
6254
|
+
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
6255
|
+
className
|
|
6256
|
+
);
|
|
6257
|
+
return /* @__PURE__ */ import_react59.default.createElement("div", { className: baseClassName, style: { width, height } });
|
|
6258
|
+
};
|
|
6259
|
+
|
|
6260
|
+
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
6261
|
+
var import_react60 = __toESM(require("react"));
|
|
6262
|
+
var import_recharts3 = require("recharts");
|
|
6263
|
+
var MiniChart = ({ data }) => {
|
|
6264
|
+
return /* @__PURE__ */ import_react60.default.createElement(import_recharts3.PieChart, { width: 48, height: 48, className: "mini-chart" }, /* @__PURE__ */ import_react60.default.createElement(
|
|
6265
|
+
import_recharts3.Pie,
|
|
5918
6266
|
{
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
6267
|
+
data,
|
|
6268
|
+
dataKey: "value",
|
|
6269
|
+
nameKey: "name",
|
|
6270
|
+
cx: "50%",
|
|
6271
|
+
cy: "50%",
|
|
6272
|
+
innerRadius: 10,
|
|
6273
|
+
outerRadius: 16,
|
|
6274
|
+
paddingAngle: 0.2,
|
|
6275
|
+
fill: "#8884d8",
|
|
6276
|
+
width: 24,
|
|
6277
|
+
height: 24,
|
|
6278
|
+
animationDuration: 250,
|
|
6279
|
+
animationEasing: "ease-in-out"
|
|
6280
|
+
},
|
|
6281
|
+
data.map((entry, index) => {
|
|
6282
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
6283
|
+
return /* @__PURE__ */ import_react60.default.createElement(
|
|
6284
|
+
import_recharts3.Cell,
|
|
6285
|
+
{
|
|
6286
|
+
key: `cell-${index}`,
|
|
6287
|
+
className: `Layer__profit-and-loss-detailed-charts__pie`,
|
|
6288
|
+
fill: entry.name === "placeholder" ? "#e6e6e6" : colorConfig.color,
|
|
6289
|
+
opacity: colorConfig.opacity
|
|
6290
|
+
}
|
|
6291
|
+
);
|
|
6292
|
+
})
|
|
6293
|
+
));
|
|
5924
6294
|
};
|
|
5925
6295
|
|
|
5926
|
-
// src/components/
|
|
5927
|
-
var
|
|
5928
|
-
var
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
dateRange: {
|
|
5936
|
-
startDate: (0, import_date_fns13.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
5937
|
-
endDate: (0, import_date_fns13.endOfMonth)(/* @__PURE__ */ new Date())
|
|
5938
|
-
},
|
|
5939
|
-
changeDateRange: () => {
|
|
5940
|
-
},
|
|
5941
|
-
refetch: () => {
|
|
5942
|
-
},
|
|
5943
|
-
sidebarScope: void 0,
|
|
5944
|
-
setSidebarScope: () => {
|
|
5945
|
-
},
|
|
5946
|
-
sortBy: () => {
|
|
5947
|
-
},
|
|
5948
|
-
setFilterTypes: () => {
|
|
5949
|
-
},
|
|
5950
|
-
filters: {
|
|
5951
|
-
expenses: void 0,
|
|
5952
|
-
revenue: void 0
|
|
6296
|
+
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6297
|
+
var import_classnames28 = __toESM(require("classnames"));
|
|
6298
|
+
var CHART_PLACEHOLDER = [
|
|
6299
|
+
{
|
|
6300
|
+
name: "placeholder",
|
|
6301
|
+
display_name: "placeholder",
|
|
6302
|
+
value: 1,
|
|
6303
|
+
type: "placeholder",
|
|
6304
|
+
share: 1
|
|
5953
6305
|
}
|
|
5954
|
-
|
|
5955
|
-
var
|
|
5956
|
-
|
|
5957
|
-
|
|
6306
|
+
];
|
|
6307
|
+
var buildMiniChartData = (scope, data) => {
|
|
6308
|
+
if (!data) {
|
|
6309
|
+
return CHART_PLACEHOLDER;
|
|
6310
|
+
}
|
|
6311
|
+
let items = [];
|
|
6312
|
+
switch (scope) {
|
|
6313
|
+
case "revenue":
|
|
6314
|
+
items = collectRevenueItems(data);
|
|
6315
|
+
break;
|
|
6316
|
+
default:
|
|
6317
|
+
items = collectExpensesItems(data);
|
|
6318
|
+
}
|
|
6319
|
+
if (!items || items.length === 0 || !items.find((x) => Math.abs(x.value) !== 0)) {
|
|
6320
|
+
return CHART_PLACEHOLDER;
|
|
6321
|
+
}
|
|
6322
|
+
return items.slice();
|
|
6323
|
+
};
|
|
6324
|
+
var ProfitAndLossSummaries = ({
|
|
6325
|
+
vertical,
|
|
6326
|
+
revenueLabel = "Revenue",
|
|
6327
|
+
actionable = true
|
|
6328
|
+
}) => {
|
|
6329
|
+
const {
|
|
6330
|
+
data: storedData,
|
|
6331
|
+
isLoading,
|
|
6332
|
+
setSidebarScope,
|
|
6333
|
+
sidebarScope
|
|
6334
|
+
} = (0, import_react61.useContext)(ProfitAndLoss.Context);
|
|
6335
|
+
const expensesChartData = (0, import_react61.useMemo)(() => {
|
|
6336
|
+
return buildMiniChartData("expenses", storedData);
|
|
6337
|
+
}, [storedData]);
|
|
6338
|
+
const revenueChartData = (0, import_react61.useMemo)(() => {
|
|
6339
|
+
return buildMiniChartData("revenue", storedData);
|
|
6340
|
+
}, [storedData]);
|
|
6341
|
+
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
6342
|
+
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6343
|
+
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6344
|
+
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6345
|
+
return /* @__PURE__ */ import_react61.default.createElement(
|
|
6346
|
+
"div",
|
|
6347
|
+
{
|
|
6348
|
+
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
6349
|
+
},
|
|
6350
|
+
/* @__PURE__ */ import_react61.default.createElement(
|
|
6351
|
+
"div",
|
|
6352
|
+
{
|
|
6353
|
+
className: (0, import_classnames28.default)(
|
|
6354
|
+
"Layer__profit-and-loss-summaries__summary",
|
|
6355
|
+
actionable && "Layer__actionable",
|
|
6356
|
+
"Layer__profit-and-loss-summaries__summary--income",
|
|
6357
|
+
sidebarScope === "revenue" ? "active" : ""
|
|
6358
|
+
),
|
|
6359
|
+
onClick: () => {
|
|
6360
|
+
actionable && setSidebarScope("revenue");
|
|
6361
|
+
}
|
|
6362
|
+
},
|
|
6363
|
+
/* @__PURE__ */ import_react61.default.createElement(MiniChart, { data: revenueChartData }),
|
|
6364
|
+
/* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react61.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react61.default.createElement(SkeletonLoader, null)) : /* @__PURE__ */ import_react61.default.createElement(
|
|
6365
|
+
"span",
|
|
6366
|
+
{
|
|
6367
|
+
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
6368
|
+
},
|
|
6369
|
+
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
6370
|
+
))
|
|
6371
|
+
),
|
|
6372
|
+
/* @__PURE__ */ import_react61.default.createElement(
|
|
6373
|
+
"div",
|
|
6374
|
+
{
|
|
6375
|
+
className: (0, import_classnames28.default)(
|
|
6376
|
+
"Layer__profit-and-loss-summaries__summary",
|
|
6377
|
+
actionable && "Layer__actionable",
|
|
6378
|
+
"Layer__profit-and-loss-summaries__summary--expenses",
|
|
6379
|
+
sidebarScope === "expenses" ? "active" : ""
|
|
6380
|
+
),
|
|
6381
|
+
onClick: () => {
|
|
6382
|
+
actionable && setSidebarScope("expenses");
|
|
6383
|
+
}
|
|
6384
|
+
},
|
|
6385
|
+
/* @__PURE__ */ import_react61.default.createElement(MiniChart, { data: expensesChartData }),
|
|
6386
|
+
/* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react61.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react61.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react61.default.createElement(
|
|
6387
|
+
"span",
|
|
6388
|
+
{
|
|
6389
|
+
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
6390
|
+
},
|
|
6391
|
+
centsToDollars(
|
|
6392
|
+
Math.abs((data.income.value ?? 0) - data.net_profit)
|
|
6393
|
+
)
|
|
6394
|
+
))
|
|
6395
|
+
),
|
|
6396
|
+
/* @__PURE__ */ import_react61.default.createElement(
|
|
6397
|
+
"div",
|
|
6398
|
+
{
|
|
6399
|
+
className: (0, import_classnames28.default)(
|
|
6400
|
+
"Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
|
|
6401
|
+
actionable && "Layer__actionable"
|
|
6402
|
+
)
|
|
6403
|
+
},
|
|
6404
|
+
/* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react61.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react61.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react61.default.createElement(
|
|
6405
|
+
"span",
|
|
6406
|
+
{
|
|
6407
|
+
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
6408
|
+
},
|
|
6409
|
+
centsToDollars(Math.abs(data.net_profit))
|
|
6410
|
+
))
|
|
6411
|
+
)
|
|
6412
|
+
);
|
|
5958
6413
|
};
|
|
5959
|
-
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
5960
|
-
ProfitAndLoss.Context = PNLContext;
|
|
5961
|
-
ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
|
|
5962
|
-
ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
5963
|
-
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
5964
|
-
|
|
5965
|
-
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
5966
|
-
var import_react64 = __toESM(require("react"));
|
|
5967
6414
|
|
|
5968
|
-
// src/components/
|
|
6415
|
+
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
5969
6416
|
var import_react63 = __toESM(require("react"));
|
|
5970
6417
|
|
|
5971
|
-
// src/
|
|
5972
|
-
var
|
|
5973
|
-
|
|
6418
|
+
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
6419
|
+
var import_react62 = __toESM(require("react"));
|
|
6420
|
+
|
|
6421
|
+
// src/icons/PieChart.tsx
|
|
6422
|
+
var React77 = __toESM(require("react"));
|
|
6423
|
+
var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React77.createElement(
|
|
5974
6424
|
"svg",
|
|
5975
6425
|
{
|
|
5976
6426
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5977
|
-
viewBox: "0 0
|
|
6427
|
+
viewBox: "0 0 12 12",
|
|
5978
6428
|
fill: "none",
|
|
5979
6429
|
...props,
|
|
5980
6430
|
width: size,
|
|
5981
6431
|
height: size
|
|
5982
6432
|
},
|
|
5983
|
-
/* @__PURE__ */
|
|
6433
|
+
/* @__PURE__ */ React77.createElement("g", null, /* @__PURE__ */ React77.createElement(
|
|
5984
6434
|
"path",
|
|
5985
6435
|
{
|
|
5986
|
-
d: "
|
|
6436
|
+
d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
|
|
5987
6437
|
stroke: "currentColor",
|
|
5988
6438
|
strokeLinecap: "round",
|
|
5989
6439
|
strokeLinejoin: "round"
|
|
5990
6440
|
}
|
|
5991
|
-
),
|
|
5992
|
-
/* @__PURE__ */ React75.createElement(
|
|
6441
|
+
), /* @__PURE__ */ React77.createElement(
|
|
5993
6442
|
"path",
|
|
5994
6443
|
{
|
|
5995
|
-
d: "
|
|
6444
|
+
d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
|
|
5996
6445
|
stroke: "currentColor",
|
|
5997
6446
|
strokeLinecap: "round",
|
|
5998
6447
|
strokeLinejoin: "round"
|
|
5999
6448
|
}
|
|
6000
|
-
)
|
|
6449
|
+
))
|
|
6001
6450
|
);
|
|
6002
|
-
var
|
|
6451
|
+
var PieChart_default = PieChart3;
|
|
6003
6452
|
|
|
6004
|
-
// src/components/
|
|
6005
|
-
var
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6453
|
+
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
6454
|
+
var ProfitAndLossRow = ({
|
|
6455
|
+
variant,
|
|
6456
|
+
lineItem,
|
|
6457
|
+
depth = 0,
|
|
6458
|
+
maxDepth = 1,
|
|
6459
|
+
direction = "DEBIT" /* DEBIT */,
|
|
6460
|
+
lockExpanded = false,
|
|
6461
|
+
scope,
|
|
6462
|
+
setSidebarScope
|
|
6014
6463
|
}) => {
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
}
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
import_recharts3.Cell,
|
|
6059
|
-
{
|
|
6060
|
-
key: `cell-${index}`,
|
|
6061
|
-
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
6062
|
-
style: { fill },
|
|
6063
|
-
opacity,
|
|
6064
|
-
onMouseEnter: () => setHoveredItem(entry.name),
|
|
6065
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
6066
|
-
}
|
|
6067
|
-
);
|
|
6068
|
-
}),
|
|
6069
|
-
/* @__PURE__ */ import_react60.default.createElement(
|
|
6070
|
-
import_recharts3.Label,
|
|
6464
|
+
if (!lineItem) {
|
|
6465
|
+
return null;
|
|
6466
|
+
}
|
|
6467
|
+
const { value, display_name, line_items } = lineItem;
|
|
6468
|
+
const [expanded, setExpanded] = (0, import_react62.useState)(true);
|
|
6469
|
+
const amount = value ?? 0;
|
|
6470
|
+
const amountString = centsToDollars(Math.abs(amount));
|
|
6471
|
+
const labelClasses = [
|
|
6472
|
+
"Layer__profit-and-loss-row",
|
|
6473
|
+
"Layer__profit-and-loss-row__label"
|
|
6474
|
+
];
|
|
6475
|
+
const valueClasses = [
|
|
6476
|
+
"Layer__profit-and-loss-row",
|
|
6477
|
+
"Layer__profit-and-loss-row__value"
|
|
6478
|
+
];
|
|
6479
|
+
const positive = amount === 0 || direction === "CREDIT" /* CREDIT */ && amount > 0 || direction === "DEBIT" /* DEBIT */ && amount < 0;
|
|
6480
|
+
valueClasses.push(
|
|
6481
|
+
positive ? "Layer__profit-and-loss-row__value--amount-positive" : "Layer__profit-and-loss-row__value--amount-negative"
|
|
6482
|
+
);
|
|
6483
|
+
labelClasses.push(`Layer__profit-and-loss-row__label--depth-${depth}`);
|
|
6484
|
+
valueClasses.push(`Layer__profit-and-loss-row__value--depth-${depth}`);
|
|
6485
|
+
variant && labelClasses.push(`Layer__profit-and-loss-row__label--variant-${variant}`);
|
|
6486
|
+
variant && valueClasses.push(`Layer__profit-and-loss-row__value--variant-${variant}`);
|
|
6487
|
+
const toggleExpanded = () => setExpanded(!expanded);
|
|
6488
|
+
const canGoDeeper = depth < maxDepth;
|
|
6489
|
+
const hasChildren = (line_items?.length ?? 0) > 0;
|
|
6490
|
+
const displayChildren = hasChildren && canGoDeeper;
|
|
6491
|
+
labelClasses.push(
|
|
6492
|
+
`Layer__profit-and-loss-row__label--display-children-${displayChildren}`
|
|
6493
|
+
);
|
|
6494
|
+
valueClasses.push(
|
|
6495
|
+
`Layer__profit-and-loss-row__value--display-children-${displayChildren}`
|
|
6496
|
+
);
|
|
6497
|
+
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
6498
|
+
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
6499
|
+
return /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, /* @__PURE__ */ import_react62.default.createElement(
|
|
6500
|
+
"div",
|
|
6501
|
+
{
|
|
6502
|
+
className: labelClasses.join(" "),
|
|
6503
|
+
onClick: () => !lockExpanded && toggleExpanded()
|
|
6504
|
+
},
|
|
6505
|
+
/* @__PURE__ */ import_react62.default.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ import_react62.default.createElement(
|
|
6506
|
+
ChevronDownFill_default,
|
|
6071
6507
|
{
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
className: "pie-center-label-title",
|
|
6075
|
-
content: (props) => {
|
|
6076
|
-
const { cx, cy } = props.viewBox ?? {
|
|
6077
|
-
cx: 0,
|
|
6078
|
-
cy: 0
|
|
6079
|
-
};
|
|
6080
|
-
const positioningProps = {
|
|
6081
|
-
x: cx,
|
|
6082
|
-
y: (cy || 0) - 15,
|
|
6083
|
-
textAnchor: "middle",
|
|
6084
|
-
verticalAnchor: "middle"
|
|
6085
|
-
};
|
|
6086
|
-
let text = "Total";
|
|
6087
|
-
if (hoveredItem) {
|
|
6088
|
-
text = hoveredItem;
|
|
6089
|
-
}
|
|
6090
|
-
return /* @__PURE__ */ import_react60.default.createElement(
|
|
6091
|
-
import_recharts3.Text,
|
|
6092
|
-
{
|
|
6093
|
-
...positioningProps,
|
|
6094
|
-
className: "pie-center-label__title"
|
|
6095
|
-
},
|
|
6096
|
-
text
|
|
6097
|
-
);
|
|
6098
|
-
}
|
|
6508
|
+
size: 16,
|
|
6509
|
+
className: "Layer__profit-and-loss-row__label__chevron"
|
|
6099
6510
|
}
|
|
6100
|
-
),
|
|
6101
|
-
/* @__PURE__ */
|
|
6102
|
-
|
|
6511
|
+
) : null, /* @__PURE__ */ import_react62.default.createElement(Text, null, display_name)),
|
|
6512
|
+
setSidebarScope && /* @__PURE__ */ import_react62.default.createElement(
|
|
6513
|
+
"span",
|
|
6103
6514
|
{
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
const { cx, cy } = props.viewBox ?? {
|
|
6109
|
-
cx: 0,
|
|
6110
|
-
cy: 0
|
|
6111
|
-
};
|
|
6112
|
-
const positioningProps = {
|
|
6113
|
-
x: cx,
|
|
6114
|
-
y: (cy || 0) + 5,
|
|
6115
|
-
textAnchor: "middle",
|
|
6116
|
-
verticalAnchor: "middle"
|
|
6117
|
-
};
|
|
6118
|
-
let value = filteredTotal;
|
|
6119
|
-
if (hoveredItem) {
|
|
6120
|
-
value = filteredData.find(
|
|
6121
|
-
(x) => x.display_name === hoveredItem
|
|
6122
|
-
)?.value;
|
|
6123
|
-
}
|
|
6124
|
-
return /* @__PURE__ */ import_react60.default.createElement(
|
|
6125
|
-
import_recharts3.Text,
|
|
6126
|
-
{
|
|
6127
|
-
...positioningProps,
|
|
6128
|
-
className: "pie-center-label__value"
|
|
6129
|
-
},
|
|
6130
|
-
`$${centsToDollars(value)}`
|
|
6131
|
-
);
|
|
6515
|
+
className: "Layer__profit-and-loss-row__detailed-chart-btn",
|
|
6516
|
+
onClick: (e) => {
|
|
6517
|
+
e.stopPropagation();
|
|
6518
|
+
setSidebarScope && setSidebarScope(scope ?? "expenses");
|
|
6132
6519
|
}
|
|
6133
|
-
}
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6520
|
+
},
|
|
6521
|
+
/* @__PURE__ */ import_react62.default.createElement(PieChart_default, null)
|
|
6522
|
+
)
|
|
6523
|
+
), /* @__PURE__ */ import_react62.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react62.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react62.default.createElement(
|
|
6524
|
+
"div",
|
|
6525
|
+
{
|
|
6526
|
+
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
6527
|
+
},
|
|
6528
|
+
/* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react62.default.createElement(
|
|
6529
|
+
ProfitAndLossRow,
|
|
6137
6530
|
{
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
cx: 0,
|
|
6144
|
-
cy: 0
|
|
6145
|
-
};
|
|
6146
|
-
const positioningProps = {
|
|
6147
|
-
x: cx,
|
|
6148
|
-
y: (cy || 0) + 25,
|
|
6149
|
-
height: 20,
|
|
6150
|
-
textAnchor: "middle",
|
|
6151
|
-
verticalAnchor: "middle"
|
|
6152
|
-
};
|
|
6153
|
-
if (hoveredItem) {
|
|
6154
|
-
return /* @__PURE__ */ import_react60.default.createElement(
|
|
6155
|
-
import_recharts3.Text,
|
|
6156
|
-
{
|
|
6157
|
-
...positioningProps,
|
|
6158
|
-
className: "pie-center-label__share"
|
|
6159
|
-
},
|
|
6160
|
-
`${formatPercent(
|
|
6161
|
-
filteredData.find((x) => x.display_name === hoveredItem)?.share
|
|
6162
|
-
)}%`
|
|
6163
|
-
);
|
|
6164
|
-
}
|
|
6165
|
-
return;
|
|
6166
|
-
}
|
|
6531
|
+
key: line_item.display_name,
|
|
6532
|
+
lineItem: line_item,
|
|
6533
|
+
depth: depth + 1,
|
|
6534
|
+
maxDepth,
|
|
6535
|
+
direction
|
|
6167
6536
|
}
|
|
6168
|
-
)
|
|
6169
|
-
))
|
|
6537
|
+
)))
|
|
6538
|
+
));
|
|
6170
6539
|
};
|
|
6171
6540
|
|
|
6172
|
-
// src/components/
|
|
6173
|
-
var
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
...props,
|
|
6184
|
-
width: size,
|
|
6185
|
-
height: size
|
|
6541
|
+
// src/components/ProfitAndLossTable/empty_profit_and_loss_report.ts
|
|
6542
|
+
var empty_profit_and_loss_report_default = {
|
|
6543
|
+
type: "Profit_And_Loss",
|
|
6544
|
+
business_id: "",
|
|
6545
|
+
start_date: "",
|
|
6546
|
+
end_date: "",
|
|
6547
|
+
income: {
|
|
6548
|
+
name: "INCOME",
|
|
6549
|
+
display_name: "Income",
|
|
6550
|
+
value: NaN,
|
|
6551
|
+
line_items: null
|
|
6186
6552
|
},
|
|
6187
|
-
|
|
6188
|
-
"
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
"
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
}
|
|
6223
|
-
)),
|
|
6224
|
-
/* @__PURE__ */ React77.createElement("defs", null, /* @__PURE__ */ React77.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React77.createElement(
|
|
6225
|
-
"rect",
|
|
6226
|
-
{
|
|
6227
|
-
width: "12",
|
|
6228
|
-
height: "12",
|
|
6229
|
-
fill: "white",
|
|
6230
|
-
transform: "translate(0 0.5)"
|
|
6231
|
-
}
|
|
6232
|
-
)))
|
|
6233
|
-
);
|
|
6234
|
-
var SortArrows_default = SortArrows;
|
|
6553
|
+
cost_of_goods_sold: {
|
|
6554
|
+
display_name: "Cost of Goods Sold",
|
|
6555
|
+
name: "COGS",
|
|
6556
|
+
value: NaN,
|
|
6557
|
+
line_items: null
|
|
6558
|
+
},
|
|
6559
|
+
gross_profit: NaN,
|
|
6560
|
+
expenses: {
|
|
6561
|
+
name: "EXPENSES",
|
|
6562
|
+
display_name: "Expenses",
|
|
6563
|
+
value: NaN,
|
|
6564
|
+
line_items: null
|
|
6565
|
+
},
|
|
6566
|
+
profit_before_taxes: NaN,
|
|
6567
|
+
taxes: {
|
|
6568
|
+
name: "TAXES",
|
|
6569
|
+
display_name: "Taxes",
|
|
6570
|
+
value: NaN,
|
|
6571
|
+
line_items: null
|
|
6572
|
+
},
|
|
6573
|
+
net_profit: NaN,
|
|
6574
|
+
other_outflows: {
|
|
6575
|
+
name: "OTHER_OUTFLOWS",
|
|
6576
|
+
display_name: "Other outflows",
|
|
6577
|
+
value: NaN,
|
|
6578
|
+
line_items: null
|
|
6579
|
+
},
|
|
6580
|
+
personal_expenses: {
|
|
6581
|
+
name: "PERSONAL",
|
|
6582
|
+
display_name: "Personal expenses",
|
|
6583
|
+
value: NaN,
|
|
6584
|
+
line_items: null
|
|
6585
|
+
},
|
|
6586
|
+
fully_categorized: false
|
|
6587
|
+
};
|
|
6235
6588
|
|
|
6236
|
-
// src/components/
|
|
6237
|
-
var
|
|
6238
|
-
var
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
"Layer__sortable-col",
|
|
6249
|
-
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
6250
|
-
);
|
|
6251
|
-
};
|
|
6252
|
-
return /* @__PURE__ */ import_react61.default.createElement("div", { className: "details-container" }, /* @__PURE__ */ import_react61.default.createElement("div", { className: "table" }, /* @__PURE__ */ import_react61.default.createElement("table", null, /* @__PURE__ */ import_react61.default.createElement("thead", null, /* @__PURE__ */ import_react61.default.createElement("tr", null, /* @__PURE__ */ import_react61.default.createElement(
|
|
6253
|
-
"th",
|
|
6254
|
-
{
|
|
6255
|
-
className: buildColClass("category"),
|
|
6256
|
-
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
6257
|
-
},
|
|
6258
|
-
"Expense/Sale ",
|
|
6259
|
-
/* @__PURE__ */ import_react61.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6260
|
-
), /* @__PURE__ */ import_react61.default.createElement(
|
|
6261
|
-
"th",
|
|
6262
|
-
{
|
|
6263
|
-
className: buildColClass("type"),
|
|
6264
|
-
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
6265
|
-
},
|
|
6266
|
-
"Type ",
|
|
6267
|
-
/* @__PURE__ */ import_react61.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6268
|
-
), /* @__PURE__ */ import_react61.default.createElement("th", null), /* @__PURE__ */ import_react61.default.createElement(
|
|
6269
|
-
"th",
|
|
6270
|
-
{
|
|
6271
|
-
className: buildColClass("value"),
|
|
6272
|
-
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
6273
|
-
},
|
|
6274
|
-
"Value ",
|
|
6275
|
-
/* @__PURE__ */ import_react61.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
6276
|
-
))), /* @__PURE__ */ import_react61.default.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
6277
|
-
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
6278
|
-
return /* @__PURE__ */ import_react61.default.createElement(
|
|
6279
|
-
"tr",
|
|
6589
|
+
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
6590
|
+
var import_classnames29 = __toESM(require("classnames"));
|
|
6591
|
+
var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
6592
|
+
const {
|
|
6593
|
+
data: actualData,
|
|
6594
|
+
isLoading,
|
|
6595
|
+
setSidebarScope
|
|
6596
|
+
} = (0, import_react63.useContext)(ProfitAndLoss.Context);
|
|
6597
|
+
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
6598
|
+
if (isLoading || actualData === void 0) {
|
|
6599
|
+
return /* @__PURE__ */ import_react63.default.createElement(
|
|
6600
|
+
"div",
|
|
6280
6601
|
{
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
"
|
|
6284
|
-
|
|
6285
|
-
),
|
|
6286
|
-
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
6287
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
6602
|
+
className: (0, import_classnames29.default)(
|
|
6603
|
+
"Layer__profit-and-loss-table__loader-container",
|
|
6604
|
+
asContainer && "Layer__component-container"
|
|
6605
|
+
)
|
|
6288
6606
|
},
|
|
6289
|
-
/* @__PURE__ */
|
|
6290
|
-
/* @__PURE__ */ import_react61.default.createElement("td", { className: "type-col" }, item.type),
|
|
6291
|
-
/* @__PURE__ */ import_react61.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
6292
|
-
/* @__PURE__ */ import_react61.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react61.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react61.default.createElement(
|
|
6293
|
-
"div",
|
|
6294
|
-
{
|
|
6295
|
-
className: "share-icon",
|
|
6296
|
-
style: {
|
|
6297
|
-
background: colorConfig.color,
|
|
6298
|
-
opacity: colorConfig.opacity
|
|
6299
|
-
}
|
|
6300
|
-
}
|
|
6301
|
-
)))
|
|
6607
|
+
/* @__PURE__ */ import_react63.default.createElement(Loader2, null)
|
|
6302
6608
|
);
|
|
6303
|
-
}
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
// src/components/ProfitAndLossDetailedCharts/Filters.tsx
|
|
6307
|
-
var import_react62 = __toESM(require("react"));
|
|
6308
|
-
var import_react_select3 = __toESM(require("react-select"));
|
|
6309
|
-
var Filters = ({
|
|
6310
|
-
filteredData,
|
|
6311
|
-
sidebarScope,
|
|
6312
|
-
filters,
|
|
6313
|
-
setFilterTypes
|
|
6314
|
-
}) => {
|
|
6315
|
-
return /* @__PURE__ */ import_react62.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react62.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react62.default.createElement(
|
|
6316
|
-
import_react_select3.default,
|
|
6609
|
+
}
|
|
6610
|
+
return /* @__PURE__ */ import_react63.default.createElement(import_react63.default.Fragment, null, /* @__PURE__ */ import_react63.default.createElement(
|
|
6611
|
+
"div",
|
|
6317
6612
|
{
|
|
6318
|
-
className:
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6613
|
+
className: (0, import_classnames29.default)(
|
|
6614
|
+
"Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
|
|
6615
|
+
asContainer && "Layer__component-container"
|
|
6616
|
+
)
|
|
6617
|
+
},
|
|
6618
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6619
|
+
ProfitAndLossRow,
|
|
6620
|
+
{
|
|
6621
|
+
lineItem: data.income,
|
|
6622
|
+
direction: "CREDIT" /* CREDIT */,
|
|
6623
|
+
lockExpanded,
|
|
6624
|
+
scope: "revenue",
|
|
6625
|
+
setSidebarScope
|
|
6626
|
+
}
|
|
6627
|
+
),
|
|
6628
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6629
|
+
ProfitAndLossRow,
|
|
6630
|
+
{
|
|
6631
|
+
lineItem: data.cost_of_goods_sold,
|
|
6632
|
+
direction: "DEBIT" /* DEBIT */,
|
|
6633
|
+
lockExpanded,
|
|
6634
|
+
scope: "expenses",
|
|
6635
|
+
setSidebarScope
|
|
6636
|
+
}
|
|
6637
|
+
),
|
|
6638
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6639
|
+
ProfitAndLossRow,
|
|
6640
|
+
{
|
|
6641
|
+
lineItem: {
|
|
6642
|
+
value: data.gross_profit,
|
|
6643
|
+
display_name: "Gross Profit"
|
|
6644
|
+
},
|
|
6645
|
+
variant: "summation",
|
|
6646
|
+
direction: "CREDIT" /* CREDIT */,
|
|
6647
|
+
lockExpanded,
|
|
6648
|
+
scope: "revenue",
|
|
6649
|
+
setSidebarScope
|
|
6650
|
+
}
|
|
6651
|
+
),
|
|
6652
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6653
|
+
ProfitAndLossRow,
|
|
6654
|
+
{
|
|
6655
|
+
lineItem: data.expenses,
|
|
6656
|
+
direction: "DEBIT" /* DEBIT */,
|
|
6657
|
+
lockExpanded,
|
|
6658
|
+
scope: "expenses",
|
|
6659
|
+
setSidebarScope
|
|
6660
|
+
}
|
|
6661
|
+
),
|
|
6662
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6663
|
+
ProfitAndLossRow,
|
|
6664
|
+
{
|
|
6665
|
+
lineItem: {
|
|
6666
|
+
value: data.profit_before_taxes,
|
|
6667
|
+
display_name: "Profit Before Taxes"
|
|
6668
|
+
},
|
|
6669
|
+
variant: "summation",
|
|
6670
|
+
direction: "CREDIT" /* CREDIT */,
|
|
6671
|
+
lockExpanded,
|
|
6672
|
+
scope: "revenue",
|
|
6673
|
+
setSidebarScope
|
|
6674
|
+
}
|
|
6675
|
+
),
|
|
6676
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6677
|
+
ProfitAndLossRow,
|
|
6678
|
+
{
|
|
6679
|
+
lineItem: data.taxes,
|
|
6680
|
+
direction: "DEBIT" /* DEBIT */,
|
|
6681
|
+
lockExpanded,
|
|
6682
|
+
scope: "expenses",
|
|
6683
|
+
setSidebarScope
|
|
6684
|
+
}
|
|
6685
|
+
),
|
|
6686
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6687
|
+
ProfitAndLossRow,
|
|
6688
|
+
{
|
|
6689
|
+
lineItem: {
|
|
6690
|
+
value: data.net_profit,
|
|
6691
|
+
display_name: "Net Profit"
|
|
6692
|
+
},
|
|
6693
|
+
variant: "summation",
|
|
6694
|
+
direction: "CREDIT" /* CREDIT */,
|
|
6695
|
+
lockExpanded
|
|
6339
6696
|
}
|
|
6697
|
+
)
|
|
6698
|
+
), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react63.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react63.default.createElement(
|
|
6699
|
+
ProfitAndLossRow,
|
|
6700
|
+
{
|
|
6701
|
+
lineItem: data.other_outflows,
|
|
6702
|
+
direction: "DEBIT" /* DEBIT */,
|
|
6703
|
+
lockExpanded
|
|
6340
6704
|
}
|
|
6341
|
-
)
|
|
6705
|
+
), /* @__PURE__ */ import_react63.default.createElement(
|
|
6706
|
+
ProfitAndLossRow,
|
|
6707
|
+
{
|
|
6708
|
+
lineItem: data.personal_expenses,
|
|
6709
|
+
direction: "DEBIT" /* DEBIT */,
|
|
6710
|
+
lockExpanded
|
|
6711
|
+
}
|
|
6712
|
+
)) : null);
|
|
6342
6713
|
};
|
|
6343
6714
|
|
|
6344
|
-
// src/components/
|
|
6345
|
-
var import_classnames29 = __toESM(require("classnames"));
|
|
6715
|
+
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
6346
6716
|
var import_date_fns14 = require("date-fns");
|
|
6347
|
-
var
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6717
|
+
var PNLContext = (0, import_react64.createContext)({
|
|
6718
|
+
data: void 0,
|
|
6719
|
+
filteredDataRevenue: [],
|
|
6720
|
+
filteredTotalRevenue: void 0,
|
|
6721
|
+
filteredDataExpenses: [],
|
|
6722
|
+
filteredTotalExpenses: void 0,
|
|
6723
|
+
isLoading: true,
|
|
6724
|
+
isValidating: false,
|
|
6725
|
+
error: void 0,
|
|
6726
|
+
dateRange: {
|
|
6727
|
+
startDate: (0, import_date_fns14.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
6728
|
+
endDate: (0, import_date_fns14.endOfMonth)(/* @__PURE__ */ new Date())
|
|
6729
|
+
},
|
|
6730
|
+
changeDateRange: () => {
|
|
6731
|
+
},
|
|
6732
|
+
refetch: () => {
|
|
6733
|
+
},
|
|
6734
|
+
sidebarScope: void 0,
|
|
6735
|
+
setSidebarScope: () => {
|
|
6736
|
+
},
|
|
6737
|
+
sortBy: () => {
|
|
6738
|
+
},
|
|
6739
|
+
setFilterTypes: () => {
|
|
6740
|
+
},
|
|
6741
|
+
filters: {
|
|
6742
|
+
expenses: void 0,
|
|
6743
|
+
revenue: void 0
|
|
6744
|
+
}
|
|
6745
|
+
});
|
|
6746
|
+
var ProfitAndLoss = ({
|
|
6747
|
+
children,
|
|
6748
|
+
tagFilter,
|
|
6749
|
+
reportingBasis,
|
|
6750
|
+
asContainer = true
|
|
6751
|
+
}) => {
|
|
6752
|
+
const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
|
|
6753
|
+
return /* @__PURE__ */ import_react64.default.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ import_react64.default.createElement(Container, { name: "profit-and-loss" }, children) : children);
|
|
6754
|
+
};
|
|
6755
|
+
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
6756
|
+
ProfitAndLoss.Context = PNLContext;
|
|
6757
|
+
ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
|
|
6758
|
+
ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
6759
|
+
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
6760
|
+
ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
|
|
6761
|
+
|
|
6762
|
+
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
6763
|
+
var import_react66 = __toESM(require("react"));
|
|
6764
|
+
|
|
6765
|
+
// src/components/Panel/Panel.tsx
|
|
6766
|
+
var import_react65 = __toESM(require("react"));
|
|
6767
|
+
var import_classnames30 = __toESM(require("classnames"));
|
|
6768
|
+
var Panel = ({
|
|
6769
|
+
children,
|
|
6770
|
+
className,
|
|
6771
|
+
sidebar,
|
|
6772
|
+
header,
|
|
6773
|
+
sidebarIsOpen,
|
|
6774
|
+
parentRef
|
|
6775
|
+
}) => {
|
|
6776
|
+
const [sidebarHeight, setSidebarHeight] = (0, import_react65.useState)(0);
|
|
6777
|
+
(0, import_react65.useEffect)(() => {
|
|
6778
|
+
if (parentRef?.current?.offsetHeight) {
|
|
6779
|
+
setSidebarHeight(parentRef?.current?.offsetHeight - 1);
|
|
6780
|
+
}
|
|
6781
|
+
}, [parentRef?.current?.offsetHeight, sidebarIsOpen]);
|
|
6782
|
+
return /* @__PURE__ */ import_react65.default.createElement(
|
|
6361
6783
|
"div",
|
|
6362
6784
|
{
|
|
6363
|
-
className: (0,
|
|
6364
|
-
"
|
|
6365
|
-
|
|
6785
|
+
className: (0, import_classnames30.default)(
|
|
6786
|
+
"Layer__panel",
|
|
6787
|
+
className,
|
|
6788
|
+
sidebarIsOpen && "Layer__panel--open"
|
|
6366
6789
|
)
|
|
6367
6790
|
},
|
|
6368
|
-
/* @__PURE__ */
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
rightIcon: /* @__PURE__ */ import_react63.default.createElement(X_default, null),
|
|
6372
|
-
iconOnly: true,
|
|
6373
|
-
onClick: () => setSidebarScope(void 0),
|
|
6374
|
-
variant: "secondary" /* secondary */
|
|
6375
|
-
}
|
|
6376
|
-
)), /* @__PURE__ */ import_react63.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ import_react63.default.createElement(BackButton, { onClick: () => setSidebarScope(void 0) })), /* @__PURE__ */ import_react63.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react63.default.createElement(
|
|
6377
|
-
DetailedChart,
|
|
6378
|
-
{
|
|
6379
|
-
filteredData,
|
|
6380
|
-
filteredTotal,
|
|
6381
|
-
hoveredItem,
|
|
6382
|
-
setHoveredItem,
|
|
6383
|
-
sidebarScope,
|
|
6384
|
-
date: dateRange.startDate
|
|
6385
|
-
}
|
|
6386
|
-
), /* @__PURE__ */ import_react63.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ import_react63.default.createElement(
|
|
6387
|
-
Filters,
|
|
6388
|
-
{
|
|
6389
|
-
filteredData,
|
|
6390
|
-
sidebarScope,
|
|
6391
|
-
filters,
|
|
6392
|
-
setFilterTypes
|
|
6393
|
-
}
|
|
6394
|
-
), /* @__PURE__ */ import_react63.default.createElement(
|
|
6395
|
-
DetailedTable,
|
|
6791
|
+
/* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__panel__content" }, header, children),
|
|
6792
|
+
sidebar && /* @__PURE__ */ import_react65.default.createElement(
|
|
6793
|
+
"div",
|
|
6396
6794
|
{
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
))))
|
|
6795
|
+
className: "Layer__panel__sidebar",
|
|
6796
|
+
style: {
|
|
6797
|
+
maxHeight: sidebarHeight > 0 && sidebarIsOpen ? sidebarHeight : 0
|
|
6798
|
+
}
|
|
6799
|
+
},
|
|
6800
|
+
/* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__panel__sidebar-content" }, sidebar)
|
|
6801
|
+
)
|
|
6405
6802
|
);
|
|
6406
6803
|
};
|
|
6407
6804
|
|
|
6408
6805
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
6409
6806
|
var COMPONENT_NAME3 = "profit-and-loss";
|
|
6410
6807
|
var ProfitAndLossView = (props) => {
|
|
6411
|
-
|
|
6808
|
+
const containerRef = (0, import_react66.useRef)(null);
|
|
6809
|
+
return /* @__PURE__ */ import_react66.default.createElement(Container, { name: COMPONENT_NAME3, ref: containerRef }, /* @__PURE__ */ import_react66.default.createElement(ProfitAndLoss, null, /* @__PURE__ */ import_react66.default.createElement(ProfitAndLossPanel, { containerRef, ...props })));
|
|
6810
|
+
};
|
|
6811
|
+
var ProfitAndLossPanel = ({
|
|
6812
|
+
containerRef,
|
|
6813
|
+
...props
|
|
6814
|
+
}) => {
|
|
6815
|
+
const { sidebarScope } = (0, import_react66.useContext)(ProfitAndLoss.Context);
|
|
6816
|
+
return /* @__PURE__ */ import_react66.default.createElement(
|
|
6817
|
+
Panel,
|
|
6818
|
+
{
|
|
6819
|
+
sidebar: /* @__PURE__ */ import_react66.default.createElement(ProfitAndLossDetailedCharts, null),
|
|
6820
|
+
sidebarIsOpen: Boolean(sidebarScope),
|
|
6821
|
+
parentRef: containerRef
|
|
6822
|
+
},
|
|
6823
|
+
/* @__PURE__ */ import_react66.default.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ import_react66.default.createElement(Heading, { className: "Layer__profit-and-loss__title" }, "Profit & Loss")),
|
|
6824
|
+
/* @__PURE__ */ import_react66.default.createElement(Components, { ...props })
|
|
6825
|
+
);
|
|
6412
6826
|
};
|
|
6413
6827
|
var Components = ({
|
|
6414
6828
|
hideChart = false,
|
|
6415
6829
|
hideTable = false
|
|
6416
6830
|
}) => {
|
|
6417
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
6831
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react66.useContext)(
|
|
6418
6832
|
ProfitAndLoss.Context
|
|
6419
6833
|
);
|
|
6420
6834
|
if (!isLoading && error) {
|
|
6421
|
-
return /* @__PURE__ */
|
|
6835
|
+
return /* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6422
6836
|
DataState,
|
|
6423
6837
|
{
|
|
6424
6838
|
status: "failed" /* failed */,
|
|
@@ -6429,27 +6843,27 @@ var Components = ({
|
|
|
6429
6843
|
}
|
|
6430
6844
|
));
|
|
6431
6845
|
}
|
|
6432
|
-
return /* @__PURE__ */
|
|
6846
|
+
return /* @__PURE__ */ import_react66.default.createElement(import_react66.default.Fragment, null, !hideChart && /* @__PURE__ */ import_react66.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6433
6847
|
"div",
|
|
6434
6848
|
{
|
|
6435
6849
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
|
|
6436
6850
|
},
|
|
6437
|
-
/* @__PURE__ */
|
|
6438
|
-
/* @__PURE__ */
|
|
6439
|
-
), /* @__PURE__ */
|
|
6851
|
+
/* @__PURE__ */ import_react66.default.createElement(ProfitAndLoss.DatePicker, null),
|
|
6852
|
+
/* @__PURE__ */ import_react66.default.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
6853
|
+
), /* @__PURE__ */ import_react66.default.createElement(
|
|
6440
6854
|
"div",
|
|
6441
6855
|
{
|
|
6442
6856
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
|
|
6443
6857
|
},
|
|
6444
|
-
/* @__PURE__ */
|
|
6445
|
-
)), !hideTable && /* @__PURE__ */
|
|
6858
|
+
/* @__PURE__ */ import_react66.default.createElement(ProfitAndLoss.Chart, null)
|
|
6859
|
+
)), !hideTable && /* @__PURE__ */ import_react66.default.createElement(ProfitAndLoss.Table, null));
|
|
6446
6860
|
};
|
|
6447
6861
|
|
|
6448
|
-
// src/components/
|
|
6449
|
-
var
|
|
6862
|
+
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
6863
|
+
var import_react81 = __toESM(require("react"));
|
|
6450
6864
|
|
|
6451
|
-
// src/hooks/
|
|
6452
|
-
var
|
|
6865
|
+
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
6866
|
+
var import_react67 = require("react");
|
|
6453
6867
|
var import_swr6 = __toESM(require("swr"));
|
|
6454
6868
|
var validate = (formData) => {
|
|
6455
6869
|
const errors = [];
|
|
@@ -6481,15 +6895,14 @@ var validateName = (formData) => {
|
|
|
6481
6895
|
return;
|
|
6482
6896
|
};
|
|
6483
6897
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
6484
|
-
var
|
|
6898
|
+
var useChartOfAccounts = () => {
|
|
6485
6899
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
6486
|
-
const [form, setForm] = (0,
|
|
6487
|
-
const [sendingForm, setSendingForm] = (0,
|
|
6488
|
-
const [apiError, setApiError] = (0,
|
|
6489
|
-
const [showARForAccountId, setShowARForAccountId] = (0, import_react65.useState)();
|
|
6900
|
+
const [form, setForm] = (0, import_react67.useState)();
|
|
6901
|
+
const [sendingForm, setSendingForm] = (0, import_react67.useState)(false);
|
|
6902
|
+
const [apiError, setApiError] = (0, import_react67.useState)(void 0);
|
|
6490
6903
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr6.default)(
|
|
6491
|
-
businessId && auth?.access_token && `
|
|
6492
|
-
Layer.
|
|
6904
|
+
businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
|
|
6905
|
+
Layer.getChartOfAccounts(apiUrl, auth?.access_token, {
|
|
6493
6906
|
params: { businessId }
|
|
6494
6907
|
})
|
|
6495
6908
|
);
|
|
@@ -6547,13 +6960,13 @@ var useLedgerAccounts = () => {
|
|
|
6547
6960
|
return;
|
|
6548
6961
|
}
|
|
6549
6962
|
const data2 = {
|
|
6550
|
-
name: form.data.name
|
|
6963
|
+
name: form.data.name ?? "",
|
|
6551
6964
|
normality: form.data.subType?.value,
|
|
6552
6965
|
parent_id: form.data.parent ? {
|
|
6553
6966
|
type: "AccountId",
|
|
6554
6967
|
id: form.data.parent.value
|
|
6555
6968
|
} : void 0,
|
|
6556
|
-
description: form.data.type?.value.toString()
|
|
6969
|
+
description: form.data.type?.value.toString() ?? ""
|
|
6557
6970
|
};
|
|
6558
6971
|
if (form.action === "new") {
|
|
6559
6972
|
create(data2);
|
|
@@ -6638,112 +7051,67 @@ var useLedgerAccounts = () => {
|
|
|
6638
7051
|
editAccount,
|
|
6639
7052
|
cancelForm,
|
|
6640
7053
|
changeFormData,
|
|
6641
|
-
submitForm
|
|
6642
|
-
showARForAccountId,
|
|
6643
|
-
setShowARForAccountId
|
|
7054
|
+
submitForm
|
|
6644
7055
|
};
|
|
6645
7056
|
};
|
|
6646
7057
|
|
|
6647
|
-
// src/
|
|
6648
|
-
var
|
|
6649
|
-
var
|
|
6650
|
-
var
|
|
6651
|
-
|
|
6652
|
-
const
|
|
6653
|
-
|
|
7058
|
+
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
7059
|
+
var import_react68 = require("react");
|
|
7060
|
+
var import_swr7 = __toESM(require("swr"));
|
|
7061
|
+
var useLedgerAccounts = () => {
|
|
7062
|
+
const { auth, businessId, apiUrl } = useLayerContext();
|
|
7063
|
+
const [accountId, setAccountId] = (0, import_react68.useState)();
|
|
7064
|
+
const [selectedEntryId, setSelectedEntryId] = (0, import_react68.useState)();
|
|
7065
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr7.default)(
|
|
7066
|
+
businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
|
|
7067
|
+
Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
|
|
7068
|
+
params: { businessId, accountId }
|
|
7069
|
+
})
|
|
6654
7070
|
);
|
|
6655
|
-
const
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
7071
|
+
const {
|
|
7072
|
+
data: entryData,
|
|
7073
|
+
mutate: mutateEntryData,
|
|
7074
|
+
isLoading: isLoadingEntry,
|
|
7075
|
+
isValidating: isValdiatingEntry,
|
|
7076
|
+
error: errorEntry
|
|
7077
|
+
} = (0, import_swr7.default)(
|
|
7078
|
+
businessId && selectedEntryId && auth?.access_token && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
|
|
7079
|
+
Layer.getLedgerAccountsEntry(apiUrl, auth?.access_token, {
|
|
7080
|
+
params: { businessId, entryId: selectedEntryId }
|
|
7081
|
+
})
|
|
6663
7082
|
);
|
|
6664
|
-
const
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
"Current balance"
|
|
6686
|
-
), /* @__PURE__ */ import_react66.default.createElement(
|
|
6687
|
-
Text,
|
|
6688
|
-
{
|
|
6689
|
-
weight: "bold" /* bold */,
|
|
6690
|
-
className: "Layer__accounts-receivable__balance-value"
|
|
6691
|
-
},
|
|
6692
|
-
"$",
|
|
6693
|
-
centsToDollars(entry?.balance || 0)
|
|
6694
|
-
))), /* @__PURE__ */ import_react66.default.createElement("table", { className: "Layer__table Layer__accounts-receivable-table" }, /* @__PURE__ */ import_react66.default.createElement("thead", null, /* @__PURE__ */ import_react66.default.createElement("tr", null, /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header" }, "Source"), /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ import_react66.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance"))), /* @__PURE__ */ import_react66.default.createElement("tbody", null, entry?.entries?.map((x) => {
|
|
6695
|
-
return /* @__PURE__ */ import_react66.default.createElement("tr", { key: x.id }, /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, x.createdAt && (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(x.createdAt), DATE_FORMAT))), /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, "#123")), /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, "Invoice")), /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, x.direction, " $X,XXX.XX")), /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, "$X,XXX.XX")), /* @__PURE__ */ import_react66.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react66.default.createElement("span", { className: "Layer__table-cell-content" }, "$X,XXX.XX")));
|
|
6696
|
-
}))));
|
|
7083
|
+
const refetch = () => mutate();
|
|
7084
|
+
const closeSelectedEntry = () => {
|
|
7085
|
+
setSelectedEntryId(void 0);
|
|
7086
|
+
mutateEntryData();
|
|
7087
|
+
};
|
|
7088
|
+
return {
|
|
7089
|
+
data: data?.data,
|
|
7090
|
+
entryData: entryData?.data,
|
|
7091
|
+
isLoading,
|
|
7092
|
+
isLoadingEntry,
|
|
7093
|
+
isValidating,
|
|
7094
|
+
isValdiatingEntry,
|
|
7095
|
+
error,
|
|
7096
|
+
errorEntry,
|
|
7097
|
+
refetch,
|
|
7098
|
+
accountId,
|
|
7099
|
+
setAccountId,
|
|
7100
|
+
selectedEntryId,
|
|
7101
|
+
setSelectedEntryId,
|
|
7102
|
+
closeSelectedEntry
|
|
7103
|
+
};
|
|
6697
7104
|
};
|
|
6698
7105
|
|
|
6699
|
-
// src/components/
|
|
6700
|
-
var
|
|
7106
|
+
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
7107
|
+
var import_react73 = __toESM(require("react"));
|
|
6701
7108
|
|
|
6702
|
-
// src/
|
|
6703
|
-
var
|
|
6704
|
-
var ArrowRightCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React83.createElement(
|
|
6705
|
-
"svg",
|
|
6706
|
-
{
|
|
6707
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
6708
|
-
viewBox: "0 0 18 18",
|
|
6709
|
-
fill: "none",
|
|
6710
|
-
...props,
|
|
6711
|
-
width: size,
|
|
6712
|
-
height: size
|
|
6713
|
-
},
|
|
6714
|
-
/* @__PURE__ */ React83.createElement(
|
|
6715
|
-
"path",
|
|
6716
|
-
{
|
|
6717
|
-
d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
|
|
6718
|
-
stroke: "currentColor",
|
|
6719
|
-
strokeLinecap: "round",
|
|
6720
|
-
strokeLinejoin: "round"
|
|
6721
|
-
}
|
|
6722
|
-
),
|
|
6723
|
-
/* @__PURE__ */ React83.createElement(
|
|
6724
|
-
"path",
|
|
6725
|
-
{
|
|
6726
|
-
d: "M9 12L12 9L9 6",
|
|
6727
|
-
stroke: "currentColor",
|
|
6728
|
-
strokeLinecap: "round",
|
|
6729
|
-
strokeLinejoin: "round"
|
|
6730
|
-
}
|
|
6731
|
-
),
|
|
6732
|
-
/* @__PURE__ */ React83.createElement(
|
|
6733
|
-
"path",
|
|
6734
|
-
{
|
|
6735
|
-
d: "M6 9H12",
|
|
6736
|
-
stroke: "currentColor",
|
|
6737
|
-
strokeLinecap: "round",
|
|
6738
|
-
strokeLinejoin: "round"
|
|
6739
|
-
}
|
|
6740
|
-
)
|
|
6741
|
-
);
|
|
6742
|
-
var ArrowRightCircle_default = ArrowRightCircle;
|
|
7109
|
+
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
7110
|
+
var import_react69 = __toESM(require("react"));
|
|
6743
7111
|
|
|
6744
7112
|
// src/icons/Edit2.tsx
|
|
6745
|
-
var
|
|
6746
|
-
var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
7113
|
+
var React83 = __toESM(require("react"));
|
|
7114
|
+
var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React83.createElement(
|
|
6747
7115
|
"svg",
|
|
6748
7116
|
{
|
|
6749
7117
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6753,7 +7121,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React84.createElement(
|
|
|
6753
7121
|
width: size,
|
|
6754
7122
|
height: size
|
|
6755
7123
|
},
|
|
6756
|
-
/* @__PURE__ */
|
|
7124
|
+
/* @__PURE__ */ React83.createElement(
|
|
6757
7125
|
"path",
|
|
6758
7126
|
{
|
|
6759
7127
|
d: "M12.75 2.25C12.947 2.05301 13.1808 1.89676 13.4382 1.79015C13.6956 1.68355 13.9714 1.62868 14.25 1.62868C14.5286 1.62868 14.8044 1.68355 15.0618 1.79015C15.3192 1.89676 15.553 2.05301 15.75 2.25C15.947 2.44698 16.1032 2.68083 16.2098 2.9382C16.3165 3.19557 16.3713 3.47142 16.3713 3.75C16.3713 4.02857 16.3165 4.30442 16.2098 4.56179C16.1032 4.81916 15.947 5.05302 15.75 5.25L5.625 15.375L1.5 16.5L2.625 12.375L12.75 2.25Z",
|
|
@@ -6765,43 +7133,51 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React84.createElement(
|
|
|
6765
7133
|
);
|
|
6766
7134
|
var Edit2_default = Edit2;
|
|
6767
7135
|
|
|
6768
|
-
// src/components/
|
|
7136
|
+
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
6769
7137
|
var import_classnames31 = __toESM(require("classnames"));
|
|
6770
|
-
var INDENTATION =
|
|
7138
|
+
var INDENTATION = 24;
|
|
7139
|
+
var MOBILE_INDENTATION = 12;
|
|
6771
7140
|
var EXPANDED_STYLE = {
|
|
6772
7141
|
height: 52,
|
|
6773
7142
|
paddingTop: 12,
|
|
6774
7143
|
paddingBottom: 12,
|
|
6775
7144
|
opacity: 1
|
|
6776
7145
|
};
|
|
7146
|
+
var EXPANDED_MOBILE_STYLE = {
|
|
7147
|
+
height: 76,
|
|
7148
|
+
paddingTop: 12,
|
|
7149
|
+
paddingBottom: 12,
|
|
7150
|
+
opacity: 1
|
|
7151
|
+
};
|
|
6777
7152
|
var COLLAPSED_STYLE = {
|
|
6778
7153
|
height: 0,
|
|
6779
7154
|
paddingTop: 0,
|
|
6780
7155
|
paddingBottom: 0,
|
|
6781
7156
|
opacity: 0.5
|
|
6782
7157
|
};
|
|
6783
|
-
var
|
|
7158
|
+
var ChartOfAccountsRow = ({
|
|
6784
7159
|
account,
|
|
6785
7160
|
depth = 0,
|
|
6786
7161
|
index,
|
|
6787
7162
|
cumulativeIndex = 0,
|
|
6788
7163
|
expanded = false,
|
|
6789
7164
|
defaultOpen = false,
|
|
6790
|
-
acountsLength
|
|
7165
|
+
acountsLength,
|
|
7166
|
+
view
|
|
6791
7167
|
}) => {
|
|
6792
|
-
const { form, editAccount
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
const [isOpen, setIsOpen] = (0,
|
|
7168
|
+
const { form, editAccount } = (0, import_react69.useContext)(ChartOfAccountsContext);
|
|
7169
|
+
const { setAccountId } = (0, import_react69.useContext)(LedgerAccountsContext);
|
|
7170
|
+
const baseStyle = view === "desktop" ? EXPANDED_STYLE : EXPANDED_MOBILE_STYLE;
|
|
7171
|
+
const [isOpen, setIsOpen] = (0, import_react69.useState)(defaultOpen);
|
|
6796
7172
|
const style = expanded ? {
|
|
6797
|
-
...
|
|
7173
|
+
...baseStyle,
|
|
6798
7174
|
transitionDelay: `${15 * index}ms`
|
|
6799
7175
|
} : {
|
|
6800
7176
|
...COLLAPSED_STYLE,
|
|
6801
7177
|
transitionDelay: `${acountsLength - 15 * index}ms`
|
|
6802
7178
|
};
|
|
6803
|
-
const [showComponent, setShowComponent] = (0,
|
|
6804
|
-
(0,
|
|
7179
|
+
const [showComponent, setShowComponent] = (0, import_react69.useState)(false);
|
|
7180
|
+
(0, import_react69.useEffect)(() => {
|
|
6805
7181
|
const timeoutId = setTimeout(() => {
|
|
6806
7182
|
setShowComponent(true);
|
|
6807
7183
|
}, cumulativeIndex * 50);
|
|
@@ -6815,56 +7191,151 @@ var LedgerAccountsRow = ({
|
|
|
6815
7191
|
form?.accountId === account.id && "Layer__table-row--active",
|
|
6816
7192
|
!showComponent && "Layer__table-row--anim-starting-state"
|
|
6817
7193
|
);
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
{
|
|
6829
|
-
size: 16,
|
|
6830
|
-
className: "Layer__table__expand-icon"
|
|
6831
|
-
}
|
|
6832
|
-
),
|
|
6833
|
-
/* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__coa__name__text" }, account.name)
|
|
6834
|
-
))), /* @__PURE__ */ import_react67.default.createElement("td", { className: "Layer__table-cell Layer__coa__type" }, /* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content", style }, account.normality)), /* @__PURE__ */ import_react67.default.createElement("td", { className: "Layer__table-cell Layer__coa__subtype" }, /* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content", style }, "Sub-Type")), /* @__PURE__ */ import_react67.default.createElement("td", { className: "Layer__table-cell Layer__coa__balance" }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6835
|
-
"span",
|
|
6836
|
-
{
|
|
6837
|
-
className: "Layer__table-cell-content Layer__table-cell--amount",
|
|
6838
|
-
style
|
|
6839
|
-
},
|
|
6840
|
-
"$",
|
|
6841
|
-
centsToDollars(Math.abs(account.balance || 0))
|
|
6842
|
-
)), /* @__PURE__ */ import_react67.default.createElement("td", { className: "Layer__table-cell Layer__coa__actions" }, /* @__PURE__ */ import_react67.default.createElement("span", { className: "Layer__table-cell-content", style }, /* @__PURE__ */ import_react67.default.createElement(
|
|
6843
|
-
Button,
|
|
7194
|
+
const desktopRowClass = (0, import_classnames31.default)(
|
|
7195
|
+
baseClass,
|
|
7196
|
+
"Layer__chart-of-accounts__row---desktop"
|
|
7197
|
+
);
|
|
7198
|
+
const mobileRowClass = (0, import_classnames31.default)(
|
|
7199
|
+
baseClass,
|
|
7200
|
+
"Layer__chart-of-accounts__row---mobile"
|
|
7201
|
+
);
|
|
7202
|
+
return /* @__PURE__ */ import_react69.default.createElement(import_react69.default.Fragment, null, view === "desktop" && /* @__PURE__ */ import_react69.default.createElement(
|
|
7203
|
+
"tr",
|
|
6844
7204
|
{
|
|
6845
|
-
|
|
6846
|
-
rightIcon: /* @__PURE__ */ import_react67.default.createElement(Edit2_default, { size: 12 }),
|
|
7205
|
+
className: desktopRowClass,
|
|
6847
7206
|
onClick: (e) => {
|
|
6848
7207
|
e.preventDefault();
|
|
6849
7208
|
e.stopPropagation();
|
|
6850
|
-
|
|
7209
|
+
setAccountId(account.id);
|
|
6851
7210
|
}
|
|
6852
7211
|
},
|
|
6853
|
-
"
|
|
6854
|
-
|
|
6855
|
-
|
|
7212
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell Layer__coa__name" }, /* @__PURE__ */ import_react69.default.createElement("span", { className: "Layer__table-cell-content", style }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7213
|
+
"span",
|
|
7214
|
+
{
|
|
7215
|
+
className: "Layer__table-cell-content-indentation",
|
|
7216
|
+
style: {
|
|
7217
|
+
paddingLeft: INDENTATION * depth + 16
|
|
7218
|
+
}
|
|
7219
|
+
},
|
|
7220
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react69.default.createElement(
|
|
7221
|
+
ChevronDownFill_default,
|
|
7222
|
+
{
|
|
7223
|
+
size: 16,
|
|
7224
|
+
className: "Layer__table__expand-icon",
|
|
7225
|
+
onClick: (e) => {
|
|
7226
|
+
e.stopPropagation();
|
|
7227
|
+
setIsOpen(!isOpen);
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
),
|
|
7231
|
+
/* @__PURE__ */ import_react69.default.createElement("span", { className: "Layer__coa__name__text" }, account.name)
|
|
7232
|
+
))),
|
|
7233
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell Layer__coa__type" }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7234
|
+
"span",
|
|
7235
|
+
{
|
|
7236
|
+
className: "Layer__table-cell-content Layer__mobile--hidden",
|
|
7237
|
+
style
|
|
7238
|
+
},
|
|
7239
|
+
account.normality
|
|
7240
|
+
), /* @__PURE__ */ import_react69.default.createElement(
|
|
7241
|
+
"span",
|
|
7242
|
+
{
|
|
7243
|
+
className: "Layer__table-cell-content Layer__desktop--hidden",
|
|
7244
|
+
style
|
|
7245
|
+
},
|
|
7246
|
+
/* @__PURE__ */ import_react69.default.createElement(
|
|
7247
|
+
Text,
|
|
7248
|
+
{
|
|
7249
|
+
weight: "bold" /* bold */,
|
|
7250
|
+
className: "Layer__coa__type--mobile"
|
|
7251
|
+
},
|
|
7252
|
+
account.normality
|
|
7253
|
+
),
|
|
7254
|
+
/* @__PURE__ */ import_react69.default.createElement(Text, { className: "Layer__coa__subtype--mobile" }, "Sub-Type")
|
|
7255
|
+
)),
|
|
7256
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell Layer__coa__subtype Layer__mobile--hidden" }, /* @__PURE__ */ import_react69.default.createElement("span", { className: "Layer__table-cell-content", style }, "Sub-Type")),
|
|
7257
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell Layer__coa__balance" }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7258
|
+
"span",
|
|
7259
|
+
{
|
|
7260
|
+
className: "Layer__table-cell-content Layer__table-cell--amount",
|
|
7261
|
+
style
|
|
7262
|
+
},
|
|
7263
|
+
"$",
|
|
7264
|
+
centsToDollars(Math.abs(account.balance || 0))
|
|
7265
|
+
)),
|
|
7266
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell Layer__coa__actions" }, /* @__PURE__ */ import_react69.default.createElement("span", { className: "Layer__table-cell-content", style }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7267
|
+
Button,
|
|
7268
|
+
{
|
|
7269
|
+
variant: "secondary" /* secondary */,
|
|
7270
|
+
rightIcon: /* @__PURE__ */ import_react69.default.createElement(Edit2_default, { size: 12 }),
|
|
7271
|
+
iconOnly: true,
|
|
7272
|
+
onClick: (e) => {
|
|
7273
|
+
e.preventDefault();
|
|
7274
|
+
e.stopPropagation();
|
|
7275
|
+
editAccount(account.id);
|
|
7276
|
+
}
|
|
7277
|
+
},
|
|
7278
|
+
"Edit"
|
|
7279
|
+
)))
|
|
7280
|
+
), view === "mobile" || view === "tablet" ? /* @__PURE__ */ import_react69.default.createElement(
|
|
7281
|
+
"tr",
|
|
6856
7282
|
{
|
|
6857
|
-
|
|
6858
|
-
rightIcon: /* @__PURE__ */ import_react67.default.createElement(ArrowRightCircle_default, { size: 12 }),
|
|
7283
|
+
className: mobileRowClass,
|
|
6859
7284
|
onClick: (e) => {
|
|
6860
7285
|
e.preventDefault();
|
|
6861
7286
|
e.stopPropagation();
|
|
6862
|
-
|
|
7287
|
+
setAccountId(account.id);
|
|
6863
7288
|
}
|
|
6864
7289
|
},
|
|
6865
|
-
"
|
|
6866
|
-
|
|
6867
|
-
|
|
7290
|
+
/* @__PURE__ */ import_react69.default.createElement("td", { className: "Layer__table-cell", colSpan: 5 }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7291
|
+
"span",
|
|
7292
|
+
{
|
|
7293
|
+
className: "Layer__table-cell-content Layer__table-cell-content-indentation",
|
|
7294
|
+
style: {
|
|
7295
|
+
paddingLeft: MOBILE_INDENTATION * depth + 16,
|
|
7296
|
+
...style
|
|
7297
|
+
}
|
|
7298
|
+
},
|
|
7299
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react69.default.createElement(
|
|
7300
|
+
ChevronDownFill_default,
|
|
7301
|
+
{
|
|
7302
|
+
size: 16,
|
|
7303
|
+
className: "Layer__table__expand-icon",
|
|
7304
|
+
onClick: (e) => {
|
|
7305
|
+
e.stopPropagation();
|
|
7306
|
+
setIsOpen(!isOpen);
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
),
|
|
7310
|
+
/* @__PURE__ */ import_react69.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content" }, /* @__PURE__ */ import_react69.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__top-row" }, /* @__PURE__ */ import_react69.default.createElement(
|
|
7311
|
+
Text,
|
|
7312
|
+
{
|
|
7313
|
+
as: "span",
|
|
7314
|
+
className: "Layer__chart-of-accounts__mobile-row-content__name"
|
|
7315
|
+
},
|
|
7316
|
+
account.name
|
|
7317
|
+
), /* @__PURE__ */ import_react69.default.createElement(
|
|
7318
|
+
TextButton,
|
|
7319
|
+
{
|
|
7320
|
+
onClick: (e) => {
|
|
7321
|
+
e.preventDefault();
|
|
7322
|
+
e.stopPropagation();
|
|
7323
|
+
editAccount(account.id);
|
|
7324
|
+
}
|
|
7325
|
+
},
|
|
7326
|
+
"Edit"
|
|
7327
|
+
)), /* @__PURE__ */ import_react69.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__bottom-row" }, /* @__PURE__ */ import_react69.default.createElement("div", { className: "Layer__chart-of-accounts__mobile-row-content__types" }, /* @__PURE__ */ import_react69.default.createElement(Text, { as: "span" }, account.normality), /* @__PURE__ */ import_react69.default.createElement("span", { className: "Layer__chart-of-accounts__mobile-row-content__separator" }), /* @__PURE__ */ import_react69.default.createElement(Text, { as: "span" }, "Sub-Type")), /* @__PURE__ */ import_react69.default.createElement(
|
|
7328
|
+
Text,
|
|
7329
|
+
{
|
|
7330
|
+
as: "span",
|
|
7331
|
+
className: "Layer__chart-of-accounts__mobile-row-content__balance"
|
|
7332
|
+
},
|
|
7333
|
+
"$",
|
|
7334
|
+
centsToDollars(Math.abs(account.balance || 0))
|
|
7335
|
+
)))
|
|
7336
|
+
))
|
|
7337
|
+
) : null, (account.sub_accounts || []).map((subAccount, idx) => /* @__PURE__ */ import_react69.default.createElement(
|
|
7338
|
+
ChartOfAccountsRow,
|
|
6868
7339
|
{
|
|
6869
7340
|
key: subAccount.id,
|
|
6870
7341
|
account: subAccount,
|
|
@@ -6872,16 +7343,19 @@ var LedgerAccountsRow = ({
|
|
|
6872
7343
|
index: idx,
|
|
6873
7344
|
expanded: isOpen && expanded,
|
|
6874
7345
|
cumulativeIndex: cumulativeIndex + idx + 1,
|
|
6875
|
-
acountsLength: (account.sub_accounts ?? []).length
|
|
7346
|
+
acountsLength: (account.sub_accounts ?? []).length,
|
|
7347
|
+
view
|
|
6876
7348
|
}
|
|
6877
7349
|
)));
|
|
6878
7350
|
};
|
|
6879
7351
|
|
|
6880
|
-
// src/components/
|
|
6881
|
-
var
|
|
7352
|
+
// src/components/ChartOfAccountsSidebar/ChartOfAccountsSidebar.tsx
|
|
7353
|
+
var import_react72 = __toESM(require("react"));
|
|
7354
|
+
|
|
7355
|
+
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
7356
|
+
var import_react71 = __toESM(require("react"));
|
|
6882
7357
|
|
|
6883
|
-
// src/components/
|
|
6884
|
-
var import_react68 = __toESM(require("react"));
|
|
7358
|
+
// src/components/ChartOfAccountsForm/constants.ts
|
|
6885
7359
|
var SUB_TYPE_OPTIONS = [
|
|
6886
7360
|
{
|
|
6887
7361
|
value: "DEBIT" /* DEBIT */,
|
|
@@ -6892,7 +7366,21 @@ var SUB_TYPE_OPTIONS = [
|
|
|
6892
7366
|
label: "Credit"
|
|
6893
7367
|
}
|
|
6894
7368
|
];
|
|
6895
|
-
|
|
7369
|
+
|
|
7370
|
+
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
7371
|
+
var import_react70 = require("react");
|
|
7372
|
+
var useParentOptions = (data) => (0, import_react70.useMemo)(
|
|
7373
|
+
() => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
7374
|
+
return {
|
|
7375
|
+
label: x.name,
|
|
7376
|
+
value: x.id
|
|
7377
|
+
};
|
|
7378
|
+
}),
|
|
7379
|
+
[data?.accounts?.length]
|
|
7380
|
+
);
|
|
7381
|
+
|
|
7382
|
+
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
7383
|
+
var ChartOfAccountsForm = () => {
|
|
6896
7384
|
const {
|
|
6897
7385
|
form,
|
|
6898
7386
|
data,
|
|
@@ -6901,17 +7389,9 @@ var LedgerAccountsForm = () => {
|
|
|
6901
7389
|
submitForm,
|
|
6902
7390
|
sendingForm,
|
|
6903
7391
|
apiError
|
|
6904
|
-
} = (0,
|
|
6905
|
-
const parentOptions = (
|
|
6906
|
-
|
|
6907
|
-
return {
|
|
6908
|
-
label: x.name,
|
|
6909
|
-
value: x.id
|
|
6910
|
-
};
|
|
6911
|
-
}),
|
|
6912
|
-
[data?.accounts?.length]
|
|
6913
|
-
);
|
|
6914
|
-
const entry = (0, import_react68.useMemo)(() => {
|
|
7392
|
+
} = (0, import_react71.useContext)(ChartOfAccountsContext);
|
|
7393
|
+
const parentOptions = useParentOptions(data);
|
|
7394
|
+
const entry = (0, import_react71.useMemo)(() => {
|
|
6915
7395
|
if (form?.action === "edit" && form.accountId) {
|
|
6916
7396
|
return flattenAccounts(data?.accounts || []).find(
|
|
6917
7397
|
(x) => x.id === form.accountId
|
|
@@ -6922,7 +7402,7 @@ var LedgerAccountsForm = () => {
|
|
|
6922
7402
|
if (!form) {
|
|
6923
7403
|
return;
|
|
6924
7404
|
}
|
|
6925
|
-
return /* @__PURE__ */
|
|
7405
|
+
return /* @__PURE__ */ import_react71.default.createElement(
|
|
6926
7406
|
"form",
|
|
6927
7407
|
{
|
|
6928
7408
|
className: "Layer__form",
|
|
@@ -6931,7 +7411,7 @@ var LedgerAccountsForm = () => {
|
|
|
6931
7411
|
submitForm();
|
|
6932
7412
|
}
|
|
6933
7413
|
},
|
|
6934
|
-
/* @__PURE__ */
|
|
7414
|
+
/* @__PURE__ */ import_react71.default.createElement("div", { className: "Layer__chart-of-accounts__sidebar__header" }, /* @__PURE__ */ import_react71.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, form?.action === "edit" ? "Edit" : "Add New", " Account"), /* @__PURE__ */ import_react71.default.createElement("div", { className: "actions" }, /* @__PURE__ */ import_react71.default.createElement(
|
|
6935
7415
|
Button,
|
|
6936
7416
|
{
|
|
6937
7417
|
type: "button",
|
|
@@ -6940,7 +7420,7 @@ var LedgerAccountsForm = () => {
|
|
|
6940
7420
|
disabled: sendingForm
|
|
6941
7421
|
},
|
|
6942
7422
|
"Cancel"
|
|
6943
|
-
), apiError && /* @__PURE__ */
|
|
7423
|
+
), apiError && /* @__PURE__ */ import_react71.default.createElement(
|
|
6944
7424
|
RetryButton,
|
|
6945
7425
|
{
|
|
6946
7426
|
type: "submit",
|
|
@@ -6949,7 +7429,7 @@ var LedgerAccountsForm = () => {
|
|
|
6949
7429
|
disabled: sendingForm
|
|
6950
7430
|
},
|
|
6951
7431
|
"Retry"
|
|
6952
|
-
), !apiError && /* @__PURE__ */
|
|
7432
|
+
), !apiError && /* @__PURE__ */ import_react71.default.createElement(
|
|
6953
7433
|
SubmitButton,
|
|
6954
7434
|
{
|
|
6955
7435
|
type: "submit",
|
|
@@ -6959,16 +7439,16 @@ var LedgerAccountsForm = () => {
|
|
|
6959
7439
|
},
|
|
6960
7440
|
"Save"
|
|
6961
7441
|
))),
|
|
6962
|
-
apiError && /* @__PURE__ */
|
|
7442
|
+
apiError && /* @__PURE__ */ import_react71.default.createElement(
|
|
6963
7443
|
Text,
|
|
6964
7444
|
{
|
|
6965
7445
|
size: "sm" /* sm */,
|
|
6966
|
-
className: "
|
|
7446
|
+
className: "Layer__chart-of-accounts__form__error-message"
|
|
6967
7447
|
},
|
|
6968
7448
|
apiError
|
|
6969
7449
|
),
|
|
6970
|
-
entry && /* @__PURE__ */
|
|
6971
|
-
/* @__PURE__ */
|
|
7450
|
+
entry && /* @__PURE__ */ import_react71.default.createElement("div", { className: "Layer__chart-of-accounts__form-edit-entry" }, /* @__PURE__ */ import_react71.default.createElement(Text, { weight: "bold" /* bold */ }, entry.name), /* @__PURE__ */ import_react71.default.createElement(Text, { weight: "bold" /* bold */ }, "$", centsToDollars(entry.balance || 0))),
|
|
7451
|
+
/* @__PURE__ */ import_react71.default.createElement("div", { className: "Layer__chart-of-accounts__form" }, /* @__PURE__ */ import_react71.default.createElement(InputGroup, { name: "parent", label: "Parent", inline: true }, /* @__PURE__ */ import_react71.default.createElement(
|
|
6972
7452
|
Select2,
|
|
6973
7453
|
{
|
|
6974
7454
|
options: parentOptions,
|
|
@@ -6976,7 +7456,7 @@ var LedgerAccountsForm = () => {
|
|
|
6976
7456
|
onChange: (sel) => changeFormData("parent", sel),
|
|
6977
7457
|
disabled: sendingForm
|
|
6978
7458
|
}
|
|
6979
|
-
)), /* @__PURE__ */
|
|
7459
|
+
)), /* @__PURE__ */ import_react71.default.createElement(InputGroup, { name: "name", label: "Name", inline: true }, /* @__PURE__ */ import_react71.default.createElement(
|
|
6980
7460
|
Input,
|
|
6981
7461
|
{
|
|
6982
7462
|
name: "name",
|
|
@@ -6987,7 +7467,7 @@ var LedgerAccountsForm = () => {
|
|
|
6987
7467
|
disabled: sendingForm,
|
|
6988
7468
|
onChange: (e) => changeFormData("name", e.target.value)
|
|
6989
7469
|
}
|
|
6990
|
-
)), /* @__PURE__ */
|
|
7470
|
+
)), /* @__PURE__ */ import_react71.default.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ import_react71.default.createElement(
|
|
6991
7471
|
Select2,
|
|
6992
7472
|
{
|
|
6993
7473
|
options: [],
|
|
@@ -6995,7 +7475,7 @@ var LedgerAccountsForm = () => {
|
|
|
6995
7475
|
value: form?.data.type,
|
|
6996
7476
|
onChange: (sel) => changeFormData("type", sel)
|
|
6997
7477
|
}
|
|
6998
|
-
)), /* @__PURE__ */
|
|
7478
|
+
)), /* @__PURE__ */ import_react71.default.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ import_react71.default.createElement(
|
|
6999
7479
|
Select2,
|
|
7000
7480
|
{
|
|
7001
7481
|
options: SUB_TYPE_OPTIONS,
|
|
@@ -7003,7 +7483,7 @@ var LedgerAccountsForm = () => {
|
|
|
7003
7483
|
onChange: (sel) => changeFormData("subType", sel),
|
|
7004
7484
|
disabled: sendingForm
|
|
7005
7485
|
}
|
|
7006
|
-
)), /* @__PURE__ */
|
|
7486
|
+
)), /* @__PURE__ */ import_react71.default.createElement(InputGroup, { name: "category", label: "Category", inline: true }, /* @__PURE__ */ import_react71.default.createElement(
|
|
7007
7487
|
Select2,
|
|
7008
7488
|
{
|
|
7009
7489
|
options: [],
|
|
@@ -7015,107 +7495,500 @@ var LedgerAccountsForm = () => {
|
|
|
7015
7495
|
);
|
|
7016
7496
|
};
|
|
7017
7497
|
|
|
7018
|
-
// src/components/
|
|
7498
|
+
// src/components/ChartOfAccountsSidebar/ChartOfAccountsSidebar.tsx
|
|
7499
|
+
var ChartOfAccountsSidebar = ({
|
|
7500
|
+
parentRef: _parentRef
|
|
7501
|
+
}) => {
|
|
7502
|
+
return /* @__PURE__ */ import_react72.default.createElement(ChartOfAccountsForm, null);
|
|
7503
|
+
};
|
|
7504
|
+
|
|
7505
|
+
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
7506
|
+
var COMPONENT_NAME4 = "chart-of-accounts";
|
|
7507
|
+
var ChartOfAccountsTable = ({
|
|
7508
|
+
view,
|
|
7509
|
+
containerRef
|
|
7510
|
+
}) => {
|
|
7511
|
+
const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react73.useContext)(ChartOfAccountsContext);
|
|
7512
|
+
let cumulativeIndex = 0;
|
|
7513
|
+
const accountsLength = data?.accounts.length ?? 0;
|
|
7514
|
+
return /* @__PURE__ */ import_react73.default.createElement(
|
|
7515
|
+
Panel,
|
|
7516
|
+
{
|
|
7517
|
+
sidebar: /* @__PURE__ */ import_react73.default.createElement(ChartOfAccountsSidebar, { parentRef: containerRef }),
|
|
7518
|
+
sidebarIsOpen: Boolean(form),
|
|
7519
|
+
parentRef: containerRef
|
|
7520
|
+
},
|
|
7521
|
+
/* @__PURE__ */ import_react73.default.createElement(Header, { className: `Layer__${COMPONENT_NAME4}__header` }, /* @__PURE__ */ import_react73.default.createElement(Heading, { className: `Layer__${COMPONENT_NAME4}__title` }, "Chart of Accounts"), /* @__PURE__ */ import_react73.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__actions` }, /* @__PURE__ */ import_react73.default.createElement(
|
|
7522
|
+
Button,
|
|
7523
|
+
{
|
|
7524
|
+
variant: "secondary" /* secondary */,
|
|
7525
|
+
disabled: isLoading,
|
|
7526
|
+
rightIcon: /* @__PURE__ */ import_react73.default.createElement(DownloadCloud_default, { size: 12 })
|
|
7527
|
+
},
|
|
7528
|
+
"Download"
|
|
7529
|
+
), /* @__PURE__ */ import_react73.default.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))),
|
|
7530
|
+
/* @__PURE__ */ import_react73.default.createElement("table", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react73.default.createElement("thead", null, /* @__PURE__ */ import_react73.default.createElement("tr", { className: "Layer__table-row--header" }, /* @__PURE__ */ import_react73.default.createElement("th", { className: "Layer__table-header Layer__coa__name" }, "Name"), /* @__PURE__ */ import_react73.default.createElement("th", { className: "Layer__table-header Layer__coa__type" }, "Type"), /* @__PURE__ */ import_react73.default.createElement("th", { className: "Layer__table-header Layer__coa__subtype Layer__mobile--hidden" }, "Sub-Type"), /* @__PURE__ */ import_react73.default.createElement("th", { className: "Layer__table-header Layer__coa__balance" }, "Balance"), /* @__PURE__ */ import_react73.default.createElement("th", { className: "Layer__table-header Layer__coa__actions" }))), /* @__PURE__ */ import_react73.default.createElement("tbody", null, !error && data?.accounts.map((account, idx) => {
|
|
7531
|
+
const currentCumulativeIndex = cumulativeIndex;
|
|
7532
|
+
cumulativeIndex = (account.sub_accounts?.length || 0) + cumulativeIndex + 1;
|
|
7533
|
+
return /* @__PURE__ */ import_react73.default.createElement(
|
|
7534
|
+
ChartOfAccountsRow,
|
|
7535
|
+
{
|
|
7536
|
+
key: account.id,
|
|
7537
|
+
account,
|
|
7538
|
+
depth: 0,
|
|
7539
|
+
index: idx,
|
|
7540
|
+
cumulativeIndex: currentCumulativeIndex,
|
|
7541
|
+
expanded: true,
|
|
7542
|
+
defaultOpen: true,
|
|
7543
|
+
acountsLength: accountsLength,
|
|
7544
|
+
view
|
|
7545
|
+
}
|
|
7546
|
+
);
|
|
7547
|
+
}))),
|
|
7548
|
+
error ? /* @__PURE__ */ import_react73.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react73.default.createElement(
|
|
7549
|
+
DataState,
|
|
7550
|
+
{
|
|
7551
|
+
status: "failed" /* failed */,
|
|
7552
|
+
title: "Something went wrong",
|
|
7553
|
+
description: "We couldn\u2019t load your data.",
|
|
7554
|
+
onRefresh: () => refetch(),
|
|
7555
|
+
isLoading: isValidating || isLoading
|
|
7556
|
+
}
|
|
7557
|
+
)) : null,
|
|
7558
|
+
(!data || isLoading) && !error ? /* @__PURE__ */ import_react73.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ import_react73.default.createElement(Loader2, null)) : null,
|
|
7559
|
+
!isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ import_react73.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react73.default.createElement(
|
|
7560
|
+
DataState,
|
|
7561
|
+
{
|
|
7562
|
+
status: "info" /* info */,
|
|
7563
|
+
title: "Accounts were not found",
|
|
7564
|
+
description: 'New account can be created with "Add Account".',
|
|
7565
|
+
onRefresh: () => refetch(),
|
|
7566
|
+
isLoading: isValidating
|
|
7567
|
+
}
|
|
7568
|
+
)) : null
|
|
7569
|
+
);
|
|
7570
|
+
};
|
|
7571
|
+
|
|
7572
|
+
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
7573
|
+
var import_react80 = __toESM(require("react"));
|
|
7574
|
+
|
|
7575
|
+
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
7576
|
+
var import_react78 = __toESM(require("react"));
|
|
7577
|
+
|
|
7578
|
+
// src/components/Card/Card.tsx
|
|
7579
|
+
var import_react74 = __toESM(require("react"));
|
|
7019
7580
|
var import_classnames32 = __toESM(require("classnames"));
|
|
7020
|
-
var
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7581
|
+
var Card = ({ children, className }) => {
|
|
7582
|
+
return /* @__PURE__ */ import_react74.default.createElement("div", { className: (0, import_classnames32.default)("Layer__card", className) }, children);
|
|
7583
|
+
};
|
|
7584
|
+
|
|
7585
|
+
// src/components/DateTime/DateTime.tsx
|
|
7586
|
+
var import_react75 = __toESM(require("react"));
|
|
7587
|
+
var import_date_fns15 = require("date-fns");
|
|
7588
|
+
var DateTime = ({
|
|
7589
|
+
value,
|
|
7590
|
+
format: format7,
|
|
7591
|
+
dateFormat,
|
|
7592
|
+
timeFormat,
|
|
7593
|
+
onlyDate,
|
|
7594
|
+
onlyTime
|
|
7595
|
+
}) => {
|
|
7596
|
+
if (format7) {
|
|
7597
|
+
return /* @__PURE__ */ import_react75.default.createElement(Text, { className: "Layer__datetime" }, (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(value), format7));
|
|
7598
|
+
}
|
|
7599
|
+
const date = (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(value), dateFormat ?? DATE_FORMAT);
|
|
7600
|
+
const time = (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(value), timeFormat ?? TIME_FORMAT);
|
|
7601
|
+
return /* @__PURE__ */ import_react75.default.createElement(Text, { className: "Layer__datetime" }, !onlyTime && /* @__PURE__ */ import_react75.default.createElement(
|
|
7602
|
+
Text,
|
|
7024
7603
|
{
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7604
|
+
as: "span",
|
|
7605
|
+
weight: "bold" /* bold */,
|
|
7606
|
+
size: "sm" /* sm */,
|
|
7607
|
+
className: "Layer__datetime__date"
|
|
7608
|
+
},
|
|
7609
|
+
date
|
|
7610
|
+
), !onlyDate && /* @__PURE__ */ import_react75.default.createElement(
|
|
7611
|
+
Text,
|
|
7612
|
+
{
|
|
7613
|
+
as: "span",
|
|
7614
|
+
weight: "bold" /* bold */,
|
|
7615
|
+
size: "sm" /* sm */,
|
|
7616
|
+
className: "Layer__datetime__time"
|
|
7617
|
+
},
|
|
7618
|
+
time
|
|
7619
|
+
));
|
|
7620
|
+
};
|
|
7621
|
+
|
|
7622
|
+
// src/components/DetailsList/DetailsList.tsx
|
|
7623
|
+
var import_react76 = __toESM(require("react"));
|
|
7624
|
+
var import_classnames33 = __toESM(require("classnames"));
|
|
7625
|
+
var DetailsList = ({
|
|
7626
|
+
title,
|
|
7627
|
+
children,
|
|
7628
|
+
className,
|
|
7629
|
+
actions
|
|
7630
|
+
}) => {
|
|
7631
|
+
return /* @__PURE__ */ import_react76.default.createElement("div", { className: (0, import_classnames33.default)("Layer__details-list", className) }, title && /* @__PURE__ */ import_react76.default.createElement(Header, null, /* @__PURE__ */ import_react76.default.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ import_react76.default.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ import_react76.default.createElement("ul", { className: "Layer__details-list__list" }, children));
|
|
7632
|
+
};
|
|
7633
|
+
|
|
7634
|
+
// src/components/DetailsList/DetailsListItem.tsx
|
|
7635
|
+
var import_react77 = __toESM(require("react"));
|
|
7636
|
+
var renderValue = (value) => {
|
|
7637
|
+
if (typeof value === "string") {
|
|
7638
|
+
return /* @__PURE__ */ import_react77.default.createElement(Text, { weight: "bold" /* bold */, size: "sm" /* sm */ }, value);
|
|
7639
|
+
}
|
|
7640
|
+
return value;
|
|
7641
|
+
};
|
|
7642
|
+
var DetailsListItem = ({
|
|
7643
|
+
label,
|
|
7644
|
+
children,
|
|
7645
|
+
isLoading
|
|
7646
|
+
}) => {
|
|
7647
|
+
return /* @__PURE__ */ import_react77.default.createElement("li", { className: "Layer__details-list-item" }, /* @__PURE__ */ import_react77.default.createElement("label", { className: "Layer__details-list-item__label" }, label), /* @__PURE__ */ import_react77.default.createElement("span", { className: "Layer__details-list-item__value" }, isLoading ? /* @__PURE__ */ import_react77.default.createElement(SkeletonLoader, null) : renderValue(children)));
|
|
7648
|
+
};
|
|
7649
|
+
|
|
7650
|
+
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
7651
|
+
var LedgerAccountEntryDetails = () => {
|
|
7652
|
+
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react78.useContext)(LedgerAccountsContext);
|
|
7653
|
+
const { totalDebit, totalCredit } = (0, import_react78.useMemo)(() => {
|
|
7654
|
+
let totalDebit2 = 0;
|
|
7655
|
+
let totalCredit2 = 0;
|
|
7656
|
+
entryData?.line_items?.forEach((item) => {
|
|
7657
|
+
if (item.direction === "CREDIT" /* CREDIT */) {
|
|
7658
|
+
totalCredit2 += item.amount || 0;
|
|
7659
|
+
} else if (item.direction === "DEBIT" /* DEBIT */) {
|
|
7660
|
+
totalDebit2 += item.amount || 0;
|
|
7661
|
+
}
|
|
7662
|
+
});
|
|
7663
|
+
return { totalDebit: totalDebit2, totalCredit: totalCredit2 };
|
|
7664
|
+
}, [entryData]);
|
|
7665
|
+
return /* @__PURE__ */ import_react78.default.createElement("div", { className: "Layer__ledger-account__entry-details" }, /* @__PURE__ */ import_react78.default.createElement("div", { className: "Layer__ledger-account__entry-details__back-btn" }, /* @__PURE__ */ import_react78.default.createElement(BackButton, { onClick: () => closeSelectedEntry() })), /* @__PURE__ */ import_react78.default.createElement(
|
|
7666
|
+
DetailsList,
|
|
7667
|
+
{
|
|
7668
|
+
title: "Transaction source",
|
|
7669
|
+
actions: /* @__PURE__ */ import_react78.default.createElement(
|
|
7670
|
+
IconButton,
|
|
7671
|
+
{
|
|
7672
|
+
icon: /* @__PURE__ */ import_react78.default.createElement(X_default, null),
|
|
7673
|
+
onClick: () => closeSelectedEntry(),
|
|
7674
|
+
className: "Layer__hidden-sm Layer__hidden-xs"
|
|
7675
|
+
}
|
|
7028
7676
|
)
|
|
7029
7677
|
},
|
|
7030
|
-
/* @__PURE__ */
|
|
7678
|
+
/* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Source", isLoading: isLoadingEntry }, /* @__PURE__ */ import_react78.default.createElement(Badge, null, "Invoice")),
|
|
7679
|
+
/* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Number", isLoading: isLoadingEntry }, "1234"),
|
|
7680
|
+
/* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, "May 5, 2023"),
|
|
7681
|
+
/* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Account", isLoading: isLoadingEntry }, "89 8888 7656 6666 0000 6765")
|
|
7682
|
+
), /* @__PURE__ */ import_react78.default.createElement(DetailsList, { title: "Journal Entry #123", className: "Layer__border-top" }, /* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Entry type", isLoading: isLoadingEntry }, humanizeEnum(entryData?.entry_type ?? "")), /* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Date", isLoading: isLoadingEntry }, entryData?.entry_at && /* @__PURE__ */ import_react78.default.createElement(DateTime, { value: entryData?.entry_at })), /* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Creation date", isLoading: isLoadingEntry }, entryData?.date && /* @__PURE__ */ import_react78.default.createElement(DateTime, { value: entryData?.date })), /* @__PURE__ */ import_react78.default.createElement(DetailsListItem, { label: "Reversal", isLoading: isLoadingEntry }, "Journal Entry #79 TBD")), !isLoadingEntry && !errorEntry ? /* @__PURE__ */ import_react78.default.createElement("div", { className: "Layer__ledger-account__entry-details__line-items" }, /* @__PURE__ */ import_react78.default.createElement(Card, null, /* @__PURE__ */ import_react78.default.createElement("table", { className: "Layer__table Layer__ledger-account__entry-details__table" }, /* @__PURE__ */ import_react78.default.createElement("thead", null, /* @__PURE__ */ import_react78.default.createElement("tr", null, /* @__PURE__ */ import_react78.default.createElement("th", { className: "Layer__table-header" }, "Line items"), /* @__PURE__ */ import_react78.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react78.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"))), /* @__PURE__ */ import_react78.default.createElement("tbody", null, entryData?.line_items?.map((item) => /* @__PURE__ */ import_react78.default.createElement("tr", { key: `ledger-line-item-${item.id}` }, /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell" }, item.account?.name || ""), /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "DEBIT" /* DEBIT */ && /* @__PURE__ */ import_react78.default.createElement(Badge, { variant: "warning" /* WARNING */ }, "$", centsToDollars(item.amount || 0))), /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, item.direction === "CREDIT" /* CREDIT */ && /* @__PURE__ */ import_react78.default.createElement(Badge, { variant: "success" /* SUCCESS */ }, "$", centsToDollars(item.amount || 0))))), /* @__PURE__ */ import_react78.default.createElement("tr", { className: "Layer__table Layer__ledger-account__entry-details__table__total-row" }, /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell" }, "Total"), /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalDebit || 0)), /* @__PURE__ */ import_react78.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, "$", centsToDollars(totalCredit || 0))))))) : null);
|
|
7683
|
+
};
|
|
7684
|
+
|
|
7685
|
+
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
7686
|
+
var import_react79 = __toESM(require("react"));
|
|
7687
|
+
var import_classnames34 = __toESM(require("classnames"));
|
|
7688
|
+
var import_date_fns16 = require("date-fns");
|
|
7689
|
+
var LedgerAccountRow = ({
|
|
7690
|
+
row,
|
|
7691
|
+
index,
|
|
7692
|
+
initialLoad,
|
|
7693
|
+
view
|
|
7694
|
+
}) => {
|
|
7695
|
+
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react79.useContext)(LedgerAccountsContext);
|
|
7696
|
+
const [showComponent, setShowComponent] = (0, import_react79.useState)(false);
|
|
7697
|
+
(0, import_react79.useEffect)(() => {
|
|
7698
|
+
if (initialLoad) {
|
|
7699
|
+
const timeoutId = setTimeout(() => {
|
|
7700
|
+
setShowComponent(true);
|
|
7701
|
+
}, index * 10);
|
|
7702
|
+
return () => clearTimeout(timeoutId);
|
|
7703
|
+
} else {
|
|
7704
|
+
setShowComponent(true);
|
|
7705
|
+
}
|
|
7706
|
+
}, []);
|
|
7707
|
+
if (view === "tablet") {
|
|
7708
|
+
return /* @__PURE__ */ import_react79.default.createElement(
|
|
7709
|
+
"tr",
|
|
7710
|
+
{
|
|
7711
|
+
className: (0, import_classnames34.default)(
|
|
7712
|
+
"Layer__table-row",
|
|
7713
|
+
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7714
|
+
initialLoad && "initial-load",
|
|
7715
|
+
"Layer__table-row--with-show",
|
|
7716
|
+
showComponent ? "show" : "Layer__table-row--anim-starting-state"
|
|
7717
|
+
),
|
|
7718
|
+
style: { transitionDelay: `${15 * index}ms` },
|
|
7719
|
+
onClick: () => {
|
|
7720
|
+
if (selectedEntryId === row.entry_id) {
|
|
7721
|
+
closeSelectedEntry();
|
|
7722
|
+
} else {
|
|
7723
|
+
setSelectedEntryId(row.entry_id);
|
|
7724
|
+
}
|
|
7725
|
+
}
|
|
7726
|
+
},
|
|
7727
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react79.default.createElement(Text, null, row.date && (0, import_date_fns16.format)((0, import_date_fns16.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react79.default.createElement(
|
|
7728
|
+
Text,
|
|
7729
|
+
{
|
|
7730
|
+
weight: "bold" /* bold */,
|
|
7731
|
+
className: "Layer__ledger_account-table__journal-id"
|
|
7732
|
+
},
|
|
7733
|
+
"#123"
|
|
7734
|
+
)), /* @__PURE__ */ import_react79.default.createElement(Text, null, "Invoice (TBD null)"))),
|
|
7735
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
7736
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
7737
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, "$X,XXX.XX"))
|
|
7738
|
+
);
|
|
7739
|
+
}
|
|
7740
|
+
if (view === "mobile") {
|
|
7741
|
+
return /* @__PURE__ */ import_react79.default.createElement(
|
|
7742
|
+
"tr",
|
|
7743
|
+
{
|
|
7744
|
+
className: (0, import_classnames34.default)(
|
|
7745
|
+
"Layer__table-row",
|
|
7746
|
+
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7747
|
+
initialLoad && "initial-load",
|
|
7748
|
+
"Layer__table-row--with-show",
|
|
7749
|
+
showComponent ? "show" : "Layer__table-row--anim-starting-state"
|
|
7750
|
+
),
|
|
7751
|
+
style: { transitionDelay: `${15 * index}ms` },
|
|
7752
|
+
onClick: () => {
|
|
7753
|
+
if (selectedEntryId === row.entry_id) {
|
|
7754
|
+
closeSelectedEntry();
|
|
7755
|
+
} else {
|
|
7756
|
+
setSelectedEntryId(row.entry_id);
|
|
7757
|
+
}
|
|
7758
|
+
}
|
|
7759
|
+
},
|
|
7760
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react79.default.createElement(Text, null, row.date && (0, import_date_fns16.format)((0, import_date_fns16.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react79.default.createElement(
|
|
7761
|
+
Text,
|
|
7762
|
+
{
|
|
7763
|
+
weight: "bold" /* bold */,
|
|
7764
|
+
className: "Layer__ledger_account-table__journal-id"
|
|
7765
|
+
},
|
|
7766
|
+
"#123"
|
|
7767
|
+
)), /* @__PURE__ */ import_react79.default.createElement(Text, null, "Invoice (TBD null)"), /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger_account-table__balances-mobile" }, /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Debit"), /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, " ", row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Credit"), /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)), /* @__PURE__ */ import_react79.default.createElement("div", { className: "Layer__ledger_account-table__balance-item" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__label" }, "Running balance"), /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__ledger_account-table__balances-mobile__value" }, "$X,XXX.XX")))))
|
|
7768
|
+
);
|
|
7769
|
+
}
|
|
7770
|
+
return /* @__PURE__ */ import_react79.default.createElement(
|
|
7771
|
+
"tr",
|
|
7772
|
+
{
|
|
7773
|
+
className: (0, import_classnames34.default)(
|
|
7774
|
+
"Layer__table-row",
|
|
7775
|
+
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
7776
|
+
initialLoad && "initial-load",
|
|
7777
|
+
"Layer__table-row--with-show",
|
|
7778
|
+
showComponent ? "show" : "Layer__table-row--anim-starting-state"
|
|
7779
|
+
),
|
|
7780
|
+
style: { transitionDelay: `${15 * index}ms` },
|
|
7781
|
+
onClick: () => {
|
|
7782
|
+
if (selectedEntryId === row.entry_id) {
|
|
7783
|
+
closeSelectedEntry();
|
|
7784
|
+
} else {
|
|
7785
|
+
setSelectedEntryId(row.entry_id);
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
},
|
|
7789
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0, import_date_fns16.format)((0, import_date_fns16.parseISO)(row.date), DATE_FORMAT))),
|
|
7790
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content" }, "#123")),
|
|
7791
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content" }, "Invoice (TBD null)")),
|
|
7792
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
7793
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
7794
|
+
/* @__PURE__ */ import_react79.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react79.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, "$X,XXX.XX"))
|
|
7795
|
+
);
|
|
7796
|
+
};
|
|
7797
|
+
|
|
7798
|
+
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
7799
|
+
var import_classnames35 = __toESM(require("classnames"));
|
|
7800
|
+
var LedgerAccount = ({
|
|
7801
|
+
containerRef,
|
|
7802
|
+
pageSize = 15,
|
|
7803
|
+
view
|
|
7804
|
+
}) => {
|
|
7805
|
+
const [currentPage, setCurrentPage] = (0, import_react80.useState)(1);
|
|
7806
|
+
const [initialLoad, setInitialLoad] = (0, import_react80.useState)(true);
|
|
7807
|
+
const { data: accountData } = (0, import_react80.useContext)(ChartOfAccountsContext);
|
|
7808
|
+
const {
|
|
7809
|
+
data: rawData,
|
|
7810
|
+
error,
|
|
7811
|
+
isLoading,
|
|
7812
|
+
isValidating,
|
|
7813
|
+
accountId,
|
|
7814
|
+
setAccountId,
|
|
7815
|
+
selectedEntryId,
|
|
7816
|
+
closeSelectedEntry,
|
|
7817
|
+
refetch
|
|
7818
|
+
} = (0, import_react80.useContext)(LedgerAccountsContext);
|
|
7819
|
+
(0, import_react80.useEffect)(() => {
|
|
7820
|
+
if (!isLoading) {
|
|
7821
|
+
const timeoutLoad = setTimeout(() => {
|
|
7822
|
+
setInitialLoad(false);
|
|
7823
|
+
}, 1e3);
|
|
7824
|
+
return () => clearTimeout(timeoutLoad);
|
|
7825
|
+
}
|
|
7826
|
+
}, [isLoading]);
|
|
7827
|
+
const baseClassName = (0, import_classnames35.default)(
|
|
7828
|
+
"Layer__ledger-account__index",
|
|
7829
|
+
accountId && "open"
|
|
7830
|
+
);
|
|
7831
|
+
const entry = (0, import_react80.useMemo)(() => {
|
|
7832
|
+
return flattenAccounts(accountData?.accounts || []).find(
|
|
7833
|
+
(x) => x.id === accountId
|
|
7834
|
+
);
|
|
7835
|
+
}, [accountId]);
|
|
7836
|
+
const data = (0, import_react80.useMemo)(() => {
|
|
7837
|
+
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
7838
|
+
const lastPageIndex = firstPageIndex + pageSize;
|
|
7839
|
+
return rawData?.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))?.slice(firstPageIndex, lastPageIndex);
|
|
7840
|
+
}, [rawData, currentPage]);
|
|
7841
|
+
const close = () => {
|
|
7842
|
+
setAccountId(void 0);
|
|
7843
|
+
closeSelectedEntry();
|
|
7844
|
+
};
|
|
7845
|
+
return /* @__PURE__ */ import_react80.default.createElement(
|
|
7846
|
+
Panel,
|
|
7847
|
+
{
|
|
7848
|
+
sidebar: /* @__PURE__ */ import_react80.default.createElement(LedgerAccountEntryDetails, null),
|
|
7849
|
+
sidebarIsOpen: Boolean(selectedEntryId),
|
|
7850
|
+
parentRef: containerRef,
|
|
7851
|
+
className: "Layer__ledger-account__panel"
|
|
7852
|
+
},
|
|
7853
|
+
/* @__PURE__ */ import_react80.default.createElement("div", { className: baseClassName }, /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account__header" }, /* @__PURE__ */ import_react80.default.createElement(BackButton, { onClick: close }), /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account__title-container" }, /* @__PURE__ */ import_react80.default.createElement(
|
|
7854
|
+
Text,
|
|
7855
|
+
{
|
|
7856
|
+
weight: "bold" /* bold */,
|
|
7857
|
+
className: "Layer__ledger-account__title"
|
|
7858
|
+
},
|
|
7859
|
+
entry?.name ?? ""
|
|
7860
|
+
), /* @__PURE__ */ import_react80.default.createElement(
|
|
7861
|
+
Button,
|
|
7862
|
+
{
|
|
7863
|
+
variant: "secondary" /* secondary */,
|
|
7864
|
+
rightIcon: /* @__PURE__ */ import_react80.default.createElement(DownloadCloud_default, { size: 12 })
|
|
7865
|
+
},
|
|
7866
|
+
"Download"
|
|
7867
|
+
)), /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account__balance-container" }, /* @__PURE__ */ import_react80.default.createElement(
|
|
7868
|
+
Text,
|
|
7869
|
+
{
|
|
7870
|
+
weight: "bold" /* bold */,
|
|
7871
|
+
className: "Layer__ledger-account__balance-label"
|
|
7872
|
+
},
|
|
7873
|
+
"Current balance"
|
|
7874
|
+
), /* @__PURE__ */ import_react80.default.createElement(
|
|
7875
|
+
Text,
|
|
7876
|
+
{
|
|
7877
|
+
weight: "bold" /* bold */,
|
|
7878
|
+
className: "Layer__ledger-account__balance-value"
|
|
7879
|
+
},
|
|
7880
|
+
"$",
|
|
7881
|
+
centsToDollars(entry?.balance || 0)
|
|
7882
|
+
))), /* @__PURE__ */ import_react80.default.createElement("table", { className: "Layer__table Layer__table--hover-effect Layer__ledger-account-table" }, /* @__PURE__ */ import_react80.default.createElement("thead", null, /* @__PURE__ */ import_react80.default.createElement("tr", null, view !== "desktop" && /* @__PURE__ */ import_react80.default.createElement("th", null), view === "desktop" && /* @__PURE__ */ import_react80.default.createElement(import_react80.default.Fragment, null, /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header" }, "Source")), view !== "mobile" && /* @__PURE__ */ import_react80.default.createElement(import_react80.default.Fragment, null, /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ import_react80.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance")))), /* @__PURE__ */ import_react80.default.createElement("tbody", null, data?.map((x, index) => /* @__PURE__ */ import_react80.default.createElement(
|
|
7883
|
+
LedgerAccountRow,
|
|
7884
|
+
{
|
|
7885
|
+
key: x.id,
|
|
7886
|
+
row: x,
|
|
7887
|
+
index,
|
|
7888
|
+
initialLoad,
|
|
7889
|
+
view
|
|
7890
|
+
}
|
|
7891
|
+
)))), data && /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__ledger-account__pagination" }, /* @__PURE__ */ import_react80.default.createElement(
|
|
7892
|
+
Pagination,
|
|
7893
|
+
{
|
|
7894
|
+
currentPage,
|
|
7895
|
+
totalCount: rawData?.length || 0,
|
|
7896
|
+
pageSize,
|
|
7897
|
+
onPageChange: (page) => setCurrentPage(page)
|
|
7898
|
+
}
|
|
7899
|
+
)), error ? /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react80.default.createElement(
|
|
7900
|
+
DataState,
|
|
7901
|
+
{
|
|
7902
|
+
status: "failed" /* failed */,
|
|
7903
|
+
title: "Something went wrong",
|
|
7904
|
+
description: "We couldn\u2019t load your data.",
|
|
7905
|
+
onRefresh: () => refetch(),
|
|
7906
|
+
isLoading: isValidating || isLoading
|
|
7907
|
+
}
|
|
7908
|
+
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */ import_react80.default.createElement("div", { className: `Layer__ledger-account__loader-container` }, /* @__PURE__ */ import_react80.default.createElement(Loader2, null)) : null, !isLoading && !error && data?.length === 0 ? /* @__PURE__ */ import_react80.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react80.default.createElement(
|
|
7909
|
+
DataState,
|
|
7910
|
+
{
|
|
7911
|
+
status: "info" /* info */,
|
|
7912
|
+
title: "No records found",
|
|
7913
|
+
onRefresh: () => refetch(),
|
|
7914
|
+
isLoading: isValidating
|
|
7915
|
+
}
|
|
7916
|
+
)) : null)
|
|
7031
7917
|
);
|
|
7032
7918
|
};
|
|
7033
7919
|
|
|
7034
|
-
// src/components/
|
|
7035
|
-
var
|
|
7036
|
-
|
|
7920
|
+
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
7921
|
+
var ChartOfAccountsContext = (0, import_react81.createContext)(
|
|
7922
|
+
{
|
|
7923
|
+
data: void 0,
|
|
7924
|
+
isLoading: false,
|
|
7925
|
+
isValidating: false,
|
|
7926
|
+
error: void 0,
|
|
7927
|
+
refetch: () => {
|
|
7928
|
+
},
|
|
7929
|
+
create: () => {
|
|
7930
|
+
},
|
|
7931
|
+
form: void 0,
|
|
7932
|
+
sendingForm: false,
|
|
7933
|
+
apiError: void 0,
|
|
7934
|
+
addAccount: () => {
|
|
7935
|
+
},
|
|
7936
|
+
editAccount: () => {
|
|
7937
|
+
},
|
|
7938
|
+
cancelForm: () => {
|
|
7939
|
+
},
|
|
7940
|
+
changeFormData: () => {
|
|
7941
|
+
},
|
|
7942
|
+
submitForm: () => {
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
7945
|
+
);
|
|
7946
|
+
var LedgerAccountsContext = (0, import_react81.createContext)({
|
|
7037
7947
|
data: void 0,
|
|
7948
|
+
entryData: void 0,
|
|
7038
7949
|
isLoading: false,
|
|
7950
|
+
isLoadingEntry: false,
|
|
7039
7951
|
isValidating: false,
|
|
7952
|
+
isValidatingEntry: false,
|
|
7040
7953
|
error: void 0,
|
|
7954
|
+
errorEntry: void 0,
|
|
7041
7955
|
refetch: () => {
|
|
7042
7956
|
},
|
|
7043
|
-
|
|
7957
|
+
accountId: void 0,
|
|
7958
|
+
setAccountId: () => {
|
|
7044
7959
|
},
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
apiError: void 0,
|
|
7048
|
-
addAccount: () => {
|
|
7960
|
+
selectedEntryId: void 0,
|
|
7961
|
+
setSelectedEntryId: () => {
|
|
7049
7962
|
},
|
|
7050
|
-
|
|
7051
|
-
},
|
|
7052
|
-
cancelForm: () => {
|
|
7053
|
-
},
|
|
7054
|
-
changeFormData: () => {
|
|
7055
|
-
},
|
|
7056
|
-
submitForm: () => {
|
|
7057
|
-
},
|
|
7058
|
-
showARForAccountId: void 0,
|
|
7059
|
-
setShowARForAccountId: () => {
|
|
7963
|
+
closeSelectedEntry: () => {
|
|
7060
7964
|
}
|
|
7061
7965
|
});
|
|
7062
|
-
var
|
|
7063
|
-
const
|
|
7064
|
-
|
|
7966
|
+
var ChartOfAccounts = (props) => {
|
|
7967
|
+
const chartOfAccountsContextData = useChartOfAccounts();
|
|
7968
|
+
const ledgerAccountsContextData = useLedgerAccounts();
|
|
7969
|
+
return /* @__PURE__ */ import_react81.default.createElement(ChartOfAccountsContext.Provider, { value: chartOfAccountsContextData }, /* @__PURE__ */ import_react81.default.createElement(LedgerAccountsContext.Provider, { value: ledgerAccountsContextData }, /* @__PURE__ */ import_react81.default.createElement(ChartOfAccountsContent, null)));
|
|
7065
7970
|
};
|
|
7066
|
-
var
|
|
7067
|
-
const {
|
|
7068
|
-
|
|
7069
|
-
const
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
"Download"
|
|
7078
|
-
), /* @__PURE__ */ import_react70.default.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))), /* @__PURE__ */ import_react70.default.createElement("table", { className: `Layer__${COMPONENT_NAME4}__table` }, /* @__PURE__ */ import_react70.default.createElement("thead", null, /* @__PURE__ */ import_react70.default.createElement("tr", { className: "Layer__table-row--header" }, /* @__PURE__ */ import_react70.default.createElement("th", { className: "Layer__table-header Layer__coa__name" }, "Name"), /* @__PURE__ */ import_react70.default.createElement("th", { className: "Layer__table-header Layer__coa__type" }, "Type"), /* @__PURE__ */ import_react70.default.createElement("th", { className: "Layer__table-header Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ import_react70.default.createElement("th", { className: "Layer__table-header Layer__coa__balance" }, "Balance"), /* @__PURE__ */ import_react70.default.createElement("th", { className: "Layer__table-header Layer__coa__actions" }))), /* @__PURE__ */ import_react70.default.createElement("tbody", null, !error && data?.accounts.map((account, idx) => {
|
|
7079
|
-
const currentCumulativeIndex = cumulativeIndex;
|
|
7080
|
-
cumulativeIndex = (account.sub_accounts?.length || 0) + cumulativeIndex + 1;
|
|
7081
|
-
return /* @__PURE__ */ import_react70.default.createElement(
|
|
7082
|
-
LedgerAccountsRow,
|
|
7083
|
-
{
|
|
7084
|
-
key: account.id,
|
|
7085
|
-
account,
|
|
7086
|
-
depth: 0,
|
|
7087
|
-
index: idx,
|
|
7088
|
-
cumulativeIndex: currentCumulativeIndex,
|
|
7089
|
-
expanded: true,
|
|
7090
|
-
defaultOpen: true,
|
|
7091
|
-
acountsLength: accountsLength
|
|
7971
|
+
var ChartOfAccountsContent = ({ asWidget }) => {
|
|
7972
|
+
const { accountId } = (0, import_react81.useContext)(LedgerAccountsContext);
|
|
7973
|
+
const [view, setView] = (0, import_react81.useState)("desktop");
|
|
7974
|
+
const containerRef = useElementSize((_a, _b, { width }) => {
|
|
7975
|
+
if (width) {
|
|
7976
|
+
if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
|
|
7977
|
+
setView("desktop");
|
|
7978
|
+
} else if (width <= BREAKPOINTS.TABLET && width > BREAKPOINTS.MOBILE && view !== "tablet") {
|
|
7979
|
+
setView("tablet");
|
|
7980
|
+
} else if (width < BREAKPOINTS.MOBILE && view !== "mobile") {
|
|
7981
|
+
setView("mobile");
|
|
7092
7982
|
}
|
|
7093
|
-
);
|
|
7094
|
-
}))), error ? /* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7095
|
-
DataState,
|
|
7096
|
-
{
|
|
7097
|
-
status: "failed" /* failed */,
|
|
7098
|
-
title: "Something went wrong",
|
|
7099
|
-
description: "We couldn\u2019t load your data.",
|
|
7100
|
-
onRefresh: () => refetch(),
|
|
7101
|
-
isLoading: isValidating || isLoading
|
|
7102
|
-
}
|
|
7103
|
-
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */ import_react70.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ import_react70.default.createElement(Loader2, null)) : null, !isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ import_react70.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react70.default.createElement(
|
|
7104
|
-
DataState,
|
|
7105
|
-
{
|
|
7106
|
-
status: "info" /* info */,
|
|
7107
|
-
title: "Accounts were not found",
|
|
7108
|
-
description: 'New account can be created with "Add Account".',
|
|
7109
|
-
onRefresh: () => refetch(),
|
|
7110
|
-
isLoading: isValidating
|
|
7111
7983
|
}
|
|
7112
|
-
)
|
|
7984
|
+
});
|
|
7985
|
+
return /* @__PURE__ */ import_react81.default.createElement(Container, { name: "chart-of-accounts", ref: containerRef, asWidget }, accountId ? /* @__PURE__ */ import_react81.default.createElement(LedgerAccount, { view, containerRef }) : /* @__PURE__ */ import_react81.default.createElement(ChartOfAccountsTable, { view, containerRef }));
|
|
7113
7986
|
};
|
|
7114
7987
|
|
|
7115
7988
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
7116
|
-
var
|
|
7117
|
-
var
|
|
7118
|
-
var
|
|
7989
|
+
var import_react82 = __toESM(require("react"));
|
|
7990
|
+
var import_date_fns17 = require("date-fns");
|
|
7991
|
+
var import_swr8 = __toESM(require("swr"));
|
|
7119
7992
|
var reducer = (state, action) => {
|
|
7120
7993
|
switch (action.type) {
|
|
7121
7994
|
case "LayerContext.setAuth" /* setAuth */:
|
|
@@ -7155,7 +8028,7 @@ var LayerProvider = ({
|
|
|
7155
8028
|
};
|
|
7156
8029
|
const colors = buildColorsPalette(theme);
|
|
7157
8030
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
7158
|
-
const [state, dispatch] = (0,
|
|
8031
|
+
const [state, dispatch] = (0, import_react82.useReducer)(reducer, {
|
|
7159
8032
|
auth: {
|
|
7160
8033
|
access_token: "",
|
|
7161
8034
|
token_type: "",
|
|
@@ -7168,8 +8041,8 @@ var LayerProvider = ({
|
|
|
7168
8041
|
theme,
|
|
7169
8042
|
colors
|
|
7170
8043
|
});
|
|
7171
|
-
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0,
|
|
7172
|
-
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0,
|
|
8044
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr8.default)(
|
|
8045
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns17.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
7173
8046
|
Layer.authenticate({
|
|
7174
8047
|
appId,
|
|
7175
8048
|
appSecret,
|
|
@@ -7178,7 +8051,7 @@ var LayerProvider = ({
|
|
|
7178
8051
|
}),
|
|
7179
8052
|
defaultSWRConfig
|
|
7180
8053
|
) : { data: void 0 };
|
|
7181
|
-
(0,
|
|
8054
|
+
(0, import_react82.useEffect)(() => {
|
|
7182
8055
|
if (businessAccessToken) {
|
|
7183
8056
|
dispatch({
|
|
7184
8057
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -7187,7 +8060,7 @@ var LayerProvider = ({
|
|
|
7187
8060
|
access_token: businessAccessToken,
|
|
7188
8061
|
token_type: "Bearer",
|
|
7189
8062
|
expires_in: 3600,
|
|
7190
|
-
expires_at: (0,
|
|
8063
|
+
expires_at: (0, import_date_fns17.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
7191
8064
|
}
|
|
7192
8065
|
}
|
|
7193
8066
|
});
|
|
@@ -7197,13 +8070,13 @@ var LayerProvider = ({
|
|
|
7197
8070
|
payload: {
|
|
7198
8071
|
auth: {
|
|
7199
8072
|
...auth,
|
|
7200
|
-
expires_at: (0,
|
|
8073
|
+
expires_at: (0, import_date_fns17.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
7201
8074
|
}
|
|
7202
8075
|
}
|
|
7203
8076
|
});
|
|
7204
8077
|
}
|
|
7205
8078
|
}, [businessAccessToken, auth?.access_token]);
|
|
7206
|
-
(0,
|
|
8079
|
+
(0, import_swr8.default)(
|
|
7207
8080
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
7208
8081
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
7209
8082
|
{
|
|
@@ -7222,23 +8095,137 @@ var LayerProvider = ({
|
|
|
7222
8095
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
7223
8096
|
payload: { theme: theme2 }
|
|
7224
8097
|
});
|
|
8098
|
+
const setLightColor = (color) => {
|
|
8099
|
+
setTheme({
|
|
8100
|
+
...state.theme ?? {},
|
|
8101
|
+
colors: {
|
|
8102
|
+
...state.theme?.colors ?? {},
|
|
8103
|
+
light: color
|
|
8104
|
+
}
|
|
8105
|
+
});
|
|
8106
|
+
};
|
|
8107
|
+
const setDarkColor = (color) => {
|
|
8108
|
+
setTheme({
|
|
8109
|
+
...state.theme ?? {},
|
|
8110
|
+
colors: {
|
|
8111
|
+
...state.theme?.colors ?? {},
|
|
8112
|
+
dark: color
|
|
8113
|
+
}
|
|
8114
|
+
});
|
|
8115
|
+
};
|
|
8116
|
+
const setColors = (colors2) => {
|
|
8117
|
+
setTheme({
|
|
8118
|
+
...state.theme ?? {},
|
|
8119
|
+
colors: colors2
|
|
8120
|
+
});
|
|
8121
|
+
};
|
|
7225
8122
|
const getColor = (shade) => {
|
|
7226
8123
|
if (colors && shade in colors) {
|
|
7227
8124
|
return colors[shade];
|
|
7228
8125
|
}
|
|
7229
8126
|
return;
|
|
7230
8127
|
};
|
|
7231
|
-
return /* @__PURE__ */
|
|
8128
|
+
return /* @__PURE__ */ import_react82.default.createElement(import_swr8.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react82.default.createElement(
|
|
8129
|
+
LayerContext.Provider,
|
|
8130
|
+
{
|
|
8131
|
+
value: { ...state, setTheme, getColor, setLightColor, setDarkColor, setColors }
|
|
8132
|
+
},
|
|
8133
|
+
children
|
|
8134
|
+
));
|
|
8135
|
+
};
|
|
8136
|
+
|
|
8137
|
+
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
8138
|
+
var import_react85 = __toESM(require("react"));
|
|
8139
|
+
|
|
8140
|
+
// src/components/View/View.tsx
|
|
8141
|
+
var import_react84 = __toESM(require("react"));
|
|
8142
|
+
|
|
8143
|
+
// src/components/ViewHeader/ViewHeader.tsx
|
|
8144
|
+
var import_react83 = __toESM(require("react"));
|
|
8145
|
+
var ViewHeader = ({ title, controls }) => {
|
|
8146
|
+
return /* @__PURE__ */ import_react83.default.createElement("div", { className: "Layer__view-header" }, /* @__PURE__ */ import_react83.default.createElement("div", { className: "Layer__view-header__content" }, /* @__PURE__ */ import_react83.default.createElement(Heading, null, title), controls && /* @__PURE__ */ import_react83.default.createElement("div", { className: "Layer__view-header__controls" }, controls)));
|
|
8147
|
+
};
|
|
8148
|
+
|
|
8149
|
+
// src/components/View/View.tsx
|
|
8150
|
+
var View6 = ({ title, children, headerControls }) => {
|
|
8151
|
+
const { theme } = useLayerContext();
|
|
8152
|
+
const styles = parseStylesFromThemeConfig(theme);
|
|
8153
|
+
return /* @__PURE__ */ import_react84.default.createElement("div", { className: "Layer__view", style: { ...styles } }, /* @__PURE__ */ import_react84.default.createElement(ViewHeader, { title, controls: headerControls }), /* @__PURE__ */ import_react84.default.createElement("div", { className: "Layer__view-main" }, children));
|
|
8154
|
+
};
|
|
8155
|
+
|
|
8156
|
+
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
8157
|
+
var AccountingOverview = ({
|
|
8158
|
+
title = "Accounting overview"
|
|
8159
|
+
}) => {
|
|
8160
|
+
return /* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ import_react85.default.createElement(View6, { title, headerControls: /* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss.DatePicker, null) }, /* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss.Summaries, { actionable: false }), /* @__PURE__ */ import_react85.default.createElement(
|
|
8161
|
+
Container,
|
|
8162
|
+
{
|
|
8163
|
+
name: "accounting-overview-profit-and-loss",
|
|
8164
|
+
asWidget: true,
|
|
8165
|
+
elevated: true
|
|
8166
|
+
},
|
|
8167
|
+
/* @__PURE__ */ import_react85.default.createElement(Header, null, /* @__PURE__ */ import_react85.default.createElement(Heading, { size: "secondary" /* secondary */ }, "Profit & Loss")),
|
|
8168
|
+
/* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss.Chart, null)
|
|
8169
|
+
), /* @__PURE__ */ import_react85.default.createElement("div", { className: "accounting-overview-profit-and-loss-charts" }, /* @__PURE__ */ import_react85.default.createElement(Container, { name: "accounting-overview-profit-and-loss-chart" }, /* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss.DetailedCharts, { scope: "revenue", hideClose: true })), /* @__PURE__ */ import_react85.default.createElement(Container, { name: "accounting-overview-profit-and-loss-chart" }, /* @__PURE__ */ import_react85.default.createElement(ProfitAndLoss.DetailedCharts, { scope: "expenses", hideClose: true })))));
|
|
8170
|
+
};
|
|
8171
|
+
|
|
8172
|
+
// src/views/BankTransactionsWithLinkedAccounts/BankTransactionsWithLinkedAccounts.tsx
|
|
8173
|
+
var import_react86 = __toESM(require("react"));
|
|
8174
|
+
var BankTransactionsWithLinkedAccounts = ({
|
|
8175
|
+
title = "Bank transactions"
|
|
8176
|
+
}) => {
|
|
8177
|
+
return /* @__PURE__ */ import_react86.default.createElement(View6, { title }, /* @__PURE__ */ import_react86.default.createElement(LinkedAccounts, { elevated: true }), /* @__PURE__ */ import_react86.default.createElement(BankTransactions, { asWidget: true }));
|
|
8178
|
+
};
|
|
8179
|
+
|
|
8180
|
+
// src/views/Reports/Reports.tsx
|
|
8181
|
+
var import_react87 = __toESM(require("react"));
|
|
8182
|
+
var Reports = ({ title = "Reports" }) => {
|
|
8183
|
+
const containerRef = (0, import_react87.useRef)(null);
|
|
8184
|
+
return /* @__PURE__ */ import_react87.default.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ import_react87.default.createElement(View6, { title, headerControls: /* @__PURE__ */ import_react87.default.createElement(ProfitAndLoss.DatePicker, null) }, /* @__PURE__ */ import_react87.default.createElement(
|
|
8185
|
+
Toggle,
|
|
8186
|
+
{
|
|
8187
|
+
name: "reports-tabs",
|
|
8188
|
+
options: [
|
|
8189
|
+
{
|
|
8190
|
+
value: "profitAndLoss",
|
|
8191
|
+
label: "Profit & loss"
|
|
8192
|
+
},
|
|
8193
|
+
{
|
|
8194
|
+
value: "balanceSheet",
|
|
8195
|
+
label: "Balance sheet",
|
|
8196
|
+
disabled: true
|
|
8197
|
+
}
|
|
8198
|
+
],
|
|
8199
|
+
selected: "profitAndLoss",
|
|
8200
|
+
onChange: () => null
|
|
8201
|
+
}
|
|
8202
|
+
), /* @__PURE__ */ import_react87.default.createElement(Container, { name: "reports", ref: containerRef }, /* @__PURE__ */ import_react87.default.createElement(ReportsPanel, { containerRef }))));
|
|
8203
|
+
};
|
|
8204
|
+
var ReportsPanel = ({ containerRef }) => {
|
|
8205
|
+
const { sidebarScope } = (0, import_react87.useContext)(ProfitAndLoss.Context);
|
|
8206
|
+
return /* @__PURE__ */ import_react87.default.createElement(
|
|
8207
|
+
Panel,
|
|
8208
|
+
{
|
|
8209
|
+
sidebar: /* @__PURE__ */ import_react87.default.createElement(ProfitAndLoss.DetailedCharts, null),
|
|
8210
|
+
sidebarIsOpen: Boolean(sidebarScope),
|
|
8211
|
+
parentRef: containerRef
|
|
8212
|
+
},
|
|
8213
|
+
/* @__PURE__ */ import_react87.default.createElement(ProfitAndLoss.Table, { asContainer: false })
|
|
8214
|
+
);
|
|
7232
8215
|
};
|
|
7233
8216
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7234
8217
|
0 && (module.exports = {
|
|
8218
|
+
AccountingOverview,
|
|
7235
8219
|
BalanceSheet,
|
|
7236
8220
|
BankTransactions,
|
|
8221
|
+
BankTransactionsWithLinkedAccounts,
|
|
8222
|
+
ChartOfAccounts,
|
|
7237
8223
|
Hello,
|
|
7238
8224
|
LayerProvider,
|
|
7239
|
-
LedgerAccounts,
|
|
7240
8225
|
LinkedAccounts,
|
|
7241
8226
|
ProfitAndLoss,
|
|
7242
|
-
ProfitAndLossView
|
|
8227
|
+
ProfitAndLossView,
|
|
8228
|
+
Reports,
|
|
8229
|
+
useLayerContext
|
|
7243
8230
|
});
|
|
7244
8231
|
//# sourceMappingURL=index.js.map
|