diff --git a/src/App/Order/Calculator/General/CarrierSpecificCalculator.php b/src/App/Order/Calculator/General/CarrierSpecificCalculator.php index 58db88c62..068badf79 100644 --- a/src/App/Order/Calculator/General/CarrierSpecificCalculator.php +++ b/src/App/Order/Calculator/General/CarrierSpecificCalculator.php @@ -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; @@ -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 diff --git a/src/App/Order/Calculator/UPS/UPSCalculator.php b/src/App/Order/Calculator/UPS/UPSCalculator.php new file mode 100644 index 000000000..9f89916bc --- /dev/null +++ b/src/App/Order/Calculator/UPS/UPSCalculator.php @@ -0,0 +1,17 @@ +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; + } + } +} diff --git a/tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php b/tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php index c8e6a8ee2..b2ad979bf 100644 --- a/tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php +++ b/tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php @@ -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'); diff --git a/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_default__1.json b/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_default__1.json new file mode 100644 index 000000000..178fcecfa --- /dev/null +++ b/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_default__1.json @@ -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" + } + ] + } +} diff --git a/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_order_mode__1.json b/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_order_mode__1.json new file mode 100644 index 000000000..178fcecfa --- /dev/null +++ b/tests/__snapshots__/ExportOrderActionTest__it_exports_international_orders_with_data_set_ups__data_set_order_mode__1.json @@ -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" + } + ] + } +}