Selaa lähdekoodia

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

refactoring
Guillaume 2 vuotta sitten
vanhempi
commit
c7daf0b46e
1 muutettua tiedostoa jossa 27 lisäystä ja 20 poistoa
  1. +27
    -20
      backend/controllers/DocumentController.php

+ 27
- 20
backend/controllers/DocumentController.php Näytä tiedosto

@@ -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(

Loading…
Peruuta
Tallenna