我正在使用PHP创建Quickbook应用程序
我正在使用https://github.com/intuit/QuickBooks-V3-PHP-SDK/
我想在单个API调用中向多张发票付款。 我看到了他们的例子,但那些只付一次。我需要针对不同客户的各种发票进行多次付款。
那怎么可能?
答案 0 :(得分:1)
他们的示例代码在这里:
这是一个代码段:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 100.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
]]
]);
$resultingObj = $dataService->Add($theResourceObj);
然后,如果您参考他们的文档:
您会看到Line
元素由Zero or more transactions accounting for this payment.
组成,包括The invoice to which payment is applied
。也就是说,您可以在Line
中重复操作,以将付款应用于多个发票。
因此,将付款应用于多个发票会在重复的Line
节点数组中列出每个单独的发票以及要应用的付款金额:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 50.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "211",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "212",
"TxnType" => "Invoice"
]]
],
]
]);
$resultingObj = $dataService->Add($theResourceObj);
答案 1 :(得分:0)
最后我找到了解决方法。
API具有批处理选项,可在单个批处理中添加多个对象。
谢谢大家