<?php if($displayPrices): ?> | <?php if($displayPrices): ?> | ||||
<td class="align-center column-unit-price"> | <td class="align-center column-unit-price"> | ||||
<?php $displayPriceUnitReference = $producerModule->getSolver()->getConfig('option_document_display_price_unit_reference'); ?> | <?php $displayPriceUnitReference = $producerModule->getSolver()->getConfig('option_document_display_price_unit_reference'); ?> | ||||
<?php $priceUnitReference = $productOrderModule->getSolver()->getPriceUnitReference($productOrder); ?> | |||||
<?php $priceUnitReference = $productOrderModule->getSolver()->getPriceUnitReference($productOrder, true); ?> | |||||
<?php $priceUnitReferenceString = Price::format($priceUnitReference, $documentPriceDecimals).' / kg' ?> | <?php $priceUnitReferenceString = Price::format($priceUnitReference, $documentPriceDecimals).' / kg' ?> | ||||
<?php if($productOrder->unit == 'piece'): ?> | <?php if($productOrder->unit == 'piece'): ?> | ||||
<?= Price::format($price, $documentPriceDecimals) ?> | <?= Price::format($price, $documentPriceDecimals) ?> |
return $productOrder->price; | return $productOrder->price; | ||||
} | } | ||||
public function getPriceUnitReference(ProductOrder $productOrder): ?float | |||||
public function getPriceUnitReference(ProductOrder $productOrder, bool $isInvoicePrice = false): ?float | |||||
{ | { | ||||
$productOrderPrice = $productOrder->price; | |||||
if($isInvoicePrice) { | |||||
$productOrderPrice = $this->getInvoicePrice($productOrder); | |||||
} | |||||
if($productOrder->unit == 'piece') { | if($productOrder->unit == 'piece') { | ||||
if($productOrder->product->weight) { | if($productOrder->product->weight) { | ||||
$price = (1000 * $productOrder->price) / $productOrder->product->weight; | |||||
$price = (1000 * $productOrderPrice) / $productOrder->product->weight; | |||||
} | } | ||||
else { | else { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$price = $productOrder->price; | |||||
$price = $productOrderPrice; | |||||
} | } | ||||
return $price; | return $price; | ||||
} | } | ||||
public function getInvoicePrice(ProductOrder $productOrder) | |||||
{ | |||||
if($productOrder->invoice_price) { | |||||
return $productOrder->invoice_price; | |||||
} | |||||
else { | |||||
return $productOrder->price; | |||||
} | |||||
} | |||||
} | } |