构建条带西格玛查询以在订阅上获得收入确认

时间:2017-11-05 21:40:48

标签: stripe-payments accounting

Stripe有许多单独的服务和插件,可以计算> 1个月订阅(例如年度计划)的月收入识别数字。

然而,随着Stripe Sigma的到来,任何人都可以帮助识别所有客户,他们的订阅期和收费金额的SQL查询

我正在寻找这些领域,至少:

  • 客户ID
  • 订阅ID
  • 订阅开始日期
  • 订阅结束日期
  • 货币
  • 已付费/付款金额(预付款)

谢谢!

1 个答案:

答案 0 :(得分:0)

分享我对此的第一次尝试

select distinct
    invoices.customer_id as customer,
    invoices.id as stripe_invoice,
    invoice_line_items.period_start as subscription_start,
    invoice_line_items.period_end as subscription_end,
    date_trunc('month', invoice_line_items.period_start) as recognition_start,
    date_add('month', -1, invoice_line_items.period_end) as recognition_end,
    invoices.currency as currency,
    (invoices.amount_due - coalesce(invoices.tax, 0)) / 100.0 as collected_amount_excl_tax

from invoices
left join invoice_line_items
    on invoices.id = invoice_line_items.invoice_id

where invoices.amount_due > 0
and paid
and date_diff('day', invoice_line_items.period_start, invoice_line_items.period_end) > 31
order by invoices.customer_id, invoices.id

然后使用电子表格计算延期并每月确认。

会喜欢一些关于我遗失/遗忘的反馈