I'm working with a SimpleXMLElement Object and retrieving amounts for invoices, some of which contain several line items each with a zero dollar value. I now need to skip any invoices where each of the line items has a zero dollar value. Here's an example:
[11] => SimpleXMLElement Object
(
[Contact] => SimpleXMLElement Object
(
[ContactID] => gzd123456
[Name] => Acme Inc.
)
[Date] => 2017-04-13T00:00:00
[DueDate] => 2017-04-13T00:00:00
[Status] => PAID
[LineAmountTypes] => Inclusive
[LineItems] => SimpleXMLElement Object
(
[LineItem] => Array
(
[0] => SimpleXMLElement Object
(
[Description] => Stock on hand
[UnitAmount] => 0.00
[TaxAmount] => 0.00
[LineAmount] => 0.00
[Quantity] => 1.0000
)
[1] => SimpleXMLElement Object
(
[Description] => Cost of goods sold
[UnitAmount] => 0.00
[TaxAmount] => 0.00
[LineAmount] => 0.00
[Quantity] => 1.0000
)
)
)
[UpdatedDateUTC] => 2017-04-12T22:55:02.657
[CurrencyCode] => AUD
[Type] => ACCPAY
[HasAttachments] => false
)
I'm looping through each invoice like this:
foreach ($invoices->Invoices->Invoice as $invoice) {
then looping through each invoice line item like this:
foreach ($invoiceLineItems->LineItem as $invoiceLineItem) {
$LineAmount = $invoiceLineItem-> LineAmount;
}
which is working fine, but I would like to short circuit the foreach ($invoiceLineItems->LineItem as $invoiceLineItem) {
if possible where all LinteItem>LineAmount values are '0.00'. Is it possible to query all the LineItems at once to see if they are all equal to '0.00'?