Link to home
Start Free TrialLog in
Avatar of J C
J CFlag for United States of America

asked on

Problem displaying sum on my coldfusion page

I have a coldfusion page that displays to our vendor's each PO that they are going to be paid on for the current pay period. There is a deduction for some of them that happens and I recently added the column/deducted value to the report. I need to get a sum for the deducted amount of each PO and show a total for it. The method I am currently using shows me the amount of one deduction on the page and does not give me a proper sum. Any help is appreciated.
Avatar of J C
J C
Flag of United States of America image

ASKER

totalWrapAmount is the variable that I'd like to hold the sum.

<form name="form1" method="post" action="">
<table width="99%" cellpadding="3" cellspacing="0" border="0" bordercolor="#999999" bgcolor="#FFFFFF">
	<tr>
		<td align="center">
			<table width="100%" cellpadding="3" cellspacing="2" border="0" style="border:2px solid #999999">
				
				<tr>
				<td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Print Lien Release</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Vendor Code</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Purchase Order</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Total Amount</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Wrap Ded.</span></td>
                  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Project Code</span></td>
				  <td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Lot</span></td>
				  <td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Due Date</span></td>
				</tr>
				
				<cfset VARIABLES.totNoTax = 0>
				<cfset VARIABLES.temp_po_row_count = 0>
				
				<cfoutput query="AmountToPayOnNextCheck" startRow="#StartRow_AmountToPayOnNextCheck#" maxRows="#MaxRows_AmountToPayOnNextCheck#" group="VendCode" groupcasesensitive="true">
				  <cfset VARIABLES.companyTotal = 0 />
				  <cfoutput group="PONo">
				
				  <cfset VARIABLES.total = 0 />

				  <cfoutput>
				    <cfset VARIABLES.total = variables.total + AmountToPayOnNextCheck.TotalAmt />
					
					</cfoutput>
					 <cfset totalWrapAmount = 0 />                          
                			 <cfoutput>
                               <cfset totalWrapAmount  = totalWrapAmount + val(AmountToPayOnNextCheck.WrapAmount)>
                               </cfoutput>
				   	<cfset VARIABLES.companyTotal = VARIABLES.companyTotal + VARIABLES.total />
				  <tr>
                    <td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><input type="checkbox" name="po_#POID#" value="#POID#" /></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="left"><span class="con">#AmountToPayOnNextCheck.VendCode#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.RuleID# - #AmountToPayOnNextCheck.PONo#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="right"><span class="con">#dollarformat(VARIABLES.total)#</span></td>
                    <td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="wrap">#dollarformat (AmountToPayOnNextCheck.WrapAmount)#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.projCode#</span></td>
					<td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2 eq 0)>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.Lot#</span></td>
					<td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#dateformat(AmountToPayOnNextCheck.DueDate,"mm/dd/yy")#</span></td>
				    
				  </tr>
				<cfset VARIABLES.totNoTax = variables.totnotax +#total#>
				<cfset VARIABLES.temp_po_row_count = VARIABLES.temp_po_row_count + 1>
				</cfoutput>
				
				 <tr>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">Company Total: </span></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">#dollarFormat(VARIABLES.companyTotal)#</span></td>
			            <td bgcolor="##cbdad6" align="right"><span class="hdr">Wrap Total: </span></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">#dollarFormat(totalWrapAmount)#</span></td>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6"></td>
                    <td bgcolor="##cbdad6"></td>
                    
				</tr>

			</cfoutput>
				 <tr>
					<td colspan="7"></td>
				</tr>
			  </table>
		</td>
	</tr>
</table>
 <input type="hidden" name="conditionalType" value="" />
</form>

Open in new window

Avatar of J C

ASKER

Here is a SS. The Wrap Ded is the column I've added and the one I am trying to get a sum of. I'd like to show the total before deductions which I am already doing. I would then like to show the sum of all the wrap deductions for this particular vendor. I would then like to show the check total which will be  Companytotal - totalWrapAmount.

I was able to get the TotalWrapAmount to an amount that is close but for some reason it's not hitting it exactly. CF is telling me the total should be 41.76 when it is actually 41.13. I am not sure why it's tacking on the additional amount. If someone can tell me how it should be structured in order to accomplish what I'd like it would be much appreciated!

Current Code:

