Procházet zdrojové kódy

Documents : correctif getProductOrders() group by invoice price

feature/souke
Guillaume Bourgeois před 10 měsíci
rodič
revize
8d8a388b29
3 změnil soubory, kde provedl 13 přidání a 9 odebrání
  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 Zobrazit soubor

@@ -300,7 +300,7 @@ class DocumentController extends BackendController
'Code Classification vente',
];

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

$price = $productOrder->getPrice();

+ 1
- 1
backend/views/document/download.php Zobrazit soubor

@@ -137,7 +137,7 @@ $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price
<?php endforeach; ?>
<?php endforeach; ?>
<?php else: ?>
<?php foreach ($documentModule->getProductsOrders($document) as $product): ?>
<?php foreach ($documentModule->getProductsOrders($document, true) as $product): ?>
<?php foreach ($product as $productOrder): ?>
<?= $this->render('_download_product_line', [
'producer' => $producer,

+ 11
- 7
common/logic/Document/Document/Service/DocumentSolver.php Zobrazit soubor

@@ -189,7 +189,7 @@ class DocumentSolver extends AbstractService implements SolverInterface
return $this->isStatus($document, Document::STATUS_VALID);
}

public function getProductsOrders(DocumentInterface $document): array
public function getProductsOrders(DocumentInterface $document, bool $groupByInvoicePrice = false): array
{
$productsOrdersArray = [];
$ordersArray = $document->orders;
@@ -205,12 +205,16 @@ class DocumentSolver extends AbstractService implements SolverInterface
} else {
$productOrderMatch = false;
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) {

Načítá se…
Zrušit
Uložit