Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-reneeli committed Jun 14, 2024
1 parent f6ea8b0 commit b5d29fc
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 5 deletions.
79 changes: 79 additions & 0 deletions models/common_data_models/stripe__common_data_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2

models:
- name: stripe__line_item_enhanced
description: Add description
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- header_id
- line_item_id
columns:
- name: header_id
description: Id of corresponding invoice.
- name: line_item_id
description: Invoice line item id.
- name: line_item_index
description: Unique index of each line item id for each invoice.
- name: record_type
description: header or line_item
- name: created_at
description: When the invoice was created
- name: header_status
description: Status of the invoice.
- name: billing_type
description: Type of invoice line item.
- name: currency
description: Currency used in the invoice.
- name: product_id
description: Product ID
- name: product_name
description: Product name
- name: product_type
description: Product type
- name: transaction_type
description: Balance transaction type
- name: quantity
description: The number of units of this line item.
- name: unit_amount
description: Amount per unit.
- name: discount_amount
description: The discount amount associated with this invoice.
- name: tax_amount
description: The tax amount associated with this invoice.
- name: total_amount
description: Invoice total
- name: payment_id
description: Payment intent ID
- name: payment_method
description: Payment method type
- name: payment_method_id
description: Payment method ID
- name: payment_at
description: Charge created date
- name: fee_amount
description: Balance transaction fee
- name: refund_amount
description: Refund amount associated with this invoice.
- name: subscription_id
description: Subscription associated with this invoice.
- name: subscription_period_started_at
description: Subscription's current period start
- name: subscription_period_ended_at
description: Subscription's current period end
- name: subscription_status
description: Subscription status
- name: customer_id
description: Customer associated with this invoice.
- name: customer_level
description: Whether 'account' or 'customer'. For Stripe, the level is 'customer'.
- name: customer_name
description: Customer name
- name: customer_company
description: Associated account's company if applicable.
- name: customer_email
description: Customer email
- name: customer_city
description: Customer city
- name: customer_country
description: Customer country
13 changes: 8 additions & 5 deletions models/common_data_models/stripe__line_item_enhanced.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ with invoice_line_item as (

), discount as (

select *
select
invoice_id,
sum(amount) as total_discount_amount
from {{ var('discount') }}
group by 1

), refund as (

Expand Down Expand Up @@ -89,12 +92,12 @@ with invoice_line_item as (
cast(product.type as {{ dbt.type_string() }}) as product_type,
cast(invoice_line_item.quantity as {{ dbt.type_numeric() }}) as quantity,
cast((invoice_line_item.amount/invoice_line_item.quantity) as {{ dbt.type_numeric() }}) as unit_amount,
cast(discount.amount as {{ dbt.type_numeric() }}) as discount_amount,
cast(discount.total_discount_amount as {{ dbt.type_numeric() }}) as discount_amount,
cast(invoice.tax as {{ dbt.type_numeric() }}) as tax_amount,
cast(invoice.total as {{ dbt.type_numeric() }}) as total_amount,
cast(payment_intent.payment_intent_id as {{ dbt.type_string() }}) as payment_id,
cast(payment_method.payment_method_id as {{ dbt.type_string() }}) as payment_method_id,
cast(payment_method.type as {{ dbt.type_string() }}) as payment_method_name,
cast(payment_method.type as {{ dbt.type_string() }}) as payment_method,
cast(charge.created_at as {{ dbt.type_timestamp() }}) as payment_at,
cast(balance_transaction.fee as {{ dbt.type_numeric() }}) as fee_amount,
cast(refund.amount as {{ dbt.type_numeric() }}) as refund_amount,
Expand Down Expand Up @@ -192,7 +195,7 @@ with invoice_line_item as (
total_amount,
payment_id,
payment_method_id,
payment_method_name,
payment_method,
payment_at,
cast(null as {{ dbt.type_numeric() }}) as fee_amount,
cast(null as {{ dbt.type_numeric() }}) as refund_amount,
Expand Down Expand Up @@ -232,7 +235,7 @@ with invoice_line_item as (
cast(null as {{ dbt.type_float() }}) as total_amount,
payment_id,
payment_method_id,
payment_method_name,
payment_method,
payment_at,
fee_amount,
refund_amount,
Expand Down

0 comments on commit b5d29fc

Please sign in to comment.