ソースを参照

Documents : correctif getProductOrders() group by invoice price

feature/souke
Guillaume Bourgeois 10ヶ月前
コミット
8d8a388b29
3個のファイルの変更13行の追加9行の削除
  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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

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

読み込み中…
キャンセル
保存