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:
2026-02-23 15:55:09 +01:00
parent b95ee46b1c
commit 714bdc3dd7
15 changed files with 1479 additions and 145 deletions

View File

@@ -205,6 +205,128 @@ it('sends correct parameters for custom_geninv_updatestock', function () {
});
});
it('sends correct parameters for document_add', function () {
Http::fake([
'*' => Http::response(['data' => ['number' => '2026/0001'], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = [
'ThirdId' => 'CUST001',
'Date' => '2026-02-20',
'Artid' => ['ART001', 'ART002'],
'Qty' => ['2', '5'],
'Saleprice' => ['10.00', '25.50'],
'JNL' => 'VEN',
];
$service->documentAdd($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'document_add')
&& $body['ThirdId'] === 'CUST001'
&& $body['JNL'] === 'VEN'
&& $body['Artid'] === ['ART001', 'ART002'];
});
});
it('sends correct parameters for document_mod', function () {
Http::fake([
'*' => Http::response(['data' => ['updated' => true], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = [
'number' => '2026/0001',
'JNL' => 'VEN',
'Thirdid' => 'CUST002',
];
$service->documentMod($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'document_mod')
&& $body['number'] === '2026/0001'
&& $body['JNL'] === 'VEN'
&& $body['Thirdid'] === 'CUST002';
});
});
it('sends correct parameters for art_add', function () {
Http::fake([
'*' => Http::response(['data' => ['artid' => 'ART001'], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = ['ARTID' => 'ART001', 'NAME1' => 'Test Article', 'SALEPRICE' => '49.99'];
$service->artAdd($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'art_add')
&& $body['ARTID'] === 'ART001'
&& $body['NAME1'] === 'Test Article'
&& $body['SALEPRICE'] === '49.99';
});
});
it('sends correct parameters for art_mod', function () {
Http::fake([
'*' => Http::response(['data' => ['artid' => 'ART001'], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = ['ARTID' => 'ART001', 'NAME1' => 'Updated Article'];
$service->artMod($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'art_mod')
&& $body['ARTID'] === 'ART001'
&& $body['NAME1'] === 'Updated Article';
});
});
it('sends correct parameters for third_add', function () {
Http::fake([
'*' => Http::response(['data' => ['thirdid' => '_@00036051'], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = ['NAME' => 'Test Company', 'VAT' => 'BE0123456789', 'EMAIL' => 'test@example.com'];
$service->thirdAdd($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'third_add')
&& $body['NAME'] === 'Test Company'
&& $body['VAT'] === 'BE0123456789';
});
});
it('sends correct parameters for third_mod', function () {
Http::fake([
'*' => Http::response(['data' => ['thirdid' => 'CUST001'], 'metadata' => ['rowcount' => 1, 'issuccess' => true], 'error' => null]),
]);
$service = app(LogisticsService::class);
$params = ['CUSTID' => 'CUST001', 'NAME' => 'Updated Company'];
$service->thirdMod($params);
Http::assertSent(function ($request) {
$body = $request->data();
return str_contains($request->url(), 'third_mod')
&& $body['CUSTID'] === 'CUST001'
&& $body['NAME'] === 'Updated Company';
});
});
it('includes endpoint info in LogisticsApiException', function () {
Http::fake(fn () => throw new ConnectionException('Connection timed out'));