Delimiter $$
/**
 * Author:  armen
 * Created: 21 juin 2018
 */

--  entries
Drop Procedure if Exists BUSINESS_COMPUTE_PUBLICVIEWS_ENTRIES $$
Create Procedure BUSINESS_COMPUTE_PUBLICVIEWS_ENTRIES ()
Begin
    Truncate Table TMP_V_PUBLIC_ENTRIES_VIEW;

    Insert Into TMP_V_PUBLIC_ENTRIES_VIEW (
        ACCOUNTS_ID_ACCOUNTS
        , ID_ENTRIES
        , ENTRIES_ID_ENTRIES
        , CONTACTS_ID_CONTACTS
        , DF_CURRENCIES_ID_DF_CURRENCIES
        , DF_CURRENCIES_CODE
        , DF_CURRENCIES_LABEL
        , DF_ENTR_TYPE_ID_DF_ENTR_TYPE
        , DF_ENTRIES_TYPE_CODE
        , DF_ENTRIES_TYPE_ACCOUNTANT
        , DF_ENTRIES_TYPE_IS_DEBIT
        , DF_ENTRIES_TYPE_IS_CREDIT
        , DF_ENTR_STT_ID_DF_ENTR_STT
        , DF_ENTRIES_STATUT_CODE
        , DF_PAY_TYPE_ID_DF_PAY_TYPE
        , DF_PAYMENT_TYPE_CODE
        , DF_RATE_GRID_ID_DF_RATE_GRID
        , DF_RATE_GRID_CODE
        , DF_RATE_GRID_LABEL
        , DF_MATCH_STAT_ID_DF_MATCH_STAT
        , DF_MATCHINGCODE_STATE_CODE
        , DF_MATCHINGCODE_STATE_OPEN
        , DF_MATCHINGCODE_STATE_PARTIAL
        , DF_MATCHINGCODE_STATE_CLOSED
        , ID_MATCHINGCODES
        , MATCHINGCODES_CODE
        , MATCHINGCODES_DATE
        , DF_SAND_STATE_ID_DF_SAND_STATE
        , DF_SANDBOX_STATE_CODE
        , DF_PAYMENT_SCHED_STATUS_ID_DF_PAYMENT_SCHED_STATUS
        , DF_PAYMENT_SCHED_STATUS_CODE
        , ENTRIES_DATE
        , ENTRIES_DUE_DATE
        , ENTRIES_PROMISE
        , ENTRIES_PROMISE_DATE
        , ENTRIES_DEBIT_INITIAL
        , ENTRIES_CREDIT_INITIAL
        , ENTRIES_DEBIT
        , ENTRIES_CREDIT
        , ENTRIES_BALANCE
        , ENTRIES_DEBIT_ADM_CURRENCY
        , ENTRIES_CREDIT_ADM_CURRENCY
        , ENTRIES_ACCOUTING_ACCOUNTS
        , ENTRIES_LABEL
        , ENTRIES_INTEREST
        , ENTRIES_INTEREST_LST_UPDAT
        , ENTRIES_REF
        , ENTRIES_ACC_EXT_REF
        , ENTRIES_PERMANENT_ATTACHEMENT
        , ENTRIES_DELAY
        , FORCED_MATCH_STATE
        , ENTRIES_LAST_UPDATE
        , ENTRIES_PURCHASE_ORDER
    )
    Select 
        ACCOUNTS_ID_ACCOUNTS
        , ID_ENTRIES
        , ENTRIES_ID_ENTRIES
        , CONTACTS_ID_CONTACTS
        , DF_CURRENCIES_ID_DF_CURRENCIES
        , DF_CURRENCIES_CODE
        , DF_CURRENCIES_LABEL
        , DF_ENTR_TYPE_ID_DF_ENTR_TYPE
        , DF_ENTRIES_TYPE_CODE
        , DF_ENTRIES_TYPE_ACCOUNTANT
        , DF_ENTRIES_TYPE_IS_DEBIT
        , DF_ENTRIES_TYPE_IS_CREDIT
        , DF_ENTR_STT_ID_DF_ENTR_STT
        , DF_ENTRIES_STATUT_CODE
        , DF_PAY_TYPE_ID_DF_PAY_TYPE
        , DF_PAYMENT_TYPE_CODE
        , DF_RATE_GRID_ID_DF_RATE_GRID
        , DF_RATE_GRID_CODE
        , DF_RATE_GRID_LABEL
        , DF_MATCH_STAT_ID_DF_MATCH_STAT
        , DF_MATCHINGCODE_STATE_CODE
        , DF_MATCHINGCODE_STATE_OPEN
        , DF_MATCHINGCODE_STATE_PARTIAL
        , DF_MATCHINGCODE_STATE_CLOSED
        , ID_MATCHINGCODES
        , MATCHINGCODES_CODE
        , MATCHINGCODES_DATE
        , DF_SAND_STATE_ID_DF_SAND_STATE
        , DF_SANDBOX_STATE_CODE
        , DF_PAYMENT_SCHED_STATUS_ID_DF_PAYMENT_SCHED_STATUS
        , DF_PAYMENT_SCHED_STATUS_CODE
        , ENTRIES_DATE
        , ENTRIES_DUE_DATE
        , ENTRIES_PROMISE
        , ENTRIES_PROMISE_DATE
        , ENTRIES_DEBIT_INITIAL
        , ENTRIES_CREDIT_INITIAL
        , ENTRIES_DEBIT
        , ENTRIES_CREDIT
        , ENTRIES_BALANCE
        , ENTRIES_DEBIT_ADM_CURRENCY
        , ENTRIES_CREDIT_ADM_CURRENCY
        , ENTRIES_ACCOUTING_ACCOUNTS
        , ENTRIES_LABEL
        , ENTRIES_INTEREST
        , ENTRIES_INTEREST_LST_UPDAT
        , ENTRIES_REF
        , ENTRIES_ACC_EXT_REF
        , ENTRIES_PERMANENT_ATTACHEMENT
        , ENTRIES_DELAY
        , FORCED_MATCH_STATE
        , ENTRIES_LAST_UPDATE
        , ENTRIES_PURCHASE_ORDER
    From V_PUBLIC_ENTRIES_VIEW ENT
    ;

End $$
Delimiter ;


