Stripe Sigma参与其中,我花了很多时间将查询基本返回:
基本上希望运行查询,这将有助于我们在Quickbooks API中合并存款。基本上将所有发票与我们的帐户中的付款相关联。这将极大地帮助我们缩短平台的会计周期。
我尝试采用“付款对帐”模板并对其进行处理,但是我似乎无法将相关发票与费用相关联,也很难确定已收取的Stripe费用。
以下是我考虑过的解决方案,也许可以证实这种正确的做法会有所帮助?
select
date(transfers.date) as payout_date,
transfers.id as payout_id,
transfers.amount/100.0 as payout_amount,
transfers.status as payout_status,
balance_transactions.id as balance_transaction_id,
balance_transactions.source_id as balance_transaction_source_id,
balance_transactions.type as balance_transaction_type,
balance_transactions.currency,
balance_transactions.fee/100.0,
balance_transactions.amount/100.0 as balance_transaction_amount,
invoices.id
from transfers
join balance_transactions
on balance_transactions.automatic_transfer_id = transfers.id
left join charges
on charges.id = balance_transactions.source_id -- balance_transactions.source_id can be used to join on charges, disputes, and refunds table.
left join disputes
on disputes.id = balance_transactions.source_id
left join refunds
on refunds.id = balance_transactions.source_id
left join invoices
on invoices.charge_id = balance_transactions.source_id
where transfers.type = 'bank_account'
and transfers.date >= date_add('day', -30, date(data_load_time))
order by transfers.date desc, transfers.id, balance_transactions.created desc
limit 1000