New model for deals total due amount

This commit is contained in:
Joaquin 2025-06-03 11:53:40 +02:00
parent 2746977671
commit d50442e887
6 changed files with 129 additions and 82 deletions

View file

@ -1426,17 +1426,6 @@ models:
data_type: numeric
description: ""
- name: outstanding_type
data_type: character varying
description: |
Field indicating whether Truvi ows more money to the deal account ('Outstanding Resolutions')
or the deal account owes more money to Truvi ('Outstanding Invoices').
data_tests:
- accepted_values:
values:
- "Outstanding Resolutions"
- "Outstanding Invoices"
- name: id_contact
data_type: character varying
description: ""
@ -1733,4 +1722,50 @@ models:
- name: contact_status
data_type: character varying
description: ""
description: ""
- name: xero__deals_due_amounts
description: |
This model provides a view on outstanding amounts related to deals,
specifically focusing on the amounts owed by Truvi or to Truvi.
This includes all AUTHORISED invoices and credit notes.
columns:
- name: id_contact
data_type: character varying
description: |
Unique identifier of a contact.
data_tests:
- not_null
- unique
- name: id_deal
data_type: character varying
description: |
Identifier of the account.
data_tests:
- not_null
- unique
- name: contact_name
data_type: character varying
description: "Name of the contact associated with the deal."
- name: total_due_amount_in_gbp
data_type: numeric
description: |
Total outstanding amount in GBP, which is the sum of all AUTHORISED invoices and credit notes
for the deal, converted to GBP.
- name: outstanding_type
data_type: character varying
description: |
Field indicating whether Truvi ows more money to the deal account ('Outstanding Resolutions')
or the deal account owes more money to Truvi ('Outstanding Invoices').
data_tests:
- accepted_values:
values:
- "Outstanding Resolutions"
- "Outstanding Invoices"

View file

@ -0,0 +1,11 @@
with
int_xero__deals_due_amounts as (
select * from {{ ref("int_xero__deals_due_amounts") }}
)
select
dda.id_contact as id_contact,
dda.id_deal as id_deal,
dda.contact_name as contact_name,
dda.total_due_amount_in_gbp as total_due_amount_in_gbp,
dda.outstanding_type as outstanding_type
from int_xero__deals_due_amounts dda

View file

@ -40,7 +40,6 @@ select
sdm.header_total_tax_in_gbp as header_total_tax_in_gbp,
sdm.header_total_due_local_curr as header_total_due_local_curr,
sdm.header_total_due_in_gbp as header_total_due_in_gbp,
sdm.outstanding_type as outstanding_type,
sdm.id_contact as id_contact,
sdm.id_deal as id_deal,
sdm.contact_name as contact_name,