Permalink
Browse files

Merge pull request #113 from garyhgohoos/22474

Issue #22474:account for nulls and divide by zero
  • Loading branch information...
2 parents 692cb01 + 5ccc82a commit 1ce08210bbbeb36b7bf4358658f03bd7a02950f8 @gpazo gpazo committed Feb 11, 2014
Showing with 5 additions and 2 deletions.
  1. +1 −1 dbscripts/functions/calcsalesorderamt.sql
  2. +4 −1 dbscripts/metasql/opensalesorders-detail.mql
View
2 dbscripts/functions/calcsalesorderamt.sql
@@ -40,7 +40,7 @@ BEGIN
AND (coitem_status != 'X');
IF (pType IN ('T', 'B', 'X')) THEN
- SELECT ROUND(SUM(taxdetail_tax), 2) INTO _tax
+ SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) INTO _tax
FROM calculateTaxDetailSummary('S', pCoheadid, 'T');
END IF;
View
5 dbscripts/metasql/opensalesorders-detail.mql
@@ -20,7 +20,10 @@ SELECT DISTINCT
<? endforeach ?>
firstline(cohead_ordercomments) AS notes,
calcSalesOrderAmt(cohead_id) AS ordertotal,
- (calcSalesOrderAmt(cohead_id,'M') / calcSalesOrderAmt(cohead_id,'S')) AS ordermarginpercent,
+ CASE WHEN (calcSalesOrderAmt(cohead_id,'S') != 0.0)
+ THEN (calcSalesOrderAmt(cohead_id,'M') / calcSalesOrderAmt(cohead_id,'S'))
+ ELSE 1.0
+ END AS ordermarginpercent,
'percent' AS ordermarginpercent_xtnumericrole,
'extprice' AS ordertotal_xtnumericrole
FROM cohead

0 comments on commit 1ce0821

Please sign in to comment.