# View: current_balance_all_accounts_Feb24

**View Name:** current_balance_all_accounts_Feb24
**Table Source:** `Derived from: Prod_Royalty_Accounting_Royalty_Accounting.Account, Prod_Royalty_Accounting_Royalty_Accounting.Account_Contract, Prod_Royalty_Accounting_Royalty_Accounting.Account_Payment_Term, Prod_Royalty_Accounting_Royalty_Accounting.Contract, Prod_Royalty_Accounting_Royalty_Accounting.Ledger_Account_Contract + 3 more`
**File Path:** `views/current_balance_all_accounts_Feb24.view.lkml`

## Overview

- **File Size:** 4972 bytes
- **Lines of Code:** 154
- **Dimensions:** 20
- **Measures:** 0
- **Dimension Groups:** 0
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `Account_ID` | number |
| `Account_Name` | string |
| `Contract_ID` | number |
| `Contract_Name` | string |
| `Contract_Type` | string |
| `Run_Controller_ID` | string |
| `Run_Controller_Name` | string |
| `Currency_Code` | string |
| `Current_Balance` | number |
| `Is_On_Hold` | string |
| `Status_Start_Date` | date |
| `Status_Reason` | string |
| `Sap_Company_Code` | string |
| `Sap_Profit_Center` | string |
| `Sap_Business_Group` | string |
| `Signing_Entity` | string |
| `Paid_By` | string |
| `Payment_Schedule` | string |
| `client_owner` | string |
| `sap_vendor_id` | number |

## Derived Table

```sql
sql:
    SELECT
ac.account_id,
a.account_name,
c.contract_id,
c.contract_name,
c.contract_type,
rcc.run_controller_id,
rc.run_controller_name,
apt.currency_code,
IFNULL(lac.current_balance, 0) AS current_balance,
apt.payment_schedule,
ifnull(ph.is_on_hold,'False') as is_on_hold,
ph.start_date as hold_start_date,
ph.reason as hold_reason,
pc.company_code AS sap_company_code,
pc.profit_center AS sap_profit_center,
pc.business_group AS sap_business_group,
rse.legal_name as signing_entity,
rpe.payment_entity_name as paid_by,
us.f_name ||' '||us.l_name as client_owner,
ap.sap_vendor_id
FROM ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.contract AS c
INNER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account_contract AS ac
ON c.contract_id = ac.contract_id AND ac._fivetran_deleted = false
INNER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account_payment_term AS apt
ON ac.account_id = apt.account_id AND apt._fivetran_deleted = false
INNER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account AS a
ON ac.account_id = a.account_id and a._fivetran_deleted = false
INNER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.run_controller_contract AS rcc
ON c.contract_id = rcc.contract_id and rcc._fivetran_deleted = false
INNER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.run_controller AS rc
ON rc.run_controller_id = rcc.run_controller_id and rc._fivetran_deleted = false
LEFT OUTER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.ledger_account_contract_current_balance AS laccb
ON c.contract_id = laccb.contract_id and laccb._fivetran_deleted = false
LEFT OUTER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.ledger_account_contract AS lac
ON laccb.ledger_account_contract_id = lac.ledger_account_contract_id and lac._fivetran_deleted = false
LEFT OUTER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.payment_hold AS ph
ON ph.account_id=a.account_id and ph._fivetran_deleted = false
LEFT OUTER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.reference_signing_entity AS rse 
ON rse.reference_signing_entity_id = c.reference_signing_entity_id AND rse._fivetran_deleted = false
LEFT OUTER JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.reference_sap_profit_center AS pc
ON pc.reference_sap_profit_center_id = rse.reference_sap_profit_center_id AND pc._fivetran_deleted = false
LEFT JOIN ORCHARD_APP_REPORTING_V2.prod_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.reference_payment_entity rpe
ON apt.payment_entity_id = rpe.reference_payment_entity_id
left join royalty_accounting_reporting.prod.vw_dim_abacus_ar_vendor as v on a.account_id = v.VENDOR_ID
left join ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS.ORCHADMIN_USERS as us on v.assigned_to = us.id
left join ORCHARD_APP_REPORTING_V2.prod_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account_payee ap on ap.account_id = a.account_id
WHERE c._fivetran_deleted = false
AND rpe.payment_entity_name like '%KNR%';;
```

