@7365admin1/layer-common 4.97.1-staging.732 → 4.97.1-staging.734
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/DashboardMain.vue +6 -4
- package/components/InventoryCheckoutReturnDialog.vue +144 -0
- package/components/InventoryCheckoutsTab.vue +257 -0
- package/components/InventoryItemDetail.vue +2 -0
- package/components/InventoryItemDialog.vue +37 -0
- package/components/InventoryLinesDialog.vue +158 -20
- package/components/InventoryMain.vue +21 -0
- package/components/InventoryMyStockTab.vue +16 -1
- package/components/InventorySerialPick.vue +85 -0
- package/components/InventorySerialScanner.vue +188 -0
- package/components/InventorySerialsDialog.vue +193 -0
- package/components/InventoryStockTab.vue +17 -0
- package/components/InventoryUsageDialog.vue +18 -0
- package/components/InventoryWorkOrderPicker.vue +222 -0
- package/components/InventoryWriteOffDialog.vue +14 -0
- package/components/Layout/Header.vue +3 -1
- package/components/Layout/NavigationDrawer.vue +3 -1
- package/components/ListCsvExport.vue +3 -1
- package/components/NavigationItem.vue +5 -3
- package/components/SiteSettingsWorkOrder.vue +14 -1
- package/components/WorkOrder/IssuedItems.vue +153 -0
- package/composables/useInventory.ts +20 -1
- package/composables/useReportPdf.ts +1 -1
- package/composables/useUiLanguage.ts +1 -1
- package/composables/useWorkOrder.ts +12 -0
- package/package.json +1 -1
- package/plugins/ui-language.ts +1 -1
- package/types/inventory.d.ts +52 -0
- package/utils/inventory-checkout.ts +64 -0
|
@@ -48,6 +48,16 @@
|
|
|
48
48
|
:disabled="isLoading || !canManageSiteSettings || !showMaterialsInResidentApp"
|
|
49
49
|
label="Also show the cost" />
|
|
50
50
|
|
|
51
|
+
<!-- DV-1787: items issued for a work order with a return date block completing it. -->
|
|
52
|
+
<v-divider class="my-4" />
|
|
53
|
+
<div class="text-subtitle-1 mb-1">Issued items</div>
|
|
54
|
+
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
55
|
+
Items issued from the store for a work order with a return date (for example tools) must be returned before the work order, or the feedback it is attached to, can be completed.
|
|
56
|
+
</p>
|
|
57
|
+
<v-switch v-model="requireItemReturnToComplete" color="primary" hide-details
|
|
58
|
+
:disabled="isLoading || !canManageSiteSettings"
|
|
59
|
+
label="Items must be returned before completing" />
|
|
60
|
+
|
|
51
61
|
<!-- Still a `v-btn`: `AppButton` has no loading state, and the
|
|
52
62
|
spinner on save is feedback, not decoration. -->
|
|
53
63
|
<v-btn v-if="canManageSiteSettings" class="screen-btn-primary text-none mt-4"
|
|
@@ -107,6 +117,7 @@ const noOfDigits = ref(1)
|
|
|
107
117
|
/** Service365 (resident) app switches; missing on a saved setting = off. */
|
|
108
118
|
const showMaterialsInResidentApp = ref(false)
|
|
109
119
|
const showMaterialCostInResidentApp = ref(false)
|
|
120
|
+
const requireItemReturnToComplete = ref(false)
|
|
110
121
|
const isLoading = ref(false)
|
|
111
122
|
|
|
112
123
|
const toast = reactive({
|
|
@@ -182,6 +193,7 @@ watchEffect(() => {
|
|
|
182
193
|
noOfDigits.value = workOrderSetting.value.noOfDigits
|
|
183
194
|
showMaterialsInResidentApp.value = !!workOrderSetting.value.showMaterialsInResidentApp
|
|
184
195
|
showMaterialCostInResidentApp.value = !!workOrderSetting.value.showMaterialCostInResidentApp
|
|
196
|
+
requireItemReturnToComplete.value = !!workOrderSetting.value.requireItemReturnToComplete
|
|
185
197
|
}
|
|
186
198
|
})
|
|
187
199
|
|
|
@@ -209,7 +221,8 @@ async function save() {
|
|
|
209
221
|
noOfDigits: noOfDigits.value,
|
|
210
222
|
showMaterialsInResidentApp: showMaterialsInResidentApp.value,
|
|
211
223
|
// Cost only shows with the materials.
|
|
212
|
-
showMaterialCostInResidentApp: showMaterialsInResidentApp.value && showMaterialCostInResidentApp.value
|
|
224
|
+
showMaterialCostInResidentApp: showMaterialsInResidentApp.value && showMaterialCostInResidentApp.value,
|
|
225
|
+
requireItemReturnToComplete: requireItemReturnToComplete.value
|
|
213
226
|
})
|
|
214
227
|
show("Saved successfully", "success")
|
|
215
228
|
} catch {
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
DV-1787: items issued from the store for this work order (or the feedback's attached work orders):
|
|
4
|
+
who has them, when they were issued, the return date, and when they came back. Hidden when none.
|
|
5
|
+
-->
|
|
6
|
+
<div v-if="items.length" class="issued-items">
|
|
7
|
+
<div class="text-subtitle-2 mb-2">Issued items</div>
|
|
8
|
+
<!-- The holder sees this right above Submit: hand the tools back so management can complete it. -->
|
|
9
|
+
<v-alert v-if="mineOut.length" type="info" variant="tonal" density="compact" class="mb-2" icon="mdi-keyboard-return">
|
|
10
|
+
{{ mineOut.length === 1 ? "1 item is with you." : `${mineOut.length} items are with you.` }} Ask to return when you hand {{ mineOut.length === 1 ? "it" : "them" }} back.
|
|
11
|
+
</v-alert>
|
|
12
|
+
<v-alert v-if="blocking" type="warning" variant="tonal" density="compact" class="mb-2" icon="mdi-lock-outline">
|
|
13
|
+
{{ blockingCount === 1 ? "1 item not returned yet." : `${blockingCount} items not returned yet.` }} Return {{ blockingCount === 1 ? "it" : "them" }} before completing.
|
|
14
|
+
</v-alert>
|
|
15
|
+
<!-- Stacked rows, not a table: the Information panel and the work order dialog are narrow. -->
|
|
16
|
+
<div class="issued-items__list">
|
|
17
|
+
<div v-for="c in items" :key="c._id" class="issued-items__row">
|
|
18
|
+
<div class="issued-items__top">
|
|
19
|
+
<span class="issued-items__name">
|
|
20
|
+
{{ c.itemName }}
|
|
21
|
+
<span v-if="showNumber && c.workOrderNumber" class="text-caption text-medium-emphasis">· {{ c.workOrderNumber }}</span>
|
|
22
|
+
</span>
|
|
23
|
+
<span class="d-flex flex-wrap ga-1">
|
|
24
|
+
<!-- hover: what the status means -->
|
|
25
|
+
<v-tooltip :text="checkoutChip(c).info" location="top" max-width="280">
|
|
26
|
+
<template #activator="{ props: tip }">
|
|
27
|
+
<v-chip v-bind="tip" size="small" variant="tonal" :color="checkoutChip(c).color" :prepend-icon="checkoutChip(c).icon">{{ checkoutChip(c).text }}</v-chip>
|
|
28
|
+
</template>
|
|
29
|
+
</v-tooltip>
|
|
30
|
+
<v-tooltip v-if="c.status === 'out' && c.returnRequest" :text="RETURN_ASKED_INFO" location="top" max-width="280">
|
|
31
|
+
<template #activator="{ props: tip }">
|
|
32
|
+
<v-chip v-bind="tip" size="small" variant="tonal" color="primary" prepend-icon="mdi-keyboard-return">Return asked</v-chip>
|
|
33
|
+
</template>
|
|
34
|
+
</v-tooltip>
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="issued-items__meta">{{ qtyUnit(c.status === "out" ? c.outQty : c.qty, c.unit) }} · with {{ c.holderName }}</div>
|
|
38
|
+
<div v-if="c.serials?.length" class="issued-items__meta text-medium-emphasis">S/N {{ c.serials.map((x) => x.serial).join(", ") }}</div>
|
|
39
|
+
<div class="issued-items__dates">
|
|
40
|
+
<span><span class="issued-items__label">Issued</span> {{ standardFormatDateTime(c.createdAt) }}</span>
|
|
41
|
+
<span><span class="issued-items__label">Return by</span> {{ c.returnDate ? returnDayText(c.returnDate) : "—" }}</span>
|
|
42
|
+
<span v-if="c.status !== 'out' && c.closedAt"><span class="issued-items__label">{{ c.status === "returned" ? "Returned" : "Closed" }}</span> {{ standardFormatDateTime(c.closedAt) }}</span>
|
|
43
|
+
</div>
|
|
44
|
+
<!-- DV-1787: the holder asks to return their own item from here (e.g. before Submit for review). -->
|
|
45
|
+
<v-btn
|
|
46
|
+
v-if="isMine(c) && !c.returnRequest"
|
|
47
|
+
size="small"
|
|
48
|
+
variant="tonal"
|
|
49
|
+
color="primary"
|
|
50
|
+
class="text-none mt-1"
|
|
51
|
+
prepend-icon="mdi-keyboard-return"
|
|
52
|
+
@click="openAsk(c)"
|
|
53
|
+
>
|
|
54
|
+
Ask to return
|
|
55
|
+
</v-btn>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<InventoryCheckoutReturnDialog v-model="ask.show" :row="ask.row" mode="ask" @done="load" />
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import useInventory from "../../composables/useInventory";
|
|
64
|
+
import useUtils from "../../composables/useUtils";
|
|
65
|
+
import { qtyUnit } from "../../utils/inventory-ack";
|
|
66
|
+
import { checkoutChip, returnDayKey, RETURN_ASKED_INFO } from "../../utils/inventory-checkout";
|
|
67
|
+
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
/** One of the two: the work order, or the feedback whose attached work orders are shown. */
|
|
70
|
+
workOrderId: { type: String, default: "" },
|
|
71
|
+
feedbackId: { type: String, default: "" },
|
|
72
|
+
/**
|
|
73
|
+
* Only on a page with a Complete button (management): warn that the items block completing.
|
|
74
|
+
* Service provider apps only Submit for review, so they leave it off.
|
|
75
|
+
*/
|
|
76
|
+
showCompletionBlock: { type: Boolean, default: false },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const { standardFormatDate, standardFormatDateTime } = useUtils();
|
|
80
|
+
const items = ref<TInventoryCheckout[]>([]);
|
|
81
|
+
const requireReturn = ref(false);
|
|
82
|
+
// A feedback can have more than one work order (re-opened): say which one each item was for.
|
|
83
|
+
const showNumber = computed(() => Boolean(props.feedbackId) && new Set(items.value.map((c) => c.workOrder)).size > 1);
|
|
84
|
+
const blockingCount = computed(() => items.value.filter((c) => c.status === "out" && c.returnDate).length);
|
|
85
|
+
const blocking = computed(() => props.showCompletionBlock && requireReturn.value && blockingCount.value > 0);
|
|
86
|
+
/** For the page's Complete button: true while items with a return date are out and the setting is on. */
|
|
87
|
+
const emit = defineEmits<{ blocking: [boolean] }>();
|
|
88
|
+
watch(() => requireReturn.value && blockingCount.value > 0, (v) => emit("blocking", v), { immediate: true });
|
|
89
|
+
|
|
90
|
+
const returnDayText = (d: string) => standardFormatDate(returnDayKey(d));
|
|
91
|
+
|
|
92
|
+
// The signed-in person's own items still out: they can ask to return them here.
|
|
93
|
+
const { currentUser } = useLocalAuth();
|
|
94
|
+
const me = computed(() => String(currentUser.value?._id ?? ""));
|
|
95
|
+
const isMine = (c: TInventoryCheckout) => c.status === "out" && !!me.value && String(c.holder) === me.value;
|
|
96
|
+
const mineOut = computed(() => items.value.filter((c) => isMine(c) && !c.returnRequest));
|
|
97
|
+
const ask = reactive({ show: false, row: null as TInventoryCheckout | null });
|
|
98
|
+
const openAsk = (row: TInventoryCheckout) => Object.assign(ask, { show: true, row });
|
|
99
|
+
|
|
100
|
+
async function load() {
|
|
101
|
+
if (!props.workOrderId && !props.feedbackId) return;
|
|
102
|
+
try {
|
|
103
|
+
const res = await useInventory().getWorkOrderCheckouts(props.workOrderId ? { workOrder: props.workOrderId } : { feedback: props.feedbackId });
|
|
104
|
+
items.value = res.items ?? [];
|
|
105
|
+
requireReturn.value = Boolean(res.requireReturn);
|
|
106
|
+
} catch {
|
|
107
|
+
items.value = [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
watch(() => [props.workOrderId, props.feedbackId], load);
|
|
111
|
+
onMounted(load);
|
|
112
|
+
defineExpose({ load });
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style scoped>
|
|
116
|
+
.issued-items {
|
|
117
|
+
margin-top: 16px;
|
|
118
|
+
}
|
|
119
|
+
.issued-items__row {
|
|
120
|
+
padding: 8px 0;
|
|
121
|
+
border-bottom: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
|
|
122
|
+
}
|
|
123
|
+
.issued-items__row:last-child {
|
|
124
|
+
border-bottom: 0;
|
|
125
|
+
}
|
|
126
|
+
.issued-items__top {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-wrap: wrap;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: space-between;
|
|
131
|
+
gap: 4px 8px;
|
|
132
|
+
}
|
|
133
|
+
.issued-items__name {
|
|
134
|
+
font-weight: 500;
|
|
135
|
+
min-width: 0;
|
|
136
|
+
overflow-wrap: anywhere;
|
|
137
|
+
}
|
|
138
|
+
.issued-items__meta {
|
|
139
|
+
font-size: 0.8125rem;
|
|
140
|
+
margin-top: 2px;
|
|
141
|
+
}
|
|
142
|
+
.issued-items__dates {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
gap: 2px 16px;
|
|
146
|
+
font-size: 0.75rem;
|
|
147
|
+
margin-top: 2px;
|
|
148
|
+
color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
|
|
149
|
+
}
|
|
150
|
+
.issued-items__label {
|
|
151
|
+
color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity));
|
|
152
|
+
}
|
|
153
|
+
</style>
|
|
@@ -61,6 +61,25 @@ export default function useInventory() {
|
|
|
61
61
|
count: (store: string, body: { item: string; countedQty: number; reason: string }) =>
|
|
62
62
|
api(`/stores/${store}/counts`, { method: "POST", body }),
|
|
63
63
|
issue: (store: string, body: Record<string, any>) => api(`/stores/${store}/issue`, { method: "POST", body }),
|
|
64
|
+
/** DV-1787: a store keeper takes back one checked-out item (or accepts the holder's request for it). */
|
|
65
|
+
returnCheckout: (checkout: string, note = "", serials?: string[]) =>
|
|
66
|
+
api(`/checkouts/${checkout}/return`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}) } }),
|
|
67
|
+
/** DV-1787: an item's serial numbers with their history, and adding serials to units on the shelf. */
|
|
68
|
+
getSerials: (item: string, status: "in_store" | "out" | "written_off" | "used" | "all" | "mine" = "all") =>
|
|
69
|
+
api<{ items: TInventorySerial[]; inStore: number; onHand: number }>(`/items/${item}/serials`, { query: status === "mine" ? { mine: true } : { status } }),
|
|
70
|
+
addSerials: (item: string, serials: string[]) => api(`/items/${item}/serials`, { method: "POST", body: { serials } }),
|
|
71
|
+
/** DV-1787: a store keeper sets, changes or clears (null) a checkout's return date. */
|
|
72
|
+
changeReturnDate: (checkout: string, returnDate: string | null, reason = "") =>
|
|
73
|
+
api(`/checkouts/${checkout}/return-date`, { method: "POST", body: { returnDate, reason } }),
|
|
74
|
+
/** DV-1787: the holder asks to return one checked-out item. */
|
|
75
|
+
requestCheckoutReturn: (checkout: string, note = "", serials?: string[]) =>
|
|
76
|
+
api(`/checkouts/${checkout}/return-request`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}) } }),
|
|
77
|
+
/** DV-1787: the items issued for a work order (or a feedback's work orders), and whether they block completing it. */
|
|
78
|
+
getWorkOrderCheckouts: (query: { workOrder?: string; feedback?: string }) =>
|
|
79
|
+
api<{ items: TInventoryCheckout[]; requireReturn: boolean }>(`/work-order-checkouts`, { query }),
|
|
80
|
+
/** DV-1787: what is checked out (issued for a work order / to come back by a date), with overdue flags. */
|
|
81
|
+
getCheckouts: (store: string, query: { status?: "out" | "closed" | "all"; mine?: boolean; overdue?: boolean; page?: number; limit?: number; search?: string } = {}) =>
|
|
82
|
+
api<{ items: TInventoryCheckout[]; total: number; page: number; pages: number; counts: { out: number; overdue: number } }>(`/stores/${store}/checkouts`, { query }),
|
|
64
83
|
receiveReturn: (store: string, body: Record<string, any>) => api(`/stores/${store}/returns`, { method: "POST", body }),
|
|
65
84
|
recordUsage: (store: string, body: Record<string, any>) => api(`/stores/${store}/usage`, { method: "POST", body }),
|
|
66
85
|
/** Usage drafts: before photo now, after photo and submit after the job (stock is deducted on submit). */
|
|
@@ -91,7 +110,7 @@ export default function useInventory() {
|
|
|
91
110
|
acknowledgeRequest: (id: string) => api<TInventoryRequest>(`/requests/${id}/acknowledge`, { method: "POST", body: {} }),
|
|
92
111
|
notReceived: (id: string, reason: string) => api<TInventoryRequest>(`/requests/${id}/not-received`, { method: "POST", body: { reason } }),
|
|
93
112
|
/** Used up / spoilt / damaged / lost / other: from the person's own stock, or from the store shelf (store keeper). */
|
|
94
|
-
writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[] }) =>
|
|
113
|
+
writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[]; serials?: string[] }) =>
|
|
95
114
|
api<TInventoryTransaction>(`/stores/${store}/write-offs`, { method: "POST", body }),
|
|
96
115
|
/** The holder asks to give stock back; a store keeper accepts it (acceptHandover) when it arrives. */
|
|
97
116
|
requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string }) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import html2canvas from "html2canvas";
|
|
2
2
|
import jsPDF from "jspdf";
|
|
3
|
-
import useUiLanguage from "./useUiLanguage";
|
|
3
|
+
import useUiLanguage from "./useUiLanguage.ts";
|
|
4
4
|
import { formatGeneratedAt, planPdfPages, type PdfTable } from "../utils/report-export";
|
|
5
5
|
|
|
6
6
|
export type ReportPdfMeta = {
|
|
@@ -91,7 +91,16 @@ export default function useWorkOrder() {
|
|
|
91
91
|
endDate = "",
|
|
92
92
|
date,
|
|
93
93
|
search = "",
|
|
94
|
+
assignee,
|
|
95
|
+
subject,
|
|
96
|
+
feedbackCreator,
|
|
94
97
|
}: {
|
|
98
|
+
/** DV-1787: also return feedbackCreator (who created the attached feedback) and search it. */
|
|
99
|
+
feedbackCreator?: boolean;
|
|
100
|
+
/** DV-1787: only work orders assigned to this user id. */
|
|
101
|
+
assignee?: string;
|
|
102
|
+
/** DV-1787: only work orders whose subject contains this text. */
|
|
103
|
+
subject?: string;
|
|
95
104
|
page?: number;
|
|
96
105
|
limit?: number;
|
|
97
106
|
search?: string;
|
|
@@ -119,6 +128,9 @@ export default function useWorkOrder() {
|
|
|
119
128
|
site,
|
|
120
129
|
provider,
|
|
121
130
|
providerService,
|
|
131
|
+
...(assignee ? { assignee } : {}),
|
|
132
|
+
...(subject ? { subject } : {}),
|
|
133
|
+
...(feedbackCreator ? { feedbackCreator: true } : {}),
|
|
122
134
|
},
|
|
123
135
|
});
|
|
124
136
|
}
|
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.734",
|
|
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/plugins/ui-language.ts
CHANGED
package/types/inventory.d.ts
CHANGED
|
@@ -58,6 +58,9 @@ declare type TInventoryItem = {
|
|
|
58
58
|
available?: number;
|
|
59
59
|
/** Issued but not yet confirmed (Received) by the person. */
|
|
60
60
|
awaitingReceipt?: number;
|
|
61
|
+
/** DV-1787: serial numbers - in all, and of units on the shelf (> 0: choose serials when issuing). */
|
|
62
|
+
serialsTotal?: number;
|
|
63
|
+
serialsInStore?: number;
|
|
61
64
|
/** Only while the item is low. */
|
|
62
65
|
lowStockAlert?: {
|
|
63
66
|
since?: string;
|
|
@@ -147,6 +150,8 @@ declare type TInventoryTransaction = {
|
|
|
147
150
|
workOrder?: string;
|
|
148
151
|
workOrderNumber?: string;
|
|
149
152
|
workOrderExists?: boolean;
|
|
153
|
+
/** Issue (DV-1787): when the person is expected to give it back ("YYYY-MM-DD" at midnight UTC). */
|
|
154
|
+
returnDate?: string | null;
|
|
150
155
|
/** The feedback the work order is tied to (2026-11): its link goes there. */
|
|
151
156
|
workOrderFeedback?: string | null;
|
|
152
157
|
supplier?: string;
|
|
@@ -174,6 +179,8 @@ declare type TInventoryTransaction = {
|
|
|
174
179
|
photosAfterAt?: string | null;
|
|
175
180
|
submittedAt?: string;
|
|
176
181
|
writeOffReason?: string;
|
|
182
|
+
/** DV-1787: the serial numbers this movement covers (issue, return, write-off, use). */
|
|
183
|
+
serials?: string[];
|
|
177
184
|
/** "Also attended" on a usage record. */
|
|
178
185
|
attendedWith?: string;
|
|
179
186
|
/** A draft taken over from a colleague. */
|
|
@@ -246,3 +253,48 @@ declare type TInventoryPoLine = {
|
|
|
246
253
|
receivedBy: string;
|
|
247
254
|
}[];
|
|
248
255
|
};
|
|
256
|
+
|
|
257
|
+
/** DV-1787: the work order picked in Issue Stock - its id, number as shown ("#CLN0012"), subject and status. */
|
|
258
|
+
declare type TPickedWorkOrder = { _id: string; number: string; subject: string; status: string };
|
|
259
|
+
|
|
260
|
+
/** DV-1787: stock issued for a work order and/or to come back by a date, tracked until it does. */
|
|
261
|
+
declare type TInventoryCheckout = {
|
|
262
|
+
_id: string;
|
|
263
|
+
store: string;
|
|
264
|
+
site?: string;
|
|
265
|
+
item: string;
|
|
266
|
+
itemName: string;
|
|
267
|
+
unit: string;
|
|
268
|
+
holder: string;
|
|
269
|
+
holderName: string;
|
|
270
|
+
qty: number;
|
|
271
|
+
outQty: number;
|
|
272
|
+
workOrder?: string;
|
|
273
|
+
workOrderNumber?: string;
|
|
274
|
+
returnDate: string | null;
|
|
275
|
+
status: "out" | "returned" | "written_off" | "used" | "handed_over" | "closed";
|
|
276
|
+
createdByName: string;
|
|
277
|
+
createdAt: string;
|
|
278
|
+
closedAt?: string;
|
|
279
|
+
overdue: boolean;
|
|
280
|
+
daysOverdue: number;
|
|
281
|
+
/** A return the holder asked for, waiting for a store keeper (its id), or null. */
|
|
282
|
+
returnRequest?: string | null;
|
|
283
|
+
/** Serial numbers still out on it. */
|
|
284
|
+
serials?: { _id: string; serial: string }[];
|
|
285
|
+
/** Return date set, changed or cleared after the issue (newest last). */
|
|
286
|
+
dateChanges?: { from: string | null; to: string | null; at: string; byName: string; reason?: string }[];
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/** DV-1787: one unit with its own serial number, and its history. */
|
|
290
|
+
declare type TInventorySerial = {
|
|
291
|
+
_id: string;
|
|
292
|
+
item: string;
|
|
293
|
+
itemName: string;
|
|
294
|
+
serial: string;
|
|
295
|
+
status: "in_store" | "out" | "written_off" | "used";
|
|
296
|
+
holderName?: string;
|
|
297
|
+
workOrderNumber?: string;
|
|
298
|
+
history: { type: string; at: string; byName: string; holderName?: string; workOrderNumber?: string; reason?: string; note?: string }[];
|
|
299
|
+
createdAt: string;
|
|
300
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DV-1787: shared wording for checkouts (stock issued for a work order / to come back by a date),
|
|
3
|
+
* used by the Checked out list, My Stock and a work order's Issued items.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** A return date is a calendar day saved as midnight UTC: the same day as a local Date, wherever the browser is. */
|
|
7
|
+
export function returnDayKey(d: string): Date {
|
|
8
|
+
const [y, m, day] = String(d).slice(0, 10).split("-").map(Number);
|
|
9
|
+
return new Date(y, m - 1, day);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type TChip = { text: string; color: string; icon: string; info: string };
|
|
13
|
+
|
|
14
|
+
const ENDED: Record<string, TChip> = {
|
|
15
|
+
returned: { text: "Returned", color: "success", icon: "mdi-check", info: "Back in the store. Nothing more to do." },
|
|
16
|
+
written_off: {
|
|
17
|
+
text: "Written off",
|
|
18
|
+
color: "grey",
|
|
19
|
+
icon: "mdi-close-circle-outline",
|
|
20
|
+
info: "Written off (lost, damaged, spoilt or used up). It is not coming back to the store.",
|
|
21
|
+
},
|
|
22
|
+
used: { text: "Used", color: "grey", icon: "mdi-check", info: "Used up on the job, so it is not coming back to the store." },
|
|
23
|
+
handed_over: {
|
|
24
|
+
text: "Handed over",
|
|
25
|
+
color: "grey",
|
|
26
|
+
icon: "mdi-account-switch-outline",
|
|
27
|
+
info: "Passed to a colleague. They have it now: see their row for its status.",
|
|
28
|
+
},
|
|
29
|
+
closed: { text: "Closed", color: "grey", icon: "mdi-check", info: "Closed: it is no longer out with anyone." },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Out / Due today / Overdue N days, or how it ended - with `info`, what the status means (hover). */
|
|
33
|
+
export function checkoutChip(c: { status: string; overdue?: boolean; daysOverdue?: number; returnDate?: string | null }): TChip {
|
|
34
|
+
if (c.status !== "out") return ENDED[c.status] ?? ENDED.closed;
|
|
35
|
+
if (c.overdue) {
|
|
36
|
+
const n = c.daysOverdue ?? 0;
|
|
37
|
+
return {
|
|
38
|
+
text: `Overdue ${n} ${n === 1 ? "day" : "days"}`,
|
|
39
|
+
color: "error",
|
|
40
|
+
icon: "mdi-alarm",
|
|
41
|
+
info: "Past its return date and still not returned. The person and the store keepers get a reminder every day until it comes back.",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const today = new Date().toLocaleDateString("en-CA", { timeZone: "Asia/Singapore" });
|
|
45
|
+
if (c.returnDate && String(c.returnDate).slice(0, 10) === today) {
|
|
46
|
+
return { text: "Due today", color: "warning", icon: "mdi-clock-outline", info: "Must be back in the store today. From tomorrow it shows as overdue." };
|
|
47
|
+
}
|
|
48
|
+
return c.returnDate
|
|
49
|
+
? {
|
|
50
|
+
text: "Not returned yet",
|
|
51
|
+
color: "info",
|
|
52
|
+
icon: "mdi-arrow-top-right",
|
|
53
|
+
info: "Still with the person. The return date has not come yet, so it is not overdue.",
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
text: "Out",
|
|
57
|
+
color: "info",
|
|
58
|
+
icon: "mdi-arrow-top-right",
|
|
59
|
+
info: "With the person, for the work order. No return date was set, so it is never overdue. It closes when returned, used up, written off or handed over.",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** "Return asked": the holder asked to return it; a store keeper accepts it when they have it. */
|
|
64
|
+
export const RETURN_ASKED_INFO = "The person asked to return it. It stays with them until a store keeper accepts the return.";
|