@7365admin1/layer-common 4.170.1 → 4.171.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.171.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 56755b3: Daily Checklist: add areas set up after the day's list was made (DV-0998, DV-1003)
8
+
9
+ A day's list is made at midnight, so an area set up during the day only started
10
+ on tomorrow's list, and "Create today's list now" showed only for an empty day.
11
+ The day view now names those areas in a notice with "Add to today's list"
12
+ (creating the list again adds only what is missing). Without the right to
13
+ create lists the notice says to ask someone who can. Areas with no units or no
14
+ visits are left out, as the list would skip them.
15
+
16
+ ## 4.170.2
17
+
18
+ ### Patch Changes
19
+
20
+ - 8d069ca: Inventory Add item: the quantity in store now sits right under the item name; Packing is now "Pack size (info only)". Saving a new item with 0 in store and a bare-number pack size asks "Did you mean N in stock?". Pack size label everywhere; item detail says when no stock has been recorded yet.
21
+
3
22
  ## 4.170.1
4
23
 
5
24
  ### Patch Changes
@@ -3873,11 +3892,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3873
3892
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3874
3893
  own rule from two endpoints the console already calls, unprojected:
3875
3894
 
3876
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3877
- GET /api/roles/id/:role that membership's role document
3895
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
3896
+ GET /api/roles/id/:role that membership's role document
3878
3897
 
3879
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3880
- staff = member.type === "admin" && role.type === "admin"
3898
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
3899
+ staff = member.type === "admin" && role.type === "admin"
3881
3900
 
3882
3901
  `role.default` is the marker because it is the only property of a platform
