Procházet zdrojové kódy

[Backend] Documents : bug génération BL vide #251

refactoring
Guillaume před 2 roky
rodič
revize
c7daf0b46e
1 změnil soubory, kde provedl 27 přidání a 20 odebrání
  1. +27
    -20
      backend/controllers/DocumentController.php

+ 27
- 20
backend/controllers/DocumentController.php Zobrazit soubor

@@ -358,6 +358,32 @@ class DocumentController extends BackendController
'id_user' => $document->user->id
]);

$productsArray = yii\helpers\ArrayHelper::map(
$productsArray,
'id',
function ($product) use ($document, $userProducer, $pointSale) {
return array_merge($product->getAttributes(), [
'price_with_tax' => $product->getPriceWithTax([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'price' => $product->getPrice([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'wording_unit' => $product->wording_unit,
'tax_rate' => $product->taxRate->value
]);
}
);

// ne fonctionne pas, à creuser
/*uasort($productsArray, function($a, $b) {
return $a['order'] < $b['order'] ? 1 : -1;
});*/

return [
'return' => 'success',
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value,
@@ -366,26 +392,7 @@ class DocumentController extends BackendController
'class' => $document->getClass()
]),
'id_user' => $document->user->id,
'products' => yii\helpers\ArrayHelper::map(
$productsArray,
'order',
function ($product) use ($document, $userProducer, $pointSale) {
return array_merge($product->getAttributes(), [
'price_with_tax' => $product->getPriceWithTax([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'price' => $product->getPrice([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'wording_unit' => $product->wording_unit,
'tax_rate' => $product->taxRate->value
]);
}
),
'products' => $productsArray,
'orders' => $ordersArray,
'total' => ($document->getClass() == 'Invoice' || $document->getClass(
) == 'DeliveryNote') ? $document->getAmount(

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