@7365admin1/layer-common 4.189.2 → 4.190.1
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 +32 -4
- package/components/AttendanceDetailsDialog.vue +13 -6
- package/components/AttendanceMain.vue +1 -1
- package/components/CleaningScheduleMain.vue +24 -0
- package/components/InventoryCheckoutDetail.vue +288 -0
- package/components/InventoryCheckoutReturnDialog.vue +189 -0
- package/components/InventoryCheckoutsTab.vue +349 -0
- package/components/InventoryHistoryDialog.vue +22 -1
- package/components/InventoryItemDetail.vue +12 -2
- package/components/InventoryItemDialog.vue +37 -0
- package/components/InventoryLinesDialog.vue +166 -20
- package/components/InventoryMain.vue +24 -0
- package/components/InventoryMyStockTab.vue +69 -5
- package/components/InventorySerialPick.vue +85 -0
- package/components/InventorySerialScanner.vue +188 -0
- package/components/InventorySerialsDialog.vue +202 -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/MyAttendanceMain.vue +1 -1
- package/components/SiteSettingsWorkOrder.vue +14 -1
- package/components/WorkOrder/IssuedItems.vue +156 -0
- package/composables/useInventory.ts +22 -2
- package/composables/useWorkOrder.ts +12 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +66 -0
- package/utils/inventory-checkout.ts +114 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { qtyUnit } from "./inventory-ack";
|
|
2
|
+
/**
|
|
3
|
+
* DV-1787: shared wording for checkouts (stock issued for a work order / to come back by a date),
|
|
4
|
+
* used by the Checked out list, My Stock and a work order's Issued items.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** A return date is a calendar day saved as midnight UTC: the same day as a local Date, wherever the browser is. */
|
|
8
|
+
export function returnDayKey(d: string): Date {
|
|
9
|
+
const [y, m, day] = String(d).slice(0, 10).split("-").map(Number);
|
|
10
|
+
return new Date(y, m - 1, day);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type TChip = { text: string; color: string; icon: string; info: string };
|
|
14
|
+
|
|
15
|
+
const ENDED: Record<string, TChip> = {
|
|
16
|
+
returned: { text: "Returned", color: "success", icon: "mdi-check", info: "Back in the store. Nothing more to do." },
|
|
17
|
+
written_off: {
|
|
18
|
+
text: "Written off",
|
|
19
|
+
color: "grey",
|
|
20
|
+
icon: "mdi-close-circle-outline",
|
|
21
|
+
info: "Written off (lost, damaged, spoilt or used up). It is not coming back to the store.",
|
|
22
|
+
},
|
|
23
|
+
used: { text: "Used", color: "grey", icon: "mdi-check", info: "Used up on the job, so it is not coming back to the store." },
|
|
24
|
+
handed_over: {
|
|
25
|
+
text: "Handed over",
|
|
26
|
+
color: "grey",
|
|
27
|
+
icon: "mdi-account-switch-outline",
|
|
28
|
+
info: "Passed to a colleague. They have it now: see their row for its status.",
|
|
29
|
+
},
|
|
30
|
+
closed: { text: "Closed", color: "grey", icon: "mdi-check", info: "Closed: it is no longer out with anyone." },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Out / Due today / Overdue N days, or how it ended - with `info`, what the status means (hover). */
|
|
34
|
+
export function checkoutChip(c: { status: string; overdue?: boolean; daysOverdue?: number; returnDate?: string | null; received?: boolean; ackStatus?: string }): TChip {
|
|
35
|
+
if (c.status !== "out") return ENDED[c.status] ?? ENDED.closed;
|
|
36
|
+
// DV-1787: not received yet - it is not with the person until they tap Received.
|
|
37
|
+
if (c.received === false && c.ackStatus === "not_received") {
|
|
38
|
+
return { text: "Not Received", color: "error", icon: "mdi-alert-circle-outline", info: "The person tapped Not Received: they say they did not get it. The store keeper checks and takes it back; if it turns up, they tap Received." };
|
|
39
|
+
}
|
|
40
|
+
if (c.received === false) {
|
|
41
|
+
return { text: "Pending Receipt", color: "grey", icon: "mdi-timer-sand", info: "Issued, but the person has not tapped Received or Not Received yet. They can ask to return it only after Received." };
|
|
42
|
+
}
|
|
43
|
+
if (c.overdue) {
|
|
44
|
+
const n = c.daysOverdue ?? 0;
|
|
45
|
+
return {
|
|
46
|
+
text: `Overdue ${n} ${n === 1 ? "day" : "days"}`,
|
|
47
|
+
color: "error",
|
|
48
|
+
icon: "mdi-alarm",
|
|
49
|
+
info: "Past its return date and still not returned. The person and the store keepers get a reminder every day until it comes back.",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const today = new Date().toLocaleDateString("en-CA", { timeZone: "Asia/Singapore" });
|
|
53
|
+
if (c.returnDate && String(c.returnDate).slice(0, 10) === today) {
|
|
54
|
+
return { text: "Due today", color: "warning", icon: "mdi-clock-outline", info: "Must be back in the store today. From tomorrow it shows as overdue." };
|
|
55
|
+
}
|
|
56
|
+
return c.returnDate
|
|
57
|
+
? {
|
|
58
|
+
text: "Not returned yet",
|
|
59
|
+
color: "info",
|
|
60
|
+
icon: "mdi-arrow-top-right",
|
|
61
|
+
info: "Still with the person. The return date has not come yet, so it is not overdue.",
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
text: "Out",
|
|
65
|
+
color: "info",
|
|
66
|
+
icon: "mdi-arrow-top-right",
|
|
67
|
+
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.",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** "Return asked": the holder asked to return it; a store keeper accepts it when they have it. */
|
|
72
|
+
export const RETURN_ASKED_INFO = "The person asked to return it. It stays with them until a store keeper accepts the return.";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* DV-1787: how much of a checked-out row can still be asked to return. A row asked for in parts
|
|
76
|
+
* (returnAsked) has the rest left; a row marked by a Return to store from My Stock counts as asked.
|
|
77
|
+
*/
|
|
78
|
+
export function askLeft(c: { status: string; outQty: number; received?: boolean; returnRequest?: string | null; returnAsked?: { qty: number } | null }): number {
|
|
79
|
+
// Not received yet: it is not with them, so nothing to ask to return.
|
|
80
|
+
if (c.status !== "out" || c.received === false) return 0;
|
|
81
|
+
if (c.returnAsked) return Math.max(0, c.outQty - c.returnAsked.qty);
|
|
82
|
+
return c.returnRequest ? 0 : c.outQty;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** DV-1787: what is asked to return on a row, e.g. "2 pcs · S/N AG-0001 + 1 without serial number". */
|
|
86
|
+
export function askedText(c: { unit: string; serials?: { _id: string; serial: string }[]; returnAsked?: { qty: number; serials: string[] } | null }): string {
|
|
87
|
+
const a = c.returnAsked;
|
|
88
|
+
if (!a?.qty) return "";
|
|
89
|
+
const names = (c.serials ?? [])
|
|
90
|
+
.filter((s) => a.serials.includes(String(s._id)))
|
|
91
|
+
.map((s) => s.serial)
|
|
92
|
+
.sort((x, y) => x.localeCompare(y, undefined, { numeric: true }));
|
|
93
|
+
const plain = Math.max(0, a.qty - a.serials.length);
|
|
94
|
+
const what = [names.length ? `S/N ${names.join(", ")}` : "", plain ? `${plain} without serial number` : ""].filter(Boolean).join(" + ");
|
|
95
|
+
return `${qtyUnit(a.qty, c.unit)}${what ? ` · ${what}` : ""}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* DV-1787: totals of checked-out rows by state (Not Returned, Return Asked, Returned, Written Off,
|
|
100
|
+
* Used) - Not Returned and Returned always, the others when there are any.
|
|
101
|
+
*/
|
|
102
|
+
export function checkoutStats(rows: { status: string; outQty: number; returnAsked?: { qty: number } | null; ended?: Partial<Record<string, number>> }[]) {
|
|
103
|
+
const n = (v: unknown) => Number(v) || 0;
|
|
104
|
+
const sum = (f: (c: (typeof rows)[number]) => number) => rows.reduce((t, c) => t + f(c), 0);
|
|
105
|
+
const list = [
|
|
106
|
+
// Not Returned leaves out what is already asked to return, so the totals add up to what was issued.
|
|
107
|
+
{ label: "Not Returned", n: sum((c) => (c.status === "out" ? Math.max(0, c.outQty - (c.returnAsked?.qty ?? 0)) : 0)), cls: "text-warning" },
|
|
108
|
+
{ label: "Return Asked", n: sum((c) => (c.status === "out" ? (c.returnAsked?.qty ?? 0) : 0)), cls: "text-primary" },
|
|
109
|
+
{ label: "Returned", n: sum((c) => n(c.ended?.returned)), cls: "text-success" },
|
|
110
|
+
{ label: "Written Off", n: sum((c) => n(c.ended?.written_off)), cls: "text-error" },
|
|
111
|
+
{ label: "Used", n: sum((c) => n(c.ended?.used)), cls: "" },
|
|
112
|
+
];
|
|
113
|
+
return list.filter((x, i) => i === 0 || i === 2 || x.n > 0);
|
|
114
|
+
}
|