@7365admin1/layer-common 4.168.4 → 4.170.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/CHANGELOG.md +18 -4
- package/components/InventoryItemDetail.vue +1 -0
- package/components/InventoryLinesDialog.vue +72 -5
- package/components/InventoryMain.vue +28 -12
- package/components/InventoryReportsTab.vue +4 -0
- package/components/InventoryRequestsTab.vue +9 -2
- package/components/InventorySettingsTab.vue +68 -13
- package/components/InventorySitePicker.vue +38 -0
- package/components/InventoryStockTab.vue +6 -2
- package/composables/useInventory.ts +9 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +5 -1
- package/utils/inventory-store-label.ts +19 -1
- package/utils/inventory-usage.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.170.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d4dcfa9: Inventory: Main store -> service provider store. Request Stock offers "Deliver to: Our store / Me" when the person's company has its own store at the property; Main store managers get "Transfer to provider store"; transfer rows in item history and Stock Movement / Reconciliation; requests show "Into <store>"; "How inventory works" text updated.
|
|
8
|
+
|
|
9
|
+
## 4.169.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b9802fd: Inventory: the "Properties this store supplies" picker shows which store already supplies a property (disabled, with the reason), has Select all / Clear, and store managers can delete a store from Settings
|
|
14
|
+
|
|
15
|
+
Uses the new `GET /api/inventory/stores/site-owners` and `DELETE /api/inventory/stores/:id`. Deleting asks for the store name; items and history are kept.
|
|
16
|
+
|
|
3
17
|
## 4.168.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -3853,11 +3867,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3853
3867
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3854
3868
|
own rule from two endpoints the console already calls, unprojected:
|
|
3855
3869
|
|
|
3856
|
-
|
|
3857
|
-
|
|
3870
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3871
|
+
GET /api/roles/id/:role that membership's role document
|
|
3858
3872
|
|
|
3859
|
-
|
|
3860
|
-
|
|
3873
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3874
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3861
3875
|
|
|
3862
3876
|
`role.default` is the marker because it is the only property of a platform
|
|
3863
3877
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -160,6 +160,7 @@ function describe(t: TInventoryTransaction) {
|
|
|
160
160
|
t.workOrder ? "" : t.reference || "",
|
|
161
161
|
);
|
|
162
162
|
if (t.type === "adjust") parts.push(t.remarks || "");
|
|
163
|
+
if (t.type === "transfer") parts.push(`${t.qty} ${t.storeChange > 0 ? "from" : "to"} ${t.transferStoreName || "another store"}`, t.reference || "", t.remarks || "");
|
|
163
164
|
if (t.type === "write_off") parts.push(`${t.qty} ${writeOffLabel(t.writeOffReason).toLowerCase()}`, (t.holderChange ?? 0) < 0 ? `by ${who}` : "from the shelf", t.remarks || "");
|
|
164
165
|
if (t.type === "opening") parts.push(t.supplier || "", t.reference ? `PO ${t.reference}` : "", t.receivedBy ? `received by ${t.receivedBy}` : "", t.remarks || "");
|
|
165
166
|
return parts.filter(Boolean).join(" · ");
|
|
@@ -9,7 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
<v-card-text class="screen-modal__body">
|
|
11
11
|
<p class="text-body-2 text-medium-emphasis" :class="mode === 'request' ? 'mb-1' : 'mb-4'">{{ copy.help }}</p>
|
|
12
|
-
<p v-if="mode === 'request'" class="text-body-2 mb-4">Requesting from: <strong>{{ store.name }}</strong></p>
|
|
12
|
+
<p v-if="mode === 'request'" class="text-body-2" :class="deliverChoice ? 'mb-2' : 'mb-4'">Requesting from: <strong>{{ store.name }}</strong></p>
|
|
13
|
+
<!-- 2026-11-05: a provider with its own store here can have Main store stock delivered straight into it. -->
|
|
14
|
+
<div v-if="deliverChoice" class="mb-4">
|
|
15
|
+
<InputLabel title="Deliver to" class="mb-1" />
|
|
16
|
+
<v-radio-group v-model="deliverTo" inline hide-details density="compact">
|
|
17
|
+
<v-radio :label="`Our store (${ownStore!.name})`" value="store" />
|
|
18
|
+
<v-radio label="Me" value="me" />
|
|
19
|
+
</v-radio-group>
|
|
20
|
+
<p class="text-caption text-medium-emphasis">
|
|
21
|
+
{{ deliverTo === "store" ? "Once approved, the items go straight into our store's stock." : "Once approved, the items are handed to you. Tap Received when you have them." }}
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
13
24
|
<!-- Errors once a field is left or the button is pressed, never from opening or resetting the form. -->
|
|
14
25
|
<v-form ref="form" validate-on="blur invalid-input">
|
|
15
26
|
<template v-if="mode === 'receive'">
|
|
@@ -19,6 +30,22 @@
|
|
|
19
30
|
</v-btn-toggle>
|
|
20
31
|
<p class="text-caption text-medium-emphasis mb-3">{{ receivingHelp }}</p>
|
|
21
32
|
</template>
|
|
33
|
+
<template v-if="mode === 'transfer'">
|
|
34
|
+
<InputLabel title="Send to" required class="mb-1" />
|
|
35
|
+
<v-select
|
|
36
|
+
v-model="transferTo"
|
|
37
|
+
:items="targets"
|
|
38
|
+
:item-title="(t: any) => (t.orgName ? `${t.name} · ${t.orgName}` : t.name)"
|
|
39
|
+
item-value="_id"
|
|
40
|
+
:loading="targetsLoading"
|
|
41
|
+
:rules="[requiredRule]"
|
|
42
|
+
density="comfortable"
|
|
43
|
+
:no-data-text="targetsLoading ? 'Loading…' : 'No service provider has its own store at this property yet.'"
|
|
44
|
+
hint="A service provider's own store at this property. They do not see your prices."
|
|
45
|
+
persistent-hint
|
|
46
|
+
class="mb-3"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
22
49
|
<template v-if="mode === 'issue' || mode === 'return'">
|
|
23
50
|
<InputLabel :title="mode === 'issue' ? 'Give to' : 'Returned by'" required class="mb-1" />
|
|
24
51
|
<v-autocomplete
|
|
@@ -207,7 +234,7 @@
|
|
|
207
234
|
</v-col>
|
|
208
235
|
</v-row>
|
|
209
236
|
|
|
210
|
-
<template v-if="mode === 'request' || mode === 'issue'">
|
|
237
|
+
<template v-if="mode === 'request' || mode === 'issue' || mode === 'transfer'">
|
|
211
238
|
<v-select
|
|
212
239
|
v-if="mode === 'issue' && siteChoices.length > 1"
|
|
213
240
|
v-model="site"
|
|
@@ -242,7 +269,7 @@ import { availableQty, availableText as availableTextOf, qtyUnit, unitWord } fro
|
|
|
242
269
|
import { RECEIVING_TYPES, receivingFields, receivingProblem, type TReceivingType } from "../utils/inventory-receiving";
|
|
243
270
|
import { notListedText } from "../utils/inventory-request-text";
|
|
244
271
|
|
|
245
|
-
type TMode = "receive" | "issue" | "request" | "return";
|
|
272
|
+
type TMode = "receive" | "issue" | "request" | "return" | "transfer";
|
|
246
273
|
type TNewItem = { name: string; unit: string; category: string; note: string };
|
|
247
274
|
type TRow = { item: string; qty: number | null; unitCost?: number | null; ordered?: number | null; typed?: string; newItem?: TNewItem | null };
|
|
248
275
|
|
|
@@ -281,6 +308,12 @@ const COPY: Record<TMode, { title: string; help: string; button: string; success
|
|
|
281
308
|
button: "Send request",
|
|
282
309
|
success: "Request sent to the store.",
|
|
283
310
|
},
|
|
311
|
+
transfer: {
|
|
312
|
+
title: "Transfer to provider store",
|
|
313
|
+
help: "Move stock from this store into a service provider's own store at this property. It leaves this store at once and is added to theirs.",
|
|
314
|
+
button: "Transfer stock",
|
|
315
|
+
success: "Stock transferred.",
|
|
316
|
+
},
|
|
284
317
|
return: {
|
|
285
318
|
title: "Receive Return",
|
|
286
319
|
help: "Take unused stock back into the store.",
|
|
@@ -294,6 +327,8 @@ const RECEIVE_TITLES: Record<TReceivingType, string> = { PO: "Record a delivery
|
|
|
294
327
|
const copy = computed(() => {
|
|
295
328
|
const c = COPY[props.mode];
|
|
296
329
|
if (props.mode === "receive") return { ...c, title: RECEIVE_TITLES[receivingType.value] };
|
|
330
|
+
if (props.mode === "request" && deliverChoice.value && deliverTo.value === "store")
|
|
331
|
+
return { ...c, success: `Request sent. Once approved, the items go straight into ${ownStore.value!.name}.` };
|
|
297
332
|
if (!reserving.value) return c;
|
|
298
333
|
if (props.mode === "request")
|
|
299
334
|
return {
|
|
@@ -339,6 +374,26 @@ const doNumber = ref("");
|
|
|
339
374
|
const doDate = ref("");
|
|
340
375
|
const receiptNumber = ref("");
|
|
341
376
|
const tried = ref(false);
|
|
377
|
+
// Deliver to (request): the person's own company store at this property, from InventoryMain.
|
|
378
|
+
const ownStore = inject<Ref<TInventoryStore | null>>("inventoryOwnStore", ref(null));
|
|
379
|
+
const deliverChoice = computed(
|
|
380
|
+
() => props.mode === "request" && props.store.main === true && props.store.owner === false && Boolean(ownStore.value?.sites?.includes(props.siteId)),
|
|
381
|
+
);
|
|
382
|
+
const deliverTo = ref<"store" | "me">("store");
|
|
383
|
+
// Transfer (Main store managers): which provider store receives it.
|
|
384
|
+
const transferTo = ref("");
|
|
385
|
+
const targets = ref<{ _id: string; name: string; orgName: string }[]>([]);
|
|
386
|
+
const targetsLoading = ref(false);
|
|
387
|
+
async function loadTargets() {
|
|
388
|
+
targetsLoading.value = true;
|
|
389
|
+
try {
|
|
390
|
+
targets.value = (await api.getTransferTargets(props.store._id, props.siteId)) ?? [];
|
|
391
|
+
} catch {
|
|
392
|
+
targets.value = [];
|
|
393
|
+
} finally {
|
|
394
|
+
targetsLoading.value = false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
342
397
|
const receivingHelp = computed(() => RECEIVING_TYPES.find((t) => t.value === receivingType.value)?.help ?? "");
|
|
343
398
|
const hasOrdered = (r: TRow) => r.ordered !== null && r.ordered !== undefined && r.ordered !== ("" as any);
|
|
344
399
|
const receivingCheck = () =>
|
|
@@ -358,7 +413,7 @@ const siteChoices = computed(() => (props.sites.length ? props.sites : props.sto
|
|
|
358
413
|
const unitOf = (id: string) => choices.value.find((c) => c._id === id)?.unit ?? "";
|
|
359
414
|
const availableOf = (id: string) => {
|
|
360
415
|
const c = choices.value.find((x) => x._id === id);
|
|
361
|
-
return c && (props.mode === "request" || props.mode === "issue") ? availableQty(c) : c?.onHand;
|
|
416
|
+
return c && (props.mode === "request" || props.mode === "issue" || props.mode === "transfer") ? availableQty(c) : c?.onHand;
|
|
362
417
|
};
|
|
363
418
|
|
|
364
419
|
function availableText(item: any) {
|
|
@@ -461,7 +516,16 @@ async function submit() {
|
|
|
461
516
|
...(r.newItem!.unit.trim() ? { unit: r.newItem!.unit.trim() } : {}),
|
|
462
517
|
...(r.newItem!.note.trim() ? { note: r.newItem!.note.trim() } : {}),
|
|
463
518
|
}));
|
|
464
|
-
await api.createRequest(props.store._id, {
|
|
519
|
+
await api.createRequest(props.store._id, {
|
|
520
|
+
site: props.siteId,
|
|
521
|
+
lines,
|
|
522
|
+
...(newItems.length ? { newItems } : {}),
|
|
523
|
+
...(deliverChoice.value && deliverTo.value === "store" ? { deliverTo: { store: ownStore.value!._id } } : {}),
|
|
524
|
+
reference: reference.value,
|
|
525
|
+
remarks: remarks.value,
|
|
526
|
+
});
|
|
527
|
+
} else if (props.mode === "transfer") {
|
|
528
|
+
await api.transferToStore(props.store._id, { to: transferTo.value, site: props.siteId, lines, reference: reference.value, remarks: remarks.value });
|
|
465
529
|
} else if (props.mode === "issue") {
|
|
466
530
|
await api.issue(props.store._id, { holder: holder.value, site: site.value || props.siteId, lines, reference: reference.value, remarks: remarks.value });
|
|
467
531
|
} else {
|
|
@@ -493,6 +557,9 @@ watch(show, (open) => {
|
|
|
493
557
|
doDate.value = "";
|
|
494
558
|
receiptNumber.value = "";
|
|
495
559
|
tried.value = false;
|
|
560
|
+
deliverTo.value = "store";
|
|
561
|
+
transferTo.value = "";
|
|
562
|
+
if (props.mode === "transfer") loadTargets();
|
|
496
563
|
if (props.mode !== "return") loadItems();
|
|
497
564
|
if (props.mode === "issue") searchPeople("");
|
|
498
565
|
});
|
|
@@ -104,17 +104,10 @@
|
|
|
104
104
|
<v-text-field v-model="setup.name" :rules="[requiredRule]" density="comfortable" placeholder="e.g. Main Store" class="mb-2" />
|
|
105
105
|
<template v-if="supplySites.length > 1">
|
|
106
106
|
<InputLabel title="Properties this store supplies" required class="mb-1" />
|
|
107
|
-
<
|
|
107
|
+
<InventorySitePicker
|
|
108
108
|
v-model="setup.sites"
|
|
109
|
-
:items="
|
|
110
|
-
|
|
111
|
-
item-value="_id"
|
|
112
|
-
multiple
|
|
113
|
-
chips
|
|
114
|
-
density="comfortable"
|
|
115
|
-
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
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."
|
|
117
|
-
persistent-hint
|
|
109
|
+
:items="setupSiteItems"
|
|
110
|
+
hint="Most properties keep their own store. Choose more than one only if they share one store room."
|
|
118
111
|
class="mb-4"
|
|
119
112
|
/>
|
|
120
113
|
</template>
|
|
@@ -183,7 +176,7 @@
|
|
|
183
176
|
<InventorySuppliersTab :store="store" />
|
|
184
177
|
</v-window-item>
|
|
185
178
|
<v-window-item v-if="ctl.tabs.settings" value="settings">
|
|
186
|
-
<InventorySettingsTab :store="store" :org-sites="supplySites" @saved="loadStores" />
|
|
179
|
+
<InventorySettingsTab :store="store" :org-sites="supplySites" @saved="loadStores" @deleted="afterStoreDeleted" />
|
|
187
180
|
</v-window-item>
|
|
188
181
|
</v-window>
|
|
189
182
|
</template>
|
|
@@ -224,7 +217,7 @@ const linked = { storeId: String(linkQuery.storeId ?? ""), tab: String(linkQuery
|
|
|
224
217
|
// `?requestId=` (approved / confirm-received alerts): the Requests tab opens on that request.
|
|
225
218
|
const focusRequest = String(linkQuery.requestId ?? "");
|
|
226
219
|
|
|
227
|
-
const { getHandovers, getStores, getStore, createStore: apiCreateStore, getRequests, getReport } = useInventory();
|
|
220
|
+
const { getHandovers, getStores, getStore, createStore: apiCreateStore, getSiteOwners, getRequests, getReport } = useInventory();
|
|
228
221
|
const { getSites } = useSite();
|
|
229
222
|
const { requiredRule } = useUtils();
|
|
230
223
|
|
|
@@ -242,6 +235,11 @@ const showSetup = ref(false);
|
|
|
242
235
|
const showHowItWorks = ref(false);
|
|
243
236
|
const { canManageInventory } = useInventoryPermission();
|
|
244
237
|
const twoStoresText = computed(() => inventoryTwoStoresText(stores.value));
|
|
238
|
+
// The person's own company store here (not a Main store): a Main store request can be delivered into it.
|
|
239
|
+
provide(
|
|
240
|
+
"inventoryOwnStore",
|
|
241
|
+
computed(() => stores.value.find((s) => s.owner === true && !s.main) ?? null),
|
|
242
|
+
);
|
|
245
243
|
// Scenario 3: a provider at a property with a main store may add its own store; offered only when it has none here.
|
|
246
244
|
const canSetUpOwnStore = computed(() => canManageInventory.value && !stores.value.some((s) => s.owner === true));
|
|
247
245
|
function openOwnStoreSetup() {
|
|
@@ -306,6 +304,13 @@ const tabs = computed(() => {
|
|
|
306
304
|
];
|
|
307
305
|
});
|
|
308
306
|
|
|
307
|
+
/** After a store is deleted: reload, and with none left show the set-up form for its freed properties. */
|
|
308
|
+
async function afterStoreDeleted() {
|
|
309
|
+
await Promise.all([loadStores(), loadSiteOwners()]);
|
|
310
|
+
Object.assign(setup, { name: "Main Store", sites: [props.siteId] });
|
|
311
|
+
showSetup.value = !store.value;
|
|
312
|
+
}
|
|
313
|
+
|
|
309
314
|
async function loadStores() {
|
|
310
315
|
loading.value = true;
|
|
311
316
|
loadError.value = "";
|
|
@@ -396,6 +401,15 @@ const supplySites = computed(() => inventorySupplySites(orgSites.value, mySites.
|
|
|
396
401
|
const setupSiteOptions = computed(() =>
|
|
397
402
|
inventorySiteOptions(supplySites.value, { sites: setup.sites, siteNames: [...mySites.value, { _id: props.siteId, name: currentSiteName.value }] }),
|
|
398
403
|
);
|
|
404
|
+
const siteOwners = ref<{ site: string; store: string; name: string }[]>([]);
|
|
405
|
+
const setupSiteItems = computed(() => inventorySitePickerItems(setupSiteOptions.value, siteOwners.value));
|
|
406
|
+
async function loadSiteOwners() {
|
|
407
|
+
try {
|
|
408
|
+
siteOwners.value = await getSiteOwners(props.orgId);
|
|
409
|
+
} catch {
|
|
410
|
+
siteOwners.value = []; // the picker then shows no hints; saving still names the clash
|
|
411
|
+
}
|
|
412
|
+
}
|
|
399
413
|
const currentSiteName = computed(() => mySites.value.find((s) => s._id === props.siteId)?.name || storeSites.value.find((s) => s._id === props.siteId)?.name || "this property");
|
|
400
414
|
async function loadMySites() {
|
|
401
415
|
try {
|
|
@@ -446,6 +460,7 @@ async function createStore() {
|
|
|
446
460
|
try {
|
|
447
461
|
const created = await apiCreateStore({ org: props.orgId, sites: setup.sites, name: setup.name });
|
|
448
462
|
notify("Store created. Add your items next.");
|
|
463
|
+
loadSiteOwners();
|
|
449
464
|
showSetup.value = false;
|
|
450
465
|
storeId.value = (created as any)?._id ?? "";
|
|
451
466
|
await loadStores();
|
|
@@ -471,5 +486,6 @@ onMounted(() => {
|
|
|
471
486
|
loadStores();
|
|
472
487
|
loadOrgSites();
|
|
473
488
|
loadMySites();
|
|
489
|
+
loadSiteOwners();
|
|
474
490
|
});
|
|
475
491
|
</script>
|
|
@@ -364,6 +364,8 @@ function reconStoreText(r: any) {
|
|
|
364
364
|
s.returned ? `returned ${s.returned}` : "",
|
|
365
365
|
s.adjusted ? `stock count ${s.adjusted > 0 ? "+" : ""}${s.adjusted}` : "",
|
|
366
366
|
s.writtenOff ? `written off from the shelf ${s.writtenOff}` : "",
|
|
367
|
+
s.transferredIn ? `transferred in ${s.transferredIn}` : "",
|
|
368
|
+
s.transferredOut ? `transferred to providers' stores ${s.transferredOut}` : "",
|
|
367
369
|
`end ${qtyUnit(s.closing, r.unit)}`,
|
|
368
370
|
]
|
|
369
371
|
.filter(Boolean)
|
|
@@ -427,6 +429,8 @@ const headers: Record<string, any[]> = {
|
|
|
427
429
|
{ title: "Issued", key: "issued" },
|
|
428
430
|
{ title: "Returned", key: "returned" },
|
|
429
431
|
{ title: "Stock count +/-", key: "adjusted" },
|
|
432
|
+
{ title: "Transferred in", key: "transferredIn" },
|
|
433
|
+
{ title: "Transferred out", key: "transferredOut" },
|
|
430
434
|
{ title: "End", key: "closing" },
|
|
431
435
|
{ title: "Used", key: "usedByTechnicians" },
|
|
432
436
|
{ title: "Usage cost", key: "usedCost" },
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
<v-chip v-if="r.status === 'issued' && r.ackStatus && r.ackStatus !== 'received'" size="small" :color="ACK_CHIP[r.ackStatus].color" variant="tonal">{{ ACK_CHIP[r.ackStatus].label }}</v-chip>
|
|
42
42
|
<!-- One store can supply several properties: say which one this request is for. -->
|
|
43
43
|
<v-chip v-if="store.sites.length > 1 && r.siteName" size="small" variant="outlined" prepend-icon="mdi-office-building-outline">For {{ r.siteName }}</v-chip>
|
|
44
|
+
<v-chip v-if="r.deliverTo" size="small" variant="outlined" prepend-icon="mdi-store-outline">Into {{ r.deliverTo.storeName }}</v-chip>
|
|
44
45
|
<v-spacer />
|
|
45
46
|
<template v-if="r.status === 'pending'">
|
|
46
47
|
<v-btn v-if="ctl.review" class="text-none screen-btn-primary" variant="flat" @click="openDecision(r)">Review</v-btn>
|
|
@@ -77,7 +78,13 @@
|
|
|
77
78
|
<v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="decision.show = false" />
|
|
78
79
|
</v-card-title>
|
|
79
80
|
<v-card-text class="screen-modal__body">
|
|
80
|
-
<p class="text-body-2 text-medium-emphasis mb-3">
|
|
81
|
+
<p class="text-body-2 text-medium-emphasis mb-3">
|
|
82
|
+
{{
|
|
83
|
+
decision.request.deliverTo
|
|
84
|
+
? `Approving moves the items from this store straight into "${decision.request.deliverTo.storeName}" (their company's own store). They do not see your prices. You can give less than asked.`
|
|
85
|
+
: "Hand over the items, then approve. You can give less than asked."
|
|
86
|
+
}}
|
|
87
|
+
</p>
|
|
81
88
|
<v-form ref="decisionForm" validate-on="blur invalid-input">
|
|
82
89
|
<div v-for="l in decision.lines" :key="l.item" class="d-flex align-center ga-3 mb-1">
|
|
83
90
|
<div class="flex-grow-1">
|
|
@@ -113,7 +120,7 @@
|
|
|
113
120
|
</v-card-text>
|
|
114
121
|
<div class="screen-modal__footer">
|
|
115
122
|
<v-btn class="screen-btn-ghost" variant="outlined" color="error" :loading="decision.busy === 'reject'" :disabled="!!decision.busy" @click="reject">Reject</v-btn>
|
|
116
|
-
<v-btn class="screen-btn-primary" variant="flat" :loading="decision.busy === 'approve'" :disabled="!!decision.busy || !!approveBlocked" @click="approve">Approve and issue</v-btn>
|
|
123
|
+
<v-btn class="screen-btn-primary" variant="flat" :loading="decision.busy === 'approve'" :disabled="!!decision.busy || !!approveBlocked" @click="approve">{{ decision.request.deliverTo ? "Approve and transfer" : "Approve and issue" }}</v-btn>
|
|
117
124
|
</div>
|
|
118
125
|
</v-card>
|
|
119
126
|
</v-dialog>
|
|
@@ -6,17 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
<template v-if="orgSites.length > 1 || sites.length > 1">
|
|
8
8
|
<InputLabel title="Properties this store supplies" required class="mb-1" />
|
|
9
|
-
<
|
|
9
|
+
<InventorySitePicker
|
|
10
10
|
v-model="sites"
|
|
11
11
|
:items="siteItems"
|
|
12
|
-
|
|
13
|
-
item-value="_id"
|
|
14
|
-
multiple
|
|
15
|
-
chips
|
|
16
|
-
density="comfortable"
|
|
17
|
-
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
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
|
-
persistent-hint
|
|
12
|
+
hint="Keep one property per store unless they share one store room."
|
|
20
13
|
class="mb-4"
|
|
21
14
|
/>
|
|
22
15
|
</template>
|
|
@@ -59,23 +52,48 @@
|
|
|
59
52
|
<div class="d-flex mt-6">
|
|
60
53
|
<v-btn class="text-none screen-btn-primary" variant="flat" :loading="saving" @click="save">Save settings</v-btn>
|
|
61
54
|
</div>
|
|
55
|
+
|
|
56
|
+
<template v-if="store.access?.canManage">
|
|
57
|
+
<v-divider class="my-6" />
|
|
58
|
+
<div class="text-subtitle-1 mb-1">Delete store</div>
|
|
59
|
+
<p class="text-body-2 text-medium-emphasis mb-2">Stop using this store. Its items and history are kept for reports.</p>
|
|
60
|
+
<v-btn class="text-none" color="error" variant="outlined" @click="openDelete">Delete store</v-btn>
|
|
61
|
+
</template>
|
|
62
62
|
</v-form>
|
|
63
|
+
|
|
64
|
+
<v-dialog v-model="showDelete" max-width="520">
|
|
65
|
+
<AppCard class="pa-6">
|
|
66
|
+
<div class="text-h6 mb-2">Delete {{ store.name }}?</div>
|
|
67
|
+
<p class="text-body-2 mb-2">
|
|
68
|
+
It will no longer be used at: {{ siteNamesText }}. Its {{ itemCount }} items and their history are kept for reports.
|
|
69
|
+
People can no longer request from it. You can then set up a new store for these sites.
|
|
70
|
+
</p>
|
|
71
|
+
<InputLabel :title="`Type "${store.name}" to confirm`" class="mb-1" />
|
|
72
|
+
<v-text-field v-model="confirmName" density="comfortable" autocomplete="off" />
|
|
73
|
+
<div class="d-flex ga-2 mt-2">
|
|
74
|
+
<v-btn class="text-none screen-btn-ghost" variant="outlined" @click="showDelete = false">Cancel</v-btn>
|
|
75
|
+
<v-btn class="text-none" color="error" variant="flat" :disabled="confirmName.trim() !== store.name" :loading="deleting" @click="removeStore">
|
|
76
|
+
Delete store
|
|
77
|
+
</v-btn>
|
|
78
|
+
</div>
|
|
79
|
+
</AppCard>
|
|
80
|
+
</v-dialog>
|
|
63
81
|
</AppCard>
|
|
64
82
|
</template>
|
|
65
83
|
|
|
66
84
|
<script setup lang="ts">
|
|
67
85
|
import useInventory from "../composables/useInventory";
|
|
68
86
|
import useUtils from "../composables/useUtils";
|
|
69
|
-
import { inventorySiteOptions } from "../utils/inventory-store-label";
|
|
87
|
+
import { inventorySiteOptions, inventorySitePickerItems, type TSiteOwner } from "../utils/inventory-store-label";
|
|
70
88
|
import { inventoryStepsLive, reminderDaysText } from "../utils/inventory-ack";
|
|
71
89
|
|
|
72
90
|
const props = defineProps({
|
|
73
91
|
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
74
92
|
orgSites: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
|
|
75
93
|
});
|
|
76
|
-
const emit = defineEmits(["saved"]);
|
|
94
|
+
const emit = defineEmits(["saved", "deleted"]);
|
|
77
95
|
|
|
78
|
-
const { updateStore } = useInventory();
|
|
96
|
+
const { updateStore, getSiteOwners, getItems, deleteStore } = useInventory();
|
|
79
97
|
const { requiredRule } = useUtils();
|
|
80
98
|
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
81
99
|
|
|
@@ -90,7 +108,44 @@ const reminderDays = ref<number>(1);
|
|
|
90
108
|
const workOrderMaterials = ref(false);
|
|
91
109
|
const stepsLive = computed(() => inventoryStepsLive(props.store));
|
|
92
110
|
|
|
93
|
-
const
|
|
111
|
+
const owners = ref<TSiteOwner[]>([]);
|
|
112
|
+
const siteItems = computed(() => inventorySitePickerItems(inventorySiteOptions(props.orgSites, props.store), owners.value, props.store._id));
|
|
113
|
+
async function loadOwners() {
|
|
114
|
+
try {
|
|
115
|
+
owners.value = await getSiteOwners(props.store.org);
|
|
116
|
+
} catch {
|
|
117
|
+
owners.value = []; // no hints; saving still names the clashing property
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
onMounted(loadOwners);
|
|
121
|
+
|
|
122
|
+
const showDelete = ref(false);
|
|
123
|
+
const deleting = ref(false);
|
|
124
|
+
const confirmName = ref("");
|
|
125
|
+
const itemCount = ref(0);
|
|
126
|
+
const siteNamesText = computed(() => siteItems.value.filter((i) => props.store.sites.includes(i._id)).map((i) => i.name).join(", ") || "its properties");
|
|
127
|
+
async function openDelete() {
|
|
128
|
+
confirmName.value = "";
|
|
129
|
+
showDelete.value = true;
|
|
130
|
+
try {
|
|
131
|
+
itemCount.value = (await getItems(props.store._id, { limit: 1 }))?.total ?? 0;
|
|
132
|
+
} catch {
|
|
133
|
+
itemCount.value = 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function removeStore() {
|
|
137
|
+
deleting.value = true;
|
|
138
|
+
try {
|
|
139
|
+
await deleteStore(props.store._id);
|
|
140
|
+
showDelete.value = false;
|
|
141
|
+
notify("Store deleted.");
|
|
142
|
+
emit("deleted");
|
|
143
|
+
} catch (error: any) {
|
|
144
|
+
notify(error?.data?.message || "Could not delete the store.", "error");
|
|
145
|
+
} finally {
|
|
146
|
+
deleting.value = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
94
149
|
|
|
95
150
|
function reset() {
|
|
96
151
|
name.value = props.store.name;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-select
|
|
3
|
+
v-model="model"
|
|
4
|
+
:items="items"
|
|
5
|
+
item-title="name"
|
|
6
|
+
item-value="_id"
|
|
7
|
+
multiple
|
|
8
|
+
chips
|
|
9
|
+
density="comfortable"
|
|
10
|
+
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
11
|
+
:hint="hint"
|
|
12
|
+
persistent-hint
|
|
13
|
+
>
|
|
14
|
+
<template #prepend-item>
|
|
15
|
+
<div class="d-flex ga-2 px-4 py-2">
|
|
16
|
+
<v-btn size="small" variant="text" class="text-none" @click.stop="selectAll">Select all</v-btn>
|
|
17
|
+
<v-btn size="small" variant="text" class="text-none" @click.stop="model = []">Clear</v-btn>
|
|
18
|
+
</div>
|
|
19
|
+
<v-divider />
|
|
20
|
+
</template>
|
|
21
|
+
</v-select>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
type TItem = { _id: string; name: string; props?: { disabled?: boolean } };
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
modelValue: { type: Array as PropType<string[]>, default: () => [] },
|
|
28
|
+
items: { type: Array as PropType<TItem[]>, default: () => [] },
|
|
29
|
+
hint: { type: String, default: "" },
|
|
30
|
+
});
|
|
31
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
32
|
+
const model = computed({ get: () => props.modelValue, set: (v: string[]) => emit("update:modelValue", v) });
|
|
33
|
+
|
|
34
|
+
// Every property that is free to pick; ones another store supplies are skipped.
|
|
35
|
+
function selectAll() {
|
|
36
|
+
model.value = props.items.filter((i) => !i.props?.disabled).map((i) => i._id);
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
<v-btn v-if="ctl.request" class="text-none screen-btn-primary" variant="flat" prepend-icon="mdi-cart-arrow-down" @click="open('request')">
|
|
27
27
|
Request Stock
|
|
28
28
|
</v-btn>
|
|
29
|
+
<!-- Main store managers: send stock into a service provider's own store at this property. -->
|
|
30
|
+
<v-btn v-if="store.main && store.access.canManage && !storeEmpty" class="text-none screen-btn-ghost" variant="outlined" prepend-icon="mdi-swap-horizontal" @click="open('transfer')">
|
|
31
|
+
Transfer to provider store
|
|
32
|
+
</v-btn>
|
|
29
33
|
<v-menu v-if="ctl.addItems">
|
|
30
34
|
<template #activator="{ props: menu }">
|
|
31
35
|
<v-btn v-bind="menu" class="text-none" :class="storeEmpty ? 'screen-btn-primary' : 'screen-btn-ghost'" :variant="storeEmpty ? 'flat' : 'outlined'" append-icon="mdi-chevron-down">Add Items</v-btn>
|
|
@@ -288,8 +292,8 @@ async function load() {
|
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
const lines = reactive({ show: false, mode: "receive" as "receive" | "issue" | "request" });
|
|
292
|
-
function open(mode: "receive" | "issue" | "request") {
|
|
295
|
+
const lines = reactive({ show: false, mode: "receive" as "receive" | "issue" | "request" | "transfer" });
|
|
296
|
+
function open(mode: "receive" | "issue" | "request" | "transfer") {
|
|
293
297
|
Object.assign(lines, { show: true, mode });
|
|
294
298
|
}
|
|
295
299
|
|
|
@@ -22,6 +22,7 @@ export default function useInventory() {
|
|
|
22
22
|
adjust: "Stock count",
|
|
23
23
|
handover: "Hand-over",
|
|
24
24
|
write_off: "Written off",
|
|
25
|
+
transfer: "Transfer",
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
return {
|
|
@@ -29,6 +30,9 @@ export default function useInventory() {
|
|
|
29
30
|
|
|
30
31
|
getStores: async (site: string) =>
|
|
31
32
|
((await api<TInventoryStore[]>("/stores", { query: { site } })) ?? []).map((s) => ({ ...s, access: inventoryCaps(s.access) })),
|
|
33
|
+
/** Which store of the organisation supplies each property (for the picker). */
|
|
34
|
+
getSiteOwners: async (org: string) => (await api<{ site: string; store: string; name: string }[]>("/stores/site-owners", { query: { org } })) ?? [],
|
|
35
|
+
deleteStore: (id: string) => api<{ deleted: boolean }>(`/stores/${id}`, { method: "DELETE" }),
|
|
32
36
|
createStore: (body: { org: string; sites: string[]; name: string }) =>
|
|
33
37
|
api<TInventoryStore>("/stores", { method: "POST", body }),
|
|
34
38
|
updateStore: (id: string, body: Partial<Pick<TInventoryStore, "name" | "sites" | "showInResidentApp" | "showCostInResidentApp" | "lowStockReminderDays" | "workOrderMaterials">>) =>
|
|
@@ -73,6 +77,11 @@ export default function useInventory() {
|
|
|
73
77
|
createRequest: (store: string, body: Record<string, any>) => api(`/stores/${store}/requests`, { method: "POST", body }),
|
|
74
78
|
approveRequest: (id: string, body: { lines?: TInventoryLine[]; remarks?: string }) =>
|
|
75
79
|
api(`/requests/${id}/approve`, { method: "POST", body }),
|
|
80
|
+
/** Main store managers: the providers' stores at `site` they may send stock to, and the transfer itself. */
|
|
81
|
+
getTransferTargets: (store: string, site: string) =>
|
|
82
|
+
api<{ _id: string; name: string; orgName: string }[]>(`/stores/${store}/transfer-targets`, { query: { site } }),
|
|
83
|
+
transferToStore: (store: string, body: { to: string; site: string; lines: TInventoryLine[]; reference?: string; remarks?: string }) =>
|
|
84
|
+
api(`/stores/${store}/transfers`, { method: "POST", body }),
|
|
76
85
|
rejectRequest: (id: string, remarks: string) => api(`/requests/${id}/reject`, { method: "POST", body: { remarks } }),
|
|
77
86
|
/** Store manager: put a requested new item on the stock list (or link a same-name item); it becomes a normal line. */
|
|
78
87
|
addRequestNewItem: (id: string, body: { key: string; name: string; unit: string; category?: string }) =>
|
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.
|
|
5
|
+
"version": "4.170.0",
|
|
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
|
@@ -84,6 +84,8 @@ declare type TInventoryRequest = {
|
|
|
84
84
|
lines: { item: string; itemName: string; unit: string; qty: number; issuedQty: number; reservedQty?: number; wasNewItem?: boolean }[];
|
|
85
85
|
/** Items asked for that are not in the stock list yet. Approve is refused while any remain. */
|
|
86
86
|
newItems?: { key: string; name: string; qty: number; unit?: string; note?: string }[];
|
|
87
|
+
/** Delivered into the requester's own company store on approval (no Received step). */
|
|
88
|
+
deliverTo?: { store: string; storeName: string };
|
|
87
89
|
reference: string;
|
|
88
90
|
remarks: string;
|
|
89
91
|
status: "pending" | "issued" | "rejected" | "cancelled";
|
|
@@ -126,7 +128,9 @@ declare type TInventoryTransaction = {
|
|
|
126
128
|
item: string;
|
|
127
129
|
itemName: string;
|
|
128
130
|
unit: string;
|
|
129
|
-
type: "opening" | "receive" | "issue" | "use" | "return" | "adjust" | "handover" | "use_draft" | "write_off";
|
|
131
|
+
type: "opening" | "receive" | "issue" | "use" | "return" | "adjust" | "handover" | "use_draft" | "write_off" | "transfer";
|
|
132
|
+
/** Transfer only (2026-11-05): the other store (Main store -> a provider's own store). */
|
|
133
|
+
transferStoreName?: string;
|
|
130
134
|
qty: number;
|
|
131
135
|
storeChange: number;
|
|
132
136
|
storeBalance: number;
|
|
@@ -88,7 +88,7 @@ export const INVENTORY_HOW_IT_WORKS = {
|
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
title: "3. Main store and service providers",
|
|
91
|
-
text: "The property manager's Main store supplies the service providers
|
|
91
|
+
text: "The property manager's Main store supplies the service providers here. A provider with its own store (Our store) asks with Deliver to: Our store, and approved stock goes straight into it; or Me, handed to the person. The Main store can also transfer stock to it.",
|
|
92
92
|
},
|
|
93
93
|
],
|
|
94
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.",
|
|
@@ -104,3 +104,21 @@ export function inventoryTwoStoresText(stores: TStoreLike[]) {
|
|
|
104
104
|
if (!ours || !theirs) return "";
|
|
105
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
106
|
}
|
|
107
|
+
|
|
108
|
+
export type TSiteOwner = { site: string; store: string; name: string };
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The picker rows: a property already supplied by ANOTHER store of the organisation is disabled with
|
|
112
|
+
* the reason as its subtitle; the current store's own properties stay selectable.
|
|
113
|
+
*/
|
|
114
|
+
export function inventorySitePickerItems(
|
|
115
|
+
options: { _id: string; name: string }[],
|
|
116
|
+
owners: TSiteOwner[],
|
|
117
|
+
currentStore?: string,
|
|
118
|
+
) {
|
|
119
|
+
const taken = new Map(owners.filter((o) => o.store !== currentStore).map((o) => [o.site, o.name]));
|
|
120
|
+
return options.map((o) => {
|
|
121
|
+
const by = taken.get(o._id);
|
|
122
|
+
return by ? { ...o, props: { disabled: true, subtitle: `Already supplied by ${by}` } } : { ...o };
|
|
123
|
+
});
|
|
124
|
+
}
|
package/utils/inventory-usage.ts
CHANGED
|
@@ -85,8 +85,10 @@ export function usageTotals(rows: { status?: string; qty: number; totalCost?: nu
|
|
|
85
85
|
const WRITE_OFF_WORDS: Record<string, string> = { expended: "used up", spoilt: "spoilt", damaged: "damaged", lost: "lost", other: "other" };
|
|
86
86
|
|
|
87
87
|
/** What a history row says happened, from the person's side. */
|
|
88
|
-
export function historyText(t: { type: string; holderChange?: number; writeOffReason?: string }) {
|
|
88
|
+
export function historyText(t: { type: string; holderChange?: number; storeChange?: number; writeOffReason?: string; transferStoreName?: string }) {
|
|
89
89
|
switch (t.type) {
|
|
90
|
+
case "transfer":
|
|
91
|
+
return `${(t.storeChange ?? 0) > 0 ? "Transferred in from" : "Transferred to"} ${t.transferStoreName || "another store"}`;
|
|
90
92
|
case "write_off":
|
|
91
93
|
return `Written off${t.writeOffReason ? ` (${WRITE_OFF_WORDS[t.writeOffReason] ?? t.writeOffReason})` : ""}${(t.holderChange ?? 0) < 0 ? "" : " from the store"}`;
|
|
92
94
|
case "issue":
|