diff --git a/DECISIONS.md b/DECISIONS.md
index f5de6f4..25abd57 100644
--- a/DECISIONS.md
+++ b/DECISIONS.md
@@ -731,3 +731,28 @@ Bổ sung @playwright/test trong devDependencies để kiểm thao tác biểu m
- **Gia hạn (D50 #23):** chữ hiển thị không còn "chờ quản lý duyệt" / "cơ sở duyệt và chốt giá"; dùng "chờ xác nhận" / "đã được xác nhận".
- **Màn khách hàng:** dưới họ tên trên thanh đầu trang hiện vai trò "Khách hàng" (giống thẻ vai trò của nhân viên, quản lý, admin).
- **Hotline ở chân trang** hiện chữ thường cùng màu các dòng khác, không còn là liên kết `tel:`. Số hotline giữ theo D50.
+
+## D64 — 18/11/2026: Xác nhận hoàn tiền không cần mã giao dịch; trả kho chỉ chọn ngày — Đã chốt
+
+> Người dùng (Thắng) chốt ngày 18/11/2026, Figma đã sửa trước (M-ĐS-CHỐT chuyển khoản + bản tiền mặt, M08a/M08a2, D30-15). Thay ý "nhập mã giao dịch ngân hàng" ở mục 21 (D50), dòng "Chuyển khoản: quản lý … nhập mã giao dịch" và các dòng D27/D32 yêu cầu mã giao dịch, thời điểm chuyển cho bước xác nhận hoàn.
+
+- Khách điền thông tin nhận hoàn (chuyển khoản: ngân hàng, số tài khoản, chủ tài khoản; hoặc tiền mặt tại quầy). Quản lý thấy đủ thông tin đó và **chỉ bấm xác nhận**: "Xác nhận đã chuyển khoản" hoặc "Xác nhận đã trả tiền mặt". **Không nhập mã giao dịch, không nhập thời gian chuyển**; máy chủ ghi thời điểm xác nhận làm ngày hoàn.
+- Áp dụng cho hoàn cọc sau trả kho và hoàn tiền đơn huỷ (M08). Vẫn giữ: xác nhận một lần (409 khi bấm lặp), khoá phương thức theo lựa chọn khách, kiểm tra tài khoản nhận đủ thông tin.
+- API giữ nguyên trường `transactionRef`/`transferredAt` nhưng **không bắt buộc**; có gửi mã (dữ liệu cũ) thì vẫn kiểm tra ≤ 100 ký tự và không trùng. Khách không còn thấy dòng "Mã giao dịch" ở theo dõi khoản hoàn.
+- Trả kho: khách chỉ chọn **ngày** mong muốn trả kho, không chọn giờ hay buổi sáng/chiều (giữ đúng mục 9 / D59).
+
+## D65 — 18/11/2026: Mốc "Sắp hết hạn" còn 10 ngày — Đã chốt
+
+> Người dùng (Thắng) chốt ngày 18/11/2026. Thay mốc 30 ngày của D11 (và mốc 14 ngày của Công cụ demo / bảng kho quản lý).
+
+- Hợp đồng chỉ chuyển "Sắp hết hạn" (EXPIRING) khi còn **≤ 10 ngày** tới ngày kết thúc; còn hơn 10 ngày là "Đang thuê". Áp dụng thống nhất cho khách (Kho của tôi, tổng quan), quản lý, Công cụ demo và tiến trình quét hằng ngày.
+- Tiến trình quét hằng ngày đưa hợp đồng EXPIRING còn hơn 10 ngày (đánh theo mốc cũ hoặc vừa gia hạn) về lại ACTIVE. Email nhắc gia hạn giữ nguyên mốc 3 ngày.
+
+## D66 — 18/11/2026: Mỗi cơ sở một nhân viên — bỏ giao việc; quản lý tự xác nhận đã trả tiền mặt — Đã chốt
+
+> Người dùng (Thắng) chốt ngày 18/11/2026, chọn phương án (a). Thay phần "quản lý duyệt chi tiền mặt và giao nhân viên, nhân viên tick 4 mục và chi" của D42/D44, phần "quản lý phân công nhân viên xử lý đồ quá hạn" và trang M06 Phân công công việc.
+
+- Mỗi cơ sở mặc định 1 nhân viên; **không có thao tác giao việc** nào cho nhân viên.
+- **Hoàn tiền mặt tại quầy:** bỏ bước "Duyệt & giao" và ô chọn nhân viên. Khoản tiền mặt chờ khách đến nhận ngay khi được tạo; khi khách nhận đủ tiền, **quản lý bấm "Xác nhận đã trả tiền mặt"** (Figma M-ĐS-CHỐT · tiền mặt), không nhập mã giao dịch. Hạn nhận 30 ngày tính từ lúc tạo khoản (khoản cũ đã duyệt vẫn tính từ lần duyệt). Nhân viên chỉ còn gọi nhắc khách ở ngày 10, 20, 25.
+- **Xử lý đồ quá hạn từ ngày 20:** bỏ bước quản lý phân công; hồ sơ hiện thẳng ở "Công việc xử lý đồ quá hạn" của nhân viên cơ sở.
+- Bỏ trang M06 "Phân công công việc" (đã ẩn khỏi menu từ #7). Yêu cầu hỗ trợ giữ cách hiện tại: nhân viên của cơ sở thấy và nhận xử lý, không cần giao.
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/BACKEND-TODO.md b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/BACKEND-TODO.md
index 549dcb1..d1f7e18 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/BACKEND-TODO.md
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/BACKEND-TODO.md
@@ -101,7 +101,7 @@ Mã việc khớp kế hoạch "SafeSpace — Kế hoạch hoàn thiện cập n
| T04 | Khách chọn trả gia hạn tại quầy; nhân viên xác nhận thu | `POST /api/renewals/{id}/counter-payment`; board `counterRenewals[]` + `POST /api/ops/counter-renewals/actions` `{action:"COLLECT_RENEWAL"}` (xem `APPROVED-FE-API-GAPS.md`) | Đạt | P1 |
| T05 | Biên bản trả kho lưu phí và ảnh | `POST /api/ops/returns/{id}/inspection` nhận thêm `damageFee`, `cleaningRequired`, `feeReason`, `photos[]` (ảnh kho trống bắt buộc); lưu `ReturnInspection.DamageFee/CleaningFee/CleaningRequired`. Vệ sinh = 10% cọc cố định, không nhập tay | Ngọc Mai | P0 |
| T06 | Quyết toán trả kho: tổng khấu trừ ≤ `DepositAmount`; bỏ `Debt`; không để khoản `DAMAGE_FEE`/`OVERDUE_FEE` nào ở trạng thái chờ thu sau quyết toán | `RefundPolicy.Calculate`, `ConfirmRefundAsync`, `RefundPolicyTests` | Ngọc Mai | P0 |
-| T07 | Hoàn cọc hai bước: M07 chốt → `REFUND` `PENDING`; màn hoàn cọc ghi `transactionRef` → `PAID`. Ô cần vệ sinh giữ `MAINTENANCE` | `POST /api/ops/contracts/{id}/refund` (chỉ chốt số), `GET /api/ops/deposit-refunds`, `POST /api/ops/deposit-refunds/actions` `{action:"CONFIRM_DEPOSIT_REFUND", id, transactionRef}` | Ngọc Mai | P0 |
+| T07 | Hoàn cọc hai bước: M07 chốt → `REFUND` `PENDING`; màn hoàn cọc bấm xác nhận → `PAID` (D64 18/11: `transactionRef`, `transferredAt` không bắt buộc). Ô cần vệ sinh giữ `MAINTENANCE` | `POST /api/ops/contracts/{id}/refund` (chỉ chốt số), `GET /api/ops/deposit-refunds`, `POST /api/ops/deposit-refunds/actions` `{action:"CONFIRM_DEPOSIT_REFUND", id, transactionRef}` | Ngọc Mai | P0 |
| T08 | Tài khoản nhận hoàn chính chủ khi huỷ đơn và khi gửi trả kho: `bankName`, `accountNumber` (6–19 chữ số), `accountHolder` (trùng tên hợp đồng) | `POST /api/reservations/{id}/cancel`, `POST /api/contracts/{id}/move-out` | Ngọc Mai | P1 |
| T09 | Phí quá hạn = `DepositAmount × rate × số ngày trễ`, tối đa `DepositAmount`; dừng khi gửi trả kho. Thêm `CalculationType` `DEPOSIT_PERCENT_PER_DAY` cho chính sách `OVERDUE` (mặc định 5) | `RefundPolicy.OverdueFeeFor`, seed/B02, test | Tiến | P0 |
| T11 | Job quá hạn mỗi ngày: EXPIRING/OVERDUE, tạo `OverdueCase`, cộng phí theo ngày không trùng, mốc nhắc ngày 10–14, việc xử lý đồ ngày 20 | Worker mới (giống `ExpiredCashHoldWorker`) | Tiến | P1 |
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/mock/mock-api.mjs b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/mock/mock-api.mjs
index b259097..fd16a31 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/mock/mock-api.mjs
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/mock/mock-api.mjs
@@ -497,7 +497,7 @@ export function startMockApi(
return send(200, page(rows));
}
// Lượt 6 · #45 #54: công cụ demo ngày & giá
- const running = (c) => { const t = dateOnly(new Date()); if (c.status !== "ACTIVE") return c.status; if (c.endDate <= t) return "OVERDUE"; return (new Date(c.endDate) - new Date(t)) / 864e5 <= 14 ? "EXPIRING" : "ACTIVE"; };
+ const running = (c) => { const t = dateOnly(new Date()); if (c.status !== "ACTIVE") return c.status; if (c.endDate <= t) return "OVERDUE"; return (new Date(c.endDate) - new Date(t)) / 864e5 <= 10 ? "EXPIRING" : "ACTIVE"; };
const overdueDays = (c) => { const t = dateOnly(new Date()); return c.status === "ACTIVE" && c.endDate <= t ? Math.round((new Date(t) - new Date(c.endDate)) / 864e5) : 0; };
const demoDto = (c) => { const u = unit(c.unitId); return { contractId: c.contractId, contractCode: `HĐ-${c.startDate.slice(0, 4)}-${String(c.contractId).padStart(4, "0")}`, customerName: S.users.find((x) => x.userId === c.customerId)?.fullName, unitNumber: u.unitNumber, facilityName: fac(u.facilityId)?.name, startDate: c.startDate, endDate: c.endDate, agreedMonthlyRate: c.agreedMonthlyRate ?? c.monthlyRate ?? 0, depositAmount: c.depositAmount ?? 0, status: running(c), overdueDays: overdueDays(c), payments: S.payments.filter((p) => p.contractId === c.contractId).map((p) => ({ paymentId: p.paymentId, paymentType: p.paymentType, status: p.status, amount: p.amount, paidAt: p.paidAt ? dbTime(p.paidAt) : null, dueDate: p.dueDate || null })) }; };
// D57 · Chỉnh giá theo cơ sở (demo): giá 4 loại kho của một cơ sở
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/scripts/check-workflow-actions.mjs b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/scripts/check-workflow-actions.mjs
index 8bcf68c..f5711c1 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/scripts/check-workflow-actions.mjs
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/scripts/check-workflow-actions.mjs
@@ -11,12 +11,11 @@ async function route(path){await page.goto('http://127.0.0.1:5173/#/'+path);awai
// Nút xác nhận / nút đóng thông báo thành công theo chữ Figma từng màn (useWorkflowChange opts), nên bấm theo vị trí.
async function confirm(){await page.locator('.modal--confirm:not(.modal--success):not(.modal--failure)').getByRole('button').last().click();await page.locator('.modal--success').getByRole('button').first().click();}
// Thời gian chuyển phải sau lúc duyệt đối soát và không ở tương lai: lấy đúng mốc hiện tại (max của ô).
-async function transferNow(){const at=page.getByLabel(/Thời gian chuyển/);await at.fill(await at.getAttribute('max'));}
const passed=[];
await login('manager01','Manager@123');await route('manager/refunds');
const han=page.locator('.record-card').filter({hasText:'Phạm Gia Hân'});await han.getByRole('button',{name:'Xem yêu cầu hoàn tiền'}).click();assert.match(await page.getByRole('dialog').innerText(),/2.166.000/);await page.getByRole('button',{name:'Đóng chi tiết',exact:true}).click();
-await han.getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).click();await page.getByRole('dialog').getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).click();assert.match(await page.getByRole('dialog').innerText(),/Nhập mã giao dịch/);await page.getByLabel('Mã giao dịch hoàn tiền').fill('QA-REF-0139');await transferNow();await page.getByLabel('Đã chuyển đúng số tiền vào đúng tài khoản nhận hoàn').check();await page.getByRole('dialog').getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).click();await page.locator('.modal--success').getByRole('button',{name:'Về yêu cầu hoàn',exact:true}).click();await page.waitForTimeout(200);assert.equal(await han.getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).count(),0);passed.push('Đúng khách / bắt buộc mã giao dịch, thời gian chuyển, xác nhận chính chủ / không xác nhận hoàn hai lần');
-await route('manager/deposit-refunds');await page.getByRole('button',{name:'Xem khoản hoàn'}).click();await page.getByLabel(/Mã giao dịch/).fill('QA-DEPOSIT-0098');await transferNow();await page.getByLabel('Tôi đã chuyển đúng số tiền vào đúng tài khoản nhận').check();await page.getByRole('button',{name:'Ghi nhận đã chuyển tiền'}).click();await confirm();assert.equal(await page.getByRole('button',{name:'Ghi nhận đã chuyển tiền'}).count(),0);passed.push('Hoàn cọc độc lập và chặn xác nhận lại');
+await han.getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).click();assert.match(await page.getByRole('dialog').innerText(),/Không cần nhập mã giao dịch/);await page.getByRole('dialog').getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).click();await page.locator('.modal--success').getByRole('button',{name:'Về yêu cầu hoàn',exact:true}).click();await page.waitForTimeout(200);assert.equal(await han.getByRole('button',{name:'Xác nhận đã hoàn',exact:true}).count(),0);passed.push('D64: M08 chỉ bấm xác nhận, không nhập mã giao dịch / không xác nhận hoàn hai lần');
+await route('manager/deposit-refunds');await page.getByRole('button',{name:'Xem khoản hoàn'}).click();assert.match(await page.locator('main').innerText(),/Số tài khoản/);await page.getByRole('button',{name:'Xác nhận đã chuyển khoản'}).click();await confirm();assert.equal(await page.getByRole('button',{name:'Xác nhận đã chuyển khoản'}).count(),0);passed.push('D64: hoàn cọc chỉ bấm xác nhận đã chuyển khoản, chặn xác nhận lại');
await login('customer01','Customer@123');await route('refunds');assert.match(await page.locator('main').innerText(),/Đã hoàn · 662\.500 đ/);passed.push('Khách nhìn thấy kết quả hoàn cọc sau khi quản lý xác nhận');await route('inquiries/HT-0091');await page.getByRole('button',{name:'Kiểm tra & gửi phản hồi'}).click();assert.match(await page.locator('main').innerText(),/Vui lòng nhập nội dung/);await page.getByLabel('Nội dung phản hồi').fill('Tôi cần kho cho 10 thùng đồ trong 3 tháng.');await page.getByRole('button',{name:'Kiểm tra & gửi phản hồi'}).click();await confirm();passed.push('Phản hồi khách: dữ liệu trống và gửi thành công');
await login('staff01','Staff@123');await route('staff/inquiries');await page.getByRole('button',{name:'Xem yêu cầu',exact:true}).click();assert.match(await page.locator('main').innerText(),/Tôi cần kho cho 10 thùng đồ/);passed.push('Nhân viên nhận đúng phản hồi của khách qua dữ liệu demo chung');
await route('staff/renewal-payments');await page.getByRole('button',{name:'Xác nhận đã thu',exact:true}).click();await confirm();assert.equal(await page.getByRole('button',{name:'Xác nhận đã thu',exact:true}).count(),0);passed.push('Thu gia hạn tại quầy một lần');
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx
index 64123aa..409abd9 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx
@@ -13,6 +13,7 @@ import { defaultRentalPolicy } from "../../features/facility-operations/workflow
import { isReturnFee, NO_RETURN_COLLECTION, visitDateError } from "../../shared/utils/returnPolicy.js";
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import { customerNotifications } from "../../features/customer/notifications/customerNotifications.js";
+import { noticeKey } from "../../shared/utils/notices.js";
import { submitCancellation, submitReturnRequest } from "../../shared/api/refundRequestApi.js";
import { readPhotoData, verifyPhotoFile } from "../../shared/utils/refundRequest.js";
import { submitRenewalWithConsent } from "../../shared/api/renewalConsentApi.js";
@@ -394,13 +395,18 @@ function ApiProvider({ children }) {
updateOverlay(o => {
const byId = new Map(events.map(event => [event.id, event]));
const ids = new Set(o.notifications.map(notice => notice.id));
- const incoming = events.filter(event => !ids.has(event.id));
+ // Thông báo quá hạn: thời điểm của sự kiện là 00:00 nên bị xếp dưới các thông báo khác trong ngày và khách không thấy.
+ // Lần đầu phát hiện và mỗi lần số ngày quá hạn đổi → đưa lên đầu chuông, chưa đọc (cùng nhịp với email quá hạn).
+ const stamp = new Date().toISOString();
+ const isOverdue = id => typeof id === "string" && id.startsWith("SERVER-OVERDUE-");
+ const dismissed = new Set(o.dismissedNotices || []);
+ const incoming = events.filter(event => !ids.has(event.id) && !dismissed.has(noticeKey(event))).map(event => isOverdue(event.id) ? { ...event, created_at: stamp } : event);
let updated = false;
const existing = o.notifications.map(notice => {
- const event = typeof notice.id === "string" && notice.id.startsWith("SERVER-OVERDUE-") ? byId.get(notice.id) : null;
+ const event = isOverdue(notice.id) ? byId.get(notice.id) : null;
if (!event || event.detail === notice.detail) return notice;
updated = true;
- return { ...notice, detail: event.detail };
+ return { ...notice, detail: event.detail, created_at: stamp, read: false };
});
return incoming.length || updated ? { ...o, notifications: [...incoming, ...existing] } : o;
});
@@ -585,6 +591,7 @@ function ApiProvider({ children }) {
...o,
returns: next.returns,
notifications: next.notifications,
+ dismissedNotices: next.dismissedNotices || o.dismissedNotices || [],
activities: next.activities,
appointments: [...next.appointments.filter((a) => !prev.appointments.some((x) => x.appointment_id === a.appointment_id)), ...o.appointments],
name: next.user?.full_name !== prev.user?.full_name ? next.user.full_name : o.name,
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js
index e68e190..cef38b8 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js
@@ -7,6 +7,7 @@
* - Thanh toán: PAY_ORDER, ADD_PAYMENT, REFUND_SETTLEMENT
* - Hỗ trợ: CREATE_TICKET, REPLY_TICKET
*/
+import { noticeKey } from "../../shared/utils/notices.js";
import { requireRentalPolicy } from "../../shared/utils/rentalPolicy.js";
import { storedRefundChoice, validateRefundChoice } from "../../shared/utils/refundRequest.js";
import { isReturnFee, NO_RETURN_COLLECTION, visitDateError } from "../../shared/utils/returnPolicy.js";
@@ -483,12 +484,16 @@ const handlers = {
return { state: { ...state, user: { ...state.user, password: p.next } }, result: {} };
},
+ // Đã đọc thì xoá khỏi chuông (18/11); nhớ khoá để thông báo sinh từ máy chủ không quay lại.
MARK_READ(state, p) {
const all = !p.ids;
+ const read = state.notifications.filter((n) => all || p.ids.includes(n.id));
+ const keys = read.map(noticeKey).filter(Boolean);
return {
state: {
...state,
- notifications: state.notifications.map((n) => (all || p.ids.includes(n.id) ? { ...n, read: true } : n)),
+ notifications: state.notifications.filter((n) => !(all || p.ids.includes(n.id))),
+ dismissedNotices: [...keys, ...(state.dismissedNotices || []).filter((k) => !keys.includes(k))].slice(0, 500),
},
result: {},
};
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appSelectors.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appSelectors.js
index 55f836e..31c2a3d 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appSelectors.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appSelectors.js
@@ -22,12 +22,13 @@ export const facilityOf = (data, id, name) =>
};
export const contractOf = (data, id) => data.contracts.find((c) => c.contract_id === id);
-// Trạng thái hợp đồng suy ra theo ngày (ACTIVE → EXPIRING trong 30 ngày → OVERDUE)
+// Trạng thái hợp đồng suy ra theo ngày (ACTIVE → EXPIRING khi còn ≤ 10 ngày, D65 → OVERDUE)
+export const EXPIRING_DAYS = 10;
export function contractStatus(c, now = new Date()) {
if (c.status === "ENDED") return "ENDED";
const left = daysBetween(localDate(now), c.end_date);
if (left < 0) return "OVERDUE";
- if (left <= 30) return "EXPIRING";
+ if (left <= EXPIRING_DAYS) return "EXPIRING";
return "ACTIVE";
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/demoModel.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/demoModel.js
index ec24daf..6e5330c 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/demoModel.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/demoModel.js
@@ -16,7 +16,7 @@ export function expectedState(start, end, today) {
if (!start || !end) return null;
if (start > today) return "Chưa tới ngày thuê";
if (end <= today) return `Quá hạn ${Math.round((Date.parse(today) - Date.parse(end)) / 86400000)} ngày`;
- return Math.round((Date.parse(end) - Date.parse(today)) / 86400000) <= 14 ? "Sắp hết hạn" : "Đang thuê";
+ return Math.round((Date.parse(end) - Date.parse(today)) / 86400000) <= 10 ? "Sắp hết hạn" : "Đang thuê";
}
export function contractFormError({ start, end, rate }) {
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js
index 1ead171..acf7234 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js
@@ -24,8 +24,8 @@ export const SYSTEM_ENFORCED_POLICIES = [
{
key: 'expiring',
label: 'Thông báo sắp hết hạn hợp đồng',
- value: '30 ngày trước khi hết hạn',
- reference: 'D11 · OverdueProcessor',
+ value: '10 ngày trước khi hết hạn',
+ reference: 'D65 · OverdueProcessor',
description: 'Hệ thống tự động rà soát hàng ngày và gửi thông báo nhắc gia hạn đến khách hàng.',
},
{
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx
index 9b46e58..ffd7394 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx
@@ -14,6 +14,6 @@ export function ReturnProgressPage({ id }) {
const ret = pendingReturn(data, id), refund = load.data?.find(r => r.contractId === id && String(r.ownerId) === String(user?.user_id));
return
{ret ? "Đã gửi lịch trả kho" : "Chưa có yêu cầu trả kho"}
{ret && <>Nhân viên sẽ kiểm tra kho và chụp ảnh hiện trạng trước khi đối soát hoàn cọc. Cần hỗ trợ ra vào, vui lòng liên hệ nhân viên.>}
-
Biên bản & hoàn cọc
{refund ? <>{refund.transactionRef &&
Mã giao dịch: {refund.transactionRef}
}> :
Chưa có kết quả kiểm tra / đối soát cọc từ cơ sở.
}
+
Biên bản & hoàn cọc
{refund ? <>> :
Chưa có kết quả kiểm tra / đối soát cọc từ cơ sở.
}
Về hợp đồngLiên hệ cơ sở
;
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx
index 34e6b36..fcf56e8 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx
@@ -2,7 +2,7 @@
* RETURN REQUEST PAGE - ĐĂNG KÝ LỊCH TRẢ KHO (C08 / UC06)
*
* Thủ tục trả kho (Move-out):
- * - Chọn ngày hẹn trả kho thực tế và giờ kiểm kê dự kiến.
+ * - Chỉ chọn ngày hẹn trả kho (D64: không chọn giờ / buổi sáng chiều).
* - Lựa chọn hình thức nhận hoàn tiền cọc (Chuyển khoản ngân hàng hoặc Tiền mặt tại quầy - D42).
* - Lưu ý hướng dẫn dọn hết đồ đạc và bàn giao lại chìa khóa/thẻ từ.
*/
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/dashboard/CustomerDashboardPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/dashboard/CustomerDashboardPage.jsx
index d8170c0..47e2d83 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/dashboard/CustomerDashboardPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/dashboard/CustomerDashboardPage.jsx
@@ -68,7 +68,7 @@ export default function CustomerDashboardPage() {
{i === 3 && r.status === "PAID" ? time ? stamp(time) : "Đã chuyển · chưa có thời điểm" : i === 3 && r.amount != null && r.amount <= 0 ? "Không có khoản chuyển" : stamp(time)}
)}
Khoản hoàn cọc · {r.contractId}
Liên hệ cơ sở
-
+
> : }>}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx
index 2d9f098..11f7b93 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx
@@ -24,7 +24,6 @@ import { RefundCenterPage } from "../manager/refunds/RefundCenterPage.jsx";
import { Empty, LinkButton } from "../../shared/components/UI.jsx";
import { UnitAllocationPage } from "../manager/allocations/UnitAllocationPage.jsx";
-import { StaffAssignmentPage } from "../manager/assignments/StaffAssignmentPage.jsx";
import { ContractListPage } from "../manager/contracts/ContractListPage.jsx";
import { CancellationRefundPage } from "../manager/refunds/CancellationRefundPage.jsx";
import { ManagerResultPage } from "../manager/results/ManagerResultPage.jsx";
@@ -82,7 +81,6 @@ const MANAGER = {
"": [ManagerDashboardPage, "manager"],
units: [UnitManagementPage, "manager/units"],
allocate: [UnitAllocationPage, "manager"], // chỉ còn cho đơn đã thanh toán mà hệ thống không bố trí được ô
- assign: [StaffAssignmentPage, "manager"], // bỏ khỏi navbar: yêu cầu của khách hiện thẳng bên nhân viên
renewals: [RenewalApprovalPage, "manager/renewals"],
contracts: [ContractListPage, "manager/contracts"],
refunds: [CancellationRefundPage, "manager/refund"],
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/components/StaffTasks.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/components/StaffTasks.jsx
index 6172ef4..e4c66cd 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/components/StaffTasks.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/components/StaffTasks.jsx
@@ -85,14 +85,13 @@ export function staffTasks(ops, me, kind = "all") {
}),
);
(ops.cash_refunds || [])
- .filter((r) => ["READY", "REMIND", "APPOINTMENT"].includes(r.status) &&
- (!r.staff_id && !r.staffId || !me?.staff_id || (r.staff_id || r.staffId) === me.staff_id))
+ .filter((r) => r.status === "REMIND") // D66: quản lý xác nhận đã trả tiền mặt; nhân viên chỉ gọi nhắc khách
.forEach((r) =>
list.push({
- key: r.id, kind: "reconcile", status: ["Chờ chi tiền", "amber"], title: `Hoàn tiền ${r.id}`,
+ key: r.id, kind: "reconcile", status: ["Cần gọi nhắc", "amber"], title: `Hoàn tiền ${r.id}`,
meta: `${r.customer} · ${r.reference || "Tiền mặt"}`,
- when: `${money(r.amount)} · Chi tiền mặt tại quầy`,
- cta: "Chi tiền", to: "staff/cash-refunds", sort: r.deadlineDate || r.deadline_date || "",
+ when: `${money(r.amount)} · Gọi nhắc khách đến nhận tiền mặt`,
+ cta: "Gọi nhắc", to: "staff/cash-refunds", sort: r.deadlineDate || r.deadline_date || "",
}),
);
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/data/facilityOperationsSeed.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/data/facilityOperationsSeed.js
index dec5c50..aa08bd3 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/data/facilityOperationsSeed.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/data/facilityOperationsSeed.js
@@ -43,7 +43,7 @@ const LAYOUT = [
function createUnits(t) {
const usage = {
K01: ["Nguyễn Thị Mai", "WAITING_HANDOVER", addMonths(addDays(t, 6), 3)],
- K02: ["Lê Văn Tùng", "EXPIRING", addDays(t, 14)],
+ K02: ["Lê Văn Tùng", "EXPIRING", addDays(t, 9)],
K03: ["Trần Quốc Bảo", "OVERDUE", addDays(t, -3)],
K04: ["Lê Văn An", "OVERDUE", addDays(t, -4)],
K05: ["Võ Thị Hạnh", "WAITING_HANDOVER", addMonths(t, 3)],
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js
index ce728ce..107e1ef 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js
@@ -26,11 +26,12 @@ export function transferProof(item,payload,now=new Date()) {
if (!isCash) {
const error=validateRefundBank({bankName:item.bankName,accountNumber:item.accountNumber,accountHolder:item.accountHolder},item.customer);if(error)throw new Error(error);
}
- const ref=String(payload.transactionRef||payload.transaction_ref||"").trim();if(!ref||ref.length>100)throw new Error(isCash ? "Nhập mã phiếu chi không quá 100 ký tự." : "Nhập mã giao dịch không quá 100 ký tự.");
+ // D64 (18/11): không nhập mã giao dịch / thời gian; quản lý chỉ bấm xác nhận. Mã (nếu có, dữ liệu cũ) tối đa 100 ký tự.
+ const ref=String(payload.transactionRef||payload.transaction_ref||"").trim();if(ref.length>100)throw new Error("Mã giao dịch không quá 100 ký tự.");
if(payload.confirmed!==true)throw new Error(isCash ? "Cần xác nhận đã chi tiền mặt cho khách hàng." : "Cần xác nhận đã chuyển đúng số tiền vào đúng tài khoản.");
- const paidAt=actualVnTime(payload.transferredAt,now);
+ const paidAt=payload.transferredAt?actualVnTime(payload.transferredAt,now):now.toISOString();
if(item.inspectedAt&&Number.isFinite(Date.parse(item.inspectedAt))&&Date.parse(paidAt)h.id===payload.id);if(!h||h.status!=="WAITING")throw new Error("Lịch nhận chìa khóa không còn chờ xử lý.");
@@ -76,12 +77,13 @@ export function opsReceiptCheck(type,payload,res,board) {
if(type==="SUBMIT_RETURN") {const r=board.returns?.find(r=>r.id===payload.id);if(r?.status!=="SUBMITTED"||!r.submitted_at||["damage_fee","cleaning_fee","cleaning_required","damage_item","fee_reason"].some(k=>r.report?.[k]!==payload.report[k])||(payload.files?.length&&!r.report?.photos?.length))throw new Error("Chưa xác nhận ảnh và các khoản khấu trừ đã được lưu đầy đủ.");}
if(type==="CONFIRM_REFUND"&&(!knownMoney(res?.refund)||res?.refundStatus!=="PENDING"||!board.contracts?.some(c=>c.id===payload.id&&c.state==="CLOSED")))throw new Error("Chưa xác nhận khoản hoàn chờ chuyển tiền.");
if(type==="CONFIRM_DEPOSIT_REFUND")transferProof(ops.deposit_refunds?.find(r=>r.id===payload.id),payload);
- if(type==="CONFIRM_RESERVATION_REFUND") {const r=board.refunds?.find(r=>r.id===payload.id);if(r?.status!=="PAID"||r.transaction_ref!==payload.transaction_ref?.trim()||!r.paid_at)throw new Error("Máy chủ chưa xác nhận bằng chứng chuyển tiền.");}
+ if(type==="CONFIRM_RESERVATION_REFUND") {const r=board.refunds?.find(r=>r.id===payload.id);if(r?.status!=="PAID"||(r.transaction_ref||null)!==(String(payload.transaction_ref||"").trim()||null)||!r.paid_at)throw new Error("Máy chủ chưa xác nhận bằng chứng chuyển tiền.");}
}
export function validateRemoval(item,payload,policy,actor,now=new Date()) {
if(!item||item.status==="DONE")throw new Error("Biên bản đã được lưu; không gửi lại.");
if(!actor.roles?.some(r=>["STAFF","MANAGER"].includes(r))||actor.facilityId!==item.facilityId)throw new Error("Hồ sơ không thuộc cơ sở phụ trách.");
- if(actor.roles.includes("STAFF")&&item.assignee!==actor.name)throw new Error("Bạn chưa được phân công hồ sơ này.");
+ // D66: mỗi cơ sở 1 nhân viên, không phân công; chỉ chặn khi hồ sơ cũ đã giao cho người khác.
+ if(actor.roles.includes("STAFF")&&item.assignee&&item.assignee!==actor.name)throw new Error("Hồ sơ đã giao cho nhân viên khác.");
const performedAt=actualVnTime(payload.performedAt,now),day=new Intl.DateTimeFormat("sv-SE",{timeZone:"Asia/Ho_Chi_Minh"}).format(new Date(performedAt)),days=Math.floor((Date.parse(`${day}T00:00:00Z`)-Date.parse(`${item.endDate}T00:00:00Z`))/86400000),removalDay=Number.isSafeInteger(policy?.removalDay)&&policy.removalDay>=20?policy.removalDay:20;
if(!Number.isFinite(days)||days ({ status: "PAID", paid_at: iso(now), method: method || "BANK_TRANSFER", transaction_ref: ref || null })) };
return { state: addLog(next, now, `Đã xác nhận hoàn ${money(r.amount)} · ${id}`, "manager/refunds", "MANAGER"), result: { id, refund: r.amount } };
},
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/utils/pendingTaskCounts.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/utils/pendingTaskCounts.js
index 786196f..f172a8a 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/utils/pendingTaskCounts.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/utils/pendingTaskCounts.js
@@ -8,10 +8,7 @@ export function pendingTaskCounts(ops, role, me) {
if (role === "STAFF") {
const counterPayments = count(ops.payments, p => p.status === "PENDING");
const renewalPayments = count(ops.counter_renewals, r => r.status === "PENDING");
- const cashRefunds = count(ops.cash_refunds, r =>
- ["READY", "REMIND", "APPOINTMENT"].includes(r.status) &&
- (!r.staff_id && !r.staffId || !me?.staff_id || (r.staff_id || r.staffId) === me.staff_id)
- );
+ const cashRefunds = count(ops.cash_refunds, r => r.status === "REMIND"); // D66: nhân viên chỉ gọi nhắc
const reconcile = counterPayments + renewalPayments + cashRefunds;
const verifications = count(ops.verifications, v => v.status === "TODO");
@@ -55,7 +52,7 @@ export function pendingTaskCounts(ops, role, me) {
// MANAGER
const overdueCases = count(ops.overdue_cases, c => c.status !== "DONE");
- const managerCashRefunds = count(ops.cash_refunds, r => r.status === "WAITING_APPROVAL");
+ const managerCashRefunds = count(ops.cash_refunds, r => ["WAITING_APPROVAL", "READY", "REMIND", "APPOINTMENT"].includes(r.status)); // D66: chờ quản lý xác nhận đã trả
// Xung đột đặt kho: hệ thống tự đề xuất đổi ô cho khách; quản lý chỉ cần xử lý khi không còn ô tương đương (NONE).
const unitConflicts = count(ops.unit_conflicts, c => c.status === "OPEN" && c.option === "NONE");
const depositRefunds = count(ops.deposit_refunds, r => r.status === "PENDING" && !isCashRefund(r));
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/cashRefundModel.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/cashRefundModel.js
index fa17ab7..517e643 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/cashRefundModel.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/cashRefundModel.js
@@ -10,14 +10,14 @@
*/
// D42/D44 · Khoản hoàn tiền mặt tại quầy (GET /api/ops/cash-refunds).
export const CASH_STATUS = {
- WAITING_APPROVAL: ["Chờ quản lý duyệt", "amber"],
- READY: ["Đã duyệt · chờ khách đến", "blue"],
+ WAITING_APPROVAL: ["Chờ khách đến nhận", "blue"],
+ READY: ["Chờ khách đến nhận", "blue"],
REMIND: ["Cần gọi nhắc khách", "amber"],
APPOINTMENT: ["Khách đã hẹn ngày đến", "blue"],
EXPIRED: ["Quá 30 ngày · khách mất khoản hoàn", "red"],
FORFEITED: ["Quá 30 ngày · khách mất khoản hoàn", "red"],
SWITCHED: ["Khách đổi sang chuyển khoản", "green"],
- PAID: ["Đã chi tại quầy", "green"],
+ PAID: ["Đã trả tiền mặt", "green"],
};
export const CASH_SOURCE = { RESERVATION: "Huỷ đơn", DEPOSIT: "Hoàn cọc", INCIDENT: "Sự cố cơ sở" };
export const cashPath = (id, action) => `/api/ops/cash-refunds/${encodeURIComponent(id)}/${action}`;
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useWorkflowData.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useWorkflowData.js
index 9a47649..ba90243 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useWorkflowData.js
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useWorkflowData.js
@@ -74,7 +74,7 @@ export function useWorkflowData(resource) {
try { localStorage.setItem(KEY, JSON.stringify(next)); } catch { /* retained only in memory */ }
setData(next[storageResource]); window.dispatchEvent(new Event("safespace-workflows"));
} else {
- let requestPayload=action==="CONFIRM_DEPOSIT_REFUND"?{...payload,transactionRef:payload.transactionRef.trim(),transferredAt:actualVnTime(payload.transferredAt)}:payload;
+ let requestPayload=action==="CONFIRM_DEPOSIT_REFUND"?{...payload,transactionRef:String(payload.transactionRef||"").trim()||null,transferredAt:payload.transferredAt?actualVnTime(payload.transferredAt):null}:payload;
if(action==="RECORD_REMOVAL") {requestPayload={...payload,location:payload.location?.trim()||OVERDUE_HOLDING_AREA,photos:[],beforePhotos:undefined,afterPhotos:undefined};for(const file of removalPhotos(payload)){await verifyPhotoFile(file);requestPayload.photos.push(await readPhotoData(file));}}
if(activeActor.current!==actorKey)throw new Error("Tài khoản đã thay đổi. Tải lại trước khi gửi.");
if(action==="RECORD_REMOVAL")requestPayload.performedAt=actualVnTime(payload.performedAt);
@@ -96,7 +96,7 @@ export function useWorkflowData(resource) {
}
inquiryRequest.current = null;
}
- if(action==="CONFIRM_DEPOSIT_REFUND") {const item=result?.item;if(item?.id!==payload.id||item.status!=="PAID"||item.transactionRef!==payload.transactionRef.trim()||!Number.isFinite(Date.parse(item.paidAt))||item.amount!==data.find(r=>r.id===payload.id)?.amount||item.facilityId!==facilityId||!Number.isSafeInteger(item.version)||item.version<=data.find(r=>r.id===payload.id)?.version||["contractId","ownerId","customer","bankName","accountNumber","accountHolder"].some(k=>item[k]!==data.find(r=>r.id===payload.id)?.[k])){const error=new Error("Máy chủ chưa xác nhận bằng chứng chuyển tiền; tải lại trước khi gửi tiếp.");error.uncertain=true;throw error;}setData(previous=>previous.map(r=>r.id===item.id?item:r));}
+ if(action==="CONFIRM_DEPOSIT_REFUND") {const item=result?.item;if(item?.id!==payload.id||item.status!=="PAID"||(item.transactionRef||null)!==(String(payload.transactionRef||"").trim()||null)||!Number.isFinite(Date.parse(item.paidAt))||item.amount!==data.find(r=>r.id===payload.id)?.amount||item.facilityId!==facilityId||!Number.isSafeInteger(item.version)||item.version<=data.find(r=>r.id===payload.id)?.version||["contractId","ownerId","customer","bankName","accountNumber","accountHolder"].some(k=>item[k]!==data.find(r=>r.id===payload.id)?.[k])){const error=new Error("Máy chủ chưa xác nhận bằng chứng chuyển tiền; tải lại trước khi gửi tiếp.");error.uncertain=true;throw error;}setData(previous=>previous.map(r=>r.id===item.id?item:r));}
else if(action==="RECORD_REMOVAL") {if(result?.item?.id!==payload.id||result.item.status!=="DONE"||!result.item.record?.savedAt||result.item.facilityId!==facilityId||!(result.item.record?.photos?.length||result.item.record?.afterPhotos?.length)){const error=new Error("Máy chủ chưa xác nhận biên bản và bằng chứng xử lý.");error.uncertain=true;throw error;}setData(previous=>previous.map(r=>r.id===result.item.id?result.item:r));}
else if (resource === "inquiries") setData(previous => {
const item = result.item;
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/assignments/StaffAssignmentPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/assignments/StaffAssignmentPage.jsx
deleted file mode 100644
index 07e3234..0000000
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/assignments/StaffAssignmentPage.jsx
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * STAFF ASSIGNMENT PAGE - PHÂN CÔNG CÔNG VIỆC CHO NHÂN VIÊN CƠ SỞ (M06)
- *
- * Nghiệp vụ:
- * - Quản lý cơ sở phân công các đầu việc (bàn giao kho, kiểm kê trả kho, xử lý sự cố)
- * cho nhân viên thuộc cơ sở phụ trách (A06).
- * - Hiển thị tình trạng công việc: Chưa giao (OPEN), Đã giao (ASSIGNED), Hoàn tất (COMPLETED).
- */
-import React, { useState } from "react";
-import { Select } from "../../../shared/components/Pickers.jsx";
-import { Button, Field, Notice, Tag } from "../../../shared/components/UI.jsx";
-import { ASSIGN_STATE } from "../../facility-operations/state/facilityOperationsReducer.js";
-import { useOps } from "../../facility-operations/state/FacilityOperationsProvider.jsx";
-import { slotLabel } from "../../facility-operations/components/FacilityOperationsComponents.jsx";
-import { PageHeaderBlock } from "../components/PageHeaderBlock.jsx";
-
-/**
- * Màn hình quản lý phân bổ công việc hàng ngày cho đội ngũ nhân viên cơ sở.
- */
-export function StaffAssignmentPage() {
- const { ops, run } = useOps();
- const open = ops.assignments.filter((a) => a.status !== "DONE");
- const [task, setTask] = useState(() => (open.find((a) => a.status === "OPEN") || open[0])?.id || "");
- const [staff, setStaff] = useState(ops.staff[0]?.staff_id || "");
- const staffName = (id) => ops.staff.find((s) => s.staff_id === id)?.full_name || "Chưa phân công";
- const busyCount = (id) => ops.assignments.filter((a) => a.staff === id && a.status !== "DONE").length;
- const submit = async (e) => {
- e.preventDefault();
- // Figma 885:10419–10443: xác nhận → kết quả “Về màn hình trước”, ở lại trang phân công
- await run("ASSIGN", { id: task, staff }, `Đã phân công ${staffName(staff)}`);
- };
- return (
-
-
-
-
-
Công việc
Lịch hẹn
Nhân viên
Trạng thái
-
- {ops.assignments.map((a) => (
-
-
{a.title}
-
{slotLabel(a.when)}
-
{staffName(a.staff)}
-
{ASSIGN_STATE[a.status][0]}
-
- ))}
-
-
-
- {open.length > 0 ? (
-
- ) : (
- Tất cả công việc đã hoàn tất.
- )}
-
- );
-}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/cash/CashRefundApprovalPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/cash/CashRefundApprovalPage.jsx
index 9961c3f..c8e5294 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/cash/CashRefundApprovalPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/cash/CashRefundApprovalPage.jsx
@@ -1,60 +1,57 @@
/**
- * CASH REFUND APPROVAL PAGE - PHÊ DUYỆT HOÀN TIỀN MẶT TẠI QUẦY (M08 / D42 / D44)
+ * CASH REFUND PAGE - HOÀN TIỀN MẶT TẠI QUẦY (M08 / D42 / D44 / D66)
*
- * Nghiệp vụ D42 / D44:
- * - Khách hàng chọn nhận tiền hoàn bằng tiền mặt (CASH) khi hủy đơn hoặc trả kho.
- * - Quản lý cơ sở xem xét hồ sơ, duyệt và giao việc cho nhân viên chi tiền tại quầy.
- * - Hạn nhận tiền mặt là 30 ngày; quá hạn hệ thống tự động tịch thu (FORFEITED).
+ * - Khách chọn nhận tiền hoàn bằng tiền mặt khi huỷ đơn, trả kho hoặc kết thúc do sự cố.
+ * - D66 (18/11): mỗi cơ sở 1 nhân viên nên không còn bước duyệt & giao nhân viên. Khi khách đến nhận đủ tiền,
+ * quản lý bấm "Xác nhận đã trả tiền mặt" (Figma M-ĐS-CHỐT · tiền mặt). Không nhập mã giao dịch.
+ * - Hạn nhận tiền mặt 30 ngày; quá hạn khách mất khoản hoàn (FORFEITED). Nhân viên gọi nhắc ở ngày 10, 20, 25.
*/
import React, { useState } from "react";
-import { Button, Field, Modal, Notice, PageHeader, Tag } from "../../../shared/components/UI.jsx";
-import { Select } from "../../../shared/components/Pickers.jsx";
+import { Button, DetailList, Modal, Notice, PageHeader, Tag } from "../../../shared/components/UI.jsx";
import { money } from "../../../shared/utils/format.js";
import { useOps } from "../../facility-operations/state/FacilityOperationsProvider.jsx";
import { RecordCard, WorkflowEmpty, WorkflowState } from "../../facility-operations/workflows/WorkflowComponents.jsx";
import { useOpsEndpoint } from "../../facility-operations/workflows/useOpsEndpoint.js";
import { CASH_SOURCE, CASH_STATUS, cashPath } from "../../facility-operations/workflows/cashRefundModel.js";
-// D42/D44 · Quản lý duyệt chi tiền mặt và giao nhân viên. Không đổi được cách nhận hoàn khách đã chọn.
+const OPEN = ["WAITING_APPROVAL", "READY", "REMIND", "APPOINTMENT"];
+// Máy chủ vẫn nhận bốn mục đối chiếu; quản lý xác nhận một lần thay cho các mục này.
+const CONFIRM_ALL = { identityChecked: true, codeChecked: true, amountCounted: true, signed: true };
+
/**
- * Màn hình quản lý cơ sở phê duyệt yêu cầu chi tiền mặt hoàn cọc hoặc hoàn tiền hủy đơn.
+ * Màn hình quản lý cơ sở xác nhận đã trả tiền mặt cho khách tại quầy.
*/
export function CashRefundApprovalPage({ embedded = false } = {}) {
- const { ops, reload: reloadOps } = useOps() || {};
+ const { reload: reloadOps } = useOps() || {};
const load = useOpsEndpoint("/api/ops/cash-refunds");
- const [approve, setApprove] = useState(null), [error, setError] = useState("");
+ const [paying, setPaying] = useState(null), [error, setError] = useState("");
const items = Array.isArray(load.data) ? load.data : [];
+ const close = () => { setPaying(null); setError(""); };
const save = async () => {
- if (!approve.staffId) return setError("Chọn nhân viên chi tiền.");
- const res = await load.post(cashPath(approve.item.id, "approve"), { staffId: approve.staffId });
- if (!res.ok) return setError(res.error);
- setApprove(null); setError("");
+ const res = await load.post(cashPath(paying.id, "pay"), CONFIRM_ALL);
+ if (!res.ok) return setError(res.error || "Chưa ghi nhận được. Tải lại trước khi thử tiếp; không trả tiền lần nữa.");
+ close();
await reloadOps?.();
};
const Wrap = embedded ? "section" : "main";
return
- {embedded ?
})}
{!refunds.length && Chưa có đơn huỷ cần hoàn tiền.}
{!embedded && Về Hoàn tiền}
- {detail && setDetail(null)}>
{detail.status === "PENDING" ? "Khoản hoàn đang chờ thực hiện; kiểm tra giao dịch trước khi xác nhận." : detail.status==="PAID"?`Đã ghi nhận hoàn tiền${detail.transaction_ref ? ` · ${detail.transaction_ref}` : ""}.`:"Chưa rõ trạng thái chuyển tiền."}
}
+ {detail && setDetail(null)}>
{detail.status === "PENDING" ? "Khoản hoàn đang chờ thực hiện; kiểm tra giao dịch trước khi xác nhận." : detail.status==="PAID"?"Đã ghi nhận hoàn tiền.":"Chưa rõ trạng thái chuyển tiền."}
}
{open && setOpen(null)} onDone={result => { setOpen(null); setConfirmed(result); }} />}
;
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx
index 9e50245..33a93b0 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx
@@ -7,7 +7,7 @@
* - Tuyệt đối không tạo nợ âm vượt quá tiền cọc đang giữ; tạo lệnh thanh toán REFUND cho số tiền còn lại.
*/
import React,{useState} from "react";
-import { Button, DetailList, Empty, Field, LinkButton, Notice, PageHeader, Tag } from "../../../shared/components/UI.jsx";
+import { Button, DetailList, Empty, LinkButton, Notice, PageHeader, Tag } from "../../../shared/components/UI.jsx";
import { useWorkflowData } from "../../facility-operations/workflows/useWorkflowData.js";
import { useWorkflowChange, WorkflowState } from "../../facility-operations/workflows/WorkflowComponents.jsx";
import { useOps } from "../../facility-operations/state/FacilityOperationsProvider.jsx";
@@ -15,144 +15,48 @@ import { isCashRefund, transferProof, knownMoney } from "../../facility-operatio
import { SettlementTable } from "../../facility-operations/settlements/SettlementComponents.jsx";
import { settlementFromRefund } from "../../facility-operations/settlements/settlementModel.js";
import { amountLabel,timeLabel } from "../../facility-operations/damage/DamageComponents.jsx";
-import { vnDateTimeInput } from "../../facility-operations/damage/damageModel.js";
import "../../../shared/styles/customer-detail.css";
import { go, qs } from "../../../app/router.js";
+// D64 (18/11, Figma M-ĐS-CHỐT): quản lý thấy thông tin nhận hoàn khách đã điền và chỉ bấm xác nhận;
+// không nhập mã giao dịch hay thời gian chuyển (máy chủ ghi thời điểm xác nhận).
function TransferForm({item,load,ask}) {
- const hasBank = Boolean(item.bankName && item.bankName !== "CASH" && item.accountNumber);
const method = (item.method === "CASH" || item.bankName === "CASH") ? "CASH" : "BANK_TRANSFER";
- const [ref, setRef] = useState(() => item.transactionRef || "");
- const [at, setAt] = useState(() => vnDateTimeInput());
- const [confirmed, setConfirmed] = useState(false);
- const [error, setError] = useState("");
-
const isCash = method === "CASH";
- const payload = {
- id: item.id,
- transactionRef: ref,
- transferredAt: at,
- confirmed,
- expectedVersion: item.version,
- method
- };
+ const [error, setError] = useState("");
+ const payload = { id: item.id, confirmed: true, expectedVersion: item.version, method };
const disabled = load.busy || load.needsRefresh;
let valid = false;
- try {
- transferProof(item, payload);
- valid = true;
- } catch {}
-
+ try { transferProof(item, payload); valid = true; } catch {}
+ const rows = isCash
+ ? [["Khách chọn nhận", "Tiền mặt tại quầy"], ["Người nhận", item.customer || item.accountHolder || "Chưa có dữ liệu"], ["Số tiền cần trả", amountLabel(item.amount)]]
+ : [["Khách chọn nhận", "Chuyển khoản"], ["Ngân hàng", item.bankName || "Chưa có dữ liệu"], ["Số tài khoản", item.accountNumber || "Chưa có dữ liệu"],
+ ["Chủ tài khoản", item.accountHolder || "Chưa có dữ liệu"], ["Số tiền cần chuyển", amountLabel(item.amount)]];
+ const submit = (e) => {
+ e.preventDefault();
+ if (disabled) return;
+ try { transferProof(item, payload); } catch (err) { return setError(err.message); }
+ setError("");
+ ask("CONFIRM_DEPOSIT_REFUND", payload,
+ isCash ? `Xác nhận đã trả ${amountLabel(item.amount)} tiền mặt?` : `Xác nhận đã chuyển ${amountLabel(item.amount)}?`,
+ isCash ? "Chỉ xác nhận khi khách đã nhận đủ tiền tại quầy. Không cần nhập mã giao dịch."
+ : `Kiểm tra đã chuyển đúng số tiền vào ${item.bankName || "tài khoản"} · ${item.accountNumber || ""} · ${item.accountHolder || ""}. Không cần nhập mã giao dịch.`,
+ { confirmLabel: isCash ? "Đã trả tiền mặt" : "Đã chuyển khoản",
+ successTitle: `Đã hoàn tiền ${amountLabel(item.amount)}`,
+ failTitle: isCash ? "Chưa ghi nhận được trả tiền mặt" : "Chưa ghi nhận được chuyển khoản",
+ doneLabel: "Về hợp đồng & quá hạn", onDone: () => go("manager/contracts") });
+ };
return (
-
);
@@ -164,8 +68,8 @@ export function DepositRefundPage({query=new URLSearchParams(),embedded=false})
const base=useWorkflowData("depositRefunds"),{ops,source,run,saving,needsRefresh}=useOps(),[selected,setSelected]=useState(query.get("id")||"");
const load=source==="local"?{...base,data:ops.deposit_refunds||[],loading:false,error:"",busy:saving,needsRefresh,demo:true,run:(action,payload)=>run(action,payload)}:base;
const [dialog,ask]=useWorkflowChange(load),item=load.data?.find(r=>r.id===selected);
- // D42/D47: hoàn cọc tiền mặt nằm ở mục "Hoàn tiền mặt tại quầy" (quản lý duyệt & giao, nhân viên chi) — không lặp ở đây.
+ // D42/D47/D66: hoàn cọc tiền mặt nằm ở mục "Hoàn tiền mặt tại quầy" (quản lý xác nhận đã trả) — không lặp ở đây.
const transfers=(load.data||[]).filter(r=>!isCashRefund(r));
const Wrap=embedded?"section":"main";
- return {embedded?
{item?`Hoàn cọc ${item.contractId} · ${item.customer}`:"Hoàn cọc sau trả kho"}
:<>
SafeSpace / Quản lý cơ sở / Hoàn tiền
>}{!selected?
{transfers.map(r=>
{r.customer} · Kho {r.unit}
{r.contractId} · {amountLabel(r.amount)}
{r.status==="PAID"?"Đã hoàn":r.status==="PENDING"?"Chờ hoàn":r.status==="NO_REFUND"?"Không còn khoản hoàn":"Chưa rõ trạng thái"}
)}{!transfers.length&&}
:!item?:<>
{item.status==="PENDING"&&knownMoney(item.amount)&&item.amount>0&&isCashRefund(item)?Khách chọn nhận tiền mặt tại quầy. Duyệt và giao nhân viên chi ở mục Hoàn tiền mặt tại quầy; nhân viên xác nhận khi đã chi cho khách. Mở Hoàn tiền mặt tại quầy:item.status==="PENDING"&&knownMoney(item.amount)&&item.amount>0?:{item.status==="PAID"?`Đã ghi nhận ${item.method==="CASH"?"chi tiền mặt":"chuyển tiền"} lúc ${timeLabel(item.paidAt)}.`:knownMoney(item.amount)&&item.amount===0?"Không còn khoản hoàn; không tạo giao dịch chuyển tiền.":"Chưa có đủ dữ liệu khoản hoàn để thao tác."}}
>}{dialog};
+ return {embedded?
{item?`Hoàn cọc ${item.contractId} · ${item.customer}`:"Hoàn cọc sau trả kho"}
:<>
SafeSpace / Quản lý cơ sở / Hoàn tiền
>}{!selected?
{transfers.map(r=>
{r.customer} · Kho {r.unit}
{r.contractId} · {amountLabel(r.amount)}
{r.status==="PAID"?"Đã hoàn":r.status==="PENDING"?"Chờ hoàn":r.status==="NO_REFUND"?"Không còn khoản hoàn":"Chưa rõ trạng thái"}
)}{!transfers.length&&}
:!item?:<>
{item.status==="PENDING"&&knownMoney(item.amount)&&item.amount>0&&isCashRefund(item)?Khách chọn nhận tiền mặt tại quầy. Khi khách đến nhận đủ tiền, xác nhận ở mục Hoàn tiền mặt tại quầy. Mở Hoàn tiền mặt tại quầy:item.status==="PENDING"&&knownMoney(item.amount)&&item.amount>0?:{item.status==="PAID"?`Đã ghi nhận ${item.method==="CASH"?"chi tiền mặt":"chuyển tiền"} lúc ${timeLabel(item.paidAt)}.`:knownMoney(item.amount)&&item.amount===0?"Không còn khoản hoàn; không tạo giao dịch chuyển tiền.":"Chưa có đủ dữ liệu khoản hoàn để thao tác."}}
>}{dialog};
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/overdue/OverdueRemovalPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/overdue/OverdueRemovalPage.jsx
index a8c1c76..adf6f2d 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/overdue/OverdueRemovalPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/overdue/OverdueRemovalPage.jsx
@@ -38,7 +38,7 @@ export function OverdueRemovalPage() {
{ confirmLabel: "Lưu biên bản", successTitle: "Đã lưu biên bản xử lý đồ", failTitle: "Chưa lưu được biên bản", doneLabel: "Về công việc trong ngày", onDone: () => go("staff") });
};
return
- {(load.data || []).map(item => open(item)}>{selected === item.id ? "Thu gọn" : item.record ? "Xem biên bản" : "Lập biên bản"}}>
+ {(load.data || []).map(item => open(item)}>{selected === item.id ? "Thu gọn" : item.record ? "Xem biên bản" : "Lập biên bản"}}>
{selected === item.id && (item.record
?
: )}
- )}{!load.data?.length && !load.error && Về công việc trong ngày}
+ )}{!load.data?.length && !load.error && Về công việc trong ngày}
{dialog};
}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/payments/CashRefundCounterPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/payments/CashRefundCounterPage.jsx
index a92c646..802e00b 100644
--- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/payments/CashRefundCounterPage.jsx
+++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/staff/payments/CashRefundCounterPage.jsx
@@ -16,7 +16,6 @@ import { RecordCard, WorkflowEmpty, WorkflowState } from "../../facility-operati
import { useOpsEndpoint } from "../../facility-operations/workflows/useOpsEndpoint.js";
import { useOps } from "../../facility-operations/state/FacilityOperationsProvider.jsx";
import { CASH_STATUS, CASH_SOURCE, cashPath } from "../../facility-operations/workflows/cashRefundModel.js";
-import { useMe } from "../hooks/useStaffIdentity.js";
const CALL_RESULTS = {
APPOINTMENT: "Khách hẹn đến quầy · ghi ngày hẹn",
@@ -24,27 +23,17 @@ const CALL_RESULTS = {
SWITCH_TO_BANK: "Khách muốn đổi sang chuyển khoản",
WRONG_NUMBER: "Sai số điện thoại · báo quản lý",
};
-const PAY_CHECKS = [
- ["identityChecked", "CCCD trùng tên trên hợp đồng"],
- ["codeChecked", "Khách đọc đúng mã đơn và số điện thoại"],
- ["amountCounted", "Đã đếm đủ tiền trước mặt khách"],
- ["signed", "Khách đã nhận tiền và ký sổ chi tại quầy"],
-];
-// Figma S10 / S10b · D42/D44: nhân viên gọi nhắc (ngày 10, 20, 25) và chi tiền hoàn tại quầy sau khi quản lý duyệt.
+// Figma S10b · D42/D44/D66: nhân viên chỉ gọi nhắc khách (ngày 10, 20, 25); quản lý xác nhận đã trả tiền mặt.
/**
* Màn hình nhân viên thực hiện chi trả tiền mặt cho khách hàng tại cơ sở.
*/
export function CashRefundCounterPage() {
const { reload: reloadOps } = useOps() || {};
const load = useOpsEndpoint("/api/ops/cash-refunds");
- const me = useMe();
- const [call, setCall] = useState(null), [pay, setPay] = useState(null), [error, setError] = useState("");
- const items = (Array.isArray(load.data) ? load.data : []).filter(r =>
- ["READY", "REMIND", "APPOINTMENT"].includes(r.status) &&
- (!r.staffId && !r.staff_id || !me?.staff_id || (r.staffId || r.staff_id) === me.staff_id)
- );
- const close = () => { setCall(null); setPay(null); setError(""); };
+ const [call, setCall] = useState(null), [error, setError] = useState("");
+ const items = (Array.isArray(load.data) ? load.data : []).filter(r => ["WAITING_APPROVAL", "READY", "REMIND", "APPOINTMENT"].includes(r.status));
+ const close = () => { setCall(null); setError(""); };
const saveCall = async () => {
if (call.result === "APPOINTMENT" && !call.appointmentDate) return setError("Chọn ngày khách hẹn đến quầy.");
const deadline = String(call.item?.deadlineDate || "").slice(0, 10);
@@ -52,28 +41,18 @@ export function CashRefundCounterPage() {
const res = await load.post(cashPath(call.item.id, "calls"), { result: call.result, appointmentDate: call.result === "APPOINTMENT" ? call.appointmentDate : null, note: call.note.trim() || null });
if (res.ok) { close(); await reloadOps?.(); } else setError(res.error);
};
- const savePay = async () => {
- if (PAY_CHECKS.some(([k]) => !pay[k])) return setError("Tick đủ 4 mục trước khi xác nhận đã chi.");
- const { item, ...checks } = pay;
- const res = await load.post(cashPath(item.id, "pay"), checks);
- if (res.ok) { close(); await reloadOps?.(); } else setError(res.error);
- };
return
-
+
{items.map(r => {
- const staffCode = r.staffId || r.staff_id;
- const staffName = r.staffName || r.staff_name;
- const isOther = staffCode && me?.staff_id && staffCode !== me.staff_id;
return Đã giao cho {staffName || staffCode} : <>
- >}>
+ actions={}>
{money(r.amount)}
-
Hạn nhận {r.deadlineDate ? vnDate(r.deadlineDate) : "Chưa có thông tin"}{staffName ? ` · nhân viên: ${staffName}` : staffCode ? ` · nhân viên: ${staffCode}` : ""}{r.daysSinceApproved != null ? ` · ngày ${r.daysSinceApproved} sau khi duyệt` : ""}{r.appointmentDate ? ` · khách hẹn ${r.appointmentDate}` : ""}{r.lastCall ? ` · lần gọi trước: ${r.lastCall}` : ""}
+
Hạn nhận {r.deadlineDate ? vnDate(r.deadlineDate) : "Chưa có thông tin"}{r.daysSinceApproved != null ? ` · ngày ${r.daysSinceApproved} kể từ khi chốt hoàn` : ""}{r.appointmentDate ? ` · khách hẹn ${r.appointmentDate}` : ""}{r.lastCall ? ` · lần gọi trước: ${r.lastCall}` : ""}