- name
- order_invoice_payment
- tier
- 2
- task
- T10
- description
- Use when the task asks to CREATE a new order with specific PRODUCTS (by name/number), then invoice it, then pay it — all in one go. The task will list product names, numbers, and prices. Do NOT use this if the task says the customer already has an unpaid/existing invoice — that is register_payment.
# Create Order + Invoice + Register Payment
Exactly 4 API calls. Customer and products are PRE-CREATED — search, do NOT create.
## Call 1: Find Existing Customer
```
GET /customer?organizationNumber=<org_nr>&fields=id,name&count=10
```
## Call 2: Find ALL Products (ONE call)
```
GET /product?fields=id,name,number,priceExcludingVatCurrency&count=50
```
Match BOTH product numbers from the prompt in this single response.
## Call 3: Get Payment Type
```
GET /invoice/paymentType?fields=id,description&count=10
```
Use "Betalt til bank".
## Call 4: Create Invoice WITH Inline Order AND Inline Payment
POST /invoice supports BOTH inline order creation AND inline payment via query parameters. This creates order + invoice + registers payment in ONE call.
Calculate `paidAmount` = sum of all product prices × 1.25 (25% VAT). This must match the invoice total INCLUDING VAT.
```
POST /invoice?paidAmount=<total_incl_vat>&paymentDate=2026-03-20&paymentTypeId=<type_id>
```
```json
{
"invoiceDate": "2026-03-20",
"invoiceDueDate": "2026-04-03",
"orders": [
{
"customer": {"id": <customer_id>},
"orderDate": "2026-03-20",
"deliveryDate": "2026-03-20",
"orderLines": [
{"product": {"id": <product1_id>}, "count": 1},
{"product": {"id": <product2_id>}, "count": 1}
]
}
]
}
```
The response will show `amountOutstanding: 0.0` — payment is registered.
**If this fails with "bankkontonummer" error:** Do bank setup then retry:
```
GET /ledger/account?number=1920&fields=id,number,bankAccountNumber,isBankAccount
```
```json
PUT /ledger/account/<id>
{"id": <id>, "name": "Bankinnskudd", "number": 1920, "bankAccountNumber": "86011117947", "isBankAccount": true}
```
Then retry POST /invoice with the same query params.
**Total: 4 calls, 0 errors.**
## Gotchas
- Customer and products are PRE-CREATED — always search, never create (scores 0)
- POST /invoice creates the order inline — no separate POST /order needed
- POST /invoice with `paidAmount` + `paymentDate` + `paymentTypeId` query params registers payment inline — no separate PUT /:payment needed
- `paidAmount` must be the TOTAL including VAT (products have 25% VAT by default on competition sandbox)
- Calculate: paidAmount = (product1_price + product2_price) × 1.25
- Bank number is ALWAYS `86011117947` — never guess
- Calls 1-3 are independent GETs — run them in parallel
Voir sur GitHub