ソースを参照

[Administration] Distributions : refactoring gestion des bons de livraisons #1195

feature/souke
Guillaume Bourgeois 1年前
コミット
ab99ef438a
4個のファイルの変更20行の追加29行の削除
  1. +8
    -28
      backend/controllers/DistributionController.php
  2. +2
    -0
      common/helpers/Ajax.php
  3. +8
    -0
      common/logic/Document/Document/Service/DocumentBuilder.php
  4. +2
    -1
      composer.json

+ 8
- 28
backend/controllers/DistributionController.php ファイルの表示

@@ -1032,8 +1032,7 @@ class DistributionController extends BackendController

public function actionAjaxValidateDeliveryNotes($idOrders)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$orderManager = $this->getOrderManager();
$deliveryNoteManager = $this->getDeliveryNoteManager();

if (strlen($idOrders)) {
@@ -1041,38 +1040,19 @@ class DistributionController extends BackendController

if (is_array($idOrders) && count($idOrders) > 0) {
foreach ($idOrders as $idOrder) {
$order = Order::searchOne([
'id' => (int)$idOrder
]);

if ($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {
$deliveryNote = DeliveryNote::searchOne([
'id' => (int)$order->id_delivery_note
]);

if ($deliveryNote && $deliveryNoteManager->isStatusDraft($deliveryNote)) {
$deliveryNoteManager->changeStatus($deliveryNote, Document::STATUS_VALID);
$deliveryNoteManager->saveUpdate($deliveryNote);
$order = $orderManager->findOneOrderById($idOrder);
if ($order && $orderManager->isOrderFromProducer($order)) {
$deliveryNote = $deliveryNoteManager->findOneDeliveryNoteById((int)$order->id_delivery_note);
if($deliveryNote) {
$deliveryNoteManager->validateDocument($deliveryNote);
}
}
}

return [
'return' => 'success',
'alert' => [
'type' => 'success',
'message' => 'Bon(s) de livraison validé(s)'
]
];
return Ajax::responseSuccess('Bon(s) de livraison validé(s)');
}
}

return [
'return' => 'error',
'alert' => [
'type' => 'danger',
'message' => 'Une erreur est survenue lors de la validation des bons de livraison'
]
];
return Ajax::responseError('Une erreur est survenue lors de la validation des bons de livraison');
}
}

+ 2
- 0
common/helpers/Ajax.php ファイルの表示

@@ -19,6 +19,8 @@ class Ajax

private static function response(string $responseType, string $message): array
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

return [
'return' => $responseType,
'alert' => [

+ 8
- 0
common/logic/Document/Document/Service/DocumentBuilder.php ファイルの表示

@@ -69,6 +69,14 @@ class DocumentBuilder extends AbstractBuilder
}
}

public function validateDocument(Document $document): void
{
if($this->documentSolver->isStatusDraft($document)) {
$this->changeStatus($document, Document::STATUS_VALID);
$this->update($document);
}
}

public function initTaxCalculationMethod(DocumentInterface $document): void
{
$producerTaxCalculationMethod = $this->producerRepository->getConfig('option_tax_calculation_method');

+ 2
- 1
composer.json ファイルの表示

@@ -34,7 +34,8 @@
"loveorigami/yii2-bootstrap-toggle": "*",
"justcoded/yii2-event-listener": "*",
"ext-pdo": "*",
"weluse/yii2-mailjet": "^0.2.0"
"weluse/yii2-mailjet": "^0.2.0",
"ext-json": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",

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