duan19780629
2014-01-28 14:21 阅读 81
已采纳

如何使用SDK(PHP)在QuickBooks Online中添加日记条目

In my project I am integrating QuickBooks Online by PHP. Here I want to add journal entry. So I have downloaded the SDK for PHP. And able to connect QuickBook Online and successfully add some customer.

But my real requirement is adding Journal Entry, but there is no example for journal entry. So I am wondering how I can add Journal using that SDK? Which class I need to use for Journal Entry? And How can I pass the journal data?

Please help me.

Thanks in Advance

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    doucao8982 doucao8982 2014-01-30 13:07

    I searched the sdk and found, there is a class IPPJournalEntry which will be used here for journal entry add. Along with this we need two more classes IPPLine, IPPJournalEntryLineDetail.

    Thanks

    点赞 评论 复制链接分享
  • duanji5746 duanji5746 2014-01-28 16:36

    If you're using the open-source QuickBooks PHP DevKit provided on GitHub:

    Then you can find the quick-start guide to getting connected here:

    And a detailed working example of adding a journal entry here:

    The code ends up looking something like:

    $JournalEntryService = new QuickBooks_IPP_Service_JournalEntry();
    
    // Main journal entry object
    $JournalEntry = new QuickBooks_IPP_Object_JournalEntry();
    $JournalEntry->setDocNumber('1234');
    $JournalEntry->setTxnDate(date('Y-m-d'));
    
    // Debit line
    $Line1 = new QuickBooks_IPP_Object_Line();
    $Line1->setDescription('Line 1 description');
    $Line1->setAmount(100);
    $Line1->setDetailType('JournalEntryLineDetail');
    
    $Detail1 = new QuickBooks_IPP_Object_JournalEntryLineDetail();
    $Detail1->setPostingType('Debit');
    $Detail1->setAccountRef(3);
    
    $Line1->addJournalEntryLineDetail($Detail1);
    $JournalEntry->addLine($Line1);
    
    // Credit line
    $Line2 = new QuickBooks_IPP_Object_Line();
    $Line2->setDescription('Line 2 description');
    $Line2->setAmount(100);
    $Line2->setDetailType('JournalEntryLineDetail');
    
    $Detail2 = new QuickBooks_IPP_Object_JournalEntryLineDetail();
    $Detail2->setPostingType('Credit');
    $Detail2->setAccountRef(56);
    
    $Line2->addJournalEntryLineDetail($Detail2);
    $JournalEntry->addLine($Line2);
    
    if ($resp = $JournalEntryService->add($Context, $realm, $JournalEntry))
    {
        print('Our new journal entry ID is: [' . $resp . ']');
    }
    else
    {
        print($JournalEntryService->lastError($Context));
    }
    
    点赞 评论 复制链接分享

相关推荐