انتقل إلى المحتوى الرئيسي

Invoice Endpoints

API endpoints for invoice management, estimates, and payments.

Invoices

List Invoices

GET /api/invoices?take=20&skip=0&relations[]=toContact&relations[]=fromOrganization
Authorization: Bearer {token}

Response (200 OK):

{
"items": [
{
"id": "...",
"invoiceNumber": "INV-001",
"invoiceDate": "2024-01-15T00:00:00.000Z",
"dueDate": "2024-02-15T00:00:00.000Z",
"currency": "USD",
"discountValue": 10,
"discountType": "PERCENT",
"tax": 7.5,
"tax2": 0,
"totalValue": 5000,
"status": "SENT",
"sentTo": "client@example.com",
"isEstimate": false,
"organizationId": "...",
"toContactId": "..."
}
],
"total": 25
}

Create Invoice

POST /api/invoices
Authorization: Bearer {token}
Content-Type: application/json

{
"invoiceNumber": "INV-002",
"invoiceDate": "2024-01-15",
"dueDate": "2024-02-15",
"currency": "USD",
"discountValue": 10,
"discountType": "PERCENT",
"tax": 7.5,
"totalValue": 5000,
"toContactId": "contact-uuid",
"organizationId": "org-uuid",
"invoiceItems": [
{
"description": "Development services",
"quantity": 40,
"price": 125,
"totalValue": 5000,
"applyTax": true,
"applyDiscount": true
}
]
}

Send Invoice

PUT /api/invoices/{id}/email
Authorization: Bearer {token}
Content-Type: application/json

{
"email": "client@example.com"
}

Invoice Statuses

StatusDescription
DRAFTCreated but not sent
SENTSent to client
VIEWEDViewed by client
ACCEPTEDAccepted by client
PAIDPayment received
PARTIALLY_PAIDPartial payment received
OVERDUEPast due date
VOIDCancelled/voided

Estimates

Estimates use the same endpoint with isEstimate: true:

POST /api/invoices
Content-Type: application/json

{
"isEstimate": true,
"invoiceNumber": "EST-001",
...
}

Convert Estimate to Invoice

PUT /api/invoices/{estimate-id}/convert
Authorization: Bearer {token}

Payments

List Payments

GET /api/payment?where[invoiceId]={invoice-id}
Authorization: Bearer {token}

Create Payment

POST /api/payment
Authorization: Bearer {token}
Content-Type: application/json

{
"invoiceId": "invoice-uuid",
"paymentDate": "2024-02-10",
"amount": 2500,
"currency": "USD",
"paymentMethod": "BANK_TRANSFER",
"note": "Partial payment",
"organizationId": "org-uuid"
}

Payment Methods

MethodDescription
BANK_TRANSFERWire/bank transfer
CASHCash payment
CHEQUECheck payment
CREDIT_CARDCredit card
DEBITDebit card
ONLINEOnline payment (PayPal, etc.)