Skip to content

Commit

Permalink
added saveOrderTo Convertim
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasLudvik committed Oct 25, 2024
1 parent 4192024 commit a811985
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Model/Order/Item/OrderItemData.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,17 @@ public function getUnitPrice(): Price
{
return new Price($this->unitPriceWithoutVat, $this->unitPriceWithVat);
}

/**
* @return string|null
*/
public function getItemUuid(): ?string
{
return match ($this->type) {
OrderItemTypeEnum::TYPE_PRODUCT => $this->product->getUuid(),
OrderItemTypeEnum::TYPE_TRANSPORT => $this->transport->getUuid(),
OrderItemTypeEnum::TYPE_PAYMENT => $this->payment->getUuid(),
default => null,
};
}
}
8 changes: 7 additions & 1 deletion src/Model/Order/Item/OrderItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function createOrderItem(
): OrderItem {
$entityClassName = $this->entityNameResolver->resolve(OrderItem::class);

return new $entityClassName(
$orderItem = new $entityClassName(
$order,
$orderItemData->name,
new Price($orderItemData->unitPriceWithoutVat, $orderItemData->unitPriceWithVat),
Expand All @@ -42,6 +42,12 @@ public function createOrderItem(
$orderItemData->unitName,
$orderItemData->catnum,
);

if ($orderItemData->usePriceCalculation === false && $orderItemData->totalPriceWithVat !== null) {
$orderItem->setTotalPrice(new Price($orderItemData->totalPriceWithoutVat, $orderItemData->totalPriceWithVat));
}

return $orderItem;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Order/OrderDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function fillFromOrder(OrderData $orderData, Order $order): void
$orderData->companyName = $order->getCompanyName();
$orderData->companyNumber = $order->getCompanyNumber();
$orderData->companyTaxNumber = $order->getCompanyTaxNumber();
$orderData->isCompanyCustomer = $order->isCompanyCustomer();
$orderData->isCompanyCustomer = $order->getCompanyName() !== null && $order->getCompanyNumber() !== null;
$orderData->street = $order->getStreet();
$orderData->city = $order->getCity();
$orderData->postcode = $order->getPostcode();
Expand Down

0 comments on commit a811985

Please sign in to comment.