diff --git a/src/App/Order/Calculator/General/LabelDescriptionCalculator.php b/src/App/Order/Calculator/General/LabelDescriptionCalculator.php index b3d16c1cc..05df17abc 100644 --- a/src/App/Order/Calculator/General/LabelDescriptionCalculator.php +++ b/src/App/Order/Calculator/General/LabelDescriptionCalculator.php @@ -35,7 +35,7 @@ private function calculateDescription(): string $labelDescription = preg_replace_callback_array([ '/\[ORDER_ID\]/' => function () { - return $this->order->orderNumber; + return $this->order->referenceIdentifier; }, '/\[CUSTOMER_NOTE\]/' => function () { diff --git a/src/App/Order/Model/PdkOrder.php b/src/App/Order/Model/PdkOrder.php index 01955ada4..57bf9259e 100644 --- a/src/App/Order/Model/PdkOrder.php +++ b/src/App/Order/Model/PdkOrder.php @@ -23,6 +23,7 @@ /** * @property null|string $externalIdentifier * @property null|string $apiIdentifier + * @property null|string $referenceIdentifier * @property null|\MyParcelNL\Pdk\Shipment\Model\CustomsDeclaration $customsDeclaration * @property \MyParcelNL\Pdk\Shipment\Model\DeliveryOptions $deliveryOptions * @property \MyParcelNL\Pdk\App\Order\Collection\PdkOrderLineCollection $lines @@ -33,7 +34,6 @@ * @property null|\MyParcelNL\Pdk\Shipment\Collection\ShipmentCollection $shipments * @property null|\MyParcelNL\Pdk\Shipment\Model\PhysicalProperties $physicalProperties * @property null|\DateTimeImmutable $orderDate - * @property null|string $orderNumber * @property bool $exported * @property int $shipmentPrice * @property int $shipmentPriceAfterVat @@ -49,10 +49,13 @@ class PdkOrder extends Model implements StorableArrayable { protected $attributes = [ /** Plugin order id */ - 'externalIdentifier' => null, + 'externalIdentifier' => null, /** Fulfilment order ID from MyParcel */ - 'apiIdentifier' => null, + 'apiIdentifier' => null, + + /** Custom order number given by plugin */ + 'referenceIdentifier' => null, 'deliveryOptions' => DeliveryOptions::class, @@ -73,7 +76,6 @@ class PdkOrder extends Model implements StorableArrayable * Timestamp of when the order was placed. */ 'orderDate' => null, - 'orderNumber' => null, /** * Whether the order has been exported as an entire order. Applicable only when using order mode. @@ -110,7 +112,7 @@ class PdkOrder extends Model implements StorableArrayable 'notes' => PdkOrderNoteCollection::class, 'orderDate' => 'datetime', - 'orderNumber' => 'string', + 'referenceIdentifier' => 'string', 'exported' => 'bool', 'shipmentPrice' => 'int', 'shipmentPriceAfterVat' => 'int', @@ -154,21 +156,21 @@ public function __construct(?array $data = null) public static function fromFulfilmentOrder(Order $order): self { return new self([ - 'externalIdentifier' => $order->externalIdentifier, - 'apiIdentifier' => $order->uuid, - 'orderDate' => $order->orderDate, - 'orderNumber' => $order->orderNumber, - 'invoiceAddress' => $order->invoiceAddress, - 'dropOffPoint' => $order->dropOffPoint, - 'notes' => new PdkOrderNoteCollection($order->notes->all()), - 'lines' => new PdkOrderLineCollection($order->lines->all()), - 'status' => $order->status, - 'type' => $order->type, - 'price' => $order->price, - 'vat' => $order->vat, - 'priceAfterVat' => $order->priceAfterVat, - 'createdAt' => $order->createdAt, - 'updatedAt' => $order->updatedAt, + 'externalIdentifier' => $order->externalIdentifier, + 'apiIdentifier' => $order->uuid, + 'orderDate' => $order->orderDate, + 'referenceIdentifier' => $order->referenceIdentifier, + 'invoiceAddress' => $order->invoiceAddress, + 'dropOffPoint' => $order->dropOffPoint, + 'notes' => new PdkOrderNoteCollection($order->notes->all()), + 'lines' => new PdkOrderLineCollection($order->lines->all()), + 'status' => $order->status, + 'type' => $order->type, + 'price' => $order->price, + 'vat' => $order->vat, + 'priceAfterVat' => $order->priceAfterVat, + 'createdAt' => $order->createdAt, + 'updatedAt' => $order->updatedAt, ]); } diff --git a/src/Fulfilment/Model/Order.php b/src/Fulfilment/Model/Order.php index 405822c26..2bf11f594 100644 --- a/src/Fulfilment/Model/Order.php +++ b/src/Fulfilment/Model/Order.php @@ -25,7 +25,7 @@ * @property null|\MyParcelNL\Pdk\Base\Model\ContactDetails $invoiceAddress * @property null|string $language * @property null|\DateTime $orderDate - * @property null|string $orderNumber + * @property null|string $referenceIdentifier * @property \MyParcelNL\Pdk\Fulfilment\Collection\OrderLineCollection $lines * @property \MyParcelNL\Pdk\Fulfilment\Collection\OrderNoteCollection $notes * @property null|\MyParcelNL\Pdk\Fulfilment\Model\Shipment $shipment @@ -49,7 +49,7 @@ class Order extends Model 'invoiceAddress' => null, 'language' => null, 'orderDate' => null, - 'orderNumber' => null, + 'referenceIdentifier' => null, 'lines' => OrderLineCollection::class, 'notes' => OrderNoteCollection::class, 'shipment' => null, @@ -72,7 +72,7 @@ class Order extends Model 'invoiceAddress' => ContactDetails::class, 'language' => 'string', 'orderDate' => 'datetime', - 'orderNumber' => 'string', + 'referenceIdentifier' => 'string', 'lines' => OrderLineCollection::class, 'notes' => OrderNoteCollection::class, 'shipment' => Shipment::class, @@ -108,7 +108,7 @@ public static function fromPdkOrder(?PdkOrder $pdkOrder): self 'invoiceAddress' => $pdkOrder->billingAddress ?? null, 'language' => Language::getIso2(), 'orderDate' => $pdkOrder->orderDate, - 'orderNumber' => $pdkOrder->orderNumber, + 'referenceIdentifier' => $pdkOrder->referenceIdentifier, 'lines' => $pdkOrder->lines ->map(function (PdkOrderLine $pdkOrderLine) { return new OrderLine( diff --git a/tests/Unit/App/Order/Calculator/General/LabelDescriptionCalculatorTest.php b/tests/Unit/App/Order/Calculator/General/LabelDescriptionCalculatorTest.php index 3fc44e66b..d498aee93 100644 --- a/tests/Unit/App/Order/Calculator/General/LabelDescriptionCalculatorTest.php +++ b/tests/Unit/App/Order/Calculator/General/LabelDescriptionCalculatorTest.php @@ -24,7 +24,7 @@ function createOrder($labelDescription): PdkOrder { return factory(PdkOrder::class) - ->withOrderNumber('123') + ->withReferenceIdentifier('123') ->withDeliveryOptions(['shipmentOptions' => ['labelDescription' => $labelDescription]]) ->withLines([ factory(PdkOrderLine::class) diff --git a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_multiple_orders__1.json b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_multiple_orders__1.json index 517a8a9ba..5222aa9f5 100644 --- a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_multiple_orders__1.json +++ b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_multiple_orders__1.json @@ -140,7 +140,7 @@ "lines": [], "notes": [], "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "exported": false, "shipmentPrice": 0, "shipmentPriceAfterVat": 0, @@ -306,7 +306,7 @@ "lines": [], "notes": [], "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "exported": false, "shipmentPrice": 0, "shipmentPriceAfterVat": 0, diff --git a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_single_order__1.json b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_single_order__1.json index 953ef8397..6cc2b672d 100644 --- a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_single_order__1.json +++ b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_single_order__1.json @@ -140,7 +140,7 @@ "lines": [], "notes": [], "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "exported": false, "shipmentPrice": 0, "shipmentPriceAfterVat": 0, diff --git a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_box__1.json b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_box__1.json index 163c07d4c..4cf3ee6bb 100644 --- a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_box__1.json +++ b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_box__1.json @@ -137,7 +137,7 @@ "lines": [], "notes": [], "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "exported": false, "shipmentPrice": 0, "shipmentPriceAfterVat": 0, diff --git a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_list_column__1.json b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_list_column__1.json index eb3980f06..78aea7e7b 100644 --- a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_list_column__1.json +++ b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_order_list_column__1.json @@ -137,7 +137,7 @@ "lines": [], "notes": [], "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "exported": false, "shipmentPrice": 0, "shipmentPriceAfterVat": 0, diff --git a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_empty_order__1.json b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_empty_order__1.json index 5fb724e8e..15a2adbee 100644 --- a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_empty_order__1.json +++ b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_empty_order__1.json @@ -8,7 +8,7 @@ "invoiceAddress": null, "language": "nl", "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "lines": [], "notes": [], "shipment": { diff --git a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_with_shipments__1.json b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_with_shipments__1.json index 5fb724e8e..15a2adbee 100644 --- a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_with_shipments__1.json +++ b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_with_shipments__1.json @@ -8,7 +8,7 @@ "invoiceAddress": null, "language": "nl", "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "lines": [], "notes": [], "shipment": { diff --git a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_without_shipments__1.json b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_without_shipments__1.json index 47e33e1b2..01be52989 100644 --- a/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_without_shipments__1.json +++ b/tests/__snapshots__/OrderTest__it_creates_fulfilment_order_from_pdk_order_with_data_set_order_without_shipments__1.json @@ -8,7 +8,7 @@ "invoiceAddress": null, "language": "nl", "orderDate": "2023-01-01 00:00:00", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": null, diff --git a/tests/__snapshots__/OrderTest__it_returns_empty_fulfilment_order_when_no_pdk_order_is_passed__1.json b/tests/__snapshots__/OrderTest__it_returns_empty_fulfilment_order_when_no_pdk_order_is_passed__1.json index b8a0532d4..1711e2aca 100644 --- a/tests/__snapshots__/OrderTest__it_returns_empty_fulfilment_order_when_no_pdk_order_is_passed__1.json +++ b/tests/__snapshots__/OrderTest__it_returns_empty_fulfilment_order_when_no_pdk_order_is_passed__1.json @@ -8,7 +8,7 @@ "invoiceAddress": null, "language": null, "orderDate": null, - "orderNumber": null, + "referenceIdentifier": null, "lines": [], "notes": [], "shipment": null, diff --git a/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_containing_many_attributes__1.json b/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_containing_many_attributes__1.json index 419eb0a6d..23e8fa432 100644 --- a/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_containing_many_attributes__1.json +++ b/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_containing_many_attributes__1.json @@ -9,7 +9,7 @@ "invoiceAddress": null, "language": null, "orderDate": "2022-08-22 00:00:00", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": "1234", diff --git a/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_with_pickup__1.json b/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_with_pickup__1.json index 419eb0a6d..23e8fa432 100644 --- a/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_with_pickup__1.json +++ b/tests/__snapshots__/PostOrdersTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_one_order_with_pickup__1.json @@ -9,7 +9,7 @@ "invoiceAddress": null, "language": null, "orderDate": "2022-08-22 00:00:00", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": "1234", diff --git a/tests/__snapshots__/QueryTest__it_creates_order_collection_from_queried_data__1.json b/tests/__snapshots__/QueryTest__it_creates_order_collection_from_queried_data__1.json index f99e350f1..0ae960b2b 100644 --- a/tests/__snapshots__/QueryTest__it_creates_order_collection_from_queried_data__1.json +++ b/tests/__snapshots__/QueryTest__it_creates_order_collection_from_queried_data__1.json @@ -21,7 +21,7 @@ }, "language": "nl", "orderDate": "2022-11-24 20:16:45", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": "4040ae40-d54a-4a64-aa5a-1ebd73680fdc", diff --git a/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_containing_many_attributes__1.json b/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_containing_many_attributes__1.json index 419eb0a6d..23e8fa432 100644 --- a/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_containing_many_attributes__1.json +++ b/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_containing_many_attributes__1.json @@ -9,7 +9,7 @@ "invoiceAddress": null, "language": null, "orderDate": "2022-08-22 00:00:00", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": "1234", diff --git a/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_with_pickup__1.json b/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_with_pickup__1.json index 419eb0a6d..23e8fa432 100644 --- a/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_with_pickup__1.json +++ b/tests/__snapshots__/SaveOrderTest__it_creates_a_valid_order_collection_from_api_data_with_data_set_order_with_pickup__1.json @@ -9,7 +9,7 @@ "invoiceAddress": null, "language": null, "orderDate": "2022-08-22 00:00:00", - "orderNumber": null, + "referenceIdentifier": null, "lines": [ { "uuid": "1234", diff --git a/tests/factories/App/Order/Model/PdkOrderFactory.php b/tests/factories/App/Order/Model/PdkOrderFactory.php index 9ec5d3323..9e436fc3b 100644 --- a/tests/factories/App/Order/Model/PdkOrderFactory.php +++ b/tests/factories/App/Order/Model/PdkOrderFactory.php @@ -34,7 +34,7 @@ * @method $this withExported(bool $exported) * @method $this withExternalIdentifier(string $externalIdentifier) * @method $this withOrderDate(string|DateTimeImmutable $orderDate) - * @method $this withOrderNumber(string $orderNumber) + * @method $this withReferenceIdentifier(string $referenceIdentifier) * @method $this withOrderPrice(int $orderPrice) * @method $this withOrderPriceAfterVat(int $orderPriceAfterVat) * @method $this withOrderVat(int $orderVat)