@7365admin1/layer-common 4.18.0 → 4.20.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a12e294: Inventory: packing on items (form, stock list, item detail, movement report), "Fault reported by" on Record Usage and in the usage report, and each technician's stock shows left and used this month (My Stock, Technicians). Items used up this month stay listed at 0 left without the Record usage button.
8
+
9
+ ## 4.19.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4575a0d: Inventory: Purchases report (by month and supplier, up to 12 months), supervisor "Mark checked" on usage records with a not-checked-yet filter, "Copy from old Equipment list", and the dashboard supply tile shown to inventory roles and named "Low Stock" when it lists items at or below their alert level.
14
+
3
15
  ## 4.18.0
4
16
 
5
17
  ### Minor Changes
@@ -1187,11 +1199,11 @@
1187
1199
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1188
1200
  own rule from two endpoints the console already calls, unprojected:
1189
1201
 
1190
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1191
- GET /api/roles/id/:role that membership's role document
1202
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1203
+ GET /api/roles/id/:role that membership's role document
1192
1204
 
1193
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1194
- staff = member.type === "admin" && role.type === "admin"
1205
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1206
+ staff = member.type === "admin" && role.type === "admin"
1195
1207
 
1196
1208
  `role.default` is the marker because it is the only property of a platform
1197
1209
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -17,7 +17,7 @@
17
17
  :key="card.key"
18
18
  class="print-kpi-card"
19
19
  >
20
- <span class="print-kpi-title">{{ card.title }}</span>
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.title"
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
- supplyAlert: ["supply-mgmt:see-all-supplies"],
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)" },
@@ -12,7 +12,7 @@
12
12
  <div class="flex-grow-1">
13
13
  <div class="text-h5 mb-1" :class="item.lowStock ? 'text-error' : ''">{{ item.onHand }} {{ item.unit }} in store</div>
14
14
  <div class="text-body-2 text-medium-emphasis">
15
- {{ [item.code && `Code ${item.code}`, item.category, item.reorderLevel ? `Alert at ${item.reorderLevel}` : "", item.unitCost !== undefined ? `$${Number(item.unitCost).toFixed(2)} each` : ""].filter(Boolean).join(" · ") }}
15
+ {{ [item.code && `Code ${item.code}`, item.category, item.packing, item.reorderLevel ? `Alert at ${item.reorderLevel}` : "", item.unitCost !== undefined ? `$${Number(item.unitCost).toFixed(2)} each` : ""].filter(Boolean).join(" · ") }}
16
16
  </div>
17
17
  <div v-if="item.description" class="text-body-2 mt-2">{{ item.description }}</div>
18
18
  </div>
@@ -15,6 +15,10 @@
15
15
  <InputLabel title="Unit" required class="mb-1" />
16
16
  <v-combobox v-model="f.unit" :items="units" :rules="[requiredRule]" density="comfortable" />
17
17
  </v-col>
18
+ <v-col cols="12" sm="4">
19
+ <InputLabel title="Packing" class="mb-1" />
20
+ <v-text-field v-model="f.packing" density="comfortable" placeholder="e.g. 25 pcs / box" maxlength="60" />
21
+ </v-col>
18
22
  <v-col cols="12" sm="4">
19
23
  <InputLabel title="Item code" class="mb-1" />
20
24
  <v-text-field v-model="f.code" density="comfortable" />
@@ -79,7 +83,7 @@ const moneyRule = (v: any) => v === "" || v === null || Number(v) >= 0 || "Enter
79
83
 
80
84
  const form = ref();
81
85
  const saving = ref(false);
82
- const blank = () => ({ name: "", unit: "pcs", code: "", category: "", reorderLevel: 0, unitCost: 0, openingQty: 0, description: "" });
86
+ const blank = () => ({ name: "", unit: "pcs", packing: "", code: "", category: "", reorderLevel: 0, unitCost: 0, openingQty: 0, description: "" });
83
87
  const f = reactive(blank());
84
88
  const photo = ref<string[]>([]);
85
89
  const inUse = ref(true);
@@ -87,7 +91,7 @@ const inUse = ref(true);
87
91
  watch(show, (open) => {
88
92
  if (!open) return;
89
93
  const i = props.item;
90
- Object.assign(f, blank(), i ? { name: i.name, unit: i.unit, code: i.code, category: i.category, reorderLevel: i.reorderLevel, unitCost: i.unitCost ?? 0, description: i.description } : {});
94
+ Object.assign(f, blank(), i ? { name: i.name, unit: i.unit, packing: i.packing ?? "", code: i.code, category: i.category, reorderLevel: i.reorderLevel, unitCost: i.unitCost ?? 0, description: i.description } : {});
91
95
  photo.value = i?.photo ? [i.photo] : [];
92
96
  inUse.value = i ? i.status === "active" : true;
93
97
  });
