인보이스 일괄 확정
curl --request POST \
--url https://meterengine.com/v1/invoices \
--header 'Authorization: Bearer <token>'const url = 'https://meterengine.com/v1/invoices';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"failed_count": 123,
"finalized_count": 123,
"invoices": [
{
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_name": "<string>",
"cutoff_at": "2023-11-07T05:31:56Z",
"finalized_at": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_number": "<string>",
"lines": [
{
"amount": 123,
"billable_metric_code": "<string>",
"billable_metric_name": "<string>",
"dimension_values": {},
"line_type": "per_unit",
"quantity": 123,
"quantity_denominator": 123,
"quantity_numerator": 123,
"target_property": "<string>",
"tier_index": 123,
"unit_price": 123
}
],
"month": "<string>",
"supply_amount": 123,
"tax_amount": 123,
"total_amount": 123
}
],
"month": "<string>",
"supply_amount": 123,
"tax_amount": 123,
"total_amount": 123
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}인보이스
인보이스 일괄 확정
그 달 청구 예정액이 0원이 아닌 고객을 한 번에 확정한다. 세액은 공급가액의 10%다. 그 달에 발생했고 집계 마감 시각(다음 달 1일 13:00 KST) 전에 받은 이벤트로 확정해서, 마감이 지난 달의 확정 금액과 라인은 그 시점의 청구 예정액과 같다. 마감 시각 전에 확정하면 확정 시각까지 받은 이벤트로 확정하고 그 시각을 인보이스의 cutoff_at에 남긴다. 수량이 0인 라인은 인보이스에 싣지 않는다. 확정한 고객은 그 달 청구 예정액에서 빠진다. 확정한 고객마다 같은 트랜잭션에서 보낼 청구 메일을 남긴다. 고객에 청구 이메일이 없으면 받는 주소 없이 남긴다. 그 달이 이미 확정된 고객은 건너뛴다. 그래서 같은 달로 다시 부르거나 동시에 불러도 인보이스가 겹치지 않는다. 고객마다 따로 커밋한다. 한 고객의 확정이 실패해도 다른 고객의 확정은 남고, 실패한 고객은 failed_count에 세며 다시 부르면 다시 시도한다. 확정은 되돌릴 수 없고, 확정한 뒤 그 달에 들어온 그 고객의 이벤트는 청구되지 않는다. finalized_count는 이번 호출로 새로 확정한 인보이스 수다. 확정된 내용은 인보이스 목록 조회로 본다.
POST
/
v1
/
invoices
인보이스 일괄 확정
curl --request POST \
--url https://meterengine.com/v1/invoices \
--header 'Authorization: Bearer <token>'const url = 'https://meterengine.com/v1/invoices';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"failed_count": 123,
"finalized_count": 123,
"invoices": [
{
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_name": "<string>",
"cutoff_at": "2023-11-07T05:31:56Z",
"finalized_at": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoice_number": "<string>",
"lines": [
{
"amount": 123,
"billable_metric_code": "<string>",
"billable_metric_name": "<string>",
"dimension_values": {},
"line_type": "per_unit",
"quantity": 123,
"quantity_denominator": 123,
"quantity_numerator": 123,
"target_property": "<string>",
"tier_index": 123,
"unit_price": 123
}
],
"month": "<string>",
"supply_amount": 123,
"tax_amount": 123,
"total_amount": 123
}
],
"month": "<string>",
"supply_amount": 123,
"tax_amount": 123,
"total_amount": 123
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
쿼리 매개변수
확정할 달(yyyy-MM, KST).