Skip to content

Commit

Permalink
Merge pull request #11 from fivetran/bugfix/retained-earnings
Browse files Browse the repository at this point in the history
Bugfix/retained earnings
  • Loading branch information
fivetran-reneeli authored May 13, 2022
2 parents b9ccdf9 + 0a07e07 commit d973391
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# dbt_sage_intacct v0.2.0
## Fix balance sheet not tying out
- The amounts in the balance sheet model were not tying out. We have added an additional `Adj. Net Income` account to include for a net income adjustment as part of the Retained Earnings category. ([#8](https://github.com/fivetran/dbt_sage_intacct/issues/8))
## Contributors
[@santi95](https://github.com/santi95) ([#9](https://github.com/fivetran/dbt_sage_intacct/pull/9))

# dbt_sage_intacct v0.1.1
## Updates
- Allow for pass-through columns from the `gl_detail` and `gl_account` source tables. In the gl_detail staging model, added additional fields and enabled/disabled configs for the AP Bill and AR Invoice tables which may not be present in the customer schema.
Expand Down
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,19 @@ vars:
sage_gl_pass_through_columns: ['custom_field_3', 'custom_field_4']
```
### Custom Account Classification
Accounts roll up into different accounting classes based on their category. The categories are brought in from the `gl_account` table. We created a variable for each accounting class (`Asset`, `Liability`, `Equity`, `Revenue`, `Expense`) that can be modified to include different categories based on your business. You can modify the variables within your root `dbt_project.yml` file. The default values for the respective variables are as follows:
Accounts roll up into different accounting classes based on their category. The categories are brought in from the `gl_account` table. We created a variable for each accounting class (`Asset`, `Liability`, `Equity`, `Revenue`, `Expense`) that can be modified to include different categories based on your business. You can modify the variables within your root `dbt_project.yml` file. The default values for the respective classes are as follows:

```yml
# dbt_project.yml
...
vars:
sage_intacct_category_asset: ('Inventory','Fixed Assets','Other Current Assets','Cash and Cash Equivalents','Intercompany Receivable','Accounts Receivable','Deposits and Prepayments','Goodwill','Intangible Assets','Short-Term Investments','Inventory','Accumulated Depreciation','Other Assets','Unrealized Currency Gain/Loss','Patents','Investment in Subsidiary','Escrows and Reserves','Long Term Investments')
sage_intacct_category_equity: ('Partners Equity','Retained Earnings','Dividend Paid')
sage_intacct_category_expense: ('Advertising and Promotion Expense','Other Operating Expense','Cost of Sales Revenue', 'Professional Services Expense','Cost of Services Revenue','Payroll Expense','Payroll Taxes','Travel Expense','Cost of Goods Sold','Other Expenses','Compensation Expense','Federal Tax','Depreciation Expense')
sage_intacct_category_liability: ('Accounts Payable','Other Current Liabilities','Accrued Liabilities','Note Payable - Current','Deferred Taxes Liabilities - Long Term','Note Payable - Long Term','Other Liabilities','Deferred Revenue - Current')
sage_intacct_category_revenue: ('Revenue','Revenue - Sales','Dividend Income','Revenue - Other','Other Income','Revenue - Services','Revenue - Products')
```
### Disabling and Enabling Models

When setting up your Sage Intacct (Sage) connection in Fivetran, it is possible that not every table this package expects will be synced. This can occur because you either don't use that functionality in Sage or have actively decided to not sync some tables. In order to disable the relevant functionality in the package, you will need to add the relevant variables.
Expand All @@ -75,20 +86,6 @@ vars:
sage_intacct__using_invoices: false # default is true
sage_intacct__using_bills: false # default is true
```


```yml
# dbt_project.yml
...
vars:
sage_intacct:
sage_intacct_category_asset: ('Inventory','Fixed Assets','Other Current Assets','Cash and Cash Equivalents','Intercompany Receivable','Accounts Receivable','Deposits and Prepayments','Goodwill','Intangible Assets','Short-Term Investments','Inventory','Accumulated Depreciation','Other Assets','Unrealized Currency Gain/Loss','Patents','Investment in Subsidiary','Escrows and Reserves','Long Term Investments')
sage_intacct_category_liability: ('Accounts Payable','Other Current Liabilities','Accrued Liabilities','Note Payable - Current','Deferred Taxes Liabilities - Long Term','Note Payable - Long Term','Other Liabilities','Deferred Revenue - Current')
sage_intacct_category_equity: ('Partners Equity','Retained Earnings','Dividend Paid')
sage_intacct_category_revenue: ('Revenue','Revenue - Sales','Dividend Income','Revenue - Other','Other Income','Revenue - Services','Revenue - Products')
sage_intacct_category_expense: ('Advertising and Promotion Expense','Other Operating Expense','Cost of Sales Revenue', 'Professional Services Expense','Cost of Services Revenue','Payroll Expense','Payroll Taxes','Travel Expense','Cost of Goods Sold','Other Expenses','Compensation Expense','Federal Tax','Depreciation Expense')
```
### Changing the Build Schema
By default this package will build the Sage Intacct staging models within a schema titled (<target_schema> + `_stg_sage_intacct`) and the Sage Intacct final models with a schema titled (<target_schema> + `_sage_intacct`) in your target database. If this is not where you would like your modeled Sage Intacct data to be written to, add the following configuration to your `dbt_project.yml` file:

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: 'sage_intacct'
version: '0.1.1'
version: '0.1.2'

require-dbt-version: [">=1.0.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,5 +1,5 @@
name: 'sage_intacct_integration_tests'
version: '0.1.1'
version: '0.1.2'
config-version: 2

profile: 'integration_tests'
Expand Down
41 changes: 41 additions & 0 deletions models/intermediate/int_sage_intacct__retained_earnings.sql
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
3 changes: 3 additions & 0 deletions models/sage_intacct.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ models:
- name: int_sage_intacct__account_classifications
description: >
Ties each account type with its category, along with its overall classification
- name: int_sage_intacct__retained_earnings
description: >
Creates and calculates an Adjusted Net Income account that rolls up Net Income into the Retained Earnings category and helps tie out the Balance Sheet.
- name: sage_intacct__ap_ar_enhanced
description: >
Expand Down
29 changes: 27 additions & 2 deletions models/sage_intacct__balance_sheet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ with general_ledger_by_period as (
where account_type = 'balancesheet'
),

retained_earnings as (
select *
from {{ ref('int_sage_intacct__retained_earnings') }}
),

combine_retained_earnings as (
select
period_first_day,
account_no,
account_title,
account_type,
book_id,
category,
classification,
currency,
entry_state,
period_ending_amount as amount
from general_ledger_by_period

union all

select *
from retained_earnings
),

final as (
select
cast ({{ dbt_utils.date_trunc("month", "period_first_day") }} as date) as period_date,
Expand All @@ -15,8 +40,8 @@ final as (
classification,
currency,
entry_state,
round(cast(period_ending_amount as {{ dbt_utils.type_numeric() }}),2) as amount
from general_ledger_by_period
round(cast(amount as {{ dbt_utils.type_numeric() }}),2) as amount
from combine_retained_earnings
)

select *
Expand Down

0 comments on commit d973391

Please sign in to comment.