@7365admin1/layer-common 4.97.1-staging.658 → 4.97.1-staging.660

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.
@@ -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, { site: props.siteId, lines, ...(newItems.length ? { newItems } : {}), reference: reference.value, remarks: remarks.value });
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
  });
@@ -235,6 +235,11 @@ const showSetup = ref(false);
235
235
  const showHowItWorks = ref(false);
236
236
  const { canManageInventory } = useInventoryPermission();
237
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
+ );
238
243
  // Scenario 3: a provider at a property with a main store may add its own store; offered only when it has none here.
239
244
  const canSetUpOwnStore = computed(() => canManageInventory.value && !stores.value.some((s) => s.owner === true));
240
245
  function openOwnStoreSetup() {
@@ -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">Hand over the items, then approve. You can give less than asked.</p>
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>
@@ -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
 
@@ -51,7 +51,7 @@
51
51
  <v-list-item
52
52
  density="compact"
53
53
  class="switch-context__row"
54
- v-for="item in uniqueItems"
54
+ v-for="item in visibleItems"
55
55
  :key="item.value"
56
56
  @click="selectItem(item.value)"
57
57
  >
@@ -61,6 +61,14 @@
61
61
 
62
62
  {{ item.text }}
63
63
  </v-list-item>
64
+ <v-list-item
65
+ v-if="!visibleItems.length && searchTerm"
66
+ density="compact"
67
+ class="switch-context__row"
68
+ disabled
69
+ >
70
+ No match for "{{ search }}"
71
+ </v-list-item>
64
72
  </v-list>
65
73
 
66
74
  <!-- The two actions under the list. Seven applications hand-wrote this
@@ -213,8 +221,61 @@ const uniqueItems = computed(() => {
213
221
  });
214
222
  });
215
223
 
224
+ /**
225
+ * THE SEARCH, APPLIED ON SCREEN.
226
+ *
227
+ * Owner report, 2026-11-05 (Security app, Aigle Security): typing "aigle" in
228
+ * the site switcher still listed every site. The layouts DO send the term to
229
+ * `GET /api/customer-sites`, but that search is the Sites page's search - it
230
+ * also matches the CLIENT's name (`siteOrgName`), and for an organisation's own
231
+ * sites the client is the organisation itself. So "aigle" matched every Aigle
232
+ * site and the server answer was the whole list. The organisation search
233
+ * (`$text` on memberships) has the opposite flaw: whole words only, and it also
234
+ * matches the member's own name.
235
+ *
236
+ * The switcher's contract is "find the row by the name I can see", so the rows
237
+ * are filtered here by that name (case-insensitive, contains) - instantly, as
238
+ * the user types, and over whatever the caller hands back. The caller's server
239
+ * search still runs (it is how a list longer than one page is reached); its
240
+ * rows are merged with the last unfiltered list, so a partial word the server
241
+ * cannot match still finds a row that was already loaded.
242
+ */
243
+ const searchTerm = computed(() =>
244
+ String(search.value ?? "").trim().toLowerCase(),
245
+ );
246
+
247
+ // The caller's list as it was with NO search - kept so a server answer that
248
+ // misses a row (or drops the selected one) does not hide it.
249
+ const unfilteredItems = shallowRef<Array<Record<string, any>>>([]);
250
+ watch(
251
+ uniqueItems,
252
+ (items) => {
253
+ if (!searchTerm.value) unfilteredItems.value = items;
254
+ },
255
+ { immediate: true },
256
+ );
257
+
258
+ const visibleItems = computed(() => {
259
+ const term = searchTerm.value;
260
+ if (!term) return uniqueItems.value;
261
+ const seen = new Set<unknown>();
262
+ return [...uniqueItems.value, ...unfilteredItems.value].filter((item) => {
263
+ const value = item?.value;
264
+ if (value !== undefined && value !== null && value !== "") {
265
+ if (seen.has(value)) return false;
266
+ seen.add(value);
267
+ }
268
+ return String(item?.text ?? "").toLowerCase().includes(term);
269
+ });
270
+ });
271
+
216
272
  const name = computed(() => {
217
- return uniqueItems.value.find((item) => item.value === selected.value)?.text ?? "";
273
+ const match = (item: Record<string, any>) => item.value === selected.value;
274
+ return (
275
+ uniqueItems.value.find(match)?.text ??
276
+ unfilteredItems.value.find(match)?.text ??
277
+ ""
278
+ );
218
279
  });
219
280
 
220
281
  /**
@@ -236,26 +297,35 @@ watchEffect(() => {
236
297
  });
237
298
 
238
299
  let searchDebounce: ReturnType<typeof setTimeout> | null = null;
239
- let skipNextWatch = false;
240
300
 
241
301
  const triggerSearch = () => {
242
302
  if (searchDebounce) clearTimeout(searchDebounce);
243
303
  emit("search");
244
304
  };
245
305
 
306
+ // Vuetify's clear button sets the field to `null` before `click:clear` fires;
307
+ // normalising to "" here lets the watch below do the one refetch. (The old
308
+ // skip-flag could swallow the user's NEXT keystroke when the two arrived in
309
+ // separate ticks.)
246
310
  const clearSearch = () => {
247
- skipNextWatch = true;
248
311
  search.value = "";
249
- triggerSearch();
250
312
  };
251
313
 
252
- watch(search, () => {
253
- if (skipNextWatch) {
254
- skipNextWatch = false;
314
+ watch(search, (value) => {
315
+ if (value === null || value === undefined) {
316
+ search.value = "";
255
317
  return;
256
318
  }
257
319
  if (searchDebounce) clearTimeout(searchDebounce);
258
- searchDebounce = setTimeout(triggerSearch, 1000);
320
+ // Emptied: restore the full list straight away. Typing: wait for a pause.
321
+ if (!value.trim()) triggerSearch();
322
+ else searchDebounce = setTimeout(triggerSearch, 1000);
323
+ });
324
+
325
+ // Closing the panel drops the search, so the list the caller holds (and the
326
+ // next opening) is the full one again rather than the last filtered answer.
327
+ watch(menu, (open) => {
328
+ if (!open && search.value) search.value = "";
259
329
  });
260
330
 
261
331
  onBeforeUnmount(() => {
@@ -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 {
@@ -76,6 +77,11 @@ export default function useInventory() {
76
77
  createRequest: (store: string, body: Record<string, any>) => api(`/stores/${store}/requests`, { method: "POST", body }),
77
78
  approveRequest: (id: string, body: { lines?: TInventoryLine[]; remarks?: string }) =>
78
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 }),
79
85
  rejectRequest: (id: string, remarks: string) => api(`/requests/${id}/reject`, { method: "POST", body: { remarks } }),
80
86
  /** Store manager: put a requested new item on the stock list (or link a same-name item); it becomes a normal line. */
81
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.97.1-staging.658",
5
+ "version": "4.97.1-staging.660",
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.",
@@ -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 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.",
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.",
@@ -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":