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);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?