Skip to content

Commit

Permalink
Use sale_price() stored procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwins committed Aug 19, 2015
1 parent 9af1c3a commit 16ca99a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
9 changes: 2 additions & 7 deletions items.php
Expand Up @@ -129,13 +129,8 @@ function (data) {
item.name Name\$name,
brand.name Brand\$brand,
retail_price MSRP\$dollar,
IF(item.discount_type,
CASE item.discount_type
WHEN 'percentage' THEN ROUND(retail_price * ((100 - item.discount) / 100), 2)
WHEN 'relative' THEN (retail_price - item.discount)
WHEN 'fixed' THEN (item.discount)
END,
NULL) Sale\$dollar,
sale_price(item.retail_price, item.discount_type, item.discount)
Sale\$dollar,
CASE item.discount_type
WHEN 'percentage' THEN CONCAT(ROUND(item.discount), '% off')
WHEN 'relative' THEN CONCAT('$', item.discount, ' off')
Expand Down
14 changes: 2 additions & 12 deletions person.php
Expand Up @@ -215,23 +215,13 @@
CAST(ROUND_TO_EVEN(
SUM(IF(txn_line.taxfree, 1, 0) *
IF(type = 'customer', -1, 1) * allocated *
CASE discount_type
WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)
WHEN 'relative' THEN (retail_price - discount)
WHEN 'fixed' THEN (discount)
ELSE retail_price
END),
sale_price(retail_price, discount_type, discount)),
2) AS DECIMAL(9,2))
untaxed,
CAST(ROUND_TO_EVEN(
SUM(IF(txn_line.taxfree, 0, 1) *
IF(type = 'customer', -1, 1) * allocated *
CASE discount_type
WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)
WHEN 'relative' THEN (retail_price - discount)
WHEN 'fixed' THEN (discount)
ELSE retail_price
END),
sale_price(retail_price, discount_type, discount)),
2) AS DECIMAL(9,2))
taxed,
tax_rate,
Expand Down
14 changes: 2 additions & 12 deletions txns.php
Expand Up @@ -84,23 +84,13 @@
CAST(ROUND_TO_EVEN(
SUM(IF(txn_line.taxfree, 1, 0) *
IF(type = 'customer', -1, 1) * allocated *
CASE discount_type
WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)
WHEN 'relative' THEN (retail_price - discount)
WHEN 'fixed' THEN (discount)
ELSE retail_price
END),
sale_price(retail_price, discount_type, discount)),
2) AS DECIMAL(9,2))
untaxed,
CAST(ROUND_TO_EVEN(
SUM(IF(txn_line.taxfree, 0, 1) *
IF(type = 'customer', -1, 1) * allocated *
CASE discount_type
WHEN 'percentage' THEN retail_price * ((100 - discount) / 100)
WHEN 'relative' THEN (retail_price - discount)
WHEN 'fixed' THEN (discount)
ELSE retail_price
END),
sale_price(retail_price, discount_type, discount)),
2) AS DECIMAL(9,2))
taxed,
tax_rate,
Expand Down

0 comments on commit 16ca99a

Please sign in to comment.