feat: Enhance InPost service selection and handling in Allegro settings

- Added a check for available InPost services and display a message if none are found.
- Updated the InPost service selection dropdown to include additional data attributes for better handling in JavaScript.
- Improved JavaScript event handling for InPost service selection to correctly populate hidden fields with selected service data.

feat: Introduce Cash on Delivery (COD) functionality in shipment preparation

- Added a new input field for specifying the COD amount and currency in the shipment preparation view.
- Updated the shipment creation logic to handle COD amounts correctly when creating shipments.

refactor: Update OrdersController to include shipment package repository

- Modified the OrdersController to accept a ShipmentPackageRepository for better management of shipment-related data.
- Enhanced order details to include shipment package information.

fix: Ensure internal order numbers are generated upon order creation

- Updated the OrderImportRepository to generate and store internal order numbers when a new order is created.

feat: Implement status synchronization for Allegro orders

- Introduced a new service for syncing order statuses from Allegro to the internal system.
- Added logic to fetch and process orders needing status updates, handling errors gracefully.

chore: Clean up InPost service definitions in AllegroIntegrationController

- Removed hardcoded InPost service definitions and replaced them with dynamic fetching based on available services.

feat: Add activity logging for shipment actions

- Implemented activity logging for various shipment actions, including creation, label downloads, and errors, to improve traceability and auditing.
This commit is contained in:
2026-03-06 20:09:59 +01:00
parent 1b5e403c31
commit 3ba6202770
21 changed files with 1888 additions and 226 deletions

View File

@@ -104,17 +104,11 @@ final class AllegroShipmentService
$codAmount = (float) ($formData['cod_amount'] ?? 0);
if ($codAmount > 0) {
$cod = [
// Allegro WZA manages COD funds internally iban/ownerName are not accepted
$apiPayload['input']['cashOnDelivery'] = [
'amount' => number_format($codAmount, 2, '.', ''),
'currency' => strtoupper(trim((string) ($formData['cod_currency'] ?? 'PLN'))),
];
if (trim($company['bank_owner_name']) !== '') {
$cod['ownerName'] = $company['bank_owner_name'];
}
if (trim($company['bank_account']) !== '') {
$cod['iban'] = $company['bank_account'];
}
$apiPayload['input']['cashOnDelivery'] = $cod;
}
$credentialsId = trim((string) ($formData['credentials_id'] ?? ''));
@@ -266,14 +260,28 @@ final class AllegroShipmentService
$filePath = $dir . '/' . $filename;
file_put_contents($filePath, $binary);
$relativePath = 'labels/' . $filename;
$this->packages->update($packageId, [
$updateFields = [
'status' => 'label_ready',
'label_path' => $relativePath,
]);
'label_path' => 'labels/' . $filename,
];
// Refresh tracking number if not yet saved (may not have been available at creation time)
if (trim((string) ($package['tracking_number'] ?? '')) === '') {
try {
$details = $this->apiClient->getShipmentDetails($env, $accessToken, $shipmentId);
$trackingNumber = trim((string) ($details['waybill'] ?? ''));
if ($trackingNumber !== '') {
$updateFields['tracking_number'] = $trackingNumber;
}
} catch (Throwable) {
// non-critical label is still saved
}
}
$this->packages->update($packageId, $updateFields);
return [
'label_path' => $relativePath,
'label_path' => 'labels/' . $filename,
'full_path' => $filePath,
];
}