Skip to content

Commit

Permalink
fix(ups): do not include delivery date for ups when exporting (#317)
Browse files Browse the repository at this point in the history
INT-711
  • Loading branch information
FlorianSDV authored Nov 14, 2024
1 parent abf4234 commit fc1eabc
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use MyParcelNL\Pdk\App\Order\Calculator\DhlParcelConnect\DhlParcelConnectCalculator;
use MyParcelNL\Pdk\App\Order\Calculator\Dpd\DpdCalculator;
use MyParcelNL\Pdk\App\Order\Calculator\PostNl\PostNLCalculator;
use MyParcelNL\Pdk\App\Order\Calculator\UPS\UPSCalculator;
use MyParcelNL\Pdk\App\Order\Contract\PdkOrderOptionCalculatorInterface;
use MyParcelNL\Pdk\Carrier\Model\Carrier;

Expand All @@ -24,6 +25,7 @@ final class CarrierSpecificCalculator extends AbstractPdkOrderOptionCalculator
Carrier::CARRIER_DHL_EUROPLUS_NAME => DhlEuroplusCalculator::class,
Carrier::CARRIER_DHL_PARCEL_CONNECT_NAME => DhlParcelConnectCalculator::class,
Carrier::CARRIER_DPD_NAME => DpdCalculator::class,
Carrier::CARRIER_UPS_NAME => UPSCalculator::class,
];

public function calculate(): void
Expand Down
17 changes: 17 additions & 0 deletions src/App/Order/Calculator/UPS/UPSCalculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace MyParcelNL\Pdk\App\Order\Calculator\UPS;

use MyParcelNL\Pdk\App\Order\Calculator\AbstractCarrierOptionsCalculator;

final class UPSCalculator extends AbstractCarrierOptionsCalculator
{
protected function getCalculators(): array
{
return [
UPSCountryShipmentOptionsCalculator::class,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace MyParcelNL\Pdk\App\Order\Calculator\UPS;

use MyParcelNL\Pdk\App\Order\Calculator\AbstractPdkOrderOptionCalculator;
use MyParcelNL\Pdk\App\Order\Model\PdkOrder;
use MyParcelNL\Pdk\Base\Contract\CountryServiceInterface;
use MyParcelNL\Pdk\Facade\Pdk;

class UPSCountryShipmentOptionsCalculator extends AbstractPdkOrderOptionCalculator
{
private $countryService;

public function __construct(PdkOrder $order)
{
parent::__construct($order);

$this->countryService = Pdk::get(CountryServiceInterface::class);
}

public function calculate(): void
{
$cc = $this->order->shippingAddress->cc;
if ($this->countryService->isRow($cc) || $this->countryService->isEu($cc)) {
$this->order->deliveryOptions->date = null;
}
}
}
15 changes: 15 additions & 0 deletions tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,21 @@ function () {
'accountHasCarrierSmallPackageContract' => true,
'carrierHasInternationalMailboxAllowed' => true,
],

'ups' => [
function () {
return factory(PdkOrderCollection::class)->push(
factory(PdkOrder::class)
->toTheUnitedStates()
->withDeliveryOptions(
factory(DeliveryOptions::class)
->withCarrier(factory(Carrier::class)->fromUPS())
)
);
},
'accountHasCarrierSmallPackageContract' => false,
'carrierHasInternationalMailboxAllowed' => false,
],
])
->with('orderModeToggle');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"data": {
"shipments": [
{
"carrier": 8,
"customs_declaration": {
"contents": 1,
"invoice": "PDK-1",
"items": [
{
"amount": 1,
"classification": "000000",
"country": "NL",
"description": "test",
"item_value": {
"amount": 1000,
"currency": "EUR"
},
"weight": 0
}
],
"weight": 1
},
"general_settings": {
"save_recipient_address": 0
},
"options": {
"package_type": 1,
"delivery_type": 2
},
"physical_properties": {
"weight": 1
},
"recipient": {
"cc": "US",
"city": "Cupertino",
"company": "MyParcel",
"person": "Felicia Parcel",
"postal_code": "95014",
"state": "CA",
"street": "1 Infinite Loop",
"vat_number": "NL123456789B01"
},
"reference_identifier": "PDK-1"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"data": {
"shipments": [
{
"carrier": 8,
"customs_declaration": {
"contents": 1,
"invoice": "PDK-1",
"items": [
{
"amount": 1,
"classification": "000000",
"country": "NL",
"description": "test",
"item_value": {
"amount": 1000,
"currency": "EUR"
},
"weight": 0
}
],
"weight": 1
},
"general_settings": {
"save_recipient_address": 0
},
"options": {
"package_type": 1,
"delivery_type": 2
},
"physical_properties": {
"weight": 1
},
"recipient": {
"cc": "US",
"city": "Cupertino",
"company": "MyParcel",
"person": "Felicia Parcel",
"postal_code": "95014",
"state": "CA",
"street": "1 Infinite Loop",
"vat_number": "NL123456789B01"
},
"reference_identifier": "PDK-1"
}
]
}
}

0 comments on commit fc1eabc

Please sign in to comment.