@7365admin1/layer-common 4.97.1-staging.734 → 4.97.1-staging.735

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.
@@ -150,6 +150,8 @@ const props = defineProps({
150
150
  store: { type: Object as PropType<TInventoryStore>, required: true },
151
151
  /** Only the signed-in person's checkouts (My Stock). */
152
152
  mine: { type: Boolean, default: false },
153
+ /** Bumped when stock changed on another tab (a return accepted in Cleaners): reload. */
154
+ refresh: { type: Number, default: 0 },
153
155
  });
154
156
  const emit = defineEmits<{ counts: [{ out: number; overdue: number }]; changed: [] }>();
155
157
  /** Store keepers take items back (the API checks too). */
@@ -253,5 +255,6 @@ watch(
253
255
  },
254
256
  );
255
257
  onMounted(load);
258
+ watch(() => props.refresh, () => load());
256
259
  defineExpose({ load });
257
260
  </script>
@@ -65,7 +65,7 @@
65
65
  </thead>
66
66
  <tbody>
67
67
  <tr v-for="t in history" :key="t._id">
68
- <td class="text-no-wrap">{{ formatDate(t.date) }}</td>
68
+ <td class="text-no-wrap">{{ whenText(t) }}</td>
69
69
  <td>
70
70
  {{ typeLabels[t.type] }}
71
71
  <template v-if="t.workOrder">
@@ -118,7 +118,7 @@ const emit = defineEmits(["edit", "done"]);
118
118
 
119
119
  const { getTransactions, count, typeLabels } = useInventory();
120
120
  const { getFileUrl } = useFile();
121
- const { requiredRule, standardFormatDate } = useUtils();
121
+ const { requiredRule, standardFormatDate, standardFormatDateTime } = useUtils();
122
122
  const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
123
123
 
124
124
  const history = ref<TInventoryTransaction[]>([]);
@@ -134,6 +134,14 @@ const writingOff = ref(false);
134
134
  const stepsLive = computed(() => inventoryStepsLive(props.store));
135
135
 
136
136
  const formatDate = (d: string) => standardFormatDate(d);
137
+ /** DV-1787: date and time of every row (DD/MM/YYYY HH:mm). A row dated a day only (a usage job date) takes the time it was recorded. */
138
+ function whenText(t: TInventoryTransaction) {
139
+ const d = new Date(t.date);
140
+ const dayOnly = d.getHours() === 0 && d.getMinutes() === 0;
141
+ const recorded = (t as any).createdAt as string | undefined;
142
+ if (dayOnly && recorded) return `${standardFormatDate(t.date)} ${String(standardFormatDateTime(recorded)).split(" ").pop()}`;
143
+ return standardFormatDateTime(t.date);
144
+ }
137
145
 
138
146
  /**
139
147
  * The work order a "Used" row came from: its feedback's details when it is tied
@@ -177,7 +177,7 @@
177
177
  :hint="serialHint(line)"
178
178
  persistent-hint
179
179
  :no-data-text="'No serial numbers on the shelf'"
180
- @update:model-value="(v: string[] | null) => (line.qty = Math.max(Number(line.qty) || 0, v?.length ?? 0) || null)"
180
+ @update:model-value="(v: string[] | null) => serialsPicked(line, v)"
181
181
  />
182
182
  <v-text-field
183
183
  v-if="mode === 'receive' && receivingType !== 'CASH'"
@@ -414,6 +414,14 @@ const copy = computed(() => {
414
414
  });
415
415
 
416
416
  const form = ref();
417
+ /** DV-1787: serials picked - Qty covers them, and its message is checked again (not left stale). */
418
+ function serialsPicked(line: TRow, v: string[] | null) {
419
+ line.qty = Math.max(Number(line.qty) || 0, v?.length ?? 0) || null;
420
+ nextTick(() => {
421
+ const qtyField = (form.value?.items ?? []).find((i: any) => i.errorMessages?.length && /serial/i.test(String(i.errorMessages)));
422
+ qtyField?.validate?.();
423
+ });
424
+ }
417
425
  const saving = ref(false);
