Skip to content
Open
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
2 changes: 2 additions & 0 deletions DECISIONLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ The corresponding entry that would result from the `int_quickbooks__invoice_doub
- Financing: The movement of cash between a firm and its owners, investors, and creditors. Account types like long term liability and account classes like equity fall here under our logic.
- Cash or Cash Equivalents: Line items that report value of a company's cash assets. Bank account types are assigned here.

- The cash flow statement reverses the signs of noncash Asset balances before calculating monthly changes, for both original and converted amounts. Bank accounts retain their balance-sheet signs. An increase in accounts receivable, prepaid expenses, or fixed assets therefore reduces cash flow; a decrease increases it. Liability and Equity accounts retain their balance-sheet signs.

- While the default case statement logic should work for many customers with basic setups, as customization gets more advanced for your specific business, this is not likely to cover all cases. This is why we created the seed functionality to allow you flexibility to adjust the cash flow types for your own custom purposes--[you can read more about how to set it up in our README](https://github.com/fivetran/dbt_quickbooks/blob/main/README.md#customize-the-cash-flow-model).

## QuickBooks Financial Statement Ordinal Logic
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.

5 changes: 5 additions & 0 deletions integration_tests/seeds/account_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ id,_fivetran_synced,account_number,account_sub_type,account_type,active,balance,
94102,2026-02-10 12:00:00,9402,100fb8196b919896e083af2939bbffb3,Accounts Payable,TRUE,0,0,Liability,2026-02-10 00:00:00,GBP,Alternate GBP AP account to simulate multi-account ambiguity,Accounts Payable GBP Alt,Accounts Payable GBP Alt,,FALSE,1,,2026-02-10 12:00:00,FALSE
95001,2021-01-01 12:00:00,4201,SalesOfProductIncome,Income,TRUE,0,0,Revenue,2021-01-01 12:00:00,USD,Product income account for an item in bundle 149,Product Sales,Product Sales,,FALSE,0,,2021-01-01 12:00:00,FALSE
95002,2021-01-01 12:00:00,4202,SalesOfProductIncome,Income,TRUE,0,0,Revenue,2021-01-01 12:00:00,USD,Second product income account so bundle 149 maps to two,Product Sales 2,Product Sales 2,,FALSE,0,,2021-01-01 12:00:00,FALSE
96001,2024-01-01 00:00:00,96001,CashOnHand,Bank,TRUE,0,0,Asset,2024-01-01 00:00:00,EUR,Synthetic cash flow sign regression fixture,Cash flow test bank,Cash flow test bank,,FALSE,0,,2024-01-01 00:00:00,FALSE
96002,2024-01-01 00:00:00,96002,PrepaidExpenses,Other Current Asset,TRUE,0,0,Asset,2024-01-01 00:00:00,EUR,Synthetic cash flow sign regression fixture,Cash flow test prepaid expenses,Cash flow test prepaid expenses,,FALSE,0,,2024-01-01 00:00:00,FALSE
96003,2024-01-01 00:00:00,96003,MachineryAndEquipment,Fixed Asset,TRUE,0,0,Asset,2024-01-01 00:00:00,EUR,Synthetic cash flow sign regression fixture,Cash flow test equipment,Cash flow test equipment,,FALSE,0,,2024-01-01 00:00:00,FALSE
96004,2024-01-01 00:00:00,96004,OtherCurrentLiabilities,Other Current Liability,TRUE,0,0,Liability,2024-01-01 00:00:00,EUR,Synthetic cash flow sign regression fixture,Cash flow test liability,Cash flow test liability,,FALSE,0,,2024-01-01 00:00:00,FALSE
96005,2024-01-01 00:00:00,96005,OwnersEquity,Equity,TRUE,0,0,Equity,2024-01-01 00:00:00,EUR,Synthetic cash flow sign regression fixture,Cash flow test equity,Cash flow test equity,,FALSE,0,,2024-01-01 00:00:00,FALSE
16 changes: 16 additions & 0 deletions integration_tests/seeds/cash_flow_signs_expected.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
account_id,cash_flow_period,cash_flow_type,cash_beginning_period,cash_ending_period,cash_net_period,cash_converted_beginning_period,cash_converted_ending_period,cash_converted_net_period
96001,2024-01-01,Cash or Cash Equivalents,0,1000,1000,0,2000,2000
96001,2024-02-01,Cash or Cash Equivalents,1000,600,-400,2000,1200,-800
96001,2024-03-01,Cash or Cash Equivalents,600,630,30,1200,1260,60
96002,2024-01-01,Operating,0,0,0,0,0,0
96002,2024-02-01,Operating,0,-200,-200,0,-400,-400
96002,2024-03-01,Operating,-200,-150,50,-400,-300,100
96003,2024-01-01,Investing,0,0,0,0,0,0
96003,2024-02-01,Investing,0,-300,-300,0,-600,-600
96003,2024-03-01,Investing,-300,-280,20,-600,-560,40
96004,2024-01-01,Operating,0,0,0,0,0,0
96004,2024-02-01,Operating,0,100,100,0,200,200
96004,2024-03-01,Operating,100,60,-40,200,120,-80
96005,2024-01-01,Financing,0,1000,1000,0,2000,2000
96005,2024-02-01,Financing,1000,1000,0,2000,2000,0
96005,2024-03-01,Financing,1000,1000,0,2000,2000,0
9 changes: 8 additions & 1 deletion integration_tests/seeds/journal_entry_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ id,_fivetran_deleted,_fivetran_synced,adjustment,created_at,currency_id,doc_numb
44,FALSE,2020-06-23 03:58:59,FALSE,2020-06-23 03:45:00,USD,93a3c769704fbd2f2e84270cae00f49b,1.0,,5aa72aeaa898300af7bf421fb3568a2d,0,,99205.00,5952.30,2020-06-23,2020-06-23 03:45:00
395,FALSE,2020-12-10 00:02:05,FALSE,2020-12-10 00:00:00,USD,ab0e9618346d8779c343a6782e079723,1.0,,5aa72aeaa898300af7bf421fb3568a2d,0,,62405.00,4680.38,2020-12-10,2020-12-10 00:00:00
9002,FALSE,2026-02-10 12:00:00,FALSE,2026-02-10 12:00:00,GBP,,,,,1,,1500,,2026-02-10,2026-02-10 12:00:00
9003,FALSE,2026-02-10 12:00:00,FALSE,2026-02-10 12:00:00,GBP,,,,,1,,7000,,2026-02-10,2026-02-10 12:00:00
9003,FALSE,2026-02-10 12:00:00,FALSE,2026-02-10 12:00:00,GBP,,,,,1,,7000,,2026-02-10,2026-02-10 12:00:00
96001,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96001,2,2000,Synthetic cash flow sign regression fixture,0,,1000,0,2024-01-15,2024-01-01 00:00:00
96002,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96002,2,400,Synthetic cash flow sign regression fixture,0,,200,0,2024-02-15,2024-01-01 00:00:00
96003,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96003,2,600,Synthetic cash flow sign regression fixture,0,,300,0,2024-02-16,2024-01-01 00:00:00
96004,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96004,2,200,Synthetic cash flow sign regression fixture,0,,100,0,2024-02-17,2024-01-01 00:00:00
96005,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96005,2,100,Synthetic cash flow sign regression fixture,0,,50,0,2024-03-15,2024-01-01 00:00:00
96006,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96006,2,80,Synthetic cash flow sign regression fixture,0,,40,0,2024-03-16,2024-01-01 00:00:00
96007,FALSE,2024-01-01 00:00:00,FALSE,2024-01-01 00:00:00,EUR,cash-flow-signs-96007,2,40,Synthetic cash flow sign regression fixture,0,,20,0,2024-03-17,2024-01-01 00:00:00
16 changes: 15 additions & 1 deletion integration_tests/seeds/journal_entry_line_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,18 @@ index,journal_entry_id,_fivetran_synced,account_id,amount,billable_status,class_
0,92011,2024-01-20 09:00:00,51515,100,,,10,,Test JE to Expense,2024-01-20,,10,Debit,,,,
0,92012,2024-01-20 09:00:00,52525,200,,,10,,Test JE to COGS,2024-01-20,,10,Debit,,,,
0,9002,2026-02-10 12:00:00,92003,1500,,,2150,,,,,,Debit,,,,
0,9003,2026-02-10 12:00:00,20299,7000,,,,,,,,,Credit,,,,
0,9003,2026-02-10 12:00:00,20299,7000,,,,,,,,,Credit,,,,
0,96001,2024-01-01 00:00:00,96001,1000,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96001,2024-01-01 00:00:00,96005,1000,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96002,2024-01-01 00:00:00,96002,200,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96002,2024-01-01 00:00:00,96001,200,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96003,2024-01-01 00:00:00,96003,300,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96003,2024-01-01 00:00:00,96001,300,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96004,2024-01-01 00:00:00,96001,100,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96004,2024-01-01 00:00:00,96004,100,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96005,2024-01-01 00:00:00,96001,50,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96005,2024-01-01 00:00:00,96002,50,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96006,2024-01-01 00:00:00,96004,40,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96006,2024-01-01 00:00:00,96001,40,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
0,96007,2024-01-01 00:00:00,96001,20,,,,,Synthetic cash flow sign regression fixture,,,,Debit,,,,
1,96007,2024-01-01 00:00:00,96003,20,,,,,Synthetic cash flow sign regression fixture,,,,Credit,,,,
6 changes: 4 additions & 2 deletions integration_tests/tests/integrity/cash_flow_amounts_match.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ with balance_sheet as (

select
calendar_date as cash_flow_period,
sum(amount) as period_amount_source,
sum(converted_amount) as period_converted_amount_source
sum(case when account_class = 'Asset' and account_type != 'Bank'
then -amount else amount end) as period_amount_source,
sum(case when account_class = 'Asset' and account_type != 'Bank'
then -converted_amount else converted_amount end) as period_converted_amount_source
from {{ ref('quickbooks__balance_sheet') }}
group by 1
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false) and var('using_journal_entry', True) and not var('cash_flow_statement_type_ordinal', [])
) }}

-- Synthetic journal entries fund a bank account, purchase prepaid expenses and
-- equipment, then release those assets. Asset purchases consume cash; releases
-- generate cash. Bank, liability, and equity balances retain their usual signs.
with expected as (

select *
from {{ ref('cash_flow_signs_expected') }}
),

actual as (

select *
from {{ ref('quickbooks__cash_flow_statement') }}
where account_id in ('96001', '96002', '96003', '96004', '96005')
and cash_flow_period between cast('2024-01-01' as date) and cast('2024-03-01' as date)
),

match_check as (

select
expected.account_id as expected_account_id,
actual.account_id as actual_account_id,
expected.cash_flow_period,
expected.cash_flow_type as expected_cash_flow_type,
actual.cash_flow_type as actual_cash_flow_type,
expected.cash_beginning_period as expected_beginning,
actual.cash_beginning_period as actual_beginning,
expected.cash_ending_period as expected_ending,
actual.cash_ending_period as actual_ending,
expected.cash_net_period as expected_net,
actual.cash_net_period as actual_net,
expected.cash_converted_beginning_period as expected_converted_beginning,
actual.cash_converted_beginning_period as actual_converted_beginning,
expected.cash_converted_ending_period as expected_converted_ending,
actual.cash_converted_ending_period as actual_converted_ending,
expected.cash_converted_net_period as expected_converted_net,
actual.cash_converted_net_period as actual_converted_net
from expected
full outer join actual
on cast(expected.account_id as {{ dbt.type_string() }}) = actual.account_id
and cast(expected.cash_flow_period as date) = actual.cash_flow_period
)

select *
from match_check
where expected_account_id is null
or actual_account_id is null
or actual_cash_flow_type is null
or actual_cash_flow_type != expected_cash_flow_type
or actual_beginning is null
or actual_ending is null
or actual_net is null
or actual_converted_beginning is null
or actual_converted_ending is null
or actual_converted_net is null
or abs(actual_beginning - expected_beginning) >= 0.01
or abs(actual_ending - expected_ending) >= 0.01
or abs(actual_net - expected_net) >= 0.01
or abs(actual_converted_beginning - expected_converted_beginning) >= 0.01
or abs(actual_converted_ending - expected_converted_ending) >= 0.01
or abs(actual_converted_net - expected_converted_net) >= 0.01
1 change: 1 addition & 0 deletions models/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ calculations are included to show if the payable/receivable has been fully paid

{% docs cash_flow_statement_table %}
Table that provides all line items necessary to construct a cash flow statement.
Noncash Asset balances use the inverse of their balance-sheet signs so that increases reduce cash flow and decreases increase it. Bank, Liability, and Equity balances retain their balance-sheet signs.
{% enddocs %}

{% docs expenses_sales_enhanced_table %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ with cash_flow_key as (
account_number,
account_id,
account_name,
amount as cash_ending_period,
converted_amount as cash_converted_ending_period,
-- Noncash asset increases consume cash; Bank accounts retain their cash balance signs.
case when account_class = 'Asset' and account_type != 'Bank'
then -amount else amount end as cash_ending_period,
case when account_class = 'Asset' and account_type != 'Bank'
then -converted_amount else converted_amount end as cash_converted_ending_period,
{{ dbt_utils.generate_surrogate_key(['account_id', 'source_relation', 'calendar_date', 'class_id']) }} as account_unique_id
from {{ ref('quickbooks__balance_sheet') }}
),
Expand Down