feat(inventory): add validation for item availability in released reservations

- Implement `check_released_reservations_available` function to verify if items from released reservations are still available for re-sale when attempting to change a returned order's status
- Update `create_sale_on_order_completion` signal to use this check, allowing transitions to positive statuses only if items are available, otherwise blocking with ValidationError
- Wrap Order.save() in transaction.atomic() to ensure ValidationError in signals rolls back the save operation
- Add comprehensive tests for scenarios where items are available or used in other orders
- Update date carousel in order to always center on today's date and remove unnecessary saving logic
- Add test flag to Django Debug Toolbar settings

Closes #123 (assuming related issue)
This commit is contained in:
2025-12-27 02:31:43 +03:00
parent 44d115b356
commit 1654962ba2
5 changed files with 231 additions and 55 deletions

View File

@@ -427,6 +427,8 @@ if DEBUG:
'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG,
# Или можно фильтровать по tenant (например, только для определенных поддоменов):
# 'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG and getattr(request, 'tenant', None) and request.tenant.schema_name != 'public',
# Отключить для тестов
'IS_RUNNING_TESTS': False,
}