账单事件数据源 - AWS Marketplace

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

账单事件数据源

此数据源提供有关账单事件的信息,包括开发票和付款。

例如,您可以使用此数据源来了解为买家开发票的时间和内容。您也可以使用示例SQL查询来分析来自此数据馈送的数据。

此数据源包含与您作为其记录卖家的账单事件相关的信息。对于通过渠道合作伙伴达成的协议,此数据源包含有关制造商和记录卖家之间的账单事件的信息。

账单事件数据源每 24 小时刷新一次,因此每天提供的都是新数据。

账单事件数据是不可变的。

下表说明了数据源列的名称和说明。

列名称 描述
billing_event_id 账单事件的标识符。此 ID 在卖家的环境中是唯一的。
from_account_id

启动账单事件的账户。如果 transaction_typeSELLER_REV_SHARE,则它是买家的付款人账户。这是账户数据源的外键。

可用于连接 account_id 数据源的 Account 字段。

to_account_id 接收产品的交易金额的账户。这是账户数据源的外键。

可用于连接 account_id 数据源的 Account 字段。

end_user_account_id 使用产品的账户。此账户可能与买家账户和付款人账户不同。

可用于连接 account_id 数据源的 Account 字段。

product_id 产品的标识符。这是产品数据源的外键。

可用于连接 product_id 数据源的 Product 字段。

action

此事件的操作类型。可能值如下所示:

  • INVOICED – 向买家开具了该金额的发票。

  • FORGIVEN – 向买家开具了该金额的发票,并且 AWS 恢复了该费用。

  • DISBURSED – 向卖家支付了该金额。这可以包括一个月的发票,也可以是按需付款。

transaction_type

交易的类型。有关示例,请参阅征税方案。可能值如下所示:

  • SELLER_REV_SHARE – 一个正金额,这是卖家在与买家的协议中设置的价格。

  • SELLER_TAX_SHARE – 一个正金额,这是添加到 SELLER_REV_SHARE 中以涵盖卖家所欠税款的金额。

  • AWS_REV_SHARE – 一个负金额,这是列示费用。

  • AWS_TAX_SHARE— 正金额;这是除此之外还征 AWS 收的税款SELLER_REV_SHARE。此金额不影响卖家的余额。无需支付此金额,提供它是为了让卖家了解向买家开具发票并代表卖家汇款给主管部门的税款金额。

  • transaction_type_REFUND – 买家请求的退款金额。

  • transaction_type_CREDIT— 向买家 AWS 存入款项的金额。

  • BALANCE_ADJUSTMENT— 为解决发票问题 AWS 而进行的调整。

  • DISBURSEMENT – 如果 action 的值为 DISBURSED1 的值为 balance_impacting,则这是支付给卖家的金额。如果 action 的值为 INVOICED,则此记录将全部或部分否定 parent_billing_event_id 记录。在这种情况下,将显示相关支付 disbursement_billing_event_idbalance_impacting 的值为 0

  • DISBURSEMENT_FAILURE – 否定交易。

parent_billing_event_id

如果 broker_id 的值为 AWS_INCaction 的值为 DISBURSEDFORGIVENtransaction_type 的值为 DISBURSEMENT,则 parent_billing_event_id 表示发起此账单事件的原始 billing_event_id。如果 action 具有其他值,则此字段为空。

broker_id 的值为 AWS_EUROPE 时,parent_billing_event_id 表示在以下情况下启动此账单事件的原始 billing_event_id

  • action 的值为 FORGIVENINVOICED,且 transaction_type 的值为 AWS_REV_SHAREAWS_REV_SHARE_REFUNDSELLER_REV_SHARE_REFUND

  • action 的值为 DISBURSED,且 transaction_type 的值为 ANY(不包含 DISBURSEMENT_FAILURE)。

  • transaction_type 的值为 AWS_TAX_SHAREAWS_TAX_SHARE_REFUNDSELLER_TAX_SHARE SELLER_TAX_SHARE_REFUND

  • action 的值为 DISBURSED,且 transaction_type 的值为 DISBURSEMENT_FAILURE

broker_id 的值为 AWS_EUROPE,则 parent_billing_event_id 表示在以下情景中上一次成功的支付账单事件的原始 billing_event_id

  • action 的值为 DISBURSED,且 transaction_type 的值为 DISBURSEMENT_FAILURE

broker_id 的值为 AWS_EUROPE 时,对于所有剩余情景,此字段均为空。

disbursement_billing_event_id

