4.9 KiB
4.9 KiB
FruitBankHybridApp — Domain Rules
@repo { type = "product" layer = 2 own-dep-repos = ["AyCode.Core", "AyCode.Blazor", "Mango.Nop Libraries"] }
This is the single source of truth for domain rules. Do not duplicate these elsewhere. For detailed docs see:
README.md→docs/For core framework rules see:.github/copilot-instructions.md(in AyCode.Core repo) For UI framework rules see:.github/copilot-instructions.md(in AyCode.Blazor repo) For nopCommerce library rules see:.github/copilot-instructions.md(in Mango.Nop Libraries repo)
Business Domain
- FruitBank = fruit & vegetable wholesaler. The server side runs as a nopCommerce plugin — Customer, Order, Product, GenericAttribute are nopCommerce entities.
- Shipping = INBOUND delivery (supplier → warehouse). Order = OUTBOUND delivery (warehouse → customer). Never confuse the two directions.
- "Pallet" (
XxxItemPallet) = a measurement record, NOT a physical pallet. Always created for every item, even non-measurable ones.
Measurement Logic
- IsMeasurable=false → weights are 0.0, only
TrayQuantityis recorded. A Pallet record is still created. - NetWeight = GrossWeight − PalletWeight − (TrayQuantity × TareWeight) — this formula is universal across ShippingItemPallet, OrderItemPallet, and StockTakingItemPallet.
- MeasuringStatus.Finnished — intentional legacy typo with double-n. Do NOT fix the spelling.
- MeasuringStatus progression: NotStarted(0) → Started(10) → Finnished(20) → Audited(30). OrderItemPallet adds Audited when RevisorId > 0.
Data Model
- GenericAttribute = polymorphic key-value store.
KeyGroup= owner type name,EntityId= owner ID. ProductDto reads IsMeasurable, Tare, AverageWeight, IncomingQuantity, NetWeight from GenericAttributes. - Three parallel measurement hierarchies share the same base (
MeasuringItemPalletBase):- Shipping: ShippingItem → ShippingItemPallet
- Order: OrderItemDto → OrderItemPallet (adds RevisorId for audit)
- StockTaking: StockTakingItem → StockTakingItemPallet
Technical
- SignalR uses AcBinaryHubProtocol (custom binary), not default JSON.
- Do not suggest removal/rollback as a solution — find a fix for the problem.
- All AyCode references are via DLL (not ProjectReference) — this is intentional. nopCommerce 4.80.9 requirement.
- No redundant code — before writing new logic, check whether similar methods already exist in the current context. Reuse or extract shared logic into smaller methods rather than duplicating.
- Keep all .md files in sync — when you modify code and you know which .md file documents it, update that .md file too. If you notice a contradiction between code and an .md file, automatically update the .md to match the code (code is the source of truth). When fixing a reference, check other .md files that may share the same broken reference. If the root cause is at a lower layer, fix it there first. During code review, if you find useful behavior or conventions not yet documented, briefly suggest what to document and where — but do not add new content without approval.
- MgGridBase (AyCode.Blazor) is the canonical grid base for all data screens. New grids inherit
FruitBankGridBase<TEntity>, set CRUD tags in the constructor, and useMgGridWithInfoPanelfor layout. SeeAyCode.Blazor.Components/docs/MGGRID.md(in AyCode.Blazor repo) for the full technical reference. Do NOT create parallel grid base classes. - AyCode.Core solution (
../../../Aycode/Source/AyCode.Core/) contains all core framework code: SignalR base classes, serialization, binary protocol, data sources, logging. Types not defined in this solution likely live in AyCode.Core. - AyCode.Blazor solution (
../../../Aycode/Source/AyCode.Blazor/) contains all UI framework code: MgGridBase, MgGridWithInfoPanel, toolbar, layout persistence, Blazor component infrastructure. UI base classes or components not found here likely live in AyCode.Blazor. - Mango.Nop Libraries (
../NopCommerce.Common/4.70/Libraries/) — independent shared library with its own.github/copilot-instructions.mdanddocs/. Contains DTOs, entities, data access, and service base classes. DTO or entity base classes not found in this solution likely live in Libraries. - FruitBank nopCommerce Plugin (
../NopCommerce.Common/4.70/Plugins/Nop.Plugin.Misc.AIPlugin/) is the server-side plugin running inside nopCommerce 4.80.9. Contains SignalR hubs/endpoints, measurement services, data access (DbTable classes), admin controllers, and AI services. Server-side endpoints and services are defined here. - Documentation layering — write
.mddocumentation at the defining layer (where the code lives). Higher-layer.mdfiles reference the base docs (e.g.see AyCode.Core/docs/SIGNALR.md) and document only project-specific overrides or extensions. Never duplicate base-layer descriptions in consumer-level docs.