编辑代码

/*
Name: fnGetAccountBalance
Function: check if accom balance is zero
Param: object of reservation details
Return:     
        fAryAccountBalance= new Array(6);
    let ACCOMM= 0;
    let INCIDENTALS= 1;
    let FOLIO3= 2;
    let BONDS= 3;
    let FOLIO5= 4;
    let SUM= 5;

future:
 */

function fnGetAccountBalance( objReservationDetails)
{
    let objAryAccountRows= objReservationDetails.ResScreenData.AccountRows;

    let ACCOMM= 0;
    let INCIDENTALS= 1;
    let FOLIO3= 2;
    let BONDS= 3;
    let FOLIO5= 4;
    let SUM= 5;
    let fAryAccountBalance= new Array(6);
    fAryAccountBalance[SUM]= 0.00;

    


    for(let nCounter= 0; nCounter< objAryAccountRows.length; nCounter++)
    {
        if( objAryAccountRows[nCounter].Identifier== "Acc_General")
            {
                if(objAryAccountRows[nCounter].ValueText.match(','))
                objAryAccountRows[nCounter].ValueText= objAryAccountRows[nCounter].ValueText.replace(',','')

                fAryAccountBalance[ACCOMM]= parseFloat(objAryAccountRows[nCounter].ValueText);
                fAryAccountBalance[SUM] += parseFloat(objAryAccountRows[nCounter].ValueText)
            }
        else if( objAryAccountRows[nCounter].Identifier== "Acc_Extras")
            {
                if(objAryAccountRows[nCounter].ValueText.match(','))
                objAryAccountRows[nCounter].ValueText= objAryAccountRows[nCounter].ValueText.replace(',','')

                fAryAccountBalance[INCIDENTALS]= parseFloat(objAryAccountRows[nCounter].ValueText);
                fAryAccountBalance[SUM] += parseFloat(objAryAccountRows[nCounter].ValueText)
            }
        else if( objAryAccountRows[nCounter].Identifier== "Acc_Gas")
            {
                if(objAryAccountRows[nCounter].ValueText.match(','))
                objAryAccountRows[nCounter].ValueText= objAryAccountRows[nCounter].ValueText.replace(',','')

                fAryAccountBalance[FOLIO3]= parseFloat(objAryAccountRows[nCounter].ValueText);
                fAryAccountBalance[SUM] += parseFloat(objAryAccountRows[nCounter].ValueText)
            }
        else if( objAryAccountRows[nCounter].Identifier== "Acc_Electricity")
            {
                if(objAryAccountRows[nCounter].ValueText.match(','))
                objAryAccountRows[nCounter].ValueText= objAryAccountRows[nCounter].ValueText.replace(',','')

                fAryAccountBalance[BONDS]= parseFloat(objAryAccountRows[nCounter].ValueText);
                fAryAccountBalance[SUM] += parseFloat(objAryAccountRows[nCounter].ValueText)
            }
        else if( objAryAccountRows[nCounter].Identifier== "Acc_Water")
            {
                if(objAryAccountRows[nCounter].ValueText.match(','))
                objAryAccountRows[nCounter].ValueText= objAryAccountRows[nCounter].ValueText.replace(',','')
                
                fAryAccountBalance[FOLIO5]= parseFloat(objAryAccountRows[nCounter].ValueText);
                fAryAccountBalance[SUM] += parseFloat(objAryAccountRows[nCounter].ValueText)
            }
    }
    

    console.log("get account balance");
    window.objGlobalParam.fAryAccountBalance = fAryAccountBalance;

    return fAryAccountBalance;

}