Make min and max inclusive; remove .99 from max

This commit is contained in:
Joshua Dwire 2016-09-14 14:31:44 -04:00
parent a29929846f
commit d96c8bd048
3 changed files with 5 additions and 18 deletions

View File

@ -72,20 +72,15 @@ class AccountGatewayDatatable extends EntityDatatable
$html .= $gatewayType->name . ' — ';
}
// Decide how many nines to add to the end of the max.
$currency = Utils::getFromCache(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY), 'currencies');
$limit_max_adjustment = $currency->precision ? floatval('.' . str_repeat('9',
$currency->precision)) : 0;
if ($accountGatewaySettings && $accountGatewaySettings->min_limit !== null && $accountGatewaySettings->max_limit !== null) {
$html .= Utils::formatMoney($accountGatewaySettings->min_limit) . ' - ' . Utils::formatMoney($accountGatewaySettings->max_limit + $limit_max_adjustment);
$html .= Utils::formatMoney($accountGatewaySettings->min_limit) . ' - ' . Utils::formatMoney($accountGatewaySettings->max_limit);
} elseif ($accountGatewaySettings && $accountGatewaySettings->min_limit !== null) {
$html .= trans('texts.min_limit',
array('min' => Utils::formatMoney($accountGatewaySettings->min_limit))
);
} elseif ($accountGatewaySettings && $accountGatewaySettings->max_limit !== null) {
$html .= trans('texts.max_limit',
array('max' => Utils::formatMoney($accountGatewaySettings->max_limit + $limit_max_adjustment))
array('max' => Utils::formatMoney($accountGatewaySettings->max_limit))
);
} else {
$html .= trans('texts.no_limit');
@ -155,8 +150,8 @@ class AccountGatewayDatatable extends EntityDatatable
function () use ($gatewayType) {
$accountGatewaySettings = AccountGatewaySettings::scope()->where('account_gateway_settings.gateway_type_id',
'=', $gatewayType->id)->first();
$min = $accountGatewaySettings && $accountGatewaySettings->min_limit != null ? $accountGatewaySettings->min_limit : 'null';
$max = $accountGatewaySettings && $accountGatewaySettings->max_limit != null ? $accountGatewaySettings->max_limit : 'null';
$min = $accountGatewaySettings && $accountGatewaySettings->min_limit !== null ? $accountGatewaySettings->min_limit : 'null';
$max = $accountGatewaySettings && $accountGatewaySettings->max_limit !== null ? $accountGatewaySettings->max_limit : 'null';
return "javascript:showLimitsModal('{$gatewayType->name}',{$gatewayType->id},$min,$max)";
},

View File

@ -826,9 +826,7 @@ class BasePaymentDriver
return false;
}
if ($accountGatewaySettings->max_limit !== null && $invoice->balance >= $accountGatewaySettings->max_limit + 1) {
// The max is limit_max + 0.99, so we add 1 to max_limit
// Then, if the balance is greater than or equal to that value, it's over the max.
if ($accountGatewaySettings->max_limit !== null && $invoice->balance > $accountGatewaySettings->max_limit) {
return false;
}
}

View File

@ -85,9 +85,6 @@
<span class="input-group-addon">{{ $currency->symbol }}</span>
<input type="number" class="form-control" min="0" id="payment-limit-min"
name="limit_min">
@if ($currency->precision)
<span class="input-group-addon">{{ $currency->decimal_separator }}{{ str_repeat( '0', $currency->precision) }}</span>
@endif
</div>
<label><input type="checkbox" id="payment-limit-min-enable"
name="limit_min_enable"> {{ trans('texts.enable_min') }}</label>
@ -101,9 +98,6 @@
<span class="input-group-addon">{{ $currency->symbol }}</span>
<input type="number" class="form-control" min="0" id="payment-limit-max"
name="limit_max">
@if ($currency->precision)
<span class="input-group-addon">{{ $currency->decimal_separator }}{{ str_repeat( '9', $currency->precision) }}</span>
@endif
</div>
<label><input type="checkbox" id="payment-limit-max-enable"
name="limit_max_enable"> {{ trans('texts.enable_max') }}</label>