如何告诉Stripe在通过其API创建贷方通知时为我计算税金?

huangapple go评论52阅读模式
英文:

How can I tell Stripe to calculate the tax for me during credit note creation via their API?

问题

使用Stripe的自动税务计算(automatic_tax[enabled]=true)时,Stripe会负责计算应用于发票的税额。我遇到的问题是,当通过Stripe的API创建“信用票据” 进行部分退款 时,refund_amount必须等于信用票据金额(信用票据金额=退款金额+税额),但我不知道计算的税额退款金额应该是多少,因为Stripe会在其端处理该计算。

考虑以下代码,该代码将尝试创建一个金额为$10.00的发票上的信用票据:

$stripe->creditNotes->create([
  'invoice' => 'in_xxxxxxxxxxxxx',
  'refund_amount' => 1000,
]);

问题在于,Stripe将在其端计算出refund_amount应为$10.70(假设税率为7%),并返回以下错误:

信用金额、退款金额和额外金额之和($10.00)必须等于信用票据金额($10.70)。

因此,我认为我需要一个额外的参数,告诉Stripe我期望他们确定税额的附加金额应该是多少;类似于这样:

$stripe->creditNotes->create([
  'invoice' => 'in_xxxxxxxxxxxxx',
  'refund_amount' => 1000,
  'automatic_tax' => [
    'enabled' => true,
  ],
]);

但是该参数在API文档上并不存在。有人有关于如何解决这个问题的建议吗?

英文:

When using Stripe's automatic tax calculation (automatic_tax[enabled]=true) Stripe takes care of calculating the amount of tax that is applied to an invoice. The problem I'm running into is that when creating a "credit note" for a partial refund via Stripe's API, the refund_amount must equal the credit note amount (credit note amount = refund amount + tax), but I don't know what the calculated tax refund amount should be since Stripe handles that calculation on their end.

Consider the following code that will attempt to create a credit note on an invoice in the amount of $10.00:

$stripe->creditNotes->create([
  'invoice' => 'in_xxxxxxxxxxxxx',
  'refund_amount => 1000,
]);

The problem is that Stripe will calculate on their end that the refund_amount should be $10.70 (assuming 7% tax), and will return the following error:

> The sum of credit amount, refund amount and out of band amount ($10.00) must equal the credit note amount ($10.70).

So what I'm thinking I need is an additional parameter that tells Stripe that I'm expecting them to determine what the additional amount for tax should be; something like this:

$stripe->creditNotes->create([
  'invoice' => 'in_xxxxxxxxxxxxx',
  'refund_amount => 1000,
  'automatic_tax' => [
    'enabled' => true,
  ],
]);

But that parameter doesn't exist on the API. Does anyone have any suggestions on how to solve this problem?

答案1

得分: 0

在创建信用备忘录之前,您应该检索发票,并查看总额税额属性,以了解您应该在信用备忘录中使用的评估金额。

英文:

Prior to creating your Credit Note you should retrieve the Invoice and look at either the total or the tax properties to know the assessed amount that you should use for your Credit Note.

答案2

得分: 0

以下是翻译好的内容:

解决方案是首先创建一个“预览”信用备忘录,其中包含计算的税额。然后,在创建实际信用备忘录时,您可以将该税额添加到退款金额中:

// 退款金额。
$amount = 1000; //($10.00)

// 首先创建一个预览信用备忘录。
$preview = $stripe->creditNotes->preview([
'invoice' => 'in_xxxxxxxxxxxxx',
'refund_amount' => $amount,
'lines' => [
[
'type' => 'invoice_line_item',
'invoice_line_item' => 'li_xxxxxxxxxxxxx',
'amount' => $amount,
],
],
]);

// 从预览中收集税款。
$tax = 0;
foreach ($preview->tax_amounts as $taxAmount) {
$tax += $taxAmount->amount;
}

// 将税款添加到退款金额中。
$totalAmount = $amount + $tax;

// 发出实际信用备忘录。
$creditNote = $stripe->creditNotes->create([
'invoice' => 'in_xxxxxxxxxxxxx',
'refund_amount' => $totalAmount,
'lines' => [
[
'type' => 'invoice_line_item',
'invoice_line_item' => 'li_xxxxxxxxxxxxx',
'amount' => $amount,
],
],
]);

英文:

The solution is to first create a "preview" credit note, which provides the calculated tax amounts. You can then add that tax onto the refund amount when creating the actual credit note:

// The amount to refund.
$amount = 1000; // ($10.00)

// First create a preview credit note.
$preview = $stripe->creditNotes->preview([
    'invoice' => 'in_xxxxxxxxxxxxx',
    'refund_amount' => $amount,
    'lines' => [
        [
            'type' => 'invoice_line_item',
            'invoice_line_item' => 'li_xxxxxxxxxxxxx',
            'amount' => $amount,
        ],
    ],
]);

// Collect the tax from the preview.
$tax = 0;
foreach ($preview->tax_amounts as $taxAmount) {
    $tax += $taxAmount->amount;
}

// Add the tax onto the refund amount.
$totalAmount = $amount + $tax;

// Issue the actual credit note.
$creditNote = $stripe->creditNotes->create([
    'invoice' => 'in_xxxxxxxxxxxxx',
    'refund_amount' => $totalAmount,
    'lines' => [
        [
            'type' => 'invoice_line_item',
            'invoice_line_item' => 'li_xxxxxxxxxxxxx',
            'amount' => $amount,
        ],
    ],
]);

huangapple
  • 本文由 发表于 2023年6月8日 21:51:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432571.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定