

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 請求イベントデータフィード
<a name="data-feed-billing-event"></a>

このデータフィードは、請求や支払いなど、請求イベントに関する情報を提供します。

例えば、このデータフィードを使用して、購入者への請求日や請求内容を確認できます。[サンプルの SQL クエリ](#data-feeds-billing-event-query-examples)を使用して、このデータフィードのデータを分析することもできます。

このデータフィードは、登録販売者としての請求イベントに関連する情報を示します。チャネルパートナーを介して締結された契約の場合、このデータフィードはメーカーと登録販売者との請求イベントに関する情報を示します。

請求イベントデータフィードは 24 時間ごとに更新されるため、新しいデータを毎日利用できます。

請求イベントデータはイミュータブルです。

以下の表では、データフィードの列の名前と説明を示しています。


| [列名]  | 説明  | 
| --- | --- | 
| billing\_event\_id | 請求イベントの識別子。この ID は、販売者の環境内で一意です。 | 
| from\_account\_id | 請求イベントを開始したアカウント。`transaction_type` が `SELLER_REV_SHARE` である場合は、購入者の支払いアカウントです。これは、[アカウント](data-feed-account.md)データフィードへの外部キーです。<br />`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| to\_account\_id | 製品の取引金額を受け取るアカウント。これは、アカウントデータフィードへの外部キーです。`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| end\_user\_account\_id | 製品を使用するアカウント。このアカウントは、購入者アカウントや支払者アカウントとは異なる場合があります。`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| product\_id | 製品の識別子。これは [製品](data-feed-product.md)データフィードへの外部キーです。`product_id`フィールドの `Product` データフィードへの結合に使用できます。 | 
| action | このイベントのアクションのタイプ。可能な値は以下のとおりです。+  `INVOICED` - 購入者に該当金額を請求しました。 <br />+  `FORGIVEN` - 購入者に該当金額を請求し、 AWS がその請求を取り消しました。 <br />+  `COLLECTED` – 購入者からこの金額を AWS 回収しました。 <br />+  `DISBURSED` - 販売者に該当金額が支払われました。これは、1 か月分の請求書をまとめるか、オンデマンド支払いとすることができます。  | 
| transaction\_type | 取引のタイプ。例については「[課税シナリオ](#data-feeds-billing-event-tax-examples)」を参照してください。可能な値は以下のとおりです。+  `SELLER_REV_SHARE` - 正の金額。販売者が購入者との契約で設定した料金です。 <br />+  `SELLER_TAX_SHARE` - 正の金額。販売者が支払う税金として `SELLER_REV_SHARE` に追加される金額です。 <br />+  `AWS_REV_SHARE` - 負の金額。出品手数料です。 <br />+  `AWS_TAX_SHARE` – 正の金額。これは、 に加えて AWS 徴収される税金の金額です`SELLER_REV_SHARE`。この金額は販売者の残高には影響しません。この金額は支払い対象ではなく、購入者に請求される税額が販売者に代わって当局に支払われることを販売者に知らせるために提供されます。 <br />+  `{{transaction_type}}_REFUND` - 購入者からリクエストされた返金額。 <br />+  `{{transaction_type}}_CREDIT` – 購入者に AWS クレジットする金額。 <br />+  `BALANCE_ADJUSTMENT` – 請求の問題を解決 AWS するために によって行われた調整。 <br />+  `DISBURSEMENT` - `action` の値が `DISBURSED` で、`balance_impacting` の値が `1` の場合、これは販売者に支払われる金額です。`action` の値が `INVOICED` である場合、このレコードは `parent_billing_event_id` レコードを全面的または部分的に無効にします。この場合、関連する支払い `disbursement_billing_event_id` が表示され、`balance_impacting` の値は `0` です。 <br />+  `DISBURSEMENT_FAILURE` - 取引を無効にします。  | 
| parent\_billing\_event\_id | `broker_id` の値が `AWS_INC` で、`action` の値が `DISBURSED` または `FORGIVEN` で、`transaction_type` の値が `DISBURSEMENT` の場合、`parent_billing_event_id` はこの請求イベントを開始した元の `billing_event_id` の金額を指します。`action` に別の値がある場合、このフィールドは null です。<br />`broker_id` の値が `AWS_EUROPE` の場合、`parent_billing_event_id` は次のシナリオで請求イベントを開始した元の `billing_event_id` を指します。+  `action` の値は `FORGIVEN` または `INVOICED` で、` transaction_type` の値は、` AWS_REV_SHARE`、`AWS_REV_SHARE_REFUND`、または `SELLER_REV_SHARE_REFUND` です。 <br />+  `action` の値は `DISBURSED` で、`transaction_type` の値は `ANY` (`DISBURSEMENT_FAILURE` を除く) です。 <br />+  `transaction_type` の値は、`AWS_TAX_SHARE`、`AWS_TAX_SHARE_REFUND`、`SELLER_TAX_SHARE`、または ` SELLER_TAX_SHARE_REFUND` です。 <br />+  `action` の値は `DISBURSED` で、`transaction_type` の値は `DISBURSEMENT_FAILURE` です。 <br />`broker_id` の値が `AWS_EUROPE` の場合、`parent_billing_event_id` は次のシナリオで前回成功した支払い請求イベントの元の `billing_event_id` を指します。+  `action` の値は `DISBURSED` で、`transaction_type` の値は `DISBURSEMENT_FAILURE` です。 <br />`broker_id` の値が `AWS_EUROPE` の場合、残りのシナリオではこのフィールドは null になります。 | 
| disbursement\_billing\_event\_id | `action` の値が `DISBURSED` であり、さらに次のいずれかに該当する場合の関連支払額。+  `transaction_type like ('SELLER%')` <br />+  `transaction_type like ('AWS%')` <br />他のすべてのシナリオでは、この値は null です。 | 
| amount | 請求イベントの金額。 | 
| currency | ISO 639 通貨コード。 | 
| disbursement\_amount | 支払い額。二重請求シナリオの場合、このフィールドには支払い金額が含まれます。統合請求シナリオの場合、このフィールドは null です。 | 
| disbursement\_currency | 支払い金額の ISO 639 通貨コード。二重請求シナリオの場合、このフィールドには支払い通貨コードが含まれます。統合請求シナリオの場合、このフィールドは null です。 | 
| balance\_impacting | 販売者の支払いを計算する際に該当金額を考慮するかどうか。0 の値は、該当金額が情報提供のために表示されており、残高には影響しないことを示します。1 の値は、該当金額が販売者の支払いを決定する際に考慮されることを示します。 | 
| invoice\_date | 請求書が作成された日付。 | 
| payment\_due\_date | `action` の値が `INVOICED` である場合は、請求書の支払期限日です。 | 
| usage\_period\_start\_date | レコードの期間の開始日。 | 
| usage\_period\_end\_date | レコードの期間の終了日。 | 
| invoice\_id |  AWS 請求書 ID。 | 
| billing\_address\_id | 住所データフィードにおける支払人の請求連絡先の参照。`address_id`フィールドの `Address` データフィードへの結合に使用できます。 | 
| transaction\_reference\_id | 以下のレポートのデータを相互参照できる識別子。+  [請求済み収益ダッシュボード](billed-revenue-dashboard.md)  | 
| bank\_trace\_id | 支払い取引 (`transaction_type` = `DISBURSEMENT` で、アクションは`DISBURSED`) の場合、銀行によって割り当てられたトレース ID。トレース ID は、銀行が提供する販売者銀行からのレポートと関連付けるために使用できます。 | 
| broker\_id | 取引を促進した事業体の識別子。可能な値は以下のとおりです。+  `AWS_INC` <br />– AWS Inc. (米国) の識別子。 <br />+  `AWS_EUROPE` <br />- Amazon Web Services EMEA SARL (ルクセンブルク拠点) の識別子。 <br />+  `AWS_JAPAN` <br />+  `AWS_AUSTRALIA` <br />+  `AWS_KOREA` <br />+  `NULL` <br />- 明示的な `broker_id` のない以前の取引は、`AWS_INC` によって円滑に進められました。  | 
| buyer\_transaction\_reference\_id | `GROUP BY` または SQL で作成されたウィンドウ関数を使用して、請求フィード内のすべての関連レコードをグループ化する識別子。これらの関連レコードには、購入者請求書、販売者請求書、および出品料金にかかる付加価値税 (VAT) が含まれる場合があります。 | 
| action\_date | トランザクションイベントが発生した日付。特定の日付はアクションタイプによって異なります。+  `INVOICED` <br />– アクションの値が INVOICED の場合、action\_date は請求日です。 <br />+  `FORGIVEN` <br />– アクションの値が FORGIVEN の場合、action\_date は AWS がこのトランザクションを許したと認識した日付です。 <br />+  `COLLECTED` <br />– アクションの値が COLLECTED の場合、action\_date は収集日です。 <br />+  `DISBURSED` <br />– アクションの値が DISBURSED の場合、action\_date は支払い日です。  | 
| recipient\_account\_id | フィードでデータを受信している販売者のアカウント。<br />`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| offer\_id | 購入者請求書の明細項目に関連付けられているオファーのフレンドリ ID。<br />`offer_id`フィールドの `Offer` データフィードへの結合に使用できます。 | 
| Buyer\_invoice\_date | 関連する購入者請求書明細項目の請求書日付。 | 
| line\_item\_id | 支払いの詳細度での請求書明細項目 ID。 | 
| Buyer\_line\_item\_id | 支払いの詳細度での購入者請求書明細項目 ID。 | 
| charge\_variant | 何を購入または販売するかを示します。 | 
| charge\_side | 販売者が請求バリアントを売買しているかどうかを示します。 | 

## 課税シナリオ
<a name="data-feeds-billing-event-tax-examples"></a>

購入者と販売者の国および州に適用されている課税モデルによって、税金の徴収と支払の方法が決まります。考えられるシナリオは次のとおりです。
+ 税金は によって収集され、送金されます AWS。この場合、`transaction_type` は `AWS_TAX_SHARE` です。
+ 税金は AWS、販売者が徴収し、販売者に支払い、販売者が税務当局に送金します。この場合、`transaction_type` は `SELLER_TAX_SHARE` です。
+ 税金は によって徴収されません AWS。販売者が税金を計算して税務当局に納税する必要があります。このような場合、 は税計算を実行 AWS Marketplace したり、税情報を受信したりしません。販売者が収益分配金から納税します。

## 請求イベントデータフィードの例
<a name="data-feed-billing-event-sample-scenario"></a>

このセクションでは、請求時と 1 か月後の請求イベントデータ期間の例を示します。このセクションのすべての表について、次の点に注意してください。
+ データフィードの `billing_event_id` 値は 40 文字の英数字文字列です。ここでは、見やすいように 2 文字の文字列として表示しています。
+ この情報は、データフィードの単一のテーブルに表示されます。見やすいように、ここではデータを複数のテーブルに表示し、一部の列を省略しています。

このセクションの例では、以下を前提とします。
+ Arnav は購入者です。
  + アカウント ID は `737399998888` です。
  + 居住国のフランスでは、マーケットプレイスファシリテーター法が適用されます。詳細については、「[アマゾン ウェブ サービス税務ヘルプ](https://aws.amazon.com/tax-help/)」を参照してください。
  + `prod-o4grxfafcxxxx` を購入し、この製品の月間使用料として 120.60 USD を請求されました。
  + 当月内に請求額を支払いました。
+ Jane はメーカーです。
  + アカウント ID は `111122223333` です。
+ Paulo は登録販売者です。
  + アカウント ID は `777788889999` です。
  + 居住しているカンザス州は、マーケットプレイスファシリテーター法の対象ではありません。

### 登録販売者の請求イベントデータフィード
<a name="billing-event-example-seller-of-record"></a>

Paulo は、登録販売者として購入者の Arnav に請求を行います。

次の表は、Paulo が Arnav に請求した際のデータフィードの関連情報を示しています。


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I0 | 737399998888 | 777788889999 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I1 | 737399998888 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\_TAX\_SHARE | 
| I2 | 777788889999 | 111122223333 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I3 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\_REV\_SHARE | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 100 | USD | 2018-12-31T00:00:00Z | 781216640 | 
|  |  | 20.6 | USD | 2018-12-31T00:00:00Z | 781216640 | 
|  |  | -80 | USD | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | -0.2 | USD | 2018-12-31T00:04:07Z | 788576665 | 

次の表は、Arnav が請求額を支払った後の月末における Paulo のデータフィードの関連情報を示しています。


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I10 | 737399998888 | 777788889999 | 737399998888 |  | DISBURSED | SELLER\_REV\_SHARE | 
| I12 | 777788889999 | 111122223333 | 737399998888 |  | DISBURSED | SELLER\_REV\_SHARE | 
| I13 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | DISBURSED | AWS\_REV\_SHARE | 
| I14 | AWS | 777788889999 |  |  | DISBURSED | DISBURSEMENT | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
| I0 | I14 | -100 | USD | 2018-12-31T00:00:00Z | 781216640 | 
| I2 | I14 | 80 | USD | 2018-12-31T00:04:07Z | 788576665 | 
| I3 | I14 | 0.2 | USD | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | 19.8 | USD |  |  | 

### メーカーの請求イベントデータフィード
<a name="billing-event-example-manufacturer"></a>

次の表は、Paulo が Arnav に請求した際の Jane のデータフィードの関連情報を示しています。


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I5 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\_REV\_SHARE | 
| I6 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\_TAX\_SHARE | 
| I7 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | INVOICED | AWS\_REV\_SHARE | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 73.5 |  | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | 6.5 |  | 2018-12-31T00:04:07Z | 788576665 | 
|  |  | -7.35 |  | 2018-12-31T00:04:07Z | 788576665 | 

次の表は、請求額が支払われた後の月末における Jane のデータフィードの関連情報を示しています。


| billing\_event\_id  | from\_account\_id  | to\_account\_id  | end\_user\_account\_id | product\_id | action | transaction\_type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I30 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\_REV\_SHARE | 
| I31 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\_TAX\_SHARE | 
| I32 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | DISBURSED | AWS\_REV\_SHARE | 
| I33 | AWS | 111122223333 |  |  | DISBURSED | DISBURSEMENT | 




| parent\_billing\_event\_id | disbursement\_billing\_event\_id | amount | currency | invoice\_date | invoice\_id | 
| --- | --- | --- | --- | --- | --- | 
| I5 | I33 | -73.5 | USD |  |  | 
| I6 | I33 | -6.5 | USD |  |  | 
| I7 | I33 | 7.35 | USD |  |  | 
|  |  | 72.65 | USD |  |  | 

## クエリの例
<a name="data-feeds-billing-event-query-examples"></a>

[データフィードを使用したデータ収集と分析](data-feed-using.md) で説明しているように、[ Athena](https://docs.aws.amazon.com/athena/latest/ug/what-is.html) を使用して、マネージド Amazon S3 バケットにデータフィードとして収集されて保存されたデータに対してクエリを実行できます。このセクションでは、これを行う一般的な方法の例をいくつか示します。すべての例で、単一の通貨を使用するものとします。

## 例 1: 請求金額 (税込み)
<a name="data-feed-example-query-tax-invoice"></a>

購入者への請求金額 (税込み) を確認するには、次の例に示すようなクエリを実行できます。

```
SELECT sum(amount) FROM billing_event 
WHERE 
  action = 'INVOICED'
  AND
  (
    (transaction_type in ('SELLER_REV_SHARE', 'SELLER_TAX_SHARE')
      -- to discard SELLER_REV_SHARE from Manufacturer to Channel Partner, aka cost of goods
      AND to_account_id='{{seller-account-id}}'
    )
  OR transaction_type= 'AWS_TAX_SHARE'
  );
```

## 例 2: 販売者に代わって購入者に請求する金額
<a name="data-feed-example-query-invoice-for-seller"></a>

販売者に代わって購入者に請求した金額を確認するには、次の例に示すようなクエリを実行できます。

```
SELECT sum(amount) FROM billing_event 
WHERE
  action = 'INVOICED'
  AND transaction_type in ('SELLER_REV_SHARE', 'SELLER_TAX_SHARE')
  AND to_account_id='{{seller-account-id}}'
;
```

## 例 3: 販売者に代わって回収 AWS できる金額
<a name="data-feed-example-query-aws-collect"></a>

販売者に代わって が回収 AWS できる金額から返金、クレジット、許されたアカウントを差し引いた金額を調べるには、次の例に示すようにクエリを実行できます。

```
SELECT sum(amount) FROM billing_event 
WHERE
  -- what is invoiced on behalf of SELLER, incl. refunds/ credits and cost of goods
  transaction_type like 'SELLER_%' 
  -- FORGIVEN action records will "negate" related INVOICED
  and action in ('INVOICED','FORGIVEN') 
;
```

## 例 4: 販売者が徴収できる金額
<a name="data-feed-example-query-seller-collect"></a>

販売者が徴収できる金額を確認するには、次の例に示すようなクエリを実行できます。この例では、 が AWS 徴収する出品料金と税金を削除し、例外的な残高調整を追加します。

```
SELECT sum(amount) FROM billing_event
WHERE
  (transaction_type like 'SELLER_%' -- what is invoiced on behalf of SELLER
  or transaction_type like 'AWS_REV_%' -- what is owed to AWS
  or transaction_type = 'BALANCE_ADJUSTMENT' -- exceptionnal case
  )
  and action in ('INVOICED','FORGIVEN')
;
```

また、次の例に示すように、次のクエリを使用して同じ情報を収集することもできます。

```
SELECT sum(amount) FROM billing_event
WHERE
  balance_impacting = 1
  and action in ('INVOICED','FORGIVEN')
;
```

次の例は同じ情報を示していますが、2018 年の取引に限定し、すべての購入者が請求額を支払ったと仮定しています。

```
SELECT sum(amount) FROM billing_event
WHERE
  invoice_date between '2018-01-01' and '2018-12-31'
  and balance_impacting = 1
  and action in ('INVOICED','FORGIVEN')
;
```

## 例 5: 支払い額
<a name="data-feed-example-query-disbursements"></a>

支払われた金額を確認するには、次の例に示すようなクエリを実行できます。

```
select sum(amount) FROM billing_event
WHERE
  action ='DISBURSED'
  and transaction_type like 'DISBURSEMENT%'
;
```

## 例 6: 保留中の支払い金額
<a name="data-feed-example-query-pending-disbursement"></a>

保留中の支払い金額を確認するには、次の例に示すようなクエリを実行できます。このクエリでは、支払い済みの金額を除外します。

```
SELECT sum(amount) FROM billing_event targeted 
WHERE
   (transaction_type like 'SELLER_%'  -- what is invoiced on behalf of SELLER
    or transaction_type like 'AWS_REV_%'  -- what is owed to AWS
    or transaction_type = 'BALANCE_ADJUSTMENT' -- exceptionnal case
   ) 
  -- DISBURSEMENT action records will "negate" 'INVOICED'
  -- but do not take into account failed disbursements
   AND 
    (not exists
      (select 1 
        from billing_event disbursement
          join billing_event failed_disbursement
           on disbursement.billing_event_id=failed_disbursement.parent_billing_event_id
        where
         disbursement.transaction_type='DISBURSEMENT'
         and failed_disbursement.transaction_type='DISBURSEMENT_FAILURE'
         and targeted.disbursement_billing_event_id=disbursement.billing_event_id
      )
    ) 
;
```

同じ情報を取得する別の方法としては、次の例に示すようなクエリを実行して販売者の残高を取得します。

```
SELECT sum(amount) FROM billing_event
WHERE
 balance_impacting = 1
;
```

次のクエリでは、この例を拡張します。クエリ結果を 2018 年の取引に限定し、これらの取引に関する追加の詳細を返します。

```
select sum(residual_amount_per_transaction)
from
 (SELECT
    max(billed_invoices.amount) invoiced_amount,
    sum(nvl(disbursed_invoices.amount,0)) disbursed_amount,
    -- Exercise left to the reader:
    -- use transaction_type to distinguish listing fee vs seller-owed money
    -- still pending collection
    max(transaction_type) transaction_type,
    max(billed_invoices.amount) 
      + sum(nvl(disbursed_invoices.amount,0)) residual_amount_per_transaction
  FROM billing_event billed_invoices
    -- find related disbursements
    left join billing_event disbursed_invoices
      on disbursed_invoices.action='DISBURSED'
      and disbursed_invoices.parent_billing_event_id=billed_invoices.billing_event_id
  WHERE
    billed_invoices.invoice_date between '2018-01-01' and '2018-12-31'
    and billed_invoices.transaction_type like 'SELLER_%' -- invoiced on behalf of SELLER
    and billed_invoices.action in ('INVOICED','FORGIVEN')
    -- do not take into account failed disbursements
    AND not exists
      (select 1 from billing_event failed_disbursement
       where disbursed_invoices.disbursement_billing_event_id = failed_disbursement.parent_billing_event_id
      )
   GROUP BY billed_invoices.billing_event_id
);
```

## 例 7: 一連の請求書の残高
<a name="data-feed-example-query-balance-invoice-set"></a>

一連の請求書の合計額を確認するには、次の例に示すようなクエリを実行できます。

```
SELECT invoice_id, sum(amount) FROM billing_event targeted
WHERE
  -- invoice_id is only not null for invoiced records AND disbursed records 
  -- linking them to related disbursement -> no need to filter more precisely
  invoice_id in ('XXX','YYY') 
  -- filter out failed disbursements 
  AND not exists
      (select 1 
        from billing_event disbursement
          join billing_event failed_disbursement
           on disbursement.billing_event_id=failed_disbursement.parent_billing_event_id
        where
         disbursement.transaction_type='DISBURSEMENT'
         and failed_disbursement.transaction_type='DISBURSEMENT_FAILURE'
         and targeted.disbursement_billing_event_id=disbursement.billing_event_id
      ) 
  group by invoice_id;
```