World-Three-Technologies / Masxaro-Prototype

Other
8 stars 4 forks source link

number format with too much precision #19

Closed Rafe closed 13 years ago

Rafe commented 13 years ago

The number is showing to much 0 after dot, Please change the precision of price columns to 2, except for tax.

I can change format in front-end, but I think change in database type is simpler (for me)

about the precision of tax calculation, round up to the closest penny is the way that vendor use, so precision in 2 is okay.

yaxing commented 13 years ago

Jimmy, I changed the precision format when data got selected. However I think it might not be a good way to do this, no matter which one is doing this process: MySQL (currently used), PHP or JS since this is inefficient and slow down the service. I'm thinking maybe we can pre-define the precision in the database? may be all of them could be decimal(10, 2)? what do you think?

Rafe commented 13 years ago

yeah. I think it's the best solution. and please notice that tax column should be able to take care .4 digits. (0.0875) so either wrap it(like times 100 before save,eg: save as 8.75) or set differently (to decimal(10,4) ) will be needed.

2011/7/18 yaxing < reply@reply.github.com>

Jimmy, I changed the precision format when data got selected. However I think it might not be a good way to do this, no matter which one is doing this process: MySQL (currently used), PHP or JS since this is inefficient and slow down the service. I'm thinking maybe we can pre-define the precision in the database? may be all of them could be decimal(10, 2)? what do you think?

Reply to this email directly or view it on GitHub:

https://github.com/gpryzby-wtt/Masxaro-Prototype/issues/19#issuecomment-1596030

yaxing commented 13 years ago

I'm sorry which is the best solution? Limit the precision in database (maybe trailing 0s) or process the selected result?

Rafe commented 13 years ago

I think limit the precision with .2 and save tax with percentage like 8.75 is best

2011/7/18 yaxing < reply@reply.github.com>

I'm sorry which is the best solution? Limit the precision in database (maybe trailing 0s) or process the selected result?

Reply to this email directly or view it on GitHub:

https://github.com/gpryzby-wtt/Masxaro-Prototype/issues/19#issuecomment-1598163

yaxing commented 13 years ago

ok

yaxing commented 13 years ago

Database has been updated, code has been updated. For now tax, discount, price are all decimal(10,2), tax, discount are percentage from 0 - 100

Rafe commented 13 years ago

check the calculation in insert receipt, line 224 should change to

$totalCost += $totalCost * 0.01 * $basicInfo['tax'];