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

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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) {

Notiek ielāde…
Atcelt
Saglabāt