<form name="form1" method="post" action="">
<table width="99%" cellpadding="3" cellspacing="0" border="0" bordercolor="#999999" bgcolor="#FFFFFF">
	<tr>
		<td align="center">
			<table width="100%" cellpadding="3" cellspacing="2" border="0" style="border:2px solid #999999">
				
				<tr>
				<td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Print Lien Release</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Vendor Code</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Purchase Order</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Total Amount</span></td>
				  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Wrap Ded.</span></td>
                  <td bgcolor="#CCCCCC" align="center"><span class="hdr">Project Code</span></td>
				  <td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Lot</span></td>
				  <td width="10%" bgcolor="#CCCCCC" align="center"><span class="hdr">Due Date</span></td>
				</tr>
				
				<cfset VARIABLES.totNoTax = 0>
				<cfset VARIABLES.temp_po_row_count = 0>
				
				<cfoutput query="AmountToPayOnNextCheck" startRow="#StartRow_AmountToPayOnNextCheck#" maxRows="#MaxRows_AmountToPayOnNextCheck#" group="VendCode" groupcasesensitive="true">
				  <cfset VARIABLES.companyTotal = 0 />
				  <cfoutput group="PONo">
				
				  <cfset VARIABLES.total = 0 />

				  <cfoutput>
				    <cfset VARIABLES.total = variables.total + AmountToPayOnNextCheck.TotalAmt />
					
					</cfoutput>
					
				   	<cfset VARIABLES.companyTotal = VARIABLES.companyTotal + VARIABLES.total />
				  <tr>
                    <td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><input type="checkbox" name="po_#POID#" value="#POID#" /></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="left"><span class="con">#AmountToPayOnNextCheck.VendCode#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.RuleID# - #AmountToPayOnNextCheck.PONo#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="right"><span class="con">#dollarformat(VARIABLES.total)#</span></td>
                    <td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="wrap">#dollarformat (AmountToPayOnNextCheck.WrapAmount)#</span></td>
					<td bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.projCode#</span></td>
					<td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2 eq 0)>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#AmountToPayOnNextCheck.Lot#</span></td>
					<td width="10%" bgcolor="##<cfif (VARIABLES.temp_po_row_count MOD 2) eq 0>FFFFFF<cfelse>F0F0F0</cfif>" align="center"><span class="con">#dateformat(AmountToPayOnNextCheck.DueDate,"mm/dd/yy")#</span></td>
				    
				  </tr>
				<cfset VARIABLES.totNoTax = variables.totnotax +#total#>
				<cfset VARIABLES.temp_po_row_count = VARIABLES.temp_po_row_count + 1>
				</cfoutput>
				 <cfset totalWrapAmount = 0 />                          
                			 <cfoutput>
                               <cfset totalWrapAmount  = totalWrapAmount + val(AmountToPayOnNextCheck.WrapAmount)>
                               </cfoutput>

				 <tr>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">Company Total: </span></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">#dollarFormat(VARIABLES.companyTotal)#</span></td>
			            <td bgcolor="##cbdad6" align="right"><span class="hdr">Wrap Total: </span></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">#dollarFormat(totalWrapAmount)#</span></td>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6"></td>
                    <td bgcolor="##cbdad6"></td>
                    
				</tr>
				<tr>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr">Check Total: </span></td>
					<td bgcolor="##cbdad6" align="right"><span class="hdr"></span></td>
			            <td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6"></td>
					<td bgcolor="##cbdad6"></td>
                    <td bgcolor="##cbdad6"></td>
                    
				</tr>


			</cfoutput>
				 <tr>
					<td colspan="7"></td>
				</tr>
			  </table>
		</td>
	</tr>
</table>
 <input type="hidden" name="conditionalType" value="" />
</form>

Open in new window

ss2.png
Avatar of Coast Line
i am not sure of it as it is big code, just remove additional cfoutput tags and see how works
Avatar of J C

ASKER

I am not finding any extra cfoutput tags
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of J C

ASKER

Thanks, I get it now. I think I almost have it fixed now. The wrap amount I've corrected. Now I have to work on the final calculation. Once I have it working I will accept your solution. Thanks again.
Avatar of J C

ASKER

Thanks a lot for the explanation, you helped me to understand what was happening and I was able to get it fixed.
You're welcome :) Glad it helped.