@7365admin1/layer-common 4.17.1-staging.331 → 4.17.1-staging.333
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 +19 -3
- package/components/HidUserEnrollment.vue +121 -6
- package/components/InventoryLegacyImportDialog.vue +108 -0
- package/components/InventoryReportsTab.vue +110 -12
- package/components/InventoryStockTab.vue +3 -0
- package/composables/useInventory.ts +9 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
:key="card.key"
|
|
18
18
|
class="print-kpi-card"
|
|
19
19
|
>
|
|
20
|
-
<span class="print-kpi-title">{{ card
|
|
20
|
+
<span class="print-kpi-title">{{ cardTitle(card) }}</span>
|
|
21
21
|
<template
|
|
22
22
|
v-if="card.key === 'supplyAlert' && Array.isArray(card.raw?.items)"
|
|
23
23
|
>
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
:icon="card.icon"
|
|
332
332
|
:tint="card.tint"
|
|
333
333
|
:color="card.color"
|
|
334
|
-
:label="card
|
|
334
|
+
:label="cardTitle(card)"
|
|
335
335
|
:value="card.value"
|
|
336
336
|
:chip="kpiChipText(card)"
|
|
337
337
|
:down="Number(card.percentage) < 0"
|
|
@@ -1422,7 +1422,15 @@ const moduleWidgetPermissions: Record<string, string[]> = {
|
|
|
1422
1422
|
],
|
|
1423
1423
|
staffStatus: ["attendance-mgmt:see-all-attendance"],
|
|
1424
1424
|
attendance: ["attendance-mgmt:see-all-attendance"],
|
|
1425
|
-
|
|
1425
|
+
// Inventory roles see the tile too: where a store serves the site it lists
|
|
1426
|
+
// the items at or below their alert level (core new-dashboard.repo).
|
|
1427
|
+
supplyAlert: [
|
|
1428
|
+
"supply-mgmt:see-all-supplies",
|
|
1429
|
+
"inventory:view-inventory",
|
|
1430
|
+
"inventory:request-stock",
|
|
1431
|
+
"inventory:approve-requests",
|
|
1432
|
+
"inventory:manage-inventory",
|
|
1433
|
+
],
|
|
1426
1434
|
feedbacks: [
|
|
1427
1435
|
"feedbacks:see-all-feedback",
|
|
1428
1436
|
"feedback:see-all-feedback",
|
|
@@ -1880,6 +1888,14 @@ const finalDashboardData = computed<Record<string, any>>(() => {
|
|
|
1880
1888
|
* new colour. That also makes each tile the design's own chip pairing, which
|
|
1881
1889
|
* is the ruling this project already follows.
|
|
1882
1890
|
*/
|
|
1891
|
+
/**
|
|
1892
|
+
* Where an Inventory store serves the site, the supply tile lists real low
|
|
1893
|
+
* stock (items at or below their alert level), so it is named for that.
|
|
1894
|
+
*/
|
|
1895
|
+
function cardTitle(card: { key: string; title: string; raw?: any }) {
|
|
1896
|
+
return card.key === "supplyAlert" && card.raw?.basis === "below-alert-level" ? "Low Stock" : card.title;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1883
1899
|
const KPI_TONES = {
|
|
1884
1900
|
info: { color: "var(--info)", tint: "var(--info-bg)" },
|
|
1885
1901
|
err: { color: "var(--err)", tint: "var(--err-bg)" },
|
|
@@ -559,22 +559,50 @@
|
|
|
559
559
|
/>
|
|
560
560
|
</template>
|
|
561
561
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
562
|
+
<v-alert
|
|
563
|
+
v-if="enrollingCard"
|
|
564
|
+
type="info"
|
|
565
|
+
variant="tonal"
|
|
566
|
+
density="compact"
|
|
567
|
+
class="mt-4"
|
|
568
|
+
>
|
|
569
|
+
Present the physical card to the selected Amico reader. The request will time out after 30 seconds.
|
|
570
|
+
</v-alert>
|
|
571
|
+
|
|
572
|
+
<!-- Reading the card at the reader is the primary way in: it is the
|
|
573
|
+
only one that does not require knowing the facility code and card
|
|
574
|
+
number up front, which are printed on nothing the operator holds.
|
|
575
|
+
Assigning by hand stays for the cards whose values are already
|
|
576
|
+
known. -->
|
|
566
577
|
<div class="hid-card-actions mt-4">
|
|
567
578
|
<AppButton
|
|
568
579
|
variant="secondary"
|
|
569
|
-
:disabled="savingCard || !cardProfileConfigured"
|
|
580
|
+
:disabled="savingCard || enrollingCard || !cardProfileConfigured"
|
|
570
581
|
@click="assignPhysicalCard"
|
|
571
582
|
>
|
|
572
583
|
Assign Manually
|
|
573
584
|
</AppButton>
|
|
585
|
+
<AppButton
|
|
586
|
+
icon="mdi-contactless-payment"
|
|
587
|
+
:disabled="savingCard || enrollingCard || !cardProfileConfigured"
|
|
588
|
+
@click="enrollPhysicalCard"
|
|
589
|
+
>
|
|
590
|
+
Read at Reader
|
|
591
|
+
</AppButton>
|
|
592
|
+
<AppButton
|
|
593
|
+
v-if="enrollingCard"
|
|
594
|
+
variant="ghost"
|
|
595
|
+
:disabled="cancellingCard"
|
|
596
|
+
@click="cancelPhysicalCardEnrollment"
|
|
597
|
+
>
|
|
598
|
+
{{ cancellingCard ? "Cancelling…" : "Cancel Reading" }}
|
|
599
|
+
</AppButton>
|
|
574
600
|
</div>
|
|
575
601
|
</v-card-text>
|
|
576
602
|
<v-card-actions class="screen-modal__footer">
|
|
577
|
-
|
|
603
|
+
<!-- Closing mid-read would leave the reader listening with nothing
|
|
604
|
+
to receive the card it reads. -->
|
|
605
|
+
<AppButton variant="ghost" :disabled="enrollingCard" @click="cardDialog = false">
|
|
578
606
|
Close
|
|
579
607
|
</AppButton>
|
|
580
608
|
</v-card-actions>
|
|
@@ -644,6 +672,8 @@ const {
|
|
|
644
672
|
deleteUserImage,
|
|
645
673
|
getUserCards,
|
|
646
674
|
assignUserCard,
|
|
675
|
+
enrollUserCard,
|
|
676
|
+
cancelUserCardEnrollment,
|
|
647
677
|
deleteUserCard,
|
|
648
678
|
getUserPinStatus,
|
|
649
679
|
setUserPin,
|
|
@@ -742,6 +772,15 @@ const physicalCardsByUserId = ref<Record<string, HidCard[]>>({});
|
|
|
742
772
|
const physicalCardErrorsByUserId = ref<Record<string, string>>({});
|
|
743
773
|
const loadingCards = ref(false);
|
|
744
774
|
const savingCard = ref(false);
|
|
775
|
+
const enrollingCard = ref(false);
|
|
776
|
+
/*
|
|
777
|
+
* Cancelling makes the in-flight enrol REJECT, and that rejection is expected
|
|
778
|
+
* rather than a failure. Without this flag the cancel raises an error toast on
|
|
779
|
+
* top of the one confirming it, which reads as the cancel having gone wrong.
|
|
780
|
+
*/
|
|
781
|
+
const cardEnrollmentCancelled = ref(false);
|
|
782
|
+
/** The cancel's own round trip to the reader — a second or two, not the enrol's. */
|
|
783
|
+
const cancellingCard = ref(false);
|
|
745
784
|
const deletingCardId = ref("");
|
|
746
785
|
const showPin = ref(false);
|
|
747
786
|
const pinEnrolled = ref(false);
|
|
@@ -2165,6 +2204,82 @@ async function assignPhysicalCard() {
|
|
|
2165
2204
|
}
|
|
2166
2205
|
}
|
|
2167
2206
|
|
|
2207
|
+
/**
|
|
2208
|
+
* Read a physical card by presenting it to the reader.
|
|
2209
|
+
*
|
|
2210
|
+
* The way most cards get assigned, because it is the only one that does not
|
|
2211
|
+
* require knowing the facility code and card number in advance - neither is
|
|
2212
|
+
* printed on the card, and an operator holding a blank fob has no way to look
|
|
2213
|
+
* them up. The reader listens for 30 seconds and reports what it read.
|
|
2214
|
+
*/
|
|
2215
|
+
async function enrollPhysicalCard() {
|
|
2216
|
+
const { readerId, hidUserId } = getCardReaderAndUser();
|
|
2217
|
+
if (!readerId || !hidUserId) return;
|
|
2218
|
+
|
|
2219
|
+
enrollingCard.value = true;
|
|
2220
|
+
cardEnrollmentCancelled.value = false;
|
|
2221
|
+
try {
|
|
2222
|
+
await enrollUserCard(readerId, hidUserId, cardForm.cardType, 30);
|
|
2223
|
+
await loadPhysicalCards();
|
|
2224
|
+
await loadUsers();
|
|
2225
|
+
showToast("Physical HID card read and enrolled on the reader.");
|
|
2226
|
+
} catch (error: unknown) {
|
|
2227
|
+
// Cancelling rejects the request above. That is the operator getting what
|
|
2228
|
+
// they asked for, so it must not also be reported as a failure.
|
|
2229
|
+
if (!cardEnrollmentCancelled.value) {
|
|
2230
|
+
showToast(getHidErrorMessage(error), "error");
|
|
2231
|
+
}
|
|
2232
|
+
} finally {
|
|
2233
|
+
enrollingCard.value = false;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
/**
|
|
2238
|
+
* Stop the reader listening.
|
|
2239
|
+
*
|
|
2240
|
+
* Told to the DEVICE, not just the screen: abandoning the request on this side
|
|
2241
|
+
* would leave the reader waiting out its 30 seconds and enrolling whatever card
|
|
2242
|
+
* was presented in the meantime.
|
|
2243
|
+
*/
|
|
2244
|
+
/**
|
|
2245
|
+
* Stop the reader listening, and hand the dialog straight back.
|
|
2246
|
+
*
|
|
2247
|
+
* Told to the DEVICE, not just the screen: abandoning the request on this side
|
|
2248
|
+
* would leave the reader waiting out its remaining seconds and enrolling
|
|
2249
|
+
* whatever card was presented in the meantime.
|
|
2250
|
+
*
|
|
2251
|
+
* The part worth understanding is what the ENROL request does next. The server
|
|
2252
|
+
* cannot tell a cancelled read from a failed one - the reader simply reports no
|
|
2253
|
+
* card - so the enrol that is still in flight ends as a 400, seconds after the
|
|
2254
|
+
* cancel. Waiting for it was the bug: Cancel appeared to do nothing until that
|
|
2255
|
+
* rejection finally arrived.
|
|
2256
|
+
*
|
|
2257
|
+
* So the dialog is released as soon as the DEVICE confirms it has stopped, and
|
|
2258
|
+
* the doomed enrol is left to land on its own. `cardEnrollmentCancelled` is set
|
|
2259
|
+
* before anything is awaited, which is what keeps its 400 silent.
|
|
2260
|
+
*/
|
|
2261
|
+
async function cancelPhysicalCardEnrollment() {
|
|
2262
|
+
const { readerId } = getCardReaderAndUser();
|
|
2263
|
+
if (!readerId) return;
|
|
2264
|
+
// Set first, awaited second: the enrol can reject at any point from here.
|
|
2265
|
+
cardEnrollmentCancelled.value = true;
|
|
2266
|
+
cancellingCard.value = true;
|
|
2267
|
+
try {
|
|
2268
|
+
await cancelUserCardEnrollment(readerId);
|
|
2269
|
+
// Only now, because the enrollment lock is released by the call above.
|
|
2270
|
+
// Re-enabling Read at Reader any earlier invites a second attempt that
|
|
2271
|
+
// the reader refuses with "already running".
|
|
2272
|
+
enrollingCard.value = false;
|
|
2273
|
+
showToast("Physical HID card reading cancelled.");
|
|
2274
|
+
} catch (error: unknown) {
|
|
2275
|
+
// The cancel itself failing is real and worth saying: the reader may still
|
|
2276
|
+
// be listening, so the dialog stays in its reading state.
|
|
2277
|
+
showToast(getHidErrorMessage(error), "error");
|
|
2278
|
+
} finally {
|
|
2279
|
+
cancellingCard.value = false;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2168
2283
|
async function removePhysicalCard(card: HidCard) {
|
|
2169
2284
|
if (!window.confirm(`Remove physical HID card ${formatPhysicalCard(card)}?`)) return;
|
|
2170
2285
|
const { readerId, hidUserId } = getCardReaderAndUser();
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-dialog v-model="show" max-width="720" persistent scrollable>
|
|
3
|
+
<v-card class="screen-modal">
|
|
4
|
+
<v-card-title class="d-flex align-center">
|
|
5
|
+
Copy from the old Equipment list
|
|
6
|
+
<v-spacer />
|
|
7
|
+
<v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="show = false" />
|
|
8
|
+
</v-card-title>
|
|
9
|
+
<v-card-text class="screen-modal__body">
|
|
10
|
+
<p class="text-body-2 mb-4">
|
|
11
|
+
Bring the items already kept under Equipment Management into this store, with their current quantities.
|
|
12
|
+
We check first; nothing is added until you confirm. Items already in the store are skipped.
|
|
13
|
+
</p>
|
|
14
|
+
<v-progress-linear v-if="loading" indeterminate color="primary" />
|
|
15
|
+
<p v-else-if="!groups.length" class="text-body-2 text-medium-emphasis">There is no old Equipment list at this store's properties.</p>
|
|
16
|
+
<v-radio-group v-else v-model="serviceType" hide-details class="mb-2" @update:model-value="result = null">
|
|
17
|
+
<v-radio v-for="g in groups" :key="g.serviceType" :value="g.serviceType" :label="`${label(g.serviceType)} (${g.count} items)`" />
|
|
18
|
+
</v-radio-group>
|
|
19
|
+
|
|
20
|
+
<template v-if="result">
|
|
21
|
+
<v-alert :type="result.errors ? 'warning' : 'success'" variant="tonal" class="mb-3">
|
|
22
|
+
<template v-if="result.committed">{{ result.ready }} item(s) added.</template>
|
|
23
|
+
<template v-else>{{ result.ready }} item(s) ready to add.</template>
|
|
24
|
+
<span v-if="result.skipped"> {{ result.skipped }} skipped.</span>
|
|
25
|
+
<span v-if="result.errors"> {{ result.errors }} could not be read.</span>
|
|
26
|
+
</v-alert>
|
|
27
|
+
<v-table density="compact" height="260" fixed-header>
|
|
28
|
+
<thead>
|
|
29
|
+
<tr>
|
|
30
|
+
<th>Item</th>
|
|
31
|
+
<th>Result</th>
|
|
32
|
+
</tr>
|
|
33
|
+
</thead>
|
|
34
|
+
<tbody>
|
|
35
|
+
<tr v-for="r in result.rows" :key="r.row">
|
|
36
|
+
<td>{{ r.name || "—" }}</td>
|
|
37
|
+
<td :class="r.status === 'error' ? 'text-error' : r.status === 'skipped' ? 'text-medium-emphasis' : 'text-success'">{{ r.message }}</td>
|
|
38
|
+
</tr>
|
|
39
|
+
</tbody>
|
|
40
|
+
</v-table>
|
|
41
|
+
</template>
|
|
42
|
+
</v-card-text>
|
|
43
|
+
<div class="screen-modal__footer">
|
|
44
|
+
<v-btn class="screen-btn-ghost" variant="outlined" :disabled="busy" @click="show = false">{{ result?.committed ? "Close" : "Cancel" }}</v-btn>
|
|
45
|
+
<v-btn v-if="!result" class="screen-btn-primary" variant="flat" :disabled="!serviceType" :loading="busy" @click="run(false)">Check</v-btn>
|
|
46
|
+
<v-btn v-else-if="!result.committed" class="screen-btn-primary" variant="flat" :disabled="!result.ready" :loading="busy" @click="run(true)">
|
|
47
|
+
Add {{ result.ready }} item(s)
|
|
48
|
+
</v-btn>
|
|
49
|
+
</div>
|
|
50
|
+
</v-card>
|
|
51
|
+
</v-dialog>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import useInventory from "../composables/useInventory";
|
|
56
|
+
|
|
57
|
+
const show = defineModel<boolean>({ default: false });
|
|
58
|
+
const props = defineProps({ store: { type: Object as PropType<TInventoryStore>, required: true } });
|
|
59
|
+
const emit = defineEmits(["done"]);
|
|
60
|
+
|
|
61
|
+
const { getLegacyEquipment, importLegacyEquipment } = useInventory();
|
|
62
|
+
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
63
|
+
|
|
64
|
+
const SERVICE_LABELS: Record<string, string> = {
|
|
65
|
+
cleaning_services: "Cleaning",
|
|
66
|
+
mechanical_electrical_services: "M&E",
|
|
67
|
+
pest_control_services: "Pest Control",
|
|
68
|
+
pool_maintenance_services: "Pool Maintenance",
|
|
69
|
+
landscaping_services: "Landscaping",
|
|
70
|
+
};
|
|
71
|
+
const label = (serviceType: string) => SERVICE_LABELS[serviceType] ?? serviceType;
|
|
72
|
+
|
|
73
|
+
const groups = ref<{ serviceType: string; count: number }[]>([]);
|
|
74
|
+
const serviceType = ref("");
|
|
75
|
+
const loading = ref(false);
|
|
76
|
+
const busy = ref(false);
|
|
77
|
+
const result = ref<Awaited<ReturnType<typeof importLegacyEquipment>> | null>(null);
|
|
78
|
+
|
|
79
|
+
async function run(commit: boolean) {
|
|
80
|
+
busy.value = true;
|
|
81
|
+
try {
|
|
82
|
+
result.value = await importLegacyEquipment(props.store._id, serviceType.value, commit);
|
|
83
|
+
if (commit) {
|
|
84
|
+
notify(`${result.value.ready} item(s) added.`);
|
|
85
|
+
emit("done");
|
|
86
|
+
}
|
|
87
|
+
} catch (error: any) {
|
|
88
|
+
notify(error?.data?.message || "Could not copy the list.", "error");
|
|
89
|
+
} finally {
|
|
90
|
+
busy.value = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
watch(show, async (open) => {
|
|
95
|
+
if (!open) return;
|
|
96
|
+
result.value = null;
|
|
97
|
+
serviceType.value = "";
|
|
98
|
+
loading.value = true;
|
|
99
|
+
try {
|
|
100
|
+
groups.value = await getLegacyEquipment(props.store._id);
|
|
101
|
+
if (groups.value.length === 1) serviceType.value = groups.value[0].serviceType;
|
|
102
|
+
} catch {
|
|
103
|
+
groups.value = [];
|
|
104
|
+
} finally {
|
|
105
|
+
loading.value = false;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
</script>
|
|
@@ -5,8 +5,20 @@
|
|
|
5
5
|
<v-btn value="movement" class="text-none">Stock Movement</v-btn>
|
|
6
6
|
<v-btn value="usage" class="text-none">Usage</v-btn>
|
|
7
7
|
<v-btn value="technicians" class="text-none">Technicians</v-btn>
|
|
8
|
+
<v-btn value="purchases" class="text-none">Purchases</v-btn>
|
|
8
9
|
</v-btn-toggle>
|
|
9
|
-
<v-
|
|
10
|
+
<v-select
|
|
11
|
+
v-if="report === 'purchases'"
|
|
12
|
+
v-model="span"
|
|
13
|
+
:items="[
|
|
14
|
+
{ value: 'month', title: 'One month' },
|
|
15
|
+
{ value: 'year', title: 'Last 12 months' },
|
|
16
|
+
]"
|
|
17
|
+
density="compact"
|
|
18
|
+
hide-details
|
|
19
|
+
style="max-width: 180px"
|
|
20
|
+
/>
|
|
21
|
+
<v-text-field v-model="month" type="month" :label="report === 'purchases' && span === 'year' ? 'Up to month' : 'Month'" density="compact" hide-details style="max-width: 180px" />
|
|
10
22
|
<v-select
|
|
11
23
|
v-if="report === 'usage' && sites.length > 1"
|
|
12
24
|
v-model="site"
|
|
@@ -29,6 +41,7 @@
|
|
|
29
41
|
hide-details
|
|
30
42
|
style="max-width: 260px"
|
|
31
43
|
/>
|
|
44
|
+
<v-checkbox v-if="report === 'usage'" v-model="uncheckedOnly" label="Not checked yet" density="compact" hide-details class="flex-grow-0" />
|
|
32
45
|
<v-spacer />
|
|
33
46
|
<v-btn class="text-none screen-btn-ghost" variant="outlined" prepend-icon="mdi-file-excel-outline" :loading="exporting" @click="exportExcel">
|
|
34
47
|
Export Excel
|
|
@@ -36,14 +49,57 @@
|
|
|
36
49
|
</div>
|
|
37
50
|
|
|
38
51
|
<p class="text-caption text-medium-emphasis mb-2">{{ help[report] }}</p>
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
|
|
53
|
+
<div v-if="report === 'usage' && rows.length" class="d-flex flex-wrap align-center ga-3 mb-2">
|
|
54
|
+
<div class="text-body-2 font-weight-medium">
|
|
55
|
+
{{ rows.length }} record(s) · {{ totals.qty }} item(s) used · Total cost {{ money(totals.cost) }}
|
|
56
|
+
</div>
|
|
57
|
+
<v-spacer />
|
|
58
|
+
<template v-if="canCheck">
|
|
59
|
+
<span class="text-caption">{{ selected.length }} selected</span>
|
|
60
|
+
<v-btn class="text-none screen-btn-primary" variant="flat" size="small" :disabled="!selected.length" :loading="checking === 'on'" @click="setChecked(true)">
|
|
61
|
+
Mark checked
|
|
62
|
+
</v-btn>
|
|
63
|
+
<v-btn class="text-none screen-btn-ghost" variant="outlined" size="small" :disabled="!selected.length" :loading="checking === 'off'" @click="setChecked(false)">
|
|
64
|
+
Clear check
|
|
65
|
+
</v-btn>
|
|
66
|
+
</template>
|
|
41
67
|
</div>
|
|
42
68
|
|
|
69
|
+
<template v-if="report === 'purchases' && rows.length">
|
|
70
|
+
<div class="text-body-2 font-weight-medium mb-2">Total purchases {{ money(totals.cost) }}</div>
|
|
71
|
+
<v-row dense class="mb-2">
|
|
72
|
+
<v-col cols="12" md="6">
|
|
73
|
+
<AppCard class="pa-3">
|
|
74
|
+
<div class="text-subtitle-2 mb-2">By month</div>
|
|
75
|
+
<div v-for="m in purchases.byMonth" :key="m.month" class="d-flex align-center ga-2 mb-1">
|
|
76
|
+
<span class="text-body-2" style="width: 72px">{{ m.month }}</span>
|
|
77
|
+
<div class="flex-grow-1 bg-grey-lighten-3 rounded" style="height: 10px">
|
|
78
|
+
<div class="bg-primary rounded" :style="{ height: '10px', width: `${barWidth(m.totalCost)}%` }" />
|
|
79
|
+
</div>
|
|
80
|
+
<span class="text-body-2 text-right" style="width: 96px">{{ money(m.totalCost) }}</span>
|
|
81
|
+
</div>
|
|
82
|
+
</AppCard>
|
|
83
|
+
</v-col>
|
|
84
|
+
<v-col cols="12" md="6">
|
|
85
|
+
<AppCard class="pa-3">
|
|
86
|
+
<div class="text-subtitle-2 mb-2">By supplier</div>
|
|
87
|
+
<div v-for="s in purchases.bySupplier" :key="s.supplier" class="d-flex justify-space-between text-body-2 mb-1">
|
|
88
|
+
<span>{{ s.supplier }} <span class="text-medium-emphasis">({{ s.deliveries }} {{ s.deliveries === 1 ? "delivery" : "deliveries" }})</span></span>
|
|
89
|
+
<span>{{ money(s.totalCost) }}</span>
|
|
90
|
+
</div>
|
|
91
|
+
</AppCard>
|
|
92
|
+
</v-col>
|
|
93
|
+
</v-row>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
43
96
|
<v-data-table
|
|
97
|
+
v-model="selected"
|
|
44
98
|
:headers="headers[report]"
|
|
45
99
|
:items="rows"
|
|
46
100
|
:loading="loading"
|
|
101
|
+
:show-select="report === 'usage' && canCheck"
|
|
102
|
+
item-value="_id"
|
|
47
103
|
density="compact"
|
|
48
104
|
:items-per-page="50"
|
|
49
105
|
class="border rounded"
|
|
@@ -55,10 +111,13 @@
|
|
|
55
111
|
<template #item.totalCost="{ value }">{{ money(value) }}</template>
|
|
56
112
|
<template #item.receivedCost="{ value }">{{ money(value) }}</template>
|
|
57
113
|
<template #item.usedCost="{ value }">{{ money(value) }}</template>
|
|
114
|
+
<template #item.checkedByName="{ item }">
|
|
115
|
+
<v-chip v-if="item.checkedByName" size="x-small" color="success" variant="tonal">{{ item.checkedByName }}</v-chip>
|
|
116
|
+
<span v-else class="text-medium-emphasis">—</span>
|
|
117
|
+
</template>
|
|
58
118
|
<template #item.closing="{ item }">
|
|
59
119
|
<span :class="item.reorderLevel && item.closing <= item.reorderLevel ? 'text-error font-weight-bold' : 'font-weight-medium'">{{ item.closing }}</span>
|
|
60
120
|
</template>
|
|
61
|
-
|
|
62
121
|
</v-data-table>
|
|
63
122
|
</div>
|
|
64
123
|
</template>
|
|
@@ -78,20 +137,31 @@ const notify = inject<(text: string, color?: string) => void>("inventoryNotify",
|
|
|
78
137
|
|
|
79
138
|
const now = new Date();
|
|
80
139
|
const month = ref(`${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`);
|
|
81
|
-
const report = ref<"movement" | "usage" | "technicians">("movement");
|
|
140
|
+
const report = ref<"movement" | "usage" | "technicians" | "purchases">("movement");
|
|
141
|
+
const span = ref<"month" | "year">("year");
|
|
82
142
|
const site = ref("");
|
|
83
143
|
const locationType = ref("");
|
|
144
|
+
const uncheckedOnly = ref(false);
|
|
84
145
|
const rows = ref<any[]>([]);
|
|
146
|
+
const selected = ref<string[]>([]);
|
|
147
|
+
const purchases = reactive({ byMonth: [] as { month: string; deliveries: number; totalCost: number }[], bySupplier: [] as { supplier: string; deliveries: number; totalCost: number }[] });
|
|
85
148
|
const totals = reactive({ qty: 0, cost: 0 });
|
|
86
149
|
const loading = ref(false);
|
|
87
150
|
const exporting = ref(false);
|
|
151
|
+
const checking = ref<"" | "on" | "off">("");
|
|
88
152
|
|
|
153
|
+
const canCheck = computed(() => props.store.access.canApprove || props.store.access.canManage);
|
|
89
154
|
const money = (v: number) => (v === undefined || v === null ? "—" : `$${Number(v).toFixed(2)}`);
|
|
155
|
+
const barWidth = (v: number) => {
|
|
156
|
+
const max = Math.max(...purchases.byMonth.map((m) => m.totalCost), 0);
|
|
157
|
+
return max ? Math.round((v / max) * 100) : 0;
|
|
158
|
+
};
|
|
90
159
|
|
|
91
160
|
const help: Record<string, string> = {
|
|
92
161
|
movement: "For each item: stock at the start of the month, what came in, what was issued and returned, count differences, and stock at the end.",
|
|
93
|
-
usage: "Every recorded usage: where it was used, for which tenant, by whom, and the cost. Use this for tenant billing.",
|
|
162
|
+
usage: "Every recorded usage: where it was used, for which tenant, by whom, and the cost. Use this for tenant billing. Tick records and mark them checked once verified.",
|
|
94
163
|
technicians: "For each person: stock they held at the start, took, used, returned, and hold at the end of the month.",
|
|
164
|
+
purchases: "Every delivery received, with totals by month and by supplier, to see how purchasing changes over time.",
|
|
95
165
|
};
|
|
96
166
|
|
|
97
167
|
const headers: Record<string, any[]> = {
|
|
@@ -115,13 +185,12 @@ const headers: Record<string, any[]> = {
|
|
|
115
185
|
{ title: "Unit / Area", key: "location" },
|
|
116
186
|
{ title: "Tenant", key: "tenantName" },
|
|
117
187
|
{ title: "Item", key: "itemName" },
|
|
118
|
-
{ title: "Unit", key: "unit" },
|
|
119
188
|
{ title: "Qty", key: "qty" },
|
|
120
189
|
{ title: "Unit price", key: "unitCost" },
|
|
121
190
|
{ title: "Total", key: "totalCost" },
|
|
122
191
|
{ title: "Technician", key: "technician" },
|
|
123
192
|
{ title: "Reference", key: "reference" },
|
|
124
|
-
{ title: "
|
|
193
|
+
{ title: "Checked by", key: "checkedByName" },
|
|
125
194
|
],
|
|
126
195
|
technicians: [
|
|
127
196
|
{ title: "Name", key: "technician" },
|
|
@@ -134,28 +203,43 @@ const headers: Record<string, any[]> = {
|
|
|
134
203
|
{ title: "Holding at end", key: "closing" },
|
|
135
204
|
{ title: "In hand now", key: "inHandNow" },
|
|
136
205
|
],
|
|
206
|
+
purchases: [
|
|
207
|
+
{ title: "Date", key: "date" },
|
|
208
|
+
{ title: "Supplier", key: "supplier" },
|
|
209
|
+
{ title: "PO No.", key: "reference" },
|
|
210
|
+
{ title: "Item", key: "itemName" },
|
|
211
|
+
{ title: "Unit", key: "unit" },
|
|
212
|
+
{ title: "Qty", key: "qty" },
|
|
213
|
+
{ title: "Unit price", key: "unitCost" },
|
|
214
|
+
{ title: "Total", key: "totalCost" },
|
|
215
|
+
{ title: "Received by", key: "receivedBy" },
|
|
216
|
+
],
|
|
137
217
|
};
|
|
138
218
|
|
|
139
|
-
function period(): TInventoryPeriod {
|
|
219
|
+
function period(): TInventoryPeriod & { unchecked?: boolean } {
|
|
140
220
|
const [y, m] = month.value.split("-").map(Number);
|
|
141
|
-
const from = new Date(y, m - 1, 1, 0, 0, 0, 0);
|
|
142
221
|
const to = new Date(y, m, 0, 23, 59, 59, 999);
|
|
222
|
+
const from = report.value === "purchases" && span.value === "year" ? new Date(y, m - 12, 1, 0, 0, 0, 0) : new Date(y, m - 1, 1, 0, 0, 0, 0);
|
|
143
223
|
return {
|
|
144
224
|
from: from.toISOString(),
|
|
145
225
|
to: to.toISOString(),
|
|
146
226
|
...(report.value === "usage" && site.value ? { site: site.value } : {}),
|
|
147
227
|
...(report.value === "usage" && locationType.value ? { locationType: locationType.value } : {}),
|
|
228
|
+
...(report.value === "usage" && uncheckedOnly.value ? { unchecked: true } : {}),
|
|
148
229
|
};
|
|
149
230
|
}
|
|
150
231
|
|
|
151
232
|
async function load() {
|
|
152
233
|
if (!month.value) return;
|
|
153
234
|
loading.value = true;
|
|
235
|
+
selected.value = [];
|
|
154
236
|
try {
|
|
155
|
-
const res = await api.getReport(props.store._id, report.value, period());
|
|
237
|
+
const res: any = await api.getReport(props.store._id, report.value, period());
|
|
156
238
|
rows.value = res.rows;
|
|
157
239
|
totals.qty = res.totalQty ?? 0;
|
|
158
240
|
totals.cost = res.totalCost ?? 0;
|
|
241
|
+
purchases.byMonth = res.byMonth ?? [];
|
|
242
|
+
purchases.bySupplier = res.bySupplier ?? [];
|
|
159
243
|
} catch (error: any) {
|
|
160
244
|
rows.value = [];
|
|
161
245
|
notify(error?.data?.message || "Could not load the report.", "error");
|
|
@@ -164,6 +248,20 @@ async function load() {
|
|
|
164
248
|
}
|
|
165
249
|
}
|
|
166
250
|
|
|
251
|
+
async function setChecked(checked: boolean) {
|
|
252
|
+
if (!selected.value.length) return;
|
|
253
|
+
checking.value = checked ? "on" : "off";
|
|
254
|
+
try {
|
|
255
|
+
const res = await api.checkUsage(props.store._id, selected.value, checked);
|
|
256
|
+
notify(checked ? `${res.updated} record(s) marked checked.` : `Check cleared on ${res.updated} record(s).`);
|
|
257
|
+
await load();
|
|
258
|
+
} catch (error: any) {
|
|
259
|
+
notify(error?.data?.message || "Could not update the records.", "error");
|
|
260
|
+
} finally {
|
|
261
|
+
checking.value = "";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
167
265
|
async function exportExcel() {
|
|
168
266
|
exporting.value = true;
|
|
169
267
|
try {
|
|
@@ -176,6 +274,6 @@ async function exportExcel() {
|
|
|
176
274
|
}
|
|
177
275
|
}
|
|
178
276
|
|
|
179
|
-
watch([report, month, site, locationType, () => props.store._id], load);
|
|
277
|
+
watch([report, month, span, site, locationType, uncheckedOnly, () => props.store._id], load);
|
|
180
278
|
onMounted(load);
|
|
181
279
|
</script>
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
<v-list density="compact">
|
|
27
27
|
<v-list-item prepend-icon="mdi-plus" title="Add one item" @click="editItem(null)" />
|
|
28
28
|
<v-list-item prepend-icon="mdi-file-excel-outline" title="Import from Excel" @click="showImport = true" />
|
|
29
|
+
<v-list-item prepend-icon="mdi-content-copy" title="Copy from old Equipment list" @click="showLegacy = true" />
|
|
29
30
|
</v-list>
|
|
30
31
|
</v-menu>
|
|
31
32
|
<v-spacer />
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
<InventoryLinesDialog v-model="lines.show" :mode="lines.mode" :store="store" :site-id="siteId" :sites="sites" @done="done" />
|
|
86
87
|
<InventoryItemDialog v-model="itemDialog.show" :store="store" :item="itemDialog.item" @done="done" />
|
|
87
88
|
<InventoryImportDialog v-model="showImport" :store="store" @done="done" />
|
|
89
|
+
<InventoryLegacyImportDialog v-model="showLegacy" :store="store" @done="done" />
|
|
88
90
|
<InventoryItemDetail v-model="detail.show" :store="store" :item="detail.item" @edit="editItem" @done="done" />
|
|
89
91
|
</div>
|
|
90
92
|
</template>
|
|
@@ -163,6 +165,7 @@ function openItem(item: TInventoryItem) {
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
const showImport = ref(false);
|
|
168
|
+
const showLegacy = ref(false);
|
|
166
169
|
|
|
167
170
|
function done() {
|
|
168
171
|
load();
|
|
@@ -54,10 +54,18 @@ export default function useInventory() {
|
|
|
54
54
|
getCommonAreas: (store: string, site: string) => api<string[]>(`/stores/${store}/common-areas`, { query: { site } }),
|
|
55
55
|
getPeople: (store: string, search = "") => api<{ _id: string; name: string; orgName: string }[]>(`/stores/${store}/people`, { query: { search } }),
|
|
56
56
|
|
|
57
|
-
getReport: (store: string, report: "movement" | "usage" | "technicians", query: TInventoryPeriod) =>
|
|
57
|
+
getReport: (store: string, report: "movement" | "usage" | "technicians" | "purchases", query: TInventoryPeriod & { unchecked?: boolean }) =>
|
|
58
58
|
api<{ rows: any[]; totalQty?: number; totalCost?: number }>(`/stores/${store}/reports/${report}`, { query }),
|
|
59
59
|
exportReport: (store: string, report: string, query: TInventoryPeriod) =>
|
|
60
60
|
api<Blob>(`/stores/${store}/reports/${report}/export`, { query, responseType: "blob" }),
|
|
61
|
+
checkUsage: (store: string, ids: string[], checked: boolean) =>
|
|
62
|
+
api<{ updated: number }>(`/stores/${store}/usage/check`, { method: "POST", body: { ids, checked } }),
|
|
63
|
+
getLegacyEquipment: (store: string) => api<{ serviceType: string; count: number }[]>(`/stores/${store}/legacy-equipment`),
|
|
64
|
+
importLegacyEquipment: (store: string, serviceType: string, commit: boolean) =>
|
|
65
|
+
api<{ committed: boolean; ready: number; skipped: number; errors: number; rows: { row: number; name: string; status: string; message: string }[] }>(
|
|
66
|
+
`/stores/${store}/legacy-equipment/import`,
|
|
67
|
+
{ method: "POST", body: { serviceType, commit } },
|
|
68
|
+
),
|
|
61
69
|
importTemplate: () => api<Blob>("/import-template", { responseType: "blob" }),
|
|
62
70
|
importItems: (store: string, file: File, commit: boolean) => {
|
|
63
71
|
const body = new FormData();
|
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.17.1-staging.
|
|
5
|
+
"version": "4.17.1-staging.333",
|
|
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.",
|