Skip to content

Commit a2be6f9

Browse files
ledger alignment
1 parent 8ab9b7c commit a2be6f9

7 files changed

Lines changed: 30 additions & 22 deletions

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
# dbt_xero v1.5.0
33

44
## Schema/Data Change
5-
**1 total change0 possible breaking changes**
5+
**6 total changes1 possible breaking change**
66

77
| Data Model(s) | Change type | Old | New | Notes |
88
| ---------- | ----------- | -------- | -------- | ----- |
99
| `xero__cash_general_ledger` | New model | N/A | New end model | Cash-basis general ledger; one row per cash journal line. Enabled by default; disable by setting `xero__using_journal_cash: false`. |
10+
| `xero__general_ledger` | Bug fix | `payment_id` excluded `ARPREPAYMENT`, `AROVERPAYMENT` | Now includes all prepayment and overpayment source types | Aligns AR prepayment/overpayment handling with AP counterparts already present.<br><br>**Possible breaking change**: Rows with `ARPREPAYMENT` or `AROVERPAYMENT` source types previously had a `NULL` `payment_id` and will now be populated. |
11+
| `stg_xero__journal_cash`<br>`stg_xero__journal_cash_tmp` | New staging models | N/A | | Cash-basis journal header data from the `journal_cash` source table. |
12+
| `stg_xero__journal_cash_line`<br>`stg_xero__journal_cash_line_tmp` | New staging models | N/A | | Cash-basis journal line data from the `journal_cash_line` source table. |
13+
| `stg_xero__journal_cash_line_has_tracking_category`<br>`stg_xero__journal_cash_line_has_tracking_category_tmp` | New staging models | N/A | | Tracking category associations for cash journal lines. Enabled when `xero__using_journal_cash_line_tracking_category` is `true`. |
14+
| `int_xero__journal_cash_line_pivoted_tracking_categories` | New intermediate model | N/A | | Pivots tracking categories across cash journal lines. Enabled when both `xero__using_journal_cash_line_tracking_category` and `xero__using_tracking_categories` are `true`. |
1015

