Skip to content

Commit

Permalink
fix(orders): fix contract ids being ignored on export
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Feb 14, 2024
1 parent 259b0f8 commit 35028f6
Show file tree
Hide file tree
Showing 30 changed files with 84 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Fulfilment/Request/PostOrdersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private function getShipment(Order $order): array

return [
'carrier' => $shipment->carrier,
'contract_id' => $shipment->contractId ? (int) $shipment->contractId : null,
'customs_declaration' => $this->encodeCustomsDeclaration($shipment),
'drop_off_point' => $shipment->dropOffPoint
? $shipment->dropOffPoint->toArray(Arrayable::ENCODED)
Expand Down
3 changes: 3 additions & 0 deletions src/Shipment/Request/PostShipmentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ protected function encodeShipment(Shipment $shipment): array
{
return Utils::filterNull([
'carrier' => $shipment->carrier->id,
'contract_id' => $shipment->carrier->subscriptionId
? (int) $shipment->carrier->subscriptionId
: null,
'customs_declaration' => $this->encodeCustomsDeclaration($shipment),
'drop_off_point' => $this->getDropOffPoint($shipment),
'general_settings' => [
Expand Down
6 changes: 5 additions & 1 deletion tests/Datasets/pdkOrdersToNl.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
'carrier dhl for you' => function () {
return factory(PdkOrderCollection::class)->push(
factory(PdkOrder::class)
->withDeliveryOptions(factory(DeliveryOptions::class)->withCarrier(Carrier::CARRIER_DHL_FOR_YOU_NAME))
->withDeliveryOptions(
factory(DeliveryOptions::class)->withCarrier(
sprintf('%s:1234', Carrier::CARRIER_DHL_FOR_YOU_NAME)
)
)
);
},

Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/Shipment/Repository/CreateConceptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ function (ShipmentCollectionFactory $shipmentCollectionFactory) {
);
},
],
'subscription carrier' => [
'input' => function () {
return factory(ShipmentCollection::class)->push(
factory(Shipment::class)
->withCarrier(
factory(Carrier::class)
->withId(Carrier::CARRIER_POSTNL_ID)
->withSubscriptionId(1234)
->withCapabilities(
factory(CarrierCapabilities::class)->withEverything()
)
)
->withRecipient(DEFAULT_INPUT_RECIPIENT)
);
},
],
'address with address1 and address2 combined' => [
'input' => function () {
return factory(ShipmentCollection::class)->push(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"carrier": 1,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
"options": {
"package_type": 1,
"delivery_type": 2
},
"physical_properties": {
"weight": 0
},
"recipient": {
"cc": "NL",
"city": "Hoofddorp",
"person": "Jaap Krekel",
"postal_code": "2132JE"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shipments": [
{
"carrier": 9,
"contract_id": 1234,
"general_settings": {
"save_recipient_address": 0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": 1234,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -93,6 +94,7 @@
],
"shipment": {
"carrier": 1,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down Expand Up @@ -156,6 +158,7 @@
],
"shipment": {
"carrier": 9,
"contract_id": null,
"customs_declaration": null,
"drop_off_point": null,
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"exported": false,
"deliveryOptions": {
"carrier": {
"externalIdentifier": "dhlforyou"
"externalIdentifier": "dhlforyou:1234"
},
"labelAmount": 1,
"shipmentOptions": {
Expand Down

0 comments on commit 35028f6

Please sign in to comment.