@7365admin1/layer-common 4.97.1-staging.655 → 4.97.1-staging.657
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/components/InventoryItemDetail.vue +6 -8
- package/components/InventoryLinesDialog.vue +6 -1
- package/components/InventoryMain.vue +54 -3
- package/components/InventoryReportsTab.vue +9 -1
- package/components/InventorySettingsTab.vue +1 -1
- package/composables/useInventoryPermission.ts +8 -1
- package/package.json +1 -1
- package/types/inventory.d.ts +2 -0
- package/utils/inventory-store-label.ts +36 -0
- package/utils/work-order-link.ts +24 -0
|
@@ -105,6 +105,7 @@ import { inventoryItemMeta } from "../utils/inventory-store-label";
|
|
|
105
105
|
import { inventoryControls } from "../utils/inventory-presets";
|
|
106
106
|
import { receiptRefText } from "../utils/inventory-receiving";
|
|
107
107
|
import { availableText, inventoryStepsLive, lowStockAlertText, qtyUnit, unitWord, writeOffLabel } from "../utils/inventory-ack";
|
|
108
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
108
109
|
|
|
109
110
|
const show = defineModel<boolean>({ default: false });
|
|
110
111
|
const props = defineProps({
|
|
@@ -134,17 +135,14 @@ const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
|
134
135
|
const formatDate = (d: string) => standardFormatDate(d);
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
|
-
* The work order a "Used" row came from
|
|
138
|
-
* (same organisation and site as the page). None
|
|
139
|
-
* exists or the app has no
|
|
138
|
+
* The work order a "Used" row came from: its feedback's details when it is tied
|
|
139
|
+
* to one, else Work Order Details (same organisation and site as the page). None
|
|
140
|
+
* when the work order no longer exists or the app has no such page: the number
|
|
141
|
+
* then shows as text.
|
|
140
142
|
*/
|
|
141
143
|
const route = useRoute();
|
|
142
144
|
const router = useRouter();
|
|
143
|
-
|
|
144
|
-
if (!t.workOrder || t.workOrderExists === false) return null;
|
|
145
|
-
if (!router.hasRoute("org-site-work-orders-id") || !route.params.org || !route.params.site) return null;
|
|
146
|
-
return { name: "org-site-work-orders-id", params: { org: route.params.org, site: route.params.site, id: t.workOrder } };
|
|
147
|
-
}
|
|
145
|
+
const workOrderRoute = (t: TInventoryTransaction) => workOrderLinkTarget(t, route, router);
|
|
148
146
|
|
|
149
147
|
function describe(t: TInventoryTransaction) {
|
|
150
148
|
const parts: string[] = [];
|
|
@@ -45,7 +45,11 @@
|
|
|
45
45
|
<v-text-field v-if="mode !== 'issue'" :model-value="holderName" density="comfortable" readonly />
|
|
46
46
|
</template>
|
|
47
47
|
|
|
48
|
-
<div class="text-subtitle-2 mb-2">
|
|
48
|
+
<div class="text-subtitle-2 mb-2">
|
|
49
|
+
Items
|
|
50
|
+
<!-- Same count as the mobile request sheet: what this request holds so far. -->
|
|
51
|
+
<span v-if="mode === 'request' && chosenCount > 0" class="text-primary">· {{ chosenCount === 1 ? "1 item in this request" : `${chosenCount} items in this request` }}</span>
|
|
52
|
+
</div>
|
|
49
53
|
<div v-for="(line, i) in rows" :key="i" class="d-flex flex-wrap ga-2 align-start mb-1">
|
|
50
54
|
<!-- An item not in the stock list (client 2026-11): a delivery adds it, a request asks for it. -->
|
|
51
55
|
<template v-if="line.newItem">
|
|
@@ -320,6 +324,7 @@ function addNew(line: TRow) {
|
|
|
320
324
|
line.item = "";
|
|
321
325
|
}
|
|
322
326
|
const rows = ref<TRow[]>([blank()]);
|
|
327
|
+
const chosenCount = computed(() => rows.value.filter((r) => r.item || r.newItem?.name?.trim()).length);
|
|
323
328
|
const supplier = ref("");
|
|
324
329
|
const reference = ref("");
|
|
325
330
|
const remarks = ref("");
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
<div class="inventory">
|
|
3
3
|
<PageHeader :title="store ? store.name : 'Inventory'" :subtitle="subtitle">
|
|
4
4
|
<template #actions>
|
|
5
|
+
<v-btn variant="text" size="small" class="text-none" prepend-icon="mdi-help-circle-outline" @click="showHowItWorks = true">
|
|
6
|
+
{{ HOW.title }}
|
|
7
|
+
</v-btn>
|
|
5
8
|
<!-- Many stores (staff of several organisations at one property): a list, not a row of buttons. -->
|
|
6
9
|
<v-select
|
|
7
10
|
v-if="stores.length > 3"
|
|
@@ -50,6 +53,25 @@
|
|
|
50
53
|
</div>
|
|
51
54
|
</v-alert>
|
|
52
55
|
|
|
56
|
+
<!-- Owner 2026-11-05: the three set-ups, in plain words, one tap away on every inventory screen. -->
|
|
57
|
+
<v-dialog v-model="showHowItWorks" max-width="640">
|
|
58
|
+
<v-card>
|
|
59
|
+
<v-card-title class="text-h6">{{ HOW.title }}</v-card-title>
|
|
60
|
+
<v-card-text>
|
|
61
|
+
<p class="text-body-2 mb-4">{{ HOW.intro }}</p>
|
|
62
|
+
<div v-for="s in HOW.setups" :key="s.title" class="mb-3">
|
|
63
|
+
<div class="font-weight-medium">{{ s.title }}</div>
|
|
64
|
+
<div class="text-body-2">{{ s.text }}</div>
|
|
65
|
+
</div>
|
|
66
|
+
<p class="text-caption mt-2">{{ HOW.where }}</p>
|
|
67
|
+
</v-card-text>
|
|
68
|
+
<v-card-actions>
|
|
69
|
+
<v-spacer />
|
|
70
|
+
<v-btn class="text-none" variant="text" @click="showHowItWorks = false">Close</v-btn>
|
|
71
|
+
</v-card-actions>
|
|
72
|
+
</v-card>
|
|
73
|
+
</v-dialog>
|
|
74
|
+
|
|
53
75
|
<v-progress-linear v-if="loading" indeterminate color="primary" class="mb-4" />
|
|
54
76
|
|
|
55
77
|
<AppCard v-else-if="loadError" class="pa-6">
|
|
@@ -59,7 +81,8 @@
|
|
|
59
81
|
</AppCard>
|
|
60
82
|
|
|
61
83
|
<!-- No store yet: one clear next step, or one clear explanation. -->
|
|
62
|
-
|
|
84
|
+
<!-- Also open when a provider sets up its own store beside the main store (scenario 3). -->
|
|
85
|
+
<AppCard v-else-if="!store || showSetup" class="pa-6">
|
|
63
86
|
<template v-if="!showSetup">
|
|
64
87
|
<div class="text-h6 mb-2">Inventory is not set up for this property yet</div>
|
|
65
88
|
<p class="text-body-2 mb-4">
|
|
@@ -67,6 +90,8 @@
|
|
|
67
90
|
</p>
|
|
68
91
|
<p class="text-body-2 mb-4">
|
|
69
92
|
One store can supply several properties (for example a company's central store): choose them all when you set it up, or later under Settings.
|
|
93
|
+
If each property keeps its own separate stock, set up a store at each property instead.
|
|
94
|
+
<a href="#" class="text-primary" @click.prevent="showHowItWorks = true">How inventory works</a>
|
|
70
95
|
</p>
|
|
71
96
|
<v-btn class="text-none screen-btn-primary" variant="flat" @click="showSetup = true">Set up inventory</v-btn>
|
|
72
97
|
<p class="text-caption mt-3">
|
|
@@ -88,7 +113,7 @@
|
|
|
88
113
|
chips
|
|
89
114
|
density="comfortable"
|
|
90
115
|
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
91
|
-
hint="Choose more than one if one store supplies them all
|
|
116
|
+
hint="Choose more than one only if one store supplies them all (e.g. a company's central store). If a property keeps its own separate stock, leave it out and set up its own store there."
|
|
92
117
|
persistent-hint
|
|
93
118
|
class="mb-4"
|
|
94
119
|
/>
|
|
@@ -105,6 +130,10 @@
|
|
|
105
130
|
<v-alert v-if="requestOnly" type="info" variant="tonal" density="compact" class="mb-4" icon="mdi-cart-arrow-down">
|
|
106
131
|
<div class="font-weight-medium">Request items from the main store</div>
|
|
107
132
|
<div class="text-body-2">Pick the items you need and press Request Stock. You are told when the store keeper approves it.</div>
|
|
133
|
+
<div v-if="canSetUpOwnStore" class="d-flex align-center flex-wrap ga-2 mt-2">
|
|
134
|
+
<span class="text-body-2">Your company can also keep its own store here for stock it buys itself.</span>
|
|
135
|
+
<v-btn size="small" variant="outlined" class="text-none" @click="openOwnStoreSetup">Set up our own store</v-btn>
|
|
136
|
+
</div>
|
|
108
137
|
</v-alert>
|
|
109
138
|
<v-alert
|
|
110
139
|
v-else-if="store.access.canApprove && pendingCount > 0 && tab !== 'requests'"
|
|
@@ -124,6 +153,9 @@
|
|
|
124
153
|
<v-btn size="small" variant="flat" color="warning" class="text-none" @click="tab = 'mine'">Open My Stock</v-btn>
|
|
125
154
|
</div>
|
|
126
155
|
</v-alert>
|
|
156
|
+
<v-alert v-if="twoStoresText" type="info" variant="tonal" density="compact" class="mb-4" icon="mdi-store-outline">
|
|
157
|
+
{{ twoStoresText }}
|
|
158
|
+
</v-alert>
|
|
127
159
|
<v-tabs v-model="tab" color="primary" class="mb-4" show-arrows>
|
|
128
160
|
<v-tab v-for="t in tabs" :key="t.value" :value="t.value" class="text-none">
|
|
129
161
|
{{ t.label }}
|
|
@@ -166,7 +198,16 @@ import useWorkerTerm from "../composables/useWorkerTerm";
|
|
|
166
198
|
import useSite from "../composables/useSite";
|
|
167
199
|
import useCustomerSite from "../composables/useCustomerSite";
|
|
168
200
|
import useUtils from "../composables/useUtils";
|
|
169
|
-
import {
|
|
201
|
+
import {
|
|
202
|
+
INVENTORY_HOW_IT_WORKS as HOW,
|
|
203
|
+
inventoryManagedBy,
|
|
204
|
+
inventorySiteOptions,
|
|
205
|
+
inventoryStoreLabel,
|
|
206
|
+
inventorySuppliesText,
|
|
207
|
+
inventorySupplySites,
|
|
208
|
+
inventoryTwoStoresText,
|
|
209
|
+
} from "../utils/inventory-store-label";
|
|
210
|
+
import useInventoryPermission from "../composables/useInventoryPermission";
|
|
170
211
|
import { inventoryControls } from "../utils/inventory-presets";
|
|
171
212
|
import { inventoryStepsLive } from "../utils/inventory-ack";
|
|
172
213
|
import useLocalAuth from "../composables/useLocalAuth";
|
|
@@ -198,6 +239,16 @@ const pendingCount = ref(0);
|
|
|
198
239
|
const orgSites = ref<{ _id: string; name: string }[]>([]);
|
|
199
240
|
|
|
200
241
|
const showSetup = ref(false);
|
|
242
|
+
const showHowItWorks = ref(false);
|
|
243
|
+
const { canManageInventory } = useInventoryPermission();
|
|
244
|
+
const twoStoresText = computed(() => inventoryTwoStoresText(stores.value));
|
|
245
|
+
// Scenario 3: a provider at a property with a main store may add its own store; offered only when it has none here.
|
|
246
|
+
const canSetUpOwnStore = computed(() => canManageInventory.value && !stores.value.some((s) => s.owner === true));
|
|
247
|
+
function openOwnStoreSetup() {
|
|
248
|
+
// Never "Main Store": that is the property manager's store in every label.
|
|
249
|
+
Object.assign(setup, { name: "Our Store", sites: [props.siteId] });
|
|
250
|
+
showSetup.value = true;
|
|
251
|
+
}
|
|
201
252
|
const setupForm = ref();
|
|
202
253
|
const setup = reactive({ name: "Main Store", sites: [props.siteId] as string[] });
|
|
203
254
|
|
|
@@ -205,7 +205,11 @@
|
|
|
205
205
|
<template #item.receivingType="{ item }">{{ item.kind === "Opening stock" ? "Opening stock" : receivingLabel(item.receivingType) }}</template>
|
|
206
206
|
<template #item.reference="{ item }">
|
|
207
207
|
<a v-if="report === 'purchases' && item.reference" href="#" class="text-primary" title="See ordered vs received for this PO" @click.prevent="openPo(item.reference)">{{ item.reference }}</a>
|
|
208
|
-
|
|
208
|
+
<!-- a work order's materials (2026-11): the number links to the work order, or to its feedback when tied -->
|
|
209
|
+
<NuxtLink v-else-if="workOrderLinkTarget(item, route, router)" :to="workOrderLinkTarget(item, route, router)!" class="text-primary">
|
|
210
|
+
{{ item.workOrderNumber || item.reference }}
|
|
211
|
+
</NuxtLink>
|
|
212
|
+
<span v-else>{{ item.workOrderNumber || item.reference || "—" }}</span>
|
|
209
213
|
</template>
|
|
210
214
|
<template #item.doNumber="{ item }">
|
|
211
215
|
<span v-if="item.doNumber">{{ item.doNumber }}<span v-if="item.doDate" class="d-block text-caption text-medium-emphasis">{{ standardFormatDate(item.doDate) }}</span></span>
|
|
@@ -265,6 +269,7 @@ import { inventoryControls } from "../utils/inventory-presets";
|
|
|
265
269
|
import { USED_BY_FILTERS } from "../utils/inventory-used-by";
|
|
266
270
|
import { USAGE_FLAG_WORDS, USAGE_STATUS_CHOICES, usagePathText, usageQuery, usageTotals } from "../utils/inventory-usage";
|
|
267
271
|
import { receivingLabel } from "../utils/inventory-receiving";
|
|
272
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
268
273
|
import { inventoryStepsLive, qtyUnit, reconciliationCheckText, reconciliationPersonText, writeOffReasonText } from "../utils/inventory-ack";
|
|
269
274
|
|
|
270
275
|
const props = defineProps({
|
|
@@ -275,6 +280,9 @@ const ctl = computed(() => inventoryControls(props.store.access));
|
|
|
275
280
|
|
|
276
281
|
const api = useInventory();
|
|
277
282
|
const { standardFormatDate, standardFormatDateTime } = useUtils();
|
|
283
|
+
// Work order numbers link to the work order, or its feedback (workOrderLinkTarget).
|
|
284
|
+
const route = useRoute();
|
|
285
|
+
const router = useRouter();
|
|
278
286
|
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
279
287
|
|
|
280
288
|
const worker = useWorkerTerm({ providers: true });
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
chips
|
|
16
16
|
density="comfortable"
|
|
17
17
|
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
18
|
-
hint="Choose more than one if this store supplies them all
|
|
18
|
+
hint="Choose more than one only if this store supplies them all (e.g. a company's central store). A property that keeps its own separate stock needs its own store instead."
|
|
19
19
|
persistent-hint
|
|
20
20
|
class="mb-4"
|
|
21
21
|
/>
|
|
@@ -31,5 +31,12 @@ export default function useInventoryPermission() {
|
|
|
31
31
|
);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/** May set up a store for this organisation (the API checks again; this only decides whether to offer the button). */
|
|
35
|
+
const canManageInventory = computed(() => {
|
|
36
|
+
const role = userAppRole.value;
|
|
37
|
+
if (!role || permissionsDenied(["inventory"], userAppModulesDenied?.value)) return false;
|
|
38
|
+
return role.permissions.includes("*") || hasPermission(role, permissions, "inventory", "manage-inventory");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return { canSeeInventory, canManageInventory };
|
|
35
42
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.657",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/types/inventory.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ declare type TInventoryTransaction = {
|
|
|
143
143
|
workOrder?: string;
|
|
144
144
|
workOrderNumber?: string;
|
|
145
145
|
workOrderExists?: boolean;
|
|
146
|
+
/** The feedback the work order is tied to (2026-11): its link goes there. */
|
|
147
|
+
workOrderFeedback?: string | null;
|
|
146
148
|
supplier?: string;
|
|
147
149
|
/** Receiving (2026-10): missing on older rows = PO. */
|
|
148
150
|
receivingType?: "PO" | "DO" | "CASH";
|
|
@@ -68,3 +68,39 @@ export function inventoryItemMeta(item: TItemLike) {
|
|
|
68
68
|
.filter(Boolean)
|
|
69
69
|
.join(" · ");
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* "How inventory works" (owner 2026-11-05): the three ways clients run stock, in the words the screens use.
|
|
74
|
+
* The mobile apps carry the same sentences; change both together.
|
|
75
|
+
*/
|
|
76
|
+
export const INVENTORY_HOW_IT_WORKS = {
|
|
77
|
+
title: "How inventory works",
|
|
78
|
+
intro:
|
|
79
|
+
"A store is the stock one company keeps. The company that owns a store runs it: adds items, receives deliveries, approves requests and issues stock. Everyone else can only request from it.",
|
|
80
|
+
setups: [
|
|
81
|
+
{
|
|
82
|
+
title: "1. One company store for many sites",
|
|
83
|
+
text: "For example a security agency: one store supplies every site the company serves. When you set it up, tick all those sites. Staff at each site request from it; issues, usage and reports are recorded per site.",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: "2. One store per property",
|
|
87
|
+
text: "For example Winsland House 1 and Winsland House 2: each property keeps its own stock, so each gets its own store. Set up the store at each property and tick only that property. Use Switch property to move between them; stock never mixes.",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
title: "3. Main store and service providers",
|
|
91
|
+
text: "The property manager's Main store supplies the service providers at the property: their staff request, the store keeper issues to the person. A provider can also keep its own store (Our store) for stock it buys itself. Stock does not move between stores.",
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
where: "Stores are set up on the web (Inventory, by a person allowed to manage inventory). The mobile apps request, receive and record usage.",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Two stores at one property for the same person: say which is which, so a request goes to the right one.
|
|
99
|
+
* Empty unless the person sees both their own company's store and another company's main store.
|
|
100
|
+
*/
|
|
101
|
+
export function inventoryTwoStoresText(stores: TStoreLike[]) {
|
|
102
|
+
const ours = stores.some((s) => s.owner === true);
|
|
103
|
+
const theirs = stores.some((s) => s.owner === false && s.main);
|
|
104
|
+
if (!ours || !theirs) return "";
|
|
105
|
+
return "Two stores supply this property. Our store is your company's own stock. Main store is the property manager's stock: you can only request from it.";
|
|
106
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where a work order number in Inventory (History, reports) links to (2026-11): the
|
|
5
|
+
* feedback's details when the work order is tied to a feedback (its work is done there), else
|
|
6
|
+
* the work order's details - in this app, at the page's organisation and site. Null (shown as
|
|
7
|
+
* text) when there is no work order, it no longer exists, or the app has no such page.
|
|
8
|
+
*/
|
|
9
|
+
export function workOrderLinkTarget(
|
|
10
|
+
row: { workOrder?: unknown; workOrderExists?: boolean; workOrderFeedback?: string | null },
|
|
11
|
+
route: RouteLocationNormalizedLoaded,
|
|
12
|
+
router: Router,
|
|
13
|
+
) {
|
|
14
|
+
if (!row.workOrder || row.workOrderExists === false) return null;
|
|
15
|
+
const { org, site } = route.params;
|
|
16
|
+
if (!org || !site) return null;
|
|
17
|
+
if (row.workOrderFeedback && router.hasRoute("org-site-feedbacks-id")) {
|
|
18
|
+
return { name: "org-site-feedbacks-id", params: { org, site, id: String(row.workOrderFeedback) } };
|
|
19
|
+
}
|
|
20
|
+
if (router.hasRoute("org-site-work-orders-id")) {
|
|
21
|
+
return { name: "org-site-work-orders-id", params: { org, site, id: String(row.workOrder) } };
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|