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

feature/credit-card-payments #50

Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# dbt_quickbooks_source v0.6.0
## 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. ([#50](https://github.com/fivetran/dbt_quickbooks/pull/50))
>**Note**: the `credit_card_payment_txn` source and models are disabled by default. In order to enabled them, you will want to set the `using_credit_card_payment_txn` variable to `true` in your dbt_project.yml.

## Contributors
- [@mikerenderco](https://github.com/mikerenderco) ([#50](https://github.com/fivetran/dbt_quickbooks/pull/50))

# dbt_quickbooks v0.5.3
## Bug Fixes
- The `int_quickbooks__bill_payment_double_entry`, `int_quickbooks__credit_memo_double_entry`, `int_quickbooks__deposit_double_entry`, and `int_quickbooks__payment_double_entry` models perform a cross join on the `stg_quickbooks__accounts` model for the respective debit/credit account. However, if this cross join includes more than one record, it will result in duplicates. An additional filter to remove sub accounts has been added to ensure the output of the models do not have duplicates. ([#49](https://github.com/fivetran/dbt_quickbooks/pull/49))

## Under the Hood
- A GitHub workflow has been added to ensure the dbt docs are regenerated before each merge to the `main` release branch. ([#49](https://github.com/fivetran/dbt_quickbooks/pull/49))

# dbt_quickbooks v0.5.2
## Bug Fixes
- Within the `v0.5.1` release, the `transaction_id` field was erroneously removed from the `quickbooks__general_ledger` model. This field has since been added back. ([#46](https://github.com/fivetran/dbt_quickbooks/pull/46))
Expand Down
2 changes: 2 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
config-version: 2
name: 'quickbooks'

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

models:
quickbooks:
+materialized: table
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ integration_tests:
schema: <PLEASE INSERT INTEGRATION TESTS SCHEMA NAMES>
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
type: databricks
4 changes: 4 additions & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: 'quickbooks_integration_tests'

version: '0.6.0'

profile: 'integration_tests'
config-version: 2
models:
Expand All @@ -15,6 +17,7 @@ models:
+materialized: table
tmp:
+materialized: view

vars:
quickbooks_schema: quickbooks_source_integrations_tests
quickbooks_source:
Expand Down Expand Up @@ -54,6 +57,7 @@ vars:
vendor_credit_line: "{{ ref('vendor_credit_line_data') }}"
vendor_credit: "{{ ref('vendor_credit_data') }}"
vendor: "{{ ref('vendor_data') }}"

seeds:
+quote_columns: "{{ true if target.type == 'redshift' else false }}"
quickbooks_integration_tests:
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/seeds/credit_card_payment_txn_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,amount,bank_account_id,credit_card_account_id,created_at,updated_at,currency_id,transaction_date,_fivetran_deleted
1111,5,5,7,2022-07-21 09:57:41,2022-07-21 09:57:41,USD,2022-07-21,FALSE
2222,10.02,5,7,2020-05-24 19:39:23,2020-05-24 19:39:23,USD,2020-05-19,FALSE
3333,13.52,5,7,2022-09-06 12:12:07,2022-09-06 12:12:07,USD,2022-09-04,FALSE
4444,65.22,5,7,2022-01-05 22:22:11,2022-01-05 22:22:11,USD,2022-01-04,FALSE
5555,94.1,5,7,2022-07-09 21:15:24,2022-07-09 21:15:24,USD,2022-06-18,FALSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Table that creates a debit record to the associated bank account and a credit record to the specified credit card account.
*/

--To enable this model, set the using_credit_card_payment_txn variable within your dbt_project.yml file to True.
{{ config(enabled=var('using_credit_card_payment_txn', False)) }}

with credit_card_payments as (
select *
from {{ref('stg_quickbooks__credit_card_payment_txn')}}
where is_most_recent_record
),

credit_card_payment_prep as (
select
credit_card_payments.credit_card_payment_id as transaction_id,
row_number() over (partition by credit_card_payments.credit_card_payment_id order by credit_card_payments.transaction_date) - 1 as index,
credit_card_payments.transaction_date,
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
from credit_card_payments
),

final as (
select
transaction_id,
index,
transaction_date,
customer_id,
vendor_id,
amount,
credit_card_account_id as account_id,
'credit' as transaction_type,
'credit card payment' as transaction_source
from credit_card_payment_prep

union all

select
transaction_id,
index,
transaction_date,
customer_id,
vendor_id,
amount,
bank_account_id,
'debit' as transaction_type,
'credit card payment' as transaction_source
from credit_card_payment_prep
)

select *
from final
7 changes: 7 additions & 0 deletions models/quickbooks__general_ledger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ with gl_union as (
from {{ref('int_quickbooks__credit_memo_double_entry')}}
{% endif %}

{% if var('using_credit_card_payment_txn', False) %}
union all

select *
from {{ref('int_quickbooks__credit_card_pymt_double_entry')}}
{% endif %}

{% if var('using_deposit', True) %}
union all

Expand Down
2 changes: 1 addition & 1 deletion packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
- package: fivetran/quickbooks_source
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]