feat: Enhance order date handling with effective date fallback and update documentation

This commit is contained in:
2026-03-04 23:56:45 +01:00
parent 7ac4293df4
commit 9df7a63244
6 changed files with 237 additions and 41 deletions

View File

@@ -3,8 +3,8 @@
"public_html": { "public_html": {
"AGENTS.md": { "AGENTS.md": {
"type": "-", "type": "-",
"size": 2593, "size": 3402,
"lmtime": 1772522685966, "lmtime": 1772652932723,
"modified": false "modified": false
}, },
"ARCHITECTURE.md": { "ARCHITECTURE.md": {
@@ -374,8 +374,20 @@
}, },
"cron.php": { "cron.php": {
"type": "-", "type": "-",
"size": 114, "size": 2398,
"lmtime": 1772490484677, "lmtime": 1772661752605,
"modified": false
},
"debug_allegro_offer_image.php": {
"type": "-",
"size": 5749,
"lmtime": 1772659638204,
"modified": false
},
"debug_allegro_order_media.php": {
"type": "-",
"size": 3578,
"lmtime": 1772659291974,
"modified": false "modified": false
}, },
"deploy_and_seed_orders.php": { "deploy_and_seed_orders.php": {
@@ -408,16 +420,22 @@
"lmtime": 1771692294431, "lmtime": 1771692294431,
"modified": false "modified": false
}, },
"randomize_order_statuses.php": {
"type": "-",
"size": 3646,
"lmtime": 1772497235553,
"modified": false
},
"test_gs1_api.php": { "test_gs1_api.php": {
"type": "-", "type": "-",
"size": 7348, "size": 7348,
"lmtime": 1771964550467, "lmtime": 1771964550467,
"modified": false "modified": false
}, },
"randomize_order_statuses.php": { "debug_order_delivery.php": {
"type": "-", "type": "-",
"size": 3646, "size": 2031,
"lmtime": 1772497235553, "lmtime": 1772662252283,
"modified": false "modified": false
} }
}, },
@@ -601,6 +619,42 @@
"size": 1378, "size": 1378,
"lmtime": 1772491798937, "lmtime": 1772491798937,
"modified": false "modified": false
},
"20260304_000023_create_allegro_integration_settings_table.sql": {
"type": "-",
"size": 1416,
"lmtime": 1772654150195,
"modified": false
},
"20260304_000024_add_allegro_token_refresh_schedule.sql": {
"type": "-",
"size": 2964,
"lmtime": 1772655425959,
"modified": false
},
"20260304_000025_create_allegro_order_status_mappings_table.sql": {
"type": "-",
"size": 618,
"lmtime": 1772656570162,
"modified": false
},
"20260304_000026_make_allegro_status_mapping_nullable.sql": {
"type": "-",
"size": 99,
"lmtime": 1772657798905,
"modified": false
},
"20260304_000027_add_allegro_orders_import_schedule.sql": {
"type": "-",
"size": 1588,
"lmtime": 1772660772041,
"modified": false
},
"20260304_000028_add_allegro_status_sync_schedule.sql": {
"type": "-",
"size": 852,
"lmtime": 1772661760885,
"modified": false
} }
}, },
"seeders": {}, "seeders": {},
@@ -628,14 +682,14 @@
"DOCS": { "DOCS": {
"ARCHITECTURE.md": { "ARCHITECTURE.md": {
"type": "-", "type": "-",
"size": 7199, "size": 14854,
"lmtime": 1772497590235, "lmtime": 1772662333693,
"modified": false "modified": false
}, },
"DB_SCHEMA.md": { "DB_SCHEMA.md": {
"type": "-", "type": "-",
"size": 3138, "size": 6999,
"lmtime": 1772496281398, "lmtime": 1772661998528,
"modified": false "modified": false
}, },
"ORDERS_SCHEMA_APILO_DRAFT.md": { "ORDERS_SCHEMA_APILO_DRAFT.md": {
@@ -652,16 +706,22 @@
}, },
"TECH_CHANGELOG.md": { "TECH_CHANGELOG.md": {
"type": "-", "type": "-",
"size": 8638, "size": 17750,
"lmtime": 1772497584302, "lmtime": 1772662343016,
"modified": false
},
"todo.md": {
"type": "-",
"size": 688,
"lmtime": 1772662690145,
"modified": false "modified": false
} }
}, },
".env": { ".env": {
"type": "-", "type": "-",
"size": 408, "size": 393,
"lmtime": 1771869136710, "lmtime": 1772654691844,
"modified": true "modified": false
}, },
".env.codex.bak": { ".env.codex.bak": {
"type": "-", "type": "-",
@@ -1876,8 +1936,8 @@
"css": { "css": {
"app.css": { "app.css": {
"type": "-", "type": "-",
"size": 25538, "size": 25757,
"lmtime": 1772497577480, "lmtime": 1772654371834,
"modified": false "modified": false
}, },
"app.css.map": { "app.css.map": {
@@ -1889,7 +1949,7 @@
"login.css": { "login.css": {
"type": "-", "type": "-",
"size": 4665, "size": 4665,
"lmtime": 1772497577979, "lmtime": 1772654372304,
"modified": false "modified": false
}, },
"login.css.map": { "login.css.map": {
@@ -1937,8 +1997,8 @@
"lang": { "lang": {
"pl.php": { "pl.php": {
"type": "-", "type": "-",
"size": 33450, "size": 41962,
"lmtime": 1772496207146, "lmtime": 1772661591586,
"modified": false "modified": false
} }
}, },
@@ -1961,8 +2021,8 @@
"scss": { "scss": {
"app.scss": { "app.scss": {
"type": "-", "type": "-",
"size": 28671, "size": 28929,
"lmtime": 1772497569553, "lmtime": 1772654341335,
"modified": false "modified": false
}, },
"login.scss": { "login.scss": {
@@ -2014,8 +2074,8 @@
"layouts": { "layouts": {
"app.php": { "app.php": {
"type": "-", "type": "-",
"size": 3524, "size": 3970,
"lmtime": 1772495209961, "lmtime": 1772655168615,
"modified": false "modified": false
}, },
"auth.php": { "auth.php": {
@@ -2092,11 +2152,17 @@
} }
}, },
"settings": { "settings": {
"allegro.php": {
"type": "-",
"size": 16587,
"lmtime": 1772661581724,
"modified": false
},
"cron.php": { "cron.php": {
"type": "-", "type": "-",
"size": 7180, "size": 6247,
"lmtime": 1772395792152, "lmtime": 1772655160233,
"modified": true "modified": false
}, },
"database.php": { "database.php": {
"type": "-", "type": "-",
@@ -2148,8 +2214,8 @@
"routes": { "routes": {
"web.php": { "web.php": {
"type": "-", "type": "-",
"size": 3538, "size": 6986,
"lmtime": 1772496154180, "lmtime": 1772661209733,
"modified": false "modified": false
} }
}, },
@@ -2197,8 +2263,8 @@
"Core": { "Core": {
"Application.php": { "Application.php": {
"type": "-", "type": "-",
"size": 7008, "size": 10729,
"lmtime": 1772495113026, "lmtime": 1772661737740,
"modified": false "modified": false
}, },
"Database": { "Database": {
@@ -2310,6 +2376,18 @@
} }
}, },
"Cron": { "Cron": {
"AllegroOrdersImportHandler.php": {
"type": "-",
"size": 665,
"lmtime": 1772660734274,
"modified": false
},
"AllegroTokenRefreshHandler.php": {
"type": "-",
"size": 1965,
"lmtime": 1772655083686,
"modified": false
},
"CronJobProcessor.php": { "CronJobProcessor.php": {
"type": "-", "type": "-",
"size": 6385, "size": 6385,
@@ -2328,6 +2406,18 @@
"lmtime": 1772489146286, "lmtime": 1772489146286,
"modified": false "modified": false
}, },
"CronRepository.php": {
"type": "-",
"size": 14940,
"lmtime": 1772661551022,
"modified": false
},
"CronRunner.php": {
"type": "-",
"size": 2815,
"lmtime": 1772655073134,
"modified": false
},
"ProductLinksHealthCheckHandler.php": { "ProductLinksHealthCheckHandler.php": {
"type": "-", "type": "-",
"size": 5247, "size": 5247,
@@ -2351,6 +2441,12 @@
"size": 528, "size": 528,
"lmtime": 1772489139382, "lmtime": 1772489139382,
"modified": false "modified": false
},
"AllegroStatusSyncHandler.php": {
"type": "-",
"size": 456,
"lmtime": 1772661713965,
"modified": false
} }
}, },
"GS1": { "GS1": {
@@ -2382,6 +2478,12 @@
} }
}, },
"Orders": { "Orders": {
"OrderImportRepository.php": {
"type": "-",
"size": 18405,
"lmtime": 1772655751334,
"modified": false
},
"OrderImportService.php": { "OrderImportService.php": {
"type": "-", "type": "-",
"size": 21009, "size": 21009,
@@ -2390,14 +2492,14 @@
}, },
"OrdersController.php": { "OrdersController.php": {
"type": "-", "type": "-",
"size": 21408, "size": 22423,
"lmtime": 1772496952329, "lmtime": 1772658312572,
"modified": false "modified": false
}, },
"OrdersRepository.php": { "OrdersRepository.php": {
"type": "-", "type": "-",
"size": 18855, "size": 24750,
"lmtime": 1772496882865, "lmtime": 1772658967435,
"modified": false "modified": false
}, },
"OrderStatusSyncService.php": { "OrderStatusSyncService.php": {
@@ -2484,12 +2586,78 @@
} }
}, },
"Settings": { "Settings": {
"AllegroApiClient.php": {
"type": "-",
"size": 3449,
"lmtime": 1772659378931,
"modified": false
},
"AllegroIntegrationController.php": {
"type": "-",
"size": 29116,
"lmtime": 1772661726470,
"modified": false
},
"AllegroIntegrationRepository.php": {
"type": "-",
"size": 10965,
"lmtime": 1772655846785,
"modified": false
},
"AllegroOAuthClient.php": {
"type": "-",
"size": 5988,
"lmtime": 1772660267587,
"modified": false
},
"AllegroOrderImportService.php": {
"type": "-",
"size": 31721,
"lmtime": 1772662304371,
"modified": false
},
"AllegroOrdersSyncService.php": {
"type": "-",
"size": 11544,
"lmtime": 1772660728121,
"modified": false
},
"AllegroOrderSyncStateRepository.php": {
"type": "-",
"size": 8757,
"lmtime": 1772660685699,
"modified": false
},
"AllegroStatusDiscoveryService.php": {
"type": "-",
"size": 5786,
"lmtime": 1772657848652,
"modified": false
},
"AllegroStatusMappingRepository.php": {
"type": "-",
"size": 4690,
"lmtime": 1772657817169,
"modified": false
},
"AllegroStatusSyncService.php": {
"type": "-",
"size": 1537,
"lmtime": 1772661706942,
"modified": false
},
"AppSettingsRepository.php": { "AppSettingsRepository.php": {
"type": "-", "type": "-",
"size": 1905, "size": 1905,
"lmtime": 1771954924419, "lmtime": 1771954924419,
"modified": false "modified": false
}, },
"CronSettingsController.php": {
"type": "-",
"size": 3345,
"lmtime": 1772655129538,
"modified": false
},
"IntegrationRepository.php": { "IntegrationRepository.php": {
"type": "-", "type": "-",
"size": 25754, "size": 25754,
@@ -3632,6 +3800,12 @@
"size": 3392, "size": 3392,
"lmtime": 1771959054615, "lmtime": 1771959054615,
"modified": false "modified": false
},
"tmp_schema_check.php": {
"type": "-",
"size": 429,
"lmtime": 1772655634873,
"modified": false
} }
} }
}, },

View File

@@ -80,6 +80,8 @@
- `GET /orders/list`: - `GET /orders/list`:
- `OrdersController::index(Request): Response` - `OrdersController::index(Request): Response`
- pobiera dane listy przez `OrdersRepository::paginate(...)`, - pobiera dane listy przez `OrdersRepository::paginate(...)`,
- data zamowienia na liscie korzysta z fallbacku: `orders.ordered_at` -> `orders.source_created_at` -> `orders.source_updated_at` -> `orders.fetched_at`,
- domyslne sortowanie i filtry zakresu dat (`date_from`, `date_to`) korzystaja z tej samej daty efektywnej,
- pobiera slowniki filtrow (`sourceOptions()`, `statusOptions()`), statystyki (`quickStats()`), agregaty statusow (`statusCounts()`) i konfiguracje grup/statusow (`statusPanelConfig()`), - pobiera slowniki filtrow (`sourceOptions()`, `statusOptions()`), statystyki (`quickStats()`), agregaty statusow (`statusCounts()`) i konfiguracje grup/statusow (`statusPanelConfig()`),
- buduje panel statusow z grupami i licznikami (`buildStatusPanel(...)`) z linkami filtrujacymi po statusie, - buduje panel statusow z grupami i licznikami (`buildStatusPanel(...)`) z linkami filtrujacymi po statusie,
- panel statusow i etykiety statusow sa zgodne z konfiguracja z `Ustawienia > Statusy` (z fallbackiem `Pozostale`), - panel statusow i etykiety statusow sa zgodne z konfiguracja z `Ustawienia > Statusy` (z fallbackiem `Pozostale`),

View File

@@ -21,6 +21,7 @@
- 2026-03-04: Rozszerzono zakladke `Ustawienia` integracji Allegro o kierunek synchronizacji statusow i interwal synchronizacji statusow; zapis do `app_settings` (`allegro_status_sync_direction`, `allegro_status_sync_interval_minutes`) - bez zmian schematu. - 2026-03-04: Rozszerzono zakladke `Ustawienia` integracji Allegro o kierunek synchronizacji statusow i interwal synchronizacji statusow; zapis do `app_settings` (`allegro_status_sync_direction`, `allegro_status_sync_interval_minutes`) - bez zmian schematu.
- 2026-03-04: Dodano harmonogram `allegro_status_sync` (cron synchronizacji statusow) + defaulty `app_settings` dla kierunku i interwalu status sync - migracja `20260304_000028_add_allegro_status_sync_schedule.sql`. - 2026-03-04: Dodano harmonogram `allegro_status_sync` (cron synchronizacji statusow) + defaulty `app_settings` dla kierunku i interwalu status sync - migracja `20260304_000028_add_allegro_status_sync_schedule.sql`.
- 2026-03-04: Import Allegro mapuje forme wysylki do `orders.external_carrier_id` i `orders.external_carrier_account_id` - bez zmian schematu. - 2026-03-04: Import Allegro mapuje forme wysylki do `orders.external_carrier_id` i `orders.external_carrier_account_id` - bez zmian schematu.
- 2026-03-04: Poprawiono prezentacje daty zamowienia na liscie (`fallback ordered_at -> source_created_at -> source_updated_at -> fetched_at`) - bez zmian schematu.
## Tabele ## Tabele

View File

@@ -1,6 +1,9 @@
# Tech Changelog # Tech Changelog
## 2026-03-04 ## 2026-03-04
- Poprawiono kolumne `Data zamowienia` na liscie zamowien:
- wartosc jest liczona fallbackiem `orders.ordered_at -> orders.source_created_at -> orders.source_updated_at -> orders.fetched_at`,
- domyslne sortowanie listy i filtry zakresu dat korzystaja z tej samej daty efektywnej, co eliminuje puste wartosci przy rekordach bez `ordered_at`.
- Import zamowienia Allegro zapisuje teraz forme wysylki: - Import zamowienia Allegro zapisuje teraz forme wysylki:
- `delivery.method.name` (fallback `delivery.method.id`) trafia do `orders.external_carrier_id`, - `delivery.method.name` (fallback `delivery.method.id`) trafia do `orders.external_carrier_id`,
- techniczne `delivery.method.id` trafia do `orders.external_carrier_account_id`. - techniczne `delivery.method.id` trafia do `orders.external_carrier_account_id`.

View File

@@ -5,4 +5,6 @@
5. [] W szczególach zamówienia dorobić opcję zmiany statusu. 5. [] W szczególach zamówienia dorobić opcję zmiany statusu.
6. [] W szczególach zamówienia 2 razy wyświetla się ID zamówienai z allegro, np: 008d3d60-1743-11f1-b15c-fdb4f87ccfc6 6. [] W szczególach zamówienia 2 razy wyświetla się ID zamówienai z allegro, np: 008d3d60-1743-11f1-b15c-fdb4f87ccfc6
7. [] Przy imporcie z allegro liczba przesyłek jest 0. 7. [] Przy imporcie z allegro liczba przesyłek jest 0.
8. [] Kolumna LP w szczególach zamówienia jest zbyt szeroka. 8. [] Kolumna LP w szczególach zamówienia jest zbyt szeroka.
9. [x] Na lisćie zamówień pole po którym jest domyślnie sortowana czyli data zamówienia jest puste.
10. [] Na liście zamówień ukryć kolumnę ostatnia zmiana.

View File

@@ -27,6 +27,7 @@ final class OrdersRepository
$where = []; $where = [];
$params = []; $params = [];
$effectiveStatusSql = $this->effectiveStatusSql('o', 'asm'); $effectiveStatusSql = $this->effectiveStatusSql('o', 'asm');
$effectiveOrderedAtSql = $this->effectiveOrderedAtSql('o');
$search = trim((string) ($filters['search'] ?? '')); $search = trim((string) ($filters['search'] ?? ''));
if ($search !== '') { if ($search !== '') {
@@ -60,13 +61,13 @@ final class OrdersRepository
$dateFrom = trim((string) ($filters['date_from'] ?? '')); $dateFrom = trim((string) ($filters['date_from'] ?? ''));
if ($dateFrom !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateFrom) === 1) { if ($dateFrom !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateFrom) === 1) {
$where[] = 'o.ordered_at >= :date_from'; $where[] = $effectiveOrderedAtSql . ' >= :date_from';
$params['date_from'] = $dateFrom . ' 00:00:00'; $params['date_from'] = $dateFrom . ' 00:00:00';
} }
$dateTo = trim((string) ($filters['date_to'] ?? '')); $dateTo = trim((string) ($filters['date_to'] ?? ''));
if ($dateTo !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateTo) === 1) { if ($dateTo !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateTo) === 1) {
$where[] = 'o.ordered_at <= :date_to'; $where[] = $effectiveOrderedAtSql . ' <= :date_to';
$params['date_to'] = $dateTo . ' 23:59:59'; $params['date_to'] = $dateTo . ' 23:59:59';
} }
@@ -84,7 +85,7 @@ final class OrdersRepository
'source_updated_at' => 'o.source_updated_at', 'source_updated_at' => 'o.source_updated_at',
'fetched_at' => 'o.fetched_at', 'fetched_at' => 'o.fetched_at',
'id' => 'o.id', 'id' => 'o.id',
default => 'o.ordered_at', default => $effectiveOrderedAtSql,
}; };
try { try {
@@ -108,8 +109,10 @@ final class OrdersRepository
o.total_with_tax, o.total_with_tax,
o.total_paid, o.total_paid,
o.ordered_at, o.ordered_at,
o.source_created_at,
o.source_updated_at, o.source_updated_at,
o.fetched_at, o.fetched_at,
' . $effectiveOrderedAtSql . ' AS effective_ordered_at,
o.is_invoice, o.is_invoice,
o.is_canceled_by_buyer, o.is_canceled_by_buyer,
a.name AS buyer_name, a.name AS buyer_name,
@@ -161,7 +164,8 @@ final class OrdersRepository
'currency' => (string) ($row['currency'] ?? ''), 'currency' => (string) ($row['currency'] ?? ''),
'total_with_tax' => $row['total_with_tax'] !== null ? (float) $row['total_with_tax'] : null, 'total_with_tax' => $row['total_with_tax'] !== null ? (float) $row['total_with_tax'] : null,
'total_paid' => $row['total_paid'] !== null ? (float) $row['total_paid'] : null, 'total_paid' => $row['total_paid'] !== null ? (float) $row['total_paid'] : null,
'ordered_at' => (string) ($row['ordered_at'] ?? ''), 'ordered_at' => (string) ($row['effective_ordered_at'] ?? ''),
'source_created_at' => (string) ($row['source_created_at'] ?? ''),
'source_updated_at' => (string) ($row['source_updated_at'] ?? ''), 'source_updated_at' => (string) ($row['source_updated_at'] ?? ''),
'fetched_at' => (string) ($row['fetched_at'] ?? ''), 'fetched_at' => (string) ($row['fetched_at'] ?? ''),
'is_invoice' => (int) ($row['is_invoice'] ?? 0) === 1, 'is_invoice' => (int) ($row['is_invoice'] ?? 0) === 1,
@@ -551,6 +555,16 @@ final class OrdersRepository
END'; END';
} }
private function effectiveOrderedAtSql(string $orderAlias): string
{
return 'COALESCE('
. $orderAlias . '.ordered_at, '
. $orderAlias . '.source_created_at, '
. $orderAlias . '.source_updated_at, '
. $orderAlias . '.fetched_at'
. ')';
}
private function resolvedMediaUrlSql(string $itemAlias): string private function resolvedMediaUrlSql(string $itemAlias): string
{ {
if (!$this->canResolveMappedMedia()) { if (!$this->canResolveMappedMedia()) {