

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

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

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

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

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

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

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

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


| [列名]  | 説明  | 
| --- | --- | 
| billing\$1event\$1id | 請求イベントの識別子。この ID は、販売者の環境内で一意です。 | 
| from\$1account\$1id |  請求イベントを開始したアカウント。`transaction_type` が `SELLER_REV_SHARE` である場合は、購入者の支払いアカウントです。これは、[アカウント](data-feed-account.md)データフィードへの外部キーです。 `account_id`フィールドの `Account` データフィードへの結合に使用できます。  | 
| to\$1account\$1id | 製品の取引金額を受け取るアカウント。これは、アカウントデータフィードへの外部キーです。`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| end\$1user\$1account\$1id | 製品を使用するアカウント。このアカウントは、購入者アカウントや支払者アカウントとは異なる場合があります。`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| product\$1id | 製品の識別子。これは [製品](data-feed-product.md)データフィードへの外部キーです。`product_id`フィールドの `Product` データフィードへの結合に使用できます。 | 
| action |  このイベントのアクションのタイプ。可能な値は以下のとおりです。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html)  | 
| transaction\$1type |  取引のタイプ。例については「[課税シナリオ](#data-feeds-billing-event-tax-examples)」を参照してください。可能な値は以下のとおりです。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html)  | 
| parent\$1billing\$1event\$1id |  `broker_id` の値が `AWS_INC` で、`action` の値が `DISBURSED` または `FORGIVEN` で、`transaction_type` の値が `DISBURSEMENT` の場合、`parent_billing_event_id` はこの請求イベントを開始した元の `billing_event_id` の金額を指します。`action` に別の値がある場合、このフィールドは null です。 `broker_id` の値が `AWS_EUROPE` の場合、`parent_billing_event_id` は次のシナリオで請求イベントを開始した元の `billing_event_id` を指します。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html) `broker_id` の値が `AWS_EUROPE` の場合、`parent_billing_event_id` は次のシナリオで前回成功した支払い請求イベントの元の `billing_event_id` を指します。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html) `broker_id` の値が `AWS_EUROPE` の場合、残りのシナリオではこのフィールドは null になります。  | 
| disbursement\$1billing\$1event\$1id |  `action` の値が `DISBURSED` であり、さらに次のいずれかに該当する場合の関連支払額。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html) 他のすべてのシナリオでは、この値は null です。  | 
| amount | 請求イベントの金額。 | 
| currency | ISO 639 通貨コード。 | 
| disbursement\$1amount | 支払い額。二重請求シナリオの場合、このフィールドには支払い金額が含まれます。統合請求シナリオの場合、このフィールドは null です。 | 
| disbursement\$1currency | 支払い金額の ISO 639 通貨コード。二重請求シナリオの場合、このフィールドには支払い通貨コードが含まれます。統合請求シナリオの場合、このフィールドは null です。 | 
| balance\$1impacting | 販売者の支払いを計算する際に該当金額を考慮するかどうか。0 の値は、該当金額が情報提供のために表示されており、残高には影響しないことを示します。1 の値は、該当金額が販売者の支払いを決定する際に考慮されることを示します。 | 
| invoice\$1date | 請求書が作成された日付。 | 
| payment\$1due\$1date |  `action` の値が `INVOICED` である場合は、請求書の支払期限日です。  | 
| usage\$1period\$1start\$1date | レコードの期間の開始日。 | 
| usage\$1period\$1end\$1date | レコードの期間の終了日。 | 
| invoice\$1id |   AWS 請求書 ID。  | 
| billing\$1address\$1id | 住所データフィードにおける支払人の請求連絡先の参照。`address_id`フィールドの `Address` データフィードへの結合に使用できます。 | 
| transaction\$1reference\$1id |  以下のレポートのデータを相互参照できる識別子。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html)  | 
| bank\$1trace\$1id |  支払い取引 (`transaction_type` = `DISBURSEMENT` で、アクションは`DISBURSED`) の場合、銀行によって割り当てられたトレース ID。トレース ID は、銀行が提供する販売者銀行からのレポートと関連付けるために使用できます。  | 
| broker\$1id |  取引を促進した事業体の識別子。可能な値は以下のとおりです。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html)  | 
| buyer\$1transaction\$1reference\$1id |  `GROUP BY` または SQL で作成されたウィンドウ関数を使用して、請求フィード内のすべての関連レコードをグループ化する識別子。これらの関連レコードには、購入者請求書、販売者請求書、および出品料金にかかる付加価値税 (VAT) が含まれる場合があります。  | 
| action\$1date |  トランザクションイベントが発生した日付。特定の日付はアクションタイプによって異なります。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/marketplace/latest/userguide/data-feed-billing-event.html)  | 
| recipient\$1account\$1id | フィードでデータを受信している販売者のアカウント。`account_id`フィールドの `Account` データフィードへの結合に使用できます。 | 
| offer\$1id | 購入者請求書の明細項目に関連付けられているオファーのフレンドリ ID。`offer_id`フィールドの `Offer` データフィードへの結合に使用できます。 | 
| Buyer\$1invoice\$1date | 関連する購入者請求書明細項目の請求書日付。 | 
| line\$1item\$1id | 支払いの詳細度での請求書明細項目 ID。 | 
| Buyer\$1line\$1item\$1id | 支払いの詳細度での購入者請求書明細項目 ID。 | 
| charge\$1variant | 何を購入または販売するかを示します。 | 
| charge\$1side | 販売者が請求バリアントを売買しているかどうかを示します。 | 