3883
3902
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -35,7 +35,7 @@ const COPY = {
35
35
  items: {
36
36
  title: "Import Items from Excel",
37
37
  noun: "items",
38
- fill: "One row per item. Unit, Packing, Category and Supplier have dropdowns with this store's values (a new supplier can still be typed in). Current Stock and the columns after it are the opening stock (date, supplier, PO no.), recorded like a delivery.",
38
+ fill: "One row per item. Unit, Pack size, Category and Supplier have dropdowns with this store's values (a new supplier can still be typed in). Pack size is info only — put how many you have in Quantity In Store Now; it and the columns after it are the opening stock (date, supplier, PO no.), recorded like a delivery.",
39
39
  duplicate: "Items already in the store are skipped and never changed, so uploading twice never doubles stock.",
40
40
  file: "inventory-items",
41
41
  done: (n: number) => `${n} item(s) added.`,
@@ -11,6 +11,7 @@
11
11
  <v-img v-if="item.photo" :src="getFileUrl(item.photo)" width="120" height="120" cover class="rounded flex-grow-0" />
12
12
  <div class="flex-grow-1">
13
13
  <div class="text-h5 mb-1" :class="item.lowStock ? 'text-error' : ''">{{ qtyUnit(item.onHand, item.unit) }} in store</div>
14
+ <div v-if="!item.onHand && !history.length && !loading" class="text-body-2 text-medium-emphasis mb-1">No stock recorded yet — use Receive Stock to add some.</div>
14
15
  <div v-if="item.reserved" class="text-body-2 mb-1">{{ availableText(item) }} (the rest is set aside for requests waiting for approval)</div>
15
16
  <div v-if="item.lowStockAlert" class="text-body-2 text-error mb-1">{{ lowStockAlertText(item.lowStockAlert, standardFormatDate) }}</div>
16
17
  <div class="text-body-2 text-medium-emphasis">
@@ -10,14 +10,20 @@
10
10
  <v-form ref="form" validate-on="blur invalid-input">
11
11
  <InputLabel title="Item name" required class="mb-1" />
12
12
  <v-text-field v-model="f.name" :rules="[requiredRule]" density="comfortable" placeholder="e.g. Philips T8 2ft 9W LED Tube" />
13
+ <!-- The stock quantity sits right under the name so it is never mistaken for Pack size (owner 2026-11-05). -->
14
+ <div v-if="!item" class="text-subtitle-2 mt-2 mb-1">How many do you have now?</div>
13
15
  <v-row dense>
14
16
  <v-col cols="12" sm="4">
15
17
  <InputLabel title="Unit" required class="mb-1" />
16
18
  <v-combobox v-model="f.unit" :items="units" :rules="[requiredRule]" density="comfortable" hint="How you count it (pcs, box, can)" persistent-hint />
17
19
  </v-col>
20
+ <v-col v-if="!item" cols="12" sm="4">
21
+ <InputLabel title="Quantity in store now" class="mb-1" />
22
+ <v-text-field v-model.number="f.openingQty" type="number" min="0" density="comfortable" :rules="[wholeRule]" :suffix="f.unit || ''" hint="0 if you have none yet" persistent-hint />
23
+ </v-col>
18
24
  <v-col cols="12" sm="4">
19
- <InputLabel title="Packing" class="mb-1" />
20
- <v-text-field v-model="f.packing" density="comfortable" placeholder="e.g. 25 pcs / box" maxlength="60" hint="How the supplier packs it (info only)" persistent-hint />
25
+ <InputLabel title="Pack size (info only)" class="mb-1" />
26
+ <v-text-field v-model="f.packing" density="comfortable" placeholder="e.g. 25 pcs / box — this is NOT the stock quantity" maxlength="60" hint="How the supplier packs it" persistent-hint />
21
27
  </v-col>
22
28
  <v-col cols="12" sm="4">
23
29
  <InputLabel title="Item code" class="mb-1" />
@@ -53,21 +59,17 @@
53
59
  </template>
54
60
  <!-- Stock already on the shelf, recorded like a delivery (one "Opening stock" entry in the item's history). -->
55
61
  <template v-if="!item">
56
- <div class="text-subtitle-2 mt-4">Opening stock</div>
62
+ <div class="text-subtitle-2 mt-4">Stock in store now — details (optional)</div>
57
63
  <div class="text-caption text-medium-emphasis mb-2">
58
- Stock you already have. It is recorded like a delivery and shows in the item's history and the Purchases report as "Opening stock".
59
- Supplier and PO no. are optional — old stock may have none. Leave the quantity at 0 if you have none yet.
64
+ The quantity in store now is recorded like a delivery and shows in the item's history and the Purchases report as "Opening stock".
65
+ Supplier and PO no. are optional — old stock may have none.
60
66
  </div>
61
67
  <v-row dense>
62
- <v-col cols="12" sm="4">
63
- <InputLabel title="Quantity" class="mb-1" />
64
- <v-text-field v-model.number="f.openingQty" type="number" min="0" density="comfortable" :rules="[wholeRule]" :suffix="f.unit || ''" hint="How many are in the store now" persistent-hint />
65
- </v-col>
66
- <v-col cols="12" sm="4">
68
+ <v-col cols="12" sm="6">
67
69
  <InputLabel title="Date received (as at)" class="mb-1" />
68
70
  <v-text-field v-model="f.openingDate" type="date" :max="today" density="comfortable" :disabled="!f.openingQty" hint="Blank = today" persistent-hint />
69
71
  </v-col>
70
- <v-col cols="12" sm="4">
72
+ <v-col cols="12" sm="6">
71
73
  <InputLabel title="Received by" class="mb-1" />
72
74
  <v-text-field v-model="f.openingReceivedBy" density="comfortable" maxlength="120" :disabled="!f.openingQty" placeholder="You" hint="Blank = you" persistent-hint />
73
75
  </v-col>
@@ -97,6 +99,13 @@
97
99
  />
98
100
  </v-form>
99
101
  </v-card-text>
102
+ <v-alert v-if="packGuess" type="warning" variant="tonal" density="compact" class="mx-4 mb-2">
103
+ Quantity in store is 0. Did you mean {{ packGuess }} in stock?
104
+ <div class="d-flex flex-wrap ga-2 mt-2">
105
+ <v-btn class="text-none" color="primary" variant="flat" size="small" @click="usePackGuess">Use {{ packGuess }} as quantity</v-btn>
106
+ <v-btn class="text-none" variant="outlined" size="small" @click="keepZero">Keep 0</v-btn>
107
+ </div>
108
+ </v-alert>
100
109
  <div class="screen-modal__footer">
101
110
  <v-btn class="screen-btn-ghost" variant="outlined" :disabled="saving" @click="show = false">Cancel</v-btn>
102
111
  <v-btn class="screen-btn-primary" variant="flat" :loading="saving" @click="save">{{ item ? "Save" : "Add item" }}</v-btn>
@@ -108,6 +117,7 @@
108
117
  <script setup lang="ts">
109
118
  import useInventory, { pickedDate } from "../composables/useInventory";
110
119
  import useUtils from "../composables/useUtils";
120
+ import { packSizeLooksLikeQty } from "../utils/inventory-store-label";
111
121
  import { normaliseUsedBy, nextUsedBy, USED_BY_ALL, USED_BY_ALL_LABEL, USED_BY_HINT, USED_BY_OPTIONS } from "../utils/inventory-used-by";
112
122
 
113
123
  const usedByItems = [{ value: USED_BY_ALL, title: USED_BY_ALL_LABEL }, ...USED_BY_OPTIONS];
@@ -150,6 +160,24 @@ const today = new Date().toLocaleDateString("en-CA");
150
160
  const f = reactive(blank());
151
161
  const photo = ref<string[]>([]);
152
162
  const inUse = ref(true);
163
+ /** A bare-number pack size on a new item with 0 in store: asked once before saving. */
164
+ const packGuess = ref<number | null>(null);
165
+ const zeroConfirmed = ref(false);
166
+ watch(() => [f.openingQty, f.packing], () => {
167
+ packGuess.value = null;
168
+ zeroConfirmed.value = false;
169
+ });
170
+
171
+ function usePackGuess() {
172
+ f.openingQty = packGuess.value!;
173
+ f.packing = "";
174
+ save();
175
+ }
176
+
177
+ function keepZero() {
178
+ zeroConfirmed.value = true;
179
+ save();
180
+ }
153
181
 
154
182
  watch(show, (open) => {
155
183
  if (!open) return;
@@ -157,11 +185,17 @@ watch(show, (open) => {
157
185
  Object.assign(f, blank(), i ? { name: i.name, unit: i.unit, packing: i.packing ?? "", code: i.code, category: i.category, reorderLevel: i.reorderLevel, unitCost: i.unitCost ?? 0, description: i.description, usedBy: normaliseUsedBy(i.usedBy) } : {});
158
186
  photo.value = i?.photo ? [i.photo] : [];
159
187
  inUse.value = i ? i.status === "active" : true;
188
+ packGuess.value = null;
189
+ zeroConfirmed.value = false;
160
190
  });
161
191
 
162
192
  async function save() {
163
193
  const { valid } = await form.value.validate();
164
194
  if (!valid) return;
195
+ if (!props.item && !zeroConfirmed.value) {
196
+ packGuess.value = packSizeLooksLikeQty(f.packing, f.openingQty);
197
+ if (packGuess.value) return;
198
+ }
165
199
  saving.value = true;
166
200
  const body = {
167
201
  name: f.name,
@@ -422,7 +422,7 @@ const headers: Record<string, any[]> = {
422
422
  movement: [
423
423
  { title: "Item", key: "name" },
424
424
  { title: "Unit", key: "unit" },
425
- { title: "Packing", key: "packing" },
425
+ { title: "Pack size", key: "packing" },
426
426
  { title: "Start", key: "opening" },
427
427
  { title: "Received", key: "received" },
428
428
  { title: "Purchase cost", key: "receivedCost" },
@@ -8,6 +8,32 @@
8
8
  :schedule-route="scheduleRoute"
9
9
  text="These are the areas on this day's checklist. Click an area to see each unit, tick it as done, or send it back to be redone. Visits today counts the area's normal visits plus any extra checks added today."
10
10
  />
11
+ <!--
12
+ DV-0998 / DV-1003: an area set up during the day is not on that day's
13
+ list (lists are made at midnight). Say which, and offer to add it:
14
+ creating the list again adds only what is missing.
15
+ -->
16
+ <v-alert
17
+ v-if="showMissingNotice"
18
+ type="info"
19
+ variant="tonal"
20
+ density="comfortable"
21
+ class="mb-3"
22
+ :title="missingNotice.title"
23
+ :text="missingNotice.body"
24
+ >
25
+ <template v-if="canGenerateChecklist" #append>
26
+ <v-btn
27
+ class="text-none screen-btn-primary"
28
+ variant="flat"
29
+ aria-label="Add to today's list"
30
+ :loading="addingAreas"
31
+ @click="addMissingAreas"
32
+ >
33
+ Add to today's list
34
+ </v-btn>
35
+ </template>
36
+ </v-alert>
11
37
  <TableMain
12
38
  :title="dayTitle"
13
39
  :headers="headers"
@@ -144,11 +170,15 @@
144
170
  <script setup lang="ts">
145
171
  import useCleaningSchedules from "../composables/useCleaningSchedules";
146
172
  import {
173
+ areaNamesText,
174
+ areasMissingFromDay,
147
175
  dailyChecklistTitle,
148
176
  dailyStatusLabel,
149
177
  dayLabel,
150
178
  isClosedDay,
179
+ missingAreasNotice,
151
180
  } from "../utils/schedule-task";
181
+ import useAreas from "../composables/useAreas";
152
182
  import useUtils from "../composables/useUtils";
153
183
 
154
184
  const props = defineProps({
@@ -271,6 +301,69 @@ const showCreateList = computed(
271
301
  items.value.length === 0,
272
302
  );
273
303
 
304
+ // Areas set up after this day's list was made (DV-0998 / DV-1003). The whole
305
+ // day and every area of the service, not the filtered page on screen.
306
+ const { getAreas } = useAreas();
307
+ const missingAreas = ref<string[]>([]);
308
+ const addingAreas = ref(false);
309
+
310
+ async function checkMissingAreas() {
311
+ if (!props.site || !props.scheduleAreaId || !props.serviceType) return;
312
+ try {
313
+ const [areas, day] = await Promise.all([
314
+ getAreas({ site: props.site, serviceType: props.serviceType, limit: 200 }),
315
+ getScheduleAreas({
316
+ scheduleAreaId: props.scheduleAreaId,
317
+ page: 1,
318
+ limit: 200,
319
+ serviceType: props.serviceType,
320
+ }),
321
+ ]);
322
+ missingAreas.value = areasMissingFromDay(areas?.items, day?.items);
323
+ } catch {
324
+ // a failed check is not evidence of a missing area: say nothing
325
+ missingAreas.value = [];
326
+ }
327
+ }
328
+
329
+ const showMissingNotice = computed(
330
+ () =>
331
+ missingAreas.value.length > 0 &&
332
+ !isScheduleClosed.value &&
333
+ !showCreateList.value &&
334
+ !loading.value,
335
+ );
336
+ const missingNotice = computed(() =>
337
+ missingAreasNotice(missingAreas.value, canGenerateChecklist.value),
338
+ );
339
+
340
+ async function addMissingAreas() {
341
+ const before = [...missingAreas.value];
342
+ try {
343
+ addingAreas.value = true;
344
+ await generateChecklist(props.site, props.scheduleAreaId);
345
+ await Promise.all([getScheduleAreasRefresh(), checkMissingAreas()]);
346
+ const added = before.filter((name) => !missingAreas.value.includes(name));
347
+ showMessage(
348
+ added.length
349
+ ? `${areaNamesText(added)} added to today's list.`
350
+ : "Today's list already has every area that can be added.",
351
+ added.length ? "success" : "info",
352
+ );
353
+ } catch (error: any) {
354
+ showMessage(
355
+ `Could not add ${areaNamesText(before)} to today's list. ${
356
+ error?.data?.message || "Check your connection and try again."
357
+ }`,
358
+ "error",
359
+ );
360
+ } finally {
361
+ addingAreas.value = false;
362
+ }
363
+ }
364
+
365
+ watch(() => [props.site, props.scheduleAreaId, props.serviceType], checkMissingAreas);
366
+
274
367
  function showMessage(msg: string, color: string = "error") {
275
368
  message.value = msg;
276
369
  messageColor.value = color;
@@ -306,6 +399,7 @@ async function _generateChecklist() {
306
399
  if (typeof getScheduleAreasRefresh === "function") {
307
400
  getScheduleAreasRefresh();
308
401
  }
402
+ checkMissingAreas();
309
403
  } catch (error: any) {
310
404
  showMessage(error?.data?.message || error?.message || "Could not create today's list.", "error");
311
405
  } finally {
@@ -314,6 +408,7 @@ async function _generateChecklist() {
314
408
  }
315
409
 
316
410
  onMounted(() => {
411
+ checkMissingAreas();
317
412
  try {
318
413
  const { $socket } = useNuxtApp() as any;
319
414
  if ($socket) {
@@ -326,6 +421,7 @@ onMounted(() => {
326
421
  if (typeof getScheduleAreasRefresh === "function") {
327
422
  getScheduleAreasRefresh();
328
423
  }
424
+ checkMissingAreas();
329
425
  }
330
426
  );
331
427
  }
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.170.1",
5
+ "version": "4.171.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.",
@@ -62,13 +62,24 @@ export function inventorySiteOptions(
62
62
 
63
63
  type TItemLike = { code?: string; category?: string; packing?: string };
64
64
 
65
- /** "Code 001 · Bulb · Packing: 25" - each figure says what it is, never a bare number. */
65
+ /** "Code 001 · Bulb · Pack size: 25" - each figure says what it is, never a bare number. */
66
66
  export function inventoryItemMeta(item: TItemLike) {
67
- return [item.code && `Code ${item.code}`, item.category, item.packing && `Packing: ${item.packing}`]
67
+ return [item.code && `Code ${item.code}`, item.category, item.packing && `Pack size: ${item.packing}`]
68
68
  .filter(Boolean)
69
69
  .join(" · ");
70
70
  }
71
71
 
72
+ /**
73
+ * A pack size typed as a bare number ("50") on a new item with 0 in store is usually the stock
74
+ * quantity in the wrong box (owner 2026-11-05: "available is 0 but there's 50 packing").
75
+ * Returns that number so the form can ask; null when the pack size reads like a pack size.
76
+ */
77
+ export function packSizeLooksLikeQty(packing: unknown, qty: unknown): number | null {
78
+ if (Number(qty || 0) !== 0) return null;
79
+ const m = /^\s*(\d+)\s*$/.exec(String(packing ?? ""));
80
+ return m && Number(m[1]) > 0 ? Number(m[1]) : null;
81
+ }
82
+
72
83
  /**
73
84
  * "How inventory works" (owner 2026-11-05): the three ways clients run stock, in the words the screens use.
74
85
  * The mobile apps carry the same sentences; change both together.
@@ -450,3 +450,49 @@ export function checklistPdfName(day: string | Date | null | undefined, now: Dat
450
450
  const p = (n: number) => String(n).padStart(2, "0");
451
451
  return `CHECKLIST_DOWNLOADED_${p(now.getDate())}_${p(now.getMonth() + 1)}_${now.getFullYear()} ${p(now.getHours())}_${p(now.getMinutes())}.pdf`;
452
452
  }
453
+
454
+ /**
455
+ * AREAS SET UP AFTER THE DAY'S LIST WAS MADE (DV-0998 / DV-1003).
456
+ *
457
+ * A day's list is made at midnight from the areas set up then, so an area added
458
+ * during the day only starts on tomorrow's list. Creating the list again adds
459
+ * the missing areas and leaves the ones already on it alone (module-hygiene
460
+ * `createAreaChecklist`). These are the areas it would add: set up with at least
461
+ * one visit and, when the server says how many, at least one unit (an area
462
+ * without units is skipped, and `ScheduleGuide` already says so). Matched by
463
+ * name, the only area field the day list returns.
464
+ */
465
+ export function areasMissingFromDay(
466
+ siteAreas: { name?: string | null; set?: unknown; unitCount?: unknown }[] | null | undefined,
467
+ dayRows: { name?: string | null }[] | null | undefined,
468
+ ): string[] {
469
+ const key = (s: unknown) => String(s ?? "").trim().toLowerCase();
470
+ const onDay = new Set((dayRows ?? []).map((r) => key(r?.name)));
471
+ const missing: string[] = [];
472
+ for (const a of siteAreas ?? []) {
473
+ const name = String(a?.name ?? "").trim();
474
+ if (!name || onDay.has(key(name))) continue;
475
+ if (!(Number(a?.set) >= 1)) continue;
476
+ if (typeof a?.unitCount === "number" && a.unitCount === 0) continue;
477
+ if (!missing.some((m) => key(m) === key(name))) missing.push(name);
478
+ }
479
+ return missing;
480
+ }
481
+
482
+ /** "Hallway", "Hallway and Lobby B", "Hallway, Lobby B and 2 more". */
483
+ export function areaNamesText(names: string[]): string {
484
+ if (names.length <= 1) return names[0] ?? "";
485
+ if (names.length === 2) return `${names[0]} and ${names[1]}`;
486
+ if (names.length === 3) return `${names[0]}, ${names[1]} and ${names[2]}`;
487
+ return `${names[0]}, ${names[1]} and ${names.length - 2} more`;
488
+ }
489
+
490
+ /** The notice above the day's list, in the words the mockup agreed (6 Nov 2026). */
491
+ export function missingAreasNotice(names: string[], canAdd: boolean): { title: string; body: string } {
492
+ const one = names.length === 1;
493
+ const title = `${areaNamesText(names)} ${one ? "was" : "were"} set up after today's list was made.`;
494
+ const body = canAdd
495
+ ? `Add ${one ? "it" : "them"} to today's list so ${one ? "it" : "they"} can be checked today. Otherwise ${one ? "it starts" : "they start"} on tomorrow's list.`
496
+ : `${one ? "It starts" : "They start"} on tomorrow's list. To check ${one ? "it" : "them"} today, ask someone who can create daily checklists to add ${one ? "it" : "them"}.`;
497
+ return { title, body };
498
+ }