question

Danielle Cox avatar image
Danielle Cox asked sam Deactivated commented

LineItem getIsRevenue()

There is a hasIsRevenue() and getIsRevenue(). It says revenue may be null. If it is null, is it considered revenue or non-revenue?

Is the "correct" way to check for an item being revenue to be

if (li.hasIsRevenue() && li.getIsRevenue())

or is it `

if (! li.hasIsRevenue() || li.getIsRevenue())

or is there a better way?

Thanks

Danielle

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

sam avatar image
sam Deactivated answered sam Deactivated commented

Use getIsRevenue which will return a boolean whether lineItem is revenue or not. It will not return null as items are defaulted to true.

hasIsRevenue is a boolean returning whether the param isRevenue exists, irregardless of it being revenue or not. Will only rturn null if isRevenue param is somehow missing.

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Danielle Cox avatar image Danielle Cox commented ·

In the case of isRevenue being null, I am getting a null pointer exception. This is with:

boolean isRevenue = lineItem->getIsRevenue();

An example lineItem for this is: LineItem{json='{"createdTime":1493752362963,"taxRates":{"elements":[{"id":"H81CTR0MNB502","isDefault":true,"name":"Broward Sales","rate":650000}]},"userData":null,"alternateName":"","id":"HWS8WYG986J58","exchanged":false,"price":1100,"refunded":false,"binName":null,"isRevenue":null,"name":"Custom Item","printed":false,"note":null,"itemCode":null}', bundle=Bundle[{}], changeLog=null}

0 Likes 0 ·
sam avatar image sam commented ·

https://devask.clover.com/question/77...

0 Likes 0 ·

Welcome to the
Clover Developer Community