## 課税シナリオ
<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\$1event\$1id  | from\$1account\$1id  | to\$1account\$1id  | end\$1user\$1account\$1id | product\$1id | action | transaction\$1type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I0 | 737399998888 | 777788889999 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\$1REV\$1SHARE | 
| I1 | 737399998888 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\$1TAX\$1SHARE | 
| I2 | 777788889999 | 111122223333 | 737399998888 | prod-o4grxfafcxxxx | INVOICED | SELLER\$1REV\$1SHARE | 
| I3 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | INVOICED | AWS\$1REV\$1SHARE | 




| parent\$1billing\$1event\$1id | disbursement\$1billing\$1event\$1id | amount | currency | invoice\$1date | invoice\$1id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 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\$1event\$1id  | from\$1account\$1id  | to\$1account\$1id  | end\$1user\$1account\$1id | product\$1id | action | transaction\$1type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I10 | 737399998888 | 777788889999 | 737399998888 |  | DISBURSED | SELLER\$1REV\$1SHARE | 
| I12 | 777788889999 | 111122223333 | 737399998888 |  | DISBURSED | SELLER\$1REV\$1SHARE | 
| I13 | 777788889999 | AWS | 737399998888 | prod-o4grxfafcxxxx | DISBURSED | AWS\$1REV\$1SHARE | 
| I14 | AWS | 777788889999 |  |  | DISBURSED | DISBURSEMENT | 




| parent\$1billing\$1event\$1id | disbursement\$1billing\$1event\$1id | amount | currency | invoice\$1date | invoice\$1id | 
| --- | --- | --- | --- | --- | --- | 
| 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\$1event\$1id  | from\$1account\$1id  | to\$1account\$1id  | end\$1user\$1account\$1id | product\$1id | action | transaction\$1type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I5 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\$1REV\$1SHARE | 
| I6 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | INVOICED | SELLER\$1TAX\$1SHARE | 
| I7 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | INVOICED | AWS\$1REV\$1SHARE | 




| parent\$1billing\$1event\$1id | disbursement\$1billing\$1event\$1id | amount | currency | invoice\$1date | invoice\$1id | 
| --- | --- | --- | --- | --- | --- | 
|  |  | 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\$1event\$1id  | from\$1account\$1id  | to\$1account\$1id  | end\$1user\$1account\$1id | product\$1id | action | transaction\$1type | 
| --- | --- | --- | --- | --- | --- | --- | 
| I30 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\$1REV\$1SHARE | 
| I31 | 777788889999 | 111122223333 |  | prod-o4grxfafcxxxx | DISBURSED | SELLER\$1TAX\$1SHARE | 
| I32 | 111122223333 | AWS |  | prod-o4grxfafcxxxx | DISBURSED | AWS\$1REV\$1SHARE | 
| I33 | AWS | 111122223333 |  |  | DISBURSED | DISBURSEMENT | 




| parent\$1billing\$1event\$1id | disbursement\$1billing\$1event\$1id | amount | currency | invoice\$1date | invoice\$1id | 
| --- | --- | --- | --- | --- | --- | 
| 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;
```