Список вычетов - массивы ASP - PullRequest
0 голосов
/ 08 мая 2018

Я хочу отобразить разбивку общих отчислений на инвестиции в виде списка массивов. Общая сумма отчислений составляет $ -20,24, и мой список не суммируется с этой суммой. Я не слишком уверен, где я ошибся. Пожалуйста, просмотрите мой код и оставьте отзыв. См. Общее значение, возвращаемое ниже:

Date         Units   Unit price       Value
30/04/2018  -4.203   $ 1.99143     $ -8.37  
30/04/2018  -0.366   $ 1.99454     $ -0.73  
30/04/2018  -1.576   $ 3.54061     $ -5.58  
30/04/2018  -0.138   $ 3.55072     $ -0.49  
30/04/2018  -1.871   $ 2.49065     $ -4.66  
30/04/2018  -0.164   $ 2.50000     $ -0.41  
Total amount                          $ 16.98

<%
Dim objMemberClient, SwitchList
set objMemberClient = Server.createObject("MemberServiceProxy")

SwitchList=   objMemberClient.GetInvestmentTransactionObjList(session("MemberId"),session("FundCode"), request.Querystring("date"), request.Querystring("date"), request.Querystring("description"))
%>

<h1>Investments</h1>
<div class="table-responsive">
<%if request.Querystring("description") = "Deduction" then %>
    <TABLE class="table">
        <%for i = LBound(SwitchList) to UBound(SwitchList)%>    
        <%if SwitchList(i).DeductionCode =   getDesc(request.Querystring("subtype")) then%>
    <tr>    
            <%if SwitchList(i).DeductionSign = true then%>
                    <td class="table_Header" width="200px">Investment sold</td>
                    <%exit for%>

            <%end if%>
        <%end if%>
        <%Next%>
            <td class="table_Header" width="125px">Date</td>
            <td class="table_Header" width="125px">Units</td>
            <td class="table_Header" width="125px">Unit price</td>
            <td class="table_Header" width="125px">Value</td>
        </tr>
        <%for i = LBound(SwitchList) to UBound(SwitchList)%>    
        <%if SwitchList(i).DeductionCode =  getDesc(request.Querystring("subtype")) then%>
    <tr>
                <td valign="top" class="border_Bottom"> <%=SwitchList(i).InvestmentOption.Name%></td>
                <td valign="top" class="border_Bottom"><%=SwitchList(i).InvestmentDate%></td>
                <td valign="top" class="border_Bottom"> <%=SwitchList(i).NumberUnits%></td>
            <%if SwitchList(i).DeductionSign = true then %>
                <%total = total + SwitchList(i).SwitchOutDollarValue%>
                <%total = total * -1%>
                <td valign="top" class="border_Bottom">$&nbsp;<%=FormatNumber(SwitchList(i).SwitchOutDollarValue/Replace(SwitchList(i).NumberUnits,"-",""),5)%></td>
            <td valign="top" class="border_Bottom">$&nbsp;-<%=FormatNumber(SwitchList(i).SwitchOutDollarValue,2)%></td> 

                 <%end if%>
    </TABLE>

1 Ответ

0 голосов
/ 12 мая 2018

Было бы легче отладить, если бы у нас было что-то, что мы могли бы выполнить, но только предположив, я думаю, что ваша проблема здесь:

<%total = total + SwitchList(i).SwitchOutDollarValue%>
<%total = total * -1%>

Total - отрицательное значение, SwitchOutDollarValue Я считаю, что это положительное значение, поэтому их объединение таким образом не даст желаемого результата.

Как упоминалось в @SearchAndResQ, я бы удалил <%total = total * -1%> из цикла for и переместил бы его непосредственно перед отображением итогового значения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...