1116
## Feature Update
12-
- Adds cash-basis journal support. Staging models for three new Xero source tables (`journal_cash`, `journal_cash_line`, `journal_cash_line_has_tracking_category`) and a new `xero__cash_general_ledger` end model are now available, enabled by default. Disable by setting `xero__using_journal_cash: false`. Cash-basis tracking category pivoting is also available via the `xero__using_journal_cash_line_tracking_category` variable. ([#73](https://github.com/fivetran/dbt_xero/pull/73))
17+
- Adds cash-basis journal support via three new staging models (`stg_xero__journal_cash`, `stg_xero__journal_cash_line`, `stg_xero__journal_cash_line_has_tracking_category`) and the new `xero__cash_general_ledger` end model. The end model includes `contact_id`, `contact_name`, and `payment_id` resolution, mirrors the structure of `xero__general_ledger`, and adds an `accounting_basis` column set to `'cash'`. All models are enabled by default; disable by setting `xero__using_journal_cash: false`. Cash-basis tracking category pivoting is also available via `xero__using_journal_cash_line_tracking_category`.
1318

1419
# dbt_xero v1.4.0
1520

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ vars:
138138
xero__using_invoice_line_item_tracking_category: false # default is true
139139
xero__using_journal_line_tracking_category: false # default is true
140140
xero__using_tracking_categories: false # default is true
141-
xero__using_journal_cash: false # default is true
141+
xero__using_journal_cash: false # will disable both journal_cash and journal_cash_line sources; default is true
142142
xero__using_journal_cash_line_tracking_category: false # default is true
143143
```
144144

models/staging/stg_xero.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ models:
2020
- name: source_relation
2121
description: >
2222
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
23-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
23+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
2424
sources, this will be an empty string.
2525
2626
@@ -36,7 +36,7 @@ models:
3636
- name: source_relation
3737
description: >
3838
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
39-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
39+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
4040
sources, this will be an empty string.
4141
4242
@@ -74,7 +74,7 @@ models:
7474
- name: source_relation
7575
description: >
7676
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
77-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
77+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
7878
sources, this will be an empty string.
7979
8080
- name: stg_xero__invoice
@@ -119,7 +119,7 @@ models:
119119
- name: source_relation
120120
description: >
121121
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
122-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
122+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
123123
sources, this will be an empty string.
124124
125125
- name: stg_xero__journal_line
@@ -154,7 +154,7 @@ models:
154154
- name: source_relation
155155
description: >
156156
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
157-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
157+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
158158
sources, this will be an empty string.
159159
160160
- name: stg_xero__journal
@@ -179,7 +179,7 @@ models:
179179
- name: source_relation
180180
description: >
181181
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
182-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
182+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
183183
sources, this will be an empty string.
184184
185185
@@ -197,7 +197,7 @@ models:
197197
- name: source_relation
198198
description: >
199199
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
200-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
200+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
201201
sources, this will be an empty string.
202202
203203
- name: stg_xero__invoice_line_item_has_tracking_category
@@ -214,7 +214,7 @@ models:
214214
- name: source_relation
215215
description: >
216216
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
217-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
217+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
218218
sources, this will be an empty string.
219219
220220
- name: stg_xero__journal_line_has_tracking_category
@@ -233,7 +233,7 @@ models:
233233
- name: source_relation
234234
description: >
235235
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
236-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
236+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
237237
sources, this will be an empty string.
238238
239239
- name: stg_xero__tracking_category
@@ -250,7 +250,7 @@ models:
250250
- name: source_relation
251251
description: >
252252
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
253-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
253+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
254254
sources, this will be an empty string.
255255
256256
- name: stg_xero__tracking_category_option
@@ -275,7 +275,7 @@ models:
275275
- name: source_relation
276276
description: >
277277
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
278-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
278+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
279279
sources, this will be an empty string.
280280
281281
- name: stg_xero__tracking_category_has_option
@@ -290,7 +290,7 @@ models:
290290
- name: source_relation
291291
description: >
292292
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
293-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
293+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
294294
sources, this will be an empty string.
295295
296296
- name: stg_xero__journal_cash
@@ -315,7 +315,7 @@ models:
315315
- name: source_relation
316316
description: >
317317
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
318-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
318+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
319319
sources, this will be an empty string.
320320
321321
- name: stg_xero__journal_cash_line
@@ -350,7 +350,7 @@ models:
350350
- name: source_relation
351351
description: >
352352
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
353-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
353+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
354354
sources, this will be an empty string.
355355
356356
- name: stg_xero__journal_cash_line_has_tracking_category
@@ -375,5 +375,5 @@ models:
375375
- name: source_relation
376376
description: >
377377
The source where this data was pulled from. If you are making use of the `union_schemas` variable, this will be the source schema.
378-
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioining together multiple
378+
If you are making use of the `union_databases` variable, this will be the source database. If you are not unioning together multiple
379379
sources, this will be an empty string.

models/staging/tmp/stg_xero__journal_cash_line_has_tracking_category_tmp.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ config(enabled=var('xero__using_journal_cash_line_tracking_category', true)) }}
1+
{{ config(enabled=(var('xero__using_journal_cash', true) and var('xero__using_journal_cash_line_tracking_category', true))) }}
22

33
{% if var('union_schemas', []) | length > 0 or var('union_databases', []) | length > 0 %}
44

models/xero.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ models:
224224
description: The identifier for the related bank transaction, if the source transaction is a cash receipt or payment.
225225
- name: credit_note_id
226226
description: The identifier for the related credit note, if the source transaction is a credit note.
227+
- name: payment_id
228+
description: The identifier for the related payment, if the source transaction is a payment (e.g. ACCRECPAYMENT, ACCPAYPAYMENT, ARCREDITPAYMENT, APCREDITPAYMENT, APPREPAYMENT, APOVERPAYMENT, ARPREPAYMENT, AROVERPAYMENT).
227229
- name: contact_id
228230
description: The identifier for the contact associated with the source transaction.
229231
- name: contact_name

models/xero__cash_general_ledger.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ with journals as (
8585

8686
case when journals.source_type in ('ACCPAY', 'ACCREC') then journals.source_id end as invoice_id,
8787
case when journals.source_type in ('CASHREC','CASHPAID') then journals.source_id end as bank_transaction_id,
88-
case when journals.source_type in ('ACCPAYCREDIT','ACCRECCREDIT') then journals.source_id end as credit_note_id
88+
case when journals.source_type in ('ACCPAYCREDIT','ACCRECCREDIT') then journals.source_id end as credit_note_id,
89+
case when journals.source_type in ('ACCRECPAYMENT','ACCPAYPAYMENT','ARCREDITPAYMENT','APCREDITPAYMENT','APPREPAYMENT','APOVERPAYMENT','ARPREPAYMENT','AROVERPAYMENT') then journals.source_id end as payment_id
8990

9091
{% if using_tracking_categories and pivoted_columns|length > 0 %}
9192
{%- set accounts_columns = ['account_class', 'account_code', 'account_id', 'account_name', 'account_type'] %}
9293
{%- set journals_columns = ['accounting_basis', 'created_date_utc', 'journal_date', 'journal_id', 'journal_number', 'reference', 'source_id', 'source_relation', 'source_type'] %}
9394
{%- set journal_lines_columns = ['description', 'gross_amount', 'journal_line_id', 'net_amount', 'tax_amount', 'tax_name', 'tax_type'] %}
94-
{%- set new_columns = ['invoice_id', 'bank_transaction_id', 'credit_note_id'] %}
95+
{%- set new_columns = ['invoice_id', 'bank_transaction_id', 'credit_note_id', 'payment_id'] %}
9596
{%- set joined_columns = accounts_columns + journals_columns + journal_lines_columns + new_columns %}
9697

9798
{% for col in pivoted_columns %}

models/xero__general_ledger.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ with journals as (
8484
case when journals.source_type in ('CASHREC','CASHPAID') then journals.source_id end as bank_transaction_id,
8585
case when journals.source_type in ('TRANSFER') then journals.source_id end as bank_transfer_id,
8686
case when journals.source_type in ('MANJOURNAL') then journals.source_id end as manual_journal_id,
87-
case when journals.source_type in ('APPREPAYMENT', 'APOVERPAYMENT', 'ACCPAYPAYMENT', 'ACCRECPAYMENT', 'ARCREDITPAYMENT', 'APCREDITPAYMENT') then journals.source_id end as payment_id,
87+
case when journals.source_type in ('APPREPAYMENT', 'APOVERPAYMENT', 'ARPREPAYMENT', 'AROVERPAYMENT', 'ACCPAYPAYMENT', 'ACCRECPAYMENT', 'ARCREDITPAYMENT', 'APCREDITPAYMENT') then journals.source_id end as payment_id,
8888
case when journals.source_type in ('ACCPAYCREDIT','ACCRECCREDIT') then journals.source_id end as credit_note_id
8989

9090
{% if using_tracking_categories and pivoted_columns|length > 0 %}

0 commit comments

Comments
 (0)