4.0 KiB
KAIZEN
Goal
The editing agent should improve the quality of the prompts in .github/ for the next editing agent if there are any breaking changes in the repository structure, requirements or testing framework.
Instructions
- If the user says something like "Do not do this, do X instead" permanentize it into the repository prompts
- "Log" important details into the prompts for future agents
- Ensure that all instructions are clear, concise, and unambiguous
- Avoid redundancy and ensure that the prompts are well-organized
- Always update the documentation in
./docs/*when making changes to the codebase. - You always aim to change .github/copilot-instructions.md or
./docs/*if applicable - NEVER use
git checkoutorgit resetcommands - manually revert changes using replace_string_in_file instead
Session Log
2025-12-30: CRITICAL MISTAKE - Misunderstood Pool Pricing Strategy
WRONG Understanding (DO NOT IMPLEMENT): ❌ Pricing strategy compares pool price vs single price ❌ LOWEST: min(poolPrice, singlePrice) ❌ Example: Pool=5000, Single=10000 → use 5000 (WRONG!)
CORRECT Understanding: ✅ Pricing strategy determines allocation ORDER of singles ✅ Singles ALWAYS use their own price if they have one ✅ Pool price is ONLY a fallback when single has NO price ✅ Example: Pool=5000, Singles=10000,50000 → use 10000 and 50000 (singles' prices)
Correct Pricing Logic:
if ($singlePrice !== null) {
// Single has its own price - USE IT
$price = $singlePrice;
} elseif ($poolPrice !== null) {
// Single has NO price - fallback to pool price
$price = $poolPrice;
}
What Pricing Strategy Actually Does:
- LOWEST: Allocate singles with lowest prices first (10000 before 50000)
- HIGHEST: Allocate singles with highest prices first (50000 before 10000)
- AVERAGE: Calculate average price of all available singles
- Strategy affects WHICH single is allocated, NOT the price used
Files That Were Incorrectly Modified (REVERTED):
src/Models/CartItem.php- removed pricing strategy comparisonsrc/Traits/MayBePoolProduct.php- removed pricing strategy comparisonsrc/Models/Cart.php- removed pricing strategy comparison
Key Learning: ALWAYS verify understanding of business logic before implementing. Pool pricing strategy is about allocation order, not price comparison.
2026-01-05: Cart Item Price/Currency Fixes
Issues Fixed:
- Pool singles bookings should show
unit_amountwhen added (not 0), even without dates - Bug: Date range adjustment was showing wrong price (5000 instead of 1755) when singles had no price
- Added
currencycolumn to cart_items table to store currency from selected price - Removed obsolete
allocated_single_item_namefrom meta (replaced byproduct_idcolumn)
Root Cause of Price Bug:
updateDates()was calling$allocatedSingle->defaultPrice()->first()instead of using$this->price()->first()- When single has no price,
reallocatePoolItemssetsprice_idto the pool's price model updateDates()was ignoring this and going back to the single's (non-existent) price
Fix Applied:
// In CartItem::updateDates()
// IMPORTANT: Use the price_id relationship first, as it was set by reallocatePoolItems
$priceModel = $this->price_id ? $this->price()->first() : null;
if ($priceModel) {
$pricePerDay = $priceModel->getCurrentPrice(...);
} else {
// Fallback: Get price from the allocated single, with fallback to pool price
...
}
New CartItem Fields:
currency: Currency from the selected price model (e.g., 'USD', 'EUR')
Removed:
meta->allocated_single_item_name- use$cartItem->product->nameinstead via theproduct_idrelationship
Files Modified:
src/Models/CartItem.php- added currency, fixed updateDates price resolutionsrc/Models/Cart.php- added currency to addToCart and reallocatePoolItemssrc/Traits/MayBePoolProduct.php- added currency to getNextAvailablePoolItemWithPrice returndatabase/migrations/create_blax_shop_tables.php.stub- added currency column