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 30, 2024
1 parent 54ab015 commit 45c8c1e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
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
10 changes: 10 additions & 0 deletions src/Model/Payment/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Shopsys\FrameworkBundle\Model\Localization\AbstractTranslatableEntity;
use Shopsys\FrameworkBundle\Model\Payment\Exception\PaymentDomainNotFoundException;
use Shopsys\FrameworkBundle\Model\Payment\Exception\PaymentPriceNotFoundException;
use Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat;
use Shopsys\FrameworkBundle\Model\Transport\Transport;

/**
Expand Down Expand Up @@ -506,4 +507,13 @@ public function isGatewayPayment(): bool
{
return in_array($this->type, $this->getGatewayPayments(), true);
}

/**
* @param int $domainId
* @return \Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat
*/
public function getVatForDomain(int $domainId): Vat
{
return $this->getPaymentDomain($domainId)->getVat();
}
}
10 changes: 10 additions & 0 deletions src/Model/Transport/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Shopsys\FrameworkBundle\Component\Grid\Ordering\OrderableEntityInterface;
use Shopsys\FrameworkBundle\Model\Localization\AbstractTranslatableEntity;
use Shopsys\FrameworkBundle\Model\Payment\Payment;
use Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat;
use Shopsys\FrameworkBundle\Model\Transport\Exception\TransportDomainNotFoundException;
use Shopsys\FrameworkBundle\Model\Transport\Exception\TransportPriceNotFoundException;

Expand Down Expand Up @@ -452,4 +453,13 @@ public function getType()
{
return $this->type;
}

/**
* @param int $domainId
* @return \Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat
*/
public function getVatForDomain(int $domainId): Vat
{
return $this->getTransportDomain($domainId)->getVat();
}
}

0 comments on commit 45c8c1e

Please sign in to comment.