098 payg form corrected, fix prices excluded
This commit is contained in:
+47
-17
@@ -185,6 +185,7 @@
|
||||
,p.cnt as p_cnt
|
||||
,p.ed_izm
|
||||
,p.code
|
||||
,p.type as p_type
|
||||
,p.discount as p_discount
|
||||
,p.__id as p_uid
|
||||
,p.name
|
||||
@@ -245,22 +246,23 @@
|
||||
<!--- <td class="c">#__name#</td> --->
|
||||
<td class="l">#user_description#</td>
|
||||
<td>
|
||||
<table class="wide">
|
||||
<cfset cost=0/>
|
||||
<cfoutput group="p_uid">
|
||||
<cfif p_cnt NEQ 0>
|
||||
<tr>
|
||||
<td class="nw">#code#</td>
|
||||
<td>#name#</td>
|
||||
<td>#p_cnt#</td>
|
||||
<td>#ed_izm#</td>
|
||||
<td class="r nw">#nFmt(price,3)#</td>
|
||||
<td class="r">#p_discount#%</td>
|
||||
</tr>
|
||||
<cfset cost+=price*p_cnt*(100-(isNumeric(p_discount)?p_discount:0))/100 />
|
||||
</cfif>
|
||||
</cfoutput>
|
||||
</table>
|
||||
<table class="wide">
|
||||
<cfset cost=0/>
|
||||
<cfoutput group="p_uid">
|
||||
<cfif p_cnt NEQ 0>
|
||||
<tr>
|
||||
<td class="nw">#code#</td>
|
||||
<td>#name#</td>
|
||||
<td>#p_cnt#</td>
|
||||
<td>#ed_izm#</td>
|
||||
<td class="r nw">#nFmt(price,3)#</td>
|
||||
<td class="r">#p_discount#%</td>
|
||||
<td class="r"><cftry>#gaussianRound((100.-discount)/100.*price*(100.-p_discount)/100.,2)#<cfcatch type="any"></cfcatch></cftry></td>
|
||||
</tr>
|
||||
<cfset cost+=price*p_cnt*(100-(isNumeric(p_discount)?p_discount:0))/100 />
|
||||
</cfif>
|
||||
</cfoutput>
|
||||
</table>
|
||||
</td>
|
||||
<td class="c">#cnt#</td>
|
||||
<td class="c">#discount#%</td>
|
||||
@@ -536,4 +538,32 @@
|
||||
</table>
|
||||
|
||||
</cfif><!--- len(d.__id) --->
|
||||
<layout:page section="footer"/>
|
||||
<layout:page section="footer"/>
|
||||
|
||||
<cfscript>
|
||||
string function gaussianRoundSafe(any num, numeric precision = 0, string default="") {
|
||||
return (isNumeric(arguments.num)) ? gaussianRound(arguments.num, arguments.precision) : arguments.default;
|
||||
}
|
||||
|
||||
function gaussianRound(numeric number, numeric precision = 0) {
|
||||
var factor = 10 ^ precision;
|
||||
var scaledNumber = number * factor;
|
||||
var absScaled = abs(scaledNumber);
|
||||
var sign = sgn(scaledNumber);
|
||||
var floored = int(absScaled);
|
||||
|
||||
// If it's not ending in exactly .5, use standard rounding or precision scaling
|
||||
if (absScaled - floored != 0.5) {
|
||||
return round(number * factor) / factor;
|
||||
}
|
||||
|
||||
// If it is exactly .5, round towards the nearest even number
|
||||
if (floored % 2 != 0) {
|
||||
// Nearest even is UP
|
||||
return (floored + 1) * sign / factor;
|
||||
} else {
|
||||
// Nearest even is DOWN
|
||||
return floored * sign / factor;
|
||||
}
|
||||
}
|
||||
</cfscript>
|
||||
Reference in New Issue
Block a user