commit wip
This commit is contained in:
parent
f768be9ea5
commit
2746977671
1 changed files with 7 additions and 9 deletions
|
|
@ -1,11 +1,5 @@
|
||||||
with
|
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__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__credit_notes as (select * from {{ ref("int_xero__credit_notes") }}),
|
int_xero__credit_notes as (select * from {{ ref("int_xero__credit_notes") }}),
|
||||||
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }}),
|
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }}),
|
||||||
stg_seed__accounting_aggregations as (
|
stg_seed__accounting_aggregations as (
|
||||||
|
|
@ -28,7 +22,9 @@ with
|
||||||
where cn.credit_note_status = 'AUTHORISED' and c.id_deal is not null
|
where cn.credit_note_status = 'AUTHORISED' and c.id_deal is not null
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
|
id_contact,
|
||||||
id_deal,
|
id_deal,
|
||||||
|
contact_name,
|
||||||
sum(total_due_in_gbp) as total_outstanding_in_gbp,
|
sum(total_due_in_gbp) as total_outstanding_in_gbp,
|
||||||
case
|
case
|
||||||
when sum(total_due_in_gbp) < 0
|
when sum(total_due_in_gbp) < 0
|
||||||
|
|
@ -37,4 +33,6 @@ with
|
||||||
then 'Outstanding Invoices'
|
then 'Outstanding Invoices'
|
||||||
end as outstanding_type
|
end as outstanding_type
|
||||||
from amount_due_deals
|
from amount_due_deals
|
||||||
group by id_deal
|
group by id_contact,
|
||||||
|
id_deal,
|
||||||
|
contact_name
|
||||||
Loading…
Add table
Add a link
Reference in a new issue