-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from fivetran/bugfix/retained-earnings
Bugfix/retained earnings
- Loading branch information
Showing
10 changed files
with
94 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
models/intermediate/int_sage_intacct__retained_earnings.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
with general_ledger_by_period as ( | ||
select * | ||
from {{ ref('sage_intacct__general_ledger_by_period') }} | ||
), | ||
|
||
retained_earnings_prep as ( | ||
select | ||
period_first_day, | ||
'dbt Package Generated' as account_no, | ||
'Adj. Net Income' as account_title, | ||
'balancesheet' as account_type, | ||
book_id, | ||
'Retained Earnings' as category, | ||
'Equity' as classification, | ||
currency, | ||
entry_state, | ||
sum(period_net_amount) as period_net_amount | ||
from general_ledger_by_period | ||
where account_type = 'incomestatement' | ||
group by period_first_day, book_id, entry_state, currency | ||
), | ||
|
||
final as ( | ||
select | ||
period_first_day, | ||
account_no, | ||
account_title, | ||
account_type, | ||
book_id, | ||
category, | ||
classification, | ||
currency, | ||
entry_state, | ||
sum(period_net_amount) over (partition by book_id, entry_state, currency | ||
order by period_first_day rows between unbounded preceding and current row | ||
) as amount | ||
from retained_earnings_prep | ||
) | ||
|
||
select * | ||
from final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters