我需要帮助格式化 ZOQL 查询 JSON 响应中的子集。我的查询当前每张发票返回多个 JSON 对象。我想要的是获得一个带有税务项目嵌套子对象的发票对象。有没有办法形成我的 ZOQL 查询,该查询将以下面概述的格式返回结果?我正在使用数据查询语言: https ://knowledgecenter.zuora.com/Central_Platform/Query/Data_Query/BA_SQL_Queries_in_Data_Query
当前查询:
select i.AccountId, i.Amount, i.PostedDate, i.InvoiceNumber, i.Status, taxI.Name, taxI.TaxAmount, taxI.TaxCode, taxI.TaxDate, taxI.TaxRate, taxI.TaxRateType
from TaxationItem taxI,
InvoiceItem it,
Invoice i,
Subscription s
where i.Status = 'Posted' and i.AccountId = s.AccountId and s.Id = '12345' and s.Id = it.SubscriptionId and taxI.InvoiceItemId = it.id
order by i.InvoiceNumber desc
当前响应:
{
"AccountId": "11111",
"Amount": 0.000000000,
"PostedDate": "2021-11-26T10:15:16-05:00",
"InvoiceNumber": "INV00039206",
"Status": "Posted",
"Name": "Tax1",
"TaxAmount": 1.520000000,
"TaxCode": "Sabrix Tax",
"TaxDate": "2021-11-26",
"TaxRate": 0.020000000,
"TaxRateType": "Percentage"
}
{
"AccountId": "11111",
"Amount": 0.000000000,
"PostedDate": "2021-11-26T10:15:16-05:00",
"InvoiceNumber": "INV00039206",
"Status": "Posted",
"Name": "Tax2",
"TaxAmount": 5.770000000,
"TaxCode": "Sabrix Tax",
"TaxDate": "2021-11-26",
"TaxRate": 0.076000000,
"TaxRateType": "Percentage"
}
首选响应(类似于以下内容):
{
"AccountId": "11111",
"Amount": 0.000000000,
"PostedDate": "2021-11-26T10:15:16-05:00",
"InvoiceNumber": "INV00039206",
"Status": "Posted",
"Tax1Details": {
"Name": "Tax1",
"TaxAmount": 1.520000000,
"TaxCode": "Sabrix Tax",
"TaxDate": "2021-11-26",
"TaxRate": 0.020000000,
"TaxRateType": "Percentage"},
"Tax2Details":{
"Name": "Tax2",
"TaxAmount": 5.770000000,
"TaxCode": "Sabrix Tax",
"TaxDate": "2021-11-26",
"TaxRate": 0.076000000,
"TaxRateType": "Percentage"
}
}