action 的值为 DISBURSED 且以下参数之一为 True 时的相关支付:

  • transaction_type like ('SELLER%')

  • transaction_type like ('AWS%')

其他所有情景下,此值为 Null。

amount 账单事件金额。
currency ISO639 货币代码。
balance_impacting 在计算卖家付款时是否考虑该金额。值为 0 指示显示该金额以供参考,对余额没有影响。值为 1 指示在确定卖家付款时考虑该金额。
invoice_date 创建发票的日期。
payment_due_date

如果 action 的值为 INVOICED,则为发票的到期日期。

usage_period_start_date 记录中期间的开始日期。
usage_period_end_date 记录中期间的结束日期。
invoice_id

发 AWS 票编号。

billing_address_id 地址数据源中的付款人账单地址参考。

可用于连接 address_id 数据源的 Address 字段。

transaction_reference_id

允许您交叉引用以下报告中的数据的标识符:

bank_trace_id

对于支付交易(transaction_type = DISBURSEMENT 且操作为DISBURSED),是银行分配的追踪 ID。追踪 ID 可用于关联卖家银行提供的银行报告。

broker_id

为交易提供便利的商业实体的标识符。可能值如下所示:

  • AWS_INC

    — AWS, Inc.(总部设在美国)的标识符。

  • AWS_EUROPE

    — 亚马逊 Web Services EMEASARL(总部设在卢森堡)的标识符。

  • NULL

    – 前期没有明确 broker_id 的交易是由 AWS_INC 促成。

buyer_transaction_reference_id

一种标识符,它使用GROUP BY或中构造的窗口函数将账单馈送中的所有相关记录分组在一起SQL。这些相关记录可以包含买家发票、卖家发票和上市费的增值税 (VATs)。

征税方案

买家和卖家所在国家/地区和州/省实施的征税模式决定了税款的收取和汇款方式。以下是可能的方案:

  • 税款由收缴和汇出。 AWS在这些情况下,transaction_typeAWS_TAX_SHARE

  • 税款由卖家收取 AWS,支付给卖家,然后由卖家汇给税务机关。在这些情况下,transaction_typeSELLER_TAX_SHARE

  • 税款不是由收取的 AWS。卖家必须计算税款并将其汇款给税务机关。在这些情况下, AWS Marketplace 不进行税务计算或接收税务信息。卖家从收入份额中支付税款。

账单事件数据源示例

本部分显示开发票时和一个月之后的账单事件数据期间的示例。对于本部分中的所有表,请注意以下各项:

  • 在数据源中,billing_event_id 值为 40 个字符的字母数字字符串。为了便于阅读,它们在这里显示为两个字符的字符串。

  • 在数据源中,此信息以单个表格形式显示。为了便于阅读,数据显示在此处的多个表中,并且不显示所有列。

对于本部分中的示例,假定以下内容:

  • Arnav 是买家。

    • 他的账户 ID 是 737399998888

    • 他位于法国,需要遵守电商平台促进法的规定。有关更多信息,请参阅 Amazon Web Service 税务帮助

    • 他购买了 prod-o4grxfafcxxxx 并因他每月使用该产品而获得了 120.60 美元的发票。

    • 他在当月内支付了发票。

  • Jane 是制造商。

    • 她的账户 ID 是 111122223333

  • Paulo 是记录卖家。

    • 他的账户 ID 是 777788889999

    • 他住在堪萨斯州,这里不受电商平台促进法约束。

记录卖家的账单事件数据源

作为记录卖家,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

制造商的账单事件数据源

下表显示了在 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

示例查询

使用数据源中所述,您可以使用 Athena 对收集并作为数据源存储在托管的 Amazon 存储桶中的数据运行查询。本部分提供了您执行此操作可能采取的常见方法的一些示例。所有示例都假定使用单一币种。

示例 1:开具发票的金额,含税

要了解向买家开具发票的金额(含税),您可以运行查询,如以下示例所示。

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:代表卖家向买家开具发票的金额

要了解代表卖家向买家开具发票的金额,您可以运行查询,如以下示例所示。

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 可以代表卖家收取的金额

要了解 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:卖家可以收取的金额

要了解卖家可以收取的金额,您可以运行查询,如以下示例所示。此示例删除了房源费用和收取的 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:支付金额

要了解已支付的金额,您可以运行查询,如以下示例所示。

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

示例 6:待支付金额

要了解待支付的金额,您可以运行查询,如以下示例所示。此查询删除了已付款的金额。

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:一组发票的余额

要了解一组发票的总额,您可以运行查询,如以下示例所示。

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;