Implement CRUD functionality for Articles and Tiers with enhanced API documentation
- Introduced new endpoints for creating and modifying articles (`art_add`, `art_mod`) and tiers (`third_add`, `third_mod`), allowing users to manage these entities effectively. - Updated the Articles and Tiers pages to include forms for adding and modifying records, complete with parameter tables for clear guidance on required inputs. - Enhanced the API documentation to include detailed descriptions, examples, and metadata for the new endpoints, improving usability and understanding for developers. - Created a new rule for writing conventions with French accents to ensure consistency across the project. - Updated existing documentation to reflect structural changes and added a summary table for CRUD operations. - Added tests to verify the functionality of the new features and ensure robust error handling.
This commit is contained in:
@@ -30,10 +30,30 @@ class Tiers extends Page
|
||||
|
||||
public string $historyThirdId = '';
|
||||
|
||||
// third_add
|
||||
public string $addName = '';
|
||||
|
||||
public string $addVat = '';
|
||||
|
||||
public string $addEmail = '';
|
||||
|
||||
// third_mod
|
||||
public string $modCustId = '';
|
||||
|
||||
public string $modName = '';
|
||||
|
||||
public string $modVat = '';
|
||||
|
||||
public string $modEmail = '';
|
||||
|
||||
public array $data = [];
|
||||
|
||||
public array $historyData = [];
|
||||
|
||||
public array $addResult = [];
|
||||
|
||||
public array $modResult = [];
|
||||
|
||||
public ?array $metadata = null;
|
||||
|
||||
public ?string $errorMessage = null;
|
||||
@@ -42,6 +62,10 @@ class Tiers extends Page
|
||||
|
||||
public bool $hasHistory = false;
|
||||
|
||||
public bool $hasAdded = false;
|
||||
|
||||
public bool $hasModified = false;
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, type: string, required: string, description: string}>
|
||||
*/
|
||||
@@ -64,6 +88,104 @@ class Tiers extends Page
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, type: string, required: string, description: string}>
|
||||
*/
|
||||
public function paramTableThirdAdd(): array
|
||||
{
|
||||
return [
|
||||
['name' => 'NAME', 'type' => 'string', 'required' => 'Non', 'description' => 'Nom du tiers (raison sociale ou nom complet).'],
|
||||
['name' => 'VAT', 'type' => 'string', 'required' => 'Non', 'description' => 'Numéro de TVA (ex : BE0123456789).'],
|
||||
['name' => 'EMAIL', 'type' => 'string', 'required' => 'Non', 'description' => 'Adresse e-mail du tiers.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, type: string, required: string, description: string}>
|
||||
*/
|
||||
public function paramTableThirdMod(): array
|
||||
{
|
||||
return [
|
||||
['name' => 'CUSTID', 'type' => 'string', 'required' => 'Oui', 'description' => 'Identifiant du tiers à modifier (champ custid de la table cust). Doit exister.'],
|
||||
['name' => 'NAME', 'type' => 'string', 'required' => 'Non', 'description' => 'Nouveau nom du tiers.'],
|
||||
['name' => 'VAT', 'type' => 'string', 'required' => 'Non', 'description' => 'Nouveau numéro de TVA.'],
|
||||
['name' => 'EMAIL', 'type' => 'string', 'required' => 'Non', 'description' => 'Nouvelle adresse e-mail.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function addTiers(): void
|
||||
{
|
||||
$this->errorMessage = null;
|
||||
$this->hasAdded = true;
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
|
||||
$params = [];
|
||||
|
||||
if (filled($this->addName)) {
|
||||
$params['NAME'] = $this->addName;
|
||||
}
|
||||
if (filled($this->addVat)) {
|
||||
$params['VAT'] = $this->addVat;
|
||||
}
|
||||
if (filled($this->addEmail)) {
|
||||
$params['EMAIL'] = $this->addEmail;
|
||||
}
|
||||
|
||||
$response = $service->thirdAdd($params);
|
||||
|
||||
$this->addResult = $response['data'] ?? [];
|
||||
$this->errorMessage = ApiErrorTranslator::translate($response['error'] ?? null);
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
|
||||
$this->addResult = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
|
||||
$this->addResult = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function modTiers(): void
|
||||
{
|
||||
$this->errorMessage = null;
|
||||
|
||||
if (blank($this->modCustId)) {
|
||||
$this->errorMessage = 'Le champ identifiant tiers (CUSTID) est obligatoire.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->hasModified = true;
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
|
||||
$params = ['CUSTID' => $this->modCustId];
|
||||
|
||||
if (filled($this->modName)) {
|
||||
$params['NAME'] = $this->modName;
|
||||
}
|
||||
if (filled($this->modVat)) {
|
||||
$params['VAT'] = $this->modVat;
|
||||
}
|
||||
if (filled($this->modEmail)) {
|
||||
$params['EMAIL'] = $this->modEmail;
|
||||
}
|
||||
|
||||
$response = $service->thirdMod($params);
|
||||
|
||||
$this->modResult = $response['data'] ?? [];
|
||||
$this->errorMessage = ApiErrorTranslator::translate($response['error'] ?? null);
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
|
||||
$this->modResult = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = ApiErrorTranslator::translate($e->getMessage());
|
||||
$this->modResult = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function searchTiers(): void
|
||||
{
|
||||
$this->errorMessage = null;
|
||||
|
||||
Reference in New Issue
Block a user