Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLineItems()[item]->getDiscountAmount() is returning empty #152

Closed
timwiel opened this issue Aug 18, 2020 · 3 comments
Closed

getLineItems()[item]->getDiscountAmount() is returning empty #152

timwiel opened this issue Aug 18, 2020 · 3 comments
Assignees

Comments

@timwiel
Copy link

timwiel commented Aug 18, 2020

SDK you're using (please complete the following information):

  • Version 2.1.0

Describe the bug
When performing a retrieval of an ACCREC invoice with that has discounted line items only the getDiscountRate is returned and getDiscountAmount is empty.

$result = $apiInstance->getInvoices($xeroTenantId,null,null,null,null,'INV-6900');
echo '<pre>';
print_r($result->getInvoices()[0]->getLineItems());

However when using the Previewer the XML returns a discountAmount AND discountRate

Expected behavior
I would expect that both discountAmount AND discountRate should be returned

Screenshots
Xero Invoice Line Items:
image

print_r result from code above:
image

API previewer on developer.xero.com:
image

@timwiel
Copy link
Author

timwiel commented Aug 18, 2020

Note I've tried this in both the example app (where the modified code above lives) and a more developed app - both fail to return the required discountAmount

@wobinb
Copy link
Contributor

wobinb commented Aug 19, 2020

@timwiel The API server response on the Invoices endpoint will vary depending on the call being made.

When retrieving a single invoice eg. api.xro/2.0/Invoices/c7e6d6b6-f32f-46a5-9e3b-31088fd9193d full detail will be returned.

If multiple invoices could be returned eg. api.xro/2.0/Invoices?where=InvoiceNumber=='ORC1041' only a summary is returned.

If the page argument is included eg. api.xro/2.0/Invoices?page=1 the response includes more - but not all the detail.

The call you are making uses the InvoiceNumbers argument eg. api.xro/2.0/Invoices?InvoiceNumbers=ORC1041 this gives the same response as the page argument, and crucially doesn't include the DiscountAmount field.

To retrieve the DiscountAmount field try making the call like this:
$apiResponse = $accountingApi->getInvoice($xeroTenantId,$invoiceId);

@timwiel
Copy link
Author

timwiel commented Jun 4, 2024

I believe there is still a bug with this issue (not in the SDK but in the API) ... I've posted the a bug report on the API issues list (XeroAPI/Xero-OpenAPI#592 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants