Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE 56 Money precision needs to accept less than 2 decimal places #57

Open
wants to merge 6 commits into
base: 2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion code/admin/PriceField.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public function FieldHolder($properties = array()) {
*/
public function setValue($val) {
if(!$val) $val = 0.00;

$shopConfig = ShopConfig::current_shop_config();
$precision = 2; //precision should always be two decimals, and only more if specified in ShopConfig
if($shopConfig && $shopConfig->BaseCurrencyPrecision > 2) {
if($shopConfig && (int) $shopConfig->BaseCurrencyPrecision) {
$precision = $shopConfig->BaseCurrencyPrecision;
}

Expand Down
2 changes: 1 addition & 1 deletion code/form/OrderForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function process($data, $form) {
try {
$shopConfig = ShopConfig::current_shop_config();
$precision = 2; //precision should always be two decimals, and only more if specified in ShopConfig
if($shopConfig && $shopConfig->BaseCurrencyPrecision > 2) {
if($shopConfig && (int) $shopConfig->BaseCurrencyPrecision) {
$precision = $shopConfig->BaseCurrencyPrecision;
}

Expand Down
8 changes: 4 additions & 4 deletions code/order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function canView($member = null) {

if ($member == null && !$member = Member::currentUser()) return false;

$administratorPerm = Permission::check('ADMIN') && Permission::check('VIEW_ORDER', 'any', $member);
$administratorPerm = Permission::check('VIEW_ORDER', 'any', $member);
$customerPerm = Permission::check('VIEW_ORDER', 'any', $member) && $member->ID == $this->MemberID;

return $administratorPerm || $customerPerm;
Expand All @@ -210,7 +210,7 @@ public function canView($member = null) {
* @return Boolean False always
*/
public function canEdit($member = null) {
$administratorPerm = Permission::check('ADMIN') && Permission::check('EDIT_ORDER', 'any', $member);
$administratorPerm = Permission::check('EDIT_ORDER', 'any', $member);

return $administratorPerm;
}
Expand All @@ -232,7 +232,7 @@ public function canCreate($member = null) {
* @return Boolean False always
*/
public function canDelete($member = null) {
return Permission::check('ADMIN');
return true;
}

/**
Expand Down Expand Up @@ -442,7 +442,7 @@ public function SummaryOfTotal() {
public function Link() {
//get the account page and go to it
$account = DataObject::get_one('AccountPage');
return $account->Link()."order/$this->ID";
return Controller::join_links($account->Link("order"), $this->ID);
}

/**
Expand Down