Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename order number to reference identifier #212

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
42 changes: 22 additions & 20 deletions src/App/Order/Model/PdkOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,

Expand All @@ -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.
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
]);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Fulfilment/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
function createOrder($labelDescription): PdkOrder
{
return factory(PdkOrder::class)
->withOrderNumber('123')
->withReferenceIdentifier('123')
->withDeliveryOptions(['shipmentOptions' => ['labelDescription' => $labelDescription]])
->withLines([
factory(PdkOrderLine::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"lines": [],
"notes": [],
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"exported": false,
"shipmentPrice": 0,
"shipmentPriceAfterVat": 0,
Expand Down Expand Up @@ -306,7 +306,7 @@
"lines": [],
"notes": [],
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"exported": false,
"shipmentPrice": 0,
"shipmentPriceAfterVat": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"lines": [],
"notes": [],
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"exported": false,
"shipmentPrice": 0,
"shipmentPriceAfterVat": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"lines": [],
"notes": [],
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"exported": false,
"shipmentPrice": 0,
"shipmentPriceAfterVat": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"lines": [],
"notes": [],
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"exported": false,
"shipmentPrice": 0,
"shipmentPriceAfterVat": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"invoiceAddress": null,
"language": "nl",
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"lines": [],
"notes": [],
"shipment": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"invoiceAddress": null,
"language": "nl",
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"lines": [],
"notes": [],
"shipment": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"invoiceAddress": null,
"language": "nl",
"orderDate": "2023-01-01 00:00:00",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"invoiceAddress": null,
"language": null,
"orderDate": null,
"orderNumber": null,
"referenceIdentifier": null,
"lines": [],
"notes": [],
"shipment": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"invoiceAddress": null,
"language": null,
"orderDate": "2022-08-22 00:00:00",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": "1234",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"invoiceAddress": null,
"language": null,
"orderDate": "2022-08-22 00:00:00",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": "1234",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"language": "nl",
"orderDate": "2022-11-24 20:16:45",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": "4040ae40-d54a-4a64-aa5a-1ebd73680fdc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"invoiceAddress": null,
"language": null,
"orderDate": "2022-08-22 00:00:00",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": "1234",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"invoiceAddress": null,
"language": null,
"orderDate": "2022-08-22 00:00:00",
"orderNumber": null,
"referenceIdentifier": null,
"lines": [
{
"uuid": "1234",
Expand Down
2 changes: 1 addition & 1 deletion tests/factories/App/Order/Model/PdkOrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down