Skip to content

Commit 35aac06

Browse files
committed
wip
1 parent 52ef2ff commit 35aac06

File tree

9 files changed

+163
-9
lines changed

9 files changed

+163
-9
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"statusCode": 404,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:45:06 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "56",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58ee37a937e5d9-ZRH",
9+
"vary": "Origin",
10+
"access-control-allow-origin": "https:\/\/office.bexio.com",
11+
"via": "1.1 google",
12+
"cf-cache-status": "DYNAMIC",
13+
"Server": "cloudflare"
14+
},
15+
"data": "{\"status\":404,\"error\":\"Not Found\",\"message\":\"Not Found\"}",
16+
"context": []
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:43:02 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "16",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58eb31f962c115-ZRH",
9+
"x-ratelimit-remaining-minute": "996",
10+
"ratelimit-limit": "1000",
11+
"ratelimit-remaining": "996",
12+
"ratelimit-reset": "58",
13+
"x-ratelimit-limit-minute": "1000",
14+
"Cache-Control": "no-store",
15+
"pragma": "no-cache",
16+
"vary": "Origin",
17+
"access-control-allow-origin": "https:\/\/office.bexio.com",
18+
"via": "1.1 google",
19+
"cf-cache-status": "DYNAMIC",
20+
"Server": "cloudflare"
21+
},
22+
"data": "{\"success\":true}",
23+
"context": []
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"statusCode": 201,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:43:02 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "1454",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58eb2dda67c115-ZRH",
9+
"x-ratelimit-remaining-minute": "999",
10+
"ratelimit-limit": "1000",
11+
"ratelimit-remaining": "999",
12+
"ratelimit-reset": "58",
13+
"x-ratelimit-limit-minute": "1000",
14+
"etag": "32e816695225918edcaf8350e3bd9901",
15+
"Cache-Control": "no-store",
16+
"pragma": "no-cache",
17+
"vary": "Origin",
18+
"access-control-allow-origin": "https:\/\/office.bexio.com",
19+
"via": "1.1 google",
20+
"cf-cache-status": "DYNAMIC",
21+
"Server": "cloudflare"
22+
},
23+
"data": "{\"id\":46,\"document_nr\":\"AN-00046\",\"title\":\"Test Quote\",\"contact_id\":1,\"contact_sub_id\":null,\"user_id\":1,\"project_id\":null,\"logopaper_id\":1,\"language_id\":1,\"bank_account_id\":1,\"currency_id\":1,\"payment_type_id\":1,\"header\":\"Guten Tag bexio AG<br\\\/><br\\\/>Danke f\\u00fcr Ihr Interesse. Sie erhalten folgendes Angebot:\",\"footer\":\"Sie haben Fragen? Melden Sie sich bei uns.<br\\\/><br\\\/>Freundliche Gr\\u00fcsse<br\\\/>Max Mustermann\",\"total_gross\":\"100\",\"total_net\":\"100\",\"total_taxes\":\"0.0000\",\"total\":\"100\",\"total_rounding_difference\":0,\"mwst_type\":1,\"mwst_is_net\":true,\"show_position_taxes\":true,\"is_valid_from\":\"2025-11-28\",\"is_valid_until\":\"2025-12-03\",\"contact_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"delivery_address_type\":0,\"delivery_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"kb_item_status_id\":1,\"api_reference\":\"fdbd7dca-2a68-4648-8c28-66b22e425c61\",\"viewed_by_client_at\":null,\"kb_terms_of_payment_template_id\":null,\"show_total\":true,\"updated_at\":\"2025-11-28 10:43:02\",\"template_slug\":\"\",\"taxs\":[],\"positions\":[{\"id\":48,\"type\":\"KbPositionCustom\",\"amount\":\"1\",\"amount_reserved\":null,\"amount_open\":null,\"amount_completed\":null,\"unit_id\":1,\"account_id\":217,\"unit_name\":\"Stk\",\"tax_id\":14,\"tax_value\":\"8.10\",\"text\":\"05cc84e2-f575-4751-9751-a7508cbbcf96\",\"unit_price\":\"100\",\"discount_in_percent\":\"0\",\"position_total\":\"100\",\"pos\":\"1\",\"internal_pos\":1,\"parent_id\":null,\"is_optional\":false}],\"network_link\":\"\"}",
24+
"context": []
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"statusCode": 201,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:43:03 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "1387",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58eb32db28c115-ZRH",
9+
"ratelimit-remaining": "995",
10+
"ratelimit-reset": "58",
11+
"x-ratelimit-limit-minute": "1000",
12+
"x-ratelimit-remaining-minute": "995",
13+
"ratelimit-limit": "1000",
14+
"etag": "373b0aaab9bb861d0faee048cf62424e",
15+
"Cache-Control": "no-store",
16+
"pragma": "no-cache",
17+
"vary": "Origin",
18+
"access-control-allow-origin": "https:\/\/office.bexio.com",
19+
"via": "1.1 google",
20+
"cf-cache-status": "DYNAMIC",
21+
"Server": "cloudflare"
22+
},
23+
"data": "{\"id\":1,\"document_nr\":\"AU-00001\",\"title\":\"Test Quote\",\"contact_id\":1,\"contact_sub_id\":null,\"user_id\":1,\"project_id\":null,\"logopaper_id\":1,\"language_id\":1,\"bank_account_id\":1,\"currency_id\":1,\"payment_type_id\":1,\"header\":\"Guten Tag bexio AG<br\\\/><br\\\/>Danke f\\u00fcr Ihren Auftrag. Nachfolgend finden Sie Ihre Auftragsbest\\u00e4tigung.\",\"footer\":\"Sie haben Fragen? Melden Sie sich bei uns.<br\\\/><br\\\/>Freundliche Gr\\u00fcsse<br\\\/>Max Mustermann\",\"total_gross\":\"100\",\"total_net\":\"100\",\"total_taxes\":\"0.0000\",\"total\":\"100\",\"total_rounding_difference\":0,\"mwst_type\":1,\"mwst_is_net\":true,\"show_position_taxes\":true,\"is_valid_from\":\"2025-11-28\",\"contact_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"delivery_address_type\":0,\"delivery_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"kb_item_status_id\":5,\"is_recurring\":false,\"api_reference\":null,\"viewed_by_client_at\":null,\"updated_at\":\"2025-11-28 10:43:03\",\"template_slug\":\"\",\"taxs\":[],\"positions\":[{\"id\":49,\"type\":\"KbPositionCustom\",\"amount\":\"1\",\"amount_reserved\":null,\"amount_open\":null,\"amount_completed\":null,\"unit_id\":1,\"account_id\":217,\"unit_name\":\"Stk\",\"tax_id\":14,\"tax_value\":\"8.10\",\"text\":\"05cc84e2-f575-4751-9751-a7508cbbcf96\",\"unit_price\":\"100.000000\",\"discount_in_percent\":\"0.0000\",\"position_total\":\"100\",\"pos\":\"1\",\"internal_pos\":1,\"parent_id\":null,\"is_optional\":false}],\"network_link\":\"\"}",
24+
"context": []
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:43:02 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "1519",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58eb30ff9ec115-ZRH",
9+
"ratelimit-reset": "58",
10+
"x-ratelimit-limit-minute": "1000",
11+
"x-ratelimit-remaining-minute": "997",
12+
"ratelimit-limit": "1000",
13+
"ratelimit-remaining": "997",
14+
"etag": "32e816695225918edcaf8350e3bd9901",
15+
"Cache-Control": "no-store",
16+
"pragma": "no-cache",
17+
"vary": "Origin",
18+
"access-control-allow-origin": "https:\/\/office.bexio.com",
19+
"via": "1.1 google",
20+
"cf-cache-status": "DYNAMIC",
21+
"Server": "cloudflare"
22+
},
23+
"data": "{\"id\":46,\"document_nr\":\"AN-00046\",\"title\":\"Test Quote\",\"contact_id\":1,\"contact_sub_id\":null,\"user_id\":1,\"project_id\":null,\"logopaper_id\":1,\"language_id\":1,\"bank_account_id\":1,\"currency_id\":1,\"payment_type_id\":1,\"header\":\"Guten Tag bexio AG<br\\\/><br\\\/>Danke f\\u00fcr Ihr Interesse. Sie erhalten folgendes Angebot:\",\"footer\":\"Sie haben Fragen? Melden Sie sich bei uns.<br\\\/><br\\\/>Freundliche Gr\\u00fcsse<br\\\/>Max Mustermann\",\"total_gross\":\"100.000000\",\"total_net\":\"100.000000\",\"total_taxes\":\"0.0000\",\"total\":\"100.000000\",\"total_rounding_difference\":0,\"mwst_type\":1,\"mwst_is_net\":true,\"show_position_taxes\":true,\"is_valid_from\":\"2025-11-28\",\"is_valid_until\":\"2025-12-03\",\"contact_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"delivery_address_type\":0,\"delivery_address\":\"bexio AG\\nAlte Jonastrasse 24\\n8640 Rapperswil\\nSchweiz\",\"kb_item_status_id\":2,\"api_reference\":\"fdbd7dca-2a68-4648-8c28-66b22e425c61\",\"viewed_by_client_at\":null,\"kb_terms_of_payment_template_id\":null,\"show_total\":true,\"updated_at\":\"2025-11-28 10:43:02\",\"template_slug\":\"\",\"taxs\":[],\"positions\":[{\"id\":48,\"type\":\"KbPositionCustom\",\"amount\":\"1.000000\",\"amount_reserved\":\"0.000000\",\"amount_open\":\"0.000000\",\"amount_completed\":\"0.000000\",\"unit_id\":1,\"account_id\":217,\"unit_name\":\"Stk\",\"tax_id\":14,\"tax_value\":\"8.10\",\"text\":\"05cc84e2-f575-4751-9751-a7508cbbcf96\",\"unit_price\":\"100.000000\",\"discount_in_percent\":\"0.0000\",\"position_total\":\"100.000000\",\"pos\":\"1\",\"internal_pos\":1,\"parent_id\":null,\"is_optional\":false}],\"network_link\":\"\"}",
24+
"context": []
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"Date": "Fri, 28 Nov 2025 09:43:02 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "16",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a58eb2fddb9c115-ZRH",
9+
"ratelimit-remaining": "998",
10+
"ratelimit-reset": "58",
11+
"x-ratelimit-limit-minute": "1000",
12+
"x-ratelimit-remaining-minute": "998",
13+
"ratelimit-limit": "1000",
14+
"Cache-Control": "no-store",
15+
"pragma": "no-cache",
16+
"vary": "Origin",
17+
"access-control-allow-origin": "https:\/\/office.bexio.com",
18+
"via": "1.1 google",
19+
"cf-cache-status": "DYNAMIC",
20+
"Server": "cloudflare"
21+
},
22+
"data": "{\"success\":true}",
23+
"context": []
24+
}

