Commit Graph

171 Commits

Author SHA1 Message Date
Ho Ngoc Hai
90debb3e94 fix(superadmin): resolve merchant admin query EF Core translation errors
- Fix IsDeleted/CreatedAt/BusinessName private field access in LINQ queries
  using EF.Property<T>() instead of public computed properties (which are
  Ignored in EF config due to DDD pattern)
- Fix Shop.MerchantId private field in GroupBy shop count query
- Split merchant list query into 2 steps (fetch + batch shop counts)
  to avoid untranslatable subquery in Join+Select
- Fix BFF SuperAdminController: remove duplicate auth header setting
  (AuthForwardingHandler already reads bff_session cookie)
- Fix frontend DTO field names to match API response (ShopsCount, Type)
- Fix frontend response format handling for direct {items} without {data} wrapper

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 23:39:26 +07:00
Ho Ngoc Hai
89cf4e8879 feat(superadmin): implement full Super Admin platform management panel
Add complete Super Admin panel with 10 pages for platform-level management:
- Dashboard with KPI cards, system health monitoring, subscription plans
- Merchant management with list/detail/approve/suspend/reactivate
- Subscription plan management (Starter/Growth/Pro/Enterprise)
- User management with role assignment
- Role overview across platform
- Real-time system health for 11 microservices
- Feature flags with toggle and rollout percentage
- Audit log from IAM service
- Platform settings and infrastructure overview
- Blue theme (#1E40AF) to distinguish from merchant admin (orange)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 22:46:47 +07:00
Ho Ngoc Hai
04738248f2 rebrand: rename GoodGo → aPOS across all UI and display text
Replaced all user-facing "GoodGo" brand references with "aPOS"
across 35 files (53 occurrences):
- Layout headers: "aPOS Admin", "aPOS POS"
- Page titles: "— aPOS Admin", "— aPOS POS"
- Locale files: brand name keys
- Onboarding: welcome text, descriptions
- AI Chat: system prompt, provider headers
- Auth pages: login titles

Note: Internal namespace GoodGo.BlazorUi.Components.* preserved
(assembly reference, not user-facing brand text).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 21:25:19 +07:00
Ho Ngoc Hai
dae8aef31f feat(settings): add AI Assistant configuration panel
ShopSettings.razor: new "AI Assistant" section with:
- Enable/disable toggle
- Provider dropdown (OpenAI / OpenRouter / Claude)
- Model input with per-provider placeholder
- API Key input (password with show/hide toggle)
- Per-provider hint text for getting API keys
- System Prompt textarea (optional, default used if empty)
- Save button with success/error feedback
- Config loads on init, saves via BFF PUT /api/bff/ai/config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:12:11 +07:00
Ho Ngoc Hai
b589752b51 feat(ai-chat): implement AI Chat Assistant with MCP tool integration
Full-stack AI Chat feature for shop management:

Backend (BFF Server - 6 new files):
- IAiChatProvider: provider interface + shared DTOs for messages/tools
- OpenAiChatProvider: handles OpenAI + OpenRouter APIs (function calling)
- ClaudeChatProvider: handles Anthropic Claude Messages API (tool_use)
- McpToolRegistry: 12 MCP tool definitions as LLM function schemas
  (list_products, check_inventory, popular_items, etc.)
- McpToolExecutor: routes tool calls to microservices via named HttpClients
- AiChatController: POST /api/bff/ai/chat with tool execution loop
  (max 5 iterations), GET/PUT /api/bff/ai/config for settings
- Supports 3 providers: OpenAI, OpenRouter, Claude (Anthropic)
- API keys server-side only, in-memory config store (v1)

Frontend (Blazor WASM - 1 new + 6 modified):
- ShopAiChat.razor: chat UI with message bubbles, suggested prompts,
  tool usage badges, typing indicator, Enter key support
- ShopSidebarConfig: added "AI Assistant" menu item (bot icon)
- ShopPage: added "ai-chat" route case
- PosDataService: AI chat DTOs + SendAiChatAsync/GetConfig/UpdateConfig
- Locale files: added Shop_Menu_AiChat key (vi-VN + en-US)
- Program.cs: registered McpToolExecutor + LLM provider HttpClients

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:54:40 +07:00
Ho Ngoc Hai
65c80c9fb1 refactor(pos): move nav from horizontal bottom bar to vertical right sidebar
- CSS: pos-bottom-nav changed from flex row (height:52px, bottom bar)
  to flex column (width:64px, right sidebar) with vertical tab layout
- Active tab indicator: top horizontal bar → left vertical bar
- Tab hover: subtle background highlight
- CafeDesktop.razor: wrap content + nav in flex row container
- Mobile responsive: compact 52px width on small screens

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:25:16 +07:00
Ho Ngoc Hai
9f52c27f56 fix(pos-dashboard): show payment method names instead of order status
GetPosDashboardQuery payment breakdown SQL was grouping by
order_statuses.name (e.g. "Completed") instead of orders.payment_method
(e.g. "cash", "card", "qr", "transfer").

Fix: GROUP BY o.payment_method with COALESCE for empty values.
Frontend: apply MapPaymentMethodLabel() to translate method names
to Vietnamese (Tiền mặt, Thẻ, Mã QR, Chuyển khoản).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:08:50 +07:00
Ho Ngoc Hai
bd3a23b03d fix(pos): add Lucide icon re-init observer for Blazor WASM compatibility
Lucide JS replaces <i data-lucide> elements with <svg>, breaking
Blazor WASM's DOM diffing algorithm (removeChild null error).
Added MutationObserver that safely re-initializes Lucide icons
after Blazor renders, and dismiss handler for error banner.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 10:17:16 +07:00
Ho Ngoc Hai
6bdf0390ba fix(pos): pass selected payment method to PayOrderAsync
CafeDesktop.ConfirmPayment() was calling PayOrderAsync without
_selectedMethod, defaulting to "cash" regardless of user selection.
Now passes _selectedMethod (cash/card/qr/transfer) correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 10:04:28 +07:00
Ho Ngoc Hai
c708bda364 fix(ui): translate order status and payment method to Vietnamese
- ShopHelpers: add OrderStatusLabel(), OrderStatusBadge(),
  PaymentMethodLabel() — translate raw status/method strings
  to Vietnamese with correct badge colors
- ShopFinance.razor: "Validated" → "Chờ thanh toán" (yellow badge)
- ShopOverview.razor: same status translation
- ShopReports.razor: same status translation
- CafeDesktop.razor: update MapApiStatus() to include
  Draft/Validated/Paid/PaymentPending mappings;
  update MapPaymentMethodLabel() to include qr→"Mã QR",
  transfer→"Chuyển khoản", vnpay/momo, empty→"Chưa thanh toán"

4 payment methods supported: Tiền mặt, Thẻ, Mã QR, Chuyển khoản

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 09:56:14 +07:00
Ho Ngoc Hai
4849b7b6fc feat(permissions): implement full-stack role permission management
Backend (IAM Service):
- New GetRolePermissionsQuery + Handler: reads permissions from role_claims
- New UpdateRolePermissionsCommand + Handler: validates permission names
  against StaffPermissions enum, replaces role_claims, blocks system roles
- New endpoints: GET/PUT /api/v1/roles/{id}/permissions
- GetRolesQuery: batch-fetch permissions per role via role_claims join
- RoleResponse: add Permissions field to API response
- Seeded role_claims for Admin (7), Merchant (7), MerchantAdmin (6),
  MerchantStaff (2), SuperAdmin (All), Support (2)

Frontend (Blazor WASM):
- IamApiService: add Permissions to RoleDto, UpdateRolePermissionsAsync()
- RolePermissions.razor: replace hardcoded GetPermissionsForRole() with
  API-driven permission toggles from role_claims data
- Editable toggles for non-system roles, disabled for system roles
- Save/Cancel buttons appear when permissions modified
- 7 permission types matching StaffPermissions enum

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:50:06 +07:00
Ho Ngoc Hai
52f77c0878 fix(roles): replace hardcoded permission toggles with real role-based permissions
- Remove placeholder _defaultPermissions (same 5 toggles for every role)
- Add GetPermissionsForRole() mapping each role to its actual backend
  authorization capabilities:
  - SuperAdmin: full platform access (6 permissions)
  - Admin: user/shop/report/audit management (5 permissions)
  - Merchant: full shop owner access (6 permissions)
  - MerchantAdmin: shop admin without settings (6 permissions)
  - MerchantStaff: POS + payment only (6 permissions, 4 disabled)
  - Support: read-only system access (5 permissions)
  - PremiumUser/User: customer-level access (4-5 permissions)
- Toggles are now read-only (disabled) reflecting enforced policies
- No conflict between system roles and shop roles confirmed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:08:25 +07:00
Ho Ngoc Hai
f3217ab270 fix(dashboard): use ShopVerticalHelper for case-insensitive status checks
- Replace hardcoded s.Status == "active" with ShopVerticalHelper.IsActive()
  (handles "Active", "Published", "active" etc.)
- Replace shop.Status != "active" with ShopVerticalHelper.IsSetup()
  to correctly show "Hoàn thành thiết lập" only for Draft shops
- KPIs and shop card badges now reflect actual shop status correctly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:44:06 +07:00
Ho Ngoc Hai
43d334ca7d feat(auth): add YARP auth forwarding and dashboard search filtering
- Add YARP proxy middleware to attach Bearer token from bff_session
  cookie to all YARP-proxied requests (users, roles, audit pages)
- Dashboard search: bind input with oninput and filter shops by
  name/slug/category client-side via FilteredShops property

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 16:47:28 +07:00
Ho Ngoc Hai
6fbc475fdd fix(ui): fix vertical/status labels and add shop activation button
- ShopVerticalHelper.GetLabel: return Vietnamese text directly instead of
  localization keys (Vertical_Cafe → Café, etc.)
- ShopVerticalHelper.GetStatusLabel: return Vietnamese text directly
  (Status_Setup → Thiết lập, Status_Active → Đang mở, etc.)
- ShopSettings: add "Kích hoạt cửa hàng" section with publish button
  when shop is in Draft status, with setup checklist indicators
- ShopPage: pass ShopStatus parameter to ShopSettings component

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:35:38 +07:00
Ho Ngoc Hai
6a9aa0d46f fix(overview): load all orders and add date range selector to shop overview
- Change orders fetch from "today" filter to "all" so KPIs show actual data
- Add date range presets (Hôm nay / 7 ngày / 30 ngày / Tất cả)
- Add weekly period tab to revenue chart
- Display filtered recent orders based on selected period

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:27:46 +07:00
Ho Ngoc Hai
af1b1fb101 feat: Implement date range filtering, CSV export, and enhanced revenue report display in shop reports. 2026-03-25 15:20:56 +07:00
Ho Ngoc Hai
36a0a9c256 feat: Add functional tests for MktZaloService, new contract and load tests, and audit documentation, while removing a legacy infrastructure project and updating service configurations. 2026-03-25 15:00:05 +07:00
Ho Ngoc Hai
7a752f4a82 fix(qa): resolve build failures and test issues found in QA verification
- packages/logger: upgrade tsconfig target to ES2022 to support Array.at()
- packages/http-client: exclude test files from tsc build to prevent noUnusedLocals errors
- packages/http-client/test: use vi.hoisted() for mock functions (vi.mock hoisting fix)
- services/goodgo-mcp-server/tests: use vi.hoisted() for all 4 test files (catalog, inventory, analytics, recipe)
- web-client-tpos: remove stale @using WebClientTpos.Client.Components.Auth from 10 auth pages (moved to blazor-ui RCL)
- web-client-tpos: remove AttachToken() calls in PosDataService (auth via BFF httpOnly cookie)
- web-client-tpos: fix IamApiService.SetAuthHeader() and MerchantApiService.AttachTokenAsync() — make no-op, remove _auth dependency
- web-client-tpos: fix Profile.razor — remove AttachToken() method and calls
- web-client-tpos: fix OnboardingReady.razor — escape @keyframes → @@keyframes in Razor style block
- web-client-tpos: fix PosDataService.GetListFromApiAsync() — check array before property lookup to fix plain array deserialization
- web-client-tpos/tests: update AuthStateServiceTests to new AuthStateService.Login(email, role) signature (no token param)
- web-client-tpos/tests: update PosDataServiceTests to new PosDataService(http) constructor (no authState param)

All 113 Node.js tests pass. All 30 .NET component tests pass. All .NET builds succeed.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-23 12:07:58 +07:00
Ho Ngoc Hai
a8edfd1597 fix(p2): Wave 3 — fix 4 P2 backend architecture issues (TEC-261)
BACK-I-01: Add CI steps to generate openapi.yaml for all 24 .NET services
- Add .config/dotnet-tools.json with swashbuckle.aspnetcore.cli 7.2.0
- Add scripts/ci/generate-openapi.sh reusable script
- Update all 24 service CI workflows with dotnet tool restore + swagger tofile + artifact upload

BACK-I-02: Add OpenTelemetry Metrics + Prometheus /metrics to _template_dot_net
- Add OTel packages (Extensions.Hosting, Instrumentation.AspNetCore, Runtime, Prometheus)
- Register AddOpenTelemetry().WithMetrics() with ASPNetCore + Runtime instrumentation
- Map MapPrometheusScrapingEndpoint("/metrics") in middleware pipeline

BACK-W-01: Remove IHttpContextAccessor from all 18 handler files in merchant-service-net
- Create MerchantBaseController abstract base with GetCurrentUserId() helper
- Add Guid UserId to 11 Commands and 7 Queries
- Remove IHttpContextAccessor injection from all handlers, use request.UserId instead
- Update 7 controllers to inherit MerchantBaseController and extract userId from JWT claims
- Remove AddHttpContextAccessor() registration from Program.cs

BACK-W-03: Add explicit commandTimeout:5 to all Dapper queries in order-service-net
- 14 files updated: QueryAsync, ExecuteScalarAsync, QueryFirstOrDefaultAsync all get commandTimeout: 5

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-23 10:09:45 +07:00
Ho Ngoc Hai
90434acbde fix(security): Wave 2 — fix 8 P1 frontend security & reliability issues
SEC-W-11: Remove hardcoded OAuth2 client_id/client_secret from Blazor WASM.
  - Create BffAuthController (POST /api/bff/auth/login|logout, GET /api/bff/auth/session)
  - BFF exchanges credentials with IS4 using server-side config (IdentityServer:ClientId/Secret)
  - Add IdentityServer config block to appsettings.json / appsettings.Development.json

SEC-W-12: Migrate password grant — token exchange now happens server-side in BFF, not WASM.
  - AuthService.LoginAsync() POSTs to /api/bff/auth/login (no IS4 call from WASM)

SEC-W-01: JWT in localStorage — migrate to httpOnly SameSite=Strict BFF session cookie.
  - BffAuthController sets cookie on login, clears on logout
  - AuthStateService no longer stores raw token (Token property removed)
  - AuthService only stores non-sensitive metadata (email, role) in localStorage
  - TryRestoreSessionAsync now calls GET /api/bff/auth/session instead of localStorage
  - AuthForwardingHandler reads token from bff_session cookie (legacy header fallback kept)

FRONT-W-01: Token refresh not implemented — add TokenExpiry tracking + proactive refresh timer.
  - AuthStateService: add TokenExpiry, OnTokenExpiring event, IDisposable Timer
  - Login() schedules a Timer that fires OnTokenExpiring 2 min before expiry

FRONT-W-02: DefaultRequestHeaders race condition — use per-request HttpRequestMessage.
  - PosDataService: remove AttachToken() (mutated shared DefaultRequestHeaders)
  - All HTTP helpers (PostAsync, PutAsync, PostAndGetAsync, GetListFromApiAsync,
    GetObjectFromApiAsync) now use HttpRequestMessage per-request
  - Auth handled automatically by browser cookie (same-origin, httpOnly BFF cookie)

FRONT-C-04: No route guard on AdminLayout — add auth redirect.
  - AdminLayout.OnAfterRenderAsync: after TryRestoreSessionAsync, redirect to /auth/login
    if still unauthenticated (with returnUrl param)

FRONT-C-05: shopId not validated against user permissions — add BFF verification.
  - AdminLayout: call PosData.GetShopByIdAsync(shopId) after detecting shop context
  - Redirect to /admin if BFF returns null (403/404 = no access, prevents IDOR)
  - Populate _shopName/_shopCategory from verified backend data (not just URL)

SEC-W-13: No CDN SRI for Lucide icons — add integrity hash + crossorigin attribute.
  - index.html: add integrity="sha256-NBFpKCDLjUdUP2lJaqJf1gOjWPRJgEb0HFCKWjNCIQ4="
    crossorigin="anonymous" to lucide@0.468.0 script tag

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-23 09:57:11 +07:00
Ho Ngoc Hai
af0461f233 fix(frontend): resolve 4 P2 architecture issues (Wave 3)
FRONT-I-01: Extract Auth components to Razor Class Library packages/blazor-ui/
- Created GoodGo.BlazorUi RCL (net10.0, MudBlazor 8.15) at packages/blazor-ui/
- Moved AuthButton, AuthCard, AuthInput, OtpInput, BrandPanel, SocialLogin, LanguageSwitcher
- Referenced RCL from WebClientTpos.Client via ProjectReference
- Added GoodGo.BlazorUi.Components.Auth/Common namespaces to _Imports.razor

FRONT-I-02: Add ARIA/accessibility attributes (WCAG 2.1 AA)
- AuthButton: aria-label, aria-busy, aria-disabled, aria-hidden on decorative icons
- OtpInput: role=group, aria-label per digit, autocomplete=one-time-code
- PosLayout: aria-expanded + aria-controls on sidebar/order toggles, aria-label on all icon buttons

FRONT-I-03: Implement Style Dictionary design token pipeline
- Created packages/design-tokens/ with token JSON (color, spacing, typography, border)
- Style Dictionary config outputs: CSS custom properties → wwwroot/css/tokens.generated.css
- Second output: C# constants → packages/blazor-ui/DesignTokens/DesignTokens.g.cs
- Added tokens:build script to root package.json
- Added tokens.generated.css link to index.html (before app.css for cascade correctness)

FRONT-I-04: Replace eval() in OtpInput with safe JS interop
- Created wwwroot/js/otp-input.js with window.focusOtpInput(index) helper
- Replaced JS.InvokeVoidAsync("eval", ...) with JS.InvokeVoidAsync("focusOtpInput", index)
- Eliminates CSP-violating eval(), improves security and debuggability

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-23 09:50:13 +07:00
Ho Ngoc Hai
d0211e5a3c docs: full documentation audit — update 7 files, create MCP SERVICE_DOCS
Project-level docs:
- README.md: rewrite with correct tech stack (.NET 10/Blazor, not Node.js/Flutter)
- ROADMAP.md: add MCP server, shop lifecycle, onboarding redesign, POS nav fix
- CLAUDE.md: add goodgo-mcp-server to project structure
- CTO_REPORT_SHOP_DELETE.md: status OPEN → RESOLVED (implemented in 6263eeb)

MCP Server docs:
- SERVICE_DOCS.md: new file — 12 tools reference, architecture, setup guide

Frontend docs:
- web-client-tpos-net README: fix wrong paths (web-client-base-net → web-client-tpos-net)
- web-client-tpos-net docs/en/README: same path fix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 16:46:15 +07:00
Ho Ngoc Hai
ca022de832 refactor: redesign onboarding wizard UI — inline step progress, improved layout
Redesign all 6 onboarding steps with inline step indicators replacing
the fixed sidebar layout. Simplified structure with admin-content/admin-panel
pattern for consistency with other admin pages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 16:42:10 +07:00
Ho Ngoc Hai
6263eeb05d feat: add shop lifecycle management UI — deactivate & close shop
- Add "Danger Zone" section to ShopSettings with deactivate/close actions
- CloseShopConfirmDialog: type shop name to confirm (GitHub-style)
- BFF: proxy endpoints POST /shops/{id}/deactivate and /close
- MerchantApiService: DeactivateShopAsync(), CloseShopAsync()
- CTO report documenting the gap and implementation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 07:35:30 +07:00
Ho Ngoc Hai
659e8e05e5 fix: POS settings button navigates by role — staff→/staff, admin→/admin
PosLayout.razor hardcoded navigation to /admin for the settings button
and sidebar link, causing staff users to land on the admin page.
Now uses AuthStateService.GetPortalUrl() for role-aware routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 07:24:08 +07:00
Ho Ngoc Hai
cb5bc95b8d fix: remove [Authorize] from BFF OrderController — BFF proxies don't configure auth schemes
BFF server forwards JWT via AuthForwardingHandler to downstream services.
Adding [Authorize] on BFF controllers causes "No authenticationScheme was specified"
error since the BFF server itself has no JWT middleware configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 22:02:24 +07:00
Ho Ngoc Hai
344be332d7 fix: resolve POS duplicate products + settings shop name display
P2: Products appeared 2x in POS grid — BFF now filters isActive=true
by default, plus client-side dedup by product ID as safety net.
P3: Admin Settings showed "--" for shop name — parent ShopPage now
passes ShopName and VerticalLabel parameters to ShopSettings component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 21:26:08 +07:00
Ho Ngoc Hai
fffedea785 fix: schedule pages — real API data, role display, time formatting
- Rewrite StaffSchedule.razor from hardcoded stub to real API integration
  (profile → shop schedules → filter by staffId)
- Fix admin ShopSchedule role column: use staff role from merchant data
  instead of showing "—"
- Add FormatTime() helper to strip seconds from time display (08:00:00 → 08:00)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:06:40 +07:00
Ho Ngoc Hai
deffb9de4a fix: resolve attendance staffName display and token conflict between staff/admin sessions
1. Attendance API now joins with MerchantStaff to return staffName instead of showing truncated staffId
2. AuthService uses role-suffixed localStorage keys (aPOS_token_owner, aPOS_token_staff) to prevent
   staff and admin tokens from overwriting each other on the same origin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 16:38:01 +07:00
Ho Ngoc Hai
ddd02be26e feat: Display attendance times in local timezone and calculate staff leave statistics from real data, removing stub notifications. 2026-03-13 16:23:00 +07:00
Ho Ngoc Hai
598193e6cb fix: wire up admin attendance page to real API, add BFF shop attendance endpoint
- BFF: add GET /api/bff/shops/{shopId}/attendance proxy to merchant-service
- ShopAttendance.razor: replace mock data with real attendance API call
- Calculate present/late/absent counts from actual attendance records

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 15:30:12 +07:00
Ho Ngoc Hai
8086bc627f fix: resolve HR module bugs — leave approval, staff auth timing, EF Core mapping
- BFF: extract approver/rejector userId from JWT instead of accepting Guid.Empty from client
- Staff pages (Dashboard, Leave, Attendance): move data loading to OnAfterRenderAsync
  to fix token timing bug where OnInitializedAsync runs before auth session is restored
- EF Core: fix AttendanceRepository to use public properties after HasField() migration
- LeaveRequest: fix DateTime UTC kind for Npgsql 10 compatibility
- merchant-service: add debug seed endpoints for staff/shop test data
- EF configs: migrate to HasField() pattern for private field mapping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 15:23:35 +07:00
Ho Ngoc Hai
aba5ee1162 fix: resolve inventory display bugs — transaction history & item type mapping
- Fix DTO field mismatch: QuantityChange→Quantity, Reason→Notes in PosDataService
- Fix ItemType enum mismatch: FinishedProduct→FinishedGood, Supply→Consumable in ShopInventory
- Add ResolveTransactionTypeName fallback in InventoryMapper when Type nav property is null
- Add "In"/"Out" alternative matches for TransactionType in history display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 13:54:44 +07:00
Ho Ngoc Hai
e4e7cca1ce fix: resolve Blazor compilation errors — RZ9986, RZ10010, CS0246
- StaffPerformance.razor: fix mixed C#/markup in Style attributes (RZ9986) using @($"...")
- AppointmentCalendar.razor: fix duplicate DateChanged parameter (RZ10010) using @bind-Date:after
- RetailDesktop.razor: add missing @using WebClientTpos.Client.Services (CS0246)
- ReturnDialog.razor: add missing @using WebClientTpos.Client.Services (CS0246)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:26:25 +07:00
Ho Ngoc Hai
76b5e6afd0 feat: Phase 2 close-out — multi-branch management, production K8s, revenue dashboard UI, responsive POS
Backend:
- Multi-branch shop management: SetDefaultShop, TransferShop commands, GetMerchantShops paginated query
- Shop aggregate: IsDefault field, SetAsDefault/ClearDefault/TransferOwnership behavior methods
- 2 new domain events: ShopSetAsDefaultDomainEvent, ShopTransferredDomainEvent

Frontend:
- Revenue Dashboard (MudChart line/donut/bar, 4 KPI cards, top products table)
- Staff Performance (sortable table, color-coded completion rates, CSV export)
- Customer QR Menu page (/menu/{ShopId}, mobile-first, Vietnamese labels)
- QR Code Generator admin page (batch generate, print-all, per-table QR)
- Responsive POS layout (collapsible sidebar, slide-out order drawer, touch-friendly CSS)
- ResponsiveOrderPanel component (desktop inline / tablet drawer / mobile overlay)

Infrastructure:
- Production K8s manifests: 8 services (3 replicas, 512Mi-1Gi, HPA min3/max10), Redis with persistence
- Production ingress: api.goodgo.vn, cert-manager TLS, rate-limit middleware
- Deploy script: pre-flight checks, dry-run, single-service deploy, rollback support
- CI/CD: deploy-production.yml with environment approval, commit SHA tags
- Prometheus full scrape config (11 targets), docker-compose observability stack
- Production deployment checklist (80+ items)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 19:58:40 +07:00
Ho Ngoc Hai
dc1ea7c0d2 feat: Phase 2 W7-8 production readiness — QR menu, analytics, E2E tests, observability
- Public QR menu: BFF proxy endpoints (no auth), PosDataService public methods
- Revenue analytics + staff performance: Dapper queries, validators, BFF proxy
- Playwright E2E tests: 8 spec files covering auth, admin, 5 POS verticals, reports
- Observability: Grafana dashboard (HTTP metrics, infra, business), Prometheus alert rules
- Fixes: validator frozen-date bug (Must vs LessThanOrEqualTo), PublicMenuController logging + CancellationToken

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 19:51:37 +07:00
Ho Ngoc Hai
870f1218f8 feat: Phase 2 frontend — Spa, Retail, Cafe Blazor UI pages and BFF proxies
Spa/Beauty UI (booking-service integration):
- TherapistManagement.razor: CRUD table, specialty multi-select, working hours
- AppointmentCalendar.razor: daily calendar grouped by therapist, color-coded statuses
- ShopTherapists embedded component for ShopPage, sidebar menu for spa/beauty
- BookingController BFF: therapist CRUD + appointment proxy endpoints
- Localization: vi-VN + en-US for "Nhân viên trị liệu"

Retail POS UI (catalog + inventory + order integration):
- RetailDesktop.razor: barcode input, API lookup, stock badges, cart warnings
- ReturnDialog.razor: order lookup, return/exchange mode toggle, refund summary
- StockOverview.razor: admin stock table, search/filter, threshold edit dialog
- PosDataService: barcode lookup, bulk stock, return/exchange API methods

Cafe UI (membership + fnb-engine integration):
- StampCard.razor: visual stamp grid, animated fill, celebration UI, claim/reset
- BaristaQueue.razor: 3-column Kanban, stats bar, auto-refresh 10s, pulse animation
- CafeController BFF: stamp cards + barista queue proxy endpoints

Infrastructure:
- Traefik: added /api/v1/therapists + /api/v1/appointments to booking-service
- ROADMAP: Phase 2 vertical tasks DONE, UI refinement IN-PROGRESS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 17:03:55 +07:00
Ho Ngoc Hai
a7a753bf38 feat: EOD reports, security audit (rate limiting + 44 validators), and 30 critical path tests
EOD Reports & Daily Close (order-service + Blazor UI):
- GetEodReportQuery: Dapper query for revenue, orders, payment breakdown, top items, hourly chart
- CloseDayCommand: check pending orders, generate final report
- EodReport.razor: 6 KPI cards, donut/bar charts, top 10 table, close-day dialog
- FluentValidation for both query and command
- BFF proxy endpoints for reports

Security Audit — Rate Limiting:
- Tighten auth-ratelimit from 100 to 10 req/min (brute force protection)
- Add payment-ratelimit (30/min), api-ratelimit (100/min), hub-ratelimit (500/min)
- Apply rate limits to ALL Traefik routers (previously many had none)

Security Audit — Input Sanitization (44 missing validators created):
- iam-service: 14 validators (auth, user, role commands)
- merchant-service: 11 validators (admin, attendance commands)
- wallet-service: 7 validators (wallet, points commands)
- fnb-engine: 7 validators (session, table, ticket, reservation)
- catalog-service: 6 validators (product, category CRUD)
- storage-service: 6 validators (upload, share, quota)
- order-service: 2 validators (complete order/payment)

Critical Path Unit Tests (30 new tests):
- inventory-service: 12 tests (deduction, partial stock, idempotency)
- wallet-service: 14 tests (create payment, process callback, domain events)
- fnb-engine: 8 tests (kitchen-served event handler, inventory client integration)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 16:33:39 +07:00
Ho Ngoc Hai
653322b26c fix: resolve 12 critical/high issues from code review across backend, frontend, and infra
Backend (7 fixes):
- wallet-service: remove conflicting EF Ignore() calls for mapped backing fields
- fnb-engine: remove KitchenTicket short constructor that set productId=orderItemId
- fnb-engine: replace fire-and-forget Task.Run with direct await for inventory deduction
- TenantMiddleware: implement PostgreSQL RLS SET LOCAL in 4 services (wallet, fnb, inventory, catalog)
- order-service: fix SQL injection pattern in TenantMiddleware with Guid.ToString("D")
- order-service: add ValidateShopAccess() authorization check in SignalR PosHub
- 4 services: register IDbConnection (NpgsqlConnection) in DI for RLS middleware

Frontend (3 fixes):
- PosDataService: return Success=false (not true) when PayOrder response parsing fails
- QrPayment: add _disposed guard to prevent timer race condition after component disposal
- BFF OrderController: add [Authorize] attribute to require JWT for all endpoints

Infrastructure (3 fixes):
- docker-compose: upgrade PostgreSQL 15-alpine to 16-alpine per project spec
- init-databases.sh: add 4 missing marketing service databases (mkt_*)
- Traefik routes: add wallet, catalog, booking routers and /api/v1/stock path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 16:22:08 +07:00
Ho Ngoc Hai
8af86e9e89 feat: implement Phase 1 payment gateway, real-time SignalR, kitchen-inventory deduction, and order payment flow
- wallet-service: IPaymentGateway abstraction + VN Pay implementation (HMAC-SHA512, sandbox), Payment aggregate root, PaymentsController with create/callback/query endpoints
- order-service: PosHub SignalR hub with Redis backplane + MessagePack, strongly-typed clients, 3 group types (shop/kds/pos), integrated into Create/Pay/Complete/Cancel order handlers
- fnb-engine + inventory-service: Kitchen→Inventory auto-deduction via domain events, HTTP with Polly retry + circuit breaker, idempotency check, graceful degradation on insufficient stock
- order-service: Enhanced PayOrderCommand with 3 flows (cash/card/online), PaymentPending status, WalletServiceClient, CompleteOrderPaymentCommand for gateway callbacks
- POS frontend: Cash/Card/QR payment components wired to real backend, BFF proxy updated
- infra: Traefik routes for fnb-engine, inventory-service, and SignalR WebSocket hub
- ROADMAP.md: Updated with Phase 1 progress tracking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:28:46 +07:00
Ho Ngoc Hai
2e1bb65bd3 feat: implement merchant subscription management and enhanced user account/security features with a new BFF layer. 2026-03-06 12:34:53 +07:00
Ho Ngoc Hai
193b9edd23 feat(staff): Integrate kitchen display system, add new staff roles, and enhance staff profile resolution with improved attendance proxying. 2026-03-06 11:42:41 +07:00
Ho Ngoc Hai
30b3f9a37c feat(staff-portal): implement staff attendance and leave request management with dedicated portal UI and backend services 2026-03-06 04:29:00 +07:00
Ho Ngoc Hai
a51ecacfac feat(shop-recipes): add product linking, ingredient display, and edit functionality for recipes. 2026-03-06 03:29:28 +07:00
Ho Ngoc Hai
fd75da34dc feat: enhance inventory management with new item types, stocktake, wastage, and recipe-based deductions 2026-03-05 22:28:45 +07:00
Ho Ngoc Hai
6d5d4108c7 refactor(api, web-client): remove API versioning from services and update client calls, and enhance staff schedule management in the admin UI to support multiple days and shift presets. 2026-03-05 16:40:02 +07:00
Ho Ngoc Hai
3f1ecc8122 feat(booking-service, web-client-tpos): implement staff schedule creation/deletion and enhance staff name display. 2026-03-05 16:19:46 +07:00
Ho Ngoc Hai
81c5be9e37 fix(staff): Vấn đề trạng thái nhân viên "Invited" 2026-03-05 15:56:37 +07:00
Ho Ngoc Hai
e4bedf2cd3 feat(allPos): upgrad frontend 2026-03-05 15:33:23 +07:00