@layerfi/components 0.1.6 → 0.1.8
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 +724 -69
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +92 -1
- package/dist/index.js +719 -71
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +241 -0
- package/dist/styles/index.css.map +3 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4022,20 +4022,23 @@ import React57 from "react";
|
|
|
4022
4022
|
import { useEffect as useEffect7, useState as useState11 } from "react";
|
|
4023
4023
|
var MOCK_DATA = [
|
|
4024
4024
|
{
|
|
4025
|
-
name: "
|
|
4025
|
+
name: "Public Demo Banking",
|
|
4026
4026
|
account: "1234",
|
|
4027
4027
|
amount: 1220620
|
|
4028
|
-
},
|
|
4029
|
-
{
|
|
4030
|
-
name: "Business Savings",
|
|
4031
|
-
account: "5678",
|
|
4032
|
-
amount: 10002062e-1
|
|
4033
|
-
},
|
|
4034
|
-
{
|
|
4035
|
-
name: "Account",
|
|
4036
|
-
account: "4321",
|
|
4037
|
-
amount: 4400020620
|
|
4038
4028
|
}
|
|
4029
|
+
/* Temporarily removing these to make it match test data (with one account)
|
|
4030
|
+
* we're using in the demo.
|
|
4031
|
+
*/
|
|
4032
|
+
// {
|
|
4033
|
+
// name: 'Business Savings',
|
|
4034
|
+
// account: '5678',
|
|
4035
|
+
// amount: 1000206.2,
|
|
4036
|
+
// },
|
|
4037
|
+
// {
|
|
4038
|
+
// name: 'Account',
|
|
4039
|
+
// account: '4321',
|
|
4040
|
+
// amount: 801.91,
|
|
4041
|
+
// },
|
|
4039
4042
|
];
|
|
4040
4043
|
var useLinkedAccounts = () => {
|
|
4041
4044
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
@@ -4098,7 +4101,63 @@ var LinkedAccounts = () => {
|
|
|
4098
4101
|
import React65, { createContext as createContext2 } from "react";
|
|
4099
4102
|
|
|
4100
4103
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4101
|
-
import { useState as useState12 } from "react";
|
|
4104
|
+
import { useMemo as useMemo3, useState as useState12 } from "react";
|
|
4105
|
+
|
|
4106
|
+
// src/utils/profitAndLossUtils.ts
|
|
4107
|
+
var doesLineItemQualifies = (item) => {
|
|
4108
|
+
return !(item.is_contra || item.value === void 0 || item.value === null || isNaN(item.value) || item.value === -Infinity || item.value === Infinity || item.value < 0);
|
|
4109
|
+
};
|
|
4110
|
+
var collectSubItems = (type, item) => {
|
|
4111
|
+
if (!item) {
|
|
4112
|
+
return [];
|
|
4113
|
+
}
|
|
4114
|
+
const items = [];
|
|
4115
|
+
item?.line_items?.forEach((item2) => {
|
|
4116
|
+
if (doesLineItemQualifies(item2)) {
|
|
4117
|
+
items.push({
|
|
4118
|
+
name: item2.name,
|
|
4119
|
+
display_name: item2.display_name,
|
|
4120
|
+
value: Math.abs(item2.value || 0),
|
|
4121
|
+
// @TODO - confirm that's safe to do this
|
|
4122
|
+
type
|
|
4123
|
+
});
|
|
4124
|
+
}
|
|
4125
|
+
});
|
|
4126
|
+
return items;
|
|
4127
|
+
};
|
|
4128
|
+
var collectExpensesItems = (data) => {
|
|
4129
|
+
const cogs = collectSubItems("Cost of Goods Sold", data.cost_of_goods_sold);
|
|
4130
|
+
const expenses = collectSubItems("Operating Expenses", data.expenses);
|
|
4131
|
+
const taxes = collectSubItems("Taxes & Licenses", data.taxes);
|
|
4132
|
+
return [].concat(cogs).concat(expenses).concat(taxes);
|
|
4133
|
+
};
|
|
4134
|
+
var collectRevenueItems = (data) => {
|
|
4135
|
+
const income = collectSubItems("Income", data.income);
|
|
4136
|
+
return [].concat(income);
|
|
4137
|
+
};
|
|
4138
|
+
var humanizeTitle = (sidebarView) => {
|
|
4139
|
+
switch (sidebarView) {
|
|
4140
|
+
case "expenses":
|
|
4141
|
+
return "Expenses";
|
|
4142
|
+
case "revenue":
|
|
4143
|
+
return "Revenue";
|
|
4144
|
+
default:
|
|
4145
|
+
return "Profit & Loss";
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
var applyShare = (items, total) => {
|
|
4149
|
+
return items.map((item) => {
|
|
4150
|
+
if (total === 0) {
|
|
4151
|
+
return item;
|
|
4152
|
+
}
|
|
4153
|
+
return {
|
|
4154
|
+
...item,
|
|
4155
|
+
share: item.value / total
|
|
4156
|
+
};
|
|
4157
|
+
});
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4160
|
+
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4102
4161
|
import { startOfMonth, endOfMonth, formatISO } from "date-fns";
|
|
4103
4162
|
import useSWR4 from "swr";
|
|
4104
4163
|
var useProfitAndLoss = ({
|
|
@@ -4117,6 +4176,11 @@ var useProfitAndLoss = ({
|
|
|
4117
4176
|
const [endDate, setEndDate] = useState12(
|
|
4118
4177
|
initialEndDate || endOfMonth(Date.now())
|
|
4119
4178
|
);
|
|
4179
|
+
const [filters, setFilters] = useState12({
|
|
4180
|
+
expenses: void 0,
|
|
4181
|
+
revenue: void 0
|
|
4182
|
+
});
|
|
4183
|
+
const [sidebarScope, setSidebarScope] = useState12("expenses");
|
|
4120
4184
|
const {
|
|
4121
4185
|
data: rawData,
|
|
4122
4186
|
isLoading,
|
|
@@ -4139,6 +4203,43 @@ var useProfitAndLoss = ({
|
|
|
4139
4203
|
})
|
|
4140
4204
|
);
|
|
4141
4205
|
const { data, error } = rawData || {};
|
|
4206
|
+
const { filteredData, filteredTotal } = useMemo3(() => {
|
|
4207
|
+
if (!data) {
|
|
4208
|
+
return { filteredData: [], filteredTotal: void 0 };
|
|
4209
|
+
}
|
|
4210
|
+
const items = sidebarScope === "revenue" ? collectRevenueItems(data) : collectExpensesItems(data);
|
|
4211
|
+
const filtered = items.map((x) => {
|
|
4212
|
+
if (sidebarScope && filters[sidebarScope]?.types && filters[sidebarScope].types.length > 0 && !filters[sidebarScope]?.types?.includes(x.type)) {
|
|
4213
|
+
return {
|
|
4214
|
+
...x,
|
|
4215
|
+
hidden: true
|
|
4216
|
+
};
|
|
4217
|
+
}
|
|
4218
|
+
return x;
|
|
4219
|
+
});
|
|
4220
|
+
const sorted = filtered.sort((a, b) => {
|
|
4221
|
+
switch (filters[sidebarScope ?? "expenses"]?.sortBy) {
|
|
4222
|
+
case "category":
|
|
4223
|
+
if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
|
|
4224
|
+
return a.display_name.localeCompare(b.display_name);
|
|
4225
|
+
}
|
|
4226
|
+
return b.display_name.localeCompare(a.display_name);
|
|
4227
|
+
case "type":
|
|
4228
|
+
if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
|
|
4229
|
+
return a.type.localeCompare(b.type);
|
|
4230
|
+
}
|
|
4231
|
+
return b.type.localeCompare(a.type);
|
|
4232
|
+
default:
|
|
4233
|
+
if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
|
|
4234
|
+
return a.value - b.value;
|
|
4235
|
+
}
|
|
4236
|
+
return b.value - a.value;
|
|
4237
|
+
}
|
|
4238
|
+
});
|
|
4239
|
+
const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
|
|
4240
|
+
const withShare = applyShare(sorted, total);
|
|
4241
|
+
return { filteredData: withShare, filteredTotal: total };
|
|
4242
|
+
}, [data, startDate, filters, sidebarScope]);
|
|
4142
4243
|
const changeDateRange = ({
|
|
4143
4244
|
startDate: newStartDate,
|
|
4144
4245
|
endDate: newEndDate
|
|
@@ -4149,22 +4250,80 @@ var useProfitAndLoss = ({
|
|
|
4149
4250
|
const refetch = () => {
|
|
4150
4251
|
mutate();
|
|
4151
4252
|
};
|
|
4253
|
+
const sortBy = (scope, field, direction) => {
|
|
4254
|
+
setFilters({
|
|
4255
|
+
...filters,
|
|
4256
|
+
[scope]: {
|
|
4257
|
+
...filters[scope],
|
|
4258
|
+
sortBy: field,
|
|
4259
|
+
sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
|
|
4260
|
+
}
|
|
4261
|
+
});
|
|
4262
|
+
};
|
|
4263
|
+
const setFilterTypes = (scope, types) => {
|
|
4264
|
+
setFilters({
|
|
4265
|
+
...filters,
|
|
4266
|
+
[scope]: {
|
|
4267
|
+
...filters[scope],
|
|
4268
|
+
types
|
|
4269
|
+
}
|
|
4270
|
+
});
|
|
4271
|
+
};
|
|
4152
4272
|
return {
|
|
4153
4273
|
data,
|
|
4274
|
+
filteredData,
|
|
4275
|
+
filteredTotal,
|
|
4154
4276
|
isLoading,
|
|
4155
4277
|
isValidating,
|
|
4156
4278
|
error: error || rawError,
|
|
4157
4279
|
dateRange: { startDate, endDate },
|
|
4158
4280
|
refetch,
|
|
4159
|
-
changeDateRange
|
|
4281
|
+
changeDateRange,
|
|
4282
|
+
sidebarScope,
|
|
4283
|
+
setSidebarScope,
|
|
4284
|
+
sortBy,
|
|
4285
|
+
filters,
|
|
4286
|
+
setFilterTypes
|
|
4160
4287
|
};
|
|
4161
4288
|
};
|
|
4162
4289
|
|
|
4163
4290
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
4164
|
-
import React59, { useContext as useContext2, useMemo as
|
|
4291
|
+
import React59, { useContext as useContext2, useMemo as useMemo4, useState as useState13 } from "react";
|
|
4165
4292
|
|
|
4166
4293
|
// src/utils/format.ts
|
|
4167
4294
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
4295
|
+
var formatPercent = (value, options) => {
|
|
4296
|
+
if (!value && value !== 0) {
|
|
4297
|
+
return;
|
|
4298
|
+
}
|
|
4299
|
+
const val = value * 100;
|
|
4300
|
+
let defaultOptions = {
|
|
4301
|
+
minimumFractionDigits: 0,
|
|
4302
|
+
maximumFractionDigits: 0
|
|
4303
|
+
};
|
|
4304
|
+
if (Math.abs(val) < 10) {
|
|
4305
|
+
defaultOptions = {
|
|
4306
|
+
minimumFractionDigits: 1,
|
|
4307
|
+
maximumFractionDigits: 1
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
if (Math.abs(val) < 1) {
|
|
4311
|
+
defaultOptions = {
|
|
4312
|
+
minimumFractionDigits: 1,
|
|
4313
|
+
maximumFractionDigits: 1
|
|
4314
|
+
};
|
|
4315
|
+
}
|
|
4316
|
+
if (val === 0) {
|
|
4317
|
+
defaultOptions = {
|
|
4318
|
+
minimumFractionDigits: 0,
|
|
4319
|
+
maximumFractionDigits: 0
|
|
4320
|
+
};
|
|
4321
|
+
}
|
|
4322
|
+
return val.toLocaleString("en-US", {
|
|
4323
|
+
...defaultOptions,
|
|
4324
|
+
...options
|
|
4325
|
+
});
|
|
4326
|
+
};
|
|
4168
4327
|
|
|
4169
4328
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
4170
4329
|
import React58, { useEffect as useEffect8 } from "react";
|
|
@@ -4342,7 +4501,7 @@ var ProfitAndLossChart = () => {
|
|
|
4342
4501
|
}
|
|
4343
4502
|
);
|
|
4344
4503
|
};
|
|
4345
|
-
const data =
|
|
4504
|
+
const data = useMemo4(
|
|
4346
4505
|
() => monthData.map(summarizePnL),
|
|
4347
4506
|
[
|
|
4348
4507
|
startSelectionMonth,
|
|
@@ -4523,34 +4682,64 @@ var SkeletonLoader = ({
|
|
|
4523
4682
|
};
|
|
4524
4683
|
|
|
4525
4684
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
4685
|
+
import classNames22 from "classnames";
|
|
4526
4686
|
var ProfitAndLossSummaries = ({
|
|
4527
4687
|
vertical,
|
|
4528
4688
|
revenueLabel = "Revenue"
|
|
4529
4689
|
}) => {
|
|
4530
|
-
const {
|
|
4690
|
+
const {
|
|
4691
|
+
data: storedData,
|
|
4692
|
+
isLoading,
|
|
4693
|
+
setSidebarScope,
|
|
4694
|
+
sidebarScope
|
|
4695
|
+
} = useContext4(ProfitAndLoss.Context);
|
|
4531
4696
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
4532
|
-
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--
|
|
4533
|
-
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--
|
|
4534
|
-
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--
|
|
4697
|
+
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4698
|
+
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4699
|
+
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4535
4700
|
return /* @__PURE__ */ React62.createElement(
|
|
4536
4701
|
"div",
|
|
4537
4702
|
{
|
|
4538
4703
|
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
4539
4704
|
},
|
|
4540
|
-
/* @__PURE__ */ React62.createElement(
|
|
4541
|
-
"
|
|
4705
|
+
/* @__PURE__ */ React62.createElement(
|
|
4706
|
+
"div",
|
|
4542
4707
|
{
|
|
4543
|
-
className:
|
|
4708
|
+
className: classNames22(
|
|
4709
|
+
"Layer__profit-and-loss-summaries__summary Layer__actionable",
|
|
4710
|
+
"Layer__profit-and-loss-summaries__summary--income",
|
|
4711
|
+
sidebarScope === "revenue" ? "active" : ""
|
|
4712
|
+
),
|
|
4713
|
+
onClick: () => setSidebarScope("revenue")
|
|
4544
4714
|
},
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4715
|
+
/* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel),
|
|
4716
|
+
isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, null)) : /* @__PURE__ */ React62.createElement(
|
|
4717
|
+
"span",
|
|
4718
|
+
{
|
|
4719
|
+
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
4720
|
+
},
|
|
4721
|
+
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
4722
|
+
)
|
|
4723
|
+
),
|
|
4724
|
+
/* @__PURE__ */ React62.createElement(
|
|
4725
|
+
"div",
|
|
4549
4726
|
{
|
|
4550
|
-
className:
|
|
4727
|
+
className: classNames22(
|
|
4728
|
+
"Layer__profit-and-loss-summaries__summary Layer__actionable",
|
|
4729
|
+
"Layer__profit-and-loss-summaries__summary--expenses",
|
|
4730
|
+
sidebarScope === "expenses" ? "active" : ""
|
|
4731
|
+
),
|
|
4732
|
+
onClick: () => setSidebarScope("expenses")
|
|
4551
4733
|
},
|
|
4552
|
-
|
|
4553
|
-
|
|
4734
|
+
/* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"),
|
|
4735
|
+
isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React62.createElement(
|
|
4736
|
+
"span",
|
|
4737
|
+
{
|
|
4738
|
+
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
4739
|
+
},
|
|
4740
|
+
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
4741
|
+
)
|
|
4742
|
+
),
|
|
4554
4743
|
/* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React62.createElement(
|
|
4555
4744
|
"span",
|
|
4556
4745
|
{
|
|
@@ -4772,6 +4961,8 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4772
4961
|
import { endOfMonth as endOfMonth4, startOfMonth as startOfMonth4 } from "date-fns";
|
|
4773
4962
|
var PNLContext = createContext2({
|
|
4774
4963
|
data: void 0,
|
|
4964
|
+
filteredData: [],
|
|
4965
|
+
filteredTotal: void 0,
|
|
4775
4966
|
isLoading: true,
|
|
4776
4967
|
isValidating: false,
|
|
4777
4968
|
error: void 0,
|
|
@@ -4782,6 +4973,17 @@ var PNLContext = createContext2({
|
|
|
4782
4973
|
changeDateRange: () => {
|
|
4783
4974
|
},
|
|
4784
4975
|
refetch: () => {
|
|
4976
|
+
},
|
|
4977
|
+
sidebarScope: void 0,
|
|
4978
|
+
setSidebarScope: () => {
|
|
4979
|
+
},
|
|
4980
|
+
sortBy: () => {
|
|
4981
|
+
},
|
|
4982
|
+
setFilterTypes: () => {
|
|
4983
|
+
},
|
|
4984
|
+
filters: {
|
|
4985
|
+
expenses: void 0,
|
|
4986
|
+
revenue: void 0
|
|
4785
4987
|
}
|
|
4786
4988
|
});
|
|
4787
4989
|
var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
|
|
@@ -4795,20 +4997,473 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
|
4795
4997
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
4796
4998
|
|
|
4797
4999
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
4798
|
-
import
|
|
5000
|
+
import React69, { useContext as useContext7 } from "react";
|
|
5001
|
+
|
|
5002
|
+
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5003
|
+
import React68, { useContext as useContext6, useMemo as useMemo5, useState as useState15 } from "react";
|
|
5004
|
+
import Select3 from "react-select";
|
|
5005
|
+
|
|
5006
|
+
// src/icons/SortArrows.tsx
|
|
5007
|
+
import * as React66 from "react";
|
|
5008
|
+
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElement(
|
|
5009
|
+
"svg",
|
|
5010
|
+
{
|
|
5011
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5012
|
+
viewBox: "0 0 12 13",
|
|
5013
|
+
fill: "none",
|
|
5014
|
+
...props,
|
|
5015
|
+
width: size,
|
|
5016
|
+
height: size
|
|
5017
|
+
},
|
|
5018
|
+
/* @__PURE__ */ React66.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React66.createElement(
|
|
5019
|
+
"path",
|
|
5020
|
+
{
|
|
5021
|
+
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
5022
|
+
stroke: "currentColor",
|
|
5023
|
+
"stroke-linecap": "round",
|
|
5024
|
+
"stroke-linejoin": "round",
|
|
5025
|
+
className: "desc-arrow"
|
|
5026
|
+
}
|
|
5027
|
+
), /* @__PURE__ */ React66.createElement(
|
|
5028
|
+
"path",
|
|
5029
|
+
{
|
|
5030
|
+
d: "M4 2.5L4 11.1667",
|
|
5031
|
+
stroke: "currentColor",
|
|
5032
|
+
"stroke-linecap": "round",
|
|
5033
|
+
"stroke-linejoin": "round",
|
|
5034
|
+
className: "desc-arrow"
|
|
5035
|
+
}
|
|
5036
|
+
), /* @__PURE__ */ React66.createElement(
|
|
5037
|
+
"path",
|
|
5038
|
+
{
|
|
5039
|
+
d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
|
|
5040
|
+
stroke: "currentColor",
|
|
5041
|
+
"stroke-linecap": "round",
|
|
5042
|
+
"stroke-linejoin": "round",
|
|
5043
|
+
className: "asc-arrow"
|
|
5044
|
+
}
|
|
5045
|
+
), /* @__PURE__ */ React66.createElement(
|
|
5046
|
+
"path",
|
|
5047
|
+
{
|
|
5048
|
+
d: "M8.66663 11.166L8.66663 2.49935",
|
|
5049
|
+
stroke: "currentColor",
|
|
5050
|
+
"stroke-linecap": "round",
|
|
5051
|
+
"stroke-linejoin": "round",
|
|
5052
|
+
className: "asc-arrow"
|
|
5053
|
+
}
|
|
5054
|
+
)),
|
|
5055
|
+
/* @__PURE__ */ React66.createElement("defs", null, /* @__PURE__ */ React66.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React66.createElement(
|
|
5056
|
+
"rect",
|
|
5057
|
+
{
|
|
5058
|
+
width: "12",
|
|
5059
|
+
height: "12",
|
|
5060
|
+
fill: "white",
|
|
5061
|
+
transform: "translate(0 0.5)"
|
|
5062
|
+
}
|
|
5063
|
+
)))
|
|
5064
|
+
);
|
|
5065
|
+
var SortArrows_default = SortArrows;
|
|
5066
|
+
|
|
5067
|
+
// src/icons/X.tsx
|
|
5068
|
+
import * as React67 from "react";
|
|
5069
|
+
var X = ({ size = 18, ...props }) => /* @__PURE__ */ React67.createElement(
|
|
5070
|
+
"svg",
|
|
5071
|
+
{
|
|
5072
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5073
|
+
viewBox: "0 0 18 18",
|
|
5074
|
+
fill: "none",
|
|
5075
|
+
...props,
|
|
5076
|
+
width: size,
|
|
5077
|
+
height: size
|
|
5078
|
+
},
|
|
5079
|
+
/* @__PURE__ */ React67.createElement(
|
|
5080
|
+
"path",
|
|
5081
|
+
{
|
|
5082
|
+
d: "M13.5 4.5L4.5 13.5",
|
|
5083
|
+
stroke: "currentColor",
|
|
5084
|
+
strokeLinecap: "round",
|
|
5085
|
+
strokeLinejoin: "round"
|
|
5086
|
+
}
|
|
5087
|
+
),
|
|
5088
|
+
/* @__PURE__ */ React67.createElement(
|
|
5089
|
+
"path",
|
|
5090
|
+
{
|
|
5091
|
+
d: "M4.5 4.5L13.5 13.5",
|
|
5092
|
+
stroke: "currentColor",
|
|
5093
|
+
strokeLinecap: "round",
|
|
5094
|
+
strokeLinejoin: "round"
|
|
5095
|
+
}
|
|
5096
|
+
)
|
|
5097
|
+
);
|
|
5098
|
+
var X_default = X;
|
|
5099
|
+
|
|
5100
|
+
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5101
|
+
import classNames23 from "classnames";
|
|
5102
|
+
import { format as format6 } from "date-fns";
|
|
5103
|
+
import {
|
|
5104
|
+
PieChart,
|
|
5105
|
+
Pie,
|
|
5106
|
+
Cell as Cell2,
|
|
5107
|
+
ResponsiveContainer as ResponsiveContainer2,
|
|
5108
|
+
Label,
|
|
5109
|
+
Text as ChartText
|
|
5110
|
+
} from "recharts";
|
|
5111
|
+
var INACTIVE_OPACITY_LEVELS = [0.85, 0.7, 0.66, 0.55, 0.4, 0.33, 0.25, 0.15];
|
|
5112
|
+
var DEFAULT_CHART_COLORS = [
|
|
5113
|
+
{
|
|
5114
|
+
color: "#7417B3",
|
|
5115
|
+
opacity: 1
|
|
5116
|
+
},
|
|
5117
|
+
{
|
|
5118
|
+
color: "#7417B3",
|
|
5119
|
+
opacity: 0.8
|
|
5120
|
+
},
|
|
5121
|
+
{
|
|
5122
|
+
color: "#7417B3",
|
|
5123
|
+
opacity: 0.6
|
|
5124
|
+
},
|
|
5125
|
+
{
|
|
5126
|
+
color: "#7417B3",
|
|
5127
|
+
opacity: 0.4
|
|
5128
|
+
},
|
|
5129
|
+
{
|
|
5130
|
+
color: "#7417B3",
|
|
5131
|
+
opacity: 0.2
|
|
5132
|
+
},
|
|
5133
|
+
{
|
|
5134
|
+
color: "#7417B3",
|
|
5135
|
+
opacity: 0.1
|
|
5136
|
+
},
|
|
5137
|
+
{
|
|
5138
|
+
color: "#006A80",
|
|
5139
|
+
opacity: 1
|
|
5140
|
+
},
|
|
5141
|
+
{
|
|
5142
|
+
color: "#006A80",
|
|
5143
|
+
opacity: 0.8
|
|
5144
|
+
},
|
|
5145
|
+
{
|
|
5146
|
+
color: "#006A80",
|
|
5147
|
+
opacity: 0.6
|
|
5148
|
+
},
|
|
5149
|
+
{
|
|
5150
|
+
color: "#006A80",
|
|
5151
|
+
opacity: 0.4
|
|
5152
|
+
},
|
|
5153
|
+
{
|
|
5154
|
+
color: "#006A80",
|
|
5155
|
+
opacity: 0.2
|
|
5156
|
+
},
|
|
5157
|
+
{
|
|
5158
|
+
color: "#006A80",
|
|
5159
|
+
opacity: 0.1
|
|
5160
|
+
},
|
|
5161
|
+
{
|
|
5162
|
+
color: "#009930",
|
|
5163
|
+
opacity: 1
|
|
5164
|
+
},
|
|
5165
|
+
{
|
|
5166
|
+
color: "#009930",
|
|
5167
|
+
opacity: 0.8
|
|
5168
|
+
},
|
|
5169
|
+
{
|
|
5170
|
+
color: "#009930",
|
|
5171
|
+
opacity: 0.6
|
|
5172
|
+
},
|
|
5173
|
+
{
|
|
5174
|
+
color: "#009930",
|
|
5175
|
+
opacity: 0.4
|
|
5176
|
+
},
|
|
5177
|
+
{
|
|
5178
|
+
color: "#009930",
|
|
5179
|
+
opacity: 0.2
|
|
5180
|
+
},
|
|
5181
|
+
{
|
|
5182
|
+
color: "#009930",
|
|
5183
|
+
opacity: 0.1
|
|
5184
|
+
}
|
|
5185
|
+
];
|
|
5186
|
+
var ProfitAndLossDetailedCharts = () => {
|
|
5187
|
+
const {
|
|
5188
|
+
data,
|
|
5189
|
+
filteredData,
|
|
5190
|
+
filteredTotal,
|
|
5191
|
+
sortBy,
|
|
5192
|
+
filters,
|
|
5193
|
+
isLoading,
|
|
5194
|
+
dateRange,
|
|
5195
|
+
sidebarScope,
|
|
5196
|
+
setSidebarScope,
|
|
5197
|
+
setFilterTypes
|
|
5198
|
+
} = useContext6(ProfitAndLoss.Context);
|
|
5199
|
+
const [hoveredItem, setHoveredItem] = useState15();
|
|
5200
|
+
const chartData = useMemo5(() => {
|
|
5201
|
+
if (!filteredData) {
|
|
5202
|
+
return [];
|
|
5203
|
+
}
|
|
5204
|
+
return filteredData.map((x) => {
|
|
5205
|
+
if (x.hidden) {
|
|
5206
|
+
return {
|
|
5207
|
+
name: x.display_name,
|
|
5208
|
+
value: 0
|
|
5209
|
+
};
|
|
5210
|
+
}
|
|
5211
|
+
return {
|
|
5212
|
+
name: x.display_name,
|
|
5213
|
+
value: x.value
|
|
5214
|
+
};
|
|
5215
|
+
});
|
|
5216
|
+
}, [filteredData]);
|
|
5217
|
+
const buildColClass = (column) => {
|
|
5218
|
+
return classNames23(
|
|
5219
|
+
"Layer__sortable-col",
|
|
5220
|
+
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
5221
|
+
);
|
|
5222
|
+
};
|
|
5223
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5224
|
+
"div",
|
|
5225
|
+
{
|
|
5226
|
+
className: classNames23(
|
|
5227
|
+
"Layer__profit-and-loss__side-panel",
|
|
5228
|
+
sidebarScope && "open"
|
|
5229
|
+
)
|
|
5230
|
+
},
|
|
5231
|
+
/* @__PURE__ */ React68.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ React68.createElement("header", null, /* @__PURE__ */ React68.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ React68.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ React68.createElement(Text, { size: "sm" /* sm */, className: "date" }, format6(dateRange.startDate, "LLLL, y"))), /* @__PURE__ */ React68.createElement(
|
|
5232
|
+
Button,
|
|
5233
|
+
{
|
|
5234
|
+
rightIcon: /* @__PURE__ */ React68.createElement(X_default, null),
|
|
5235
|
+
iconOnly: true,
|
|
5236
|
+
onClick: () => setSidebarScope(void 0),
|
|
5237
|
+
variant: "secondary" /* secondary */
|
|
5238
|
+
}
|
|
5239
|
+
)), /* @__PURE__ */ React68.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React68.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React68.createElement(PieChart, null, /* @__PURE__ */ React68.createElement(
|
|
5240
|
+
Pie,
|
|
5241
|
+
{
|
|
5242
|
+
data: chartData,
|
|
5243
|
+
dataKey: "value",
|
|
5244
|
+
nameKey: "name",
|
|
5245
|
+
cx: "50%",
|
|
5246
|
+
cy: "50%",
|
|
5247
|
+
innerRadius: 105,
|
|
5248
|
+
outerRadius: 120,
|
|
5249
|
+
paddingAngle: 0.5,
|
|
5250
|
+
fill: "#8884d8"
|
|
5251
|
+
},
|
|
5252
|
+
chartData.map((entry, index) => {
|
|
5253
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
5254
|
+
let fill = colorConfig.color;
|
|
5255
|
+
let opacity = colorConfig.opacity;
|
|
5256
|
+
let active = true;
|
|
5257
|
+
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5258
|
+
active = false;
|
|
5259
|
+
fill = void 0;
|
|
5260
|
+
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5261
|
+
}
|
|
5262
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5263
|
+
Cell2,
|
|
5264
|
+
{
|
|
5265
|
+
key: `cell-${index}`,
|
|
5266
|
+
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5267
|
+
style: { fill },
|
|
5268
|
+
opacity,
|
|
5269
|
+
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5270
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5271
|
+
}
|
|
5272
|
+
);
|
|
5273
|
+
}),
|
|
5274
|
+
/* @__PURE__ */ React68.createElement(
|
|
5275
|
+
Label,
|
|
5276
|
+
{
|
|
5277
|
+
position: "center",
|
|
5278
|
+
value: "Total",
|
|
5279
|
+
className: "pie-center-label-title",
|
|
5280
|
+
content: (props) => {
|
|
5281
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5282
|
+
cx: 0,
|
|
5283
|
+
cy: 0
|
|
5284
|
+
};
|
|
5285
|
+
const positioningProps = {
|
|
5286
|
+
x: cx,
|
|
5287
|
+
y: (cy || 0) - 15,
|
|
5288
|
+
textAnchor: "middle",
|
|
5289
|
+
verticalAnchor: "middle"
|
|
5290
|
+
};
|
|
5291
|
+
let text = "Total";
|
|
5292
|
+
if (hoveredItem) {
|
|
5293
|
+
text = hoveredItem;
|
|
5294
|
+
}
|
|
5295
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5296
|
+
ChartText,
|
|
5297
|
+
{
|
|
5298
|
+
...positioningProps,
|
|
5299
|
+
className: "pie-center-label__title"
|
|
5300
|
+
},
|
|
5301
|
+
text
|
|
5302
|
+
);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5305
|
+
),
|
|
5306
|
+
/* @__PURE__ */ React68.createElement(
|
|
5307
|
+
Label,
|
|
5308
|
+
{
|
|
5309
|
+
position: "center",
|
|
5310
|
+
value: "Total",
|
|
5311
|
+
className: "pie-center-label-title",
|
|
5312
|
+
content: (props) => {
|
|
5313
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5314
|
+
cx: 0,
|
|
5315
|
+
cy: 0
|
|
5316
|
+
};
|
|
5317
|
+
const positioningProps = {
|
|
5318
|
+
x: cx,
|
|
5319
|
+
y: (cy || 0) + 5,
|
|
5320
|
+
textAnchor: "middle",
|
|
5321
|
+
verticalAnchor: "middle"
|
|
5322
|
+
};
|
|
5323
|
+
let value = filteredTotal;
|
|
5324
|
+
if (hoveredItem) {
|
|
5325
|
+
value = filteredData.find(
|
|
5326
|
+
(x) => x.display_name === hoveredItem
|
|
5327
|
+
)?.value;
|
|
5328
|
+
}
|
|
5329
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5330
|
+
ChartText,
|
|
5331
|
+
{
|
|
5332
|
+
...positioningProps,
|
|
5333
|
+
className: "pie-center-label__value"
|
|
5334
|
+
},
|
|
5335
|
+
`$${centsToDollars(value)}`
|
|
5336
|
+
);
|
|
5337
|
+
}
|
|
5338
|
+
}
|
|
5339
|
+
),
|
|
5340
|
+
/* @__PURE__ */ React68.createElement(
|
|
5341
|
+
Label,
|
|
5342
|
+
{
|
|
5343
|
+
position: "center",
|
|
5344
|
+
value: "Total",
|
|
5345
|
+
className: "pie-center-label-title",
|
|
5346
|
+
content: (props) => {
|
|
5347
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5348
|
+
cx: 0,
|
|
5349
|
+
cy: 0
|
|
5350
|
+
};
|
|
5351
|
+
const positioningProps = {
|
|
5352
|
+
x: cx,
|
|
5353
|
+
y: (cy || 0) + 25,
|
|
5354
|
+
height: 20,
|
|
5355
|
+
textAnchor: "middle",
|
|
5356
|
+
verticalAnchor: "middle"
|
|
5357
|
+
};
|
|
5358
|
+
if (hoveredItem) {
|
|
5359
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5360
|
+
ChartText,
|
|
5361
|
+
{
|
|
5362
|
+
...positioningProps,
|
|
5363
|
+
className: "pie-center-label__share"
|
|
5364
|
+
},
|
|
5365
|
+
`${formatPercent(
|
|
5366
|
+
filteredData.find(
|
|
5367
|
+
(x) => x.display_name === hoveredItem
|
|
5368
|
+
)?.share
|
|
5369
|
+
)}%`
|
|
5370
|
+
);
|
|
5371
|
+
}
|
|
5372
|
+
return;
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
)
|
|
5376
|
+
)))), /* @__PURE__ */ React68.createElement("div", { className: "filters" }, /* @__PURE__ */ React68.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ React68.createElement(
|
|
5377
|
+
Select3,
|
|
5378
|
+
{
|
|
5379
|
+
className: "type-select",
|
|
5380
|
+
classNamePrefix: "Layer__select",
|
|
5381
|
+
value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
|
|
5382
|
+
value: x,
|
|
5383
|
+
label: x
|
|
5384
|
+
})) : [],
|
|
5385
|
+
isMulti: true,
|
|
5386
|
+
isClearable: false,
|
|
5387
|
+
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
5388
|
+
label: x,
|
|
5389
|
+
value: x
|
|
5390
|
+
})),
|
|
5391
|
+
onChange: (selected) => {
|
|
5392
|
+
setFilterTypes(
|
|
5393
|
+
sidebarScope ?? "expenses",
|
|
5394
|
+
selected.map((x) => x.value)
|
|
5395
|
+
);
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
)), /* @__PURE__ */ React68.createElement("div", { className: "details-container" }, /* @__PURE__ */ React68.createElement("div", { className: "table" }, /* @__PURE__ */ React68.createElement("table", null, /* @__PURE__ */ React68.createElement("thead", null, /* @__PURE__ */ React68.createElement("tr", null, /* @__PURE__ */ React68.createElement(
|
|
5399
|
+
"th",
|
|
5400
|
+
{
|
|
5401
|
+
className: buildColClass("category"),
|
|
5402
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
5403
|
+
},
|
|
5404
|
+
"Expense/Sale ",
|
|
5405
|
+
/* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5406
|
+
), /* @__PURE__ */ React68.createElement(
|
|
5407
|
+
"th",
|
|
5408
|
+
{
|
|
5409
|
+
className: buildColClass("type"),
|
|
5410
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5411
|
+
},
|
|
5412
|
+
"Type ",
|
|
5413
|
+
/* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5414
|
+
), /* @__PURE__ */ React68.createElement("th", null), /* @__PURE__ */ React68.createElement(
|
|
5415
|
+
"th",
|
|
5416
|
+
{
|
|
5417
|
+
className: buildColClass("value"),
|
|
5418
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
5419
|
+
},
|
|
5420
|
+
"Value ",
|
|
5421
|
+
/* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5422
|
+
))), /* @__PURE__ */ React68.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
5423
|
+
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
5424
|
+
return /* @__PURE__ */ React68.createElement(
|
|
5425
|
+
"tr",
|
|
5426
|
+
{
|
|
5427
|
+
key: `pl-side-table-item-${idx}`,
|
|
5428
|
+
className: classNames23(
|
|
5429
|
+
"Layer__profit-and-loss-detailed-table__row",
|
|
5430
|
+
hoveredItem && hoveredItem !== item.display_name ? "inactive" : ""
|
|
5431
|
+
),
|
|
5432
|
+
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
5433
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5434
|
+
},
|
|
5435
|
+
/* @__PURE__ */ React68.createElement("td", { className: "category-col" }, item.display_name),
|
|
5436
|
+
/* @__PURE__ */ React68.createElement("td", { className: "type-col" }, item.type),
|
|
5437
|
+
/* @__PURE__ */ React68.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
5438
|
+
/* @__PURE__ */ React68.createElement("td", { className: "share-col" }, /* @__PURE__ */ React68.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ React68.createElement(
|
|
5439
|
+
"div",
|
|
5440
|
+
{
|
|
5441
|
+
className: "share-icon",
|
|
5442
|
+
style: {
|
|
5443
|
+
background: colorConfig.color,
|
|
5444
|
+
opacity: colorConfig.opacity
|
|
5445
|
+
}
|
|
5446
|
+
}
|
|
5447
|
+
)))
|
|
5448
|
+
);
|
|
5449
|
+
}))))))
|
|
5450
|
+
);
|
|
5451
|
+
};
|
|
5452
|
+
|
|
5453
|
+
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
4799
5454
|
var COMPONENT_NAME3 = "profit-and-loss";
|
|
4800
5455
|
var ProfitAndLossView = (props) => {
|
|
4801
|
-
return /* @__PURE__ */
|
|
5456
|
+
return /* @__PURE__ */ React69.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ React69.createElement(ProfitAndLoss, null, /* @__PURE__ */ React69.createElement("div", { className: `Layer__${COMPONENT_NAME3}__main-panel` }, /* @__PURE__ */ React69.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ React69.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ React69.createElement(Components, { ...props })), props.showDetailedCharts !== false && /* @__PURE__ */ React69.createElement(ProfitAndLossDetailedCharts, null)));
|
|
4802
5457
|
};
|
|
4803
5458
|
var Components = ({
|
|
4804
5459
|
hideChart = false,
|
|
4805
5460
|
hideTable = false
|
|
4806
5461
|
}) => {
|
|
4807
|
-
const { error, isLoading, isValidating, refetch } =
|
|
5462
|
+
const { error, isLoading, isValidating, refetch } = useContext7(
|
|
4808
5463
|
ProfitAndLoss.Context
|
|
4809
5464
|
);
|
|
4810
5465
|
if (!isLoading && error) {
|
|
4811
|
-
return /* @__PURE__ */
|
|
5466
|
+
return /* @__PURE__ */ React69.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React69.createElement(
|
|
4812
5467
|
DataState,
|
|
4813
5468
|
{
|
|
4814
5469
|
status: "failed" /* failed */,
|
|
@@ -4819,24 +5474,24 @@ var Components = ({
|
|
|
4819
5474
|
}
|
|
4820
5475
|
));
|
|
4821
5476
|
}
|
|
4822
|
-
return /* @__PURE__ */
|
|
5477
|
+
return /* @__PURE__ */ React69.createElement(React69.Fragment, null, !hideChart && /* @__PURE__ */ React69.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ React69.createElement(
|
|
4823
5478
|
"div",
|
|
4824
5479
|
{
|
|
4825
5480
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
|
|
4826
5481
|
},
|
|
4827
|
-
/* @__PURE__ */
|
|
4828
|
-
/* @__PURE__ */
|
|
4829
|
-
), /* @__PURE__ */
|
|
5482
|
+
/* @__PURE__ */ React69.createElement(ProfitAndLoss.DatePicker, null),
|
|
5483
|
+
/* @__PURE__ */ React69.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
5484
|
+
), /* @__PURE__ */ React69.createElement(
|
|
4830
5485
|
"div",
|
|
4831
5486
|
{
|
|
4832
5487
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
|
|
4833
5488
|
},
|
|
4834
|
-
/* @__PURE__ */
|
|
4835
|
-
)), !hideTable && /* @__PURE__ */
|
|
5489
|
+
/* @__PURE__ */ React69.createElement(ProfitAndLoss.Chart, null)
|
|
5490
|
+
)), !hideTable && /* @__PURE__ */ React69.createElement(ProfitAndLoss.Table, null));
|
|
4836
5491
|
};
|
|
4837
5492
|
|
|
4838
5493
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
4839
|
-
import
|
|
5494
|
+
import React70, { useReducer, useEffect as useEffect9 } from "react";
|
|
4840
5495
|
import { add as add2, isBefore } from "date-fns";
|
|
4841
5496
|
import useSWR5, { SWRConfig } from "swr";
|
|
4842
5497
|
var reducer = (state, action) => {
|
|
@@ -4951,11 +5606,11 @@ var LayerProvider = ({
|
|
|
4951
5606
|
}
|
|
4952
5607
|
return;
|
|
4953
5608
|
};
|
|
4954
|
-
return /* @__PURE__ */
|
|
5609
|
+
return /* @__PURE__ */ React70.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React70.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
|
|
4955
5610
|
};
|
|
4956
5611
|
|
|
4957
5612
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
4958
|
-
import
|
|
5613
|
+
import React73, { useState as useState17 } from "react";
|
|
4959
5614
|
|
|
4960
5615
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
4961
5616
|
import useSWR6 from "swr";
|
|
@@ -4975,21 +5630,21 @@ var useChartOfAccounts = () => {
|
|
|
4975
5630
|
};
|
|
4976
5631
|
|
|
4977
5632
|
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
4978
|
-
import
|
|
4979
|
-
import
|
|
5633
|
+
import React71, { useMemo as useMemo6, useState as useState16 } from "react";
|
|
5634
|
+
import Select4 from "react-select";
|
|
4980
5635
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
4981
5636
|
var ChartOfAccountsNewForm = () => {
|
|
4982
5637
|
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
4983
|
-
const accountOptions =
|
|
5638
|
+
const accountOptions = useMemo6(
|
|
4984
5639
|
() => flattenAccounts(data?.accounts || []).sort(
|
|
4985
5640
|
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
4986
5641
|
),
|
|
4987
5642
|
[data?.accounts?.length]
|
|
4988
5643
|
);
|
|
4989
|
-
const [name, setName] =
|
|
4990
|
-
const [description, setDescription] =
|
|
4991
|
-
const [normality, setNormality] =
|
|
4992
|
-
const [parentAccount, setParentAccount] =
|
|
5644
|
+
const [name, setName] = useState16("");
|
|
5645
|
+
const [description, setDescription] = useState16("");
|
|
5646
|
+
const [normality, setNormality] = useState16("DEBIT" /* DEBIT */);
|
|
5647
|
+
const [parentAccount, setParentAccount] = useState16(
|
|
4993
5648
|
data?.accounts[0]
|
|
4994
5649
|
);
|
|
4995
5650
|
const save = () => {
|
|
@@ -5003,22 +5658,22 @@ var ChartOfAccountsNewForm = () => {
|
|
|
5003
5658
|
description
|
|
5004
5659
|
});
|
|
5005
5660
|
};
|
|
5006
|
-
return /* @__PURE__ */
|
|
5661
|
+
return /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Name"), /* @__PURE__ */ React71.createElement(
|
|
5007
5662
|
"input",
|
|
5008
5663
|
{
|
|
5009
5664
|
name: "name",
|
|
5010
5665
|
value: name,
|
|
5011
5666
|
onChange: (event) => setName(event.target.value)
|
|
5012
5667
|
}
|
|
5013
|
-
)), /* @__PURE__ */
|
|
5668
|
+
)), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Description"), /* @__PURE__ */ React71.createElement(
|
|
5014
5669
|
"input",
|
|
5015
5670
|
{
|
|
5016
5671
|
name: "description",
|
|
5017
5672
|
value: description,
|
|
5018
5673
|
onChange: (event) => setDescription(event.target.value)
|
|
5019
5674
|
}
|
|
5020
|
-
)), /* @__PURE__ */
|
|
5021
|
-
|
|
5675
|
+
)), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Normality"), /* @__PURE__ */ React71.createElement(
|
|
5676
|
+
Select4,
|
|
5022
5677
|
{
|
|
5023
5678
|
isSearchable: false,
|
|
5024
5679
|
onChange: (value) => value && setNormality(value.value),
|
|
@@ -5027,8 +5682,8 @@ var ChartOfAccountsNewForm = () => {
|
|
|
5027
5682
|
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
5028
5683
|
]
|
|
5029
5684
|
}
|
|
5030
|
-
)), /* @__PURE__ */
|
|
5031
|
-
|
|
5685
|
+
)), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Parent Account"), /* @__PURE__ */ React71.createElement(
|
|
5686
|
+
Select4,
|
|
5032
5687
|
{
|
|
5033
5688
|
isSearchable: true,
|
|
5034
5689
|
value: parentAccount,
|
|
@@ -5037,49 +5692,49 @@ var ChartOfAccountsNewForm = () => {
|
|
|
5037
5692
|
getOptionValue: (a) => a.id,
|
|
5038
5693
|
options: accountOptions
|
|
5039
5694
|
}
|
|
5040
|
-
)), /* @__PURE__ */
|
|
5695
|
+
)), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ React71.createElement("button", { onClick: save }, "Save")));
|
|
5041
5696
|
};
|
|
5042
5697
|
|
|
5043
5698
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
5044
|
-
import
|
|
5699
|
+
import React72 from "react";
|
|
5045
5700
|
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
5046
|
-
const
|
|
5701
|
+
const classNames24 = [
|
|
5047
5702
|
"Layer__chart-of-accounts-row__table-cell",
|
|
5048
5703
|
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
5049
5704
|
];
|
|
5050
|
-
const className =
|
|
5705
|
+
const className = classNames24.filter((id) => id).join(" ");
|
|
5051
5706
|
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
5052
|
-
return /* @__PURE__ */
|
|
5707
|
+
return /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement(
|
|
5053
5708
|
"div",
|
|
5054
5709
|
{
|
|
5055
5710
|
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
5056
5711
|
},
|
|
5057
5712
|
account.name
|
|
5058
|
-
), /* @__PURE__ */
|
|
5713
|
+
), /* @__PURE__ */ React72.createElement(
|
|
5059
5714
|
"div",
|
|
5060
5715
|
{
|
|
5061
5716
|
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
5062
5717
|
},
|
|
5063
5718
|
"Assets"
|
|
5064
|
-
), /* @__PURE__ */
|
|
5719
|
+
), /* @__PURE__ */ React72.createElement(
|
|
5065
5720
|
"div",
|
|
5066
5721
|
{
|
|
5067
5722
|
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
5068
5723
|
},
|
|
5069
5724
|
"Cash"
|
|
5070
|
-
), /* @__PURE__ */
|
|
5725
|
+
), /* @__PURE__ */ React72.createElement(
|
|
5071
5726
|
"div",
|
|
5072
5727
|
{
|
|
5073
5728
|
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
5074
5729
|
},
|
|
5075
5730
|
centsToDollars(Math.abs(account.balance || 0))
|
|
5076
|
-
), /* @__PURE__ */
|
|
5731
|
+
), /* @__PURE__ */ React72.createElement(
|
|
5077
5732
|
"div",
|
|
5078
5733
|
{
|
|
5079
5734
|
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
5080
5735
|
},
|
|
5081
|
-
/* @__PURE__ */
|
|
5082
|
-
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */
|
|
5736
|
+
/* @__PURE__ */ React72.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
|
|
5737
|
+
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ React72.createElement(
|
|
5083
5738
|
ChartOfAccountsRow,
|
|
5084
5739
|
{
|
|
5085
5740
|
key: subAccount.id,
|
|
@@ -5092,15 +5747,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
|
5092
5747
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
5093
5748
|
var ChartOfAccounts = () => {
|
|
5094
5749
|
const { data, isLoading } = useChartOfAccounts();
|
|
5095
|
-
const [showingForm, setShowingForm] =
|
|
5096
|
-
return /* @__PURE__ */
|
|
5750
|
+
const [showingForm, setShowingForm] = useState17(false);
|
|
5751
|
+
return /* @__PURE__ */ React73.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ React73.createElement(React73.Fragment, null, /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ React73.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ React73.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ React73.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ React73.createElement(
|
|
5097
5752
|
"button",
|
|
5098
5753
|
{
|
|
5099
5754
|
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
5100
5755
|
onClick: () => setShowingForm(!showingForm)
|
|
5101
5756
|
},
|
|
5102
5757
|
"Edit Accounts"
|
|
5103
|
-
))), showingForm && /* @__PURE__ */
|
|
5758
|
+
))), showingForm && /* @__PURE__ */ React73.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ React73.createElement(
|
|
5104
5759
|
ChartOfAccountsRow,
|
|
5105
5760
|
{
|
|
5106
5761
|
key: account.id,
|