@mulmoclaude/accounting-plugin 1.2.1 → 1.3.0
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/server/bodyFields.d.ts +8 -1
- package/dist/server/bodyFields.d.ts.map +1 -1
- package/dist/server/io.d.ts.map +1 -1
- package/dist/server/journal.d.ts +7 -0
- package/dist/server/journal.d.ts.map +1 -1
- package/dist/server/report.d.ts.map +1 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/service.d.ts.map +1 -1
- package/dist/server/snapshotCache.d.ts.map +1 -1
- package/dist/server/timeSeries.d.ts.map +1 -1
- package/dist/server.cjs +364 -323
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +364 -323
- package/dist/server.js.map +1 -1
- package/dist/shared/fiscalYear.d.ts.map +1 -1
- package/dist/shared/types.d.ts +2 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/{shared-qp9j-GTD.js → shared-BZAAF-I4.js} +16 -11
- package/dist/shared-BZAAF-I4.js.map +1 -0
- package/dist/{shared-C9K9ZkfK.cjs → shared-BpFVwa6Y.cjs} +27 -10
- package/dist/shared-BpFVwa6Y.cjs.map +1 -0
- package/dist/shared.cjs +2 -1
- package/dist/shared.js +2 -2
- package/dist/style.css +3 -3
- package/dist/vue/Preview.vue.d.ts.map +1 -1
- package/dist/vue/View.vue.d.ts.map +1 -1
- package/dist/vue/components/BalanceSheet.vue.d.ts.map +1 -1
- package/dist/vue/components/BookSwitcher.vue.d.ts.map +1 -1
- package/dist/vue/components/DateRangePicker.vue.d.ts.map +1 -1
- package/dist/vue/components/NewBookForm.vue.d.ts.map +1 -1
- package/dist/vue/components/OpeningBalancesForm.vue.d.ts.map +1 -1
- package/dist/vue/components/accountNumbering.d.ts.map +1 -1
- package/dist/vue/previewSummary.d.ts +15 -0
- package/dist/vue/previewSummary.d.ts.map +1 -0
- package/dist/vue/useAccountingChannel.d.ts.map +1 -1
- package/dist/vue.cjs +138 -89
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js +138 -89
- package/dist/vue.js.map +1 -1
- package/package.json +3 -3
- package/dist/shared-C9K9ZkfK.cjs.map +0 -1
- package/dist/shared-qp9j-GTD.js.map +0 -1
package/dist/vue.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shared = require("./shared-
|
|
2
|
+
const require_shared = require("./shared-BpFVwa6Y.cjs");
|
|
3
3
|
let vue = require("vue");
|
|
4
4
|
let _mulmoclaude_core_plugin_vue_i18n = require("@mulmoclaude/core/plugin-vue/i18n");
|
|
5
5
|
//#region src/vue/hostContext.ts
|
|
@@ -1845,7 +1845,7 @@ var NewBookForm_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1845
1845
|
function regionFromLocaleTag(tag) {
|
|
1846
1846
|
try {
|
|
1847
1847
|
const { region } = new Intl.Locale(tag).maximize();
|
|
1848
|
-
if (
|
|
1848
|
+
if (require_shared.isSupportedCountryCode(region)) return region;
|
|
1849
1849
|
} catch {}
|
|
1850
1850
|
return "";
|
|
1851
1851
|
}
|
|
@@ -2016,7 +2016,8 @@ var BookSwitcher_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2016
2016
|
return `${book.name} (${suffix})`;
|
|
2017
2017
|
}
|
|
2018
2018
|
function onSelect(event) {
|
|
2019
|
-
const target = event
|
|
2019
|
+
const { target } = event;
|
|
2020
|
+
if (!(target instanceof HTMLSelectElement)) return;
|
|
2020
2021
|
const bookId = target.value;
|
|
2021
2022
|
if (bookId === NEW_BOOK_SENTINEL) {
|
|
2022
2023
|
target.value = props.modelValue;
|
|
@@ -2140,7 +2141,10 @@ var DateRangePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2140
2141
|
if (rangesEqual(value, UNBOUNDED_RANGE)) return "all";
|
|
2141
2142
|
return "";
|
|
2142
2143
|
});
|
|
2143
|
-
function onShortcutChange(
|
|
2144
|
+
function onShortcutChange(event) {
|
|
2145
|
+
const { target } = event;
|
|
2146
|
+
if (!(target instanceof HTMLSelectElement)) return;
|
|
2147
|
+
const raw = target.value;
|
|
2144
2148
|
const today = /* @__PURE__ */ new Date();
|
|
2145
2149
|
if (raw === "currentQuarter") emit("update:modelValue", require_shared.currentQuarterRange(props.fiscalYearEnd, today));
|
|
2146
2150
|
else if (raw === "previousQuarter") emit("update:modelValue", require_shared.previousQuarterRange(props.fiscalYearEnd, today));
|
|
@@ -2151,16 +2155,20 @@ var DateRangePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2151
2155
|
if (lifetime) emit("update:modelValue", lifetime);
|
|
2152
2156
|
} else if (raw === "all") emit("update:modelValue", UNBOUNDED_RANGE);
|
|
2153
2157
|
}
|
|
2154
|
-
function onFromChange(
|
|
2158
|
+
function onFromChange(event) {
|
|
2159
|
+
const { target } = event;
|
|
2160
|
+
if (!(target instanceof HTMLInputElement)) return;
|
|
2155
2161
|
emit("update:modelValue", {
|
|
2156
|
-
from: value,
|
|
2162
|
+
from: target.value,
|
|
2157
2163
|
to: props.modelValue.to
|
|
2158
2164
|
});
|
|
2159
2165
|
}
|
|
2160
|
-
function onToChange(
|
|
2166
|
+
function onToChange(event) {
|
|
2167
|
+
const { target } = event;
|
|
2168
|
+
if (!(target instanceof HTMLInputElement)) return;
|
|
2161
2169
|
emit("update:modelValue", {
|
|
2162
2170
|
from: props.modelValue.from,
|
|
2163
|
-
to: value
|
|
2171
|
+
to: target.value
|
|
2164
2172
|
});
|
|
2165
2173
|
}
|
|
2166
2174
|
return (_ctx, _cache) => {
|
|
@@ -2169,9 +2177,9 @@ var DateRangePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2169
2177
|
value: selectedShortcut.value,
|
|
2170
2178
|
class: "h-8 px-2 rounded border border-gray-300 text-sm bg-white",
|
|
2171
2179
|
"data-testid": "accounting-daterange-shortcut",
|
|
2172
|
-
onChange:
|
|
2180
|
+
onChange: onShortcutChange
|
|
2173
2181
|
}, [
|
|
2174
|
-
_cache[
|
|
2182
|
+
_cache[0] || (_cache[0] = (0, vue.createElementVNode)("option", {
|
|
2175
2183
|
value: "",
|
|
2176
2184
|
hidden: ""
|
|
2177
2185
|
}, null, -1)),
|
|
@@ -2187,14 +2195,14 @@ var DateRangePicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2187
2195
|
type: "date",
|
|
2188
2196
|
class: "h-8 px-2 rounded border border-gray-300 text-sm",
|
|
2189
2197
|
"data-testid": "accounting-daterange-from",
|
|
2190
|
-
onInput:
|
|
2198
|
+
onInput: onFromChange
|
|
2191
2199
|
}, null, 40, _hoisted_11$9)]),
|
|
2192
2200
|
(0, vue.createElementVNode)("label", _hoisted_12$9, [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.dateRange.toLabel")) + " ", 1), (0, vue.createElementVNode)("input", {
|
|
2193
2201
|
value: __props.modelValue.to,
|
|
2194
2202
|
type: "date",
|
|
2195
2203
|
class: "h-8 px-2 rounded border border-gray-300 text-sm",
|
|
2196
2204
|
"data-testid": "accounting-daterange-to",
|
|
2197
|
-
onInput:
|
|
2205
|
+
onInput: onToChange
|
|
2198
2206
|
}, null, 40, _hoisted_13$9)])
|
|
2199
2207
|
]);
|
|
2200
2208
|
};
|
|
@@ -2227,9 +2235,8 @@ function isValidAccountCode(code) {
|
|
|
2227
2235
|
}
|
|
2228
2236
|
function typeForCode(code) {
|
|
2229
2237
|
if (!isValidAccountCode(code)) return null;
|
|
2230
|
-
const leading = Number.parseInt(code
|
|
2231
|
-
|
|
2232
|
-
return null;
|
|
2238
|
+
const leading = Number.parseInt(code.charAt(0), 10);
|
|
2239
|
+
return require_shared.ACCOUNT_TYPES.find((type) => ACCOUNT_TYPE_PREFIX[type] === leading) ?? null;
|
|
2233
2240
|
}
|
|
2234
2241
|
function codeMatchesType(code, type) {
|
|
2235
2242
|
return typeForCode(code) === type;
|
|
@@ -2641,7 +2648,7 @@ var AccountsModal_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2641
2648
|
}
|
|
2642
2649
|
function bindNewEditor(node, sectionType) {
|
|
2643
2650
|
if (sectionType !== draft.value.type) return;
|
|
2644
|
-
newEditorWrapper.value = node
|
|
2651
|
+
newEditorWrapper.value = node instanceof HTMLDivElement ? node : null;
|
|
2645
2652
|
}
|
|
2646
2653
|
function onEdit(account) {
|
|
2647
2654
|
addingNew.value = false;
|
|
@@ -3750,12 +3757,21 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3750
3757
|
credit: null
|
|
3751
3758
|
};
|
|
3752
3759
|
}
|
|
3760
|
+
const accountRows = (0, vue.computed)(() => bsAccounts.value.flatMap((account) => {
|
|
3761
|
+
const row = rows.value[account.code];
|
|
3762
|
+
return row ? [{
|
|
3763
|
+
account,
|
|
3764
|
+
row
|
|
3765
|
+
}] : [];
|
|
3766
|
+
}));
|
|
3753
3767
|
function onDebitInput(code) {
|
|
3754
3768
|
const row = rows.value[code];
|
|
3769
|
+
if (!row) return;
|
|
3755
3770
|
if (row.debit !== null && row.debit !== 0) row.credit = null;
|
|
3756
3771
|
}
|
|
3757
3772
|
function onCreditInput(code) {
|
|
3758
3773
|
const row = rows.value[code];
|
|
3774
|
+
if (!row) return;
|
|
3759
3775
|
if (row.credit !== null && row.credit !== 0) row.debit = null;
|
|
3760
3776
|
}
|
|
3761
3777
|
const imbalance = (0, vue.computed)(() => {
|
|
@@ -3779,12 +3795,13 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3779
3795
|
for (const account of bsAccounts.value) {
|
|
3780
3796
|
const row = rows.value[account.code];
|
|
3781
3797
|
if (!row) continue;
|
|
3782
|
-
const
|
|
3783
|
-
const
|
|
3798
|
+
const { debit, credit } = row;
|
|
3799
|
+
const debitOk = isPositiveAmount(debit);
|
|
3800
|
+
const creditOk = isPositiveAmount(credit);
|
|
3784
3801
|
if (!debitOk && !creditOk) continue;
|
|
3785
3802
|
const line = { accountCode: account.code };
|
|
3786
|
-
if (debitOk) line.debit =
|
|
3787
|
-
if (creditOk) line.credit =
|
|
3803
|
+
if (debitOk) line.debit = debit;
|
|
3804
|
+
if (creditOk) line.credit = credit;
|
|
3788
3805
|
out.push(line);
|
|
3789
3806
|
}
|
|
3790
3807
|
return out;
|
|
@@ -3874,7 +3891,7 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3874
3891
|
(0, vue.createElementVNode)("th", _hoisted_11$5, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.entryForm.accountLabel")), 1),
|
|
3875
3892
|
(0, vue.createElementVNode)("th", _hoisted_12$5, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.entryForm.debitLabel")), 1),
|
|
3876
3893
|
(0, vue.createElementVNode)("th", _hoisted_13$5, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.entryForm.creditLabel")), 1)
|
|
3877
|
-
])]), (0, vue.createElementVNode)("tbody", null, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(
|
|
3894
|
+
])]), (0, vue.createElementVNode)("tbody", null, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(accountRows.value, ({ account, row }) => {
|
|
3878
3895
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("tr", {
|
|
3879
3896
|
key: account.code,
|
|
3880
3897
|
class: "border-b border-gray-100"
|
|
@@ -3885,7 +3902,7 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3885
3902
|
(0, vue.createElementVNode)("span", _hoisted_16$4, (0, vue.toDisplayString)(account.type), 1)
|
|
3886
3903
|
]),
|
|
3887
3904
|
(0, vue.createElementVNode)("td", _hoisted_17$4, [(0, vue.withDirectives)((0, vue.createElementVNode)("input", {
|
|
3888
|
-
"onUpdate:modelValue": ($event) =>
|
|
3905
|
+
"onUpdate:modelValue": ($event) => row.debit = $event,
|
|
3889
3906
|
type: "number",
|
|
3890
3907
|
step: step.value,
|
|
3891
3908
|
min: "0",
|
|
@@ -3894,12 +3911,12 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3894
3911
|
onInput: ($event) => onDebitInput(account.code)
|
|
3895
3912
|
}, null, 40, _hoisted_18$4), [[
|
|
3896
3913
|
vue.vModelText,
|
|
3897
|
-
|
|
3914
|
+
row.debit,
|
|
3898
3915
|
void 0,
|
|
3899
3916
|
{ number: true }
|
|
3900
3917
|
]])]),
|
|
3901
3918
|
(0, vue.createElementVNode)("td", _hoisted_19$4, [(0, vue.withDirectives)((0, vue.createElementVNode)("input", {
|
|
3902
|
-
"onUpdate:modelValue": ($event) =>
|
|
3919
|
+
"onUpdate:modelValue": ($event) => row.credit = $event,
|
|
3903
3920
|
type: "number",
|
|
3904
3921
|
step: step.value,
|
|
3905
3922
|
min: "0",
|
|
@@ -3908,7 +3925,7 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3908
3925
|
onInput: ($event) => onCreditInput(account.code)
|
|
3909
3926
|
}, null, 40, _hoisted_20$4), [[
|
|
3910
3927
|
vue.vModelText,
|
|
3911
|
-
|
|
3928
|
+
row.credit,
|
|
3912
3929
|
void 0,
|
|
3913
3930
|
{ number: true }
|
|
3914
3931
|
]])])
|
|
@@ -3934,7 +3951,7 @@ var OpeningBalancesForm_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
3934
3951
|
}, null, 8, ["book-id", "accounts"])) : (0, vue.createCommentVNode)("", true)], 64);
|
|
3935
3952
|
};
|
|
3936
3953
|
}
|
|
3937
|
-
}), [["__scopeId", "data-v-
|
|
3954
|
+
}), [["__scopeId", "data-v-eb577d9f"]]);
|
|
3938
3955
|
//#endregion
|
|
3939
3956
|
//#region src/vue/components/AccountsList.vue?vue&type=script&setup=true&lang.ts
|
|
3940
3957
|
var _hoisted_1$6 = {
|
|
@@ -4317,7 +4334,10 @@ var BalanceSheet_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4317
4334
|
if (value === require_shared.decemberOfPreviousYearString(now)) return "lastYear";
|
|
4318
4335
|
return "";
|
|
4319
4336
|
});
|
|
4320
|
-
function onShortcutChange(
|
|
4337
|
+
function onShortcutChange(event) {
|
|
4338
|
+
const { target } = event;
|
|
4339
|
+
if (!(target instanceof HTMLSelectElement)) return;
|
|
4340
|
+
const raw = target.value;
|
|
4321
4341
|
const now = /* @__PURE__ */ new Date();
|
|
4322
4342
|
if (raw === "thisMonth") period.value = require_shared.localMonthString(now);
|
|
4323
4343
|
else if (raw === "lastMonth") period.value = require_shared.previousMonthString(now);
|
|
@@ -4355,9 +4375,9 @@ var BalanceSheet_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4355
4375
|
value: selectedShortcut.value,
|
|
4356
4376
|
class: "h-8 px-2 rounded border border-gray-300 text-sm bg-white",
|
|
4357
4377
|
"data-testid": "accounting-bs-shortcut",
|
|
4358
|
-
onChange:
|
|
4378
|
+
onChange: onShortcutChange
|
|
4359
4379
|
}, [
|
|
4360
|
-
_cache[
|
|
4380
|
+
_cache[1] || (_cache[1] = (0, vue.createElementVNode)("option", {
|
|
4361
4381
|
value: "",
|
|
4362
4382
|
hidden: ""
|
|
4363
4383
|
}, null, -1)),
|
|
@@ -4367,7 +4387,7 @@ var BalanceSheet_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4367
4387
|
(0, vue.createElementVNode)("option", _hoisted_8$3, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.balanceSheet.lastYear")), 1)
|
|
4368
4388
|
], 40, _hoisted_4$3)]),
|
|
4369
4389
|
(0, vue.createElementVNode)("label", _hoisted_9$3, [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.balanceSheet.asOfLabel")) + " ", 1), (0, vue.withDirectives)((0, vue.createElementVNode)("input", {
|
|
4370
|
-
"onUpdate:modelValue": _cache[
|
|
4390
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => period.value = $event),
|
|
4371
4391
|
type: "month",
|
|
4372
4392
|
class: "h-8 px-2 rounded border border-gray-300 text-sm",
|
|
4373
4393
|
"data-testid": "accounting-bs-period"
|
|
@@ -4375,7 +4395,7 @@ var BalanceSheet_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4375
4395
|
(0, vue.createElementVNode)("button", {
|
|
4376
4396
|
class: "h-8 px-2.5 rounded border border-gray-300 text-sm text-gray-600 hover:bg-gray-50",
|
|
4377
4397
|
onClick: refresh
|
|
4378
|
-
}, [..._cache[
|
|
4398
|
+
}, [..._cache[2] || (_cache[2] = [(0, vue.createElementVNode)("span", { class: "material-icons text-base align-middle" }, "refresh", -1)])])
|
|
4379
4399
|
]), loading.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("p", _hoisted_10$3, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.common.loading")), 1)) : error.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("p", _hoisted_11$3, (0, vue.toDisplayString)((0, vue.unref)(t)("pluginAccounting.common.error", { error: error.value })), 1)) : balanceSheet.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.createElementVNode)("div", _hoisted_12$3, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(balanceSheet.value.sections, (section) => {
|
|
4380
4400
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("section", {
|
|
4381
4401
|
key: section.type,
|
|
@@ -4828,6 +4848,19 @@ var BookSettings_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4828
4848
|
});
|
|
4829
4849
|
//#endregion
|
|
4830
4850
|
//#region src/vue/useAccountingChannel.ts
|
|
4851
|
+
var BOOK_EVENT_KIND_VALUES = Object.values(require_shared.BOOK_EVENT_KINDS);
|
|
4852
|
+
/** The host hands subscribers an `unknown`, so rebuild the payload from
|
|
4853
|
+
* the fields we can prove rather than trusting the publisher's type. */
|
|
4854
|
+
function toBookChannelPayload(data) {
|
|
4855
|
+
if (typeof data !== "object" || data === null || !("kind" in data)) return null;
|
|
4856
|
+
const kind = BOOK_EVENT_KIND_VALUES.find((candidate) => candidate === data.kind);
|
|
4857
|
+
if (kind === void 0) return null;
|
|
4858
|
+
const period = "period" in data && typeof data.period === "string" ? data.period : void 0;
|
|
4859
|
+
return period === void 0 ? { kind } : {
|
|
4860
|
+
kind,
|
|
4861
|
+
period
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4831
4864
|
function useAccountingChannel(bookId, onPayload) {
|
|
4832
4865
|
const version = (0, vue.ref)(0);
|
|
4833
4866
|
let unsubscribe = null;
|
|
@@ -4837,9 +4870,9 @@ function useAccountingChannel(bookId, onPayload) {
|
|
|
4837
4870
|
version.value = 0;
|
|
4838
4871
|
if (!nextBookId) return;
|
|
4839
4872
|
unsubscribe = hostSubscribe(require_shared.bookChannel(nextBookId), (data) => {
|
|
4840
|
-
const event = data;
|
|
4841
4873
|
version.value += 1;
|
|
4842
|
-
|
|
4874
|
+
const event = toBookChannelPayload(data);
|
|
4875
|
+
if (event) onPayload?.(event);
|
|
4843
4876
|
});
|
|
4844
4877
|
}
|
|
4845
4878
|
(0, vue.watch)(bookId, bind, { immediate: true });
|
|
@@ -4955,7 +4988,7 @@ var View_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4955
4988
|
}
|
|
4956
4989
|
];
|
|
4957
4990
|
function isTabKey(value) {
|
|
4958
|
-
return
|
|
4991
|
+
return TAB_KEYS.some((key) => key === value);
|
|
4959
4992
|
}
|
|
4960
4993
|
const initialPayload = (0, vue.computed)(() => props.selectedResult?.data ?? props.selectedResult?.jsonData ?? {});
|
|
4961
4994
|
const currentTab = (0, vue.ref)((0, vue.computed)(() => isTabKey(initialPayload.value.initialTab) ? initialPayload.value.initialTab : "journal").value);
|
|
@@ -4978,10 +5011,11 @@ var View_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
4978
5011
|
const { version: bookVersion } = useAccountingChannel(activeBookId);
|
|
4979
5012
|
useAccountingBooksChannel(() => void refetchBooks());
|
|
4980
5013
|
function pickInitialBookId() {
|
|
4981
|
-
|
|
5014
|
+
const [firstBook] = books.value;
|
|
5015
|
+
if (!firstBook) return null;
|
|
4982
5016
|
const requested = initialPayload.value.bookId;
|
|
4983
5017
|
if (requested && books.value.some((book) => book.id === requested)) return requested;
|
|
4984
|
-
return
|
|
5018
|
+
return firstBook.id;
|
|
4985
5019
|
}
|
|
4986
5020
|
async function refetchBooks() {
|
|
4987
5021
|
loadingBooks.value = true;
|
|
@@ -5260,6 +5294,73 @@ var View_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
5260
5294
|
}
|
|
5261
5295
|
});
|
|
5262
5296
|
//#endregion
|
|
5297
|
+
//#region src/vue/previewSummary.ts
|
|
5298
|
+
var optionalString = (value) => typeof value === "string" ? value : void 0;
|
|
5299
|
+
var optionalNumber = (value) => typeof value === "number" ? value : void 0;
|
|
5300
|
+
function summariseError(json, translate) {
|
|
5301
|
+
const error = optionalString(json.error);
|
|
5302
|
+
if (error === void 0) return null;
|
|
5303
|
+
return translate("pluginAccounting.previewError", { error });
|
|
5304
|
+
}
|
|
5305
|
+
function summariseEntry(json, translate) {
|
|
5306
|
+
const [first] = require_shared.isUnknownArray(json.entries) ? json.entries : [];
|
|
5307
|
+
const entry = require_shared.isRecord(first) ? first : void 0;
|
|
5308
|
+
const entryId = optionalString(entry?.id);
|
|
5309
|
+
const date = optionalString(entry?.date);
|
|
5310
|
+
if (!entryId || !date) return null;
|
|
5311
|
+
return translate("pluginAccounting.preview.entry", { date });
|
|
5312
|
+
}
|
|
5313
|
+
function summarisePl(json, translate) {
|
|
5314
|
+
const { profitLoss } = json;
|
|
5315
|
+
if (!require_shared.isRecord(profitLoss)) return null;
|
|
5316
|
+
const netIncome = optionalNumber(profitLoss.netIncome);
|
|
5317
|
+
if (netIncome === void 0) return null;
|
|
5318
|
+
return translate("pluginAccounting.preview.pl", {
|
|
5319
|
+
from: optionalString(profitLoss.from) ?? "?",
|
|
5320
|
+
to: optionalString(profitLoss.to) ?? "?",
|
|
5321
|
+
net: require_shared.formatAmountNumeric(netIncome)
|
|
5322
|
+
});
|
|
5323
|
+
}
|
|
5324
|
+
function summariseBs(json, translate) {
|
|
5325
|
+
const { balanceSheet } = json;
|
|
5326
|
+
if (!require_shared.isRecord(balanceSheet)) return null;
|
|
5327
|
+
const date = optionalString(balanceSheet.asOf);
|
|
5328
|
+
const sections = require_shared.isUnknownArray(balanceSheet.sections) ? balanceSheet.sections : void 0;
|
|
5329
|
+
if (!date || !sections) return null;
|
|
5330
|
+
const assets = sections.find((section) => require_shared.isRecord(section) && section.type === "asset");
|
|
5331
|
+
return translate("pluginAccounting.preview.bs", {
|
|
5332
|
+
date,
|
|
5333
|
+
assets: require_shared.isRecord(assets) ? require_shared.formatAmountNumeric(optionalNumber(assets.total) ?? 0) : "?"
|
|
5334
|
+
});
|
|
5335
|
+
}
|
|
5336
|
+
function summariseBook(json, translate) {
|
|
5337
|
+
const { book } = json;
|
|
5338
|
+
if (!require_shared.isRecord(book)) return null;
|
|
5339
|
+
const bookId = optionalString(book.id);
|
|
5340
|
+
const name = optionalString(book.name);
|
|
5341
|
+
if (!bookId || !name) return null;
|
|
5342
|
+
return translate("pluginAccounting.preview.bookCreated", {
|
|
5343
|
+
name,
|
|
5344
|
+
id: bookId
|
|
5345
|
+
});
|
|
5346
|
+
}
|
|
5347
|
+
function summariseFallback(json, translate) {
|
|
5348
|
+
const bookId = optionalString(json.bookId);
|
|
5349
|
+
if (bookId !== void 0) return translate("pluginAccounting.previewSummary", { bookId });
|
|
5350
|
+
return translate("pluginAccounting.previewGeneric");
|
|
5351
|
+
}
|
|
5352
|
+
/** Merge the two props a host might carry the payload on. `isRecord` rejects
|
|
5353
|
+
* arrays, which the old `typeof value === "object"` check spread into the
|
|
5354
|
+
* payload. */
|
|
5355
|
+
var asPayload = (value) => require_shared.isRecord(value) ? value : {};
|
|
5356
|
+
function summarisePreview(data, jsonData, translate) {
|
|
5357
|
+
const json = {
|
|
5358
|
+
...asPayload(data),
|
|
5359
|
+
...asPayload(jsonData)
|
|
5360
|
+
};
|
|
5361
|
+
return summariseError(json, translate) ?? summariseEntry(json, translate) ?? summarisePl(json, translate) ?? summariseBs(json, translate) ?? summariseBook(json, translate) ?? summariseFallback(json, translate);
|
|
5362
|
+
}
|
|
5363
|
+
//#endregion
|
|
5263
5364
|
//#region src/vue/Preview.vue?vue&type=script&setup=true&lang.ts
|
|
5264
5365
|
var _hoisted_1 = {
|
|
5265
5366
|
class: "text-sm text-gray-700",
|
|
@@ -5276,59 +5377,7 @@ var Preview_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
5276
5377
|
setup(__props) {
|
|
5277
5378
|
const { t } = useAccountingI18n();
|
|
5278
5379
|
const props = __props;
|
|
5279
|
-
|
|
5280
|
-
const { error } = json;
|
|
5281
|
-
if (typeof error !== "string") return null;
|
|
5282
|
-
return t("pluginAccounting.previewError", { error });
|
|
5283
|
-
}
|
|
5284
|
-
function summariseEntry(json) {
|
|
5285
|
-
const { entries } = json;
|
|
5286
|
-
if (!Array.isArray(entries) || entries.length === 0) return null;
|
|
5287
|
-
const [first] = entries;
|
|
5288
|
-
if (!first?.id || !first?.date) return null;
|
|
5289
|
-
return t("pluginAccounting.preview.entry", { date: first.date });
|
|
5290
|
-
}
|
|
5291
|
-
function summarisePl(json) {
|
|
5292
|
-
const { profitLoss } = json;
|
|
5293
|
-
if (!profitLoss || typeof profitLoss.netIncome !== "number") return null;
|
|
5294
|
-
return t("pluginAccounting.preview.pl", {
|
|
5295
|
-
from: profitLoss.from ?? "?",
|
|
5296
|
-
to: profitLoss.to ?? "?",
|
|
5297
|
-
net: require_shared.formatAmountNumeric(profitLoss.netIncome)
|
|
5298
|
-
});
|
|
5299
|
-
}
|
|
5300
|
-
function summariseBs(json) {
|
|
5301
|
-
const { balanceSheet } = json;
|
|
5302
|
-
if (!balanceSheet?.asOf || !balanceSheet.sections) return null;
|
|
5303
|
-
const assets = balanceSheet.sections.find((section) => section.type === "asset");
|
|
5304
|
-
return t("pluginAccounting.preview.bs", {
|
|
5305
|
-
date: balanceSheet.asOf,
|
|
5306
|
-
assets: assets ? require_shared.formatAmountNumeric(assets.total ?? 0) : "?"
|
|
5307
|
-
});
|
|
5308
|
-
}
|
|
5309
|
-
function summariseBook(json) {
|
|
5310
|
-
const { book } = json;
|
|
5311
|
-
if (!book?.id || !book?.name) return null;
|
|
5312
|
-
return t("pluginAccounting.preview.bookCreated", {
|
|
5313
|
-
name: book.name,
|
|
5314
|
-
id: book.id
|
|
5315
|
-
});
|
|
5316
|
-
}
|
|
5317
|
-
function summariseFallback(json) {
|
|
5318
|
-
const { bookId } = json;
|
|
5319
|
-
if (typeof bookId === "string") return t("pluginAccounting.previewSummary", { bookId });
|
|
5320
|
-
return t("pluginAccounting.previewGeneric");
|
|
5321
|
-
}
|
|
5322
|
-
function asObject(value) {
|
|
5323
|
-
return value && typeof value === "object" ? value : {};
|
|
5324
|
-
}
|
|
5325
|
-
const summary = (0, vue.computed)(() => {
|
|
5326
|
-
const json = {
|
|
5327
|
-
...asObject(props.data),
|
|
5328
|
-
...asObject(props.jsonData)
|
|
5329
|
-
};
|
|
5330
|
-
return summariseError(json) ?? summariseEntry(json) ?? summarisePl(json) ?? summariseBs(json) ?? summariseBook(json) ?? summariseFallback(json);
|
|
5331
|
-
});
|
|
5380
|
+
const summary = (0, vue.computed)(() => summarisePreview(props.data, props.jsonData, t));
|
|
5332
5381
|
return (_ctx, _cache) => {
|
|
5333
5382
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1, [_cache[0] || (_cache[0] = (0, vue.createElementVNode)("span", { class: "material-icons text-base align-middle mr-1" }, "account_balance", -1)), (0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(summary.value), 1)]);
|
|
5334
5383
|
};
|