douliao8318 2013-04-03 11:56
浏览 29
已采纳

如何使用php api访问Quickbooks发票行项目

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\
Jeffery traders\
Cochin\
India
                                                                )

                                                            [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条回答 默认 最新

  • douchiwan1503 2013-04-03 15:11
    关注
    $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);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!