Skip to content

Commit b5d29fc

Browse files
add docs
1 parent f6ea8b0 commit b5d29fc

File tree

2 files changed

+87
-5
lines changed

2 files changed

+87
-5
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: 2
2+
3+
models:
4+
- name: stripe__line_item_enhanced
5+
description: Add description
6+
tests:
7+
- dbt_utils.unique_combination_of_columns:
8+
combination_of_columns:
9+
- header_id
10+
- line_item_id
11+
columns:
12+
- name: header_id
13+
description: Id of corresponding invoice.
14+
- name: line_item_id
15+
description: Invoice line item id.
16+
- name: line_item_index
17+
description: Unique index of each line item id for each invoice.
18+
- name: record_type
19+
description: header or line_item
20+
- name: created_at
21+
description: When the invoice was created
22+
- name: header_status
23+
description: Status of the invoice.
24+
- name: billing_type
25+
description: Type of invoice line item.
26+
- name: currency
27+
description: Currency used in the invoice.
28+
- name: product_id
29+
description: Product ID
30+
- name: product_name
31+
description: Product name
32+
- name: product_type
33+
description: Product type
34+
- name: transaction_type
35+
description: Balance transaction type
36+
- name: quantity
37+
description: The number of units of this line item.
38+
- name: unit_amount
39+
description: Amount per unit.
40+
- name: discount_amount
41+
description: The discount amount associated with this invoice.
42+
- name: tax_amount
43+
description: The tax amount associated with this invoice.
44+
- name: total_amount
45+
description: Invoice total
46+
- name: payment_id
47+
description: Payment intent ID
48+
- name: payment_method
49+
description: Payment method type
50+
- name: payment_method_id
51+
description: Payment method ID
52+
- name: payment_at
53+
description: Charge created date
54+
- name: fee_amount
55+
description: Balance transaction fee
56+
- name: refund_amount
57+
description: Refund amount associated with this invoice.
58+
- name: subscription_id
59+
description: Subscription associated with this invoice.
60+
- name: subscription_period_started_at
61+
description: Subscription's current period start
62+
- name: subscription_period_ended_at
63+
description: Subscription's current period end
64+
- name: subscription_status
65+
description: Subscription status
66+
- name: customer_id
67+
description: Customer associated with this invoice.
68+
- name: customer_level
69+
description: Whether 'account' or 'customer'. For Stripe, the level is 'customer'.
70+
- name: customer_name
71+
description: Customer name
72+
- name: customer_company
73+
description: Associated account's company if applicable.
74+
- name: customer_email
75+
description: Customer email
76+
- name: customer_city
77+
description: Customer city
78+
- name: customer_country
79+
description: Customer country

models/common_data_models/stripe__line_item_enhanced.sql

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ with invoice_line_item as (
6060

6161
), discount as (
6262

63-
select *
63+
select
64+
invoice_id,
65+
sum(amount) as total_discount_amount
6466
from {{ var('discount') }}
67+
group by 1
6568

6669
), refund as (
6770

@@ -89,12 +92,12 @@ with invoice_line_item as (
8992
cast(product.type as {{ dbt.type_string() }}) as product_type,
9093
cast(invoice_line_item.quantity as {{ dbt.type_numeric() }}) as quantity,
9194
cast((invoice_line_item.amount/invoice_line_item.quantity) as {{ dbt.type_numeric() }}) as unit_amount,
92-
cast(discount.amount as {{ dbt.type_numeric() }}) as discount_amount,
95+
cast(discount.total_discount_amount as {{ dbt.type_numeric() }}) as discount_amount,
9396
cast(invoice.tax as {{ dbt.type_numeric() }}) as tax_amount,
9497
cast(invoice.total as {{ dbt.type_numeric() }}) as total_amount,
9598
cast(payment_intent.payment_intent_id as {{ dbt.type_string() }}) as payment_id,
9699
cast(payment_method.payment_method_id as {{ dbt.type_string() }}) as payment_method_id,
97-
cast(payment_method.type as {{ dbt.type_string() }}) as payment_method_name,
100+
cast(payment_method.type as {{ dbt.type_string() }}) as payment_method,
98101
cast(charge.created_at as {{ dbt.type_timestamp() }}) as payment_at,
99102
cast(balance_transaction.fee as {{ dbt.type_numeric() }}) as fee_amount,
100103
cast(refund.amount as {{ dbt.type_numeric() }}) as refund_amount,
@@ -192,7 +195,7 @@ with invoice_line_item as (
192195
total_amount,
193196
payment_id,
194197
payment_method_id,
195-
payment_method_name,
198+
payment_method,
196199
payment_at,
197200
cast(null as {{ dbt.type_numeric() }}) as fee_amount,
198201
cast(null as {{ dbt.type_numeric() }}) as refund_amount,
@@ -232,7 +235,7 @@ with invoice_line_item as (
232235
cast(null as {{ dbt.type_float() }}) as total_amount,
233236
payment_id,
234237
payment_method_id,
235-
payment_method_name,
238+
payment_method,
236239
payment_at,
237240
fee_amount,
238241
refund_amount,

0 commit comments

Comments
 (0)