How to access Quickbooks Invoice Line Items using php api

时光毁灭记忆、已成空白 提交于 2019-12-22 23:57:32

问题


am trying to access the line items of the invoice in quickbooks using php api,

so that i could do some manipulations on it.....

am able to get the invoice data when i do this...

<?php
$Invoice = $InvoiceService->findById($Context, $realmID, $InvoiceID);
pr($Invoice);
?>

the result is obtained as follows

QuickBooks_IPP_Object_Invoice Object
(
    [_data:protected] => Array
        (
            [Id] => Array
                (
                    [0] => {QBO-52}
                )

            [SyncToken] => Array
                (
                    [0] => 13
                )

            [MetaData] => Array
                (
                    [0] => QuickBooks_IPP_Object_MetaData Object
                        (
                            [_data:protected] => Array
                                (
                                    [CreateTime] => Array
                                        (
                                            [0] => 2013-04-02T02:55:30-07:00
                                        )

                                    [LastUpdatedTime] => Array
                                        (
                                            [0] => 2013-04-03T04:15:53-07:00
                                        )

                                )

                        )

                )

            [Header] => Array
                (
                    [0] => QuickBooks_IPP_Object_Header Object
                        (
                            [_data:protected] => Array
                                (
                                    [TxnDate] => Array
                                        (
                                            [0] => 2013-03-31-07:00
                                        )

                                    [Msg] => Array
                                        (
                                            [0] => Customer Message update via QB++
                                        )

                                    [CustomerId] => Array
                                        (
                                            [0] => {QBO-35}
                                        )

                                    [SubTotalAmt] => Array
                                        (
                                            [0] => 15.00
                                        )

                                    [TotalAmt] => Array
                                        (
                                            [0] => 15.00
                                        )

                                    [ToBePrinted] => Array
                                        (
                                            [0] => false
                                        )

                                    [ToBeEmailed] => Array
                                        (
                                            [0] => false
                                        )

                                    [DueDate] => Array
                                        (
                                            [0] => 2013-04-29-07:00
                                        )

                                    [BillAddr] => Array
                                        (
                                            [0] => QuickBooks_IPP_Object_BillAddr Object
                                                (
                                                    [_data:protected] => Array
                                                        (
                                                            [Line1] => Array
                                                                (
                                                                    [0] => Jeffery
                                                                )

                                                            [Line2] => Array
                                                                (
                                                                    [0] => Ads India
                                                                )

                                                            [Line3] => Array
                                                                (
                                                                    [0] => Jeffery trading Co Ltd
                                                                )

                                                            [Line4] => Array
                                                                (
                                                                    [0] => Cochin
                                                                )

                                                            [Line5] => Array
                                                                (
                                                                    [0] => Kerala
India
                                                                )

                                                            [GeoCode] => Array
                                                                (
                                                                    [0] => INVALID
                                                                )

                                                        )

                                                )

                                        )

                                    [ShipAddr] => Array
                                        (
                                            [0] => QuickBooks_IPP_Object_ShipAddr Object
                                                (
                                                    [_data:protected] => Array
                                                        (
                                                            [Line1] => Array
                                                                (
                                                                    [0] => Jeffery
                                                                )

                                                            [Line2] => Array
                                                                (
                                                                    [0] => Jeffery trading Co Ltd\\nJeffery traders\\nCochin\\nIndia
                                                                )

                                                            [Line3] => Array
                                                                (
                                                                    [0] => Jeffery
                                                                )

                                                            [Line4] => Array
                                                                (
                                                                    [0] => 0484232425
                                                                )

                                                            [PostalCode] => Array
                                                                (
                                                                    [0] => 0
                                                                )

                                                            [GeoCode] => Array
                                                                (
                                                                    [0] => INVALID
                                                                )

                                                            [Tag] => Array
                                                                (
                                                                    [0] => CUSTOMER
                                                                )

                                                        )

                                                )

                                        )

                                    [ShipMethodId] => Array
                                        (
                                            [0] => {QBO-}
                                        )

                                    [Balance] => Array
                                        (
                                            [0] => 15.00
                                        )

                                    [DiscountTaxable] => Array
                                        (
                                            [0] => true
                                        )

                                )

                        )

                )

            [Line] => Array
                (
                    [0] => QuickBooks_IPP_Object_Line Object
                        (
                            [_data:protected] => Array
                                (
                                    [Desc] => Array
                                        (
                                            [0] => TES15++
                                        )

                                    [Amount] => Array
                                        (
                                            [0] => 15.00
                                        )

                                    [Taxable] => Array
                                        (
                                            [0] => false
                                        )

                                    [ItemId] => Array
                                        (
                                            [0] => {QBO-30}
                                        )

                                )

                        )

                    [1] => QuickBooks_IPP_Object_Line Object
                        (
                            [_data:protected] => Array
                                (
                                    [Amount] => Array
                                        (
                                            [0] => 0.00
                                        )

                                    [Taxable] => Array
                                        (
                                            [0] => false
                                        )

                                    [ItemId] => Array
                                        (
                                            [0] => {QBO-21}
                                        )

                                )

                        )

                )

        )

)

I can get invoice Id, customer Id respectivly as follows

<?php

pr($Invoice->getId());

pr($Invoice->getHeader()->getCustomerId());

?>

My question is how do i get the count of Line items and extract it to a normal array

I tired pr($Invoice->getLine()); it doesnt give me the whole array but just the 1st item in that array...

am finding it difficult to achieve this ....


回答1:


$Invoice->getLine(0);
$Invoice->getLine(1);
$Invoice->getLine(2);
$Invoice->getLine(3);
etc.

OR

$count = $Invoice->countLine();
for ($i = 0; $i < $count; $i++)
{
  $Line = $Invoice->getLine($i);
}


来源:https://stackoverflow.com/questions/15786681/how-to-access-quickbooks-invoice-line-items-using-php-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!