Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source relation fix #123

Merged
merged 12 commits into from
Apr 30, 2024
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# dbt_quickbooks v0.12.3
# dbt_quickbooks v0.12.4
[PR #123](https://github.com/fivetran/dbt_quickbooks/pull/123) includes the following updates:

## Bug Fixes
- Added `source_relation` to joins within the following models as it was perviously missed:
- `int_quickbooks__invoice_join`
- `int_quickbooks__bill_join`
- `int_quickbooks__refund_receipt_double_entry`
- `int_quickbooks__sales_receipt_double_entry`
- `quickbooks__balance_sheet` analysis model.

## Contributors
- [@MatteyRitch](https://github.com/MatteyRitch) ([PR #120](https://github.com/fivetran/dbt_quickbooks/pull/120))

# dbt_quickbooks v0.12.3
[PR #119](https://github.com/fivetran/dbt_quickbooks/pull/119) includes the following updates:

## Bug Fixes
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ vars:
```

## (Optional) Step 5: Additional Configurations
<details><summary>Expand for configurations</summary>

### Unioning Multiple Quickbooks Connectors
If you have multiple Quickbooks connectors in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. The package will union all of the data together and pass the unioned table into the transformations. You will be able to see which source it came from in the `source_relation` column of each model. To use this functionality, you will need to set either the `quickbooks_union_schemas` or `quickbooks_union_databases` variables:
Expand Down Expand Up @@ -213,14 +212,11 @@ If an individual source table has a different name than the package expects, add
vars:
quickbooks_<default_source_table_name>_identifier: your_table_name
```
</details>

## (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
<details><summary>Expand for details</summary>
<br>

Fivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).
</details>


## (Optional) Step 7: Validate your data
After running the models within this package, you may want to compare the baseline financial statement totals from the data provided against what you expect. You can make use of the [analysis functionality of dbt](https://docs.getdbt.com/docs/building-a-dbt-project/analyses/) and run pre-written SQL to test these values. The SQL files within the [analysis](https://github.com/fivetran/dbt_quickbooks/blob/master/analysis) folder contain SQL queries you may compile to generate balance sheet and income statement values. You can then tie these generated values to your expected ones and confirm the values provided in this package are accurate.
Expand Down
18 changes: 12 additions & 6 deletions analysis/quickbooks__balance_sheet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,37 @@ with general_ledger_by_period as (
liability_date as (
select
account_id,
source_relation,
max(period_first_day) as period_first_day
from general_ledger_by_period

where account_class = 'Liability'

group by 1
group by 1,2
),

asset_date as (
select
account_id,
source_relation,
max(period_first_day) as period_first_day
from general_ledger_by_period

where account_class = 'Asset'

group by 1
group by 1,2
),

equity_date as (
select
account_id,
source_relation,
max(period_first_day) as period_first_day
from general_ledger_by_period

where account_class = 'Equity'

group by 1
group by 1,2
),

liability as (
Expand Down Expand Up @@ -68,20 +71,23 @@ equity as (
)

select
"liability" as balance_sheet_type,
'liability' as balance_sheet_type,
sum(period_ending_balance) as balance
from liability
group by 1

union all

select
"asset" as balance_sheet_type,
'asset' as balance_sheet_type,
sum(period_ending_balance) as balance
from asset
group by 1

union all

select
'equity' as balance_sheet_type,
sum(period_ending_balance) as balance
from equity
from equity
group by 1
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.12.3'
version: '0.12.4'

require-dbt-version: [">=1.3.0", "<2.0.0"]

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/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'quickbooks_integration_tests'

version: '0.12.3'
version: '0.12.4'

profile: 'integration_tests'
config-version: 2
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ 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
dbt-databricks>=1.3.0,<1.7.13
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ refund_receipt_join as (

left join items
on refund_receipt_lines.sales_item_item_id = items.item_id
and refund_receipt_lines.source_relation = items.source_relation

where coalesce(refund_receipt_lines.discount_account_id, refund_receipt_lines.sales_item_account_id, refund_receipt_lines.sales_item_item_id) is not null
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ items as (

left join {{ ref('stg_quickbooks__item') }} parent
on item.parent_item_id = parent.item_id
and item.source_relation = parent.source_relation
),

sales_receipt_join as (
Expand Down
1 change: 1 addition & 0 deletions models/intermediate/int_quickbooks__bill_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ final as (
on bill_payments.bill_payment_id = bill_payment_lines.bill_payment_id
and bill_payments.source_relation = bill_payment_lines.source_relation
and bill_link.bill_id = bill_payment_lines.bill_id
and bill_link.source_relation = bill_payment_lines.source_relation

{{ dbt_utils.group_by(10) }}
)
Expand Down
11 changes: 9 additions & 2 deletions models/intermediate/int_quickbooks__invoice_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ invoice_est as (

select
invoices.invoice_id,
invoice_linked.estimate_id
invoice_linked.estimate_id,
invoices.source_relation
from invoices

left join invoice_linked
on invoices.invoice_id = invoice_linked.invoice_id
and invoices.source_relation = invoice_linked.source_relation

where invoice_linked.estimate_id is not null
),
Expand All @@ -52,11 +54,13 @@ invoice_pay as (

select
invoices.invoice_id,
invoice_linked.payment_id
invoice_linked.payment_id,
invoices.source_relation
from invoices

left join invoice_linked
on invoices.invoice_id = invoice_linked.invoice_id
and invoices.source_relation = invoice_linked.source_relation

where invoice_linked.payment_id is not null
),
Expand All @@ -71,9 +75,11 @@ invoice_link as (

left join invoice_est
on invoices.invoice_id = invoice_est.invoice_id
and invoices.source_relation = invoice_est.source_relation

left join invoice_pay
on invoices.invoice_id = invoice_pay.invoice_id
and invoices.source_relation = invoice_pay.source_relation
),

final as (
Expand Down Expand Up @@ -121,6 +127,7 @@ final as (

left join payment_lines_payment
on payments.payment_id = payment_lines_payment.payment_id
and payments.source_relation = payment_lines_payment.source_relation
and invoice_link.invoice_id = payment_lines_payment.invoice_id
and invoice_link.source_relation = payment_lines_payment.source_relation

Expand Down