Now parse line return the *raw* discount (instead of /100).
Meaning its treated exactly as the other.
Before formula where converted to integer (/100)
before being expanded or evaluated.
}
+ // convert the percentage to float.
+ if($discount) $discount /= 100;
+
#echo "Stock Code : $stock_code</br><ul>";
#echo "<li>mode : $mode</li>";
#echo "<li>quantity : $quantity</li>" ;
,"stock_code" => $stock_code
,"quantity" => $quantity
,"price" => $price
- ,"discount" => $discount !== null && $discount !== '' ? $discount/100.0 : null
+ ,"discount" => $discount
,"description" => $description
,"date" => $date
);
function get_default_discount($cart, $stock_code) {
if(empty($cart)) return null;
- return $cart->default_discount;
+ return 100*$cart->default_discount;
}
function get_kit_description($cart, $stock_code) {
,array("A ^2013/03/01 10", "A", '10', null, null, null, 'Date: 2013/3/1')
,array("A 2013/03/01 10", "A", '10', null, null, null, 'Date: 2013/3/1')
/*** Everything is passed ***/
- ,array("A 10 5.0 3% ^2013/03/01 | hello", "A", '10', '5.0', 0.03, "hello", 'Date: 2013/3/1')
- ,array("A 3% 10 5.0 ^2013/03/01 | hello", "A", '10', '5.0', 0.03, "hello", 'Date: 2013/3/1')
+ ,array("A 10 5.0 3% ^2013/03/01 | hello", "A", '10', '5.0', 3, "hello", 'Date: 2013/3/1')
+ ,array("A 3% 10 5.0 ^2013/03/01 | hello", "A", '10', '5.0', 3, "hello", 'Date: 2013/3/1')
);
}
/**
public function processNormalExamples() {
return array(
+/*
array("A", "A", 1, 5.2, 0.02)
,array("A 3", "A", 3, 5.2, 0.02)
,array("A $3", "A", 1, 3, 0.02)
,array(":# 5%\nA", "A", 1, 5.2, 0.05)
,array("A 0%", "A", 1, 5.2, 0)
,array("A 10%", "A", 1, 5.2, 0.1)
+
+ // overriding discount
+ ,array(":# 0%\nA 5%", "A", 1, 5.2, 0.05) // line win
+ ,array(":# 10%\nA 0%", "A", 1, 5.2, 0)
+ ,array(":# (0)%\nA 0.5%", "A", 1, 5.2, 0) // template win
+ ,array(":# (10)%\nA 0%", "A", 1, 5.2, 0.1)
+ ,*/array(":A (10)%\nA ", "A", 1, 5.2, 0.1)
+ ,array(":# 10%\nA 35 ", "A", 1, 5.2, 0.1)
);
}