# View: royalty_accounting_prod_vw_dim_abacus_contract_abacus_fact_sales

**View Name:** royalty_accounting_prod_vw_dim_abacus_contract_abacus_fact_sales
**Table Source:** `Derived from: Abacus_Contract, Contract_Lifecyle, Orchard_App_Reporting_V2, Orchard_App_Reporting_V2.Prod_Royalty_Accounting_Royalty_Accounting, Prod.Vw_Dim_Abacus_Contract + 3 more`
**File Path:** `views/royalty_accounting_prod_vw_dim_abacus_contract_abacus_fact_sales.view.lkml`

## Overview

- **File Size:** 7022 bytes
- **Lines of Code:** 324
- **Dimensions:** 37
- **Measures:** 2
- **Dimension Groups:** 3
- **Filters:** 0

## Comments & Notes

- hidden: yes
- The below sets are created to be able to exclude account_id from abacus_fact_sales

## Dimensions

| Name | Type |
|------|------|
| `contract_id` | number |
| `reference_sap_profit_center_id` | number |
| `contract_name` | string |
| `contract_type` | string |
| `run_controller_id` | number |
| `run_controller_name` | string |
| `is_primary_for_calc` | yesno |
| `company_code` | string |
| `profit_center` | string |
| `signing_entity_legal_name` | string |
| `company_registration_number` | string |
| `signing_entity_address` | string |
| `signing_entity_vat_number` | number |
| `sax_agreement_id` | string |
| `account_id` | number |
| `business_group` | string |
| `current_balance` | number |
| `abacus_contract_url` | string |
| `general_note` | string |
| `summary_note` | string |
| `created_by` | string |
| `created_at` | date_time |
| `last_modified_by` | string |
| `last_modified` | date_time |
| `usa_mech_rights` | string |
| `usa_mech_type` | string |
| `usa_mech_admin_type` | string |
| `usa_mech_admin_fee` | string |
| `can_mech_rights` | string |
| `can_mech_type` | string |
| `can_mech_admin_type` | string |
| `can_mech_admin_fee` | string |
| `row_mech_rights` | string |
| `row_mech_type` | string |
| `row_mech_admin_type` | string |
| `row_mech_admin_fee` | string |
| `is_excluded_from_accounting_run` | string |

## Measures

| Name | Type |
|------|------|
| `min_cont_start` | date |
| `max_cont_end` | date |

## Dimension Groups

| Name | Type |
|------|------|
| `initial_start_date` | time |
| `term_start` | time |
| `term_end` | time |

## SQL Comments

- where contract_id = 39907
- where contract_id = 66927
- all columns minus flowthrough contract info

## Derived Table

```sql
sql: with contract_lifecyle as (
select
    contract_id,
    lifecycle_term_end,
    lifecycle_term_start,
    deleted_at
from ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.CONTRACT_LIFECYCLE
-- where contract_id = 39907
group by all),


abacus_contract as (
select
    *
    EXCLUDE (contract_flowthrough_id, reference_flowthrough_calculation_id, flowthrough_rate, has_automatic_shutoff, recoupment_cap, flowthrough_status)
from ROYALTY_ACCOUNTING.PROD.VW_DIM_ABACUS_CONTRACT
--where contract_id = 66927
group by all
)

select
          dac.*, -- all columns minus flowthrough contract info
          lifecycle_term_end,
          lifecycle_term_start
      from
          abacus_contract dac
          left join contract_lifecyle cl ON cl.contract_id = dac.contract_id
      where
          cl.deleted_at is null
      ;;
```