@@ -99,6 +103,7 @@ async function save() {
99
103
  const body = {
100
104
  name: f.name,
101
105
  unit: f.unit,
106
+ packing: f.packing,
102
107
  code: f.code,
103
108
  category: f.category,
104
109
  reorderLevel: Number(f.reorderLevel || 0),
@@ -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>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <div class="d-flex flex-wrap ga-2 align-center mb-3">
4
- <div class="text-body-2 text-medium-emphasis">Stock you have taken from the store and not used or returned yet.</div>
4
+ <div class="text-body-2 text-medium-emphasis">Stock you have taken from the store: how many are left, and how many you used this month.</div>
5
5
  <v-spacer />
6
6
  <v-btn class="text-none screen-btn-primary" variant="flat" prepend-icon="mdi-cart-arrow-down" @click="showRequest = true">Request Stock</v-btn>
7
7
  </div>
@@ -21,9 +21,9 @@
21
21
  </v-avatar>
22
22
  <div class="flex-grow-1">
23
23
  <div class="font-weight-medium">{{ h.itemName }}</div>
24
- <div class="text-body-2">{{ h.qty }} {{ h.unit }} in hand</div>
24
+ <div class="text-body-2">{{ h.qty }} {{ h.unit }} left · {{ h.usedThisMonth ?? 0 }} used this month</div>
25
25
  </div>
26
- <v-btn class="text-none screen-btn-primary" variant="flat" size="small" @click="use(h)">Record usage</v-btn>
26
+ <v-btn v-if="h.qty > 0" class="text-none screen-btn-primary" variant="flat" size="small" @click="use(h)">Record usage</v-btn>
27
27
  </AppCard>
28
28
  </v-col>
29
29
  </v-row>
@@ -90,7 +90,7 @@ const usage = reactive({ show: false, holding: null as TInventoryHolding | null
90
90
  async function load() {
91
91
  loading.value = true;
92
92
  try {
93
- const [h, t] = await Promise.all([api.getHoldings(props.store._id, "me"), api.getTransactions(props.store._id, { page: 1, limit: 15, holder: currentUser.value?._id })]);
93
+ const [h, t] = await Promise.all([api.getHoldings(props.store._id, "me", true), api.getTransactions(props.store._id, { page: 1, limit: 15, holder: currentUser.value?._id })]);
94
94
  holdings.value = h;
95
95
  activity.value = t.items.filter((x) => x.holderChange !== undefined);
96
96
  } catch {
@@ -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-text-field v-model="month" type="month" label="Month" density="compact" hide-details style="max-width: 180px" />
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
- <div v-if="report === 'usage' && rows.length" class="text-body-2 font-weight-medium mb-2">
40
- {{ rows.length }} record(s) · {{ totals.qty }} item(s) used · Total cost {{ money(totals.cost) }}
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,26 +137,38 @@ 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[]> = {
98
168
  movement: [
99
169
  { title: "Item", key: "name" },
100
170
  { title: "Unit", key: "unit" },
171
+ { title: "Packing", key: "packing" },
101
172
  { title: "Start", key: "opening" },
102
173
  { title: "Received", key: "received" },
103
174
  { title: "Purchase cost", key: "receivedCost" },
@@ -115,13 +186,13 @@ const headers: Record<string, any[]> = {
115
186
  { title: "Unit / Area", key: "location" },
116
187
  { title: "Tenant", key: "tenantName" },
117
188
  { title: "Item", key: "itemName" },
118
- { title: "Unit", key: "unit" },
119
189
  { title: "Qty", key: "qty" },
120
190
  { title: "Unit price", key: "unitCost" },
121
191
  { title: "Total", key: "totalCost" },
122
192
  { title: "Technician", key: "technician" },
123
193
  { title: "Reference", key: "reference" },
124
- { title: "Remarks", key: "remarks" },
194
+ { title: "Reported by", key: "reportedBy" },
195
+ { title: "Checked by", key: "checkedByName" },
125
196
  ],
126
197
  technicians: [
127
198
  { title: "Name", key: "technician" },
@@ -134,28 +205,43 @@ const headers: Record<string, any[]> = {
134
205
  { title: "Holding at end", key: "closing" },
135
206
  { title: "In hand now", key: "inHandNow" },
136
207
  ],
208
+ purchases: [
209
+ { title: "Date", key: "date" },
210
+ { title: "Supplier", key: "supplier" },
211
+ { title: "PO No.", key: "reference" },
212
+ { title: "Item", key: "itemName" },
213
+ { title: "Unit", key: "unit" },
214
+ { title: "Qty", key: "qty" },
215
+ { title: "Unit price", key: "unitCost" },
216
+ { title: "Total", key: "totalCost" },
217
+ { title: "Received by", key: "receivedBy" },
218
+ ],
137
219
  };
138
220
 
139
- function period(): TInventoryPeriod {
221
+ function period(): TInventoryPeriod & { unchecked?: boolean } {
140
222
  const [y, m] = month.value.split("-").map(Number);
141
- const from = new Date(y, m - 1, 1, 0, 0, 0, 0);
142
223
  const to = new Date(y, m, 0, 23, 59, 59, 999);
224
+ 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
225
  return {
144
226
  from: from.toISOString(),
145
227
  to: to.toISOString(),
146
228
  ...(report.value === "usage" && site.value ? { site: site.value } : {}),
147
229
  ...(report.value === "usage" && locationType.value ? { locationType: locationType.value } : {}),
230
+ ...(report.value === "usage" && uncheckedOnly.value ? { unchecked: true } : {}),
148
231
  };
149
232
  }
150
233
 
151
234
  async function load() {
152
235
  if (!month.value) return;
153
236
  loading.value = true;
237
+ selected.value = [];
154
238
  try {
155
- const res = await api.getReport(props.store._id, report.value, period());
239
+ const res: any = await api.getReport(props.store._id, report.value, period());
156
240
  rows.value = res.rows;
157
241
  totals.qty = res.totalQty ?? 0;
158
242
  totals.cost = res.totalCost ?? 0;
243
+ purchases.byMonth = res.byMonth ?? [];
244
+ purchases.bySupplier = res.bySupplier ?? [];
159
245
  } catch (error: any) {
160
246
  rows.value = [];
161
247
  notify(error?.data?.message || "Could not load the report.", "error");
@@ -164,6 +250,20 @@ async function load() {
164
250
  }
165
251
  }
166
252
 
253
+ async function setChecked(checked: boolean) {
254
+ if (!selected.value.length) return;
255
+ checking.value = checked ? "on" : "off";
256
+ try {
257
+ const res = await api.checkUsage(props.store._id, selected.value, checked);
258
+ notify(checked ? `${res.updated} record(s) marked checked.` : `Check cleared on ${res.updated} record(s).`);
259
+ await load();
260
+ } catch (error: any) {
261
+ notify(error?.data?.message || "Could not update the records.", "error");
262
+ } finally {
263
+ checking.value = "";
264
+ }
265
+ }
266
+
167
267
  async function exportExcel() {
168
268
  exporting.value = true;
169
269
  try {
@@ -176,6 +276,6 @@ async function exportExcel() {
176
276
  }
177
277
  }
178
278
 
179
- watch([report, month, site, locationType, () => props.store._id], load);
279
+ watch([report, month, span, site, locationType, uncheckedOnly, () => props.store._id], load);
180
280
  onMounted(load);
181
281
  </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 />
@@ -60,7 +61,7 @@
60
61
  </v-avatar>
61
62
  <div>
62
63
  <div class="font-weight-medium">{{ item.name }}</div>
63
- <div class="text-caption text-medium-emphasis">{{ [item.code, item.category].filter(Boolean).join(" · ") }}</div>
64
+ <div class="text-caption text-medium-emphasis">{{ [item.code, item.category, item.packing].filter(Boolean).join(" · ") }}</div>
64
65
  </div>
65
66
  </div>
66
67
  </template>
@@ -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();
@@ -16,7 +16,7 @@
16
16
  <v-btn class="text-none screen-btn-ghost" variant="outlined" size="small" prepend-icon="mdi-keyboard-return" @click="openReturn(g)">Receive return</v-btn>
17
17
  </div>
18
18
  <div class="d-flex flex-wrap ga-2">
19
- <v-chip v-for="h in g.items" :key="h._id" variant="tonal">{{ h.itemName }}: {{ h.qty }} {{ h.unit }}</v-chip>
19
+ <v-chip v-for="h in g.items" :key="h._id" variant="tonal">{{ h.itemName }}: {{ h.qty }} {{ h.unit }} left · {{ h.usedThisMonth ?? 0 }} used this month</v-chip>
20
20
  </div>
21
21
  </AppCard>
22
22
 
@@ -83,6 +83,8 @@
83
83
 
84
84
  <InputLabel title="Date used" class="mb-1 mt-3" />
85
85
  <v-text-field v-model="date" type="date" :max="today" density="comfortable" style="max-width: 200px" />
86
+ <InputLabel title="Fault reported by (optional)" class="mb-1" />
87
+ <v-text-field v-model="reportedBy" density="comfortable" placeholder="e.g. tenant, security guard" maxlength="120" />
86
88
  <InputLabel title="Remarks (optional)" class="mb-1" />
87
89
  <v-textarea v-model="remarks" rows="2" auto-grow density="comfortable" />
88
90
  </v-form>
@@ -122,6 +124,7 @@ const unit = ref("");
122
124
  const area = ref("");
123
125
  const reference = ref("");
124
126
  const remarks = ref("");
127
+ const reportedBy = ref("");
125
128
  const date = ref(today);
126
129
  const photosBefore = ref<string[]>([]);
127
130
  const photosAfter = ref<string[]>([]);
@@ -169,6 +172,7 @@ async function save() {
169
172
  photosBefore: photosBefore.value,
170
173
  photosAfter: photosAfter.value,
171
174
  remarks: remarks.value,
175
+ reportedBy: reportedBy.value,
172
176
  });
173
177
  notify("Usage saved.");
174
178
  show.value = false;
@@ -195,6 +199,7 @@ watch(show, (open) => {
195
199
  area.value = "";
196
200
  reference.value = "";
197
201
  remarks.value = "";
202
+ reportedBy.value = "";
198
203
  date.value = today;
199
204
  site.value = props.store.sites.includes(props.siteId) ? props.siteId : props.store.sites[0];
200
205
  searchUnits("");
@@ -45,7 +45,8 @@ export default function useInventory() {
45
45
  rejectRequest: (id: string, remarks: string) => api(`/requests/${id}/reject`, { method: "POST", body: { remarks } }),
46
46
  cancelRequest: (id: string) => api(`/requests/${id}/cancel`, { method: "POST" }),
47
47
 
48
- getHoldings: (store: string, holder: string = "me") => api<TInventoryHolding[]>(`/stores/${store}/holdings`, { query: { holder } }),
48
+ getHoldings: (store: string, holder: string = "me", includeUsedUp = false) =>
49
+ api<TInventoryHolding[]>(`/stores/${store}/holdings`, { query: { holder, ...(includeUsedUp ? { includeUsedUp: true } : {}) } }),
49
50
  getTransactions: (store: string, query: Record<string, any>) =>
50
51
  api<{ items: TInventoryTransaction[]; total: number; page: number; pages: number }>(`/stores/${store}/transactions`, { query }),
51
52
 
@@ -54,10 +55,18 @@ export default function useInventory() {
54
55
  getCommonAreas: (store: string, site: string) => api<string[]>(`/stores/${store}/common-areas`, { query: { site } }),
55
56
  getPeople: (store: string, search = "") => api<{ _id: string; name: string; orgName: string }[]>(`/stores/${store}/people`, { query: { search } }),
56
57
 
57
- getReport: (store: string, report: "movement" | "usage" | "technicians", query: TInventoryPeriod) =>
58
+ getReport: (store: string, report: "movement" | "usage" | "technicians" | "purchases", query: TInventoryPeriod & { unchecked?: boolean }) =>
58
59
  api<{ rows: any[]; totalQty?: number; totalCost?: number }>(`/stores/${store}/reports/${report}`, { query }),
59
60
  exportReport: (store: string, report: string, query: TInventoryPeriod) =>
60
61
  api<Blob>(`/stores/${store}/reports/${report}/export`, { query, responseType: "blob" }),
62
+ checkUsage: (store: string, ids: string[], checked: boolean) =>
63
+ api<{ updated: number }>(`/stores/${store}/usage/check`, { method: "POST", body: { ids, checked } }),
64
+ getLegacyEquipment: (store: string) => api<{ serviceType: string; count: number }[]>(`/stores/${store}/legacy-equipment`),
65
+ importLegacyEquipment: (store: string, serviceType: string, commit: boolean) =>
66
+ api<{ committed: boolean; ready: number; skipped: number; errors: number; rows: { row: number; name: string; status: string; message: string }[] }>(
67
+ `/stores/${store}/legacy-equipment/import`,
68
+ { method: "POST", body: { serviceType, commit } },
69
+ ),
61
70
  importTemplate: () => api<Blob>("/import-template", { responseType: "blob" }),
62
71
  importItems: (store: string, file: File, commit: boolean) => {
63
72
  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.18.0",
5
+ "version": "4.20.0",
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.",
@@ -24,6 +24,7 @@ declare type TInventoryItem = {
24
24
  code: string;
25
25
  category: string;
26
26
  unit: string;
27
+ packing?: string;
27
28
  description: string;
28
29
  photo: string;
29
30
  reorderLevel: number;
@@ -60,6 +61,9 @@ declare type TInventoryHolding = {
60
61
  holder: string;
61
62
  holderName: string;
62
63
  qty: number;
64
+ packing?: string;
65
+ /** Used by this holder since the start of the month (Singapore time). */
66
+ usedThisMonth?: number;
63
67
  };
64
68
 
65
69
  declare type TInventoryTransaction = {
@@ -82,6 +86,7 @@ declare type TInventoryTransaction = {
82
86
  totalCost: number;
83
87
  photos?: { before: string[]; after: string[]; other: string[] };
84
88
  remarks?: string;
89
+ reportedBy?: string;
85
90
  date: string;
86
91
  createdByName: string;
87
92
  };