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

Bugfix/v0.12.5 #124

Merged
merged 20 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# dbt_quickbooks v0.13.0
[PR #124](https://github.com/fivetran/dbt_quickbooks/pull/124) includes the following updates:

## 🚨 Breaking Changes 🚨:
- Updates the [int_quickbooks__invoice_join](https://github.com/fivetran/dbt_quickbooks/blob/main/models/intermediate/int_quickbooks__invoice_join.sql) and downstream [quickbooks__ap_ar_enhanced](https://github.com/fivetran/dbt_quickbooks/blob/main/models/quickbooks__ap_ar_enhanced.sql) models to include and require the `using_payments` config. Previously, these models would fail if the `payment` or the `payment_line` source tables did not exist.
- Corrects the misspelled `customer_vendor_webiste` field to `customer_vendor_website` in `quickbooks__ap_ar_enhanced`.

## Bug Fixes
- Updates the logic for the `amount` field in [int_quickbooks__invoice_double_entry](https://github.com/fivetran/dbt_quickbooks/blob/main/models/double_entry_transactions/int_quickbooks__invoice_double_entry.sql) to use `invoice.total_amount` only on the condition when a bundle is associated with the invoice and `invoice.total_amount` is 0, otherwise `invoice_lines.amount` is used.
- This avoids double counting when aggregating invoice_line items and accounts for the edge cases where a bundle_id is involved.

## Feature Updates
- Updates the [quickbooks__profit_and_loss](https://github.com/fivetran/dbt_quickbooks/blob/main/models/quickbooks__profit_and_loss.sql) and [quickbooks__balance_sheet](https://github.com/fivetran/dbt_quickbooks/blob/main/models/quickbooks__balance_sheet.sql) models to include both `period_first_day` and `period_last_day` in addition to `calendar_date`. This allows users to have greater flexibility in choosing which date to aggregate records upon.
- Please note `calendar_date` is slotted to be deprecated, and the fields `period_first_day` and `period_last_day` are both offered as replacements, depending on how your company performs their financial reporting.

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

Expand Down
2 changes: 1 addition & 1 deletion DECISIONLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The corresponding entry that would result from the `int_quickbooks__invoice_doub

## Accrual Basis Accounting Models
- There are two types of accounting methods
- Accrual, which records reevenue and expenses when transactions occur, but before money is received or dispensed.
- Accrual, which records revenue and expenses when transactions occur, but before money is received or dispensed.
- Cash basis, which records revenue and expenses when cash related to transactions actually is received or dispensed.
- For our initial build of `quickbooks__profit_and_loss`, `quickbooks__general_ledger_by_period`, and `quickbooks__balance_sheet`, we used the accrual accounting method rather than cash, as it is approved by GAAP (generally accepted accounting principles). Accrual accounting requires companies match revenues with expenses incurred to generate them.
- If you'd like models that rely on the cash basis accounting, [please comment on this feature and we can prioritize it for future development](https://github.com/fivetran/dbt_quickbooks/issues/111).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Include the following QuickBooks package version in your `packages.yml` file.
```yaml
packages:
- package: fivetran/quickbooks
version: [">=0.12.0", "<0.13.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.13.0", "<0.14.0"] # we recommend using ranges to capture non-breaking changes automatically
```

Do NOT include the `quickbooks_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
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.12.4'
version: '0.13.0'
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

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.4'
version: '0.13.0'

profile: 'integration_tests'
config-version: 2
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.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,<1.7.13
dbt-snowflake>=1.3.0,<1.8.0
dbt-bigquery>=1.3.0,<1.8.0
dbt-redshift>=1.3.0,<1.8.0
dbt-postgres>=1.3.0,<1.8.0
dbt-spark>=1.3.0,<1.8.0
dbt-spark[PyHive]>=1.3.0,<1.8.0
dbt-databricks>=1.3.0,<1.8.0
2 changes: 1 addition & 1 deletion models/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The type of account associated
{% enddocs %}

{% docs calendar_date %}
Timestamp of the first calendar date of the month.
Timestamp of the first calendar date of the month. This is slated to be deprecated, and the fields `period_first_day` and `period_last_day` are both offered as replacements, depending on how your company performs their financial reporting.
{% enddocs calendar_date %}

{% docs is_sub_account %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,20 @@ invoice_join as (
invoices.source_relation,
invoice_lines.index,
invoices.transaction_date as transaction_date,
case when invoices.total_amount != 0
then invoice_lines.amount
else invoices.total_amount
end as amount,

{% if var('using_invoice_bundle', True) %}
case when invoice_lines.bundle_id is not null and invoices.total_amount = 0 then invoices.total_amount
else invoice_lines.amount
end as amount,
case when invoice_lines.detail_type is not null then invoice_lines.detail_type
when coalesce(invoice_lines.account_id, items.parent_income_account_id, items.income_account_id, bundle_income_accounts.account_id, invoice_lines.sales_item_account_id) is not null then 'SalesItemLineDetail'
when invoice_lines.discount_account_id is not null then 'DiscountLineDetail'
when coalesce(invoice_lines.account_id, items.parent_income_account_id, items.income_account_id, bundle_income_accounts.account_id, invoice_lines.discount_account_id, invoice_lines.sales_item_account_id) is null then 'NoAccountMapping'
end as invoice_line_transaction_type,
coalesce(invoice_lines.account_id, items.parent_income_account_id, items.income_account_id, bundle_income_accounts.account_id, invoice_lines.discount_account_id, invoice_lines.sales_item_account_id) as account_id,

{% else %}
invoice_lines.amount as amount,
case when invoice_lines.detail_type is not null then invoice_lines.detail_type
when coalesce(invoice_lines.account_id, items.parent_income_account_id, items.income_account_id, invoice_lines.sales_item_account_id) is not null then 'SalesItemLineDetail'
when invoice_lines.discount_account_id is not null then 'DiscountLineDetail'
Expand Down Expand Up @@ -140,6 +141,7 @@ invoice_join as (
left join bundle_income_accounts
on bundle_income_accounts.bundle_id = invoice_lines.bundle_id
and bundle_income_accounts.source_relation = invoice_lines.source_relation

{% endif %}
),

Expand Down
4 changes: 2 additions & 2 deletions models/intermediate/int_quickbooks__invoice_join.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--To disable this model, set the using_invoice variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_invoice')) }}
{{ config(enabled=var('using_invoice') and var('using_payment', True)) }}

with invoices as (

Expand Down Expand Up @@ -120,7 +120,6 @@ final as (
on invoice_link.estimate_id = estimates.estimate_id
and invoice_link.source_relation = estimates.source_relation
{% endif %}

left join payments
on invoice_link.payment_id = payments.payment_id
and invoice_link.source_relation = payments.source_relation
Expand All @@ -131,6 +130,7 @@ final as (
and invoice_link.invoice_id = payment_lines_payment.invoice_id
and invoice_link.source_relation = payment_lines_payment.source_relation


{{ dbt_utils.group_by(15) }}
)

Expand Down
8 changes: 8 additions & 0 deletions models/quickbooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ models:
description: "{{ doc('source_relation') }}"
- name: calendar_date
description: "{{ doc('calendar_date') }}"
- name: period_first_day
description: Timestamp of the first date of the month.
- name: period_last_day
description: Timestamp of the last date of the month.
- name: account_class
description: "{{ doc('account_class') }} with the profit and loss line."
- name: is_sub_account
Expand Down Expand Up @@ -449,6 +453,10 @@ models:
columns:
- name: calendar_date
description: "{{ doc('calendar_date') }}"
- name: period_first_day
description: Timestamp of the first date of the month.
- name: period_last_day
description: Timestamp of the last date of the month.
- name: account_class
description: "{{ doc('account_class') }} with the balance sheet line."
- name: is_sub_account
Expand Down
15 changes: 8 additions & 7 deletions models/quickbooks__ap_ar_enhanced.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--To disable this model, set the using_invoice variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_bill', True)) }}
--To disable this model, set the using_bill and using_invoice variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_bill', True) and var('using_invoice', True) and var('using_payment', True)) }}

with bill_join as (

Expand Down Expand Up @@ -72,7 +72,6 @@ final as (
bill_join.total_amount,
cast(null as {{ dbt.type_numeric() }}) as estimate_amount,
bill_join.current_balance,
bill_join.total_current_payment,
bill_join.due_date,
case when bill_join.current_balance != 0 and {{ dbt.datediff("bill_join.recent_payment_date", "bill_join.due_date", 'day') }} < 0
then true
Expand All @@ -83,7 +82,8 @@ final as (
else 0
end as days_overdue,
bill_join.initial_payment_date,
bill_join.recent_payment_date
bill_join.recent_payment_date,
bill_join.total_current_payment
from bill_join

{% if var('using_department', True) %}
Expand Down Expand Up @@ -126,13 +126,12 @@ final as (
concat(billing_address.address_1, billing_address.address_2) as customer_vendor_address_line,
{% endif %}

customers.website as customer_vendor_webiste,
customers.website as customer_vendor_website,
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
invoice_join.delivery_type,
invoice_join.estimate_status,
invoice_join.total_amount as total_amount,
invoice_join.estimate_total_amount as estimate_total_amount,
invoice_join.current_balance as current_balance,
invoice_join.total_current_payment as total_current_payment,
invoice_join.due_date,
case when invoice_join.current_balance != 0 and {{ dbt.datediff("invoice_join.recent_payment_date", "invoice_join.due_date", 'day') }} < 0
then true
Expand All @@ -143,7 +142,9 @@ final as (
else 0
end as days_overdue,
invoice_join.initial_payment_date,
invoice_join.recent_payment_date
invoice_join.recent_payment_date,
invoice_join.total_current_payment as total_current_payment

from invoice_join

{% if var('using_department', True) %}
Expand Down
4 changes: 3 additions & 1 deletion models/quickbooks__balance_sheet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ with general_ledger_by_period as (

final as (
select
period_first_day as calendar_date,
period_first_day as calendar_date, -- Slated to be deprecated; we recommend using `period_first_day` or `period_last_day`
period_first_day,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should note here as well in a comment that calendar_date will be deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! added

period_last_day,
source_relation,
account_class,
class_id,
Expand Down
2 changes: 1 addition & 1 deletion models/quickbooks__profit_and_loss.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with general_ledger_by_period as (

final as (
select
period_first_day as calendar_date,
period_first_day as calendar_date, -- Slated to be deprecated; we recommend using `period_first_day` or `period_last_day`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that period_first_day and period_last_day aren't included in the quickbooks__profit_and_loss SQL even though the yml definition says the columns exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah @sbrudz you're right, this was mistakenly removed during the PR. We will have this fix ready first thing next week!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sbrudz for catching this, the package has been updated!

source_relation,
account_class,
class_id,
Expand Down