@7365admin1/layer-common 4.97.1-staging.658 → 4.97.1-staging.659
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/InventoryItemDetail.vue +1 -0
- package/components/InventoryLinesDialog.vue +72 -5
- package/components/InventoryMain.vue +5 -0
- package/components/InventoryReportsTab.vue +4 -0
- package/components/InventoryRequestsTab.vue +9 -2
- package/components/InventoryStockTab.vue +6 -2
- package/composables/useInventory.ts +6 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +5 -1
- package/utils/inventory-store-label.ts +1 -1
- package/utils/inventory-usage.ts +3 -1
|
@@ -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
|
});
|
|
@@ -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">
|
|
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
|
|
|
@@ -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.
|
|
5
|
+
"version": "4.97.1-staging.659",
|
|
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.",
|
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":
|