php - 在 Quickbook 中添加客户日记条目时出现问题 - 消息 : Passed array has no key for 'Value' when contructing an ReferenceType

标签 php quickbooks

我浏览了这个文档“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/

相关文章:

php - 使用 YiiMail 发送密件抄送电子邮件需要很长时间。有办法加快速度吗?

php - 如何初始化我的自定义 joomla 2.5 模型?

php - Quickbooks Web 连接器突然抛出 0x80040400 错误

c# - 无需用户交互即可连接到 Oauth [QuickBooks]

quickbooks - 使用 Web 连接器的 Quick books 中的迭代示例

php - 是否可以使用 PHP PDO::FETCH_UNIQUE 在结果数组中保留唯一索引?

javascript - 下拉菜单不适用于 bootstrap 4/webpack encore/symfony 4 helppp

php - 如何接受与设备的多个连接

python - QuickBooks 在传递值时解析提供的 XML 文本流时发现错误

QuickBooks Web 连接器 TimeModified 偏移量不考虑夏令时