@@ -21,7 +21,9 @@ | |||
<?= Price::format($price) ?> | |||
</td> | |||
<?php endif; ?> | |||
<td class="align-center"><?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?></td> | |||
<td class="align-center"> | |||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | |||
</td> | |||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | |||
<?php if($displayPrices): ?> | |||
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?> |
@@ -106,16 +106,16 @@ $displayProductDescription = Producer::getConfig('document_display_product_descr | |||
<?php endforeach; ?> | |||
<?php endforeach; ?> | |||
<?php else: ?> | |||
<?php foreach($document->getProductsOrders() as $product): ?> | |||
<?php foreach($product as $productOrder): ?> | |||
<?= $this->render('_download_product_line', [ | |||
'document' => $document, | |||
'productOrder' => $productOrder, | |||
'displayPrices' => $displayPrices, | |||
'displayProductDescription' => $displayProductDescription | |||
]) ?> | |||
<?php endforeach; ?> | |||
<?php foreach($document->getProductsOrders() as $product): ?> | |||
<?php foreach($product as $productOrder): ?> | |||
<?= $this->render('_download_product_line', [ | |||
'document' => $document, | |||
'productOrder' => $productOrder, | |||
'displayPrices' => $displayPrices, | |||
'displayProductDescription' => $displayProductDescription | |||
]) ?> | |||
<?php endforeach; ?> | |||
<?php endforeach; ?> | |||
<?php endif; ?> | |||
<?php if($displayPrices): ?> | |||
<?php $typeAmount = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL ; ?> |
@@ -96,7 +96,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function($invoice) { | |||
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||
} | |||
], | |||
[ |
@@ -342,26 +342,25 @@ class Document extends ActiveRecordCommon | |||
if ($ordersArray && count($ordersArray)) { | |||
foreach ($ordersArray as $order) { | |||
foreach ($order->productOrder as $productOrder) { | |||
//$indexProductOrder = $productOrder->id_product ; | |||
$indexProductOrder = $productOrder->product->order ; | |||
$newProductOrder = clone $productOrder ; | |||
if (!isset($productsOrdersArray[$indexProductOrder])) { | |||
$newProductOrder = clone $productOrder ; | |||
$productsOrdersArray[$indexProductOrder] = [$newProductOrder]; | |||
} else { | |||
$productOrderMatch = false; | |||
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { | |||
if ($theProductOrder->unit == $productOrder->unit | |||
&& ($theProductOrder->price == $productOrder->price | |||
|| ($this->isInvoicePrice() | |||
&& $theProductOrder->invoice_price == $productOrder->invoice_price))) { | |||
&& ( (!$this->isInvoicePrice() && $theProductOrder->price == $productOrder->price) | |||
|| ($this->isInvoicePrice() && $theProductOrder->invoice_price == $productOrder->invoice_price) | |||
)) { | |||
$theProductOrder->quantity += $productOrder->quantity; | |||
$productOrderMatch = true; | |||
} | |||
} | |||
if (!$productOrderMatch) { | |||
$productsOrdersArray[$indexProductOrder][] = $productOrder; | |||
$productsOrdersArray[$indexProductOrder][] = $newProductOrder; | |||
} | |||
} | |||
} |
@@ -251,7 +251,13 @@ class Order extends ActiveRecordCommon | |||
$productOrder->taxRate->value | |||
) * $productOrder->quantity; | |||
$invoicePrice = $productOrder->invoice_price ? $productOrder->invoice_price : $productOrder->price; | |||
if($productOrder->invoice_price) { | |||
$invoicePrice = $productOrder->invoice_price; | |||
} | |||
else { | |||
$invoicePrice = $productOrder->price; | |||
} | |||
$this->invoice_amount += $invoicePrice * $productOrder->quantity; | |||
$this->invoice_amount_with_tax += Price::getPriceWithTax( | |||
$invoicePrice, | |||
@@ -416,7 +422,7 @@ class Order extends ActiveRecordCommon | |||
public function getAmount($type = self::AMOUNT_TOTAL, $format = false) | |||
{ | |||
$amount = $this->amount; | |||
if ($type == self::INVOICE_AMOUNT_TOTAL) { | |||
if ($type == self::INVOICE_AMOUNT_TOTAL && $this->invoice_amount) { | |||
$amount = $this->invoice_amount; | |||
} | |||
@@ -426,7 +432,7 @@ class Order extends ActiveRecordCommon | |||
public function getAmountWithTax($type = self::AMOUNT_TOTAL, $format = false) | |||
{ | |||
$amount = $this->amount_with_tax; | |||
if ($type == self::INVOICE_AMOUNT_TOTAL) { | |||
if ($type == self::INVOICE_AMOUNT_TOTAL && $this->invoice_amount) { | |||
$amount = $this->invoice_amount_with_tax; | |||
} | |||