Skip to content

Commit

Permalink
removed constraint for retail price
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Feb 28, 2018
1 parent 3f5ed81 commit fd7ecf4
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Entity/StockMovement.php
Expand Up @@ -326,12 +326,11 @@ public static function create(int $quantity, Money $unitPrice, float $vatPercent
->setReference($reference)
;

$retailPrice = $unitPrice;
if ($product->getPrices()->count()) {
$retailPrice = $product->findPriceByCurrency($unitPrice->getCurrency());
if ($retailPrice) {
$retailPrice = $retailPrice->getUnitPriceExclVat($vatPercent);
}
$retailPrice = $product->findPriceByCurrency($unitPrice->getCurrency());
if($retailPrice) {
$retailPrice = $retailPrice->getUnitPriceExclVat($vatPercent);
} else {
$retailPrice = $unitPrice;
}

$stockMovement->setRetailPrice($retailPrice);
Expand Down Expand Up @@ -364,12 +363,11 @@ public function populateFromOrderLine(OrderLineInterface $orderLine)
->setCreatedAt($created) // for order lines we specifically override the createdAt and updatedAt dates because the stock movement is actually happening when the order comes in and not when the order is synced
;

$retailPrice = $orderLine->getUnitPriceExclVat();
if ($orderLine->getProduct()->getPrices()->count()) {
$retailPrice = $orderLine->getProduct()->findPriceByCurrency($orderLine->getUnitPrice()->getCurrency());
if (!$retailPrice) {
$retailPrice = $retailPrice->getUnitPriceExclVat($orderLine->getVatPct());
}
$retailPrice = $orderLine->getProduct()->findPriceByCurrency($orderLine->getUnitPrice()->getCurrency());
if($retailPrice) {
$retailPrice = $retailPrice->getUnitPriceExclVat($orderLine->getVatPct());
} else {
$retailPrice = $orderLine->getUnitPriceExclVat();
}

$this->setRetailPrice($retailPrice);
Expand Down

0 comments on commit fd7ecf4

Please sign in to comment.