我浏览了这个文档“https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/journalentry”
并尝试添加包含客户的行的日记帐分录,如下面的代码所示:
$journal_entry_create['TxnDate'] = date('Y-m-d');
$journal_entry_line = array(
'Amount' => $amount,
'DetailType' => 'JournalEntryLineDetail',
'JournalEntryLineDetail' => array(
'PostingType' => Credit,
'Entity' => array(
'Type' => 'Customer',
'EntityRef' => array(
'type' => 'Customer',
'value' => "2",
'name' => 'Abc'
)
),
'AccountRef' => array(
'name' => 'Account Name',
'value' => '1'
),
)
);
$journal_entry_lines[] = $journal_entry_line;
$journal_entry_create['Line'] = $journal_entry_lines;
$journal_entry_receipt_create = QBJournalEntry::create($journal_entry_create);
$journal_entry_receipt_create_result = $dataService->Add($journal_entry_receipt_create);
没有 EntityRef 它工作正常但是当我添加 EntityRef 时它给我错误“消息:在构造 ReferenceType 时传递的数组没有 'Value' 的键”
最佳答案
我自己才遇到这个问题。他们确实解决了这个问题,但似乎根本没有记录或告诉任何人。在 source code 中找到修复.您需要在“JournalEntryLineDetail”下使用“JournalEntryEntity”而不是“Entity”,如下所示:
'JournalEntryLineDetail' => array(
'PostingType' => "Credit",
'JournalEntryEntity' => array(
'Type' => 'Customer',
'EntityRef' => array(
'value' => "2"
)
),
'AccountRef' => array(
'name' => 'Account Name',
'value' => '1'
),
)
我还使用了 PHP SDK V3 中的 FacadeHelper(我不确定它是否适用于您使用的方法):
use QuickBooksOnline\API\Facades\FacadeHelper;
...
$journal_entry_receipt_create = FacadeHelper::reflectArrayToObject('JournalEntry', $journal_entry_create);
$journal_entry_receipt_create_result = $dataService->Add($journal_entry_receipt_create);
我知道这对你 OP 来说可能为时已晚,但希望它能帮助其他人!
关于php - 在 Quickbook 中添加客户日记条目时出现问题 - 消息 : Passed array has no key for 'Value' when contructing an ReferenceType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54643083/