# Description Hyperline invoices/credit notes have an issuing date that corresponds to the moment in which these are actually created. This is an issue since it means that an invoice or credit note posted today, 4th March 2025, that is supposed to be related to February 2025 invoicing cycle, will have: * If the document is posted in Hyperline, an issuing date on the March 2025 * If the document is NOT posted in Hyperline, an issuing date on February 2025 This PR just creates a field that handles the logic effectively, to be used further in other reports/kpis purposes. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #28158
52 lines
2.6 KiB
SQL
52 lines
2.6 KiB
SQL
with
|
|
int_xero__sales_denom_mart as (
|
|
select * from {{ ref("int_xero__sales_denom_mart") }}
|
|
)
|
|
select
|
|
sdm.id_line_item as id_line_item,
|
|
sdm.id_item as id_item,
|
|
sdm.document_class as document_class,
|
|
sdm.item_code as item_code,
|
|
sdm.account_code as account_code,
|
|
sdm.account_name as account_name,
|
|
sdm.quantity as quantity,
|
|
sdm.unit_amount as unit_amount,
|
|
sdm.line_amount_local_curr as line_amount_local_curr,
|
|
sdm.line_amount_in_gbp as line_amount_in_gbp,
|
|
sdm.line_amount_wo_taxes_local_curr as line_amount_wo_taxes_local_curr,
|
|
sdm.line_amount_wo_taxes_in_gbp as line_amount_wo_taxes_in_gbp,
|
|
sdm.tax_amount_local_curr as tax_amount_local_curr,
|
|
sdm.tax_amount_in_gbp as tax_amount_in_gbp,
|
|
sdm.tax_type as tax_type,
|
|
sdm.line_description as line_description,
|
|
sdm.id_document as id_document,
|
|
sdm.is_document_posted_in_hyperline as is_document_posted_in_hyperline,
|
|
sdm.reference as reference,
|
|
sdm.document_number as document_number,
|
|
sdm.document_issued_at_utc as document_issued_at_utc,
|
|
sdm.document_issued_date_utc as document_issued_date_utc,
|
|
sdm.document_is_effective_at_end_of_month_utc
|
|
as document_is_effective_at_end_of_month_utc,
|
|
sdm.document_type as document_type,
|
|
sdm.document_currency_iso_4217 as document_currency_iso_4217,
|
|
sdm.exchange_rate_to_gbp as exchange_rate_to_gbp,
|
|
sdm.document_status as document_status,
|
|
sdm.line_amount_tax_inclusiveness as line_amount_tax_inclusiveness,
|
|
sdm.header_total_amount_local_curr as header_total_amount_local_curr,
|
|
sdm.header_total_amount_in_gbp as header_total_amount_in_gbp,
|
|
sdm.header_total_amount_wo_tax_local_curr as header_total_amount_wo_tax_local_curr,
|
|
sdm.header_total_amount_wo_tax_in_gbp as header_total_amount_wo_tax_in_gbp,
|
|
sdm.header_total_tax_local_curr as header_total_tax_local_curr,
|
|
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.id_contact as id_contact,
|
|
sdm.id_deal as id_deal,
|
|
sdm.contact_name as contact_name,
|
|
sdm.accounting_root_aggregation as accounting_root_aggregation,
|
|
sdm.accounting_kpis_aggregation as accounting_kpis_aggregation,
|
|
sdm.accounting_financial_l1_aggregation as accounting_financial_l1_aggregation,
|
|
sdm.accounting_financial_l2_aggregation as accounting_financial_l2_aggregation,
|
|
sdm.accounting_financial_l3_aggregation as accounting_financial_l3_aggregation,
|
|
sdm.account_code || '-' || sdm.account_name as account_code_name
|
|
from int_xero__sales_denom_mart sdm
|