Pārlūkot izejas kodu

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

feature/souke
Guillaume Bourgeois pirms 1 gada
vecāks
revīzija
ab99ef438a
4 mainītis faili ar 20 papildinājumiem un 29 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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": "*",

Notiek ielāde…
Atcelt
Saglabāt