Sfoglia il codice sorgente

Merge branch 'dev'

prodstable
Guillaume 2 anni fa
parent
commit
eb6b64a04f
1 ha cambiato i file con 27 aggiunte e 20 eliminazioni
  1. +27
    -20
      backend/controllers/DocumentController.php

+ 27
- 20
backend/controllers/DocumentController.php Vedi File

@@ -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…
Annulla
Salva