Skip to content

Commit

Permalink
Merge pull request #51 from fivetran/MagicBot/dbt-utils-cross-db-migr…
Browse files Browse the repository at this point in the history
…ation

Updates for dbt-utils to dbt-core cross-db macro migration
  • Loading branch information
fivetran-sheringuyen authored Dec 19, 2022
2 parents 7770cfc + e2c0bec commit 7b930ae
Show file tree
Hide file tree
Showing 34 changed files with 127 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install libsasl2-dev

Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# dbt_quickbooks v0.6.0

## 🚨 Breaking Changes 🚨:
[PR #51](https://github.com/fivetran/dbt_quickbooks/pull/51) includes the following breaking changes:
- Dispatch update for dbt-utils to dbt-core cross-db macros migration. Specifically `{{ dbt_utils.<macro> }}` have been updated to `{{ dbt.<macro> }}` for the below macros:
- `any_value`
- `bool_or`
- `cast_bool_to_text`
- `concat`
- `date_trunc`
- `dateadd`
- `datediff`
- `escape_single_quotes`
- `except`
- `hash`
- `intersect`
- `last_day`
- `length`
- `listagg`
- `position`
- `replace`
- `right`
- `safe_cast`
- `split_part`
- `string_literal`
- `type_bigint`
- `type_float`
- `type_int`
- `type_numeric`
- `type_string`
- `type_timestamp`
- `array_append`
- `array_concat`
- `array_construct`
- For `current_timestamp` and `current_timestamp_in_utc` macros, the dispatch AND the macro names have been updated to the below, respectively:
- `dbt.current_timestamp_backcompat`
- `dbt.current_timestamp_in_utc_backcompat`
- Dependencies on `fivetran/fivetran_utils` have been upgraded, previously `[">=0.3.0", "<0.4.0"]` now `[">=0.4.0", "<0.5.0"]`.

# dbt_quickbooks_source v0.5.4
## Features
- Addition of the `credit_card_payment_txn` (enabled/disabled using the `using_credit_card_payment_txn` variable) source as well as the accompanying staging and intermediate models. This source includes all credit card payment transactions and will be used in downstream General Ledger generation to ensure accurate reporting of all transaction types. ([#61](https://github.com/fivetran/dbt_quickbooks/pull/61))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Include in your `packages.yml`
```yaml
packages:
- package: fivetran/quickbooks
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]
```
## Configuration
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2
name: 'quickbooks'

version: '0.5.4'
version: '0.6.0'
require-dbt-version: [">=1.0.0", "<2.0.0"]

models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# HEY! This file is used in the dbt package integrations tests with CircleCI.
# HEY! This file is used in the dbt package integrations tests with Buildkite.
# You should __NEVER__ check credentials into version control. Thanks for reading :)

config:
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'quickbooks_integration_tests'

version: '0.5.4'
version: '0.6.0'

profile: 'integration_tests'
config-version: 2
Expand Down Expand Up @@ -32,6 +32,7 @@ vars:
bundle: "{{ ref('bundle_data') }}"
credit_memo: "{{ ref('credit_memo_data') }}"
credit_memo_line: "{{ ref('credit_memo_line_data') }}"
credit_card_payment_txn: "{{ ref('credit_card_payment_txn_data') }}"
customer: "{{ ref('customer_data') }}"
department: "{{ ref('department_data') }}"
deposit_line: "{{ ref('deposit_line_data') }}"
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dbt-snowflake>=1.0.0,<1.3.0
dbt-bigquery>=1.0.0,<1.3.0
dbt-redshift>=1.0.0,<1.3.0
dbt-postgres>=1.0.0,<1.3.0
dbt-spark>=1.0.0,<1.3.0
dbt-spark[PyHive]>=1.0.0,<1.3.0
dbt-databricks>=1.0.0,<1.3.0
dbt-snowflake>=1.3.0,<2.0.0
dbt-bigquery>=1.3.0,<2.0.0
dbt-redshift>=1.3.0,<2.0.0
dbt-postgres>=1.3.0,<2.0.0
dbt-spark>=1.3.0,<2.0.0
dbt-spark[PyHive]>=1.3.0,<2.0.0
dbt-databricks>=1.3.0,<2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final as (
transaction_id,
index,
transaction_date,
cast(null as {{ dbt_utils.type_string() }}) as customer_id,
cast(null as {{ dbt.type_string() }}) as customer_id,
vendor_id,
amount,
payment_account_id as account_id,
Expand All @@ -64,7 +64,7 @@ final as (
transaction_id,
index,
transaction_date,
cast(null as {{ dbt_utils.type_string() }}) as customer_id,
cast(null as {{ dbt.type_string() }}) as customer_id,
vendor_id,
amount,
account_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ credit_card_payment_prep as (
credit_card_payments.amount,
credit_card_payments.bank_account_id,
credit_card_payments.credit_card_account_id,
cast(null as {{ dbt_utils.type_string() }}) as customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id
cast(null as {{ dbt.type_string() }}) as customer_id,
cast(null as {{ dbt.type_string() }}) as vendor_id
from credit_card_payments
),

Expand All @@ -32,7 +32,7 @@ final as (
customer_id,
vendor_id,
amount,
bank_account_id as account_id,
cast(bank_account_id as {{ dbt.type_string() }}) as account_id,
'credit' as transaction_type,
'credit card payment' as transaction_source
from credit_card_payment_prep
Expand All @@ -46,7 +46,7 @@ final as (
customer_id,
vendor_id,
amount,
credit_card_account_id as account_id,
cast(credit_card_account_id as {{ dbt.type_string() }}) as account_id,
'debit' as transaction_type,
'credit card payment' as transaction_source
from credit_card_payment_prep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount * -1 as amount,
account_id,
'credit' as transaction_type,
Expand All @@ -74,7 +74,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount * -1 as amount,
df_accounts.account_id,
'debit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
deposit_to_acct_id as account_id,
'debit' as transaction_type,
Expand All @@ -69,7 +69,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
deposit_from_acct_id as account_id,
'credit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
account_id,
'credit' as transaction_type,
Expand All @@ -138,7 +138,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
ar_accounts.account_id,
'debit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
deposit_to_account_id as account_id,
'debit' as transaction_type,
Expand All @@ -62,7 +62,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
coalesce(receivable_account_id, ar_accounts.account_id) as account_id,
'credit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
credit_to_account_id as account_id,
'credit' as transaction_type,
Expand All @@ -65,7 +65,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
debit_account_id as account_id,
'debit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
debit_to_account_id as account_id,
'debit' as transaction_type,
Expand All @@ -65,7 +65,7 @@ final as (
index,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
credit_to_account_id as account_id,
'credit' as transaction_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ final as (
transaction_id,
index,
transaction_date,
cast(null as {{ dbt_utils.type_string() }}) as customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as customer_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
credit_to_account_id as account_id,
'credit' as transaction_type,
Expand All @@ -40,8 +40,8 @@ final as (
transaction_id,
index,
transaction_date,
cast(null as {{ dbt_utils.type_string() }}) as customer_id,
cast(null as {{ dbt_utils.type_string() }}) as vendor_id,
cast(null as {{ dbt.type_string() }}) as customer_id,
cast(null as {{ dbt.type_string() }}) as vendor_id,
amount,
debit_to_account_id as account_id,
'debit' as transaction_type,
Expand Down
2 changes: 1 addition & 1 deletion models/intermediate/int_quickbooks__bill_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bill_link as (

final as (
select
cast('bill' as {{ dbt_utils.type_string() }}) as transaction_type,
cast('bill' as {{ dbt.type_string() }}) as transaction_type,
bill_link.bill_id as transaction_id,
bill_link.doc_number,
bill_link.department_id,
Expand Down
6 changes: 3 additions & 3 deletions models/intermediate/int_quickbooks__expenses_union.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ final as (
expense_union.doc_number,
expense_union.transaction_type,
expense_union.transaction_date,
cast(null as {{ dbt_utils.type_string() }}) as item_id,
cast(null as {{ dbt_utils.type_numeric() }}) as item_quantity,
cast(null as {{ dbt_utils.type_numeric() }}) as item_unit_price,
cast(null as {{ dbt.type_string() }}) as item_id,
cast(null as {{ dbt.type_numeric() }}) as item_quantity,
cast(null as {{ dbt.type_numeric() }}) as item_unit_price,
expense_union.account_id,
expense_accounts.name as account_name,
expense_accounts.account_sub_type as account_sub_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ gl_period_balance as (
account_sub_type,
financial_statement_helper,
account_class,
cast({{ dbt_utils.date_trunc("year", "transaction_date") }} as date) as date_year,
cast({{ dbt_utils.date_trunc("month", "transaction_date") }} as date) as date_month,
cast({{ dbt.date_trunc("year", "transaction_date") }} as date) as date_year,
cast({{ dbt.date_trunc("month", "transaction_date") }} as date) as date_month,
sum(adjusted_amount) as period_balance
from general_ledger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ with spine as (
{{ dbt_utils.date_spine(
datepart="month",
start_date=first_date_adjust,
end_date=dbt_utils.dateadd("month", 1, last_date_adjust)
end_date=dbt.dateadd("month", 1, last_date_adjust)
)
}}
),
Expand All @@ -59,10 +59,10 @@ general_ledger as (

date_spine as (
select
cast({{ dbt_utils.date_trunc("year", "date_month") }} as date) as date_year,
cast({{ dbt_utils.date_trunc("month", "date_month") }} as date) as period_first_day,
{{ dbt_utils.last_day("date_month", "month") }} as period_last_day,
row_number() over (order by cast({{ dbt_utils.date_trunc("month", "date_month") }} as date)) as period_index
cast({{ dbt.date_trunc("year", "date_month") }} as date) as date_year,
cast({{ dbt.date_trunc("month", "date_month") }} as date) as period_first_day,
{{ dbt.last_day("date_month", "month") }} as period_last_day,
row_number() over (order by cast({{ dbt.date_trunc("month", "date_month") }} as date)) as period_index
from spine
),

Expand Down
6 changes: 3 additions & 3 deletions models/intermediate/int_quickbooks__invoice_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ invoice_link as (

final as (
select
cast('invoice' as {{ dbt_utils.type_string() }}) as transaction_type,
cast('invoice' as {{ dbt.type_string() }}) as transaction_type,
invoice_link.invoice_id as transaction_id,
invoice_link.doc_number,
invoice_link.estimate_id,
Expand All @@ -87,8 +87,8 @@ final as (
estimates.transaction_status as estimate_status,

{% else %}
cast(null as {{ dbt_utils.type_numeric() }}) as estimate_total_amount,
cast(null as {{ dbt_utils.type_string() }}) as estimate_status,
cast(null as {{ dbt.type_numeric() }}) as estimate_total_amount,
cast(null as {{ dbt.type_string() }}) as estimate_status,

{% endif %}

Expand Down
22 changes: 11 additions & 11 deletions models/intermediate/int_quickbooks__retained_earnings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ net_income_loss as (

retained_earnings_starter as (
select
cast('9999' as {{ dbt_utils.type_string() }}) as account_id,
cast('9999-00' as {{ dbt_utils.type_string() }}) as account_number,
cast('Net Income / Retained Earnings Adjustment' as {{ dbt_utils.type_string() }}) as account_name,
cast('9999' as {{ dbt.type_string() }}) as account_id,
cast('9999-00' as {{ dbt.type_string() }}) as account_number,
cast('Net Income / Retained Earnings Adjustment' as {{ dbt.type_string() }}) as account_name,
false as is_sub_account,
cast(null as {{ dbt_utils.type_string() }}) as parent_account_number,
cast(null as {{ dbt_utils.type_string() }}) as parent_account_name,
cast('Equity' as {{ dbt_utils.type_string() }}) as account_type,
cast('RetainedEarnings' as {{ dbt_utils.type_string() }})as account_sub_type,
cast('Equity' as {{ dbt_utils.type_string() }}) as account_class,
cast('balance_sheet' as {{ dbt_utils.type_string() }}) as financial_statement_helper,
cast({{ dbt_utils.date_trunc("year", "period_first_day") }} as date) as date_year,
cast(null as {{ dbt.type_string() }}) as parent_account_number,
cast(null as {{ dbt.type_string() }}) as parent_account_name,
cast('Equity' as {{ dbt.type_string() }}) as account_type,
cast('RetainedEarnings' as {{ dbt.type_string() }})as account_sub_type,
cast('Equity' as {{ dbt.type_string() }}) as account_class,
cast('balance_sheet' as {{ dbt.type_string() }}) as financial_statement_helper,
cast({{ dbt.date_trunc("year", "period_first_day") }} as date) as date_year,
cast(period_first_day as date) as period_first_day,
{{ dbt_utils.last_day("period_first_day", "month") }} as period_last_day,
{{ dbt.last_day("period_first_day", "month") }} as period_last_day,
(revenue_net_change - expense_net_change) as period_net_change
from net_income_loss
),
Expand Down
Loading

0 comments on commit 7b930ae

Please sign in to comment.