Invoice creation fails for micro-transactions (< $0.01) with unitdp: 4
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- api
Hướng nghiên cứu
The report centres on the createInvoices call in the accounting API client, passing unitdp as 4, with a line item whose unitAmount is 0.001 and status AUTHORISED. Start by running the minimal reproduction in the issue body and comparing the AUTHORISED and DRAFT outcomes to confirm the failure. Then determine whether the validation comes from the SDK's request handling or from the Xero API. Done means a clear explanation of the cause and either a fix or a documented workaround.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
SDK you're using (please complete the following information):
- xero-node version: 9.2.0
- Node.js version: 16.20.2
Describe the bug
When using unitdp: 4 with line items that have a total amount less than $0.01 and no tax, unexpected validation errors are thrown. This occurs even when the account code and tax type are valid.
☝️ Update: This condition appears to be triggered when the invoice status is set to AUTHORISED. If the invoice is set to DRAFT it is created as expected.
To Reproduce
Steps to reproduce the behavior:
- Create a new invoice object with a line item that has the following shape:
{
"description": "Email messages delivery",
"quantity": 2,
"unitAmount": 0.001,
"accountCode": "40113",
"taxType": "OUTPUT",
"taxAmount": 0
}
- Submit the invoice using the
createInvoicesmethod and setunitdp: 4, like so:
const createdInvoicesResponse = await XeroClient.accountingApi.createInvoices(
tenantId,
{invoices},
undefined,
4,
undefined,
undefined,
);
- Observe the following validation error returned:
{
"Description": "Email messages delivery",
"UnitAmount": 0.001,
"TaxAmount": 0,
"LineAmount": 0,
"Tracking": [],
"Quantity": 2,
"LineItemID": "b5275db3-9817-40d9-9dd4-d50f22ed03d0",
"ValidationErrors": [
{
"Message": "Account must be valid."
},
{
"Message": "Tax rate must be valid."
}
]
}
However, when I change the line item's unitAmount to be "0.1" it works as expected.
Expected behavior
The Xero API and SDK should allow creation of invoices with line items having four decimal places, no tax, and total amounts less than $0.01, without throwing validation errors.
Additional context
Here's a minimal, complete example that reproduces the issue:
import {Invoice} from 'xero-node';
const reproduceIssue = async () => {
const {xero, tenantId} = await getXeroClient();
const invoice = {
type: Invoice.TypeEnum.ACCREC,
contact: {contactID: 'VALID_CONTACT_ID'},
lineItems: [{
description: "Email messages delivery",
quantity: 2,
unitAmount: 0.001,
accountCode: "40113",
taxType: "OUTPUT",
taxAmount: 0
}],
date: new Date().toISOString().split('T')[0],
dueDate: new Date().toISOString().split('T')[0],
status: Invoice.StatusEnum.AUTHORISED,
};
try {
const response = await xero.accountingApi.createInvoices(
tenantId,
{invoices: [invoice]},
undefined,
4,
undefined,
undefined
);
console.log('Invoice created successfully:', response.body);
} catch (error: any) {
console.error('Error creating invoice:', error);
}
};
(async () => {
await reproduceIssue();
})();
- I can provided the full API response, but I don't think it's needed.
- I could not find similar issues here.
- The account code
40113is a "Sales" account type.
- Ngôn ngữ chính
- TypeScript
- Star
- 264
- Fork
- 177
- Merge trung bình
- 10 giờ 5 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của XeroAPI/xero-node
-
`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameterĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Có thể đã có người làm @miachillgood đã nhận 152 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 18/100
-
BankTransaction type is missing the batchPayment object.Có thể đã có người làm @miachillgood đã nhận 171 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 22/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Tất cả issue của XeroAPI/xero-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
super-productivity/super-productivity#12128 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at onceCó thể đã có người làm @2389400626lh-ops đã nhận hôm nay. Đang mởArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
justyns/silverbullet-ai#199 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
spartan-ng/spartan#1931 ·
Maintainer thường phản hồi trong vòng 2 ngày