Siparişi Faturaya Dönüştürme
Siparişi faturaya dönüştürür.
Endpoint
POST /kolaybi/v1/orders/{document_id}/transform
Parametreler
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
document_id | integer | Evet | Dönüştürülecek sipariş ID'si (URL'de) |
type | string | Evet | Satış siparişi için sale_invoice, alış siparişi için purchase_invoice |
receiver_email | string | Hayır | E-fatura/e-arşiv alıcısı. Varsayılan: carinin e-postası |
cross_currency_rate | number | Hayır | Şirket ve sipariş para birimlerinin ikisi de TRY değilse sipariş para birimi / TRY oranı |
order_reference[serial_no] | string | Koşullu | Sipariş numarası; issue_date ile birlikte gönderilir. Varsayılan: siparişin order_number değeri |
order_reference[issue_date] | date | Koşullu | Sipariş tarihi (YYYY-MM-DD); serial_no ile birlikte gönderilir. Varsayılan: siparişin tarihi |
E-fatura entegrasyonu bağlıysa satış faturası aynı istekte gönderime hazırlanır ve invoices/e-document/create ile gönderilebilir. E-belge alanları için E-Belge Gönderime Hazırlama sayfasına bakın.
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/orders/145/transform" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "type=sale_invoice"
async function transformOrder(documentId, type) {
const formData = new URLSearchParams();
formData.append("type", type);
const response = await fetch(
`https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/orders/${documentId}/transform`,
{
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
Channel: channel,
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData,
}
);
return await response.json();
}
// Kullanım
const result = await transformOrder(145, "sale_invoice");
function transformOrder($documentId, $type) {
$url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/orders/{$documentId}/transform";
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(['type' => $type]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Channel: ' . $channel,
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Kullanım
$result = transformOrder(145, 'sale_invoice');
import requests
def transform_order(document_id, type):
url = f"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/orders/{document_id}/transform"
headers = {
"Authorization": f"Bearer {access_token}",
"Channel": channel,
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, headers=headers, data={"type": type})
return response.json()
# Kullanım
result = transform_order(145, "sale_invoice")
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
async Task<dynamic> TransformOrderAsync(int documentId, string type)
{
using var client = new HttpClient();
var data = new Dictionary<string, string>
{
{ "type", type }
};
var request = new HttpRequestMessage(HttpMethod.Post,
$"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/orders/{documentId}/transform")
{
Content = new FormUrlEncodedContent(data)
};
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Add("Channel", channel);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(content);
}
// Kullanım
var result = await TransformOrderAsync(145, "sale_invoice");
Yanıt
- Başarılı Yanıt
{
"data": {
"document_id": 1830,
"exchange_grand_total": 660,
"exchange_grand_currency": "try",
"grand_total": 660,
"grand_currency": "try"
}
}
Yanıt Alanları
| Alan | Tip | Açıklama |
|---|---|---|
document_id | integer | Oluşturulan fatura ID |
grand_total | number | Fatura para biriminde genel toplam |
grand_currency | string | Faturanın para birimi |
exchange_grand_total | number | Şirket para birimindeki karşılığı |
exchange_grand_currency | string | Şirket para birimi |
Fatura kalemleri ve diğer alanlar için Fatura Detayı endpoint'ini kullanın.