瀏覽代碼

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

Loading…
取消
儲存