$this->select, 'thirdid' => $this->thirdId, ]); $response = $service->documentList($params); $this->data = $response['data'] ?? []; $this->metadata = $response['metadata'] ?? null; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->data = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->data = []; } } public function getDocumentDetail(): void { if (blank($this->detailJnl) || blank($this->detailNumber)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentDetail($this->detailJnl, $this->detailNumber); $this->detailData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->detailData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->detailData = []; } } public function getStatusList(): void { if (blank($this->statusJnl)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentGetStatusList($this->statusJnl); $this->statusData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->statusData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->statusData = []; } } public function getUnitPriceAndVat(): void { if (blank($this->priceArtId) || blank($this->priceQty) || blank($this->priceJnl) || blank($this->priceThirdId) || blank($this->priceDate)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentGetUnitPriceAndVat([ 'ARTID' => $this->priceArtId, 'QTY' => $this->priceQty, 'JNL' => $this->priceJnl, 'THIRDID' => $this->priceThirdId, 'DATE' => $this->priceDate, ]); $this->priceData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->priceData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->priceData = []; } } public function getDueDate(): void { if (blank($this->payDelay) || blank($this->dueDateInput)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentGetDueDate($this->payDelay, $this->dueDateInput); $this->dueDateData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->dueDateData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->dueDateData = []; } } public function getAttachListThumbnail(): void { if (blank($this->attachJnl) || blank($this->attachNumber)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentGetAttachListThumbnail($this->attachJnl, $this->attachNumber); $this->attachData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->attachData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->attachData = []; } } public function getPdf(): void { if (blank($this->pdfJnl) || blank($this->pdfNumber) || blank($this->pdfLayout)) { return; } try { $service = app(LogisticsService::class); $response = $service->documentGetPdf($this->pdfJnl, $this->pdfNumber, $this->pdfLayout); $this->pdfData = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->pdfData = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->pdfData = []; } } public function addDocument(): void { if (blank($this->addThirdId) || blank($this->addDate) || blank($this->addArtIds) || blank($this->addQty) || blank($this->addSalePrice) || blank($this->addJnl)) { return; } try { $service = app(LogisticsService::class); $params = [ 'ThirdId' => $this->addThirdId, 'Date' => $this->addDate, 'Artid' => $this->splitCsv($this->addArtIds), 'Qty' => $this->splitCsv($this->addQty), 'Saleprice' => $this->splitCsv($this->addSalePrice), 'JNL' => $this->addJnl, ]; if (filled($this->addDiscount)) { $params['Discount'] = $this->splitCsv($this->addDiscount); } if (filled($this->addVatId)) { $params['Vatid'] = $this->splitCsv($this->addVatId); } if (filled($this->addVatPc)) { $params['Vatpc'] = $this->splitCsv($this->addVatPc); } $response = $service->documentAdd($params); $this->addResult = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->addResult = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->addResult = []; } } public function modDocument(): void { if (blank($this->modNumber) || blank($this->modJnl)) { return; } try { $service = app(LogisticsService::class); $params = [ 'number' => $this->modNumber, 'JNL' => $this->modJnl, ]; if (filled($this->modThirdId)) { $params['Thirdid'] = $this->modThirdId; } if (filled($this->modArtIds)) { $params['Artid'] = $this->splitCsv($this->modArtIds); } if (filled($this->modQty)) { $params['Qty'] = $this->splitCsv($this->modQty); } if (filled($this->modSalePrice)) { $params['Saleprice'] = $this->splitCsv($this->modSalePrice); } $response = $service->documentMod($params); $this->modResult = $response['data'] ?? []; $this->errorMessage = $response['error'] ?? null; } catch (LogisticsApiException $e) { $this->errorMessage = $e->getMessage(); $this->modResult = []; } catch (\Throwable $e) { $this->errorMessage = "Erreur inattendue : {$e->getMessage()}"; $this->modResult = []; } } /** * @return array */ private function splitCsv(string $value): array { return array_map('trim', explode(',', $value)); } }