2

PHP APIを使用してクイックブックの請求書の項目にアクセスしようとしています.

その上でいくつかの操作を行うことができるように.....

これを行うと、請求書データを取得できます...

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

結果は次のように得られます

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}
                                        )

                                )

                        )

                )

        )

)

次のように、請求書ID、顧客IDをそれぞれ取得できます

<?php

pr($Invoice->getId());

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

?>

私の質問は、ラインアイテムの数を取得して通常の配列に抽出する方法です

pr($Invoice->getLine());配列全体ではなく、その配列の最初の項目だけが得られるのに疲れました...

これを達成するのは難しいと思います....

4

1 に答える 1

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

また

$count = $Invoice->countLine();
for ($i = 0; $i < $count; $i++)
{
  $Line = $Invoice->getLine($i);
}
于 2013-04-03T15:11:21.653 に答える