commit wip

This commit is contained in:
Joaquin 2025-06-03 10:53:22 +02:00
parent f768be9ea5
commit 2746977671

View file

@ -1,11 +1,5 @@
with
int_xero__invoice_line_items as (
select * from {{ ref("int_xero__invoice_line_items") }}
),
int_xero__invoices as (select * from {{ ref("int_xero__invoices") }}),
int_xero__credit_note_line_items as (
select * from {{ ref("int_xero__credit_note_line_items") }}
),
int_xero__invoices as (select * from {{ ref("int_xero__invoices") }}),
int_xero__credit_notes as (select * from {{ ref("int_xero__credit_notes") }}),
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }}),
stg_seed__accounting_aggregations as (
@ -13,7 +7,7 @@ with
),
amount_due_deals as (
select c.id_contact as id_contact,
c.id_deal as id_deal,
c.id_deal as id_deal,
c.contact_name as contact_name,
i.total_due_in_gbp
from int_xero__invoices i
@ -28,7 +22,9 @@ with
where cn.credit_note_status = 'AUTHORISED' and c.id_deal is not null
)
select
id_contact,
id_deal,
contact_name,
sum(total_due_in_gbp) as total_outstanding_in_gbp,
case
when sum(total_due_in_gbp) < 0
@ -37,4 +33,6 @@ with
then 'Outstanding Invoices'
end as outstanding_type
from amount_due_deals
group by id_deal
group by id_contact,
id_deal,
contact_name