QuickBooks Online API如何提交负数日记账分录?
解决QuickBooks Online(QBO)API提交负数日记账分录时的Error 2290问题
QBO API的JournalEntry接口不允许交易行使用负数金额,哪怕常规会计操作中负数分录很常见。遇到Error 2290「Negative amount not supported on transaction line」时,只需调整提交逻辑:将负数金额转为正数,同时反转对应的PostingType(Debit和Credit互换)。
错误请求示例
{ "Line": [ { "JournalEntryLineDetail": { "PostingType": "Debit", "AccountRef": { "name": "Opening Bal Equity", "value": "39" } }, "DetailType": "JournalEntryLineDetail", "Amount": "-100.0", "Id": "0", "Description": "nov portion of rider insurance" }, { "JournalEntryLineDetail": { "PostingType": "Credit", "AccountRef": { "name": "Notes Payable", "value": "44" } }, "DetailType": "JournalEntryLineDetail", "Amount": 100.0, "Description": "nov portion of rider insurance" } ] }
错误响应示例
{ "responseHeader": { "status": 400, "message": "", "intuitTid": "1-653f9b94-4d7cf9f5129c893b74025b8c", "realmID": "4620816365234297530" }, "response": { "Fault": { "Error": [ { "Message": "Amount is invalid", "Detail": "Negative amount -100 not supported on a transaction line", "code": "2290", "element": "Line.Amount" } ], "type": "ValidationFault" }, "time": "2023-10-30T05:03:32.257-07:00" } }
修正后的请求示例
把原Debit行的负数金额转为正数,PostingType改为Credit;确保所有Line的Amount均为正数,通过PostingType控制借贷方向:
{ "Line": [ { "JournalEntryLineDetail": { "PostingType": "Credit", "AccountRef": { "name": "Opening Bal Equity", "value": "39" } }, "DetailType": "JournalEntryLineDetail", "Amount": 100.0, "Id": "0", "Description": "nov portion of rider insurance" }, { "JournalEntryLineDetail": { "PostingType": "Debit", "AccountRef": { "name": "Notes Payable", "value": "44" } }, "DetailType": "JournalEntryLineDetail", "Amount": 100.0, "Description": "nov portion of rider insurance" } ] }
核心逻辑说明
QBO API的设计规则是:所有交易行的Amount必须为正数,借贷方向完全由PostingType字段(Debit/Credit)控制。常规会计操作中的负数分录,对应到API里就是切换PostingType并使用正数金额,而非直接传递负数。
内容的提问来源于stack exchange,提问作者ViaTech
相关产品推荐
相关产品推荐