tests/Requests/ItemPositions/EditAnItemPositionRequestTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
use Saloon\Laravel\Saloon;
1111

1212
it('can perform the request', closure: function () {
13-
$fixturePath = __DIR__.'/../../Fixtures/Saloon/ItemPositions/edit-an-item-position.json';
14-
$listFixturePath = __DIR__.'/../../Fixtures/Saloon/ItemPositions/fetch-a-list-of-item-positions.json';
13+
$fixturePath = __DIR__.'/../../Fixtures/Saloon/ItemPositions/edit-an-item-position';
1514

1615
if (shouldResetFixtures()) {
17-
@unlink($fixturePath);
18-
@unlink($listFixturePath);
16+
@unlink($fixturePath.'/fetch-a-list-of-item-positions.json');
17+
@unlink($fixturePath.'/edit-an-item-position.json');
1918
}
2019

2120
$mockItemPositions = [
@@ -73,15 +72,16 @@
7372
];
7473

7574
Saloon::fake([
76-
EditAnItemPositionRequest::class => MockResponse::make(body: $mockUpdatedItemPosition, status: 200),
7775
FetchAListOfItemPositionsRequest::class => MockResponse::make(body: $mockItemPositions, status: 200),
76+
EditAnItemPositionRequest::class => MockResponse::make(body: $mockUpdatedItemPosition, status: 200),
7877
]);
7978

8079
$connector = new BexioConnector(new ConnectWithToken);
8180

81+
$kbDocumentType = 'kb_offer';
8282
$itemPositionsResponse = $connector->send(new FetchAListOfItemPositionsRequest(
8383
kb_document_id: 1,
84-
kb_document_type: 'kb_offer'
84+
kb_document_type: $kbDocumentType
8585
));
8686
$existingItemPosition = $itemPositionsResponse->dto()->first();
8787

@@ -90,7 +90,7 @@
9090
}
9191

9292
$itemPosition = CreateEditItemPositionDTO::fromArray([
93-
'kb_document_type' => $existingItemPosition->kb_document_type,
93+
'kb_document_type' => $kbDocumentType,
9494
'type' => $existingItemPosition->type,
9595
'amount' => '2',
9696
'unit_id' => $existingItemPosition->unit_id,

tests/Requests/Quotes/CreateOrderFromQuoteRequestTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use CodebarAg\Bexio\Requests\Quotes\AcceptAQuoteRequest;
1313
use CodebarAg\Bexio\Requests\Quotes\CreateAQuoteRequest;
1414
use CodebarAg\Bexio\Requests\Quotes\CreateOrderFromQuoteRequest;
15+
use CodebarAg\Bexio\Requests\Quotes\FetchAQuoteRequest;
1516
use CodebarAg\Bexio\Requests\Quotes\IssueAQuoteRequest;
1617
use CodebarAg\Bexio\Requests\Units\FetchAListOfUnitsRequest;
1718
use CodebarAg\Bexio\Requests\Users\FetchAuthenticatedUserRequest;
@@ -25,6 +26,7 @@
2526
if (shouldResetFixtures()) {
2627
@unlink($fixturePath.'/create-a-quote.json');
2728
@unlink($fixturePath.'/issue-a-quote.json');
29+
@unlink($fixturePath.'/fetch-a-quote.json');
2830
@unlink($fixturePath.'/accept-a-quote.json');
2931
@unlink($fixturePath.'/create-order-from-quote.json');
3032
}
@@ -39,6 +41,7 @@
3941
FetchAListOfUnitsRequest::class => MockResponse::fixture('Units/fetch-a-list-of-units'),
4042
CreateAQuoteRequest::class => MockResponse::fixture('Quotes/create-order-from-quote/create-a-quote'),
4143
IssueAQuoteRequest::class => MockResponse::fixture('Quotes/create-order-from-quote/issue-a-quote'),
44+
FetchAQuoteRequest::class => MockResponse::fixture('Quotes/create-order-from-quote/fetch-a-quote'),
4245
AcceptAQuoteRequest::class => MockResponse::fixture('Quotes/create-order-from-quote/accept-a-quote'),
4346
CreateOrderFromQuoteRequest::class => MockResponse::fixture('Quotes/create-order-from-quote/create-order-from-quote'),
4447
]);
@@ -88,15 +91,26 @@
8891
$issueResponse = $connector->send(new IssueAQuoteRequest(quote_id: $createdQuote->id));
8992
expect($issueResponse->successful())->toBeTrue();
9093

94+
// Fetch the quote again to check its status
95+
$fetchResponse = $connector->send(new FetchAQuoteRequest(quote_id: $createdQuote->id));
96+
expect($fetchResponse->successful())->toBeTrue();
97+
$currentQuote = $fetchResponse->dto();
98+
99+
// Ensure the quote is in 'issued' status (ID 2) before accepting
100+
expect($currentQuote->kb_item_status_id)->toBe(2, 'Quote must be in status 2 (issued) before it can be accepted and converted to an order');
101+
102+
// Accept the quote
91103
$acceptResponse = $connector->send(new AcceptAQuoteRequest(quote_id: $createdQuote->id));
92104
expect($acceptResponse->successful())->toBeTrue();
93105

106+
// Now create an order from the created quote
94107
$response = $connector->send(new CreateOrderFromQuoteRequest(quote_id: $createdQuote->id));
95108

96109
expect($response->successful())->toBeTrue();
97110

98111
Saloon::assertSent(CreateAQuoteRequest::class);
99112
Saloon::assertSent(IssueAQuoteRequest::class);
113+
Saloon::assertSent(FetchAQuoteRequest::class);
100114
Saloon::assertSent(AcceptAQuoteRequest::class);
101115
Saloon::assertSent(CreateOrderFromQuoteRequest::class);
102-
})->group('quotes')->only();
116+
})->group('quotes');

0 commit comments

Comments
 (0)