z-syst-pharmacy-refactor
Refactor Z-Syst Pharmacy Laravel code toward service-driven stock allocation, module provider consistency, and production-ready module routing. Use when replacing legacy Stock/ProductStock writes, fixing module auto-registration, or improving pharmacy business logic separation.
- License 许可
- MIT
- 所属仓库
- darkcsda/Z-Syst
- 最近更新
- 2026-08-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- z-syst-pharmacy-refactor
- license
- MIT
- metadata
- { "author": "claudekit", "version": "1.0.0" }
- description
- Refactor Z-Syst Pharmacy Laravel code toward service-driven stock allocation, module provider consistency, and production-ready module routing. Use when replacing legacy Stock/ProductStock writes, fixing module auto-registration, or improving pharmacy business logic separation.
- argument-hint
- [task]
03 SKILL.md 正文
Z-Syst Pharmacy Refactor
Refactor helper for the Z-Syst Pharmacy management app. Focuses on converting legacy inventory mutations to StockAllocationService, enforcing thin controllers, preserving auditability, and ensuring Laravel module/provider routing works correctly.
When to Use
- Replacing direct
StockorProductStockwrites withStockAllocationService - Fixing module service provider discovery in
app/Modules - Verifying route loading for modular Laravel providers
- Refactoring pharmacy stock, sales, GRN, prescription, purchase, and return workflows
- Ensuring pessimistic locking and consistent audit trail for stock operations
- Cleaning up legacy stock mutation code paths in controllers and services
Core Focus
- Keep Controllers thin: validate, delegate, return response
- Centralize stock mutation in
App\Services\Stock\StockAllocationService - Preserve business rules in Services, not Controllers
- Use pessimistic locking for stock allocation and release
- Maintain stock audit trail and avoid inconsistent direct model updates
- Support real pharmacy flows: purchases, GRN, sales, returns, prescriptions
Primary Patterns
Stock Allocation
Always prefer StockAllocationService over direct Stock / ProductStock mutation:
StockAllocationService::addToProductStock($payload)StockAllocationService::allocateToProductStock($payload)StockAllocationService::addToLegacyStock($payload)StockAllocationService::releaseFromProductStock($payload)StockAllocationService::allocate($payload)StockAllocationService::release($payload)
Use these methods for:
- GRN receipt
- Sales and POS deductions
- Prescription dispensing
- Purchase returns and sale returns
- Stock transfers and legacy stock updates
Service Layer
- Controllers should only orchestrate requests and responses
- Business logic should live in Service classes such as:
GoodsReceivedNoteServicePrescriptionServicePurchaseOrderReturnServiceSaleServiceInvoiceOcrService
- Use dependency injection and dedicated request validation classes
Provider Auto-Discovery
For modular route/provider loading, ensure each module exposes a valid provider class in app/Modules/{ModuleName}. Prefer a fallback resolution strategy when module names do not match provider class names exactly.
Route Validation
After provider fixes, verify module routes using:
php artisan route:list --name=auth
php artisan route:list --path=api
and clear caches when needed:
php artisan config:clear
php artisan route:clear
php artisan cache:clear
composer dump-autoload
Recommended Workflow
- Search for legacy stock model usage:
grep -R "new Stock|ProductStock::|Stock::" app/Http app/Services
2. Replace direct writes with `StockAllocationService` calls
3. Keep controller methods thin and move business logic to service methods
4. Clear Laravel caches and confirm routes/providers load
5. Run focused tests for stock movement and prescription flows
## Avoid
- Direct `Stock::create`, `Stock::update`, or `ProductStock::create` for write operations
- Business logic scattered across controllers
- Stale or misnamed module provider classes
- Ignoring `company_id`, `branch_id`, or warehouse scope in stock workflows
- Bypassing audit trail on inventory changes
## Example Replacement
```php
// BAD
Stock::where('id', $stockId)->decrement('quantity', $qty);
// GOOD
StockAllocationService::allocateToProductStock([
'product_id' => $productId,
'branch_id' => $branchId,
'quantity' => $qty,
'reference_type' => Sale::class,
'reference_id' => $saleId,
]);
Scope
This skill applies to the Z-Syst Pharmacy Laravel codebase, especially the following areas:
app/Http/Controllers/API/AcnooSaleController.phpapp/Http/Controllers/API/GoodsReceivedNoteController.phpapp/Http/Controllers/API/V1/PrescriptionController.phpapp/Services/PrescriptionService.phpapp/Services/InvoiceOcrService.phpapp/Services/Stock/StockAllocationService.phpapp/Shared/Providers/ModuleServiceProvider.php
When Not to Use
- Generic Laravel apps unrelated to pharmacy or inventory management
- Tasks that do not involve stock workflows, provider registration, or modular route loading
- UI-only work without backend inventory/business logic changes
04 同仓库更多 Skills
ui-styling
Create beautiful, accessible user interfaces with shadcn/ui components (built on Radix UI + Tailwind), Tailwind CSS utility-first styling, and canvas-based visual designs. Use when building user interfaces, implementing design systems, creating responsive layouts, adding accessible components (dialogs, dropdowns, forms, tables), customizing themes and colors, implementing dark mode, generating visual designs and posters, or establishing consistent styling patterns across applications.
omniroute
Work effectively in the OmniRoute repository by understanding its architecture, implementing features safely, and validating changes across routing, compression, providers, and the UI.
developer-saas
Developer SaaS skill for planning, architecting, implementing, and launching modern software-as-a-service products. Covers multi-tenancy, subscription billing, API design, onboarding, operations, security, and product/engineering tradeoffs.
design
Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads.
design-system
Token architecture, component specifications, and slide generation. Three-layer tokens (primitive→semantic→component), CSS variables, spacing/typography scales, component specs, strategic slide creation. Use for design tokens, systematic design, brand-compliant presentations.
banner-design
Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with AI-generated visuals. Actions: design, create, generate banner. Platforms: Facebook, Twitter/X, LinkedIn, YouTube, Instagram, Google Display, website hero, print. Styles: minimalist, gradient, bold typography, photo-based, illustrated, geometric, retro, glassmorphism, 3D, neon, duotone, editorial, collage. Uses ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal skills.