mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Allow max of 0 for payment limits
This commit is contained in:
parent
7b203c11f1
commit
a5580cc650
@ -1243,10 +1243,10 @@ class AccountController extends BaseController
|
|||||||
$gateway_settings->gateway_type_id = $gateway_type_id;
|
$gateway_settings->gateway_type_id = $gateway_type_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$gateway_settings->min_limit = Input::get('limit_min_enable') ? intval(Input::get('limit_min')) : 0;
|
$gateway_settings->min_limit = Input::get('limit_min_enable') ? intval(Input::get('limit_min')) : null;
|
||||||
$gateway_settings->max_limit = Input::get('limit_max_enable') ? intval(Input::get('limit_max')) : 0;
|
$gateway_settings->max_limit = Input::get('limit_max_enable') ? intval(Input::get('limit_max')) : null;
|
||||||
|
|
||||||
if ($gateway_settings->max_limit && $gateway_settings->min_limit > $gateway_settings->max_limit) {
|
if ($gateway_settings->max_limit !== null && $gateway_settings->min_limit > $gateway_settings->max_limit) {
|
||||||
$gateway_settings->max_limit = $gateway_settings->min_limit;
|
$gateway_settings->max_limit = $gateway_settings->min_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,14 +77,16 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
$limit_max_adjustment = $currency->precision ? floatval('.' . str_repeat('9',
|
$limit_max_adjustment = $currency->precision ? floatval('.' . str_repeat('9',
|
||||||
$currency->precision)) : 0;
|
$currency->precision)) : 0;
|
||||||
|
|
||||||
if ($accountGatewaySettings && $accountGatewaySettings->min_limit && $accountGatewaySettings->max_limit) {
|
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 + $limit_max_adjustment);
|
||||||
} elseif ($accountGatewaySettings && $accountGatewaySettings->min_limit) {
|
} elseif ($accountGatewaySettings && $accountGatewaySettings->min_limit !== null) {
|
||||||
$html .= trans('texts.min_limit',
|
$html .= trans('texts.min_limit',
|
||||||
array('min' => Utils::formatMoney($accountGatewaySettings->min_limit)));
|
array('min' => Utils::formatMoney($accountGatewaySettings->min_limit))
|
||||||
} elseif ($accountGatewaySettings && $accountGatewaySettings->max_limit) {
|
);
|
||||||
|
} elseif ($accountGatewaySettings && $accountGatewaySettings->max_limit !== null) {
|
||||||
$html .= trans('texts.max_limit',
|
$html .= trans('texts.max_limit',
|
||||||
array('max' => Utils::formatMoney($accountGatewaySettings->max_limit + $limit_max_adjustment)));
|
array('max' => Utils::formatMoney($accountGatewaySettings->max_limit + $limit_max_adjustment))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$html .= trans('texts.no_limit');
|
$html .= trans('texts.no_limit');
|
||||||
}
|
}
|
||||||
@ -153,8 +155,8 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
function () use ($gatewayType) {
|
function () use ($gatewayType) {
|
||||||
$accountGatewaySettings = AccountGatewaySettings::scope()->where('account_gateway_settings.gateway_type_id',
|
$accountGatewaySettings = AccountGatewaySettings::scope()->where('account_gateway_settings.gateway_type_id',
|
||||||
'=', $gatewayType->id)->first();
|
'=', $gatewayType->id)->first();
|
||||||
$min = $accountGatewaySettings ? $accountGatewaySettings->min_limit : 0;
|
$min = $accountGatewaySettings && $accountGatewaySettings->min_limit != null ? $accountGatewaySettings->min_limit : 'null';
|
||||||
$max = $accountGatewaySettings ? $accountGatewaySettings->max_limit : 0;
|
$max = $accountGatewaySettings && $accountGatewaySettings->max_limit != null ? $accountGatewaySettings->max_limit : 'null';
|
||||||
|
|
||||||
return "javascript:showLimitsModal('{$gatewayType->name}',{$gatewayType->id},$min,$max)";
|
return "javascript:showLimitsModal('{$gatewayType->name}',{$gatewayType->id},$min,$max)";
|
||||||
},
|
},
|
||||||
|
@ -822,11 +822,11 @@ class BasePaymentDriver
|
|||||||
if ($accountGatewaySettings) {
|
if ($accountGatewaySettings) {
|
||||||
$invoice = $this->invoice();
|
$invoice = $this->invoice();
|
||||||
|
|
||||||
if ($accountGatewaySettings->min_limit && $invoice->balance < $accountGatewaySettings->min_limit) {
|
if ($accountGatewaySettings->min_limit !== null && $invoice->balance < $accountGatewaySettings->min_limit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($accountGatewaySettings->max_limit && $invoice->balance >= $accountGatewaySettings->max_limit + 1) {
|
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
|
// 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.
|
// Then, if the balance is greater than or equal to that value, it's over the max.
|
||||||
return false;
|
return false;
|
||||||
|
@ -32,8 +32,8 @@ class CreateGatewayTypes extends Migration
|
|||||||
$t->timestamp('updated_at')->nullable();
|
$t->timestamp('updated_at')->nullable();
|
||||||
|
|
||||||
|
|
||||||
$t->unsignedInteger('min_limit');
|
$t->unsignedInteger('min_limit')->nullable();
|
||||||
$t->unsignedInteger('max_limit');
|
$t->unsignedInteger('max_limit')->nullable();
|
||||||
|
|
||||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
@ -138,9 +138,9 @@
|
|||||||
var modalLabel = {!! json_encode(trans('texts.set_limits')) !!};
|
var modalLabel = {!! json_encode(trans('texts.set_limits')) !!};
|
||||||
$('#paymentLimitsModalLabel').text(modalLabel.replace(':gateway_type', gateway_type));
|
$('#paymentLimitsModalLabel').text(modalLabel.replace(':gateway_type', gateway_type));
|
||||||
|
|
||||||
limitsSlider.noUiSlider.set([min_limit, max_limit ? max_limit : 100000]);
|
limitsSlider.noUiSlider.set([min_limit !== null ? min_limit : 0, max_limit !== null ? max_limit : 100000]);
|
||||||
|
|
||||||
if (min_limit) {
|
if (min_limit !== null) {
|
||||||
$('#payment-limit-min').removeAttr('disabled');
|
$('#payment-limit-min').removeAttr('disabled');
|
||||||
$('#payment-limit-min-enable').prop('checked', true);
|
$('#payment-limit-min-enable').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
@ -148,7 +148,7 @@
|
|||||||
$('#payment-limit-min-enable').prop('checked', false);
|
$('#payment-limit-min-enable').prop('checked', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_limit) {
|
if (max_limit !== null) {
|
||||||
$('#payment-limit-max').removeAttr('disabled');
|
$('#payment-limit-max').removeAttr('disabled');
|
||||||
$('#payment-limit-max-enable').prop('checked', true);
|
$('#payment-limit-max-enable').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user