418
426
  const blank = (): TRow => ({ item: null, qty: null, unitCost: null, ordered: null, typed: "", newItem: null });
419
427
  /** Receive: only store managers may add items to the list (the API says 403 otherwise). Request: anyone may ask. */
@@ -171,7 +171,7 @@
171
171
  </v-window-item>
172
172
  <!-- DV-1787: what is checked out (issued for a work order / to come back by a date), overdue first. -->
173
173
  <v-window-item v-if="seesCheckouts" value="checkouts">
174
- <InventoryCheckoutsTab :store="store" @counts="(c: { out: number; overdue: number }) => (overdueCount = c.overdue)" @changed="refreshCounts" />
174
+ <InventoryCheckoutsTab :store="store" :refresh="refreshTick" @counts="(c: { out: number; overdue: number }) => (overdueCount = c.overdue)" @changed="refreshCounts" />
175
175
  </v-window-item>
176
176
  <v-window-item v-if="ctl.tabs.requests" value="requests">
177
177
  <InventoryRequestsTab :store="store" :site-id="siteId" :focus-request="focusRequest" @changed="refreshCounts" />
@@ -416,7 +416,10 @@ async function refreshReturns() {
416
416
  }
417
417
  }
418
418
 
419
+ /** DV-1787: tells the Checked out list to reload after stock changed on another tab. */
420
+ const refreshTick = ref(0);
419
421
  async function refreshCounts() {
422
+ refreshTick.value++;
420
423
  refreshToConfirm();
421
424
  refreshReturns();
422
425
  refreshOverdue();
@@ -211,6 +211,17 @@
211
211
  style="max-width: 200px"
212
212
  :rules="[retQtyRule]"
213
213
  />
214
+ <!-- DV-1787: which serial numbers come back; the rest are units without a serial -->
215
+ <InventorySerialPick
216
+ v-model="ret.serials"
217
+ :item="String(ret.holding.item)"
218
+ source="mine"
219
+ :qty="Number(ret.qty || 0)"
220
+ :units="freeOf(ret.holding)"
221
+ :open="ret.show"
222
+ label="Which serial numbers? (optional)"
223
+ @update:model-value="(v: string[] | null) => (ret.qty = Math.max(Number(ret.qty) || 0, v?.length ?? 0) || null)"
224
+ />
214
225
  <InputLabel title="Note (optional)" class="mb-1" />
215
226
  <v-text-field v-model="ret.note" density="comfortable" maxlength="500" placeholder="e.g. job cancelled, not needed" />
216
227
  </v-form>
@@ -287,14 +298,14 @@ async function loadToReceive() {
287
298
  }
288
299
 
289
300
  const retForm = ref();
290
- const ret = reactive({ show: false, holding: null as TInventoryHolding | null, qty: 1 as number | null, note: "", saving: false });
301
+ const ret = reactive({ show: false, holding: null as TInventoryHolding | null, qty: 1 as number | null, note: "", serials: [] as string[], saving: false });
291
302
  const retQtyRule = (v: any) => {
292
303
  if (!Number.isInteger(Number(v)) || Number(v) < 1) return "Enter a whole number";
293
304
  const max = ret.holding ? freeOf(ret.holding) : 0;
294
305
  return Number(v) <= max || `You can return up to ${max}`;
295
306
  };
296
307
  function openReturn(h: TInventoryHolding) {
297
- Object.assign(ret, { show: true, holding: h, qty: freeOf(h), note: "", saving: false });
308
+ Object.assign(ret, { show: true, holding: h, qty: freeOf(h), note: "", serials: [], saving: false });
298
309
  }
299
310
  async function submitReturn() {
300
311
  const { valid } = await retForm.value.validate();
@@ -302,7 +313,13 @@ async function submitReturn() {
302
313
  ret.saving = true;
303
314
  try {
304
315
  const site = props.store.sites.includes(props.siteId) ? props.siteId : props.store.sites[0];
305
- await api.requestReturn(props.store._id, { site, item: String(ret.holding.item), qty: Number(ret.qty), note: ret.note });
316
+ await api.requestReturn(props.store._id, {
317
+ site,
318
+ item: String(ret.holding.item),
319
+ qty: Number(ret.qty),
320
+ note: ret.note,
321
+ ...(ret.serials.length ? { serials: ret.serials } : {}),
322
+ });
306
323
  notify("Return requested. Bring the items to the store keeper; they leave your stock once the keeper accepts them.");
307
324
  ret.show = false;
308
325
  changed();
@@ -128,6 +128,9 @@ const STATUS: Record<string, { text: string; color: string; info: string }> = {
128
128
  const EVENT: Record<string, string> = {
129
129
  added: "Serial number added",
130
130
  issued: "Issued",
131
+ received: "Received",
132
+ return_asked: "Asked to return",
133
+ return_declined: "Return not received",
131
134
  returned: "Returned to the store",
132
135
  written_off: "Written off",
133
136
  used: "Used",
@@ -138,9 +141,15 @@ function eventText(e: TInventorySerial["history"][number]) {
138
141
  const parts = [EVENT[e.type] ?? e.type];
139
142
  // Write-off: why - "Written off as damaged" (Used up, Spoilt, Damaged, Lost, Other).
140
143
  if (e.reason) parts[0] += ` as ${writeOffLabel(e.reason).toLowerCase()}`;
141
- if (e.holderName) parts.push(e.type === "handed_over" ? `to ${e.holderName}` : `to ${e.holderName}`);
144
+ // Both people (Benar 2026-11-23): who had it, and who did the step.
145
+ if (e.fromName && !["issued", "return_declined"].includes(e.type)) parts.push(`from ${e.fromName}`);
146
+ if (e.holderName) parts.push(`to ${e.holderName}`);
142
147
  if (e.workOrderNumber) parts.push(`for ${e.workOrderNumber}`);
143
- if (e.byName) parts.push(`· by ${e.byName}`);
148
+ if (e.byName) {
149
+ if (e.type === "received" || e.type === "return_asked") parts.push(`by ${e.byName}`);
150
+ else if (e.type === "returned" || e.type === "closed") parts.push(`· accepted by ${e.byName}`);
151
+ else if (!(e.fromName && e.fromName === e.byName)) parts.push(`· by ${e.byName}`);
152
+ }
144
153
  if (e.note) parts.push(`· ${e.note}`);
145
154
  return parts.join(" ");
146
155
  }
@@ -113,7 +113,7 @@ export default function useInventory() {
113
113
  writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[]; serials?: string[] }) =>
114
114
  api<TInventoryTransaction>(`/stores/${store}/write-offs`, { method: "POST", body }),
115
115
  /** The holder asks to give stock back; a store keeper accepts it (acceptHandover) when it arrives. */
116
- requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string }) =>
116
+ requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string; serials?: string[] }) =>
117
117
  api<TInventoryHandover>(`/stores/${store}/returns/request`, { method: "POST", body }),
118
118
  takeOverDraft: (id: string) => api<TInventoryUsageDraft>(`/usage-drafts/${id}/take-over`, { method: "POST", body: {} }),
119
119
  acknowledgeLowStock: (itemId: string, poNumber = "") =>
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.734",
5
+ "version": "4.97.1-staging.735",
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.",
@@ -295,6 +295,6 @@ declare type TInventorySerial = {
295
295
  status: "in_store" | "out" | "written_off" | "used";
296
296
  holderName?: string;
297
297
  workOrderNumber?: string;
298
- history: { type: string; at: string; byName: string; holderName?: string; workOrderNumber?: string; reason?: string; note?: string }[];
298
+ history: { type: string; at: string; byName: string; holderName?: string; workOrderNumber?: string; reason?: string; fromName?: string; note?: string }[];
299
299
  createdAt: string;
300
300
  };