30 lines
2.4 KiB
Markdown
30 lines
2.4 KiB
Markdown
# FruitBankHybridApp — Domain Rules
|
||
|
||
> This is the **single source of truth** for domain rules. Do not duplicate these elsewhere.
|
||
> For detailed docs see: `README.md` → `docs/`
|
||
|
||
## Business Domain
|
||
1. **FruitBank** = fruit & vegetable wholesaler. This is a **nopCommerce plugin** — Customer, Order, Product, GenericAttribute are nopCommerce entities.
|
||
2. **Shipping** = INBOUND delivery (supplier → warehouse). **Order** = OUTBOUND delivery (warehouse → customer). Never confuse the two directions.
|
||
3. **"Pallet"** (`XxxItemPallet`) = a **measurement record**, NOT a physical pallet. Always created for every item, even non-measurable ones.
|
||
|
||
## Measurement Logic
|
||
4. **IsMeasurable=false** → weights are 0.0, only `TrayQuantity` is recorded. A Pallet record is still created.
|
||
5. **NetWeight = GrossWeight − PalletWeight − (TrayQuantity × TareWeight)** — this formula is universal across ShippingItemPallet, OrderItemPallet, and StockTakingItemPallet.
|
||
6. **MeasuringStatus.Finnished** — intentional legacy typo with double-n. Do NOT fix the spelling.
|
||
7. **MeasuringStatus** progression: NotStarted(0) → Started(10) → Finnished(20) → Audited(30). OrderItemPallet adds Audited when RevisorId > 0.
|
||
|
||
## Data Model
|
||
8. **GenericAttribute** = polymorphic key-value store. `KeyGroup` = owner type name, `EntityId` = owner ID. ProductDto reads IsMeasurable, Tare, AverageWeight, IncomingQuantity, NetWeight from GenericAttributes.
|
||
9. **Three parallel measurement hierarchies** share the same base (`MeasuringItemPalletBase`):
|
||
- Shipping: ShippingItem → ShippingItemPallet
|
||
- Order: OrderItemDto → OrderItemPallet (adds RevisorId for audit)
|
||
- StockTaking: StockTakingItem → StockTakingItemPallet
|
||
|
||
## Technical
|
||
10. SignalR uses **AcBinaryHubProtocol** (custom binary), not default JSON.
|
||
11. Do not suggest removal/rollback as a solution — find a fix for the problem.
|
||
12. All AyCode references are via **DLL** (not ProjectReference) — this is intentional. nopCommerce 4.80.9 requirement.
|
||
13. **No redundant code** — before writing new logic, search for existing methods. Reuse or extract shared logic into smaller methods rather than duplicating.
|
||
14. **Keep all .md files in sync** — when you modify code, update any affected .md file (README.md, docs/, GLOSSARY, ARCHITECTURE, CONVENTIONS, SCHEMA, etc.). If you notice any .md content does not match the current code, fix it automatically.
|