Pārlūkot izejas kodu

Documents : correctif getProductOrders() group by invoice price

feature/souke
Guillaume Bourgeois pirms 10 mēnešiem
vecāks
revīzija
8d8a388b29
3 mainītis faili ar 13 papildinājumiem un 9 dzēšanām
  1. +1
    -1
      backend/controllers/DocumentController.php
  2. +1
    -1
      backend/views/document/download.php
  3. +11
    -7
      common/logic/Document/Document/Service/DocumentSolver.php

+ 1
- 1
backend/controllers/DocumentController.php Parādīt failu

'Code Classification vente', 'Code Classification vente',
]; ];


foreach ($documentModule->getProductsOrders($document) as $productOrderArray) {
foreach ($documentModule->getProductsOrders($document, true) as $productOrderArray) {
foreach ($productOrderArray as $productOrder) { foreach ($productOrderArray as $productOrder) {


$price = $productOrder->getPrice(); $price = $productOrder->getPrice();

+ 1
- 1
backend/views/document/download.php Parādīt failu

<?php endforeach; ?> <?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php else: ?> <?php else: ?>
<?php foreach ($documentModule->getProductsOrders($document) as $product): ?>
<?php foreach ($documentModule->getProductsOrders($document, true) as $product): ?>
<?php foreach ($product as $productOrder): ?> <?php foreach ($product as $productOrder): ?>
<?= $this->render('_download_product_line', [ <?= $this->render('_download_product_line', [
'producer' => $producer, 'producer' => $producer,

+ 11
- 7
common/logic/Document/Document/Service/DocumentSolver.php Parādīt failu

return $this->isStatus($document, Document::STATUS_VALID); return $this->isStatus($document, Document::STATUS_VALID);
} }


public function getProductsOrders(DocumentInterface $document): array
public function getProductsOrders(DocumentInterface $document, bool $groupByInvoicePrice = false): array
{ {
$productsOrdersArray = []; $productsOrdersArray = [];
$ordersArray = $document->orders; $ordersArray = $document->orders;
} else { } else {
$productOrderMatch = false; $productOrderMatch = false;
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) {
if ($theProductOrder->unit == $productOrder->unit
&& $theProductOrder->price == $productOrder->price
&& $theProductOrder->invoice_price == $productOrder->invoice_price) {

$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
if ($theProductOrder->unit == $productOrder->unit) {
if($groupByInvoicePrice && $theProductOrder->invoice_price == $productOrder->invoice_price) {
$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
}
elseif($theProductOrder->price == $productOrder->price
&& $theProductOrder->invoice_price == $productOrder->invoice_price) {
$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
}
} }
} }
if (!$productOrderMatch) { if (!$productOrderMatch) {

Notiek ielāde…
Atcelt
Saglabāt