Function setInvoiceStatus
Description
Changes the status of an invoice between TYMCZASOWA (draft) and AKTYWNA (active).
Workflow
- Create invoice header with
createInvoiceHeadβ status = TYMCZASOWA (default) - Add line items with
createInvoiceItem - When finished, change status to AKTYWNA with
setInvoiceStatus
Important notes
- Invoice with status TYMCZASOWA is a draft and can be freely modified
- Invoice with status AKTYWNA is finalized
- Cannot change status of invoice that has been sent to KSEF (has KSEF_NUMBER)
Arguments
- params :
array ( [ 'idInvoice' ] = string, // Invoice ID (32 char GUID) - REQUIRED [ 'status' ] = string, // 'AKTYWNA' or 'TYMCZASOWA' - REQUIRED )
Example
require_once ( 'classUddsOx.php' ) ; $udds = new classUddsOx ; $udds->customerCode = [your_customerCode] ; $udds->login = [your_login] ; $udds->password = [your_password] ; $udds->serverUrl = 'http://api.dlaoperatora.pl/udds/' ; $params = array(); $params['idInvoice'] = '00000004M1G221031126JF1B44ASNQ6D'; $params['status'] = 'AKTYWNA'; $ret = $udds->setInvoiceStatus($params); // $ret['data']['idInvoice'] - invoice ID // $ret['data']['previousStatus'] - status before change // $ret['data']['newStatus'] - status after change
Returns
Success response
{
"status": "OK",
"data": {
"idInvoice": "00000004M1G221031126JF1B44ASNQ6D",
"previousStatus": "TYMCZASOWA",
"newStatus": "AKTYWNA"
},
"errors": []
}
Error response
{
"status": "ERROR",
"data": null,
"errors": [
{ "code": 1004, "message": "Nie moΕΌna zmieniΔ statusu faktury wysΕanej do KSEF (numer KSEF: ...)" }
]
}
Error codes
| Code | Description |
|---|---|
| 1001 | Missing required field (idInvoice or status) |
| 1002 | Invalid status value (must be 'AKTYWNA' or 'TYMCZASOWA') |
| 1003 | Invoice not found |
| 1004 | Invoice already sent to KSEF - cannot change status |
| 1005 | Database error |
Related endpoints
- createInvoiceHead - Create invoice header (creates with TYMCZASOWA status)
- createInvoiceItem - Add line items
- getInvoice - Get invoice details
- sendInvoiceToKsef - Send invoice to KSEF