Delimiter $$
/**
 * Author:  armen
 * Created: 21 juin 2018
 * @deprecated inutil fi_aba est deja calculé
 */

--  fi_ana
Drop Procedure if Exists BUSINESS_COMPUTE_PUBLICVIEWS_FI_ANA $$
Create Procedure BUSINESS_COMPUTE_PUBLICVIEWS_FI_ANA ()
Begin
    Truncate Table TMP_V_PUBLIC_FI_ANA_VIEW;

    Insert Into TMP_V_PUBLIC_FI_ANA_VIEW (
        ID_FI_ANA
        , ACCOUNTS_ID_ACCOUNTS
        , FI_ANA_OUTSTANDING
        , FI_ANA_OVERDUE
        , FI_ANA_NOT_OVERDUE
        , FI_ANA_DUE
        , FI_ANA_FROZEN_AMOUNT
        , FI_ANA_BLOCKED_ALL
        , FI_ANA_BLOCKED_NOTOVERDUE
        , FI_ANA_AGE_PORTFOLIO_PERIOD1
        , FI_ANA_AGE_PORTFOLIO_PERIOD2
        , FI_ANA_AGE_PORTFOLIO_PERIOD3
        , FI_ANA_AGE_PORTFOLIO_PERIOD4
        , FI_ANA_AGE_PORTFOLIO_PERIOD5
        , FI_ANA_AGE_PORTFOLIO_PERIOD6
        , FI_ANA_AGE_PORTFOLIO_PERIOD7
        , FI_ANA_AGE_PORTFOLIO_PERIOD8
        , FI_ANA_AGE_ACCOUNT_PERIOD1
        , FI_ANA_AGE_ACCOUNT_PERIOD2
        , FI_ANA_AGE_ACCOUNT_PERIOD3
        , FI_ANA_AGE_ACCOUNT_PERIOD4
        , FI_ANA_CURRENT_ORDER_AMOUNT
        , FI_ANA_BLOCKED_ORDER_AMOUNT
        , FI_ANA_DELIVERY_TOBEINVOICED
        , FI_ANA_BLOCKED_DELIVERY_TOBEINVOICED
        , FI_ANA_BANK_DRAFT
        , FI_ANA_CASH_ASSESSMENT
        , FI_ANA_CASH_ASSSSMNTLASTUPDAT
        , FI_ANA_INTERNAL_SCORE_RATING
        , FI_ANA_INTRSCORRATLASTUPDAT
        , FI_ANA_EXTERNAL_SCORE_RATING
        , FI_ANA_EXTSCORRATLASTUPDAT
        , FI_ANA_BPDSO
        , FI_ANA_BPDSO_LASTUPDAT
        , FI_ANA_ACD
        , FI_ANA_ACD_LASTUPDAT
        , FI_ANA_ACD_EVOLUTION
        , FI_ANA_DSO
        , FI_ANA_DSO_LAST_UPDAT
        , FI_ANA_ADD
        , FI_ANA_ADD_LAST_UPDAT
        , FI_ANA_ADD_EVOLUTION
        , FI_ANA_SALES
        , FI_ANA_PAYMENT
    )
    Select 
        ID_FI_ANA
        , ACCOUNTS_ID_ACCOUNTS
        , FI_ANA_OUTSTANDING
        , FI_ANA_OVERDUE
        , FI_ANA_NOT_OVERDUE
        , FI_ANA_DUE
        , FI_ANA_FROZEN_AMOUNT
        , FI_ANA_BLOCKED_ALL
        , FI_ANA_BLOCKED_NOTOVERDUE
        , FI_ANA_AGE_PORTFOLIO_PERIOD1
        , FI_ANA_AGE_PORTFOLIO_PERIOD2
        , FI_ANA_AGE_PORTFOLIO_PERIOD3
        , FI_ANA_AGE_PORTFOLIO_PERIOD4
        , FI_ANA_AGE_PORTFOLIO_PERIOD5
        , FI_ANA_AGE_PORTFOLIO_PERIOD6
        , FI_ANA_AGE_PORTFOLIO_PERIOD7
        , FI_ANA_AGE_PORTFOLIO_PERIOD8
        , FI_ANA_AGE_ACCOUNT_PERIOD1
        , FI_ANA_AGE_ACCOUNT_PERIOD2
        , FI_ANA_AGE_ACCOUNT_PERIOD3
        , FI_ANA_AGE_ACCOUNT_PERIOD4
        , FI_ANA_CURRENT_ORDER_AMOUNT
        , FI_ANA_BLOCKED_ORDER_AMOUNT
        , FI_ANA_DELIVERY_TOBEINVOICED
        , FI_ANA_BLOCKED_DELIVERY_TOBEINVOICED
        , FI_ANA_BANK_DRAFT
        , FI_ANA_CASH_ASSESSMENT
        , FI_ANA_CASH_ASSSSMNTLASTUPDAT
        , FI_ANA_INTERNAL_SCORE_RATING
        , FI_ANA_INTRSCORRATLASTUPDAT
        , FI_ANA_EXTERNAL_SCORE_RATING
        , FI_ANA_EXTSCORRATLASTUPDAT
        , FI_ANA_BPDSO
        , FI_ANA_BPDSO_LASTUPDAT
        , FI_ANA_ACD
        , FI_ANA_ACD_LASTUPDAT
        , FI_ANA_ACD_EVOLUTION
        , FI_ANA_DSO
        , FI_ANA_DSO_LAST_UPDAT
        , FI_ANA_ADD
        , FI_ANA_ADD_LAST_UPDAT
        , FI_ANA_ADD_EVOLUTION
        , FI_ANA_SALES
        , FI_ANA_PAYMENT
    From V_PUBLIC_FI_ANA_VIEW ;
End $$
Delimiter ;
