// montant et poids des commandes | // montant et poids des commandes | ||||
$revenues = 0; | $revenues = 0; | ||||
$revenuesWithTax = 0; | |||||
$weight = 0; | $weight = 0; | ||||
if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
$orderModule->initOrder($order); | $orderModule->initOrder($order); | ||||
if (is_null($order->date_delete)) { | if (is_null($order->date_delete)) { | ||||
$revenues += $orderModule->getOrderAmountWithTax($order); | |||||
$revenues += $orderModule->getOrderAmount($order); | |||||
$revenuesWithTax += $orderModule->getOrderAmountWithTax($order); | |||||
$weight += $order->weight; | $weight += $order->weight; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$distributionJsonData['revenues'] = Price::format($revenues); | $distributionJsonData['revenues'] = Price::format($revenues); | ||||
$distributionJsonData['revenues_with_tax'] = Price::format($revenuesWithTax); | |||||
$distributionJsonData['weight'] = number_format($weight, 2); | $distributionJsonData['weight'] = number_format($weight, 2); | ||||
$distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | $distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | ||||
$distributionJsonData['potential_revenues_with_tax'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray, true)); | |||||
$distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | $distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | ||||
return $distributionJsonData; | return $distributionJsonData; |
<div id="summary-ca-weight" class="info-box col-md-4"> | <div id="summary-ca-weight" class="info-box col-md-4"> | ||||
<span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span> | <span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text">CA (TTC)</span> | |||||
<span class="info-box-number">{{ distribution.revenues }} <span class="normal" v-if="distribution.potential_revenues != '0,00 €'">/ {{ distribution.potential_revenues }}</span></span> | |||||
<span class="info-box-text">CA (HT)</span> | |||||
<span class="info-box-number"> | |||||
<span data-toggle="tooltip" data-placement="bottom" :data-original-title="distribution.revenues_with_tax+' TTC'">{{ distribution.revenues }}</span> | |||||
<span class="normal" v-if="distribution.potential_revenues != '0,00 €'">/ <span data-toggle="tooltip" data-placement="bottom" :data-original-title="distribution.potential_revenues_with_tax+' TTC'">{{ distribution.potential_revenues }}</span></span> | |||||
</span> | |||||
<span class="info-box-text">Poids</span> | <span class="info-box-text">Poids</span> | ||||
<span class="info-box-number">{{ distribution.weight }} kg <span class="normal" v-if="distribution.potential_weight > 0">/ {{ distribution.potential_weight }} kg</span></span> | <span class="info-box-number">{{ distribution.weight }} kg <span class="normal" v-if="distribution.potential_weight > 0">/ {{ distribution.potential_weight }} kg</span></span> | ||||
</div> | </div> |
return $productArrayFilter; | return $productArrayFilter; | ||||
} | } | ||||
public function getProductDistributionPotentialRevenues(array $productsArray) | |||||
public function getProductDistributionPotentialRevenues(array $productsArray, bool $withTax = false) | |||||
{ | { | ||||
$potentialRevenues = 0; | $potentialRevenues = 0; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
if (isset($product['productDistribution'][0]) && $product['productDistribution'][0]['active'] && $product['productDistribution'][0]['quantity_max']) { | if (isset($product['productDistribution'][0]) && $product['productDistribution'][0]['active'] && $product['productDistribution'][0]['quantity_max']) { | ||||
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $product['price']; | |||||
$price = $withTax ? $product['price_with_tax'] : $product['price']; | |||||
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $price; | |||||
} | } | ||||
} | } | ||||